akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ans = min(k, a);
  k -= min(k, a);
  k -= min(k, b);
  cout << ans - k << endl;
  return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  string ans="No";
  for (int i=1; i <10 ;  i++){
    for (int j=1; j <10 ; j++){
      if(N== i * j){
        ans="Yes";
        break;
      }
    }
  }
  cout << ans << endl;
}
  

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

using namespace std;

int main()
{     int A[100005];
         int ftime=0;
         int ttime=0;
         int ztime=0;
       memset(A,0,sizeof(A));
        int N;
         cin>>N;
         int b;
          for(int i=0;i<N;i++)
          {
              cin>>b;
              if(b%4==0)
              {
                  ftime++;
              }
              else if(b%2==0)
              {
                  ttime++;
              }
              else
                ztime++;
          }
          if(ttime==0)
          {
               if(ftime>=ztime-1)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
          }
          else
          {
               if(ftime>=ztime)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
          }
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	protected static final String CORRECT = "AC";
	protected static final String WRONG = "WA";

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		int[] missions = new int[N];
		int[] scores = new int[N];
		int correctRes = 0;
		int penaltiesRes = 0;
		for (int i = 0; i < M; i++) {
			int num = scanner.nextInt() - 1;
			String score = scanner.next();
			if (scores[num] == 1) {
				
			}else if (score.equals(CORRECT)) {
				correctRes ++;
				scores[num] = 1;
			}else {
				missions[num] ++;
			}
		}
		for (int i = 0; i < N; i++) {
			if (scores[i] == 1) {
				penaltiesRes += missions[i];
			}
		}
		System.out.println(correctRes);
		System.out.println(penaltiesRes);
		scanner.close();
	}
}

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

int main() {
  int N,n,s=0;
  cin>>N;
  n = N;
  while(n>0){
    s += n%10;
    n/=10;
  }
  if(N%s==0){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}

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

int main(){

	int k,n ; cin >> k >> n;
	int a[n];
	for(int i = 0; i<n;i++ ) cin >> a[i];
	int max_dist = 0;
	for(int i =1;i<n;i++){
		max_dist = max(max_dist,a[i]-a[i-1]);
	}
	max_dist = max(max_dist,a[0]+k-a[n-1]);
	cout << k - max_dist;

	
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a[ohara],b[ohara],c[ohara],d,tmp,tmpp,m,h,w,y,pos,k,bit[ohara];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
bool fl;
struct edge{int to,cost;};
ll atu[ohara];
ll atu_cou;
map<ll,ll> mp;
unordered_map<ll,ll> fuku;
ll tasu;
ll yoso;
ll anss;
ll before;
vector<ll> kouho;
ll zyuu[ohara];

//-------------------------↓↓↓↓↓↓------------------------

ll sum(ll i){
  ll s=0;
  while(i>0){
    s+=bit[i];
    i-=i&-i;
  }
  return s;
}

void add(ll i,ll x){
  while(i<=ohara-10){
    bit[i]+=x;
    i+=i&-i;
  }
}

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

    //cin>>n;
    scanf("%lld",&n);
    rep(i,n){
        //cin>>a[i];
        scanf("%lld",&a[i]);
        if(a[i]==1){
          //cin>>b[i]>>c[i];
          scanf(" %lld %lld",&b[i],&c[i]);
          atu[atu_cou++]=b[i];
        }
    }
    sort(atu,atu+atu_cou);
    tmp=1;
    rep(i,atu_cou-1){
        mp[atu[i]]=tmp;
        fuku[tmp]=atu[i];
        if(atu[i]!=atu[i+1])tmp++;
    }
    mp[atu[atu_cou-1]]=tmp;
    fuku[tmp]=atu[atu_cou-1];
    rep(i,n){
      if(a[i]==1){
        add(mp[b[i]],1LL);
        zyuu[mp[b[i]]]++;
        tasu+=c[i];
        yoso++;

         ll le=1,ri=tmp,mid;
        while(ri-le>1){
          mid=(le+ri)/2;
          if(sum(mid)-zyuu[mid]+1>(yoso+1)/2)ri=mid;
          else if((yoso+1)/2>sum(mid))le=mid;
          else break;
        }
        int ok=0;
        rrep(j,max(le-3,0LL),min(ri+3,tmp+1)){
          if(sum(j)-zyuu[j]+1<=(yoso+1)/2&&(yoso+1)/2<=sum(j)){
            tmpp=j;
            ok=1;
            break;
          }
        }
        if(!ok)tmpp=tmp;
        /////
        ans+=(yoso%2==0?abs(fuku[before]-b[i]):abs(fuku[tmpp]-b[i]));
        /////
        anss=fuku[tmpp];
        before=tmpp;
      }
      else{
        printf("%lld %lld\n",anss,ans+tasu);
      }
    }
    return 0;
}


Measured memory_bytes: 34212
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

const ll INF = 1e9;
const long long INFL = 1LL<<60;

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

  ll n = 0;
  ll s = 0;

  rep(i, m) {
    ll d, c;
    cin >> d >> c;
    n += c;
    s += d * c;
  }

  ll ans = (n - 1) + (s - 1) / 9;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

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

    int ans = 0;
    for (int i = 0; i < n - 2; i++) {
        if (p[i] > p[i+1] && p[i+1] > p[i+2]) ans++;
        if (p[i] < p[i+1] && p[i+1] < p[i+2]) ans++;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  set<int> s;
  int a;
  int n;
  cin>>n;
  rep(i,n){
    cin>>a;
    s.insert(a);
  }
  
  int ans=0;
  
  for(auto x:s){
    ans++;
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef struct ver{
  int e[101];
  int se;
  int color;
} ver;
  
int n,u,v;
int h,t;
int Q[500];
int d[101];
ver g[101];

int dequeue(){
  int x;
  x=Q[h];
  h++;
  return x;
}

void enqueue(int x){
  Q[t]=x;
  t++;
}

void bfs(int s){
  int u,v,i;
  for(u=1;u<=n;u++){
    g[u].color=0;
    d[u]=-1;
  }
  g[s].color=1;
  d[s]=0;
  h=t=0;
  enqueue(s);
  while(h-t!=0){
    u=dequeue();
    for(i=1;i<=g[u].se;i++){
      v=g[u].e[i];
      if(g[v].color==0){
	g[v].color=1;
	d[v]=d[u]+1;
	enqueue(v);
      }
    }
  }
  g[u].color=2;
}

int main(){
  int i,j,k,v;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    g[u].se=k;
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      g[u].e[j]=v;
    }
  }
  bfs(1);
  for(i=1;i<=n;i++){
    printf("%d %d\n",i,d[i]);
  }
 return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))

struct UnionFind{
  vector<int> d;
  UnionFind(int n = 0): d(n, -1){};
  int find(int x){
    if(d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y){
    x = find(x); y = find(y);
    if(x == y) return false;
    if(d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y){
    return find(x) == find(y);
  }
  int size(int x){
    return -d[find(x)];
  }
};

int deg[100000];//直接の友達の数
vector<int> to[100000];//ブロック関係の隣接リスト


int main(){
  fill(deg, deg+100000,1);
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--;b--;
    deg[a]++;deg[b]++;
    uf.unite(a, b);
  }
  rep(i, k){
    int c, d;
    cin >> c >> d;
    c--;d--;
    to[c].push_back(d);to[d].push_back(c);
  }
  
  rep(i, n){
    int ans = 0;
    ans = uf.size(i) - deg[i];
    for(int x : to[i]){
      if(uf.same(x, i)) ans--;
    }
    printf("%d%c", ans, i==n-1 ? '\n' : ' ');
  }
}
    
  

Measured memory_bytes: 6784
#include<iostream>
#include<cmath>

long long n,a[100000],minus,min=10000000000,res;

int main(){

    std::cin>>n;

    for(int i=0;i<n;i++){
        std::cin>>a[i];
        if(min>std::abs(a[i]))min=std::abs(a[i]);
        if(a[i]<0)
        minus++;
        res+=abs(a[i]);
    }

    if(minus%2==1)res-=min*2;

    std::cout<<res<<std::endl;

    return 0;

}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n;
ll K;

int main()
{
	scanf("%d",&n);
	if(n%2==1)n *= 2;
	printf("%d\n",n);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
long long n,t,a,b,ans;

int main(){
	cin>>n>>t;
	cin>>a;
	for(int i=0;i<n-1;i++){
		cin>>b;
		if(b-a>t){
			ans+=t;
		}else{
			ans+=b-a;
		}
		swap(a,b);
	}
	cout<<ans+t<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int N, K;
	scanf ("%d %d", &N, &K);
	int scores[N];

	for (int i = 0; i < N; i++) {
	  scanf("%d", &scores[i]);
	}
	
	for (int i = 0; i < N-K; i++) {
		(scores[i] < scores[i+K]) ? puts("Yes") : puts("No");
	}
	
	return 0;
}

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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
        llin(n);
        llin(m);
        vllin(a,m);
        vll c(n+1,0);
        if(n==1){
                sal(1)
                return 0;
        }
        c[0]=1;
        c[1]=1;
        FOR(i,2,n){
                c[i]=(c[i-1]+c[i-2])%MOD;
        }
        if(m==0){
                sal(c[n])
                return 0;
        }
        ll k=c[a[0]-1];
        FOR(i,1,m-1){
                if(a[i]-a[i-1]==1){
                        sal(0)
                        return 0;
                }
                k=(k*c[a[i]-a[i-1]-2])%MOD;
        }
        k=(k*c[n-a[m-1]-1])%MOD;
        sal(k)
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;



int main()
{
int arr[3];
cin>>arr[0]>>arr[1]>>arr[2];
cout<<arr[2]<<" " <<arr[0]<<" "<<arr[1]<<endl;

 return 0;
}


Measured memory_bytes: 3632
import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    Edge = [[] for _ in range(N)]
    for _ in range(M):
        l, r, d = map(int, input().split())
        Edge[l-1].append((r-1, d))
        Edge[r-1].append((l-1, -1 * d))
    Dist = [10 ** 20] * N
    possible = True
    for i in range(N):
        if Dist[i] == 10 ** 20:
            q = deque()
            q.append((i, 0))
            while q:
                nn, nd = q.popleft()
                if Dist[nn] == 10 ** 20:
                    Dist[nn] = nd
                    for ne, add in Edge[nn]: q.append((ne, nd + add))
                else:
                    if Dist[nn] == nd: continue
                    else:
                        possible = False
                        break
            if not possible:
                print("No")
                break
    else: print("Yes")

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 92920
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

const vector<string> targets = {
	"dreamer",
	"dream",
	"eraser",
	"erase"
};

int main() {
	string s;
	cin >> s;

	reverse(s.begin(), s.end());
	vector<string> targets2;
	for (auto t: targets) {
		reverse(t.begin(), t.end());
		targets2.emplace_back(t);
	}

	int idx = 0;
	while (idx < s.size()) {
		bool updates = false;
		for (auto t: targets2) {
			string u = s.substr(idx, t.size());
			if (u == t) {
				idx += u.size();
				updates = true;
				break;
			}
		}

		if (!updates) {
			break;
		}
	}

	cout << (idx == s.size() ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 512
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double[] x = new double[N];
        String[] s = new String[N];
        float sum = 0;
        for(int i = 0; i<N; i++) {
            x[i] = sc.nextDouble();
            s[i] = sc.next();
            if(s[i].equals("BTC")) {
                sum += x[i]*380000.0;
            }else {
                sum += x[i];
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 22612
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n,a[300],l,b[300];
char s[100];
int main(){
	scanf("%d",&n);
	n--;
	scanf("%s",s+1);
	l=strlen(s+1);
	fo(i,1,l) a[s[i]]++;
	while (n--){
		scanf("%s",s+1);
		l=strlen(s+1);
		fo(i,'a','z') b[i]=0;
		fo(i,1,l) b[s[i]]++;
		fo(i,'a','z') if (b[i]<a[i]) a[i]=b[i];
	}
	fo(i,'a','z')
		fo(j,1,a[i])
			putchar(i);
	return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main implements Comparable<Main>{
	private int deadline;
	private int takes;
	
	Main(String in) {
		String[] t = in.split(" ");
		deadline = Integer.parseInt(t[1]);
		takes = Integer.parseInt(t[0]);
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
	    List<Main> task = new ArrayList<>();
	    String kizahashiSay = "Yes";
	    int num = Integer.parseInt(in.nextLine());
	    for (int i = 0; i < num; i++) {
	      task.add(new Main(in.nextLine()));
	    }
	    in.close();
	    task.sort((e, o) -> e.compareTo(o));
	    long surplusTime = 0;
	    int nowTime = 0;
	    long elapsedTime = 0;
	    for (Main e : task) {
	    	elapsedTime = e.deadline() - nowTime;
	    	nowTime = e.deadline();
	    	surplusTime += elapsedTime - e.cost();
	    	if (surplusTime < 0) {
	    		kizahashiSay = "No";
	    		break;
	    	}
	    }
	    System.out.println(kizahashiSay);
	}

	@Override
	public int compareTo(Main o) {
		Main other = (Main) o;
		return this.deadline - other.deadline();
	}
	
	public int deadline() {
		return this.deadline;
	}
	public int cost() {
		return this.takes;
	}
	
}


Measured memory_bytes: 183016
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main() {
	string s;
	cin >> s;

	int ans = 0;
	int tmp = 0;
	for (int i = 0;i < s.length();i++) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			tmp++;
		}
		else {
			if (ans < tmp) {
				ans = tmp;
			}
			tmp = 0;
		}
	}

	if (ans < tmp) {
		ans = tmp;
	}

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


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

int n,f,p;


long long C(int n,int m)
{
	if(n==m) return 1ll;
	if(!m||!n) return 1ll;
	return C(n-1,m)+C(n-1,m-1);
}

int main()
{
	scanf("%d%d",&n,&p);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		if(x&1) f++;
	}
	long long Ans=0;
	for(int i=p;i<=f;i+=2) Ans+=C(f,i);
	Ans<<=n-f;
	cout<<Ans<<endl;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n, A[MAX], s;
int B[MAX], T[VMAX + 1];

int solve()
{
    int ans = 0;

    bool V[MAX];
    for (int i = 0; i < n; i++) {
        B[i] = A[i];
        V[i] = false;
    }

    sort(B, B+n);
    for (int i = 0; i < n; i++) {
        T[B[i]] = i;
    }
    for (int i = 0; i < n; i++) {
        if (V[i]) continue;
        int cur = i;
        int S = 0;
        int m = VMAX;
        int an = 0;
        while (1) {
            V[cur] = true;
            an++;
            int v = A[cur];
            m = min(m, v);
            S += v;
            cur = T[v];
            if (V[cur]) break;
        }
        ans += min(S + (an - 2) * m, m + S + (an + 1) * s);
    }

    return ans;
}


int main(int argc, char const *argv[])
{
    cin >> n;
    s = VMAX;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        s = min(s, A[i]);
    }
    int ans = solve();
    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 3152
#include<bits//stdc++.h>
using namespace std;
#define int long long
char a[500][500];
string s;
int n,b[500],c[500],ans=1145141919810,sum;
signed main(){
	cin>>n;
	bool l=false;
	for(int i=0;i<n;i++){
		cin>>s;
		for(int j=0;j<n;j++){
			a[i][j]=s[j];
			if(s[j]=='#'){
				b[i]++;
				c[j]++;
				l=1;
			}
		}
	}
	if(!l){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=0;i<n;i++){
		if(c[i]==n) sum++;
	}
	for(int i=0;i<n;i++){
		if(b[i]==n){
			ans=min(ans,n-sum);
		}
		else if(c[i]==0){
			ans=min(ans,n-b[i]+n-sum+1);
		}
		else{
			ans=min(ans,n-b[i]+n-sum);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<iostream>
 
using namespace std;
 
int main(){
	int a,b,c;
	int p;
	while(1){
		cin>>a>>b>>c;

		p = a+b;

		if(a==-1 && b==-1 && c==-1)
			break;

		if(a==-1){
			cout<<"F"<<endl;
			continue;
		}
	
		if(b==-1){
			cout<<"F"<<endl;
			continue;
		}
		
		if(80<=p)
			cout<<"A";
		else if(65<=p && p<80)
			cout<<"B";
		else if(50<=p && p<65)
			cout<<"C";
		else if(30<=p && p<50)
			if(50<=c)
				cout<<"C";
			else
				cout<<"D";
		else
			cout<<"F";		

		cout<<endl;


	}
	return 0;
}

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

int main() {
    string S;
    cin >> S;
    int N=0;
    for(int i=0; i<4; i++){
        if(S.at(i) == '+'){
            N += 1;
        }
        else{
            N -= 1;
        }
    }
    cout << N << endl;
}


Measured memory_bytes: 256
t = [int(input()) for i in range(5)]
t.sort()
count = 0
min_list = [t[0]%10,t[1]%10,t[2]%10,t[3]%10,t[4]%10]
min_list.sort()
for i in range(5):
    x = min_list[i]
    if x != 0:
        break
f =min([t[0]%10,t[1]%10,t[2]%10,t[3]%10,t[4]%10])
for i in range(5):
    if t[i]%10 == 0 :
        t[i] = t[i]-1
        count = 1
a =(t[4]//10+1)*10
b =(t[3]//10+1)*10
c =(t[2]//10+1)*10
d =(t[1]//10+1)*10
e =(t[0]//10+1)*10
if count == 0:
        print(a+b+c+d+e+f-10)
else:
    if min_list == [0]*5:
        print(a+b+c+d+e)
    else:
        print(a+b+c+d+e+x-10)


Measured memory_bytes: 3064
a = int(input())
b = int(input())
if a == 1:
  if b == 2:
    print(3)
  else:
    print(2)
elif a == 2:
  if b == 1:
    print(3)
  else:
    print(1)
else:
  if b == 1:
    print(2)
  else:
    print(1)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
	//freopen("test", "r", stdin);
	ios::sync_with_stdio(false);
	int A1, A2, A3;
	cin >> A1 >> A2 >> A3;	
	if(A1 + A2 + A3 >= 22){
		cout << "bust";	
	}else
		cout << "win";
	return 0;
}


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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 100100;

vi a[N];
vi b[N];
int cost[N];
int sz = 0;
bool use[N];
int lim[N];

void dfs(int v) {
	use[v] = 1;
	b[sz].pb(cost[v]);
	forn(i, sz(a[v])) {
		int to = a[v][i];
		if (!use[to])
			dfs(to);
	}
}

int main () {
	//std::ios::sync_with_stdio(false);
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	int n, m;
	cin >> n >> m;
	forn(i, n) {
		cin >> cost[i];
	}
	forn(i, m) {
		int u, v;
		cin >> u >> v;
		a[u].pb(v);
		a[v].pb(u);
	}
	forn(i, n) {
		if (!use[i]) {
			dfs(i);
			sz++;
		}
	}
	if (sz == 1) {
		cout << 0 << endl;
		return 0;
	}
	if (2 * (sz - 1) > n) {
		puts("Impossible");
		debug(sz);
		return 0;
	}
	ll ans = 0;
	int kol = 0;
	ve<pii> ord;
	forn(i, sz) {
		sort(all(b[i]));
		ans += b[i][0];
		kol++;
		lim[i]++;
		forn(j, 1, sz(b[i])) {
			ord.pb(mp(b[i][j], i));			
		}
	}
	sort(all(ord));
	forn(i, sz(ord)) {
		int v = ord[i].sc;
		if (lim[v] == sz - 1) {
			continue;
		}
		if (kol == 2 * (sz - 1)) {
			continue;
		}
		lim[v]++;
		ans += ord[i].fs;
		kol++;
	}
	if (2 * (sz - 1) > kol) {
		puts("Impossible");
		debug(mt(kol, sz));
		return 0;
	}
	cout << ans << endl; 
	
	return 0;
}

Measured memory_bytes: 10360
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  string s;
  cin>>s;
  for(int p=0;p<(1<<4);p++){
    vector<int> a(4);
    for(int i=0;i<4;i++){
      if((p>>i)&1){a[i]=1;}
    }
    string g;
    if(a[0]){g.push_back('A');}
    g+="KIH";
    if(a[1]){g.push_back('A');}
    g.push_back('B');
    if(a[2]){g.push_back('A');}
    g.push_back('R');
    if(a[3]){g.push_back('A');}

    if(s==g){cout<<"YES"<<endl;return 0;}
  }
  cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <functional>
#include <set>
using namespace std;
int main() {
	long N;
	cin >> N;
	long answer = 0;
	for (int i = 0; i < N; i++) {
		long a;
		cin >> a;
		while (a % 2 == 0) {
			a = long(a/2);
			answer += 1;
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
N,L=map(int,input().split())
taste=[0] #0は数合わせ
sum1=0
for i in range(1,N+1): #1～N
    a=L+i-1
    sum1+=a
    taste.append(a)

#print(sum1)
#print(taste)

ans=0
best=100000
for i in range(1,N+1): #どれを食べるか
    sum2=sum1-taste[i]
    dif=abs(sum1-sum2)
    #print(str(i)+" "+str(sum2)+" "+str(dif))
    if dif<best:
        best=dif
        ans=sum2
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){
    
    ll N, T;
    cin >> N >> T;
    ll ans = 0;
    ll r = -1;
    for(ll i = 0; i < N; i++){
        ll t;
        cin >> t;
        if(t > r)ans += T;
        else ans += (t + T - r);
        r = t + T;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	char A;
	cin >> A;
	if(A == 'A'){
		cout << "T" << endl;
	}else if(A == 'T'){
		cout << "A" << endl;
	}else if(A == 'G'){
		cout << "C" << endl;
	}else{
		cout << "G" << endl;
	}
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    ll n;
    cin >> n;
    if (n%2 == 0) cout << n << endl;
    else cout << n*2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>

ll INF = 1000000007;


//-----------------//
  #define amin main
//----------------//
    ll dp[2002]={0};

int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j;
	ll n;
	cin>>n;
	memset(dp,0,sizeof(dp));
	for(i=3;i<=n;i++)
	{

		dp[i] = 1;
		for(j=1;j<n;j++)
		{
			if(i-j>=3 && j>=3)
			{
				dp[i] = (dp[i]+dp[j])%INF;
			}
		}
	}
	cout<<dp[n]<<endl;
	// ll dp[n+2][n+2];
	// memset(dp, 0, sizeof(dp));
	// dp[0][n+1]=1;
	// for (int k = n; k >= 3; k--) { 
 //        for (i = 0; i <= n; i++) { 
 //            dp[i][k] = (dp[i][k + 1])%INF;
 //            if (i - k >= 0) 
 //                dp[i][k] = (dp[i][k]%INF + dp[i - k][k]%INF)%INF; 
 //        } 

	
	


	
	return 0;
}

Measured memory_bytes: 3648
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = [0,0] + list(map(int,read().split()))
child = [[] for _ in range(n+1)]

for i,ai in enumerate(a[2:],2):
    child[ai].append(i)

stack = [1]
tp = []
while(stack):
    i = stack.pop()
    tp.append(i)

    for j in child[i]:
        stack.append(j)

cost = [[] for _ in range(n+1)]
for i in tp[::-1]:
    if(len(cost[i])==0):
        cost[a[i]].append(0)
        continue

    cost_i = sorted(cost[i], reverse=True)
    for j in range(len(cost_i)):
        cost_i[j] += j+1
    cost[a[i]].append(max(cost_i))

print(cost[0][0])

Measured memory_bytes: 109132
import itertools
import math
N = int(input())
xy= [list(map(int, input().split())) for _ in range(N)]

#順列の生成
permi = list(itertools.permutations(range(N)))


sum_kyori = 0
for i in range(math.factorial(N)):
    kyori = 0

    for j in range(1,N):
        
        x_ = (xy[permi[i][j]][0] - xy[permi[i][j-1]][0])**2 
        y_ = (xy[permi[i][j]][1] - xy[permi[i][j-1]][1])**2
        kyori += math.sqrt(x_ + y_)
    sum_kyori += kyori

ans=(float(sum_kyori/math.factorial(N)))
print(ans)

Measured memory_bytes: 7972
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>

int main()
{
    std::string S;
    std::cin >> S;
    int flag=0;
    for(long i=0; i<S.length();i++){
        if(i%2==1){
            if(S[i]=='R'){
                flag=1;
            }
        }
        if(i%2==0){
            if(S[i]=='L'){
                flag=1;
            }
        }
    }
    if(flag==0){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

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

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main() {
    int a=0;
    string n;
    cin >> n;
    for(int i=0; i < n.size(); ++i){
        a += ctoi(n.at(i));
    }
    if(a%9==0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}




Measured memory_bytes: 3712
#include <iostream>
using namespace std;
int main(){

	int a,b,c,d,e,f,g,h,s,t;
	cin >> a >> b >> c >> d >> e >> f >> g >> h;
	s = a+b+c+d;
	t = e+f+g+h;

	if(s >= t){
		cout << s << endl;
	}
	else{
		cout << t << endl;
	}

	return 0;
}


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(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())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (1 <= a && a <= 9 && 1 <= b && b <= 9 ? a * b : -1) << endl;

    return 0;
}


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

using namespace std;

int n, m, a[15], stat[15], ans = 0;

bool valid (int mask) {
  for (int i = 0; i < m; i++) {
    if (((__builtin_popcount(a[i] & mask) & 1)) != stat[i]) return false;
  }
  return true;
}

int solve (int p, int mask) {
  if (p > n) return (valid (mask) == 1);
  return solve (p + 1, mask) + solve (p + 1, mask | (1 << p));
}

int main () {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int mask = 0, k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int p;
      cin >> p;
      mask |= (1 << p);
    }
    a[i] = mask;
  }
  for (int i = 0; i < m; i++) {
    cin >> stat[i];
  }
  cout << solve (1, 0) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
int main()
{
	int n,m,a[1000],i,t=0;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int j; 
	for(i=1;i<n;i++)
	{
	 	for(j=1;j<=n-i;j++)
		 {
		 	if(a[j]<a[j+1])
		 	swap(a[j],a[j+1]);
				 }		
	}
	for(i=1;i<=m;i++)
	{
		t=t+a[i];
	}
	cout<<t;
	return 0;
}











Measured memory_bytes: 256
def xor_sum(n):
    #0からの連続数のXOR和は４つ目が０（初項）
    st =n -n%4
    n_list =[i for i in range(st,n+1)]
    ans =0
    for i in n_list:
        ans ^=i
    return ans
# 初期入力

import sys
input = sys.stdin.readline
A,B = (int(i) for i in input().split())
ans =xor_sum(B) ^xor_sum(A-1)
print(ans)

Measured memory_bytes: 9004
/* You lost the game. */
 
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cfloat>
#include <numeric>
#include <cassert>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <vector>
#include <pthread.h>
 
#define fin(i,n) for (int i = (L) 0; i < n; i++)
#define fin2(i,a,b) for (int i = a; i < b; i++)
 
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define mod 1000000007
#define PI 3.1415926535897932384626
 
#define si(n) scanf("%d", &n)
#define sii(n,m) scanf("%d %d", &n, &m)
#define siii(n,m,k) scanf("%d %d %d", &n, &m, &k)
#define sl(n) scanf("%lld", &n)
#define sll(n,m) scanf("%lld %lld", &n, &m)
#define slll(n,m,k) scanf("%lld %lld %lld", &n, &m, &k)
#define sd(n) scanf("%lf", &n)
#define sdd(n,m) scanf("%lf %lf", &n, &m)
#define sddd(n,m,k) scanf("%lf %lf %lf", &n, &m, &k)
#define sc(c) scanf("%c", &c)
#define ss(s) scanf("%s", s)
#define sai(t,n) fin(i,n) { scanf("%d", &t[i]); }
#define sal(t,n) fin(i,n) { scanf("%lld", &t[i]); }
#define sad(t,n) fin(i,n) { scanf("%lf", &t[i]); }
 
#define pc(n) printf("%c\n", n)
#define ps(s) printf("%s\n", s)
#define pi(n) printf("%d\n", n)
#define pii(n,m) printf("%d %d\n", n, m)
#define pl(n) printf("%lld\n", n)
#define pll(n,m) printf("%lld %lld\n", n, m)
#define plll(n,m,k) printf("%lld %lld %lld\n", n, m, k)
#define pd(n) printf("%lf\n", n)
#define pdd(n,m) printf("%lf %lf\n", n, m)
#define pai(t,n) fin(i,n) { printf("%d ", t[i]); } printf("\n")
#define pal(t,n) fin(i,n) { printf("%lld ", t[i]); } printf("\n")
#define pad(t,n) fin(i,n) { printf("%lf ", t[i]); } printf("\n")

#define OK ps("OK")
#define OK1 ps("OK1")
#define OK2 ps("OK2")
 
#define L long long int
#define D double
#define C char
#define PII pair<int, int>
#define VPII vector<PII>
#define VL vector<L>
#define VI vector<int>
#define VVI vector<VI>
#define VD vector<D>
#define VVD vector<VD>
#define VVPII vector<VPII>
#define VC vector<C>
 
using namespace std;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    char s[20000];
    ss(s);
    int n = strlen(s);
    fin(i, n-8) { printf("%c", s[i]); }
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

int main() {
  ll X;
  cin >> X;

  ll ng = 0;
  ll ok = 1e9;

  while(ok - ng > 1){
    ll mid =(ok+ng)/2;

    if((ll)mid*(mid+1)/2 >= X){
      ok = mid;
    }else{
      ng = mid;
    }
  }

  cout << ok << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);

		while(sc.hasNext())
		{
			int n=1000-sc.nextInt();
			if(n==1000)
				return;
			int ans = 0;

			if(n>=500)
			{
				n -=500;
				ans++;
			}
			while(n>=100)
			{
				n-=100;
				ans++;
			}
			if(n>=50)
			{
				n-=50;
				ans++;
			}
			while(n>=10)
			{
				n-=10;
				ans++;
			}
			if(n>=5)
			{
				n-=5;
				ans++;
			}
			while(n>=1)
			{
				n-=1;
				ans++;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);
    	int a=sc.nextInt();
    	int b=sc.nextInt();
    	
    	int sum=a+b;
    	int ave=(sum+2-1)/2;
    	
    	System.out.println(ave);
    	
    }

}







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

struct Rectangle {
    int h;
    int w;
    int d;

    Rectangle() : Rectangle(0,0) {}
    Rectangle(int h, int w) 
        : h(h), w(w), d(0) {
            calculate_distance();
        }
    Rectangle(Rectangle const &other) {
        this->h = other.h;
        this->w = other.w;
        this->d = other.d;
    }

    Rectangle &operator=(Rectangle const &rhs) {
        this->h = rhs.h;
        this->w = rhs.w;
        this->d = rhs.d;
        return *this;
    }

    void calculate_distance() {
        this->d = h*h + w*w;
    }
    bool is_larger_than(Rectangle &other) {
        this->calculate_distance();
        other.calculate_distance();
        if (this->d == other.d) {
            return this->h > other.h;
        }
        return this->d > other.d;
    }
};

int main(void)
{
    int h, w;
    while (std::cin >> h >> w, h) {
        Rectangle base(h,w);

        Rectangle curr;
        Rectangle min(h+2, w+2);

        int mh = std::max(base.h, base.w);
        for (curr.h = 1; curr.h <= mh; curr.h++) {
            int mw = sqrt(base.d - curr.h*curr.h) + 1;
            for (curr.w = curr.h+1; curr.w <= mw; curr.w++) {
                if (curr.is_larger_than(base) && min.is_larger_than(curr)) {
                    min = curr;
                    break;
                }
            }
        }

        std::cout << min.h << " " << min.w << std::endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
#define mems(p) memset(p,-1,sizeof(p))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define nl "\n"

const int mxN = 2e5;
const ll MOD = 1e9 + 7;

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

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

ll a[mxN], suma[mxN];

int main() {
	fast();
	int n;
	cin >> n;
	ll ans = 0;
	for (ll i = 1; i <= n; ++i) {
		ll num = n/i;
		ans += (((num * (num+1))/2) * i);
	}
	cout << ans << nl;
}

Measured memory_bytes: 3648
/// Template by Zayed ///

///************************************************************///
/// #include <bits/stdc++.h>
#include <iostream>
#include <cstdio>

#include <string>
#include <cstring>
#include <sstream>

#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
//#include<unordered_map>
#include <set>
//#include<unordered_set>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
///************************************************************///
using namespace std;
int caseno = 1;
///************************************************************///
#define NL '\n'
#define SF scanf
#define PF printf
#define PC() printf("Case %d: ", caseno++)//NOTES:printf
//#define PC cout << "Case "//NOTES:cout
//#define CN cout << caseno++ << ": "//NOTES:cout
#define CLR(ar) memset(ar, 0, sizeof(ar))
#define SET(ar) memset(ar, -1, sizeof(ar))
#define READ() freopen("input.txt", "r", stdin)
#define WRITE() freopen("output.txt", "w", stdout)
#define BOOST std::ios_base::sync_with_stdio(0);
///************************************************************///
typedef long long LL;//NOTES:"%lld"
typedef unsigned long long ULL;//NOTES:"%llu"
///************************************************************///
#define INF (1 << 31) - 1
#define MOD 1000000007
#define PRIME 999998727899999 			// (largest prime below 10^16)
#define PB push_back
#define pii pair<int, int>
#define pic pair<int, char>
#define pci pair<char, int>
#define pLL pair<LL, LL>
#define pis pair<int, string>
#define psi pair<string, int>
#define pss pair<string, string>
#define PI 2 * acos(0.0)
#define EPS 1e-11
///************************************************************///
// Numeric Functions
template < class T > inline void SWAP(T &a, T &b) { T t = a; a = b; b = t; }
inline LL POW(LL base, LL power){
	LL res = base; if (power == 0) return 1;
	for (int I = 0; I < power - 1; I++) res *= base; return res;
}
// Translator Functions
int ToInt(string s) { int r = 0; istringstream sin(s); sin >> r; return r; }//NOTES:ToInt(
double ToDouble(string s) { double r = 0; istringstream sin(s); sin >> r; return r; }//NOTES:ToDouble(
string ToString(int n) { string s; stringstream convert; convert << n; s = convert.str(); return s; }//NOTES:ToString(
///************************************************************///

/*
*******4 Direction Array*******
int dx[] = {0, 0, - 1, 1}, dy[] = {-1, 1, 0, 0};
*******8 Direction Array*******
int dx[] = {0, 0, -1, +1, -1, -1, +1, +1}, dy[] = {-1, +1, 0, 0, -1, +1, -1, +1};
********Knight Moves********
int dx[] = {-2, -2, -1, -1, +1, +1, +2, +2}, dy[] = {-1, +1, -2, +2, -2, +2, -1, +1};
*/

const int SIZE = 50 + 10;



int main()
{
	BOOST
	///READ();
	///WRITE();
	int T, I, J, K, N, n, m, cnt = 0, len, A, B;

	cin >> A >> B;

	if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0)
		cout << "Possible\n";
	else
		cout << "Impossible\n";

	return 0;
}





Measured memory_bytes: 256
h,w=map(int,input().split())
sx,sy=0,0
gx,gy=w-1,h-1

maze=[]
white=0
for _ in range(h):
    temp=input()
    t=[]
    for s in temp:
        t.append(s)
        if s==".":
            white+=1
    maze.append(t)

maze[sy][sx]=1

from collections import deque
fifo = deque()
fifo.append([sy,sx])

result=-1

while len(fifo)>0:
    temp=fifo.popleft()
    y,x=temp[0],temp[1]

    if y==gy and x==gx:
        result=maze[y][x]

    if y>0:
        if maze[y-1][x]==".":
            fifo.append([y-1,x])
            maze[y-1][x]=maze[y][x]+1
    if y<h-1:
        if maze[y+1][x]==".":
            fifo.append([y+1,x])
            maze[y+1][x]=maze[y][x]+1
    if x>0:
        if maze[y][x-1]==".":
            fifo.append([y,x-1])
            maze[y][x-1]=maze[y][x]+1
    if x<w-1:
        if maze[y][x+1]==".":
            fifo.append([y,x+1])
            maze[y][x+1]=maze[y][x]+1



if result==-1:
    print(result)
else:
    print(white-result)




    



Measured memory_bytes: 40176
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		long a = in.nextLong();
		long b = in.nextLong();
		long k = in.nextLong();

		if (a > k)
			System.out.println((a-k) + " " + b);
		else if (a <= k && k < (a+b))
			System.out.println(0 + " " + (a + b - k));
		else
			System.out.println("0 0");
	}
}



Measured memory_bytes: 23892
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 1000 * 100 + 47;
LL A[MAX];
LL C[MAX];
int U[MAX];

void no()
{
	cout << "NO" << endl;
	exit(0);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	FOR(i, 0, n) cin >> A[i];

	LL s = 0;
	FOR(i, 0, n)
	{
		s += A[i];
	}

	LL all = n *(LL) (n + 1) / 2;
	if (s % all != 0) no();

	LL cnt = s / all;
	FOR(i, 0, n)
	{
		int nex = i + 1;
		if (nex == n) nex = 0;
		if ((A[i] - A[nex] + cnt) % n != 0) no();
		C[nex] = (A[i] - A[nex] + cnt) / n;
	}

	LL dod = 0;
	LL c = 0;
	FOR(k, 0, 2 * n)
	{
		int i = k % n;
		int nex = i + 1;
		if (nex == n) nex = 0;

		if (U[i])
		{
			c -= C[i];
			dod -= (n + 1) * C[i];
			C[i] = 0;
		}
		else
		{
			U[i] = 1;
			c += C[i];
			dod += C[i];
		}

		if (A[i] - dod < 0) no();
		A[i] -= dod;
		dod += c;
	}

	FOR(i, 0, n)
	{
		if (A[i] != 0) no();
	}

	cout << "YES" << endl;
}


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

int main(){
    int a, b, c;
    cin>>a>>b>>c;
    int ans;
    if(a==b){
        cout<<c<<endl;
    }
    else if(a==c){
        cout<<b<<endl;
    }
    else{
        cout<<a<<endl;
    }
    return 0;
}


Measured memory_bytes: 256