akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

void solve(int N, int L, VV &a) {
    int cnt = N;
    int lastAnt = -1;
    int t = 0;
    while (true) {
        t++;
        VV b(L, V(2, 0));

        // move
        rrep(x, L) {
            rep(k, 2) {
                if (a[x][k] == 0) continue;
                int nx = x + (k == 0 ? +1 : -1);
                if (nx < 0 || nx >= L) {
                    cnt--;
                    lastAnt = a[x][k];
                }
                else {
                    b[nx][k] = a[x][k];
                }
            }
        }

        if (cnt == 0) {
            cout << t << " " << lastAnt << endl;
            return;
        }

        // collision
        rep(x, L) {
            if (b[x][0] > 0 && b[x][1] > 0) {
                swap(b[x][0], b[x][1]);
            }
        }

        a = b;
    }
}

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

    int N, L;
    while (cin >> N >> L, N) {
        L--;
        VV a(L, V(2, 0));
        rep(i, N) {
            char c;
            int x;
            cin >> c >> x;
            x--;
            a[x][c == 'L'] = i + 1;
        }

        solve(N, L, a);
    }

}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    string s;
    cin >> s;
    ll count = 0;

    rep(i, 0, s.size()){
        if(s[i] == 'g'){
            count++;
        }else{
            count--;
        }
    }

    cout << count / 2 << endl;
    return 0;
}


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

// ショートハンド
// #define ll intに変えればメモリ節約
#define ll long long
#define ld long double

const int MOD = 1e9 + 7;
#define INF 2e9

/* 
 * ループ系のマクロ
 * `REP(i, 10) { cout << i; }`のように、変数名,回数で動く
 */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/*
 * 正規表現
 */
#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20)

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
// `chmax(a, b)` aがbより小さければ、aをbに上書きする。chminは逆
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


ll x,y,n,k;
vector<ll> a;
string s;
int main() {
    INIT();
    cin >> n;
    cout << (n ? 0 : 1);
}

Measured memory_bytes: 3608
/* 
 * Project: AtCoder Beginners Contest 162 A - Lucky 7
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/04/12
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#pragma GCC optimize("Ofast")
#include <cstdio>
using namespace std;

int main() {

    char n[3];
    scanf("%s",n);

    if (!(n[0] ^ '7'))
        puts("Yes");
    else if (!(n[1] ^ '7'))
        puts("Yes");
    else if (!(n[2] ^ '7'))
        puts("Yes");
    else
        puts("No");
 
}

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

int main(void)
{
	ll n,s=0;
	cin>>n;
	ll c[n],v[n];
	for(ll i=0;i<n;i++)
	{
		cin>>c[i];
	}
	for(ll i=0;i<n;i++)
	{
		cin>>v[i];
	}
	for(ll i=0;i<n;i++)
	{
		if(c[i]-v[i]>0)
		{
			s+=(c[i]-v[i]);
		}
	}
	cout<<s<<endl;
}

Measured memory_bytes: 3604
H, W = gets.split.map(&:to_i)
B = '#'*(W+3) + $<.read.gsub(/\r?\n/, '##') + '#'*(W+1)
D = [nil]*B.size
# (0..H+1) × (0..W+1)
# k = i*(W+2)+j

d, Q, WASD = 1, [W+3], [-W-2, -1, W+2, 1]
D[W+3] = d
until Q.empty?
	d += 1
	Q.size.times{
		k = Q.shift
		WASD.each{|l| l += k
			next if D[l] or B[l] == ?#
			D[l] = d
			Q << l
		}
	}
end
p((B.count('.')-D[H*(W+2)+W] rescue -1))


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

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

using namespace std;

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

	int L[10]={},R[10]={};
	rep(i,n-1) R[s[i+1]-'0']++;

	bool ans[1000]={};
	rep(i,n-2){
		L[s[i]-'0']++;
		R[s[i+1]-'0']--;

		int c=s[i+1]-'0';
		rep(d,10) if(L[d]>0) rep(e,10) if(R[e]>0) ans[d*100+c*10+e]=true;
	}

	printf("%ld\n",count(ans,ans+1000,true));

	return 0;
}


Measured memory_bytes: 256
s = gets.chomp.chars
q = gets.chomp.to_i
is_reverse = false
 
q.times do
  val = gets.chomp.split
  t, f, c = val
  t = t.to_i
  if t == 1
    # 先頭に付けるかお尻につけるか
    is_reverse = !is_reverse
  elsif t == 2
    f = f.to_i
    if f == 1 && is_reverse == false || f == 2 && is_reverse == true
      s.unshift c
    elsif f == 2 && is_reverse == false || f == 1 && is_reverse == true
      s.push c
    end
  end
end
 
s.reverse! if is_reverse
 
puts s.join

Measured memory_bytes: 28028
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll n,m,k;
  cin>>n>>m>>k;
  vector<ll> va,vb;
  rep(i,0,n){
    ll a;
    cin>>a;
    va.pb(a);
  }
  rep(i,0,m){
    ll a;
    cin>>a;
    vb.pb(a);
  }
  rep(i,0,vb.sz-1){
    vb[i+1]+=vb[i];
  }
  ll a = 0;
  ll mx = 0;
  rep(i,0,va.sz+1){
    if(a<=k){
      mx = max(mx,i);
    }
    long long low = 0;
    long long high = vb.sz-1;
    
    while(low < high){
      long long mid = (high + low + 1) >> 1;
    
      if(a+vb[mid] <=k){
        low = mid;
      }
      else{
        high = mid - 1;
      }
    }
    if(a+vb[low]<=k){
      mx = max(mx,i+low+1);
    }
    if(i==va.sz)break;
    a += va[i];
  }
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 7984
#include <stdio.h>

int main(void){

  int n;
  scanf("%d", &n);

  int flag = 0;

  for (int i = 1; i < 10; i++) {
    if (n % i == 0) {
      if (n/i > 0 && n/i < 10) {
        flag = 1;
        break;
      }
    }
  }

  if (flag == 1) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
   int n,ans=0;
   cin >> n;
   for(int i=1;i<=n;i+=2){
       int cnt = 0;
       for(int j=1;j<=i;j++){
           if(i%j==0) cnt++;
       }
       if(cnt==8) ans++;
   }
   cout << ans << endl;
}


Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,a[202020],b[202020];
bool check(int x)
{
	for(int i=1;i<=n;i++) b[i]=a[i];
	for(int i=n-x+1;i<=n;i++) b[i]-=m;
	sort(b+1,b+n+1);
	for(int i=1;i<=n/2;i++)
	if(b[i]+b[n-i+1]<0) return 0;
	return 1;
}
int main()
{
	scanf("%d%d",&n,&m);
	n<<=1;
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int l=0,r=n/2,mid;
	while(l<r)
	{
		mid=(l+r+1)/2;
		if(check(mid)) l=mid;
		else r=mid-1;
	}
	for(int i=n-l+1;i<=n;i++)
	a[i]-=m;
	sort(a+1,a+n+1);
	int ans=0;
	for(int i=1;i<=n/2;i++)
	ans=max(ans,a[i]+a[n-i+1]);
	printf("%d\n",ans);
	return 0;
}
	

Measured memory_bytes: 1920
#include <iostream>
#include <string>
using namespace std;
int main() {
    int count[26] = {0};
    char c;
    while (cin >> c) {
        if (isalpha(c)) {
            if (isupper(c)) c = tolower(c);
            count[c - 'a'] ++;
        }
    }
    for (int i=0; i<26; ++i) {
        cout << (char)('a'+i) << " : " << count[i] << endl;
    }
}

Measured memory_bytes: 1140
#include <iostream>
#include<map>
#include<set>
#include<vector>
using namespace std;
long a[100004],p[100003],z[100004],b[100004];
int main()
{
    ios::sync_with_stdio(false);
        	cin.tie(0);
        	cout.tie(0);
        	long n;
        	cin>>n;
        	for(long i=1;i<=n;i++){cin>>p[i];z[p[i]]=i;}
        	a[1]=1;b[1]=1000000000;
        	for(long i=2;i<=n;i++)
            {
                if(z[i]>z[i-1])
                {
                    long long h=z[i]-z[i-1];
                    long long f=2*h;long long d=h;
                    a[i]=a[i-1]+f;b[i]=b[i-1]-d;
                }
                else
                {
                    long long h=z[i-1]-z[i];
                    long long f=h;long long d=2*h;
                    a[i]=a[i-1]+f;b[i]=b[i-1]-d;

                }
            }
            for(long i=1;i<=n;i++)
            {
                cout<<a[i]<<" ";
            }
            cout<<endl;
            for(long i=1;i<=n;i++)
            {
                cout<<b[i]<<" ";
            }
            cout<<endl;





}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define mod (int)1000000007
#define MOD (int)10000000007
#define X 1001100011100001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for0e(i, n) for (int i = 0; i <= n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define F first
#define S second
#define pi pair<int, int>
#define ppi pair<pair<int,int> , int >
#define vii vector<pi>
const int MAXN = (int)((1e5) + 100);
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;} 
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int N =  (int)(1e6+5); 
// ========================================================
signed main(){
  #ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  #endif
  fio;
    int n;
    char s[N];
    cin>>n;
    int cnt = 0;
    for(int i=1;i<=n;i++){
        cin>>s[i];
        if(s[i] == 'W'){
            cnt++;
        }
    }
    int ans = cnt;
    for(int i=n;i>n-cnt;i--){
        if(s[i] == 'W'){
            ans--;
        }
    }
    cout<<ans<<endl;
  rr;
}



Measured memory_bytes: 3876
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

#print(S)
for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            mass = 0
            for s in range(-1, 2):
                for t in range(-1, 2):
                    if H > i+s >= 0 and W > j+t >= 0:
                        #print(i,j)
                        #print(i+s,j+t)
                        if S[i+s][j+t] == "#":

                            mass += 1
            S[i][j] = str(mass)
for i in range(H):
    l = "".join(S[i])
    print(l)

Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  long N, K;
  cin >> N >> K;
  K--;
  string S;
  cin >> S;
  if (S[K] == 'A') S[K] = 'a';
  if (S[K] == 'B') S[K] = 'b';
  if (S[K] == 'C') S[K] = 'c';
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer ST = new StringTokenizer(BR.readLine());
		int N = Integer.parseInt(ST.nextToken()), M = Integer.parseInt(ST.nextToken()), observationHeight[] = new int[N]; boolean goodObservations[] = new boolean[N];
		Arrays.fill(goodObservations, true);
		ST = new StringTokenizer(BR.readLine());
		for (int i = 0; i < N; i++) observationHeight[i] = Integer.parseInt(ST.nextToken());
		for (; M > 0; M--) 
		{
			ST = new StringTokenizer(BR.readLine());
			int Start = Integer.parseInt(ST.nextToken()) - 1, End = Integer.parseInt(ST.nextToken()) - 1;
			if (observationHeight[Start] < observationHeight[End]) goodObservations[Start] = false;
			else if (observationHeight[Start] > observationHeight[End]) goodObservations[End] = false;
			else /*if (observationHeight[Start] == observationHeight[End])*/ { goodObservations[Start] = false; goodObservations[End] = false;}
		}
		int goodCount = 0;
		for (int i = 0; i < N; i++)
		{
			if (goodObservations[i]) goodCount++;
		}
		System.out.println(goodCount);
	}
}


Measured memory_bytes: 46220
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

struct box {
	bool infected;
	int balls;
};

int main()
{
	int n, m;
	cin >> n >> m;
	struct box *boxList = new struct box[n];
	boxList[0].balls = 1;
	boxList[0].infected = true;
	for (int i = 1; i < n; i++) {
		boxList[i].balls = 1;
		boxList[i].infected = false;
	}
	for (int i = 0; i < m; i++) {
		int inputIndex, outputIndex;
		cin >> inputIndex >> outputIndex;
		inputIndex--;
		outputIndex--;
		boxList[inputIndex].balls--;
		boxList[outputIndex].balls++;
		if (boxList[inputIndex].infected == true) boxList[outputIndex].infected = true;
		if (boxList[inputIndex].balls == 0) boxList[inputIndex].infected = false;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (boxList[i].infected == true && boxList[i].balls != 0) ans++;
	}
	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);

      int n = Integer.parseInt(sc.next());

      String ans = "No";
      for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
          if(i*j==n){
            ans = "Yes";
          }
        }
      }



      System.out.println(ans);

    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll a, b,c,k;
    cin >>a >> b >> c >>k;
    ll ans = 0;
    if(k >= a){
    	k -= a;
    	ans += a;
    }else{
    	ans += k;
    	k = 0;
    }
    if(k >= b){
    	k -= b;
    }else{
    	k = 0;
    }
    ans -= k;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int n, K;
ll x[50], y[50], ans = INT64_MAX;

int main() {
	cin >> n >> K;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			ll maxx, minx, maxy, miny;
			maxx = max(x[i], x[j]);
			minx = min(x[i], x[j]);
			maxy = max(y[i], y[j]);
			miny = min(y[i], y[j]);
			//cout << "maxx:" << maxx << " minx:" << minx << " maxy:" << maxy << " miny:" << miny << endl;

			int count = 0;
			for (int k = 0; k < n; k++) {
				if (maxx >= x[k] && x[k] >= minx && maxy >= y[k] && y[k] >= miny)count++;
			}
			if (count >= K) {
				ans = min(ans, abs(maxx - minx)*abs(maxy - miny));
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				ll maxx, minx, maxy, miny;
				maxx = max(max(x[i], x[j]),x[k]);
				minx = min(min(x[i], x[j]),x[k]);
				maxy = max(max(y[i], y[j]),y[k]);
				miny = min(min(y[i], y[j]),y[k]);
				//cout << "maxx:" << maxx << " minx:" << minx << " maxy:" << maxy << " miny:" << miny << endl;

				int count = 0;
				for (int l = 0; l < n; l++) {
					if (maxx >= x[l] && x[l] >= minx && maxy >= y[l] && y[l] >= miny)count++;
				}
				if (count >= K) {
					ans = min(ans, abs(maxx - minx)*abs(maxy - miny));
				}
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				for (int l = k + 1; l < n; l++) {
					ll maxx, minx, maxy, miny;
					maxx = max(max(x[i], x[j]), max(x[k], x[l]));
					minx = min(min(x[i], x[j]), min(x[k], x[l]));
					maxy = max(max(y[i], y[j]), max(y[k], y[l]));
					miny = min(min(y[i], y[j]), min(y[k], y[l]));
					//cout << "maxx:" << maxx << " minx:" << minx << " maxy:" << maxy << " miny:" << miny << endl;

					int count = 0;
					for (int m = 0; m < n; m++) {
						if (maxx >= x[m] && x[m] >= minx && maxy >= y[m] && y[m] >= miny)count++;
					}
					if (count >= K) {
						ans = min(ans, abs(maxx - minx)*abs(maxy - miny));
					}
				}
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 888
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    mem = defaultdict(lambda : None)
    def gcd(a,b):
        if mem[(a,b)] != None:
            return mem[(a,b)]
        if a == 0:
            mem[(a,b)] = mem[(b,a)] = b
            return b
        mem[(a,b)] = mem[(b,a)] = gcd(b%a,a)
        return mem[(a,b)]
    k = I()
    ans = 0
    for a in range(1,k+1):
        for b in range(1,k+1):
            g = gcd(a,b)
            for c in range(1,k+1):
                ans += gcd(g,c)
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 78048
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
class FordFulkerson{
	struct Edge{
		int64_t to, cap, rev_index;
	};
	private:
	vector<vector<Edge>> v;
	int64_t n;
	bool *used;
	const int64_t INF = numeric_limits<int64_t>::max();

	int dfs(int64_t now, int64_t goal, int64_t f){
		if(now == goal) return f;
		used[now] = 1;
		for(Edge &e : v[now]){
			if(used[e.to]){
				continue;
			}
			if(e.cap <= 0){
				continue;
			}
			int64_t d = dfs(e.to, goal, min(f, e.cap));
			if(d > 0){
				e.cap -= d;
				v[e.to][e.rev_index].cap += d;
				return d;
			}
		}
		return 0;
	}
	public:
	FordFulkerson(int64_t n, vector<Edge> *v){
		this->n = n;
		for(int64_t i = 0; i < n; i++){
			this->v.push_back(v[i]);
		}
		used = new bool[n];
	}

	FordFulkerson(int64_t n, vector<pair<int64_t, int64_t>> *v){
		this->n = n;
		for(int i = 0; i < n; i++){
			this->v.push_back(vector<Edge>(0));
		}
		for(int i = 0; i < n; i++){
			for(auto e : v[i]){
				this->v[i].push_back((Edge){e.first, e.second, (int64_t)this->v[e.first].size()});
				this->v[e.first].push_back((Edge){i, 0, (int64_t)this->v[i].size() - 1});
			}
		}
		used = new bool[n];
	}

	int64_t max_flow(int64_t start, int64_t goal){
		int64_t ret = 0;
		while(1){
			memset(used, 0, n);
			int64_t add = dfs(start, goal, INF);
			if(add == 0){
				return ret;
			}
			ret += add;
		}
	}
};
int main(){
	ll n;
	cin >> n;
	ll po[n][2], yo[n][2];
	for(ll i = 0; i < n; i++) cin >> po[i][0] >> po[i][1];
	for(ll i = 0; i < n; i++) cin >> yo[i][0] >> yo[i][1];
	vector<pair<ll, ll>> v[2 * n + 2];
	for(ll i = 0; i < n; i++){
		for(ll j = 0; j < n; j++){
			if(po[i][0] < yo[j][0] && po[i][1] < yo[j][1]) v[i + 1].push_back(pair<ll, ll>(n + j + 1, 1));
		}
	}
	for(ll i = 0; i < n; i++) v[0].push_back(pair<ll, ll>(i + 1, 1));
	for(ll i = 0; i < n; i++) v[n + i + 1].push_back(pair<ll, ll>(2 * n + 1, 1));
	auto F = FordFulkerson(2 * n + 2, v);
	cout << F.max_flow(0, 2 * n + 1) << endl;
	return 0;
}

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

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))

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



Measured memory_bytes: 256
N = int(input())
h = list(map(int,input().split()))
DP = [0]*N
for i in range(1,N):
    if i == 1:
        DP[i] = abs(h[i] - h[i-1])
    else:
        DP[i] = min((abs(h[i] - h[i-1]))+DP[i-1], (abs(h[i] - h[i-2]))+DP[i-2])
print(DP[-1])

Measured memory_bytes: 52208
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        mut ab: [(i64, i64); n],
    }
    ab.sort();
    let m1;
    if n % 2 == 1 {
        m1 = ab[n / 2].0 * 2;
    } else {
        m1 = ab[n / 2].0 + ab[n / 2 - 1].0;
    }

    ab.sort_by_key(|x| x.1);

    let m2;
    if n % 2 == 1 {
        m2 = ab[n / 2].1 * 2;
    } else {
        m2 = ab[n / 2].1 + ab[n / 2 - 1].1;
    }

    // println!("{} {}", m1, m2);

    if n % 2 == 1 {
        println!("{}", (m2 - m1 + 1) / 2 + 1);
    } else {
        println!("{}", m2 - m1 + 1);
    }
}


Measured memory_bytes: 10316
// inputに入力データ全体が入る
// @ts-ignore
const main = (input: string) => {
  const inputs = input.split('\n');
  const [N, M] = inputs[0].split(' ').map(v=>Number(v));

  const votes = inputs[1].split(' ').map(v=>Number(v));

  const minimumVoteCount = votes.reduce((total, current) => total + current, 0) / (4 * M);

  votes.sort((a,b)=> a < b ? 1 : -1);

  // console.log(votes);

  let ans = 'Yes';
  for(let i = 0;i < M; i += 1) {
    if (votes[i] < minimumVoteCount) ans = 'No';
  }

  console.log(ans);
}

// *この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
let () = Scanf.scanf "%d\n%s" @@ fun n s ->
  let r, g, b =
    List.fold_left (fun (r, g, b) -> function
      | 'R' -> r + 1, g, b
      | 'G' -> r, g + 1, b
      | 'B' -> r, g, b + 1) (0, 0, 0) @@
    List.init (String.length s) @@ String.get s in
  let ignore =
    List.fold_left (List.fold_left ( + )) 0 @@
    List.init (String.length s / 2) @@ fun w ->
      List.init (String.length s - 2 * (w + 1)) @@ fun i ->
        if s.[i] = s.[i + w + 1] || s.[i + w + 1] = s.[i + 2 * (w + 1)] || s.[i] = s.[i + 2 * (w + 1)]
        then 0
        else 1 in
  Printf.printf "%d\n" @@ r * g * b - ignore

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

signed main(){

  int a,b; cin >> a >> b;
  if(a >= 13) cout << b << endl;
  else if(6 <= a && a <= 12) cout << b/2 << endl;
  else cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(int i = (int)(b); i < (int)(e); ++i)
#define RFOR(i, b, e) for(int i = (int)(e-1); i >= 0; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<int,int>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;

using namespace std;

ll conb(ll n, ll r) {
	if (n - r < r) { return conb(n, n - r); }
	ll tmp = 1;
	FOR(i, n - r + 1, n + 1) {
		tmp *= i;
	}
	FOR(i, 1, r + 1) {
		tmp /= i;
	}
	return tmp;
}

ll mod(ll n, ll r) {
	ll q = n % r;
	return (q < 0) ? q + r : q;
}

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int l = a + b;
	int r = c + d;
	cout << ((l > r) ? "Left" : (l == r) ? "Balanced" : "Right") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <string.h>  
#include <stdlib.h>  
#include <iostream>  
#include <algorithm>  
#include <time.h>  
#include<cstdio>
#include<vector>
#include<functional>


using namespace std;

int main() {
	int a[200] = {0};
	char b[28];
	scanf("%s", b);
	int i = 0;
	while (i <strlen(b)) {
		a[b[i] - 'A']++;
		if (a[b[i] - 'A'] > 1) {
			printf("no");
			return 0;
		}
		i++;
	}
	
	printf("yes");
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi pair<ll,ll>
#define pii pair<pi,ll>
#define fr freopen("in.txt","r",stdin)
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define frep(i,n) for(int i=1;i<=n;i++)
#define ll long long
#define f first
#define s second

int main() {
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    string ans="";
    rep(i,n-m+1) {
        string cur = s;
        bool flag = 1;
        rep(j,m) {
            if(cur[i+j]=='?') cur[i+j]=t[j];
            else if(cur[i+j]!=t[j]) {
                flag = 0;
                break;
            }
        }
        if(flag) {
            rep(j,n) {
                if(cur[j]=='?') cur[j]='a';
            }
            if(ans=="") ans =cur;
            else if(ans > cur) {
                ans = cur;
            }
        }
    }
    if(ans=="") ans = "UNRESTORABLE";
    cout << ans;
}

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

using namespace std;


int solution_DP_bottom_up(const vector<int>& s)
{
	vector<int> DP(s.size(), 0);
	int s2;
	int s1;
	for (int i = 1; i < (int) s.size(); i++) {
		if (i-2 >= 0)
			s2 = DP[i-2] + abs(s[i-2] - s[i]);
		else
			s2 = numeric_limits<int>::max();
		if (i-1 >= 0)
			s1 = DP[i-1] + abs(s[i-1] - s[i]);
		else
			s1 = numeric_limits<int>::max();
		if (s1 < s2) {
			DP[i] = s1;
		} else {
			DP[i] = s2;
		}
	}
	return DP[s.size()-1];
}



int main()
{
	int N;
	cin >> N;
	vector<int> s(N);
	for(int i = 0; i < N; i++) {
		cin >> s[i];
	}
	cout << solution_DP_bottom_up(s) << endl;
}


Measured memory_bytes: 1024
import math


def isPrime(n):
    if n <= 2:
        return n == 2
    if (n % 2 == 0):
        return False
    for i in range(3, int(math.sqrt(n)) + 1, 2):
        if n % i == 0:
            return False
    return True


N = int(input())
print(len(list(filter(isPrime, [int(input()) for i in range(N)]))))



Measured memory_bytes: 6072
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Arrays;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();   //4
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;  //2-1=0
			int degree = in.nextInt();//1
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1; //4-1=3
				tmp.add(idx2);// adds 3
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];

		adjMatrix[0][0] = (adjList.get(0).get(0));
	
		
		//Assign the matrix 0's
		for (int i=0; i<totalVertex;i++) {
			for (int j =0; j < totalVertex; j++) {
				adjMatrix[i][j] = 0;
			}
		}
		// uses index to change 0 to 1
		for (int i=0; i <totalVertex;i++) {
			for (int j=0; j< adjList.get(i).size(); j++) {
				adjMatrix[i][adjList.get(i).get(j)] = 1;
			}
		}
	for(int i =0; i < totalVertex;i++) {
			for (int j =0; j < totalVertex; j++) {
				System.out.print(adjMatrix[i][j]);
				if(j == totalVertex-1) {
					
				}
				else {
					System.out.print(" ");
				}
			}
			System.out.println();
		}
		//complete the following
	}
}
//change class name GraphRepresentation to Main() for submission to AIZU
public class Main{
	
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}


Measured memory_bytes: 34336
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

int main() {
	int m, d,n;
	while (1) {
		cin >> m >> d;
		if (m == 0)
			break;
		n = d-1;
		switch (m) {
		case 12:
			n += 30;
		case 11:
			n += 31;
		case 10 :
			n += 30;
		case 9:
			n += 31;
		case 8:
			n += 31;
		case 7:
			n += 30;
		case 6:
			n += 31;
		case 5 :
			n += 30;
		case 4:
			n += 31;
		case 3:
			n += 29;
		case 2:
			n += 31;
		}
		switch (n % 7) {
		case 0:
			cout << "Thursday\n";
			break;
		case 1:
			cout << "Friday\n";
			break;
		case 2:
			cout << "Saturday\n";
			break;
		case 3:
			cout << "Sunday\n";
			break;
		case 4:
			cout << "Monday\n";
			break;
		case 5:
			cout << "Tuesday\n";
			break;
		case 6:
			cout << "Wednesday\n";
			break;
		}
	}
}


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

int main() {
  int N;
  cin>>N;
  int T=0,X=0,Y=0;
  bool f=true;
  while (N--) {
    int t,x,y;
    cin>>t>>x>>y;
    int dt=abs(t-T);
    int dis=abs(x-X)+abs(y-Y);
    if (dis>dt || abs(dis-dt)%2!=0) {
      f=false;
    }
    T=t,X=x,Y=y;
  }
  cout<<(f?"Yes":"No")<<endl;
  return 0;
}


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

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr ll inf = 1ll<<62;

int main(){
    string str;
    cin>>str;
    vector<ll> from(2),to(2);
    from[0] = 1ll;
    for(int i=0;i<(int)str.size();++i){
        fill(to.begin(),to.end(),0);
        if(str[i] == '1'){
            to[0] = (2*from[0])%mo;
            to[1] = (from[0] + (3*from[1])%mo)%mo;
        }else{
            to[0] = from[0];
            to[1] = (3*from[1])%mo;
        }
        swap(to,from);
    }
    cout << (from[1] + from[0])%mo<< endl;
    return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, K;
	cin >> N >> K;

	vector<Int> a(N);
	for (Int i = 0; i < N; i++) {
		cin >> a[i];
	}

	vector<pair<mint, mint>> count(N, pair<mint, mint>());

	mint before;
	mint after;
	for (Int i = 0; i < N; i++) {
		before = 0;
		after = 0;
		for (Int j = 0; j < N; j++) {
			if (i == j) continue;
			if ((j < i) && (a[i] > a[j]))before+=1;
			if ((j > i) && (a[i] > a[j]))after+=1;
		}
		count[i].first = before;
		count[i].second = after;
	}

	mint ans = 0;
	for (Int i = 0; i < N; i++) {
		ans += count[i].second * K + (count[i].second + count[i].first) * K * (K - 1) / 2;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as MP
import qualified Data.Set as ST
import qualified Data.Sequence as SQ
import Data.Array
import Data.Array.Unboxed
import Data.Array.ST
import Data.Array.IO
import Data.Maybe
import Data.Ratio
import Data.Char
import Data.Bits
import Data.List
import Data.Tuple
import Data.Functor
import Data.IORef
import Data.STRef
import Control.Applicative
import Control.Monad
import Control.Monad.ST

main = do
  [a,b] <- map read . words <$> getLine :: IO [Int]
  putStrLn $ min (replicate a $ intToDigit b) (replicate b $ intToDigit a)


Measured memory_bytes: 508
s = input()

a = ''
for i in range(len(s)):
    if s[i]!='x':
        a+=s[i]

b = ''
for i in range(len(a)):
    b+=a[-1-i]

if a!=b:
    print(-1)
else:
    ss = ''
    for i in range(len(s)):
        ss += s[-1-i]
    i = 0
    j=0
    ans = 0
    while True:
        if i>=len(s):
            ans += len(ss)-j
            break
        elif j>=len(ss):
            ans += len(s)-i
            break
        if s[i]!=ss[j]:
            if s[i]=='x':
                i+=1
            else:
                j+=1
            ans += 1
        else:
            i+=1
            j+=1
    print(ans//2)



Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

int32_t main(){_
   
   int h1, m1;  
   int h2, m2, k;

   cin >> h1 >> m1 >> h2 >> m2 >> k;

   int A = h1 * 60 + m1;  
   int B = h2 * 60 + m2 - k;  
      
   int ans = max(0LL, B - A);

   cout<<ans;

   return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
        using namespace std;
        #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
        #define M_PI 3.14159265358979323846
        #define data data_
        #define ff first
        #define ss second
        #define pb push_back
        #define ld long double
        #define int long long
        #define print(t) cout << "Case #" << t << ": ";
        int32_t main()
        {
            tani_nachi_ke  
            
            int n;
            cin >> n;

            int limit = 2*1e6;
            int m = 7;
            int d = 1;
            while(limit != 0 && (m%n)!=0)
            {
                m = (m*10 + 7)%n;
                limit--;
                d++;
                // cout << m << endl;

            }
            if(m%n==0)
                cout << d << '\n';
            else 
                cout << -1 << '\n'; 





           return 0;
        }
          

Measured memory_bytes: 3648
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n,i,sum=0,sub;
    cin>>m>>n;
    int ara[n];
    for(i=0;i<n;i++)
    {
        cin>>ara[i];
        sum=sum+ara[i];
        sub=m-sum;

    }
  if(sub<=0)
  {
      cout<<"Yes"<<endl;
  }
  else{

    cout<<"No"<<endl;
  }


 return 0;
}


Measured memory_bytes: 4020
package main

import (
        "fmt"
        "sort"
)

func main() {
        l := make([]int, 4)
        for i := range l {
                fmt.Scan(&l[i])
        }
        a := l[0]
        b := l[1]
        c := l[2]
        d := l[3]
        sort.Ints(l)

        if l[1] >= a && l[1] >= c && l[2] <= b && l[2] <= d {
                fmt.Println(l[2] - l[1])
        } else {
                fmt.Println(0)
        }
}


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

#define ll long long
#define ld long double
#define fi first
#define se second
#define pi 3.1415926535
#define mod1 1000000007
#define mod2 1000000009
#define mp make_pair
#define no_of_digits(n) floor(log10(n)) + 1
#define lcm(a, b) (a/__gcd(a,b)*b)

using namespace std;

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

  int n;
  cin >> n;
  int k = 2*n;
  int a[2*n];
  for(int i = 0; i < k; i++){
    cin >> a[i];
  }

  sort(a, a+k);
  ll sm = 0;
  for(int i = 0; i < k; i += 2){
    sm += a[i];
  }

  cout << sm;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e15
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
typedef long long ll;
typedef pair<int, int> P;
#define END system("PAUSE");return 0
int n, x;
int a[222];
signed main() {
	cin >> n >> x;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	int ans = 0;
	rep(i, n) {
		if (x < a[i])break;
		ans++;
		x -= a[i];
	}
	if (ans == n && x)ans--;
	cout << ans << endl;
	END;
}


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

#ifdef DEBUG
#define debug(...) __VA_ARGS__
#else
#define endl '\n'
#define debug(...)
#endif
#define debugf(...) debug(printf(__VA_ARGS__))

const int N = 1e6 + 5;

int a[N];
int f[N], F[N];

int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        f[a[i]]++;
    }

    for (int x = 1; x < N; x++) {
        for (int y = x; y < N; y += x) {
            F[y] += f[x];
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x = a[i];
        if (F[x] == 1)
            ans++;
    }

    cout << ans << endl;

    return 0;
%>

Measured memory_bytes: 12060
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    cout << lcm(a,b) << '\n';
	return 0;
}


Measured memory_bytes: 256
import sys, re
import math
from decimal import Decimal
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul	# 
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd	# 最大公約数
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.maxsize = 10 ** 15
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

# -*- coding: utf-8 -*-
n = INT()
alphabet = "abcdefghijklmnopqrstuvwxyz"
ans = ""

def A(value):
    global alphabet, ans
    if value <= 26:
        ans += alphabet[value - 1]
        print(ans[::-1])
    else:
        a = value % 26
        ans += alphabet[a - 1]
        if a == 0:
            A( math.floor(Decimal(value - 2) / Decimal(26)) )
        else:
            A( math.floor(Decimal(value) / Decimal(26)) )
A(n)

Measured memory_bytes: 10792
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>
#include<unordered_set>

using namespace std;

/*

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

tree<pair<long long, long long>, null_type, less<pair<long long, long long>>, rb_tree_tag, tree_order_statistics_node_update> st;

*/
/*

st.find_by_order();
st.order_of_key();

*/

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define ld long double
#define int long long

mt19937 rnd(51);

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n), b(m), pr(n), pr1(m);
    for (int i = 0; i < n; i++){
        cin >> a[i];
        pr[i] = a[i];
        if (i != 0) pr[i] += pr[i - 1];
    }
    for (int i = 0; i < m; i++){
        cin >> b[i];
        pr1[i] = b[i];
        if (i != 0) pr1[i] += pr1[i - 1];
    }
    int l = 0, r = n + m + 1;
    while(r - l > 1){
        int mid = (r + l) / 2, mn = 1e18;
        for (int i = 0; i < min(n, mid); i++){
            if (mid - i - 2 < m && mid - i - 2 >= 0){
                int sum = pr[i] + pr1[mid - i - 2];
                mn = min(mn, sum);
            }
        }
        if (mid <= n){
            mn = min(mn, pr[mid - 1]);
        }
        if (mid <= m){
            mn = min(mn, pr1[mid - 1]);
        }
        if (mn <= k){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e4+5;
int a[N],b[N];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        cin>>b[i];
    long long s=0;
    for(int i=0;i<n;i++)
        s+=a[i];
    for(int i=0;i<n;i++)
        s-=b[i];
    if(s>0)
        printf("No");
    else
    {
        long long ta=-s,tb=-s;
        for(int i=0;i<n;i++)
        {
            if(a[i]>b[i])
                tb-=a[i]-b[i];
            else if(a[i]<b[i])
            {
                if((b[i]-a[i])&1)
                    ta-=(b[i]-a[i])/2+1,tb--;
                else ta-=(b[i]-a[i])/2;
            }
        }
        if(2*ta==tb&&ta>=0&&tb>=0)
            printf("Yes");
        else printf("No");
    }
    return 0;
}



Measured memory_bytes: 384
import java.util.*;

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

        int h = sc.nextInt();
        int w = sc.nextInt();
        int k = sc.nextInt();
        int[][] g = new int[h][w];
        for(int i=0; i<h; i++) {
            char[] c = sc.next().toCharArray();
            for(int j=0; j<w; j++) {
                g[i][j] = c[j]-'0';
            }
        }


        int[] res = new int[1];
        res[0] = 1000000;
        int[] a = new int[h];
        dfs(a, g, h, w, k, res, 1, 0);

        System.out.println(res[0]);
    }


    static void dfs(int[] a, int[][]g,  int h, int w, int k, int[] res, int d, int last) {
        if(d == h) {
            int[] sum = new int[last+1];
            boolean reset = true;
            int cut = 0;
            for(int i=0; i<w; i++) {
                for(int j=0; j<h; j++) {
                    if(g[j][i] == 1) sum[a[j]] += 1;
                }
                for(int l=0; l<=last; l++) {
                    if(sum[l] > k) {
                        if(reset) return;
                        Arrays.fill(sum, 0);
                        for(int j=0; j<h; j++) {
                            if(g[j][i] == 1) sum[a[j]] += 1;
                        }
                        cut++;
                    }
                }
                reset = false;
            }
            res[0] = Math.min(res[0], cut + last);
            return;
        }
        a[d] = last;
        dfs(a, g, h, w, k, res, d+1, last);
        a[d] = last + 1;
        dfs(a, g, h, w, k, res, d+1, last+1);
    }
}

Measured memory_bytes: 25316
N, M=map(int,input().split())
As=list(map(int,input().split()))

sumu=0
for i in range(N):
    sumu+=As[i]

sles=sumu*0.25/M
count=0
flag="No"
for i in range(N):
    if As[i]>=sles:
        count+=1
    if count==M:
        flag="Yes"
        break



print(flag)

Measured memory_bytes: 3064