akhauriyash/Code-Regression huggingface dataset:
# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }


int main()
{
	while (true)
	{
		string dat[] = { "0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "11111111", "1101111" };
		INT(n);
		if (n == -1)break;
		string now = "0000000";
		FOR(i, n)
		{
			INT(x);
			FOR(j, 7)
			{
				if (now[j] != dat[x][j])cout << 1;
				else cout << 0;
			}
			cout << endl;
			now = dat[x];
		}
	}
}

Measured memory_bytes: 3180
#include <iostream>
 int main() {
  int x, y;
    while (1) { 
     std::cin >> x >> y;
     if (x == 0 && y == 0) break;
     if (x > y) {
      std::cout << y << " " << x <<std::endl;
     } else {
      std::cout << x << " " << y <<std::endl;
     }



    }


 return 0;



}


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

const int N=100;
int ch[N],fA[N],fB[N],col[N],n,T;
vector<int>ga[N],gb[N];
queue<int>q;

void dfsA(int x){ch[x]=0;for(int i:ga[x])if(i!=fA[x])fA[i]=x,dfsA(i),++ch[x];}
void dfsB(int x,int y){col[x]=y;for(int i:gb[x])if(i!=fB[x])fB[i]=x,dfsB(i,y&&x==fA[i]);}

void ins(int t){for(int i:gb[t])if(!col[i]&&!ch[i])q.push(i);}
void clear(){
	for(int i=1;i<=n;++i)ga[i].clear(),gb[i].clear();
}
int work(int x){
	int u=ga[x][0];
	fA[x]=fB[x]=0;
	dfsA(x);dfsB(x,1);
	for(int i=1;i<=n;++i)if(col[i])ins(i);
	int cnt=0;
	for(;!q.empty();){
		int t=q.front();q.pop();++cnt;
		col[t]=1;ins(t);--ch[fA[t]];
		if(!ch[fA[t]]&&!col[fA[t]])for(int i:gb[fA[t]])if(col[i]){q.push(fA[t]);break;}
	}
	for(int i=1;i<=n;++i)if(!col[i])return n+1;
	return cnt;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	for(cin>>T;T--;){
		cin>>n;
		for(int i=1;i<n;++i){
			int x,y;cin>>x>>y;
			ga[x].push_back(y);ga[y].push_back(x);
		}
		for(int i=1;i<n;++i){
			int x,y;cin>>x>>y;
			gb[x].push_back(y);gb[y].push_back(x);
		}
		int flag=1;
		for(int i=1;i<=n;++i){
			sort(ga[i].begin(),ga[i].end());
			sort(gb[i].begin(),gb[i].end());
			if(ga[i]!=gb[i])flag=0;
		}
		if(flag){cout<<0<<'\n';clear();continue;}
		int ans=n+1;
		for(int i=1;i<=n;++i)if((int)ga[i].size()==1){
			int f=ga[i][0];ga[f].erase(lower_bound(ga[f].begin(),ga[f].end(),i));
			for(int j=1;j<=n;++j)if(j!=i&&j!=f){
				ga[i][0]=j;
				ga[j].insert(lower_bound(ga[j].begin(),ga[j].end(),i),i);
				ans=min(ans,work(i)+1);
				ga[j].erase(lower_bound(ga[j].begin(),ga[j].end(),i));
			}
			ga[i][0]=f;
			ga[f].insert(lower_bound(ga[f].begin(),ga[f].end(),i),i);
		}
		cout<<(ans==n+1?-1:ans)<<'\n';clear();
	}
	return 0;
}



Measured memory_bytes: 256
n=int(input())
balls=[]
for i in range(n):
  x,y=map(int,input().split())
  balls.append([x,y])
minans=n
for i in range(0,n-1):
  for j in range(i+1,n):
    p=balls[j][0]-balls[i][0]
    q=balls[j][1]-balls[i][1]
    ballset=set()
    ans=0
    for k in range(n):
      x=balls[k][0]
      y=balls[k][1]
      ballset.add(x*(10**10)+y)
    while ballset:
      current=ballset.pop()
      ballset.add(current)
      y=current%(10**10)
      x=(current-y)//(10**10)
      while (x-p)*(10**10)+(y-q) in ballset:
        x-=p
        y-=q
      while x*(10**10)+y in ballset:
        ballset.remove(x*(10**10)+y)
        x+=p
        y+=q
      ans+=1
    minans=min(minans,ans)
print(minans)

Measured memory_bytes: 75644
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
#define ll long long
ll p = 998244353;


int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    vector<ll> a(n);
    for (int i = 0; i<n; i++) cin>>a[i];
    int l = 0;
    int r = n-1;
    sort(a.begin(), a.end());
    
    ll ans = 0;
    if (n%2==0)
    {
        while (r>l+1)
        {
            ans+=2*a[r];
            ans-=2*a[l];
            r--; l++;
        }
        ans+=a[r]; ans-=a[l];
    }
    else
    {
        int k = n/2;
        for (int i = 0; i<k; i++) ans-=2*a[i];
        for (int i = k+2; i<n; i++) ans+=2*a[i];
        ans+=a[k];
        ans+=a[k+1];
        
        if (a[k+1]-a[k]>a[k]-a[k-1]) ans+=(a[k+1]+a[k-1]-2*a[k]);
        
    }
    
    cout<<ans;
}

Measured memory_bytes: 1024
//c// 
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
 
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	int tag[105][105]={0};
	int way[105][105]={0};
	int i,j,k;
	for(i=0;i<m;i++)
	{
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		if(tag[a][b]==1)
		{
			way[a][b]=min(c,way[a][b]);
		}
		else
		{
			way[a][b]=c;
			tag[a][b]=1;	
		}
	} 
	for(k=0;k<n;k++)
	{
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				if(i==j) tag[i][j]=1;
				if(tag[i][k]==1&&tag[k][j]==1&&tag[i][j]==1)
				{
					way[i][j]=min(way[i][k]+way[k][j],way[i][j]);
				}	
				else if(tag[i][k]==1&&tag[k][j]==1&&tag[i][j]==0)	
				{
					way[i][j]=way[i][k]+way[k][j];
					tag[i][j]=1;
				}		
			} 	
		} 
	}
	for(k=0;k<n;k++)
	{
		if(way[k][k]<0)
		{
			printf("NEGATIVE CYCLE\n");
			goto end;
		} 
	} 
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(j>0) printf(" ");
			if(i==j)
			{
				printf("0");
			}
			else if(tag[i][j]==1)
			{
				printf("%d",way[i][j]);
			}
			else
			{
				printf("INF");
			}
		}
		 printf("\n");
	}
	end:return 0;
}


Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            long N = line[0];
            long Q = line[1];


            var S = Console.ReadLine().ToCharArray();

            long[] s = new long[N+1];

            // Aの左となりにCがある場合をカウントする。（0 - N+1）までの配列
            for (long i = 0; i < N; i++)
            {
                if (i + 1 < N && S[i] == 'A' && S[i + 1] == 'C')
                {
                    s[i + 1] = s[i] + 1;
                }
                else
                {
                    s[i + 1] = s[i];
                }
            }

            for (long i = 0; i < Q; i++)
            {
                var lr = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

                // Aの左隣にCがある場合をカウントしているため配列の番号は一つずつずれている
                long l = --lr[0];
                long r = --lr[1];

                Console.WriteLine(s[r] - s[l]);
            }
        }
    }
}

Measured memory_bytes: 47996
import sys

def main():
    line = sys.stdin.readline()
    lst = line.split()
    r = int(lst[0])
    g = int(lst[1])
    b = int(lst[2])

    if (g * 10 + b) % 4 == 0:
        print("YES")
    else:
        print("NO")
    return 0

if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 2940
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

H,W,N = MI()

from collections import defaultdict,Counter

d = defaultdict(int)  # d[(i,j)] = [i,i+2]×[j,j+2] に黒いマスが何個あるか
for i in range(N):
    a,b = MI()
    for j in range(max(1,a-2),min(a,H-2)+1):
        for k in range(max(1,b-2),min(b,W-2)+1):
            d[(j,k)] += 1

c = Counter(list(d.values()))
print((H-2)*(W-2)-sum(c.values()))
for i in range(1,10):
    print(c[i])


Measured memory_bytes: 232020
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100005
#define MAX_M 100005
typedef pair<int,int> P;

int n,m;
int x[MAX_M],y[MAX_M],w[MAX_M];

vector<int> G[MAX_N];
vector<int> g[MAX_N];

vector<int> group[MAX_N];
int id[MAX_N];
bool visited[MAX_N];
vector<int> vd;

int dp[MAX_N];

bool dfs(int pos,int prev,int root){
  id[pos]=root;
  visited[pos]=true;
  group[root].push_back(pos);
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    if(i&&to==G[pos][i-1])return true;
    if(visited[to])return true;
    if(dfs(to,pos,root))return true;
  }
  return false;
}

bool check(){
  memset(visited,false,sizeof(visited));
  for(int i=0;i<n;i++){
    if(visited[i])continue;
    if( dfs(i,-1,i) )return true;
  }

  vector< int > deg(n);
  vector< vector<int> > graph(n);
  
  for(int i=0;i<m;i++){
    if(w[i]==1){
      int X=id[ x[i] ];
      int Y=id[ y[i] ];
      if(X==Y)return true;
      graph[X].push_back(Y);
      deg[Y]++;
    }
  }

  queue<int> Q;
  for(int i=0;i<n;i++)
    if(deg[i]==0&&id[i]==i)
      Q.push(i);

  while(!Q.empty()){
    int pos=Q.front();Q.pop();
    vd.push_back(pos);
    for(int to:graph[pos]){
      deg[to]--;
      if(deg[to]==0)Q.push(to);
    }
  }
  
  for(int i=0;i<n;i++)
    if(deg[i]>0)return true;
  
  return false;
}

int d[MAX_N];

void init(int root){
  root=id[root];
  for(int pos:group[root])
    d[pos]=-1;
}

void bfs(int root){
  init(root);
  queue<int> Q;
  Q.push(root);
  d[root]=0;
  while(!Q.empty()){
    int pos=Q.front();Q.pop();
    for(int to:G[pos]){
      if(d[to]!=-1)continue;
      d[to]=d[pos]+1;
      Q.push(to);
    }
  }
}

void update(int root,int dif){
  for(int pos:group[root])
    for(int to:g[pos])
      dp[to]=max(dp[to],d[pos]+dif+1);
}

int solve(int root){
  int res=0;
  bfs(root);
  int maxm=-1,maxmid;
  for(int pos:group[root])
    if(d[pos]+dp[pos]>maxm)maxm=d[pos]+dp[pos],maxmid=pos;
  
  bfs(maxmid);
  update(root,dp[maxmid]);
  for(int pos:group[root])res=max(res,d[pos]+dp[maxmid]);
  
  maxm=-1;
  for(int pos:group[root])
    if(d[pos]+dp[pos]>maxm)maxm=d[pos]+dp[pos],maxmid=pos;

  bfs(maxmid);
  update(root,dp[maxmid]);
  for(int pos:group[root])res=max(res,d[pos]+dp[maxmid]);
  
  return res;
}

int main(){
  scanf("%d %d",&n,&m);
  for(int i=0;i<m;i++){
    scanf("%d %d %d",&x[i],&y[i],&w[i]);
    x[i]--,y[i]--;
    if(w[i]==1){
      g[x[i]].push_back(y[i]);
    }
    if(w[i]==2){
      G[x[i]].push_back(y[i]);
      G[y[i]].push_back(x[i]);
    }
  }
  
  if( check() ){
    printf("Infinite\n");
    return 0;
  }

  int ans=0;
  for(int root : vd ){
    if(root!=id[root])continue;
    ans=max(ans,solve(root));
  }
  printf("%d\n",ans);  
  return 0;
}

Measured memory_bytes: 23672
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    vector<int> v(3, 0); for(int i = 0; i < 3; i++) cin >> v[i];
    sort(v.begin(), v.end());
    
    cout << v.back() * 10 + v[1] + v[0] << endl;
    
    
    return 0;
}


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

typedef long long int64;

int main() {
  int64 n;
  scanf("%lld", &n);

  int64 digit = std::to_string(n).length();
  int64 ref = 0;

  if(digit%2 != 0){
    ref += n - pow(10, digit-1) + 1;
    digit -= 1;
  }

  for(int i = digit; i > 0; i--){
    if(i%2 != 0){
      ref += pow(10, i) - pow(10, i-1);
    }
  }

  printf("%lld\n",ref);

  return 0;
}

Measured memory_bytes: 256
<?php
// Your code here!
    fscanf(STDIN,"%d%d",$N,$D);
    
    for($i=0;$i<$N;$i++){
        $X[] = array_map('intval',explode(" ",trim(fgets(STDIN))));
    }
    $count=0;
    for($j=0;$j<$N-1;$j++){
        for($k=$j+1;$k<$N;$k++){
            $ans=0;
            for($d=0;$d<$D;$d++){
                // echo $X[$j][$d];
                // echo " ";
                // echo $X[$k][$d];
                // echo " ";
                
                $dis = (abs($X[$j][$d]-$X[$k][$d]))**2;
                $ans += $dis;
            }
            // echo $j." ".$k." ".sqrt($ans)."\n";
            // var_dump(intval(sqrt($ans)))."\n";
            if((sqrt($ans))==intval(sqrt($ans))){
                $count++;
            }
        }
    }
    echo $count;
?>

Measured memory_bytes: 15972
import java.util.Scanner;

public class Main
{
    // https://atcoder.jp/contests/abc086/tasks/abc086_a
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if ((a * b) % 2 == 0) {
            System.out.println("Even");
        }
        else {
            System.out.println("Odd");
        }
    }
}


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

#define CIN1(a) long long a;cin >> a;
#define CIN2(a,b) long long a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)

int main(){
    CIN1(n)
    for(int i=n;;i++){
        if(!(i%111)){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.first); __p(a.second); cout << "}"; }
template<typename T>
void __f(const char* s, T t) { cout << s << " : "; __p(t); }
template<typename T>
void __t(const char* s, const T &x) { cout << s << " : { "; for (auto it : x) __p(it); cout << "} ";}
template<typename T, typename ... F>
void __f(const char* s, T t, F ... f) {
	int i = 0; for (;; ++i) if (s[i] == ',') break;
	cout.write(s, i) << " : "; __p(t); cout << " | "; __f(s + i + 1, f...);
}
#define trace(...) { cout<<"LINE: "<<__LINE__<<" || "; __f(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
#define debug(...) { cout<<"LINE: "<<__LINE__<<" || "; __t(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define debug(...) 
#define end_time()
#endif
 
 
#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

inline bool equals(ld a, ld b) {return fabs(a - b) < 1e-9;}
inline int gcd(int a, int b) { a=abs(a); b=abs(b); while(a>0 && b>0) (a>b?a%=b:b%=a); return (a==0?b:a); } 
inline int power(int x, int n, int m = LLONG_MAX)
    {  int res=1; x = (x%m + m)%m;
       while(n) { if(n&1) res=(res*x)%m;  x=(x*x)%m;  n >>= 1; }  return res;
    }
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007

void solve(){
	int n;
	cin>>n;
	int a[n];
	for(int i = 0; i<n; i++){
		cin>>a[i];
	}
	int pre[n] = {0};
	int sum = 0;
	for(int i = 0; i<n; i++){
		sum+=a[i];
		pre[i] = sum%mod;
	}
	int ans = 0;
	for(int i = 0; i<n; i++){
		ans = (ans + ((a[i]*((pre[n-1]-pre[i]+mod)%mod))%mod))%mod;
	}
	cout<<ans<<"\n";
}
signed main(){
	speedX;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;++i) {
		//cout<<"Case #"<<i<<": ";
		solve();
	}
	end_time();
	return 0;
}


Measured memory_bytes: 6780
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] arg) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int K = sc.nextInt();
			int M = sc.nextInt();
			int[] next = new int[N];
			int[] prev = new int[N];
			for (int i = 0; i < N; ++i) {
				next[i] = (i + 1) % N;
				prev[i] = (i + N - 1) % N;
			}
			int pos = M - 1;
			next[prev[pos]] = next[pos];
			prev[next[pos]] = prev[pos];
			for (int i = 0; i < N - 2; ++i) {
				for (int j = 0; j < K; ++j) {
					pos = next[pos];
				}
				next[prev[pos]] = next[pos];
				prev[next[pos]] = prev[pos];
			}
			System.out.println(next[pos] + 1);
		}
	}

}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> Vector;
typedef vector< vector<ll> > DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define ub(x,y)     upper_bound(all(x),y)-x.begin()
#define lb(x,y)     lower_bound(all(x),y)-x.begin()
#define uni(x)      x.erase(unique(all(x)),x.end())
#define rep(i,n)    repl(i,0,n-1)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<int>())
#define mkp(x,y)    make_pair(x,y)

int main(){
  cin.sync_with_stdio(false);
  int n;
  cin >> n;
  Vector a(n);
  int mx = -INF;
  rep(i,n)cin >> a[i];
  Vector table(n);
  table[0] = a[0];
  repl(i,1,n-1)table[i] = mmin(table[i-1],a[i]);
  repl(i,1,n-1)maxch(mx,a[i]-table[i-1]);
  cout << mx << endl;
}

Measured memory_bytes: 5988
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int r=sc.nextInt();

        if(n<10){
            System.out.println(r+(100*(10-n)));
        }
        if(n>=10){
            System.out.println(r);
        }
        sc.close();
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

  deque<char> ans;
  string str;cin >> str;
  REP(i, str.size())ans.push_back(str[i]);
  int q;cin >> q;
  int cou = 0;
  REP(i, q){
    ll type;cin >> type;
    if(type == 1)cou++;
    else {
      ll a;
      char c;
      cin >> a >> c;
      if((cou + a) % 2)ans.push_front(c);
      else ans.push_back(c);
    }
  }

  if(cou % 2){
    for(auto it = ans.rbegin();it != ans.rend();it++){
      cout << *it;
    }
  }
  else {
    for(auto it = ans.begin();it != ans.end();it++){
      cout << *it;
    }
  }
  cout << endl;

	return 0;
}


Measured memory_bytes: 976
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    private static final PrintStream so = System.out;
    private static final Scanner     sc = new Scanner(System.in);

    public static void main(String[] args) {
        final long N = sc.nextLong();
        final long P = sc.nextLong();
        if (N == 1) {
            so.println(P);
            return;
        }
        int[] primeCount = new int[(int) 1E6 + 1];
        
        long prod = P;
        for (int i = 2; i <= Math.sqrt(P); i++) {
            while (true) {
                if (prod % i == 0) {
                    prod /= i;
                    primeCount[i]++;
                } else {
                    break;
                }
            }
        }
        
        long ans = 1;
        for (int i = 2; i < 1E6 + 1; i++) {
            if (primeCount[i]/N > 0) {
                ans *= Math.pow(i,(primeCount[i]/N));
            }
        }
        so.println(ans);
    }
}


Measured memory_bytes: 27988
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          int i;

	      	  cin.tie(0);  ios_base::sync_with_stdio(false);
	      	  
	      	  int R,G;
	      	  cin >> R  >> G;
	      	  cout << 2*G-R << endl;





	          return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N,K;

int main(void) {
    cin>>N>>K;

    vector<pair<int,int> > S;
    for(int i = 1;i*i <= N;i++) {
        S.push_back({i, 0});
        S.push_back({N/i,0});
    }
    sort(S.begin(),S.end());
    S.erase(unique(S.begin(),S.end()),S.end());
    for(int i = 0;i < S.size()-1;i++) {
        int l = N/S[i+1].first;
        int r = N/S[i].first;
        S[i].second = r-l; 
    }
    S.back().second = 1;
    int m = S.size();

    map<int,int> mp;
    for(int i = 0;i < m;i++) {
        mp[S[i].first] = i;
    }
    vector<vector<Int> > dp(K+1, vector<Int>(m));
    dp[0][mp[N]] = 1;
    for(int i = 0;i < K;i++) {
        for(int j = m-2;j >= 0;j--) {
            dp[i][j] += dp[i][j+1];
            dp[i][j] %= MOD;
        }
        for(int j = 0;j < m;j++) {
            int nj = mp[N/S[j].first];
            dp[i+1][j] += dp[i][nj]*S[j].second;
            dp[i+1][j] %= MOD;
        }
    }

    Int ans = 0;
    for(int i = 0;i < m;i++) {
        ans += dp[K][i];
        ans %= MOD;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 54264
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	int a, b, c, d; cin >> a >> b >> c >> d;
	cout << (int)(min(a, b) + min(c, d)) << endl;
	return 0;
}

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

#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PER(j,n,a) for (int j=n-1;j>=a;j--)
#define REP(i,a,n) for (int i=a;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define show(x) cout<<(x)<<endl
#define UM unordered_map
#define PB push_back
#define V vector
#define EPS 1e-8
typedef unsigned long ul;
typedef long long ll;
typedef string str;
/*FIN*/

int main() {
	FAST;
	int h,w,m;
	int a,b,x,y,ans,ans2;
	cin>>h>>w>>m;
	set<int> grid[h];
	V<int> rcnt(h,0),ccnt(w,0);
	REP(i,0,m) {
		cin>>a>>b;
		a--;b--;
		grid[a].insert(b);
		rcnt[a]++;
		ccnt[b]++;
	}
	x=0;
	REP(i,0,h) {
		if(rcnt[i] > rcnt[x])
			x=i;
	}
	y=0;
	REP(i,0,w) {
		if(ccnt[i] > ccnt[y])
			y=i;
		if(ccnt[i] == ccnt[y] and grid[x].count(i)==0)
			y=i;
	}
	ans = rcnt[x] + ccnt[y];
	if(grid[x].count(y)==1)
		ans--;

	y=0;
	REP(i,0,w) {
		if(ccnt[i] > ccnt[y])
			y=i;
	}
	x=0;
	REP(i,0,h) {
		if(rcnt[i] > rcnt[x])
			x=i;
		if(rcnt[i] == rcnt[x] and grid[i].count(y)==0)
			x=i;
	}
	ans2 = rcnt[x] + ccnt[y];
	if(grid[x].count(y)==1)
		ans2--;
	show(max(ans,ans2));
	return 0;
}



Measured memory_bytes: 33812
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;

int main(){
    int N; cin >> N;
    cout << 180 * (N-2) << endl;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))

if len(l) == 1:
  print("Yes")
  quit()

a=l[-1]

for i in range(n-1):
  b = l[-2-i]
  if b - a  > 1:
    print("No")
    quit()
  if b - a == 1:
    b = b-1
  a = b
print("Yes")

Measured memory_bytes: 14396
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		String line = "";

		try {
			scanner = new Scanner(System.in);
			line = scanner.next();

			System.out.println(line.replaceAll("2017", "2018"));

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int n = 0;

		try {
			scanner = new Scanner(System.in);
			n = scanner.nextInt();
			int[] wk = new int[n];

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

			Arrays.sort(wk);

			int res = 0;
			for (int i = 0; i < wk.length; i++) {
				if (i == 0) {
					res++;
				} else if (wk[i] != wk[i - 1]) {
					res++;
				}

			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int n = 0;
		int y = 0;

		try {
			scanner = new Scanner(System.in);
			n = scanner.nextInt();
			y = scanner.nextInt();

			for (int i = n; i >= 0; i--) {
				for (int j = 0; j <= n - i; j++) {
					for (int k = 0; k <= n - i - j; k++) {
						if (n == i + j + k && i * 10000 + j * 5000 + k * 1000 == y) {
							System.out.println(i + " " + j + " " + k);
							return;
						}
					}
				}
			}

			System.out.println(-1 + " " + -1 + " " + -1);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
#define N 200010
using namespace std;

ll n, a[N];

map < ll, ll > b;

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9'){
		if (ch == '-') w *= -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9'){
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * w;
}

inline void init(){
	n = read();
	REP(i, 1, n){
		a[i] = read();
		if (b[a[i]] > 0){
			puts("NO");
			exit(0);
		}
		b[a[i]]++;
	}
}

inline void work(){
	init();
	if (n == 2)
		if (a[1] == a[2]){
			puts("NO");
			exit(0);
		}
	puts("YES");
}

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

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define sz(x) (int((x).size()))
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
template<typename T> bool domax(T &a, T b) { return (b > a ? (a = b, true) : false); }
template<typename T> bool domin(T &a, T b) { return (b < a ? (a = b, true) : false); }
typedef long long ll;

const int maxc = 105, inf = 1e9;

int Y, X, s[maxc][maxc], ey, ex, dp[maxc][maxc][maxc][maxc], ans;
char g[maxc][maxc];
int bly, blx, bsy, bsx;

int sum(int ly, int lx, int sy, int sx) {
    if (bly < ly) ly = bly;
    if (blx < lx) lx = blx;
    if (bsy > sy) sy = bsy;
    if (bsx > sx) sx = bsx;
    return std::max(0, s[ly+1][lx+1] - s[ly+1][sx] - s[sy][lx+1] + s[sy][sx]);
}

int main() {
    scanf("%d%d", &Y, &X);
    for (int y = 0; y < Y; y++) scanf(" %s", g[y]);
    for (int y = 0; y < Y; y++) for (int x = 0; x < X; x++) {
        if (g[y][x] == 'E') { ey = y; ex = x; }
        s[y+1][x+1] = s[y+1][x] + s[y][x+1] - s[y][x];
        if (g[y][x] == 'o') s[y+1][x+1]++;
    }
    int W = ex+1, E = X-ex;
    int N = ey+1, S = Y-ey;
    for (int w = 0; w < W; w++) for (int e = 0; e < E; e++) for (int n = 0; n < N; n++) for (int s = 0; s < S; s++) {
        dp[w][e][n][s] = -inf;
    }
    dp[0][0][0][0] = 0;
    for (int w = 0; w < W; w++) for (int e = 0; e < E; e++) for (int n = 0; n < N; n++) for (int s = 0; s < S; s++) {
        domax(ans, dp[w][e][n][s]);
        //if (ans == 5) {
        //    printf("%d %d %d %d\n", w, e, n, s);
        //    return 0;
        //}
        domax(dp[w+1][e][n][s], dp[w][e][n][s]);
        domax(dp[w][e+1][n][s], dp[w][e][n][s]);
        domax(dp[w][e][n+1][s], dp[w][e][n][s]);
        domax(dp[w][e][n][s+1], dp[w][e][n][s]);
        bsx = e; blx = X-1-w;
        bsy = s; bly = Y-1-n;
        if (e <= ex-(w+1))         domax(dp[w+1][e][n][s], dp[w][e][n][s] + sum(ey+s, ex-(w+1), ey-n, ex-(w+1)));
        if (w <= X-1 - (ex+(e+1))) domax(dp[w][e+1][n][s], dp[w][e][n][s] + sum(ey+s, ex+(e+1), ey-n, ex+(e+1)));
        if (s <= ey-(n+1))         domax(dp[w][e][n+1][s], dp[w][e][n][s] + sum(ey-(n+1), ex+e, ey-(n+1), ex-w));
        if (n <= Y-1 - (ey+(s+1))) domax(dp[w][e][n][s+1], dp[w][e][n][s] + sum(ey+(s+1), ex+e, ey+(s+1), ex-w));
        //if (dp[0][0][0][1] == 3) {
        //    printf("wtf %d %d %d %d\n", w, e, n, s);
        //    return 0;
        //}
        //if (dp[0][1][0][1] == 5) {
        //    printf("hi %d %d %d %d\n", w, e, n, s);
        //    return 0;
        //}
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 101376
var fs = require('fs');
var inn = fs.readFileSync(0).toString().split(" ").map((a) => parseInt(a));
var org = inn[0];
inn[0] = Math.max(0, inn[0] - inn[2]);
inn[1] = Math.max(0, inn[1] - Math.max(0, inn[2] - org));
console.log(inn[0] + " " + inn[1]);


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

int main()
{ 
  int n, ans = 0;
  vector<int> p(20);
  vector<bool> flag(20);

  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> p[i];
  if (p[0] < p[1])
    flag[0] = true;
  else
    flag[0] = false;
  for (int i = 1; i < n - 1; i++)
  {
    if (p[i] < p[i + 1])
      flag[i] = true;
    else
      flag[i] = false;
    if (flag[i] == flag[i - 1])
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <ctime>
#include <unordered_set>
#include <string>
#include <map>
#include <unordered_map>
#include <random>
#include <set>
#include <cassert>
#include <string.h>
#include <limits.h>
#include <stack>
#include <functional>
#include <queue>
#include <numeric>
#include <bitset>
#include <iterator>
#include <algorithm>
#include <sstream>
 
 
#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back	
#define ii pair<int,int>
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define iii pair<int, ii >
#define in freopen("arquivoentrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);	
#define eps 1e-9
#define pi 3.14159265359
const int mod = 7723 ;
 
using namespace std;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long long ll;

using namespace std;

const int maxn = 1e4 + 10;


int v[maxn],n;

 
signed main (){
	//~ in
	cin >> n;
	
	long long ans = 0;
	for(int i = 0 ;i < n;i++)
		cin >> v[i] , ans += v[i] -1;
		
	cout << ans << '\n';
	
	return 0;
}






 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main() {
    string s;
    cin >> s;
    if (s == "SUN") {
        cout << 7 << endl;
    } else if (s == "MON") {
        cout << 6 << endl;
    } else if (s == "TUE") {
        cout << 5 << endl;
    } else if (s == "WED") {
        cout << 4 << endl;
    } else if (s == "THU") {
        cout << 3 << endl;
    } else if (s == "FRI") {
        cout << 2 << endl;
    } else if (s == "SAT") {
        cout << 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    string s;
    cin >> s;
    int l = 0, r = s.size() - 1;
    int cnt = 0;
    while( l < r ) {
        if( s[l] != s[r] ) ++cnt;
        ++l; --r;

    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
n, k = [int(_) for _ in input().split(' ')]
s = '0' + input() + '0'


a = []
if s[1] == '0':
    a.append((1, 0))

state = ''
for i in range(n + 1):
    if s[i] == '0' and s[i + 1] == '1':
        state = i + 1
    elif s[i] == '1' and s[i + 1] == '0':
        a.append((state, i))

if s[n] == '0':
    a.append((n + 1, n))

l = len(a)
if k <= l - 1:
    print(max([a[i + k][1] - a[i][0] + 1 for i in range(l - k)]))
else:
    print(n)



Measured memory_bytes: 11544
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    int N,X;
    cin>>N>>X;
    vector<int> m(N);
    rep(i,N)cin>>m[i];
    X=X-accumulate(m.begin(), m.end(), 0);
    int min=*min_element(m.begin(), m.end());
    cout<<(X/min)+N<<endl;
    return 0;
}


Measured memory_bytes: 256
//
//  AOJ0013.c
//
//
//  Created by 中野 優 on 2014/02/23.
//
//

#include <stdio.h>
int main(void){
    int stack[100],i=0,j=0,temp,ans[100]={0};
    while(scanf("%d",&temp)!=EOF) {
        if(temp!=0){
            stack[i]=temp;
            i++;
        } else {
            ans[j]=stack[i-1];
            j++;
            i--;
        }
    }
    for(i=0;i<j;i++) printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 600
from bisect import bisect_left,bisect_right
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
#print(A)
#print(B)
#print(C)
for b in B:
    num1 = bisect_left(A,b)
    num2 = bisect_right(C,b)
    #print(num1,b,num2)
    ans += num1*(n-num2)

print(ans)


Measured memory_bytes: 105444
/*
 * ITP1_7_B.cpp
 *
 *  Created on: 2016/05/21
 *      Author: suna
 */

#include <iostream>

using namespace std;

//1???limit????????§???3????????°???????¨????target????????????????????????????????????
//3????????°???????????????????????°???????????¢??°
int countWay(int limit, int target)
{
	int counter = 0;

	for(int i = 1; i <= limit-2; i++)
	{
		for(int j = i+1; j <=limit-1; j++)
		{
			for(int k = j+1; k <= limit; k++)
			{
				if(i+j+k == target)
				{
					counter++;
				}
			}
		}
	}
	return counter;
}

int main(void)
{
	//?????????
	int upper_limit;

	//3????????°???????¨?????????°
	int target_sum_value;

	while(1)
	{
		//??\???
		cin >> upper_limit >> target_sum_value;

		if( (upper_limit == 0) && (target_sum_value == 0) )
		{
			break;
		}
		//?????????????????°?????????
		cout << countWay(upper_limit, target_sum_value) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import math
n=int(input())
a=list(map(int, input().split()))
dp=[0]*n
dp[0]=0
dp[1]=max(a[0],a[1])
curr=a[0]
for i in range(2,n):
  if i&1==1:
    curr+=a[i-1]
    dp[i]=max(curr,dp[i-2]+a[i])
  else: dp[i]=max(dp[i-2]+a[i],dp[i-1])
print(dp[n-1])


Measured memory_bytes: 93932
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




















int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n + 1);
    REP(i, n){
        cin >> p[i + 1];
        p[i + 1]++;
    }
    REP(i, n){
        p[i + 1] += p[i];
    }
    double ans = -INF;
    for(ll i = k; i <= n; i++){
        ans = max(ans, (double)(p[i] - p[i - k]) / 2.0);
    }
    printf("%.8lf\n", ans);
}

Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  	string a , b , c;
  	cin >> a >> b >> c;
  	if ( a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0] ) cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const ld PI = (acos(-1));
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

ld solve(ld a, ld b, ld x) {
	if (a * a * b / 2.0 <= x) {
		return atan(2 * (a * a * b - x) / (a * a * a));
	} else {
		return PI / 2 - atan(2 * x / (a * b * b));
	}
}

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

	ld a, b, x;
	cin >> a >> b >> x;

	cout << fixed << setprecision(10) << solve(a, b, x) * 180.0 / PI << 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++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  int n;
  cin >> n;
  vi l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(),l.end());
  int ans = 0;
  for(int i = 0; i<n-2; i++) {
    for(int j = i+1; j<n-1; j++) {
      int k = lower_bound(l.begin(),l.end(),l[i]+l[j])-l.begin();
      k--;
      ans += max(0,k-j);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define INF (1<<29)
int dp[10000][10000];
int main()
{
	fill(dp[0], dp[1000], INF);
	string s1, s2; cin >> s1 >> s2;
	int s1sz = s1.size()+1, s2sz = s2.size()+1;
	for (int i = 0; i < s1sz; ++i) {
		dp[i][0] = i;
	}
	for (int j = 0; j < s2sz; ++j) {
		dp[0][j] = j;
	}
	for (int i = 1; i < s1sz; ++i) {
		for (int j = 1; j < s2sz; ++j) {
			dp[i][j] = min(dp[i - 1][j - 1] + (s1[i - 1] != s2[j - 1]), min(dp[i - 1][j] + 1, dp[i][j - 1] + 1));
		}
	}
	cout << dp[s1sz-1][s2sz-1] << endl;
}

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

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

  int sum=0;
  int ans;
  for(int i=0; i<M; i++){
    sum += A[i];
  }
  ans = N - sum;
  if(ans < 0){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }
}


Measured memory_bytes: 3672
#include<stdio.h>
int main(){
  int n,a,b,c,r,s=0,d[1000],i;
  while(scanf("%d %d %d %d %d",&n,&a,&b,&c,&r),n){
    for(i=s=0;i<n;i++)scanf("%d",&d[i]);
    for(i=0;i<10001;i++){
      if(d[s]==r)s++;
      if(s==n)break;
      r=(a*r+b)%c;
    }
    printf("%d\n",i-10001?i:-1);
  }
  return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const LL N=100005;
LL n;
LL a[N],b[N];
LL sum=0;
LL c[N],tot=0;
bool cmp (LL x,LL y)	{return x>y;}
int main()
{
	scanf("%lld",&n);
	for (LL u=1;u<=n;u++)	scanf("%lld",&a[u]);
	LL ans=0;
	for (LL u=1;u<=n;u++)	
	{
		scanf("%lld",&b[u]);
		if (b[u]<a[u]) c[++tot]=a[u]-b[u];
		if (b[u]>a[u]) ans++,sum=sum+b[u]-a[u];
	}
	sort(c+1,c+1+tot,cmp);
	if (sum<=0)	{printf("0\n");return 0;}
	
	for (LL u=1;u<=tot;u++)
	{
		sum=sum-c[u];
		if (sum<=0)
		{
			printf("%lld\n",ans+u);
			return 0;
		}
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n,i;
  string s;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> s;
    if(s=="Y"){
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
lst = [int(i) for i in input().split()]
for i in range(n):
    s1=0
    for j in range(i):
        s1+=lst[j]
    s2=sum(lst)-s1
    if i==0:
        ans=abs(s1-s2)
    elif abs(s1-s2)<ans:
        ans=abs(s1-s2)
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define MAX 128
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
#define int long long
const double PI = 3.141593;
const ll MOD = 1e9 + 7;
const int INF = 100100100;
const double EPS = 1e-9;
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;}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }     //最小公倍数
ll combination(ll n, ll r){if (r * 2 > n)r = n - r;ll dividend = 1;ll divisor = 1;for (ll i = 1; i <= r; ++i){dividend *= (n - i + 1);divisor *= i;}return dividend / divisor;}


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

    int n;
    cin >> n;
    int a[n];
    int tmp = 1;
    int ans = 0;
    rep(i, n)
    {
        cin >> a[i];
    }
    rep(i,n){
        if(tmp!=a[i]){
            ans++;
        }
        else
            tmp++;
    }
    if(ans==n){
        cout << -1 << endl;
    }
    else
        cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define Rep(i, s, n) for (int i = (int)s; i < (int)n; i++)

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

    struct Rest {
        int num;
        string name;
        int point;

        bool operator<( const Rest& right ) const {
            return name == right.name ? point > right.point : name < right.name;
        }
    };

    int n;
    cin >> n;
    Rest r[n];
    rep(i, n) {
        string s;
        int p;
        cin >> s >> p;
        r[i].num = i;
        r[i].name = s;
        r[i].point = p;
    }

    sort(r, r + n);
    rep(i, n) {
        cout << r[i].num + 1 << endl;
    }
}

Measured memory_bytes: 3600
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int M=500,N=8000;
ll num[M+5][M+5],prm[N+5];
bool avoid[N+5];
int n;
void Prepare_Prime(){
	for(int i=2;i<=N;i++){
		if(!avoid[i]) prm[++prm[0]]=i;
		for(int j=1;j<=prm[0];j++){
			if(i*prm[j]>N) break;
			avoid[prm[j]*i]=true;
			if(i%prm[j]==0) break;
		}
	}
}

ll GCD(ll a,ll b){return b? GCD(b,a%b):a;}
ll LCM(ll a,ll b){return a/GCD(a,b)*b;}

int main(){
	scanf("%d",&n);
	if(n==2){
		printf("4 7\n23 10\n");
		return 0;
	}
	Prepare_Prime();
	for(int i=0;i<=n+1;i++)
		for(int j=0;j<=n+1;j++)
			num[i][j]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if((i+j)%2==0)
				num[i][j]=prm[(i+j)/2]*prm[1000-(i-j)/2-(n+1)/2+1];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if((i+j)%2)
				num[i][j]=LCM(LCM(num[i-1][j],num[i][j-1]),LCM(num[i+1][j],num[i][j+1]))+1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<n;j++)
			printf("%lld ",num[i][j]);
		printf("%lld\n",num[i][n]);
	}
	return 0;
}

Measured memory_bytes: 4992
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] lst = new char[12];
		String tmp = sc.nextLine();
		lst = tmp.toCharArray();
		String result = "";
		for (int i = 0; i < 12; i++) {
			result += lst[i];
			if (i == 3) {
				result += " ";
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 9684
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    int a, b, c, d;
    readf("%d %d %d %d\n", &a, &b, &c, &d);
    auto x = a + b;
    auto y = c + d;
    writeln(x > y ? "Left" : x < y ? "Right" : "Balanced");
}


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 d[10][10];
int V=10;

void warshall_floyd(){
    rep(k, V) rep(i, V) rep(j, V){
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
}

int main() {
  int h,w;
  cin>>h>>w;
  rep(i,10) rep(j,10) cin>>d[i][j];
  int a[h][w],ans[10]={0};
  rep(i,h) rep(j,w){
    cin>>a[i][j];
    if(a[i][j]!=-1) ans[a[i][j]]++;
  }
  warshall_floyd();
  int sum=0;
  rep(i,10) sum+=ans[i]*d[i][1];
  cout<<sum<<endl;
  
}

Measured memory_bytes: 384
#include <cstdio>
#define SIZE 244140625

int Hash(const char* c)
{
    int Hash = 0;
    for(; *c; ++c){
        Hash *= 5;
        switch(*c){
        case 'A':
            Hash += 1; break;
        case 'C':
            Hash += 2; break;
        case 'G':
            Hash += 3; break;
        case 'T':
            Hash += 4; break;
        }
    }
    return Hash;
}
int main()
{
    bool* dic = new bool[SIZE];
    int n;
    std::scanf("%d", &n);
    char command[7];
    char str[13];
    for(int i = 0; i < n; ++i){
        std::scanf("%s %s", command, str);
        if(command[0] == 'i'){
            dic[Hash(str)] = true;
        }else{
            std::puts((dic[Hash(str)] ? "yes" : "no"));
        }
    }
    return 0;
 }

Measured memory_bytes: 11692