akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define ss second
//#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  A.begin(), A.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))


#define forr(i,n) for(i=0; i<n; i++)
#define whilee(i,t) while(i!=t)
#define pb(x) push_back(x);

//sort(A.begin(),A.end());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//accumulate(A.begin(), A.end(), 0);
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll i, j, k, a, b, c, l, m, n, p, q, r, s, t, x, y, z, cnt=0, min=INT_MAX;

    cin>>n>>x;
    int A[n];
    forr(i,n)
    {
        cin>>A[i];
    }
    t=abs(x-A[n-1]);
    forr(i,n-1)
    {
       t = __gcd(t,abs(x-A[i]));
    }
     cout<<t<<endl;

    return 0;
}

Measured memory_bytes: 3964
import java.util.Arrays;
import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] a = new int[n];
        
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        
        Arrays.sort(a);
        
        int sumA = 0;
        int sumB = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                sumA += a[n-1 -i];
            } else {
                sumB += a[n-1 -i];
            }
        }
        
        System.out.println(sumA - sumB);
    }
}

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

int main() {
  int N, K, tot;
  cin >> N >> K;
  tot = 0;
  
  for (int i = 0; i < N; i++){
    int xi;
    cin >> xi;
    if (xi > K - xi){
      tot += K - xi;
    }
    else {
      tot += xi;
    }
  }
  cout << 2 * tot << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

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

    int n, k, aa;
    cin >> n >> k;
    vector<int> a(n+1, 0);
    for(int i=0;i<k;++i){
        cin >> aa;
        a[aa] = 1;
    }

    vector<ll> dp(n+1, 0);
    dp[0] = 1;
    for(int i=0;i<n;++i) {
        if(a[i+1] == 0) {
            dp[i+1] += dp[i];
            dp[i+1] %= MOD;
        }
        if(i < n-1 && a[i+2] == 0) {
            dp[i+2] += dp[i];
            dp[i+1] %= MOD;
        }
    }

    cout << dp[n] << endl;
}


Measured memory_bytes: 1408
from collections import deque

def solve(init):
  groups = [-1 for i in range(N)]
  groups[init] = 1
  q = deque()
  q.append(init)
  while len(q) > 0:
    u = q.popleft()
    for v in range(N):
      if M[u][v] == 0:
        continue
      if groups[v] != -1:
        if groups[v] == groups[u]-1 or groups[v] == groups[u]+1:
          continue
        else:
          return -1
      groups[v] = groups[u] + 1
      q.append(v)
  return max(groups)


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

res = -1
for u in range(N):
  res = max(res, solve(u))

print(res)


Measured memory_bytes: 3692
using System;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());

        if (N == 1)
        {
            Console.WriteLine("1");
        }

        for (int i = 1; i < N+1; i++)
        {
            if (i * i > N)
            {
                Console.WriteLine((i-1) *(i-1));
                break;
            }
        }
        
    }
}

Measured memory_bytes: 13140
require 'prime'
n=gets.to_i
a=gets.split.map(&:to_i)
l=[0]*1000001
a.each do |aa|
  l[aa]+=1
end
s=0
2.upto(1000000) do |i|
  x=i
  c=0
  while x<=1000000
    if l[x]>0
      c+=l[x]
    end
    x+=i
  end
  s=c if s<c
end
#s=l.max
if s<=1
  puts "pairwise coprime"
elsif s==n
  puts "not coprime"
else
  puts "setwise coprime"
end


Measured memory_bytes: 88548
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,x,y,t;
    cin>>n>>x>>y;
    vector<int> a(n-1,0);
    
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            t=min(j-i,abs(x-i)+1+abs(y-j));
            a[t-1]++;
        }
    }
    
    for(int m:a){
        cout<<m<<"\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
int dp[3001][3001];

using namespace std;

int solve(int i,int j,int *arr){
    if(i>j) return 0;
    if(i==j) return dp[i][j] = arr[i];
    if(dp[i][j]!=-1) return dp[i][j];


    int a = solve(i+2,j,arr);
    int b = solve(i+1,j-1,arr);
    int c = solve(i,j-2,arr);

    int ans = max(min(arr[i] - (arr[i+1] - a),arr[i] - (arr[j]-b)) , min(arr[j] - (arr[j-1] - c),arr[j] - (arr[i]-b)));
    return dp[i][j] = ans;

}




int32_t main(){
    int n;
    cin >> n;
    int *arr = new int[n];
    for(int i=  0 ;i < n ; i++) cin >> arr[i];

    for(int i =0 ; i < 3001;i++){
        for(int j= 0 ; j < 3001;j++) dp[i][j] = -1;
    }

    solve(0,n-1,arr);
    cout << dp[0][n-1];


}


Measured memory_bytes: 70784
v = list(map(int, input().split()))
v.insert(0,-1)
n = int(input())
case = [[],
        [4,2,3,5], #1
        [6,3,1,4], #2
        [6,5,1,2], #3
        [6,2,1,5], #4
        [6,4,1,3], #5
        [5,3,2,4]] #6

for _ in range(n):
    topval, frontval = map(int, input().split())
    topkey, frontkey = v.index(topval), v.index(frontval)
    for i in range(4):
        if case[topkey][i] == frontkey:
            if i != 3:
                rightkey = case[topkey][i+1]
            else:
                rightkey = case[topkey][0]
    print(v[rightkey])



Measured memory_bytes: 5596
n = int(input())
a_ls = [0] * n
b_ls = [0] * n
c_ls = [0] * n
for i in range(n):
    a,b,c = map(int,input().split())
    a_ls[i] = a
    b_ls[i] = b
    c_ls[i] = c

dp = [[0]*3 for _ in range(n+1)]
dp[1] = [a_ls[0], b_ls[0], c_ls[0]]
for i in range(1,n):
    dp[i+1][0] = max(dp[i+1][0], dp[i][1] + a_ls[i], dp[i][2] + a_ls[i])
    dp[i+1][1] = max(dp[i+1][1], dp[i][0] + b_ls[i], dp[i][2] + b_ls[i])
    dp[i+1][2] = max(dp[i+1][2], dp[i][0] + c_ls[i], dp[i][1] + c_ls[i])

print(max(dp[-1]))

Measured memory_bytes: 34632
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int par[10001],rank[10001];
void init(int n){
  for(int i=0;i<n;i++)
    par[i]=i,rank[i]=1;
}
int find(int x){
  if(par[x]==x)return x;
  else return par[x]=find(par[x]);
}
void unit(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y)return;
  if(rank[x]<rank[y])par[x]=y;
  else{
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}
bool same(int x,int y){
  return find(x)==find(y);
}
struct edge{int u,v;double cost;};
bool comp(const edge& e1,const edge& e2){
  return e1.cost>e2.cost;
}
edge es[1000001];
int V,E;
double kruskal(){
  sort(es,es+E,comp);
  init(V);
  double res=0;
  for(int i=0;i<E;i++){
    edge e=es[i];
    if(!same(e.u,e.v)){
      unit(e.u,e.v);
      res+=e.cost;
    }
  }
  return res;
}
int main(){
  cin>>V>>E;
  double p[V][2],sum=0;
  r(i,V)cin>>p[i][0]>>p[i][1];
  r(i,E){
    int a,b;
    cin>>a>>b;a--;b--;
    es[i].u=a;es[i].v=b;
    es[i].cost=sqrt((p[a][0]-p[b][0])*(p[a][0]-p[b][0])+(p[a][1]-p[b][1])*(p[a][1]-p[b][1]));
    sum+=es[i].cost;
  }
  printf("%.10f\n",sum-kruskal());
}

Measured memory_bytes: 3888
#include<stdio.h>
#include<math.h>
int main(){
    double x1, x2, y1, y2;
    double dis, disr;
    scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
    dis = (x2 - x1 ) * ( x2 - x1 ) + (y2 - y1 ) * ( y2 - y1 );

    disr = sqrt(dis);

    printf("%f\n", disr);

    return 0;
}

Measured memory_bytes: 652
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N, M;
    cin >> N >> M;

    int ans = 0;

    int num = min(N, M / 2);
    ans += num;
    M -= num * 2;

    ans += M / 4;
    cout << ans << endl;
    return 0;
}


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

main () {
  ll n;
  array<ll, 5> a;
  scanf("%lld", &n);
  rep(i,5) scanf("%lld", &a[i]);

  ll min_ = *min_element(a.begin(), a.end());

  printf("%lld\n", n/min_ + (n%min_ ? 5 : 4));

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

template<typename T>
T gcd(T a, T b)
{
	if (a < b) return gcd(b, a);
	T r;
	while (r = a % b)
	{
		a = b;
		b = r;
	}
	return b;
}

int main()
{
	long long a, b;
	scanf("%lld %lld", &a, &b);
	long long g = gcd(a, b);
	std::vector<long long> pcount;

	long long n = g;
	for (long long i = 2; i * i <= g; ++i)
	{
		long long c = 0;
		while (n % i == 0)
		{
			c++;
			n /= i;
		}
		if (c > 0) pcount.push_back(c);
	}
	if (n != 1) pcount.push_back(1);

	printf("%lld\n", pcount.size() + 1);
}

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

using namespace std;
#define ull unsigned long long
#define ll long long

/*-----------------------------------------------------MATH------------------------------------------------*/
inline ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
inline int pwm(ll xx, ll pow, int MD) {
    if (pow < 0) { pow = pow % (MD - 1) + MD - 1; }
    ll mlt = 1;
    while (pow) {
        if (pow & 1) {
            mlt *= xx;
            mlt %= MD;
        }
        xx *= xx;
        pow >>= 1;
        xx %= MD;
    }
    return (int) mlt;
}
inline ll gcdex(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll xx, yy;
    ll gc = gcdex(b, a % b, yy, xx);
    x = xx;
    y = yy - (a / b) * xx;
    return gc;
}
inline int inv(ll r, int _mod) { return pwm(r % _mod, _mod - 2, _mod); }
/*-----------------------------------------------------MATH------------------------------------------------*/

const int inf = 1e6;
const int MAXN = 2e5 + 10;
ll mod = 1e9;
vector<ll> arr;
bool cmp(ll a, ll b) {
    return a>b;
}
bool check(vector<ll> &arr, int num, int n, ll m, int v, int p){
    if(p-1+n-num>=v && arr[num]+m>=arr[p-1]){
        return true;
    }
    else if(p-1+n-num>=v && arr[num]+m<arr[p-1]) return false;
    else if(p-1+n-num<v && arr[num]+m<arr[p-1]) return false;
    else v-=(p-1+n-num);
    ll summ=0;
    for(int i=p-1;i<=num-1;i++){
        summ+=(arr[num]+m-arr[i]);
    }
    return summ >= m * v;
}

void solve(){
    int n,v,p;
    ll m;
    cin>>n>>m>>v>>p;
    arr.resize(n);
    for(int i=0;i<n;i++) cin>>arr[i];
    sort(arr.begin(), arr.end(), cmp);
    int l=0;
    int r=n;
    /*for(int son:arr) cout<<son<<" ";
    cout<<endl;*/
    while(r-l>1){
        int num=(l+r)/2;
        if(check(arr, num, n,m,v,p)){
            l=num;
        }
        else r=num;
    }
    cout<<l+1;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n=1;
    for (int i = 0; i < n; i++) solve();
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S;
    cin >> S;
    int N = S.size();
    ll ans = 0;
    reverse(S.begin(), S.end());
    bool ok = false;
    int cnt = 0;
    rep(i, N) {
        if (ok) {
            if (S[i] == 'A') {
                ans += cnt;
            } else if (S[i] == 'C' && i < N - 1 && S[i + 1] == 'B') {
                cnt++;
            } else if (S[i] == 'B' && S[i - 1] == 'C') {
                continue;
            } else {
                cnt = 0;
                ok = false;
            }
        } else {
            if (S[i] == 'C' && i < N - 1 && S[i + 1] == 'B') {
                cnt++;
                ok = true;
            }
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 720
import sys
sys.setrecursionlimit(10000000)
input=lambda : sys.stdin.readline().rstrip()

def eratosthenes(n):
    prime_table = [False,False,True]+[False if i%2!=0 else True for i in range(n-2)]
    i=3
    primes=[]
    while i*i<=n:
        if prime_table[i]:
            j=i*i
            while j<=n:
                prime_table[j]=False
                j+=i
        i+=2
    for i in range(len(prime_table)):
        if prime_table[i]:
            primes.append(i)
    return primes

prime_table = eratosthenes(50001)
while True:
    m,a,b=map(int,input().split())
    if m==a==b==0:
        break
    l=0
    mx=(0,0,0)
    for r in range(len(prime_table)):
        while True:
            if  mx[0]<prime_table[l]*prime_table[r]<=m and prime_table[l]/prime_table[r]>=a/b:
                mx=(prime_table[l]*prime_table[r],l,r)
            if prime_table[l]*prime_table[r]>m and l-1>=0:
                l-=1
            elif l+1<=r and (prime_table[l+1])*prime_table[r]<=m:
                l+=1
            else:
                break
    print(prime_table[mx[1]],prime_table[mx[2]])




Measured memory_bytes: 6180
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
#n = int(input())
#n, k = map(int, sys.stdin.readline().split())
n = input()
#a = list(map(int, sys.stdin.readline().split()))

x = int(n[-1])
if x == 3:
    print("bon")
elif x == 0 or x == 1 or x == 6 or x == 8:
    print("pon")
else:
    print("hon")


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

int main() {
 UL N; scanf("%u",&N);
 UL A[100000]; rep(i,N) scanf("%u",&A[i]);
 UL Q; scanf("%u",&Q);
 rep(q,Q){
  UL k; scanf("%u",&k);
  UL l=0,r=N+1;
  while(l+1!=r){
   UL m=(l+r)>>1;
   if(A[m-1]<k) l=m;
   else r=m;
  }
  printf("%u\n",l);
 }
 return 0;
}




Measured memory_bytes: 3564
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        long count = S.chars().filter(ch -> ch == 'x').count();
        System.out.println(count >= 8 ? "NO" : "YES");
    }

}


Measured memory_bytes: 26836
def readinput():
    n=int(input())
    s=[]
    for _ in range(n):
        s.append(input())
    return n,s

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def main(n,s):
    count={}
    for word in s:
        sword=''.join(sorted(word))
        if sword in count:
            count[sword]+=1
        else:
            count[sword]=1
    ans=0
    for k,v in count.items():
        if v>1:
            ans+=cmb(v,2)        

    return ans

if __name__=='__main__':
    n,s=readinput()
    ans=main(n,s)
    print(ans)


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

int main()
{
    /*freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);*/
    int n,c,k;
    cin>>n>>c>>k;
    int t[n];
    for(int i=0;i<n;i++)
    {
       cin>>t[i];
    }
    sort(t,t+n);
    int j=0,b=0,cpt=0;
    for(int i=0;i<n;i++)
    {
        if(t[i]>t[j]+k || cpt==c)
        {
            j=i;
            b++;
            cpt=1;
        }
        else
            cpt++;
    }
    cout<<++b<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  int n; cin >> n;

  vector<int> d(n, 1);
  for (int i = 2; i < n; i++) {
    int j = i;
    while (j < n) {
      d[j]++;
      j += i;
    }
  }

  ll sum = 0;
  for (int i = 1; i < n; i++) {
    sum += d[i];
  }
  cout << sum << endl;
  return 0;
}


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
  int a , b , c ;
  scanf("%d %d %d", &a, &b,&c) ; 

  for(int i = 1 ;i<=b+1 ; i++){
    if((a*i)%b == c){
      printf("YES") ;
      return 0 ;
    }
  }
  printf("NO") ;
	
  return 0 ;
}



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

using namespace std;
#define ll long long
const int N=2e5+5;
int a[N];
bool ball[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int l,r;
    set<int>st;
    cin>>l>>r;
    st.insert(l%2019);
    int ans=1e9;
    for(int i=l+1;i<=r;i++){
        for(auto x:st)
            ans=min(ans,x*(i%2019)%2019);
        if(ans==0)
            return cout<<ans<<endl,0;
        st.insert(i%2019);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int n, a[101];

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

	sort(a, a + n);

	int s = 0, t = 0;
	for(int i = 0;i < n;i+=2){
		s -= a[i];
		if(i + 1 < n) t -= a[i+1];
	}

	cout << s - t << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define NIL -1
#define MAX 1000
typedef long long ll;

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

    int N, W;
    cin >> N >> W;

    vector<ll> w(N+1), v(N+1);
    for(int i = 1; i <= N; ++i){
        cin >> w[i] >> v[i];
    }

    ll dp[N+1][W+1];
    rep(j, W+1) dp[0][j] = 0;
    rep(i, N+1) dp[i][0] = 0;

    for(int i = 1; i <= N; ++i){
        for(int j = 1; j <= W; ++j){
            dp[i][j] = 0;
            if (j - w[i] < 0) dp[i][j] = dp[i-1][j];
            else dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
        }
    }

    ll maxv = 0;
    rep(i, N+1) maxv = max(maxv, dp[i][W]);

    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 79232
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef long double ld;
ll A[100000];



int main() {
	ll x;
	cin >> x;
	x = pow(x, 3);
	cout << x << endl;
	return 0;
}





Measured memory_bytes: 3268
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> bool chmax(T &a, U b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> bool chmin(T &a, U b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, k; cin >> n >> k;
  int x = (n + 1) / 2;

  if (x >= k) cout << "YES" << endl;
  else cout << "NO" << endl;

  return (0);
}


Measured memory_bytes: 3648
#!/usr/bin/env python3
s = input()
s = s.replace('G', 'A')
s = s.replace('T', 'A')
s = s.replace('C', 'A')


def long_repeat(line):
    cnt = 1
    max = 1
    if line != "":
        for i in range(1, len(line)):
            if line[i] == line[i-1]:
                cnt += 1
                if cnt > max:
                    max = cnt
            else:
                cnt = 1
        return max
    else:
        return 0


if 'A' not in s:
    print(0)
    exit()

print(long_repeat(s))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
const int mod=1e9+5;
struct edge{
  int to,id;
};
vector<vector<edge>> g;
vector<int> ans;
void dfs(int v,int c=-1,int p=-1){
  int k=1;
  rep(i,g[v].size()){
    int u=g[v][i].to;int ei=g[v][i].id;
    if(u==p)continue;
    if(c==k)++k;
    ans[ei]=k;++k;
    dfs(u,ans[ei],v);
  }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    g.resize(n);
    ans.resize(n);
    rep(i,n-1){
      int a,b;cin>>a>>b;
      --a;--b;
      g[a].push_back((edge){b,i});
      g[b].push_back((edge){a,i});
    }
    dfs(0);
    int mx=0;
    rep(i,n)mx=max(mx,int(g[i].size()));
      cout<<mx<<endl;
    rep(i,n-1)cout<<ans[i]<<endl;
    return 0;
}


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

using namespace std;

int getNum(string s)
{
    if (s == "mamoru") return 0;
    if (s == "tameru") return 1;
    return 2;
}

int main()
{
    int K;
    cin >> K;
    string s;
    vector<int> I(K), N(K);
    for (int i = 0; i < K; i++) {
	cin >> s;
	I[i] = getNum(s);
    }
    for (int i = 0; i < K; i++) {
	cin >> s;
	N[i] = getNum(s);
    }
    int win = 0;
    int it = 0, nt = 0;
    for (int i = 0; i < K; i++) {
	if (I[i] == 1) it++;
	if (N[i] == 1) nt++;
	it = min(it, 5);
	nt = min(nt, 5);
	if (I[i] == 2 && N[i] == 0) {
	    if (it == 0) {
		win = 2;
		break;
	    } else if (it >= 5) {
		win = 1;
		break;
	    }
	} else if (I[i] == 0 && N[i] == 2) {
	    if (nt == 0) {
		win = 1;
		break;
	    } else if (nt >= 5) {
		win = 2;
		break;
	    }
	} else if (I[i] == 2 && N[i] == 1) {
	    if (it == 0) {
		win = 2;
		break;
	    } else {
		win = 1;
		break;
	    }
	} else if (I[i] == 1 && N[i] == 2) {
	    if (nt == 0) {
		win = 1;
		break;
	    } else {
		win = 2;
		break;
	    }
	} else if (I[i] == 2 && N[i] == 2) {
	    if (it == 0 && nt > 0) {
		win = 2;
		break;
	    } else if (it > 0 && nt == 0) {
		win = 1;
		break;
	    } else if (it > 0 && nt > 0) {
		if (it > nt) {
		    win = 1;
		    break;
		} else if (it < nt) {
		    win = 2;
		    break;
		}
	    }
	}
	if (I[i] == 2) it = 0;
	if (N[i] == 2) nt = 0;
    }
    if (win == 0) {
	cout << "Hikiwake-kun" << endl;
    } else if (win == 1) {
	cout << "Isono-kun" << endl;
    } else {
	cout << "Nakajima-kun" << endl;
    }
    return 0;
}

Measured memory_bytes: 3208
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	A, B, C := sc.nextInt(), sc.nextInt(), sc.nextInt()
	if A+B >= C {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll dp[100010][13];
int main() {
	string s;
	cin>>s;
	if(s[0]=='?'){
	for(ll i=0;i<10;i++){
		dp[0][i]=1;
	}
	}
	else{
		dp[0][s[0]-'0']=1;
	}
	for(ll i=1;i<s.size();i++){
		for(ll j=0;j<13;j++){
			if(s[i]=='?'){
			for(ll k=0;k<=9;k++){
				ll now=k+j*10;
				now%=13;
				dp[i][now]+=dp[i-1][j];
				dp[i][now]%=inf;
			}
			}
			else{
				ll now=s[i]-'0'+j*10;
				now%=13;
				dp[i][now]+=dp[i-1][j];
				dp[i][now]%=inf;
			}
		}
	}
	cout << dp[s.size()-1][5];
	// your code goes here
	return 0;
}

Measured memory_bytes: 10752
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> bool max_self(T & a, const T & b){ 
  return b > a ? a = b, true : false; 
}
template<class T> bool min_self(T & a, const T & b){ 
  return b < a ? a = b, true : false;    
}
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

 
int main(){
  FAST_IO
  int a, b;
  cin >> a >> b;
  cout << a * b << '\n';
  return 0;
}


Measured memory_bytes: 3488
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n,k; cin>>n>>k;
  ll ans=k*pow(k-1,n-1);
  cout <<ans<<endl;
}
      
    

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const int maxn = 1e6 + 7;
const ll f = 1e6;
int n, m, k, q;
int ar[maxn];

vector<int> g[maxn];
int main() 
{
    //ios::sync_with_stdio(0); cin.tie(0); //C++关同步
    cin >> n >> m;
    for(int i = 1; i <= n; ++i)cin >> ar[i];
    for(int i = 1; i <= m; ++i){
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        int flag = 1;
        for(int v : g[i]){
            if(ar[i] <= ar[v]){
                flag = 0;
                break;
            }
        }
        ans += flag;
    }
    cout << ans << '\n';
    


    return 0;
}


Measured memory_bytes: 30236
#include <iostream>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << ((a + b) >= 24 ? (a + b) - 24 : (a + b)) << "\n";
  return 0;
}


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

using namespace std;

int main(void){

    int n;
    cin >> n;

    cout << (n >= 1000 ? "ABD" : "ABC") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)





int main() {
	string s, t;
	in(s);
	in(t);
	ll sizeT = t.size() - 1;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());

	rep(i, 0, min(s.size(), t.size())) {
		if (s[i] < t[sizeT-i]) {
			outn("Yes");
			return 0;
		}
		else if (s[i] > t[sizeT-i]) {
			outn("No");
			return 0;
		}
	}
	if (s.size() < t.size()) {
		outn("Yes");
		return 0;
	}
	outn("No");
	return 0;

}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var abk = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var a = abk[0];
        var b = abk[1];
        var k = abk[2];
        Console.WriteLine(E.Range(1, 100).Where(x => a % x == 0 && b % x == 0).Reverse().Take(k).Last());
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string.h>
#include <string>
using namespace std;
int main()
{
	string in;
	cin >> in;
	if (in[0] == in[1]) { cout << "Bad"; }
	else {
		if(in[1] == in[2]){ cout << "Bad"; }
		else {
			if (in[2] == in[3]) { cout << "Bad"; }
			else {
				cout << "Good";
			}
		}
	}
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    cout << (m * 1900 + (n - m) * 100) * (1 << m);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n){
		cin >> a[i];
	}
	int i = 1, ans = 0;
	while(i != 2){
		if(a[i-1] == i){
			ans = -1;
			break;
		}
		ans++;
		if(ans > n){
			ans = -1;
			break;
		} 
		i = a[i-1];
	}
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 3784
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    unsigned long long A;
    double B;
    cin >> A >> B;
    unsigned long long sum = B * 100 + 0.1;
    sum *= A;
    cout << sum/100 << endl;
    return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, k;

int main() {
	cin >> n >> k;
	
	cout << (k == 1 ? 0 : n - k) << endl;
	
	return 0;
}


Measured memory_bytes: 256
h={}
f=->l,r{h[[l,r]]||=r<l ?0:l<2?1+f[2,r]:f[l/2,~-r/2]+f[l=-~l/2,r/2]+f[l,~-r/2]}
eval"p f[%d,%d].%%10**9+7"%gets.split

Measured memory_bytes: 3964
import sys

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

def dfs(fr, now, num):
    global graph, addsum, ans
    tmp = num + addsum[now]
    for a in graph[now]:
        if a == fr:
            continue
        dfs(now, a, tmp)
    ans[now] = tmp


def main():
    global graph, addsum, ans
    N, Q = map(int, readline().split())
    graph = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, readline().split())
        a -= 1; b -= 1
        graph[a].append(b)
        graph[b].append(a)
    addsum = [0]*N
    for _ in range(Q):
        p, x = map(int, readline().split())
        p -= 1
        addsum[p] += x
    
    ans = [0]*N
    dfs(-1, 0, 0)

    print(*ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 236948
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;

int main(){
  int n,q;
  string s;
  cin >> n;
  cin >> s;
  cin >> q;
  vector<set<int>> table(26);
  rep(i,s.size()) table[s[i]-'a'].insert(i);
  rep(query,q){
    int com;cin >> com;
    if(com == 1){
      int i;
      char ch;
      cin >> i >> ch;
      --i;
      table[s[i]-'a'].erase(i);
      s[i] = ch;
      table[ch-'a'].insert(i);
    }else{
      int ans = 0;
      int l,r;cin >> l >> r;
      --r;--l;
      rep(j,26){
        set<int>::iterator it = table[j].lower_bound(l);
        if(it != table[j].end() && *it <= r) ans++;
      }
      printf("%d\n",ans);
    }
  }
}

Measured memory_bytes: 27256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

const uint64_t MOD = 1000000000 + 7;

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

	map<int, int> a;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;

		a[x - 1] ++;
		a[x] ++;
		a[x + 1] ++;
	}

	int maxs = -1;
	for (int i = -1; i < 100010; i++)
	{
		maxs = max(maxs, a[i]);
	}

	cout << maxs << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
	while(1){
		int t;
		cin >> t;
		if(t==0) break;
		
		vector<int> dur(t);
		for(int i=0; i<t; i++){
			cin >> dur[i];
		}
		int n;
		cin >> n;
		vector<int> sch(101, 24);
		int last=0;
		for(int i=0; i<n; i++){
			int d,m;
			cin >> d >> m;
			sch[d] = min(sch[d], m);
			last = max(last, d);
		}
		
		vector<vector<int> > dp(last+1, vector<int>(t, inf));
		dp[1][0] = 0;
		for(int i=1; i<last; i++){
			for(int j=0; j<t; j++){
				if(dp[i][j]==inf) continue;
				if(sch[i+1] >= dur[(j+1)%t]){
					dp[i+1][(j+1)%t] = min(dp[i][j], dp[i+1][(j+1)%t]);
				}
				dp[i+1][0] = min(dp[i+1][0], dp[i][j]+1);
			}
		}
		
		int ans=inf;
		for(int i=0; i<t; i++){
			ans = min(ans, dp[last][i]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3136
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <functional>
#include <time.h>
#include <ctype.h>
#include <stack>
#include <bitset>
#include <iostream>

using namespace std;

#define x first
#define y second
#define pb push_back
#define INF (2000000000)
#define LINF (1000000000000000000LL)
#define lowbit(x) (x&(-x))
#define gc getchar

inline int geti(){
  register int c = gc(), x = 0;
  for(; c<'0' || c>'9'; c=gc());
  for(; c>='0' && c<='9'; c=gc())
    x = (x<<1) + (x<<3) + c -'0';
  return x;
}

template <class T>
  inline T sq(T x){ return x * x; }

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const ll MOD = 1000000007LL;
const double pi = acos(-1.0);
const int MAXN = 1e6 + 5;

int A, B, C;
map<vector<int>, int> mp;

int main(){
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif
  scanf("%d %d %d", &A, &B, &C);
  int cnt = 0;
  bool ok = true;
  while(!(A & 1) && !(B & 1) && !(C & 1)){
    if(A == B && B == C){ ok = false; break; }
    vector<int> vec;
    vec.push_back(A); vec.push_back(B); vec.push_back(C);
    sort(vec.begin(), vec.end());
    if(mp.find(vec) != mp.end()){ ok = false; break; }
    mp[vec] = 1;
    ll tmp1 = A, tmp2 = B, tmp3 = C;
    A = tmp2 / 2 + tmp3 / 2;
    B = tmp1 / 2 + tmp3 / 2;
    C = tmp1 / 2 + tmp2 / 2;
    cnt++;
  }
  printf("%d\n", ok ? cnt : -1);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

string s, t;

int main() {
    cin >> s >> t;
    bool ans = true;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i])
            ans = false;
    }
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

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


int main() {
    int N; cin >> N;
    
    vector<vector<int>> A(N, vector<int>(N-1));
    rep(i, N){
        rep(j, N-1){
            cin >> A[i][j];
            A[i][j]--;
        }
    }
    
    vector<vector<int>> id(N, vector<int>(N));
    int V = 0;
    rep(i, N){
        rep(j, N){
            if(i<j){
                id[i][j] = V++;
            }
        }
    }
    
    auto toId = [&](int i, int j){
        if(i>j) swap(i, j);
        return id[i][j];
    };
    
    vector<vector<int>> E(V);
    vector<int> Nyuji(V);
    for(int i=0; i<N; i++){
        for(int j=0; j<N-2; j++){
            int from = toId(i, A[i][j]);
            int to = toId(i, A[i][j+1]);
            E[from].push_back(to);
            Nyuji[to]++;
        }
    }
    
    queue<PII> S;
    for(int i=0; i<V; i++){
        if(Nyuji[i]==0){
            S.push({i, 1});
        }
    }
    
    int ans = 0;
    int done = 0;
    while(S.size()){
        PII p = S.front();
        done++;
        ans = p.sc;
        S.pop();
        for(int to:E[p.fs]){
            Nyuji[to]--;
            if(Nyuji[to]==0){
                S.push({to, p.sc+1});
            }
        }
    }
    
    if(done!=V){
        cout << -1 << endl;
        return 0;
    }
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 37376
# coding: utf-8
#Problem Name: List of Top 3 Hills
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp

height = [0 for _ in range(10)]
for i in range(10):
    height[i] = int(raw_input())

top3 = sorted(height)[:6:-1]
for h in top3:
    print h

'''
sample input
1819
2003
876
2840
1723
1673
3776
2848
1592
922
'''

Measured memory_bytes: 4208
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;

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

  ll current = n;
  ll ans = 0;
  while (current > 0) {
    current = current / k;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
n, k = map(int, input().split())
A = list(map(int, input().split()))
for _ in range(k):
  B = [0]*(n+1)
  for i, a in enumerate(A):
    B[max(i-a, 0)] += 1
    B[min(i+a+1, n)] -= 1
  A = list(accumulate(B))[:-1]
  if min(A) == n:
    break
print(*A)

Measured memory_bytes: 202240
s = list(input())
left = int( s[0]+s[1] )
right = int( s[2]+s[3] )

if 1 <= left <= 12:
    if 1 <= right <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= right <= 12:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void)
{
  int n;
  scanf("%d", &n);
  int i;
  int a[n+1];
  int b[n+1];
  memset(b, 0, sizeof(b));
  for (i = 2; i <= n; i++)
  {
    scanf("%d", &a[i]);
    b[a[i]]++;
  }
  for (i = 1; i <= n; i++)
    printf("%d\n", b[i]);
  
  return 0;
}

Measured memory_bytes: 3288
s = list(input())

res = "Yes"

for index, value in enumerate(s):
    index += 1
    if index % 2 == 0:
        if value != 'L' and value != 'U' and value != 'D':
            res = "No"
            break
    else:
        if value != 'R' and value != 'U' and value != 'D':
            res = "No"
            break

print(res)


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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    int n, m;
    cin >> n >> m;

    vector<vector<int>> g(n + 1);

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<pair<int, int>> b(n + 1);
    for (int i = 0; i < n + 1; i++) {
        b[i] = make_pair(-1, INT_MAX);
    }

    b[1] = make_pair(0, 0);

    queue<pair<int, int>> q;
    q.push(make_pair(1, 0));

    while (!q.empty()) {
        pair<int, int> t = q.front();
        q.pop();

        for (int i = 0; i < g[t.first].size(); i++) {
            if (b[g[t.first][i]].first < 0) {
                b[g[t.first][i]] = make_pair(t.first, t.second + 1);
                q.push(make_pair(g[t.first][i], t.second + 1));
            }
        }
    }

    cout << "Yes" << endl;
    for (int i = 2; i <= n; i++) {
        cout << b[i].first << endl;
    }
}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

const int mod = 2019;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll l,r,ans=2020;
	cin>>l>>r;
	for(ll i=l;i<r;++i){
		for(ll j=i+1;j<=r;++j){
			ans=min(ans,(i*j)%mod);
			if(ans==0){
				cout<<0<<endl;
				exit(0);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256