akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
const int mod = 1e9 + 7;
int main(){
	SPEED
	string s; 
	cin >> s;
	ll n = s.length();
	ll dp[n][13]; 
	memset(dp, 0, sizeof dp);

	if (s[0] == '?') 
	{
		for ( int k = 0; k < 10; k++ )
				dp[0][k] = 1;
	}
	else 
		dp[0][s[0] - '0'] = 1;
	
	for ( int k = 1; k < n; k++ )
	{
		ll temp = s[k] - '0';
		if (s[k] == '?') 
		{
			for ( int i = 0; i < 10; i++ )
			{
				temp = i;
				for ( int j = 0; j < 13; j++ )
				{
					dp[k][(j * 10 + temp)%13] += dp[k - 1][j];
					dp[k][(j * 10 + temp)%13] %= mod;
				}
			}
		}
		else 
		{
			for ( int j = 0; j < 13; j++ )
			{
				dp[k][(j * 10 + temp)%13] += dp[k - 1][j];
				dp[k][(j * 10 + temp)%13] %= mod;
			}
		}
	}
	/*for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < 13; ++j)
		{
			cout << dp[i][j] << '\t';
		}
		cout << '\n';
	}
	cout << '\n';*/
	cout << dp[n - 1][5] << '\n';
	return 0;
}

Measured memory_bytes: 10604
#include <stdio.h>

int main(){
	int i,j,k;
	int a,b;
	char c[10];
	int m,n;
	int base;
	int out;
	int tokuten;
	int count=0,counter;
	scanf("%d",&counter);
	while(count<counter){
		base=0;
		out=0;
		tokuten=0;
		while(out!=3){
			scanf("%s",&c);
			if(strcmp(c,"HIT")==0){
				base++;
			}else if(strcmp(c,"HOMERUN")==0){
				tokuten+=base+1;
				base=0;
			}else if(strcmp(c,"OUT")==0){
				out++;
			}
			if(base>3){
				base--;
				tokuten++;
			}
		}
		printf("%d\n",tokuten);
		count++;
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()


int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++) {
        cin >> A[i];
    }
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        ans += A[i] / 2;
        A[i] -= (A[i]/2)*2;
        if(i==n-1)break;
        if(A[i]){
            if(A[i+1]){
                ans++;
                A[i]--;
                A[i+1]--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;
typedef long long ll;

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

int main(){
    int S,W;
    cin>>S>>W;
    if(S<=W)cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;


return 0;

}

Measured memory_bytes: 3600
def main():
	import sys
	input = sys.stdin.readline
	N, L = map(int, input().split())
	sum = L * N + N * (N - 1) / 2
	if L >= 0:
		eat = L
	elif L + N - 1 >= 0:
		eat = 0
	else:
		eat = L + N -1
	print(int(sum - eat))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw_2(62,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,61) pw_2[i]=-2*pw_2[i-1];}
    
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    sort(all(A));
    // 0 1 2 ..... N-1
    // - ? ?        +
    vector<ll> sign(N,0);
    ll plus=1;
    sign[0]=-1;
    sign[N-1]=1;
    rep1(i,N-2){
        if(A[i]<0) sign[i]=-1;
        else{
            plus++;
            sign[i]=1;
        }
    }
    
    //Mだす
    ll M=0;
    rep(i,N){
        M+=sign[i]*A[i];
    }
    cout<<M<<endl;
    
    //[0] - (+) - (+) - (+) ...... = tmp
    //[1]~ (マイナスのやつ)　- tmp
    ll tmp=A[0];
    for(ll i=N-2;i>=N-plus;i--){
        cout<<tmp<<" "<<A[i]<<endl;
        tmp-=A[i];
    }
    
    cout<<A[N-1]<<" "<<tmp<<endl;
    tmp=A[N-1]-tmp;
    
    rep1(i,N-plus-1){
        cout<<tmp<<" "<<A[i]<<endl;
        tmp-=A[i];
    }
}



Measured memory_bytes: 4836
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n, p, tmp, ans = 1;
    scanf("%d", &n);
    scanf("%d", &tmp);

    for (int i = 1; i < n; i++)
    {
        scanf("%d", &p);
        if (tmp > p)
        {
            ans++;
            tmp = p;
        }
    }
    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main(){
    int a,b;cin>>a>>b;
    cout<<a*b-(a+b-1)<<endl;
    return 0;
}


Measured memory_bytes: 256
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  100005

void solve()
{
	ll x,n;
	cin>>x>>n;
	vi v(n);
	rep(i,0,n)
	{
		cin>>v[i];
	}
	vi a;
	rep(i,1,n)
	{
		a.pb(v[i]-v[i-1]);
	}
	a.pb(x-v[n-1]+v[0]);
	ll sum=0;
	rep(i,0,n)
	sum+=a[i];
	ll ans=sum;
	rep(i,0,n)
	{
		ans=min(ans,sum-a[i]);
	}
	cout<<ans<<endl;
	return;
}
int main()
{
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

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

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

    int ans = 0;
    vector<int> B(N - 1);
    for (int i = 0; i < N - 1; i++)
    {
        cin >> B[i];
        if (i == 0)
        {
            ans += B[i];
            continue;
        }
        ans += min(B[i - 1], B[i]);
        
        
    }
    ans += B[N - 2];
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from bisect import bisect_right
n, m, k = map(int, input().split())
li_a = list(map(int, input().split()))
li_b = list(map(int, input().split()))
sa = [0] * (len(li_a)+1)
sb = [0] * (len(li_b)+1)
for i in range(n):
    sa[i+1] = sa[i] + li_a[i]
for i in range(m):
    sb[i+1] = sb[i] + li_b[i]
ans = 0

for i in range(n+1):
    tmp = k
    tmp -= sa[i]
    if tmp >= 0:
        bi = bisect_right(sb, tmp)
        ans = max(ans, i+bi-1)
print(ans)
        

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

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        double r = sc.nextDouble();
        double PI = 3.141592653589793238;
        
        System.out.printf("%.6f %.6f\n", (r*r*PI), (2*PI*r));
    }
}

Measured memory_bytes: 28076
#include <iostream>
#include <limits>
#include <math.h>

long long int n, a, b, h[100010], best = 1e10;

int check(long long int mid)
{
	long long int ordinaryAttacks = b * mid, specialAttacks = 0;

	for (int i = 0; i < n; ++i)
	{
		long long int d = h[i] - ordinaryAttacks;

		if (d > 0 && d % (a - b) == 0)
			specialAttacks += (d / (a - b));
		else if (d > 0)
			specialAttacks += (d / (a - b)) + 1;

		if (specialAttacks > mid)
			return 0;
	}

//	std::cout << specialAttacks << " " << ordinaryAttacks;

	if (mid < best)
		best = mid;

	return 1;

}

int main()
{
	std::cin >> n >> a >> b;

	for (int i = 0; i < n; ++i)
		std::cin >> h[i];

	long long int l = 1, r = 1e10;
	long long int mid = l + (r - l) / 2;

	while (l <= r)
	{
		mid = l + (r - l) / 2;

//		std::cout << l << " " << mid << " " << r << "\n";

		if (check(mid))
		{
			r = mid - 1;
		}
		else
		{
			l = mid + 1;
		}
//		std::cout << "\n\n";
	}

	std::cout << best;

}

Measured memory_bytes: 1024
n = int(input())
x = []
y = []
h = []
for i in range(n):
    xx, yy, hh = map(int, input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
kk = h.index(max(h))
k = 0
for i in range(101):
    for j in range(101):
        ass = h[kk]+abs(x[kk]-i)+abs(y[kk]-j)
        for r in range(n):
            if h[r] == 0:
                if ass -abs(x[r]-i)-abs(y[r]-j) > 0:
                    ass = -1
            else:
                if ass != abs(x[r]-i)+abs(y[r]-j)+h[r]:
                    ass = -1
        if ass != -1:
                print(i, j, ass)
                break

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
    long i, cnt=0, ans=0;
    char s[200000];
    scanf("%s", s);
    for(i=0; s[i]; i++)
        s[i]=='B' ? cnt++ : (ans+=cnt);
    printf("%ld\n", ans);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	freopen("firesafe.in", "r", stdin);
//	freopen("firesafe.out", "w", stdout);
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if(u == s) cout << a - 1 << ' ' << b;
	else cout << a << ' ' << b - 1;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <vector>

using namespace std;
int main(){
  int N;
  long long int x;
  scanf("%d%lld", &N, &x);
  vector<long long int> a(N, 0);
  for (int i = 0; i < N; i++){
    scanf("%lld", &(a[i]));
  }
  long long int sum = 0;
  if (a[0] + a[1] > x){
    sum += a[0]+a[1]-x;
    a[1] -= a[0]+a[1]-x;
    if (a[1] < 0){
      a[0] += a[1];
      a[1] = 0;
    }
  }
  for (int i = 1; i < N; i++){
    if ((a[i-1]+a[i]) > x){
      sum += a[i-1]+a[i]-x;
      a[i] -= a[i-1]+a[i]-x;
    }
  }
  printf("%lld", sum);
  return 0;
}


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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;

  int N, K;
  cin >> N >> K;

  if ((N - 1) / 2 >= K - 1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		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();
		}
		sc.close();

		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (i % 2 == 0 && a[i] % 2 == 1) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


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

int main(){
	
	string s[10];
	s[1]="SAT";
	s[2]="FRI";
	s[3]="THU";
	s[4]="WED";
	s[5]="TUE";
	s[6]="MON";
	s[7]="SUN";
	
	string value;
	cin>>value;
	
	for(int i=1;i<=7;i++)
	{
		if(value==s[i])
		{
			cout<<i<<endl;
			break;
		}
	}
	
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rrep(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
typedef long long ll;
using namespace std;

ll dp[105][100500];

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,W; cin >> n >> W;
  vector<ll> v(n+1000), w(n+1000);
  rep(i,n) cin >> w[i] >> v[i];
  dp[0][0] = 0; 
  rep2(j,w[0],W+1) dp[0][j] = v[0];
  
  rep(i,n)rep(j,W+1){
  		if(j-w[i+1] >= 0) dp[i+1][j] = max(dp[i][j], dp[i][j-w[i+1]] + v[i+1]); 
        else dp[i+1][j] = dp[i][j];
  }   
  cout << dp[n-1][W];
  return 0;
}

Measured memory_bytes: 80128
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<queue>

using namespace std;

int main(){
    int dx[2]={1,2};
    int N,A,B,C,D;
    cin>>N>>A>>B>>C>>D;
    A--;B--;C--;D--;
    string S;
    cin>>S;
    bool dekiru;
    if(D>C) dekiru=true;
    if(C>D) dekiru=false;
    for(int i=A;i<min(max(C,D),N-1);i++){
        if(S[i]=='#'&&S[i+1]=='#'){ 
            dekiru=false;
            break;
        }
        if(C>D){
            if(B-1<=i&&i<D&&S[i]=='.'&&S[i+1]=='.'&&S[i+2]=='.') dekiru=true;
        }
    }
    if(dekiru) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int gcd(x , y){
    if(y == 0){
        return x ;
    }
    if(x < y){
        return gcd(x , y % x) ;
    }else{
        return gcd(y , x % y) ;
    }
}

int main(void){
    int x , y ;
    scanf("%d %d" , &x , &y) ;
    printf("%d\n" , gcd(x , y)) ;
    return 0 ;
}


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

int main() {
  int a, b, c, p, q;
  cin >> a >> b >> c;
  p = a - b;
  q = a - c;
  if(p < 0)
    p *= -1;
  if(q < 0)
    q *= -1;
  
  if(p > q)
    cout << "B" << endl;
  else
    cout << "A" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	rep(i,n) cin >> h.at(i);
	vector<bool> flg(n,true);
	
	rep(i,m){
		int a,b;
		cin >> a >> b;
		if(h[a-1] > h[b-1]) flg[b-1] = false;
		else if(h[a-1] < h[b-1]) flg[a-1] = false;
		else flg[a-1] = flg[b-1] = false;
	}
	
	int ans = 0;
	rep(i,n){
		if(flg[i]) ans++;
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
typedef long long ll;
int main(){
    string N;
    cin>>N;
    if(N[0]=='7'||N[1]=='7'||N[2]=='7'){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int main(){
  ll A,B;
  cin>>A>>B;

  ll k=(A+B);
  if(k%2) cout<<"IMPOSSIBLE"<<endl;
  else cout<<k/2<<endl;

  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

d1 = defaultdict(lambda: 'AA')
d2 = defaultdict(lambda: 'AA')

S = input()
T = input()

flag = True
for i in range(len(S)):
    if d2[T[i]] != 'AA':
        if d2[T[i]] != S[i]:
            flag = False
            break
    if d1[S[i]] != 'AA':
        if d1[S[i]] != T[i]:
            flag = False
            break
    d1[S[i]] = T[i]
    d2[T[i]] = S[i]

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 4144
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define LL long long

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

    int lost = 0;
    for (int i=0; i < s.length(); i++) {
        if (s[i] == 'x') {
            lost++;
        }
    }

    if (lost >= 8) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }

    return 0;
}

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

using namespace std;

int main()
{
	stack<int> S1;
	stack<pair<int,int>> S2;
	int sum=0;
	char ch;
	for (int i = 0; cin>>ch; ++i)
	{
		if(ch=='\\')
		{
			S1.push(i);
		}
		else if(ch=='/'&&S1.size()>0)
		{
			int j=S1.top();
			S1.pop();
			int a=i-j;
			sum+=a;
			while(S2.size()>0&&S2.top().first>j)
			{
				a=S2.top().second+a;
				S2.pop();
			}
			S2.push(make_pair(j,a));
		}
	}

	vector<int> ans;
	while(S2.size()!=0)
	{
		ans.push_back(S2.top().second);
		S2.pop();
	}
	reverse(ans.begin(),ans.end());
	cout<<sum<<endl;
	int s=ans.size();
	cout<<s;
	for (int i = 0; i < s; ++i)
	{
		cout<<" "<<ans[i];
	}
	cout<<endl;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define inf 100000000000000000
#define ll long long 
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define test ll t ; cin>>t; while(t--)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	
	ll n , m ;
	cin>> n>> m ;
	if(n>12)cout<<m<<endl;
	else if(n>=6 && n<=12)cout<<m/2<<endl;
	else cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll N, K, Q;
  cin >> N >> K >> Q;
  vector<ll> A(N, 0);
  for(ll i=0; i<Q; ++i){
    ll a;
    cin >> a;
    A[a-1]++;
  }
  for(ll i=0; i<N; ++i){
    if(K-(Q-A[i])>0){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }
  return  0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N, S = 0; std::cin >> N;
  std::vector<int> s(N);
  for(int i = 0; i < N; ++i) {
    int W; std::cin >> W;
    s[i] = (S += W);
  }
  int mi = 100*100;
  for(int i = 1; i < N; ++i) {
    mi = std::min(mi, std::abs(S-s[i]-s[i]));
  }
  fin(mi);
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

long[2*10^^5] AS, SAS;

void main()
{
    auto N = readln.chomp.to!int;
    foreach (i, e; readln.split.to!(long[])) {
        AS[i] = e;
        if (i) {
            SAS[i] = SAS[i-1] + e;
        } else {
            SAS[i] = e;
        }
    }
    auto SUM = SAS[N-1];

    size_t pi = 0, qi = 1, ri = 2;
    long P, Q, R, S, min_v = long.max;
    while (qi < N-2) {
        while (ri <= qi) ++ri;
        while (pi < qi-1 && abs(SAS[qi] - SAS[pi]*2) > abs(SAS[qi] - SAS[pi+1]*2)) ++pi;
        P = SAS[pi];
        Q = SAS[qi] - P;
        while (ri < N-2 && abs(SUM - SAS[ri] - (SAS[ri] - P - Q)) > abs(SUM - SAS[ri+1] - (SAS[ri+1] - P - Q))) ++ri;
        R = SAS[ri] - P - Q;
        S = SUM - P - Q - R;
        auto v = max(P, Q, R, S) - min(P, Q, R, S);
        min_v = min(min_v, v);
        ++qi;
    }
    writeln(min_v);
}

Measured memory_bytes: 13872
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 9999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli repow(lli n,lli k,lli m){
  if(k==0)return 1;
  else if(k%2==1)return repow(n,k-1,m)*n%m;
  else{
    lli temp=repow(n,k/2,m);
    return temp*temp%m;
  }
}
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  map<pint,int>mp1;
  map<pint,int>mp2;
  rep(i,0,N){
    cin >> A >> B;
    if(A==B&&A==0)flag++;
    else if(B==0)mp1[pint(1,0)]++;
    else if(A==0)mp2[pint(1,0)]++;
    else if((double)A/B>0){
      C=gcd(abs(A),abs(B));
      A/=C;
      B/=C;
      A=abs(A);
      B=abs(B);
      mp1[pint(A,B)]++;
    }
    else{
      C=gcd(abs(A),abs(B));
      A/=C;
      B/=C;
      A=abs(A);
      B=abs(B);
      mp2[pint(B,A)]++;
    }
  }
  num=1;
  set<pint>st;
  for(auto v:mp1)st.insert(v.first);
  for(auto v:mp2)st.insert(v.first);
  for(auto v:st){
    if(mp1.find(v)!=mp1.end()&&mp2.find(v)!=mp2.end()){
      num*=(repow(2,mp1[v],mod)+repow(2,mp2[v],mod)-1)%mod;
    }
    else if(mp1.find(v)!=mp1.end()){
      num*=(repow(2,mp1[v],mod));
    }
    else{
      num*=(repow(2,mp2[v],mod));
    }
    num%=mod;
  }
  Out((num+mod+flag-1)%mod);
}


Measured memory_bytes: 28568
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn enum_pats(n: usize, v: &Vec<Vec<bool>>, cur_stat: &mut Vec<bool>, cur_pos: usize) -> usize{

    if cur_stat.iter().all(|x| *x){
        return 1;
    }

    let mut ans = 0;
    for i in 0..n{
        if v[cur_pos][i] && !cur_stat[i]{
            cur_stat[i] = true;
            ans += enum_pats(n, v, cur_stat, i);
            cur_stat[i] = false;
        }
    }

    return ans;
}

fn main(){
    let line = read_as_vec::<usize>();
    let (n, m) = (line[0], line[1]);

    let mut v: Vec<Vec<bool>> = vec![vec![false;n];n];

    for _ in 0..m{
        let line = read_as_vec::<usize>();
        let (a, b) = (line[0]-1, line[1]-1);
        v[a][b] = true;
        v[b][a] = true;
    }

    let mut tmp = vec![false;n];
    tmp[0] = true;
    println!("{}", enum_pats(n, &mut v, &mut tmp, 0));
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void)
{
	int data[10];
	int dai1,dai2,wk;
	int i,j;
	for(i=0;i<10;i++){
		scanf("%d",&data[i]);
	}
	for(i=0;i<9;i++){
		for(j=i+1;j<10;j++){
			if(data[i]<data[j]){
				wk=data[i];
				data[i]=data[j];
				data[j]=wk;
			}
		}
	}
	dai1=data[0]+data[1]+data[2];
	for(j=0;j<10;j++){
		scanf("%d",&data[j]);
	}
	for(j=0;j<9;j++){
		for(i=j+1;i<10;i++){
			if(data[j]<data[i]){
				wk=data[j];
				data[j]=data[i];
				data[i]=wk;
			}
		}
	}
	dai2=data[0]+data[1]+data[2];
	printf("%d %d\n",dai1,dai2);
	return 0;
}



Measured memory_bytes: 2720
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

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

    ll ans = 0;
    for(int k = 1; k < n / 2; ++k){
        vector<ll> LeftSum(1, 0), RightSum(1, 0);
        if((n - 1) % k == 0){
            for(int i = n - k - 1; i >= n / 2; i -= k){
                RightSum.emplace_back(RightSum.back() + s[i]);
            }
        } else {
            for(int i = n - k - 1; i > k; i -= k){
                RightSum.emplace_back(RightSum.back() + s[i]);
            }
        }
        int sz = RightSum.size();
        for(int i = k; i < k * sz; i += k){
            LeftSum.emplace_back(LeftSum.back() + s[i]);
        }
        if(k * (sz - 1) == n - k * (sz - 1) - 1)    --sz;
        for(int i = 1; i < sz; ++i){
            chmax(ans, LeftSum[i] + RightSum[i]);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4924
#include <bits/stdc++.h>  
#define ll long long
#define mk make_pair
#define y1 yyy
using namespace std;

const int N = 3e5 + 5;

int n, a[N], p;
ll ans, f[N][2];

int main() {
	cin >> n >> p;
	for (int i = 1; i <= n; i++) cin >> a[i];
	f[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		a[i] %= 2;
		f[i][0] = f[i - 1][0];
		f[i][1] = f[i - 1][1];
		f[i][0 + a[i]] += f[i - 1][0];
		f[i][1 ^ a[i]] += f[i - 1][1];
	}
	cout << f[n][p];
}

Measured memory_bytes: 256
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處
namespace Number {
    typedef long long int LL;
    // 求取 a, b 的最大公因數
    LL gcd(LL a, LL b) {
        if (a % b == 0) {
            return b;
        }
        return gcd(b, a % b);
    }
    // 求取 a, b 的最大公因數 gcd
    // 以及 x, y 使得 a*x + b*y = gcd
    LL gcd_extend(LL a, LL b, LL *x, LL *y) { 
        if (a == 0) { 
            *x = 0, *y = 1; 
            return b; 
        } 
    
        LL x1, y1; // To store results of recursive call 
        LL gcd = gcd_extend(b%a, a, &x1, &y1); 
    
        *x = y1 - (b/a) * x1; 
        *y = x1; 
    
        return gcd; 
    }
    // 求 a_inv 使得 (a * a_inv) % m = gcd(a, m)
    // 若 a, m 互質，即求 a 在 mod m 群的反元素 a_inv 
    LL mod_inv(LL a, LL m) { 
        LL x, y; 
        LL g = gcd_extend(a, m, &x, &y); 
        // 處理 x 爲負的情形 
        LL a_inv = (x%m + m) % m; 
        return a_inv;
    }
    // 求 x^n % m
    LL mod_pow(LL x, LL n, LL m) {
        if (n == 0) {
            return 1;
        } else if (n & 1) {
            LL half = mod_pow(x, n/2, m);
            return (half * half % m) * x % m;
        } else {
            LL half = mod_pow(x, n/2, m);
            return half * half % m;
        }
    }
    // 連乘
    LL mul(LL from, LL to, LL m) {
        LL ret = 1;
        for (LL i = from; i <= to; i++) {
            ret *= i;
            ret %= m;
        }
        return ret;
    }
    // 求 (C n 取 k) % m
    LL mod_comb(LL n, LL k, LL m) {
        if (n < 0 || k < 0) { return 0; }
        if (n == 0 || k == 0) {return 1;}
        LL mi = k < n-k ? k : n-k;
        LL up = mul(n - mi + 1, n, m);
        LL down = mul(1, mi, m);
        return (up * mod_inv(down, m)) % m;
    }
}

char L[100005];

const LL M = (LL)1e9 + 7;

int main() {
    scanf("%s", L);
    int n = strlen(L);
    vector<int> ones;
    for (int i = 0; i < n; i++) {
        if (L[i] == '1') { ones.push_back(i); }
    }

    // 打表
    LL ans = 0;
    for (int i = 0; i < ones.size(); i++) {
        int digit = n - ones[i];
        ans += Number::mod_pow(2, i, M) * Number::mod_pow(3, digit - 1, M);
        ans %= M;
        // ans += Number::mod_pow(2, i + 1, M);
    }
    ans += Number::mod_pow(2, ones.size(), M);
    ans %= M;
    printf("%lld\n", ans);
}


Measured memory_bytes: 1652
#include <iostream>
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define MAX 10000
using namespace std;
int ans,cou;
int n;
char s[10],g[10];
struct t {
  int h;
  int m;
  int s;
};
t start[MAX],goal[MAX];
int main() {
  while(true){
    cin >> n;
    if(n==0) return 0;
    ans = 0;
    cou = 0;
    rep(i,n){
      cin >> s >> g;
      start[i] = t();
      goal[i] = t();
      start[i].h = (int)(s[0]-'0')*10+(int)(s[1]-'0');
      start[i].m = (int)(s[3]-'0')*10+(int)(s[4]-'0');
      start[i].s = (int)(s[6]-'0')*10+(int)(s[7]-'0');
      goal[i].h = (int)(g[0]-'0')*10+(int)(g[1]-'0');
      goal[i].m = (int)(g[3]-'0')*10+(int)(g[4]-'0');
      goal[i].s = (int)(g[6]-'0')*10+(int)(g[7]-'0');
    }
    rep(i,24) rep(j,60) rep(k,60){
      rep(l,n){
        if(goal[l].h==i&&goal[l].m==j&&goal[l].s==k) cou--;
        if(start[l].h==i&&start[l].m==j&&start[l].s==k) cou++;
      }
      if(cou>ans) ans = cou;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1396
import scala.math.floor
import scala.io.StdIn

object Main extends App {
  var input = StdIn.readInt()

  var firstInt = 0
  if(input % 1000 == 0) {
    firstInt = floor(input / 1000).toInt
  } else {
    firstInt = floor(input / 1000).toInt + 1
  }

  val money = firstInt * 1000
  println(money - input)
}


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

int main(){
  string S;
  ll r=0,l=0,koko=0,wa=0;
  cin>>S;
  vector<ll> vec(S.size());
  
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='R'&&l==0)
      r++;
    else if(S.at(i)=='L'&&r!=0){
      koko = i-1;
      vec.at(koko)=r;
      r=0;
      l++;
    }
    else if(S.at(i)=='L'&&r==0)
      l++;
    else if(S.at(i)=='R'&&l!=0){
      wa = vec.at(koko)+l;
      if(wa%2==0){
        vec.at(koko)=wa/2;
        vec.at(koko+1)=wa/2;
      }
      else{
        if(vec.at(koko)%2==0){
          vec.at(koko)=wa/2;
          vec.at(koko+1)=(wa/2)+1;
        }
        else{
          vec.at(koko)=(wa/2)+1;
          vec.at(koko+1)=(wa/2);
        }
      }
      l=0;
      r++;
    }
  }
  
  wa = vec.at(koko)+l;
  if(wa%2==0){
    vec.at(koko)=wa/2;
    vec.at(koko+1)=wa/2;
  }
  else{
    if(vec.at(koko)%2==0){
      vec.at(koko)=wa/2;
      vec.at(koko+1)=(wa/2)+1;
    }
    else{
      vec.at(koko)=(wa/2)+1;
      vec.at(koko+1)=(wa/2);
    }
  }
  
  for(int i=0;i<S.size();i++)
    cout<<vec.at(i)<<" ";
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;

int main(){
    int n;
    cin>>n;
    vector<vector<P>> tree(n);
    for(int i=0; i<n-1; i++){
        int u,v,w;
        cin>>u>>v>>w;
        u--;v--;
        tree[u].push_back(P(v,w));
        tree[v].push_back(P(u,w));
    }
    V ans(n,-1);
    ans[0] = 0;
    Q q;
    q.push(0);
    while(q.size()>0){
        int tmp = q.front();
        q.pop();
        for(P p: tree[tmp]){
            if(ans[p.first]!=-1) continue;
            ans[p.first] = (ans[tmp]+p.second)%2;
            q.push(p.first);
        }
    }
    for(int i : ans) OUT(i);
}


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

#ifdef DEBUG
#include "../.inc/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

const int mod = 998244353;
struct P { int x, y; };

void compress(vector<int> &v) {
    vector<int> w(v);
    sort(w.begin(), w.end());
    for (int i=0; i<(int)v.size(); ++i) {
        v[i] = lower_bound(w.begin(), w.end(), v[i]) - w.begin();
    }
}

class BIT {
public:
    int n;
    vector<int> nodes;
    BIT(int n): n(n+1), nodes(n+1, 0) {}

    void add(int i, int v) {
        nodes[++i] += v;
        for (i+=i&(-i); i<=n; i+=i&(-i)) nodes[i] += v;
    }
    int sum(int i) {
        int res = nodes[++i];
        for (i-=i&(-i); i>0; i-=i&(-i)) res += nodes[i];
        return res;
    }
};

long long modpow(long long a, long long n) {
    if (n == 0) return 1;
    a %= mod;
    if (n % 2 == 0) {
        long long t = modpow(a, n/2);
        return (t * t) % mod;
    }
    return (modpow(a, n-1) * a) % mod;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    int n;
    cin >> n;

    vector<int> x(n), y(n);
    for (int i=0; i<n; ++i) {
        cin >> x[i] >> y[i];
    }
    compress(x);
    compress(y);

    vector<P> p;
    for (int i=0; i<n; ++i) {
        p.push_back((P){x[i], y[i]});
    }
    sort(p.begin(), p.end(), [](const P &a, const P &b){
        return a.x < b.x || (a.x == b.x && a.y < b.y);
    });

    vector<int> tl(n), bl(n);
    {
        BIT bit(2*n);
        for (int i=0; i<n; ++i) {
            bl[i] = bit.sum(p[i].y);
            tl[i] = i - bl[i];
            bit.add(p[i].y, 1);
        }
    }
    vector<int> tr(n), br(n);
    {
        BIT bit(2*n);
        for (int i=n-1; i>=0; --i) {
            br[i] = bit.sum(p[i].y);
            tr[i] = (n-1-i) - br[i];
            bit.add(p[i].y, 1);
        }
    }

    vector<vector<int>> pick = {
        {1,0,0,1}, {0,1,1,0}, {1,0,1,1}, {0,1,1,1}, {1,1,0,1}, {1,1,1,0}, {1,1,1,1}
    };

    long long ans = 0;
    for (int i=0; i<n; ++i) {
        for (int j=0; j<7; ++j) {
            if (pick[j][0] && tl[i] <= 0) continue;
            if (pick[j][1] && tr[i] <= 0) continue;
            if (pick[j][2] && bl[i] <= 0) continue;
            if (pick[j][3] && br[i] <= 0) continue;
            long long c = 1;
            c *= pick[j][0] ? modpow(2, tl[i])-1 : 1; c %= mod;
            c *= pick[j][1] ? modpow(2, tr[i])-1 : 1; c %= mod;
            c *= pick[j][2] ? modpow(2, bl[i])-1 : 1; c %= mod;
            c *= pick[j][3] ? modpow(2, br[i])-1 : 1; c %= mod;
            ans += c; ans %= mod;
        }
        ans += modpow(2, n-1); ans %= mod;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9968
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
    int N,K;
    scanf("%d%d", &N,&K);
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int xi;
        scanf("%d", &xi);
        ans += 2 * min(K - xi, xi- 0);
    }

    printf("%d\n", ans);
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    int64_t m;
    int64_t a[100000];
    cin >> n >> m;
    for(int i=0;i<n;++i) cin >> a[i];

    int q = a[0] & -a[0];
    if(q == 1){ cout << "0\n"; return 0; }
    for(int i=1;i<n;++i){
        if(a[i] % q != 0 || a[i] / q % 2 != 1){
            cout << "0\n";
            return 0;
        }
    }
    int64_t x0 = a[0] / q;
    if(q / 2 * x0 > m){ cout << "0\n"; return 0; }
    for(int i=1;i<n;++i){
        x0 /= __gcd(x0, a[i] / q);
        x0 *= a[i] / q;
        if(q / 2 * x0 > m){ cout << "0\n"; return 0; }
    }
    x0 = q / 2 * x0;

    int64_t x = a[0];
    for(int i=1;i<n;++i){
        x /= __gcd(x, a[i]);
        x *= a[i];
        if(x > m){ cout << "1\n"; return 0; }
    }
    cout << 1 + (m-x0) / x << endl;

    return 0;
}

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

using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  int fours = 0, twos = 0, other = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (a % 4 == 0)
      ++fours;
    else if (a % 2 == 0)
      ++twos;
    else
      ++other;
  }
  if (twos == 0)
    if (other <= fours + 1)
      cout << "Yes\n";
    else
      cout << "No\n";
  else if (other <= fours)
    cout << "Yes\n";
  else
    cout << "No\n";
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a, b, jum, min, kali;
    scanf("%d %d", &a, &b);
    jum = a+b;
    min = a-b;
    kali = a*b;
    if(jum >= kali && jum >= min) printf("%d", jum);
    else if(kali >= jum && kali >= min) printf("%d", kali);
    else printf("%d", min);
    return 0;
}

Measured memory_bytes: 128
n,x,y = map(int,input().split())
x -= 1
y -= 1
dis = [0 for i in range(n)]
for i in range(n):
    for j in range(i+1,n):
        dis[min(abs(j-i),min(abs(j-y)+abs(x-i)+1,abs(j-x)+abs(y-i)+1))] += 1
print("\n".join(map(str,dis[1:])))

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
long long N, Q;
void DFS(vector<vector<long long>>&Tree, vector<long long>&Count, vector<bool>&reach, vector<long long>&Num, long long x) {
	reach.at(x) = true;
	for (int i = 0; i < Tree.at(x).size(); i++) {
		int to = Tree.at(x).at(i);
		if (reach.at(to)) continue;
		Num.at(to) += Num.at(x);
		DFS(Tree, Count, reach, Num, to);
	}
}
void output_line(vector<long long>& A, int N) {
	for (long long i = 1; i <= N; i++) {
		cout << A.at(i);
		if (i != A.size() - 1) cout << ' ';
	}
	cout << endl;
	return;
}
int main() {
	cin >> N >> Q;
	vector<vector<long long>>Tree(200001);
	vector<long long>Count(200001, 0);
	vector<bool>reach(200001, false);
	vector<long long>Num(200001, 0);
	pair<long long, long long>Edge;
	for (long long i = 0; i < N - 1; i++) {
		cin >> Edge.first >> Edge.second;
		Tree.at(Edge.first).push_back(Edge.second);
		Tree.at(Edge.second).push_back(Edge.first);
	}
	vector<long long>P(200001), X(200001);
	for (long long i = 0; i < Q; i++) {
		cin >> P.at(i) >> X.at(i);
		Num.at(P.at(i)) += X.at(i);
	}
	DFS(Tree, Count, reach, Num, 1);
	output_line(Num, N);
}


Measured memory_bytes: 38400
from math import ceil


def katana_thrower(N: int, H: int, AB: int)->int:
    damages = []
    for a, b in AB:
        damages.append((a, False))
        damages.append((b, True))

    count = 0
    for damage, throw in sorted(damages, key=lambda x: -x[0]):
        if H <= 0:
            break
        if throw:
            H -= damage
            count += 1
        else:
            count += ceil(H / damage)
            break
    return count


if __name__ == "__main__":
    N = 0
    N, H = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in range(N)]
    ans = katana_thrower(N, H, AB)
    print(ans)


Measured memory_bytes: 41748
#include<cstdio>
#include<algorithm>

int selectionSort(int A[], int N){
    int i, j, min_j, count=0;

    for(i=0; i<N-1; i++){
        min_j = i;
        for(j=i; j<N; j++){
            if(A[j] < A[min_j]) min_j = j;
        }
        std::swap(A[i], A[min_j]);
        if(i != min_j) count++;
    }
    return count;
}

int main(){
    int N, i, A[100], count;
    scanf("%d", &N);
    for(i=0; i<N; i++) scanf("%d", &A[i]);

    count = selectionSort(A, N);

    for(i=0; i<N; i++){
        if(i) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n", count);

    return 0;  
}


Measured memory_bytes: 2748
from collections import deque

def dfs():
    global color
    color = [-1] * n
    q = deque([])
    q.append(0)
    color[0] = 1
    
    while q:
        p = q.pop()
        for u in edge[p]:
            if color[u] == -1:
                color[u] = (color[p] + 1) % 2
                q.append(u)
            else:
                if color[u] == color[p]:
                    return False
    return True

n, m = map(int, input().split())
edge = [[] for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)


if dfs():
    B = 0
    W = 0
    for i in range(n):
        if color[i] == 1:
            B += 1
        else:
            W += 1
    print(B*W - m)
else:
    print(n * (n-1) // 2 - m)

Measured memory_bytes: 22396
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,m,q;
	int x;
	int i;
	int box[100001];
	int sum;
	cin>>n>>m>>q;
	for(i=1;i<=n;i++)	box[i]=0;
	for(i=0;i<q;i++){
		cin>>x;
		box[x]++;
	}
	for(i=1;i<=n;i++){
		sum=m-q+box[i];
		if(sum>0)	cout<<"Yes"<<endl;
		else		cout<<"No"<<endl;
	}
	return 0;
}

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		String s = nextString();
		String ans =s.replaceAll(",", " ");
		System.out.println(ans);

	}

	public static boolean isPalindromicStr(String s) {
		int h = 0;
		int t = s.length() - 1;
		while (h <= t) {
			if (s.charAt(h) != s.charAt(t)) {
				break;
			}
			h++;
			t--;
		}
		if (h > t) {
			return true;
		}
		return false;
	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

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

    string s;
    cin >> s;

    lint ans = 0;
    for(lint i=0; i<n; i++) {
        if(s.substr(i, 3) == "ABC")  ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
// head
int n,ans;
int K[100010];

int main() {
	scanf("%d",&n);
  VI v(100010);
  rep(i,0,n){cin >> v[i];
  }
  set<int> s(v.begin(), v.end());
  vector<int> va(s.begin(), s.end());
  ans = va.size()-1;
  if (ans %2 ==1){
    printf("%d",ans);
  }
  else{
	printf("%d",ans-1);
}
}


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

int main() {
 int A,B, C,D;
  cin >> A >> B >> C >> D;
  if (A+B > C+D)
    cout << "Left" <<endl;
  else if (A+B < C+D)
    cout << "Right" << endl;
  else
    cout << "Balanced" << endl;
}

Measured memory_bytes: 3540
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int order[] = new int[n + 1];
		for ( int i = 1; i <= n; i++ ) {
			order[in.nextInt()] = i;
		}
		
		for ( int i = 1; i <= n; i++ ) {
			System.out.print(order[i] + " ");
		}
		in.close();
	}
}

Measured memory_bytes: 63120
using System;
using System.Collections.Generic;
using System.Linq;

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var L = ReadArrayInt();
            Array.Sort(L);
            var cnt = 0;
            for (int i = 0; i < N - 2; i++)
            {
                for (int j = i + 1; j < N - 1; j++)
                {
                    cnt += LowerBound(L, L[i] + L[j]) - (j + 1);
                }
            }

            Console.WriteLine(cnt);
        }

        static int LowerBound(int[] arr, int val)
        {
            if (arr[0] >= val) return 0;
            if (arr[arr.Length - 1] < val) return arr.Length;

            var low = 0;
            var high = arr.Length - 1;

            while (low + 1 < high)
            {
                var mid = (low + high) / 2;
                if (arr[mid] >= val) high = mid;
                else low = mid;
            }

            return high;
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 11344