akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll inf = 1e18;
constexpr ll mod = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a[5];
    for (int i = 0; i < 5;i++){
        cin >> a[i];
    }
    int mi = mod;
    for (int i = 0; i < 5;i++){
        int sum = 0;
        for (int j = 0; j < 5;j++){
            if(i==j)
                sum += a[j];
                else{
                    if(a[j]%10==0)
                        sum += a[j];
                        else
                            sum += (a[j] / 10 + 1) * 10;
                }
        }
        mi = min(mi, sum);
    }
    cout << mi << endl;
    return 0;
}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  int h,w; cin >> h >> w;
  vector< vector<char> > s(h+2,vector<char>(w+2,'.'));
  for(int i=1;i<=h;i++) { for(int j=1;j<=w;j++) { cin >> s[i][j]; } }

  int check=0;
  for(int i=1;i<=h;i++) {
    for(int j=1;j<=w;j++) {
      if(s[i][j] == '#') {
        if(s[i][j-1] != '#' && s[i-1][j] != '#' && s[i+1][j] != '#' && s[i][j+1] != '#') {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3640
import Control.Applicative
import Data.Array.IArray
import Data.Array.ST 
import Control.Monad
import Control.Monad.ST
import Debug.Trace
import Data.List

type Graph = Array Int [Int]
type STResult s = STArray s Int (Int, Int)
type Result = Array Int (Int, Int)

main :: IO ()
main = do
  n <- readLn :: IO Int
  ns <- replicateM n $ do
    (a:b:ns) <- getInts
    return (a, ns)
  let graph = makeGraph n ns
  mapM_ putStrLn $ res2str $ solve n graph

getInts :: IO [Int]
getInts = map read . words <$> getLine

makeGraph :: Int -> [(Int, [Int])] -> Graph
makeGraph n = accumArray (++) [] (1, n)

res2str :: Result -> [String]
res2str res = zipWith (curry f) [1..] res' 
  where
    res' :: [(Int, Int)]
    res' = map (res !) [1..(snd (bounds res))]
    f (a, (b, c)) = show a ++ " " ++
                    show b ++ " " ++ show c

solve :: Int -> Graph -> Result
solve n graph = runST $ do
  res <- newArray (1, n) (-1, -1) :: ST s (STResult s)
  solve' 1 2 [] res
  where
    solve' m d path res = do
      writeArray res m (d-1, -1)
      res'<- dfs m d path res
      let (flg, n', d') = check res'
      if flg
        then return res'
        else do
        res'' <- thaw res'
        solve' n' (d'+2) [] res''
      where
        dfs :: Int -> Int -> [Int] ->
               STResult s -> ST s Result
        dfs current depth ls _res
          = do
              cs <- filterM (\i -> do
                                (s, _) <- readArray _res i
                                return (s == -1)) is
              if null cs
                then do
                (s', _) <- readArray _res current 
                writeArray _res current (s', depth)
                if null ls
                  then do
                  writeArray _res m (d-1, depth)
                  freeze _res
                  else
                  dfs (head ls) (depth + 1) (tail ls) _res
                else do
                let c = head cs
                writeArray _res c (depth, 0)
                dfs c (depth + 1) (current:ls) _res
                  where
                    is = graph ! current
    check :: Result -> (Bool, Int, Int)
    check res = (flg, n', d')
      where
        is = map (\i -> let (s, e) = res ! i in
                          (i, s, e) ) [1..n]
        (_, _, d') = maximumBy (\(_, _, c1) (_, _, c2) ->
                           compare c1 c2) is
        (n', _, _) = minimumBy (\(n1, _, _) (n2, _, _) ->
                       compare n1 n2) $
                     filter (\(_, s1, _) -> s1 == -1) is
        flg = all (\(n, s, e) -> s /= -1) is
        
        

Measured memory_bytes: 4212
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ll rt<<1
#define rr rt<<1|1
#define PI acos(-1)
#define MM int m=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
//#define P pair<int,int>
using namespace std;
const int INF=LLONG_MAX;
const int maxn=1e6+5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;
int jc[maxn];
int Pow(int a,int b){//快速幂
    a%=mo_num;
    int ans = 1;
    while(b)
    {
        if(b&1)
            ans = (ans*a)%mo_num;
        a = (a*a)%mo_num;
        b/=2;
    }
    return ans%mo_num;
}
int ext_gcd(int a,int b,int &x,int &y){ if(b==0){x=1;y=0;return a;}int q=a/b, g=ext_gcd(b,a-q*b,x,y), z=x-q*y;x=y; y=z;return g; }
int inv(int a){ int x,y;ext_gcd(a,mo_num,x,y);return (x+mo_num)%mo_num; }
void init(int *x, int len){ x[0]=1;for(int i=1;i<len;i++)x[i]=(x[i-1]*i)%mo_num; }
int CC(int r,int n){ if(n<0 or n<r or r<0)return 0;return (jc[n]*inv(jc[r])%mo_num)*inv(jc[n-r])%mo_num; }
int A,B,C;
int did(int aa,int bb,int x)
{
    return mod(mod(Pow(aa,n)*Pow(bb,x-n))*Pow(inv(aa+bb),x));
}
int qw(int x)
{
    return mod(mod(CC(n-1,x-1)*(did(A,B,x)+did(B,A,x)))*mod((int)100*inv((int)100-C)));
}
int32_t main()
{
    IOS
    cin>>n>>A>>B>>C;
    init(jc,2*n+10);//这个是初始化阶乘数组的上限
    fu(i,n,2*n-1)
    {
        ans=mod(ans+mod(i*qw(i)));
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3840
#

import sys
from fractions import gcd
input=sys.stdin.readline

def main():
    MOD=10**9+7
    N=int(input())
    A=list(map(int,input().split()))
    if N==1:
        print(1)
        exit()
    l=(A[0]*A[1])//gcd(A[0],A[1])
    for i in range(2,N):
        l=(l*A[i])//gcd(A[i],l-A[i])
    l%=MOD
    ans=0
    for i in range(N):
        ans+=l*pow(A[i],MOD-2,MOD)
        ans%=MOD
    print(ans)
    
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 6112
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define N 100010
char s[N];
int main()
{
	cin>>s;
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD           1000000007LL
#define ll            long long
#define ld            long double
#define all(x)        (x).begin (),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define pb            push_back
#define mp            make_pair
#define vi            vector<ll>
#define pii           pair<ll,ll>
#define vii           vector<pii>
#define mi            map<ll,ll>
#define lb            lower_bound
#define ub            upper_bound
#define endl          "\n"
#define si            set<ll>
#define gcd(a,b)      __gcd(a,b)
#define lcm(a,b)      (a*(b/gcd(a,b)))
#define rep(i,a,b) for(unsigned ll i=a;i<b;i++)
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  int modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  int modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  int modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  int modPow(ll b, ll p) { int r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  int modInv(int a) { return modPow(a, MOD-2); }
inline  int modDiv(int a,int b) { return modMul(a, modInv(b)); }
inline  int fact(int r){ int ans=1;while(r)ans=modMul(ans,r),r--;return ans; }
inline  int invfact(int r){int ans=1;while(r)ans=modMul(ans,modInv(r)),r--; return ans;}

ll binary_power(ll a, ll n) {
    if (n==0) return 1;
    ll k=binary_power(a,n/2);
    if (n%2==0) return (k*k)%MOD;
    else return (((k*k)%MOD)*a)%MOD;
}
bool isPrime(int num){
    bool flag=true;
    for(int i = 2; i*i <= num ; i++) {
       if(num % i == 0) {
          flag = false;
          break;
       }
    }
    return flag;
}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll calc(ll n, ll r)
{
    ll k=1;
    while(r>0)
    {
        k = ((k%MOD)*((n/r)%MOD))%MOD;
        n--; r--;
    }
    return k%MOD;
}
void solve()
{
   ll n,k; cin>>n>>k;
   ll mn = modMul(n,n+1)/2;
   ll mx = mn;
   ll cnt=0;
   ll N=n+1;
   ll a[N];
   memset(a,0,sizeof(a));
   rep(i,0,N)
   {
       cnt = modAdd(cnt,mx-mn+1);
       mx-=i;
       mn-=N-i-1;
       a[N-i-1]+=cnt;
   }
   cout<<a[k-1];
}

int main()
{
    SPEED;
    ll t = 1;

  // cin>>t;

    while(t--) solve();

   return 0;
}


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

int main()
{

    ll n;
    cin>>n;

    ll a[10];
    for(int i=1;i<10;i++)
    a[i]=i;

    vector<int >v;


    for(int i=1;i<10;i++)
    {
        for(int j=i;j<10;j++)
        {
            int p= a[i]*a[j];
            v.push_back(p);
        }
    }

    sort( v.begin(), v.end() );
    v.erase( unique( v.begin(), v.end() ), v.end() );

    int t=0;

    for(int i=0;i<v.size();i++)
    {
        if(v[i]==n)
        {
            t=1;
            break;
        }
        //cout<<v[i]<<" ";
    }

    if(t==1)
    cout<<"Yes";
    else
    {
        cout<<"No";

    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>

using namespace std;

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define REPS(i, n) for(int i=1;i<=(int)(n);i++)
#define RREP(i, n) for(int i=(int)n-1;i>=0;i--)
#define RREPS(i, n) for(int i=(int)n;i>0;i--)

typedef vector<int> vi;
double d, n, b, p[12], h[12];

int check(double vx, double vy, double w){
	REP(i, n){
		double x = p[i];
		while(x > w) x -= w;
		double y = -x*x/(2*vx*vx)+vy/vx*x;
		if(y < h[i]) return 0;
	}
	return 1;
}

int main(){
	cin >> d >> n >> b;
	REP(i, n) cin >> p[i] >> h[i];
	
	double ans = 1e9;
	REP(i, b+1){
		double w = d / (i+1);
		double l = 1, r = 1e9;
		double res = 0;
		REP(itr, 50){
			double mid = (l+r)/2;
			double vx = sqrt(w / (2*mid));
			double vy = vx * mid;
			res = sqrt(vx*vx + vy*vy);
			if(check(vx, vy, w)) r = mid;
			else l = mid;
		}
		ans = min(ans, res);
	}
	printf("%.11f\n", ans);
}

Measured memory_bytes: 1232
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#include <algorithm>
#define LL long long
#define maxn 600005

using namespace std;

int n,a[maxn],dp[maxn],v[maxn<<3],k;

void Insert(int n,int L,int R,int l,int r,int k)
{
    if (l<=L && r>=R)
    {
        v[n]=max(v[n],k);
        return;
    }
    int mid=(L+R)>>1;
    if (l<=mid) Insert(n<<1,L,mid,l,r,k);
    if (r>mid) Insert(n<<1|1,mid+1,R,l,r,k);

    v[n]=max(v[n],max(v[n<<1],v[n<<1|1]));

    return;
}

int query(int n,int L,int R,int l,int r)
{
    if (l<=L && r>=R) return v[n];
    int mid=(L+R)>>1;
    int ret=0;
    if (l<=mid) ret=max(ret,query(n<<1,L,mid,l,r));
    if (r>mid) ret=max(ret,query(n<<1|1,mid+1,R,l,r));

    return ret;
}

int main()
{
    memset(v,-1,sizeof(v));
    scanf("%d%d",&n,&k);
    int h=-1;
    for (int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        h=max(h,a[i]);
    }
    h+=k;
    for (int i=0;i<n;i++)
    {
        int c=query(1,0,h,max(0,a[i]-k),a[i]+k);
        dp[i]=c+1;
        Insert(1,0,h,a[i],a[i],dp[i]);
    }
    int ans=0;
    for (int i=0;i<n;i++) ans=max(ans,dp[i]);
    printf("%d\n",ans);
    return 0;
}
/*
10 0
0
111
4
3
8
6
9
7
2
4
*/


Measured memory_bytes: 24780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int n;
  string s;

  cin >> n >> s;

  if (n % 2 != 0) {
    cout << "No" << endl;
  } else {
    int half = n / 2;
    for (int i = 0; i < n / 2; i++) {
      if (s[i] != s[half + i]) {
        cout << "No" << endl;
        return 0;
      }
    }

    cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
/*
 * main.cpp
 *
 *  Created on: 2020/04/12
 *      Author: SkAaO
 */

#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
	int N;
	cin >> N;
	int X[N];
	for(int i = 0; i < N; i++){
		cin >> X[i];
	}

	sort(X, X + N, greater<int>());
	int max = X[0];

	int cost[max + 1] = {0};
	for(int i = 0; i <= max; i++){
		for(int j = 0; j < N; j++){
			cost[i] += pow((X[j] - i), 2);
		}
	}

	sort(cost, cost + max + 1);

	cout << cost[0] << endl;

	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll n, k;
    cin >>n >>k;
    vll a(n);
    
    rep(i, n) {
        cin >>a[i];
            
            if (i > k-1) {
                if (a[i] <= a[i-(k)]) {
                    mes("No");
                } else {
                    mes("Yes");
                }
            }
    }
    
    
    
    
    
    
    


}


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

long long N, M, R;
vector<long long> r;
long long d[300][300];

int main(){

	cin >> N >> M >> R;
	for(long long i = 0; i < R; i++){
		long long tmp;
		cin >> tmp;
		tmp--;
		r.push_back(tmp);
	}

	for(long long i = 0; i < 300; i++){
		for(long long j = 0; j < 300; j++){
			d[i][j] = INT_MAX;
		}
		d[i][i] = 0;
	}

	for(long long i = 0; i < M; i++){
		long long a, b, c;
		cin >> a >> b >> c;
		a--;b--;
		d[a][b] = c;
		d[b][a] = c;
	}

	for(int k = 0; k < N; ++k){
		for(int i = 0; i < N; ++i){
			for(int j = 0; j < N; ++j){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}

	long long ans = INT_MAX;

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

	do {
		long long tmp = 0;
		for(long long i = 0; i < r.size() - 1; i++){
			tmp += d[r[i]][r[i + 1]];
		}
		ans = min(tmp, ans);
	} while( next_permutation(r.begin(), r.end()) );     // 次の順列を生成




	cout << ans << endl;

}



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

int main(){
  int n,k;
  cin >> n >> k;
  char s[n];
  for(int i=0;i<n;i++) cin >> s[i];
  s[k-1] = s[k-1]+32;
  for(int i=0;i<n;i++) cout << s[i];
  return 0;
}

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

const int N = 2e5 + 7;
int dir[4][2] = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}};
int ok[N];

int main()
{
	ios::sync_with_stdio(false);
	long long h;
	cin >> h;
	long long ans = 0;
	long long res = 1;
	while(h){
		h /= 2;
		ans += res;
		res *= 2;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    int n; cin >> n;
    int cnt = 0;
    int p[n];
    int judge = 1;
    rep(i,n) cin >> p[i];
    rep(i,n-1) if(p[i] > p[i+1]) judge = 0;
    if(judge == 0){
        rep(i,n-1){
            for(int j = i+1; j < n; j++){
                swap(p[i],p[j]);
                judge = 1;
                rep(k,n-1) if(p[k] > p[k+1]) judge = 0;
                swap(p[i],p[j]);
                if(judge) break;
            }
            if(judge) break;
        }
    }
    if(judge) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (ll i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<ll, ll>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
  string s;
  cin >> s;
  string ans = "No";
  if (s[0]=='9' || s[1]=='9') ans = "Yes";
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main(){
	int n,y;
	scanf("%d%d",&n,&y);
	y/=1000;
	if(y<n){
		printf("-1 -1 -1\n");
		return 0;
	}
	if(y>10*n){
		printf("-1 -1 -1\n");
		return 0;
	}
	int S=y-n;
	for(int sum=0;sum<=n;sum++){
		for(int x=0;x<=sum;x++){
			if(4*x+9*(sum-x)==S){
				printf("%d %d %d\n",sum-x,x,n-sum);
				return 0;
			}
		}
	}

	printf("-1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    string s,t;cin >> s >> t;
    ll ans=1;
    for(int i=0;i<n;i++){
        if(i==0){
            if(s[i]==t[i]){
                ans*=3;
            }
            else{
                ans*=6;
                i++;
            }
        }
        else{
            if(s[i]==t[i]){
                if(s[i-1]==t[i-1]){
                    (ans*=2)%=mod;
                }
            }
            else{
                if(s[i-1]==t[i-1]){
                    (ans*=2)%=mod;
                }
                else{
                    (ans*=3)%=mod;
                }
                i++;
            }
        }
    }
    cout << ans << endl;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
  int n;

  while(cin >> n, n) {
    string s;
    cin >> s;

    VI  a(n), b(n);
    REP(i, n) {
      cin >> a[i] >> b[i];
      a[i]--;
      b[i]--;
    }

    reverse(ALL(a));
    reverse(ALL(b));

    REP(i, n) {
      swap(s[a[i]], s[b[i]]);
      int len = b[i] - a[i];

      s[a[i]] = (s[a[i]] - 'a' + len) % 26 + 'a';
      s[b[i]] = (s[b[i]] - 'a' + len) % 26 + 'a';
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define     mod             1e9+7
#define     MOD             998244353
#define     ll              long long
#define     mp              make_pair
#define     F               first
#define     S               second
#define     pb              emplace_back
#define     pf              emplace_front
#define     all(p)          p.begin(), p.end()
#define     rep(i,a,b)      for( i=a;i<b;++i)
#define     repr(i,a,b)     for( i=a;i>=b;i--)
#define     up              upper_bound
#define     lb              lower_bound
#define     t()             int test;cin>>test;while(test--)
#define     setbits(x)      __builtin_popcountll(x)
#define     si              set<int>
#define     ii              pair<int,int>
#define     que_max         priority_queue <int>
#define     que_min         priority_queue <int, vi, greater<int> >
#define     isOn(S, j)      (S & (1 << j))
#define     setBit(S, j)    (S |= (1 << j))
#define     clearBit(S, j)  (S &= ~(1 << j))
#define     toggleBit(S, j) (S ^= (1 << j))
#define     lowBit(S)       (S & (-S))
#define     setAll(S, n)    (S = (1 << n) - 1)
#define     isPowerOfTwo(S) (!(S & (S - 1)))
#define     nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define     turnOffLastBit(S) ((S) & (S - 1))
#define     turnOnLastZero(S) ((S) | (S + 1))
#define     turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define     turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            "\n"
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

int N=1e5;    

 
int32_t main()
 
{  
    

    IOS;
    int n,ip=0,ip1=0,count=0;
    cin>>n;
    vector<int> f;
    vector<int> s;
    for(int i=0 ; i<n ; i++){
    	cin>>ip;
    	f.push_back(ip);
    	cin>>ip1;
    	s.push_back(ip1);
	}

    for(int i=0;i<n-2;i++){
    	count=0;
    	for(int j=i;j<i+3;j++){
    		//trace(f[i],s[i]);
    		if(f[j]==s[j]){
    			count++;
			}
		}
	//	trace(i,count);
		if(count==3)
		{
			cout<<"Yes";
			break;
		}
	}
	if(count!=3)
		cout<<"No";
	return 0;
   
}

Measured memory_bytes: 3652
n = gets.to_i
p = gets.split.map(&:to_i)

p.each_with_index do |n, i|
  if n != i + 1
    tmp = p.find_index(i + 1)
    p[i] = i + 1
    p[tmp] = n
    break
  end
end

puts p == (1..n).to_a ? 'YES' : 'NO'

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	// your code goes here
	ll d,t,s;
	cin>>d>>t>>s;
    ll a=ceil(double(d)/s);
	if(t>=a)
	   cout<<"Yes";
	else
	   cout<<"No";
	return 0;
}

Measured memory_bytes: 3688
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  char t[] = "CODEFESTIVAL2016";
  string s;
  cin >> s;
  int cnt = 0;
  rep(i, s.size()) {
    if (t[i] != s[i]) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

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

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

    cout << setprecision(20) << 2.0 * R * M_PI << endl;
}


Measured memory_bytes: 3788
import sys
input=sys.stdin.readline

n,W=map(int,input().split())
items=[list(map(int,input().split())) for i in range(n)]
import numpy as np

dp=np.zeros([n+1,W+1],dtype=np.int64)
for i in range(n):
  w=items[i][0]
  v=items[i][1]
  dp[i+1][:w]=dp[i][:w]
  dp[i+1][w:]=np.maximum(dp[i][w:],dp[i][:-w]+v)
print(dp[-1][-1])

Measured memory_bytes: 91836
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

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

int N;
vector<int> A, B;

map<vector<int>, int> bfs(vector<int> start) {
    map<vector<int>, int> memo;
    queue< vector<int> > Q;
    Q.push(start);
    memo[start] = 0;

    while(!Q.empty()) {
        vector<int> vi = Q.front();
        Q.pop();

        int cost = memo[vi];

        if(cost >= (N - 1) / 2) continue;

        for(int i = 0; i < N; i++) {
            for(int j = i + 2; j <= N; j++) {
                vector<int> tmp = vi;
                reverse(tmp.begin() + i, tmp.begin() + j);
                if(memo.find(tmp) == memo.end()) {
                    memo[tmp] = cost + 1;
                    Q.push(tmp);
                }
            }
        }
    }

    return memo;
}

int solve() {
    int ans = N - 1;
    map<vector<int>, int> memo_A = bfs(A);
    map<vector<int>, int> memo_B = bfs(B);
    if(memo_A.find(B) != memo_A.end()) ans = memo_A[B];
    else {
        do {
            if(memo_A.find(B) == memo_A.end()) continue;
            if(memo_B.find(B) == memo_B.end()) continue;
            ans = min(ans, memo_A[B] + memo_B[B]);
        } while(next_permutation(B.begin(), B.end()));
    }
    return ans;
}

int main() {
    cin >> N;
    rep(i, N) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    B = A;
    sort(B.begin(), B.end());
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 83084
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int dp[1001][1001];

int ComputeDistance(int x1,int x2,int w){
  // ..x1....x2.. dist = min(x2-x1,(col-x2)+x1);
  // ..x2....x1.. dist = min(x1-x2,(col-x1)+x2);
  return x1 < x2 ? min(x2-x1,(w-x2)+x1) : min(x1-x2,(w-x1)+x2);
}

int ComputeCandidateNum(int x1,int x2,int w){
  if(x1 < x2){
    if(x2-x1 != (w-x2)+x1){
      return 1;
    }
    else{
      return 2;
    }
  }
  else{
    if(x1-x2 != (w-x1)+x2){
      return 1;
    }
    else{
      return 2;
    }
  }
}

int main(){
  int row,col;
  int x1,y1,x2,y2;

  while(~scanf("%d %d %d %d %d %d",&row,&col,&x1,&y1,&x2,&y2)){
    memset(dp,0,sizeof(dp));
    int x_dist=ComputeDistance(x1,x2,row);
    int x_candidate_num = ComputeCandidateNum(x1,x2,row);
    int y_dist=ComputeDistance(y1,y2,col);
    int y_candidate_num = ComputeCandidateNum(y1,y2,col);

    for(int x=0;x<=x_dist;x++) dp[0][x] = 1;
    for(int y=0;y<=y_dist;y++) dp[y][0] = 1;

    for(int y=0;y<y_dist;y++){
      for(int x=0;x<x_dist;x++){
	dp[y+1][x+1] 
	  = max((dp[y][x+1] + dp[y+1][x]) % 100000007,dp[y+1][x+1]);
      }
    }

    printf("%d\n",
	   dp[y_dist][x_dist]*x_candidate_num*y_candidate_num % 100000007);
  }
}

Measured memory_bytes: 5112
n, time = map(int, input().split() )

c = [0]*n
t = [0]*n

ans = 1001

for i in range(n) :
   c[i],t[i] = map(int, input().split() )

for i in range(n) :

   if ( t[i] <= time and c[i] < ans ) :
      ans = c[i]

if ans == 1001 :
   print('TLE')
else :
   print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    string res;
    if(a+b > c+d) res = "Left";
    else if (a+b < c+d) res = "Right";
    else res = "Balanced";
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import Data.List

main = do 
       t<-getLine
       putStrLn $ if (length (h t))==0 then "0" else (show (maximum (h t)))
       where f c
              |c `elem` "AGCT"='A'
              |otherwise=' '
             g xs='A'==(head xs)
             h t=map length $ filter g $ group $ map f t

Measured memory_bytes: 380
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define REP(i,n)for(int i=0;i<(n);i++)

int h,w,n;
int a[12525];
int ans[125][125];

int main(void){
    scanf("%d%d%d",&h,&w,&n);
    REP(i,n)scanf("%d",a+i);
    int it = 0;
    REP(y,h){
        REP(_x,w){
            int x = y%2==0?_x:(w-1-_x);
            ans[y][x] = it+1;
            a[it]--;
            if(a[it]==0)it++;
        }
    }
    REP(y,h)REP(x,w)printf("%d%c",ans[y][x],x==w-1?'\n':' ');
}


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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

const int MAX = 300;
int H, W;
int K;
bool cake[MAX][MAX];
int cake_map[MAX][MAX];
int current_index = 1;

void ApplyNum(int start_y, int end_y, int start_x, int end_x) {
  REPS(h, start_y, end_y) {
    REPS(w, start_x, end_x) {
      cake_map[h][w] = current_index;
    }
  }
  ++current_index;
}
void PrintCakeMap() {
  REP(h, H) {
    REP(w, W) {
      cout << cake_map[h][w];
      if(w<W-1) cout << " ";
      else cout << "\n";
    }
  }
}
/***** MAIN *****/
signed main() {
  cin >> H >> W >> K;
  vector<int> row_with_sb;
  REP(h, H) {
    REP(w, W) {
      char c;
      cin >> c;
      cake[h][w] = (c == '#');
    }
  }
  REP(h, H) {
    REP(w, W) {
      if(cake[h][w]) {
        row_with_sb.PB(h);
        break;
      }
    }
  }

  REP(i, row_with_sb.size()) {
    int start_y = row_with_sb[i];
    int end_y = row_with_sb[i+1];
    // 最初の領域
    if(i == 0) {
      start_y = 0;
    }
    // 最後の領域
    if(i == row_with_sb.size() - 1) {
      end_y = H;
    }

    bool is_first_column = true;  // 最初の列は無視
    int start_x = 0;
    // イチゴがある行を調査する
    REP(w, W) {
      if(cake[row_with_sb[i]][w]) {
        if(is_first_column) {
          is_first_column = false;
          continue;
        }
        // 2番目以降のイチゴを見つけたら、それより左の数字が決定する
        ApplyNum(start_y, end_y, start_x, w);
        start_x = w;
      }
    }
    ApplyNum(start_y, end_y, start_x, W); // その領域の一番右のいちごから右の数字が決定
  }
  PrintCakeMap();
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 1536
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        a: usize,
        b: usize,
    );

    println!("{}", 6 - a - b);
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

Measured memory_bytes: 8572
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin >> str;
  int i;
  int m,b;
  while(str!="-"){
    cin >> m;
    for(i=0;i<m;i++){
      cin >> b;
      str=str.substr(b,str.size()-b)+str.substr(0,b);
    }
    cout << str << endl;
    cin >> str;
  } 
}


Measured memory_bytes: 3216
#include"bits/stdc++.h"	// include
using namespace std;	// 名前空間
/* typedef */
typedef long long ll;	// long long
typedef long double ld;	// long double
typedef vector<int> vint; // intのvector
typedef vector<double> vdouble; // doubleのvector
typedef vector<ll> vll; // llのvector
typedef vector<ld> vld; // ldのvector
typedef vector<pair<ll, ll>> vl_l; // l_lのvector
typedef vector<pair<int, int>> vi_i; // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<string> vstring;	// stringのvector
typedef pair<ll, ll> l_l;	// ll同士のpair
typedef pair<int, int> i_i;	// int同士のpair
typedef pair<double, double> d_d;	// double同士のpair
/* define */
#define pb push_back	// push_back
#define all(v) v.begin(),v.end()	// コンテナ全体
#define PI (acos(-1))  // 円周率pi
/* 入出力 read, write */
template <typename T>	// 1変数
void read(T& x) {
    cin >> x;
}
template <typename T, typename T0>	// 2変数
void read(T& x, T0& y) {
    cin >> x >> y;
}
template <typename T, typename T0, typename T1>	// 3変数
void read(T& x, T0& y, T1& z) {
    cin >> x >> y >> z;
}
template <typename T, typename T0, typename T1, typename T2>	// 4変数
void read(T& x, T0& y, T1& z, T2& w) {
    cin >> x >> y >> z >> w;
}
template <typename T>	// 1変数
void write(T& x) {
    cout << x << endl;
}
template <typename T, typename T0>	// 2変数
void write(T& x, T0& y) {
    cout << x << " " << y << endl;
}
template <typename T, typename T0, typename T1>	// 3変数
void write(T& x, T0& y, T1& z) {
    cout << x << " " << y << " " << z << endl;
}
template <typename T, typename T0, typename T1, typename T2>	// 4変数
void write(T& x, T0& y, T1& z, T2& w) {
    cout << x << " " << y << " " << z << " " << w << endl;
}
// vectorの出力
template <typename T>
void printvec(const vector<T> &data) {
for (const auto elm : data) {
    cout << elm << " ";
}
cout << endl;
}


int main(int argc, char const *argv[])
{
    // 入力
    ll a, b, m; read(a, b, m);
    vll la;
    la.resize(a);
    for (ll rv = 0; rv < a; rv++) {
        cin >> la[rv];
    }
    vll lb;
    lb.resize(b);
    for (ll rv = 0; rv < b; rv++) {
        cin >> lb[rv];
    }
    
    // 割引無し
    ll ans = *min_element(all(la)) + *min_element(all(lb));

    // 割引あり
    for (ll i = 0; i < m; i++) {
        ll x, y, c; read(x, y, c);
        x--; y--;
        ll reg = la[x] + lb[y] - c;
        if (reg < ans) ans = reg;
    }
    
    // 出力
    write(ans);

    return 0;
}


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

using namespace std;
const int N = 2e5;

int n, q, m;
int vis[N][20], color[N], v[N], d[N], c[N];
vector < int > a[N];

int read(void)
{
	int s = 0, w = 0; char c = getchar();
	while (c < '0' || c > '9') w |= c == '-', c = getchar();
	while (c >= '0' && c <= '9') s = s*10+c-48, c = getchar();
	return w ? -s : s;
}

void dfs(int v,int d,int c)
{
	if (vis[v][d]) return;
	vis[v][d] = 1;
	if (!color[v]) color[v] = c;
	if (d == 0) return;
	for (int i=0;i<a[v].size();++i)
	{
		int y = a[v][i];
		dfs(y,d-1,c);	
	} 
	return;
}

int main(void)
{
	n = read(), m = read();
	for (int i=1,x,y;i<=m;++i)
	{
		x = read(), y = read();
		a[x].push_back(y);
		a[y].push_back(x);
	}
	int q = read();
	for (int i=1;i<=q;++i) {
		v[i] = read();
		d[i] = read();
		c[i] = read();
	}
	while (q) dfs(v[q],d[q],c[q]), q --;
	for (int i=1;i<=n;++i)
		printf("%d\n", color[i]);
	return 0;
}

Measured memory_bytes: 20472
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

 
int main() {

    ll n,k;
    cin >> n >> k;
    vector<P> v(n);
    rep(i,n)    cin >> v[i].first >> v[i].second;

    sort(all(v));
    ll sum=0;
    rep(i,n) {
        sum+=(ll)v[i].second;
        if(sum>=k) {
            cout << v[i].first << endl;
            return 0;
        }
    }


 return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

#ifdef DEBUG
#define dprintf      printf
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(1){}else
#define drep(i,n)    if(1){}else
#define dstop()      if(1){}else
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__);
#define array(T,id,n) T id[n]; rep(i,n)cin>>id[i];

//#define int long long;
#ifndef int
#define INF (0x7fffffff)
#else
#define INF (0x7fffffffffffffff)
#endif

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  int i,j=0;
  in(int,n,m);
  int a[212345]={};
  int b[212345]={};
  int s[212345]={};

  rep(i,m)
    {
      cin>>a[i]>>b[i];
      if(b[i]==n)
	s[a[i]]=1;
    }
  rep(i,m)
    {
      if(a[i]==1)
	if(s[b[i]]==1)
	  j=1;
    }
  if(j)
    cout<<"POSSIBLE"<<endl;
  else
    cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 10005
int N,M;
int main(){
  while(cin>>N>>M){
    int Min[MAX_N]={},Max[MAX_N]={};
    if(M==0&&N==0)break;
    for(int i=0;i<M;i++){
      int p,k,id;
      cin>>p>>k;
      for(int j=0;j<k;j++){
        cin>>id;
        id--;
        if(k==1){
          Min[id]+=p;
        }
        Max[id]+=p;
      }
    }

    int mini=1e9,maxm=-1e9,ans=0;

    for(int i=0;i<N;i++){

      if(Max[i]>mini)
        ans=max(ans, abs(Max[i]-mini) );
        
      if(maxm>Min[i])
        ans=max(ans, abs(maxm-Min[i]) );

      mini=min(mini,Min[i]);
      maxm=max(maxm,Max[i]);
    }
    cout<<ans+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC164C()
{
	int N;
	cin >> N;
	set<string> S;
	for (int i = 0; i < N; ++i)
	{
		string x;
		cin >> x;
		S.insert(x);
	}
	cout << S.size() << endl;
}

int main()
{
	ABC164C();
	return 0;
}

Measured memory_bytes: 19176
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,K,S,A,B,C,a,b,c;
  char D;
  string str;
  cin >> N >> K >> str ;
  D=str[K-1];
 if(D=='A'){
  str[K-1]='a';
 }else if(D=='B'){
    str[K-1]='b';
 }else{
    str[K-1]='c';
 }
  
  cout << str << endl;



}



Measured memory_bytes: 256
//In the Name of God
//Ya Ali

#include<bits/stdc++.h>

#define err(A) cout<<#A<<" = "<<(A)<<endl

using namespace std;

const int maxn=10;

int n,m;

string s[maxn];

bool vis[maxn][maxn];

void dfs(int x,int y)
{
  vis[x][y]=true;
  if(x+1<n and s[x+1][y]=='#')
    dfs(x+1,y);
  else if(y+1<m and s[x][y+1]=='#')
    dfs(x,y+1);
}
  
int main()
{
  ios::sync_with_stdio(0);cin.tie(0);

  cin>>n>>m;

  for(int i=0;i<n;i++)
    cin>>s[i];

  if(s[0][0]=='#')
    dfs(0,0);

  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
      if(vis[i][j]!=(s[i][j]=='#'))
	{
	  cout<<"Impossible"<<endl;
	  return  0;
	}
  cout<<"Possible"<<endl;
  
  return 0;
}


Measured memory_bytes: 384
import math
K = int(input())

gcdmem = [[[0] * (K+1) for i in range(K+1)] for j in range(K+1)]

for a in range(1, K+1):
    for b in range(a, K+1):
        for c in range(b, K+1):
            if gcdmem[a][b][c] > 0:
                continue
            gcdab = math.gcd(a, b)
            gcdmem[a][b][c] = math.gcd(gcdab, c)

ans = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            s1, s2, s3 = sorted([a, b, c])
            ans += gcdmem[s1][s2][s3]

print(ans)


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

using namespace std;
typedef long long ll;

const int maxn = 1e5 + 10;
int a[maxn];

int main()
{
	int h, n, m = 0;
	scanf("%d%d", &h, &n);
	for(int i = 0; i < n; i ++) 
	{
		int x;
		scanf("%d",&x);
		m += x;
	}
	printf("%s\n", h <= m ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N, M;
	cin >> N >> M;
	int ans = 0;
	rep(i, N)
		ans += i;
	rep(j, M)
		ans += j;


	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int n, a[100005], mi = INF, ans;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	for (int i = 1; i < n; i++) {
		if (mi > abs(a[0] / 2 - a[i])) {
			ans = a[i];
			mi = abs(a[0] / 2 - a[i]);
		}
	}
	cout << a[0] << " " << ans << endl;
	endre;
}


Measured memory_bytes: 1024
loop do
  n, x = gets.chomp.split.map(&:to_i)
  ans = 0

  break if n == 0 && x == 0

  if x == 0
    puts 0
    next
  end

  1.upto(n) do |i|
    (i + 1).upto(n) do |j|
      (j + 1).upto(n) do |k|
        ans += 1 if i + j + k == x
      end
    end
  end

  puts ans
end


Measured memory_bytes: 6876