akhauriyash/Code-Regression huggingface dataset:
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<cmath>
#include<algorithm>
#define debug1 cout<<"?"<<endl;
#define debug2 cout<<"?"<<i<<endl;
#define PII pair<int,int>
typedef long long ll;
const int maxn=3e5+9;
const double pi=acos(-1);
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
const double ep=1e-7;
using namespace std;
ll n,a[maxn],k,fs,zs,zero;
bool check(ll x)//小于等于x的个数 
{
	ll sum=0;
	if(x>=0)
	{
		sum=fs*zs+zero*(fs+zs)+zero*(zero-1)/2;//<=0
		for(ll i=1;i<=n;i++)
		{
			if(a[i]<0)
			{
				ll kk=lower_bound(a+1,a+1+n,x/a[i])-a;
				sum+=(fs-max(i,kk-1));
//				cout<<"!"<<i<<' '<<fs-max(i,kk-1)<<endl;
			}
			if(a[i]>0)
			{
				ll kk=upper_bound(a+1,a+1+n,x/a[i])-a;
				sum+=(max(kk-1,i)-i);
//				cout<<"?!"<<i<<' '<<max(kk-1,i)-i<<endl;
			}
		}
	}
	else
	{
		for(ll i=1;a[i]<0&&i<=n;i++)
		{
			ll g=x/a[i];
			if((-x)%(-a[i]))g++;
			ll kk=lower_bound(a+1,a+1+n,g)-a;
			sum+=(n-kk+1);
		}
	}
//	cout<<"?"<<sum<<' '<<x<<endl;
	if(sum>=k)return 1;
	return 0;
}
int main()
{
	scanf("%lld%lld",&n,&k);
	for(ll i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		if(a[i]<0)fs++;
		else if(a[i]>0)zs++;
		else zero++;
	}
	sort(a+1,a+1+n);
	ll l=-1e18,r=1e18,ans=0;
	while(r-l>1)
	{
		ll mid=(l+r)>>1;
		if(check(mid))r=mid,ans=mid;
		else l=mid;
//		cout<<l<<' '<<r<<endl;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1792
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long const MOD = 1000000007LL;

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

    int n = s.size();
    vector<int> res(n);
    for (int i = 0; i < 2; i++) {
        int cnt = 0;
        // Rの子供だけ考える
        for (int i = 0; i < n; i++) {
            if (s[i] == 'R') ++cnt;
            else {
                res[i] += cnt / 2;
                res[i - 1] += (cnt + 1) / 2;
                cnt = 0;
            }
        }

        reverse(s.begin(), s.end());
        reverse(res.begin(), res.end());

        for (int i = 0; i < n; i++) {
            if (s[i] == 'L') s[i] = 'R';
            else s[i] = 'L';
        }
    }

    for (int i = 0; i < n; i++) cout << res[i] << " ";
    cout << endl;
}


Measured memory_bytes: 1024
//Author: kaiyu
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define tt ll t;cin >> t;while(t--)
#define int3(x,y,z) ll x,y,z;cin >> x >> y >> z;
#define int2(x,y) ll x,y;cin >> x >>y;
#define int1(x) ll x;cin>>x;
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}

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


bool cmp(pair<string,int>p1,pair<string,int>p2) {
    return p1.ss > p2.ss;
}

int32_t main()
{
    fio
    int a,b,c,d;
    cin >> a>> b>> c >> d;

    while(true) {
        c = c - b;
        if(c <= 0) {cout << "Yes" << endl; break;}
        a = a - d;
        if( a <= 0) {cout << "No"  << endl;break;}
    }

    return 0;

};




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

int main(){
	int a[3];
	int i=0;
	int j=0;
	int t=0;
	for(i=0;i<3;i++){
		cin>>a[i];
	}
	for(i=0;i<3;i++){
		for(j=i;j<3;j++){
			if(a[i]<a[j]){
				t=a[i];
				a[i]=a[j];
				a[j]=t;
			}
		}
	}
	if(a[0]==a[1]+a[2]){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

class Queue{
  static int NUM = 100000;
  Process[] a = new Process[NUM];
  int head;
  int tail;

  Queue(){
    head = 0;
    tail = 0;
  }

  void enqueue(Process p){
    if(!this.isFull()){
      a[tail] = p;
      if(tail == NUM - 1)
        tail = 0;
      else
        tail++;
      }
  }

  Process dequeue(){
    if(!this.isEmpty()){
      if(head == NUM - 1)
        head = 0;
      else
        head++;

      if(head == 0)
        return a[NUM - 1];
      else
        return a[head-1];
    }
    else
      return null;
  }

  boolean isFull(){
    return (head == 0 && tail == NUM-1) || (head == tail+1);
  }

  boolean isEmpty(){
    return head == tail;
  }

}

class Process{
  String name;
  int time;
  Process(String name, int time){
    this.name = name;
    this.time = time;
  }
  Process(Process p){
    this.name = p.name;
    this.time = p.time;
  }
}

public class Main{
  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int q = stdIn.nextInt();
    Queue queue = new Queue();

    for(int i = 0; i < n; i++){
      String name = stdIn.next();
      int time = stdIn.nextInt();
      queue.enqueue(new Process(name, time));
    }

    int time_sum = 0;
    while(!queue.isEmpty()){
      Process p = queue.dequeue();
      p.time -= q;
      if(p.time <= 0){
        time_sum += (q + p.time);
        System.out.println(p.name + " " + (time_sum));
      }
      else{
        queue.enqueue(p);
        time_sum += q;
      }
    }

  }
}

Measured memory_bytes: 76852
n = int(input())
sixs = [6,36,216,1296,7776,46656]
nines = [9,81,729,6561,59049]
lis = [i for i in range(170000)]
for i in range(0,100001):
 for j in sixs:
  if lis[i+j] > lis[i]+1:
    lis[i+j] = lis[i] + 1
 for j in nines:
  if lis[i+j] > lis[i]+1:
    lis[i+j] = lis[i] + 1
print(lis[n])

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int a, b, c;
  cin>>a>>b>>c;
  cout<<((a==b && b!=c) || (b==c && c!=a) || (c==a && c!=b) ? "Yes" : "No")<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[10001],ans,n;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=2*n;i++) scanf("%d",&a[i]);
    sort(a+1,a+1+2*n);
    for(int i=1;i<=2*n;i+=2) ans+=a[i];
    printf("%d",ans);
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int maxa=-1, mina=-1, a;
  for (int i=0; i<N; i++) {
    cin >> a;
    if (maxa == -1) maxa = mina = a;
    else if (a > maxa) maxa = a;
    else if (a < mina) mina = a;
  }
  cout << maxa - mina << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,i=0,j=0,k=0;
    int a[30];
    cin>>n;
    for(i=1; i<=n; i++)
    {
        if(i%3!=0 && i%5!=0)
        {
            k+=i;
        }
    }
    cout<<k;
}


Measured memory_bytes: 3632
n,m = map(int,input().split())
e = [[] for _ in range(n)]
for i in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  e[a].append(b)
  e[b].append(a)

q = [0]
i = 1
ans = [-1 for _ in range(n)]
while(len(q) > 0):
  qq = []
  for v in q:
    for u in e[v]:
      if ans[u] == -1:
        ans[u] = v
        qq.append(u)
  q = qq[:]
  i += 1

for i in range(1,n):
  if ans[i] == -1:
    print('No')
    exit()
print('Yes')
for i in range(1,n):
  print(ans[i]+1)


Measured memory_bytes: 101608
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    string S;
    cin >> N >> S;
    ll i;
    ll w[N+1],b[N+1];
    w[0]=0;b[0]=0;
    for(i=0;i<N;i++){
        if(S[i]=='#')w[i+1]=w[i]+1;else w[i+1]=w[i];
        if(S[N-i-1]=='.')b[i+1]=b[i]+1;else b[i+1]=b[i];
    }
    ll ans=N;
    for(i=0;i<N+1;i++){
        ans=min(ans,w[i]+b[N-i]);
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    vector<ll> b;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        ll tmp = 0;
        for (int j = i; j >= 0; --j) {
            tmp += a[j];
            b.push_back(tmp);
        }
    }

    ll ans = 0;
    int siz = b.size();
    for (int i = 39; i >= 0; --i) {
        int cnt = 0;
        ans |= (1LL << i);
        for (int j = 0; j < siz; ++j)
            if ((b[j] & ans) == ans)
                cnt++;
        if (cnt < K)
            ans &= ~(1LL << i);
    }

    cout << ans << endl;

    return 0;
}


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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 2e5;
ll k[N], l[N], r[N];

void solve () {
	ll n;
	cin >> n;
	ll ans = 0;
	vector <ll> adj1[n + 1], adj2[n + 1];
	for (ll i = 0; i < n; i++) {
		cin >> k[i] >> l[i] >> r[i];
		if (l[i] == r[i]) 
			ans += l[i];
		else if (l[i] > r[i]) {
			adj1[k[i]].pb(i);
		}
		else {
			adj2[k[i]].pb(i);
		}
	}
	priority_queue <pair <ll, ll>> pq;
	pair <ll, ll> x;
	for (ll i = 1; i <= n; i++) {
		for (auto j : adj1[i]) {
			pq.push(mp(r[j] - l[j], j));
		}
		while (pq.size() > i) {
			x = pq.top();
			pq.pop();
			ans += l[x.se] + x.fi;
		}
	}
	while (!pq.empty()) {
		x = pq.top();
		pq.pop();
		ans += l[x.se];
	}
	for (ll i = n; i >= 1; i--) {
		for (auto j : adj2[i]) {
			pq.push(mp(l[j] - r[j], j));
		}
		while (pq.size() > n - i) {
			x = pq.top();
			pq.pop();
			ans += r[x.se] + x.fi;
		}
	}
	while (!pq.empty()) {
		x = pq.top();
		pq.pop();
		ans += r[x.se];
	}
	cout << ans << "\n";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
  #endif
	int t;
	cin >> t;
	while (t--) {
		solve();
	}
 	return 0;
}

Measured memory_bytes: 24000
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
// #define int long long
#define smin(a, b) a = min(a, b)

const int N = 2005;

vector<pair<int, int> > balls;
int cost[2][N][N];
int dp[N][N];	// dp[i][j] : minimum cost to arrange 1 to i black balls and 1 to j white balls,
				// 				if we build the final order from left to right
	
int32_t main() {
	fast_cin();  
	int n; cin >> n;
	for (int i = 1; i <= 2 * n; ++i) {
		char c; cin >> c;
		int a; cin >> a;
		balls.push_back({a, c == 'W' ? 1 : 0});
	}
	for (int i = 0; i < 2 * n; ++i) {
		int a = balls[i].first, c = balls[i].second;
		for (int j = i + 1; j < 2 * n; ++j) {
			int na = balls[j].first, nc = balls[j].second;
			if (na < a) {
				if (nc == c) {
					++cost[c][a - 1][0];
				} else {
					++cost[c][a - 1][na];
				}
			} else {
				if (nc != c) {
					++cost[c][a - 1][na];
				}
			}
		}
	}
	for (int c : {0, 1}) {
		for (int i = 0; i <= n; ++i) {
			for (int j = 1; j <= n; ++j) {
				cost[c][i][j] += cost[c][i][j - 1];
			}
		}
	}
	memset(dp, 63, sizeof dp);
	dp[0][0] = 0;
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= n; ++j) {
			if (i > 0) smin(dp[i][j], dp[i - 1][j] + cost[0][i - 1][j]);
			if (j > 0) smin(dp[i][j], dp[i][j - 1] + cost[1][j - 1][i]);
		}
	}
	cout << dp[n][n] << endl;
	return 0;
}

Measured memory_bytes: 47488
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>

using namespace std;

void showIntArray(int a[], int n) {
  for (int i=0; i<n; i++) {
    cout << a[i] << ' ';
  } cout << endl;
}

int main() {
  int A, B, T, biscuit, time;
  cin >> A >> B >> T;

  for (int i=0; 1; i++) {
    time += A;
    if (time > T + 0.5) break;
    biscuit += B;
  }
  cout << biscuit<< endl;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
INF = 10 ** 10
ans = INF


def rec(A, C, X, idx, ability, sum_):
    if idx == len(A):
        for i in range(len(ability)):
            if ability[i] < X:
                break
        else:
            global ans
            ans = min(sum_, ans)
    else:
        # not buy
        rec(A, C, X, idx+1, ability, sum_)
        M = len(A[0])
        import copy 
        new_ability = copy.copy(ability)
        for i in range(M):
            new_ability[i] += A[idx][i]
        rec(A, C, X, idx+1, new_ability, sum_+C[idx])


def main():
    N, M, X = map(int, input().split())
    C = []
    A = []
    for i in range(N):
        lists = [int(c) for c in input().split()]
        ci = lists[0]
        ai = lists[1:]
        C.append(ci)
        A.append(ai)

    ability = [0] * M
    rec(A, C, X, 0, ability, 0)

    if ans == INF:
        print(-1)
    else:
        print(ans)
    

    
    



if __name__ == '__main__':
    main()


Measured memory_bytes: 9272
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int a[]=new int[n];
    for(int i=0;i<n;i++)
      a[i]=sc.nextInt();
    Arrays.sort(a);
    int co=0;
     for(int i=0;i<n-1;i++)
     {
       if(a[i]==a[i+1])
          {System.out.println("NO");
          co++;
          break;}
          }
       if(co==0)
    System.out.println("YES");
  }
}

Measured memory_bytes: 64636
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[200000];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=n-1;i>=0;i-=2)
		cout<<a[i]<<' ';
	for(int i=n%2;i<n;i+=2)
		cout<<a[i]<<(i+2==n?'\n':' ');
}


Measured memory_bytes: 2944
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//ドーナツ種類
		int b = sc.nextInt();//所持グラム数
		int n[] = new int[a];//
		int x = 0;
		int d = 0;
		int batu = 0;
		for(int i = 0;i < a;i++){
			n[i] = sc.nextInt();
			b = b - n[i];
		
			
		}
		finish:for(int i = 0;i < a;i++){
		batu = 0;

		for(int e = 0; e < a; e++){
				if((n[e] >= n[i]) ){//その数字以下の数字の時
				batu++;
				if (batu == a){
					x = n[i];
					break finish;
				}

				
				}	
		}

		}

		d = b / x;//残りの数/最小で最大生成数取得
		System.out.println(a+d);
		
		
	
	}
}


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

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// ll dp[]

int main(){
  ll k, a, b;

  scanf("%lld", &k);
  scanf("%lld%lld", &a, &b);

  for (int i = a; i < b+1; i++)
  {
      if(i % k == 0) {
          printf("OK\n");
          return 0;
      }
  }
  
  printf("NG\n");

  return 0;
}

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

using namespace std;

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

    long long sum = 0;
    for (int i = 0; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=1e5+100;
int n;
vector<int>X;
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n;
    X.resize(n+1);
    cin>>X[0];
    for(int i=1; i<=n; i++)
        cin>>X[i];
    sort(all(X));
    int g=X[1]-X[0];
    for(int i=1; i<sz(X)-1; ++i)
        g=__gcd(g, X[i+1]-X[i]);
    cout<<g<<"\n";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
 string s;
 cin >> s;
 int count = 0;
  for (int i=0; i<s.size(); i++){
    if (s.at(i) == 'C') {
      for (int j=i; j<s.size(); j++){
        if (s.at(j) == 'F'){
          count++;
          break;
        }  
      }
    }
  }
  
 if (count > 0) 
   cout << "Yes" << endl;
 else
   cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n+1), b(n);
    rep(i, n+1) cin >> a[i];
    rep(i, n) cin >> b[i];
    ll cnt = 0;
    rep(i, n) {
        cnt += min(a[i], b[i]);
        b[i] -= a[i];
        if (b[i] > 0) {
            cnt += min(a[i+1], b[i]);
            a[i+1] = max(0, a[i+1] - b[i]);
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
const ll INF = ll(1e18)+1;
 
int main() {
  int n; ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  ll l = -INF, r = INF;
  while (l+1 < r) {
    ll x = (l+r)/2;
    bool ok = [&]{
      ll tot = 0;
      rep(i,n) {
        if (a[i] < 0) {
          int l = -1, r = n;
          while (l+1<r) {
            int c = (l+r)/2;
            if (a[c]*a[i] < x) r = c; else l = c;
          }
          tot += n-r;
        } else {
          int l = -1, r = n;
          while (l+1<r) {
            int c = (l+r)/2;
            if (a[c]*a[i] < x) l = c; else r = c;
          }
          tot += r;
        }
        if (a[i]*a[i] < x) tot--;
      }
      tot /= 2;
      return tot < k;
    }();
    if (ok) l = x; else r = x;
  }
  cout << l << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> par;  // 親の番号

// n要素で初期化
void init(int n)
{
  par.resize(n);
  for (int i = 0; i < n; i++)
  {
    par[i] = i;
  }
}

int root(int x)
{
  if (par[x] == x)
  {
    return x;  // 根
  }
  else
  {
    return par[x] = root(par[x]);  // 経路圧縮
  }
}

// 同じ集合か？
bool same(int x, int y)
{
  return root(x) == root(y);
}

// xとyの属する集合を併合
void unite(int x, int y)
{
  x = root(x);
  y = root(y);
  if (x == y)
    return;

  par[x] = y;  // xの値をyに更新
}

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

  init(n);

  for (int i = 0; i < m; i++)
  {
    int a, b;
    cin >> a >> b;

    a--;
    b--;

    unite(a, b);
  }

  // 経路圧縮漏れが出ているから、再度ルール
  for (int i = 0; i < n; i++)
  {
    root(i);
  }

  // for (int i = 0; i < n; i++)
  // {
  //   cout << i << "," << par[i] << endl;
  // }

  vector<int> _size(n);

  // size
  for (int i = 0; i < n; i++)
  {
    _size[par[i]]++;
  }

  // for (int i = 0; i < n; i++)
  // {
  //   cout << _size[i] << endl;
  // }

  auto it = max_element(_size.begin(), _size.end());

  cout << *it << endl;
  return 0;
}

Measured memory_bytes: 7920
#include <iostream>
#define ll long long
using namespace std;

ll A[200010], B[200010];

int main() {
	int N;
	cin >> N;
	ll sum=0;
	for(int i=0; i<N; ++i){
		cin >> A[i] >> B[i];
		sum += A[i];
	}
	ll mn=sum;
	for(int i=0; i<N; ++i){
		if(A[i]>B[i]){
			mn=min(mn, B[i]);
		}
	}
	cout << sum-mn << endl;
	return 0;
}

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

int main()
{
    string s[3];
    int tu = 0;
    cin >> s[0] >> s[1] >> s[2];

    while (1) {
        if (s[tu].empty()) {
            if (tu == 0) cout << 'A' << endl;
            else if (tu == 1) cout << 'B' << endl;
            else if (tu == 2) cout << 'C' << endl;
            return 0;
        }
        else {
            if (s[tu][0] == 'a') {
                s[tu].erase(0, 1);
                 tu = 0;
            }
            if (s[tu][0] == 'b') {
                s[tu].erase(0, 1);
                tu = 1;
            }
            if (s[tu][0] == 'c') {
                s[tu].erase(0, 1);
                tu = 2;
            }
        }
    }
}



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

double h[] = {35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0};
double f[] = {71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0};
string s[] = {"AAA", "AA", "A", "B", "C", "D", "E"};

int main()
{
  double a, b;
  while(cin >> a >> b)
  {
    for(int i = 0; i < 7; i++)
    {
      if(a < h[i] && b < f[i])
      {
        cout << s[i] << endl;
        goto next;
      }
    }
    cout << "NA\n";
  next:;
  }
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = (a); i < (n); i++)
#define MP make_pair
#define all(s) (s).begin(), (s).end()
#define rev(s) (s).rbegin(), (s).rend()
#define X first
#define Y second

using namespace std;

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

int memo[1<<10][10][1000];

int dfs(int used, int n, int s){
	if(n == 0) return s == 0;
	if(memo[used][n][s] != -1) return memo[used][n][s];

	int cnt = 0;
	rep(i, 10){
		int num = 1<<i;
		if(used&num) continue;
		used |= num;
		cnt += dfs(used, n-1, s-i*n);
		used &= ~num;
	}
	return memo[used][n][s] = cnt;
}

int main(){
	memset(memo, -1, sizeof(memo));
	int n, s;
	while(cin >> n >> s){
		if(s > 1000) cout << 0 << endl;
		else cout << dfs(0, n, s) << endl;
	}

	return 0;
}

Measured memory_bytes: 41168
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <stack>
#include <functional>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main() {
	ll n, k;
	cin >> n >> k;
	vector<priority_queue<ll>> q(n);
	for (ll i = 0; i < n; i++)
	{
		ll t, d;
		cin >> t >> d;
		q[t - 1].push(d);
	}

	priority_queue<ll> best, remain;
	for (ll i = 0; i < n; i++)
	{
		if (!q[i].empty()) {
			best.push(q[i].top());
			q[i].pop();

			while (!q[i].empty()) {
				remain.push(q[i].top());
				q[i].pop();
			}
		}
	}

	vector<ll> bsum = { 0 }, rsum = { 0 };

	while (!best.empty())
	{
		bsum.push_back(bsum.back() + best.top());
		best.pop();
	}

	while(!remain.empty())
	{
		rsum.push_back(rsum.back() + remain.top());
		remain.pop();
	}

	ll ans = 0;

	for (ll x = 1; x <= k; x++)
	{
		if (x >= bsum.size())break;
		if (k - x >= rsum.size())continue;
		ans = max(ans, bsum[x] + rsum[k - x] + x* x);
	}

	cout << ans << endl;
}

Measured memory_bytes: 8820
<?php

$time = intval(trim(fgets(STDIN))); //カードを出す回数
$taro = 0;
$hanako = 0;

for ($i = 0; $i < $time; $i++) {
    $alphabet = strtolower(trim(fgets(STDIN)));
    list($l, $r) = explode(' ', $alphabet);
    $result = strnatcmp($l, $r);

    if ($result < 0) {
        $hanako += 3;
    } elseif ($result == 0) {
        $hanako++;
        $taro++;
    } else {
        $taro += 3;
    }
}

echo sprintf("%d %d\n", $taro, $hanako);


Measured memory_bytes: 9240
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";var r=n(1);n(2)(r.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,n){"use strict";var r=n(3),i=n(5);t.exports=function(t){var e=new r(t);i(e)}},function(t,e,n){"use strict";var r=n(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new r(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,n){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,n){"use strict";t.exports=function(t){var e=t.in(),n=t.in();1<=e&&e<=9&&1<=n&&n<=9?console.log(e*n):console.log(-1)}}]);

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		long[] l = new long[n + 1];
		l[0] = 2;
		l[1] = 1;
		for (int i = 2; i <= n; i++) {
			l[i] = l[i - 1] + l[i - 2];
		}

		pr.println(l[n]);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
# -*- coding:utf-8 -*-
import math

if __name__ == "__main__":
    N = int(input())

    if N == 7:
        print("Yes")
        exit()

    max_7 = math.floor(N / 7)
    for i in range(max_7, -1, -1):
        rest = N - i*7
        if rest%4 == 0:
            print("Yes")
            exit()

    print("No")


Measured memory_bytes: 3060
open Batteries
open Printf
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let a_lst = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in

  Printf.printf "%d\n" @@
  (List.max a_lst) - (List.min a_lst)


Measured memory_bytes: 1152
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	while(true) {
		ll m, nn, nx;
		cin>>m>>nn>>nx;
		if(m==0 && nn==0 && nx==0) break;
		vector<ll> p(m);
		REP(i, m) cin>>p[i];
		ll gap = -1;
		ll res = -1;
		for(ll i = nx - 1; i >= nn - 1; --i) {
			if(p[i] == p[nx]) continue;
			if(p[i] - p[i + 1] > gap) {
				gap = p[i] - p[i + 1];
				res = i + 1;
			}
		}
		cout<<res<<endl;
	}
}

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

char A1[33] = " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char B1[33] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";

string A2[32] = {
	"101",
	"000000",
	"000011",
	"10010001",
	"010001",
	"000001",
	"100101",
	"10011010",
	"0101",
	"0001",
	"110",
	"01001",
	"10011011",
	"010000",
	"0111",
	"10011000",
	"0110",
	"00100",
	"10011001",
	"10011110",
	"00101",
	"111",
	"10011111",
	"1000",
	"00110",
	"00111",
	"10011100",
	"10011101",
	"000010",
	"10010010",
	"10010011",
	"10010000"
};

string B2[32] = {
	"00000",
	"00001",
	"00010",
	"00011",
	"00100",
	"00101",
	"00110",
	"00111",
	"01000",
	"01001",
	"01010",
	"01011",
	"01100",
	"01101",
	"01110",
	"01111",
	"10000",
	"10001",
	"10010",
	"10011",
	"10100",
	"10101",
	"10110",
	"10111",
	"11000",
	"11001",
	"11010",
	"11011",
	"11100",
	"11101",
	"11110",
	"11111"
};

string U;
string V;

int main() {
	while (getline(cin, U)) {
		V = "";
		for (int i = 0; i < U.size(); i++) {
			for (int j = 0; j < 32; j++) {
				if (B1[j] == U[i]) {
					V += B2[j];
				}
			}
		}
		U = "";
		int pass = 0;
		while (pass < V.size()) {
			for (int j = 0; j < 32; j++) {
				if (pass + A2[j].size() <= V.size()) {
					if (A2[j] == V.substr(pass, A2[j].size())) {
						U += A1[j];
						pass += A2[j].size();
						goto I;
					}
				}
			}
			break;
		I:;
		}
		cout << U << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
	int N,K; cin >> N>>K;
    vl H(N); rep(i,N) cin >> H[i];
    sort(rall(H));
    if(N <= K) cout << 0 << endl;
    else {
        rep(i,K) H[i] = 0;
        ll ans = 0;
        rep(i,N) ans += H[i];
        cout << ans << endl;
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>

#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define N 10000


using namespace std;

int main(void){
    int a,b;
    int n;
    
    while (cin>>n && n){
        int s = 0 , t = 0;
        REP(i,n){
            cin >> a >> b;
            if (a>b)
                s += (a+b);
            else if (a<b)
                t += (a+b);
            else{
                s += a;
                t += b;
            }
        }
        cout << s << " " << t << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#include <bits/stdc++.h>
using namespace std;typedef long long ll;ll N,L,T;int main(){cin>>N>>L>>T;vector<ll> ans;ll diff=0;REP(i,N){ll x,w;cin>>x>>w;ll pos;if(w==1){pos=(x+T)%L;diff+=(x+T)/L;}else{pos=((x-T)%L+L)%L;diff-=(T-x+L-1)/L;}ans.push_back(pos);}sort(ans.begin(),ans.end());diff=(diff%N+N)%N;rotate(ans.begin(),ans.begin()+diff,ans.end());REP(i,N)cout<<ans[i]<<endl;return 0;}

Measured memory_bytes: 2164
#include <iostream>
#include <algorithm>
#include <stack>
#include <map>
#include <math.h>
#include <vector>
#include <cctype>
using namespace std;

int main() {

	string a;
	cin >> a;
	bool good = true;
	if(a[0] != 'A'){
		good = false;
	}

	int ct = 0;
	for(int i=2; i<a.size()-1; i++){
		if(a[i] == 'C'){
			ct += 1;
		}
	}
	if(ct != 1){
		good = false;
	}

	ct = 0;
	for(int i=1; i<a.size(); i++){
		if(a[i] == 'C'){
			ct += 1;
		}
		if(a[i] != tolower(a[i]) && a[i] != 'C'){
			good = false;
		}
	}
	if(ct != 1){
		good = false;
	}
	if(good){
		cout << "AC";
	}else{
		cout << "WA";
	}
}


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

#define llint long long int

using namespace std;

int main()
{
    llint N, X, M;

    cin >> N >> X >> M;

    if (N == 1)
    {
        cout << X << endl;

        return 0;
    }
    // ループするまで
    vector<bool> sumi(M, false);

    llint sum = 0;
    llint A;

    bool loop = false;
    llint loop_start = -1;

    for (int i = 1; i <= N; i++)
    {
        if (i == 1)
        {
            A = X;
        }
        else
        {
            A = (A * A) % M;
        }
        sum += A;
        loop_start = A;

        if (sumi[A] == false)
        {
            sumi[A] = true;
        }
        else
        {
            loop = true;

            break;
        }
    }
    if (loop = false)
    {
        cout << sum << endl;

        return 0;
    }
    // ループの開始まで
    sum = 0;

    llint i = 1;

    while (true)
    {
        if (i == 1)
        {
            A = X;
        }
        else
        {
            A = (A * A) % M;
        }
        sum += A;
        i++;

        if (A == loop_start)
        {
            break;
        }
    }
    // ループの長さ
    llint count = 0;
    llint sum_part = 0;

    while (true)
    {
        A = (A * A) % M;
        sum_part += A;
        count++;
        i++;

        if (A == loop_start)
        {
            break;
        }
    }

    i -= count;
    sum += ((N + 1 - i) / count) * sum_part;
    i += ((N + 1 - i) / count) * count;
    // ループの終了から
    for (; i <= N; i++)
    {
        A = (A * A) % M;
        sum += A;
    }
    cout << sum << endl;
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    vector<int> A(N),B(N),C(N);
    rep(i,N) {
        int a;
        cin >> a ;
        A[i] = a;

    }
    rep(i,N) {
        int b;
        cin >> b;
        B[i] = b;
    }
    rep(i,N) {
        int c;
        cin >>c;
        C[i] = c;
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());

    vector<int> X(N),Y(N);
    ll ans = 0;

    rep(i,N) {
        ll idx1 = lower_bound(A.begin(),A.end(),B[i]) - A.begin();
        ll idx2 = upper_bound(C.begin(),C.end(),B[i]) - C.begin();
        idx2 = N-idx2;
        //idx1 = idx-1;
        ans += idx1*idx2; 
        //cout << idx1 << " " << idx2 << endl;

    }
    cout << ans << endl;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s;
    cin >> s;
    int n = s.size();
    int k;
    cin >> k;
    vector<string> v;
    map<string, int> mp;
    rep(i, n) {
        string now;
        rep(j, 5) {
            if (i+j>=n) continue;
            now += s[i+j];
            if (!mp.count(now)) {
                v.push_back(now);
                mp[now]++;
            }
        }
    }
    sort(whole(v));
    string ans = v[k-1];
    
    cout << ans << endl;
    return 0;
}


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

int main(){
	int n, cnt;
	while(cin >> n, n){
		cnt = 0;
		while(1){
			if(n == 1){
				break;
			}
			if(n%2 == 0){
				n /= 2;
			}
			else if(n%2 == 1){
				n *= 3;
				n += 1;
			}
			cnt++;
		}
		cout << cnt << endl;
	}

}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int a,b,x,xx,xxx;
    cin>>a>>b;
    xx=(a+b)/2;
    x=(a*10+b*10)/2;
    if(x%10!=0){
        xxx=xx+1;
    }
    else{
        xxx=xx;
    }
    cout<<xxx<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a=0;
	int b=0;
	int x[2];
	int i=0;
	cin>>x[0]>>x[1];
	a=x[0]*x[1];
	b=x[0]*2+x[1]*2;
	cout<<a<<" "<<b<<endl;
}

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

int main() {
    int h,w,k;cin>>h>>w>>k;
    
    int a[h][w];
    
    rep(i,h){
        string s;cin>>s;
        rep(j,w){
            if(s[j]=='#')a[i][j]=1;
            else a[i][j]=0;
        }
    }
    ll ans = 0;

    for (int bit = 0; bit < (1<<(h+w)); ++bit){
        int b[h][w];
        rep(d1,h)rep(d2,w)b[d1][d2]=a[d1][d2];

    for (int i = 0; i < (h+w); ++i) {
        if (bit & (1<<i)) { // i が bit に入るかどうか
        if(i<h)rep(c1,w)b[i][c1]=0;
        else rep(c2,h)b[c2][i-h]=0;
        }
    }
    
    int tmp=0;
        rep(d1,h)rep(d2,w)if(b[d1][d2]==1)++tmp;
        if(tmp==k)++ans;
    }
    cout<<ans<<endl;
    return 0;
}

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

const ll MOD = 1e9+7LL;

ll power(ll a, ll x) {
    if (x == 0) return 1;
    if (x & 1) return a * power(a, x-1) % MOD;
    return power(a * a % MOD, x / 2);
}

int main(){
    ll n;
    cin >> n;
    ll ans = power(10, n);
    ans = ((ans - power(9, n)) % MOD + MOD) % MOD;
    ans = ((ans - power(9, n)) % MOD + MOD) % MOD;
    ans = ((ans + power(8, n)) % MOD + MOD) % MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main() {

	std::ios::sync_with_stdio(0);
	std::cin.tie(NULL);
	std::cout.tie(0);


	int n, k, t, query, a[(int)2e5 + 1];
	int change = 0;
	cin >> n >> k >> t;
	for (int i = 0; i < n; ++i)a[i] = k;
	while (t--) {
		cin >> query;
		a[--query]++;
		change--;
	}
	for (int i = 0; i < n; ++i) {
		if (a[i] + change <= 0)cout << "No" << '\n';
		else cout << "Yes" << '\n';
	}
	return 0;
}

Measured memory_bytes: 1024
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

int main(){	
	ll N, M;
	cin >> N >> M;
	vector<ll> s(M), c(M), res(N, -1);
	rep(i, M) {
		cin >> s[i] >> c[i];
		s[i]--;
	}
	bool flg = true;
	rep(i, M) {
		if (s[i] > N) {
			cout << "-1" << endl; 
			return 0;
		}
		if (res[s[i]] != -1 && res[s[i]] != c[i]) {
			cout << "-1" << endl; 
			return 0;
		}
		if (N > 1 && s[i] == 0 && c[i] == 0) {
			cout << "-1" << endl; 
			return 0;
		}
		res[s[i]] = c[i];
	}

	bool flg2 = false;
	ll cnt = 0;
	rep(i, N) {
		if (res[i] == -1) {
			if (N > 1 && i == 0) res[i] = 1; else res[i] = 0;
		} else {
			flg2 = true;
		}
	}
	if (flg) {
		for (ll i = 0; i < N; i++) {
			cout << res[i];
		}
		cout << endl;
	} else {
		cout << "-1" << endl; 
	}
}


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

int n;
int w[300];

int memo[512][512];

int search(int begin, int end) {
	int ret = end - begin;
	if (end <= begin) return 0;
	if (end == begin + 1) return 1;
	if (end == begin + 2) return abs(w[begin] - w[begin + 1]) <= 1 ? 0 : 2;
	if (memo[begin][end]) return ~memo[begin][end];
	if (abs(w[begin] - w[end - 1]) <= 1 && search(begin + 1, end - 1) == 0) {
		/* zenbu otoseru */
		ret = 0;
	} else {
		int i;
		for (i = begin + 1; i < end; i++) {
			int candidate = search(begin, i) + search(i, end);
			if (candidate < ret) ret = candidate;
		}
	}
	return ~(memo[begin][end] = ~ret);
}

int main(void) {
	int i;
	while (scanf("%d", &n) == 1 && n > 0) {
		for (i = 0; i < n; i++) {
			if (scanf("%d", &w[i]) != 1) return 1;
		}
		memset(memo, 0, sizeof(memo));
		printf("%d\n", n - search(0, n));
	}
	return 0;
}

Measured memory_bytes: 1652
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;

const ll MOD=1000000007;

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b){
  ll p=1;
  for(int i=0;i<b;i++){
    p*=a;
  }
  return p;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll binom1(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i)/(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

int main(){
  int i,j,k,cnt=0;
  int n;
  cin>>n>>k;
  int h[n+k];
  for(i=k;i<n+k;i++)cin>>h[i];
  for(i=0;i<k;i++)h[i]=h[k];
  ll d[n+k];
  for(i=0;i<k;i++)d[i]=0;
  for(i=k;i<n+k;i++){
    ll mi=LLONG_MAX;
    for(j=1;j<=k;j++){
      mi=min(mi,d[i-j]+abs1(h[i]-h[i-j]));
    }
    d[i]=mi;
  }
  cout<<d[n+k-1]<<endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
//#include <cstdio>
//#include <cstring>
//#include <iostream>
//#include <algorithm>
using namespace std;
typedef long long ll;
const  int maxx=3e5+100;
const int INF=1e9;
const int MOD=1e9+7;
int p[maxx];
int main()
{
    int n,k;
    scanf("%d%d",&k,&n);
    if(k%2==0){
        printf("%d ",k/2);
        for(int i=2; i<=n; i++)
            printf("%d ",k);
    }
    else{
        for(int i=1; i<=n; i++)
            p[i]=k/2+1;
        int tail=n;
        for(int j=1; j<=n/2; j++){
            if(p[tail]==1)  tail--;
            else{
                p[tail]--;
                for(int i=tail+1; i<=n; i++)
                    p[i]=k;
                tail=n;
            }
        }
        for(int i=1; i<=tail; i++){
            printf("%d ",p[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 3456
import numpy as np
N = int(input())
R = []
for _ in range(N):
    R.append(list(map(int, input().split())))
R = np.array(R)
X = R[:,0].reshape((-1,1))
Y = R[:,1].reshape((-1,1))
dX = X-X.T
dY = Y-Y.T
D = np.sqrt(dX*dX+dY*dY)
sum_D = np.sum(np.sum(D))/N
print(sum_D)

Measured memory_bytes: 21140
#include<stdio.h>

int main(void)
{
   int a, b , c;
   
   scanf("%d" , &a);
   scanf("%d" , &b);
   scanf("%d" , &c);
   
   if(a<b && b<c){
   printf("Yes\n");
   }
   else{
   printf("No\n");
   }

   return 0;
}

Measured memory_bytes: 2600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
int main()
{
  
        FastIO

        int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

        int i;
        cin>>i;
        cout<<a[i-1];
        return 0;
    }

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

using namespace std;
using namespace atcoder;

int main()
{
  int n, d;
  cin >> n >> d;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++)
  {
    cin >> x[i] >> y[i];
  }
  two_sat ts(n);
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < n; j++)
    {
      if (i == j) continue;
      if (abs(x[i] - x[j]) < d) ts.add_clause(i, 1, j, 1);
      if (abs(x[i] - y[j]) < d) ts.add_clause(i, 1, j, 0);
      if (abs(y[i] - y[j]) < d) ts.add_clause(i, 0, j, 0);
    }
  }
  int A = ts.satisfiable();
  if (!A)
  {
    cout << "No";
    return 0;
  }
  cout << "Yes\n";
  vector<bool> ans = ts.answer();
  for (int i = 0; i < n; i++)
  {
    if (ans[i] == 0) cout << x[i] << "\n";
    else cout << y[i] << "\n";
  }
}

Measured memory_bytes: 3764