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

class Dice{
    void advance_vertical(){ 
        advance(0, 1, 5, 4); // N方向
    }
    
    void advance_horizontal(){ 
        advance(0, 3, 5, 2); // E方向
    }

    void advance_rotation(){
        advance(1, 2, 4, 3);
    }

    void advance(int i, int j, int k, int l){
        int tmp = x[i]; 
        x[i] = x[j];
        x[j] = x[k];
        x[k] = x[l];
        x[l] = tmp;
    }

public:
    vector<int> x;
    
    Dice() = default;
    Dice(vector<int> x) : x(x) {}
    
    void roll(const string& command){
        for(const auto c : command){
            if(c == 'E'){
                advance_horizontal();
            }
            else if(c == 'N'){
                advance_vertical();
            }
            else if(c == 'S'){
                for(int i = 0; i < 3; ++i){
                    advance_vertical();
                }
            }
            else{
                for(int i = 0; i < 3; ++i){
                    advance_horizontal();
                }
            }
        }      
    }

    int getNow(){
        return x[0];
    }

    int getRightSide(int top_side, int front){
        for(int i = 0; i < 6; i++){ // 面一つずつ見ていく
            for(int j = 0; j < 4; j++){ // rotate方向 4回す
                if(x[0] == front && x[4] == top_side){
                    return x[2];
                }
                advance_rotation();
            }
            if(i % 2 == 0){
                advance_vertical();
            }
            else{
                advance_horizontal();
            }
        }
        return 0; // 失敗
    }

    bool isSame(Dice dice){
        for(int i = 0; i < 6; i++){ // 面一つずつ見ていく
            for(int j = 0; j < 4; j++){ // rotate方向 4回す
                if(dice.x == x){
                    return true;
                }
                advance_rotation();
            }
            if(i % 2 == 0){
                advance_vertical();
            }
            else{
                advance_horizontal();
            }
        }
        return false;
    }
};

int main(){

    int n;
    cin >> n;
    vector<Dice> dice(n);
    for(int i = 0; i < n; ++i){
        vector<int> x(6);
        for(int j = 0; j < 6; ++j){
            cin >> x[j];
        }
        Dice tmp(x);
        dice[i] = tmp;
    }

    bool ok = true;
    for(int i = 0; i < n-1; ++i){
        for(int j = i+1; j < n; ++j){
            if(dice[j].isSame(dice[i])){
                ok = false;
            }
        }
    }
    if(ok){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3172
#include <stdio.h>
#include <string.h>

static char * e;

static int
term (
  void
  )
{
  if ( *e == '~' )
  {
    ++e;
    return ( -*( e++ ) );
  }

  return ( *( e++ ) );
}

static int
expr (
  void
  )
{
  for ( ; ; )
  {
    char res[ 3 ];

    if ( *e == '\0' ) break ;

    ++e;
    res[ 0 ] = term ( );
    ++e;
    res[ 1 ] = term ( );
    ++e;
    res[ 2 ] = term ( );
    ++e;
    e += !!( *e == '|' );

    if ( res[ 0 ] != -res[ 1 ]
      && res[ 1 ] != -res[ 2 ]
      && res[ 2 ] != -res[ 0 ] )
    {
      return ( 1 );
    }
  }

  return ( 0 );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    char s[ 512 ];

    scanf ( " %s", s );
    if ( !strcmp ( s, "#" ) ) break ;

    e = s;
    puts ( expr ( ) ? "yes" : "no" );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
using namespace std;

int main() {
	int x, y, s;
	while(cin >> x >> y >> s, x || y || s) {
		int res = 0;
		for(int i = 1; i < s; i++) {
			for(int j = 1; j < s; j++) {
				int a, b;
				a = (double)i * (100 + x) / 100;
				b = (double)j * (100 + x) / 100;
				if(a + b == s) {
					int c, d;
					c = (double)i * (100 + y) / 100;
					d = (double)j * (100 + y) / 100;
					res = max(res, abs((c+d)));
				}
			}
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 1164
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
inline int  in(){int n;scanf("%lld",&n);return n;}
inline void out(int n){printf("%lld\n",n);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

string s;
string t;

signed main(){
    io();
    cin >> s;
    cin >> t;
    rep(i,s.size()){
        if(s==t){
            yes;
            return 0;
        }
        char c=s[s.size()-1];
        for(int j = s.size()-1;j>0;j--){
            s[j]=s[j-1];
        }
        s[0]=c;
        //cout<<s<<endl;
    }
    no;

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using T = tuple<ll,int,int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

int main(void){
  ll l,r;
  cin >> l >> r;
  ll calc = 2019 * (l / 2019 + (l % 2019 != 0));
  if(calc <= r){
    cout << 0 << endl;
    return 0;
  }
  ll res = inf;
  for(ll i = l;i <= r;++i){
    for(ll j = i+1;j <= r;++j){
      res = min(res, (i*j) % 2019);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;

typedef long long ll;
ll INF = 1LL << 60;
ll MAX = 100010;
ll MOD = 2019;

int
main() 
{

  string S; cin >> S;
  ll K; cin >> K;
  string ans;
  if(S.size() > K){
    rep(i, 0, K){
      ans = S[i];
      if(S[i] != '1') break;
    }
  } else {
    rep(i, 0, S.size()){
      ans = S[i];
      if(S[i] != '1')break;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
vector<P> ans;
string S;
bool solve(){
    vector<ll> v;
    if(S[0] == '0' || S[S.size() - 1] == '1') return 0;
    for(ll i = 1; i < S.size() / 2; i++){
        if(S[i] != S[S.size() - i - 2]) return 0;
        if(S[i] == '1' && S[i + 1] == '0') v.push_back(i);
    }
    ll parent = S.size();
    for(ll i = S.size() - 2; i >= 0; i--){
        if(S[i] == '0'){
            ans.push_back(P(parent, i + 1));
        }else{
            ans.push_back(P(parent, i + 1));
            parent = i + 1;
        }
    }
    return 1;
}
int main(){
    cin >> S;
    if(solve()) for(P p : ans) cout << p.first << " " << p.second << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3312
#include<stdio.h>
int main()
{
  int h , w , i , j;

  while(1){
    scanf("%d%d",&h ,&w);
    if(h == 0 && w == 0) break;

    for(i = 0 ; i < h ; i++){
      for(j = 0 ; j < w ; j++){
	printf("#");
      
      }
    
      printf("\n");
    
    }

    printf("\n");

  }

  return 0;
  
}

Measured memory_bytes: 572
#include<stdio.h>
int srx[51]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
    int n;
    scanf("%d",&n);
    printf("%d",srx[n]);
    return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    ll N; cin >> N;
    ll M=0;
    int A[N+1];
    for(ll i=1; i<=N; i++) cin >> A[i];
    int dp[N];
    for(ll i=N; i>0; i--){
        dp[i] = A[i];
    }
    for(ll i=N/2; i>0; i--){
        for(ll j=2; j<=N/i; j++){
            dp[i] += dp[i*j];
            dp[i] %= 2;
        }
    }
    for(ll i=1; i<=N; i++){
        if(dp[i]==1) M++;
    }      
    cout << M << endl;
    for(ll i=1; i<=N; i++){
        if(dp[i]==1){
            cout << i << endl;
        }
    }             
}

    


Measured memory_bytes: 2432
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys


def get_ints():
    return map(int, sys.stdin.readline().strip().split())


def std_in():
    return sys.stdin.readline().strip()


def main():
    n = int(std_in())
    a = list(get_ints())
    a.append(0)
    m = 1000
    k = 0

    for i in range(n):
        if i == n:
            break
        if a[i] > a[i+1]:
            m += k * a[i]
            k = 0
        elif a[i] < a[i+1]:
            q, mod = divmod(m, a[i])
            k += q
            m = mod
    print(m)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61832
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H;
	string s;
	while(cin>>H>>W>>N) {
		ll l = max(H, W);
		ll ans = (N+l-1)/l;
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner scn = new Scanner(System.in);
		int cnt = scn.nextInt();
		String a = scn.next();
		String b = scn.next();
		String result = "";
		String[] c = new String[cnt];
		String[] d = new String[cnt];
		for(int i=0;i<cnt;i++){
			c[i] = a.charAt(i)+"";
			d[i] = b.charAt(i)+"";
			result += c[i] + d[i];
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 22740
N,D = map(int,input().split())
X = [list(map(int, input().split())) for j in range(N)]

count_ = 0
for j in range(0,N):
  for i in range(j+1,N):
    sum_ = 0
    for d in range(D):
      sum_+=(X[i][d]-X[j][d])**2
    if (sum_**0.5)%1==0: count_+=1
print(count_)

Measured memory_bytes: 3188
#include<iostream>
#include<vector>

using namespace std;

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

    vector<int>A;
    vector<int>B;
    vector<int>C;
    for(int i=0;i<n;i++){
        int temp;
        cin >> temp;
        A.push_back(temp-1);
    }
    for(int i=0;i<n;i++){
        int temp;
        cin >> temp;
        B.push_back(temp);
    }

    for(int i=0;i<n-1;i++){
        int temp;
        cin >> temp;
        C.push_back(temp);
    }

    int point = 0;
    for(int i=0;i<n;i++){
        point = point + B[A[i]];
        if(0<i && i<n && (A[i]-A[i-1]==1)){
            point += C[A[i-1]];
        }
    }
    cout << point << endl;
    
    return 0;
}

Measured memory_bytes: 256
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
d=[0]*3
e=d
for i in range(3):
  d[i]=a[i]-b[i]
  e[i]=b[i]-c[i]
f=[a[0]-a[1],b[0]-b[1],c[0]-c[1]]
g=[a[1]-a[2],b[1]-b[2],c[1]-c[2]]
d=len(set(d));e=len(set(e));f=len(set(f));g=len(set(g))
if d==1 and e==1 and f==1 and g==1:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3064
import numpy as np
 
N = int(input())
 
 
def divisor(N):
    x = np.arange(1, int(N**(1/2))+1, dtype=np.int64)
    div = set(x[N % x == 0])
    return div | set(N // x for x in div)
 
 
cand = divisor(N) | divisor(N - 1)
 
 
def test(N, K):
    if K == 1:
        return False
    while N % K == 0:
        N //= K
    return N % K == 1
 
 
answer = sum(test(N, d) for d in cand)
print(answer)

Measured memory_bytes: 28896
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[List[int]]"):
    from itertools import accumulate
    B = [list(accumulate([0]+a)) for a in A]
    return max(B[0][i+1] + B[1][N] - B[1][i] for i in range(N))

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [[int(next(tokens)) for _ in range(N)] for _ in range(2)]  # type: "List[List[int]]"
    print(solve(N, A))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

using namespace std;

class UnionFind {
   private:
    vector<int> par;

   public:
    UnionFind(int N) { par.resize(N, -1); }

    int root(int x) {
        if(par[x] < 0) {
            return x;
        }
        return par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry)
            return false;

        if(par[rx] > par[ry]) {
            swap(rx, ry);
        }

        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }

    int size(int x) { return -par[root(x)]; }
};

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

    UnionFind uf(N);
    for(int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        uf.unite(A, B);
    }

    int ans = 0;
    for(int i = 0; i < N; i++) {
        ans = max(ans, uf.size(i));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h,w;
    cin >> h >> w;
    vector<vector<int>> a(h,vector<int>(w));
    rep(i,h) rep(j,w) cin >> a[i][j];
    vector<vector<int>> ans;
    rep(i,h) {
        if(i%2 == 0) {
            rep(j,w) {
                if(a[i][j]%2 == 0) continue;
                if(j < w-1) {
                    a[i][j+1]++;
                    ans.pb({i+1,j+1,i+1,j+2});
                } else {
                    if(i < h-1) {
                        a[i+1][j]++;
                        ans.pb({i+1,j+1,i+2,j+1});
                    }
                }
            }
        } else {
            rrep(j,w) {
                if(a[i][j]%2 == 0) continue;
                if(j > 0) {
                    a[i][j-1]++;
                    ans.pb({i+1,j+1,i+1,j});
                } else {
                    if(i < h-1) {
                        a[i+1][j]++;
                        ans.pb({i+1,j+1,i+2,j+1});
                    }
                }
            }
        }
    }
    cout << ans.size() << endl;
    for(auto v : ans) printf("%d %d %d %d\n",v[0],v[1],v[2],v[3]);
}


Measured memory_bytes: 10032
#include <bitset>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int V, E, a, b, col[100009]; bool flag; vector<int> g[100009];
void dfs(int pos) {
	a++;
	if (col[pos] == 1) b++;
	for (int i : g[pos]) {
		if (col[pos] == col[i]) flag = true;
		if (!col[i]) col[i] = 3 - col[pos], dfs(i);
	}
}
int main() {
	scanf("%d %d", &V, &E);
	for (int i = 0; i < E; i++) {
		scanf("%d %d", &a, &b); a--, b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	bitset<50001> dp = 1;
	int cur = 0;
	for (int i = 0; i < V; i++) {
		if (!col[i]) {
			a = b = 0; col[i] = 1;
			dfs(i);
			if (b * 2 > a) b = a - b;
			cur += b;
			dp |= dp << (a - b * 2);
		}
	}
	long long ret = 0;
	for (int i = cur; i <= V && i - cur <= 50000; i++) {
		if (dp[i - cur]) ret = max(ret, 1LL * i * (V - i));
	}
	printf("%lld\n", (flag ? -1LL : ret - E));
	return 0;
}



Measured memory_bytes: 9136
N = gets.to_i
v = []
v = gets.split.map(&:to_f)

v = v.sort.reverse

v1, v2 = 0
while not v.size == 1
  v1 = v.pop
  v2 = v.pop
  v.push((v1+v2)/2)
  v = v.sort.reverse
  # puts "#{v}"
end
puts v[0]

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

int main() {
	int n;
	cin >> n;
	set<int> s;
	rep(i,n) {
		int a;
		cin >> a;
		s.insert(a);
	}
	int ans = s.size();
	if ((n - ans) % 2 == 1) ans--;
	cout << ans << endl;
}

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

int main(){
    int n;cin>>n;
    string s[n];for(int i=0;i<n;i++){cin>>s[i];sort(s[i].begin(),s[i].end());}
    ll sum=0;
    map<string,ll> box;
    for(int i=0;i<n;i++){
        box[s[i]]+=1;
    }
    for(auto p:box){
        ll i = p.second;
        sum+=i*(i-1)/2;
    }
    cout <<sum;
    
}

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

using namespace std;

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

    int n;
    cin>>n;

    if(n%10==3){
        cout<<"bon\n";
    }
    else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
        cout<<"pon\n";
    }
    else{
        cout<<"hon\n";
    }


    return 0;
}


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

int main()
{
	int N, S;
	scanf("%d", &N);
	if (~N & 1)
	{
		printf("%d\n", (N - 2) * N / 2);
		S = N + 1;
	}
	else
	{
		printf("%d\n", (N - 1 + (N - 1) * (N - 2)) / 2);
		S = N;
	}
	for (int i{1}; i <= N; i++)
	{
		for (int j{i + 1}; j <= N; j++)
			if (i + j != S && j != i)
				printf("%d %d\n", i, j);
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int M=60,N=100000;
ll n,cnt[M],ID=0;
vl a;
vp d;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	a=vl(n);
	vector<bitset<N+1>> b;
	for(auto &i:a){
		cin>>i;
		for(int j=0;j<M;j++) if(i&1ll<<j) cnt[j]++;
	}
	ll sum=0;
	for(int i=M-1;i>=0;i--){
		ll cnt=0,t=1ll<<i;
		bitset<N+1> c;
		c[N]=1;
		for(int j=0;j<n;j++) if(a[j]&t){
			c[j]=1;
			cnt++;
		}
		if(cnt%2==1){
			sum+=t;
			continue;
		}
		sort(d.begin(),d.end());
		for(auto p:d){
			int tmp=p.first,id=p.second;
			if(c[tmp]) c^=b[id];
		}
		bitset<N+1> beet;
		beet[N]=1;
		if(c==beet) continue;
		int I;
		for(int j=0;j<=N;j++) if(c[j]){
			d.push_back({j,ID});
			ID++;
			b.push_back(c);
			I=j;
			break;
		}
		for(int j=0;j<d.size();j++){
			int tmp=d[j].first,id=d[j].second;
			if(tmp<I&&b[id][I]) b[id]^=c;
		}
		sum+=t*2;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 2052
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct UnionFind {
private:
    vector<int> data;
public:
    UnionFind(int sz) {
        data.assign(sz, -1);
    }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return(false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return(true);
    }
    int find(int k) {
        if(data[k] < 0) return(k);
        return(data[k] = find(data[k]));
    }
    int size(int k){
        return(-data[find(k)]);
    }
};

int main () {

    int n; cin >>n;
    int m; cin >>m;
    vector<ll> a(m);
    vector<ll> b(m);
    for (int i = 0; i < m; i++) {
        cin >> a[m-1-i] >> b[m-1-i];
        a[m-1-i] -= 1;
        b[m-1-i] -= 1;
    }

    UnionFind tree(n);
    vector<ll> ans;
    ll res = (ll)n *(n-1)/2;
    ans.push_back(res);
    for (int i = 0; i < m-1; i++) {
        ll n1 = tree.size(a[i]);
        ll n2 = tree.size(b[i]);
        if(tree.unite(a[i], b[i])) {
            res -= n1*n2;
            ans.push_back(res);
        } else {
            ans.push_back(res);
        }
    }

    for (int i = 0; i < m; i++) {
        cout << ans[m-1-i] << endl;
    }
    
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// void genid(int P, int x, char str[]){
//     // char str[20];
//     sprintf(str, "%06d%06d", P, x);
//     // return str;
// }

string genid(int P, int x){
    char s[15];
    sprintf(s, "%06d%06d", P, x);
    string ss = string(s);
    return ss;
}

void solve(){
    ll N,M;
    cin >> N >> M;

    vector<ll> P(M), Y(M);
    for (int i = 0; i < M; i++) {
        cin >> P[i] >> Y[i];
    }

    map<ll, vector<pair<ll, int>> > mp;
    for (int i = 0; i < M; i++) {
        (mp[P[i]]).push_back(make_pair(Y[i], i));
    }

    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        // cout << "key" << itr->first << " value" << itr->second << endl;
        sort(all(mp[itr->first]));
    }

    vector<string> ids(M);
    // int idx = 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++){
        int n = (itr->second).size();
        for (int j = 0; j < n; j++) {
            // char idstring[15];
            ids[(itr->second)[j].second] = genid( (int)(itr->first), j+1);
            // idx++;
        }
    }

    // sort(all(ids));
    for (int i = 0; i < M; i++) {
        cout << ids[i] << endl;
    }
    // string str = genid(1,10);
    // cout << str << endl;



    // char str[20];
    // sprintf(str, "%06d%06d", 1, 10);
    // cout << str << endl;

    // char str[20];
    // genid(1,10, str);
    // cout << str << endl;


    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 19456
#include <iostream>
#include <fstream>
#include <ctime>
#include <climits>
#include <functional>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <set>
using namespace std;
struct UnionFind {
    vector<int> par, sz;
    int n_tree;

    explicit UnionFind(int n) : par(n), sz(n, 1), n_tree(n) { //0-indexed
        iota(par.begin(), par.end(), 0);
    }

    int n_cluster() const {
        return n_tree;
    }

    int size(int x) {
        return sz[root(x)];
    }

    int root(int x) {
        return x == par[x] ? x : par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        int rx = root(x), ry = root(y);
        if (rx != ry) {
            par[rx] = ry;
            --n_tree;
            sz[ry] += sz[rx];
            return true;
        }
        return false;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    bool is_root(int x) const {
        return par[x] == x;
    }
};
int main() {
#ifdef LOCAL
    ifstream in("in.txt");
    cin.rdbuf(in.rdbuf());
#endif
    //仿tourist的做法
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    vector<vector<int>> g(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u;
        --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<int> c(n);
    iota(c.begin(), c.end(), 0);
    sort(c.begin(), c.end(), [&](int x, int y) {return a[x] - b[x] < a[y] - b[y]; });
    vector<long long> sum_b(n);
    // ans[i]：子树i的最优解
    vector<bool> done(n, false);
    vector<long long> ans(n);
    for (int i = 0; i < n; ++i) {
        ans[i] = max(a[i], b[i]);
        sum_b[i] = b[i];
    }
    //vector<bool> added(n, false);
    UnionFind uf(n);
    for (auto v : c) {
        set<int> s;
        for (auto u : g[v]) {
            if (done[u]) {
                //并查集用来查找子树的根
                s.insert(uf.root(u));
            }
        }
        for (auto u : s) {
            sum_b[v] += sum_b[u];
            uf.unite(u, v);
        }
        //cout << v << ' ' << sum_b[v] << endl;
        if (!s.empty()) {
            long long best = LLONG_MAX;
            for (auto u : s) {
                long long sum_b_without = sum_b[v] - sum_b[u];
                long long cur = max(sum_b_without + ans[u], sum_b_without + a[v] - b[v]);
                best = min(best, cur);
                uf.unite(u, v);
            }
            ans[v] = best;
        }
        done[v] = true;
        //assert(uf.root(v) == v);
    }
    //for (int i = 0; i < n; ++i) {
    //    cout << c[i] << ' ' << sum_b[c[i]] << ' ' << ans[c[i]] << endl;
    //}
    cout << ans[c[n - 1]] << '\n';
#ifdef LOCAL
    cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}

Measured memory_bytes: 11004
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
int main()
{
	double a, b, x;
	cin >> a >> b >> x;
	double h;
	double res;
	if (a*a*b/2.0 < x){
		h = 2 * ((a*a*b)-x) / (a*a);
		res = atanl(h/a);
		printf("%.10lf\n",  res/M_PI * 180);
	} else {
		h = 2*x/(a*b);
		res = atanl(b/h);
		printf("%.10lf\n",  res/M_PI * 180);
	}

			


}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	int c1 = c / b + (c % b > 0);
	int c2 = a / d + (a % d > 0);
	cout << (c1 <= c2 ? "Yes" : "No");
}

Measured memory_bytes: 3636
// Problem : C - Repsept
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define int long long
const int N = 1e6;
const ll mod = 1e9+7;
#define ld long double
#define PI 3.14159265358979323846
const int INF = 10000000;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(9);
}

//3. Structure or classes
//3. Ends here

//1. Data structures declaration here
//1. Ends here

//2. Extra Functions here
int bolt(int k){
	int cnt=1;
	int tmp = 7;
	
	while(tmp%k!=0){
		tmp = (tmp%k)*10+7;
		cnt++;
	}
	
	return cnt;
}
//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}



void solve()
{
	int k;
	cin>>k;
	
	if(k%2==0 || k%5==0){
		cout<<"-1";return;
	}
	
	cout<<bolt(k);
	
    return;
}
// how r u bro

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int a,aa;
    int b,bb;
    int c;
    cin >> a >> aa >> b >> bb >> c;
    if(abs(a-b) <= (aa-bb)*c)
    cout << "YES" << endl;
    else
        cout << "NO" << endl;
    

    return 0;
}

Measured memory_bytes: 3620
// better!

// 数位 DP
// 状态一般可以表示为 f[i][stats][bound]s

#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>
using namespace std;

const int maxn = 10002;
const int mo = 1e9 + 7;

int f[maxn][102][2];

void add(int &a, int b) {
    a = (a + b) % mo;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    int n, d;
    string s;
    cin >> s >> d;
	
    n = s.length();
    if (n == 1) {
        int tmp = (s[0] - '0' >= d) ? 1 : 0;
        cout << tmp << endl;
        return 0;
    }

    vector<int> lim(n);
    for (int i = 0; i < n; ++i)
        lim[i] = s[i] - '0';

    for (int i = 0; i < lim[0]; ++i)
        ++f[0][i % d][0];
    f[0][lim[0]%d][1] = 1;

    for (int i = 0; i < n-1; ++i)
        for (int j = 0; j < d; ++j)
            for (int k = 0; k < 2; ++k)
                if (f[i][j][k] != 0) {
                    int curlim = k == 1 ? lim[i+1] : 9;
                    for (int t = 0; t <= curlim; ++t)
                        add(f[i+1][(j+t)%d][k && (t == lim[i+1])], f[i][j][k]);
                }

    int res = ((f[n-1][0][0] + f[n-1][0][1]) % mo - 1 + mo) % mo;
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,q;
	cin>>n>>k>>q;
	int a[q],score[n];
	for (int i=1;i<=q;i++)
	{
		cin>>a[i];
	}
	for (int i=1;i<=n;i++)
	{
		score[i]=k-q;
	}
	for (int i=1;i<=q;i++)
	{
		score[a[i]]++;
	}
	for (int i=1;i<=n;i++)
	{
		if (score[i]>0)
		{
			cout<<"Yes"<<endl;
		}
		else
		{
			cout<<"No"<<endl;
		} 
	}
	return 0;
 }

Measured memory_bytes: 1408
n=int(input())
arr=[]
tmp=[]
for _ in range(2**n):
    tmp.append(int(input()))
arr.append(tmp)
while len(arr[-1])>1:
    tmp=[]
    for i in range(len(arr[-1])//2):
        if arr[-1][2*i] == arr[-1][2*i+1]:
            tmp.append(arr[-1][2*i])
        else:
            tmp.append(abs(arr[-1][2*i]-arr[-1][2*i+1]))
    arr.append(tmp)
print(arr[-1][0])


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

int main(){
  int N;
  cin >> N;
  vector<int> B(N-1);
  for(int i = 0; i < N-1; i++) cin >> B[i];
  
  int ans = B[0] + B[N-2];
  for(int j = 0; j < N-2; j++){
    int now = B[j];
    if(now >= B[j+1]) now = B[j+1];
    ans += now;
  }
  cout << ans;
}

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

using namespace std;

#define F first
#define S second
#define pb push_back
#define epr(...) fprintf(stderr, __VA_ARGS__)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; 
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define dbv(a) cerr << #a << ": "; for (auto& xxxx: a) cerr << xxxx << " "; cerr << endl;
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)a.size()
#define pw(n) (1ll << (n))

#define equal equalll
#define less lesss
typedef long double dbl;
typedef long long ll;
const int N = -1;
const ll INF = 1.01e9;
typedef vector<int> vi;



int main(){
#ifdef HOME 
    assert(freopen("in", "r", stdin));
#endif
    int n, m;
    scanf("%d%d", &n, &m);
    vector<int> a(n);
    for (int i = 0; i < m; i++) {
        int v, u;
        scanf("%d%d", &v, &u); v--; u--;
        a[v] ^= 1;
        a[u] ^= 1;
    }
    bool ok = 1;
    for (auto A: a) {
        ok &= A == 0;
    }
    if (ok)
        puts("YES");
    else
        puts("NO");


    
    
#ifdef HOME 
    epr("time = %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
#endif
    return 0;
}



Measured memory_bytes: 640
program sample
    implicit none
  
    integer(8) :: i,j,m,n,a,b,k
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) a,b,k
    do i=1,k/2
        b=b+a/2
        a=a/2+b/2
        b=b/2
    end do
    if(mod(k,2)==1)then
        b=b+a/2
        a=a/2
    end if
  
    write(*,*) a,b
  
    stop
end program sample
  



Measured memory_bytes: 2796
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long X,K,D;
    cin >> X >> K >> D;
    X = abs(X);
    long long f = floor(double(X)/double(D));
    if(f>K) cout << X-D*K;
    else{
        K = K-f;
        //cout << K <<" " <<f <<endl;
        if(K%2==0) cout << X-D*f;
        else cout << abs(X-D*(f+1));
    }
    return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n; cin >> n;
    string s = "";
    while(n != 0){
        s += (n-1)%26 + 'a';
        n--;
        n /= 26;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    for(i = 0;i < n;++i){
        cout << s.at(i) << t.at(i);
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
fun main(arg: Array<String>) {
    val (A, B) = listOfInt()
    val L = listOf(A+B, A-B, A*B)
    println(L.max())
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


Measured memory_bytes: 37864
#pragma GCC optimize(3,"Ofast","inline")
#include<map>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 200009;
int n, MN, cnt;
string g[N];
map<string, int>f;
map<string, bool>p;
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> g[i];
		f[g[i]]++;
	}
	for(map<string, int>::iterator it = f.begin(); it != f.end(); it++)
		MN = max(MN, it->second);
	sort(g+1, g+n+1);
	for(int i = 1; i <= n; i++)
	{
		if(f[g[i]] != MN) continue;
		cout << g[i] << endl;
		f[g[i]] = 0;
	}
	return 0;
}

Measured memory_bytes: 25472
#include <cstdio>
#include <utility>
#include <queue>
using namespace std;
#define max(a,b)((a)>=(b)?(a):(b))
typedef pair<int,int> P;
int dp[100002];
int main() {
	priority_queue<P,vector<P>,greater<P> > Q;
	int N,L;
	scanf("%d %d",&N,&L);
	for(int i=1;i<=N;i++) {
		int ai;
		scanf("%d",&ai);
		Q.push(P(ai,i));
	}
	int ans=0;
	while(!Q.empty()) {
		P p=Q.top();Q.pop();
		ans=max(ans,dp[p.second]=(L-p.first)+max(dp[p.second+1],dp[p.second-1]));
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 2292
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
5
2 4
1 9
1 8
4 9
3 12
---+/
/+---test
3
334 1000
334 1000
334 1000
---+/
/+---test
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
---+/

void main(string[] args) {
  const N = readln.chomp.to!long;

  long[][long] jobs;
  foreach (i; 0..N) {
    long a, b;
    readf(" %d %d ", &a, &b);
    jobs[b] ~= a;
  }

  auto limits = jobs.keys.array.sort!"a < b";

  long t;
  foreach (limit; limits) {
    t += jobs[limit].sum;
    if (t > limit) {
      "No".writeln;
      return;
    }
  }
  "Yes".writeln;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    long double result = 0;
    for(int i = 1; i <= N; i++) {
        long double tmp = (long double)K / i;
        int count = ceil(log2(tmp));
        if(count < 0) {
            count = 0;
        }
        long double perm = 1.0/(N * pow(2, count));
        result += perm;
    }
    cout << setprecision(12) << result << endl;
}

Measured memory_bytes: 640
temp1 = input().split(" ")
temp1 = [int(i) for i in temp1]
x = temp1[0]
n = temp1[1]

if not n == 0:
    temp2 = input().split(" ")
    temp2 = [int(i) for i in temp2]
else:
    temp2 = input()
    temp2 = []

pn = temp2

counter = 0
while True:
    if n == 0:
        print(x)
        break

    mx = x - counter
    px = x + counter

    if not mx in pn:
        print(mx)
        break
    if not px in pn:
        print(px)
        break

    counter += 1

Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll a,b,x;cin>>a>>b>>x;
    if(a!=0){
        cout<<b/x-(a-1)/x<<endl;
    }
    else{
        cout<<b/x+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;

namespace Circle_in_a_Rectangle
{
    class CircleinaRectangle
    {
        static void Main()
        {
            string input = Console.ReadLine();
            string[] a = input.Split(' ');
            int w = int.Parse(a[0]);
            int h = int.Parse(a[1]);
            int x = int.Parse(a[2]);
            int y = int.Parse(a[3]);
            int r = int.Parse(a[4]);
            if (x + r > w || x - r < 0 || y + r > h || y - r < 0)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
    }
}



Measured memory_bytes: 17932
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1000000007;
main(){
    string s;
    int point = 0;
    cin >> s;
    for(int i = 0;i < s.length();i++){
        if(i % 2 && s[i] == 'g')point++;
        if(!(i % 2) && s[i] == 'p')point--;
    }
    cout << point << endl;
}   

Measured memory_bytes: 512
def solve():
    N, M = map(int, input().split())
    T = {}
    for i in range(M):
        a, b = map(int, input().split())
        if a not in T:
            T[a] = []
        T[a].append(b)
        if b not in T:
            T[b] = []
        T[b].append(a)
    # print(N, M, T)
    FROM_1 = T[1]

    for f in FROM_1:
        if N in T[f]:
            print('POSSIBLE')
            exit()
    print('IMPOSSIBLE')

if __name__ == '__main__':
    solve()


Measured memory_bytes: 101080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto e : s) os << e; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  vector<string> t({"AC", "WA", "TLE", "RE"});
  rep(i, 4) cout << t[i] << " x " << mp[t[i]] << endl;
}


Measured memory_bytes: 3664
from math import gcd

n = int(input())
ans = 0

for i in range(n):
    ans += i+1
    for j in range(i):
        tmp = gcd(i+1, j+1)
        ans += tmp * 6
        for k in range(j):
            ans += gcd(tmp, k+1) * 6

print(ans)


Measured memory_bytes: 9180
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define LL long long

using namespace std;
int main()
{
  int a, b, c, x, count = 0;
  REP(i, 4) { cin >> a >> b >> c >> x; };
  REP(five, a+1){
    REP(one, b+1){
      REP(fifth, c+1){
        if(x == five * 500 + one * 100+ fifth * 50 ){
          ++count;
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
# c = [[0]*n for _ in range(m)]

ans = 0
if n == 1 and m == 1:
    ans = 1
elif n == 1:
    ans = m - 2
elif m == 1:
    ans = n - 2
else:
    ans = (n-2)*(m-2)

print(ans)

Measured memory_bytes: 2940
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		long x = stdIn.nextLong();
		long y = stdIn.nextLong();
		
		long a = x;
		long cnt = 0;
		while(a <= y) {
			cnt++;
			a*=2;
		}
		
		System.out.println(cnt);
		
		
	}

}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
template<class T> inline void dmin(T& x,T y){ y<x?x=y:0; }
template<class T> inline void dmax(T& x,T y){ y>x?x=y:0; }
template<class T> inline void dmin(T& x,vector<T> y){ 
	for(auto t:y) t<x?x=t:0;
}
template<class T> inline void dmax(T& x,vector<T> y){
	for(auto t:y) t>x?x=t:0;
}
int main(){
	int A,B,V,W,T; cin>>A>>V>>B>>W>>T;
	if(V<=W){
		puts("NO");
		return 0;
	}
	if(abs(A-B)<=1ll*T*(V-W)) puts("YES");
	else puts("NO");
	return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <functional>
using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<int> C(N);
    for (int &c: C)
        cin>>c, c--;
    vector<vector<int>> E(N);
    for (int i=0; i<N-1; i++)
    {
        int a, b;
        cin>>a>>b;
        E[a-1].push_back(b-1);
        E[b-1].push_back(a-1);
    }

    vector<long long> A(N, (long long)N*(N+1)/2);
    vector<int> CN(N);
    function<int(int, int)> f = [&](int c, int p)
    {
        int s = 0;
        int sc = 0;
        for (int e: E[c])
            if (e!=p)
            {
                int pre = CN[C[c]];
                int n = f(e, c);
                long long nc = n-(CN[C[c]]-pre);
                A[C[c]] -= nc*(nc+1)/2;
                sc += nc;
                s += n;
            }
        CN[C[c]] += sc+1;
        return s+1;
    };
    f(0, -1);
    for (int c=0; c<N; c++)
    {
        long long t = N-CN[c];
        A[c] -= t*(t+1)/2;
    }
    for (long long a: A)
        cout<<a<<endl;
}


Measured memory_bytes: 32456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  string s[n];
  ll c[5];
  for(ll i=0;i<5;i++)c[i]=0;
  for(ll i=0;i<n;i++){
    cin>>s[i];
    char a=s[i][0];
    if(a=='M')c[0]++;
    if(a=='A')c[1]++;
    if(a=='R')c[2]++;
    if(a=='C')c[3]++;
    if(a=='H')c[4]++;
  }
  ll ans=0;
  for(ll i=0;i<3;i++){
    for(ll j=i+1;j<4;j++){
      for(ll k=j+1;k<5;k++){
        ans+=c[i]*c[j]*c[k];
      }
    }
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 6144