akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define sz(x) ((int) x.size())
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


ll eleva( ll x, int y, int mod ) {
    ll res = 1;

    while ( y ) {
        if ( y & 1 ) {
            res = (res * x) % mod;
        }

        y >>= 1;
        x = (x * x) % mod;
    }

    return res;
}


int main() {sws;

    ll k;
    cin >> k;

    if ( !(k & 1) or (k % 5 == 0) ) {
        cout << "-1\n";
        return 0;
    }


    int resto = 7 % k;
    int cont = 1;
    while ( resto != 0 ) {
        resto = (resto + ((7 * eleva(10, cont, k)) % k)) % k;
        // cout << resto << endl;
        cont++;
    }

    cout << cont << endl;

    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int cnt = 0;
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < 3; i++) {
    if (s[i] == t[i]) cnt++;
  }
  cout << cnt << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N; cin >> N;
    string S,T; cin >> S >> T;
    string ans;
    REP(i,N){
        ans += S[i];
        ans += T[i];
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, beg, end) for (int i = (beg); i < (end); i++)
const ll PSIZE = 10000000;

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (a >= k)
    {
        cout << k;
    }
    else if (a + b >= k)
    {
        cout << a;
    }
    else
    {
        cout << a - (k - a - b);
    }

    return 0;
}

Measured memory_bytes: 3596
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N, Y = inm()
FALSE = (-1, -1, -1)


def solve():
    if Y % 1000 != 0:
        return FALSE
    y = Y // 1000
    for c in range(N + 1):
        b4 = y - 9 * c - N
        if b4 < 0 or b4 > 4 * N or b4 % 4 != 0:
            continue
        b = b4 // 4
        a = N - b - c
        if a < 0 or a > N:
            continue
        return c, b, a
    return FALSE


print(*solve())


Measured memory_bytes: 9176
import Control.Applicative
import Data.List
import Data.Char

getInt :: IO Integer
getInt = (\a -> read a :: Integer) <$> getLine

getIntArray :: IO [Integer]
getIntArray = ((map (\a -> read a :: Integer)) . words) <$> getLine

getStrArray :: Integer -> IO [String]
getStrArray 0 = return [] :: IO [String]
getStrArray n = (:) <$> getLine <*> (getStrArray (n - 1))

countEach :: [Integer] -> (Integer, Integer, Integer)
countEach [] = (0, 0, 0)
countEach (x:xs)
    | mod x 4 == 0 = 
        let (a, b, c) = countEach xs
            in (a + 1, b, c)
    | mod x 2 == 0 =
        let (a, b, c) = countEach xs
            in (a, b + 1, c)
    | otherwise =
        let (a, b, c) = countEach xs
            in (a, b, c + 1)

canSort :: (Integer, Integer, Integer) -> String
canSort (a, b, c)
    | b == 0 && c <= a + 1 = "Yes"
    | b > 0 && c <= a = "Yes"
    | otherwise = "No"

main =do
    getLine
    putStrLn =<< (canSort . countEach) <$> getIntArray


Measured memory_bytes: 36220
H,W=map(int,input().split())
MAP=[list(input()) for i in range(H)]

BLIST=[]

for i in range(H):
    for j in range(W):
        if MAP[i][j]=="B":
            BLIST.append([i,j])

BLIST.sort(key=lambda x:x[0]+x[1])
ANS=abs(BLIST[0][0]-BLIST[-1][0])+abs(BLIST[0][1]-BLIST[-1][1])

BLIST.sort(key=lambda x:x[0]-x[1])
ANS=max(ANS,abs(BLIST[0][0]-BLIST[-1][0])+abs(BLIST[0][1]-BLIST[-1][1]))

print(ANS)



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

int a[5];
int c1,c2;

int main()
{
	cin>>a[0]>>a[1]>>a[2];
	for(int i=0;i<3;++i)
		if(a[i]==5) c1++;
		else if(a[i]==7) c2++;
	if(c1==2&&c2==1) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
    return 0;
} 

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


int main(){
    ll N;cin>>N;
    ll a[200010],rui[200010];
    cin>>a[0];
    map<ll,ll> m;
    m[0]++;
    m[a[0]]++;
    rui[0]=a[0];
    rep(i,1,N){
        cin>>a[i];
        rui[i]=rui[i-1]+a[i];
        m[rui[i]]++;
    }
    ll ans=0;
    for(auto i:m){
        if(i.second>=2){
            ans+=i.second*(i.second-1)/2;
        }
    }
    cout<<ans<<endl;
    
}







Measured memory_bytes: 15872
# -*- coding: utf-8 -*-

#input
import numpy as np
[X,Y,Z,K] = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

D = []
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

#make list
for i in range(min(K,X)):
    for j in range(min((K//(i+1))+1,Y)):
        for k in range(min(((K//(i+1))+1)//(j+1),Z)):
                D.append(A[i]+B[j]+C[k])
D.sort(reverse=True)
for i in range(K):
    print(int(D[i]))

Measured memory_bytes: 18036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
int gcd(int a,int b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
int main() {
    int h,w,cnt = 0;
    cin >> h >> w;
    vector<string> a(h);
    for (int i = 0; i < h; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(a[i][j] == '#') cnt++;
        }
    }
    if(cnt == h+w-1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

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

int main(){
	int m,d;
	cin>>m>>d;
	int c=0,x,y;
	for(int i=1;i<=d;i++){
		x=i/10;
		y=i%10;
		if(x>=2 && y>=2){
			if(x*y<=m) c++;
		}
	}
	cout<<c<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>
 
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
 
#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;

template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<<(i+1==n?'\n':' '); }
template<class T>void pp(T v){ EACH(it,v) cout<<(it==v.begin()?"":" ")<<*it; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

inline void write_bool(bool b, const string &tval, const string &fval) {
  cout << (b ? tval : fval) << endl;
} 
inline void YESNO(bool b) { return write_bool(b, "YES", "NO"); }
inline void YesNo(bool b) { return write_bool(b, "Yes", "No"); }
inline void yesno(bool b) { return write_bool(b, "yes", "no"); }

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

struct Edge { int src, dst; };

vector<vector<Edge>> v;
vint qs;

void DFS(int cur, int parent, int sum, vint &result) {
  sum += qs[cur];
  result[cur] = sum;

  REP(i,v[cur].size()) {
    int next = v[cur][i].dst;
    if (next == parent) continue;
    DFS(next, cur, sum, result);
  }
}

int main() {
  int n, q;
  while (cin >> n >> q) {
    v = vector<vector<Edge>>(n);
    REP(i,n-1) {
      int s, d; cin >> s >> d;
      s--; d--;
      v[s].push_back((Edge) { s, d });
      v[d].push_back((Edge) { d, s });
    }
    qs = vint(n);
    REP(_,q) {
      int a, b; cin >> a >> b;
      qs[a-1] += b;
    }

    vint result(n, 0);
    DFS(0, -1, 0, result);
    pp(result);
  }
  
}


Measured memory_bytes: 28288
import itertools
N,M,Q = map(int,input().split())

number_list = [int(i) for i in range(1,M+1)]
comb_number_list = list(itertools.combinations_with_replacement(number_list,N))
Q_list_total = []

for i in range(Q):
    Q_list = [int(x) for x in input().split()]
    Q_list_total.append(Q_list)
#print(Q_list_total)    
    
#print(comb_number_list)
answer_list = []

for i in range(len(comb_number_list)):
    answer = 0
    total = 0
    for j in range(len(Q_list_total)):
        answer = comb_number_list[i][Q_list_total[j][1]-1] - comb_number_list[i][Q_list_total[j][0]-1]
        if answer == Q_list_total[j][2]:
            total += Q_list_total[j][3]
    answer_list.append(total)
#print(Q_list)
print(max(answer_list))

Measured memory_bytes: 25192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define vpli vector<pair<long long,int>>
#define deb(x) cout<<x<<endl;
#define all(x) x.begin(),x.end()
ll MOD = 1e9+7;
const int M = 1e6+5;
unordered_map<int,int> mp;

int helper()
{
    for(int i=1;i<M;i++)
    {
        if(mp[i]> 0)
        {
            for(int j=i+i;j<M;j+=i)
            {
                if(mp[j]>0)
                    mp[j]++;
            }
        }
    }
    int count = 0;
    for(auto x : mp)
    {
        if(x.second == 1) count++;
    }
    return count;
}

void solve()
{
    int n,x;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        mp[x]++;
        //sieve[x]++;
    }
    cout<<helper();
}

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

Measured memory_bytes: 42704
n, k = map(int, input().split())
a = list(map(int, input().split()))

pos = 0
visit = [0]*n
move = []
roop = []
while visit[pos] != 2:
    if visit[pos] == 0:
        move.append(pos)
    else:
        roop.append(pos)
    visit[pos] += 1
    pos = a[pos] - 1
if len(move) > k:
    print(move[k]+1)
else:
    print(roop[(k-(len(move)-len(roop))) % len(roop)]+1)


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

vector<int> to[200005];
vector<int> ans;

void dfs(int v, int p = -1){
  for(int u : to[v]){
    if(u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
}

int main(){
  int N, Q;
  cin >> N >> Q;
  for(int i = 0; i < N-1; i++){
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(N);
  
  for(int i = 0; i < Q; i++){
    int p, x;
    cin >> p >> x;
    --p;
    ans[p] += x;
  }
  dfs(0);
  for(int i = 0; i < N; i++) cout << ans[i] << endl;
  return 0;
}

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

struct edge{
    int u, v, c;
    bool operator<(const edge &e)const{
        return c < e.c;
    }
};

struct UnionFind{
    vector<int> par, sz;
    UnionFind(int n){
        par.resize(n);
        sz.resize(n, 1);
        for(int i = 0; i < n; i++) par[i] = i;
    }
    int find(int x){
        if(x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return;
        if(sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

int n, m;
vector<edge> es; 

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(1){
        cin >> n >> m;
        if(n + m == 0) break;
        es.clear();
        es.resize(m);
        rep(i, 0, m){
            cin >> es[i].u >> es[i].v >> es[i].c;
            es[i].u--; es[i].v--;
        }
        UnionFind uf(n);
        sort(es.begin(), es.end());
        int ans = -1;
        int cnt = 0;
        rep(i, 0, m){
            if(!uf.same(es[i].u, es[i].v)){
                uf.unite(es[i].u, es[i].v);
                cnt++;
                if(cnt == n / 2){
                    ans = es[i].c;
                }
            }
        }
        cout << ans << endl;
    }
}


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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

int main() {
	string s; cin >> s;
	while (!s.empty()) {
		s = s.substr(0, s.size() - 1);
		if (!(s.size() & 1) && s.substr(s.size() >> 1) == s.substr(0, s.size() >> 1)) {
			cout << s.size() << endl; return 0;
		}
	}
	return 0;
}


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

const int MaxN = 100000;
unsigned long long S[ MaxN + 10 ];

void SCNF( unsigned long long &x )
{
char C;

	while( true )
	{
		C = fgetc( stdin );
		if( C >= '0' && C <= '9' ) break;
	}

	x = C - '0';
	while( true )
	{
		C = fgetc( stdin );
		if( C < '0' || C > '9' ) break;

		x = x * 10 + ( C - '0' );
	}
}

int main()
{
unsigned long long i;
unsigned long long N;
unsigned long long M;
unsigned long long A;
unsigned long long x;
unsigned long long iCnt;
unsigned long long iSum;

	scanf( "%llu%llu", &N, &M );

	iSum = 0;
	iCnt = 0;
	for( i = 1; i <= N; i++ )
	{
		SCNF( A );

		iSum += A;
		iSum %= M;
		S[ i ] = iSum;
	}

	sort( S, S + ( N + 1 ) );

	x = 0;
	for( i = 1; i <= N; i++ )
	{
		if( S[ i - 1 ] == S[ i ] )
			x++;
		else
		{
			iCnt += ( x + 1 ) * x / 2;
			x = 0;
		}
	}

	if( x > 0 ) iCnt += ( x + 1 ) * x / 2;

	printf( "%llu\n", iCnt );

	return 0;
}


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

int main() {
  int h, w;

  while (true) {
    cin >> h >> w;
    if (h == 0 && w == 0) {
      // cout << endl;
      break;
    }

    for (int i=0; i<h; i++) {
      for (int j=0; j<w; j++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
//const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}


int main() {
	ll A, B;

	cin >> A >> B;

	if (A <= 9 && A >= 1 && B <= 9 && B >= 1) {

		cout << A * B << endl;
	}
	else
		cout << -1 << endl;
	

	
	
	return 0;
}

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

int main()
{
	int N;
	cin >> N;
	cout << (N+1) /2 <<endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    println(problem140a(n))
}

fun problem140a(n: Int): Long {
    var count = 0L
    for (i in 1..n) {
        for (j in 1..n) {
            for (k in 1..n) {
                count++
            }
        }
    }
    return count
}

Measured memory_bytes: 31264
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int n,l;
    cin >> n >> l;
    ll sum = 0;
    vector <ll> a(n);
    ll mi = 500;
    bool positive = true;
    rep(i,0,n) {
        a[i] = l + i; 
        if (abs(0-a[i]) < mi) {
            mi = abs(0-a[i]);
            if (a[i] < 0) {
                positive = false;
            }
        }
        sum += a[i];
    }
    if (positive) {
        cout << sum -mi << endl;
    } else {
        cout << sum + mi << endl;
    }
}

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

int main()
{
    int l,sum=0;
    string s;
    cin>>s;
    l = s.length();
    if(s[0]=='?') s[0]='D';
    for(int i=1;i<l-1;i++)
    {
        if(s[i]=='?')
        {
            if(s[i-1]=='P') s[i]='D';
            else if(s[i+1]=='D') s[i]='P';
            else if(s[i+1]=='?') s[i]='P';
            else s[i]='D';
        }
    }
    if(s[l-1]=='?') s[l-1]='D';
    cout<<s;
}


Measured memory_bytes: 3756
H, W , N = (int(i) for i in input().split())  
sr, sc = (int(i) for i in input().split())  
S = input()
T = input()

# 高橋はUR、青木はDL重視

su = sr
sd = sr
sle = sc
sri = sc 
flag = False
for ss, tt in zip(S, T):

    if ss == "U":
        su -= 1
    if ss == "D":
        sd += 1
    if ss == "R":
        sri += 1
    if ss == "L":
        sle -= 1

    if su == 0 or sd > H or sri > W or sle == 0:
        flag = True    

    if tt == "U" and sd > 1:
        sd -= 1
    if tt == "D" and su < H: 
        su += 1
    if tt == "R" and sle < W:
        sle += 1
    if tt == "L" and sri > 1:
        sri -= 1

if flag==True:
    print("NO")
else:
    print("YES")



Measured memory_bytes: 53604
# -*- coding: utf-8 -*-
N = int(input())
sum = 0

if N >= 9:
  sum += 9
else:
  sum += N % 10

if N >= 999:
  sum += 999-99
elif N >= 100:
  sum += (N-99)%1000

if N >= 99999:
  sum += 99999-9999
elif N >= 10000:
  sum += (N-9999)%100000
  
print("{}".format(sum))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<ll,int>;
using Graph = vector<vector<int>>;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

vector<vector<ll>> dp(30,vector<ll>((1<<21)+10,0));

int main(){
  int n;
  cin >> n;
  vector<vector<int>> a(n,vector<int>(n,0));
  rep(i,n) rep(j,n) cin >> a[i][j];
  
  dp[0][0] = 1;
  for(int i=0;i<n;i++){
    for(ll j=0;j<(1<<n);j++){
      if(dp[i][j] !=0 ) for(int s=0;s<n;s++){
        if(!(j&(1<<s)) && a[i][s]) dp[i+1][j|(1<<s)] += dp[i][j] % mod;
      }
    }
  }
  cout << dp[n][(1<<n)-1] % mod << endl;
} 

Measured memory_bytes: 508288
/**
 *  author:   TakeruOkuyama
 *  created:  2020-04-15 11:17:28
**/
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    int N;
    cin >> N;
    /*vector<pair<string, int>> sp(N);
    rep(i, N){
        string s;
        int p;
        cin >> s >> p;
        sp[i].first = s;
        sp[i].second = p;
    }
    sort(sp.begin(), sp.end());
    reverse(sp.begin(), sp.end());
    rep(i, N){
        cout << sp[i].second << sp[i].first << endl;
    }*/
    vector<tuple<string, int , int>> guide(N);
    rep(i, N){
        string s;
        int p;
        cin >> s >> p;
        get<0>(guide[i]) = s;
        get<1>(guide[i]) = -p;
        get<2>(guide[i]) = i+1;
    }
    sort(guide.begin(), guide.end());
    //reverse(guide.begin(), guide.end());
    rep(i, N){
        cout << get<2>(guide[i]) << endl;
    }
return 0;}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  cout << 180*(N-2) << endl;
}

Measured memory_bytes: 256
from collections import Counter, defaultdict
N = int(input())
S = [input() for _ in range(N)]

alphabets = [chr(ord('a')+i) for i in range(26)]
nums = defaultdict(int)
for s in S:
  ct = Counter(s)
  key = tuple([ct[al] for al in alphabets])
  nums[key] += 1

ans = 0
for n in nums.values():
  if n >= 2:
    ans += n * (n-1) // 2
print(ans)

Measured memory_bytes: 43376
#include<cstdio>
using namespace std;
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<6){
        printf("0\n");
    }
    else if(a<13){
        printf("%d\n",b/2);
    }
    else{
        printf("%d\n",b);
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>

using namespace std;

int dp[100030];
int cost[100030];

int main () {
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>cost[i];
	}
	int gr=min(k,n);
	for(int i=1;i<=gr;i++){
		dp[i]=abs(cost[i]-cost[0]);
	}
	for(int i=k+1;i<n;i++){
		dp[i]=dp[i-1]+abs(cost[i]-cost[i-1]);
		for(int j=2;j<=k;j++){
			dp[i]=min(dp[i],dp[i-j]+abs(cost[i]-cost[i-j]));
		}
	}
	cout<<dp[n-1];



return 0;
}


Measured memory_bytes: 1024
// A - We Love Golf
#include <bits/stdc++.h>
using namespace std;

int main(){
	int K,A,B; cin>>K>>A>>B;
	string ans = "NG";
	for(int i=A; i<=B; ++i) if(i%K==0) ans = "OK";
	cout<< ans <<endl;
}


Measured memory_bytes: 3520
#!/usr/bin/env python2
# -*- coding: utf-8 -*-

N = int(raw_input())
tree = [[] for _ in xrange(N)]

for i in range(N-1):
    a, b, c = map(int, raw_input().split())
    a -= 1; b -= 1;
    tree[a].append((b, c))
    tree[b].append((a, c))

Q, K = map(int, raw_input().split())
K -= 1

depth = [0 for _ in xrange(N)]

def dfs(v, p = -1, d = 0):
    St = []
    St.append([v, p, d])
    # 空のシーケンスは偽になる
    while St:
        cur = St.pop()
        depth[cur[0]] = cur[2]
        for i, j in tree[cur[0]]:
            if i == cur[1]:
                continue
            St.append([i, cur[0], cur[2] + j])

dfs(K)

for i in range(Q):
    x, y = map(int, raw_input().split())
    x -= 1; y -= 1
    print depth[x] + depth[y]


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

bool isKaibun(string s){
  int N = s.size();
  if(N % 2 == 1){
    for(int i=0;i<(N-1)/2;i++){
    if(s.at(i) != s.at(N-1-i)){
      return false;
    }
  }
  }else{
      for(int i=0;i<=(N-1)/2;i++){
    if(s.at(i) != s.at(N-1-i)){
      return false;
    }
  }
  }
  return true;
}
 
int main(){
  string S;
  cin >> S;
  int N = S.size();
  
  string Ss, Se;
  string tmp = S;
  for(int i=0;i<N;i++){
    if(i<(N - 1)/2){
      Ss.push_back(tmp.at(i));
    }else if(i>(N - 1)/2){
      Se.push_back(tmp.at(i));
    }
  }
  if(isKaibun(S) && isKaibun(Ss) && isKaibun(Se)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
//  cout << S << " " << Ss << " " << Se << endl;
//  cout << isKaibun(S) << isKaibun(Ss) << isKaibun(Se) << endl;
}
  

Measured memory_bytes: 256
while l = gets
  name, type = l.split
  break if type == "X"
  ret = ""
  if name.include?("_")
    if type == "D"
      ret = name
    else
      names = name.split("_")
      sz = names.size
      if type == "L"
        ret = names[0]
      else
        ret = names[0].capitalize
      end
      (1..sz-1).each do |i|
        ret << names[i].capitalize
      end
    end
  else
    sz = name.size
    if type == "U"
      x = name[0].capitalize
      ret << x << name[1,sz-1]
    else
      x = name[0].downcase
      ret = x
      if type == "L"
        ret << name[1,sz-1]
      else
        (1..sz-1).each do |i|
          if name[i].match(/[A-Z]/) == nil
            ret << name[i]
          else 
            ret << "_" << name[i].downcase
          end
        end
      end
    end
  end
  puts ret
end

Measured memory_bytes: 8696
N = int(input())
TA = []
for i in range(N):
    T, A = map(int, input().split())
    TA.append((T, A))

T, A = TA[0]
answer = T+A
p = 1
prev = p
pT, pA = T, A
for i in range(1,N):
    # (T+A) * p >= prev
    # p >= prev/(T+A)
    T, A = TA[i]
    s = T+A
    p = (answer+s-1)//s
    p1 = (pT+T-1)//T
    p2 = (pA+A-1)//A
    p = max([p,p1,p2])
    pT, pA = p*T, p*A
    answer =  pT+pA
    #print(T, A, p, answer, sep="\t")
print(answer)

    


Measured memory_bytes: 38896
import java.util.*;

public class Main {

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

		int n = sc.nextInt();
		int[] num = new int[n];
		int chk = 0;
		
		for (int i = 0; i < n; i++) {
			num[i] = sc.nextInt();
		}
		
		Arrays.sort(num);
		

		for (int i = 0; i < n - 1; i++) {
			if (num[i] == num[i + 1]) {
				System.out.println("NO");
				chk++;
				break;
			}
		}
		
		if (chk == 0) {
			System.out.println("YES");
		}

	}

}


Measured memory_bytes: 64452
#include <stdio.h>

main(){

  int i,j,mini=0,min;
  int n,A[100],tmp;
  int count=0,flag=0;

  scanf("%d",&n);
  if(n<1||100<n)return 0;

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


  min=A[0];

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(min>A[j]){
	min=A[j];
	mini=j;
	flag=1;
      }
    }
    if(flag==1){
	tmp=A[i];
	A[i]=A[mini];
	A[mini]=tmp;
	flag=0;
	count++;
      }
    min=A[i+1];


  }
      for(i=0;i<n;i++){
	printf("%d",A[i]);
	if(i<n-1)printf(" ");
	if(i==n-1)printf("\n");
  }
      printf("%d\n",count);
      return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int, int> P;

int main() {
    string s;
    cin >> s;
    int n = sz(s);

    //R,Lの区間をつくる
    //移動回数実質無限だから, RLが隣接するマスに入る

    vector<int> r; //Lの右隣のRの場所
    vector<int> l; //Rの左隣のLの場所
    vector<int> b; //RとLの境界

    int cnt = 0;

    rep(i, n) {
        if (i==0) {
            r.push_back(i);
            cnt++;
            continue;
        }
        if (s[i-1] == 'L' && s[i] == 'R') {
            r.push_back(i);
            l.push_back(i-1);
            cnt++;
            continue;
        }
        if (i == n-1) l.push_back(i);
    }

    for (int i=1; i<n; i++) {
        if (s[i-1] == 'R' && s[i] == 'L') {
            b.push_back(i-1); //R基準
        }
    }

    int p = 0;
    vector<int> ans(n);

    rep(i, cnt) {
        if (l[i]-r[i] == 1) {
            ans[r[i]] = 1;
            ans[l[i]] = 1;
        } else {
            
            ans[b[i]] = 1 + (b[i]-p)/2 + (l[i]-b[i])/2;
            ans[b[i]+1] = 1 + (b[i]+1-p)/2 + (l[i]-b[i]-1)/2;
        }

        p = l[i] + 1;

    }

    rep(i, n) {
        cout << ans[i] << endl;
    }

}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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 int mod = 1000000007;
struct mint {
    ll x; // using long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n;
    cin>>n;

    vector<vector<vector<vector<mint>>>> dp(n - 2, vector<vector<vector<mint>>>(4, vector<vector<mint>>(4, vector<mint>(4))));   // 0:A 1:G 2:C 3:T
    rep(k, 4) rep(l, 4) rep(m, 4) {
        if (k == 0 && l == 1 && m == 2) continue;
        if (k == 0 && l == 2 && m == 1) continue;
        if (k == 1 && l == 0 && m == 2) continue;
        dp[0][k][l][m] = 1;
    }
    rep(i, n - 3) rep(j, 4) rep(k, 4) rep(l, 4) rep(m, 4) {
        int ni = i + 1, nj = k, nk = l, nl = m;
        if (k == 0 && l == 1 && m == 2) continue;
        if (k == 0 && l == 2 && m == 1) continue;
        if (k == 1 && l == 0 && m == 2) continue;
        if (j == 0 && k == 1 && l == 1 && m == 2) continue;
        if (j == 0 && k == 3 && l == 1 && m == 2) continue;
        if (j == 0 && k == 1 && l == 3 && m == 2) continue;
        dp[ni][nj][nk][nl] += dp[i][j][k][l];
    }
    mint ans = 0;
    rep(i, 4) rep(j, 4) rep(k, 4) ans += dp[n - 3][i][j][k];
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target (sse, sse1, sse2, tune=native, popcnt)

#include <bits/stdc++.h>
/*
const int MAX_MEM = 25e7;
int mpos = 0;
char mem[MAX_MEM];
inline void* operator new(size_t n) {
    char *res = mem + mpos;
    mpos += n;
    assert(mpos <= MAX_MEM);
    return (void *) res;
}
inline void operator delete(void *) {}
*/
using namespace std;

#define loop(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, n) for(int i = a; i < n; ++i)
#define vec vector
#define paii pair<int, int>
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define SZ(x) (int)x.size()
#define Unique(x) x.erase(unique(all(x)), x.end())

#define int long long

const int inf = 1e17 + 47, MAXN = 2047, N = 20, mod = 1e9 + 7;

mt19937 rnd(time(0));

int n, k;
int d[MAXN], cnt[MAXN];
vec<int> graf[MAXN];

paii bfs(int st, int pr) {
    vec<int> pt;
    pt.pb(pr);
    d[pr] = -1;
    d[st] = 1;
    queue<int> q;
    q.push(st);
    while(!q.empty()) {
        int p1 = q.front();
        q.pop();

        pt.pb(p1);
        cnt[d[p1]]++;

        for(int p2 : graf[p1]) {
            if(d[p2] > d[p1] + 1) {
                d[p2] = d[p1] + 1;
                q.push(p2);
            }
        }
    }
    /*cout << st + 1 << ": ";
    loop(i, 5) cout << cnt[i] << " ";
    cout << endl*/;

    int kek = cnt[0];
    FOR(i, 1, k / 2) {
        if(cnt[i] == 0) break;
        cnt[i] += cnt[i - 1];
        kek = cnt[i];
    }
    paii p = {kek, kek + cnt[k / 2]};
    FOR(i, 1, n) {
        if(cnt[i] == 0) break;
        cnt[i] = 0;
    }
    for(int c : pt) d[c] = inf;
    return p;
}

void solve() {
    loop(i, MAXN) d[i] = inf;
    loop(i, MAXN) cnt[i] = 0;
    cin >> n >> k;
    if(k == 1) {
        if(n == 1) cout << 0 << endl;
        else cout << n - 2 << endl;
        return ;
    }
    k++;
    loop(i, n - 1) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        graf[a].pb(b);
        graf[b].pb(a);
    }
    int ans = 0;
    loop(p1, n) {
        //cout << p1 + 1 << ": " << endl;
        vec<paii> t;
        for(int p2 : graf[p1]) {
            t.pb(bfs(p2, p1));
            //cout << t.back().fr << " " << t.back().sc << endl;
        }
        if(k % 2 == 1) {
            int sum = 1;
            for(paii p : t) sum += p.sc;
            ans = max(ans, sum);
        } else {
            int sum = 1;
            for(paii p : t) sum += p.fr;
            for(paii p : t) {
                int k = sum - p.fr + p.sc;
                ans = max(ans, k);
            }
        }
        //cout << endl;
    }
    cout << n - ans << endl;
}

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

    #ifdef COFFEE_MACHINE
        freopen("input.cpp", "r", stdin);
        freopen("output.cpp", "w", stdout);
    #endif // COFFEE_MACHINE

    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
}


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

const int INF = 1 << 30;

int h[101000];
int dp[101000];

int main() {
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> h[i];

    for (int i = 0; i < 101000; i++) dp[i] = INF;
    dp[0] = 0;

    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= K; j++) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    cout << dp[N - 1] << endl;
}

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

using namespace std;

int main(){
	long long a, b, res; scanf("%lld %lld", &a, &b);
	if((a + b) % 2 != 0) res = (a + b) / 2 + 1;
	else res = (a + b) / 2;
	printf("%lld\n", res);
}

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

void solve(long long a, long long b){
    string ans = "";
    if(a <= b){
        for(int i=0;i<b;i++){
            ans += to_string(a);
        }
    }else{
        for(int i=0;i<a;i++){
            ans += to_string(b);
        }
    }
    cout << ans << endl;

}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


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

int main()
{
    int n,c=0,s=0;
    cin>>n;
    long long a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++){
        if(a[i]>=a[i+1]){
            c++;
        }
        else{
            c=0;
        }
        if(c>s){
            s=c;
        }
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

// 頂点数、変数
int v, e;
const int MAX_N = 100100;
// 隣接リスト
vector<int> g[MAX_N];
bool used[MAX_N];
// トポロジカルソートされた数列
vector<int> tsorted;

void dfs(int u) {
  if(used[u]) return;
  used[u] = true;
  for(auto& i: g[u]) dfs(i);
  // 帰りがけ順で追加
  tsorted.push_back(u);
}

void tsort() {
  for(int i=0; i<v; ++i) dfs(i);
  reverse(tsorted.begin(), tsorted.end());
}

signed main(void)
{
  cin >> v >> e;
  for(int i=0; i<e; ++i) {
    int s, t;
    cin >> s >> t;
    g[--s].push_back(--t);
  }

  tsort();
  int dp[v]={};
  rep(i,v){
    int j=tsorted[i];
    for(k:g[j]){
      chmax(dp[k],dp[j]+1);
    }
  }
  sort(dp,dp+v);
  cout<<dp[v-1]<<endl;
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    valarray<llong> a(n);
    REP(i, n){cin >> a[i];}
    cout << a.min() << " " << a.max() << " " << a.sum() << endl;

    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int H = Integer.parseInt(tokens[0]);
		int W = Integer.parseInt(tokens[1]);
		char[][] s = new char[H][W];
		for (int i = 0; i < H; ++i) {
			String line = in.nextLine();
			for (int j = 0; j < W; ++j) {
				s[i][j] = line.charAt(j);
			}
		}

		boolean[][] flags = new boolean[H][W];
		for (int i = 0; i < H; ++i) {
			Arrays.fill(flags[i], false);
		}

		boolean result = true;
		for (int h = 0; h < H; ++h) {
			for (int w = 0; w < W; ++w) {
				if (s[h][w] == '#') {
					if (!check(s, flags, h, w, H, W)) {
						result = false;
						break;
					}
				}
			}
			if (!result) {
				break;
			}
		}
		if (result) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		in.close();
	}

	private static boolean check(char[][] s, boolean[][] flags, int h, int w, int H, int W) {
		if (flags[h][w]) {
			return true;
		}

		if (h > 0) {
			if (s[h - 1][w] == '#') {
				flags[h - 1][w] = true;
				return true;
			}
		}
		if (w > 0) {
			if (s[h][w - 1] == '#') {
				flags[h][w - 1] = true;
				return true;
			}
		}
		if (h + 1 < H) {
			if (s[h + 1][w] == '#') {
				flags[h + 1][w] = true;
				return true;
			}
		}
		if (w + 1 < W) {
			if (s[h][w + 1] == '#') {
				flags[h][w + 1] = true;
				return true;
			}
		}
		return false;
	}
}

Measured memory_bytes: 25172
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

a, b, c = LI()

# ABCの3人が持っているクッキーを交換する。
# 3人は同時に、手持ちのクッキーを半分割し、残りの二人にそれぞれ1方を渡すことを繰り返す。
# 誰かの持っているクッキーが奇数個になったら操作をやめる。
# クッキー交換は何回行うことができるか。無限に続けられることもある。

def distribute(a,b,c):
    x = a/2
    y = b/2
    z = c/2

    a2 = y + z
    b2 = x + z
    c2 = x + y

    if a == a2 and b == b2 and c == c2:
        print(-1)
        sys.exit()
    return a2, b2, c2

count = 0

while (a % 2 == 0) and (b % 2 == 0) and (c % 2 == 0):
    a, b, c = distribute(a, b, c)
    count += 1
    # print(a, b, c)

print(count)

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

void dfs(ll x){
  if(n>=x ){
    set<int> s; ll y=x;
    while(y%10!=0){
      s.insert(y%10); y/=10;
    }
    if(s.size()==3){ans++;}
  }
  if(n<x){return;}
  dfs(x*10+3);
  dfs(x*10+5);
  dfs(x*10+7);
}
int main() {
  cin>>n;
  dfs(3);dfs(5);dfs(7);
  cout<<ans;
}

Measured memory_bytes: 256
var line, i, eof_i;

line = require('fs').readFileSync('/dev/stdin', 'ascii').split("\n");
for (i = line.length - 1; i >= 0; i--)
	if (line[i].indexOf("?") !== -1) eof_i = i;
line = line.slice(0, eof_i);
console.log(line.map(solve).join("\n"));

function solve(line) {
	var ary;
	ary = line.split(" ", 3);
	if (ary[1] == '+') return parseInt(ary[0]) + parseInt(ary[2]);
	else if (ary[1] == '-') return parseInt(ary[0]) - parseInt(ary[2]);
	else if (ary[1] == '*') return parseInt(ary[0]) * parseInt(ary[2]);
	return Math.floor(parseInt(ary[0]) / parseInt(ary[2]));
}

Measured memory_bytes: 15732
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

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

    int N,X,Y; cin >> N >> X >> Y;
    X--; Y--;
    int cnt[10000];
    rep(i,10000) cnt[i]=0;
    rep(i,N){
        rng(j,i+1,N){
            int a=min(j-i,abs(X-i)+abs(Y-j)+1);
            cnt[a]++;
        }
    }
    rep(i,N){
        if(i==0) continue;
        cout << cnt[i] << endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	int n, i;
	cin >> n;
	string s;
	cin >> s;
	
	int r = 0;
	for(char c : s) {
		if(c == 'R') 
		r++;
	}
	
	int totr = 0;
	fo(i, 0, r) {
		if(s[i] == 'R')
		totr++;
	}
	cout << r - totr;
}


Measured memory_bytes: 3740
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
 
int main(void) {
    int n;cin>>n;
    int i=2;
    cout<<n<<":";
    while(n!=1 && i*i<=n){
        if(n%i!=0)i++;
        else{
            cout<<" "<<i;
            n/=i;
        }
    }
    if(n!=1)cout<<" "<<n;
    cout<<endl;
     
    return 0;
}


Measured memory_bytes: 3112
N,C = map(int,input().split())
X,V = [],[]
for i in range(N):
    x,v = map(int,input().split())
    X.append(x)
    V.append(v)
Ans = 0

# 右回り、左周りの原点基準の移動距離
xR = [0]+X
xL = [0]+list(map(lambda x: C-x,reversed(X)))

# 右回り,左周りで食べた時の累積カロリー
V2 = list(reversed(V))
calR,calL = [0],[0]
for i in range(N):
    calR.append(calR[i]+V[i])
    calL.append(calL[i]+V2[i])

# 移動距離を考慮した獲得カロリー
getR,getL = [],[]
for i in range(N+1):
    getR.append(calR[i]-xR[i])
    getL.append(calL[i]-xL[i])
# 単調増加になるように修正
for i in range(N):
    if getR[i+1] < getR[i]:
        getR[i+1] = getR[i]
    if getL[i+1] < getL[i]:
        getL[i+1] = getL[i]

for i in range(N+1):
    gr = getR[N-i]
    gl = getL[i]
    xr = xR[N-i]
    xl = xL[i]
    # 右回り → 左周り
    Ans = max(Ans, gr, gr-xr+gl)
    # 左周り → 右回り
    Ans = max(Ans, gl, gl-xl+gr)

print(Ans)


Measured memory_bytes: 35856
import math
n = int(input())
a = list(map(int, input().split()))

if n == 0:
    print(1 if a[0] == 1 else -1)
    exit()

top_m = [0] * (n+1)
top = 1
for i, x in enumerate(a):
    top_m[i] = top - x
    top = top_m[i] * 2
top_m = top_m[::-1][1:]
# print(top_m)

p_max = a[-1]
p_min = math.ceil(p_max/2)
top = p_max
a = a[::-1][1:]
for i, x in enumerate(a):
    # print(x, p_max, p_min, top_m[i], top)
    if p_min > top_m[i]:
        print(-1)
        exit()
    now = x + min(p_max, top_m[i])
    p_max = now
    p_min = math.ceil(now/2)
    top += now
print(top)


Measured memory_bytes: 703504
#include <stdio.h>

int main(void){
	
	int i, n, time, min = 9999;
	
	scanf("%d %d", &n, &time);
	
	int c[n], t[n];
	
	for(i = 0; i < n; i++){
		scanf("%d %d", &c[i], &t[i]);
	}
	
	for(i = 0; i < n; i++){
		if(time >= t[i] && min > c[i]){
			min = c[i];
		}
	}
	
	if(min == 9999){
		printf("TLE");
	}else{
		printf("%d", min);
	}
	
	return 0;
}

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

int checkEvenStr(string& str)
{
    int size = str.length();
    if(size == 0){
        return -1;
    }
    
    if(size % 2 != 0){
        return -1;
    }
    
    string str1 = str.substr(0, size/2);
    string str2 = str.substr(size/2, size-1);
    
    if(str1 == str2){
        return size;
    }
    return -1;
}

int main()
{
    string str;
    cin >> str;
    
    str.pop_back();
    
    while(str.length() > 0){
        int result = checkEvenStr(str);
        if(result > 0){
            cout << result;
            break;
        }
        str.pop_back();
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
  int N,K;
  cin>>N>>K;
  int x[N];
  int ans=0;
  for(int i=0;i<N;i++){
    cin>>x[i];
    ans+=min(x[i],abs(x[i]-K))*2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#挿入ソート
#A[i] i = 1-n　でソート済み箇所をiで指定
#A[j] j = 0-i　でA[i]より大きな値が出てくるまで走査

n = int(input())
A = list(map(int, input().split()))

for i in range(0, n):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    for i in range(n):
        if i < n-1:
            print(A[i],end=' ')
        else:
            print(A[i])


Measured memory_bytes: 5976
#include <iostream>
#include <iostream>

using namespace std;

int const NMAX = 200000;
int v[1 + NMAX];

int main() {

  int n, full = 0;
  cin >> n;
  for(int i = 1;i <= n;i++){
    cin >> v[i];
    full = v[i] ^ full;
  }
  for(int i = 1;i <= n;i++){
    v[i] = v[i] ^ full;
    cout << v[i] << ' ';
  }
  return 0;
}


Measured memory_bytes: 4420
<?php
fscanf(STDIN, "%d", $n);
$a = explode(' ', trim(fgets(STDIN)));
$s = $a[0];
$t = array_sum($a) - $a[0];
$x = abs($s - $t);
for ($i = 1; $i < $n - 1; $i++) {
	$s += $a[$i];
	$t -= $a[$i];
	$d = abs($s - $t);
	if ($d < $x) $x = $d;
}
echo $x;

Measured memory_bytes: 20980