akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define line                    cout << "\n===================\n"

int main ()
{
    //freopen ("input.txt", "r", stdin);
    //freopen ("output.txt", "w", stdout);
    //fastRead;
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22){
		cout << "bust\n";
	}
	else{
		cout << "win\n";
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

ll f(ll K, ll A, ll B, ll mid) {
    ll rem = K - mid;
    ll yen = 1+mid;
    if(yen >= A && B >= A)  {
      yen += (rem / 2LL) * (B - A);
    }
    return yen;
}

int main() {
  map<ll, ll> rec;
  ll K, A, B; cin>>K>>A>>B;
  ll low = 0, high = K;
  ll ans = 0;
  while(low + 100LL <= high) {
    ll mid1 = (low * 2LL + high * 1LL) / 3LL;
    ll mid2 = (low * 1LL + high * 2LL) / 3LL;
    ll v1 = f(K, A, B, mid1), v2	= f(K, A, B, mid2);
    if(v1 > v2) high = mid2;
    else low = mid1;
  }

  for(ll mid = low; mid <= high; mid++) {
    ll yen = f(K, A, B,	mid);
    ans = max(ans, yen);
    //    cout << mid << " " << yen << " " << ans << endl;                             
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = input()
res = 0
k = ''
log = []
for i in range(N):
  t = T[i]
  if t == 'r':
    if K <= i and log[i-K] == 'p':
      log.append('x')
    else:
      res += P
      log.append('p')
  elif t == 's':
    if K <= i and log[i-K] == 'r':
      log.append('x')
    else:
      res += R
      log.append('r')
  else:
    if K <= i and log[i-K] == 's':
      log.append('x')
    else:
      res += S
      log.append('s')

print(res)


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

namespace CSharpSample01
{

	class Program
	{

		static void Main(string[] args)
		{
			var N = int.Parse(Console.ReadLine());
			var answer = 0;

			for (int x = 1; x <= N; x++)
			{
				for(int y = 1; y <= N; y++)
				{
					for (int z = 1; z <= N; z++)
					{
						answer += GcdController(x, y, z);
					}
				}
			}

			Console.WriteLine(answer);
		}

//		private static Dictionary<string,int> dicAnswer = new Dictionary<string,int>();

		public static int GcdController(int a,int b,int c)
		{
			var d = Gcd(a, b);			
			return Gcd(c,d);
		}

		// ユークリッドの互除法 
		public static int Gcd(int a, int b)
		{
			if (a < b)
				// 引数を入替えて自分を呼び出す
				return Gcd(b, a);

		//	var answer = 0;
	//		var key = $"{a},{b}";

/*			if (dicAnswer.TryGetValue(key,out answer))
			{
				return answer;
			}
*/
			while (b != 0)
			{
				var remainder = a % b;
				a = b;
				b = remainder;
			}
//			dicAnswer.Add(key, a);
			return a;
		}


	}
}

Measured memory_bytes: 27540
n, t = map(int, input().split())
listT=list(map(int, input().split()))

index=1
sum=0
while index < len(listT):
    if listT[index] - listT[index-1]<t:
        sum += listT[index] - listT[index-1]
    else:
        sum+=t
    index+=1
sum+=t

print(sum)

Measured memory_bytes: 25200
#include <iostream>
#include <set>
using namespace std;
int collatz(int x){
    if(x%2 == 0) return x/2;
    else return 3*x+1;
}
int main(){
    int s; cin >> s;
    set<int> st;
    int ans = 1;
    while(1){
        st.insert(s);
        s = collatz(s);
        ans++;
        if(st.count(s) == 1) {
            cout << ans << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
//const int mod=1e9+7;
//int Pow(int x,int y){
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
void ckmax(int &x,int y){
	if (x<y)
		x=y;
}
void ckmin(int &x,int y){
	if (x>y)
		x=y;
}
int main(){
	LL A=read(),V=read();
	LL B=read(),W=read();
	LL T=read();
	LL dis=abs(A-B);
	LL dv=V-W;
	puts(dv*T>=dis?"YES":"NO");
	return 0;
}

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

int main() {
  int N,i=0;
  cin >> N;
  for(; i<N; i++){
    string S;
    cin >> S;
    if(S=="Y")
      break;
  }
  if(i==N)
    cout << "Three" << endl;
  else
    cout << "Four" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------------------

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

  int ans=0;
  REP(i,1,n+1){
    string s=to_string(i);
    if(s.size()%2==1){
      ans++;
    }
  }

  prt(ans);

}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
vi hoge;
int N;
vector<ll> water;
ll ans[114514];
int main(){
	cin>>N;
	ll sum=0;
	rep(i,N){
		ll x;
		cin>>x;
		water.pb(2*x);
		sum+=x;
	}
	rep(i,N/2){
		sum-=water[i*2];
		//cout<<sum<<endl;
	}
	ans[N-1]=sum;
	for(int i=N-2;i>=0;i--){
		ans[i]=water[i]-ans[i+1];
	}
	rep(i,N)cout<<ans[i]<<" ";
	cout<<endl;
}


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <iomanip>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

int main() {

    int N;
    cin >> N;
    vint num(N);
    vint As(N);
    vint Bs(N);

    rep(i, N) {
        num[i] = i + 1;
        cin >> As[i];
    }

    rep(i, N) {
        cin >> Bs[i];
    }

    int counter = 0;
    bool flag = false;
    if (As == Bs) {
        cout << 0 << endl;
        return 0;
    }
    do {
        if (flag && (As == num || Bs == num)) {
            cout << counter << endl;
            return 0;
        }

        if (!flag && (As == num || Bs == num)) {
            flag = true;
        }
        

        if (flag) {
            counter++;
        }
    } while (next_permutation(num.begin(), num.end()));
    
}

Measured memory_bytes: 256
from numba import njit

@njit
def func(N):
  dp = [1 for _ in range(N+1)]
  for i in range(2,N+1):
    for j in range(i, N+1, i):
      dp[j] += 1
  ans = 0
  for i in range(1, N+1):
    ans += i*dp[i]
  return ans

N = int(input())
ans = func(N)
print(ans)


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

int main() {
  int N, M;
  cin >> N >> M;
  vector V(N, vector(3, 0L));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> V.at(i).at(j);
    }
  }
  long ans = 0;
  for (int bit = 0; bit < 1 << 3; bit++) {
    vector sum(N, 0L);
    for (int i = 0; i < N; i++) {
      vector tmp = V.at(i);
      for (int j = 0; j < 3; j++) {
        if (bit >> j & 1) {
          tmp.at(j) *= -1;
        }
      }
      sum.at(i) = accumulate(tmp.begin(), tmp.end(), 0L);
    }
    sort(sum.rbegin(), sum.rend());
    ans = max(ans, accumulate(sum.begin(), sum.begin() + M, 0L));
  }
  cout << ans << "\n";
}

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

using namespace std;

typedef long long ll;

int main(){
  int a, b, x;
  double z = 0.0;
  cin >> a >> b >> x;
  if (a*a*b/2.0 >= x){
    z = 2.0*x/(a*b);
    cout << setprecision(10) << atan(b/z)*(180/acos(-1)) << endl;
  }
  else{
    z = 2.0*x/(a*a)-b;
    cout << setprecision(10) << atan((b-z)/a)*(180/acos(-1)) << endl;
  }
  return 0;
}



Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            map.put(a[i], map.getOrDefault(a[i], 0) + 1);
        }
        long cnt = 0;
        for (Entry<Integer, Integer> e : map.entrySet()) {
            cnt += e.getValue() - 1;
        }
        if (cnt % 2 == 0) {
            System.out.println(map.size());
        } else {
            System.out.println(map.size() - 1);
        }
    }

}


Measured memory_bytes: 62516
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;

map<int, vector<int>> mp;
map<int, int> dn;
int num[100010], hig[100010];
void se(int k){
    for(int i=0; i<mp[k].size(); ++i){
        --dn[mp[k][i]];
        if(hig[k]+1>hig[mp[k][i]]){
            num[mp[k][i]]=k;
            hig[mp[k][i]]=hig[k]+1;
        }
        if(dn[mp[k][i]]<1) se(mp[k][i]);
    }
}
int main() {
    int N, M; cin >> N >> M;
    int a, b;
    for(int i=1; i<N+M; ++i){
        cin >> a >> b;
        mp[a].push_back(b);
        ++dn[b];
        num[b]=1;
    }
    int key=1;
    while(num[key]) ++key;
    se(key);
    for(int i=1; i<=N; ++i) cout << num[i] << endl;
	return 0;
}


Measured memory_bytes: 26624
#include <bits/stdc++.h>
using namespace std;
static const int MAX=100000;
int a[MAX];
int flag2,flag4,x;

int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>x;
        if(x%4==0)flag4++;
        else if(x%2==0)flag2++;
    }
    if(flag2/2+flag4>=N/2)
        cout<<"Yes"<<"\n";
    else
        cout<<"No"<<"\n";
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
 //  Find the minimum number of coins the sum of which is S (we can use as many coins of one type as we want), or report that it’s not possible to select coins in such a way that they sum up to S.



int main()
{
  ios_base::sync_with_stdio(false);
ll n,flag=0,i,j;
cin>>n;
ll arr[n];

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

for(i=0;i<n;i++)
{
  if(arr[i]%2!=0)continue;
else if(arr[i]%2==0&&(arr[i]%3!=0&& arr[i]%5!=0))
 {
  flag=1;
  break;
 }

   }

 if(flag==1)cout<<"DENIED"<<"\n";
 else cout<<"APPROVED"<<"\n";


return 0;

}

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

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

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N - 1);
    rep(i, N)
    {
        cin >> A[i];
        A[i]--;
    }
    rep(i, N) cin >> B[i];
    rep(i, N - 1) cin >> C[i];

    int sum = accumulate(B.begin(), B.end(), 0);
    rep(i, N - 1)
    {
        if (A[i + 1] == A[i] + 1)
            sum += C[A[i]];
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 1000;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s,t;
	cin>>s>>t;
	ll ss = s.size();
	bool ans = false;
	FOR(i,0,ss){
		char c=s[0];
		s = s.substr(1,ss-1);
		s+=c;
		if(s==t)ans = true;
	}
	if(ans)pri("Yes");
	else pri("No");
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))

    ans = 0
    prev_a = 0
    for a in A:
        if prev_a <= a:
            prev_a = a
        else:
            ans += (prev_a - a)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 31604
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var abcd = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var all = abcd[1] - abcd[0] + 1;
            var c = (abcd[1] / abcd[2]) - ((abcd[0] - 1) / abcd[2]);
            var d = (abcd[1] / abcd[3]) - ((abcd[0] - 1) / abcd[3]);
            var lcm = LCM(abcd[2], abcd[3]);
            var e = (abcd[1] / lcm) - ((abcd[0] - 1) / lcm);
            Console.WriteLine(all - (c + d - e));
        }

        static long LCM(long a, long b) => a * b / GCD(a, b);
        static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,c;
int main()
{
	string s,t,s1;
	cin>>s>>t;
	cin>>a>>b;
	cin>>s1;
	if(s1==s)
		cout<<a-1<<" "<<b<<endl;
	else if(s1==t)
		cout<<a<<" "<<b-1<<endl;
	else
		cout<<a<<" "<<b<<endl;		
} 

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	double r,S,L;
	
	scanf("%lf\n",&r);
	
	S=r*r*3.14159265359;
	
	L=2*r*3.14159265359;
	
	printf("%.6f %.6f\n",S,L);
	
	return 0;
}

Measured memory_bytes: 656
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
  -- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative

getVector = V.unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

main = do
  (a,b) <- (\vec -> (vec V.! 0, vec V.! 1)) <$> getVector
  let ans = case a `compare` b of
              LT -> V.replicate b a
              GT -> V.replicate a b
              EQ -> V.replicate a a

  putStrLn $ V.foldl' (\n m -> ((intToDigit m):n)) [] ans


Measured memory_bytes: 380
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 998244353
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n,s;
    cin >> n >> s;
    vi a(n);
    rep(i,n)cin >> a[i];
    vvi dp(n+1,vi(s+1,0));
    //iまでみて和がjのときの場合のかず
    dp[0][0] = 1;
    rep(i,n)rep(j,s+1){
        //使わない
        (dp[i+1][j] += dp[i][j]*2) %= MOD;
        //使う
        if(j+a[i] <= s)(dp[i+1][j+a[i]] += dp[i][j]) %= MOD;
    }
    cout << dp[n][s] << endl;
}


Measured memory_bytes: 73684
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <map>
#include <functional>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
  int n;
  cin >> n;
  map<int, int> point;
  vector<int> tmp(n);
  for(int i = 0; i < n; i++){
    int a, v;
    cin >> a >> v;
    point[a] = v;
    tmp[i] = v;
  }
  sort(tmp.begin(), tmp.end(), greater<int>());
  for(int i = 1; i <= n; i++){
    if(point[i] == tmp[0]){
      cout << i << " " << point[i] << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 1000
using namespace std;
int main() {
  vector<int> v;
  int n;
  cin >> n;
  while (n--) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  int m = v[0];
  int cnt = 0;
  for (int i = 0; i < v.size(); i++) {
    if (m <= v[i]) {
      cnt++;
    }
    m = max(v[i], m);
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
//Prashant Tyagi
using namespace std;
#include <bits/stdc++.h>
#define TRACE
#ifdef TRACE
#define TR(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define TR(...)
#endif
typedef  long long                     LL;
typedef  vector < int >                VI;
typedef  pair< int, int >              II;
typedef  vector < II >                 VII;
#define SI(x)                          scanf ("%d", &x)
#define SLL(x)                         scanf ("%lld", &x)
#define PI(x)                          printf ("%d\n", x)
#define PLL(x)                         printf ("%lld\n", x)
#define MOD                            98765431
#define PB                             push_back
#define MP                             make_pair
#define ALL(v)                         v.begin(), v.end()
#define VIF(x,V)                       for(int x:V)
#define FILL(a,b)                      memset(a,b,sizeof(a))
#define REP(i,j,n)                     for(int i=j;i<n;i++)
#define FLD(i,j,n)                     for(int i=n-1;i>=j;i--)
#define F                              first  
#define S                              second
#define fast_io                        ios_base::sync_with_stdio(false);cin.tie(NULL)

int main ()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	string S;cin>>S;
	cout<<S[0]<<S.length()-2<<S[S.length()-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(1){
    c-=b;
    if(c<=0){
      Yes;
      return 0;
    }
    a-=d;
    if(a<=0){
      No;
      return 0;
    }
  }
}

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

int32_t main(){
    string s, t;
  	cin >> s >> t;
  	int n = s.size();
  	int res = 0;
  	for(int i=0; i<n; i++){
		if(s[i] != t[i]){
			res++;
        }
    }
  	cout << res << "\n";
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int ans = 0;
    ans += min(A, K);
    K -= min(A, K);
    if (K > 0)
    {
        K -= min(B, K);
    }
    if (K > 0)
    {
        ans -= min(C, K);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <deque>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <climits>

using namespace std;

void dfs(vector<vector<pair<int, int>>>& tr, vector<long long>& dist, int v, long long d){
    if(dist[v]!=-1) return;
    dist[v]=d;
    for(auto& adj : tr[v]){
        dfs(tr, dist, adj.first, d+adj.second);
    }
}

int main(){
    int n; cin >> n;
    vector<vector<pair<int, int>>> tr(n);
    for(int i=0; i<n-1; ++i){
        int a, b, c; cin >> a >> b >> c;
        --a; --b;
        tr[a].push_back({b, c});
        tr[b].push_back({a, c});
    }
    int q, k; cin >> q >> k;
    --k;
    vector<long long> dist(n, -1);
    dfs(tr, dist, k, 0);
    for(int i=0; i<q; ++i){
        int x, y; cin >> x >> y;
        --x; --y;
        cout << dist[x]+dist[y] << endl;
    }
    return 0;
}


Measured memory_bytes: 12800
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		for (int i = (int)Math.ceil(Math.sqrt(n)); i > 0; i--) {
			if(n%i==0) {
				System.out.println(dig(n/i));
				break;
			}
		}
		sc.close();
	}
	public static long dig(long l) {
		long dig = 0;
		while(l > 0) {
			l = l/10;
			dig++;;
		}
		return dig;
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    int n,s;
    cin >> n >> s;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<vector<int>> dp(3001,vector<int>(3001,0));
    dp[0][0] = 1;
    rep(i,n){
        rep(j,s+1){
            dp[i+1][j] += (dp[i][j]*2 % MODD);
            dp[i+1][j] %= MODD;
            if(j + a[i] <= s){
                dp[i+1][j+a[i]] += dp[i][j];
                dp[i+1][j+a[i]] %= MODD;
            }
        }
    }
    cout << dp[n][s] << endl;
}

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

using namespace std;

using ll = long long;

struct _IN {
    _IN() {
        ios::sync_with_stdio(0);
        cin.tie(0);
    }
    template <typename T>
    operator T() const {
        T x;
        cin >> x;
        return x;
    }
    template <typename Container>
    void operator()(Container& c) {
        for (auto& x : c)
            cin >> x;
    }
} IN;

int main() {
    int A = IN, B = IN;
    cout << A * B << endl;
}


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

double calc(int a, int b, int c, int d, int e, int f){
    double a_ = a + b;
    double b_ = c + d;
    if (a_ + b_ > f){
        return 0;
    }
    if (a_ == 0 or b_ == 0){
        return 0;
    }
    double dens = double((100.0 * b_) / (a_ + b_ + 0.0));
    if (dens > double((e * 100.0) / (e + 100.0))){
        dens = 0;
    }
    return dens;
}

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

    long long int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    long long int sugar_w = a*100, sugar = 0;
    double dens, max_dens = 0;
    for (int i = 0; i <= ceil(f / a / 100); i++){
        for (int j = 0; j <= ceil(f / b / 100); j++){
            for (int k = 0; k <= ceil(f / c); k++){
                for (int l = 0; l <= ceil(f / d); l++){
                    dens = calc(100*i*a, 100*j*b, k*c, l*d, e, f);
                    if (dens > max_dens){
                        max_dens = dens;
                        sugar_w = 100*i*a + 100*j*b + k*c + l*d;
                        sugar = k*c + l*d;
                    }
                }
            }
        }
    }
    cout << sugar_w << " " << sugar << endl;
}


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

int main() {
  int A,B,T,sum=0;
  cin>>A>>B>>T;
  for(int i=1;i<=T+0.5;i++){
    if((i%A)==0) sum+=B;
    }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
#include<iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> t(m, 0);
    rep(i, n){
        int k;
        cin >> k;
        vector<int> v(k);
        rep(i, k)cin >> v[i];
        rep(i, k){
            t[v[i]-1]++;
        }
    }
    int ans = 0;
    rep(i, m){
        if(t[i] == n)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, Q;
  cin >> N >> A;
  
  Q = N % 500;
    
  if ( Q > A ){
  cout << "No" << endl;
  }
  else {
  cout << "Yes" << endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*
given n and three n size array (A, B, C). array[i] means the happiness
find out how can maximize the happiness. p.s. can consecutively same at most 2

A: [10, 20, 30, 50, 50, 500000]
B: [40, 50, 60, 10, 10, 10]
C: [70, 80, 90, 5, 5, 5]

push dp

dp[i] = dp[i-1] + max(A[i], B[i], C[i])

dp[i][ban] => i means the i-th day and ban means A/B/C is banned (A=0, B=1, C=2, no_ban=3)

dp[i+1][x] = max(dp[i+1][x], dp[i][j] + z)

dp[i][ban] = dp[i-1]

ans = max(dp[n-1][0], dp[n-1][1], dp[n-1][2], dp[n-1][3])

*/
// Time: O(N) | Space: O(N) -> O(1)
int main() {
    int n;
    scanf("%d", &n);
	vector<int> A;
	vector<int> B;
	vector<int> C;
	
	for (int i = 0; i < n; i++) {
	    int a;
	    int b;
	    int c;
	    scanf("%d%d%d", &a, &b, &c);
	    A.push_back(a);
	    B.push_back(b);
	    C.push_back(c);
	}
	
	vector<int> cur(3, 0);
	vector<int> next(3, 0);
	
	//vector<vector<int>> dp(n+1, vector<int>(3, 0));
	vector<vector<int>> vs = {A, B, C};
	
	for (int i = 0; i < n; i++) {
	    next = vector<int>(3, 0);    
	    for (int j = 0; j <= 2; j++) {
	        for (int k = 0; k <= 2; k++) {
	            // not banned
	            if (k != j) {
	                if (i+1 <= n) {
	                    // choose to add 1 vs[k], then it is banned
	                    next[k] = max(next[k], cur[j] + vs[k][i]);    
	                }
	            }
	        }
	    }
	    cur = next;
	}
	
	printf("%d", max({next[0], next[1], next[2]}));
	
	return 0;
}

Measured memory_bytes: 4076
#include<stdio.h>
#include<stdlib.h>
int parent(int);
int left(int);
int right(int);
int main(){
  int *T, n, i;
  scanf("%d",&n);
  T = (int*)malloc(sizeof(int) * n);
  for(i=0; i<n; i++) scanf("%d",&T[i]);
  for(i=0; i<n; i++){
    printf("node %d: ",i+1);
    printf("key = %d, ",T[i]);
    if(i != 0) printf("parent key = %d, ",T[parent(i+1)-1]);
    if(left(i+1) <= n) printf("left key = %d, ",T[left(i+1)-1]);
    if(right(i+1) <= n) printf("right key = %d, ",T[right(i+1)-1]);
    printf("\n");
  }
  return 0;
}
int parent(int n){
  return n/2;
}
int left(int n){
  return 2*n;
}
int right(int n){
  return 2*n+1;
}

Measured memory_bytes: 600
import bisect,collections,copy,itertools,math,numpy,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N,x = LI()
a = sorted(LI())
ans = 0
if a[0]>x:
    pass
else:
    for i in range(N):
        if i!=N-1 and a[i+1]<=x:
            x -= a[i]
            ans += 1
        elif i!=N-1 and a[i+1]>x:
            if a[i]==x:
                ans += 1
                break
        else:
            if a[i]==x:
                ans += 1
print(ans)


Measured memory_bytes: 12088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a), greater<ll>());
    ll ans = a[0];
    n--;
    n--;
    int i=1;
    while(n > 0){
        ans += a[i];
        n--;
        if(n > 0) ans += a[i];
        n--;
        i++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4836
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	int N;
	int a;
	cin >> N;
	while (N > a * 1000) {
		a++;
	}
	cout << a * 1000 - N << endl;
}

Measured memory_bytes: 3096
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	int a[3], b, n;
	cin >> n;
	for(int i = 0;i<n;i++){
		cin >> a[0] >> a[1] >> a[2];
		sort(a,a + 3);
		b = pow(a[1],2) + pow(a[0],2);
		if (pow(a[2],2) == b){
			cout << "YES";
		}
		else{
			cout << "NO";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3064
#include<iostream>
#include<string>

using namespace std;

int main(void){
    string a;
    bool f = false;
    cin >> a;

    if(a[0]!=a[1]&&a[0]!=a[2]&&a[1]!=a[2])f = true;

    if(f){
        cout << "Yes"<< endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

#include<string.h>
using namespace std;

int main()
{
	int h,w;
	cin>>h>>w;
	char a[h][w];
	int i,j;
	for(i=0;i<h;i++)
		for(j=0;j<w;j++)
		{
			cin>>a[i][j];//到什么结束？ 
		}
	int cnt;
	for(i=0;i<h;i++)
		for(j=0;j<w;j++)
		{
			if(a[i][j]=='#')
			{
				cnt=0;
				if(i+1!=h)
				{
					if(a[i+1][j]==a[i][j])
						cnt++;
				}
				if(i!=0)
				{
					if(a[i-1][j]==a[i][j])
						cnt++;
				}
				if(j!=w)
				{
					if(a[i][j+1]==a[i][j])
						cnt++;
				}
				if(j!=0)
				{
					if(a[i][j-1]==a[i][j])
						cnt++;
				}
				if(cnt==0)
				{
					cout<<"No\n";
					return 0;
				}
			}
		}
	cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 256
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;
    
    auto arr = readln.chomp.split.map!(to!int).array;
    
    int ans = 0, cur = 0;
    foreach (i; 1 .. n) {
        if (arr[i] <= arr[i-1]) { ++cur; }
        else { cur = 0; }
            
        ans = max(ans, cur);
    }
    
    ans.writeln;
}

Measured memory_bytes: 4220
#include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <string>
    #include <algorithm>
    using namespace std;
    typedef struct
    {
        int x;
        int y;
    }nb;
    int comp1(const void*p1,const void*p2)
    {
        nb*c=(nb*)p1;
        nb*d=(nb*)p2;
        if(c->x!=d->x)return c->x-d->x;
    else return c->y-d->y;
    }
    int comp2(const void*p1,const void*p2)
    {
        nb*c=(nb*)p1;
        nb*d=(nb*)p2;
        if(c->y!=d->y)return d->y-c->y;
    else return c->x-d->x;
    }
    int main()
    {
        int n,s=0;
        scanf("%d",&n);
        nb a[n],b[n];
        for(int i=0;i<n;i++)
        scanf("%d%d",&a[i].x,&a[i].y);
        for(int i=0;i<n;i++)
        scanf("%d%d",&b[i].x,&b[i].y);
        qsort(a,n,sizeof(nb),comp2);
        qsort(b,n,sizeof(nb),comp1);
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
    {
        if(a[i].x<b[j].x&&a[i].y<b[j].y)
        {
            b[j].x=b[j].y=0;
            s++;
            break;
        }
    }
        printf("%d\n",s);
        return 0;
    }


Measured memory_bytes: 256
S = input()
res_first = S[0:len(S) // 2]
res_second = S[len(S) // 2 if len(S) % 2 == 0
               else ((len(S) // 2) + 1):]
count = 0

for i in range(0, len(res_first)):
    if res_first[i] != res_second[len(res_second)-i-1]:
        count += 1

print(count)

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  map<int32,int32> mp;
  int64 sum = 0;
  REP(i,n){
    int32 a;
    cin >> a;
    mp[a]++;
    sum += a;
  }
  int32 q;
  cin >> q;
  REP(_,q){
    int32 b,c;
    cin >> b >> c;
    sum -= b * mp[b];
    sum += c * mp[b];
    mp[c] += mp[b];
    mp[b] = 0;
    ANS(sum);
  }
  return 0;
}

Measured memory_bytes: 9552
#include <bits/stdc++.h>
using namespace std;
int n, m; 
int main() {
  cin>>n>>m;
	int x = (m+1)/2, y = m/2;
	for (int i = 1; i <= x; ++i) {
		cout<<i<<" "<<2*x+1-i<<endl;
	}
	for (int j = 1; j <= y; ++j) {
		cout<<2*x+j<<" "<<2*x+2*y+2-j<<endl;
	}
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i,a,b) for(int i=(a);i<=(b);++i)
#define FD(i,b,a) for(int i=(b);i>=(a);--i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;
LL inv(LL x, LL m) { return x > m ? inv(x % m, m) : x > 1 ? inv(m % x, m) * (m - m / x) % m : x; }
LL mpow(LL a, LL k, LL m) { LL r(1); for (a %= m; k; k >>= 1, a = a * a % m) if (k & 1)r = r * a % m; return r; }

const int N = 1e5 + 5;
int n, A[N], B[N];

int main() {
    cin >> n;
    FI(i, 1, n) scanf("%d%d", &A[i], &B[i]);
    vector<int> I(n);
    iota(I.begin(), I.end(), 1);
    sort(I.begin(), I.end(), [&](int i, int j) { return A[i] + B[i] > A[j] + B[j]; });
    LL ans = 0;
    for (int i = 0; i < n; i++) {
        int j = I[i];
        if (~i & 1) ans += A[j];
        else ans -= B[j];
    }
    cout << ans << endl;
}


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

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

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

int main() {
    int N;
    cin >> N;
    vector<long long int> l(N+1);
    l[0] = 2;
    l[1] = 1;
    for (int i = 2; i < N+1; i++) {
        l[i] = l[i-2] + l[i-1];
    }
    cout << l[N] << endl;
}

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

void selectsort(int A[100],int N){
  int cnt=0;
  for(int i=0;i<N-1;i++){
    int minj=i;
    for(int j=i;j<N;j++){
      if(A[j]<A[minj])minj=j;}
    if(A[i]>A[minj]){
    swap(A[i],A[minj]);
    cnt++;}
  }
  for(int k=0;k<N-1;k++)cout <<A[k]<<" ";
  cout <<A[N-1]<<endl;
  cout <<cnt<<endl;}

int main(){
  int N,A[100];
 cin>>N;
  for(int i=0;i<N;i++)cin>>A[i];
  selectsort(A,N);
}

Measured memory_bytes: 1160
class UnionFind:
    def __init__(self, size):
        self.rank=[0]*size
        self.par =[int(i) for i in range(size)]
        self.grp =size

    def find(self, x):
        if x==self.par[x]: return x

        self.par[x]=self.find(self.par[x])
        return self.par[x]

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

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

        self.grp-=1
        if self.rank[x]<self.rank[y]:
            self.par[x]=y
        else:
            self.par[y]=x
            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1

    def group_num(self):
        return self.grp


n,m=map(int, input().split())
p=[int(i) for i in input().split()]
uf=UnionFind(n+1)

for i in range(m):
    x,y=map(int, input().split())
    uf.unite(x,y)

ans=chk=0
for a,i in enumerate(p):
    if uf.same(p[a],a+1): ans+=1
print(ans)


Measured memory_bytes: 95852
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=200005;
int n,a[max_n],b[max_n];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d%d",a+i,b+i);
    sort(a+1,a+n+1),sort(b+1,b+n+1);
    if(n&1)printf("%d\n",b[(n+1)/2]-a[(n+1)/2]+1);
    else printf("%d\n",b[n/2+1]+b[n/2]-a[n/2]-a[n/2+1]+1);
    return 0;
}

Measured memory_bytes: 5392
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[5];
	for(int i=0;i<5;i++){
		cin>>a[i];
	}
	int sum=0,ans=1000000000;
	for(int i=0;i<5;i++){
		for(int i1=0;i1<5;i1++){
			if(i==i1){
				continue;
			}
			else{
				for(int i2=0;i2<5;i2++){
					if(i==i2||i1==i2){
						continue;
					}
					else{
						for(int i3=0;i3<5;i3++){
							if(i==i3||i1==i3||i2==i3){
								continue;
							}
							else{
								for(int i4=0;i4<5;i4++){
									if(i==i4||i1==i4||i2==i4||i3==i4){
										continue;
									}
									else{
										sum=a[i];
										if(sum%10!=0){
											sum=(sum/10+1)*10;
										}
										sum+=a[i1];
										if(sum%10!=0){
											sum=(sum/10+1)*10;
										}
										sum+=a[i2];
										if(sum%10!=0){
											sum=(sum/10+1)*10;
										}
										sum+=a[i3];
										if(sum%10!=0){
											sum=(sum/10+1)*10;
										}
										sum+=a[i4];
										ans=min(ans,sum);
									}
								}
							}
						}
					}
				}
			}
		}
	}
	cout<<ans;
} 

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

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

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

    long long sum = 0;
    if(n * 2 <= m){
        sum += n;
        m -= n * 2;
        sum += m / 4;
    }else{
        sum += m / 2;
    }

    cout << sum;

    return 0;
}

Measured memory_bytes: 256
//-------------
//include
//-------------
#include <map>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <random>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef long long LL;
typedef  vector<int> VI;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(a) cout<<a<<endl
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(c) REP(i,SZ(c))cerr<<#c<<i<<"="<<(c[i])<<endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__<< endl;

const int MOD = 1000000007;
int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) < abs(x - b))
	{
		COUT("A");
	}
	else
	{
		COUT("B");
	}
#ifdef _DEBUG
	while(1);
#endif // _DEBUG

	return 0;
}

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

#define ll long long

#define MOD 998244353

int main(){
    ll n;
    scanf("%lld", &n);

    ll ans = 0;
    for(ll i=2;i*i<=n;i++){
        ll j = i;
        while(n%j==0){
            n /= j;
            j *= i;
            ans++;
        }
        while(n%i==0){
            n /= i;
        }
        if(n<i){
            break;
        }
    }
    if(n>1){
        ans += 1;
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 1732