akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl
using IT = vector<int>::iterator;
using ll = long long;

ll merge(IT s_orig, IT u, IT t, int n) {
  IT s_end = u, s = s_orig;
  int s_size = n/2, t_size = n - n/2;
  vector<int> v;
  ll ans = 0;
  REP(k, n) {
    if (s_size > 0 && t_size > 0) {
        if (*s < *u) {
          v.push_back(*s);
          ++s;
          --s_size;
        } else {
          v.push_back(*u);
          ++u;
          ans += s_size;
          --t_size;
        }
    } else if (t_size == 0) {
      v.push_back(*s);
      ++s;
      --s_size;
    } else {
      v.push_back(*u);
      ++u;
      --t_size;
    }
  }
  int i = 0;
  for (auto s = s_orig; s != t; ++s) {
    *s = v[i++];
  }
  return ans;
}
ll mergeSort(IT s, IT t, int n) {
  if (n <= 1)
    return 0;
  ll ans = 0;
  ans += mergeSort(s, s + n/2, n/2) + mergeSort(s + n/2, t, n - n/2);
  ans += merge(s, s + n/2, t, n);
  return ans;
}
int main() {
  IN(N);

  vector<int> A;
  REP(i, N) {
    IN(a);
    A.push_back(a);
  }
  cout << mergeSort(A.begin(), A.end(), N) << endl;

  return 0;
}



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

int main(){
  int N,count = 0;
  string S;
  cin >> N >> S;
  for (int i = 0; i < (N - 2); i++){
    if (S.at(i) == 'A' && S.at(i + 1) == 'B' && S.at(i + 2) == 'C') count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define int               long long
#define M                 1000000007
#define MM                998244353
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount

template<typename T1,typename T2>
std::istream& operator>>(std::istream& in,pair<T1,T2> &a)
{
	in>>a.fr>>a.sc;
	return in;
}
template<typename T1,typename T2>
std::ostream& operator<<(std::ostream& out,pair<T1,T2> &a)
{
	out<<a.fr<<" "<<a.sc;
	return out;
}

vector<int> v[100005];
int dp[100005][2];
int dfs(int z,int p,int c){
	int &ans=dp[z][c];
	if(ans!=-1)return ans;
	ans=1;
	for(int x:v[z]){
		if(x==p)continue;
		if(c)ans*=dfs(x,z,!c);
		else ans*=(dfs(x,z,!c)+dfs(x,z,c))%M;
		ans%=M;
	}
	return ans;
}

void solve(){
	mem1(dp);
	int n;
	cin>>n;
	rep(i,1,n){
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	int ans= (dfs(1,0,0)+dfs(1,0,1))%M;
	cout<<ans;
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	#ifdef DSU
		cleardsu(MAXDSUSIZE);
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 15616
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    n, k = map(int,input().split())
    x = 1
    y = 0
    if n == 1:
        print(1)
        exit()
    while x <= n:
        x *= k
        y += 1
    print(y)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
# 入力データの数値化
nums = list(map(int, input().split()))
A = nums[0] 
B = nums[1]
C = nums[2]

count=0

if C-1-B <= 0 or C-1-B <=A:
  print(C+B)
else:
  print(1+2*B+A)

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

using ll = long long;
#define mod 1000000007
#define init ios::sync_with_stdio(0), cin.tie(0);
typedef vector<int> vi;
typedef pair<int, int> pi;
#define MS(x, y) memset(x, y, sizeof(x))
#define F first
#define S second
#define PB push_back
#define MP make_pair

int main()
{
    init;

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max({a * c, a * d, c * a, c * b, d * b});
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a % b) : a;
}

int main(){
  ll n;cin>>n;
  vector<ll> t(n);
  rep(i,n){
    cin>>t[i];
  }
  ll ans=1;
  rep(i,n){
    ans=t[i]*(ans/gcd(t[i],ans));
  }
  cout<<ans<<endl;    
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int A[100050], B[100050], C[100050];

int main() {
  int N = in();
  int K = in();

  if (2 * K > N + 1) {
    puts("-1");
    return 0;
  }

  int ai = 1, bi = 0;
  for (int i = 0; i < N; ++i) {
    A[ai] = i;
    ai += 2;
    B[bi] = N + i;
    bi += 2;
    C[i] = 2 * N + i;
    if (ai >= N) ai = 0;
    if (bi >= N) bi = 1;
  }

  for (int i = 0; i < N; ++i) {
    printf("%d %d %d\n", A[i] + K, B[i] + K, C[i] + K);
    assert(A[i] + K + B[i] + K <= C[i] + K);
  }

  return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define ll long long
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define abs(a,b) (a-b>0?a-b:b-a)


int main(){
    int n,T;
    cin >> n >> T;
    vi t(n);
    rp(i,n){
        cin >> t[i];
    }
    int ans=0;
    if(n==1){
        cout << T << endl;
    }else{
        rp(i,n-1){
            if(t[i+1]-t[i]<=T){
                ans += t[i+1]-t[i];
            }else{
                ans += T;
            }
        }
        ans += T;
        cout << ans << endl;
    }
}








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

const int INF = 1<<24;
int N, M;
string S, P, G;
int E[501][501];
map<string, int> id;

int main() {
  while(cin >> N >> M && (N || M)) {
    id.clear();
    cin >> S >> P >> G;
    for(int i = 1; i <= N; ++i) {
      for(int j = 1; j <= N; ++j) {
	E[i][j] = INF;
      }
    }
    for(int i = 0; i < M; ++i) {
      string a, b;
      int d, t;
      cin >> a >> b >> d >> t;
      if(id[a] == 0) id[a] = id.size();
      if(id[b] == 0) id[b] = id.size();
      int cost = d/40 + t;
      E[id[a]][id[b]] = min(E[id[a]][id[b]], cost);
      E[id[b]][id[a]] = min(E[id[b]][id[a]], cost);
    }

    for(int k = 1; k <= N; ++k) {
      for(int i = 1; i <= N; ++i) {
	for(int j = 1; j <= N; ++j) {
	  E[i][j] = min(E[i][j], E[i][k] + E[k][j]);
	}
      }
    }
    cout << E[id[S]][id[P]] + E[id[P]][id[G]] << endl;
  }
  return 0;
}

Measured memory_bytes: 1944
#include<stdio.h>
#define N 100
int main(){
  int i,j,n,v,A[N],k;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  for(i=0;i<n-1;i++) printf("%d ",A[i]); printf("%d",A[n-1]);
  printf("\n");
  for(i=1;i<n;i++){
    v=A[i];
    j=i-1;
    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    for(k=0;k<n-1;k++){
      printf("%d ",A[k]);
    }
    printf("%d",A[n-1]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  vi a(n);
  vi b(m);
  rep(i,n) cin >> a.at(i);
  rep(i,m) cin >> b.at(i);
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  for(int i=x+1;i<=y;i++){
    if(a.at(n-1) < i && b.at(0) >= i){
      cout << "No War" <<endl;
      return 0;
    }
  }
  cout << "War" << endl;
}


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

const int N_MAX=9;
vector<int> fac(N_MAX);

void factorial(){
  fac[0]=1;
  for(int i=1;i<N_MAX;++i){
    fac[i]=fac[i-1]*i;
  }
}

int main(){
  int N;
  cin>>N;
  vector<int> P(N),Q(N);
  for(int i=0;i<N;++i) cin>>P[i];
  for(int i=0;i<N;++i) cin>>Q[i];

  int64_t ordP=0,ordQ=0;
  factorial();
  
  set<int> S;
  for(int i=0;i<N;++i){
    S.insert(i+1);
  }


  for(int i=0;i<N;++i){
    int count=0;
    
    for(auto s:S){
      if(s<=P[i]-1){
        ++count;
      }
    }
    
    ordP += count*fac[N-i-1];
    S.erase(P[i]);
  }

  set<int> T;
  for(int i=0;i<N;++i){
    T.insert(i+1);
  }
  
  for(int i=0;i<N;++i){
    int count=0;
    
    for(auto s:T){
      if(s<=Q[i]-1){
        ++count;
      }
    }
    
    ordQ += count*fac[N-i-1];
    T.erase(Q[i]);
  }

  cout<<abs(ordP-ordQ)<<endl;
}


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

int main() {
    int a[5];
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
    int ans = 0;
    rep(i,5) ans += (a[i]+9)/10*10;
    int subt = 0;
    rep(i,5) subt = max(subt,(a[i]+9)/10*10-a[i]);
    ans -= subt;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	long A = Long.parseLong(stdIn.next());
	long B = Long.parseLong(stdIn.next());
	long K = Long.parseLong(stdIn.next());
	long n =A-K;
	if(A+B<=K){
	    System.out.println("0 0");
	}else if(n<0){
	    System.out.println("0 "+(A+B-K));
	}else{
	    System.out.println(n+" "+B);
	}
    }
}


Measured memory_bytes: 21716
<?php
fscanf(STDIN, "%d%d", $n,$l);

$arr = [];
for($i = 0;$i < $n; $i++){
 	fscanf(STDIN, "%s", $s);
  	$arr[$i] = $s;
}
sort($arr, SORT_STRING);

$string="";
for($i = 0;$i < $n; $i++){
  	$string .= $arr[$i];
}
	echo"$string";

?>

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end() //使うときはsort(all())という感じで
using ll = long long;
#define PI 3.14159265359

int main(){
  int n;
  ll ans=0;
  cin>>n;
  map<ll, ll> a;
  vector<ll> am(n);
  rep(i,n){
    int ai;
    cin>>ai;
    am.at(i)=ai;
    a[ai]++;
  }
  for(auto p:a){
  ll v=p.second;
  ans+=v*(v-1)/2;
  }
  rep(i,n){
    cout<<ans-ll(a[am[i]])*ll(a[am[i]]-1)/2+ll(a[am[i]]-1)*ll(a[am[i]]-2)/2<<endl;
  }
  return 0;
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}

int main(){
    M();
    int arr[300];
    arr[1]=300000;
    arr[2]=200000;
    arr[3]=100000;

    int x,y;
    cin>>x>>y;
    ll ans=0;
    for(int i=1;i<=3;i++){
        if(x==i){
            ans+=arr[i];
        }
    }
    for(int i=1;i<=3;i++){
        if(y==i){
            ans+=arr[i];
        }
    }
    if(x==1&&y==1) ans+=400000;
    cout<<ans<<endl;
}




Measured memory_bytes: 256
n=int(input())
x=1
if n<=599:
	x=8
elif n<=799:
	x=7
elif n<=999:
	x=6
elif n<=1199:
	x=5
elif n<=1399:
	x=4
elif n<=1599:
	x=3
elif n<=1799:
	x=2
print(x)


Measured memory_bytes: 9168
#include<iostream>
using namespace std;
int main(){
	char b[52];
	int n,i,a[52];
	int S[52]={0},H[52]={0},C[52]={0},D[52]={0};

	cin>>n;
	for(i=1;i<=n;i++){
		cin>>b[i]>>a[i];
	}
	for(i=1;i<=n;i++){
		if(b[i]=='S')S[a[i]]=a[i];
		else if(b[i]=='H')H[a[i]]=a[i];
		else if(b[i]=='C')C[a[i]]=a[i];
		else if(b[i]=='D')D[a[i]]=a[i];
	}
	for(i=1;i<=13;i++){
		if(S[i]==0)cout<<"S "<<i<<endl;
	}
	for(i=1;i<=13;i++){
		if(H[i]==0)cout<<"H "<<i<<endl;
	}
	for(i=1;i<=13;i++){
		if(C[i]==0)cout<<"C "<<i<<endl;
	}
	for(i=1;i<=13;i++){
		if(D[i]==0)cout<<"D "<<i<<endl;
	}

	return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <memory>

//#define int long long

using namespace std;

void Main()
{
	int n = 0;
	int m = 0;

	cin >> n >> m;

	cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}

int32_t main()
{
	Main();
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b;
    cin >> a >> b;
    
    int waru = a / b;
    int amari = a % b;
    double syousu = (double)a / b;
    
    printf("%d %d %.10f\n", waru, amari ,syousu);
}



Measured memory_bytes: 3228
s=input()
n=len(s)
ans=0
for i in range(1<<(n-1)):
  tmp=int(s[0])
  for j in range(n-1):
    if (i&(1<<j)):
      tmp*=10
      tmp+=int(s[j+1])
    else:
      ans+=tmp
      tmp=int(s[j+1])
  ans+=tmp
print(ans)



Measured memory_bytes: 3060
#include "bits/stdc++.h"



using namespace std;

#define int long long int
#define loop(i,s,e) for(int i=s; i<e; i++)
#define endl '\n'
#define vii vector<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX
#define M (int)(1e9+7)

void INP();

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}
int arr[22][22];
int n;
int dp[22][(1<<22)];

int util(int i, int mask){

	if(i==n and mask==(1<<n)-1) return 1;
	if(i==n) return 0;
	//if(i + 1 < __builtin_popcount(mask)) return dp[i][mask] = 0;

	if(dp[i][mask]!=-1) return dp[i][mask];

	int ans=0;
	loop(j,0,n){
		if(arr[i][j]==1 and (mask & (1<<j))==0){
			int nmask = (mask ^ (1<<j));
			ans += util(i+1, nmask);
			ans%=M;
		}
	}

	return dp[i][mask] = ans;
	
}

void alpha()
{	
	cin>>n;

	memset(dp, -1, sizeof(dp));

	loop(i,0,n){
		loop(j,0,n){
			cin>>arr[i][j];
		}
	}

	cout<<util(0, 0)<<endl;

	return;
}

int32_t main(){

	ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//INP();
    int t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}



inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}
 
 

Measured memory_bytes: 721280
#include<iostream>
using namespace std;
string s;
int n,q,k;
main()
{
	cin>>n>>s>>q;
	while(cin>>k)
	{
		long cd=0,cm=0,c=0,a=0;
		for(int i=0;i<n;i++)
		{
			if(i>=k)
			{
				if(s[i-k]=='D')cd--,c-=cm;
				else if(s[i-k]=='M')cm--;
			}
			if(s[i]=='D')cd++;
			else if(s[i]=='M')cm++,c+=cd;
			else if(s[i]=='C')a+=c;
		}
		cout<<a<<endl;
	}
}


Measured memory_bytes: 1412
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		String st = sc.next();
		int N = sc.nextInt();

		String ans = "";
		for(int n=0;n<(int)Math.ceil((float)st.length()/N);n++){

			ans += st.charAt(N*n);
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 24768
#include "bits/stdc++.h"

using namespace std;

void solve()
{
	int N, L, Q;
	cin >> N;
	vector<int> xs(N);
	for (int i = 0; i < N; i++)
	{
		cin >> xs[i];
	}
	cin >> L >> Q;
	vector<vector<int>> memo(20, vector<int>(N));
	for (int i = N-1; i >= 0; i--)
	{
		int ok = i, ng = N;
		while(ok+1 < ng)
		{
			int m = (ok + ng) / 2;
			(xs[i] + L >= xs[m] ? ok : ng) = m;
		}
		memo[0][i] = ok;
		int pos = ok;
		for (int j = 0; j < 19 && pos < N; j++)
		{
			pos = memo[j+1][i] = memo[j][pos];
		}
	}

	while (Q--)
	{
		int a, b;
		cin >> a >> b;
		a--, b--;
		if (a > b) swap(a, b);
		int ans = 0;
		while(a < b)
		{
			int ok = 19, ng = 0;
			while(ok > ng+1)
			{
				int m = (ok + ng) / 2;
				(memo[m][a] >= b ? ok : ng) = m;
				//cout << a << ' ' << b << ' ' << ok << ' ' << memo[ok][a] << endl;
			}
			a = memo[ng][a];
			ans += pow(2, ng);
		}
		cout << ans << endl;
	}
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 9080
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int n,k;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	in(n);in(k);
	if(n%k==0)printf("0\n");
	else printf("1\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
using ld=long double;
const ld eps=1e-10;

int k_,r,l;
ld p,e,t;

ld dfs(ld lo, ld hi, int k){
  //REP(i,k_-k)cout<<" ";
  ld mid=(lo+hi)/2;
  if(k==0){
    bool isExact=t-e-eps<mid&&mid<t+e+eps;
    //cout<<lo<<" "<<hi<<" "<<(isExact?1.0:0.0)<<endl;
    return isExact?1.0:0.0;
  }
  if (t+e+eps<lo||hi<t-e-eps){
    //cout<<lo<<" "<<hi<<" "<<0.0<<endl;
    return 0.0;
  }
  if (t-e-eps<lo&&hi<t+e+eps){
    //cout<<lo<<" "<<hi<<" "<<1.0<<endl;
    return 1.0;
  }
  //cout<<lo<<" "<<hi<<endl;
  ld pHi=mid>=t?p:1-p;
  ld pLo=(1-pHi);
  return dfs(lo,mid,k-1)*pLo+dfs(mid,hi,k-1)*pHi;
}

void solve(){
  cout<<fixed<<setprecision(6)<<dfs((ld)r,(ld)l,k_)<<endl;
}

int main(){ _;
  cin>>k_>>r>>l;
  cin>>p>>e>>t;
  solve();
}

Measured memory_bytes: 3284
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

int main(void) {
  int ch = getchar();
  putchar(ch+1);
  return 0;
}


Measured memory_bytes: 256
s = gets.chomp.split('')
cnt = 0
sumo = 0
s.each do |i|
  sumo += 1
  if i == 'o'
    cnt += 1
  end
end

if cnt > 7
  puts 'YES'
else
  k = 15 - sumo
  if k+cnt > 7
    puts 'YES'
  else
    puts 'NO'
  end
end


Measured memory_bytes: 1788
import Data.Char
import Data.List

main = interact $ unlines . map affine_cipher . tail . lines

affine_cipher str = affine a b str
 where
  (a,b) = try (sequence [cand_a,cand_b]) (filter ((==4) . length) $ words str)
  try ([a,b]:cands) words4
   | any (\w -> intersect (words $ affine a b w) ["that","this"] /= []) words4 = (a,b)
   | otherwise = try cands words4
  cand_a = filter (\x -> gcd x 26 == 1) [1..100]
  cand_b = [0..25]

affine a b str = encode str
 where
  encode [] = []
  encode (c:cs)
   | isLower c = to_lower ((a * to_digit c + b) `mod` 26) : encode cs
   | otherwise = c : encode cs
  to_digit c = length (takeWhile (/= c) "abcdefghijklmnopqrstuvwxyz")
  to_lower n = head (drop n "abcdefghijklmnopqrstuvwxyz")

Measured memory_bytes: 4092
import sys

inputs = [row.split() for row in sys.stdin.readlines()]

mount_list = inputs[1]
mount_list = [int(height) for height in mount_list]

result_cnt = 0
old_max_height = mount_list[0]
for height in mount_list:
    new_max_height = max(old_max_height, height)
    if old_max_height < new_max_height:
        result_cnt+=1
        old_max_height = new_max_height
    elif old_max_height == height:
        result_cnt+=1    
print(result_cnt)



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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
typedef long long ll;

int n;
ll a[51], k; 

int main()
{
	cin >> n;
	fo(i,0,n-1) cin >> a[i];
	while(1)
	{
		ll t, s; t = s = 0;
		fo(i,0,n-1) {t=a[i]/n;a[i]%=n;a[i]-=t;s+=t;}
		if(!s)break;
		fo(i,0,n-1) a[i]+=s;
		k += s;
	}
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 256
mod = 10**9+7
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
def cinit(N):
    for i in range( 2, N + 1 ):
        g1[i] = ( ( g1[i-1] * i ) % mod )
        inverse[i] = ( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2[i] = ( (g2[i-1] * inverse[i]) % mod )
X,Y = map(int, input().split())
if (X+Y)%3==0and(X<Y*2 or Y<X*2):
    N = (X+Y)//3
    g1,g2,inverse = [0]*(N+1),[0]*(N+1),[0]*(N+1)
    g1[0],g1[1],g2[0],g2[1],inverse[0],inverse[1] = 1,1,1,1,0,1
    cinit(N)
    p = (min(X,Y)*2 - max(X,Y))//3
    print(cmb((X+Y)//3,p,mod))
else:
    print(0)

Measured memory_bytes: 82076
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

//最大公約数
ll gcd(ll m, ll n)
{
	if (m < n) {
		swap(m, n);
	}

	if (n == 0) {
		return m;
	}

	return gcd(n, m % n);
}

//最小公倍数
ll lcm(ll m, ll n)
{
	// 引数に０がある場合は０を返す
	if ((0 == m) || (0 == n))
		return 0;

	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

signed main() {
	ll a, b, c, d;

	cin >> a >> b >> c >> d;

	ll x = lcm(c, d);

	ll cd = b / x - (a - 1) / x;

	ll cc = b / c - (a - 1) / c;

	ll dd = b / d - (a - 1) / d;

	cout << (b - a + 1) - (cc + dd - cd) << endl;
}

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

char fi[25][25];
int h,w;

int p[4] = {1,0,-1,0};
int q[4] = {0,1,0,-1};

int fh(int x, int y){
	return x*w + y;
}

int apsp[405][405];

int main(){
	scanf("%d%d",&h,&w);
	for(int i=0;i<h;i++){
		scanf("%s",fi[i]);
	}
	
	for(int i=0;i<h*w;i++){
		for(int j=0;j<h*w;j++){
			if(i==j) apsp[i][j] = 0;
			else apsp[i][j] = 1e9;
		}
	}
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(fi[i][j] == '#') continue;
			int dari = fh(i,j);
			for(int k=0;k<4;k++){
				int ti = i+p[k];
				int tj = j+q[k];
				if(ti < 0 || ti >= h || tj < 0 || tj >= w || fi[ti][tj] == '#') continue;
				int ke = fh(ti,tj);
				apsp[dari][ke] = 1;
			}
		}
	}
	for(int k=0;k<h*w;k++){
		for(int i=0;i<h*w;i++){
			for(int j=0;j<h*w;j++){
				apsp[i][j] = min(apsp[i][j],apsp[i][k] + apsp[k][j]);
			}
		}
	}
	
	int ans = 0;
	
	for(int i=0;i<h*w;i++){
		for(int j=0;j<h*w;j++){
			if(apsp[i][j] == 1e9) continue;
			ans = max(ans,apsp[i][j]);
		}
	}
	
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define inf 1000000007
#define N 1005
using namespace std;

typedef long long ll;
typedef pair < int , int > ii;

int n, m, ans, d[N][N];
int o[] = {1, -1, 0, 0};
int p[] = {0, 0, 1, -1};
char s[N][N];
priority_queue < pair < int , ii > > q;

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d %d",&n ,&m);
	for(int i = 1; i <= n; i++)
		scanf("%s",s[i] + 1);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(s[i][j] == '.')
				d[i][j] = inf;
			else{
				d[i][j] = 0;
				q.push(mp(0, mp(i, j)));
			}
	// cout << "AMK" << endl;
	while(!q.empty()){
		int i = q.top().nd.st;
		int j = q.top().nd.nd;
		q.pop();
		// cout << i << " " << j << endl;

		ans = max(ans, d[i][j]);
		for(int k = 0; k < 4; k++)
			if(i + o[k] > 0 and j + p[k] > 0 and i + o[k] <= n and j + p[k] <= m and d[i + o[k]][j + p[k]] > d[i][j] + 1){
				d[i + o[k]][j + p[k]] = d[i][j] + 1;
				q.push(mp(-d[i + o[k]][j + p[k]], mp(i + o[k], j + p[k])));
			}
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 18412
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  char s[10010];
  scanf("%d %s",&n,s);
  int len=strlen(s);
  for(int i=0;i<len;i++){
    int x=s[i]-'A';
    x=(x+n)%26;
    putchar('A'+x);
  }
  putchar('\n');
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            switch (S)
            {
                case "SUN":
                    Console.WriteLine("7");
                    break;
                case "MON":
                    Console.WriteLine("6");
                    break;
                case "TUE":
                    Console.WriteLine("5");
                    break;
                case "WED":
                    Console.WriteLine("4");
                    break;
                case "THU":
                    Console.WriteLine("3");
                    break;
                case "FRI":
                    Console.WriteLine("2");
                    break;
                case "SAT":
                    Console.WriteLine("1");
                    break;
                default:
                    Console.WriteLine();
                    break;
            }
        }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 25588
#include <bits/stdc++.h>
using namespace std;
const int tam = 3005;
int dp[tam][tam][3];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s, t;
    cin >> s >> t;
    int n1 = s.size(), n2 = t.size();
    memset(dp, 0, sizeof  dp);
    for(int i = n1-1; i >= 0; i--) {
        for(int j = n2-1; j >= 0; j--) {
            if(s[i] == t[j]) {
                dp[i][j][0] = 1 + dp[i+1][j+1][0];
                dp[i][j][1] = i+1;
                dp[i][j][2] = j+1;
            } else {
                /*if(dp[i+1][j+1][0] >= dp[i][j+1][0] && dp[i+1][j+1][0] >= dp[i+1][j][0]) {
                    dp[i][j][0] = dp[i+1][j+1][0];
                    dp[i][j][1] = i+1;
                    dp[i][j][2] = j+1;
                    continue;
                }*/
                if(dp[i][j+1][0] >= dp[i+1][j][0]) {
                    dp[i][j][0] = dp[i][j+1][0];
                    dp[i][j][1] = i;
                    dp[i][j][2] = j+1;
                } else {
                    dp[i][j][0] = dp[i+1][j][0];
                    dp[i][j][1] = i+1;
                    dp[i][j][2] = j;
                }
            }
        }
    }
    //cout << dp[n1-1][n2-1][0] << ' ' << dp[n1-1][n2-1][1] << ' ' << dp[n1-1][n2-1][2] << '\n';
    /*for(int i=0; i<n1; i++) {
        for(int j=0; j<n2; j++) {
            cout << dp[i][j][1] << dp[i][j][2] <<' ';
        }
        cout << '\n';
    }*/
    int x = 0, y = 0;
    while(x < n1 && y < n2) {
        if(s[x] == t[y]) {
            cout << s[x];
        }
        //cout << x << y << '\n';
        int temp = dp[x][y][1];
        y = dp[x][y][2];
        x = temp;
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 106112
from collections import deque

H,W=map(int,input().split())
grid=[input() for i in range(H)]
dist=[[-1]*W for _ in range(H)]

M=deque()
for i in range(H):
    for j in range(W):
        if grid[i][j]=="#":
            M.append((i,j))
            dist[i][j]=0

def bfs(M,dist):
    d=0
    while M:
        x,y=M.popleft()
        d=dist[x][y]
        for dx,dy in ((1,0),(0,1),(-1,0),(0,-1)):
            new_h=x+dy
            new_w=y+dx
            if new_h < 0 or H <= new_h or new_w <0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:
                dist[new_h][new_w]=d+1
                M.append((new_h,new_w))
    return d

d=bfs(M,dist)
print(d)



Measured memory_bytes: 86620
void main() {
  problem();
}

void problem() {
  const K = scan!long;

  long solve() {
    long ans;
    foreach(a; 1..K+1) {
      foreach(b; 1..K+1) {
        foreach(c; 1..K+1) {
          ans += a.gcd(b).gcd(c);
        }
      }
    }

    return ans;
  }

  solve().writeln;
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }

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


Measured memory_bytes: 2752
N=io.read"*n"
K=io.read"*n"
A={}
for i=1,N do
	A[i]=io.read"*n"
end

D={[0]=A}
for i=1,math.log(K)/math.log(2) do
	D[i]={}
	for j=1,N do
		D[i][j]=D[i-1][D[i-1][j]]
	end
end

local a=1
for i=0,math.log(K)/math.log(2)do
	if((K>>i)&1~=0)then
		a=D[i][a]
	end
end
print(a)

Measured memory_bytes: 248496
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
static const ll MOD = 2019;
int main(){
    ll L, R;cin >> L >> R;
    int modL = L % MOD, modR = R %MOD;
    int MIN  = 2019;
    if(modL >= modR){
        cout << 0 << endl;
        return 0;
    }
    if(R - L >= MOD){
        cout << 0 << endl;
        return 0;
    }
    for(int i = modL; i <modR; i++){
        for(int j = i + 1; j <= modR; j++){
            if(MIN > (i * j) % MOD) MIN = (i * j) % MOD;
        }
    }
    cout << MIN << endl;
}

Measured memory_bytes: 256
D = gets.to_i
C,*S = (0..D).map{gets.split.map &:to_i}
1 < (I=(0..25).select{C[_1]==0}).size and S.each {|s;z|
  I.each {|i| if i!=(z||=i); s[z]<s[i] ? z = i+s[z]=0 : s[i]=0 end }
}
L,M,N = [-1]*27,3,6
def calc(d,n)
  s,x = S[d],0
  n = D-d  if n > D-d
  t = (0..25).map {s[_1] > 0 ? C[_1]*(d-L[_1])*n+s[_1] : 0}
  i = (0..25).max_by(M){t[_1]}.max_by {|i|
    0 == (c=t[i])*(n-1) and next c
    l,L[i] = L[i],d
    c += calc(d+1,n-1) >> 5
    L[i] = l
    x < c ? x=c : c
  }
  ((x>0 ? x : t[i]) << 5) + i
end
D.times { p 1 + i=calc(_1,N)&31; L[i]=_1 }

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

typedef long long ll;
const ll mod=1e9+7;
const ll N=2e5+1;
const ll INF=1e10;

int n,m,cnt,ans=0;
vector<vector<int>> adj(N);
vector<bool> visited(N);
set<pair<int,int>> edge;

void dfs(int u){
	visited[u]=true;
	cnt++;
	for(int v:adj[u]){
		if(!visited[v]) dfs(v);
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		if(edge.find({u,v})!=edge.end() or edge.find({v,u})!=edge.end()) continue;
		adj[v].push_back(u);
		adj[u].push_back(v);
	}
	for(int i=1;i<=n;i++){
		if(!visited[i]){
			cnt=0;
			dfs(i);
			ans=max(ans,cnt);
		}
	}
	cout<<ans;
} 


Measured memory_bytes: 20280
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int MAXN=100000;

int n,q;
LL a[MAXN+1],sum[MAXN+1],sum2[MAXN+1];

void init(){
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sum[0]=0;
	for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
	sum2[0]=0;
	sum2[1]=a[1];
	for(int i=2;i<=n;i++) sum2[i]=sum2[i-2]+a[i];
}

void solve(){
	while(q--){
		LL x; scanf("%lld",&x);
		int L=1,R=(n+1)/2,Mid;
		int i,j;
		while(L<R){
			Mid=(L+R)/2;
			j=n-Mid;
			i=j-Mid;
			if(i>0&&abs(x-a[i])<=abs(x-a[j])) L=Mid+1;
			else R=Mid;
		}
		Mid=(L+R)/2;
		j=n-Mid;
		i=j-Mid;
		
		LL ans=sum[n]-sum[j]+sum2[i];
		printf("%lld\n",ans);
	}
}

int main(){
	init();
	solve();
} 

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    ll ans = 0;

    ll R = min(n, k);

    for (ll a = 0; a <= R; a++)
    {
        for (ll b = 0; a + b <= R; b++)
        {
            priority_queue<ll, vector<ll>, greater<ll>> pq;
            for (ll i = 0; i < a; i++)
            {
                pq.push(v[i]);
            }
            for (ll i = 0; i < b; i++)
            {
                pq.push(v[n - i - 1]);
            }

            for (ll i = 0; i < k - (a + b); i++)
            {
                if (pq.empty())
                {
                    break;
                }
                if (pq.top() < 0)
                {
                    pq.pop();
                }
            }

            ll tmp = 0;

            while (!pq.empty())
            {
                tmp += pq.top();
                pq.pop();
            }

            ans = max(ans, tmp);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
    int a, b;
    cin >> a >> b;
    if(a < b){
        for(int i = 0;i < b;i++){
            printf("%d", a);
        }
    } else {
        for(int i = 0;i < a;i++){
            printf("%d", b);
        }
    } 

    printf("\n");         
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int a, b, k;
    cin >> k;
    cin >> a >> b;
    int aa = a / k;
    int bb = b / k;

    if (a % k ==0 || b % k == 0) {
        cout << "OK";
    } else if (aa != bb) {
        cout << "OK";
    } else {
        cout << "NG";
    }

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair
#define mod 1000000007
#define qmod 998244353
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const ll LINF = LLONG_MAX;

int main(){
	ll k,n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	ll sum1=0,sum2=0;
	for(int i=0;i<n;i++){
		if(i%2==0){
			sum1 +=a[i];
		}
		else{
			sum2 +=a[i];
		}
	}
	cout<<abs(sum1-sum2)<<endl;
	

}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int ans = 0;
    REP(i, 1, n - 1) {
        if ((p[i] > p[i-1] && p[i] < p[i+1]) || (p[i] < p[i-1] && p[i] > p[i+1])) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int mod = 1000000007;

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

  long long ans = 1;
  int x = 0, y = 0, z = 0;
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    if (a[i] == x) { cnt++; }
    if (a[i] == y) { cnt++; }
    if (a[i] == z) { cnt++; }

    ans = (ans * cnt) % mod;

    if (a[i] == x) { x++; }
    else if (a[i] == y) { y++; }
    else if (a[i] == z) { z++; }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int time;
	int s;
	int m;
	int h;

	scanf("%d",&time);
	h = time / 3600;
	time = time % 3600;
	m = time / 60;
	s = time % 60;
	//m = (time - (h * 3600) )/ 60;
	//s = time % 60;
	//s = time / 60;
	//c = a * b;
	//d = (a * 2) + ( b * 2 );
	
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define ll long long int
#define pi 3.1415926535897
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug 0
#define loop(a,b) for(a=0;a<b;a++)
#define test() while(t--)
 
using namespace std;
 

 

int pointer,n;
ll maxm,res;

ll vis[100005];
ll ar[100005];
ll ans[100005];
ll mark[100005];
ll segTree[500005];
ll cost[100006];

vector<int> adj[100005];

void constructTree(int node, int start, int end)
{
    if(start == end)
    {
         segTree[node] = 0;
    }
    else
    {
        int mid = (start + end) / 2;
        constructTree(2*node, start, mid);
        constructTree(2*node+1, mid+1, end);
        segTree[node] = max(segTree[2*node],segTree[2*node+1]);
    }
}


void update(int si, int ss, int se,int pos,ll val)
{
    if (ss>se || pos<ss || pos>se)
        return ;
        
 
   
    if (ss==se)
    {
    	//int old_val=cost[ss];
    	cost[ss]=val;
    	ll new_val=cost[ss];
    	ll old_val=segTree[si];
    	ll diff=new_val-old_val;
        segTree[si]+=diff;
        return;
    }
    
 
    int mid = (ss+se)/2;
    update(si*2, ss, mid,pos,val);
    update(si*2+1, mid+1,se,pos,val);
 
    segTree[si] = max(segTree[si*2],segTree[si*2+1]);
    //return;
}

ll get(int node, int start, int end, int l, int r)
{
	
	if(r < start || end < l)
    {
        return 0;
    }
    if(l <= start && end <= r)
    {
        return segTree[node];
    }
    
    
   
    int mid = (start + end) / 2;
    ll min1 = get(2*node, start, mid, l, r);
    ll min2 = get(2*node+1, mid+1, end, l, r);
    return max(min1,min2);
}

void DFS(int s)
{

	vis[s]=true;
	
	
	vector<int>::iterator it;
	vector<pair<int,ll> >::iterator jt;
	
	int val=ar[s];
	
	ans[s]=val;
//	update(1,1,n,pointer,ans[s]);
	pointer++;
	
	
	for(it=adj[s].begin();it!=adj[s].end();++it)
	{
		if(!vis[*it])
		{
		
		//val=ar[*it];
		mark[*it]=ar[*it]^ans[s];
		res=res^mark[*it];
		
		//cout<<res<<"\n";
		if(res>maxm)
		maxm=res;
		DFS(*it);	
			
		}
		//answ[*it]=dist[*it];
	
		//update(1,1,n,pointer,dist[*it]);
		
			
		
	   }
	
	pointer--;
	res=mark[s];
	
	
}


int main()
{
	int m,a,b,i,j,q,v,home,k,t,n;
	ll w;
	
string str;

cin>>str;

int len=str.length();

cout<<str[0]<<len-2<<str[len-1];
}

Measured memory_bytes: 4352
K,S = map(int,input().split())
ans = 0

for x in range(K+1):
    rem = S - x
    if rem < 0: break
    if rem > 2*K: continue
    for y in range(K+1):
        z = rem - y
        if z < 0: break
        if z > K: continue
        ans += 1
print(ans)


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<pair<int, int> > v;
	rep (i, n) {
	  int a;
	  cin >> a;
	  v.emplace_back(a, i + 1);
	}
	sort(v.begin(), v.end());
	rep (i, n) {
	  cout << v[i].second;
	  if (i == n - 1) cout << endl;
	  else cout << " ";
	}
    
    return 0;
}



Measured memory_bytes: 4164
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map{ it.toInt() }
    
    val ans = when{
        a == b -> a + b
        a > b -> a + (a - 1)
        else -> b + (b - 1)
    }
    
    println(ans)
}


Measured memory_bytes: 35956
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int n, k;
	int cnt4 = 0, cnt1 = 0, cnt2 = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		if (num % 4 == 0) {
			cnt4++;
		}
		else if (num % 2 == 1) {
			cnt1++;
		}
		else if (num % 2 == 0) {
			cnt2++;
		}
	}

	if (cnt1 == 1 && cnt4 >= 1) {
		cout << "Yes" << endl;
	}
	else if (cnt4 >= cnt1 - 1 && (cnt4-(cnt1-1)>=(cnt2>=1?1:0)) ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}





	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array(lr())
diff = A.max() - A.min()
if diff > 1:
    print('No')
    exit()
if diff == 0:
    if A[0] == N-1:
        print('Yes')
    else:
        group = A[0]
        if 2 * group > N:
            print('No')
        else:
            print('Yes')
    exit()
else:
    # 差が１
    x = np.count_nonzero(A==A.min()) #自分自身はalone
    group = A.max()
    if x < group and 2 * (group-x) <= N - x:
        print('Yes')
    else:
        print('No')
#13

Measured memory_bytes: 23436
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        n: usize,
        b: [u64;n-1]
    }
    let mut v = Vec::new();
    v.push(b[0]);
    for i in 1..n-1 {
        v.push(std::cmp::min(b[i-1], b[i]));
    }
    v.push(b[n-2]);
    println!("{}", v.iter().sum::<u64>());
}
/* vim:set foldmethod=marker: */


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

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

typedef long long ll;

using namespace std;

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

  string result = n == m ? "Yes" : "No";

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
vector<vector<int> > adj;
vector<int> A, ans, s;

void dfs(int i, int p) {
    int j = lower_bound(s.begin(), s.end(), A[i]) - s.begin();
    int save = s[j];
    s[j] = A[i];
    ans[i] = max(ans[i], j);
    for (int j : adj[i]) {
        if (j != p) { ans[j] = ans[i]; dfs(j, i); }
    }
    s[j] = save;
}

int main() {
    int n; scanf("%d", &n);
    adj.resize(n);
    A.resize(n);
    for (int &a : A) scanf(" %d", &a);
    for (int i = 1; i < n; i++) {
        int u, v; scanf(" %d %d", &u, &v);
        u--; v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    ans.resize(n);
    s.resize(n, 1<<30);
    s[0] = 0;
    dfs(0, -1);
    for (int a : ans) printf("%d\n", a);
}


Measured memory_bytes: 33316