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

#define ll long long

int main() {
	string s;
	ll i, j;
	ll buf=0;
	cin >> s;
	for (i = 0; i < s.length(); i++) {
		buf += s[i] - '0';
	}
	if (buf % 9 == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <set>
#include <map>

using namespace std;

int n, m;
long xyz[1001][3];

long getScoreXYZ(long x, long y, long z)
{
    return abs(x) + abs(y) + abs(z);
}

long getScore(int idx, int p)
{
    long res = 0;
    for(int i=0; i<3; i++)
    {
        if(p & (1 << i)) res += xyz[idx][i];
        else res -= xyz[idx][i];
    }

    return res;
}

bool sortScore(pair<int, long> p1, pair<int, long> p2)
{
    return p1.second > p2.second;
}

int main(){

    long ans = 0;
    cin >> n; cin >> m;

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

    for(int i=0; i<8; i++)
    {
        vector<pair<int, long>> vec;
        for(int j=0; j<n; j++)
        {
            vec.emplace_back(make_pair(j, getScore(j, i)));
        }
        sort(vec.begin(), vec.end(), sortScore);

        long x=0, y=0, z=0;
        for(int j=0; j<m; j++)
        {
            x += xyz[vec[j].first][0];
            y += xyz[vec[j].first][1];
            z += xyz[vec[j].first][2];
        }
        ans = max(ans, getScoreXYZ(x, y, z));
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class DGameOnTree {
public:

    vector<int> graph[100005];
    vector<bool> used;

    int dfs(int p) {
      used[p] = true;
      int ret = 0;
      for(auto& e: graph[p]) {
        if (used[e]) continue;
        ret ^= (dfs(e)+1);
      }
      return ret;
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      used.resize(n);
      rep(i, n-1) {
        int x, y; cin >> x >> y;
        x--; y--;
        graph[x].push_back(y);
        graph[y].push_back(x);
      }
      if (dfs(0) == 0) {
        cout << "Bob" << endl;
      } else {
        cout << "Alice" << endl;
      }
    }
};

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

Measured memory_bytes: 8192
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> v1;
int main(){
	int n;
	int a,b;
	int s=0;
	int i,j,k;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a;
		v1.push_back(a);
	}
	sort(v1.begin(),v1.end());
	a=0,b=0;
	for(i=0;i<n;i++){
		if(v1[i]==a)b++;
		else{
			if(b%2!=0)s++;
			a=v1[i],b=1;
		}
	}
	if(b%2!=0)s++;
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
lint powint(lint x,lint y){
	if(y==0)return 1;
	if(y%2)return x*powint(x,y-1);
	lint a = powint(x,y/2);
	return a*a;
}
int main(){
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=5;i++){
		if(i%2==0)continue;
		for(int j=powint(10,i-1);j<powint(10,i);j++)if(j<=n)ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
void main(){
	int[] a = _scanln();
	writeln( a.sum()>=22? "bust": "win" );
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

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

    char input[3];
    char data[3];

    int count;

    rep(i, 3) cin >> input[i];
    rep(i, 3) cin >> data[i];

    rep(i, 3) if (input[i]==data[i]) count++;

    cout << count << endl;
}


Measured memory_bytes: 384
s=int(input())

l=[s]
c=0

while s!=1 or c<2:
  s = 3*s+1 if s%2 else s//2
  if s==1:
    c += 1
  l.append(s)

for i in range(len(l)):
  if l.count(l[i]) >= 2:
    for j in range (i+1,len(l)):
      if l[i]==l[j]:
         print(j+1)
         exit()


Measured memory_bytes: 3060
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    vector<int> aa(7);
    int i;
    for(i=0; i<7; i++) {
        scanf("%d", &aa[i]);
    }

    ll ans=0;
    {
        vector<int> a=aa;
        ll cnt=0;
        cnt+=a[1];
        cnt+=(a[3]/2)*2;
        a[3]%=2;
        cnt+=(a[4]/2)*2;
        a[4]%=2;
        if(a[3]==1 && a[4]==1 && a[0]>0) {
            cnt+=3;
            a[3]--; a[4]--; a[0]--;
        }
        cnt+=(a[0]/2)*2;
        ans=MAX(ans,cnt);
    }
    {
        vector<int> a=aa;
        ll cnt=0;
        cnt+=a[1];
        if(a[3]>0 && a[4]>0 && a[0]>0) {
            cnt+=3;
            a[3]--; a[4]--; a[0]--;
        }
        cnt+=(a[3]/2)*2;
        a[3]%=2;
        cnt+=(a[4]/2)*2;
        a[4]%=2;
        cnt+=(a[0]/2)*2;
        ans=MAX(ans,cnt);
    }
    printf("%lld\n", ans);

    return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
int f[8];
int main(int argc, char const *argv[]){
	int n,a,i,j,m=0,g=0,M;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		for(j=1;j<9;j++){
			if(a<400*j){
				f[j-1]=1;
				break;
			}
		}
		if(j==9) g++;
	}
	for(i=0;i<8;i++){
		m+=f[i];
	}
	M=m;
	if(m==0) m++;
	M=M+g;
	printf("%d %d\n",m,M);
	return 0;
}

Measured memory_bytes: 128
using System;

public class ACBC151_C {
    public static void Main() {
        string[] line = Console.ReadLine().Split(' ');
        int value = int.Parse(line[0]);
        int count = int.Parse(line[1]);
        bool[] isAC = new bool[value];
        int[] cWA = new int[value];
        int AC = 0, WA = 0;

        for(int i = 0;i < count;i++) {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]) - 1;
            if(!isAC[n]) {
                if(s[1] == "AC") {
                    isAC[n] = true;
                }
                else if (s[1] == "WA")
                    cWA[n]++;
            }
        }

        for(int i = 0;i < value;i++) {
            if(isAC[i]) {
                AC++;
                WA += cWA[i];
            }
        }

        Console.WriteLine(AC + " " + WA);
    }
}

Measured memory_bytes: 15444
#include <iostream>
using namespace std;
int main() {
	int x, a, b, c;
	cin >> x;
	a = x / 3600;
	b = (x - a * 3600) / 60;
	c = x - a * 3600 - b * 60;
	cout << a << ":" << b << ":" << c << endl;
	return 0;
}

Measured memory_bytes: 3028
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto v : vs)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl

int solve() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	ll count = 0;
	while (a >= b) {
		b *= 2;
		++count;
	}
	while (b >= c) {
		c *= 2;
		++count;
	}
	bool is_good = count <= k;
	cout << (is_good ? "Yes" : "No") << endl;


	return 0;
}

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

	solve();

	return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;
int ans[100005];
int main(void){
	string s;
	cin >> s;
	int i = 0,j = 0;
	int cnt;
	char c1 = 'R',c2 ='L';
	while(i<s.size()){
		cnt = 0;
		while(s[i]==c1){
			i++;
			cnt++;
		}
		j = i;
		ans[j-1] += (cnt+1)/2;
		ans[j] += (cnt)/2;
		cnt = 0;
		while(s[i]==c2){
			i++;
			cnt++;
		}
		ans[j]  +=(cnt+1)/2;
		ans[j-1]+=(cnt/2);
	}
	for(int i=0;i<s.size();i++){
		cout << ans[i] <<" ";
	}
	cout << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
	bool operator<(const mint a){
		return x < a.x;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<mint> v(n+1), left(n+2, 0), right(n+2, 0);
	rep(i,n+1){
		v[i] = i;
		left[i+1] = left[i] + v[i];
	}
	rep(i,n+1){
		right[i+1] = right[i] + v[n-i];
	}
	mint ans = 0;
	for(int i = k; i <= n+1; i++){
		mint add = right[i] - left[i] + 1;
		//cout << right[i].x << " " << left[i].x << " " << add.x << endl;
		if(add < 0) continue;
		ans += add;
	}
	cout << ans.x << endl;
	return 0;
}

Measured memory_bytes: 7908
#include <iostream>
#include <cstdio>
#include <map>
#include <cstring>
#define INF 210
#define NMAX 105
using namespace std;
int dp[NMAX][NMAX];
string S[NMAX][NMAX],tmp;
int K[NMAX][NMAX];
map<char,char> M;
int i,j,k,N;
char C[NMAX];
void afisare(int i,int j)
{
    if(i>j)
        return ;
    if(i==j)
    {
        if(C[i]=='('||C[i]==')')
            cout<<"()";
        else
            cout<<"[]";
    }
    else
    {
         if(K[i][j]==0&&M[C[i]]==C[j])
        {
            cout<<C[i];
            afisare(i+1,j-1);
            cout<<C[j];
        }
        else if(K[i][j]==-1)
        {
            cout<<"(";
            afisare(i,j-1);
            cout<<")";
        }
        else if(K[i][j]==-2)
        {
            cout<<"(";
            afisare(i+1,j);
            cout<<")";
        }
        else
        {
            afisare(i,K[i][j]);
            afisare(1+K[i][j],j);
        }
    }
}
int main()
{
    cin>>N;
    cin.getline(C+1,105);
    cin.getline(C+1,105);
    M['(']=')';
    for(i=N;i>=1;i--)
    {
        for(j=i;j<=N;j++)
        {
            if(i==j)
                {dp[i][j]=1;S[i][j]="()";}
            else
            {
                dp[i][j]=INF;
                if(M[C[i]]==C[j])
                {
                    dp[i][j]=dp[i+1][j-1];
                    S[i][j]="("+S[i+1][j-1]+")";
                }
                if(C[j]==')')
                {
                    tmp="("+S[i][j-1]+")";
                    if(dp[i][j]>dp[i][j-1]+1||(dp[i][j]==dp[i][j-1]+1&&tmp<S[i][j]))
                    {
                        dp[i][j]=dp[i][j-1]+1;
                        S[i][j]=tmp;
                        K[i][j]=-1;
                    }
                }
                if(C[i]=='(')
                {
                    tmp="("+S[i+1][j]+")";
                    if(dp[i][j]>dp[i+1][j]+1||(dp[i][j]==dp[i+1][j]+1&&tmp<S[i][j]))
                    {
                        dp[i][j]=dp[i+1][j]+1;
                        S[i][j]=tmp;
                        K[i][j]=-2;
                    }
                }
                for(k=j;k>=i;k--)
                {
                    tmp=S[i][k]+S[k+1][j];
                    if(dp[i][j]>dp[i][k]+dp[k+1][j]||(dp[i][j]==dp[i][k]+dp[k+1][j]&&tmp<S[i][j]))
                    {
                        K[i][j]=k;
                        S[i][j]=tmp;
                        dp[i][j]=dp[i][k]+dp[k+1][j];
                    }
                }
            }
        }
    }

    cout<<S[1][N];
    return 0;
}


Measured memory_bytes: 1280
import itertools

TS = ['dream','dreamer','erase','eraser']
I = itertools.permutations(TS)
L = list(I)

S = raw_input()
res = []
for i in range(len(L)):
    Sn = S
    for j in range(4):
        Sn = Sn.replace(L[i][j],"")
    res.append(len(Sn))

if min(res) == 0:
    print "YES"
else:
    print "NO"

Measured memory_bytes: 2820
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Network{
	private:
	int V;
	struct edge{
		int to,cap,rev;
	};
	vector<vector<edge> > List;
	int DFSplus(int v,int t,int f,vi& iter,vi level){
		if(v==t) return f;
		for(int &i=iter[v];i<List[v].size();i++){
			edge &e=List[v][i];
			if(e.cap>0&&level[v]<level[e.to]){
				int d=DFSplus(e.to,t,min(f,e.cap),iter,level);
				if(d>0){
					e.cap-=d;
					List[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	void BFSplus(int s,vi& level){
		level=vi(V,-1);
		queue<int> que;
		level[s]=0;
		que.push(s);
		while(!que.empty()){
			int v=que.front();
			que.pop();
			for(int i=0;i<List[v].size();i++){
				edge &e=List[v][i];
				if(e.cap>0&&level[e.to]<0){
					level[e.to]=level[v]+1;
					que.push(e.to);
				}
			}
		}
	}
	public:
	Network(int v){
		V=v;
		List=vector<vector<edge> >(v);
	}
	void add_edge(int s,int t,int c){
		List[s].push_back(edge{t,c,(int)List[t].size()});
		List[t].push_back(edge{s,0,(int)List[s].size()-1});
	}
	int MFplus(int s,int t){
		int ans=0;
		while(1){
			vi iter(V),level;
			BFSplus(s,level);
			if(level[t]<0) return ans;
			int f;
			while((f=DFSplus(s,t,inf,iter,level))>0) ans+=f;
		}
	}
};

int h,w;
int sx,sy,tx,ty;
vvc a;

int main(){
	cin>>h>>w;
	a=vvc(h,vc(w));
	for(int i=0;i<h;i++) for(int j=0;j<w;j++){
		cin>>a[i][j];
		if(a[i][j]=='S'){
			sx=i;
			sy=j;
		}
		if(a[i][j]=='T'){
			tx=i;
			ty=j;
		}
	}
	if(sx==tx||sy==ty){
		cout<<-1<<endl;
		return 0;
	}
	Network nt(h*w*2);
	for(int i=0;i<h;i++) for(int j=0;j<w;j++) if(a[i][j]!='.'){
		if(!(i==sx&&j==sy||i==tx&&j==ty)) nt.add_edge(i*w+j,h*w+i*w+j,1);
		for(int k=0;k<h;k++) if(i!=k&&a[k][j]!='.'){
			if(!(i==tx&&j==ty)) nt.add_edge(h*w+i*w+j,k*w+j,500);
			if(!(i==sx&&j==sy)) nt.add_edge(h*w+k*w+j,i*w+j,500);
		}
		for(int k=0;k<w;k++) if(j!=k&&a[i][k]!='.'){
			if(!(i==tx&&j==ty)) nt.add_edge(h*w+i*w+j,i*w+k,500);
			if(!(i==sx&&j==sy)) nt.add_edge(h*w+i*w+k,i*w+j,500);
		}
	}
	cout<<nt.MFplus(h*w+sx*w+sy,tx*w+ty)<<endl;
}

Measured memory_bytes: 124872
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x) cout<<#x<<" = "<<(x)<<endl;
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int f(int n) {
  return n%2 ? 3*n+1 : n/2;
}

int main() {
  int a[1000000];
  cin >> a[0];

  M m; m[a[0]] = 1;
  for(int i = 1; i <= 1000000; i++) {
    a[i] = f(a[i-1]);
    if (m[a[i]] == 1) { COUT(i+1); break; }
    m[a[i]]++;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  for(int i=0;i<4;i++){
    int cnt=0;
    for(int j=0;j<4;j++)if(s.at(i)==s.at(j))cnt++;
    if(cnt!=2){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

struct Box {
    int cnt = 1;
    bool f = false;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    vector<Box> vb(n);
    vb[0].f = true;
    int ans = 0;
    
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        
        if (vb[x].f) {
            vb[x].cnt--;
            vb[y].cnt++;
            vb[y].f = true;
            
            if (vb[x].cnt == 0) {
                vb[x].f = false;
            }
        }
        else {
            vb[x].cnt--;
            vb[y].cnt++;
        }
    }
    
    rep(i, n) {
        if (vb[i].f) {
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
//ABC042-C「こだわり者いろはちゃん」
#include<iostream>
using namespace std;

int N,K;
bool ng[11];

int main(){
    cin>>N>>K;
    for(int i=0; i<K; i++){
        int t;
        cin>>t;
        ng[t]=true;
    }
    
    for(int i=N;;i++){
        int a=i;
        while(1){
            int d=a%10;
            if(ng[d])break;
            a/=10;
            if(a==0){
                cout<<i<<endl;
                return 0;
            }
        }
    }
    
    return 0;
}

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

void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}

int main(void){
    int N,*v,i;
    float s;
    scanf("%d",&N);
    v = malloc(sizeof(int)*N);
    for(i=0;i<N;i++){
        scanf("%d",&v[i]);
    }
    quick_sort(v,0,N-1);
    s = (float) v[0];
    for(i=1;i<N;i++){
        s = (s + v[i]) / 2; 
    }
    
    printf("%g",s);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>

using namespace std;

typedef long long ll;

ll N,A,B;
ll x[100000];

int main(){
    cin >> N >> A >> B;
    for(int i=0;i<N;i++) cin >> x[i];
    ll cost = 0;
    for(int i=1;i<N;i++){
        cost += min(A * (x[i]-x[i-1]),B);
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

        int n = sc.nextInt();
        int x = sc.nextInt();

        int cnt = 1;
        int l = 0;
        for (int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            l += tmp;
            if (l <= x)
                cnt++;
            else
                break;
        }
        sc.close();

        System.out.println(cnt);
    }
}

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

typedef long long ll;

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


    int N, T;
    cin >> N >> T;

    vector<pair<int, int> > X(N);

    for(int i = 0; i < N; i++) {
        int c, t;
        cin >> c >> t;
        X[i] = make_pair(t, c);
    }

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

    int ans = 1000000;

    for(int i = 0; i < N; i++) {
        int t = X[i].first;
        int c = X[i].second;

        if(t > T) break;
        ans = min(ans, c);
    }

    if(ans == 1000000) {
        cout << "TLE" << endl;
        return 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp_practice
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int x = 1; x <= 50000; x++)
            {
                if (Math.Floor(x * 1.08) == n)
                {
                    Console.WriteLine(x);
                    return;
                }
            }
            Console.WriteLine(":(");
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define ll long long

using namespace std;
const int MAXN = 100005;

vector<int> g[MAXN];

int dfs(int a){
	vector<int> v;
	for(int i:g[a]){
		v.push_back(dfs(i));
	}
	sort(v.begin(),v.end());
	int ans = 0;
	for(int i:v){
		if(i <= ans) ans++;
		else ans = i+1;
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	for(int i=2;i<=n;i++){
		int a; cin >> a;
		g[a].push_back(i);
	}
	int ans = dfs(1);
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+10;
vector<int> datas[MAXN];//通道关系
int ans[MAXN];//保存最近的房间号

void bfs() {
    queue<int> q;
    q.push(1);
    ans[1] = 1;

    while (!q.empty()) {
        int u = q.front();
        q.pop();

        for (auto v:datas[u]) {
            if (0==ans[v]) {
                q.push(v);
                ans[v] = u;
            }
        }
    }
}

int main() {
    int n,m;
    scanf("%d%d", &n, &m);
    for (int i=0; i<m; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        datas[u].push_back(v);
        datas[v].push_back(u);
    }

    bfs();

    //查询
    for (int i=2; i<=n; i++) {
        if (0==ans[i]) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    for (int i=2; i<=n; i++) {
        printf("%d\n", ans[i]);
    }

    return 0;
}

Measured memory_bytes: 12896
l,r = map(int, input().split())
if r-l+1>2019:
  print(0)
  exit()
L = []
for i in range(l,r):
  for j in range(i+1,r+1):
    a = i*j
    b = a%2019
    L.append(b)
    if b == 0:
      break
print(min(L))


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string t, s;
	cin >> s >> t;
	sort(t.begin(), t.end());
	sort(s.begin(), s.end());
	vector<char> afb = { 'a','b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
	vector<int> res1;
	vector<int> res2;
	for (int i = 0; i < afb.size(); ++i) {
		res1.push_back(count(t.begin(), t.end(), afb[i]));
		res2.push_back(count(s.begin(), s.end(), afb[i]));
	}
	sort(res1.begin(), res1.end());
	sort(res2.begin(), res2.end());
	if (res1 == res2) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 916
a, b, k = map(int, input().split())
flag = True
for i in range(k):
    if flag:
        if a % 2 != 0:
            a -= 1
        b += a // 2
        a -= a // 2
        flag = False
    else:
        if b % 2 != 0:
            b -= 1
        a += b // 2
        b -= b // 2
        flag = True
print(a, b)


Measured memory_bytes: 3316
//Created by Aminul on 6/27/2020.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = in.nextInt(), m = in.nextInt();
        long k = in.nextInt();
        long[] a = new long[n], b = new long[m];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
            if (i > 0) a[i] += a[i - 1];
        }

        TreeMap<Long, Integer> map = new TreeMap<>();
        map.put(Long.MIN_VALUE, 0);
        for (int i = 0; i < m; i++) {
            b[i] = in.nextInt();
            if (i > 0) b[i] += b[i - 1];
            map.put(b[i], i + 1);
        }


        int res = map.floorEntry(k).getValue();
        for (int i = 0; i < n; i++) {
            if(k >= a[i]) res = max(res, i + 1 + map.floorEntry(k - a[i]).getValue());
        }

        pw.println(res);

        pw.close();
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

Measured memory_bytes: 69488
n = int(input())
s = input()
ans = s.count('R') * s.count('G') * s.count('B')

for i in range(n):
    for j in range(i+1, n-1):
        k = 2 * j - i
        if(k < n):
            if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
                ans -= 1

print(ans)


Measured memory_bytes: 68140
import java.util.Scanner;

class Main{

	static int[] p;
	static	int N ;
	static	int M ;


	public static void main(String[] args) {


		Scanner scanner = new Scanner(System.in);
		N = scanner.nextInt();
		M = scanner.nextInt();

		int ans = 0;
		if((N+M) %2 == 1){
			System.out.println((N+M)/2+1);
			return;

		}

		System.out.println((N+M)/2);

	}


}

class Pair implements Comparable{
	int from;
	int middle;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}





Measured memory_bytes: 25300
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            string result = "";
            if (!s.Contains("1"))
            {
                result = "1";
            }
            else if (!s.Contains("2"))
            {
                result = "2";
            }
            else if (!s.Contains("3"))
            {
                result = "3";
            }
            else if (!s.Contains("4"))
            {
                result = "4";
            }
            else if (!s.Contains("5"))
            {
                result = "5";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 25796
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
LL gcd(LL a,LL b){
   if(a>b)return gcd(b,a);
   if(b%a==0)return a;
   return gcd(b%a,a);
}
int main(){
        LL a,b;
        while(cin>>a,cin>>b){
	      LL g=gcd(a,b);
	      cout<<g<<" "<<a/g*b<<endl;;
        }
	return(0);
}

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

bool prime(int n){
  if(n%2==0) return false;
  for(int i=3;i<sqrt(n);i+=2){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  if(n==2) {
    cout << "2" << endl;
    return 0;
  }
  for(int i=n;;i++){
    if(prime(i)) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
   int n;
   scanf("%d", &n);
   if(n < 10){
       printf("%d", n);
   } else if(n < 100){
       printf("%d", 9);
   } else if(n < 1000){
       printf("%d", 9+(n-100+1));
   } else if(n < 10000){
       printf("%d", 9+900);
   } else if(n < 100000){
       printf("%d", 9+900+(n-10000)+1);
   } else {
       printf("%d", 9+900+90000);
   }
    return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = l[0], B = l[1], Q = l[2];
            var s = new long[A];
            var t = new long[B];
            var x = new long[Q];

            for (var i = 0; i < A; i++)
                s[i] = long.Parse(Console.ReadLine());
            for (var i = 0; i < B; i++)
                t[i] = long.Parse(Console.ReadLine());
            for (var i = 0; i < Q; i++)
                x[i] = long.Parse(Console.ReadLine());

            var jbs = new BinarySearch<long>() { Data = s };
            var tbs = new BinarySearch<long>() { Data = t };
            
            foreach (var p in x)
            {
                // 自分の位置から最も近い神社を両方取得
                var jRet = GetBothSide(jbs, p);
                // 右の神社から最も近い寺を両方取得
                var tRet = GetBothSide(tbs, s[jRet.Item1]);
                var total1 = GetMin(tbs, t, tRet)+Math.Abs(jbs.Target-s[jRet.Item1]);
                // 左の神社から最も近い寺を両方取得
                tRet = GetBothSide(tbs, s[jRet.Item2]);
                var total2 = GetMin(tbs, t, tRet)+Math.Abs(jbs.Target-s[jRet.Item2]);

                // 自分の位置から最も近い寺を両方取得
                tRet = GetBothSide(tbs, p);
                // 右の寺から最も近い神社を両方取得
                jRet = GetBothSide(jbs, t[tRet.Item1]);
                var total3 = GetMin(jbs, s, jRet)+Math.Abs(tbs.Target-t[tRet.Item1]);
                // 左の寺から最も近い神社を両方取得
                jRet = GetBothSide(jbs, t[tRet.Item2]);
                var total4 = GetMin(jbs, s, jRet)+Math.Abs(tbs.Target-t[tRet.Item2]);

                Console.WriteLine(Math.Min(Math.Min(Math.Min(total1, total2), total3), total4));
            }
        }

        static Tuple<int, int> GetBothSide(BinarySearch<long> bs, long p)
        {
            bs.Target = p;
            return bs.Search();
        }

        static long GetMin(BinarySearch<long> bs, long[] list, Tuple<int, int> val)
        {
            return Math.Min(Math.Abs(list[val.Item1] - bs.Target), Math.Abs(list[val.Item2] - bs.Target));
        }
    }

    public class BinarySearch<T> where T : IComparable
    {
        public T[] Data { get; set; }
        public T Target { get; set; }

        public Tuple<int, int> Search()
        {
            int ng = -1;
            int ok = (int)Data.Length;

            while (Math.Abs(ok - ng) > 1)
            {
                int mid = (ok + ng) / 2;

                if (IsOK(mid)) ok = mid;
                else ng = mid;
            }
            if (ng < 0) ng = 0;
            if (ok > Data.Length - 1) ok = Data.Length - 1;
            return new Tuple<int, int>(ok, ng);
        }

        public bool IsOK(int index)
        {
            if (Data[index].CompareTo(Target) >= 0) return true;
            else return false;
        }
    }
}


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

int main(){
	string s;
	cin >> s;
	int y = stoi(s.substr(0,4));
	int m = stoi(s.substr(5,2));
	int d = stoi(s.substr(8,2));
	
	cout << ((y >= 2019 && m >= 5)?"TBD":"Heisei") << endl;
}


Measured memory_bytes: 256
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main() {
    long n;
    readf("%s", &n);
    readln;
   
    int best = 1;
    foreach (k; 1 .. sqrt(n.to!real).to!int + 1) {
        if (n % k == 0) {
            best = k;
        }
    }
    
    long ans = best - 1 + (n / best) - 1;
    
    ans.writeln;
}

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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		List<Integer> sosuu = sosuuList(55555);
		StringBuilder sb = new StringBuilder();
		int cnt = 0;
		for (int i = 0; i < sosuu.size(); i++) {
			if (sosuu.get(i) % 5 == 1) {
				sb.append(sosuu.get(i) + " ");
				cnt++;
				if (cnt == n) {
					break;
				}
			}
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());
	}

	static List<Integer> sosuuList(int n) {
		List<Integer> sosuu = new ArrayList<Integer>();
		for (int i = 2; i <= n; i++) {
			int r = (int) Math.sqrt(i);
			boolean flg = false;
			for (Integer o : sosuu) {
				if (r < o) {
					break;
				}
				if (i % o == 0) {
					flg = true;
					break;
				}
			}
			if (!flg) {
				sosuu.add(i);
			}
		}
		return sosuu;
	}
}


Measured memory_bytes: 24660
#include <iostream>

using namespace std;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    for (int i = sx; i < tx; i++) {
        cout << "R";
    }

    for (int i = sy; i < ty; i++) {
        cout << "U";
    }

    cout << "R";

    for (int i = ty; i > sy - 1; i--) {
        cout << "D";
    }

    for (int i = tx + 1; i > sx; i--) {
        cout << "L";
    }

    cout << "U";

    for (int i = sy; i < ty; i++) {
        cout << "U";
    }

    for (int i = sx; i < tx; i++) {
        cout << "R";
    }

    cout << "U";

    for (int i = tx; i > sx - 1; i--) {
        cout << "L";
    }

    for (int i = ty + 1; i > sy; i--) {
        cout << "D";
    }

    cout << "R" << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public final class Main {
	public static void main(String[] args) throws java.lang.Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String arg = br.readLine();
		Solver s = new Solver();
		System.out.println(s.solve(arg));
	}

}

class Solver {

	String solve(String s) {

		int in[] = new int[26];
		for (int i = 0; i < s.length(); i++) {
			in[s.charAt(i) - 'a']++;
		}
		int t = 0;
		for (int j = 0; j < in.length; j++) {
			t |= (in[j] & 1);
		}
		if (t > 0)
			return "No";
		else
			return "Yes";

	}

}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
#define STDIO
#define MOD 1000000007
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define INF MOD
using namespace std;
int n,m,k;
vector<int> like[100100];
vector<int> hate[100100];
int u,v;
int sz[100100];
int fa[100100];
int ff(int nod){
	if(fa[nod]==nod)
		return nod;
	return fa[nod]=ff(fa[nod]);
}
void joi(int nod1,int nod2){
	nod1=ff(nod1);
	nod2=ff(nod2);
	if(nod1==nod2)
		return;
	if(sz[nod1]<sz[nod2])
		swap(nod1,nod2);
	//link nod2 to nod1
	fa[nod2]=nod1;
	sz[nod1]+=sz[nod2];
}
int main(){
	#ifndef STDIO
		freopen("input.in","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++){
		fa[i]=i;
		sz[i]=1;
	}
	for(int i=1;i<=m;i++){
		cin>>u>>v;
		like[u].push_back(v);
		like[v].push_back(u);
		joi(u,v);
	}
	for(int i=1;i<=k;i++){
		cin>>u>>v;
		hate[u].push_back(v);
		hate[v].push_back(u);
	}
	int dic,rr;
	int vv;
	for(int i=1;i<=n;i++){
		dic=ff(i);
		rr=sz[dic]-like[i].size()-1;
		for(int j=0;j<hate[i].size();j++){
			vv=hate[i][j];
			vv=ff(vv);
			if(vv==dic)
				rr--;
		}
		cout<<rr<<' ';
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 12664
//  zukonit14 - Kunal Raut

#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define int         long long
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define fi          first
#define se          second
#define mod         1000000007
#define mod9        1000000009
#define pi          3.1415926535
#define MAXN        2000005
#define N           1000001
#define MAX2N       1*1000 + 10
#define all(v)      v.begin(), v.end()
#define allr(v)     v.rbegin(), v.rend()
#define ms(s, n)    memset(s, n, sizeof(s))
#define prec(n)     fixed<<setprecision(n)
#define forci(p,n)  for(ll i=p;i<(ll)n;i++)
#define forcj(p,n)  for(ll j=p;j<(ll)n;j++)
#define bolt        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define bits(a)     __builtin_popcount(a)
#define test        ll t;cin>>t;for(ll testi=1;testi<=t;testi++)
#define djokovic    freopen("input00.txt", "r", stdin);freopen("output00.txt", "w", stdout);

ll gcd(ll a, ll b)  {    if (b == 0) return a;    return gcd(b, a % b);}
ll lcm(ll a, ll b)  {    return (a / gcd(a, b) * b);}
ll expo(ll x, ll y) {
    ll res = 1; x = x % mod; while (y > 0) {
        if (y & 1)res = (1ll * res * x) % mod;
        y = y >> 1; x = (1ll * x * x) % mod;
    } return res;
}
ll ncr(ll n, ll r)  { ll res = 1; if (r > n - r)r = n - r; for (ll i = 0; i < r; i++) {  res *= n - i;  res /= i + 1; } return res;}
ll max(ll a, ll b)  {return (a > b) ? a : b;}
bool prime(ll n)    {ll i; for (i = 2; i <= sqrt(n); i++) {if (n % i == 0)return false;} return true;}
bool comp(const pair<ll, ll> &a, const pair<ll, ll> &b)
{
    if (a.second - a.first == b.second - b.first)
    {
        return (a.first < b.first);
    }
    return (a.second - a.first > b.second - b.first);
}
//https://www.youtube.com/watch?v=WTJSt4wP2ME

ll rr[] = {0, 1, 1, 1, 0, -1, -1, -1};
ll cc[] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll INF = 2e18;
ll n, k, m, q, x, ans, b[MAXN], pref[MAXN], min1 = 2e18, max1 = 0;
ld polyapothem(ld n, ld a = 1)
{
    if (a < 0 && n < 0)
        return -1;
    return a / (2 * tan((180 / n) * pi / 180));
}
ld findRadiusOfcircumcircle(ld n, ld a = 1)
{

    if (n < 0 || a < 0)
        return -1;
    //return a / sqrt(2 - (2 * cos((360 / n) * pi / 180)));
    //return a / (2 * sin((180 / n) * pi / 180));
    return polyapothem(n) / (cos((180 / n) * 3.14159 / 180));
}
void solve()
{
    cin >> n;
    ld s1 = 1 / (sqrt(2)), s2 = 0.5;
    if (n % 2 == 0)
    {
        cout << prec(12) << 2 * polyapothem(2 * n) << "\n";
    }
    else
    {
        ld off = sqrt(s1 * s1 + s2 * s2);
        //cout << prec(12) << 2 * findRadiusOfcircumcircle(2 * n) << "\n";
        cout << prec(12) << 2 * polyapothem(2 * n) + 2 * off << "\n";
    }
}
signed main()
{
    bolt;
#ifndef ONLINE_JUDGE
    djokovic;
#endif
    ll n; cin >> n;
    ll sum = n % 10;
    if (sum == 2 || sum == 4 || sum == 5 || sum == 7 || sum == 9)
        cout << "hon";
    else if (sum == 0 || sum == 1 || sum == 6 || sum == 8)
        cout << "pon";
    else
        cout << "bon";
}

Measured memory_bytes: 3596
#include <stdio.h>

int main(){
  int n, m, i, j, max, sum;
  int item[1000];

  while(1){
    scanf("%d %d", &n, &m);
    if(n == 0 && m == 0)
      break;
    max = 0;
    sum = 0;
    for(i = 0; i < n; ++i)
      scanf("%d", &item[i]);
    for(i = 0; i < n - 1; ++i)
      for(j = i + 1; j < n; ++j){
	sum = item[i] + item[j];
	if(sum > max && sum <= m)
	  max = sum;
      }
    if(max == 0)
      printf("NONE\n");
    else
      printf("%d\n", max);
  }
  return 0;
}



Measured memory_bytes: 2032
// AOJ 1533: Caterpillar
// 2019.2.28 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

// 数値のハッシュ関数
#define HASHSIZ 99991  // 499979
long long hash[HASHSIZ + 5], *hashend = hash + HASHSIZ;

// 数値をハッシュテーブルに登録。成功からリターン値が1。
int insert(long long n)
{
	long long *p = hash + (int)(n % HASHSIZ);
	while (*p) {
		if (*p == n) return 0;
		if (++p == hashend) p = hash;
	}
	*p = n;
	return 1;
}

#define QMAX 10000
typedef struct { long long p; int s, lv; } Q;
Q q[QMAX + 2]; int top, end;
int mv[4][2] = { {-1,0},{1,0},{0,-1},{0,1} };

int H, W, N;
char map[15][15];

long long next(int nr, int nc, long long p)
{
	int i, j, r[6], c[6];
	r[0] = nr, c[0] = nc;                                    // Sの位置
	r[1] = ((p >> 40) >> 4) & 0xf, c[1] = (p >> 40) & 0xf;   // aの位置
	r[2] = ((p >> 32) >> 4) & 0xf, c[2] = (p >> 32) & 0xf;   // bの位置
	r[3] = ((p >> 24) >> 4) & 0xf, c[3] = (p >> 24) & 0xf;   // cの位置
	r[4] = ((p >> 16) >> 4) & 0xf, c[4] = (p >> 16) & 0xf;   // dの位置
	r[5] = ((p >>  8) >> 4) & 0xf, c[5] = (p >>  8) & 0xf;   // eの位置

	for (i = 0; i < 5; i++) for (j = i + 1; j < 6; j++) {
		if (r[i] == r[j] && c[i] == c[j]) return 0;
	}

	return ((long long)((r[0] << 4) | c[0]) << 40) |
		   ((long long)((r[1] << 4) | c[1]) << 32) |
		   ((long long)((r[2] << 4) | c[2]) << 24) |
		   ((long long)((r[3] << 4) | c[3]) << 16) |
		   ((long long)((r[4] << 4) | c[4]) << 8 ) |
		   ((long long)((r[5] << 4) | c[5]));
}

int bfs(long long p)
{
	int i, r, c, rr, cc, s, lv;
	long long pp;

	q[0].p = p, q[0].s = 0, q[0].lv = 1;
	top = 0, end = 1;
	while (top != end) {
		p = q[top].p, s = q[top].s, lv = q[top].lv;
		if (++top == QMAX) top = 0;

		r = ((p >> 40) >> 4) & 0xf, c = (p >> 40) & 0xf;   // 頭の位置
//		printf("(%d,%d) s=%d, level=%d\n", r, c, s, lv);
		if (map[r][c] == lv+'0') lv++;
		if (lv > N) return s;
		if (!insert(p | ((long long)lv << 48))) continue;

		s++;
		for (i = 0; i < 4; i++) {
			rr = r + mv[i][0], cc = c + mv[i][1];
			if (rr < 0 || rr >= H || cc < 0 || cc >= W || map[rr][cc] == '#') continue;
			if (!(pp = next(rr, cc, p))) continue;
			q[end].p = pp, q[end].s = s, q[end].lv = lv;
			if (++end == QMAX) end = 0;
		}
	}
	return -1;
}

int main()
{
	int r, c;
	long long p;

	scanf("%d%d%d", &H, &W, &N);
	p = 0; for (r = 0; r < H; r++) {
		scanf("%s", map[r]);
		for (c = 0; c < W; c++) {
			switch (map[r][c]) {
			case 'S': p |= ((long long)((r << 4) | c) << 40); break;
			case 'a': p |= ((long long)((r << 4) | c) << 32); break;
			case 'b': p |= ((long long)((r << 4) | c) << 24); break;
			case 'c': p |= ((long long)((r << 4) | c) << 16); break;
			case 'd': p |= ((long long)((r << 4) | c) <<  8); break;
			case 'e': p |= ((long long)((r << 4) | c)      ); break;
			}
			if (isalpha(map[r][c])) map[r][c] = '.';
		}
	}
	printf("%d\n", bfs(p));
	return 0;
}


Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string S,T;
    cin >> S >> T;
    vector<int> Smoji(26),Tmoji(26);
    rep(i,S.size()){
        Smoji[S[i]-'a']++;
        Tmoji[T[i]-'a']++;
    }
    sort(Smoji.begin(),Smoji.end());
    sort(Tmoji.begin(),Tmoji.end());
    rep(i,26){
        if(Smoji[i]!=Tmoji[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3856
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#include<iostream>
using namespace std;
typedef long long ll;
int main()
{
    ll n,x=0,y,i;
    ll a[200010];

    scanf("%lld",&n);
    for(i=1;i<=n;i++)
        scanf("%lld",&a[i]);

    sort(a+1,a+1+n,greater<int>());

    for(;x<=a[x];x++);
    x--;

    if((a[x]-x)%2==0)
    {
        y=0;
        for(;x<=a[x+y];y++);
        if(y%2)
        {
            printf("Second\n");
            return 0;
        }
    }
    printf("First\n");
    return 0;
}


Measured memory_bytes: 1024