akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace std;
#define int long long
#define ld long double
#define endl '\n'
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define Fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const int M =1e9+7;

class graph
{
    public:
    vector<int> *g;
    int n;
    graph(int v)
    {
        n=v;
        g= new vector<int>[n];
    }
    void addedge(int u,int v)
    {
        g[u].pb(v);
        g[v].pb(u);
    }
};
void solve()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	int x;
    	cin>>x;
    	if(x%2==0)
    	{
    		if(x%3!=0&&x%5!=0)
    		{
    			cout<<"DENIED"<<endl;
    			return;
    		}
    	}
    }
    cout<<"APPROVED"<<endl;
}
signed main()
{
    Fast;
    
    
    solve();
    
 return 0;    
}


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

int main(){
  vector<vector<char>> c(3, vector<char>(3));
  for (int i=0 ; i<3 ; i++){
    for (int j=0 ; j<3 ; j++){
      cin >> c.at(i).at(j);
      if (i == j)
        cout << c.at(i).at(j);
    }
  }
}

Measured memory_bytes: 3528
""" C
    https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_c
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return reduce(lambda acc, _: acc + [readIntegerSet(m)], range(0, n), [])

def main(N, K, A):
    for i in range(0, N-K):
        print("Yes" if A[i] < A[i+K] else "No")

if __name__ == "__main__":
    _N, _K = readIntegerSet(2)
    _A = readIntegerSet(_N)

    main(_N, _K, _A)

Measured memory_bytes: 32788
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n;
    cin >> n;
    int s=0;
    REP(i,n+1)if(i%2==1)s++;
    printf("%.7f",(double)s/(double)n);

    return 0;
}

Measured memory_bytes: 3768
let () =
  Scanf.scanf "%f %f" (fun a b ->
    let a, b = min a b, max a b in
    if b -. a <= 180.0 then (a +. b) /. 2.0 else mod_float ((a +. b) /. 2.0 +. 180.0) 360.0)
  |> Printf.printf "%f\n"


Measured memory_bytes: 2452
import math 
x = int(input())
Su = math.floor(x/11)
M = x%11
if x < 11:
    if x <=6:
        print(1)
    else:
        print(2)
else:
    if M ==0:
        print(Su*2)
    else:
        if M <= 6:
            print(Su*2+1)
        else:
            print(Su*2+2)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1505,mod=998244353;
int n,tot,a[N][N],head[N],nex[N*N<<1],to[N*N<<1];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
char s[N][N];
vector<int>v[N][N];
bool vis[N];
int num,c[N][N],vt[N],e[N];
void solve(int x,int y,int dx,int dy,int tot)
{
    while(x>=0&&x<=n&&y>=0&&y<=n)
    {
        v[x][y].push_back(tot);
        x+=dx;y+=dy;
    }
}
void dfs(int u)
{
    if(vis[u]) return;
    vis[u]=true;num+=vt[u];
    for(int i=head[u];i;i=nex[i])
        dfs(to[i]);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++)
        scanf("%s",s[i]+1);
    for(int i=0;i<=n;i++)
    {
        int x=0,y=i,dx=1,dy=1;
        for(int j=1;j<=(i>0&&i<n?2*n:n);j++)
        {
            v[x][y].push_back(i);
            if(x+dx<0||x+dx>n) dx*=-1;
            if(y+dy<0||y+dy>n) dy*=-1;
            x+=dx;y+=dy;
        }
    }
    for(int i=1;i<n;i++)
        for(int j=1;j<n;j++)
        if(s[i][j]=='o') a[i][j]=1;
    else if(s[i][j]=='x') a[i][j]=2;
    for(int i=1;i<n;i++)
        for(int j=1;j<n;j++)
    {
        int x=v[i][j][0],y=v[i][j][1];
        c[x][y]|=a[i][j];
        if(c[x][y]==3){cout<<0<<endl;return 0;}
    }
    for(int i=0;i<=n;i++)
        for(int j=i+2;j<=n;j+=2)
        if(c[i][j]==0) add(i,j),add(j,i),e[i&1]++;
    else vt[i]^=c[i][j]-1,vt[j]^=c[i][j]-1;
    int ans=1;
    for(int d=0;d<2;d++)
    {
        int nt=(n-d)/2+1;
        if(nt&1)
        {
            int cnt=0;
            for(int i=d;i<=n;i+=2)
                if(!vis[i])
            {
                cnt++;num=0;
                dfs(i);
                if(num&1){cout<<0<<endl;return 0;}
            }
            for(int i=1;i<=e[d]-nt+cnt;i++)
                ans=ans*2%mod;
        }
        else for(int i=1;i<=e[d];i++) ans=ans*2%mod;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 157696
#include<bits/stdc++.h>
#define forn(i, n) for(int i=0;i<(int)(n);i++)
#define for1(i, n) for(int i=1;i<=(int)(n);i++)
#define fore(i, l, r) for(int i=(int)(l);i<=(int)(r);i++)
#define ford(i, n) for(int i=(int)(n)-1;i>=0;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define MAX 1000000007
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<int64_t> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
string s,t;
int dp[3005][3005];
string ans="";
int LCS(int m,int n){
if(n==0||m==0) return 0;;
if(dp[m][n]!=-1) return dp[m][n];
if(s[m-1]==t[n-1]){
	return dp[m][n]=1+ LCS(m-1,n-1);
}
else{
return dp[m][n]=max(LCS(m-1,n),LCS(m,n-1));}

}
int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	cin>>s>>t;
	memset(dp,-1,sizeof(dp));
//	cout<<s.length()<<t.length();
	int v=LCS(s.length(),t.length());
	int i=s.length(),j=t.length();
	while(j>0&&i>0){
	if(s[i-1]==t[j-1]){
	ans.push_back(s[i-1]);
	i--;
	j--;
	}
	else{
	if(dp[i][j-1]>dp[i-1][j])
			j--;
	else
			i--;
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
	return 0;
}



Measured memory_bytes: 39200
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)

int main() {
  int d,n;cin>>d>>n;
  if (n==100) n++;
  int ans = n*pow(100,d);
  cout << ans << endl;
}


Measured memory_bytes: 512
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    n=int(input())
    print(2*math.pi * n)
    #n,k,s= map(int, sys.stdin.readline().split(' '))
    #a=list(map(int,sys.stdin.readline().split(' ')))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Measured memory_bytes: 9212
#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; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
//template end



int main(){
    int n; scanf("%d",&n);
    multiset<P> a; multiset<int> x,y;
    rep(i,0,n){
        int r,b; scanf("%d%d",&r,&b);
        if(r>b)swap(r,b);
        x.insert(r); y.insert(b);
        a.insert({r,b});
    }
    ll ans=INF;
    for(auto p:a){
        int r=p.first,b=p.second;
        chmin(ans,1LL*(*x.rbegin()-*x.begin())*(*y.rbegin()-*y.begin()));
        x.erase(x.find(r)); x.insert(b);
        y.erase(y.find(b)); y.insert(r);
    }
    printf("%lld\n",ans);
    return 0;
}

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


for i in range(n):
    mid = s[i]
    for j in range(1, n):
        if i-j >= 0 and i+j <= n-1:
            if mid != s[i-j] and mid != s[i+j] and s[i-j] != s[i+j]:
                ans -= 1

print(ans)


Measured memory_bytes: 67804
n = int(input())
li = list(map(int,input().split()))
left = [0] * (n+1)
right = [0] * (n+1)
for i in range(n):
    left[i+1] = left[i] + li[i]
    right[i+1] = right[i] + li[n-i-1]

min = abs(left[0] - right[n])
for i in range(n):
    if abs(left[i] - right[n-i]) < min:
        min = abs(left[i] - right[n-i])

print(min)


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

int main(){
    string n;
    cin >> n;
    if (n[0] == '7' || n[1] =='7'|| n[2] =='7'){
        cout << "Yes" << "\n";
    }
    else cout << "No" << "\n";

    

    return 0;
}

Measured memory_bytes: 3584
//https://atcoder.jp/contests/abc086/tasks/abc086_a

use std::io;
use std::str::FromStr;

fn main(){
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let mut temp = input.split_whitespace()
                .map(|e| i32::from_str(e).unwrap());
    let mut a = temp.next().unwrap();
    let mut b = temp.next().unwrap();

    if (a*b)%2==0 {
        println!("Even");
    }else{
        println!("Odd");
    }
}   

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 3e5 + 5;

int main()
{
    double r;
    cin>>r;
    cout<<setprecision(12)<<fixed<<2*acos(-1)*r<<'\n';
    return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    double s=w*h/2;
    cout << setprecision(10) << s<<" ";
    if(w==2*x && h==2*y)cout <<"1";
    else cout <<"0";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)

vector<int> G[100000];

const ll H = (1LL<<30);
const ll B = 100003;

ll ans=0;
map<ll,int> hs;

ll dfs(int cur,int bef,int depth){
    ll ret = 0;
    bool isLeaf=true;
    for(auto &e:G[cur]){
        if(e==bef)continue;
        isLeaf = false;
        ret += dfs(e,cur,depth+1);
    }
    
    int hash_num = (ret*B + 1)%H;
    if(hs.count(hash_num)) ans+=hs[hash_num];
    hs[hash_num]++;
    
    return hash_num;
}


int main(){
    int v,a,b;
    cin>>v;
    rep(i,v-1){
        cin>>a>>b;
        G[--a].pb(--b);
        G[b].pb(a);
    }
    dfs(0,-1,0);
    
    cout<<ans<<endl;
}

Measured memory_bytes: 24264
#include <iostream>
#include <cstdio>
using namespace std;
const int N = 1005;
int k, a[N][N];
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	k = read();
	if(k <= 500)
	{
		printf("%d\n", k);
		for(int i = 1; i <= k; i ++, printf("\n"))
			for(int j = 1; j <= k; j ++, printf(" "))
				printf("%d", j);
		return 0;
	}
	printf("500\n");
	for(int i = 1; i <= 500; i ++)
		for(int j = 1; j <= 500; j ++)
			a[i][j] = (i + j - 2) % 500 + 1;
	for(int i = 501; i <= k; i ++)
		for(int j = 1; j <= 500; j ++)
			if(j & 1) a[(i - j - 2) % 500 + 1][j] = i;
	for(int i = 1; i <= 500; i ++, printf("\n"))
		for(int j = 1; j <= 500; j ++, printf(" "))
			printf("%d ", a[i][j]);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 3456
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;

int main(void){
	string str; cin >> str;
	string str2 = str+str;
	ll k; cin >> k;
	ll single = 0;
	ll joint = 0;
	ll count = 1;
	ll last = 0;
	ll top = 0;
	bool tflag = true;
	bool lflag = true;
	bool hoge = true;
	rep(i, str2.length()-2){
		if(str2[i] == str2[i+1]){
			count++;
			hoge = true;
			if(lflag && i==str.length()-2){
				last += count / 2;
				lflag = false;
				hoge = false;
			}
		} else{
			if(i < str.length()){
				if(tflag){
					top += count / 2;
					count = 1;
					tflag = false;
				} else{
					single += count / 2;
					count = 1;
					if(!hoge){
						last = 0;
					}
				}
			} else{
				joint = count / 2;
				break;
			}
		}
	}
	joint = count / 2;

	ll ans = single * k;
	ans += joint * (k-1);
	if(k > 1) ans += last;
	ans += top;

	rep(i, str.length()-1){
		if(str[i] != str[i+1]){
			cout << ans << endl;
			return 0;
		}
	}
	cout << str.length()*k / 2 << endl;
}

/*
int main(void){
	string str; cin >> str;
	string str2 = str+str;
	ll k; cin >> k;
	ll ans = 0;
	bool flag = false;
	if(str[0] == str[str.length()-1]) flag = true;

	ll count = 1;
	bool all = true;
	rep2(i, 0, str.length()-1){
		if(str[i] != str[i+1]){
			all = false;
			break;
		}
	}
	if(all){
		cout << (str.length()* k) /2;
		return 0;
	}

	if(!flag){
		rep2(i, 0, str.length()-1){
			if(str[i] == str[i+1]) count++;
			else{
				ans += count/2;
				count = 1;
			}
		}
		ans += count/2;
		ans *= k;
	} else{
		 if(str.length() == 1) {
			rep2(i, 0, str.length()-1){
				if(str[i] == str[i+1]) count++;
				else{
					ans += count /2;
					count = 1;
				}
			}
			ans += count/2;
			ans *= k;
			ans += k-1;
		}
		else if(str.length() == 1 || str[0] == str[1] || str[str.length()-2] == str[str.length()-1]){
			rep2(i, 0, str.length()-1){
				if(str[i] == str[i+1]) count++;
				else{
					ans += count /2;
					count = 1;
				}
			}
			ans += count/2;
			ans *= k;
		} else{
			rep2(i, 0, str.length()-1){
				if(str[i] == str[i+1]) count++;
				else{
					ans += count /2;
					count = 1;
				}
			}
			ans += count/2;
			ans *= k;
			ans += k-1;
		}
	}
	cout << ans << endl;

	return 0;
}
*/

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
a=input()
b=input()
c=input()

p='a'
while True:
  if p=='a':
    if len(a)==0:
      print('A')
      break
    p=a[0]
    a=a[1:]
  elif p=='b':
    if len(b)==0:
      print('B')
      break
    p=b[0]
    b=b[1:]
  elif p=='c':
    if len(c)==0:
      print('C')
      break
    p=c[0]
    c=c[1:]
  


Measured memory_bytes: 3064
S = [s for s in input().split()]
stack = []
for s in S:
    
    if s.isdigit() == True:
        stack.append(s)
    
    elif s == '+' or '-' or '*':
        b=int(stack.pop())
        a=int(stack.pop())
        if s == '+':
            stack.append(a+b)
        elif s == '-':
            stack.append(a-b)
        elif s == '*':
            stack.append(a*b)

print(stack[0])


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define MAXN 100100
#define pii pair<int, int>
#define pb push_back
typedef long long ll;

using namespace std;

int n, a[MAXN][3], dp[MAXN][3];
ll infi = 1e9;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++)
        	cin >> a[i][j];
    }
    for(int i = n - 1; i >= 0; i--){
    	for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(j == k) continue;
                dp[i][j] = max(dp[i][j], dp[i + 1][k] + a[i][k]);
            }
        }
    }
    cout << max(dp[0][0], max(dp[0][1], dp[0][2]));
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int 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<int, int>;
#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(){
    int n;
    cin >> n;
    string ans = "Yes";
    int x = 0;
    int y = 0;
    int t = 0;
    
    rep(i, n) {
        int it, ix, iy;
        cin >> it >> ix >> iy;
        int d = abs(ix-x) + abs(iy-y);
        if (d<=it-t && (d%2)==((it-t)%2)) {
            t = it; x = ix; y = iy;
        }
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A,B;
    cin >> A >> B;
    int Count = 0;
    for(int i = A; i <= B; i++){
        if(i%10 == i/10000 && i/10%10 == i/1000%10) Count++;
    }
    cout << Count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include<string.h>
using namespace std;
typedef pair<int,int>pa;
vector<pa>vec;
int main(){
    while(true){
        int N,n,d,l=0,r=1,t=1,b=0,x,y;
        cin>>N;
        if(N==0)break;
        vec.push_back(pa(0,0));
        while(--N){
            cin>>n>>d;
            pa p=vec[n];
            x=p.first,y=p.second;
            switch(d){
                case 0:
                    l=min(l,x-1);vec.push_back(pa(x-1,y));
                    break;
                case 1:
                    b=min(b,y-1);vec.push_back(pa(x,y-1));
                    break;
                case 2:
                    r=max(r,x+2);vec.push_back(pa(x+1,y));
                    break;
                case 3:
                    t=max(t,y+2);vec.push_back(pa(x,y+1));
                    break;
                default:break;
            }
        }
        cout<<r-l<<" "<<t-b<<endl;
        vec.clear();
    }
    return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll n;
    cin >> n;
    ll p = 1;
    ll mod = pow(10, 9) + 7;
    for(size_t i = 2; i <= n; i++) {
        p *= i;
        p %= mod;
    }
    cout << p << endl;
}


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

int main() {
    ll n;
    while(cin>>n){
        if(n==0)break;
        vector<pair<ll,char>> ps;
        ps.push_back(make_pair(0,'a'));
        bool ee=false;
        rep(i,n){
            char tou;
            cin>>tou;
            if(!ee){
            bool flag=true;
            rep(k,ps.size()){
                if(ps[k].second==tou){
                    ps[k].first++;
                    flag=false;
                }
            }
            if(flag)ps.push_back(make_pair(1,tou));
            sort(ps.begin(),ps.end(),greater<pair<ll,char>>());
            if(ps[0].first>(ps[1].first+n-i-1)){
                cout<<ps[0].second<<" "<<i+1<<endl;
                ee=true;
            }
            }
        }
        if(!ee){
            cout<<"TIE"<<endl;
        }
    }
}



Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <numeric>
#include <iomanip>
using namespace std;
int main(){
    long N;
    cin >> N;
    vector<long double > p_ls(N);
    vector<vector<long double >> memo_ls(N);
    for(int i=0; i<N; i++){
        cin >> p_ls[i];
        memo_ls[i].resize(N+1);
    }
    memo_ls[0][0] = 1 - p_ls[0];
    memo_ls[0][1] = p_ls[0];
    long double _sum = 0;
    if (N == 1){
        _sum = memo_ls[0][1];
    }
    for(int i=1; i<N; i++){
        for(int j=0; j<N+1; j++){
            if(j == 0){
                memo_ls[i][j] = memo_ls[i-1][j] * (1-p_ls[i]);
            }
            else{
                memo_ls[i][j] = memo_ls[i-1][j] * (1-p_ls[i]) +
                        memo_ls[i-1][j-1] * p_ls[i];
            }
            if (i==N-1 && j >= N / 2 + 1){
                _sum += memo_ls[i][j];
            }
        }
    }
    cout << fixed << setprecision(10) << _sum << endl;
}


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

def resolve():
    n=int(input())
    a=list(input().split())
    akisu=a[0::2]
    agusu=a[1::2][::-1]
    b=agusu+akisu
    if n%2==0:
        print(*b)
    else:
        print(*b[::-1])
resolve()

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

int N;
long long int M;

vector<long long int > V;

set<long long int> S, nS;

int main(void) {

	cin >> N >> M;

	long long int tmp = M;

	int i = 2;
	while(i*i<=M){
		if (tmp%i == 0) { V.push_back(i); tmp /= i; i = 1; }
		i++;
	}
	if (tmp > 1) { V.push_back(tmp); }

	/*for (int i = 0; i < (int)V.size(); i++) {
		cout << V[i] << endl;
	}*/

	nS.insert(1);
	for (int i = 0; i < (int) V.size(); i++) {
		S = nS; nS.clear();
		for (auto it = S.begin(); it != S.end(); it++) {
			nS.insert((*it)); nS.insert((*it)*V[i]);
		}
	}
	S = nS;

	long long int Y = M;

	//cout << "== S ==" << endl;
	for (auto it = S.begin(); it != S.end(); it++) {
		//cout << *it << endl;
		if (*it >= N) { Y = min(Y, *it); }
	}

	//cout << "Y= " << Y << endl;
	
	long long int ans = M / Y;

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    int a,l,r,m;
    vin dp(n,-1);
    rep(i,n){
        cin>>a;
        l=-1;r=n;
        while(r-l>1){
            m=(l+r)/2;
            if(dp[m]>=a)l=m;
            else r=m;
        }
        dp[r]=a;
    }
    int ans=0;
    rep(i,n){
        if(dp[i]<0)break;
        ans++;
    }
    cout<<ans<<endl;
}

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

#define SZ(x) ((int)(x).size())
#define FOR(i, j, n) for (int i(j); i < (n); ++i)
#define FORR(v, c) for (auto &v : (c))
#define F first
#define S second
#define SQ(x) (x)*(x)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define pnl(x) cout << x << '\n'
#define pns(x) cout << x << ' '
#define read(x) cin >> x
#define read2(x,y) cin >> x >> y
#define read3(x, y, z) cin >> x >> y >> z
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define readv(v) FORR(c,v) read(c)

typedef	vector<int>	vi;
typedef vector<long long>	vl;
typedef	long long ll;

void solve(void)
{
	double R;
	read(R);
	cout <<  2*acos(-1)*R << endl;
}

int main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int __t(1);	
	while (__t--)
		solve();
}



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

typedef long long ll; 

int main(){
  
  int n; cin>>n; 
  int a[n+1]; 
  for(int i=1;i<=n;i++){
    cin>>a[i]; 
    a[i]-=i; 
  }
  sort(a+1,a+n+1); 
  int x; 
  x=a[n/2+1]; 
  ll ans=0; 
  for(int i=1;i<=n;i++){
    ans+=abs(a[i]-x); 
  }
  cout<<ans; 

 
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 998244353;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll n, s, dp[3005][3005], a[3005];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n >> s;
	for(ll i = 1; i <= n; i++){
		cin >> a[i];
	}
	dp[0][0] = 1;
	for(ll i = 1; i <= n; i++){
		for(ll j = 0; j <= s; j++){
			dp[i][j] += 2 * dp[i-1][j];
			dp[i][j] %= mod;
			if(j + a[i] <= s){
				dp[i][j+a[i]] += dp[i-1][j];
				dp[i][j+a[i]] %= mod;
			}
		}
	}
	cout << dp[n][s] << '\n';
}


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

int main(){
  int K, X;
  cin >> K >> X;
  const int min = -1 * pow(10, 6);
  const int max = pow(10, 6);
  for(int i=X-K+1; i<X+K; i++){
    if(min<=i && i<=max) cout << i << " ";
  }

  cout << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cassert>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

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

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  int n; cin >> n;
  int ans = 0;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  vector<int> c(n);
  rep(i, n) cin >> c[i];
  rep(i, n) {
    if (v[i]-c[i]>0) {
      ans += v[i]-c[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;

const int MAXN = 500005;
struct disj{
	int pa[MAXN], sz[MAXN];
	void init(int n){
		for(int i=0; i<=n; i++){
			pa[i] = i;
			sz[i] = 1;
		}
	}
	int find(int x){
		return pa[x] = (pa[x] == x ? x : find(pa[x]));
	}
	bool uni(int p, int q){
		p = find(p);
		q = find(q);
		if(p == q) return 0;
		pa[q] = p;
		sz[p] += sz[q];
		return 1;
	}
}disj;


lint ipow(lint x, lint p){
	lint ret = 1, piv = x % mod;
	while(p){
		if(p&1) ret *= piv;
		piv *= piv;
		ret %= mod;
		piv %= mod;
		p >>= 1;
	}
	return ret % mod;
}


struct ball{
	int c, w, i;
}a[200005];

int n, x, y;
vector<int> col[200005];
lint fact[200005], invf[200005];

int main(){
	fact[0] = invf[0] = 1;
	scanf("%d %d %d",&n,&x,&y);
	for(int i=1; i<=n; i++) fact[i] = fact[i-1] * i % mod, invf[i] = ipow(fact[i], mod - 2);
	disj.init(n);
	for(int i=0; i<n; i++){
		scanf("%d %d",&a[i].c,&a[i].w);
		a[i].i = i;
	}
	sort(a, a+n, [&](const ball &a, const ball &b){
		return pi(a.c, a.w) < pi(b.c, b.w);
	});
	vector<ball> v;
	for(int i=0; i<n; ){
		int e = i;
		while(e < n && a[e].c == a[i].c) e++;
		for(int j=i+1; j<e; j++){
			if(a[j].w + a[i].w <= x) disj.uni(a[j].i, a[i].i);
		}
		v.push_back(a[i]);
		i = e;
	}
	sort(v.begin(), v.end(), [&](const ball &a, const ball &b){
		return a.w < b.w;
	});
	for(int i=0; i<v.size() && i<2; i++){
		for(int j=0; j<n; j++){
			if(a[j].c != v[i].c && v[i].w + a[j].w <= y) disj.uni(v[i].i, a[j].i);
		}
	}
	for(int i=0; i<n; i++){
		col[disj.find(a[i].i)].push_back(a[i].c);
	}
	lint ans = 1;
	for(int i=0; i<n; i++){
		sort(col[i].begin(), col[i].end());
		ans *= fact[col[i].size()];
		ans %= mod;
		for(int j=0; j<col[i].size(); ){
			int e = j;
			while(e < col[i].size() && col[i][j] == col[i][e]) e++;
			ans *= invf[e - j];
			ans %= mod;
			j = e;
		}
	}
	cout << ans;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,W;
    cin>>n>>W;
    ll w[n],v[n];
    for(int i=0; i<n; i++){
        cin>>w[i]>>v[i];
    }
    ll dp[W+1][n+1];
    for(int i=0; i<=W; i++){
        for(int j=0; j<=n; j++){
            if(i==0||j==0){
                dp[i][j]=0;
                continue;
            }
            ll take=INT_MIN,not_take=INT_MIN;
            if(w[j-1]<=i){
                take=v[j-1]+dp[i-w[j-1]][j-1];
            }
            not_take=dp[i][j-1];
            dp[i][j]=max(take,not_take);
        }
    }
    cout<<dp[W][n];
}


Measured memory_bytes: 82360
class Integer
  def !
    (1..self).inject(1, &:*)
  end
end

def d(i)
  n = i
  p = Array.new(1000, 0)
  (2..i).each do |k|
    break if n < k
    while n % k == 0
      n /= k
      p[k] += 1
    end
  end
  p.select{ |i| i > 0 }.map{ |i| i + 1 }.inject(1, &:*)
end

fact_n = gets.chomp.to_i.!
puts d(fact_n) % (10 ** 9 + 7)


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

int main(){

    int N, M;
    cin >> N >> M;

    vector<bool> ac(N);
    vector<int> penalty(N);
    vector<pair<int,bool>> item;
    
    while(M--){
        int num;
        string result;
    
        cin >> num >> result;
        num--;
        if (result == "AC")
            item.push_back(make_pair(num, true));
        else
            item.push_back(make_pair(num, false));
    }

    int ac_num = 0, penalty_num = 0;
    for (int i = 0; i < item.size(); i++) {
        bool result = item[i].second;
        int idx = item[i].first;
        if(result) {
            if (!ac[idx]) {
                ac[idx] = true;
                ac_num++;
            }
        }else {
            if (!ac[idx]) {
                penalty[idx]++;
            }
        }

    }

    for (int idx = 0 ; idx < N; idx++) {
        if(ac[idx])
            penalty_num += penalty[idx];
    }

    cout << ac_num << " " << penalty_num << endl; 

    return 0;
}


Measured memory_bytes: 1788
#include<iostream>
#include<cmath>
#include<queue>
#include<complex>
#include<cstdio>
#include<vector>

using namespace std;

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

const double INF = 1e40;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef complex<double> P;
typedef pair<P, P> L;
#define X real()
#define Y imag()
enum CCW{FRONT = 1, RIGHT = 2, BACK = 4, LEFT = 8, ON = 16};

int sig(double r) {return (r < -EPS) ? -1 : (r > EPS) ? 1: 0;}
bool eq(double a, double b) {return abs(a - b) < EPS;}
double dot(P a, P b) {return a.X * b.X + a.Y * b.Y;}
double cross(P a, P b) {return a.X * b.Y - a.Y * b.X;}
int ccw(const P a, P b, P x) {
  b -= a;
  x -= a;
  double cr = cross(b, x);
  if (eq(cr, 0)) {
    if (dot(b, x) < 0) return BACK;
    if (abs(b) < abs(x)) return FRONT;
    return ON;
  }
  return (cr > 0) ? LEFT : RIGHT;
}
P vec(L a) {return a.second - a.first;}
bool iSS(L a, L b) {
  int cwaf = ccw(a.first, a.second, b.first);
  int cwbf = ccw(b.first, b.second, a.first);
  int cwas = ccw(a.first, a.second, b.second);
  int cwbs = ccw(b.first, b.second, a.second);
  if ((cwaf | cwas | cwbf | cwbs) & ON) return true;
  return (cwaf | cwas) == (LEFT | RIGHT) && (cwbf | cwbs) == (LEFT | RIGHT);
}
double dLP(L l, P x) {return abs(cross(vec(l), x - l.first)) / abs(vec(l));}
double dSP(L s, P x) {
  if (dot(vec(s), x - s.first) <= 0) return abs(x - s.first);
  if (dot(-vec(s), x - s.second) <= 0) return abs(x - s.second);
  return dLP(s, x);
}
double dSS(L a, L b) {return iSS(a, b) ? 0 : min(min(dSP(a, b.first), dSP(a, b.second)), min(dSP(b, a.first), dSP(b, a.second)));}


double x[111], y[111], a[111], r[111];
L star[111][5];
double dis[111][111];
double mem[111];

void f(int s, int t) {
  double res = 1e40;
  rep (i, 5) rep (j, 5) {
    res = min(dSS(star[s][i], star[t][j]), res);
    if (eq(res, 0)) break;
  }
  dis[s][t] = res;
}

int main() {
  int n, m, l;
  for (;;) {
    cin >> n >> m >> l;
    if (n == 0 && m == 0 && l == 0) break;
    --m; --l;
    rep (i, n) cin >> x[i] >> y[i] >> a[i] >> r[i];
    rep (i, n) a[i] = a[i] / 360 * 2 * PI;
    rep (i, n) rep (j, 5) {
      double theta = a[i] + j * 2 * PI / 5 + PI / 2;
      P p1 = P(x[i] + r[i] * cos(theta), y[i] + r[i] * sin(theta));
      theta = a[i] + (j + 2) * 2 * PI / 5 + PI / 2;
      P p2 = P(x[i] + r[i] * cos(theta), y[i] + r[i] * sin(theta));
      star[i][j] = L(p1, p2);
    }
    rep (i, n) rep (j, n) if (i < j) f(i, j);
    rep (i, n) rep (j, n) if (i > j) dis[i][j] = dis[j][i];
    rep (i, n) mem[i] = INF;
    priority_queue<pair<double, int>, vector<pair<double, int> >, greater<pair<double, int> > > que;
    que.push(make_pair(0, m));
    while (!que.empty()) {
      pair<double, int> now = que.top();
      que.pop();
      if (mem[now.second] <= now.first) continue;
      mem[now.second] = now.first;
      rep (i, n) if (i != now.second) {
	que.push(make_pair(now.first + dis[now.second][i], i));
      }
    }
    printf("%.12lf\n", mem[l]);
  }
}

Measured memory_bytes: 1296
/*
 KUNAL RAUT (ZUKONIT14)  :- "DO WHAT YOU LIKE!"
 -PICT,PUNE! :)
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define mod9 1000000009
#define pi 3.1415926535
#define MAXN 1000001
#define MAX2N 1*1000 + 10
#define all(v) v.begin(), v.end()
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define forci(p,n) for(ll i=p;i<(ll)n;i++)
#define forcj(p,n) for(ll j=p;j<(ll)n;j++)
#define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define bits(a) __builtin_popcount(a)
#define test ll t;cin>>t;while(t--)
ll zero=0;
ll one=1;
ll gcd(ll a,ll b){    if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) {    return (a/gcd(a,b)*b);}
ll expo(ll x, ll y) {ll res=1;x=x%mod;while(y>0){if(y&1)res=(1ll*res*x)%mod;
    y=y>>1;x=(1ll*x*x)%mod;} return res;}
ll ncr(ll n,ll r){ ll res=1; if(r>n-r)r=n-r; for(ll i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime(ll n){ll i;for(i=2;i<=sqrt(n);i++){if(n%i==0)return false;}return true;}
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return(a.second<b.second);}

//https://www.youtube.com/watch?v=k4V3Mo61fJM

ll rr[]={0,1,1,1,0,-1,-1,-1,};
ll cc[]={1,1,0,-1,-1,-1,0,1};

signed main()
{
    bolt;
    ll n;cin>>n;
    if(n%2) cout<<n/2 +1;
    else    cout<<n/2;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double eps=1e-9;
ll num[100010];
int main()
{
	int n;
	cin>>n;
	ll ans=1;
	ll a;
	ll maxn=1e18;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		if(a==0) ans=0;
		num[i]=a;
	}
	if(ans==0)
	{
		cout<<0;
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		if(((double)ans-(double)maxn/(double)num[i])>eps)
		{
			cout<<-1;
			return 0;
		}
		ans=ans*num[i];
       }
     if(ans>maxn) cout<<-1;
     else cout<<ans;
	return 0;
 } 

Measured memory_bytes: 4372
#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 X, A, B;
  cin >> X >> A >> B;

  if (B <= A)
    cout << "delicious" << endl;
  else if (B <= A + X)
    cout << "safe" << endl;
  else
    cout << "dangerous" << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#define int long long int
using namespace std;
const int N = 1e5;
const int mod = 1e9+7;

int bigMod(int b, int p){
    if(p==1) return b%mod;
    else if(p%2==0){
        int e = bigMod(b,p/2);
        return (e*e)%mod;
    }
    else{
        int o = b%mod;
        int aa = bigMod(b,p-1);
        return (aa*o)%mod;
    }
}

int nCr(int n, int r){
    int curr = 1;
    for(int i=1; i<=r; i++){
        curr = (curr*(n+1-i))%mod;
        curr = (curr*bigMod(i, mod-2))%mod;
    }
    return curr;
}

int32_t main(){
    int n,a,b;
    cin>>n>>a>>b;
    int curr = bigMod(2,n)-1;
    if(curr<0)
        curr += mod;
    int x = nCr(n,a), y = nCr(n,b);

    curr = (curr - x)%mod;
    if(curr<0)
        curr += mod;

    curr = (curr - y)%mod;
    if(curr<0)
        curr += mod;
    cout<<curr<<"\n";
    return 0;
}


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

#define int long long

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

int a, b;

signed main() {
    cin >> a >> b;
    cout << ceil(((double)a + b) / 2) << endl;
    return 0;
}


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

hash = {}
for i in range(N):
	key = input()
	if key in hash:
		hash[key] += 1
	else:
		hash[key] = 1
        
max = 0
results = []
for i, v in hash.items():
	if max == v:
		results.append(i)
	elif max < v:
		results = [i]
		max = v

results.sort()
for i in results:
	print(i)



Measured memory_bytes: 32096
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    string a;
    cin >> a;
    if (a[0]==a[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>

#include<queue>

using namespace std;

priority_queue<int,vector<int>,less<int> >q;
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0; i<n; i++)
    {
        int t;
        cin>>t;
        q.push(t);
    }
    int sum=0;
    for(int i=0; i<m; i++)
    {
        sum=sum+q.top();
        q.pop();
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int N,Y;
		Scanner scan = new Scanner(System.in);
		N = scan.nextInt();
		Y = scan.nextInt();

		for(int a = 0; a <= N; a++) {
			for(int b = 0; b <= N - a; b++) {
				int c = N - a - b;
				int total = 10000 * a + 5000 * b + 1000 * c;
				if(total == Y) {
					System.out.println(a + " " + b + " " + c);
					System.exit(0);
				}
			}
		}
		System.out.println("-1 -1 -1");
		scan.close();
	}
}


Measured memory_bytes: 22868
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>

int main (int argc, char **argv)
{
  int n = 0;
  struct Human {
    char x[16];
    char u[4];
  } *h = NULL;
  int i = 0;
  long long j = 0;
  long long bi = 0;
  long long bf = 0;

  scanf("%d", &n);

  h = (struct Human *)malloc(n * sizeof(struct Human));

  for(i = 0; i < n; i++)
  {
    scanf("%s %s", h[i].x, h[i].u);
    if(*h[i].u == 'J')
    {
      j += atoi(h[i].x);
    }
    else
    {
      bi += atoi(strtok(h[i].x, "."));
      bf += atoi(strtok(NULL, "."));
      while(bf >= 100000000)
      {
        bi++;
        bf -= 100000000;
      }
    }
  }

  printf("%lld", (j + (bi * 380000) + ((38 * bf) / 10000)));
  if((38 * bf) % 10000)
  {
    printf(".%04lld\n", ((38 * bf) % 10000));
  }

  free(h);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h> 
using namespace std;
typedef long long LL; 
const LL T = 1e9; 
int N; 
int a[50][50], b; 
void div(LL x) { 
    int _2 = 0, _5 = 0; 
    while (x % 2 == 0) x /= 2, ++_2; 
    while (x % 5 == 0) x /= 5, ++_5; 
    a[_2][_5]++; 
    if (_2 >= 9 && _5 >= 9) ++b; 
} 
int main () { 
    scanf("%d", &N); 
    for (int i = 1; i <= N; i++) {
        char ch[20]; scanf("%s", ch); 
        int l = strlen(ch), cnt = 0, flag = 0; 
        for (int j = 0; j < l; j++) if (ch[j] == '.') flag = 1; 
        for (int j = l - 1; ~j; j--) 
            if (ch[j] != '.') ++cnt; 
            else break; 
        LL y = 1; 
        if (!flag) y = 1e9; 
        else for (int i = 1; i <= 9 - cnt; i++) y = y * 10; 
        LL w = 0; 
        for (int j = 0; j < l; j++) { 
            if (ch[j] == '.') continue; 
            w = w * 10 + ch[j] - '0'; 
        } 
        div(y * w); 
    } 
    LL ans = 0; 
    for (int i = 0; i < 50; i++) 
        for (int j = 0; j < 50; j++) 
            for (int k = 0; k < 50; k++) 
                for (int l = 0; l < 50; l++) { 
                    int m = min(i + k, j + l); 
                    if (m >= 18) ans += 1ll * a[i][j] * a[k][l]; 
                } 
    ans = (ans - b) / 2; 
    printf("%lld\n", ans); 
    return 0; 
} 

Measured memory_bytes: 3816
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


struct node{
    int key;
    struct node *next,*prev;
};
 
typedef struct node * NodePointer;
 
NodePointer nil;
 
NodePointer listSearch(int key){
    NodePointer cur=nil->next;
    while(cur != nil ){
        //if ( cur == nil ) break;
        if(cur->key==key) return cur;
        cur=cur->next;
    }
    return nil;
}
 
void init(){
    nil=(NodePointer)malloc(sizeof(struct node));
    nil->next=nil;
    nil->prev=nil;
}
void printList(){
    NodePointer cur=nil->next;
    int isf=0;
    while(1){
        if(cur==nil) break;
        if(isf++>0) printf(" ");
        printf("%d",cur->key);
        cur=cur->next;
    }
    printf("\n");
}

void deleteNode(NodePointer t){
    if(t==nil) return;
    t->prev->next=t->next;
    t->next->prev=t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    NodePointer x=(NodePointer)malloc(sizeof(struct node));
    x->key=key;
    x->next=nil->next;
    nil->next->prev=x;
    nil->next=x;
    x->prev=nil;
}
int main(){
    int key,n,i;
    int size=0;
    char com[20];
    int np=0,nd=0;
    scanf("%d",&n);
    init();
    for(i=0;i<n;i++){
        scanf("%s%d",com,&key);
        if(com[0]=='i'){insert(key); np++; size++;}
        else if (com[0]=='d'){
            if(strlen(com)>6){
                if(com[6]=='F') deleteFirst();
                else if (com[6]=='L')deleteLast();
                }else{
                deleteKey(key); nd++;
            }
            size--;
        }
    }
    printList();
    return 0;
}
       
       


Measured memory_bytes: 32988
fun main(args: Array<String>) {
  val N = readLine()!!.toInt()
  val p = (1..N).map{readLine()!!.toInt()}
  val max = p.max()
  val divmax = max!!/2
  val psum = p.sum()
  val result = psum - max + divmax
  println(result)
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;
typedef pair<double,pi> P;

struct UF{
    int n;
    //??£?????£????????????????????????,????????£???????????§??£?????????????????°
    vector<int> d;
    UF() {}
    UF(int N):n(N), d(N,-1){}
    int root(int v){
        if(d[v]<0) return v;
        return d[v]=root(d[v]);
    }
    bool unite(int X,int Y){
        X=root(X); Y=root(Y);
        if(X==Y) return false;
        if(size(X) < size(Y)) swap(X,Y);
        d[X]+=d[Y];
        d[Y]=X;
        return true;
    }
    int size(int v){ return -d[root(v)]; }
    bool same(int X,int Y){ return root(X)==root(Y); }
};

int n;
double x[100],y[100],z[100],r[100];

inline double dist(int i, int j)
{
    return sqrt( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) + (z[i]-z[j])*(z[i]-z[j]) );
}

inline double make_edge(int i, int j)
{
    double ret=dist(i,j)-r[i]-r[j];
    return ret>0?ret:0;
}

int main()
{
    while(cin >>n,n)
    {
        rep(i,n) scanf(" %lf %lf %lf %lf", &x[i], &y[i], &z[i], &r[i]);

        vector<P> e;
        rep(i,n)rep(j,i) e.pb(P(make_edge(i,j),pi(i,j)));
        sort(all(e));

        double ans=0;
        UF uf(n);
        rep(i,e.size())
        {
            int a=e[i].se.fi, b=e[i].se.se;
            if(!uf.same(a,b))
            {
                uf.unite(a,b);
                ans+=e[i].fi;
            }

            if(uf.size(0)==n) break;
        }

        printf("%.3f\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3204
#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;
#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(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#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 INF 999999999
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 main(){

    int a;
    string s;
    cin >> a >> s;
    if(a>=3200)cout << s << endl;
    else cout << "red" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	for (int i = 0; i < s.size() - 1; i++) {
		if (s[i] == s[i + 1]) {
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int max(int len, int *nums) {
    int i, _max = nums[0];
    for (i = 1; i < len; i++) {
        if (nums[i] > _max)
            _max = nums[i];
    }
    return _max;
}
int min(int len, int *nums) {
    int i, _min = nums[0];
    for (i = 1; i < len; i++) {
        if (nums[i] < _min)
            _min = nums[i];
    }
    return _min;
}
int main(){
	int a,b,n,result,min_,max_;
	scanf("%d",&n);
	int list[n];
	for(int i=0;i<n;i++)scanf("%d",&list[i]);
    min_=min(n,list);
    max_=max(n,list);

    printf("%d",max_-min_);
    return 0;
}

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

#define vi vector<int>
#define pb push_back

ll gcd(ll a ,ll b){
    if(a < b) return gcd(b, a);
  ll r;
  while ((r = a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll lcm(ll a, ll b){
    return a/gcd(a,b)*b;
}

int main() {
    ll n,t,ans;
    cin >> n;
    cin >> ans;
    rep(i,n-1){
        cin >> t;
        ans = lcm(ans,t);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256