akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N; cin >> N;
  int power = 1e9;
  vector<int> x(N + 1);
  for(int i = 1; i <= N; i++){
    cin >> x[i];
  }
  sort(x.begin(), x.end());
  int start = x[0], end = x[N];
  for(int i = start; i <= end; i++){
    int power1 = 0;
    for(int j = 1; j <= N; j++){
      power1 += pow(i - x[j], 2);
    }
    power = min(power, power1);
  }
  cout << power << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long


int main()
{
    io
	int t=1;
//	cin >> t;
	while (t--)
	{
        int sheep, wol;
        cin >> sheep >> wol;
        if(wol >= sheep)
            cout << "unsafe\n";
        else cout << "safe\n";
	}
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> v(N);
    for(int i = 0; i < N; i++){
        cin >> v.at(i);
    }
    vector<ll> s(N);
    s[0] = v[0];
    for(int i = 0; i < N-1; i++){
        s[i+1] = s[i] + v[i+1];
    }
    ll ans = 0;
    for(int i = 0; i <= N - K; i++){
        ll tmpans = 0;
        if(i == 0){
            tmpans = s[i + K-1];
        } else { 
            tmpans = s[i + K-1] - s[i-1];
        }
        if(tmpans > ans){
            ans = tmpans;
        }
    }
    cout << setprecision(10) <<  (double)(ans+K) / 2  << endl;
}


Measured memory_bytes: 3328
# -*- coding: utf-8 -*-
"""
Created on Sat May  9 16:54:06 2020

@author: shinba
"""

s = input()
k = int(input())

cnt = 0

while s[cnt] == "1":
    cnt += 1
    if cnt == len(s):
        break

if cnt >= k:
    print(1)
else:
    print(s[cnt])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,r;cin >> n >> r;
  cout << r + 100 * max(0ll, 10-n) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		String[] num_str = str.split("");

		int result=0;
		int[] num_int = new int[num_str.length];

		for(int i=0; i < num_int.length; i++){
			num_int[i] = Integer.parseInt(num_str[i]);

			result += num_int[i]; 
		}
		sc.close();

		if(result % 9 == 0){
			System.out.println("Yes");
		}else{
		System.out.println("No");
		}
	}
}


Measured memory_bytes: 65900
#include <stdio.h>

main(){
  int x, y, r;

  scanf("%d%d", &x, &y);
  while(1){
    r =  x % y;
    if(r != 0){
      x = y;
	y = r;
    }
    else{
      printf("%d\n", y);
      break;
      }
  }
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
using namespace std;
struct po {int x,y,r,g;};
vector <po> c[5];
int ans;
bool used[1<<24];
bool check(po a){
  if(a.x==100000)return false;
  for(int i=0;i<4;i++)
    for(int j=0;j<c[i].size();j++){
      po b = c[i][j];
      if(a.g>b.g && (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y) < (a.r+b.r)*(a.r+b.r)) return false;
    }
  return true;
}

void saiki(int sum,int i,int ima){
  ans = max(ans,sum);
  vector <int> J;
  for(int j=0;j<(int)c[i].size();j++)if(check(c[i][j])==true)J.push_back(j);
  for(int j=0;j<(int)J.size();j++)
    for(int k=j+1;k<(int)J.size();k++){
      int a,b;
      int nx=(1<<c[i][J[j]].g)|(1<<c[i][J[k]].g)|ima;
      if(used[nx]==1)continue;
      used[nx]=1;
      a=c[i][J[j]].x;
      b=c[i][J[k]].x;
      c[i][J[j]].x = c[i][J[k]].x = 100000;
      for(int l=1;l<=4;l++)saiki(sum+2,(i+l)%4,nx);
      c[i][J[j]].x=a;
      c[i][J[k]].x=b;
    }
}

int main(){
  while(1){
    int n;
    cin>>n;
    if(n==0)break;
    int x,y,r,col;
    for(int j=0;j<(1<<24);j++)used[j]=0;
    for(int i=0;i<4;i++) c[i].clear();
    for(int i=0;i<n;i++)cin >>x>>y>>r>>col, c[--col].push_back((po){x,y,r,i});

    ans=0;
    for(int i=0;i<4;i++) saiki(0,i,0);
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 17600
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    ll n,k;
    cin>>n>>k;
    lvec a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    ll ans=0;
    rep(i,n-k) ans+=a[i];
    cout<<ans;
}

Measured memory_bytes: 1792
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    k = int(readline())
    a = list(map(int, readline().split()))
    a = a[::-1]

    if a[0] != 2:
        return print(-1)

    l = 2
    r = 3

    for x in a[1:]:
        l = (x + l - 1) // x * x
        r = r // x * x + (x - 1)

    if l == r == 0 or l > r:
        print(-1)
    else:
        print(l, r)


if __name__ == '__main__':
    main()


Measured memory_bytes: 86128
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#define MAX 200001
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	map<int, int> p;
	int a, b;
	bool f = 0;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		if (a == 1) {
			p[b]++;
			if (p[b] == 2) f = 1;
		}
		if (b == n) {
			p[a]++;
			if (p[a] == 2) f = 1;
		}
	}
	if (f) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 9600
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    ll a, b, c;

    while(cin >> a >> b >> c >> n)
    {
		ans = min(a,n);

		n -= min(a,n);

		n -= min(b,n);

		ans -= min(c,n);

		n -= min(c,n);

		cout << ans << endl;
    }


}





Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;

signed main()
{
  int a,b,c,x;
  cin >> a >> b >> c >> x;

  int i,j,k;
  int sum,cnt=0;
  for(i=0; i<=a; ++i) {
    for(j=0; j<=b; ++j){
      for(k=0; k<=c; ++k){
        sum = 500 *i + 100 *j + 50 *k;
        if(sum==x) cnt++;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3608
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int MOD = (int)1e9 + 7;

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();
        int[][] arr = new int[n][3];
        for (int i=0; i<n; i++) {
            arr[i][0] = sc.nextInt();
            arr[i][1] = sc.nextInt();
            arr[i][2] = sc.nextInt();
        }
        boolean[][] flag = new boolean[h][w];

        for (int i=0; i<n; i++) {
            if (arr[i][2] == 1) {
                for (int j=0; j<h; j++) {
                    for (int k=0; k<arr[i][0]; k++) {
                        flag[j][k] = true;
                    }
                }
            } else if (arr[i][2] == 2) {
                 for (int j=0; j<h; j++) {
                     for (int k=arr[i][0]; k<w; k++) {
                         flag[j][k] = true;
                     }
                 }
            } else if (arr[i][2] == 3) {
                for (int j=0; j<arr[i][1]; j++) {
                    for (int k=0; k<w; k++) {
                        flag[j][k] = true;
                    }
                }
            } else {
                for (int j=arr[i][1]; j<h; j++) {
                    for (int k=0; k<w; k++) {
                        flag[j][k] = true;
                    }
                }
            }
        }

        int cnt = 0;
        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                if (flag[i][j]) cnt++;
            }
        }

        System.out.println(h * w - cnt);


    }
}



Measured memory_bytes: 22732
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ll long long
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

int main()
{
    int n;
    cin >> n;
    int memo = 101;
    int max_num = -100;
    for(int i = n; i >=0; --i){
        int cnt = 0; 
         
        int num = i;
        while(num > 0){
            if(num%2==1) break;
            if(num%2==0){
                num = num/2;
                cnt++;
                
            }
        }
        if(max_num < cnt){
            max_num = cnt;
            memo = i;
        }

    }

    cout << memo << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> int size(const T &x) { return x.size(); }
#define rep(i,a,b) for (auto i=(a); i<(b); ++i)
#define iter(it,c) for (auto it = (c).begin(); it != (c).end(); ++it)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;
const int INF = 2147483647;

// g = gcd(n,m)
// lcm(n,m) = n*m / g

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

int main() {
    // S = {i*k*m/g}
    // T = {i*k*n/g}

    ll n, m;
    cin >> n >> m;

    string a, b;
    cin >> a >> b;

    ll g = gcd(n,m);

    map<ll,char> need;
    rep(i,0,n) {
        need[i*m/g] = a[i];
    }
    rep(i,0,m) {
        if (need.find(i*n/g) != need.end() && need[i*n/g] != b[i]) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << (ll)n*m/g << endl;

    return 0;
}



Measured memory_bytes: 6144
/*************************************************\
           In the name of almighty ALLAH
                 MD.Faysal Hasan
                Comilla Univesity
\*************************************************/

#include<bits/stdc++.h>
using namespace std;

#define     ikarus_101  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef     long long             ll;
typedef     long double           ld;
typedef     unsigned long long    ull;
typedef     vector<ll>            vll;
typedef     pair<ll,ll>           pll;
typedef     vector<pll>           vpl;
typedef     map<ll,ll>            mll;
typedef     multiset<ll>          msl;
typedef     multimap<ll,ll>       Mll;
using pqboro=priority_queue<ll,vll,less<ll>>;
using pqchoto=priority_queue<ll,vll,greater<ll>>;

#define    all(str)       str.begin(),str.end()
#define    sajo(str)      sort(str.begin(),str.end())
#define    rev(str)       reverse(str.begin(),str.end())
#define    usajo(str)     sort(str.rbegin(),str.rend())
#define    vin(a)         for(auto &it : a) cin>>it
#define    vout(a)        for(auto it:a) cout<<it<<' ';cout<<nn
#define    pb             push_back
#define    eb             emplace_back
#define    mkp(x,y)       make_pair(x,y)
#define    F              first
#define    S              second
#define    yes            cout<<"YES"<<nn
#define    no             cout<<"NO"<<nn
#define    nn             "\n" ///endl
#define    rep(i,n)       for (i=0;i<n;++i )
#define    rep1(i,n)      for (i=1;i<=n;++i )

#define    min3(a,b,c)    min(a,min(b,c))
#define    max3(a,b,c)    max(a,max(b,c))
#define    sqr(x)         ((x)*(x))
#define    pi             2*acos(0.0)
#define    gcd(a,b)       __gcd(a,b)
#define    lcm(a,b)       (a/gcd(a,b))*b
#define    mem(a,b)       memset(a,b,sizeof (a))
#define    dec(x)         cout<<fixed<<setprecision(x)
#define    none(n)         __builtin_popcountll(n)

template < typename T > string toString ( T Number ) { stringstream ss ; ss << Number ; return ss.str() ; }
template < typename T > ll toll ( T str ) { stringstream ss ; ss << str ; ll num ; ss >> num ; return num ; }

const   int  N   =   2e5+7;
const   int  M   =   1e9+7;
const   ll  inf  =   0x7f7f7f7f7f7f7f7f;

int main() {ikarus_101

    ll n,m,i,j,k,x;

    cin>>i>>j>>k;

    cout << j/k - (i+k-1)/k + 1 << endl;














}


Measured memory_bytes: 3640
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for(int i = 0; i < n; i++)
        cin >> s[i];
    sort(s.begin(), s.end());
    for(int i = 0; i < n; i++)
        cout << s[i];

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int64_t N;
  cin >> N;
  
  int64_t MIN = 10e12;
  int64_t F = 1;
  int64_t SUM=0;
  
  for(int i=pow(N,0.5); i<pow(N,0.5)+1; i--){
    if(N%i==0){
      F*=i;
      N/=i;
      SUM=F+N-2;
      MIN = min(MIN,SUM);
      break;
    }
  }
  
  cout << MIN << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i=0;i<n;i++)cin >> d[i];

    sort(d.begin(),d.end());
    int ans = d[n/2] - d[(n/2)-1];

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
  ll N, x, sum=0;
  cin >> N >> x;
  vector<ll> s(N);
  rep(i, N){
    cin >> s[i];
    sum += s[i];
  }
  sort(s.begin(), s.end());
  int ans = 0;
  if(sum == x){
  	cout << N << endl;
  } else {
    rep(i, N){
      if(s[i] <= x && i != N - 1){
        ans++;
        x -= s[i];
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	long long a, b, ma, mi;
	cin >> a >> b;
	ma = max(a, b);
	mi = min(a, b);
	for(long long i = 1; i <= ma; ++i){
		if((ma * i) % mi == 0){
			cout << ma * i;
			return 0;
		}
	}

	return 0;
}



Measured memory_bytes: 256
//07-3 ????????¶?????????
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
using namespace std;
int main(){
    string S;
    cin >> S;

    string new_S = "";
    for(int i=0; i<S.length(); i++){
        if(S.substr(i,1) == "A"){
            new_S += "X";
        }
        else if(S.substr(i,1) == "B"){
            new_S += "Y";
        }
        else if(S.substr(i,1) == "C"){
            new_S += "Z";
        }
        else if(S.substr(i,1) == "D"){
            new_S += "A";
        }
        else if(S.substr(i,1) == "E"){
            new_S += "B";
        }
        else if(S.substr(i,1) == "F"){
            new_S += "C";
        }
        else if(S.substr(i,1) == "G"){
            new_S += "D";
        }
        else if(S.substr(i,1) == "H"){
            new_S += "E";
        }
        else if(S.substr(i,1) == "I"){
            new_S += "F";
        }
        else if(S.substr(i,1) == "J"){
            new_S += "G";
        }
        else if(S.substr(i,1) == "K"){
            new_S += "H";
        }
        else if(S.substr(i,1) == "L"){
            new_S += "I";
        }
        else if(S.substr(i,1) == "M"){
            new_S += "J";
        }
        else if(S.substr(i,1) == "N"){
            new_S += "K";
        }
        else if(S.substr(i,1) == "O"){
            new_S += "L";
        }
        else if(S.substr(i,1) == "P"){
            new_S += "M";
        }
        else if(S.substr(i,1) == "Q"){
            new_S += "N";
        }
        else if(S.substr(i,1) == "R"){
            new_S += "O";
        }
        else if(S.substr(i,1) == "S"){
            new_S += "P";
        }
        else if(S.substr(i,1) == "T"){
            new_S += "Q";
        }
        else if(S.substr(i,1) == "U"){
            new_S += "R";
        }
        else if(S.substr(i,1) == "V"){
            new_S += "S";
        }
        else if(S.substr(i,1) == "W"){
            new_S += "T";
        }
        else if(S.substr(i,1) == "X"){
            new_S += "U";
        }
        else if(S.substr(i,1) == "Y"){
            new_S += "V";
        }
        else if(S.substr(i,1) == "Z"){
            new_S += "W";
        }
    }

    cout << new_S << endl;
    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
int h,w,d;
char s[4]={'R','Y','G','B'};
int main(){
	cin>>h>>w>>d;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			int x=i+j+w;
			int y=i-j+w;
			putchar(s[((x / d) & 1) * 2 + ((y / d) & 1)]);
		}
		cout<<endl;
	}
}

Measured memory_bytes: 512
import numpy as np
N = int(input())
nn = np.zeros((9,9), dtype=int)

for i in range(1,N+1):
  istr = str(i)
  a = int(istr[0])
  b = int(istr[-1])
  if (a != 0) and (b != 0): nn[a-1, b-1] += 1
    
ans = 0
for a in range(9):
  for b in range(9):
    ans += nn[a, b] * nn[b, a]
print(ans)

Measured memory_bytes: 12488
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N=in();
  vector<int> s(N);
  int mp=1e9+7;
  REP(i,N){
    s[i]=in();
  }
  do{
    int index;
    REP(i,N){
      if(s[i]>0 && mp>s[i]){
        mp = s[i];
        index = i;
      }
    }
    REP(i,N){
      if(i!=index) s[i]%=mp;
    }
  }while(count(ALL(s),0)<N-1);
  
  cout << mp << endl;
  return 0;
}


Measured memory_bytes: 640
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    ans = 0
    for i in range(N):
        if i % 2 == 0 and A[i] % 2 == 1:
            ans += 1
    print(ans)

    
    

if __name__ == '__main__':
    main()



Measured memory_bytes: 9044
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String s [] = sc.next().split("");
		String t [] = sc.next().split("");

		int answer = n*2;
		int sum = 0;
		for(int  i = 0;i < n;i++){
			if(s[i].equals(t[0])){
				sum++;
				for(int j = i+1;j < n;j++){
					if(s[j].equals(t[j-i])){
						sum++;
					}else{
						sum = 0;
					}
				}
			}
			if(sum > 0){
				answer -= sum;
				break;
			}
		}

		System.out.println(answer);
	}
}

Measured memory_bytes: 9808
#include <bits/stdc++.h>
#define SIZE 10
#define PI 3.141592653589793

using namespace std;
typedef long long ll;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int i,j;
	int tmp;
	int counter=0;
	double N;
	double answer=0;
	vector<int> given;

	cin >> N;

	answer=(N/3)*(N/3)*(N/3);
	cout << std::fixed << std::setprecision(15) << answer << endl;

	return 0;
}



Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  int N; cin >> N;
  map<string,int> map;
  rep(i, N) {
    string St;
    cin >> St;
    map[St]++;
  }
  
  int maxval = 0;
  for(auto v : map){
    chmax(maxval,v.second);
  }

  for (auto v : map) {
    if(v.second < maxval) continue;
    cout << v.first << endl;
  }
}

Measured memory_bytes: 23808
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

typedef pair<int, int> P;
vector<P> v[61];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int L; cin >> L;
    int V = 0;
    int t = L;
    while(t > 0) {
        V++;
        t /= 2;
    }
    int m = 0;
    rep(i, (V - 1)) {
        v[i + 2].push_back({i + 1, 0});
        v[i + 2].push_back({i + 1, (1 << i)});
        m += 2;
    }
    int num = (1 << (V - 1));

    RREP(i, V - 2, 0) {
        if(L & (1 << i)) {
            v[V].push_back({i + 1, num});
            num += (1 << i);
            m++;
        }
    }
    //v[V].push_back({1, num});
    //m++;
    //cout << num << endl;
    cout << V << " " << m << endl;
    rep(i, V) {
        for(auto& e: v[i + 1]) {
            cout << e.first << " " << i + 1 << " " << e.second << endl;
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    if(n % 10 == 0) cout << 10;
    else
    {
        int c = 0;
        while(n)
        {
            c += (n%10);
            n /= 10;
        }
        cout << c;
    }
}


Measured memory_bytes: 256
X =int(input())
max = 1 #このように書かないとX = 1,2 のときに正しい値を返せない。listにappendだとlistが空になってエラーになる。
for k in range(X):
    for j in range(X):
        if k**2 > X:
            break
        elif k**j > X:
            sub_max = k**(j-1)
            if sub_max >= max:
                max = sub_max
            break
            
print(max)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    vector<ll> apb(n);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        ans -= b; 
        apb[i] = a + b;
    }
    sort(apb.begin(), apb.end());
    reverse(apb.begin(), apb.end());
    rep(i, n) {
        if ( i & 1 ) continue;
        else         ans += apb[i]; 
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
A, B, C, D = map(int, input().split())
min = min(C, D)
max = max(C, D)
 
def gcd(max, min):
  while min:
    max, min = min, max%min
  return max
lcm = max*min//gcd(max,min)

#Cで割り切れる数
c = B//C-(-(-A//C))+1
#Dで割り切れる数
d = B//D-(-(-A//D))+1
#CとDで割り切れる数
e = B//lcm-(-(-A//lcm))+1

print(B-A+1-(c+d-e))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  string s,t,u;
  cin >> s >> t;
  int i,j;
  bool is=true,no=false;
  string ans;
  for(i=0;i<s.size();i++){
    ans+='z';
  }
  for(i=0;i<s.size()-t.size()+1;i++){
    u=s;
    is=true;
    for(j=0;j<t.size();j++){
      if(u.at(i+j)=='?'){
        u.at(i+j)=t.at(j);
      }
    }
    for(j=0;j<t.size();j++){
      if(t.at(j)!=u.at(i+j)){
        is=false;
      }
    }
    if(is){
      no=true;
      for(int k=0;k<s.size();k++){
        if(u.at(k)=='?'){
          u.at(k)='a';
        }
      }
      if(ans>u){
        ans=u;
      }
    }
  }
  if(no){
    cout << ans;
  }else{
    cout << "UNRESTORABLE";
  }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const double PI=3.14159265358979323846;
#define int long long int
signed main(){
    int k,a,b;cin>>k>>a>>b;
    bool flag=0;
    for (int i=a;i<b+1;i++)if(i%k==0)flag=1;
    cout<<(flag?("OK"):("NG"))<<endl;
    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String[] tmp = scanner.nextLine().split(" ");

		int bio = Integer.parseInt(tmp[0]);
		int leg = Integer.parseInt(tmp[1]);

		double diff = leg - (2.0 * bio);
		double Knum = diff / 2.0;
		double Tnum = bio - Knum;

		int bioSum = (int) (Knum + Tnum);
		int legSum = (int) (Knum * 4 + Tnum * 2);

		if(Knum < 0 || Tnum < 0) {

			System.out.println("No");

		}else if(leg % 2 != 0) {

			System.out.println("No");

		}else if(bioSum == bio && legSum == leg) {

			System.out.println("Yes");

		}else {

			System.out.println("No");

		}


	}

}

Measured memory_bytes: 35728
#include<stdio.h>

int main()
{
  int n, m, i, j, a[100][100], b[100];
  int c = 0, d = 0;

  scanf("%d%d", &n, &m);

  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++){
      scanf("%d", &a[i][j]);
    }
  }

  for(i = 0; i < m; i++){
    scanf("%d", &b[i]);
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < m; j++){
      c = a[i][j] * b[j];
      d += c;
    }
    printf("%d\n", d);
    c = 0;
    d = 0;
  }
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

#define out(t) cout << (t) << "\n"

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int uint;

int popcount(uint x) {
    x -= x >> 1 & 0x55555555;
    x = (x & 0x33333333) + (x >> 2 & 0x33333333);
    x = x + (x >> 4) & 0x0F0F0F0F;
    return x * 0x01010101 >> 24;
}

int tzcnt(uint x) {
    return popcount(~x & x - 1);
}

struct Point {
    int x, y;

    Point(int p, int q) : x(p), y(q) {}
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> arr;
    arr.reserve(200000);

    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;

        arr.push_back(a);
    }

    vector<int> arr2(arr);

    sort(arr2.begin(), arr2.end());

    for (auto x : arr) {
        auto it = lower_bound(arr2.begin(), arr2.end(), x);

        int d = distance(arr2.begin(), it);

        if (d >= (N / 2)) {
            out(arr2[N / 2 - 1]);
        }
        else {
            out(arr2[N / 2]);
        }
    }

    int aaa;
    cin >> aaa;
}

Measured memory_bytes: 3840
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Parent(i int) int {
	return i / 2
}
func Left(i int) int {
	return 2 * i
}
func Right(i int) int {
	return 2*i + 1
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()

	A := make([]int, n+1)

	for i := 1; i <= n; i++ {
		A[i] = nextInt()
	}
	for i := 1; i <= n; i++ {
		fmt.Printf("node %d: key = %d, ", i, A[i])
		if Parent(i) >= 1 {
			fmt.Printf("parent key = %d, ", A[Parent(i)])
		}
		if Left(i) <= n {
			fmt.Printf("left key = %d, ", A[Left(i)])
		}
		if Right(i) <= n {
			fmt.Printf("right key = %d, ", A[Right(i)])
		}
		fmt.Println("")
	}
}



Measured memory_bytes: 1084
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(ll i = 0; i < n; i++)
#define Rep(i,n) for(ll i = 0; i <= n; i++)
#define REp(i,n) for(ll i = 1; i < n; i++)
#define REP(i,n) for(ll i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  string s;
  cin >> s;
  rep(i,sz(s)) {
    if(i == 4) cout << " ";
    cout << s[i];
  }
  cout << endl;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int N, K, Q;

    scanf("%d%d%d", &N, &K, &Q);

    int i;

    int *A = (int *) malloc(sizeof(int) * N);

    for(i = 0; i < N; i ++){
        A[i] = 0;
    }
    int tmp;

    for(i = 0; i < Q; i ++){
        scanf("%d", &tmp);

        A[tmp - 1] ++;
    }
    for(i = 0; i < N; i ++){
        if(K - Q + A[i] > 0){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
}

Measured memory_bytes: 896
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e9+7;

int main(){
    ll n,k;
    cin >> n >> k;
    if((n+1)/2>=k) cout << "YES" << endl;
    else cout << "NO" << endl;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define lo long
const long long lmax=1999999999;
const long long lmx=1999999999999999999;
int n,m,rans;
pair<int,int>a[100003];
int main(){std::ios::sync_with_stdio(false);
//	ifstream cin("IN.in");
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>a[i].first>>a[i].second;
	}
	sort(a,a+m);
	int l=a[0].first;
	int r=a[0].second;
	for(int i=1;i<m;i++)
	{
		if(a[i].first==l)
		{
			rans++;
		}
		else
		if(a[i].first<r&&a[i].first>l)
		{
			l=a[i].first;
			r=min(a[i].second,r);
			rans++;
		}
		else
		{
			l=a[i].first;
			r=a[i].second;
		}
//		cout<<l<<" "<<r<<endl;
	}
	cout<<m-rans<<endl;
	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        string codefestival = "CODEFESTIVAL2016";
        int res = 0;
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] != codefestival[i]) res++;
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

const double EPS = 0.00000001;
int n;
double arr[3001], dp[3001][6002];

double solve(int i = 0, int heads = 0) {
    if (i == n) {
        return heads > n - heads;
    }
    double& ret = dp[i][heads];
    if (ret >= 0) {
        return ret;
    }
    
    return ret = arr[i] * solve(i+1, heads+1) + (1-arr[i]) * solve(i+1, heads);
}
int main()
{
    IOS
    //bfreopen("balalance.in", "r", stdin);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    memset(dp, -1, sizeof dp);
    cout.precision(10);
    cout << fixed << solve() << endl;
    return 0;
}


Measured memory_bytes: 141184
#include <stdio.h>
#include <stdlib.h>

#define SDATAMAX 100

int top;
int stack[SDATAMAX];

void push(int);
int pop(void);

int main(){
  int x, a, b;
  char s[1000000];
  

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      push(pop() + pop());
    } else if ( s[0] == '-' ){
      a = pop();
      b = pop();
      push(b - a);
    } else if ( s[0] == '*' ){
      push(pop() * pop());
    } else {
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n",pop());

  return 0;
}

void push(int x)
{
  top++;
  stack[top] = x;
}

int pop(void)
{
  top--;
  return stack[top + 1];
}
    



Measured memory_bytes: 2100
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	N := readInt()
	A := readInt()
	B := readInt()
	h := make([]int, N)
	for i := range h {
		h[i] = readInt()
	}
	println(solve(N, A, B, h))
}

func solve(N, A, B int, h []int) int {
	maxa := 0
	for _, v := range h {
		maxa = max(maxa, v)
	}
	l := 0
	r := maxa/B + 1
	var rec func(l, r int) int
	rec = func(l, r int) int {
		if l+1 == r {
			return r
		}
		m := (l + r) / 2
		if ok(m, N, A, B, h) {
			return rec(l, m)
		}
		return rec(m, r)
	}

	return rec(l, r)
}

func ok(m, N, A, B int, h []int) bool {
	var ac int
	for _, v := range h {
		v -= B * m
		if v < 0 {
			continue
		}
		ac += v / (A - B)
		if v%(A-B) != 0 {
			ac++
		}
	}
	return ac <= m
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define N 100005
ll inf = 1e14;
int mod = 998244353;
char en = '\n';

ll abs1(ll x) {
  if (x < 0)
    return -x;
  return x;
}
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
// topological sort where for each edge a->b,a comes before b
bool visited[N];
vector<ll> adj[N];
vector<ll> res;
void dfs(ll curr) {
  visited[curr] = true;
  for (ll x : adj[curr]) {
    if (!visited[x])
      dfs(x);
  }
  res.push_back(curr);
}

void topologicalSort(ll n) {
  res.clear();
  memset(visited, false, sizeof(visited));
  for (ll i = 1; i <= n; i++) {
    if (!visited[i])
      dfs(i);
  }
  reverse(res.begin(), res.end());
}

ll dp[N];
vector<ll> adjr[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, m;
  cin >> n >> m;

  memset(visited, false, sizeof(visited));

  for (ll i = 1; i <= m; i++) {
    ll x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adjr[y].push_back(x);
  }

  topologicalSort(n);

  memset(dp, 0, sizeof(dp));

  for (ll i = 1; i < res.size(); i++) {
    ll curr = res[i];

    for (ll x : adjr[curr])
      dp[curr] = max(dp[curr], 1 + dp[x]);
  }

  cout << (*max_element(dp + 1, dp + n + 1)) << en;

  return 0;
}


Measured memory_bytes: 15228
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    vector<vector<P>>an(n);
    for(int i=0;i<n;i++){
        int a;cin>>a;
        while(a--){
            int x,y;cin>>x>>y;
            an[i].pb(mp(x,y));
        }
    }
    int maxm=-1;
    for(int bit=0;bit<(1<<n);bit++){
        bool abc=true;
        for(int i=0;i<n;i++){
            if((bit&(1<<i))){
                for(int j=0;j<siz(an[i]);j++)
                    if(((bit>>(an[i][j].fi-1))&1)^an[i][j].se)
                        abc=false;
            }
        }
        if(abc==true)
            chmax(maxm,counter(bit));
    }
    cout<<maxm<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include <stdio.h>
int checkeye(double val){
    if(val>=1.1){
        return 0;
    }else if(0.6<=val&&val<1.1){
        return 1;
    }else if(0.2<=val&&val<0.6){
        return 2;
    }else{
        return 3;
    }
}

int main(void)
{
    int result[4][2] = {0} ,i;
    double l ,r;
    while(scanf("%lf %lf" ,&l ,&r) != EOF){
        result[checkeye(l)][0]++;
        result[checkeye(r)][1]++;
    }
    for(i=0;i<4;i++){
        printf("%d %d\n",result[i][0] ,result[i][1]);
    }
    return 0;
}

Measured memory_bytes: 628
package main

import "fmt"

func main(){
	var h,n,temp,sum int
	fmt.Scan(&h,&n)
	for i := 0 ; i < n ; i++ {
		fmt.Scan(&temp)
		sum += temp
	}
	if h <= sum {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 5504
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	int H=0,W=0;

	do{
	    H=scan.nextInt();
	    W=scan.nextInt();
	    if(H==0 && W==0) break;
	    for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
		    if((i+j)%2==0){
			System.out.print("#");
		    }else{
			System.out.print(".");
		    }
		}
		System.out.println("");
	    }
	    System.out.println("");
	}while(H!=0 && W!=0);
    }
}



Measured memory_bytes: 33428
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a(3);
  cin>> a[0]>>a[1]>>a[2];
  sort(a.begin(),a.end());
  if(a[0]!=a[1]){
    cout << a[0]<< "\n";
  }else{
    cout << a[2] << "\n";
  }
}

Measured memory_bytes: 256
def calc(n):
    if n <= 1:
        return 1
    else:
        return 2 ** (n - 1)


def solution(s):
    n = len(s)
    dp = [None for i in range(len(s))]
    cnt = 0
    for i in range(n):
        a = s[:i]
        b = s[i:]
        cnt += calc(len(a)) * int(b)
        cnt2 = 0
        for j in range(len(a)):
            c = a[:j]
            d = a[j:]
            cnt2 += calc(len(c)) * int(d)
            if len(c) == 1:
                cnt2 += int(c)
            elif len(c) > 1:
                cnt2 += dp[len(c)]
        dp[i] = cnt2
        cnt += dp[i]
    return cnt


print(solution(input()))


Measured memory_bytes: 9232
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif
typedef long long ll;
const int INF=0x3f3f3f3f;

int main()
{
	int n;
	ll m;
	cin>>n>>m;
	vector<int> a(n);
	vector<ll> suf(n+1);
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a.begin(),a.end());
	for(int i=n-1;i>=0;i--)
		suf[i]=suf[i+1]+a[i];
	int L=2,R=2e5,tar=-1;
	while(L<=R)
	{
		int mid=L+R>>1;
		ll cnt=0;
		//debug(mid);
		for(int i=0;i<n;i++)
		{
			int pos=lower_bound(a.begin(),a.end(),mid-a[i])-a.begin();
			cnt+=n-pos;
			//debug(cnt);
			//debug(pos);
		}
		if(cnt>=m)
		{
			L=mid+1;
			tar=mid;
		}
		else R=mid-1;
	}
	//debug(tar);
	ll cnt=0,ans=0;
	for(int i=0;i<n;i++)
	{
		int pos=upper_bound(a.begin(),a.end(),tar-a[i])-a.begin();
		//debug(pos);
		cnt+=n-pos;
		//debug(cnt);
		//debug(a[i]);
		ans+=1ll*(n-pos)*a[i]+suf[pos];
		//debug(ans);
		//debug(suf[pos]);
	}
	//debug(ans);
	ans+=1ll*tar*(m-cnt);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2 2");
            //0
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("1 7");
            //5
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("314 1592");
            //496080
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        long[] wkArr = InputList[0].Split(' ').Select(X => long.Parse(X)).ToArray();
        long N = wkArr[0];
        long M = wkArr[1];

        long NewX = Math.Min(N, M);
        long NewY = Math.Max(N, M);

        if (NewX == 1) {
            if (NewY == 1) {
                Console.WriteLine(1);
            }
            else if (NewY == 2) {
                Console.WriteLine(0);
            }
            else {
                Console.WriteLine(NewY - 2);
            }
        }
        else if (NewX == 2) {
            Console.WriteLine(0);
        }
        else {
            Console.WriteLine((NewX - 2) * (NewY - 2));
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;

const int inf=1e9;
int N,M,n,m;

int main()
{int i,j;
 
 scanf("%d%d%d%d",&N,&M,&n,&m);
 if(N%n==0 && M%m==0)
 {	printf("No\n");
 	return 0;
 }
 printf("Yes\n");
 for(i=1;i<=N;i++)
 	for(j=1;j<=M;j++)
 	{	if((n==1 || i%n==1) && (m==1 || j%m==1))
 			printf("%d",inf-1);
 		else if((n==1 || i%n==0) && (m==1 || j%m==0))
 			printf("%d",-inf);
 		else
 			printf("%d",0);
 		printf("%c",j!=M?' ':'\n');
	}
 return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>

#define INF 1e9
using namespace std;

#define REPR(i, n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

typedef long long ll;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll calc(const vector<char> &ans, const vector<ll> &tbl) {
    ll now = 0;
    REP(i, ans.size()) {
        int bit = ans[i] - '0';
        if (bit == 1) now += tbl[i];
    }
    return now;
}

int main() {
    int N;
    cin >> N;
    vector<char> ans;
    if (N==0) {
        cout << 0 << endl;
        return 0;
    }
    while(N!=0) {
        // cout << N;
        int q = N%2;
        int p = N/(-2);
        if (q!=0) {
            if (q<0) p++;
            ans.push_back('1');
            if (q==p && p==1) break;
        }
        else ans.push_back('0');
        // cout << "next: " << p << endl;

        N=p;
    }
    reverse(ALL(ans));
    string s(ALL(ans));

    cout << s << endl;
}


Measured memory_bytes: 256
S = input()
Q = int(input())

s = ""
l = ""
h = 1

for _ in range(Q):
    q = list(map(str, input().split()))
    if q[0] == "1":
        h *= -1
        continue
    if q[1] == "1":
        if h == 1:
            s += q[2]
        else:
            l += q[2]
    else:
        if h == 1:
            l += q[2]
        else:
            s += q[2]

ans = s[::-1] + S + l
print(ans[::h])

Measured memory_bytes: 4596
#include<stdio.h>
char a[1000],b[1000],ab[100000];
int main()
{
	int n,j=0,i;
	scanf("%d",&n);
	scanf("%s %s",a,b);
	for(i=0;i<n;i++)
	{
		ab[j]=a[i];
		j++;
		ab[j]=b[i];
		j++;
	}
	puts(ab);
}

Measured memory_bytes: 128