akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int m = input.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++){
            h[i] = input.nextInt();
        }
        int[] t = new int[n];
        for (int i = 0; i < m; i++){
            int a = input.nextInt();
            int b = input.nextInt();
            t[a-1] = Math.max(t[a-1],h[b-1]);
            t[b-1] = Math.max(t[b-1],h[a-1]);
        }
        int ans = 0;
        for (int i = 0; i < n; i++){
            if (h[i] > t[i]){
                ans += 1;
            }
        }
        System.out.println(ans);
    }
}

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

using namespace std;

#define MOD 1000000007
typedef long long int ll;

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);
        
	string s;
	cin>>s;
	int n=s.size();
	bool ch=true;
	for(int i=1;i<=(n-1)/2;i++){
		int first=i;
		int second=(n-1)/2-i+1;
		int third=(n+3)/2+i-1;
		int fourth=n-i+1;
		if(s[first-1]==s[second-1]&&s[second-1]==s[third-1]&&s[third-1]==s[fourth-1]){

		}
		else{
			ch=false;
		}
	}
	if(ch){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <map>
#include <set>

using namespace std;

int main() {
    int n;  cin >> n;
    cout << (n+1) / 2 << endl;
    return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
const ll MAX_N = 1e5;
ll N, T;
ll a[MAX_N];
int main(){
  cin >> N;
  ll ans = 0;
  REP(i, N){
    cin >> a[i];
  }
  ll sum1 = 0, sum2 = 0, temp1 = 0, temp2 = 0;
  REP(i, N){
    sum1 += a[i];
    sum2 += a[i];
    if(i % 2 == 0){
      temp1 += abs(max(1ll, sum1) - sum1);
      sum1 = max(1ll, sum1);
      temp2 += abs(min(-1ll, sum2) - sum2);
      sum2 = min(-1ll, sum2);
    }
    else{
      temp1 += abs(min(-1ll, sum1) - sum1);
      sum1 = min(-1ll, sum1);
      temp2 += abs(max(1ll, sum2) - sum2);
      sum2 = max(1ll, sum2);
    }
  }
  cout << min(temp1, temp2)  << endl;
}


Measured memory_bytes: 1024
class Union_Find():
    def __init__(self,N):
        """0,1,...,n-1を要素として初期化する.

        n:要素数
        """
        self.n=N
        self.parents=[-1]*N
        self.rank=[0]*N

    def find(self, x):
        """要素xの属している族を調べる.

        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,yを同一視する.

        x,y:要素
        """
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x]>self.rank[y]:
            self.parents[x] += self.parents[y]
            self.parents[y] = x
        else:
            self.parents[y] += self.parents[x]
            self.parents[x] = y

            if self.rank[x]==self.rank[y]:
                self.rank[y]+=1

    def size(self, x):
        """要素xの属している要素の数.

        x:要素
        """
        return -self.parents[self.find(x)]

    def same(self, x, y):
        """要素x,yは同一視されているか?

        x,y:要素
        """
        return self.find(x) == self.find(y)

    def members(self, x):
        """要素xが属している族の要素.
        ※族の要素の個数が欲しいときはsizeを使うこと!!

        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=int(input())
P=[0]*N

for i in range(N):
    x,y=map(int,input().split())
    P[i]=(x,y)

M=float("inf")
for i in range(N):
    for j in range(N):
        p=P[j][0]-P[i][0]
        q=P[j][1]-P[i][1]

        U=Union_Find(N)
        for k in range(N):
            for l in range(N):
                if P[l]==(P[k][0]+p,P[k][1]+q):
                    U.union(k,l)

        M=min(M,U.group_count())
print(M)


Measured memory_bytes: 75588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define N 100009
int a[N] , b[N];
vector< int >v[N];
int seive[1000009];
int main()
{
   	string s;
  	cin >> s;
  	int ans = 0 , cnt = 0;
  	for(int i = 0 ; i < s.size() ; i++){
      	ans = max(ans , cnt);
		if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
          cnt++;
          ans = max(ans , cnt);
		}
      	else
          cnt = 0;
    }
 	cout << ans << endl;
	return 0;
}

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

vector <int> edge[200001];
int arr[200001];
int n;
int res[200001];
bool visited[200001];
set <int> lis;

void dfs(int now)
{
	int val = -1;
	if(lis.empty())
	{
		lis.insert(arr[now]);
	}
	else
	{
		auto it = lis.end();
		it--;
		if(*it < arr[now])
		{
			lis.insert(arr[now]);
		}
		else
		{
			auto it = lis.lower_bound(arr[now]);
			if(it!=lis.end())
			{
				val = *it;
				lis.erase(val);
				lis.insert(arr[now]);
			}
		}
	}
	res[now] = lis.size();
	for(auto next : edge[now])
	{
		if(visited[next]==false)
		{
			visited[next] = true;
			dfs(next);
		}
	}
	lis.erase(arr[now]);
	if(val!=-1)
	{
		lis.insert(val);
	}
}
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> n;

	for(int i=1;i<=n;i++)
	{
		cin >> arr[i];
	}

	for(int i=0;i<n-1;i++)
	{
		int u,v;
		cin >> u >> v;
		edge[u].push_back(v);
		edge[v].push_back(u);
	}

	memset(visited,false,sizeof(visited));
	visited[1] = true;
	dfs(1);

	for(int i=1;i<=n;i++)
	{
		cout << res[i] << '\n';
	}

	return 0;
}

Measured memory_bytes: 28268
/**
*    author:  Taichicchi
*    created: 07.09.2020 21:33:09
**/

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

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

    ll ans = 0;

    if(A >= K) {
        ans = K;
    } else if(A + B >= K) {
        ans = A;
    } else if(A + B + C >= K){
        ans = A - (K - A - B);
    } else {
        ans = A - C;
    }

    cout << ans << endl;
    return 0;
}

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

#define zerol

using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout  << #x << " -> "; err(x); } while (0)
void err() { cout << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif


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



LL S;

LL findlr(LL S) {
    LL l = 0, r = 1e9;
    while (l < r-1) {
        LL m = (l+r) >> 1;
        if (m*m >= S) r = m;
        else l = m;
    }
    return r;
}

int main(int argc, char const *argv[])
{
    scanf("%lld", &S);

    LL x, y, a, b;
    a = findlr(S);
    b = a;
    LL remain = a*b-S;
    x = 1;
    y = remain;
    printf("%lld %lld %lld %lld %lld %lld\n", 0, 0, x, b, a, y);


    return 0;
}



Measured memory_bytes: 256
# coding: utf-8
# Your code here!


n = int(input())
aa = [int(i) for i in input().split()]

INF = 10**13
#from itertools import accumulate, product, permutations, combinations, groupby
#acc = accumulate([0]+aa)

#dp[x][y] = (bの位置x,aの」位置y)
dp= [[0]*(i+1) for i in range(n+1)]
#dp[n][0]=0
"""
for b in range(n,-1,-1):
    for a in range(b+1):
#        print(b,a)
#        print(dp)
        c=(n-a-b)%2
        if c:
            if b<n and a>0:
                dp[b][a] = max(dp[b+1][a] + aa[b], dp[b][a-1]+aa[a-1])
            elif b<n:
                dp[b][a] = dp[b+1][a] + aa[b]
            elif a>0:
                dp[b][a] = dp[b][a-1]+aa[a-1]
        else:
            if b<n and a>0:
                dp[b][a] = min(dp[b+1][a] - aa[b], dp[b][a-1]-aa[a-1])
            elif b<n:
                dp[b][a] = dp[b+1][a] - aa[b]
            elif a>0:
                dp[b][a] = dp[b][a-1] - aa[a-1]

print(dp)
for b in range(1,n+1):
    for a in range(b-1,-1,-1):
#        print(b,a)
        c=(n-a-b)%2
        if c:
            dp[b][a] = max(dp[b-1][a], dp[b][a+1])
        else:
            dp[b][a] = min(dp[b-1][a], dp[b][a+1])
"""

for b in range(1,n+1):
    for a in range(b-1,-1,-1):
#        print(b,a)
        c=(n-a-b+1)%2
        if c:
            dp[b][a] = max(dp[b-1][a]+aa[b-1], dp[b][a+1]+aa[a])
        else:
            dp[b][a] = min(dp[b-1][a]-aa[b-1], dp[b][a+1]-aa[a])

#print(dp)
print(dp[n][0])








Measured memory_bytes: 77660
//In the Name of God
//Let Our Voices Echo
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define X real()
#define Y imag()
typedef long long ll;
typedef double ld;
typedef complex<ld> point;
const ld eps=1e-9;
const int MAX=1e5+9,MOD=1e9+7;

int main()
{
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	string s;
	map<char,bool> mp;
	cin>>s;
	for (int i=0;i<s.size();i++) mp[s[i]]=true;
	if ((mp['S'] ^ mp['N']) || (mp['E'] ^ mp['W']))
		cout<<"No";
	else
		cout<<"Yes";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

void output(int H[3][10]){
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 10; j++){
			printf(" %d",H[i][j]);
		}
		printf("\n");
	}
}


int main(){
	int H1[3][10],H2[3][10],H3[3][10],H4[3][10],n,h_num,f_num,r_num,div_num;
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 10; j++){
			H1[i][j] = H2[i][j] = H3[i][j] = H4[i][j] = 0;
		}
	}
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d %d %d %d",&h_num,&f_num,&r_num,&div_num);
		switch(h_num){
		case 1:
			H1[f_num-1][r_num-1] += div_num;
			break;
		case 2:
			H2[f_num-1][r_num-1] += div_num;
			break;
		case 3:
			H3[f_num-1][r_num-1] += div_num;
			break;
		case 4:
			H4[f_num-1][r_num-1] += div_num;
			break;
		}
	}

	output(H1);
	printf("####################\n");
	output(H2);
	printf("####################\n");
	output(H3);
	printf("####################\n");
	output(H4);

}


Measured memory_bytes: 2664
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
using namespace std;
#define lli long long int
inline lli modsum(lli a,lli b,lli mod)
{
	a = a % mod;
	b = b % mod;
	lli ans = (a+b)%mod;
	ans = (ans + mod)%mod;
	return ans;
} 
inline lli modmul(lli a,lli b,lli mod)
{
	a = a % mod;
	b = b % mod;
	lli ans = (a*b)%mod;
	ans = (ans + mod)%mod;
	return ans;
} 
inline lli modpow(lli a,lli b,lli mod)
{
	if(b==0)
		return 1;
	lli sqrt = modpow(a,b/2,mod);
	lli ans = modmul(sqrt,sqrt,mod);
	if(b%2)
		ans = modmul(ans,a,mod);
	return ans;
}
vector<lli> fact;
vector<lli> fact_inv;

inline lli ncr(lli n,lli r)
{
	if(r>n)
		return 0;
	lli ans = fact[n];
	ans = modmul(ans,fact_inv[r],MOD);
	ans = modmul(ans,fact_inv[n-r],MOD);
	return ans;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	fact.resize(5001);
	fact_inv.resize(5001);
	lli i;
	fact[0] = 1;
	fact_inv[0] = 1;
	for(i=1;i<=5000;i++)
	{
		fact[i] = modmul(fact[i-1],i,MOD);
		fact_inv[i] = modpow(fact[i],MOD-2,MOD);
	}
	vector<lli> ans;
	int n,k;
	cin>>n>>k;
	ans.resize(k+1);
	for(i=1;i<=k;i++)
	{
		ans[i] = modmul(ncr(n-k+1,i),ncr(k-1,i-1),MOD);
	}
	for(i=1;i<=k;i++)
		cout<<ans[i]<<"\n";
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if (n == 7 || n == 5 || n == 3) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
    
  }
}

Measured memory_bytes: 21972
#121-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
a,b=IL()
import math
if a==0:
    if b==0:
        n=1
    else:
        n=int(math.log(b,2))+1
else:
    if b==0:
        n=int(math.log(a,2))+1
    else:
        n=max(int(math.log(a,2)),int(math.log(b,2)))+1
al=[0 for i in range(n)]
bl=[0 for i in range(n)]
cl=[0 for i in range(n)]
for i in range(1,n):
    k=pow(2,i+1)
    al[i]=a%k
    bl[i]=b%k
    bou=k//2-1
    if al[i]<=bl[i]:
        if al[i]<=bou:
            if bl[i]<=bou:
                cl[i]=0
            else:
                cl[i]=0 if (bl[i]-bou)%2==0 else 1
        else:
            cl[i]=1 if (bl[i]-al[i])%2==0 else 0
    else:
        if bl[i]<=bou:
            if al[i]<=bou:
                cl[i]=0
            else:
                cl[i]=0 if (k-al[i])%2==0 else 1
        else:
            if al[i]<=bou:
                cl[i]=0 if (bl[i]-bou)%2==0 else 1
            else:
                cl[i]=0 if (k-al[i]+bl[i]-bou)%2==0 else 1
if a%2==0:
    if b%2==0:
        cl[0]=0 if ((b-a)//2)%2==0 else 1
    else:
        cl[0]=0 if (((b+1)-a)//2)%2==0 else 1
else:
    if b%2==1:
        cl[0]=1 if ((b-a)//2)%2==0 else 0
    else:
        cl[0]=1 if (((b-1)-a)//2)%2==0 else 0
        
ans=0
for i in range(n):
    ans+=cl[i]*pow(2,i)
print(ans)

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
int W,H;
vector<ll> p;
vector<ll> q;
ll p_sum = 0;
ll q_sum = 0;
void solve(){
    sort(p.begin(),p.end());
    sort(q.begin(),q.end());
    ll res = p_sum+q_sum;
    auto pre = q.begin();
    ll pre_min_sum = 0;
    for(int i=0;i<W;i++){
        auto it = lower_bound(pre, q.end(), p[i]);
        for(auto itr = pre;itr != it;itr++){
            pre_min_sum += *itr;
        }
        res += pre_min_sum;
        res += distance(it,q.end())*p[i];
        pre = it;
    }
    cout << res <<endl;
}

int main() {
    cin >> W >> H;
    for(int i=0;i<W;i++){
        int tmp;
        cin >> tmp;
        p_sum += tmp;
        p.push_back(tmp);
    }
    for(int i=0;i<H;i++){
        int tmp;
        cin >> tmp;
        q_sum += tmp;
        q.push_back(tmp);
    }
    solve();
    return 0;
}

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

const int INF = 1e9;
int N,T,c[100],t[100],ans = INF;

int main()
{
    cin >> N >> T;
    for(int i = 0; i < N; i++){
        cin >> c[i] >> t[i];
        if(t[i] <= T) ans = min(ans,c[i]);
    }

    if(ans == INF) cout << "TLE" << endl;
    else cout << ans << endl;

    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(auto&& i : h){
        cin >> i;
    }
    int ans = 0, cnt = 0;
    for(int i = 1; i < n; i++){
        if(h[i] <= h[i - 1]){
            cnt++;
        }else{
            cnt = 0;
        }
        ans = max(cnt, ans);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <set>
#include <memory.h>
using namespace std;

int main(){
    int d, n;
    long long int ans = 1;
    
    cin >> d >> n;
    
    while(d != 0){
        ans *= 100;
        d--;
    }
    
    if(n == 100){
        ans *= 101;
    }else{
        ans *= n;
    }
    
    cout << ans << endl;
}


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


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

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<'\n';
    return 0;
}

Measured memory_bytes: 896
from collections import deque

N = int(input())
e = [[] for i in range(N)]
for i in range(1, N):
    u, v, w = map(int, input().split())
    e[u-1].append((v-1, w))
    e[v-1].append((u-1, w))
l = [-1 for i in range(N)]

q = deque()
l[0] = 0
q.append(0)
while (q):
    u = q.pop()
    for v, w in e[u]:
        if l[v] >= 0:
            continue
        if w % 2 == 0:
            l[v] = l[u]
        else:
            l[v] = 1 - l[u]
        q.append(v)

for col in l:
    print(col)


Measured memory_bytes: 99160
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

long long int factmod(long long int a,long long int m) {
    long long int s=1;
    while(a>0){
        s = s*a % m;
        a -= 1;
    }
    return s;
}

int main(){

  long long int x,y;
  cin >> x >> y;

  if((2*x-y)%3!=0 || (2*y-x)%3!=0 || 2*x-y<0 || 2*y-x<0)cout << 0 << endl;
  else{
    long long int a,b;
    a=(2*x-y)/3;
    b=(2*y-x)/3;
    long long int m=1000000007;
    long long int c=factmod(a+b,m);
    c*=modinv(factmod(a,m),m);
    c%=m;
    c*=modinv(factmod(b,m),m);
    c%=m;
    cout << c << endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

// AtCoder
#include <atcoder/all>
using namespace atcoder;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

constexpr ll M = 1e10;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    int st = 2 * n, gl = 2 * n + 1, c = 0, r = n;
    mcf_graph<int, ll> graph(gl + 1);

    graph.add_edge(st, gl, n * k, M);
    rep (i, n) {
        graph.add_edge(st, c + i, k, 0);
        graph.add_edge(r + i, gl, k, 0);
    }
    rep (i, n) {
        rep (j, n) {
            ll a; cin >> a;
            graph.add_edge(c + i, r + j, 1, M - a);
        }
    }

    cout << n * k * M - graph.flow(st, gl, n * k).second << "\n";
    vector<vector<char>> b(n, vector<char>(n, '.'));
    for (auto &e : graph.edges()) {
        if (e.from >= c + n || e.to >= r + n || e.flow == 0) continue;
        b[e.from - c][e.to - r] = 'X';
    }
    rep (i, n) {
        rep (j, n) cout << b[i][j];
        cout << "\n";
    }

    /***************************************************/
    /* Submit this code from the browser if using ACL! */
    /***************************************************/
    return 0;
}

Measured memory_bytes: 3944
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	while(true){
		scanf("%d %d",&a,&b);
		if(a == 0 && b == 0) break;
		if(a > b) printf("%d %d\n",b,a);
		else{
			printf("%d %d\n",a,b);
		}
	}
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

ll MOD;

const int SZ = 312345;
ll inv[SZ];
ll fact[SZ];
ll fact_inv[SZ];
ll choose(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
}


ll mod_pow(ll a, ll b, ll p) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % p;
    a = (a * a) % p;
    b >>= 1;
  }
  return res;
}

ll memoP[3010][3010];
ll P(int k, int r) {
  if (k == 0 && r == 0) return 1;
  if (k > 0 && r == 0) return 1;
  if (k < r) return 0;
  if (memoP[k][r] != -1) return memoP[k][r];
  ll res = 0;
  res += P(k-1, r-1);
  res += P(k-1, r) * (r+1) % MOD;
  res %= MOD;
  return memoP[k][r] = res;
}

ll ways2(const int N, const int k, const int r) {
  ll t = ((N-k)*r + mod_pow(2, N-k, MOD-1)) % (MOD-1);
  ll res = P(k, r) * mod_pow(2, t, MOD) % MOD;
  return res;
}

ll ways(const int N, const int k) {
  ll res = 0;
  for (int r = 0; r <= k; r++) {
    (res += ways2(N, k, r)) %= MOD;
  }
  return res;
}

int main2() {
  CLR(memoP, -1);
  int N = nextInt();
  MOD = nextInt();
  {
    inv[1] = 1;
    for (int i = 2; i < SZ; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
    fact[0] = 1;
    for (int i = 1; i < SZ; i++) fact[i] = fact[i-1] * i % MOD;
    fact_inv[0] = 1;
    for (int i = 1; i < SZ; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;
  }

  ll ans = 0;
  for (int k = 0; k <= N; k++) {
    int f = (k % 2 == 0 ? +1 : -1); 
    ll add = f * choose(N, k) % MOD * ways(N, k) % MOD;
    // cout << add << endl;
    add = (add % MOD + MOD) % MOD;
    (ans += add) %= MOD;
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

const long double PI = (acos(-1));

int main(){
    long double a, b, x;
    cin >> a >> b >> x;
    long double ans;
    long double si = PI/4;
    long double dsi = PI/8;
    rep(i, 10000){
        if(a/2*tan(si) <= x/a/a){
            if(tan(si)*a/2 <= b-x/a/a){
                si += dsi;
                dsi *= 0.5;
            }else{
                si -= dsi;
                dsi *= 0.5;
            }
        }else{
            if(a*b*b/2*tan(PI/2-si) >= x){
                si += dsi;
                dsi *= 0.5;
            }else{
                si -= dsi;
                dsi *= 0.5;
            }
        }
    }
    cout << fixed << setprecision(10) << si*180/PI << endl;
    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>

#define REP(i,s,n) for(register int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define MAX 500010

using namespace std;

long long depth[MAX],L[MAX],R[MAX],N,noSaveDp[MAX],saveDp[MAX],leaf[MAX];

int main(){
  scanf("%d",&N);
  depth[0] = leaf[N-1] = 1;
  rep(i,N-1){
    scanf("%d %d",&L[i],&R[i]);
    depth[--L[i]] = depth[--R[i]] = depth[i] + 1;
  }

  for(int i = N-2;i>=0;i--){
    leaf[i] = leaf[L[i]] + leaf[R[i]];
    saveDp[i] = noSaveDp[i] = noSaveDp[L[i]] + noSaveDp[R[i]] + leaf[L[i]] + leaf[R[i]];
    saveDp[i] = min(saveDp[i],
		    min(noSaveDp[L[i]]+leaf[L[i]]+1+saveDp[R[i]],
			noSaveDp[R[i]]+leaf[R[i]]+1+saveDp[L[i]]));
    saveDp[i] = min(saveDp[i],
		    saveDp[L[i]]+1+depth[i]-1+1+saveDp[R[i]]);
  }
  printf("%d\n",saveDp[0]);
  return 0;
}

Measured memory_bytes: 24624
from collections import deque
import heapq
class Graph:
    edges = {}

    def append_edge(self, sv, ev, weight = 1):
        if sv in self.edges:
            self.edges[sv].append((ev, weight))
        else:
            self.edges[sv] = [(ev, weight)]

    def bfs(self, sv, n):
        dist = [-1]*len(self.edges.keys())
        q = deque([])   # キュー
        q.append(sv)
        dist[sv] = 0
        connect_vtxs = []
        ans = [-1] * n
        ans[0] = -1
        while len(q) > 0:
            p = q.popleft()     # キュー取りだし（先頭）
            connect_vtxs.append(p)
            for (ev, w) in self.edges[p]:
                if ans[ev] == -1:
                    ans[ev] = p
                if dist[ev] != -1:
                    continue
                q.append(ev)    # キュー追加
                dist[ev] = dist[p] + 1
        return ans


N, M = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(M)]

for i in range(len(ab)):
    ab[i][0] -= 1
    ab[i][1] -= 1

g = Graph()
for i in range(M):
    s = ab[i][0]
    t = ab[i][1]
    g.append_edge(s, t)
    g.append_edge(t, s)

ans = g.bfs(0, N)
ans = ans[1:]

if -1 in ans:
    print("No")
else:
    print("Yes")
    for i in range(N-1):
        print(ans[i]+1)


Measured memory_bytes: 139524
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <unordered_set>
using namespace std;
using ll = long long int;
int main()
{
    int x;
    cin >> x;

    int ans = 1;
    for (size_t i = 2; i < 40; i++)
    {
        int cnt = 2;
        while (pow(i, cnt) <= x) {
            ans = max(ans, (int)pow(i, cnt));
            cnt++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    long long N;
    cin >> N;
    int pre=0;
    string ans = "";
    while(N>0){
        if(N==26){
            ans = ans + "z";
            break;
        }
        pre = N %26;
        //if(N-pre >26){
        
        N = (N-pre)/26;
        
        if(pre == 1){
        ans = ans + "a";
        }
        else if(pre ==2){
            ans = ans + "b";
        }
        else if(pre == 3){
        ans = ans + "c";
        }
        else if(pre ==4){
            ans = ans + "d";
        }
        else if(pre == 5){
        ans = ans + "e";
        }
        else if(pre ==6){
            ans = ans + "f";
        }
        if(pre == 7){
        ans = ans + "g";
        }
        else if(pre ==8){
            ans = ans + "h";
        }
        if(pre == 9){
        ans = ans + "i";
        }
        else if(pre ==10){
            ans = ans + "j";
        }
        if(pre == 11){
        ans = ans + "k";
        }
        else if(pre ==12){
            ans = ans + "l";
        }
        if(pre == 13){
        ans = ans + "m";
        }
        else if(pre ==14){
            ans = ans + "n";
        }
        if(pre == 15){
        ans = ans + "o";
        }
        else if(pre ==16){
            ans = ans + "p";
        }
        if(pre == 17){
        ans = ans + "q";
        }
        else if(pre ==18){
            ans = ans + "r";
        }
        if(pre == 19){
        ans = ans + "s";
        }
        else if(pre ==20){
            ans = ans + "t";
        }
        if(pre == 21){
        ans = ans + "u";
        }
        else if(pre ==22){
            ans = ans + "v";
        }
        if(pre == 23){
        ans = ans + "w";
        }
        else if(pre ==24){
            ans = ans + "x";
        }
        if(pre == 25){
        ans = ans + "y";
        }
        else if(pre ==0){
            ans = ans + "z";
            N = N-1;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    
}


Measured memory_bytes: 3636
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	println(n/2+(n%2));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
string s;
cin >> s;
for(ll bit = 0; bit < (1 << 3); bit++){
    vector<char> op(3,'-');
    for(ll i = 0; i < 3; i++){
        if(bit & (1 << i))
        op[i] = '+';
    }
    ll ans = s[0] - '0';
    for(ll i = 0; i < 3; i++){
        if(op[i] == '+')
        ans += s[i + 1] - '0';
        else
        {
            ans -= s[i + 1] - '0'; 
        }
    }
    if(ans == 7){
        cout << s[0] - '0';
        for(ll i = 0; i < 3; i++){
            cout << op[i] << s[i + 1] - '0';
        }
        cout<< "=7" << endl;
        return 0;
    }
}
}

Measured memory_bytes: 256
from collections import defaultdict
from itertools import accumulate


def main():
    n = int(input())
    prime_counter = defaultdict(int)
    acc = tuple(accumulate(range(1, 42)))  # 10^12 < 2^39

    f = 2
    while f * f <= n:
        if n % f == 0:
            n //= f
            prime_counter[f] += 1
        else:
            f += 1
    if n != 1:
        prime_counter[n] += 1

    ans = 0
    for c in prime_counter.values():
        for i, x in enumerate(acc):
            if c < x:
                tmp = i
                break
        ans += tmp
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9464
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int X, Y;
    cin >> X >> Y;

    int ans = 0;
    if (X == 1) ans += 300000;
    else if (X == 2) ans += 200000;
    else if (X == 3) ans += 100000;

    if (Y == 1) ans += 300000;
    else if (Y == 2) ans += 200000;
    else if (Y == 3) ans += 100000;

    if (X == 1 && Y == 1) ans += 400000;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
using namespace std;
typedef long long LL;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b == c + d) {
        cout << "Balanced" << endl;
    }
    else if (a + b < c + d) {
        cout << "Right" << endl;
    }
    else {
        cout << "Left" << endl;
    }
    return 0;
}


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

int main() {
  int64_t n, k;
  std::cin >> n >> k;

  std::string s;
  std::cin >> s;

  std::vector<int64_t> v;
  v.reserve(n);

  if (s[0] != '0') {
    v.push_back(0);
  }

  char c = s[0];
  auto itr = s.cbegin();
  int count = 0;
  while (itr != s.cend()) {
    if (c == *itr) {
      count++;
    } else {
      v.push_back(count);
      c = *itr;
      count = 1;
    }
    itr++;
  }
  v.push_back(count);

  int64_t val = 0;
  for (int64_t i = 0; i < std::min<int64_t>(v.size(), 2 * k); i++) {
    val += v[i];
  }

  int64_t max = val;

  val = 0;
  for (int64_t i = 1; i < std::min<int64_t>(v.size(), 2 * (k + 1)); i++) {
    val += v[i];
  }
  max = std::max(max, val);
  int64_t start = 1, end = 2 * (k + 1);
  for (; end < v.size(); end += 2) {
    val -= v[start] + v[start + 1];
    start += 2;
    val += v[end];
    if (end + 1 < v.size()) {
      val += v[end + 1];
    }
    max = std::max(val, max);
  }

  std::cout << max << std::endl;
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  vector<int> x(a);
  for(int i = 0;i < c;i++){
    int y;
    cin >> y;
    x.at(y-1)++;
  }
  for(int i = 0;i < a;i++){
  if((c-b)<x.at(i))cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 1024
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline
mii=lambda:map(int,input().split())

n=int(input())

p=[list(mii()) for _ in range(n)]

d={}
for a in p:
    for b in p:
        if a==b: continue
        c=(b[0]-a[0],b[1]-a[1])
        if c in d:
            d[c]+=1
        else:
            d[c]=1

best=0
for i,j in d.items():
    best=max(best,j)

print(n-best)


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

using namespace std;
const int N = 100;
int arr[N*N];
int ans[N][N];
int main()
{
    int q, m, n;
    scanf("%d%d%d",&n,&m,&q);
    vector<int> vec;

    for(int i = 0;i<q;i++)
        scanf("%d",&arr[i]);
    bool rev = false;
    int curr = 0;
    for(int i = 0;i<n;i++) {
        for(int j = rev?m-1:0;rev?j>=0:j<m;rev?j--:j++) {
            ans[i][j] = curr+1;
            arr[curr]--;
            if(!arr[curr])
                curr++;
        }
        rev = !rev;
    }
    for(int i = 0;i<n;i++) {
        for(int j = 0;j<m;j++) {
            printf("%d ",ans[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 384
N, K = map(int, input().split())
P = [int(i) - 1 for i in input().split()]
C = [int(i) for i in input().split()]

points = list()
for i in range(N):
    sum = 0
    now = P[i]
    result = list()
    flag = True
    for j in range(N):
        sum += C[now]
        result.append(sum)
        if now == i:
            break
        if j == N-1 and now != i:
            flag = False
        now = P[now]

    if flag:
        points.append(result)
    else:
        # iスタートでiに戻るループが存在しない
        points.append([-int(1e19)])

ans = -int(1e19)

for i in range(len(points)):
    now = i
    tmpp = 0
    k = K
    while points[now][0] == -int(1e19):
        now = P[now]
        tmpp += C[now]
        k -= 1
        ans = max(ans, tmpp)

    cir = len(points[now])
    cir_point = points[now][cir-1]

    if k <= cir:
        for j in range(k):
            ans = max(ans, points[now][j] + tmpp)
    else:
        if cir_point > 0:
            lm = k // cir - 1
            for j in range(cir):
                ans = max(ans, points[now][j] + lm * cir_point + tmpp)
            for j in range(k % cir):
                ans = max(ans, points[now][j] + (lm + 1) * cir_point + tmpp)
        else:
            for j in range(cir):
                ans = max(ans, points[now][j] + tmpp)

print(ans)

Measured memory_bytes: 286056
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();
        int n = s.length();
        int k = 0;
        for(int i = 0 ; i < n / 2 ; i++ ){
            if(s.charAt(i) != s.charAt(n - i - 1)){
                k++;
            }
        }
        System.out.println(k);
    }
}

Measured memory_bytes: 35508
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i< n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 29;
const double EPS = 1e-10;

const ll mod = 1000000007;

int w[300];
ll dp[2][201][10010];

int main(){
  int N, W;
  while(cin >> N >> W){
    memset(dp, 0, sizeof(dp));
    ll res = 0;
    rep(i, N){
      cin >> w[i];
    }
    sort(w, w + N, greater<int>());
    w[N] = INF;
    dp[0][N][0] = 1;
    rep(i, N){
      rep(j, N + 1)rep(k, W + 1){
	if(k + w[i] <= W){
	  dp[1][j][k+w[i]] = (dp[1][j][k+w[i]] + dp[0][j][k]);
	}
	dp[1][i][k] = (dp[1][i][k] + dp[0][j][k]);
      }
      rep(j, N + 1)rep(k, W + 1){
	dp[0][j][k] = dp[1][j][k];
	dp[1][j][k] = 0;
      }
    }
    rep(i, N + 1)rep(j, W + 1){
      if(j > W - w[i]) res = (res + dp[0][i][j]) % mod;
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 31000
def solve(string):
    ins = list(map(int, string.split("\n")))[1:]
    ins.sort()
    ins[-1] //= 2
    return str(sum(ins))


if __name__ == '__main__':
    n = int(input())
    ins = [input() for _ in range(n)]
    print(solve("{}\n{}".format(n, "\n".join(ins))))


Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
    int a[5],i,j,k;
    int x=0;

    scanf("%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&a[4]);

    for(i=0;i<5;i++){
        for(j=0;j<5;j++){
            if(a[i]>a[j]){
                x=a[i];
                a[i]=a[j];
                a[j]=x;
            }
        }
    }
    for(k=0;k<4;k++){
        printf("%d ",a[k]);
    }
	printf("%d\n",a[4]);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
    int n,l;
    cin>>n>>l;
    string ans;
    vector<string>s(n);
    for(int i=0; i<n; i++){
        cin>>s.at(i);
    }
    sort(s.begin(),s.end());
    for(int i=0; i<n; i++){
        ans +=s.at(i);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <utility>
#include <algorithm>
#define FL(i,j,k) for(int i=j;i<k;++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
ll A,B;

ll now(int A,int d=0){
    if(A==B)return 0;
    if(d==5)return 1e10;
    ll n=A<B?B-A:1e10;
    ll m=A<-B?-B-A:1e10;
    return min(now(-A,d+1)+1,min(m+1,n));
}

int main(){
    cin>>A>>B;
    cout<<now(A);
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!.toCharArray()
    var count = 0L
    var aCount = 0
    for (i in 0..(s.size - 3)) {
        aCount = if (s[i] == 'A') aCount + 1 else 0
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
            s[i] = 'B'
            s[i + 1] = if (aCount > 1) 'A' else 'C'
            s[i + 2] = 'A'
            count += aCount
            aCount = Math.max(0, aCount - 2)
        }
    }
    println(count)
}



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

using namespace std;

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;

#ifdef WIN32
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

const int maxn = 105;

int d[maxn];
int n;

bool can(int s)
{
//     cout << "can " << s << endl;
    int l = 0;
    int r = 0;
    for (int i = 0; i < n; i++)
    {
//         cout << i << ' ' << d[i] << ' ' << l << ' ' << r << endl;
        if (d[i] - l < s) return false;
        if (d[i] - r >= s) r = d[i];
        else
        {
            l = r;
            r = d[i];
        }
    }
    if (24 - l - r < s) return false;
    return true;
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &d[i]);
    sort(d, d + n);
    for (int s = 12; s > 0; s--)
    {
        if (can(s))
        {
            cout << s << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

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

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

	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! invec {
    ( $t:ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s.trim().split_whitespace().map(|s| s.parse::<$t>().unwrap()).collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }}
}

#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($(
            {
                 splits.next().unwrap().parse::<$t>().unwrap()
            },
        )*)
    }}
}

struct Primes {
    prime_list: Vec<bool>
}

impl Primes {
    fn new(n: usize) -> Self {
        let mut lis = vec![false; n+1];
        lis[2] = true;

        for i in (3..n+1).filter(|a| a % 2 == 1) {
            let i_sqrt = (i as f64).sqrt().ceil() as usize;
            lis[i] = !(3..i_sqrt+1).fold(false, |flag, now| flag || i % now == 0);
        }

        Primes { prime_list: lis }

    }

    fn is_prime(&self, n: usize) -> bool {
        if (n as usize) < self.prime_list.len() {
            self.prime_list[n as usize]
        } else {
            panic!(n.to_string() + " hasn't been calculated yet.");
        }
    }
}


#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (q,) = input!(usize);
    let p = Primes::new(100000);

    let mut comulative = vec![0; 100001];
    let mut total = 0;
    for i in 0..100001 {
        if p.is_prime(i) && p.is_prime((i + 1) / 2) {
            total += 1;
        }
        comulative[i] = total;
    }

    for _ in 0..q {
        let (l, r) = input!(usize, usize);
        println!("{}", comulative[r] - comulative[l-1]);
    }


}

fn main() {
    solve();
}


Measured memory_bytes: 4732
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    llong A;
    double B1;
    cin >> A >> B1;
    llong B2 = round(B1 * 100);
    llong C = (A * B2) / 100;
    cout << C << endl;
}


Measured memory_bytes: 3788
#include<stdio.h>

int heap[260];

int main() {
	int N;

	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		scanf("%d", &heap[i]);
	}

	for (int i = 1; i <= N; i++) {
		printf("node %d: key = %d, ", i, heap[i]);
		if (i / 2 > 0)printf("parent key = %d, ", heap[i / 2]);
		if (2 * i <= N)printf("left key = %d, ", heap[2 * i]);
		if (2 * i + 1 <= N)printf("right key = %d, ", heap[2 * i + 1]);
		printf("\n");
	}

	return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#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())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//main code

int main(int argc, char const* argv[])
{
	int w,h,x,y;
	cin >> w >> h >> x >> y;
	cout << double(w)*double(h)/2.0 << " ";
	if (x == w/2 and y == h/2 and w%2 == 0 and h%2 == 0) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}


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

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

  for (int i = 0; i < min((ll)s.size(), k); i++) {
    int n = s[i] - '0';
    if (n > 1) {
      printf("%d\n", n);
      return 0;
    }
  }
  puts("1");

  return 0;
}


Measured memory_bytes: 256