akhauriyash/Code-Regression huggingface dataset:
/*
   Created by Rahul Goel.
*/

#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1e9;
const ll LINF = 1e18;

#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c) (c).begin(), (c).end()
#define pii pair < ll, ll >
#define vi vector < ll >
#define vb vector < bool >
#define vvi vector < vector < ll > >
#define vvb vector < vector < bool > >
#define vpii vector < pair < ll, ll > >
#define vvpii vector < vector < pair < ll, ll > > >
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define min_pq(t) priority_queue < t, vector < t >, greater < t > >
#define max_pq(t) priority_queue < t >
#define pb push_back
#define ff first
#define ss second

ll mod_sum() { return 0ll; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_prod() { return 1LL; }
template<typename T, typename... Args>
T mod_product(T a, Args... args) { return (a*mod_product(args...))%mod; }

// --------------------------------------------------------------

ll solve(){
    string str;
    cin >> str;
    if(str == "ARC")
        cout << "ABC" << endl;
    else
        cout << "ARC" << endl;
    return 0;
}

int main(){
    fastio;

    ll t = 1;
    while(t--)
        solve();

    return 0;
}



Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define N 100005
#define LL long long int
const LL MOD = 1e9+7;

vector<int> g[N];
int vis[N], par[N], out[N], t = 1;

void getin(int node) {
  vis[node] = true;
  t++;
  for (auto it : g[node]) {
    if (!vis[it]) getin(it);
  }
  out[node] = t;
  t++;
}
void dfs(int node) {
  vis[node] = true;
  for (auto it : g[node]) {
    if (par[it] == 0 || (out[par[it]] > out[node])) par[it] = node;
    if (!vis[it]) dfs(it);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);cout.tie(NULL);
  int n, m, i, u, v, root;
  cin >> n >> m;
  m += n-1;
  for (i=0;i<m;i++) {
    cin >> u >> v;
    g[u].push_back(v);
    vis[v] = true;
  }
  for (i=1;i<=n;i++) if (!vis[i]) break;
  root = i;
  memset(vis, 0, sizeof(vis));
  getin(root);
  // for (i=1;i<=n;i++) cout << out[i] << " ";
  // cout << '\n';
  memset(vis, 0,sizeof(vis));
  dfs(root);
  for (i=1;i<=n;i++) cout << par[i] << '\n';
  return 0;
}


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

using namespace std;

int main()
{
string s;
cin>>s;
set<char>ss;
for(int i=0;i<s.size();i++)
{
    ss.insert(s[i]);
}
if(ss.size()==2)cout<<"Yes";
else cout<<"No";
      return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;


int main(){
    string s;
    cin >> s;
    s = s + '/';
    int info[3];
    int count = 0;
    string sub = string();
    for(int i = 0; i < s.length(); i++){
        if(s[i] != '/') sub += s[i];
        else{
            if(sub[0] == '0'){
                sub = sub.substr(1,sub.length()-1);
            }
            info[count] = stoi(sub);
            count++;
            sub = string();
        }
    }
    if(info[0] < 2019) cout << "Heisei" << endl;
    else if(info[0] > 2019) cout << "TBD" << endl;
    else if(info[1] > 4) cout << "TBD" << endl;
    else if(info[1] < 4) cout << "Heisei" << endl;
    else if(info[2] > 30) cout << "TBD" << endl;
    else cout << "Heisei" << endl;
    return 0;
}

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

using namespace std;

const int N=1e3+10;
char G[N][N];
int to[4][2]={1,0,0,1,-1,0,0,-1}; 
int n,m;
int sx,sy,ex,ey;
bool vis[N][N];
int ans;
struct node{
	int x;
	int y;
};

bool check(int x,int y){
	if(x>=1&&x<=n&&y>=1&&y<=m&&!vis[x][y]&&G[x][y]=='.') return true;
	return false;
}

int bfs(node now){
	int res=-1;
	queue<node> q1,q2;
	q1.push(now);
	vis[now.x][now.y]=1;
	node nxt;
	while(q1.size()){
		res++;
		while(q1.size()){
			now=q1.front();
			q1.pop();
			q2.push(now);
			if(now.x==ex&&now.y==ey){
				return res;
			}
			for(int i=0;i<4;i++){
				int dx=now.x+to[i][0];
				int dy=now.y+to[i][1];
				nxt={dx,dy};
				if(check(dx,dy)){
					q1.push(nxt);
					vis[dx][dy]=1;
				}
			}
		}
		while(q2.size()){
			now=q2.front();
			q2.pop();
			for(int i=-2;i<=2;i++) 
				for(int j=-2;j<=2;j++){
					int dx=now.x+i;
					int dy=now.y+j;
					nxt={dx,dy};
					if(check(dx,dy)){
						q1.push(nxt);
						vis[dx][dy]=1;
					}
				}
		}
	}
	return -1; 
}
int main()
{
	scanf("%d%d",&n,&m); 
	scanf("%d%d%d%d",&sx,&sy,&ex,&ey); 
	for(int i=1;i<=n;i++){
		scanf("%s",G[i]+1);
	}
	node now={sx,sy};
	ans=bfs(now);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5740
inf = 10**9+7
mod = 10**9+7
s = input()
slen = len(s)
ans = inf
for i in range(slen-2):
    a = s[i]
    b = s[i+1]
    c = s[i+2]
    tmp = int(''.join([a, b, c]))
    ans = min(ans, abs(tmp - 753))
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n,k; cin>>n>>k;
    vector<int> x(n), y(n);
    vector<char> c(n);
    rep(i,n) cin>>x[i]>>y[i]>>c[i];
    rep(i,n){
        x[i]%=2*k;
        y[i]%=2*k;
    }
    vector<vector<int>> b(2*k, vector<int>(2*k,0)), w(2*k, vector<int>(2*k,0));
    rep(i,n){
        if(c[i]=='B'){
            b[x[i]][y[i]]++;
        }else{
            w[x[i]][y[i]]++;
        }
    }
    rep(i,2*k){
        rep(j,2*k-1){
            b[i][j+1]+=b[i][j];
            w[i][j+1]+=w[i][j];
        }
    }
    rep(i,2*k-1){
        rep(j,2*k){
            b[i+1][j]+=b[i][j];
            w[i+1][j]+=w[i][j];
        }
    }
    int ans=0, karians=0;
    rep(i,k){
        rep(j,k){
            karians=0;
            karians+=(b[2*k-1][2*k-1]-b[2*k-1][j+k]-b[i+k][2*k-1]+b[i+k][j+k]+b[i+k][j+k]-b[i+k][j]-b[i][j+k]+b[i][j]+b[2*k-1][j]-b[i+k][j]+b[i][2*k-1]-b[i][j+k]+b[i][j]);
            karians+=(w[2*k-1][j+k]+w[i+k][2*k-1]-w[i+k][j+k]-(w[2*k-1][j]-w[i+k][j]+w[i][2*k-1]-w[i][j+k]+w[i+k][j+k]-w[i+k][j]-w[i][j+k]+w[i][j]+w[i][j]));
            ans=max(ans,karians);
        }
    }
    vector<vector<int>> rp=b;
    b=w;
    w=rp;
    rep(i,k){
        rep(j,k){
            karians=0;
            karians+=(b[2*k-1][2*k-1]-b[2*k-1][j+k]-b[i+k][2*k-1]+b[i+k][j+k]+b[i+k][j+k]-b[i+k][j]-b[i][j+k]+b[i][j]+b[2*k-1][j]-b[i+k][j]+b[i][2*k-1]-b[i][j+k]+b[i][j]);
            karians+=(w[2*k-1][j+k]+w[i+k][2*k-1]-w[i+k][j+k]-(w[2*k-1][j]-w[i+k][j]+w[i][2*k-1]-w[i][j+k]+w[i+k][j+k]-w[i+k][j]-w[i][j+k]+w[i][j]+w[i][j]));
            ans=max(ans,karians);
        }
    }
    cout<<ans<<endl;    
    return 0;
}

Measured memory_bytes: 51260
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  priority_queue<long long>A;
  for(int i=0;i<N;i++){
    long long a;
    cin>>a;
    A.push(a);
  }
  for(int j=0;j<M;j++){
    long long b=A.top();
    b=b/2;
    A.pop();
    A.push(b);
  }
  long long sum=0;
  for(int i=0;i<N;i++){
    long long c=A.top();
    sum=sum+c;
    A.pop();
  }
  cout<<sum<<endl;
}
    


Measured memory_bytes: 1528
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define nl n<<1
#define nr (n<<1)  1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
const int INF=0x3f3f3f3f;
const ll INFF=0x3f3f3f3f3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-9;
const ll mod=1e9+7;
int main()
{
    int n;
    scanf("%d",&n);
    printf("ABC%d\n",n);
    return 0;
}







//#include<bits/stdc++.h>
//using namespace std;
//typedef long long ll;
//char s1[30],s2[100010],s3[100010];
//int vis[205];
//int main()
//{
//    scanf("%s%s",s1,s2);
//    int l1=strlen(s2);
//    for(int i=0;i<strlen(s1);i++)vis[s1[i]]=1;
//    int q;scanf("%d",&q);
//    while(q--)
//    {
//        scanf("%s",s3);
//        int l2=strlen(s3);
//        if(l1-l2>1)
//        {
//            printf("NO\n");continue;
//        }
//    }
//    return 0;
//}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long money = 100;
		long x = sc.nextLong();
		int cnt = 0;

		while(true) {
			money = money + money / 100;
			cnt++;
			if(money >= x) break;
		}
		System.out.println(cnt);

	}

}

Measured memory_bytes: 35616
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;
#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1; char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 200010;
const int INF = 1000000000;

int N,X,Y;
struct Tree{
	int dep[MAXN+1],fa[20][MAXN+1];
	int Node[MAXN<<1],Next[MAXN<<1],Root[MAXN<<1],cnt;
	inline void insert(int u,int v){
		Node[++cnt]=v; Next[cnt]=Root[u]; Root[u]=cnt; return ;
	}
	inline void dfs(int k,int Fa){
		if(Fa) dep[k]=dep[Fa]+1; fa[0][k]=Fa;
		for(int j=1;j<=19;j++) fa[j][k]=fa[j-1][fa[j-1][k]];
		for(int x=Root[k];x;x=Next[x]){
			int v=Node[x]; if(v==Fa) continue; dfs(v,k);
		} return ;
	}
	inline int LCA(int u,int v){
		if(dep[u]<dep[v]) swap(u,v);
		for(int i=19;i>=0;i--) if(dep[u]-dep[v]>=(1<<i)) u=fa[i][u];
		for(int i=19;i>=0;i--) if(fa[i][u]!=fa[i][v]) u=fa[i][u],v=fa[i][v];
		if(u!=v) return fa[0][u]; return u;
	}
	inline int dist(int u,int v){ return dep[u]+dep[v]-2*dep[LCA(u,v)]; }
}T[2];
int ans=0; bool use[MAXN+1];
inline void getans(int k,int Fa){
	if(!use[k]) return ;
	ans=max(ans,T[1].dep[k]);
	for(int x=T[0].Root[k];x;x=T[0].Next[x]){
		int v=T[0].Node[x]; if(v==Fa) continue;
		if(T[1].dist(k,v)>2) { puts("-1"); exit(0); }
		getans(v,k);
	}
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(),X=read(),Y=read();
	if(X==Y){ puts("0"); return 0; }
	for(int i=2;i<=N;i++){
		int u=read(),v=read(); 
		T[0].insert(u,v); T[0].insert(v,u);
	} for(int i=2;i<=N;i++){
		int u=read(),v=read();
		T[1].insert(u,v); T[1].insert(v,u);
	} T[0].dfs(X,0); T[1].dfs(Y,0);
	for(int i=1;i<=N;i++){
		if(T[0].dep[i]<T[1].dep[i]) use[i]=1;
	} getans(X,0);
	printf("%d\n",ans*2);
	return 0;
}


Measured memory_bytes: 46208
N = int(input())
a = list(map(int,input().split()))
num = 1000
flag = True
flag2 = True
for i in range(1,N):
  if a[i-1]<a[i] and flag == True:
    mi = a[i-1]
    ma = a[i]
    flag = False
  elif a[i-1]<a[i] and flag == False:
    ma = a[i]
  elif a[i-1]>a[i] and flag == False:
    num = (num//mi)*ma+(num%mi)
    flag = True
  if i == N-1 and flag == False:
    num = (num//mi)*ma+(num%mi)
print(num)

Measured memory_bytes: 9184
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
	int a,n;
	cin>>n>>a;
	if(n%500<=a) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

int main(){
  int n;

  while( true ){
    cin >> n;
    if( !n ) break;

    // a:テつ催δつ湘つャテつづδ古つ静つョテつ静つ氾つ、kテつ古δづつづδ古つ和テつづδーテつ偲δヲテつづδゥ
    // kテつ古δづつづδ古つ和テつづつェnテつづδつづδ暗つづδゥテつづδヲテつづつ、テつづδテつづつェテつ妥つカテつ催δ敕つづつキテつづδゥテつづつゥテつづδーテつ津つイテつづδ療つづδゥ
    // n = k*a+k(k-1)/2 
    int sum = 0,a;
    for( int k=2;true;k++ ){
      a = n-k*(k-1)/2;
      if( a<=0 )  break;
      if( a%k==0 ){
	sum++;
	//	cout << k << ",st="<<a/k<<"\t";
      }
    }
    cout << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define  sf  scanf
#define  pf  printf
int main()
{
    int i,j,n,s,c=0;
    sf("%d",&n);
    s=n;
    while(s!=0)
    {
        c+=(s%10);
        s/=10;
    }
    if(n%c==0)
    {
        pf("Yes\n");
    }
    else
    pf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
#include <climits>
using namespace std;

int main(){
    long long n;
    cin >> n;
    vector<long long> a(n), p(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        p[i] = a[i];
        if(i) p[i] += p[i - 1];
    }
    long long ans = 1e18;
    for(int i = 1; i < n - 2; ++i){
        int l = max(0, (int)(upper_bound(p.begin(), p.begin() + i + 1, p[i] / 2) - p.begin()) - 1);
        if(l + 1 != i){
            if(abs(p[i] - 2 * p[l]) > abs(p[i] - 2 * p[l + 1])) l++;
        }
        int r = max(i + 1, int(upper_bound(p.begin() + i, p.end(), (p[i] + p[n - 1]) / 2) - p.begin()) - 1);
        if(r + 1 != n - 1){
            if(abs(2 * p[r] - p[i] - p[n - 1]) > abs(2 * p[r + 1] - p[i] - p[n - 1])) r++;
        }
        long long mn = min(p[l], min(p[i] - p[l], min(p[r] - p[i], p[n - 1] - p[r]))), mx = max(p[l], max(p[i] - p[l], max(p[r] - p[i], p[n - 1] - p[r])));
        ans = min(ans, mx - mn);
    }
    cout << ans;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  ll n,k;
  cin >> n >> k;
  vector<ll> c(n),p(n);
  rep(i,n)cin >> p[i],p[i]--;
  rep(i,n)cin >> c[i];
  ll res = -1e10;
  vector<bool> seen(n,0);
  rep(i,n){
    if(seen[i])continue;
    vector<ll> v;
    ll pos = i;
    ll sum = 0,len = 0;
    while(!seen[pos]){
      sum += c[pos];len++;
      v.push_back(c[pos]);
      seen[pos] = 1;
      pos = p[pos];
    }
    if(sum > 0){
      sum *= max((k/len)-1,0ll);
      ll r = (k%len)+len;
      if(k < len)r -= len;
      ll RES = -1e10;
      {
        ll gg = v.size();
        rep(j,gg)v.push_back(v[j]);
        rep(j,gg)v.push_back(v[j]);
        rep(j,gg)v.push_back(v[j]);
      }
      ll gg = v.size();
      rep(l,v.size()){
        ll S = 0;
        for(ll j = l;j < min(gg,l+r);j++){
          S = max(S+v[j],v[j]);
          RES = max(RES,S);
        }
      }
      sum += max(0ll,RES);
    }else{
      if(v.size() > k){
        {
          ll gg = v.size();
          rep(j,gg)v.push_back(v[j]);
          rep(j,gg)v.push_back(v[j]);
        }
        ll gg = v.size();
        ll RES = -1e10;
        rep(l,v.size()){
          ll S = 0;
          for(ll j = l;j < min(gg,l+k);j++){
            S = max(S+v[j],v[j]);
            RES = max(RES,S);
          }
        }
        sum = RES;
      }else{
        {
          ll gg = v.size();
          rep(j,gg)v.push_back(v[j]);
          rep(j,gg)v.push_back(v[j]);
        }
        ll RES = -1e10;
        ll S = 0;
        rep(j,v.size()){
          S = max(S+v[j],v[j]);
          RES = max(RES,S);
        }
        sum = RES;
      }
    }
    res = max(res,sum);
  }
  cout << res << "\n";




  return 0;
}

Measured memory_bytes: 3832
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n)cin >> a[i];
    ll sum = 0;
    map<ll,ll>mp;
    rep(i,n)mp[a[i]]++;
    rep(i,n)sum += a[i];
    int q;
    cin >> q;
    while(q--){
        int b, c;
        cin >> b >> c;
        ll k = mp[b] * b;
        sum -= k;
        mp[c] += mp[b];
                sum += c * mp[b];
        mp[b] = 0;
        cout << sum << "\n";
    }
}


Measured memory_bytes: 10064
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
#define erase(i) erase(i, 1)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
template<typename T> void remove(std::vector<T>& vector, unsigned int index){vector.erase(vector.begin() + index);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;


signed main()
{
    string s;
    cin >> s;
    SORT(s);
    string ans = "";
    if(s[0] != 'a')
    {
        ans = "a";
        goto End;
    }
    rep(i,s.size()-1)
    {
        if(s[i+1] - s[i] > 1)
        {
            ans = s[i] + 1;
            break;
        }
    }
    if(ans == "" && s[s.size() - 1] != 'z')ans = s[s.size() - 1] + 1;
    if(ans == "")ans = "None";
    End:
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

int N,M;
vector<vector<int>> G;

int dp[100100];

int rec(int v){
    if(dp[v]!=-1) return dp[v];

    int res=0;
    for(auto nv:G[v]){
        chmax(res,rec(nv)+1);
    }
    return dp[v]=res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin>>N>>M;
    G.assign(N, vector<int>());
    for(int i=0;i<M;i++){
        int x,y;cin>>x>>y;
        --x,--y;
        G[x].push_back(y);
    }
    for(int v=0;v<N;++v) dp[v]=-1;
    int res=0;
    for(int v=0;v<N;++v) chmax(res,rec(v));
    cout<<res<<endl;
}


Measured memory_bytes: 8192
// Aizu Vol-5 0518: The Oldest Site
// 2017.9.1 bal4u@uu

#include <stdio.h>
#include <string.h>

typedef struct { int x, y; } T;
T p[3003]; int n;
char mk[5003][5003];

int ans;

int search(int x1, int y1, int x2, int y2)
{
	int x3, y3, x4, y4;
	int s;

	s = (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
	if (s < ans) return -1;

	x3 = x2+y1-y2, y3 = y2+x2-x1;
	x4 = x1+y1-y2, y4 = y1+x2-x1;
	if (x3 >= 0 && x3 <= 5000 && y3 >= 0 && y3 <= 5000 &&
		x4 >= 0 && x4 <= 5000 && y4 >= 0 && y4 <= 5000) {
		if (mk[x3][y3] && mk[x4][y4]) return s;
	}

	x3 = x2+y2-y1, y3 = y2+x1-x2;
	x4 = x1+y2-y1, y4 = y1+x1-x2;
	if (x3 >= 0 && x3 <= 5000 && y3 >= 0 && y3 <= 5000 &&
		x4 >= 0 && x4 <= 5000 && y4 >= 0 && y4 <= 5000) {
		if (mk[x3][y3] && mk[x4][y4]) return s;
	}
	return -1;
}

int main()
{
	int i, j, k, x, y;

	while (scanf("%d", &n) && n) {
		memset(mk, 0, sizeof(mk));
		for (i = 0; i < n; i++) {
			scanf("%d%d", &x, &y);
			p[i].x = x, p[i].y = y, mk[x][y] = 1; 
		}
		for (ans = 0, i = 0; i < n; i++) for (j = i+1; j < n; j++) {
			if ((k = search(p[i].x, p[i].y, p[j].x, p[j].y)) > ans) ans = k;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 25072
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

long binary_search(long lower, long upper, bool (* f)(long, long, long*, long), long N, long * A, long M){ 
    long middle;
    while(upper - lower > 1){
        middle = (lower + upper) / 2;
        if(f(middle, N, A, M)){
            lower = middle;
        }
        else{
            upper = middle;
        }
    }
    return lower;
}

long count_pair_over_m(long X, long N, long * A){  //A is in ascend order
    long sum = 0;
    long j = 0;
    long temp = 0;
    for(int i =0; i<N; i++){
        while(A[i] + A[N-1-j] >= X && j < N){
            j++;
        }
        sum += j;
    }
    return sum;
}

bool f(long X, long N, long * A, long M){
    if(count_pair_over_m(X, N, A) >= M) return true;
    else return false;
}

long sum(long X, long N, long * A, long M){  //A is in ascend order
    long ans = 0;
    long sum = 0;
    long j = 0;
    long temp = 0;
    long cnt = 0;
    for(int i =0; i<N; i++){
        while(A[i] + A[N-1-j] >= X && j < N && cnt < M){
            sum += A[N-1-j];
            j++;
        }
        cnt += j;
        ans += sum + A[i] * j;
    }
    if(cnt > M) {
        ans -= X * (cnt-M);
    }
    return ans;
}

int main(){
    long N, M;
    cin >> N >> M;
    long A[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A, A + N); 
    long min_happy = binary_search(-1, 2000001, f, N, A, M);
    long ans = sum(min_happy, N, A, M);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int Q = Integer.parseInt(S[1]);
    String[] T = sc.nextLine().split("");
    int[] val = new int[N];
    int count = 0;
    for(int i = 1; i < N; i++){
      if(T[i-1].equals("A") && T[i].equals("C")){
        count++;
      }
      val[i] = count;
    }
    
    for(int i = 0; i < Q; i++){
      int a = Integer.parseInt(sc.next())-1;
      int b = Integer.parseInt(sc.next())-1;
      System.out.println(val[b]-val[a]);
    }
  }
}

Measured memory_bytes: 52596
s = input()
ans = abs(753 - int(s[0] + s[1] + s[2]))
for i in range(1,len(s) - 2):
    n = s[i]+ s[i + 1] + s[i + 2]
    ans = min(ans,abs(int(n) - 753))
print(ans)

Measured memory_bytes: 9172
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<limits.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int IINF=INT32_MAX;
static const ll LINF=INT64_MAX;
static const ll mod=1e9+7;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};

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

ll A;

int main(){
    ll b1, b2;
    cin>>A;
    scanf("%lld.%lld", &b1, &b2);
    ll B=b1*100 + b2;
    cout<<A*B/100<<endl;
}

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

int main() {
    int n, d, x, p[10][10];
    cin >> n >> d >> x;
    for(int i=0;i<d;i++){
        for(int j=0;j<n;j++){
            cin >> p[i][j];
        }
    }
    int dp[11][100005];  // dp[i][j] 銘柄iまでみてj円使ったときの最大
    for(int i=0;i<d-1;i++){
        for(int j=0;j<n;j++) fill(dp[j], dp[j]+x+1, 0);
        dp[0][0] = x;
        for(int j=0;j<n;j++){
            for(int k=0;k<=100000;k++){
                dp[j+1][k] = max(dp[j+1][k], dp[j][k]);
                dp[j][k+1] = max(dp[j][k+1], dp[j][k]);
                if(k + p[i][j] <= x){
                    dp[j][k+p[i][j]] = max(dp[j][k+p[i][j]], dp[j][k]-p[i][j]+p[i+1][j]);
                }
            }
        }
        x = dp[n][x];
    }
    cout << x << endl;
    return 0;
}



Measured memory_bytes: 7388
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
	var a = parseInt(input[0], 10);
    var b = parseInt(input[1], 10);
    if(a == b){
    console.log('Yes');
      }else{
    console.log('No');
       }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits>
#include <memory>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define sz(a) static_cast<int>((a).size())
#define fillchar(a, x) memset(a, x, sizeof(a))
#define rep(i, a, b) for(int i=int(a); i<=int(b); ++i)
#define irep(i, a, b) for(int i=int(a); i>=int(b); --i)
#define replr(i, a, b) rep(i, a, (b)-1)
#define reprl(i, a, b) irep(i, (b)-1, a)
#define repn(i, n) rep(i, 0, (n)-1)
#define irepn(i, n) irep(i, (n)-1, 0)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<string> VS;
template<class T, class S> ostream& operator<<(ostream& os, const pair<T, S>& v) { return os<<"("<<v.first<<", "<<v.second<<")"; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { os<<"["; repn(i, sz(v)) { if(i) os<<", "; os<<v[i]; } return os<<"]"; }
template<class T> bool setmax(T &_a, T _b) { if(_b>_a) { _a=_b; return true; } return false; }
template<class T> bool setmin(T &_a, T _b) { if(_b<_a) { _a=_b; return true; } return false; }
template<class T> T gcd(T _a, T _b) { return _b==0?_a:gcd(_b,_a%_b); }

int main() {
    int x, y; cin>>x>>y;
    LL ans=1ll<<50;
    repn(i, 2) repn(j, 2) {
        int a=x, b=y;
        LL cur=0;
        if(i) ++cur, a=-a;
        if(j) ++cur, b=-b;
        if(a<=b) setmin(ans, cur+b-a);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 764
#include <algorithm>
#include <cstdio>
#define LL long long
#define maxn 600010
using namespace std;
struct node{
	int v,c;
}a[maxn];
int cmp(node a,node b){
	return a.v>b.v;
}
int main(){
	int X,Y,A,B,C,i,cnt;//红苹果1,绿苹果2,无色苹果0
	LL sum=0;
	scanf("%d%d%d%d%d",&X,&Y,&A,&B,&C);
	for(i=1;i<=A;i++)scanf("%d",&a[i].v),a[i].c=1;
	for(i=A+1;i<=A+B;i++)scanf("%d",&a[i].v),a[i].c=2;
	for(i=A+B+1;i<=A+B+C;i++)scanf("%d",&a[i].v),a[i].c=0;
	sort(a+1,a+1+A+B+C,cmp);//按美味值，自大到小排序
	cnt=0;//统计无色苹果数量
	for(i=1;i<=A+B+C;i++)
		if(a[i].c==1){//红苹果
			if(X>0)X--,sum+=a[i].v;
			if(X+Y==cnt)break;//无色苹果可替代红绿苹果
		}else if(a[i].c==2){//绿苹果
			if(Y>0)Y--,sum+=a[i].v;
			if(X+Y==cnt)break;//无色苹果可替代红绿苹果
		}else if(a[i].c==0){//无色苹果
			cnt++;
			sum+=a[i].v;
			if(X+Y==cnt)break;//无色苹果可替代红绿苹果
		}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, l;
	cin >> n >> l;
	vector<string> s(n);
	rep(snip_i, n) cin >> s.at(snip_i);
	sort(s.begin(), s.end());
	for(auto a : s){
		cout << a;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

int main() {
#ifdef kvutxdy
    freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/test/input.in", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h, a;
    cin >> h >> a;
    cout << (h / a) + (h % a > 0) << '\n';
}

Measured memory_bytes: 256
/**
*    author:  y_takano
*    created: 22.06.2020 10:17:57
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

using namespace std;

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

  int n, m, l;
  cin >> n >> m >> l;

  ll a[100][100] = {};
  ll b[100][100] = {};
  ll c[100][100] = {};



  REP(i, n)
  {
      REP(j, m)
      {
          cin >> a[i][j];
      }
  }

  REP(i, m)
  {
      REP(j, l)
      {
          cin >> b[i][j];
      }
  }

    REP(i, n)
  {
      REP(j, l)
      {
          REP(k, m)
          {
              c[i][j] += a[i][k] * b[k][j];
          }
      }
  }

  REP(i, n)
  {
      REP(j, l - 1)
      {
          cout << c[i][j] << ' ';
      }
      cout << c[i][l - 1] << endl;
  }


  

  return 0;
}


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

//conversion
//------------------------------------------
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();}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#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 SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()


int main() {
  int X,A,B;
  cin >> X >> A >> B;
  
  X -= A;
  
  while(X>=B) {
    X-=B;
  }
  
  cout << X << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define maxn 1005
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
using namespace std;
int n,cnt=0;
int tot=0;
struct node{
	int y,nxt;
}e[maxn*maxn];
int first[maxn*maxn],goin[maxn*maxn],q[maxn*maxn],dp[maxn*maxn];
int id[maxn][maxn],a[maxn];
void adde(int x,int y){
	e[tot].nxt=first[x];
	e[tot].y=y;
	first[x]=tot++;
	goin[y]++;
}
bool tupu(){
	int head=1,tail=0;
	for (int i=1;i<=cnt;i++)
	if (goin[i]==0) q[++tail]=i;
	while (head<=tail){
		int x=q[head];
		for (int i=first[x];i>=0;i=e[i].nxt){
			int y=e[i].y;
			goin[y]--;
			dp[y]=max(dp[x]+1,dp[y]);
			if (goin[y]==0) q[++tail]=y;
		}
		head++;
	}
	return tail==cnt;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=n;j++)
	if (i<j) id[i][j]=++cnt,first[cnt]=-1;
	for (int i=1;i<=n;i++){
		for (int j=1;j<n;j++)
			scanf("%d",&a[j]);
		for (int j=1;j<n-1;j++){
			int A=min(i,a[j]),B=max(i,a[j]);
			int C=min(i,a[j+1]),D=max(i,a[j+1]);
		//	printf("%d %d %d %d %d %d\n",A,B,C,D,id[A][B],id[C][D]);
			adde(id[A][B],id[C][D]);
		}
	}
/*	for (int i=1;i<=cnt;i++)
	printf("%d goin=%d\n",i,goin[i]);*/
	if (tupu()){
		int ans=0;
		for (int i=1;i<=cnt;i++)
		if (dp[i]>ans) ans=dp[i];
		printf("%d\n",ans+1);
	}else printf("-1");
	return 0;
}

Measured memory_bytes: 27648
from collections import defaultdict


class Team:
    def __init__(self, num):
        self.num = num
        self.score = 0
        self.time = 0
        self.penalty = defaultdict(int)


while True:
    _, T, _, R = map(int, input().split())
    if T == 0:break
    teams = [Team(i + 1) for i in range(T)]
    for _ in range(R):
        m, t, p, j = map(int, input().split())
        if j != 0:
            teams[t - 1].penalty[p] += 20
        if j == 0:
            teams[t - 1].score += 1
            teams[t - 1].time += m + teams[t - 1].penalty[p]

    teams.sort(key=lambda team: (-team.score, team.time, -team.num))
    ans = str(teams[0].num)
    pre_score = teams[0].score
    pre_time = teams[0].time
    for i in range(1, T):
        team = teams[i]
        ans += "=" if team.score == pre_score and team.time == pre_time else ","
        ans += str(team.num)
        pre_score = team.score
        pre_time = team.time
    print(ans)




Measured memory_bytes: 6012
import Control.Applicative
import Control.Monad
import Text.Printf

main :: IO ()
main = do
  [d, e] <- f
  unless (d == 0 && e == 0) $ do
    printf "%f\n" $ solve d e
    main
  where
    f = map read <$> words <$> getLine

solve :: Int -> Int -> Double
solve d e = f 200 (d, 0)
  where
    f :: Double -> (Int, Int) -> Double
    f dv (x, y)
      | x < y = dv
      | otherwise = f (min dv (abs $ fromIntegral e - (sqrt $ fromIntegral $ x ^ 2 + y ^ 2))) (x - 1, y + 1)



Measured memory_bytes: 4424
#include<iostream>
using namespace std;
void dfs(int v);
int graph[51][51],visited[51];
int N,M,flag;
int main(){
	cin>>N>>M;
	int a[M],b[M],ans=0;
	int i,j,k;
	for(i=0;i<51;i++){
		for(j=0;j<51;j++){
			graph[i][j]=0;
		}
	}
	for(i=0;i<M;i++){
		cin>>a[i]>>b[i];
		a[i]--;b[i]--;
		graph[a[i]][b[i]]=graph[b[i]][a[i]]=1;
	}
	/*for(i=1;i<51;i++){
		for(j=1;j<51;j++){
			cout<<graph[i][j]<<endl;
		}
	}*/
	for(i=0;i<M;i++){
		flag=0;
		graph[a[i]][b[i]]=graph[b[i]][a[i]]=0;
		for(j=0;j<N;j++)visited[j]=0;
		dfs(0);
		for(j=0;j<N;j++){
			if(visited[j]==0){
				flag=1;
			}
		}
		if(flag==1)ans++;
		graph[a[i]][b[i]]=graph[b[i]][a[i]]=1;
	}
	/*for(i=1;i<51;i++){
		for(j=1;j<51;j++){
			cout<<graph[i][j]<<endl;
		}
	}*/

	cout<<ans<<endl;
}

void dfs(int v){
	visited[v]=1;
	int i;
	for(i=0;i<N;i++){
		if(graph[v][i]==0)continue;
		if(visited[i]==1)continue;
		dfs(i);
	}
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

template <class InputIterator, class T>
bool contains(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    string s;
    cin >> s;
    if (s == "ABC")
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
vector<int> a,b,c,d;
int n,m,q;
int ans;

void dfs(vector<int> A){
    if(A.size()==n+1){
        int sum=0;
        for(int i=0;i<q;i++){
            if(A[b[i]]-A[a[i]]==c[i]){
                sum+=d[i];
            }
        }
        ans=max(ans,sum);
        return;
    }
    A.push_back(A.back());
    while(A.back()<=m){
        dfs(A);
        A.back()++;
    }
}
int main(){
    cin>>n>>m>>q;
    a=b=c=d=vector<int>(q);
    for(int i=0;i<q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    vector<int> A(1,1);
    dfs(A);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main()
  {
  int a,b,c,d,e;
  scanf("%d%d%d",&a,&b,&c);
  d=a-b;
  e=c-d;
  if(e<0)
    printf("0\n");
  else
  printf("%d\n",e);
  
  return 0;
  }


Measured memory_bytes: 128
import java.util.*;
    public class Main {
    	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int a[] = new int[3];
		int b[] = new int[2];
		b[0] = 0;
		b[1] = 0;

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

			a[i] = sc.nextInt();

			if(a[i] == 5){
				b[0]++;
			}
			else if(a[i] == 7){
				b[1]++;
			}
		}

		if((b[0] == 2) && (b[1] == 1)){
			System.out.println("YES");
		}
		else{
			System.out.println("NO");
		}
    	}
    }

Measured memory_bytes: 21844
d = [set([]) for i in range(4)]
for i in range(3):
    a, b = list(map(int, input().split()))
    d[a-1].add(b-1)
    d[b-1].add(a-1)

flag = False
def BFS(now, visited, depth):
    global flag
    if depth == 3:
        if len(visited) == 4:
            flag = True
        return

    for i in d[now]:
        if i in visited:
            continue
        next_visited = visited.copy()
        next_visited.add(i)
        BFS(i, next_visited, depth+1)

for i in range(4):
    BFS(i, set([i]), 0)

if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
def submit():
    n = int(input())
    alist = list(map(int, input().split()))
    modp = 10**9 + 7

    d = 1
    ans = 0
    for i in range(60):
        bit_test = [a & d > 0 for a in alist]
        on_count = sum(bit_test)
        off_count = n - on_count
        ans += d * on_count * off_count
        ans %= modp
        d = d<<1

    print(ans)


submit()
        

Measured memory_bytes: 42212
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int r,d,x;
    cin>>r>>d>>x;
    rep(i,1,10){
        x = r*x-d;
        cout<<x<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    if(n>=400&&n<=599)
    {
        cout<<"8\n";
    }
    else if(n>=600&&n<=799)
    {
        cout<<"7\n";
    }
    else if(n>=800&&n<=999)
    {
        cout<<"6\n";
    }
    else if(n>=1000&&n<=1199)
    {
        cout<<"5\n";
    }
    else if(n>=1200&&n<=1399)
    {
        cout<<"4\n";
    }
    else if(n>=1400&&n<=1599)
    {
        cout<<"3\n";
    }
    else if(n>=1600&&n<=1799)
    {
        cout<<"2\n";
    }
    else
    {
        cout<<"1\n";
    }
    return 0;
}

Measured memory_bytes: 3632
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let l: Vec<char> = input::<String>().chars().collect();
    const MOD: i64 = 1000000007;

    let n = l.len();
    let mut dp = vec![vec![0; 2]; n + 1];
    dp[0][0] = 1;
    for i in 0..n {
        if l[i] == '0' {
            dp[i + 1][0] += dp[i][0];
            dp[i + 1][1] += dp[i][1] * 3;
        } else {
            dp[i + 1][0] += dp[i][0] * 2;
            dp[i + 1][1] += dp[i][0] + dp[i][1] * 3;
        }
        dp[i + 1][0] %= MOD;
        dp[i + 1][1] %= MOD;
    }

    println!("{}", (dp[n][0] + dp[n][1]) % MOD);
}


Measured memory_bytes: 10492
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
ll n,k,ans=1;
vector<int> G[100001];

void dfs(int x,int y,ll z,ll d){
    ll flag=0;
    if(x==1){
        ans=k;
    }
    else if(k-z-d<=0){
        ans=0;
    }
    else{
        ans*=(k-d-z);
    }
    ans%=MOD;
    for(ll i=0;i<G[x].size();i++){
        if(G[x][i]!=y){
            dfs(G[x][i],x,i-flag,min(2LL,d+1));
        }
        else{
            flag=1LL;
        }
    }
}

int main(){
    int a,b;
    ans=1;
    scanf("%lld%lld",&n,&k);
    for(int i=0;i<n-1;i++){
        scanf("%d%d",&a,&b);
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(1,-1,0LL,0LL);
    printf("%lld\n",ans);
}

Measured memory_bytes: 11520
# coding: utf-8
# Your code here!
n=int(input())
sw=[0 for i in range(n)]
ox=list(input())

def who(x):
    if sw[x-1]=="S":
        a=1
    else:
        a=-1
        
    if sw[x]=="S":
        b=1
    else:
        b=-1
    
    if ox[x]=="o":
        c=1
    else:
        c=-1
    
    if a*b*c==1:
        return "S"
    else:
        return "W"
   
        
start=[["S","S"],["S","W"],["W","S"],["W","W"]]
ans=-1

for i in range(4):
    sw[0],sw[-1]=start[i]
    tmp1=sw[-1]
    tmp2=sw[0]

    for j in range(n):
        sw[(j+1)%n]=who(j)

    if tmp1==sw[-1] and tmp2==sw[0]:
        ans="".join(sw)
    
print(ans)

Measured memory_bytes: 4960
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define min(a,b) a > b ? b : a
#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int h,w,k;
vector<string> S;

int calc(int pat){
    int div = 0;
    rep(i,h-1){
        if((pat>>i) & 1)div++;
    }

    vector<int> mem(div+1);
    int ans = div;

    rep(i,w){
        int d = 0;
        vector<int> add(div+1);
        rep(j,h){
            if(S[j][i] == '1'){
                mem[d]++;
                add[d]++;
            }
            if((pat>>j) & 1)d++;
        }

        bool isOver = false;
        rep(j,div+1){
            if(mem[j] > k){
                isOver = true;
                ans++;
                break;
            }
        }

        if(isOver){
            rep(j,div+1){
                mem[j] = add[j];
                if(mem[j] > k) return -1;
            }
        }
    }
    return ans;
}

int main(){
    cin >> h >> w >> k;
    S.resize(h);

    rep(i,h){
        cin >> S[i];
    }
    int ans = h+w;
    rep(i,(1<<(h-1))){
        int a;
        a = calc(i);
        if(a != -1){
            ans = min(ans,a);
        }
    }

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

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    double N; cin >> N;
    vector<double> X(N);
    rep(i, N) cin >> X[i];

    double S=0, T=0;
    
    rep(i,N) S += X[i] * X[i];

    rep(i, N) T += X[i];

    double P = round(T / N);

    cout << N * P * P - 2 * T * P + S << endl;

}

Measured memory_bytes: 256
#! /usr/bin/env python

def proc_inputs ():
    num_inputs = int(input())
    inputs = [int(input()) for i in range(num_inputs)]
    return inputs

def main ():
    inputs = proc_inputs()
    print(calc_prof(inputs))
    exit(0)

def calc_prof (inputs):
    maxnum = inputs[-1]
    # minnum = min(inputs[:-1])
    inputs.reverse()
    profs = []

    for i,n in enumerate(inputs[1:]):
        profs.append(maxnum - n)

        if n > maxnum and i != len(inputs) - 1:
            maxnum = n
            # print(maxnum)

        # if n >= maxnum and i != len(inputs) - 2:
        #     minnum = n
            # print("min changed at {} to {}".format(i, n))
            # maxnum = n
            # print(minnum)

    return max(profs)

if __name__ == "__main__":
    main()





Measured memory_bytes: 18732
using System;

namespace ABC104_B_AcCepted
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string s = Console.ReadLine();
			string[] sArr = new string[s.Length];
			

			for (int i = 0; i < s.Length; i++)
			{
				sArr[i] = s.Substring(i, 1);
			}
			
			int countC = 0;
			int appearC = 0;
			bool smallChar = true;
			
			for (int i = 2; i < s.Length - 1; i++) {
				if (sArr[i] == "C")
				{
					countC++;
					appearC = i;
				}
			}

			for (int i = 1; i < s.Length; i++) {
				if (!char.IsLower(sArr[i], 0))
				{
					if (i != 0 && i != appearC)
					{
						smallChar = false;
					}
				}
			}

			if (sArr[0] == "A" && countC == 1 && smallChar) 
			{
				Console.WriteLine("AC");
			}
			else
			{
				Console.WriteLine("WA");
			}
		}
	}
}

Measured memory_bytes: 11092