akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    long long n;
    cin >> n;
    vector<long double> v(n);

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

    sort(v.begin(), v.end());

    for(long long i = 0; i < n-1; i++){
        v[i+1] = (v[i]+v[i+1])/2.0;
    }

    printf("%.10Lf\n", v[n-1]);
    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,sse")
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, a, b;
    cin >> n >> a >> b;
    vector<vector<int>> adj(n + 1);
    for (int i = 1; i < n; i++) {
        adj[i].push_back(i + 1);
        adj[i + 1].push_back(i);
    }
    adj[a].push_back(b);
    adj[b].push_back(a);
    vector<int> kek(n);

    for (int i = 1; i <= n; i++) {
        vector<int> dist(n + 1, -1);
        queue<int> q;
        q.push(i);
        dist[i] = 0;
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (int k : adj[v]) {
                if (dist[k] == -1) {
                    dist[k] = dist[v] + 1;
                    q.push(k);
                }
            }
        }
        for (int k : dist) {
            if (k == -1) continue;
            kek[k]++;
        }
    }

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

    fflush(stdout);
    return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a); i<ll(b); i++)
#define rer(i,a,b) for(ll i=ll(a)-1; i>=ll(b); i--)

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    for(;;){
        int n,l,r;
        cin>>n>>l>>r;
        if(n==0) break;
        vector<int> a(n);
        rep(i,0,n) cin>>a[i];
        ll cnt=0;
        rep(x,l,r+1){
            rep(i,0,n){
                if(x%a[i]==0){
                    if(i%2==0){
                        cnt++;
                    }
                    break;
                }
                if(i==n-1&&n%2==0) cnt++;
            }
        }
        cout<<cnt<<"\n";
    }
}


Measured memory_bytes: 3156
int main()
{
	int N,B,F,R,V,A[5][4][11]={0},i,j,k;
	for(scanf("%d",&N);N--;)
	{
		scanf("%d%d%d%d",&B,&F,&R,&V);
		A[B][F][R]+=V;
	}
	for(i=1;i<=4;i++)
	{
		for(j=1;j<=3;j++)
			for(k=1;k<=10;k++)
				printf(" %d%s",A[i][j][k],k==10?"\n":"");
		if(i<4)
		puts("####################");
	}
	return 0;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
int h[100], n;

int grow(int l, int r){
    if(l==r-1)
	    return h[l];
    else if(l==r)
	    return 0;
    int min_h = INF, ret;
    for(int i=l;i<r;i++)
  	    min_h=min(min_h, h[i]);
  
    ret=min_h;
    vector<int> zero_h={l-1};
    for(int i=l;i<r;i++){
        h[i]-=min_h;
        if(h[i]==0)
    		zero_h.push_back(i);
    }
    zero_h.push_back(r);
    for(int i=0;i<(int)zero_h.size()-1;i++)
        ret+=grow(zero_h[i]+1, zero_h[i+1]);
    return ret;
}

int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
      cin>>h[i];
    cout<<grow(0, n)<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
import heapq

L = [A[0]]
i = 0
ans = 0
for a in A[1:]:
    ans += L[i]
    i += 1
    L.append(a)
    L.append(a)

print(ans)

Measured memory_bytes: 31400
#include<bits/stdc++.h>
using namespace std;
int main() {
     long long  int a,b,c,d,s=0,m=0;
     cin>>a>>b>>c>>d;
     m=max  ((a*c), (a*d)  );
     s=max  ((b*c), (b*d));
     cout<<max(m,s)<<endl;

}


Measured memory_bytes: 3672
module Main where

import Control.Monad
import Control.Applicative
import Data.List

showingList :: [Int] -> String
showingList (x:[]) = show x
showingList (x:xs) = (show x) ++ " " ++ (showingList xs)

solve :: [Int] -> Int -> Int
solve (x:xs) idx = if x == 0 then idx else solve xs (idx + 1)

main :: IO ()
main = do
    x <- map read . words <$> getLine :: IO [Int]
    print $ solve x 1


Measured memory_bytes: 3888
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pli = std::pair<long long, int> ;

using namespace std;

const long long MOD = 1000000007;

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

	char c;
	cin >> c;
	++c;
	cout << c << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define vii vector<pii>
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 


int solve(){

	double n;cin>>n;
	double area=M_PI*n*2;
	cout<<fixed<<setprecision(10)<<area;


    return 0;
}
signed main(){
    asdf
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3752
#include <iostream>
using namespace std;
int main(void){
    long long a, b;
    long long tmp, r , x;
    
    cin >> a >> b;
    
    x = a * b;
    
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
     }
     
    r = a % b;
    
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
 
    cout << x/b << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        while(true){
            String line = br.readLine();
            if(line.equals("0")){
                break;
            }
            
            char[] charArray = line.toCharArray();
            int total = 0;
            for(int i = 0; i < charArray.length; i++){
                char ch = charArray[i];
                total += Character.getNumericValue(ch);
            }
            
            System.out.println(total);
        }
    }
}

Measured memory_bytes: 24108
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

constexpr ll MAX = 1LL<<50;

vector<vector<pair<ll, ll>>> edge;
vll dp;
vb path_flag;

void search(const ll pos, const ll tmp_cost){
  //printf("%ld vs %ld\n", tmp_cost, dp[pos]);
  if(tmp_cost <= dp[pos]) return;
  if(path_flag[pos]){
    if(dp[pos] < tmp_cost){
      path_flag[pos] = false;
      dp[pos] = MAX;
      for(auto tmp_pair : edge[pos]){
        search(tmp_pair.first, MAX);
      }
      path_flag[pos] = true;
    }
    return;
  }
  path_flag[pos] = true;
  dp[pos] = max(tmp_cost, dp[pos]);
  for(auto tmp_pair : edge[pos]){
    //printf("%d to %d\n", pos, tmp_pair.first);
    search(tmp_pair.first, min(tmp_cost+tmp_pair.second, MAX));
  }
  path_flag[pos] = false;
  return;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, M;
  cin >> N >> M;
  edge.resize(N);
  REP(i, M){
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    pair<ll, ll> tmp(b, c);
    edge[a].push_back(tmp);
  }

  dp.resize(N, -MAX);
  path_flag.resize(N, false);

  search(0, 0);

  if(dp[N-1]==-MAX || dp[N-1]==MAX){
    cout << "inf\n";
  }else{
    cout << dp[N-1] << "\n";
  }

  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>//Lunch565
int main(void)
{
	int a,b,c,d,e;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	if(b<=a && b<=c){
		a=b;
	}
	else if(c<=a && c<=b){
		a=c;
	}
	if(e<=d){
		d=e;
	}
	printf("%d\n",a+d-50);
	return 0;
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
#define rep(i,n) 
using namespace std;
 
int main() {
  int N, D;
  cin >> N >> D;
  int a[11][11];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> a[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      int x = 0;
      for (int k = 0; k < D; k++) {
        x += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]); // ^2したら謎解でてきたので今度から累乗はしない
      }
      double y = sqrt(x);
      if (ceil(y) == floor(y)) ans++; // ceilとfloor使うの天才っぽい、if(y%1.0==0)とかでもいけそう(やってないけど)
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

vi v;
int n,ans;
bool calc[200000];
int memo[200000];
int dp (int x){
    if(x < 0){return 200000;}
    else if(x==0)return 0;
    else if(calc[x])return memo[x];
    else{
        int mn = 200000;
        for(int i=v.size()-1;i>=0;i--){
            if(v[i]>x){continue;}
            else{
                mn = min (mn, 1 + dp(x-v[i]));
            }
        }
        calc[x]=true;
        memo[x]=mn;
        return mn;
    }
}
int main(){
	//IO();
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    int temp = 6;
    v.pb(1);
    while(temp<=100000){
        v.pb(temp);
        temp *= 6;
    }
    temp = 9;
    while(temp<=100000){
        v.pb(temp);
        temp *= 9;
    }

    sort(v.begin(),v.end());
    cin>>n;
    cout<<dp(n)<<newl;

}


Measured memory_bytes: 768
#設定
import sys
input = sys.stdin.buffer.readline

#入力受け取り
def getlist():
	return list(map(int, input().split()))

N, K = getlist()
const = 10 ** 9 + 7
fac = [0] * (N + 1)
inv = [0] * (N + 1)
finv = [0] * (N + 1)
fac[0], fac[1] = 1, 1
inv[1] = 1
finv[0], finv[1] = 1, 1

for i in range(2, N + 1):
	fac[i] = fac[i - 1] * i % const
	inv[i] = inv[const % i] * (const - (const // i)) % const
	finv[i] = finv[i - 1] * inv[i] % const

#処理内容
def main():

	for i in range(1, K + 1):
		if i > N - K + 1:
			print(0)
		else:
			ans = fac[N - K + 1] * finv[N - K + 1 - i] * finv[i] * fac[K - 1] * finv[i - 1] * finv[K - i]
			print(ans % const)



if __name__ == '__main__':
	main()

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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> P;

int main(){
		vector<int> A(3);
		rep(i,3){
			cin>>A[i];
		  }
		  SORT(A);
		  int ans = 0;
		  rep(i,3){
			  ans+=A[i];
			  if(i>=1){
				  ans -= A[i-1];
				}
			}
			cout<<ans-A[0]<<endl;
	  }



Measured memory_bytes: 256
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
  
ans=0
for i in range(k):
  ans += (a[i]+1)/2
past=ans
for i in range(1,n-k+1):
  tmp = past - (a[i-1]+1)/2 +  (a[i+k-1]+1)/2
  if ans<tmp:
    ans=tmp
  past = tmp
    
print(ans)

Measured memory_bytes: 71792
#include <iostream>
using namespace std;
int main(void){

	int n;
	cin >> n;

	int num[100];

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

	for (int j = 0; j < n - 1; j++) cout << num[j] << ' ';
	cout << num[n - 1] << endl;

	for (int i = 1; i < n; i++){

		int temp = num[i];
		int k = i;
		for (int j = i - 1; j >= 0; j--){

			if (num[j] <= temp)
				break;
			num[k] = num[j];
			k = j;
		}

		num[k] = temp;
		for (int j = 0; j < n - 1; j++) cout << num[j] << ' ';
		cout << num[n - 1] << endl;
	}
}

Measured memory_bytes: 1160
import sys
sys.setrecursionlimit(10**6)
n, q = map(int, input().split())

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

c = [0] * n

for j in range(q):
    p, x = map(int, input().split())
    c[p - 1] += x

used = [0] * n
used[0] = 1

def dfs(x):
    cost=c[x]
    for nx in g[x]:
        if used[nx]:
            continue
        used[nx]=1
        c[nx]+=cost
        dfs(nx)
dfs(0)
print(*c)

Measured memory_bytes: 223188
#include<bits/stdc++.h>
#define ll long long
using namespace std;
char s[105][105];
int a[30];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0; i<n; i++)
    {
        scanf("%s",s[i]);
    }
    memset(a,0,sizeof(a));
    for(int i=0; i<n; i++)
        for(int j=0; j<m; j++)
        {
            a[s[i][j]-'a']++;
        }
    int x=0,y=0,z=0;
    for(int i=0; i<26; i++)
    {
        x+=a[i]/4;
        y+=(a[i]%4)/2;
        z+=(a[i]%4)%2;
    }
    if(n%2==0&&m%2==0)
    {
        if(y>=1||z>=1)
            printf("No\n");
        else
            printf("Yes\n");
    }
    else if((n%2==1&&m%2==0)||(n%2==0&&m%2==1))
    {
        if(z>=1)
            printf("No\n");
        else
        {
            if(n-y*2>=0&&((n-y*2)%4==0)&&n%2==0)
                printf("Yes\n");
            else if(m-y*2>=0&&((m-y*2)%4==0)&&m%2==0)
                printf("Yes\n");
            else
                printf("No\n");
        }
    }
    else
    {
        if(z==1&&n+m-2-2*y>=0&&((n+m-2)-2*y)%4==0)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    string s,k;
    cin>>s;
    k=s;
    VREV(k);
    if(s==k)
    {
        cout<<"Yes"<<NL;
    }
    else
    {
        cout<<"No"<<NL;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n,a,b; cin>>n>>a>>b;
	cout<<min(b,n*a)<<endl;



	return 0;
}


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

int main()
{
  int a, b;
  string s;
  cin >> a >> b >> s;
  bool flag = true;
  for (int i = 0; i < s.size(); i++) {
    if (i == a) {
      if (s[i] != '-') flag = false;
    }
    else {
      if (!('0' <= s[i] && s[i] <= '9')) flag = false;
    }
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
s_pos = []
c_pos = []

for i in range(n):
    a, b = map(int, input().split())
    s_pos.append([a, b])

for i in range(m):
    c, d = map(int, input().split())
    c_pos.append([c, d])

for i in range(n):
    min_dist = 10 ** 16
    c_index = 0
    for j in range(m):
        dist = abs(s_pos[i][0] - c_pos[j][0]) + abs(s_pos[i][1] - c_pos[j][1])
        if dist < min_dist:
            min_dist = dist
            c_index = j + 1
    print(c_index)

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

using namespace std;

long long xorsum(long long in) {
  if (in % 4 == 0) {
    return in;
  }
  
  if (in % 4 == 1) {
    return 1;
  }
  
  if (in % 4 == 2) {
    return in + 1;
  }
  
  if (in % 4 == 3) {
    return 0;
  }
}

int main() {
  long long A, B;
  
  cin >> A >> B;
  
  cout << (xorsum(B) ^ xorsum(A - 1)) << endl;
  
  return 0;
}

Measured memory_bytes: 384
N = int(input())
l = [list(i) for i in input().split()]

a = l.copy()
frag = 1
i = 0
while frag:
    frag = 0
    for j in range(N-1,i,-1):
        if a[j][1] < a[j-1][1]:
            a[j], a[j-1] = a[j-1], a[j]
        frag = 1
    i += 1 
bubble_a = ["".join(a[i]) for i in range(N)]
print(" ".join(bubble_a))
print("Stable")

a = l.copy()
for i in range(N):
    minj = i
    for j in range(i,N):
        if a[j][1] < a[minj][1]:
            minj = j
    if i != minj:
        a[i], a[minj] = a[minj], a[i]
selection_a = ["".join(a[i]) for i in range(N)]
print(" ".join(selection_a))

if bubble_a == selection_a:
    print("Stable")
else:
    print("Not stable")

Measured memory_bytes: 7796
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    string s;
    ll k;
    cin >> s >> k;
    int n = s.length();
    if(n == 1){
        cout << k/2 << endl;
        return 0;
    }
    bool same = true;
    for(char c : s) same &= c == s[0];
    if(same){
        cout << k*(n)/2 << endl;
        return 0;
    }
    ll ans = 0;
    int i = 0;
    while(i < n){
        int j = i;
        while(j < n && s[j] == s[i])   j++;
        ans += (j-i)/2;
        i = j;
    }
    ans *= k;
    if(s[0] == s.back() && k > 1){
        int i = 0, j = n-1;
        while(s[0] == s[i]) i++;
        while(s[0] == s[j]) j--;
        ans -= (i/2+(n-1-j)/2)*(k-1);
        ans += (i+n-1-j)/2*(k-1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

vector<LL> fact, finv, inv;

void init_nCk(int N) {
  fact.resize(N + 1);
  finv.resize(N + 1);
  inv.resize(N + 1);
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i <= N; i++) {
    fact[i] = fact[i - 1] * i % kMod;
    inv[i] = kMod - inv[kMod % i] * (kMod / i) % kMod;
    finv[i] = finv[i - 1] * inv[i] % kMod;
  }
}

LL nCk(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fact[n] * (finv[k] * finv[n - k] % kMod) % kMod;
}

int main() {
  LL S; cin >> S;
  init_nCk(20000);

  S -= 3;
  LL i = 0;
  LL ans = 0;
  while (S >= 0) {
    ans = (ans + nCk(S + i, i)) % kMod;
    S -= 3;
    ++i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3700
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define LL long long
#define NUM 1000000007

using namespace std;

int main()
{
    string s;
    cin >> s;
    if (s.size() >= 4)
    {
        if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lson l, mid, i<<1
#define rson mid+1, r, i<<1|1
#define PII pair<int, int>
#define Size(x) (int)(x.size())
using namespace std;
typedef long long LL;
//const int MOD = 1e9+7;
const auto INF = 0x3f3f3f3f;
const int N = 2e5+5;

char str[N];
LL num[26];

int main() {
//    freopen("/Users/xin58/Desktop/in.txt", "r", stdin);
    scanf("%s", str);
    int len = (int)strlen(str);
    LL ans = 0;
    for(int i=0; i<len; i++) {
        ans += num[str[i]-'a'];
        num[str[i]-'a']++;
    }
    LL answer = (LL)(1+len)*(LL)len/2;
    answer++;
    printf("%lld\n", answer - ans - len);
}





Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std; 
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define mp make_pair
#define endl "\n"
#define N (ll)2e5+10 




int main(){
    
    ios::sync_with_stdio(0);
    
    int n ;
    cin >> n ;
    int d[n] , i , j;
    for(i=0 ; i<n ; i++){
    	cin >> d[i] ;
    }
    int ans = 0 ;
    for(i=0  ; i<n ; i++){
    	for(j=i+1 ; j<n ; j++){
    		ans += d[i]*d[j] ;
    	}
    }
    cout << ans ;

    return 0 ;
 }

Measured memory_bytes: 3592
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
using namespace std;

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


int gcd(int a, int b) {
	if (a%b==0) return b;
	else return gcd(b, a%b);
}

int main() {
	int n;
	cin >> n;
	int A[n];
	rep(i, n) cin >> A[i];

	int t = gcd(A[0], A[1]);
	for (int i=2; i<n; i++) {
		t = gcd(t, A[i]);
	}
	cout << t << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int h(int a,int b)
{   if(a<b) return b;
       else return a;
}
int main()
{
    int n,i,j;
    int sum[2][100];
    while(scanf("%d",&n)!=EOF)
    {
        for (i=0;i<=1;i++)
            for (j=0;j<n;j++)
            scanf("%d",&sum[i][j]);
            sum[1][0]=sum[1][0]+sum[0][0];
            for (i=1;i<n;i++)
                {
                    sum[0][i]=sum[0][i-1]+sum[0][i];
                    sum[1][i]=sum[1][i]+h(sum[0][i],sum[1][i-1]);
                }


        printf("%d\n",sum[1][n-1]);

    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];	a[i]--;
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(a[a[i]]==i)	cnt++;
	}
	cout<<cnt/2<<endl;
	return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

n = int(input())

cnt25 = [[0]*19 for i in range(19)]

for i in range(n):
    a = input()[:-1]
    cnt2 = 0
    cnt5 = 0
    if "." in a:
        a, b = a.split(".")
        cnt2 += 9 - len(b)
        cnt5 += 9 - len(b)
        a = int(a+b)
    else:
        a = int(a)
        cnt2 += 9
        cnt5 += 9
    b = a
    while a>0 and a%2 == 0:
        a //= 2
        cnt2 += 1
    while b>0 and b%5 == 0:
        b //= 5
        cnt5 += 1

    cnt25[min(18, cnt2)][min(18, cnt5)] += 1

sumcnt = [[cnt25[i][j] for j in range(19)] for i in range(19)]
for i in range(18,-1,-1):
    for j in range(18, 0, -1):
        sumcnt[i][j-1] += sumcnt[i][j]

for i in range(18, -1, -1):
    for j in range(18, 0, -1):
        sumcnt[j-1][i] += sumcnt[j][i]

ans = 0
for i in range(19):
    for j in range(19):
        ans += cnt25[i][j] * sumcnt[18-i][18-j]
        if 18-i <= i and 18-j <= j and cnt25[i][j] > 0:
            ans -= cnt25[i][j]


print(ans//2)


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

const int INF = 2e9;

int solve(int x, int y) {
  if (x > y) return INF;
  return y - x;
}

int main() {
  int x, y;
  cin >> x >> y;

  int ans = solve(x, y);
  ans = min(ans, solve(-x, y) + 1);
  ans = min(ans, solve(x, -y) + 1);
  ans = min(ans, solve(-x, -y) + 2);

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


Measured memory_bytes: 256
def gcd(p,q):
  #print(str(p)+" "+str(q))
  big=max(p,q)
  small=min(p,q)
  if small==0:
    return big
  else:
    return gcd(big%small,small)

ab=input().split(" ")
a=int(ab[0])
b=int(ab[1])
print(a*b//gcd(a,b))

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//方針
//最短経路問題と思いきや、リットルが足りないと通れない道が存在する
//一度に移動できる距離の連続 (Lで割ったときの値が小さい組合せをとればよい)
//満パン状態から1リットルで行けるものをコスト1に変換しちゃう???

ll d[300][300] = {};
int N,M,L;

void warshallFloyd(int n) {
  for (int k = 0; k < n; ++k){       // 経由する頂点
    for (int i = 0; i < n; ++i) {    // 始点
      for (int j = 0; j < n; ++j) {  // 終点

        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

      }
    }
  }
}

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

    REP(i,N)REP(j,N)d[i][j] = MOD;
    //とりあえず各道のコストをとっちゃう?
    REP(i,M)
    {
        int a,b,c;
        cin >> a >> b >> c;
        --a;--b;
        d[a][b] = c;
        d[b][a] = c;
    }
    warshallFloyd(N);
    //Lを超える値をINFに、L以下を1にする
    REP(i,N)
    {
        REP(j,N)
        {
            if(d[i][j] <= L)d[i][j] = 1;
            else d[i][j] = MOD;
        }
    }

    warshallFloyd(N);

    int Q;
    cin >> Q;

    REP(i,Q)
    {
        int s,t;
        cin >> s >> t;
        --s;--t;

        int res;
        if(d[s][t] >= MOD)res = -1;
        else res = d[s][t] - 1;
        cout << res << endl;

    }

    return 0;    
}



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

#define LL long long
#define DD long double

#define M 1000000007
#define INF 1e18

void setIO(string s = "") { 
  cin.sync_with_stdio(0); cin.tie(0);
  if (s.size()) s += ".in", freopen(s.c_str(), "r", stdin);
}

int tt = 1;
void solve() {
  set<int> nums;
  int a;
  while (cin >> a) nums.insert(a);
  cout << ((nums.size() == 2) ? "Yes" : "No") << endl;
}

int main() {
  setIO();
  while (tt--) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 110
char a[N][N];
int n,m;
int dir[4][2]={{0,1},{1,0},{-1,0},{0,-1}};
int check(int x,int y)
{
    int i,j,k;
    for(i=0;i<4;i++)
    {
        j=x+dir[i][0];
        k=y+dir[i][1];
        if(j<0||j>=n||k<0||k>=m)
            continue;
        if(a[j][k]=='#')
            return 1;
    }
    return 0;
}
int main()
{
    int i,j,k,flag;
    flag=1;
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++)
        scanf("%s",a[i]);
    for(i=0;i<n;i++)
    for(j=0;j<m;j++)
    if(a[i][j]=='#')
    if(check(i,j)==0)
        flag=0;
    if(flag)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


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

using namespace std;

int n;
vector<int> a;

int main() {
	scanf("%d", &n);
	a.resize(n);
	for (int i = 1; i < n; i++) {
		int x; scanf("%d", &x);
		a[x - 1]++;
	}

	for (auto &x : a) printf("%d\n", x);
	return 0;
}

Measured memory_bytes: 4044
n, a, b, c = list(map(int, input().split()))
lll = [int(input()) for _ in range(n)]

ans = 10 ** 9
for i in range(4 ** n):
    abc = [0] * 3
    tmp = 0
    for j in range(n):
        k = (i >> (2 * j)) & 3
        if k < 3:
            if abc[k] > 0:
                tmp += 10
            abc[k] += lll[j]
    if any(t == 0 for t in abc):
        continue
    tmp += sum(abs(d - e) for d, e in zip((a, b, c), abc))
    ans = min(ans, tmp)
print(ans)


Measured memory_bytes: 3064
N, *L,  = [list(map(int, s.split())) for s in open(0)]
A = L[:1][0]
B = L[1:]
cnt = 0
for b in B:
    c = 0
    for i in range(len(b)):
        c += A[i]*b[i]
    if c + N[2] > 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n>>s;
  for(int i=0;i<n;i++) for(int j=0;j<s.size();j++){
  	char t=s[j];
    if(t!='Z') t++;
    else t='A';
    s[j]=t;
  }
  cout<<s;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;i <= 0; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x); i++)
#define rreps(i,x) for(ll i = (ll)(x)-1; i <= 1; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll a,b,c; cin >> a >> b >> c;
    set<ll> st;
    st.insert(a);
    st.insert(b);
    st.insert(c);
    if(st.size() == 2)cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

int main()
{
    int x, y; cin >> x >> y;
    for(int i=0; i<=x; ++i){
        if (i*2 + (x - i)*4 == y) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  int N, M, C;
  cin >> N >> M >> C;
  int B[M];
  REP(i, M) { cin >> B[i]; }
  int A[N][M];
  REP(i, N) {
    REP(j, M) { cin >> A[i][j]; }
  }
  int cnt = 0;
  REP(i, N) {
    int sum = C;
    REP(j, M) { sum += A[i][j] * B[j]; }
    if (sum > 0) {
      cnt++;
    }
  }

  cout << cnt;
  return 0;
}

Measured memory_bytes: 256
/*
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,n)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
using li = long int;
using ull= unsigned long long;
using vi = vector<li>;
using vs = vector<string>;


int main()
{
    li n;
    cin>>n;
    li a[n];
    rep(i,n)cin>>a[i];
    for(int i=n-1;i>=0;i-=2) cout<<a[i]<<" ";
    for(int i=n%2;i<n;i+=2) cout<<a[i]<<" ";
    cout<<endl; 
    
    return 0;
}



Measured memory_bytes: 3712
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

#define MAX_N 10000
struct edge{ int to, cap, rev; };

vector<edge> G[MAX_N];
int level[MAX_N]; // sからの距離
int iter[MAX_N];  // どこまで調べ終わったか

void add_edge(int from, int to, int cap) {
  G[from].PB({to, cap, (int)G[to].size()});
  G[to].PB({from, 0, (int)G[from].size()-1});
}

void bfs(int s) {
  memset(level, -1, sizeof(level));
  queue<int> que;
  level[s] = 0;
  que.push(s);
  while(que.size()) {
    int v = que.front(); que.pop();
    for(auto i: G[v]) {
      if(i.cap > 0 && level[i.to] < 0) {
        level[i.to] = level[v] + 1;
        que.push(i.to);
      }
    }
  }
}

int dfs(int v, int t, int f) {
  if(v == t) return f;
  for(int &i = iter[v]; i<(int)G[v].size(); ++i) {
    edge &e = G[v][i];
    if(e.cap > 0 && level[v] < level[e.to]) {
      int d = dfs(e.to, t, min(f, e.cap));
      if(d > 0) {
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s, int t) {
  int flow = 0;
  while(1) {
    bfs(s);
    if(level[t] < 0) return flow;
    memset(iter, 0, sizeof(iter));
    int f;
    while((f = dfs(s, t, INF)) > 0) flow += f;
  }
}

int dist[205][205];
int u[2010], v[2010], d[2010], c[2010];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, m, s, t;
  cin >> n >> m >> s >> t;
  s--, t--;
  REP(i, 205) REP(j, 205) dist[i][j] = (i==j?0:LLINF);
  REP(i, m) {
    cin >> u[i] >> v[i] >> d[i] >> c[i];
    u[i]--, v[i]--;
    dist[u[i]][v[i]] = d[i];
  }

  REP(k, n) REP(i, n) REP(j, n) {
    chmin(dist[i][j], dist[i][k]+dist[k][j]);
  }

  REP(i, m) {
    if(dist[s][u[i]] + d[i] + dist[v[i]][t] == dist[s][t]) {
      add_edge(u[i], v[i], c[i]);
    }
  }

  cout << max_flow(s, t) << endl;

  return 0;
}



Measured memory_bytes: 4016
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int p[1100][1100];
int G[1100][1100];
vector<int>g[510000];
int v[510000];
int dfs(int a){
	if(v[a]==-2){
		return -2;
	}
	if(v[a]!=-1){
		return v[a];
	}
	v[a]=-2;
	int ret=0;
	for(int i=0;i<g[a].size();i++){
		int tmp=dfs(g[a][i]);
		if(tmp==-2)return -2;
		ret=max(ret,tmp+1);
	}
	return v[a]=ret;
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		for(int j=0;j<a-1;j++){
			scanf("%d",&p[i][j]);p[i][j]--;
		}
	}
	int sz=0;
	for(int i=0;i<a;i++){
		for(int j=i+1;j<a;j++)
			G[i][j]=sz++;
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<a-2;j++){
			int fi=G[min(i,p[i][j])][max(i,p[i][j])];
			int se=G[min(i,p[i][j+1])][max(i,p[i][j+1])];
			g[fi].push_back(se);
		}
	}
	for(int i=0;i<sz;i++)v[i]=-1;
	int ret=0;
	for(int i=0;i<sz;i++){
		if(v[i]==-1){
			int val=dfs(i);
			if(val==-2){
				printf("-1\n");return 0;
			}
			ret=max(ret,val);
		}
	}
	printf("%d\n",ret+1);
}

Measured memory_bytes: 38912
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a <= 5) cout << 0 << endl;
  else if(a <= 12) cout << b / 2 << endl;
  else cout <<  b << endl;
}

Measured memory_bytes: 256
/*à¥à¥*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* â€œStrength is the only thing that matters in this world. Everything else is just a delusion for the weak.â€ â€“ Vegeta */

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



ll N,D;
/*ll freq[200005];*/
void solve(){
   /*memset(freq,0,sizeof(freq));*/
  cin>>N>>D;
   ll x,y;
   ll count = 0;
  for(ll i = 0 ; i<N ; i++){
    cin>>x>>y;
    
    if(  sqrt(x*x + y*y) <= D)
      count++;
  }


cout<<count<<'\n';


}



int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
   solve();

  return 0;
}

Measured memory_bytes: 3664
Scanf.scanf "%d" (fun n ->
    let k = 18 in
    let mat = Array.make_matrix (k + 1) (k + 1) 0 in
    let fact a =
        let rec loop_5 i acc2 acc5 =
            if i mod 5 = 0 then loop_5 (i / 5) acc2 (acc5 + 1) else acc2, acc5
        in
        let rec loop_2 i acc =
            if i mod 2 = 0 then loop_2 (i / 2) (acc + 1) else loop_5 i acc 0
        in
        loop_2 a 0
    in

    let rec loop i acc =
        if i = n then acc else
            let acc = Scanf.scanf " %f" (fun f ->
                let (d2, d5) = fact (int_of_float (f *. 1000000000. +. 0.5)) in
                let d2 = min d2 k in
                let d5 = min d5 k in
                mat.(d2).(d5) <- mat.(d2).(d5) + 1;
                if d2 * 2 >= k && d5 * 2 >= k then acc + 1 else acc
            )
            in
            loop (i + 1) acc
    in
    let acc = loop 0 0 in
    let sum = Array.make_matrix (k + 1) (k + 1) 0 in
    sum.(k).(k) <- mat.(k).(k);
    for i = k - 1 downto 0 do
        sum.(i).(k) <- sum.(i + 1).(k) + mat.(i).(k);
        sum.(k).(i) <- sum.(k).(i + 1) + mat.(k).(i);
    done;
    for y = k - 1 downto 0 do
        for x = k - 1 downto 0 do
            sum.(y).(x) <- mat.(y).(x) + sum.(y + 1).(x) + sum.(y).(x + 1) - sum.(y + 1).(x + 1)
        done
    done;

    let rec loop_2 i2 acc =
        let rec loop_5 i5 acc =
            if i5 = k + 1 then loop_2 (i2 + 1) acc else
                let acc = acc + mat.(i2).(i5) * sum.(k - i2).(k - i5) in
                loop_5 (i5 + 1) acc
        in
        if i2 = k + 1 then acc else loop_5 0 acc
    in
    let res = loop_2 0 0 in
    Printf.printf "%d\n" @@ (res - acc) / 2
)

Measured memory_bytes: 5972
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define FF first
#define SS second
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

#define N 1000004

void solve()
{
	lli a,b,c,k;
	cin>>a>>b>>c>>k;

	lli cnt=0;
	while(b <= a) 
	{
		b*=2;
		cnt++;
	}

	while(c <= b) 
	{
		c*=2;
		cnt++;
	}

	if(cnt <= k) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	

}

int main()
{
/////////////////////////////////////
    fastio;
/////////////////////////////////////  

    lli t;
    t=1;
    
    loopl(i,1,t+1)
    {
    	//cout<<"Case #"<<i<<": ";
    	solve();
    }  
}	
   


Measured memory_bytes: 3652
#include <cstdio>
#define N 100005
int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}
int n,k;
bool ans;
int a[N];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]),ans|=a[i]>=k;
	int g=a[1];
	for(int i=2;i<=n;++i)
		g=gcd(a[i],g);
	ans&=(k%g==0);
	puts(ans?"POSSIBLE":"IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<map>
using namespace std;

int x, n, m;
int main()
{
	scanf("%d%d%d", &x, &n, &m);
	int sum = x - n;
	int y = sum / m;
	printf("%d\n", sum - (y * m));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;

ll A[200002], ps[200002], px[200002];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);

	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) cin >> A[i];
	for (int i = 0; i < N; ++i) ps[i + 1] = A[i] + ps[i], px[i + 1] = A[i] ^ px[i];
	ll ans = 0;
	for (int i = 0; i < N; ++i) {
		int l = i - 1, h = N;
		for (int j = 0; j < 20; ++j) {
			int m = (l + h) / 2;
			((ps[m + 1] - ps[i]) == (px[m + 1] ^ px[i])) ? l = m + 1 : h = m;
		}
		ans += h - i;
	}
	cout << ans;
}

Measured memory_bytes: 8336
#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 double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  if(N%1000 == 0) cout << 0 <<endl;
  else cout << 1000-N%1000 <<endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int n;

template <typename T>
void print(vector<T> vec)
{
    int n = vec.size();
    for (int i = 0; i < n; i++)
    {
        cout << vec[i] << (i == n - 1 ? "\n" : " ");
    }
}

template <typename T>
void bubbleSort(vector<T> &A, int &cnt)
{
    int n = A.size();
    cnt = 0;
    bool flag = true;
    while (flag)
    {
        flag = false;
        for (int i = n - 1; i > 0; i--)
        {
            if (A[i] < A[i - 1])
            {
                swap(A[i], A[i - 1]);
                flag = true, cnt++;
            }
        }
    }
    print(A);
}

// https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/all/ALDS1_1_A

#include <vector>
template <typename T>
void insertionSort(vector<T> &A)
{
    print(A);
    int n = A.size();
    for (int i = 1; i < n; i++)
    {
        T v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v)
        {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        print(A);
    }
}

int main()
{
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++)
        cin >> A[i];
    insertionSort(A);
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    int H,W;
    cin >> H >> W;
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];
    
    vector<vector<int>> ans(H,vector<int>(W,-1));
    
    int u = 0;
    int ww = 0;
    rep(h,H) rep(w,W){
        if(h%2==0) ww = w;
        else ww = W-1-w;
        if(a[u] > 0){
            a[u]--;
            ans[h][ww] = u+1;
        }
        if(a[u] == 0) u++;
        
        
    }
    
    rep(i,H){
        rep(j,W) cout << ans[i][j] << " ";
        cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 384