akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>
#include <cassert>


typedef long long ll;
using namespace std;

#define mod 1000000007
#define INF 1000000000 //(int)1e9
#define LLINF 8000000000000000000 //(ll)2e18
#define PI  3.1415926536

#define SIZE 510



int main(){
    int h,w;
    int d[SIZE][SIZE];
    int c[SIZE][SIZE]={0};
    int in[SIZE][SIZE]={0};
    int c_c=0,in_c=0;
    vector<pair<int,int> > vec;
    
    scanf("%d%d",&h,&w);
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            scanf("%d",&d[i][j]);
        }
    }
    
    for(int i=1;i<h-1;i++){
        for(int j=1;j<w-1;j++){
            
            int min_d = 4;
            
            for(int k=-1;k<=1;k++){
                for(int l=-1;l<=1;l++){
                    min_d = min(min_d,d[i+k][j+l]);
                }
            }
            
            for(int k=-1;k<=1;k++){
                for(int l=-1;l<=1;l++){
                    d[i+k][j+l] -= min_d;
                }
            }
            
            c[i][j]=min_d;
            
        }
    }
    /*
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            printf("%d ",c[i][j]);
        }
        printf("\n");
    }
    */
    
    for(int i=1;i<h-1;i++){
        for(int j=1;j<w-1;j++){
            if(c[i][j]==0) continue;
            c_c++;
            
            for(int k=-1;k<=1;k++){
                for(int l=-1;l<=1;l++){
                    if(k==0 && l==0) continue;
                    if(c[i+k][j+l]>0){
                        in[i][j]++;
                    }
                }
            }
            
            if(in[i][j]<=1){
                vec.push_back({i,j});
            }
        }
    }
    
    
    assert(vec.size()<=2);
    
    sort(vec.begin(),vec.end());
    
    if(vec.size()==1){
        printf("%d %d %d %d\n",vec[0].first,vec[0].second,vec[0].first,vec[0].second);
    }else{
        printf("%d %d %d %d\n",vec[1].first,vec[1].second,vec[0].first,vec[0].second);
    }
    
    
}

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

using namespace std;

#define ll long long
#define pb push_back
#define vi vector<int>
#define bn(n) (n).begin(), (n).end()
#define FOR(n) for(int i = 0; i < (int)n; i++)

void solve() {
    int n, k;
    cin >> n >> k;
    vector<char> v;
    for (int i = 0; i < k; i++) {
        char a;
        cin >> a;
        v.push_back(a);
    }

    bool xd = true;
    while(true) {
        string s = to_string(n);
        for (char a : s) {
            if (find(v.begin(), v.end(), a) != v.end()) {
                xd = false;
                break;
            }
        }
        if (xd) {
            cout << n << "\n";
            return;
        }
        n++;
        xd = true;
    }
}

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

    int t = 1, i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 3668
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  for(int i=0;i<n-1;i++){
  	if(a[i]==a[i+1])return cout<<"NO"<<endl,0;
  }
  cout<<"YES"<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979

int main()
{
	int x = 0, n, max = 0;
	string s;
	cin >> n >> s;

	rep(i, n)
	{
		if (s[i] == 'I')	x++;
		else x--;

		if (x > max) max = x;
	}

	cout << max << endl;
	return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		int k = 0;
		int s = 1;
		boolean mini = true;
		boolean large = true;
		int[] p = new int[n];
		if(n == 0) {
			System.out.println(x);
			System.exit(0);
		}
		for(int i = 0; i < p.length; i++) {
			int num = sc.nextInt();
			p[i] = num;
			if(num == x) {
				k += 1;
			}
		}
		if(k == 0) {
			System.out.println(x);
			System.exit(0);
		}
		while(true) {
			int min = x - s;
			int lar = x + s;
			for(int i = 0; i < p.length; i++) {
				if(min == p[i]) {
					mini = false;
				}
				if(lar == p[i]) {
					large = false;
				}
			}
			if(mini == true) {
				System.out.println(min);
				break;
			}
			if(large == true) {
				System.out.println(lar);
				break;
			}
			s++;
			mini = true;
		    large = true;
		}
	}

}

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

using namespace std;

int n;
vector<vector<int>> adj;
vector<pair<int, int>> DP;
const int inf = (int)1e9 + 7;

// dfs on a tree
void dfs(int i, int p)
{
	// visit i, node processing is based on its children
	// processing should be after all children has been visited
	// cout << "visiting " << i << endl;
	long long n1 = 1, n2 = 1;
	for (auto x : adj[i])
	{
		if (x == p) // add parents to avoid stuck in loops (no visited array here)
			continue;
		dfs(x, i);
		// if all children are white, i can be both while and black
		// if one of the children is black, i has to be white
		// update DP here, first is when number of different subtree if this node is white
		// second is the number of different subtree if this node is black
		n1 *= (long long) (DP[x].first + DP[x].second);
		n2 *= DP[x].first;
		n1 %= inf;
		n2 %= inf;
	}
	DP[i].first = n1;
	DP[i].second = n2;
}

int main()
{
	cin >> n;
	adj.resize(n + 1);
	DP.resize(n + 1);

	// bottom up DP for trees
	int a, b;
	for (int i = 0; i < n - 1; i++)
	{
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	dfs(1, 1);
	cout << (DP[1].first + DP[1].second)%inf << endl;
}

Measured memory_bytes: 16284
#include <iostream>
#include <vector>

using namespace std;

struct Edge {
	int to, cost;
};

struct dfsAns {
	int n, v;
};

int N;
vector< vector<Edge> > edges;

dfsAns dfs(int n, int prev) {
	dfsAns ret = {n, 0};
	for (int i = 0; i < edges[n].size(); ++i) {
		if (edges[n][i].to != prev) {
			dfsAns a = dfs(edges[n][i].to, n);
			if ( edges[edges[n][i].to].size() > 1 ) a.v += edges[n][i].cost;
			if (a.v > ret.v) {
				ret = a;
			}
		}
	}
	return ret;
}

int main() {
	while (cin >> N, N) {
		edges.clear();
		edges.resize(N);

		vector<int> p(N);
		for (int i = 0; i < N-1; ++i) {
			cin >> p[i];
		}
		for (int i = 0; i < N-1; ++i) {
			int d; cin >> d;
			edges[i+1].push_back({p[i]-1, d});
			edges[p[i]-1].push_back({i+1, d});
		}
		dfsAns a = dfs(0, -1);
		a = dfs(a.n, -1);

		int ans = 0;
		for (int i = 0; i < edges.size(); ++i) for (int j = 0; j < edges[i].size(); ++j) {
			ans += edges[i][j].cost;
		}
		ans /= 2;
		for (int i = 0; i < edges.size(); ++i) {
			if (edges[i].size() > 1) {
				for (int j = 0; j < edges[i].size(); ++j) {
					if (edges[edges[i][j].to].size() > 1) ans += edges[i][j].cost;
//					if (i == edges[i][j].to) cout << "error" << endl;
				}
			}
		}
		ans -= a.v;
		cout << ans << endl;
	}
}

Measured memory_bytes: 1328
S=input()
s=0
t=0
for i in range(len(S)):
  if i%2==0 and S[i]=="0":
    s+=1
  elif i%2!=0 and S[i]=="1":
    s+=1
for j in range(len(S)):
  if j%2==0 and S[j]=="1":
    t+=1
  elif j%2!=0 and S[j]=="0":
    t+=1
print(min(s,t))

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

int main() {
int N;
long long int ans = 0;
cin >> N;
vector<int> d(N);
rep(i, N)
cin >> d.at(i);
rep(i, N-1){
rep2(j, i+1, N){
ans+= d.at(i)*d.at(j);
}
}

cout << ans << endl;
}

Measured memory_bytes: 256
import sys
A,B,K = map(int,input().split())
if not ( 1 <= A <= 100 and 1 <= B <= 100 ): sys.exit()
if not ( 1 <= K ): sys.exit()
#euclid algorithm
if A < B: 
    A, B = B, A
while A%B != 0:
    A,B = B,A%B
# B is greatest common divisor
count = 0
for I in range(B,0,-1):
    if B % I == 0:
        count += 1
    if count == K:
        print(I)
        break


Measured memory_bytes: 9068
#include<stdio.h>

#define MAX 100

int main(){

  int i, j, num, flag, count, temp;
  int data[MAX];

  flag = 1;
  count = 0;

  scanf("%d", &num);

  for(i = 0; i < num; i++){

    scanf("%d", &data[i]);

  }

  for(i = 0; i < num - 1; i++){

    for(j = num - 1; j > i; j--){

      if(data[j] < data[j - 1]){
	
	temp = data[j - 1];

	data[j - 1] =  data[j];

	data[j] = temp;
	
	count++;
	
      }
	
    }
     
  }

  for(i = 0; i < num - 1; i++){
    
    printf("%d ", data[i]);

  }

  printf("%d\n%d\n", data[i], count);
  
  return 0;
}

Measured memory_bytes: 600
n = int(input())
a = input()
b = input()
c = input()

ans = 0
for i in range(n):
    if a[i] == b[i] == c[i]:
        continue
    elif a[i] != b[i] and b[i] != c[i] and c[i] != a[i]:
        ans += 2
    else:
        ans += 1
print(ans)


Measured memory_bytes: 8968
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 15;
const int MAXM = 1000010;
const int MAXK = 510;
const int MAXQ = 200010;

int n, m, a[MAXN][MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int L, R;
    cin >> L >> R;
    R = min(R, L + 2030);
    int res = 2020;
    FOR(i,L,R)
        FOR(j,i+1,R) {
            res = min(res, (i % 2019) * (j % 2019) % 2019);
        }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
// Dmitry _kun_ Sayutin (2019)

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;
using std::queue;

using std::pair;
using std::make_pair;

using std::tuple;
using std::make_tuple;
using std::get;

using std::min;
using std::abs;
using std::max;
using std::swap;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // code here
    string s;
    cin >> s;

    const int inf = 1e9;
    vector<int> value(1 + SZ(s), inf);
    queue<int> q;

    for (int i = 0; i <= SZ(s); ++i) {
        bool ready = true;
        if (i != 0 and s[i - 1] == '<')
            ready = false;
        if (i != SZ(s) and s[i] == '>')
            ready = false;

        if (ready)
            q.push(i), value[i] = 0;
    }

    while (not q.empty()) {
        int i = q.front();
        q.pop();

        for (int j: {i - 1, i + 1}) {
            if (j < 0 or j >= SZ(s) + 1)
                continue;

            if (value[j] != inf)
                continue;
            
            int min_val = 0;
            if (j != 0 and s[j - 1] == '<')
                min_val = max(min_val, 1 + value[j - 1]);
            if (j < SZ(s) and s[j] == '>')
                min_val = max(min_val, 1 + value[j + 1]);

            if (min_val < inf) {
                value[j] = min_val;
                q.push(j);
            }
        }
    }

    int64_t ans = 0;
    for (int x: value)
        ans += x;

    cout << ans << "\n";
    

    return 0;
}


Measured memory_bytes: 3484
N = int(input())
a = list(map(int, input().split()))

ans = float("inf")
X = a[0]
Y = sum(a) - a[0]

for i in range(1, N):
	if abs(X - Y) < ans:
		ans = abs(X - Y)

	X += a[i]
	Y -= a[i]

print(ans)

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int t[n]; int x[n],y[n];
    rep(i,0,n) cin >> t[i] >> x[i] >> y[i];
    int locatex=0,locatey=0,time=0;
    bool ok = true;
    rep(i,0,n){
        if(!(t[i]-time >= abs(x[i]-locatex)+abs(y[i]-locatey) &&
        (t[i]-time-(abs(x[i]-locatex)-abs(y[i]-locatey)))%2==0)) ok = false;
        locatex = x[i]; locatey = y[i]; time = t[i];
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n<4)
	{
		cout<<"No";
		return 0;
	}
	if(n%4==0||n%7==0)
	{
		cout<<"Yes";
		return 0;
	}
	bool isbreak=false;
	int n4=n;
	while(n4>=7)
	{
		n4-=4;
		if(n4%7==0)
		{
			cout<<"Yes";
			return 0;
		}
	}
	int n7=n;
	while(n7>=4)
	{
		n7-=7;
		if(n7%4==0)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);
#define debug(x) cerr << #x << " = " << x << "\n" ;

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int main(){

 int a , b , c ;
 cin >> a >> b >> c ;
 if( a - b < c ){
    cout << abs(( a - b ) - c) ;
 } else cout << "0" ;

 return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n, a;
    string moji;
    
    cin>>n>>a;
    cin>>moji;
    
    a--;
    if(moji[a]=='A'){
        moji[a]='a';
    }else if(moji[a]=='a'){
        moji[a]='A';
    }else if(moji[a]=='B'){
        moji[a]='b';
    }else if(moji[a]=='b'){
        moji[a]='B';
    }else if(moji[a]=='C'){
        moji[a]='c';
    }else if(moji[a]=='c'){
        moji[a]='C';
    }
    
    cout<<moji<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(i = 0; i < (n); ++i)
#define rrep(i,n) for(i = 1; i <= (n); ++i)
#define drep(i,n) for(i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//./a.exe

bool isPrime(int x){
    int i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
   int n,sum,i;
   cin >> n; 
   int V[n];
   rep(i,n)cin >> V[i] ;
   int C[n];
   rep(i,n)cin >> C[i] ;
   sum = 0;
   rep(i,n){
    if( V[i] > C[i] ){

        sum += V[i]-C[i];
    } 
}
cout << sum << endl;



//////////////////////////////////////////////////////
return 0;}

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

bool cmp(const pair<int,int> &f,const pair<int,int> &s)
{
	return f.second>s.second;
}

int main()
{
	int N;
	int v[100010]={};
	map<int,int> m;
	vector<pair<int,int>> even,odd;
	int f,s;
	int ans=0;
	
	cin >> N;
	for(int i=0;i<N;i++)
		cin >> v[i];
	
	//even
	for(int i=0;i<N;i+=2)
		m[v[i]]++;
	for(auto&& i:m)
		even.push_back({i.first,i.second});
	//odd
	m.clear();
	for(int i=1;i<N;i+=2)
		m[v[i]]++;
	for(auto&& i:m)
		odd.push_back({i.first,i.second});
	
	if(even.size()==1 && odd.size()==1)
	{
		if(even[0].first==odd[0].first)
		{
			cout << N/2 << endl;
		}
		else
		{
			cout << 0 << endl;
		}
		return 0;
	}
	
	
	sort(even.begin(),even.end(),cmp);
	sort(odd.begin(),odd.end(),cmp);
	
	for(int i=0,j=0;i<even.size() && odd.size();)
	{
		f=even[i].first;
		s=odd[j].first;
		if(f==s)
		{
			if(even[i].second>odd[j].second)
			{
				j++;
				continue;
			}
			else if(even[i].second<odd[j].second)
			{
				i++;
				continue;
			}
			else
			{
				if(even[i+1].second>=odd[j+1].second)
				{
					i++;
					continue;
				}
				else
				{
					j++;
					continue;
				}
			}
		}
		break;
	}
	
	//even
	for(int i=0;i<N;i+=2)
		if(v[i]!=f)ans++;
	for(int i=1;i<N;i+=2)
		if(v[i]!=s)ans++;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4088
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

ll N,P;
ll A[50];

ll pow(ll x,ll n){
    if(n==0) return 1;
    else if(n%2) return x*pow(x,n-1);
    return pow(x*x,n/2);
}

ll pcomb(ll n, ll r){
    vector<vector<ll>> v(n+1,vector<ll>(n+1,0));
    for(int i = 0;i <v.size(); i++){
        v[i][0]=1;
        v[i][i]=1;
    }
    for(int k = 1;k <v.size();k++){
        for(int j = 1;j<k;j++){
            v[k][j]=(v[k-1][j-1]+v[k-1][j]);
        }
    }
    return v[n][r];
}

int main(){
    cin>>N>>P;
    rep(i,N) cin>>A[i];
    rep(i,N) A[i]%=2;

    ll even=0, odd=0;
    rep(i,N){
        if(A[i]==0) even++;
        else odd++;
    }

    ll ans=0;
    if(P==0){
        for(int i=0;i<=odd;i+=2){
            ans+=pcomb(odd,i);
        }
        ans*=pow(2,even);
    }else{
        for(int i=1;i<=odd;i+=2){
            ans+=pcomb(odd,i);
        }
        ans*=pow(2,even);
    }

    cout<<ans<<endl;
}

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

#define rep(i, N) for(int i = 0;i < N;i++)
typedef long long ll;

using namespace std;

int main(void) {
	int N; cin >> N;
	vector<int> a(3*N);
	rep(i, 3*N)cin >> a[i];
	sort(a.begin(), a.end(), greater<int>());
	ll ans = 0;


	rep(i, N) {
		ans += a[2 * i + 1];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
 
vector <ll> s;
vector <ll> a;
ll k;
 
void modify(int p,int x,int id = 1,int l = 0,int r = k){
	if(r - l < 2){
		s[id] = x;
		a[p] = x;
		return;
	}
	int mid = (l + r)/2;
	if(p < mid) modify(p, x, id * 2, l, mid);
	else modify(p, x, id * 2 + 1, mid, r);
	s[id] = max(s[id * 2],s[id * 2 + 1]);
}

int query(int x,int y,int id = 1,int l = 0,int r = k){
	if(x >= r or l >= y)	return 0;
	if(x <= l && r <= y)	return s[id];
	int mid = (l+r)/2;
	return max(query(x, y, id * 2, l, mid),
	       query(x, y, id * 2 + 1, mid, r));
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	vector <ll> arr(n);
	map <ll,ll> mapp;
	for (int z=0;z<n;z++){
		cin >> arr[z];
		mapp[arr[z]]++;
	}
	unordered_map <ll,ll> index;
	a.resize(mapp.size());
	k = mapp.size();
	ll c = 0;
	for (auto it = mapp.begin();it != mapp.end();it++){
		index[it->first] = c;
		c++;
	}
	s.resize(k*4,0);
	ll ans = 0;
	for (int z=0;z<n;z++){
		ll i = index[arr[z]];
		ll j = query(i,k);
		modify(i,j+1);
		ans = max(ans,j+1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 15140
#include <bits/stdc++.h>
/* Type alias */
using ll = long long;
using ld = long double;

using vec_i = std::vector<int>;
using vec_ll = std::vector<ll>;
using vec_ld = std::vector<ld>;

using set_i = std::set<int>;
using set_ll = std::set<ll>;
using set_ld = std::set<ld>;

using uset_i = std::unordered_set<int>;
using uset_ll = std::unordered_set<ll>;
using uset_ld = std::unordered_set<ld>;

/* IO macros */
#define in(i)            int i; std::cin >> i
#define in2(i, j)        int i, j; std::cin >> i >> j
#define in3(i, j, k)     int i, j, k; std::cin >> i >> j >> k
#define in_(i)           std::cin >> i
#define in2_(i, j)       std::cin >> i >> j
#define in3_(i, j, k)    std::cin >> i >> j >> k
#define in_ll(i)         ll i; std::cin >> i
#define in2_ll(i, j)     ll i, j; std::cin >> i >> j
#define in3_ll(i, j, k)  ll i, j, k; std::cin >> i >> j >> k
#define in_ll_(i)        std::cin >> i
#define in2_ll_(i, j)    std::cin >> i >> j
#define in3_ll_(i, j, k) std::cin >> i >> j >> k
#define in_ld(i)         ld i; std::cin >> i
#define in2_ld(i, j)     ld i, j; std::cin >> i >> j
#define in3_ld(i, j, k)  ld i, j, k; std::cin >> i >> j >> k
#define in_ld_(i)        std::cin >> i
#define in2_ld_(i, j)    std::cin >> i >> j
#define in3_ld_(i, j, k) std::cin >> i >> j >> k
#define in_c(i)          char i; std::cin >> i
#define in2_c(i, j)      char i, j; std::cin >> i >> j
#define in3_c(i, j, k)   char i, j, k; std::cin >> i >> j >> k
#define in_c_(i)         std::cin >> i
#define in2_c_(i, j)     std::cin >> i >> j
#define in3_c_(i, j, k)  std::cin >> i >> j >> k
#define in_str(s)        std::string s; std::cin >> s

#define vec_in(v, n)    auto v=vec_i(n); for(auto &x:v){std::cin>>x;}
#define vec_in_ll(v, n) auto v=vec_ll(n);for(auto &x:v){std::cin>>x;}
#define vec_in_ld(v, n) auto v=vec_ld(n);for(auto &x:v){std::cin>>x;}

#define print(x)   std::cout << x
#define println(x) std::cout << x << "\n"
#define print_fixed(x)   std::cout << std::fixed << x
#define println_fixed(x) std::cout << std::fixed << x << "\n"
#define print_vec(v) for (auto &x:v) { std::cout << x << " ";}
#define println_vec(v) for (auto &x:v) { std::cout << x << " ";} std::cout << "\n";
#define print_long_vec(v) for (auto &x:v) { std::cout << x << "\n";}
#define println_long_vec(v) for (auto &x:v) { std::cout << x << "\n";} std::cout << "\n";

/* Loops */
#define rep(i, n) for (auto i = 0; i < n; ++i)

/* Vector manipulation */
#define vec_sort(v) std::sort(v.begin(), v.end())

using namespace std;
/* Code Starts Here*/
int main () {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    in2(N, M);
    vec_in(H, N);
    vec_i A(N, 0);
    rep(i, M) {
        in2(a, b);
        a--; b--;
        A[a] = max(A[a], H[b]);
        A[b] = max(A[b], H[a]);
    }
    int ans = 0;
    rep(i, N) {
        ans += A[i] < H[i];
    }
    println(ans);
    return 0;
}


Measured memory_bytes: 3960
x=int(input())
if (x>=400 and x<=599):
  print("8")
elif (x>=600 and x<=799):
  print("7")
elif (x>=800 and x<=999):
  print("6")
elif (x>=1000 and x<=1199):
  print("5")
elif (x>=1200 and x<=1399):
  print("4")
elif (x>=1400 and x<=1599):
  print("3")
elif (x>=1600 and x<=1799):
  print("2")
elif (x>=1800 and x<=1999):
  print("1")

Measured memory_bytes: 8980
#include<stdio.h>
#include<stdlib.h>
int main(void){
  
  int n[100],m[100],N,M,X,Y,i,L,R;
  
  scanf("%d%d%d%d",&N,&M,&X,&Y);
  
  for(i=0;i<N;i++)scanf("%d",&n[i]);
  for(i=0;i<M;i++)scanf("%d",&m[i]);
  
  L=b_sort(n,N);
  R=s_sort(m,M);
  
  if(L<R){
    for(i=L+1;i<=R;i++){
      if(i>X&&i<Y){
        puts("No War");
        exit(0);
      }
    }
  }
  puts("War");
  return 0;
}

int b_sort(int a[], int n){
  int i,L=-100;
  for(i=0;i<n;i++)if(a[i]>L)L=a[i];
  return L;
}

int s_sort(int a[], int n){
  int i,L=100;
  for(i=0;i<n;i++)if(a[i]<L)L=a[i];
  return L;
}

Measured memory_bytes: 128
<?php
  
$a=fgets(STDIN);
$b=fgets(STDIN);
$a_array=str_split($a,1);
$b_array=str_split($b,1);
$result=0;
$str_int=strlen($a);
for($i=0;$i<=$str_int-1;$i++){
    if($a[$i]!==$b[$i]){
        $result++;
    }
}
echo $result;

Measured memory_bytes: 41440
#include<iostream>
#include<string>

using namespace std;
int main(){
   int k;
   string str;
   cin>>k>>str;
   int count=0;
   for(auto i=0;i<str.length()-2;i++){
      if(str.substr(i,3) == "ABC") count++;
   }
   cout<<count;
   return 0;
}

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

const int MOD = (int)1e9 + 7;
struct mint { int n; mint(int n=0):n(n){ } operator int(){return !!this->n;} };
mint operator+(mint a, mint b) { return (a.n += b.n) >= MOD ? a.n - MOD : a.n; }
mint operator-(mint a, mint b) { return (a.n -= b.n) < 0 ? a.n + MOD : a.n; }
mint operator*(mint a, mint b) { return 1LL * a.n * b.n % MOD; }
mint operator*(mint a, int b) { return 1LL * a.n * b % MOD; }
bool operator!=(mint a, mint b) { return a.n != b.n; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
ostream &operator<<(ostream &os, mint a) { return os << a.n; }

int main() {
    string s; cin >> s;
    int n = s.length();
    vector<vector<mint>> dp(n + 1, vector<mint>(2, 0));
    dp[0][1] = 1;
    for (int i = 0; i < n; i++) {
        dp[i + 1][0] += dp[i][0] * 3;
        if (s[i] == '0') {
            dp[i + 1][1] += dp[i][1];
        } else {
            dp[i + 1][0] += dp[i][1];
            dp[i + 1][1] += dp[i][1] * 2;
        }
    }
    cout << dp[n][0] + dp[n][1] << endl;
    return 0;
}

Measured memory_bytes: 5760
n,m=map(int,input().split())

a=[int(input()) for i in range(m)]

waru=1000000007

def Fib(n):
    a, b = 0, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b

ans=1
now=0
for i in range(m):
    ans*=Fib(a[i]-now+1)
    now=a[i]+1
ans*=Fib(n-now+2)
print(ans%waru)

Measured memory_bytes: 7080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  int n,m;
  cin>>n>>m;
  vector<int>a(m),b(m);
  rep(i,m)cin>>a[i]>>b[i];
  vector<int>c(n,0);
  rep(i,m){
  c[a[i]-1]++;
  c[b[i]-1]++;
  }
  rep(i,n)cout<<c[i]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ull unsigned long long int
#define ll long long int
#define vll vector<ll>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define itr vll::iterator
#define all(c) c.begin(),c.end()
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define inf 1000000000000000001
 
#define rep(i, n)      for(ll i = 0; i <  n; ++i)
#define repA(i, a, n)  for(ll i = a; i <= n; ++i)
#define repD(i, a, n)  for(ll i = a; i >= n; --i)
 
using namespace std;
 
bool func(const pll &a, const pll &b){
    return a.s < b.s;
}
 
ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return ((power(x, y / 2)%mod) * (power(x, y / 2)%mod)%mod); 
    else
        return (x * ((power(x, y / 2)%mod) * (power(x, y / 2)%mod)%mod))%mod; 
}
 
ll modInverse(ll a, ll m){
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1) return 0;
    while (a > 1){
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0) x += m0;
    return x;
} 

void solve(int t){
    char c;
    cin >> c;
    cout << (char)((int)c+1);
}
 
int main(){
 
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int t, tmp = 0;
    // cin >> t;
    t = 1;
    while(tmp++ < t){
        // cout << "Case #" << tmp << ": ";
        solve(tmp-1);
        if(t-tmp) cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
n = list(input())

ans=[]
b = 0
for i in n:
    if ord(i) == ord("A"):
        ans.append("X")
    elif ord(i) == ord("B"):
        ans.append("Y")
    elif ord(i) == ord("C"):
        ans.append("Z")
    else:
        b = chr(ord(i)-3)
        ans.append(b)

ans = [str(i) for i in ans]
ans = "".join(ans)
print(ans)


Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
const ll INF = (1LL<<60);
const int MOD = 1000000007;
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 n;
vector<int> a(3030);
vector<vector<ll> > dp(3030,vector<ll>(3030,0));
bool seen[3030][3030];

// [l, r)
ll rec(int l, int r){
    if(l>r) return 0;
    if(seen[l][r]) return dp[l][r];

    seen[l][r] = true;

    ll res = 0;
    int dif = n-(r-l+1);
    if(dif%2==0){
        res = -INF;
        chmax(res, rec(l+1,r) + a[l]);
        chmax(res, rec(l,r-1) + a[r]);
    }else{
        res = INF;
        chmin(res, rec(l+1,r) - a[l]);
        chmin(res, rec(l,r-1) - a[r]);
    }

    return dp[l][r]=res;
}

int main(){
    cin >> n;
    rep(i,n) cin >> a[i];
    rec(0,n-1);
    cout << dp[0][n-1] << endl;
}

Measured memory_bytes: 84200
#include<iostream>

using namespace std;

int main(){
  long long n,a,b;
  cin>>n>>a>>b;
  if((b-a)%2==0)
    cout<<(b-a)/2;
  else
  	cout<<min(a-1, n-b) + 1 + (b-a-1)/2;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	while(cin>>n,n){
		int out[10]={0};
		rep(i,n){
			int in;
			cin>>in;
			out[in]++;
		}
		rep(i,10){
			if(out[i])rep(j,out[i])cout<<"*";
			else cout<<"-";
			cout<<endl;
		}
	}
}

Measured memory_bytes: 1152
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#define fi first
#define sec second
using namespace std;
typedef pair<int,int> P;

int n;
vector<int> v;
int a[100000000], b[4];

int pow(int x){
	int ret = 1;
	for(int i = 0; i < x; i++) ret *= 10;
	return ret;
}

int rank(int x){
	int ret = 1;
	for(int i = 0;;i++){
		x/=10;
		if(x == 0) break;
		ret++;
	}
	return ret;
}

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	sort(a,a+n);
	if(n == 3){
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				if(i == j) continue;
				v.push_back(a[i]*pow(rank(a[j]))+a[j]);
			}
		}
		sort(v.begin(),v.end());
		printf("%d\n", v[2]);
	} else{
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 4; j++){
				if(i == j) continue;
				v.push_back(a[i]*pow(rank(a[j]))+a[j]);
			}
		}
		sort(v.begin(),v.end());
		printf("%d\n", v[2]);
	}
}

Measured memory_bytes: 1084
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class ASharingCookies {
public:
	void solve(istream& in, ostream& out) {
        int a, b; in >> a >> b;
        if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) out << "Possible" << endl;
        else out << "Impossible" << endl;
	}
};

int main() {
	ASharingCookies solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;



public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int d = scanner.nextInt();
    double d_d = d;
    int[] x = new int[n];
    int[] y = new int[n];
    int ans = 0;

    for(int i = 0; i< n; i++){
      x[i] = scanner.nextInt();
      y[i] = scanner.nextInt();
    }

    for(int i = 0; i< n; i++){
      if(Math.sqrt(Math.pow(Long.valueOf(x[i]),2) + Math.pow(Long.valueOf(y[i]),2)) <= d_d){
        ans += 1;
      }
    }

    System.out.println(ans);
    
    
    scanner.close();
    return;
  }
  
}


Measured memory_bytes: 62372
#include <stdio.h>
#define MAX 500000
#define SENTINEL 2000000000
int L[MAX/2+2],R[MAX/2+2];
int count;
void merge(int[],int,int,int,int);
void mergeSort(int[],int,int,int);
int main(){
  int A[MAX],n,i;
  count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  mergeSort(A,n,0,n);
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i==n-1){
      printf("\n");
      break;
    }
    printf(" ");
  }
  printf("%d\n",count);
  return 0;
}
void merge(int A[],int n,int left,int mid,int right){
  int i,j,k,n1,n2;
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++)
    L[i]=A[left+i];
  for(j=0;j<n2;j++)
    R[j]=A[mid+j];
  L[n1]=SENTINEL;
  R[n2]=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    count++;
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
    }else{
      A[k]=R[j];
      j=j+1;
    }
  }
}
void mergeSort(int A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left + right)/2;
   mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}



Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
#define pb emplace_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=998244353;

int32_t main(){
	int n;
	cin>>n;
	cout<<3*n*n<<endl;	
}

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

const int maxn = 1e5 + 6;
int dp[maxn];
vector <int> adj[maxn];
bitset <maxn> mark;

void dfs(int v) {
	mark[v] = true;
	for (auto u: adj[v]) {
		if (!mark[u])
			dfs(u);
		dp[v] = max(dp[v], dp[u] + 1);
	}
//	cout << v << ' ' << dp[v] << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int v, u;
		cin >> v >> u;
		v --;
		u --;
		adj[v].push_back(u);
	}
	for (int i = 0; i < n; i++) {
		if (!mark[i])
			dfs(i);
	}
	cout << *(max_element(dp, dp + n));
}


Measured memory_bytes: 8192
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
	public static void main(String[] args) {  
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		String S = I.next();
		int N = S.length();
		int ans = 0;
		StringBuilder cur = new StringBuilder();
		StringBuilder next = new StringBuilder();
		cur.append(S.charAt(0));
		for (int i = 1; i<N; i++) {
			next.append(S.charAt(i));
			if (S.charAt(i)!=cur.charAt(0)||next.length()==2||cur.length()==2) {
				ans++;
				cur=new StringBuilder();
				cur.append(next);
				next=new StringBuilder();
			}
		}
		ans++; //Last ever partition
		O.pln(ans);
	}
	public static long min(long a, long b) {return Math.min(a,b);}
	public static long max(long a, long b) {return Math.max(a,b);}
	public static int min(int a, int b) {return Math.min(a,b);}
	public static int max(int a, int b) {return Math.max(a,b);}
	public static long abs(long x, long y) {return Math.abs(x-y);}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return max(a,b);
		return GCD(max(a,b),max(a,b)%min(a,b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}

Measured memory_bytes: 45016
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#else
#define VS_ENDPAUSE()
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
	func();
	VS_ENDPAUSE();
	return 0;
}


void func(void)
{
	int n;
	string s;
	cin >> n;

	char tmpStr[300];
	scanf("%s", tmpStr);

	const int o = 1;
	const int c = 2;
	const int t = 0;
	int searchS[300];
	for(int i=0; i<n; i++){
		searchS[i] = -1;
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(tmpStr[j] == '(' && searchS[j] == -1){
				for(int k=j+1; k<n; k++){
					if(searchS[k]!=-1){
						continue;
					}
					if(tmpStr[k] == ')'){
						searchS[j] = t;
						searchS[k] = t;
						break;
					}else{
						break;
					}
				}
			}
		}
	}

	int cntOpenBlacket = 0;
	int cntCloseBlacket = 0;
	for(int i=0; i<n; i++){
		if(searchS[i] == -1){
			if(tmpStr[i] == '('){
				cntOpenBlacket++;
			}else{
				cntCloseBlacket++;
			}
		}
	}
	for(int i=0; i<cntCloseBlacket; i++){
		cout << "(";
	}
	for(int i=0; i<n; i++){
		cout << tmpStr[i];
	}
	for(int i=0; i<cntOpenBlacket; i++){
		cout << ")";
	}
	cout << endl;

	return;
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main(void){
  int n,m,c;
  vector <int> a,b;
  int i,j,k=0;
  int ans=0,sum=0;
  
  cin>>n>>m>>c;
  for(i=0;i<m;i++){
    a.push_back(0);
  }
  for(i=0;i<m;i++){
    cin>>j;
    b.push_back(j);
  }
  for(i=0;i<n;i++){
    ans=0;
    for(j=0;j<m;j++){
      cin>>k;
      a[j]=k;
    }
    for(j=0;j<m;j++){
      ans+=a[j]*b[j];
    }
    ans+=c;
    if(ans>0)
       sum++;
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner
var out *bufio.Writer

func main() {
	sc = bufio.NewScanner(os.Stdin)
	//bytes, _ := ioutil.ReadFile("./stdin.txt")
	//sc = bufio.NewScanner(strings.NewReader(string(bytes)))
	out = bufio.NewWriter(os.Stdout)
	buf := make([]byte, 1<<20)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	n := nextInt()

	nums := f(0, digit(n))
	result := 0
	for i := 0; i < len(nums); i++ {
		if nums[i] < 300 || nums[i] > n {
			continue
		}
		ok3, ok5, ok7 := false, false, false
		for nums[i] > 0 {
			switch nums[i] % 10 {
			case 3:
				ok3 = true
			case 5:
				ok5 = true
			case 7:
				ok7 = true
			}
			nums[i] /= 10
		}
		if ok3 && ok5 && ok7 {
			result++
		}
	}

	fmt.Fprintln(out, result)
}

func digit(n int) int {
	ret := 1
	for n > 0 {
		ret++
		n /= 10
	}
	return ret
}

func f(n, d int) []int {
	nn := make([]int, 3)
	for i, b := range []int{3, 5, 7} {
		nn[i] = n*10 + b
	}
	if digit(nn[0]) == d {
		return nn
	}
	return append(nn, append(f(nn[0], d), append(f(nn[1], d), f(nn[2], d)...)...)...)
}

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func intMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}
func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 5336
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]

x, y = map(int, input().split())

if (x in A and y in A) or (x in B and y in B) or (x in C and y in C):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
k = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
puts k[gets.to_i-1]


Measured memory_bytes: 1788
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  vector<int> H(N + 1);

  for (int i = 1; i < N + 1; i++) {
    cin >> H[i];
  }

  int ans = 1;
  int max = H[1];

  for (int i = 2; i < N + 1; i++) {
    if (H[i] >= max) {
      max = H[i];
      ans++;
    }
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,i,j,k,l,m,n,ans,tmp,hoge,fuga,piyo;
ll x[200100],y[200100],z[200100];
string s,str;
int main(){
  cin>>a;
  b=100;
  while(b<a){
    b+=b/100;
    ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int A[101] = {0};

void showA(int A[], int N) {
	int i;
	for (i = 0; i < N; ++i) {
		printf("%d ", A[i]);
	}
	printf("\n");
	return;
}

int SelectionSort(int A[], int N) {
	int i, j, tmp, minj;
	int cnt=0;
	
	for (i = 0; i < N; ++i) {
//		showA(A, N);
		minj = i;
		for (j = i; j < N; ++j) {
			if (A[j] < A[minj]) {
				minj = j;
			}
		}
		if (i != minj) {
			tmp = A[i];
			A[i] = A[minj];
			A[minj] = tmp;
			cnt++;
		}
	}
	return cnt;
}

int main(void) {
	int n, i, cnt;
	scanf("%d", &n);
	
	for (i = 0; i < n; ++i) {
		scanf("%d", &A[i]);
	}
	cnt = SelectionSort(A, n);
	
	for (i = 0; i < n; ++i) {
		if (i != n - 1) {
			printf("%d ", A[i]);
		} else {
			printf("%d\n", A[i]);
		}
	}
	printf("%d\n", cnt);
	
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int get(int64_t k){
    int cnt=0;
    for(int64_t i=1;i<100000000000;i*=10){
      if(k>=i)cnt++;
      else break;
    }
  return cnt;
}
int main(){
  int64_t n;
  cin >> n;
  int64_t ans=get(n);
  for(int64_t i=1;i<=sqrt(n);i++){
    if(n%i==0){
      int64_t j=n/i;
      int k=max(get(i),get(j));
      if(k<ans)ans=k;
    }
  }
  cout << ans << endl;
}
     


Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	double t=3.1415926,s;
	cin>>s;
	s=s*t*2.0;
	cout<<s<<'\n';
	RE 0;
}




Measured memory_bytes: 3800
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll n,k; cin >> n >> k;
  ll t = 0;
  while(true){
    if(pow(k,t) <= n && n < pow(k,t+1)){
      t++;
      break;
    }
    else t++;
  }
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 256