akhauriyash/Code-Regression huggingface dataset:
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 998244353;
int t,n,m,k,x,y;
 
bool check(int k){
	int x=n;
	while(x%k==0){
		x/=k;
	}
	if(x%k == 1) return true;
	else return false;
}

int32_t main()
{
	IOS;
	cin>>n;
	// set<int> factors;
	set<int> works;
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0){
			if(check(i) && i>1 && i<=n) works.insert(i);
			if(check(n/i)) works.insert(n/i);
		}
	}
	works.insert(n);

	for(int i=2;i<=sqrt(n-1);i++){
		if((n-1)%i==0){
			// if(check(i)) works.insert(i);
			// if(check((n-1)/i)) works.insert((n-1)/i);
			if(i>1 && i<=n && n%i==1) works.insert(i);
			int f=(n-1)/i;
			if(f>1 && f<=n && n%f==1) works.insert(f);
		}
	}
	if(n>2)
		works.insert(n-1);
	// int x=2;
	// while(x<=n){
	// 	if(check(x)) works.insert(x);
	// 	x*=2;
	// }
	// if(check(n/2)) works.insert(n/2);
	cout<<works.size()<<ln;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>

using namespace std;

int main() {
	int a1 = 0;
	int a2 = 0;
	int a3 = 0;
	int b1 = 0;
	int b2 = 0;
	int b3 = 0;
	int sum1 = 0;
	int sum2 = 0;
	int d;

	for (int i = 0; i < 10; i++) {
		cin >> d;
		a3 = max(a3,d);
		if (a2 < a3) {
			a3 = a2;
			a2 = d;
			if (a1 < a2) {
				a2 = a1;
				a1 = d;
			}
		}

	}

	sum1 = a1 + a2 + a3;

	for (int j = 0; j < 10; j++) {
		cin >> d;
		b3 = max(b3,d);
		if (b2 < b3) {
			b3 = b2;
			b2 = d;
			if (b1 < b2) {
				b2 = b1;
				b1 = d;
			}
		}
	}

	sum2 = b1 + b2 + b3;

	cout << sum1 << " " << sum2 << endl;

	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,a,b) for(int i= (int)(a); i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define what_is(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
const int N = 1e6+7 ;
string s ;

int main(){fast ;
	int n,k ;
	cin >> n ;
	vector<int>a(n) ;
	vector<int>L(n+1,0) , R(n+1,0) ;
	for(int i = 0 ; i < n ; i++){
		cin >> a[i] ;
	}
	int res = 0 ;
	for(int i = 1 ; i <= n ; i++){
		L[i] = __gcd(L[i-1] , a[i-1] );
		R[n-i] = __gcd(R[n-i+1] , a[n-i]) ;
	}
	for(int i = 0 ; i < n ; i++)
		res = max(res, __gcd(L[i], R[i+1])) ;
	
	cout << res << endl ;
}




Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <fstream>
#include <bitset>
#include <time.h>
#include <assert.h>
#include <random>

#define LL long long
#define VI vector<int>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14


using namespace std;


struct Edge {
    int from;
    int to;
    int cost;
    Edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
    bool operator<(const Edge& edge) const {
        return this->cost < edge.cost;
    }
    bool operator>(const Edge& edge) const {
        return this->cost > edge.cost;
    }
};

class UnionFind {
public:
    vector<int> parent;
    vector<int> setSize;

    UnionFind(unsigned int size) {
        parent.resize(size + 1);
        iota(parent.begin(), parent.end(), 0);
        setSize.resize(size + 1, 1);
    }

    // x??¨y???????????????????±??????????
    bool isSameSet(int x, int y) {
        return findRoot(x) == findRoot(y);
    }

    // x??¨y????±??????????????????????
    void unionSet(int x, int y) {
        x = findRoot(x);
        y = findRoot(y);
        if (x == y) { return; }

        parent[x] = y;
        setSize[y] += setSize[x];
    }

private:
    // ??¨??????????±???????
    int findRoot(int x) {
        if (parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = findRoot(parent[x]);
        }
    }
};

/**
 * ??°?????????????°???¨?????¨????±??????????O(|E| log|V|)
 * @param num_of_node ???????????°
 * @param edges?????¨?????????????????°????????????u -> v??¨v -> u??????????????\??????
 * @return
 */
long long kruskal(unsigned int num_of_node, vector<Edge> &edges) {
    sort(edges.begin(), edges.end());

    UnionFind uf(num_of_node);

    long long ans = 0;
    for (Edge e : edges) {
        if (!uf.isSameSet(e.from, e.to)) {
            uf.unionSet(e.from, e.to);
            ans += e.cost;
        }
    }
    return ans;
}

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int V, E;
    cin >> V >> E;

    vector<Edge> edges;
    FOR(i, 0, E) {
        int s, t, w;
        cin >> s >> t >> w;
        edges.emplace_back(Edge(s, t, w));
        edges.emplace_back(Edge(t, s, w));
    }

    cout << kruskal(V, edges) << endl;

    return 0;
}

Measured memory_bytes: 5964
using System;
class Program{
	static void Main(){
		string s=Console.ReadLine();
		int n=int.Parse(Console.ReadLine());
		int l=s.Length-1;
		char[] c=new char[l+1];
		for(int i=0;i<l;i++){
			if(s[i]!='a'&&n>=123-s[i]){
				n-=123-s[i];
				c[i]='a';
			}
			else{c[i]=s[i];}
		}
		n%=26;
		if(n>0&&(s[l]-0+n>122)){
			n-=123-(s[l]-0);
			c[l]=(char)('a'+n);
		}
		else{c[l]=(char)(s[l]+n);}
		Console.WriteLine(String.Join("",c));
	}
}

Measured memory_bytes: 16352
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265358979

using namespace std;
typedef pair<int, int> P;

int main(void) {
	double a, b, c;
	double s,l, h;
	double si ,co;

	cin >> a >> b >> c;
	si = sin(PI*c/180);
	co = cos(PI*c/180);
	s = a*b*si / 2;
	l = a + b + sqrt(a*a + b*b - 2 * a*b*co);
	h = 2 * s / a;


	printf("%.10lf\n", s);
	printf("%.10lf\n", l);
	printf("%.10lf\n", h);
	return 0;
}


Measured memory_bytes: 3624
"""
互いに異なる隣り合う要素を揃えることに着目する

_________10___
↓
_________00___
(左端から1のところまでを反転)

_________01___
↓
_________11___
(左端から0のところまでを反転)
↓
_________00___
(全体を反転)

K>=max(k, n-k)+1だとどのような区間を取っても
01, 10を揃えることができない
"""

import sys
input = sys.stdin.readline

S = input()[:-1]

if S in ['0'*len(S), '1'*len(S)]:
    print(len(S))
    exit()

T = 10**10

for i in range(len(S)-1):
    if S[i]!=S[i+1]:
        T = min(T, max(i+1, len(S)-i-1))

print(T)

Measured memory_bytes: 40432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll n;
    double d; cin >> n >> d;
    ll ans = 0;
    rep(i, n) {
        double x, y; cin >> x >> y;
        if(sqrt(x*x + y*y) <= d) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3776
#include<iostream>

int main(){
	double D = 0;
	int T = 0;
	double S = 0;

	std::cin >> D >> T >> S;
	if (D/S <= T){
      std::cout << "Yes" << std::endl;
    }
  	else{
      std::cout << "No" << std::endl;
    }
	return 0;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
#define S 1999999
struct e{
    int v,nxt;
} ed[2000000];
int head[2000000],tot=2;
int in[2000000],ok[2000000];
void add_edge(int u,int v){
    ok[u]=ok[v]=1;
    ed[tot]={v,head[u]};
    head[u]=tot++;
    in[v]++;
}
int n;
inline int get(int x,int y){
    return min(x,y)*n+max(x,y);
}
queue<int> q,ans;
int main(){
    cin>>n;
    int p=S;
    for(int i=1;i<n;i++){
        int a;
        cin>>a;
        add_edge(p,a);
        p=a;
    }
    for(int i=1;i<n;i++){
        int p=S;
        for(int j=0;j<i;j++){
            int a;
            cin>>a;
            a--;
            add_edge(p,get(a,i)+1);
            p=get(a,i)+1;
        }
        for(int j=i+1;j<n;j++){
            int a;
            cin>>a;
            a--;
            add_edge(p,get(a,i)+1);
            p=get(a,i)+1;
        }
    }
    int sum=0;
    for(int i=0;i<=n*n;i++)sum+=ok[i];
    q.push(S);
    ans.push(0);
    int cntt=0,Ans=0;
    while(q.size()){
        int u=q.front(),anss=ans.front();
        Ans=max(Ans,anss);
        q.pop();
        ans.pop();
        cntt++;
        for(int i=head[u];i;i=ed[i].nxt){
            in[ed[i].v]--;
            if(!in[ed[i].v]){
                q.push(ed[i].v);
                ans.push(anss+1);
            }
        }
    }
    if(cntt<sum)cout<<-1<<endl;
    else cout<<Ans<<endl;
    return 0;
}


Measured memory_bytes: 26880
#include <algorithm>
#include <cstdio>


int answer = 10000000, N,start,end;
char s[101], t[101];

int main(){
	scanf("%d", &N);
	scanf("%s", s);
	scanf("%s", t);
	answer = N * 2;
	bool flag = true;
	for (int i = 0; i < N; ++i){
		for (int x = 0; x <= i; ++x){
			if (s[N - i + x - 1] == t[x]){
				if (x == i){
					answer =  N * 2-( i + 1);
				}
			}
			else break;
		}
	}


	printf("%d\n", answer);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pr pair<int,int>
#define pb push_back
#define f first
#define s second
#define ld long double
// int mod;
// int mul(int a,int b){
//     return (1LL*a*b)%mod;
// }
int A,B,C,D;
vector<int>num={2,3,5};
vector<int>cost;
map<int,int>dp;
int fun(int n){
    if(dp.find(n)!=dp.end()){
        return dp[n];
    }
    int &ans=dp[n];
    // cout<<n<<endl;
    if(n==0){
        // ans=min(ans,a*A+b*B+c*C+d*D);
        return ans=0;
    }
    if(n==1){
        return ans=D;
    }
    
    int lim=LLONG_MAX;
    int temp=lim;
    if(n<lim/D){
        temp=n*D;
    }
    for(int i=0;i<3;i++){
        if(n%num[i]==0){
            temp=min(temp,cost[i]+fun(n/num[i]));
        }
        else{
            int lo=(n/num[i])*num[i];
            int hi=lo+num[i];
            // if(lo>=0)
            temp=min(temp,cost[i]+((n-lo)*D)+fun(lo/num[i]));
            // if(hi>=0)
            temp=min(temp,cost[i]+((hi-n)*D)+fun(hi/num[i]));
        }
    }
    return ans=temp;
}
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    
    // t=1;
    cin>>t;
    while(t--){
        dp.clear();
        cost.clear();
        int n;
        // memset(dp,0,sizeof(dp));
        // ans=INT_MAX;
        cin>>n>>A>>B>>C>>D;
        cost.pb(A);
        cost.pb(B);
        cost.pb(C);
        int ans=fun(n);
        cout<<ans<<"\n";
    }
}

Measured memory_bytes: 4356
n, m = map(int, input().split())
list = []
for i in range(n) :
    a, b = map(int, input().split())
    list.append([a, b])
list.sort(key=lambda x:x[0])
count = 0 ; ans = 0
for i in range(n) :
    if list[i][1] < m - count :
        ans += list[i][0] * list[i][1]
        count += list[i][1]
    elif list[i][1] >= m - count :
        ans += list[i][0] * (m - count)
        break
print(ans)


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

int main(){

    int n,d, ans, count=0;
    float t,s;
    cin>>n>>d;
    vector<vector<float> > v(n, vector<float>(d));
    for(int i=0; i<n; i++){
        for(int j=0;j<d; j++)cin>>v[i][j];
    }

    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            s=0;
            for(int k=0; k<d; k++){
                s+=pow((v[i][k]-v[j][k]),2);
            }
            t=sqrt(s);
            if(t-(int)t==0)count++;
        }
    }

    cout<< count;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int n;
  cin>>n;
  map<int,int> ma;
  rep(i,n){
    int x;
    cin>>x;
    ma[x]++;
  }

  int ans = 0;
  for(int x=(1<<30); x>1;x>>=1){
    for(auto &p : ma) if(p.second > 0){
      if (x == p.first * 2){
        int c = p.second / 2;
        ans += c;
        ma[p.first] -= c*2;
      }
      else if(ma.count(x - p.first)){
        int c = min(ma[x-p.first], p.second);
        ma[x-p.first] -= c;
        ma[p.first] -= c;
        ans += c;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9600
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

#define rep(i, n) for(int i=0;i<(int)(n);++i)

using namespace std;

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;
}

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

using ll = long long;
using P = pair<int, int>;

const unsigned long long INF = 1LL << 60;

////////////////////////////////////////////////////////////

double r;

int main() {
    cin >> r;
    printf("%f %f\n",
           M_PI * pow(r, 2),
           2 * M_PI * r
    );
}



Measured memory_bytes: 3196
n = int(input())
h = list(map(int, input().split()))
flag = True
for i in range(n-1):
    if h[i] > h[i+1] + 1:
        flag = False
        break
    elif h[i] == h[i+1] + 1:
        h[i+1] += 1
if flag:
    print("Yes")
else:
    print("No")

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

int main() {
	    int n;
	    cin>>n;

	    vector<pair<int,int> > B(n);
	    for(int i=0;i<n;i++)
	    {
                int a,b;
                cin>>a>>b;
                B[i].first=a;
	        B[i].second=b;
	    }
	    vector<vector<int> > dp(n,vector<int>(n,0));
	    for(int i=0;i<n-1;i++)
	        dp[i][i+1]=B[i].first*B[i].second*B[i+1].second;
	    for(int l=2;l<=n-1;l++)
	    {
	        for(int i=0;i<n-l;i++)
	        {
	            int j=i+l;
	            dp[i][j]=INT_MAX;
	            int q=dp[i][j];
	            for(int k=1;i+k<=j;k++)
	            {

	              q=min(q,dp[i][i+k-1]+dp[i+k][j]+B[i].first*B[i+k].first*B[j].second);
	                if( q < dp[i][j])
	                dp[i][j]=q;

	            }
	        }
	    }
	  /* for(int i=0;i<n;i++)
	   {
	       for(int j=0;j<n;j++)
	       cout<<dp[i][j]<<"           ";
	       cout<<endl;
	   }*/
	    cout<<dp[0][n-1]<<endl;

	return 0;
}



Measured memory_bytes: 3204
#include<stdio.h>
int main (void){
    int n,m,i,j,k,h;
    char a[63],b[63],c,d;
    for(;;){
        scanf("%d",&n);
        if(n==0)break;
        j=0,k=0;
        for(i=0;i<n*2;i++){
            scanf(" %c",&c);
            if(i%2==0){
                a[j]=c;
                j++;
            }
            else if(i%2==1){
                b[k]=c;
                k++;
            }
        }
        scanf("%d",&m);
        for(i=0;i<m;i++){
            scanf(" %c",&d);
            for(j=0;j<n;j++){
                h=0;
                if(d==a[j]){
                    printf("%c",b[j]);
                    h++;
                    break;
                }
            }
            if(h==0){
                printf("%c",d);
            }
            if(i==m-1){
                printf("\n");
            }
        }
    }
return 0;
}

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


public class Main {
	static Scanner InData = new Scanner(System.in);
	static int qType, qVal;
	static String qKey;
	static Map<String, Integer> M = new HashMap<String, Integer>();
	public static void main(String[] args) {
		getQuery();
	}
	private static void getQuery() {
		int qNum = InData.nextInt();
		for(int indexOfQuery = 0; indexOfQuery < qNum; indexOfQuery++) {
			qType = InData.nextInt();
			qKey = InData.next();
			doQuery(qType, qKey);
		}
	}
	private static void doQuery(int type, String key) {
		switch(type) {
		case 0:
			qVal = InData.nextInt();
				M.put(key, qVal);
			break;
		case 1:
			if(M.containsKey(key)) 
				System.out.println(M.get(key));
			else
				System.out.println(0);
			break;
		case 2:
			M.remove(key);
			break;
		}
	}
}


Measured memory_bytes: 193772
#include "iostream"

using  namespace std;

#define N 1000000
#define M 300

int tet_num[M];
int tet_num_odd[M];
int ans_integer[N];
int ans_odd[N];

int main(){

	int n;
	int j = 1;

	for (int i = 0; i < M; i++){
		tet_num[i] = i*(i + 1)*(i + 2) / 6;
		if (tet_num[i] % 2 == 1){
			tet_num_odd[j] = tet_num[i];
			j++;
		}
	}

	for (int i = 0; i < N; i++){
		ans_integer[i] = N;
		ans_odd[i] = N;
	}

	while (1){

		cin >> n;

		if (n == 0)break;

		for (int m = 1; m <= n; m++){
			if (ans_integer[m] == N){
				for (int i = 1; i <= N; i++){
					if (m == tet_num[i]){
						ans_integer[m] = 1;
						break;
					}
					if (m - tet_num[i] > 0){
						if (ans_integer[m] > ans_integer[m - tet_num[i]] + 1)
							ans_integer[m] = ans_integer[m - tet_num[i]] + 1;
					}
					else break;
				}
				for (int i = 1; i <= N; i++){
					if (m == tet_num_odd[i]){
						ans_odd[m] = 1;
						break;
					}
					if (m - tet_num_odd[i] > 0){
						if (ans_odd[m] > ans_odd[m - tet_num_odd[i]] + 1)
							ans_odd[m] = ans_odd[m - tet_num_odd[i]] + 1;
					}
					else break;
				}
			}
		}

		cout << ans_integer[n] << " " << ans_odd[n] << endl;

	}


	return 0;

}

Measured memory_bytes: 8976
#include<iostream>
#include <stdio.h>
using namespace std;
int n, q, i, j;
int a[20], b[200];
bool solve(int i, int m) {
	if (m == 0)return true;
	if (i >= n)return false;
	bool f = solve(i + 1, m) || solve(i + 1, m - a[i]);
	return f;
}
int main() {
	
	cin >> n;
	for (i = 0; i < n; i++)cin >> a[i];
	cin >> q;
	while (q) {
		q--;
		int m;
		cin >> m;
		if (solve(0, m)) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}
	return 0;
}


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

int main() {
	// your code goes here
	string s[3], v;
	char s1[3] = {'A', 'B', 'C'};
	int i=0;
	while(cin >> s[i]) i++;
	
	i = 0;
	
	while(s[i].size() != 0){
		v = s[i].front();
		s[i].erase(0, 1);
		if(v == "a") i = 0;
		else if(v == "b") i = 1;
		else if(v == "c") i = 2;
	}
	
	cout << s1[i] << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

ll edgeid(ll h, ll w, ll W) {
    return h * W + w;
}

struct edge {
    ll u;
    ll v;
    ll cost;
};
bool operator<=(const edge& lhs, const edge& rhs) {
    return lhs.cost <= rhs.cost;
}
bool operator<(const edge& lhs, const edge& rhs) {
    return lhs.cost < rhs.cost;
}
bool operator>=(const edge& lhs, const edge& rhs) {
    return lhs.cost >= rhs.cost;
}
bool operator>(const edge& lhs, const edge& rhs) {
    return lhs.cost > rhs.cost;
}
bool operator==(const edge& lhs, const edge& rhs) {
    return lhs.cost == rhs.cost;
}
bool operator!=(const edge& lhs, const edge& rhs) {
    return lhs.cost != rhs.cost;
}

void dijkstra(ll n, ll start, vector<vector<edge>>& edgemap, vector<ll>& min_cost) {
    vector<bool> done(n + 1);
    for (ll j = 0; j <= n; j++) {
        min_cost[j] = -1;
        done[j] = false;
    }
    priority_queue<edge, vector<edge>, greater<edge>> pq;

    pq.push(edge{u : -1, v : start, cost : 0});
    while (!pq.empty()) {
        edge e = pq.top();
        pq.pop();
        if (done[e.v]) {
            continue;
        }
        done[e.v] = true;
        min_cost[e.v] = e.cost;
        for (auto next_e : edgemap[e.v]) {
            if (!done[next_e.v]) {
                edge total_next_e = next_e;
                total_next_e.cost = min_cost[next_e.u] + next_e.cost;
                pq.push(total_next_e);
            }
        }
    }
}

int main() {
    ll H, W;
    cin >> H >> W;
    ll sh, sw, gh, gw;
    cin >> sh >> sw;
    cin >> gh >> gw;
    sh--;
    sw--;
    gh--;
    gw--;

    // 道の一覧
    vector<vector<bool>> roads(H, vector<bool>(W, false));
    for (ll h = 0; h < H; h++) {
        for (ll w = 0; w < W; w++) {
            char c;
            cin >> c;
            while (c != '.' && c != '#') {
                cin >> c;
            }
            if (c == '.') {
                roads[h][w] = true;
            }
        }
    }

    vector<vector<edge>> edgemap(H * W);
    for (ll h = 0; h < H; h++) {
        for (ll w = 0; w < W; w++) {
            if (!roads[h][w]) {
                continue;
            }
            ll u = edgeid(h, w, W);
            for (ll y = h - 2; y <= h + 2; y++) {
                for (ll x = w - 2; x <= w + 2; x++) {
                    if (y >= 0 && y < H && x >= 0 && x < W && roads[y][x]) {
                        ll v = edgeid(y, x, W);
                        if (y == h && x == w) {
                            continue;
                        } else if (abs(x - w) + abs(y - h) == 1) {
                            edgemap[u].push_back({u : u, v : v, cost : 0});
                        } else {
                            edgemap[u].push_back({u : u, v : v, cost : 1});
                        }
                    }
                }
            }
        }
    }
    vector<ll> min_cost(H * W);
    dijkstra(H * W, edgeid(sh, sw, W), edgemap, min_cost);
    cout << min_cost[edgeid(gh, gw, W)] << endl;
}


Measured memory_bytes: 231548
#include <bits/stdc++.h> 
using namespace std; 
 
int main() 
{ 
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.length()<=k)
        cout<<s<<endl;
    else
        cout<<s.substr(0,k)+"..."<<endl;
}

Measured memory_bytes: 3604
/* ****GT_18**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  3005

ll r,c,k;
// map<pii,ll> m;
ll dp[N][N][4];
ll vals[N][N];

ll solve(ll i, ll j, ll left){
	if(i<1 or j<1)return 0;
	if(dp[i][j][left]!=-1)return dp[i][j][left];
	if(vals[i][j]==0){
		return dp[i][j][left]=max(solve(i-1,j,3),solve(i,j-1,left));
	}
	ll ifchoose = 0;
	if(left>0)ifchoose = max(solve(i-1,j,3),solve(i,j-1,left-1)) + vals[i][j];
	ll ifnotchoose = max(solve(i-1,j,3),solve(i,j-1,left));
	return dp[i][j][left]=max(ifchoose,ifnotchoose);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	rep(i,0,N)rep(j,0,N)rep(z,0,4)dp[i][j][z]=-1;
	while(TESTS--)
	{
		cin>>r>>c>>k;
		rep(i,0,k){
			ll x,y,z;
			cin>>x>>y>>z;
			// m[{x,y}]=z;
			vals[x][y]=z;
		}
		cout<<solve(r,c,3)<<endl;

	}
	return 0;
}

Measured memory_bytes: 356700
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const int MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//原点(0,0)から(X,Y)までに移動する組み合わせを求める

//(i,j) -> (i + 1, j + 2) or (i + 2, j + 1)に移動できる

//コンビネーション


// 二項係数ライブラリ Binomial coefficient
// constexpr: constant expression 定数式
template<class T> struct BiCoef {

    vector<T> fact_, inv_, finv_;
    constexpr BiCoef() {}
//    constexpr BiCoef(int n) noexcept : fact_(n, 1), inv_(n, 1), finv_(n, 1) 
    constexpr BiCoef(int n)
    {
        init(n);
    }
    constexpr void init(int n) noexcept 
    {
        fact_.assign(n,1),inv_.assign(n,1),finv_.assign(n,1);
        //int MOD = fact_[0].getmod();
        for(int i = 2; i < n; ++i)
        {
            //累積積
            fact_[i] = fact_[i-1] * i % MOD;
            //- をつける?
            inv_[i] = MOD - inv_[MOD%i] * (MOD/i) % MOD;
            finv_[i] = finv_[i-1] * inv_[i] % MOD;
        }
    }

    //nCk = n! * (n-k)!^-1 * k!^-1
    //nCk = n! / ((n-k)! * k!)
    constexpr T com(int n, int k) const noexcept {
        if (n < k || n < 0 || k < 0) return 0;
        return fact_[n] * (finv_[k] * finv_[n-k] % MOD) % MOD;
    }

};

BiCoef<ll> bc;

int main(){

  ll X,Y;
  cin >> X >> Y;
  if((X+Y) % 3 != 0)
  {
    cout << 0 << endl;
    return 0;
  }



  uint64_t res = 0;
  ll N = (X + Y) / 3;

  ll A = X - N;
  ll B = Y - N;
  bc.init(A+B+1); // 二項係数ライブラリを初期化

  if(A < 0 || B < 0)
  {
    cout << 0 << endl;
    return 0;
  }

  res = bc.com(A+B , A);
  cout << res << endl;

  return 0;    
}



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

int main() {
   int n;
   string s;
	cin >> n;
    cin >> s;
	int m=s.size();
	int r=0;
    int a,b,c;
	int d;
    for(int i=0;i<1000;i++){ 
	    a=i/100;
		b=(i%100)/10;
		c=i%10;
		int e=0;
		for(int j=0;j<m;j++){
		    
			 
			 if(e==2&&c==s.at(j)-'0') e++;
			 if(e==3){
			 	r++;
				break;
			 }
             if(e==1&&b==s.at(j)-'0') {
               e++;
               
             }
              if(e==0&&a==s.at(j)-'0'){
               e++;
               
             }
		}
		
    }
    cout << r << endl; 
}

Measured memory_bytes: 256
#define taskname ""

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
#define long long long

const int N = 16 + 10;
const int MOD = 1e9 + 7;

int n, a[N][N];
long dp[1 << N];

inline int bit(int i, int mask) {return (mask >> i) & 1;}
void cre_dp()
{
    for (int mask = 1; mask < (1 << n); ++mask) {
        for (int i = 0; i < n; ++i) if (bit(i, mask))
            for (int j = i + 1; j < n; ++j) if (bit(j, mask))
                dp[mask] += a[i][j];
    }
}

int main()
{
//    freopen(taskname".INP", "r", stdin);
//    freopen(taskname".OUT", "w", stdout);
    cin.tie(nullptr); ios_base::sync_with_stdio(false);

    cin >> n;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j) cin >> a[i][j];
    cre_dp();

    for (int mask = 1; mask < (1 << n); ++mask)
        for (int t = (mask - 1) & mask; t; t = (t - 1) & mask)
            dp[mask] = max(dp[mask], dp[t] + dp[mask ^ t]);
    cout << dp[(1 << n) - 1];

    return 0;
}


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

int compare(const void *a, const void *b){
	long long int *A = (long long int *)a;
	long long int *B = (long long int *)b;
	if (*A > *B) return 1;
	if (*A < *B) return -1;
	return 0;
}

long long ab(long long x){
	if(x<0)return -x;
	return x;
}

int main(){
	int N,i;
	scanf("%d",&N);
	long long A[N],B[N],C[N];
	long long ans=0,tmp=0;
	for(i=0;i<N;i++)scanf("%lld",&A[i]);
	qsort(A,N,sizeof(long long),compare);
	B[N/2]=A[0];
	int min=1;
	int max=N-1;
	for(i=1;i<=(N+1)/2-1;i++){
		if(i%2==1){
			B[N/2-i]=A[max--];
			B[N/2+i]=A[max--];
		}else{
			B[N/2-i]=A[min++];
			B[N/2+i]=A[min++];
		}
	}
	if(N%2==0)B[0]=A[N/2];
	for(i=0;i<N-1;i++)ans+=ab(B[i]-B[i+1]);
	
	C[N/2]=A[N-1];
	min=0;
	max=N-2;
	for(i=1;i<=(N+1)/2-1;i++){
		if(i%2==1){
			C[N/2-i]=A[min++];
			C[N/2+i]=A[min++];
		}else{
			C[N/2-i]=A[max--];
			C[N/2+i]=A[max--];
		}
	}
	if(N%2==0)C[0]=A[N/2];
	for(i=0;i<N-1;i++)tmp+=ab(C[i]-C[i+1]);
	if(tmp>ans)ans=tmp;
	
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3068
#include <stdio.h>

typedef long long ll;

int main(){

	ll a,b,x;

	scanf("%lld %lld %lld",&a,&b,&x);

	if(a==0ll){printf("%lld\n",(b/x)+1ll);}
	else{
	printf("%lld\n",(b/x)-((a-1ll)/x));
	}


	return 0;
}

Measured memory_bytes: 128
import java.util.*

fun main() {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        var ans = 0L
        for (a in 1 until N) {
            ans += N / a
            if (N % a == 0) ans--
        }
        pw.println(ans)
    }
}


Measured memory_bytes: 36456
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include<string.h>
#include<limits.h>

int  hantei(char str[],int i){
	switch(str[i]){
		case '0':
		return 0;
		break;
		
		case '1':
		return 1;
		break;
		
		case '2':
		return 2;
		break;
		
		case '3':
		return 3;
		break;
		
		case '4':
		return 4;
		break;
		
		case '5':
		return 5;
		break;
		
		case '6':
		return 6;
		break;
		
		case '7':
		return 7;
		break;
		
		case '8':
		return 8;
		break;
		
		case '9':
		return 9;
		break;
	}
}

int fx(int n){
	if(n!=0){
		return n*fx(n-1);
	}
	else return 1;
}

int main(){
	int num=1,n=0,i,j,k=0;
	int ans[100000]={0},flag=0,count=0;
	
	
	while(scanf("%d",&n)!=EOF){
		if(n==0)break;
		ans[0]=1;
	for(i=1;i<=n;i++){
		for(j=0;j<=k;j++){
			ans[j]*=i;
		}
		
		for(j=0;j<=k;j++){
			if(ans[j]>=10000){
				ans[j+1]+=ans[j]/10000;
				ans[j]%=10000;
				if(j==k)k++;
			}
		}
	}
		for(i=0;;i++){
			if(ans[i]!=0){
				if(ans[i]%1000==0)count+=3;
				else if(ans[i]%100==0)count+=2;
				else if(ans[i]%10==0)count++;
				break;
			}
			count+=4;
		}
	printf("%d\n",count);
		for(i=0;i<=k;i++)ans[i]=0;
		count=0;
		num=1;
		k=0;
	}
return 0;
}

Measured memory_bytes: 1000
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#include <iomanip>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;

int main()
{
    int n, k;
    cin >> n >> k;
    LD ans = 0;
    for(int i = 1; i <= n; i++){
        LD tmp = 1.0/n;
        int x = i;
        while(x < k){
            tmp *= 0.5;
            x <<= 1;
        }
        ans += tmp;
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int m;
vector<vector<bool> > room;
vector<vector<vector<int> > > memo;

int solve(int a, int b, int depth)
{
    if(depth >= 2*m)
        return INT_MAX/2;
    if(memo[a][b][depth] != -1)
        return memo[a][b][depth];

    if(depth%2 == 0){
        int ret = 0;
        for(int i=0; i<m; ++i){
            if(a != i && !room[a][i])
                continue;
            ret = max(ret, solve(i, b, depth+1));
        }
        return memo[a][b][depth] = ret;
    }else{
        int ret = INT_MAX/2;
        for(int i=0; i<m; ++i){
            if(b == i || !room[b][i])
                continue;
            ret = min(ret, solve(a, i, depth+1)+1);
        }
        return memo[a][b][depth] = ret;
    }
}

int main()
{
    int n;
    cin >> n;

    while(--n >= 0){
        cin >> m;
        room.assign(m, vector<bool>(m));
        memo.assign(m, vector<vector<int> >(m, vector<int>(2*m, -1)));
        for(int i=0; i<m; ++i){
            for(int j=0; j<m; ++j){
                int tmp;
                cin >> tmp;
                room[i][j] = (tmp == 1);
            }
            for(int j=0; j<2*m; ++j){
                memo[i][i][j] = 0;
                memo[i][i][j] = 0;
            }
        }

        int a, b;
        cin >> a >> b;

        int ret = solve(a, b, 0);
        if(ret >= INT_MAX/2)
            cout << "infinity" << endl;
        else
            cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M;
  cin>>N>>M;
  if(M==1)
    cout<<0<<endl;
  else{
  vector<int>X(M);
  for(int i=0;i<M;i++)
    cin>>X.at(i);
  sort(X.begin(),X.end());
  vector<int>Y(M-1);
  for(int i=0;i<M-1;i++)
    Y.at(i)=X.at(i+1)-X.at(i);
  sort(Y.begin(),Y.end());
  if(M<=N)
    cout<<0<<endl;
    else{
    int ans=0;
      for(int i=0;i<M-N;i++)
        ans+=Y.at(i);
      cout<<ans<<endl;
    
    }
    
  
  }
   return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <cmath>

using namespace std;

typedef pair<int, int> P;

bool add_queue(const int s1, queue<P>& q, vector<int>& s) {
    auto it = lower_bound(s.begin(), s.end(), s1);
    if (it == s.begin()) return false;
    it--;
    // cout << s1 << " " << *it << endl;
    q.push(P(s1, *it));
    s.erase(it);
    return true;
}

int main() {
    int n;
    cin >> n;

    int ns = pow(2, n);
    vector<int> s(ns);
    for (int i=0; i<ns; i++) cin >> s[i];
    sort(s.begin(), s.end());

    int s1, s2;
    s2 = s.back();
    s.pop_back();
    s1 = s.back();
    s.pop_back();
    
    bool ans = true;
    queue<P> q;
    if (s1 < s2) q.push(P(s1, s2));
    else ans = false;

    int day = 0;
    while (true) {
        if (q.empty()) break;
        queue<P> next_q;
        day++;
        while (!q.empty()) {
            P p = q.front();
            q.pop();
            s1 = p.first;
            s2 = p.second;

            // if (!add_queue(s1, q, s) && !add_queue(s2, q, s)) break;
            add_queue(s1, next_q, s);
            add_queue(s2, next_q, s);
        }
        q = next_q;
    }

    ans = ans && q.empty() && s.size()<=0 && day <= n;
    cout << (ans?"Yes":"No") << endl;
}



Measured memory_bytes: 3328
#include <stdio.h>

int main(void){
    
    int num;
    int i,j,k,l;
    int ans=1;
   
   scanf("%d",&num);
   
   for(i=1;i<=num;i++){
        k=i;
        j=0;
        while(k%2==0){
            k=k/2;
            j++;
        }
       if(j>l){
           l=j;
           ans=i;
       }
    }
    
   printf("%d",ans);
   
   
    return 0;
}

Measured memory_bytes: 128
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			String x1=sc.next();
			String y1=sc.next();
			int s=sc.nextInt();
			if((x1.equals("0")&&y1.equals("0"))&&s==0) break;
			BigDecimal n1=new BigDecimal("100");
			BigDecimal n2=new BigDecimal("1");
			BigDecimal x = new BigDecimal(x1);
			BigDecimal y = new BigDecimal(y1);
			BigDecimal tx = x.divide(n1,2,RoundingMode.DOWN);
			tx = tx.add(n2);
			BigDecimal ty = y.divide(n1,2,RoundingMode.DOWN);
			ty = ty.add(n2);
			int[] taxa = new int[s];
			int[] taxb = new int[s];
			for(int i=0;i<s;++i){
				BigDecimal n3=new BigDecimal(Integer.toString(i+1));
				BigDecimal tx2=tx.multiply(n3);
				BigDecimal ty2=ty.multiply(n3);
				taxa[i]=tx2.intValue();
				taxb[i]=ty2.intValue();
			}
			int max=0;
			for(int j=0;j<s-1;++j){
				for(int i=0;i<s-1;++i){
					int numa = taxa[j]+taxa[i];
					int numb = taxb[j]+taxb[i];
					if(numa==s && max<numb) max=numb; 
				}
			}
			System.out.println(max);
		}
	}
}



Measured memory_bytes: 63816
import sys
def input(): return sys.stdin.readline().strip()


def main():
    H, W = map(int, input().split())
    # 真横に分ける時
    if H % 3 == 0 or W % 3 == 0:
        print(0)
        return
    ans = min(W, H)
    # 縦と横に分ける時
    for i in range(1, W):
        s1, s2 = H * i, (W - i) * (H // 2)
        if H % 2 == 0:
            ans = min(ans, abs(s1 - s2))
        else:
            s3 = s2 + W - i
            max_s, min_s = max(s1, s2, s3), min(s1, s2, s3)
            ans = min(ans, max_s - min_s)
    for i in range(1, H):
        s1, s2 = W * i, (H - i) * (W // 2)
        if W % 2 == 0:
            ans = min(ans, abs(s1 - s2))
        else:
            s3 = s2 + H - i
            max_s, min_s = max(s1, s2, s3), min(s1, s2, s3)
            ans = min(ans, max_s - min_s)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 70836
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    sc.useDelimiter("\\s");
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    if(a < b ){
       if(b < c){
       System.out.println("Yes");
       }else{
       System.out.println("No");
       }
    }else {
       System.out.println("No");
    }  

       
   
  }

}

Measured memory_bytes: 26340
#include<cstdio>
#include<cmath>
using namespace std;
long long n,ans;
int s;
int main(){
    scanf("%lld",&n);
    for(int i=(int)floor(sqrt(n));i;--i)
        if(n%i==0)
		{
            ans=n/i;
            break;
        }
    while(ans)	++s,ans/=10;
    printf("%d\n",s); 
    return 0;
}

Measured memory_bytes: 128
N = int(input())
E = [[] for _ in range(N)]
for _ in range(N - 1):
  a, b = map(int, input().split())
  E[a - 1].append(b - 1)
  E[b - 1].append(a - 1)
def dijkstra(s):
  D = [-1] * N
  D[s] = 0
  Q = [0] * N
  Q[0] = s
  pos = 1
  for i in range(N):
    v = Q[i]
    for adj in E[v]:
      if D[adj] >= 0:
        continue
      Q[pos] = adj
      pos += 1
      D[adj] = D[v] + 1
  return D
D = dijkstra(0)
_, s = max([[D[i], i] for i in range(N)])
D = dijkstra(s)
L = max(D)
print('First' if L % 3 != 1 else 'Second')

Measured memory_bytes: 75668
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    string s;
    cin >> s;
    if(s.back() == 's'){
        cout << s + "es" << endl;
    }
    else{
        cout << s + "s" << endl;
    }
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


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

namespace AOJ_Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            string gradeResult;
            while (true)
            {
                var oneLine = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

                if (oneLine.All(x => x == -1))
                {
                    goto Finish;
                }

                var intermediateTestValue = oneLine[0];
                var finalExamValue = oneLine[1];
                var reExamValue = oneLine[2];

                if (intermediateTestValue == -1 || finalExamValue == -1)
                {
                    gradeResult = "F";
                }
                else if (intermediateTestValue + finalExamValue >= 80)
                {
                    gradeResult = "A";
                }
                else if (intermediateTestValue + finalExamValue >= 65)
                {
                    gradeResult = "B";
                }
                else if (intermediateTestValue + finalExamValue >= 50)
                {
                    gradeResult = "C";
                }
                else if (intermediateTestValue + finalExamValue >= 30)
                {
                    if (reExamValue >= 50)
                    {
                        gradeResult = "C";
                    }
                    else
                    {
                        gradeResult = "D";
                    }
                }
                else
                {
                    gradeResult = "F";
                }

                Console.WriteLine(gradeResult);
            }

            Finish:
            return;
        }
    }
}



Measured memory_bytes: 18404
import java.util.Scanner;

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

                int N = scan.nextInt();

                int[] s = {0, 0, 0, 0};

                for (int i = 0; i < N; i++) {
                	String temp = scan.next();
                	if (temp.equals("AC")) {
                		s[0]++;
                	} else if (temp.equals("WA")) {
                		s[1]++;
                	} else if (temp.equals("TLE")) {
                		s[2]++;
                	} else if (temp.equals("RE")) {
                		s[3]++;
                	}
                }

                System.out.println("AC x " + s[0]);
                System.out.println("WA x " + s[1]);
                System.out.println("TLE x " + s[2]);
                System.out.println("RE x " + s[3]);

                scan.close();

        }

}

Measured memory_bytes: 58308
#include <climits>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

struct state {
	int x, y, used_p, dir, dist;
	state(int x_, int y_, int u, int d, int d_):x(x_), y(y_), used_p(u),dir(d), dist(d_) {}
	bool operator>(const state &s) const {
		return dist > s.dist;
	}
};

constexpr int MAX_SIZE = 100;
constexpr int MAX_A = 10;

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

int h, w, a;
string field[MAX_SIZE];
int dist[MAX_SIZE][MAX_SIZE][MAX_A + 1][4];

inline bool out(int x, int y) {
	return x < 0 || y < 0 || x >= w || y >= h;
}

int dijkstra(int sx, int sy, int gx, int gy) {
	priority_queue<state, vector<state>, greater<state>> que;
	fill_n((int *)dist, sizeof(dist) / sizeof(int), INT_MAX);

	if(!out(sx, sy + 1) && field[sy + 1][sx] != '#') {
		que.push({sx, sy + 1, 0, 0, 0});
		dist[sx][sy + 1][0][0] = 0;
	}

	while(!que.empty()) {
		const state s = que.top();
		que.pop();

		if(dist[s.x][s.y][s.used_p][s.dir] < s.dist) continue;
		if(s.x == sx && s.y == sy && s.dir == 3) continue;
		if(s.x == gx && s.y == gy) return s.dist;

		for(int d = 0; d < 4; ++d) {
			int next_dist = s.dist;
			int next_used_p = s.used_p;

			if(s.x == sx && s.y == sy) {
				if(d != s.dir) continue;
			}

			else {
				if(d == s.dir) {
					// do nothing
				}
				else if(d == (s.dir ^ 0x1)) { // type p mirror
					if(s.used_p == a) continue;
					++next_dist;
					++next_used_p;
				}
				else if(d == (s.dir ^ 0x2)) { // type q mirror
					if(s.dist - s.used_p == a) continue;
					++next_dist;
				}
				else {
					continue;
				}
			}

			const int nx = s.x + dx[d];
			const int ny = s.y + dy[d];
			if(out(nx, ny) || field[ny][nx] == '#') continue;
			if(dist[nx][ny][next_used_p][d] > next_dist) {
				dist[nx][ny][next_used_p][d] = next_dist;
				que.push({nx, ny, next_used_p, d, next_dist});
			}
		}
	}
	return -1;
}

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

	cin >> h >> w >> a;

	for(int i = 0; i < h; ++i) {
		cin >> field[i];
	}

	int sx, sy, gx, gy;
	for(int y = 0; y < h; ++y) {
		for(int x = 0; x < w; ++x) {
			if(field[y][x] == 'S') {
				sx = x;
				sy = y;
			}
			else if(field[y][x] == 'G') {
				gx = x;
				gy = y;
			}
		}
	}

	cout << dijkstra(sx, sy, gx, gy) << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>=0;(i)--)
typedef long long lint;

int main(){
  lint N,s,a,b,c;
  cin >>N; priority_queue <int> M;
  rep(i,N){cin >> s;
  M.push(s);
  }
  a=M.top();
  M.pop();
  b=M.top();
  M.pop();
  rep(i,N-2){
    int c=M.top();
    if(abs(a/2-b)>abs(a/2-M.top()))
    b=c;
    M.pop();
  }
  cout <<a<<" "<<b;
}


  


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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
    int N, P;
    cin >> N >> P;
    string S;
    cin >> S;
    vector<int> ds;
    reverse(S.begin(), S.end());
    for (int i = 0; i < S.size(); ++i) {
        ds.push_back(S[i] - '0');
    }

    if (P != 2 && P != 5) {
        vector<int> pow10({1});
        vector<int> invpow10({1});
        for (int i = 1; i < N; ++i) {
            pow10.push_back((10 * pow10[i - 1]) % P);
            invpow10.push_back(modinv(pow10[i], P));
        }
        vector<int> sys({ds[0] % P});
        for (int y = 1; y < N; ++y) {
            sys.push_back((sys[y - 1] + pow10[y] * ds[y]) % P);
        }

        int64_t cnt = 0;
        vector<int> ns(P, 0);
        for (int y = 1; y <= N; ++y) {
            debug(sys[y - 1]);
            ns[sys[y - 1]] += 1;
            cnt += ns[sys[y]];
            // for (int i = 0; i < P; ++i) { cout << ns[i] << " "; }; cout << endl;
        }
        cout << cnt << endl;
    } else {
        int64_t cnt = 0;
        for (int i = 0; i < N; ++i) {
            if (ds[i] % P == 0) {
                cnt += N - i;
            }
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 4384