akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if ( (a+b) % 2 == 0 ){
    cout << (a+b)/2 << endl;
  }
  else{
    cout << (a+b+1)/2 << endl;
  } 
}


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

int main(){

	int i,n=100000,m;

	cin >> i;
	while(i--){
		n+=n*0.05;
		m=n%1000;
		if(m){
			n+=1000-m;
		}
	}
	cout << n << endl;

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n)-1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a)-1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using Vec = vector<T>;
template<class T> using VVec = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i-1)*10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}
 
struct IoSetup {
  	IoSetup() {
    	cin.tie(nullptr);
    	ios::sync_with_stdio(false);
    	cout << fixed << setprecision(10);
  	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//


int main() {
	int D, T, S;
	cin >> D >> T >> S;

	if (D <= T * S)yn

	return 0;
}


Measured memory_bytes: 3636
import java.util.*;

class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();

		int wid = x2 - x1;
		int heg = y2 - y1;

		System.out.print(x2 - heg + " ");
		System.out.print(y2 + wid + " ");
		System.out.print(x1 - heg + " ");
		System.out.println(y1 + wid);


	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
struct point {
  long x;
  long y;
};

int main(int argc, char **argv)
{
  int N, D;
  
  cin >> N >> D;
  struct point points[N];
  for (int i = 0; i < N; i++) {
    cin >> points[i].x >> points[i].y;
  }
  
  int n_points = 0;
  for (int i = 0; i < N; i++) {
    if (sqrt(points[i].x * points[i].x + points[i].y * points[i].y) <= D) {
  		n_points++;
    }
  }
  cout << n_points << endl;
  return 0;
}

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

int main()
{
	int l, r;
	scanf("%d %d", &l, &r);
	if(r-l+1 >= 2019) printf("0\n");
	else {
		int ans = 2020;
		for (int i=l; i<=r; i++){
			for (int j=i+1; j<=r; j++){
				ans = min(ans, ((i%2019) *(j%2019))%2019);
			}
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int n;

int main() {
    while (cin >> n) {
        if (n == 0) break;
    
        vector<vint> res(n, vint(n, -1));
        
        int x = n/2+1, y = n/2;
        for (int i = 1; i <= n*n; ++i) {
            res[x][y] = i;
            
            int nx = (x+1)%n, ny = (y+1)%n;
            if (res[nx][ny] != -1) nx = (nx+1)%n, ny = (ny-1+n)%n;
            x = nx, y = ny;
        }
        
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) printf("%4d", res[i][j]);
            cout << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 1248
#include<iostream>
#include<string>
#include<cmath>
using namespace std;

int main()
{
  int H,W,K,count=0,n,tmp;
  char *c;
  bool *b;
  cin>>H>>W>>K;
  c=new char[H*W];
  b=new bool[H+W];
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      cin>>c[i*W+j];
  
  n=pow(2,H+W);
  for(int i=0;i<n;i++)
  {
    tmp=i;
    for(int j=0;j<H;j++)
    {
      if(tmp%2==0)
	      b[j]=false;
      else
        b[j]=true;
      
      tmp=tmp/2;
    }
    for(int j=0;j<W;j++)
    {
      if(tmp%2==0)
	      b[j+H]=false;
      else
        b[j+H]=true;
      
      tmp=tmp/2;
    }
    
    tmp=0;
    for(int i=0;i<H;i++)
    {
      if(!b[i])
        continue;
      for(int j=0;j<W;j++)
      {
        if(!b[j+H])
          continue;
        if(c[i*W+j]=='#')
          tmp++;
      }
    }
    if(tmp==K)
      count++;
  }
  cout<<count;
  
  delete[] b;
  delete[] c;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
//max=({});
//条件式が真ならwhileの中身を回し続ける

bool flag[1050000];

int main() {
	ll h, n;
	cin >> h >> n;
	vector<ll>A(n), B(n);
	rep(i, n) {
		cin >> A[i] >> B[i];
	}
	vector<ll>dp(h + 1, 100100100);
	dp[0] = 0;
	rep(i, n) {
		rep(j, h) {
			ll nj = min(h, j + A[i]);
			dp[nj] = min(dp[nj], dp[j] + B[i]);
		}
	}
	cout << dp[h] << endl;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

bool foo(int ABCD, int level, int accum) {
  // cout << ABCD << ", " << level << ", " << accum << endl;
  if (level == 3) {
    if (ABCD / 1000 + accum == 7) {
      cout << ABCD / 1000;
      return true;
    }
    return false;
  }
  int keta = 1;
  for (int i = 0; i < level; i++) {
    keta *= 10;
  }
  int current = ABCD / keta % 10;
  if (foo(ABCD, level + 1, accum + current)) {
    cout << "+" << current;
    return true;
  }
  if (foo(ABCD, level + 1, accum - current)) {
    cout << "-" << current;
    return true;
  }
  return false;
}

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

  foo(ABCD, 0, 0);
  cout << "=7" << endl;

  return 0;
}


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

using namespace std;

struct Edge{int src, dst, cost;};

vector<int> topological_sort(const vector<Edge>& graph){
  const int MAX = 21;
  int inEdge[MAX];
  bool come[MAX];
  vector<int> node;
  vector<int> order;
  queue<int> Q;

  memset(inEdge,0,sizeof(inEdge));
  memset(come,false,sizeof(come));
 
  for(int i = 0; i < (int)graph.size(); i++) {
    node.push_back(graph[i].src);
    node.push_back(graph[i].dst);
  }
  sort(node.begin(),node.end());
  node.erase(unique(node.begin(),node.end()),node.end());

  for(int i = 0; i < (int)graph.size(); i++) inEdge[graph[i].dst]++;
  for(int i = 0; i < (int)node.size(); i++) if(inEdge[node[i]]==0) Q.push(node[i]);
 
  while(!Q.empty()){
    int now = Q.front();
    Q.pop();

    if(come[now]) continue;
    come[now] = true;

    order.push_back(now);
    for(int i = 0; i < (int)graph.size(); i++) if(graph[i].src==now) inEdge[graph[i].dst]--;
    for(int i = 0; i < (int)node.size(); i++) if(inEdge[node[i]]==0 && !come[node[i]]) Q.push(node[i]);
  }
  return order;
}

int main(){
  int m,n;
  cin >> m >> n;
  vector<Edge> V(n);
  for(int i = 0; i < n; i++) cin >> V[i].src >> V[i].dst;
  vector<int> ans = topological_sort(V);
  for(int i = 0; i < (int)ans.size(); i++) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 1224
import sys
input = sys.stdin.readline
N, M, X = list(map(int, input().split()))

CA = [list(map(int, input().split())) for _ in range(N)]

ans = float('inf')

for i in range(2**N):
    cost = 0
    A = [0] * M
    for j in range(N):
        if i >> j & 1 == 1:
            cost += CA[j][0]
            for m in range(M):
                A[m] += CA[j][m+1]

    flg = True
    for m in range(M):
        if A[m] < X:
            flg = False
            break
    if flg:
        ans = min(ans, cost)

if ans == float('inf'):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 68616
#include <vector>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <queue>
#include <deque>
#include <iostream>
#include <cstdio>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1 ; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define FILL(a,b) memset(a , b , sizeof(a))
#define SZ(a) (int)a.size()
#define PB push_back
#define MP make_pair

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAX = 100007;
const int INF = 1000000000;

vector<PII> G[MAX];
Int res = 0;
int d[MAX];
int n;

int sp = INF;
int cnts = 0;

void dfs(int v, int p)
{
	//cout << v << ' ' << p << endl;
	d[v] = 1;
	multiset<int> SS;
	FOR(i,0,SZ(G[v]))
	{
		int to = G[v][i].first;
		if (to == p) continue;
		dfs(to, v);
		d[v] += d[to];
		SS.insert(d[to]);
		res += 2LL * min(d[to] , (n - d[to])) * G[v][i].second;

	}
	SS.insert(n - d[v]);
	FOR(i,0,SZ(G[v]))
	{
		int to = G[v][i].first;
		if (to == p) continue;
		SS.erase(SS.find(d[to]));
		if (d[to] <= n / 2 && *SS.rbegin() <= (n - 1) / 2)
		{
			sp = min(sp , G[v][i].second);
		}
		SS.insert(d[to]);
	}

}

int main()
{
	//freopen("in.txt" , "r" , stdin);


	cin >> n;

	int mn = INF;

	FOR(i,0,n - 1)
	{
		int a , b , c;
		scanf("%d%d%d" , &a , &b, &c);
		--a; --b;
		G[a].push_back(MP(b , c));
		G[b].push_back(MP(a , c));
		mn = min(mn, c);
	}

	dfs(0, -1);

	if (sp != INF) mn = sp;

	cout << res - mn << endl;



}


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

const long long INF = 1LL<<60;
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;}

int main(){
    int N;cin>>N;
    vector<int> n(101);
    for(int i=1;i<=N;i++) cin>>n[i];
    vector<vector<long long>> dp(N,(vector<long long>(21,0)));
    //求めるのはN-1番目の入力数までの計算結果が成立する個数
    //dp[i][j]：i番目までの計算結果がjとなる等式の個数
    dp[1][0]=0;//この行いらん
    dp[1][n[1]]=1;
    for(int i=2;i<N;i++){
        for(int j=0;j<=20;j++){//jはi番目まで足した時の和(これまでの和)
                               //n[i]が基本的に反映されるため
                               //jがn[i]とこれまでの和の和ではないとき
                               //dpは0のまま
                               //jがこれまでの和と一致している場合
                               //のみdpが更新される
            if(j+n[i]<=20) dp[i][j+n[i]]+=dp[i-1][j];
            //このforの中でjが更新されることはないので同じjについて
            //直前の符号が+,-の場合を共に考えることができる
            if(j-n[i]>=0) dp[i][j-n[i]]+=dp[i-1][j];
        }
    }
    cout<<dp[N-1][n[N]]<<endl;//n[N]は=の右の数字つまり答え
    return 0;
}


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

int main() { 
  int sum = 0;
  int N;
  cin >> N ;
  for ( int i = 0; i < N; i++){
    int l,r ;
    cin >>l >> r;
    sum += r-l+1;
  }
  cout << sum <<endl;

}


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

long damage(long H){
    if(H==1) return 1;
    long harf = H/2;
    return 1 + 2 * damage(harf);
} 

int main(){
    long H; cin >> H;

    long result = damage(H);
    cout << result << endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

def main():
    ans = 0
    A,B,C = map(int, input().split())
    if A*B*C%2 == 1:
        ans = min(A,B,C)*(A+B+C-(min(A,B,C)+max(A,B,C)))
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9136
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
print("x"*len(S))

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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = (int)s.size();
  if (n < 26) {
    map<char, bool> mp;
    for (auto&& c : s) {
      mp[c] = true;
    }
    for (char c = 'a'; c <= 'z'; c++) {
      if (!mp.count(c)) {
        s += c;
        break;
      }
    }
    cout << s << '\n';
  } else {
    if (s == "zyxwvutsrqponmlkjihgfedcba") {
      cout << -1 << '\n';
    } else {
      string ans;
      for (int i = n - 1; i > 0; i--) {
        if (s[i - 1] < s[i]) {
          ans = s.substr(0, i);
          break;
        }
      }
      map<char, bool> mp;
      for (auto&& c : ans) {
        mp[c] = true;
      }
      debug(ans);
      for (char c = ans.back() + 1; c <= 'z'; c++) {
        if (!mp.count(c)) {
          ans.pop_back();
          ans += c;
          break;
        }
      }
      cout << ans << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;

int main() {
  int A,B,K; cin >> A >> B >> K;
  vector<int> ans;

  for ( int i = 1; i <= 100; i++ ) {
    if ( A % i == 0 && B % i == 0 ) ans.push_back(i);
  }
  cout << ans[ans.size()-K] << endl;
  return 0;
}


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

#define ll long long
#define ar array

const int mxN=100000, M=1e9+7;
int n;
ll dp[mxN][2];
vector<int> adj[mxN];

void dfs(int u=0, int p=-1) {
	dp[u][0]=dp[u][1]=1;
	for (int v : adj[u]) if (v!=p) {
		dfs(v, u);
		dp[u][0]=dp[u][0]*(dp[v][0]+dp[v][1])%M;
		dp[u][1]=dp[u][1]*dp[v][0]%M;
	}
}

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

	cin >> n;
	for (int i=1, u, v; i<n; ++i) {
		cin >> u >> v, --u, --v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs();
	cout << (dp[0][0]+dp[0][1])%M;
	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 17500
#include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 2E5+2;
 
int n;
vector<pair<long long, int> > a(MAXN);
vector<bool> b(MAXN, 0);
vector<pair<int,int> > v;
 
long long pairing(long long X){
	int l = 0, r = 60, msb = 60;
	while(l<=r){
		int mid = (l+r)>>1;
		long long val = (1LL << mid);
		if(val > X) msb = mid, r = mid-1;
		else l = mid+1;
	}
	return (1LL<<msb) - X;
}
 
int main() {
	// your code goes here
	cin >> n;
	for(int i=1; i<= n; ++i){
		cin >> a[i].first; a[i].second = i;
	}
	sort(a.begin()+1, a.begin()+n+1);
	for(int i=n; i>= 1;--i){
		if(b[i]) continue;
		long long X = pairing(a[i].first);
		int l = 1, r = i-1, j = -1;
		while(l<=r){
			int mid = (l+r)>>1;
			
			if(a[mid].first < X) l = mid+1;
			else if(a[mid].first > X) r =mid-1;
			else if(b[mid]) l = mid+1;
			else j = mid, r = mid-1;
		}
		if(j!= -1){
			v.push_back({a[i].second, a[j].second});
			b[j] = 1;
		}
	}
	cout << v.size() << "\n";
	return 0;
}

Measured memory_bytes: 4604
#include <iostream>
#include <stdio.h>
using namespace std;

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2 + 2], R[MAX/2 + 2];
int cnt;

void Merge(int A[], int n, int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;

  for(int i = 0; i < n1; i++) L[i] = A[left + i];
  for(int i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i = 0;
  int j = 0;
  for(int k = left; k < right; k++){
    cnt++;
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    }else{
      A[k] = R[j];
      j++;
    }
  }
}

void MergeSort(int A[], int n, int left, int right){
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    MergeSort(A, n, left, mid);
    MergeSort(A, n, mid, right);
    Merge(A, n, left, mid, right);
  }
}


int main(int argc, char const *argv[]) {
  int A[MAX];
  int n;
  cnt = 0;

  scanf("%d", &n);
  for(int i = 0; i < n; i++)  scanf("%d", &A[i]);

  MergeSort(A, n, 0, n);

  for(int i = 0; i < n; i++){
    if (i) {
      printf(" ");
    }
    printf("%d", A[i]);
  }
  cout << endl;
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 7080
#include<bits/stdc++.h>
using namespace std;
int n,t,a[100010],ans,num,p[100010];
int main(){
	cin>>n>>t;
	for (int i=0;i<n;i++) cin>>a[i];
	p[n-1]=a[n-1];
	for (int i=n-2;i>=0;i--){
		p[i]=p[i+1];
		if (p[i]<a[i]) p[i]=a[i];
	}
	for (int i=0;i<n;i++) num=max(num,p[i]-a[i]);
	for (int i=0;i<n;i++) if (p[i]-a[i]==num) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(), (x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for (int i = m; i < n; i++)
#define INF INT_MAX
#define fcout cout << fixed << setprecision(15) // 15桁まで表示
#define en '\n'
using str = string;
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using puu = pair<ui, ui>;
using P = pair<int, int>;
using vi = vector<int>;
int gcd(int a, int b) {
  return b ? gcd(b, a % b) : a;
};
int lcm(int a, int b) {
  return a / gcd(a, b) * b;
};
int floor(int a, int b) {
  return (a + b - 1) / b;
};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
};
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
};
const ll mod = 1000000007;
const double PI = acos(-1.0);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  int n;
  cin >> n;
  vi a(n);
  double ans = 0;
  rep(i,n){
    cin >> a[i];
    ans += a[i];
  }
  ans /= n;
  int ind = 0;
  double tmp = 10000000;
  rep(i, n){
    if (abs(a[i]-ans)<tmp){
      ind = i;
      tmp = abs(a[i] - ans);
    }
  }
  cout << ind << en;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a %2 == 1 || b %2 == 1 || c %2 == 1) {
			System.out.println(0);
		} else if (a == b && b == c) {
			System.out.println(-1);
		} else {
			int count = 0;
			while (a%2 == 0 && b%2 == 0 && c%2 == 0) {
				count++;
				int x = (b+c)/2;
				int y = (a+c)/2;
				int z = (a+b)/2;
				a = x;
				b = y;
				c = z;
			}
			System.out.println(count);
		}
		sc.close();
	}

}


Measured memory_bytes: 27100
/*********************
*  Author: xuziyuan  * 
*********************/
 
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair
 
using namespace std;
 
const LL MOD=1e9+7;

string s;
int dp[1000010][2];

int main()
{
	cin>>s;
	reverse(s.begin(),s.end());
	s.pb('0');
	rep(i,1000005) rep(j,2) dp[i][j]=1e9;
	dp[0][0]=0;
	rep(i,s.size())
	{
		rep(j,2)
		{
			if(dp[i][j]==1e9) continue;
			rep(k,10)
			dp[i+1][(s[i]-'0'+k+j)/10]=min(dp[i+1][(s[i]-'0'+k+j)/10],dp[i][j]+k+(k+s[i]-'0'+j)%10);
		}
	}
	cout<<dp[s.size()][0]<<endl;
	return 0;
}

Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

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

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

int main() {
  ll n,m;cin >> n>>m;
  string s,t;cin >> s>>t;
  ll l = lcm(n,m);
  //vector<ll> vn(n);
  //for(ll i=0;i<n;++i)vn[i] = i*(l/n);
  ll ld = lcm(l/n,l/m);
  bool canExist =true;
  ll tmp = 0;
  while (tmp<=l) {
    int i = tmp/(l/n);
    int j = tmp/(l/m);
    auto sub_s = s.substr(i,1);
    auto sub_t = t.substr(j,1);
    if(sub_s != sub_t ) {
      canExist = false;
      break;
    }
    tmp += ld;
  }
  if(canExist){
    cout << l << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 1e5 + 5;
string baris;
int n, ans=0, ans1=0;
char a[9], b[9];

int main(){
	IOS
	cin >> n;
	for(int i=1;i<=n;i++){
		char a=i+'0';
		baris+=a;
	}
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int j=0;j<n;j++){
		cin >> b[j];
	}
	string c=a, d=b;
	while(baris!=c){
		next_permutation(baris.begin(), baris.end());
		ans++;
	}
	sort(baris.begin(), baris.end());
	while(baris!=d){
		next_permutation(baris.begin(), baris.end());
		ans1++;
	}
	cout << abs(ans-ans1) << '\n';
}


Measured memory_bytes: 3664
#!/usr/bin/env python3

import bisect

N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
# print(f"N: {N}")
# print(f"A, B, C: {A}, {B}, {C}")

def binary_search_more_than(arr, value):
    left = 0
    right = len(arr) - 1
    if value < arr[left]:
        return left
    if value > arr[right]:
        return None
    while left <= right:
        mid = int((left + right) / 2)
        if value > arr[mid]:
            left = mid + 1
        elif value < arr[mid]:
            right = mid - 1
        else:
            return mid + 1
    # left == right + 1, so arr[right] < value < arr[left]
    return left

def binary_search_less_than(arr, value):
    left = 0
    right = len(arr) - 1
    if value < arr[left]:
        return None
    if value > arr[right]:
        return right
    while left <= right:
        mid = int((left + right) / 2)
        if value > arr[mid]:
            left = mid + 1
        elif value < arr[mid]:
            right = mid - 1
        else:
            return mid - 1
    # left == right + 1, so arr[right] < value < arr[left]
    return right

# count = 0
# if N == 1:
#     if A[0] < B[0] < C[0]:
#         count += 1
# else:
#     for bot in B:
#         index_A = binary_search_less_than(A, bot)
#         index_C = binary_search_more_than(C, bot)
#         # print(f"index_A: {index_A}")
#         # print(f"index_C: {index_C}")
#         if index_A != None and index_C != None:
#             count += (index_A + 1) * (N - index_C)

# print(count)

count = 0
for bot in B:
    i_A = bisect.bisect_left(A, bot)
    i_C = bisect.bisect_right(C, bot)
    count += i_A * (N - i_C)
print(count)


Measured memory_bytes: 105444
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  n <- getInt

  let countABs i s res
        | i >= BS.length s - 1 = res
        | s `BS.index` i == 'A' && s `BS.index` (i+1) == 'B' =
          countABs (i+2) s (res+1)
        | otherwise = countABs (i+1) s res

      loop :: Int -> Int -> Int -> Int -> Int -> IO (Int, Int, Int, Int)
      loop i x y z abs
        | i == n = return (x, y, z, abs)
        | otherwise = do
        s <- BS.getLine
        let cl = s `BS.index` 0
            cr = s `BS.index` (BS.length s - 1)
            x' = x + if cl /= 'B' && cr == 'A' then 1 else 0
            y' = y + if cl == 'B' && cr /= 'A' then 1 else 0
            z' = z + if cl == 'B' && cr == 'A' then 1 else 0
            ct = countABs 0 s 0
            abs' = abs + ct
          in loop (i+1) x' y' z' abs'

  (x, y, z, abs) <- loop 0 0 0 0 0

  let ans | z == 0    = abs + min x y
          | x + y > 0 = abs + z + min x y
          | otherwise = abs + z - 1

  print ans

Measured memory_bytes: 7036
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n; string s; cin>>n>>s;
  for(int i=0;i<s.size();i++){
    s.at(i)+=n;
    s.at(i)= 90<s.at(i)? s.at(i)-26:s.at(i); 
  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;
typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<' '<<y<<endl
#define p3(x,y,z)               out<<x<<' '<<y<<' '<<z<<endl
#define p4(x,y,z,w)             out<<x<<' '<<y<<' '<<z<<' '<<w<<endl
#define pl(x)                   out<<x
#define pll(x)                  out<<x<<' '
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

#define EACH(x, a) for (auto& x: a)
template<class T> void read_v(T& x, std::istream& in) {
    in >> (x);
}
template<class A> void read_vec(vector<A>& x, std::istream& in) {
    EACH(a, x)
        read_v(a, in);
}

bool sortpairbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
template <typename T>
T factmod(T a, T modulus){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=modulus;} return res; }
template <typename T>
int powmod(T a,T b,int m){ int ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
int power(T a, T b){ int ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}


void ssolve(std::istream& in, std::ostream& out){
    int n, w; s2(n, w);

    vi dp(w + 1, 0);
    vi newdp(w + 1, 0);
    f(i, 0, n){
        int we, vl;
        s2(we, vl);
        newdp = dp;
        for(int j = we; j <= w; j++){
            newdp[j] = max(dp[j], dp[j - we] + vl);
        }
        dp = newdp;
    }
    int ans = *max_element(range(dp));
    p(ans);
    return;
}

class DKnapsack1 {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(nullptr);out.tie(nullptr);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    DKnapsack1 solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

Measured memory_bytes: 4740
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()

using namespace std;

using ll = long long;

const int MOD = 1000000007;

struct mint {
  int n;
  mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return a.n == 0 || b.n == 0 ? 0 : (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N), S(N+1), zero(N+2);
  REP(i, N) {
    cin >> A[i];
    S[i+1] = S[i]^A[i];
  }
  REP(i, N+1) {
    zero[i+1] = zero[i] + (S[i] == 0);
  }
  vector<vector<int>> v((1<<20)+1);
  for (int i = 0; i <= N; i++) {
    v[S[i]].push_back(i);
  }
  if (S[N] == 0) {
    mint ans = 1;
    REP(i, v[0].size() - 2) ans *= 2;
    for (int k = 1; k < 1 << 20; k++) {
      vector<mint> dp(v[k].size());
      mint dp0 = 0;
      mint dp1 = 0;
      for (int i = 0; i < v[k].size(); i++) {
        dp[i] += 1;
        dp[i] += dp0 * zero[v[k][i]];
        dp[i] -= dp1;
        dp0 += dp[i];
        dp1 += dp[i] * zero[v[k][i]];
        ans += dp[i];
      }
      /*
      vector<mint> dp(v[k].size());
      for (int i = 0; i < v[k].size(); i++) {
        dp[i] += 1;
        for (int j = 0; j < i; j++) {
          dp[i] += dp[j] * (zero[v[k][i]] - zero[v[k][j]]);
        }
        ans += dp[i];
      }
      */
    }
    cout << ans.n << '\n';
  } else {
    int k = S[N];
    vector<mint> dp(v[k].size());
    mint dp0 = 0;
    mint dp1 = 0;
    for (int i = 0; i < v[k].size(); i++) {
      dp[i] += 1;
      dp[i] += dp0 * zero[v[k][i]];
      dp[i] -= dp1;
      dp0 += dp[i];
      dp1 += dp[i] * zero[v[k][i]];
    }
    /*
    for (int i = 0; i < v[k].size(); i++) {
      dp[i] += 1;
      for (int j = 0; j < i; j++) {
        dp[i] += dp[j] * (zero[v[k][i]] - zero[v[k][j]]);
      }
    }
    */
    cout << dp.back().n << '\n';
  }
}


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

int main() {
char h,g;
  int s,e,d;
  cin >> s >>h>> e >>g>> d;
  int a=s;
  int b=e;
    int c=d;
  if(a<=2019){
    if(b<=04){
      if(c<=30){
    cout << "Heisei" << endl;
      } }}
  if(a>2019){
    cout << "TBD" << endl;
  } else if(b>04){
    cout << "TBD"  << endl;
  } else if(c>30){
    cout << "TBD" << endl;
  }
}


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

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

int main(){
	long long a,b;
	cin>>a>>b;
	cout<<a*b/gcd(a,b)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    cout << n*n*n << endl;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    repe(i, 1, N){
        ans += (N - 1) / i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d)
    cout<<"Yes"<<endl;
  else{
  if(abs(a-b)<=d && abs(c-b)<=d)
    cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  
  }
 return 0;
}

Measured memory_bytes: 256
MOD = 1000000007

def conv(a, b)
    if b > a / 2
        b = a - b
    end
    ans = 1
    div = 1
    b.times do |i|
        ans *= (a - i)
        div *= (i + 1)
        ans %= MOD
        div %= MOD
    end
    ans = ans * pow(div, MOD - 2)
    ans % MOD
end

def pow(x, n)
    if n == 0
        1
    elsif n % 2 == 0
        pow(x * (x % MOD), n / 2) % MOD
    else
        x * pow(x, n - 1) % MOD
    end
end

n, a, b = gets.chomp.split(" ").map(&:to_i)

all = (pow(2, n) - 1) % MOD
if a > n / 2
    a = n - a
end
if b > n / 2
    b = n - b
end
all = all - conv(n, a) - conv(n, b)
all %= MOD

puts all


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


//void warshall_floyd(int n){
//    for(int k=0;k<n;k++){
//        for(int i=0;i<n;i++){
//            for(int j=0;j<n;j++){
//                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//            }
//        }
//    }
//}
//ll calc_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        ++res;
//        N /= 10;
//    }
//    return res;
//}
//ll sum_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        res += N % 10;
//        N /= 10;
//    }
//    return res;
//}


int main(){
    ll n; cin >> n;
    vector<ll> v;
    for(int i = 0;i < n;i++){
        ll x; cin >> x;
        v.push_back(x);
    }
    ll ans = 1000;ll k = 0;
    v.erase(unique(v.begin(),v.end()),v.end());
    for(int i = 1;i < v.size();i++){
        if(v[i] > v[i-1]){
            k = 0;
            k = ans/v[i-1];
            ans -= k*v[i-1];
            ans += k*v[i];
        }
    }
    cout << ans;
}



Measured memory_bytes: 3632
Var     r,g,b,a: Longint;

Procedure       Nhap;
Begin
Readln(r,g,b);
End;

Procedure       Xuly;
Begin
a:=r*100+g*10+b;
If a mod 4 = 0 Then Writeln('YES')
Else Writeln('NO');
End;

Begin
Nhap;
XuLy;
End.

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {

  int n,m,k;
  scanf("%d %d %d", &n, &m, &k);
  int black;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      black = i*j+(n-i)*(m-j);
      if (black == k) {
        printf("Yes\n");
        return 0;
      }
    }
  }
  printf("No\n");

  return 0;
}

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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n-1; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }

const ll inf = 1e18;
const int nax = 1e5 + 5;

// ll fact[nax], invfact[nax];

// void pre()
// {
// 	fact[0] = 1;
// 	forn(i, 1, nax)
// 	{
// 		fact[i] = mult(fact[i - 1], i);
// 	}

// 	invfact[nax - 1] = mypow(fact[nax - 1], mod - 2);

// 	ford(i, nax, 1)
// 	{
// 		invfact[i - 1] = mult(invfact[i], i);
// 	}
// }

// ll ncr(ll n, ll r)
// {
// 	if (r > n)
// 		return 0;

// 	ll ans = mult(fact[n], mult(invfact[n - r], invfact[r]));

// 	return ans;
// }

int main()
{
	speedup_IO;

	int t = 1;
	//cin >> t;
	while (t--)
	{
		set<ll>s;
		ll a,b,c;
		cin>>a>>b>>c;
		s.insert(a),s.insert(b),s.insert(c);

		if(s.size() == 2)
		{
			cout<<"Yes";
		}
		else
		{
			cout<<"No";
		}
	}

	return 0;
}

Measured memory_bytes: 768
N = int(input())
P = list(map(int, input().split()))

Q = []
for i in range(N):
    if i == 0:
        Q.append(P[i])
    else:
        Q.append(min(Q[-1], P[i]))

cnt = 0
for i in range(N):
    if P[i] <= Q[i]:
        cnt += 1
print(cnt)

Measured memory_bytes: 32388
N, K = [int(n) for n in input().split()]
NUM = 1000000007

def modpow(a, b): # (a ** b) % NUM
    ans = 1
    while b != 0:
        if b % 2 == 1:
            ans *= a
            ans %= NUM
        a = a * a
        a %= NUM
        b //= 2
    return ans

C = [0 for _ in range(K+1)]
for d in range(K):
    k = K - d # K ... 1
    L = K // k
    C[k] = modpow(L, N) # A = 1*k ... L*k
    for l in range(2, L+1):
        C[k] -= C[l*k]
        if C[k] < 0:
            C[k] += NUM
        C[k] %= NUM

ans = 0
for k in range(1, K+1):
    ans += k * C[k]
    ans %= NUM
print(ans)



Measured memory_bytes: 11212
#include<iostream>
using namespace std;
char s[30010];
int main()
{
	int n;
	cin>>n;
	cin>>s;
	int sum=0;
	int a,b,c;
	int ppp=0;
	int p=0;
	for(int i='0';i<='9';i++){
		ppp=0;
		p=ppp;
		while(1){
			if(p>=n){
				break;
			}
			if(s[p]==i){
				break;
			}
			p++;
			
		}
		a=p;
		if(p<n-2){
			for(int j='0';j<='9';j++){
				p=a+1;
				while(1){
					if(p>=n){
						break;
					}
					if(s[p]==j){
						break;
					}
					p++;
					
				}
				b=p;
				if(p<n-1){
					for(int z='0';z<='9';z++){
						p=b+1;
						while(1){
							if(p>=n){
								break;
							}
							if(s[p]==z){
								break;
							}
							p++;
						}
						c=p;
						if(p<n){
							sum++;
						}
					}
					
				}
			}
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
xc = Counter()
for _ in range(n):
    xc[input()] += 1

mx = xc.most_common(1)[0][1]
ans = []
for v in xc.items():
    if v[1] == mx:
        ans.append(v[0])
ans.sort()
print(*ans, sep="\n")


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

bool isPalin(const string& s, int i, int j) {
    if (i >= j) return true;
    while (i < j) {
        if (s[i] != s[j]) return false;
        ++i;
        --j;
    }
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string s;
    cin >> s;
    int N = s.size();
    int i1 = 0, i2 = (N - 1) / 2 - 1;
    int j1 = (N + 3) / 2 - 1, j2 = N - 1;
    if (isPalin(s, 0, N - 1) && isPalin(s, i1, i2) && isPalin(s, j1, j2)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


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

  int N;
  cin>>N;
  vector<int>A(N);
  vector<int>key(N,0);
  int ans=0;
  int check=0;
  for(int i=0;i<=N-1;i++){
  
    cin>>A[i];
  }
  for(int i=0;i<=N-1;i++){
  
    if(key[i]==0){
      
      check=A[i]-1;
      if(A[check]==i+1){
    
        key[i]=1;
        key[check]=1;
        ans++;
      }
    }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 4020
#include<stdio.h>
int main(void){
  int i,n,sum=0;
  scanf("%d",&n);
  int v[n],c[n];
  for(i=0;i<n;i++){
    scanf("%d",&v[i]);
  }
  for(i=0;i<n;i++){
    scanf("%d",&c[i]);
  }
  for(i=0;i<n;i++){
    if(v[i]>c[i]) sum += v[i] - c[i];
  }
  printf("%d \n",sum);
  return 0;
}

Measured memory_bytes: 128
n,w=map(int,input().split())
a=[[int(i) for i in input().split()] for _ in range(n)]

dp=[]
for y in range(n+1):
    l=[]
    if y==0:dp.append([0]*(w+1));continue
    for x in range(w+1):
        if x==0:l.append(0);continue
        
        now_weight=x
        up_value=dp[-1][now_weight]

        index_weight=a[y-1][0]
        index_value=a[y-1][1]

        blank_weight=max(0,now_weight-index_weight)
        blank_max_value=dp[-1][blank_weight]
        

        t_value=up_value
        if now_weight>=index_weight:t_value=max(blank_max_value+index_value,up_value) 
        
        l.append(t_value)
        
    dp.append(l)

print(dp[n][w])

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

int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int>> job(m+1);
  rep(i,n){
    int a,b;
    cin>>a>>b;
    if(a<=m) job[a].pb(b);
  }  
  int ans = 0;
  priority_queue<int> q;
  rep(i,m+1){
    for(auto x:job[i]){
      q.push(x);
    }
    if(!q.empty()){
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;

signed main()
{
	string s; cin>>s;
	cout<<s[0]<<s[1]<<s[2]<<endl;
	return 0;
}




Measured memory_bytes: 3588
H,W,K=map(int,input().split())
c_map=[]
for _ in range(H):
	c=input()
	c_map.append(c)

ans=0

for i in range(2**H):
	for j in range(2**W):
		cnt=0
		for k in range(H):
			for l in range(W):
				if c_map[k][l]=='#' and (i>>k)&1==0 and (j>>l)&1==0:
					cnt+=1
		if cnt==K:
			ans+=1

print(ans)

Measured memory_bytes: 9204
#include <iostream>

using namespace std;

typedef unsigned long long ull;

int m, n;
ull w[100];

bool b(ull W)
{
	int need = 1;
	ull s = 0;
	for(int i=0; i<n; i++)
	{
		if(w[i] > W)
		{
			return false;
		}

		if(s+w[i] > W)
		{
			need++;
			s = 0;
		}
		s+=w[i];
	}
	return need <= m;
}

int main()
{
	while( 1 )
	{
		scanf("%d", &m);
		scanf("%d", &n);
		if((m|n)==0) break;
		
		for(int i=0; i<n; i++)
		{
			scanf("%llu", &w[i]);
		}
		
		ull l = 1;
		ull r = 1500000;
		while(r-l > 1)
		{
			ull mid = (r + l) / 2;
			if(b(mid)) r = mid;
			else l = mid;
		}

		printf("%llu\n", b(l)?l:r);
	}
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    int a = sc.nextInt();
    int b = sc.nextInt(); 
    String u = sc.next();
    if(u.equals(s)) {
      a--;
    } else {
      b--;
    }
    System.out.println(a + " " + b);
  }
}


Measured memory_bytes: 23124
N,M,C=map(int,raw_input().split())
B_ary=[]
A_ary=[]

B_ary = map(int,raw_input().split())

score=0
result = 0
for i in range(N):
    score=0
    A = map(int,raw_input().split())
    for j in range(M):
        score = score + A[j] * B_ary[j]

    if score + C > 0:
        result = result + 1

print result


Measured memory_bytes: 2568
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int N;
	cin >> N;
	REP(i,N){
		int n;
		cin >> n;
		int maxh = 0;
		int minh = 0;
		int pre = 0;
		REP(j, n){
			int a;
			cin >> a;
			if (j != 0){
				maxh = max(maxh, a - pre);
				minh = min(minh, a - pre);
			}
				pre = a;
		}
		cout << maxh << " " << abs(minh) << endl;
	}
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
//#include <cstdlib>
#include <string>
#include <math.h>
using namespace std;
//整形Shift + alt + f 
//int x[101],y[101],h[101];
//int koya[100001][];
/*
//ユークリッドの互除法
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
*/
int n;
int a[101];
double sum = 0;
int main(){

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
        sum += a[i]; 
    }
    sum = sum / (double)n;
    
    int res=0;
    double k = 1000;
    for(int i=0; i<n; i++){
        double test;
        test = sum - a[i];
        if(test <= 0){
            test = -test;
        }
        if(test < k){
                res = i;
                k = test;
        }
    }

    cout << res;
    return 0;
}

Measured memory_bytes: 256