akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try{
	    int m, d;
	    while(true){
		String day;
		String[] st = sc.readLine().split(" ");
		m = Integer.valueOf(st[0]);
		d = Integer.valueOf(st[1]);
		if(m==0 && d==0)
		    break;
		if(m>1){
		    d+=31;
		    if(m>2){
			d+=29;
			if(m>3){
			    d+=31;
			    if(m>4){
				d+=30;
				if(m>5){
				    d+=31;
				    if(m>6){
					d+=30;
					if(m>7){
					    d+=31;
					    if(m>8){
						d+=31;
						if(m>9){
						    d+=30;
						    if(m>10){
							d+=31;
							if(m>11)
							    d+=30;
						    }}}}}}}}}}
		if(d%7==1)
		    day="Thursday";
		else if(d%7==2)
		    day="Friday";
		else if(d%7==3)
		    day="Saturday";
		else if(d%7==4)
		    day="Sunday";
		else if(d%7==5)
		    day="Monday";
		else if(d%7==6)
		    day="Tuesday";
		else
		    day="Wednesday";
		System.out.println(day);
	    }
	}catch (Exception e){
	    System.out.println("Error");
	}
    }
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  int x[3] = {a,b,c};
  sort(x, x+3);
  
  int parity = (x[2] - x[0]) % 2 + (x[2] - x[1]) % 2;
  int res;
    
  switch (parity) {
    case 0:
      res = 0;
      break;
    case 1:
      res = 2;
      break;
    case 2:
      res = 1;
      break;
  }
  cout << (x[2] - x[0]) / 2 + (x[2] - x[1]) / 2 + res << endl;
}

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

int x[200005];
int x2[200005];
long long xsm[200005];
long long x2sm[200005];
int main() {
	int L, N;
	scanf("%d %d", &L, &N);
	for (int i = 0; i < N; i++) scanf("%d", x + i);
	for (int i = 0; i < N; i++) {
		x2[i] = L - x[N - 1 - i];
		xsm[i] = x[i];
		x2sm[i] = x2[i];
		if (i) {
			xsm[i] += xsm[i - 1];
			x2sm[i] += x2sm[i - 1];
		}
	}
	long long mx = 0;
	for (int i = 0; 2 * i <= N; i++) {
		int l = i;
		int r = N - i;
		int extra = r - l;
		long long ans = 0;
		long long ll = 0;
		int left = 0;
		if (l) {
			ll = 2 * x2sm[l - 1];
			left = x2[l - 1];
		}
		long long rr = 2 * xsm[r - 1];
		long long ex = 0;
		if (extra) {
			rr -= 2*xsm[extra - 1];
			ex = x[extra-1];
		}
		ans = ex + ll + rr;
		if (i)
			ans -= min(x[r - 1] - ex, left + ex);
		mx = max(mx, ans);
	}
	for (int i = 0; i < N; i++) {
		swap(x[i], x2[i]);
		swap(xsm[i], x2sm[i]);
	}
	for (int i = 0; 2 * i <= N; i++) {
			int l = i;
			int r = N - i;
			int extra = r - l;
			long long ans = 0;
			long long ll = 0;
			int left = 0;
			if (l) {
				ll = 2 * x2sm[l - 1];
				left = x2[l - 1];
			}
			long long rr = 2 * xsm[r - 1];
			long long ex = 0;
			if (extra) {
				rr -= 2*xsm[extra - 1];
				ex = x[extra-1];
			}
			ans = ex + ll + rr;
			if (i)
				ans -= min(x[r - 1] - ex, left + ex);
			mx = max(mx, ans);
		}
	printf("%lld\n", mx);
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

#define ll long long
#define ldb long double
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(i,a,b) for (int i = (a); i < (b); ++i)
#define rrof(i,a,b) for (int i = (b)-1; i >= (a); --i)


ll int MOD = 1e9+7;
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n){
	ll res=1;

	while(n){
		if(n%2)
		res*=a;
		a*=a;
		n/=2;
	}
	
	return res;
}

ll int h=pow(10,6);

int main(){
	fast;
	
	char c;
	cin>>c;
	
	char s='a'+(((c-'a')+1)%26);
	cout<<s;
	return 0;
}


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

int main(){
    int H,W,A,B;
    cin >> H >> W >> A >> B;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if((i<B && j<A) || (B<=i && A<=j)) cout << 1;
            else cout << 0;
        }
        cout << endl;
    }
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;
const int maxn = 1e6 + 10;

class UnionFind {
private:
    vector<int> par;
public:
    UnionFind(int n) : par(n + 1) {
        for (int i = 1; i <= n; ++i) {
            par[i] = i;
        }
    }

    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }

    void unite(int x, int y) {
        int rx = find(x);
        int ry = find(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = find(x);
        int ry = find(y);
        return rx == ry;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> nums(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> nums[i];
    }
    UnionFind tree(n);
    int xi, yi;
    for (int i = 1; i <= m; ++i) {
        cin >> xi >> yi;
        tree.unite(xi, yi);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (tree.same(i, nums[i])) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();


Measured memory_bytes: 1024
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<lint,lint> pl;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint gcd( lint m, lint n )
{
	lint a=max(m,n),b=min(m,n);
	if(m==0) return n;if(n==0) return m;
	if(a%b==0) return b;
	return gcd(b,a-b*(a/b));
}
lint mo=1000000007;
lint zyo(lint x,lint y){
    lint ret=1,a=x;
    while(y>0){
    	if(y%2==1) ret=(ret*a)%mo;
    	a=(a*a)%mo;y/=2;
    }
    return ret;
}
map<pl,pint> me;
int main()
{
	int n,z=0;lint a,b;
	cin>>n;
	rep(i,n){
		cin>>a>>b;
		if(a<0L) a*=-1,b*=-1;
		if(a==0L && b<0) b*=-1;
		if(a==0L && b==0L){
			z++;continue;
		}
		lint g=gcd(abs(a),abs(b));
		a/=g;b/=g;
		if(me[mp(a,b)].fi>0) me[mp(a,b)].fi++;
		else if(me[mp(-b,a)].fi>0) me[mp(-b,a)].se++;
		else if(me[mp(b,-a)].fi>0) me[mp(b,-a)].se++;
		else me[mp(a,b)].fi++;
	}
	lint out=1;
	map<pl,pint>::iterator it=me.begin();
	while(it!=me.end()){
		out*=(zyo(2,(*it).se.fi)+zyo(2,(*it).se.se)-1);out%=mo;
		it++;
	}
	out-=1;out+=z;out%=mo;out+=mo;out%=mo;
	cout<<out<<endl;
}


Measured memory_bytes: 40952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

const int n_max=5e3+1;
int dp[n_max][n_max];

int f(int l, int r, const string &s){
  if(dp[l][r]!=-1) return dp[l][r];
  if(s[l]==s[r]){
    dp[l][r]=min(f(l+1, r+1, s)+1, r-l);
    return dp[l][r];
  }
  else return 0;
}

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

  int n;
  cin >> n;
  string s;
  cin >>s;

  rep(i,n)rep(j,n) dp[i][j]=-1;
  int ans=0;
  rep(i,n){
    for(int j=i+1; j<n;j++){
      ans=max(ans,f(i,j,s));
    }
  }

  cout << ans << endl;
  return 0;
    

}


Measured memory_bytes: 98048
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int a[100][100][4];
int h, w;

bool isin(int i, int j){
    return i >= 0 && j >= 0 && i < h && j < w;
}

int main() {
    ll l;
    while (cin >> h >> w >> l && h){
        vector<string> s(h);
        REP(i,h) cin >> s[i];
        int si, sj, dir;
        REP(i,h) REP(j,w){
            if (s[i][j] != '.' && s[i][j] != '#'){
                si = i;
                sj = j;
                if (s[i][j] == 'E') dir = 0;
                if (s[i][j] == 'S') dir = 1;
                if (s[i][j] == 'W') dir = 2;
                if (s[i][j] == 'N') dir = 3;
            }
        }
        REP(i,h) REP(j,w) REP(k,4) a[i][j][k] = -1;
        a[si][sj][dir] = 0;
        int i = si, j = sj, x = 0;
        int di[] = {0,1,0,-1}, dj[] = {1,0,-1,0};
        while (1){
            int ii = i + di[dir], jj = j + dj[dir];
            if (!isin(ii,jj) || s[ii][jj] == '#'){
                dir = (dir + 1) % 4;
                continue;
            }
            i = ii, j = jj, x++;
            if (a[i][j][dir] >= 0) break;
            a[i][j][dir] = x;
            if (x == l) break;
        }
        string c = "ESWN";
        if (a[i][j][dir] == l){
            printf("%d %d %c\n", i+1, j+1, c[dir]);
        }else{
            int p = a[i][j][dir];
            l = (l - p) % (x - p) + p;
            REP(i,h) REP(j,w) REP(k,4){
                if (a[i][j][k] == l){
                    printf("%d %d %c\n", i+1, j+1, c[k]);
                    i = h, j = w, k = 4;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3332
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
    int H,W;
    cin>>H>>W;
    vector<string> data(H);
    for (int i=0;i<H;i++){
            cin>>data[i];

    }
    queue <vector<int>> d_queue;
    int count =0;
    int ans =0;

    for (int k=0;k<H;k++){
        for (int l=0;l<W;l++){
            if (data[k].at(l) == '#'){
                d_queue.push({k,l,count});
            }

        }
    }

    vector<vector<int>> move = {
            {0,  1},
            {1,  0},
            {-1, 0},
            {0,  -1},
    };
    vector<int> temp_vec(3);
    while (!d_queue.empty()){
        temp_vec = d_queue.front();
        d_queue.pop();
        for (int c=0;c<4;c++){
            int a,b;
            a=move[c][0];
            b=move[c][1];

            if (0 <= temp_vec[0]+a && temp_vec[0]+a < H && 0 <= temp_vec[1]+b && temp_vec[1]+b < W){
                if (data[temp_vec[0]+a][temp_vec[1]+b]== '.'){
                    d_queue.push({temp_vec[0]+a,temp_vec[1]+b,temp_vec[2]+1});
                    ans = max(ans,temp_vec[2]+1);
                    data[temp_vec[0]+a][temp_vec[1]+b] = '#';
                }
            }
        }

    }
    cout<<ans<<endl;


}


Measured memory_bytes: 56756
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);    

    ll x;
    cin>>x;
    if(x>=30){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }

    return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> L(M),R(M);
  int maxL,minR;
  cin >> L.at(0) >> R.at(0);
  maxL=L.at(0);
  minR=R.at(0);
  for(int i=1;i<M;i++){
    cin >> L.at(i) >> R.at(i);
    maxL=max(maxL,L.at(i));
    minR=min(minR,R.at(i));
  }
  int ans=0;
  for(int i=1;i<=N;i++){
    if((i>=maxL)&&(i<=minR)){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

ll n, dp[100010][5], a[100010][3];

ll solve(int pos, int pre){
  if(pos == n) return 0;
  ll &r = dp[pos][pre];
  if(r >= 0) return r;
  fore(i,0,3) if(pre != i) r = max(r, a[pos][i]+solve(pos+1,i));
  return r;
}

int main(){FIN;
  memset(dp,-1,sizeof(dp));
  cin >> n;
  fore(i,0,n) fore(j,0,3) cin >> a[i][j];
  cout << solve(0,4) << "\n";
}

Measured memory_bytes: 14336
class SlotMachine:
    def __init__(self, reel_num, A, B, C):
        self.reel_num = reel_num
        self.A = A
        self.B = B
        self.C = C
    def calculate_random_num(self, random_num):
        random_num = (self.A * random_num + self.B) % self.C
        # print("random_num", random_num) # debug
        return random_num

    def count_flame(self, condition_list, random_num) :
        flame_num = 0
        order = 0
        while order < len(condition_list):
            order, flame_num, random_num = self.check_condition(condition_list, random_num, order, flame_num)
            if flame_num > 10001:
                flame_num = -1
                return flame_num
        return flame_num - 1

    def check_condition(self, condition_list, random_num, order, flame_num):
        if random_num == condition_list[order]:
            order += 1
        random_num = self.calculate_random_num(random_num)
        flame_num += 1
        # print("flame_num", flame_num) # debug
        return order, flame_num, random_num




def get_data_list():
    data_list = input().split()
    for i in range(len(data_list)):
        data_list[i] = int(data_list[i])
    return data_list


if __name__ == "__main__":
    while True:
        data_list = get_data_list()
        # print("data_list", data_list) # debug
        reel_num = data_list[0]
        A = data_list[1]
        B = data_list[2]
        C = data_list[3]
        first_num = data_list[4]
        if reel_num == 0:
            break
        condition_list = get_data_list()
        slot_machine = SlotMachine(reel_num, A, B, C)
        flame_num = slot_machine.count_flame(condition_list, first_num)
        # print("ans", flame_num) # debug
        print(flame_num)




Measured memory_bytes: 5620
n, k = gets.split(" ").map{|v|v.to_i}
data = gets.split(" ").map{|v|v.to_i}

def p1(i, l, r, s)
  lm = l % s
  ld = l / s
  ld += 1 if lm != 0
  r -= ((s - lm) % s)
  rm = r % s
  rd = r / s
  rd += 1 if rm != 0
  return ld + rd
end

i = data.index(1)
l = i
r = n - i - 1
s = k - 1

puts p1(i, l, r, s)


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


int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans=0;
  for(int i=1;i<n;++i){
    vector<int> mae(26);
    int c=0;
    
    for(int j=0;j<i;++j){
      mae[s[j]-'a']++;
    }
    for(int j=i;j<n;++j){
      if(mae[s[j]-'a']>0){
        c++;
        mae[s[j]-'a']=0;
      }
    }
    ans=max(ans,c);
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
	string s;
	getline( cin, s );
	stack<int> st;
	int num = 0;
	for( int i = 0; i < s.size(); i++ ) {
		if( s[i] == '+' ) {
			int a = st.top();
			st.pop();
			int b = st.top();
			st.pop();
			st.push( a + b );
			i++;
		}
		else if( s[i] == '-' ) {
			int a = st.top();
			st.pop();
			int b = st.top();
			st.pop();
			st.push( b - a );
			i++;
		}
		else if( s[i] == '*' ) {
			int a = st.top();
			st.pop();
			int b = st.top();
			st.pop();
			st.push( a * b );
			i++;
		}
		else if( '0' <= s[i] && s[i] <= '9' ) {
			num = num * 10 + s[i] - '0';
		}
		else if( s[i] == ' ' ) {
			st.push( num );
			num = 0;
		}
	}

	cout << st.top() << endl;
}



Measured memory_bytes: 3212
#include<stdio.h>
#include<string.h>
int main(){
  char word[1111];
  int a,i;
  gets(word);
  a = strlen(word);
  for(i=0;i<a;i++){
    if(word[i] <= 122 && word[i] >= 97){
      word[i] -= 32;
    }
  }
  for(i=0;i<a;i++){
    printf("%c",word[i]);
    if(i == a-1){
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 524
// finish date: 2018/03/25

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int N;
    cin >> N;
    vi A(N + 2, 0);
    FOR(i, 1, N + 1) cin >> A[i];
    ll cost = 0;
    rep(i, A.size()-1) {
        cost += abs(A[i + 1] - A[i]);
    }
    FOR(i, 1, N + 1) {
        cout << cost - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]) << endl;
    }


    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define debug(val) "[ " << #val " : " << (val) << " ]\n"
#define space " "
#define space " "
#define vi vector<int>
#define PI atan(1)*4
#define pb push_back
#define ff first
#define ss second
#define PI atan(1)*4

const int maxN = (int)1e5 +3;
vi g[maxN] ;
int in[maxN] ;
int dp[maxN] ;
bool vis[maxN] ;
void dfs(int v){
    vis[v] = 1 ;
    for(auto adj : g[v]){
        dp[adj] = max(dp[adj] , 1 + dp[v]) ;
        --in[adj] ;
        if(in[adj] == 0 ) {
            dfs(adj);
        }
    }
}
void solve() {
    int n , m ;
    cin >> n >>m ;
    for(int i=0;i<n;i++) {
        in[i] = 0 ;
        vis[i] = 0 ;
        dp[i] =  0;
    }
    for(int i=0;i<m;i++){
        int a ,b;
        cin >> a >>b ;
        a--;b-- ;
        g[a].pb(b) ;
        in[b]++ ;
    }
    int res = 0;
    for(int i=0;i<n;i++){
       if(in[i] == 0 && !vis[i]) dfs(i) ;
    }
    for(int i=0;i<n;i++){
        //cerr << dp[i] << space ;
        res = max(res ,dp[i] ) ;
    }
   // cerr << endl;
    cout <<  res << endl;

}
int main() {
#ifdef _DEBUG // place in cmake-build-debug folder
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int q = 1;
    //cin >> q;
    for (int i = 1; i <= q; i++) {
        // cout << "Case #" << i << ": ";
        solve();
    }
}


Measured memory_bytes: 14596
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	int R;
	cin >> R;

	string ret;
	if(R < 1200)
		ret = "ABC";
	else if(R < 2800)
		ret = "ARC";
	else
		ret = "AGC";

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int s;
  cin>>s;
  vector<int> number(1000000);
  map<int, int> collatz;
  number.at(0)=s;
  collatz[s]=1;
  for(int i=1; i<=1000000; i++){
    if(number.at(i-1)%2==0){
      number.at(i)=number.at(i-1)/2;
    }
    else if(number.at(i-1)%2==1){
      number.at(i)=3*number.at(i-1)+1;
    }
    if(collatz.count(number.at(i))){
      cout<<i+1<<endl;
      break;
    }
    else{
      collatz[number.at(i)]=1;
    }
}
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int r, g, b;
    cin >> r >> g >> b;

    int n;
    n = 100*r + 10*g + b;

    if(n % 4 == 0)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     PI                       acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=300000+5,mod=1e9+7;
int a[N];
ll arr[N];
ll rng(int a,int b){
  return arr[b]-(a?arr[a-1]:0);
}
int main(){
    GO();

    int T;
   // cin>>T;
   T=1;
    while(T--){

       int n;
       cin>>n;
       ll sum=0;
       for(int i=0;i<n;i++) cin>>a[i],sum+=a[i],arr[i]=sum;
       ll ans=0;
       for(int i=0;i<n;i++){
         ans=(ans+(rng(i+1,n-1)%mod*a[i])%mod)%mod;
       }
       cout<<ans<<"\n";
    }

}





































































Measured memory_bytes: 5964
#include <stdio.h>
#include <string.h>
 
int main(){
  int i,flag=0,acount=0,bcount=0;
  char s[100000];
  scanf("%s",s);
 
  //printf("%d",strlen(s));
 
    for(i=0;i<strlen(s);i++){
      if(flag == 0){
        if(s[i]=='0') acount++;
        else bcount++;
        flag=1;
      }
      else{
        if(s[i]=='1') acount++;
        else bcount++;
        flag=0;
      }
    }
 
    if(acount>bcount) printf("%d",strlen(s)-acount);
    else printf("%d",strlen(s)-bcount);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lsb(x) (x & (-x)) 

using namespace std;


int main() {
	//ifstream cin("A.in");
	//ofstream cout("A.out");
	int i, j, n, k;
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	
	cin >> n >> k;
	
	if(k > (n - 1) * (n - 2) / 2) {
		cout << -1;
		return 0;
	}

	vector < pair <int, int> > sol;
	for(i = 1; i <= n - 1; i++) {
		sol.push_back({i, n});
	}
	
	for(i = 1; i < n; i++) {
		for(j = i + 1; j < n; j++) {
			if(k < (n - 1) * (n - 2) / 2) {
				k++;
				sol.push_back({i, j});
			}
		}
	}

	cout << sol.size() << "\n";
	for(auto it : sol) {
		cout << it.first << " " << it.second << "\n";
	}
	
	return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<cmath>
#include<climits>

using namespace std;

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

int main(){

    long N;
    cin >> N;

    vector<vector<long>> X(N+1,vector<long>(3,0));
    for(int i = 0;i < N;i++){
        for(int j = 0; j < 3; j++){
            cin >> X[i][j];
        }
    }
    

    vector<vector<long>> dp(N+1,vector<long>(3,0));
    for(int i = 0 ; i < N;i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(j == k) continue;
              
                chmax(dp[i+1][k],dp[i][j] + X[i][k]);
            }
        }
    }

    long res = 0;
    for(int j = 0; j < 3; j++) chmax(res,dp[N][j]);

    cout << res;

    return 0;

}

Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <map>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    string s; cin >> s;
    vector<int> ans((int)s.size(), 0);
    vector<pair<int, int>> v;
    int lc = 0, rc = 0;
    for(int i = 0; i < s.size(); i++)
    {
        
        if(i + 1 < s.size() && s[i] == 'R' && s[i + 1] == 'L')
        {
            ans[i] = 1;
            ans[i + 1] = -1;
        }

        if (s[i] == 'L')
            lc++;
        else
            rc++;

        if (i + 1 < s.size() && s[i] == 'L' && s[i + 1] == 'R')
        {
            v.push_back(make_pair(lc, rc));
            lc = rc = 0;
        }
    }
    v.push_back(make_pair(lc, rc));
    for(int i = 0; i < v.size(); i++)
    {
        int l = v[i].first;
        int r = v[i].second;
        v[i].first = (l + 1) / 2 + r / 2;
        v[i].second = l / 2 + (r + 1) / 2;
    }

    int pos = 0;
    for(int i = 0; i < ans.size(); i++)
    {
        if(ans[i] == 1)
        {
            ans[i] = v[pos].second;
        }
        if(ans[i] == -1)
        {
            ans[i] = v[pos].first;
            pos++;
        }
    }
    cout << ans << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 1480
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MAXN = 310000;

int n;
ll a[MAXN];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	if (n % 2 == 0) {
		ll x = 0;
		ll y = 0;
		for (int i = 0; i < n; ++i)
			if (i % 2 == 0)
				x += a[i];
			else
				y += a[i];
		cout << max(x, y) << " " << min(x, y) << "\n";
		return 0;
	}
	ll base = 0;
	ll sum = 0;
	for (int i = 0; i < n; ++i) {
		sum += a[i];
		if (i % 2 == 0)
			base -= a[i];
		else
			base += a[i];
	}
	ll l = max(0ll, -base * 2);
	ll r = 1e9;
	while (r - l > 1) {
		ll mid = (l + r) >> 1;
		set<ll> ss;
		ss.insert(0);
		ll cur = 2 * a[0];
		int fl = 0;
		for (int i = 0; i < n; i += 2) {
			if (i > 0)
				cur -= a[i - 1] * 2, cur += 2 * a[i];
			if (cur - *ss.begin() >= mid) {
				if (i == n - 1)
					fl = 1;
				else {
					ss.insert(cur - 2 * a[i + 1]);
				}
			}
		}
		if (fl)
			l = mid;
		else
			r = mid;
	}
	ll diff = base + l;
	cout << (sum + diff) / 2 << " " << (sum - diff) / 2 << "\n";
	return 0;
}




Measured memory_bytes: 9600
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int inf = 1e9;

int main(void) {
  int N;
  scanf("%d", &N);
  vector<bool> c(2*N);
  vector<int> a(2*N);
  REP(i, 2*N) {
    static char buff[5];
    scanf("%s %d", buff, &a[i]);
    --a[i];
    c[i] = buff[0] == 'W';
  }

  vector<int> pos_0(N), pos_1(N);
  REP(i, 2*N) {
    if (c[i]) {
      pos_1[a[i]] = i;
    } else {
      pos_0[a[i]] = i;
    }
  }

  vector<int> right_00(N), right_11(N);
  vector<vector<int>> right_01(N, vector<int>(N+1)), right_10(N, vector<int>(N+1));

  REP(i, 2*N) {
    FOR(j, i+1, 2*N) {
      if (c[i] == 0) {
        if (c[j] == 0) {
          if (a[j] < a[i]) right_00[a[i]]++;
        } else {
          right_01[a[i]][a[j]+1]++;
        }
      } else {
        if (c[j] == 1) {
          if (a[j] < a[i]) right_11[a[i]]++;
        } else {
          right_10[a[i]][a[j]+1]++;
        }
      }
    }
  }

  REP(i, N) {
    FOR(j, 1, N+1) {
      right_01[i][j] += right_01[i][j-1];
      right_10[i][j] += right_10[i][j-1];
    }
  }

  vector<vector<int>> f(N+1, vector<int>(N+1, inf));
  f[0][0] = 0;

  REP(i, N+1) REP(j, N+1) {
    if (i < N) {
      int npos = pos_0[i] + right_00[i] + right_01[i][j];
      assert(npos >= i + j);
      f[i+1][j] = min(f[i+1][j], npos - (i + j) + f[i][j]);
    }
    if (j < N) {
      int npos = pos_1[j] + right_11[j] + right_10[j][i];
      assert(npos >= i + j);
      f[i][j+1] = min(f[i][j+1], npos - (i + j) + f[i][j]);
    }
  }

  printf("%d\n", f[N][N]);
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  
  vector<tuple<string, int, int>> v(n);
  
  for(int i = 0; i < n; i++){
    string a;
    int b;
    cin >> a >> b;
    v.at(i) = make_tuple(a,(-1)*b,i+1);
  }
  
  sort(v.begin(), v.end());

  for(int i = 0; i < n; i++){
    int a;
    tie(ignore, ignore, a) = v.at(i);
    cout << a << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main(){
	int N,D,ans=0,k=0;
	cin>>N>>D;
	int x[N][D];
	for(int j=0;j<N;j++){
		for(int i=0;i<D;i++){
			cin>>x[j][i];
		} 
	}
	for(int a=0;a<N;a++){
		for(int i=a+1;i<N;i++){
			for(int j=0;j<D;j++){
				k=k+abs(x[a][j]-x[i][j])*abs(x[a][j]-x[i][j]);
			}
			if(sqrt(k)-int(sqrt(k))==0){
				ans++;
			}
			k=0;	
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef complex<double> Point;
typedef Point Vector;
typedef pair<Point, Point> Segment;
typedef Segment Line;
constexpr double EPS = (1e-9L);
enum CCW { ONLINE_FRONT = -2, CLOCKWISE, ON_SEGMENT, COUNTER_CLOCKWISE, ONLINE_BACK };
double dot(const Point& p1, const Point& p2) { return (conj(p1) * p2).real(); }
double cross(const Point& p1, const Point& p2) { return (conj(p1) * p2).imag(); }
constexpr bool eq(double a) { return abs(a) < EPS; }
Point project(Segment s, Point p) {
	Vector base = s.fi - s.se;
	double r = dot(p - s.fi, base) / norm(base);
	return s.fi + base * r;
}
Point reflect(Segment s, Point p) { return p + (project(s, p) - p) * 2.0; }
int ccw(const Point& p1, const Point& p2, const Point& p3) {
	Point a = p2 - p1, b = p3 - p1;
	if (cross(a, b) > EPS) return 1;
	if (cross(a, b) < -EPS) return -1;
	if (dot(a, b) < -EPS) return 2;
	if (norm(a) < norm(b)) return -2;
	return 0;
}
bool intersect(Point p1, Point p2, Point p3, Point p4) {
	return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
			ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}
bool intersect(Segment s1, Segment s2) {
	return intersect(s1.fi, s1.se, s2.fi, s2.se);
}
double getDistance(Point &a, Point &b) { return abs(a - b); }
double getDistanceLP(Line &l, Point &p) {
	return abs(cross(l.se - l.fi, p - l.fi) / abs(l.se - l.fi));
}
double getDistanceSP(Segment &s, Point &p) {
	if(dot(s.se - s.fi, p - s.fi) < 0.0) return abs(p - s.fi);
	if(dot(s.fi - s.se, p - s.se) < 0.0) return abs(p - s.se);
	return getDistanceLP(s, p);
}
double getDistance(Segment &s1, Segment &s2) {
	if(intersect(s1, s2)) return 0.0;
	return min(min(getDistanceSP(s1, s2.fi), getDistanceSP(s1, s2.se)),
				min(getDistanceSP(s2, s1.fi), getDistanceSP(s2, s1.se)));
}
Point getCrossPoint(Segment s1, Segment s2) {
	Vector base = s2.se - s2.fi;
	double d1 = abs(cross(base, s1.fi - s2.fi));
	double d2 = abs(cross(base, s1.se - s2.fi));
	double t = d1 / (d1 + d2);
	return s1.fi + (s1.se - s1.fi) * t;
}
int main() {
	cout << setprecision(10) << fixed;
	double x0, y0, x1, y1, x2, y2, x3, y3;
	int q; cin >> q;
	Point p;
	rep(i, 0, q) {
		cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		p = getCrossPoint(Segment(Point(x0, y0), Point(x1, y1)), Segment(Point(x2, y2), Point(x3, y3)));
		cout << p.real() << " " << p.imag() << "\n";
	}
	return 0;
}

Measured memory_bytes: 3296
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=200010;

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

    ll n;
    cin>>n;
    ll ar[n];
    for(ll i=0;i<n;++i){cin>>ar[i];}
    ll ans=0;
    ll ma=ar[0];
    for(ll i=1;i<n;++i){
        if(ar[i]<=ma){
            ans+=ma-ar[i];
        }
        else{
            ma=ar[i];
        }
    }
    cout<<ans;

    return (0);
}


Measured memory_bytes: 5172
#include <stdio.h>

int main(){
  int n, k;
  char s[11];
  
  scanf("%d", &n);
  scanf("%s", s);
  scanf("%d", &k);
  
  for(int i = 0; i < n; i++)
    if(s[i] != s[k-1])
      s[i] = '*';
  
  puts(s);
  
  return 0;
}

Measured memory_bytes: 1616
#include <stdio.h>

int main()
{
	double xa,ya,ra,xb,yb,rb,sqrd;
	int n,i;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb);
		sqrd=(xa-xb)*(xa-xb)+(ya-yb)*(ya-yb);
		if((ra+rb)*(ra+rb)<sqrd){
			printf("0\n");
		}else if((ra+rb)*(ra+rb)>=sqrd && sqrd>=(rb-ra)*(rb-ra)){
			printf("1\n");
		}else if(rb>ra && sqrd<(rb-ra)*(rb-ra)){
			printf("-2\n");
		}else if(ra>rb && sqrd<(rb-ra)*(rb-ra)){
			printf("2\n");
		}
	}
	return 0;
}

Measured memory_bytes: 620
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    T, A = map(int, input().split())
    H = list(map(int, input().split()))
    result = [abs((T - h * 0.006) - A) for h in H]
    print(result.index(min(result)) + 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long n,a,b;
int main()
{
	scanf("%lld %lld %lld",&n,&a,&b);
	if(n==1)
	{
		if(a==b)printf("1");
		else printf("0");
	}
	else printf("%lld",max((n-2)*(b-a)+1,(long long)0));
}


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

int main() {
  int n;
  cin >> n;
  vector<int> w(n);
  int i;
  for(i=0;i<n;i++){
    cin >> w[i];
  }
  int sl,sr;
  sl = 0;sr=0;
  for(i=0;i<n;i++){
    sr += w[i];
  }
  i=0;
  int tmp = sr;
  int div = 0;
  while(true){
    sr -= w[i];
      sl += w[i];
    div = sr - sl;
    if(div<0) div*=-1;
    if(tmp < div){
      cout << tmp << endl;
      break;
    }

    tmp = div;
    i++;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll infl = 1ll<<60;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;

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

    ll a,b,k;
    cin>>a>>b>>k;
    ll t= min(a,k);
    a-=t;
    k-=t;
    t = min(b,k);
    b-=t;
    k-=t;
    cout << a << " " << b << endl;
    return 0;
}

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

vector<int> to[200005];
vector<int> ans;

void dfs(int v, int p = -1) {
  for (int u : to[v]) {
    if (u == p) continue;
    ans[u] += ans[v];
    dfs(u, v);
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  ans.resize(n);
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  rep(i, q) {
    int p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0);
  rep(i, n) printf("%d\n", ans[i]);
  return 0;
}


Measured memory_bytes: 23424
-- GCD and LCM
main = getContents >>= putStr . solve

solve :: String -> String
solve = unlines . map (unwords . map show . gcdAndLcm . map read . words) . lines
-- solve = unlines . map (unwords . map show . gcdAndLcm . map read) . map words . lines

gcdAndLcm :: [Int] -> [Int]
gcdAndLcm [a,b] = [gcd a b,lcm a b]

Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int cnt = 0;
  vector<int> vec(n);
  for (int i=0; i<n; i++) {
    cin >> vec.at(i);
  }
  for (int i=0; i<n; i++) {
    if(vec.at(i) >= k) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    ll ans = 0;
    FOR(i, 1, N+1) {
        ll lo = i;
        ll hi = (N / i) * i;
        ll cnt = hi / i - lo / i + 1;
        ans += (cnt * (lo + hi)) / 2;
    }
    cout << ans << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3636
import math

N = int(input())

max_A = math.floor(N**0.5)
#print(max_A)
ans = len(str(N))
#print("initial answer : ", ans)
for A in range(1, max_A+1):
  if N % A == 0:
    B = int(N / A)
    if len(str(B)) >= len(str(A)) and len(str(B)) < ans:
      ans = len(str(B))
      #print(A,B,ans)
    elif len(str(A)) > len(str(B)) and len(str(A)) < ans:
      ans = len(str(A))
      #print(A,B,ans)

print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {
    ll h, w, k;
    cin >> h >> w >> k;

    vvl board1(h, vl(w));
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, w) {
            if(s[j] == '#') {
                board1[i][j] = 1;
            }
        }
    }

    ll ans = 0;
    rep(b1, 1<<h) {
        rep(b2, 1<<w) {
            vvl board2(h, vl(w));
            rep(i, h) {
                rep(j, w) {
                    board2[i][j] = board1[i][j];
                }
            }
            rep(i, h) {
                if(b1 & 1<<i) {
                    rep(j, w) {
                        board2[i][j] = 0;
                    }
                }
            }
            rep(j, w) {
                if(b2 & 1<<j) {
                    rep(i, h) {
                        board2[i][j] = 0;
                    }
                }
            }
            ll cnt = 0;
            rep(i, h) {
                rep(j, w) {
                    if(board2[i][j]) {
                        cnt++;
                    }
                }
            }
            if(cnt == k) {
                ans++;
            }
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long ha[100010] = { 0 };
int main() {
	int n;
	cin >> n;
	long long ans = 1;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a != 0) {
			ans = ans * (ha[a - 1] - ha[a]) % 1000000007;
		}
		else {
			ans = ans * (3 - ha[a]) % 1000000007;
		}
		ha[a]++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String ans = "No";
        Map<Character, Integer> map = new HashMap<>();
        for(char c : s.toCharArray()) map.put(c, map.containsKey(c) ? map.get(c) + 1 : 1);
        if(map.size() == 2 && map.containsValue(2)) ans = "Yes";
        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n;
int v[2][210000];
int main()
{
	scanf("%d",&n);
	int ans1=0,ans2=0,ans3=0,ans4=0,posa=-1,posb=-1;
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		v[i&1][x]++;
		if(i&1)
		{
			if(v[i&1][x]>ans1)
			{
				if(posa!=x)ans2=ans1;
				ans1=v[i&1][x],posa=x;
			}
			else if(v[i&1][x]>ans2)ans2=v[i&1][x];
		}
		else
		{
			if(v[i&1][x]>ans3)
			{
				if(posb!=x)ans4=ans3;
				ans3=v[i&1][x],posb=x;
			}
			else if(v[i&1][x]>ans4)ans4=v[i&1][x];
		}
	}
	if(posa!=posb)printf("%d\n",n-ans1-ans3);
	else printf("%d\n",min(n-ans1-ans4,n-ans2-ans3));
	return 0;
}

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

int main(){
  
  int N, i, j, cnt = 0; cin >> N;
  vector<int> h(N);
  for(i=0; i<N; i++) cin >> h[i];
  
  while(true){
    
    j = 0;
    while(h[j] == 0) j++;
    
    for(i = j; i < N; i++){
      
      if(h[i] == 0){
        cnt++;
        break;
      }
      h[i]--;
      if(i == N - 1) cnt++;
    }
    
    bool flag = true;
    for(i = 0; i < N; i++){
      if(h[i] != 0) flag = false;
    }
    if(flag){
      cout << cnt << endl;
      return 0;
    }
  }
  return -1;
}

Measured memory_bytes: 3612
function Main(input) {
    input = input.split("\n");
    for (i=0; i < input.length; i++) {
        tmp = input[i].split(" ")
        var m = parseInt(tmp[0])
        var f = parseInt(tmp[1])
        var r = parseInt(tmp[2])
        var a = m+f
        if (m === -1 && f === -1 && r === -1) {
            break
        }
        if (m === -1 || f === -1) {
            console.log('F')
        } else if (a >= 80) {
            console.log('A')
        } else if (a >= 65) {
            console.log('B')
        } else if (a >= 50) {
            console.log('C')
        } else if (a >= 30) {
            if (r >= 50) {
                console.log('C')
            } else {
                console.log('D')
            }
        } else {
            console.log('F')
        }
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 15136
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int a;
	vector<int> x;
	cin >> a;
	for (int i = 0; i < a; i++)
	{
		int w;
		cin >> w;
		x.push_back(w);
	}
	int s = 0;
	long long int dp[101][101];
	for (int i = 0; i < 100; i++)
	{
		for (int j = 0; j < 100; j++)
		{
			dp[i][j] = 0;
		}
	}
	dp[1][x[0]] = 1;
	for (int i = 1; i < a; i++)
	{
		for (int j = 0; j <= 20 ; j++)
		{
			if (j - x[i] >= 0)
			{
				dp[i + 1][j - x[i]] += dp[i][j];
			}
			dp[i + 1][j + x[i]] += dp[i][j];
		}
	}
	cout << dp[a - 1][x[a - 1]] << endl;
	return 0;

}

Measured memory_bytes: 3140
#include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <math.h>
     
    #define BIG 2000000007
     
    #define MOD 1000000007
    typedef unsigned long long ull;
    typedef   signed long long sll;
     
     
    #define N_MAX 100
    #define M_MAX 20
     
    ull n, m, k;
    ull h, w;
    ull a[N_MAX];
    // ull b[M_MAX][N_MAX];
    ull dp[N_MAX][M_MAX + 1];
    // char s[N_MAX][M_MAX + 1];
     
    void swap_adj(ull *a, ull *b){
    	ull tmp = *b;
    	*b = *a;
    	*a = tmp;
    	return;
    }
     
    int comp(const void *a, const void *b){
    	if (*(ull*)a > *(ull*)b) {
    		return -1;
    	} else if (*(ull*)a < *(ull*)b) {
    		return +1;
    	} else {
    		return 0;
    	}
    }
     
    ull divide(ull a, ull b){
    	ull x = MOD - 2;
    	ull ans = 1;
    	while (x) {
    		if (x & 1) ans = (ans * b) % MOD;
    		b = (b * b) % MOD;
    		x /= 2;
    	}
    	return (a * ans) % MOD;
    }
     
    int digits(ull x){
    	int i = 1;
    	while (x >= 10) {
    		x /= 10;
    		i++;
    	}
    	return i;
    }
     
    int min(ull x, ull y){
    	return (x < y) ? x : y;
    }
     
    ull solve(){
    	int i, j;
     
    	i = n / 100;
    	j = n % 10;
     
    	if (i == j) {
    		puts("Yes");
    	} else {
    		puts("No");
    	}
     
    }
     
    int main(void){
    	ull i, j;
    	int a, b, c, d;
     
    	scanf("%d%d%d%d", &a, &b, &c, &d);
     
    	if (a < c) a = c;
    	if (b > d) b = d;
     
    	if (a > b) a = b;
    	printf("%d\n", b - a);
     
    	// solve();
     
    	return 0;
    }

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      final int numMax = 1_000_000;
      String line;
      int num;
      int result;

      int[] prime = new int[100_000];
      prime[0] = 2;
      int[] numOfPrimes = new int[numMax+2];
      numOfPrimes[0] = 0; numOfPrimes[1] = 0; numOfPrimes[2] = 1;

      for ( int i=3, j=1; i < numMax; i+=2 ) {
        if( isPrime(i,prime) ) {
          prime[j++] = i;
        }
        numOfPrimes[i] = numOfPrimes[i+1] = j;
      }

      while(true) {

        if( ((line = br.readLine()) == null) || line.isEmpty() ) break;

        num = Integer.parseInt(line);        
        System.out.println(numOfPrimes[num]);
      }
    }
  }

  public static boolean isPrime(int num,int[] prime) {
    int k = Double.valueOf( Math.sqrt(num) ).intValue();
    for(int i: prime) {
      if ( num % i == 0 ) return false;
      if ( i > k ) return true;
    }
    return true;
  }
}


Measured memory_bytes: 29692