akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define mp  make_pair
#define NODE 1000005
#define NINF INT_MIN

vll graph[NODE];
bool vis[NODE];
bool wset[NODE];
int wss;
bool gset[NODE];
bool bset[NODE];
ll n;
void dfs(int node,int dp[]) 
{ 
    // Mark as visited 
    vis[node] = true; 
  
    // Traverse for all its children 
    for (auto v:graph[node]) { 
  
        // If not visited 
        if (!vis[v]) 
            dfs(v,dp); 
  
        // Store the max of the paths
        dp[node] = max(dp[node], 1 + dp[v]); 
    } 
}
  
// Function that returns the longest path 
int findLongestPath(int n) 
{ 
    // Dp array 
    int dp[n + 1]; 
    memset(dp, 0, sizeof dp);
  
    // Call DFS for every unvisited vertex 
    for (int i = 1; i <= n; i++) { 
        if (!vis[i]) 
            dfs(i,dp); 
    } 
  
    int ans = 0; 
  
    // Traverse and find the maximum of all dp[i] 
    for (int i = 1; i <= n; i++) { 
        ans = max(ans, dp[i]); 
    } 
    return ans; 
}

bool dfs(int curr) {
   //moving curr to white set to grey set.
   wset[curr]=false;
   wss--;
   gset[curr]=true;

   for(auto v:graph[curr]) {

         if(bset[v]==true)
            continue;    //if the vertices are in the black set
         if(gset[v]==true)
            return true;    //it is a cycle
         if(dfs(v))
            return true;    //cycle found
   }

   //moving v to grey set to black set.
   gset[curr]=false;
   bset[curr]=true;
   return false;
}

bool hasCycle(int k) {
	wss=0;
   for(int i = 1; i<=k; i++){
      wss++;
      wset[i]=true;   //initially add all node into the white set
   }

   while(wss > 0) {
   	// cout<<1<<endl;
      for(int current = 1; current <= k; current++) {
         if(wset[current]==true)
            if(dfs(current))
               return true;
      }
   }
   return false;
}

ll mymap(pair<ll,ll> p){
	ll a=n-p.second;
	ll key=(n*(n-1))/2-(a*(a+1))/2+p.first-p.second;
	return key;
}

int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	cin>>n;
	// for(auto val: m){
	// 	for(auto p :val.first)
	// 		cout<<p<<" ";
	// 	cout<<":";
	// 	cout<<val.second<<endl;
	// }
	pair<ll,ll> s,t;
	for(ll i=1;i<=n;++i){
		ll val;
		scanf("%d",&val);
		s=mp(max(i,val),min(i,val));
		for(ll j=1;j<n-1;++j){
			scanf("%d",&val);
			t=mp(max(i,val),min(i,val));
			graph[mymap(s)].pb(mymap(t));
			s=t;
		}
	}
	// cout<<"here"<<endl;
	ll k=(n*(n-1))/2;
	// cout<<k<<endl;
	if(hasCycle(k))
		printf("-1\n");
	else{
		// cout<<1<<endl;
		printf("%d",findLongestPath(k)+1);
	}
}

Measured memory_bytes: 44288
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] x = new int[n];

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

    Arrays.sort(x);

    long ans = 1000000000;

    for (int i = x[0]; i <= x[n-1]; i++) {
      long sum = 0;
      for (int j = 0; j < n; j++) {
        sum += (i-x[j])*(i-x[j]);
      }
      ans = Math.min(ans,sum);
    }

    System.out.println(ans);

  }

}


Measured memory_bytes: 23636
#include<stdio.h>
int main(void){
  int n;
  int pm[10000],pe[10000],pj[10000];
  int i;

  scanf("%d",&n);
  while(n){
  for(i=0;i<n;i++)
    scanf("%d %d %d",&pm[i],&pe[i],&pj[i]);
  

  for(i=0;i<n;i++){
    if(pm[i]==100 || pe[i]==100 || pj[i]==100){
      puts("A");
      continue;
    }
    else if((pm[i]+pe[i])/2>=90){
      puts("A");
      continue;
    }
    else if((pm[i]+pe[i]+pj[i])/3>=80){
      puts("A");
      continue;
    }
    else if((pm[i]+pe[i]+pj[i])/3>=70){
      puts("B");
      continue;
    }
    else if((pm[i]+pe[i]+pj[i])/3>=50){
      if(pm[i]>=80 || pe[i]>=80)
	puts("B");
      else 
	puts("C");
      continue;
    }
    else
      puts("C");
  }
  scanf("%d",&n);
  }
  return 0;
}
    
  

  

Measured memory_bytes: 596
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int n;
int d[100];
int s[100];
int ans = 0;
 
int main(void) {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &d[i]);
	}
	for(int i = 0; i <= 100; i++) {
		s[i] = 0;
	}
	for(int i = 0; i < n; i++) {
		s[d[i] - 1]++;
	}
	for(int i = 0; i <= 100; i++) {
		if(s[i] > 0) {
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,K;
    cin >> N >> K;
    vector<int>cnt(200005);
    for(int i = 0; i < N; i++) {
        int A;
        cin >> A;
        cnt[A]++;
    }
    sort(cnt.rbegin(),cnt.rend());
    int ans = 0;
    for(int i = K; i < N; i++) {
        ans += cnt[i];
    }
    cout << ans << endl;
}


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

int main()
{
  string str;

  while (getline(cin, str)){
    while (1){
      for (int i = 0; i < str.size(); i++){
        if ('a' <= str[i] && str[i] <= 'z'){
          if (str[i] != 'z')  str[i]++;
          else  str[i] = 'a';
        }
      }
      if (str.find("the") != string::npos || str.find("this") != string::npos || str.find("that") != string::npos){
        cout << str << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 1176
#include <stdio.h>
int main(void)
{
  char S[256],T[256];
  scanf("%s", S);
  scanf("%s", T);
  int n = 0;
  if(S[0]==T[0]){n++;}
  if(S[1]==T[1]){n++;}
  if(S[2]==T[2]){n++;}
  printf("%d\n", n);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll mod = 1000000007;

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

	ll h, w;
	cin >> h >> w;
	vll okh(h), okw(w);
	vector<string> a(h);	
	REP(i, h){
		cin >> a[i];
		REP(j, w){
			if(a[i][j] == '#'){
				okh[i] = 1;
				okw[j] = 1;
			}
		}
	}
	REP(i, h){
		if(!okh[i]) continue;
		REP(j, w){
			if(okw[j]) cout << a[i][j];
		}
		cout << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //cin,coutの高速化
    int h,w,m;
    cin>>h>>w>>m;
    map< pair<int,int>,int> bomp;
    map<int,int> gyo,retu;
    vector<int> gid,rid;
    int ans=0;
    rep(i,m){
        int bh,bw;
        cin>>bh>>bw;
        bh--,bw--;
        gyo[bh]++,retu[bw]++;
        bomp[{bh,bw}]=1;
    }
    int gmax=0,rmax=0;
    for(auto c:gyo){
        int num = c.second;
        gmax = max(num,gmax);
    }
    for(auto c:retu){
        int num = c.second;
        rmax = max(num,rmax);
    }
    for(auto c:gyo){
        if(c.second==gmax) gid.push_back(c.first);
    }
    for(auto c:retu){
        if(c.second==rmax) rid.push_back(c.first);
    }
    ans = gmax+rmax-1;
    for(int g:gid){
        for(int r:rid){
            if(bomp[{g,r}]!=1){
                ans = gmax+rmax;
                break;
            }
            
        }
    }
    cout<<ans<<endl;
}

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

class Program
{
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        int n = cin.NextInt();
        List<Tuple<string, int>> e = new List<Tuple<string, int>>();
        for (int i = 0; i < n; i++)
        {
            e.Add(Tuple.Create<string, int>(cin.Next(), cin.NextInt()));
        }
        Dictionary<Tuple<string, int>, int> container = new Dictionary<Tuple<string, int>, int>();

        for (int i = 1; i <= n; i++)
        {
            int index = i - 1;
            container.Add(e[index], i);
        }
        e.Sort((a, b) => Compare(a, b));
        foreach(var a in e)
        {
            Console.WriteLine(container[a]);
        }
    }

    int Compare(Tuple<string, int> x, Tuple<string, int> y)
    {
        if (string.Compare(x.Item1, y.Item1) > 0)
        {
            return 1;
        }
        else if (string.Compare(x.Item1, y.Item1) < 0)
        {
            return -1;
        }
        else if (x.Item2 > y.Item2)
        {
            return -1;
        }
        else
        {
            return 1;
        }
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public char[] ArrayChar()
    {
        return Next().ToCharArray();
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13536
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

#define MAXN   100001 
  
int spf[MAXN]; 
  
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++)
        spf[i] = i; 

    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  
vector<int> getFactorization(ll x) 
{ 
    vector<int> ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 

vector<ll> primeFactors(ll n)  { 
	vector<ll> res;
    while (n % 2 == 0)  {  
    	res.push_back(2);
        n = n/2;  
    }  
    for (ll i = 3; i * i <= n; i = i + 2)  {   
        while (n % i == 0)  {  
            res.push_back(i);
            n = n/i;  
        }  
    }  
    if (n > 2)  
        res.push_back(n);
    return res; 
}  

void testcase() {
	//sieve();
    ll n; cin >> n;
    vector<ll> fac = primeFactors(n);
    sort(fac.begin(), fac.end());
    int m = fac.size();

    int i=0;
    int res = 0;
    while (i < m) {
    	ll cur = fac[i];
    	int ct = 0;
    	while (i < m && cur == fac[i]) {
    		ct++;
    		i++;
    	}
    	int sum = 0, c = 0;
    	while (true) {
    		sum += c; 
    		if (sum  > ct) {
    			c--;
    			break;
    		}
    		c++;
    	}
    	res += c;
    }
    cout << res;

}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3648
def spline(func=int, iter_=None):
    if iter_ is None:
        iter_ = input().split()
    return map(func, iter_)


N, Y = spline()
N += 1
res = None
for x in range(N):
    n = N - x
    xm = x * 10000
    if xm > Y:
        break
    for y in range(n):
        z = n - y - 1
        m = xm + y * 5000 + z * 1000
        if m == Y:
            res = (x, y, z)
            break
    else:
        continue
    break
if res is None:
    res = (-1, -1, -1)
print(*res)


Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))
dic = {}
for i in range(N):
  if dic.get(A[i]) is None: 
    dic[A[i]] = 1
  else:
    dic[A[i]] += 1

ans = 0
for k in dic:
  if dic[k] >= k:
    ans += abs(dic[k] - k)
  else:
    ans += dic[k]
print(ans)

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

void swap(int* a, int* b);

void swap(int* a, int* b){
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int main(){
    int x, y;
    while(cin >> x >> y, x != 0 || y != 0){
        int cnt = 0;
        if(x < y) swap(&x, &y);
        while(y != 0){
            x = x % y;
            swap(&x, &y);
            cnt++;
        }
        cout << x << " " << cnt << endl;
    }
    return 0;
}

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

int main() {
  int X; cin >> X;
  int fh = 1000;
  int f = 5;

  int ans = (X / 500) * fh;
  ans += ((X - ((X / 500) * 500)) / 5) * f;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

const int N = 202020;

int n;
int a[N], cnt[N];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, m;
    cin >> n >> m;
    ll L = 0, R = 1e14;
    while (L + 1 < R)
    {
        ll M = (L + R) / 2;
        if (m - 2 * M >= 2 * (n + M)) L = M;
        else R = M;
    }
    m -= 2 * L, n += L;
    while (m - 2 >= 2 * (n + 1)) m -= 2, n++;
    cout << min(n, m / 2);
    return 0;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


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

int main(void)
{
  int n;
  long int j;
  long int sum=0;
  scanf("%d",&n);

  for(int i=1;i<=n;i++)
  {
    j=(long int)n/i;
    sum += j*(j+1)*i/2;
  }
  printf("%ld\n",sum);

  return 0;
}

Measured memory_bytes: 1716
"use strict";

var processData = function processData(lines) {
  var r = +lines[0];
  console.log(r * Math.PI * 2);
};

var i = '';
process.stdin.on('data', function (c) {
  return i += c;
});
process.stdin.on('end', function () {
  var _require = require('os'),
      EOL = _require.EOL;

  var lines = i.split(EOL);
  /*your input text, split by lines*/

  processData(lines);
});


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end



int main(){
   int a,b,m; scanf("%d%d%d",&a,&b,&m);
   vector<int> as(a),bs(b);
   rep(i,0,a)scanf("%d",&as[i]);
   rep(i,0,b)scanf("%d",&bs[i]);
   int res=*min_element(ALL(as))+*min_element(ALL(bs));
   rep(i,0,m){
      int x,y,c; scanf("%d%d%d",&x,&y,&c); x--; y--;
      chmin(res,as[x]+bs[y]-c);
   } printf("%d\n",res);
   return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define trav(a,x) for (auto& a: x)
#define cout(tt) cout<<"Case #"<<(tt)<<": ";
#define minheap(name) priority_queue <int, vector<int>, greater<int> > (name); 
#define ll long long int
/*	Things to remember handling:
	1. int overflows
	2. array boundaries
	3. base cases (n=1)
*/

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int H,W;
	cin>>H>>W;
	vector<vector<char>> grid(H,vector<char>(W));
	FOR(i,0,H){
		FOR(j,0,W){
			cin>>grid[i][j];
		}
	}
		vector<vector<ll>> dp(H,vector<ll>(W,0));
		
		for(int i=0;i<W;i++)
				if(grid[0][i]=='#')
					break;
				else
					dp[0][i] = 1;
		for(int i=0;i<H;i++)
				if(grid[i][0]=='#')
					break;
				else
					dp[i][0] = 1;
					
		for(int i=1;i<H;i++){
			for(int j =1;j<W;j++){
				if(grid[i][j] =='.')
				dp[i][j] = ( dp[i-1][j] + dp[i][j-1] )%1000000007;
			}
		}
		cout<< dp[H-1][W-1]<<endl;
}


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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) { cin1(x[i]); }
#define ncin2(n, x, y)      REP(i, 0, n) { cin2(x[i], y[i]); }
#define ncin3(n, x, y, z)   REP(i, 0, n) { cin3(x[i], y[i], z[i]); }
#define ncinp(n, p)         REP(i, 0, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }
#define ncin1_1(n, x)       REPE(i, 1, n) { cin1(x[i]); }
#define ncin2_1(n, x, y)    REPE(i, 1, n) { cin2(x[i], y[i]); }
#define ncin3_1(n, x, y, z) REPE(i, 1, n) { cin3(x[i], y[i], z[i]); }
#define ncinp_1(n, p)       REPE(i, 1, n) { lli p1,p2; cin >> p1 >> p2; p[i] = P(p1, p2); }

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    lli a,b;
    cin2(a,b);
    cout << max({a+b, a-b, a*b}) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#define ll long long 
using namespace std;

struct node
{
	ll x; ll sz;
	bool operator < (const node& a) const
	{
		return x < a.x;
	}
};

priority_queue<node> q;
int main()
{
	std::ios::sync_with_stdio(false);
	ll N; ll M; cin >> N >> M;
	for (int i = 1; i <= N; i++)
	{
		ll x; cin >> x;
		q.push(node{ x, 1ll });
	}
	for (int i = 1; i <= M; i++)
	{
		ll b; ll c; cin >> b >> c;
		q.push(node{ c,b });
	}

	ll ans = 0; ll n = 0;
	while (n < N)
	{
		ll sz = q.top().sz;
		ll x = q.top().x;
		q.pop();
		if (n + sz <= N)
		{
			n += sz; ans += sz * x;
		}
		else
		{
			ans += (N - n) * x; break;
		}
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 6384
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#define N 100020
#define Q 100020
using namespace std;

int a[Q];
int c[N];

int main(void)
{
    int n, k, q;
    int i;

    scanf("%d %d %d", &n, &k, &q);
    for(i = 1; i <= q; i ++)
    {
        scanf("%d", &a[i]);
        ++ c[a[i]];
    }

    for(i = 1; i <= n; i ++)
        puts((q - c[i]) < k ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
int n,m,x;
  cin>>n>>m>>x;
  int ans=10101010;
  int a[12][12];
  vector<int>c(n);
  rep(i,n){
  	cin>>c.at(i);
    	rep(j,m) cin>>a[i][j];
  }
  rep(s,1<<n){
    int cost=0;
    vector<int>d(m,0);
  	rep(i,n){
    	if(s>>i &1){
        	cost+=c.at(i);
          	rep(j,m) d.at(j)+=a[i][j];
        }
    }
    bool ok=true;
    rep(j,m) if(d.at(j) <x) ok=false;
    if(ok) ans=min(ans,cost);
   }
  if(ans==10101010) cout<<-1<<endl;
  else cout<<ans<<endl;
}
// ビット全探索を使って考える

Measured memory_bytes: 3604
k, s = gets.chomp.split(' ').map(&:to_i)
cnt = 0

if k*3 < s
    cnt = 0
elsif k*3 == s
    cnt = 1
else
    0.upto(k) do |a|
        0.upto(s-a) do |b|
            next if b > k || (a + b) > s
            cnt += 1 if s - a - b <= k
        end
    end
end
puts cnt

Measured memory_bytes: 1788
// template version 1.2
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0LL)
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

template<typename A, size_t N, typename T> // n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  int n;cin>>n;
  int a[n]; rep(i, n) {cin>>a[i];}

  int dp[n+1] = {};
  dp[a[0]]=1;
  rep(i, 1, n){ dp[a[i]] = (dp[a[i]-1]?dp[a[i]-1]+1:1); }
  dump_1d(dp, n+1);

  int d = *max_element(dp, dp+n+1);
  dump(d);

  cout << n-d << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define repl(n) for (int l = 0; l < (n); l++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
ll modpow(ll a, ll b, ll m) {
  ll re = 1, k = 1;
  while (k <= b) {
    if (b & k) {
      re *= a;
      re %= m;
    }
    k = k << 1;
    a *= a;
    a %= m;
  }
  return re;
}
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

int a[100], b[100], c[100];
int main() {
  // int n;
  // cin >> n;
  // cout << n * n * n << endl;
  int n;
  cin >> n;
  repi(n) cin >> a[i];
  repi(n) cin >> b[i + 1];
  repi(n - 1) cin >> c[i + 1];
  ll re = 0;
  int pre = -100;
  repi(n) {
    re += b[a[i]];
    if (pre == a[i] - 1) re += c[a[i] - 1];
    pre = a[i];
  }
  cout << re << endl;
}


Measured memory_bytes: 256
from itertools import product
L, R = map(int, input().split())
MOD = 10**9 + 7

dp = [[[0, 0] for _ in range(2)] for _ in range(2)]
pp = [[[0, 0] for _ in range(2)] for _ in range(2)]
dp[0][0][0] = 1
for d in range(60, -1, -1):
    pp, dp = dp, pp
    dp = [[[0, 0] for _ in range(2)] for _ in range(2)]
    lb = L>>d & 1
    rb = R>>d & 1
    if d == 1:
        pass
    ans = 0
    for lrs in product((0,1), repeat=3):
        l, r, s = lrs
        for xy in product((0,1), repeat=2):
            nl, nr, ns = l, r, s
            x, y = xy
            if x and not y:
                continue
            if not s and x != y:
                continue
            if x and y:
                ns = 1
            if not l and not x and lb:
                continue
            if x and not lb:
                nl = 1
            if not r and y and not rb:
                continue
            if not y and rb:
                nr = 1
            dp[nl][nr][ns] += pp[l][r][s]
            dp[nl][nr][ns] %= MOD

print(sum(dp[l][r][s] for l in (0,1) for r in (0,1) for s in (0,1)) % MOD)


Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;

public class Main {
	static HashMap<String, Integer> map = new HashMap<String, Integer>();

	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int n = Integer.parseInt(br.readLine());
		String[] str = br.readLine().split(" ");
		int[] a = new int [n];
		int[] ans = new int [n];
		int pos = 0;
		for(int i = 0; i < n; i++){
			a[i] = Integer.parseInt(str[n-i-1]);
			if(i%2 == 0){
				ans[pos] = a[i];
			}else{
				ans[n-pos-1] = a[i];
				pos++;
			}
		}
		System.out.print(ans[0]);
		for(int i = 1; i < n; i++){
			System.out.print(" "+ans[i]);
		}
	}
}

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

const int N = 10000;


void initTbl(unsigned char* p, unsigned char*rev_p){
	p[0]=1;
	rev_p[N-1]=1;

    for(int i=4; i<N; i+=2){
        p[i-1] = 1;
		rev_p[(N-1)-(i-1)] = 1;
    }
 
    for(int j=3; j*j<=N; j+=2){
        for(int k=j; j*k<=N ;k+=2){
            p[j*k-1] = 1;
			rev_p[(N-1)-(j*k-1)] = 1;
        }
    }
}

//0104
int main(){
	unsigned char isprime[N]={0};
	unsigned char rev_isprime[N]={0};

	initTbl(isprime, rev_isprime);

	int n;
	while(cin >> n){
		int count=0;
		int ofs=N-n;
		for(int i=0; i<n; ++i){
			if(isprime[i]==0 && rev_isprime[i+ofs]==0){
				++count;
			}
		}
		cout << count << endl;
#ifdef debug
		for(int i=0; i<n; ++i){
			cout.width(3);
			cout << i+1 ;
		}
		cout << endl;
		for(int i=0; i<n; ++i){
			cout.width(3);
			cout <<  (isprime[i]?"":"*") ;
		}
		cout << endl;
		for(int i=0; i<n; ++i){
			cout.width(3);
			cout << (rev_isprime[i+ofs]?"":"*");
		}
		cout << endl;
#endif

	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main{

    public static void main(String args[]){

        // スキャナーの宣言
        Scanner sc = new Scanner(System.in);
        // 整数の入力
		int n = sc.nextInt();
        // スペース区切りの整数の入力
        int k = sc.nextInt();

        // 出力
        System.out.println(n-k+1);

    }

}


Measured memory_bytes: 23892
#include<stdio.h>

int main() {
	int a, b, i;
	scanf("%d%d", &a,&b);
	for (i = 10; b >= i; i *= 10);
	a = a*i+b;
	//printf("%d", a);
	for (i = 1; a > i*i; i++);
	if (a == i*i) { printf("Yes\n"); }
	else { printf("No\n"); }
	//getch();
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a==1) a = 14;
  if(b==1) b = 14;
  if(a==b) cout << "Draw" << endl;
  else if(a>b) cout << "Alice" << endl;
  else cout  << "Bob" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define int long long

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


ll m = 1000000007;

const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

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



long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}

std::vector<ll> enum_div(ll n)//nの約数を列挙
{
	std::vector<ll> ret;
	for (int i = 1; i*i <= n; ++i)
	{
		if (n%i == 0)
		{
			ret.push_back(i);
			if (i != 1 && i*i != n)
			{
				ret.push_back(n / i);
			}
		}
	}
	ret.pb(n);
	return ret;
}

int x[101], y[101], h[101];
signed main() {
	int N; cin >> N;
	REP(i, N) {
		cin >> x[i] >> y[i] >> h[i];
	}
	int H = 0, X, Y;
	int ans = 0;
	if (N == 1) {
		REP(i, 101) {
			REP(j, 101) {
				H = h[0] + abs(i - x[0]) + abs(j - y[0]);
				if (H > ans) {
					ans = H;
					X = i; Y = j;
				}
			}
		}
		cout << X << " " << Y << " " << ans << endl;
		return 0;
	}
	REP(i, 101) {
		REP(j, 101) {
			bool ok = true;
			FOR(k, 0, N) {
				if (h[k] == 0)continue;
				H = h[k] + abs(i - x[k]) + abs(j - y[k]);
				break;
			}
			int H2;
			FOR(k, 0, N) {
				if (h[k] == 0) {
					if (H - abs(i - x[k]) - abs(j - y[k]) > 0) {
						ok = false;
						break;
					}
					else continue;
				}
				H2 = h[k] + abs(i - x[k]) + abs(j - y[k]);
				if (H != H2) {
					ok = false;
					break;
				}
			}
			if (ok) {
				if (H > ans) {
					ans = H;
					X = i; Y = j;
				}
			}
			else continue;
		}
	}
	cout << X << " " << Y << " " << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  ll ans=0;
  ll n;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
    ll y = n/i;
    ans += y*(y+1)*i/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    std::cout << std::defaultfloat << std::setprecision(10);
    
    double L; cin >> L;
    double i = L/3;

    cout << i*i*i << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    vector<int> c;
    if (s[0] == '0') c.push_back(0);
    int cnt = 1;
    for (int i = 1; i < n; ++i) {
        if (s[i] != s[i-1]) {
            c.push_back(cnt);
            cnt = 1;
        } else {
            ++cnt;
        }
    }
    c.push_back(cnt);
    if (s[n-1] == '0') c.push_back(0);

    int len = k * 2 + 1;
    if (c.size() <= len) {
        cout << n << endl;
        return 0;
    }

    int v = accumulate(c.begin(), c.begin() + len, 0);
    int ans = v;
    for (int l = 2; l <= c.size() - len; l += 2) {
        v -= c[l-2] + c[l-1];
        v += c[l+len-2] + c[l+len-1];
        ans = max(v, ans);
    }

    cout << ans << endl;

    return 0;
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
	ll n,a,b;cin>>n>>a>>b;
	vector<ll> h(n);
	int i;
	rep(i,n)cin>>h[i];
	int low=1;
	int high=1000000000;
	int ok=high;
	while(low<=high)
	{
		int kans=(high+low)/2;
		ll bomc=0;
		rep(i,n)
		{
			if(h[i]-b*kans>0)
			{
				bomc+=(h[i]-b*kans+a-b-1)/(a-b);
			}
		}
		if(bomc<=kans)
		{
			ok=kans;
			high=kans-1;
		}
		else
		{
			low=kans+1;
		}
	}
	cout<<ok<<endl;
}


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

int main()
{
    ///queに格納
    queue<char> a, b, c;
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    rep(i, sa.length()) a.push(sa[i]);
    rep(i, sb.length()) b.push(sb[i]);
    rep(i, sc.length()) c.push(sc[i]);
    a.push('z');
    b.push('z');
    c.push('z');

    //ゲームスタート
    char p = 'a'; //次を示す
    while (1)
    {
        if (p == 'a')
        {
            if (a.front() == 'z')
            {
                cout << 'A' << endl;
                return 0;
            }
            p = a.front();
            a.pop();
        }
        if (p == 'b')
        {
            if (b.front() == 'z')
            {
                cout << 'B' << endl;
                return 0;
            }
            p = b.front();
            b.pop();
        }
        if (p == 'c')
        {
            if (c.front() == 'z')
            {
                cout << 'C' << endl;
                return 0;
            }
            p = c.front();
            c.pop();
        }
    }
}

Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

case class Coord(x: Double, y: Double) extends Ordered[Coord] {

  def this(p: (Double, Double)) = this(p._1, p._2)

  def compare(that: Coord): Int = {
    if (this.x != that.x)
      this.x.compare(that.x)
    else
      this.y.compare(that.y)
  }

  def +(co: Coord): Coord = {
    Coord(this.x + co.x, this.y + co.y)
  }

  def -(co: Coord): Coord = {
    Coord(this.x - co.x, this.y - co.y)
  }

  def toPair: (Double, Double) = (x, y)

  def dist(that: Coord): Double = {
    import Math.{sqrt, pow}
    sqrt(pow(this.x - that.x, 2) + pow(this.y - that.y, 2))
  }

  def moveTo(that: Coord, ratio: Double): Coord = {
    import Math.{sqrt, pow, abs}
    val dx = abs(x - that.x) * ratio
    val dy = abs(y - that.y) * ratio

    val gx =
      if (x > that.x) x - dx
      else x + dx
    val gy =
      if (y > that.y) y - dy
      else y + dy

    Coord(gx, gy)
  }

}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val p = new Array[Coord](N)
  for (i <- 0 until N) {
    val x, y = in.next().toInt
    p(i) = Coord(x, y)
  }

  //
  var now = Coord(0.0, 0.0)
  for (n <- 1 to 1500000) {
    var hoge: Coord = null
    var maxDist = 0.0
    for (c <- p) {
      if (now.dist(c) > maxDist) {
        maxDist = now.dist(c)
        hoge = c
      }
    }

    now = now.moveTo(hoge, 1.0 / n)
  }

  var maxDist = 0.0
  for (c <- p) {
    if (now.dist(c) > maxDist) {
      maxDist = now.dist(c)
    }
  }

  println(maxDist)
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 65468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {

	int r, c; cin >> r >> c;

	vector<vector<char>> a(r + 2, vector<char>(c + 2, 'e'));

	for (int i = 1; i <= r; i++) for (int j = 1; j <= c; j++) cin >> a[i][j];

	int ans = 0;
	for (int sy = 1; sy <= r ; sy++) {
		for (int sx = 1; sx <= c; sx++) {

			if (a[sy][sx] == '#') continue;

			// BFS のためのデータ構造
			vector<vector<int>> dist(r + 2, vector<int>(c + 2, -1)); // 全頂点を「未訪問」に初期化
			queue<pair<int, int>> que;

			// 初期条件
			dist[sy][sx] = 0;
			que.push({ sy,sx });

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

			int tmp = 0;

			// BFS 開始 (キューが空になるまで探索を行う)
			while (!que.empty()) {

				pair<int, int> p = que.front(); // キューから先頭頂点を取り出す
				que.pop();

				// p から辿れるマスをすべて調べる
				for (int i = 0; i < 4; i++) {

					int y_next = p.first + dy[i];
					int x_next = p.second + dx[i];

					if (dist[y_next][x_next] != -1) continue;
					if (a[y_next][x_next] == 'e' || a[y_next][x_next] == '#') continue;

					// 新たなマス { y_next, x_next } について距離情報を更新してキューに追加する
					dist[y_next][x_next] = dist[p.first][p.second] + 1;
					que.push({ y_next, x_next });
					tmp = max(tmp, dist[y_next][x_next]);
				}

			}
			ans = max(ans, tmp);
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {

		Scanner sc = new Scanner(System.in);

		int dir[][] = { { 0, -1 }, { 0, 1 }, { 1, 0 } };

		while (true) {
			final int w = sc.nextInt();
			final int h = sc.nextInt();

			if (w == 0 && h == 0) {
				break;
			}

			final int amount = sc.nextInt();
			final int capacity = sc.nextInt();
			final int init = sc.nextInt();

			int[][] map = new int[h][w];

			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					map[i][j] = sc.nextInt();
				}
			}

			PriorityQueue<Walk> queue = new PriorityQueue<Walk>();
			for (int i = 0; i < w; i++) {
				boolean[][] b = new boolean[h][w];
				Walk walk = new Walk(0, init, 0, i, b);
				walk.sanso--;
				queue.add(walk);
			}

			boolean flag = false;
			while (!queue.isEmpty()) {
				Walk walk = queue.poll();
				int y = walk.y;
				int x = walk.x;

				if (walk.sanso <= 0) {
					continue;
				} else if (walk.y >= h) {
					flag = true;
					System.out.println(walk.cost);
					break;
				}

				walk.visited[y][x] = true;

				if (map[y][x] <= 0) {
					walk.cost += (-map[y][x]);
				} else {
					walk.sanso = Math.min(map[y][x] + walk.sanso, capacity);
				}

				if (walk.cost > amount) {
					continue;
				}

				for (int i = 0; i < 3; i++) {
					int ny = y + dir[i][0];
					int nx = x + dir[i][1];
					if (nx >= 0 && nx < w && ny >= 0 && ny <= h - 1
							&& !walk.visited[ny][nx]) {
						Walk wa = new Walk(walk);
						wa.y = ny;
						wa.x = nx;
						wa.sanso--;
						queue.add(wa);
					} else if (i == 2 && walk.y == h - 1) {
						Walk wa = new Walk(walk);
						wa.y++;
						queue.add(wa);
					}
				}
			}

			if (!flag) {
				System.out.println("NA");
			}

		}
	}
}

class Walk implements Comparable<Walk> {
	int cost;
	int sanso;
	int x, y;
	boolean[][] visited;

	public Walk(int cost, int sanso, int y, int x, boolean[][] visited) {
		super();
		this.cost = cost;
		this.sanso = sanso;
		this.x = x;
		this.y = y;
		this.visited = visited;
	}

	public Walk(Walk w) {
		this.cost = w.cost;
		this.sanso = w.sanso;
		this.x = w.x;
		this.y = w.y;
		visited = new boolean[w.visited.length][w.visited[0].length];
		for (int i = 0; i < w.visited.length; i++) {
			visited[i] = Arrays.copyOf(w.visited[i], w.visited[0].length);
		}
	}

	@Override
	public int compareTo(Walk arg0) {
		return this.cost - arg0.cost;
	}
}

Measured memory_bytes: 75864
//d
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair

using namespace std;

static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;

map<string, int> cores;
int n;
int jmp[128];
int vis[128];
int res = INT_MAX;

void solve(int now, int del){
	
	if(vis[now])
		return;
		
	if(now == n+1){
		res = min(res, del);
		return;
	}
	
	vis[now] += 1;
	
	if(jmp[now] != 0){	
		solve(jmp[now], del);
		solve(now+1, del+1);
	}
	else{
		solve(now+1, del);
	}
	
	vis[now] -= 1;
	
	return;
}

int main(){
	
	string str1, str2;
	queue<string> undef;
	cin >> n;
	
	CLR(vis);
	
	for(int i=1; i<=n; ++i){
	
		cin >> str1;
		
		if(str1 == "goto"){
		
			cin >> str2;
			str2.erase(str2.size()-1);
			
			if(!cores.count(str2)){
				jmp[i] = -1;
				undef.push(str2);
			}
			else
				jmp[i] = cores[str2];
		}
		else{
			str1.erase(str1.size()-1);
			cores[str1] = i;
			jmp[i] = 0;
		}
	}
	
	int ptr = 1;
	
	while(!undef.empty()){
		
		if(jmp[ptr] < 0){
			jmp[ptr] = cores[undef.front()];
			undef.pop();
		}
		
		ptr++;
	}
	
	solve(1, 0);
	cout << res << endl;
	
	return 0;	
}

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

int main() {
    int A, B, C;

    cin >> A >> B >> C;

    if ( A == 5 && B == 5 && C ==7){
        cout << "YES" << endl;
    } else if (A == 5 && B == 7 && C == 5){
        cout << "YES"  << endl;
    } else if (A == 7 && B == 5 && C == 5){
        cout << "YES"  << endl;
    } else {
        cout << "NO"   << endl;
    }

    return 0;

}


Measured memory_bytes: 256