akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <string>
#include <iostream>
#include <vector>

using namespace std;


struct Comparator
{
        bool operator()( const string& l, const string& r ) const
        {
                if ( l.size() == r.size() )
                {
                        return l < r;
                }
                return l.size() < r.size();
        }
};
int main()
{
        int n; cin >> n;
        map<string, int, Comparator> m;

        for ( int i = 0; i < n; ++i )
        {
                string k;
                int v;
                cin >> k >> v;
                if ( m.count( k ) > 0 )
                {
                        m[ k ] += v;
                } else
                {
                        m[ k ] = v;
                }
        }

        for ( auto it = m.begin(); it != m.end(); ++it )
        {
                std::cout << it->first << " " << it->second << std::endl;
        }
}

Measured memory_bytes: 3148
def a_atCoder_group_contest(N, A):
    A.sort()
    ans = 0
    for k in range(N):
        group = [A[k], A[3 * N - (2 * k + 2)], A[3 * N - (2 * k + 1)]]
        ans += group[1]
    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(a_atCoder_group_contest(N, A))

Measured memory_bytes: 37084
#include <iostream>
#include <string>
using namespace std;
int main(){
    int a=0,b=0,i;
    string s;
    cin>>s;
    for(i=2;i<s.length()-1;i++){
        if (s[i]=='C'){
            a++;
        }
    }
    for(i=0;i<s.length();i++){
        if (s[i]>='A' &&s[i]<='Z'){
            b++;
        }
    }
    if (s[0] == 'A' && a==1 &&b==2){
        cout<<"AC";
    }
    else{
        cout<<"WA";
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

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

		if(str.length() % 2 == 0){
			str = str.substring(0, str.length()-2);
		}else{
			str = str.substring(0, str.length()-1);
		}
		
		while(true){
			if(str.substring(0, str.length()/2).equals(str.substring(str.length()/2))){
				System.out.println(str.length());
				break;
			}else{
				str = str.substring(0, str.length()-2);
			}
		}
	}
}

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{   
    gearup;
    int n; cin >> n;
    vl a(n);
    rep(i,n)cin>>a[i];
    auto b = a;
    sort(all(b)); //昇順
    ll odd = 0;
    rep(i,n){
        if(i % 2 != 0)continue;
        int idx = lower_bound(all(b),a[i]) - b.begin();
        int dif = abs(i-idx);
        //out(dif);
        if(dif & 1)odd++;
    }
    out(odd);
}

Measured memory_bytes: 4752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,K;
  cin >> N >> K; 
  long double ans = 0.0;
  for (int i = 1; i <= N; i++) {
    int a = i;
    int cnt = 0;
    for (int j = a; j < K; j*=2) {
      cnt++;
    }
    long double res = 1 / (long double)(N);
    res *= 1 / (long double)pow(2,cnt);
    ans += res;
  }
  cout << setprecision(120) << ans << endl;
  return 0;
}

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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000001
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main() {
  int a[3];
  REP(i, 3) cin >> a[i];
  sort(a, a+3);
  int k;
  cin >> k;
  a[2] <<= k;
  cout << a[0]+a[1]+a[2] << endl;
  return 0;
}


Measured memory_bytes: 256
// review

#include <iostream>

using namespace std;
typedef long long ll;
const int MOD = 1e9+7;

int h, w, a, b;
ll dp[200010];

void init() {
  dp[0] = dp[1] = 1;
  for (ll i=2;i<=200000;i++) {
    dp[i] = i * dp[i-1] % MOD;
  }
}

ll mod_pow(ll x, int n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}

ll mod_inv(ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}

ll nCr(int n, int r) {
  return ((dp[n] * mod_inv(dp[r]) % MOD) * mod_inv(dp[n - r])) % MOD;
}

void solve() {
  init();
  ll sum = 0;
  for (int i = b+1; i <= w;i++) {
    sum = (sum + nCr(h - a - 1 + i - 1, i - 1) * nCr(a + w - i - 1, w-i)) % MOD;
  }
  cout << sum << endl;
}

int main () {
  cin >> h >> w >> a >> b;
  solve();
}


Measured memory_bytes: 1792
program knapsack_for_all_subsets
  implicit none
  integer(8), parameter :: md = 998244353
  integer :: n, s, a(3000) = 0, i
  integer(8) :: f(0:3000) = 0, g(0:3000) = 0
  read(*,*) n, s
  read(*,*) a(1:n)
  f(0) = 1
  do i = 1, n
    g = f
    f(a(i):s) = f(a(i):s)+g(0:s-a(i))
    f = mod(f+g,md)
  end do
  write(*,'(i0)') f(s)
end program knapsack_for_all_subsets

Measured memory_bytes: 2996
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
#define endl '\n'
#define pi pair<int, int>

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	string s;
	cin >> n >> s;
	
	string ret;
	for(int i = 0; i < s.size(); i++){
		ret += ((s[i] - 'A' + n) % 26 + 'A');
	}
	
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int st,en,cnt=0;
  string s,tmp;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(s[i]!='x')tmp+=s[i];
  }
  for(int i=0;i<tmp.size()/2;i++){
    if(tmp[i]!=tmp[tmp.size()-1-i]){
      cout <<"-1\n";
      return 0;
    }
  }
  st = 0;
  en = s.size()-1;
  while(st<en){
    if(s[st]!=s[en]){
      if(s[st]!='x')en--;
      else st++;
      cnt++;
    }else{
      st++;
      en--;
    }
  }
  cout << cnt <<endl;
}


Measured memory_bytes: 640
N = int(input())

xyhs = []
for n in range(N):
	x, y, h = map(int, input().split())
	xyhs.append((x,y,h))

xyhs.sort(key=lambda x:x[2], reverse = True)

for cx in range(101):
	for cy in range(101):
		x, y, h = xyhs[0]
		H = h + abs(x - cx) + abs(y - cy)
				
		for xyh in xyhs[1:]:
			x, y, h = xyh

			if h == 0:
				if H > abs(x - cx) + abs(y - cy):
					break
			else:
				if H != h + abs(x - cx) + abs(y - cy):
					break
		else:
			if H < 1:
				H = 1
			print(cx, cy, H)
			exit()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define INF 1000000000
#define INFLL 1000000000000000010ll
#define UQ(x) (x).resize(distance((x).begin(),unique(all((x)))))
#define mid(x,y) (((x)+(y))>>1)

int n,m;
vector<int> adj[100005];
int nodes[100005],col[100005],bip[100005],comps;
ll cn,cb,single;
void dfs(int v,int c) {
	col[v]=c;
	nodes[comps]++;
	for (int x:adj[v]) {
		if (col[x]==-1) dfs(x,!c);
		else if (col[x]==c) bip[comps]=0;
	}
}
int main() {
	scanf("%d%d",&n,&m);
	ll s=(ll)n;
	for (int i=0;i<n;i++) col[i]=-1,bip[i]=1;
	int a,b;
	for (int i=0;i<m;i++) {
		scanf("%d%d",&a,&b);
		--a,--b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	for (int i=0;i<n;i++) {
		if (col[i]==-1) {
			dfs(i,0);
			if (nodes[comps]==1) {
				single++;
				comps++;
				continue;
			}
			if (bip[comps]) cb++;
			else cn++;
			comps++;
		}
	}
	//printf("%d\n", single);
	//printf("%lld\n", cb*2ll + cn + 2ll*(cb*(cb-1ll) + (cn*(cn-1ll)/2ll) + cb*cn));
	printf("%lld\n", cb*2ll + cn + 2ll*(cb*(cb-1ll) + (cn*(cn-1ll)/2ll) + cb*cn) + (ll)n*(ll)n-(ll)(n-single)*(ll)(n-single));
}

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

int main()
{
  long double a, b, c;
  cin >> a >> b >> c;
  
  if (a + b + (long double)2*sqrt(a)*sqrt(b) < c)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
/* LETS SEE IF U CAN PULL IT UP THIS TIME OR NOT */
/* WORK HARD MAN ! IT DEFINETELY AIN'T EASY FOR THE PRIZE IT HOLDS .... */
/* GET YOUR ASS TO WORK ALREADY */
#include<bits/stdc++.h>

#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.tie(nullptr);
#define int long long
#define pb emplace_back
#define range(v) v.begin(),v.end()
#define mod 1000000007
#define inf 1e15
#define pii pair<int,int>
#define ff first
#define ss second
// #define N --

using namespace std;

int32_t main() {
	fast
	string s, t;
	cin >> s >> t;
	if (t.substr(0, s.length()) == s)
		cout << "Yes";
	else
		cout << "No";
}

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

using namespace std;

int n, x[100], ans = INT_MAX;

int f(int p){
	int res = 0;
	for(int i = 0; i < n; ++i) res += (p-x[i])*(p-x[i]);
	return res;
}

int main(){
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> x[i];
	for(int i = 1; i <= 100; ++i) ans = min(ans, f(i));
	cout << ans << endl;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

bool solve(){
    int n,m,l,s,t;
    cin >> n >> m >> l >> s >> t;
    if(n==0 and m==0 and l==0 and s==0 and t==0) return false;

    --s;
    vector<vector<pii>> graph1(n);
    vector<pii> jiro(l);
    rep(i,0,m){
        int a,b,c;
        cin >> a >> b >> c;
        --a;
        --b;
        graph1[a].emplace_back(make_pair(b,c));
        graph1[b].emplace_back(make_pair(a,c));
    }
    rep(i,0,l){
        cin >> jiro[i].first >> jiro[i].second;
        --jiro[i].first;
    }

    vector<vector<int>> dist(l+1,vector<int>(l+1,inf));
    auto dijkstra=[&](const int start,const int idx){
        vector<int> d(n,inf);
        priority_queue<pii,vector<pii>,greater<pii>> q;
        d[start]=0;
        q.push(make_pair(0,start));
        while(!q.empty()){
            auto p=q.top();
            q.pop();
            if(p.first>d[p.second]) continue;
            for(auto &e:graph1[p.second]){
                int tmp=p.first+e.second;
                if(tmp>=d[e.first]) continue;
                d[e.first]=tmp;
                q.push(make_pair(tmp,e.first));
            }
        }
        dist[idx][0]=d[s];
        rep(i,0,l) dist[idx][i+1]=d[jiro[i].first];
    };
    dijkstra(s,0);
    rep(i,0,l) dijkstra(jiro[i].first,i+1);

    static int memo[17][1<<17];
    static bool done[17][1<<17];
    fill_n((int*)memo,17*(1<<17),inf);
    fill_n((bool*)done,17*(1<<17),false);
    function<int(int,int)> rec=[&](int u,int state){
        if(u==0 and state==1) return memo[0][1]=0;
        int &res=memo[u][state];
        if(done[u][state]) return res;
        rep(i,0,l+1){
            if(i==u) continue;
            if(((state>>i)&1)==0) continue;
            if(dist[i][u]==inf) continue;
            res=min(res,rec(i,state&~(1<<u))+dist[i][u]+(u?jiro[u-1].second:0));
        }
        done[u][state]=true;
        return res;
    };
    
    int ans=0;
    rep(i,0,l+1) rep(j,0,1<<(l+1)) if(dist[i][0]!=inf and ((j>>i)&1) and rec(i,j)+dist[i][0]<=t) ans=max(ans,__builtin_popcount(j)-1);
    cout << ans << endl;
    return true;
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(8);
    while(solve());
    return 0;
}

Measured memory_bytes: 14164
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

struct UnionFind {
	vector<int> parent;
	int size;
	UnionFind(int n) :parent(n, -1), size(n) {}
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y)return false;
		if (sizeOf(x) < sizeOf(y))swap(x, y);
		parent[x] += parent[y]; parent[y] = x; size--;
		return true;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
	int sizeOf(int x) { return -parent[root(x)]; }
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<vector<char>> A(N, vector<char>(N));
	rep(i, 0, N) rep(j, 0, N) { cin >> A[i][j]; }

	UnionFind uf(N*N);

	auto inrange = [&](int i, int j) { return i >= 0 && i < N && j >= 0 && j < N; };

	rep(i, 0, N)rep(j, 0, N) {
		static const int di[] = { 1,0,1 };
		static const int dj[] = { 0,1,1 };
		rep(k, 0, 3) {
			int ni = i + di[k], nj = j + dj[k];
			if (!inrange(ni, nj))continue;
			if (A[i][j] == 'o'&&A[ni][nj] == 'o') {
				uf.unite(i*N + j, ni*N + nj);
			}
		}
	}

	set<int> st;
	rep(i, 0, N)rep(j, 0, N) {
		if (A[i][j] == 'o')
			st.insert(uf.root(i*N + j));
	}
	dump(st);
	int w = st.size();
	cout << (w - 1) / 3 << endl;

	return 0;
}

Measured memory_bytes: 3224
#include <stdio.h>
int main ()
{
	int r=0,i,n,k,h[100100];
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&h[i]);
	}
	for(i=1;i<=n;i++)
	{
		if(h[i]>=k)
		{
			r++;
		}
	}
	printf("%d",r);
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
const int maxn = 1e5 + 5;
int a[maxn] , pre[maxn] , aft[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n , t; cin >> n >> t;
    for (int i = 1 ; i <= n ; i++) cin >> a[i];
    pre[0] = 2e9;
    for (int i = 1 ; i <= n ; i++) pre[i] = min(pre[i - 1] , a[i]);
    for (int i = n ; i >= 1 ; i--) aft[i] = max(aft[i + 1] , a[i]);
    int mx = 0;
    for (int i = 1 ; i < n ; i++) {
        mx = max (mx , aft[i + 1] - pre[i]);
    }
    set<pii> Q;
    for (int i = 1 ; i < n ; i++) {
        if (mx == aft[i + 1] - pre[i]){
            Q.insert(mp(aft[i + 1] , pre[i]));
        }
    }
    cout << Q.size()<< endl;
    return 0;
}

Measured memory_bytes: 7000
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */

    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(int i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(int i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(int i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 103000;

    void solve() {
      string s;
      cin >> s;
      ll cnt = 0;
      stack<char> st;
      rep(i, s.length()){
       if(s[i] == 'S') st.push('S');
       else if(s[i] == 'T') { 
        if (st.empty()) st.push('T');
        else if(st.top() == 'S') { cnt+=2; st.pop();}
        else st.push('T');
       }
      }
      cout << s.length() - cnt << endl;
    }
    

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      //te
      solve();
      return 0;
    } 

Measured memory_bytes: 720
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] str_ar = line.split(" ");
        List<Integer> list = new ArrayList<Integer>();
        for(int i=0;i<str_ar.length;i++) {
	        list.add(Integer.valueOf(str_ar[i]));
        }
        Collections.sort(list);
        for(int i=0;i < list.size();i++) {
        	System.out.print(list.get(i));
                if(i==list.size()-1)
                            	System.out.println("");
                else
                        	System.out.print(" ");

        }
    }
}

Measured memory_bytes: 17092
#include<bits/stdc++.h>
using namespace std;
int memo[100010],n,sss;
string zyanken;
int solve(int dp,int sum_p,int sum_g,int win,int lose);

int main(){
    cin >> zyanken;
    sss=zyanken.size();
    cout << solve(0,0,0,0,0) << endl;
return 0;
}

int solve(int dp,int sum_p,int sum_g,int win,int lose){
    int s1=0,s2=0;
    if(dp==sss)return win-lose;
    else{
        if(sum_g>=sum_p+1){
            if(zyanken[dp]=='g')s1=solve(dp+1,sum_p+1,sum_g,win+1,lose);
            else s1=solve(dp+1,sum_p+1,sum_g,win,lose);
        }else{
            if(zyanken[dp]=='g')s1=solve(dp+1,sum_p,sum_g+1,win,lose);
            else s2=solve(dp+1,sum_p,sum_g+1,win,lose+1);
        }
        return memo[dp]=max(s1,s2);
    }
}


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


int main() {
	int N;
   cin >> N;
	int sum = 0;
	for (int i = 0;i < N;i++){
	  int A;
		cin >> A;
		sum += A % 2;
	}
	if (sum % 2 == 0){
      cout << "YES" << endl;
    }
	else{
      cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
const double pi=3.1415926535897932384626;
//-0.4620981203755741
int main(){
    ll n,m,d;
    std::cin >> n>>m>>d;
    if(d==0)std::cout <<keta(10)<< (m-1)*(n/pow(n,2)) << std::endl;
    else std::cout <<keta(10)<< (m-1)*((2*(n-d))/pow(n,2)) << std::endl;
}

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

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

    int n;
    cin >> n;
    cout << (1000 - n % 1000) % 1000 << "\n";
    return 0;
}


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

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2  

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;



int main(){
    bool flag=true;
    ll ans=0,sum=0;

    int n;
    cin >>n;
    vector<int> c(n-1),s(n-1),f(n-1);

    for (int i = 0; i < n-1; i++){
        cin >>c[i]>>s[i]>>f[i];
    }
    
    for(int j = 0; j < n;++j){
        
        int t=0;
        for (int i = j; i < n-1; i++)
        {
            if(t/f[i] < s[i]/f[i])t = s[i] + c[i];
            else{
                t = f[i]*((t + f[i] - 1)/f[i]) + c[i]; 
            }
        }
        cout << t << endl;
    }

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A(N,0);
    for(ll i=0;i<N;++i)cin>>A[i];
    sort(A.rbegin(), A.rend());
    vl B={A[0]};

    ll ans=0;
    for(ll i=1;i<N;++i){
        B.emplace_back(A[i]);
        B.emplace_back(A[i]);
    }
    for(ll i=0;i<N-1;++i)ans+=B[i];
    prt(ans);fl

    return 0;
}



Measured memory_bytes: 8988
//D
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

int main() {
	int n;
	scanf("%d", &n);
	int arr[n + 1];
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
	}
	sort(arr, arr + n);
	LL ans = 0;
	ans += arr[n - 1];
	int idx = n - 2;
	for (int i = 0; i < n - 2; i++) {
		ans += arr[idx];
		if (i % 2) idx--;	
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 4612
import kotlin.math.ceil

fun main(args: Array<String>) {
    //val (tap_sockets, need_sockets) = Pair(8, 9)
    val (tap_sockets, need_sockets) = readLine()!!.split(" ").map { it.toInt() }
    val answer = ceil((need_sockets.toDouble() - 1) / (tap_sockets - 1)).toInt()
    println("$answer")
}

Measured memory_bytes: 36348
n = gets.to_i

s = []
sum = 0
n.times do
    s << gets.to_i
    sum += s.last
end

if sum % 10 == 0
    s.sort!.each do |e|
        next if e % 10 == 0
        sum -= e
        break
    end

    if sum % 10 == 0
        puts "0"
    else
        puts sum
    end
else
    puts sum
end

Measured memory_bytes: 1788
#include <cstdio>
#include <string>
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n==1) cout<<"Hello World"<<endl;
	else {
		int a,b;
		cin>>a>>b;
		cout<<a+b<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    double L;
    cin >> L;
    printf("%.10f\n", pow(L / 3, 3));
}


Measured memory_bytes: 256
def GCD(m, n):
    while n:
        m, n = n, m % n
    return m

while True:
    try:
        a, b = map(int, input().split())
    except:
        break
    if a < b:
        a, b = b, a
    gcd = GCD(a, b)
    lcm = (a * b) // gcd
    print(gcd, lcm)

Measured memory_bytes: 5600
#-------------------------------------------------------------------------------
#関数定義
def f(a,d,T):
    try:
        return T[d+1:].index(a)+(d+1)
    except ValueError:
        return len(T)

def g(a,d,T):
    try:
        return (d-1)-T[d-1::-1].index(a)
    except ValueError:
        return 0
#-------------------------------------------------------------------------------
#インポート
from math import inf
from random import random,randint
import time
from copy import copy
#-------------------------------------------------------------------------------
#定数
TIME_LIMIT=1.864 #ループの時間制限
PROB=0.001 #突然変異の確率  
A=26 #アルファベットの数
START=time.time()
#-------------------------------------------------------------------------------
#読み込み部
D=int(input())

C=[True]+list(map(int,input().split())) #減る満足度のベース
S=[True]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))           
#-------------------------------------------------------------------------------
#貪欲部
L=[0]*(A+1)
T=[0]
for d in range(1,D+1):
    Y=-inf
    E=0
    for a in range(1,A+1):
        X=S[d][a]
        for s in range(1,A+1):
            if a!=s:
                X-=C[s]*(d-L[s])

        if X>Y:
            Y=X
            E=a
    L[E]=d
    T.append(E)
#-------------------------------------------------------------------------------
#調節部
while time.time()-START<=TIME_LIMIT:
    d=randint(1,D)
    p=T[d]
    q=randint(1,A)
    Y=(d-g(p,d,T))*(f(p,d,T)-d)
    Z=(d-g(q,d,T))*(f(q,d,T)-d)
        
    if (S[d][q]-S[d][p])+Z*C[q]-Y*C[p]>0 or random()<PROB:
        T[d]=q

for i in range(1,D+1):
    print(T[i])


Measured memory_bytes: 91200
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <queue>
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(){
    ll n,a,b; cin>>n>>a>>b;
    cout<<min(a,b)<<' ';
    if(a+b>n){
        cout<<a+b-n<<endl;
    }else{
        cout<<0<<endl;
    }
}

Measured memory_bytes: 256
Q = int(input())
lr = list(list(map(int,input().split())for i in range(Q)))
pn = [0,0]+[1]*(10**5-2)
O = 0
for i in range(2,317):
    for j in range(i*2,10**5,i):
        pn[j] = 0
p = pn.copy()
for i in range(7,10**5):
    if p[i]==1:
        if(pn[int((i+1)/2)]==0):
            p[i] = 0
tmp = 0
p[2] =0
for i in range(10**5):
    p[i] = tmp+p[i]
    tmp = p[i]
for l,r in lr:
    print(p[r]-p[l-1])

Measured memory_bytes: 53772
# coding: utf-8
class Case02

  def initialize
  end

  def show
    p self.instance_variables
        .map{ |sym| [sym, self.instance_variable_get(sym)] }
        .to_h
  end
  
  # 実行する
  def execute
    read
    solve
    output
  end

  # 読込
  def read
    @n, @k = gets.chomp.split.map(&:to_i)
    @h = gets.chomp.split.map(&:to_i)
  end

  # 回答
  def solve
    @result = @h.reduce(0) do |r,x|
      r += (x >= @k) ? 1 : 0
    end
  end
  
  # 出力
  def output
    puts @result
  end

end

Case02.new.execute if $0 == __FILE__



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

using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI 3.14159265358979

signed main(){

	lli n,k;
	cin>>n>>k;

	vector<lli> v(n);
	REP(i,0,n)cin>>v[i];

	lli ans = 0;

	for(lli a=0;a<=k;a++){ 
		for(lli b=0;a+b<=k;b++){
			lli sum = 0;
			priority_queue<lli, vector<lli>, greater<lli>>q;
			if(a>n || b>n || (a+b)>n)continue;
			REP(i,0,a)q.push(v[i]),sum += v[i];
			REP(i,0,b)q.push(v[n-1-i]),sum += v[n-1-i];
			
			lli act = k-(a+b);
			REP(i,0,act){
				if(q.size()==0)break;
				lli top = q.top();
				if(top<0){
					sum -= top;
				}else break;
				q.pop();
			}
			ans = max(ans,sum);
		}
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define faster ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define FO(n) for (ll i = 0; i < n; i++)
#define endl "\n"
const long long int M = 10e9 + 7;
void solve()
{
    ll n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        ll temp=1;
        while(i*temp<n){
            ans++;
            temp++;
        }
    }
    cout<<ans<<endl;
}

int main()
{
    faster;
    //int t;
    //cin >> t;
    //while (t--)
        solve();
    return 0;
}




Measured memory_bytes: 3648
<?php

$single_line_input = fgets(STDIN);
$input = explode(" ", $single_line_input);

$a_ = $input[0] * $input[1];
$b_ = $input[2] * $input[3];

if($a_ > $b_){
    echo $a_;
}else if($b_ > $a_){
    echo $b_;
}else{
    echo $a_;
}

Measured memory_bytes: 16236
#include <iostream>
#include <unordered_map>
#include <vector>
#include <stack>
#define lli long long int
using namespace std ;


int main(int argc, char const *argv[])
{

	int k ;
	string s ;

	cin>>k>>s ;

	if(k >= s.size()) cout<<s<<endl ;
	else
	{
		for(int i = 0 ; i < k ; i++) cout<<s[i] ;
		cout<<"..."<<endl ;
	}
	return 0;
}

Measured memory_bytes: 3628
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// class
// ------------------------------------------------
class Combi
{
  public:
    Combi();
    long long Combination(long long n, long long k);
  private:
    vector<vector<long long>> memo;
    long long n_num;
    long long k_num;
    void Resize(long long n, long long k);
};

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {

  string s;
  cin >> s;

  bool ans = true;
  rep(i,sz(s))
  {
    if(i % 2 == 0)
    {
      if(s[i] != 'h')
        ans = false;
    }
    else
    {
      if(s[i] != 'i')
        ans = false;
    }
  }

  if(sz(s) % 2) ans = false;

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;


  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Combi::Combi(){
  n_num = -1;
  k_num = -1;
};
ll Combi::Combination(ll n, ll k)
{
  Resize(n,k);

  ll ret;
  if(memo[n][k] != 0)
  {
    ret = memo[n][k];
  }
  else if(n == k || k == 0)
  {
    memo[n][k] = 1;
    ret = 1;
  }
  else
  {
    ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
    memo[n][k] = ret;
  }
  return ret;
}

void Combi::Resize(ll n, ll k)
{
  if(n_num <= n || k_num <= k)
  {
    n_num = (n + 1) * 2;
    k_num = (k + 1) * 2;
    memo.resize(n_num);
    for(auto itr = memo.begin(); itr != memo.end(); ++itr)
    {
      itr->resize(k_num);
    }
  }
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(br.readLine());
        System.out.print(x >= 30 ? "Yes" : "No");
    }
}

Measured memory_bytes: 32696
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint n;
	cin>>n;
	vector<lint>a(n,0);
	rep(i,n-1){
		int tmp;
		cin>>tmp;
		a[tmp-1]++;
	}
	rep(i,n)cout<<a[i]<<endl;
}

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

int main(){
    int x,n;
    cin >> x >> n;
    int p[102];

    for(int i=0;i<102;i++){
        p[i] = 1;
    }

    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        p[a] = 0;
    }

    int min=1000;
    int ans = 0;

    for(int i=0;i<102;i++){
        if(p[i]==1){
            if(abs(x-i)<min){
                min = abs(x-i);
                ans = i;
            }
        }
    }
    
    cout << ans << endl;
}



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

using namespace std;

void SolveA()
{
	int a;
	string s;

	cin >> a >> s;

	if (3200 <= a)
		cout << s << endl;
	else
		cout << "red" << endl;
}



int main()
{
	SolveA();

	return 0;
}

Measured memory_bytes: 256
/*
 * Author Name: Sourab Hossain
 * Email: cpsourab@gmail.com
 */

#include <bits/stdc++.h>

using namespace std;

#define PI acos(-1)
#define DEGREE(radian) (radian * (180 / PI))
#define RADIAN(degree) ((degree * PI) / 180)

int dr[] = {+0, +0, +1, -1, -1, +1, -1, +1};
int dc[] = {-1, +1, +0, +0, +1, +1, -1, -1};

bool smallToBig(int *data, int length) {
    int cnt = 0;

    for(int i = 0; i < length - 1; i++) {
        int minIndex = i;

		for(int j = i + 1; j < length; j++) {
            if(data[j] < data[minIndex]) {
                minIndex = j;
            }
        }

        if(minIndex ^ i) {
            swap(data[i], data[minIndex]);
            cnt++;
        }
	}

    return cnt < 2;
}

int main(int argc, char const *argv[])
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);

    int n;

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

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

    if(smallToBig(data, n)) {
        puts("YES");
    } else {
        puts("NO");
    }
 
    return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {

var line = chunk.split(' ');
var a = Number(line[0]);
var b = Number(line[1]);
var c = Number(line[2]);
var count = 0;

for(var i = a; i <= b; i++){
   if( c % i == 0){
    count++;
  }
 }
   console.log(count); 
});

Measured memory_bytes: 15544
l,r,d = map(int,input().split())
total = 0
i = 1
while True:
  num = d*i
  if num >= l:
    break
  else:
    i+=1

while True:
  num = d*i
  if num <= r:
    total += 1
    i+=1
  else:
    break
print(total)

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

using namespace std;

int main() {
	int h, w;
	char mapdata[300][300];

	while (cin >> h >> w, h) {
		//fill(mapdata[0], mapdata[0] + h*w, '.');
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				mapdata[i][j] = '.';
			}
		}
		for (int j = 0; j < w; ++j) {
			mapdata[0][j] = '#';
			mapdata[h - 1][j] = '#';
		}
		for (int i = 0; i < h; ++i) {
			mapdata[i][0] = '#';
			mapdata[i][w - 1] = '#';
		}
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				cout << mapdata[i][j];
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	int r, g, b, n; cin >> r >> g >> b >> n;

	int64_t cases = 0;
	int r_max = n / r;
	FOR_LE(i, 0, r_max) {
		int cur = n - r * i;

		int j = 0;
		while (j * g <= cur) {
			if ((cur - j * g) % b == 0) cases++;
			j++;
		}
	}

	cout << cases << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        boolean judge = a == b && b == c;
        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 22740
mod = 1000000007

N = int(input())
A = list(map(int, input().split()))

C = [0,0,0]
ans = 1
i = 0
while i < N:
  a = A[i]
  cnt = sum([1 if C[j] == a else 0 for j in range(3)])
  ans = (ans*cnt)%mod
  if C[0] == a:
    C[0] += 1
  elif C[1] == a:
    C[1] += 1
  else:
    C[2] += 1
  i += 1
print(ans)

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<int> sz(n, 1), depth(n), parent(n);

  function<void(int,int)> dfs = [&](int u, int pa) {
    parent[u] = pa;
    if (pa != -1) {
      depth[u] = depth[pa] + 1;
    }
    for (auto v : g[u]) {
      if (v == pa) continue;
      dfs(v, u);
      sz[u] += sz[v];
    }
  };

  dfs(0, -1);
  int v = n - 1;
  for (int i = 0; i < (depth[n - 1] - 1) / 2; i++) {
   v = parent[v];
  }
  
  int x = n - sz[v], y = sz[v];
  cout << (x > y ? "Fennec" : "Snuke") << '\n';  

  return 0;
}


Measured memory_bytes: 19284
import Control.Monad
import qualified Data.IntSet as S
import Control.Monad.Trans.State
 
main :: IO ()
main = do
  n <- readLn
  as <- replicateM n readLn
  print $ evalState (solve as) S.empty
 
solve :: [Int] -> State (S.IntSet) Int
solve [] = S.size <$> get
solve (a:as) = do
  s <- get
  put $ if a `S.member` s
    then S.delete a s
    else S.insert a s
  solve as

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

/*int LCS(std::string str1, std::string str2, int i, int j){
  if(str1[i] == str2[j]){
    return 1;
  }
  else{
    return 0;
  }
 }
*/

int max(int a, int b, int c){
  int m = a;
  if(b > m){
    m = b;
  }
  if(c > m){
    m = c;
  }
  return m;
}

int main(){
  int q;
  std::cin >> q;
  //int ans[q];
  std::string str1, str2;
  for(int z=0; z<q; z++){
    std::cin >> str1 >> str2;
    int l1 = str1.size();
    int l2 = str2.size();
    int DP[l1+1][l2+1];

    for(int i=0; i<=l1; i++){
      DP[i][0] = 0;
    }
    for(int j=0; j<=l2; j++){
      DP[0][j] = 0;
    }

    for(int i=1; i<=l1; i++){
      for(int j=1; j<=l2; j++){
	if(str1[i-1] == str2[j-1]){
	  DP[i][j] = max(DP[i-1][j], DP[i][j-1], DP[i-1][j-1] + 1);
	}
	else{
	  DP[i][j] = max(DP[i-1][j], DP[i][j-1], DP[i-1][j-1]);
	}
      }
    }
    //ans[z] = DP[l1][l2];
    std::cout << DP[l1][l2] << std::endl;
  }

  /*for(int z=0; z<q; z++){
    std::cout << ans[z] << std::endl;
    }*/
  return 0;
}


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

using namespace std;

long find(const vector<int>& a, int x, int max_i)
{
    int prev = a[max_i-1] + a[max_i];
    int next = a[max_i] + a[max_i + 1];
    int diff = prev > next ? prev - x : next - x;
    if (diff < 0) diff = 0;
    if (diff > a[max_i]) diff = a[max_i];

    long step = diff;

    // prev
    next = a[max_i] - diff;
    for (int i = max_i - 1; i >= 0; --i) {
        int now = x - next;
        if (now > a[i]) now = a[i];
        step += a[i] - now;
        next = now;
    }

    // next
    prev = a[max_i] - diff;
    for (int i = max_i + 1; i < a.size(); ++i) {
        int now = x - prev;
        if (now > a[i]) now = a[i];
        step += a[i] - now;
        prev = now;
    }

    return step;
}

long check(const vector<int>& a, int x)
{
	int i = 0;
	long long sum = a[0] + a[1];
    long all = 0;
	for (int j = 1; j < a.size(); j++) {
		long long tmp = a[j];
		if (sum > x) {
			tmp -= (sum - x);
			if (tmp < 0) tmp = 0;
            all += (sum - x);
		}
		sum = a[j + 1] + tmp;
	}
    return all;
}

int main()
{
    int N, x;
    cin >> N >> x;
    vector<int> a(N, 0);
    vector<int> b(N, 0);
    int max = 0, max_i = -1;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        if (i > 0) {
            int diff = x - (a[i-1] + a[i]);
            b[i-1] += diff <= a[i-1] ? diff : a[i-1];
            b[i] += diff <= a[i] ? diff : a[i];
            if (max < b[i-1]) {
                max = b[i-1];
                max_i = i - 1;
            }
        }
    }

    cout << check(a, x) << endl;
    // cout << find(a, x, max_i) << endl;
    return 0;
}

Measured memory_bytes: 1024
n  = []
while True:
    try:n.append(int(raw_input()))
    except:break
R = max(n)+1
p = [1]*R
p[0] = p[1] = 0
p[4::2] = [0 for i in range(4,R,2)]
for i in range(3,int(R**0.5)+1,2):
    if p[i]:
        p[2*i::i] = [0 for j in range(2*i,R,i)]
for i in n:
    print sum(p[:i+1])

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

using namespace std;

int n, ans;
string s;

int main() {
	cin >> n >> s;
	for(int j = 1; j < n; j++) {
		int tmp_j = j, tmp_i = 0;
		while(tmp_j < n && s[tmp_i] == s[tmp_j])
			tmp_i++, tmp_j++;

		if(tmp_j == n && n - j == j) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	
	cout << "No" << endl;
	
    return 0;
}


Measured memory_bytes: 256
var
	a,b,c,t:longint;
begin
	read(a,b,c);
    if a>b then
    begin
    	t:=a; a:=b; b:=t;
    end;
    if b>c then
    begin
    	t:=b; b:=c; c:=t;
    end;
    if a>b then
    begin
    	t:=a; a:=b; b:=t;
    end;
    writeln(a*b div 2);
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
double eps=1e-6;
double PI=acos(-1);

bool eq(double a,double b){
  return (-eps<a-b&&a-b<eps);
}

P getCrossPoint(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}

bool isParallel(P a,P b,P c,P d){
  return eq(0,imag( (b-a)*conj(d-c) ) );
}

bool onSegment(P a,P b,P p){
  return eq(abs(b-a),abs(p-a)+abs(p-b));
}


int lcm(int a,int b){
  return a/ __gcd(a,b) * b;
}

int n;

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    
    double R=1.0/sqrt(3.0);
    P a=P(R,0);
    P b=P(R-0.5*sqrt(3.0),0.5);
    
    double lc=lcm(n,3);
    double ti=2.0*PI/lc;

    P c=a,d=b;

    if(lc==3){
      printf("0.433013\n");
      continue;
    }
    
    double T=1e9;
    for(int i=0;i<n;i++){
      c*=P(cos(ti),sin(ti));
      d*=P(cos(ti),sin(ti));
      if(!isParallel(a,b,c,d)){
        P target=getCrossPoint(a,b,c,d);
        double k=min(abs(target-a),abs(target-b));
        if(eq(k,0))continue;
        T=min(T,k);
      }

    }
    double ans=T*R*0.5;
    printf("%.8f\n",ans*lc);
  }
}

Measured memory_bytes: 1212
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    List<Integer> values = new ArrayList<>();
    Scanner scanner = new Scanner(System.in);

    while (scanner.hasNext()) {
      Integer a = scanner.nextInt();
      Integer b = scanner.nextInt();

      System.out.println(String.valueOf(a + b).length());
    }
  }
}



Measured memory_bytes: 26868