akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define lli long long
#define rep0(i,j) for(int i=0; i<j; i++)
#define rep1(i,j) for(int i=1; i<=j; i++)
#define all(a) a.begin(), a.end()
using namespace std;

void dfs(lli ed, lli num, vector<map<lli,lli>>& vec){
    lli n=1;
    for(auto e: vec[num]){
        if(n == ed)n++;
        if(e.second != -1)continue;
        vec[num][e.first] = n;
        vec[e.first][num] = n;   
        dfs(n, e.first, vec);
        n++;
    }
}

int main(){
    lli n, num=0;
    cin >> n;
    vector<map<lli,lli>> vec(n+1);
    queue<pair<lli,lli>> q;
    rep0(i,n-1){
        lli ta, tb;
        cin >> ta >> tb;
        q.push(make_pair(ta,tb));
        vec[ta][tb] = -1;
        vec[tb][ta] = -1;
    }
    rep1(i,n) num = (vec[num].size() < vec[i].size() ? i: num);

    dfs(-1, num, vec);
    cout << vec[num].size() << '\n';
    rep0(i,n-1){
        cout << vec[q.front().first][q.front().second] << '\n';
        q.pop();
    }
}

Measured memory_bytes: 19200
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		if(kaibun(s, n)) {
			if(kaibun(s.substring(0, n / 2 + 1), n / 2)) {
				String s2 = s.substring((n + 3) / 2 - 1);
				if(kaibun(s2, s2.length())){
					System.out.println("Yes");
				}
			}
		}
		sc.close();
	}

	public static boolean kaibun(String s, int n) {
		for(int i = 0; i < n / 2; i++) {
			if(s.charAt(i) != s.charAt(n - i - 1)){
				System.out.println("No");
				return false;
			}
		}
		return true;
	}
}


Measured memory_bytes: 23124
S = input()

ans = 0
N = 2**(len(S) - 1)

if len(S) == 1:
    print(S)
    exit()
for i in range(N):
    bit = bin(i)[2:]
    if len(bit) != len(S):
        bit = '0'*(len(S)-len(bit) - 1) + bit

    tmp = S[0]
#    print(bit)
    for i,b in enumerate(bit):
        if b == '0':
            tmp += S[i+1]
        else:
            ans += int(tmp)
            tmp  = S[i+1]
#            tmp += '+' + S[i+1]
    if len(tmp) > 0:
        ans += int(tmp)
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#define ll long long

int main(){
ll n;
std::cin >> n;
ll ac=0,wa=0,tle=0,re=0;
while(n--){
    std::string s;
    std::cin >> s;
    if(s=="AC")
         ac++;
    else if(s=="WA")
        wa++;
    else if(s=="TLE")
        tle++;
    else
        re++;
}
std::cout << "AC" << " x " << ac << "\n";
std::cout << "WA" << " x " << wa << "\n";
std::cout << "TLE" << " x " << tle << "\n";
std::cout << "RE" << " x " << re << "\n";
return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;

void pr(bool f){
	if(f)cout<<"Yay!"<<endl;
	else cout<<":("<<endl;
}

signed main(){
	int M,D,MM,DD;
	cin>>M>>D>>MM>>DD;
	if(D>DD){
		cout<<1<<endl;
	}else{
		cout<<0<<endl;
	}
}

Measured memory_bytes: 256
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();
    if (a-(b*2)>0) {
      System.out.println(a-(b*2));
    }else{
      System.out.println(0);
    }
  }
}


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

int main(){
  long n,m;
  cin >> n >> m;
  vector<long> a(n),b(n);
  for(int i = 0;i < n;i++){
    cin >> a.at(i);
    if(i != 0){
      b.at(i) = b.at(i-1) + a.at(i);
    }
    else{
      b.at(i) = a.at(i);
    }
  }
  map<long,long> mp;
  mp[0]++;
  for(int i = 0;i < n;i++){
    mp[b.at(i)%m]++;
    b.at(i) %= m;
  }
  sort(b.begin(), b.end());
  b.erase(unique(b.begin(), b.end()), b.end());
  long kekka = 0;
  for(int i = 0;i < b.size();i++){
    kekka += mp[b.at(i)]*(mp[b.at(i)] - 1)/2;
  }
  cout << kekka << endl;
}

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

int dp[100005][3];

struct abc{
  int a,b,c;
};

int solve(struct abc ar[],int n){
//base case
 dp[1][0]=ar[1].a;
 dp[1][1]=ar[1].b; 
 dp[1][2]=ar[1].c; 
for(int i=2;i<=n;i++){
  dp[i][0]=ar[i].a+max(dp[i-1][1],dp[i-1][2]);
  dp[i][1]=ar[i].b+max(dp[i-1][0],dp[i-1][2]);
  dp[i][2]=ar[i].c+max(dp[i-1][0],dp[i-1][1]);
  //cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
 }
  int ans= max(dp[n][0],max(dp[n][1],dp[n][2]));
  return ans;
}
int main(){
   memset(dp, 0, sizeof(dp)); 
  int n;
  cin>>n;
  struct abc ar[n+1];
  for(int i=1;i<=n;i++)
    cin>>ar[i].a>>ar[i].b>>ar[i].c;

  cout<<solve(ar,n);

  return 0;
  
}


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

typedef long long LL;

const int M = 2e5, N = 4e3, MOD = 1e9 + 7, I2 = (MOD + 1) >> 1;

int n, a[M + 5], b[M + 5], fac[N + N + 5], ifac[N + N + 5], pool[N + 5][N + 5], *g[N + 5], **f;

inline int add(const int &x) {
	return x >= MOD ? x - MOD : x;
}
inline void add(int &x, const int &y) {
	(x += y) >= MOD && (x -= MOD);
}
inline void sub(int &x, const int &y) {
	(x -= y) < 0 && (x += MOD);
}
inline int binom(int n, int m) {
	return (LL)fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;
}
inline int pow(int x, int k) {
	int ans = 1;
	for (; k > 0; k >>= 1, x = (LL)x * x % MOD) {
		if (k & 1) {
			ans = (LL)ans * x % MOD;
		}
	}
	return ans;
}
inline int inv(int x) {
	return pow(x, MOD - 2);
}
void init(int n) {
	fac[0] = 1;
	for (int i = 1; i <= n; i++) {
		fac[i] = (LL)fac[i - 1] * i % MOD;
	}
	ifac[n] = inv(fac[n]);
	for (int i = n; i >= 1; i--) {
		ifac[i - 1] = (LL)ifac[i] * i % MOD;
	}
}
int main() {
	init(N + N);
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", &a[i], &b[i]);
	}
	int maxA = *std::max_element(a + 1, a + n + 1);
	int maxB = *std::max_element(b + 1, b + n + 1);
	for (int i = 0; i <= N + 1; i++) {
		g[i] = &pool[i][2001];
	}
	f = &g[2001];
	for (int i = 1; i <= n; i++) {
		f[-a[i]][-b[i]]++;
	}
	for (int i = -maxA; i <= maxA; i++) {
		for (int j = -maxB; j <= maxB; j++) {
			add(f[i][j], add(f[i - 1][j] + f[i][j - 1]));
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		add(ans, f[a[i]][b[i]]);
		sub(ans, binom((a[i] + b[i]) << 1, a[i] << 1));
	}
	printf("%lld\n", (LL)ans * I2 % MOD);
	return 0;
}

Measured memory_bytes: 67924
r,c = gets.split.map!(&:to_i)

res = String.new
raw_sum = Array.new(c+1,0)

r.times do
  line = gets.split.map!(&:to_i)
  i = 0
  line << line.inject(0) {|col_sum, element|
    raw_sum[i]+=element
    i += 1
    col_sum + element}
  raw_sum[c] += line[c]
  res += line.map(&:to_s).join(' ')+"\n"
end
print res
puts raw_sum.map(&:to_s).join(' ')



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

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

    if (n == 1 || m == 1)
        cout << 1;
    else if (!(n&1) || !(m&1))
        cout << n * m / 2;
    else
        cout << n * m / 2 + 1;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	string S;
	cin >> S;

	string alp = "abcdefghijklmnopqrstuvwxyz";

	if (S.length() < 26) {
		for (int i = 0; i < alp.length(); i++) {
			if (S.find(alp.substr(i, 1)) == string::npos) {
				S += alp.substr(i, 1);
				break;
			}
		}
		cout << S << endl;
	}
	else {
		reverse(S.begin(), S.end());

		if (S == alp) {
			cout << -1 << endl;
		}
		else {
			size_t ii = 0;
			size_t pos = alp.find(S.substr(ii, 1), 0);

			while (pos != string::npos) {
				ii += 1;
				pos = alp.find(S.substr(ii, 1), pos);
			}

			string str = S.substr(ii, 1);

			for (size_t i = 0; i < ii; i++) {
				if (S.substr(i, 1) > str) {
					str = S.substr(i, 1);
					break;
				}
			}

			string ans = str + S.substr(ii + 1);

			reverse(ans.begin(), ans.end());

			cout << ans << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3620
s = input()
k = int(input())

x = set()
n = len(s)

for i in range(k):
    for j in range(n-i):
        t = s[j:j+i+1]
        if not t in x:
            x.add(t)
x = list(x)
x.sort()
print(x[k-1])

Measured memory_bytes: 4464
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <class T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
void co() { cout << endl; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << endl; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18L+1;
constexpr ll MOD = 1e9L+7;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void){
    ll n;
    cin >> n;
    Vec a(n);
    rep(i, n) cin >> a[i];

    ll ans = 0, h = 0;
    rep(i, n){
        if (h > a[i]) ans += h - a[i];
        chmax(h, a[i]);
    }
    co(ans);

    return 0;
}


Measured memory_bytes: 4752
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

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

Measured memory_bytes: 3620
a,b = map(int,raw_input().split())

if((a<0 and b>0) or a==0 or b==0):
    print("Zero")
elif(a>0):
    print("Positive")
else:
    if((((a-b)*-1)+1)%2==1):
        print("Negative")
    else:
        print("Positive")


Measured memory_bytes: 2568
require 'prime'
c = Array.new(10**5+2, 0)
3.step(10**5, 2) do |i|
  if i.prime? && ((i + 1) / 2).prime?
    c[i] += 1
  end
end
3.upto(10**5) do |i|
  c[i] += c[i-1]
end
N = gets.to_i
while line = gets
  l, r = line.chomp.split.map(&:to_i)
  p c[r] - c[l - 1]
end

Measured memory_bytes: 3836
//人正是因为度过了一段阴暗岁月，才会更渴求黎明的曙光
//青春不能回头。所以青春也没有终点。
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <memory.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

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

const int MAXN = 110;
int dp[MAXN][MAXN];
char c[MAXN][MAXN];

int main(void) {
	int N,M;
	cin >> N >> M;
	REP(i,N) cin >> c[i];
	dp[0][0] = c[0][0]=='#';
    for (int i=1; i<M; i++) dp[0][i] = dp[0][i-1]+(c[0][i-1]=='.' && c[0][i]=='#');
    for (int i=1; i<N; i++) dp[i][0] = dp[i-1][0]+(c[i-1][0]=='.'&&c[i][0]=='#');
    for (int i=1; i<N; i++) for (int j=1; j<M; j++) dp[i][j] = min(dp[i-1][j]+(c[i-1][j]=='.'&&c[i][j]=='#'), dp[i][j-1]+(c[i][j - 1]=='.'&&c[i][j]=='#'));
	cout << dp[N-1][M-1] << endl;
	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
#define pb push_back
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::set<int> si;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N,A,B;
int main(){
  cin>>N>>A>>B;
  if((B-A)%2==0) prin("Alice");
  else prin("Borys");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp  make_pair
#define pb  push_back
void c_p_c(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void solve(){
    int x;
    cin>>x;
    if(x>=30){
        cout<<"Yes"<<endl;
        return;
    }
    else{
        cout<<"No"<<endl;
        return;
    }
}
int32_t main(){
    c_p_c();
    int t;
    t=1;
    //cin>>t;
    while(t--){
       solve(); 
    }
	return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<string>
using namespace std;
int main()
{
  long long int n;cin>>n;
  long long int a[n];
  cin>>a[0];
  long long int ans=0;
  for(long long int i=1;i<n;i++)
  {
      cin>>a[i];
  }
  long long int maxn=0;
  for(int i=0;i<n;i++)
  {
      maxn=max(maxn , a[i]);
      ans=ans+(maxn-a[i]);
  }
  cout<<ans;
}


Measured memory_bytes: 4724
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
using System.IO.Pipes;

class Program
{
    static char[] abc = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
    static long mod = 1000000007;
    static void Main(string[] args)
    {
        //var S = Console.ReadLine();
        //var A = long.Parse(Console.ReadLine());
        var NCK = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var N = NCK[0];
        var C = NCK[1];
        var K = NCK[2];

        var T = new long[N];
        for (int i = 0; i < N; i++)
        {
            T[i] = long.Parse(Console.ReadLine());
        }
        Array.Sort(T);

        var now = 0;
        long ans = 0 ;
        while(now < N)
        {
            ans++;
            var first = T[now];
            for (int i = 0; i < C && now < N; i++)
            {
                if (first+K < T[now])
                {
                    break;
                }
                now++;
            }
        }

        Console.WriteLine(ans);
        
    }



}


Measured memory_bytes: 32928
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main(){
	string S;
	cin>>S;
	int len=S.length();
	char c_pre1,c_now1,c_pre2,c_now2;
	int count1=0,count2=1;
	c_pre1=S[0];
	if(S[0]=='1')c_pre2='0';
	else c_pre2='1';
	for(int i=1;i<len;i++){
		c_now1=S[i];
		c_now2=S[i];
		if(c_pre1=='0'){
			if(c_now1=='1')c_pre1='1';
			else{
				count1++;
				c_pre1='1';
			}
		}else{
			if(c_now1=='0')c_pre1='0';
			else{
				count1++;
				c_pre1='0';
			}
		}
		if(c_pre2=='0'){
			if(c_now2=='1')c_pre2='1';
			else{
				count2++;
				c_pre2='1';
			}
		}else{
			if(c_now2=='0')c_pre2='0';
			else{
				count2++;
				c_pre2='0';
			}
		}
	}
	if(count1<=count2)cout<<count1<<endl;
	else cout<<count2<<endl;
	return 0;
}

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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define  endl 			"\n"
#define  FOR(i, a, n)   for (ll i = a; i < n; i++)
#define  ROF(i, a, n)   for (ll i = a; i >= n; i--)
#define  all(x)         (x).begin(), (x).end()
#define  mset(x, val)   memset(x,val,sizeof(x))
#define  dline          cout<<"///REACHED///\n";

typedef long long ll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  4e+5+7;



// void solve(){
// 	ll n,m,k,ans=0;
// 	cin>>n>>m>>k;
// 	if(m>n/k){
// 		ll p1 =n/k;
// 		ll remjokers=m-n/k;
// 		if(remjokers > k-1){
// 			ans=remjokers/(k-1);
// 		}
// 		else{
// 			cout<<abs(p1-1)<<endl;
// 			return;
// 		}
// 		cout<<abs(p1-(ans+ans*(k-1)))<<endl;
// 		return;
// 	}
// 	if(m<n/k){
// 		cout<<m<<endl;
// 		return;
// 	}


// }

vector<ll> arr;
ll n;

void solve(){
	ll n;
	cin>>n;
	vector<ll> arr(n);
	ll sum=0;
	for(ll&x:arr)cin>>x;
	sum = accumulate(all(arr),0);
	sum-=n;
	cout << sum << endl;
}


int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	solve();
	return 0;
}

// 2*3*5 29

// 59
// 2, 3, 4, 5 --> 1+2+

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
 
string S;
 
int main(void) {
  cin >> S;
 
  ll l = 0, r = S.length() - 1;
  ll ans = 0;
  while(1) {
    if(l >= r) break;
    if(S[l] == S[r]) {
      l++;
      r--;
      continue;
    }
    if(S[l] != 'x' && S[r] != 'x') {
      cout << -1 << endl;
      return 0;
    }
    if(S[l] == 'x' && S[r] != 'x') {
      l++;
      ans++;
    }
    if(S[l] != 'x' && S[r] == 'x') {
      r--;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <ctype.h>
 
int main(void)
{
  int len,i;
  char m;
 
  while((m=getchar())!=EOF){
 
    if(isupper(m)){
        printf("%c",tolower(m));
      }
    else {
        printf("%c",toupper(m));
      }
  }
       
  return 0;
}

Measured memory_bytes: 2468
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define abs(a) ((a) > 0 ? (a) : -(a))
int main()
{
    int n;
    long long s = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
        a[i] = a[i] - (i+1);
    }
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    sort(a.begin(), a.end());
    int k1 = a[(n & 1 ? n/2 : n/2-1)], k2 = a[n/2], b = (k1 + k2) / 2;
    for(int i = 0; i < n; i++){
        s += abs(a[i] - b);
    }
    cout << s << endl;
    return 0;
}

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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i) for(i=0;i<n;++i)
#define fa(x,y) for(auto x:y)

//Warsaw debug template
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template        
    

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x;
    cin>>x;
    if(x%2==0) cout<<x;
    else cout<<2*x;
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 3e5 + 5 ; 
const int P = 1e9 + 7 ; 
int n, a[100 + 5][2], Ans, Iv ; 
int fpow( int x, int k ) {
	int ans = 1ll, base = x ;
	while( k ) {
		if( k & 1ll ) ans = ans * base % P ;
		k >>= 1, base *= base, base %= P ; 
	}
	return ans ; 
}
void Init( int x ) {
	for( re int i = 0; i <= 60; ++ i ) {
		int k = 1ll << i ; 
		if( k & x ) Ans = ( Ans + ( k % P * a[i][0] ) % P ) % P, ++ a[i][1] ; 
		else Ans = ( Ans + ( k % P * a[i][1] ) % P ) % P, ++ a[i][0] ; 
	}
}
signed main()
{
	n = gi() ; int x ; 
	rep( i, 1, n ) x = gi(), Init(x) ; 
	printf("%lld\n", Ans % P ) ; 
	return 0 ;
}


Measured memory_bytes: 256
/*
the top of the losers
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))
#define    X            real()
#define    Y            imag()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     point        complex<ll>
#define    cp(a,b)          (((conj(a))*(b)).imag())
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
string st;
int main(){
    GO();
    int n;
    cin>>n>>st;
    ll cnt=0;
    for(int i=0;i<n;i++){
        if(i+1<n&&st[i]==st[i+1])
            ;
        else{
            cnt++;
        }
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 512
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

N = read_a_int()
A = read_ints()

# どの数字を一番多くできるか
n_X = [0] * (10 ** 5 + 2)  # =Xにできる個数

for a in A:
    for da in [-1, 0, 1]:
        n_X[a + da + 1] += 1
print(max(n_X))
# https://atcoder.jp/contests/abc072/tasks/arc082_a


Measured memory_bytes: 52752
n, k = map(int, input().split())
dislike = [str(i) for i in input().split()]
strn = str(n)

while(1):
  flag = 1
  for i in range(len(strn)):
    if strn[i] in dislike:
      flag = 0
  if flag == 1:
    print(n)
    break
  else:
    n += 1
    strn = str(n)

Measured memory_bytes: 3060
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
constexpr ll MOD = 1e9 + 7;

vector<vector<vector<ll>>> dp;

ll rec(const string& s, const ll D, int k = 0, bool tight = true, ll odd = 0) {
	if (k == s.size())return odd == 0;

	ll x = s[k] - '0';
	ll r = tight ? x : 9;
	ll& res = dp[k][tight][odd];
	if (res != -1)return res;
	res = 0;

	rep(d, r + 1) {
		(res += rec(s, D, k + 1, tight && (d == r), (odd + d) % D)) %= MOD;
	}
	return res;
}

int main()
{
	string K;
	ll D;
	cin >> K >> D;
	dp.resize(K.size() + 2, vector<vector<ll>>(2, vector<ll>(D, -1)));
	cout << (rec(K, D) - 1 + MOD) % MOD << endl;
	return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  cout << max({a + b, a - b, a * b});
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i).sort

tmp = a[-1] / 2.0
idx = a.bsearch_index { |i| i > tmp }

print a[-1]
puts tmp - a[idx - 1] <= a[idx] - tmp ? " #{a[idx - 1]}" : " #{a[idx]}"

Measured memory_bytes: 10112
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;


namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());

            long m = long.MaxValue;
            for (int i = 0; i < 5; i++)
            {
                m = Math.Min(m, long.Parse(Console.ReadLine()));
            }

            long ans = (N + m - 1) / m;
            ans += 4;

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
  vector<Pl> c(N);
  rep(i,N) c[i] = {-B[i], A[i]};
  sort(ALL(c));
  set<ll> st;
  rep(i,M) st.insert(-i);
  ll ans = 0;
  rep(i,N){
    ll a, b;
    a = c[i].second;
    b = -c[i].first;
    auto itr = st.lower_bound(a-M);
    if(itr==st.end()){
      continue;
    }
    ans += b;
    st.erase(itr);
  }
  cout << ans << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> A(N);
  std::vector<long long> B(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
    scanf("%lld",&B[i]);
  }
  solve(N, M, std::move(A), std::move(B));
  return 0;
}


Measured memory_bytes: 8064
x, y, z, k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)

ans = []
for ai in range(len(a)):
    for bi in range(len(b)):
        if (ai+1)*(bi+1) > k:
            break
        for ci in range(len(c)):
            if (ai+1)*(bi+1)*(ci+1) >k:
                break
            ans.append(a[ai] + b[bi] +c[ci])

ans = sorted(ans, reverse=True)
for i in range(k):
    print(ans[i])

Measured memory_bytes: 9564
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#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=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int h[100010];
int dp[100010];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	rep(i, n)cin >> h[i];
	rep(i, 100010)dp[i] = INF;
	dp[0] = 0;
	rep(i, n) {
		chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
		chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1792
l,a,b,m = map(int,input().split())

ten = 1
def f(x):

    if x == 0:
        return 0
    if x % 2 == 1:
        t = x-1
        x = f(t)
        return x*ten+1
    else:
        t = x//2
        x = f(t)
        return x*pow(ten,t,m) + x

def g(x):

    if x == 0:
        return 0
    if x % 2 == 1:
        t = x-1
        x = g(t)
        return x*ten + b*(t)
    else:
        t = x//2
        x = g(t)
        return x*pow(ten,t,m) + x + b*(t)*f(t)
last = a+b*(l-1)

ans = 0
for i in range(1,20):
    le = ten
    r = ten*10-1
    
    ten *= 10
    if last < le or a > r:
        continue
    if le < a:
        na = a
    else:
        na = (le-a+b-1)//b*b+a
    if last <= r:
        nl = last
    else:
        nl = (r-a)//b*b+a
    n = (nl-na)//b+1
    
    ans *= pow(ten,n,m)
    ans += ((f(n)%m)*na)%m
    ans += g(n)%m
    ans %= m

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string O,E;
    cin >> O >> E;
    if(O.size() == E.size()){
        for(int i = 0; i < E.size(); i++){
            cout << O[i] << E[i];
        }
        cout << endl;
    }
    else{
        for(int i = 0; i < E.size(); i++){
            cout << O[i] << E[i];
        }
        cout << O[O.size()-1] << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  int a,b,c; cin >> a >> b >> c;
  if(a == b)cout << c << endl;
  else if(b == c)cout << a << endl;
  else cout << b << endl;
  system("pause");
}

Measured memory_bytes: 504
import sys
input = sys.stdin.readline
import numpy as np

n = int(input())
A = [int(a) for a in input().split()]
mul = 1
top = 1000000000000000000
if 0 in A:
    print(0)

else:
    for a in A:
        mul *= a
        if mul > top:
            mul =-1
            break
    print(mul)


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

int main() {
  int N;
  cin >> N;
  int p[N];
  
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  
  sort(p, p+N);
  
  int ans = 0;
  
  for (int i = 0; i < N-1; i++) {
    ans += p[i];
  }
  ans += p[N-1] / 2;
  
  cout << ans << endl;
  
}

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

int main() {

string S;
  cin >>S;
  int N,cN;
  int J1,J2,J3;//判定結果
  J1=1;J2=1;J3=1;//1なら条件を満してる
  
  N=S.size();

    for (int i = 0; i < N/2; i++) {
      
      if (S.at(i) != S.at(N-1-i)) {
        J1=0;  
         break; // 回文でない時点でループから抜ける
      }
 
    }
  
    //条件２
       
    for (int i = 0; i < N/4; i++) {
      
      if (S.at(i) != S.at(N-1-i)) {
        J2=0;  
         break; // 回文でない時点でループから抜ける
       }
 
    }
  
      //条件３
       
    for (int i = 0; i < N/4; i++) {
      
      if (S.at(i+1+N/2) != S.at(N-1-i)) {
        J3=0;  
         break; // 回文でない時点でループから抜ける
       }
 
    }
    
  if ( J1*J2*J3 == 1){
    cout<<"Yes"<<endl;}
    else {cout<<"No"<<endl;}
  
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
    	new B().doIt();
    }
    class B{
    	void doIt(){
    		long N = sc.nextLong();
    		long X = sc.nextLong();
    		long XX = X * 2;
    		if(N - XX < 0)X = N - X;
    		long NN = N - X;
//    		System.out.println(NN+" "+X);
    		if(X == 0){
    			X = NN;
    			NN = 0;
    		}
    		long sum = X + NN;
    		while(true){
//    			System.out.println(NN+" "+X);
    			if(NN % X == 0)break;
    			long cnt = (NN / X)*2;
    			sum = sum + cnt * X;
    			long temp = X;
    			X = NN % X;
    			NN = temp;
    		}
    		long cnt = (NN / X)*2 - 1;
    		sum = sum + cnt * X;
    		System.out.println(sum);
    	}
    }
}

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

#define N 1010
int p[N];

int main(){
    int n, k;
    cin>>n>>k;
    for(int i = 1; i <= n; i++){
        cin>>p[i];
    }
    sort(p + 1, p + 1 + n);
    int ans = 0;
    for(int i = 1; i <= k; i++) ans += p[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
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;}
int nxt() {int x;scanf("%d", &x);return x;}


// Union-Find Disjoint Sets Library written in OOP manner, using both path compression and union by rank heuristics
class UnionFind {                                              // OOP style
private:
  VI p, rank, setSize;                       // remember: vi is vector<int>
  int numSets;
public:
  UnionFind(int N) {
    setSize.assign(N, 1); numSets = N; rank.assign(N, 0);
    p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i; }
  int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
  bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
  void unionSet(int i, int j) { 
    if (!isSameSet(i, j)) { numSets--; 
    int x = findSet(i), y = findSet(j);
    // rank is used to keep the tree short
    if (rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
    else                   { p[x] = y; setSize[y] += setSize[x];
                             if (rank[x] == rank[y]) rank[y]++; } } }
  int numDisjointSets() { return numSets; }
  int sizeOfSet(int i) { return setSize[findSet(i)]; }
};


int main(){
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    VVI fri(n, VI()), ene(n, VI());
    REP(i, m){
        int a = nxt(), b = nxt();
        a--;b--;
        uf.unionSet(a, b);
        fri[a].push_back(b);
        fri[b].push_back(a);
    }
    REP(i, k){
        int a = nxt(), b = nxt();
        a--;b--;
        ene[a].push_back(b);
        ene[b].push_back(a);
    }
    REP(i, n){
        int ans = uf.sizeOfSet(i) - fri[i].size() - 1;
        for(int v : ene[i]) if(uf.isSameSet(i, v)) ans--;
        printf("%d ", ans);
    }
    return 0;
}



Measured memory_bytes: 13048
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define PRN(n) printf("%d\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c\n",c)
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  PRN((a>=b)*10);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
    #include <iostream>
    using namespace std;
     
    int main() {
      int N;
      cin >> N;
      int total = 0;
      int temp = N;
      while (temp != 0) {
        total += temp % 10;
        temp /= 10;
      }
      if (N % total == 0)
        cout << "Yes" << endl;
      else
        cout << "No" << endl;
      return 0;
    }

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

const int N=1e5+100;
int n,a[N];
char op[N];
LL f[N][3];

void cmax(LL &x,LL y) {x=x>y?x:y;}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]); op[i]='!';
		if(i == n) break;
		while(op[i] != '+' && op[i] != '-') op[i]=getchar();
	}
	memset(f,0xcf,sizeof(f)); f[1][0]=a[1];
	for(int i=1;i<n;++i)
	{
		if(op[i] == '-') cmax(f[i+1][1],f[i][0]-a[i+1]);
		if(op[i] == '+') cmax(f[i+1][0],f[i][0]+a[i+1]);
		if(op[i] == '-') cmax(f[i+1][0],f[i][0]-a[i+1]);
		
		if(op[i] == '+') cmax(f[i+1][1],f[i][1]-a[i+1]);
		if(op[i] == '-') cmax(f[i+1][1],f[i][1]+a[i+1]);
		//if(op[i] == '-') cmax(f[i+1][1],f[i][1]-a[i+1]);
		if(op[i] == '-') cmax(f[i+1][2],f[i][1]+a[i+1]);
		if(op[i] == '+') cmax(f[i+1][0],f[i][1]+a[i+1]);
		if(op[i] == '-') cmax(f[i+1][0],f[i][1]-a[i+1]);
		
		if(op[i] == '+') cmax(f[i+1][2],f[i][2]+a[i+1]);
		//if(op[i] == '-') cmax(f[i+1][2],f[i][2]-a[i+1]);
		if(op[i] == '-') cmax(f[i+1][2],f[i][2]+a[i+1]);
		if(op[i] == '+') cmax(f[i+1][0],f[i][2]+a[i+1]);
		if(op[i] == '-') cmax(f[i+1][0],f[i][2]-a[i+1]);
		if(op[i] == '-') cmax(f[i+1][1],f[i][2]-a[i+1]);
	}
	printf("%lld",max(f[n][0],max(f[n][1],f[n][2])));
	return 0;
}

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

int main(){
	int r, g, b;
	cin >> r >> g >> b;
	if((g*10+b) % 4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 256
s=gets
a=s[0,2].to_i
b=s[2,2].to_i
yymm=1<=b && b<=12
mmyy=1<=a && a<=12
if yymm && mmyy
    puts 'AMBIGUOUS'
elsif yymm
    puts 'YYMM'
elsif mmyy
    puts 'MMYY'
else
    puts 'NA'
end


Measured memory_bytes: 1788
/*input
271828182845904523
314159265358979323
*/
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N
#define bit(x,y) ((x>>y)&1LL)
#define na(x) (#x) << ":" << x
ostream& operator << (ostream &os, vector<int>&x) {
	for (int i = 0; i < x.size(); i++) os << x[i] << sp;
	return os;
}
ostream& operator << (ostream &os, pair<int, int> x) {
	cout << x.fi << sp << x.se << sp;
	return os;
}
ostream& operator << (ostream &os, vector<pair<int, int> >&x) {
	for (int i = 0; i < x.size(); i++) os << x[i] << endl;
	return os;
}

#define pow binPow
long long binPow(long long a, long long q) {
	long long ret = 1;
	for (int i = 0; (1LL << i) <= q; i++) {
		if (q & (1LL << i)) ret = (ret * a);
		a = (a * a);
	}
	return ret;
}

int L, R;
pair<int, int> a[3];
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> L >> R;
	if (L == R) {
		cout << 1 << endl;
		return 0;
	}
	int diff = 0;
	for (int i = 61; i >= 0; i--) {
		if (bit(L, i) != bit(R, i)) {
			diff = i;
			break;
		}
		if (bit(L, i) && bit(R, i)) {
			L -= (1LL << i); R -= (1LL << i);
		}
	}
	a[0].fi = L; a[0].se = binPow(2, diff) - 1;
	a[1].fi = (1LL << diff); a[1].se = a[1].fi;
	for (int i = diff - 1; i >= 0; i--) {
		if (bit(R, i)) {
			a[1].se += (1LL << (i + 1)) - 1;
			break;
		}
	}
	a[2].fi = (1LL << diff) + a[0].fi;
	a[2].se = (1LL << (diff + 1)) - 1;
	int ans = 0;
	for (int mask = 1; mask < (1 << 3); mask++) {
		int Rx = 9e18, Lx = -9e18;
		for (int j = 0; j < 3; j++) {
			if (bit(mask, j)) {
				Rx = min(Rx, a[j].se);
				Lx = max(Lx, a[j].fi);
			}
		}
		if (__builtin_popcount(mask) % 2 == 1)
			ans += max(0LL, Rx - Lx + 1);
		else
			ans -= max(0LL, Rx - Lx + 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict

class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
    
  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
        return

    if self.parents[x] > self.parents[y]:
        x, y = y, x

    self.parents[x] += self.parents[y]
    self.parents[y] = x

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m, k = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(m)]
CD = [list(map(int, input().split())) for _ in range(k)]

uf = UnionFind(n)
fre = [0] * n
for a, b in AB:
  fre[a - 1] += 1
  fre[b - 1] += 1
  uf.union(a - 1, b - 1)

blo = [0] * n
for c, d in CD:
  if uf.same(c - 1, d - 1):
    blo[c - 1] += 1
    blo[d - 1] += 1

rs = uf.roots()
cnt = {r: uf.size(r) for r in rs}

ans = []
for i in range(n):
    r = uf.find(i)
    ans.append(cnt[r] - fre[i] - blo[i] - 1)
print(*ans)


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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

string S, l ,r, res;
int N, k, ok, ng, mid;

void solve(){
    rep(i, k){
        mid = (ok + ng)/ 2;
        cout << mid << endl;
        cin >> res;
        if(res == "Vacant") exit(1);

        if(mid%2==0)(res==l ? ok : ng)=mid;
        else (res==r ? ok : ng)=mid;
        
    }
}

int main(){
    cin >> N;
    k = 20;

    // 半開区間で管理
    ok = 0, ng = N;

    cout << 0 << endl;
    cin >> l;
    if(l == "Vacant") exit(1);

    cout << N-1 << endl;
    cin >> r;
    if(r == "Vacant") exit(1);

    k -= 2;

    solve();
}


Measured memory_bytes: 852
#include<stdio.h>

 int B(int n,int S[],int key){
      int i,right,left,mid;
      left=0;
      right=n;
      while(left<right){
             mid=(left+right)/2;
             if(S[mid]==key)return 1;
             else if(key<S[mid])right=mid;
             else left=mid+1;
             }
      return 0;
      }
 
 
 int main(){
      int i,j,n,q,S[100000],T,count=0,key;
      scanf("%d",&n);
      for(i=0;i<n;i++){
            scanf("%d",&S[i]);
            }
      scanf("%d",&q);
      for(i=0;i<q;i++){
            scanf("%d",&T);
            key=B(n,S,T);
            if(key!=0)count++;
            }
      printf("%d\n",count);
      return 0;
      }


Measured memory_bytes: 2092
nmxy=list(map(int,input().split()))
x=list(map(int,input().split()))
y=list(map(int,input().split()))
xm=0
ym=0
if max(x)>nmxy[2]:
    xm=max(x)
else:
    xm=nmxy[2]
if min(y)<nmxy[3]:
    ym=min(y)
else:
    ym=nmxy[3]
if ym<=xm:
    print('War')
else:
    print('No War')


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)
int main(){
    int n,a,b;
    int sum=0;
    cin >> n >> a; 
    vector<int> v(a);
    rep(i,a){
      cin >> b;
      sum+=b;
    }
    if (sum >= n) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 640