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

using namespace std;

int main() {
    int n;
    cin >> n;
    int cnt4=0, cntx=0;
    for (int i=0; i<n; i++) {
        int a; cin >> a;
        if (a % 4 == 0) cnt4++;
        else if (a % 2 != 0) cntx++;
    }
    cout << (cnt4 >= cntx || (cnt4 + cntx == n && cntx == cnt4 + 1) ? "Yes" : "No") << '\n';
    return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();
            p.Solve();
        }

        void Solve()
        {
            var s = Console.ReadLine();
            var newString = new string(s.Where((x, index) => index % 2 == 0).ToArray());
            Console.WriteLine(newString);
        }

    }
}


Measured memory_bytes: 14048
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
typedef vector<int> state;

enum { EMPTY = -3, WHITE, ROOT };

inline bool not_black(const int x) {
	return x == EMPTY || x == WHITE;
}

inline int find(state &uf, const int x) {
	return uf[x] == ROOT ? x : uf[x] = find(uf, uf[x]);
}

inline bool unite(state &uf, int x, int y) {
	x = find(uf, x);
	y = find(uf, y);
	if(x == y) return false;

	uf[y] = x;
	return true;
}

inline void change_root(state &uf, const int x) {
	if(find(uf, x) != x) return;

	int r = -1;
	for(int i = 0; i < uf.size(); ++i) {
		if(x != i && !not_black(uf[i]) && x == find(uf, i)) r = i;
	}

	assert(r != -1);

	for(int i = 0; i < uf.size(); ++i) {
		if(x == uf[i]) uf[i] = r;
	}
	uf[x] = r;
	uf[r] = ROOT;
}

inline int cardinality(state &uf, int x) {
	int res = 0;
	x = find(uf, x);

	for(int i = 0; i < uf.size(); ++i) {
		if(!not_black(uf[i]) && x == find(uf, i)) ++res;
	}
	return res;
}

inline int number_of_sets(const state &uf) {
	return count(begin(uf), end(uf), ROOT);
}

int solve() {
	int h, w;
	cin >> h >> w;

	vector<string> field(h);
	for(auto &e : field) cin >> e;

	if(h == 1 && w == 1) return field[0][0] == '.' ? 0 : 1;
	if(w == 1) {
		if(h == 2) {
			if(field.front()[0] == '.' && field.back()[0] == '.') return -1;
			if(field.front()[0] == '.' || field.back()[0] == '.') return 1;
			return 2;
		}

		for(int i = 1; i < h - 1; ++i) {
			if(field[i][0] == '.') return -1;
		}
		int res = h;
		if(field.front()[0] == '.') --res;
		if(field.back()[0] == '.') --res;
		return res;
	}

	if(h == 1) {
		const string &s = field.front();
		if(w == 2) {
			if(s.front() == '.' && s.back() == '.') return -1;
			if(s.front() == '.' || s.back() == '.') return 1;
			return 2;
		}

		for(int i = 1; i < w - 1; ++i) {
			if(s[i] == '.') return -1;
		}
		int res = w;
		if(s.front() == '.') --res;
		if(s.back() == '.') --res;
		return res;
	}

	map<state, int> dp;
	dp[state(w, EMPTY)] = 0;

	for(const auto &row : field) {
		for(int x = 0; x < w; ++x) {
			map<state, int> next_dp;

			if(row[x] != '.') { // black
				for(const auto &e : dp) {
					state s = e.first;
					if(not_black(s[x])) s[x] = ROOT;
					if(x > 0 && !not_black(s[x - 1]) && !unite(s, x - 1, x)) continue;
					chmax(next_dp[s], e.second + 1);
				}
			}

			if(row[x] != '#') { // white
				for(const auto &e : dp) {
					state s = e.first;
					if(s[x] == WHITE) continue;
					if(x > 0 && s[x - 1] == WHITE) continue;
					if(s[x] != EMPTY) {
						if(cardinality(s, x) == 1) continue;
						change_root(s, x);
					}
					s[x] = WHITE;
					chmax(next_dp[s], e.second);
				}
			}

			dp = move(next_dp);
		}
	}

	int res = -1;
	for(const auto &e : dp) {
		if(number_of_sets(e.first) == 1) chmax(res, e.second);
	}
	return res;
}

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

	cout << solve() << endl;

	return EXIT_SUCCESS;
}

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

#define ran 2022

int n, k;
int c[ran*2][ran*2];

struct modular_arithmetic{
	int mod;

	modular_arithmetic(){
		mod = 1000000007;
	}
	//No specific settings.
	int add(int x,int y){return (x+=y)<mod?x:x-mod;}
	int sub(int x,int y){return (x-=y)>=0?x:x+mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
};
modular_arithmetic ma;

int c2(int n, int m) {
	if(m<n) return 0;
	return c[m-1][n-1];
}
int c3(int n, int m) {
	return c[m+n-1][n-1];
}

int main() {
	scanf("%d%d", &n, &k);
	c[0][0] = 1;
	for(int i=1;i<=n*2;i++) {
		c[i][0] = c[i][i] = 1;
		for(int j=1;j<i;j++)
			c[i][j] = ma.add(c[i-1][j-1], c[i-1][j]);
	}
	for(int i=1;i<=k;i++) {
		printf("%d\n", ma.mul(c2(i, k), c3(i+1, (n-k) - (i-1))));
	}
	
	return 0;
}

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

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}
typedef vector<int> Node;
typedef vector<Node> Graph;
int N, K;
Graph G;
vector<int> depth;
void make_depth(int p, int v, int d) {
    depth[v] = d;
    for(int nv : G[v]) if(p != nv) {
        make_depth(v, nv, d+1);
    }
}
int get_size(int p, int v, int lb) {
    int ans = 0;
    if(depth[v] >= lb) ans ++;
    for(int nv : G[v]) if(p != nv) {
        ans += get_size(v, nv, lb);
    }
    return ans;
}
int solve(int root) {
    depth.resize(G.size());
    make_depth(-1, root, 0);
    vector<pair<int, int>> ps;
    for(int v : G[root]) {
        ps.push_back(make_pair(get_size(root, v, K/2+1),
                               get_size(root, v, K/2+2)));
    }
    int sum = 0;
    for(int i = 0; i < ps.size(); i++) {
        sum += ps[i].first;
    }
    int ans = sum;
    if(K % 2 == 1) {
        for(int i = 0; i < ps.size(); i++) {
            ans = min(ans, sum - ps[i].first + ps[i].second);
        }
    }
    return ans;
}

int main(){
    iostream_init();
    while(cin >> N >> K) {
        G.assign(N, Node());
        REP(i, N-1) {
            int u, v;
            cin >> u >> v;
            u--; v--;
            G[u].push_back(v);
            G[v].push_back(u);
        }
        int ans = INT_MAX;
        REP(i, N) ans = min(ans, solve(i));
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
 
int main(){
    int n,m;
    cin >> n >> m;
 
    int left =1;
    int right = INT_MAX;
    REP(i,0,m){
        int l,r;
        cin >> l >> r;
        if(left < l) left=l;
        if(right >r) right=r;
    }
 
    int ans =0;
    if(right-left>=0)ans=right-left+1;
 
    cout << ans << endl;
 
    return 0;
}

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

using namespace std;

int main() {
	int a,b;
	cin >> a >> b;
	int sum = 0;
	if (a>b) {
		sum += a;
		--a;
	} else {
		sum += b;
		--b;
	}
	sum += max(a,b);
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct iofix
{
   ios_base::Init i;
   iofix() {
      cin.sync_with_stdio(0);
      cin.tie(0);
      cout.sync_with_stdio(0);
      cout.tie(0);
      cout.precision(10);
      cout << fixed;
   }
} iofix;

void solve(){
     int64_t N, c = 0 ;
     cin >> N;
     for(int i=1;i<=N;i++){
         int64_t x; cin >> x;
         if(x%2 != 0 && i%2 != 0)
             c++;
     }
     cout << c;
}

int main(){

   	solve();

   return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
using namespace std;
int main(void){
int n,p;
while(1){
	cin>>n>>p;
	if(n==0)break;
	vector<int> a(n,0);
	int stock=p;
	bool flag=false;
	while(1){
		for(int i=0;i<n;i++){
			if(stock==0){
				stock=a[i];
				a[i]=0;
			}else{
				a[i]++;
				stock--;
			}
			if(a[i]==p){
				cout<<i<<endl;
				flag=true;
				break;
			}
		}
		if(flag)break;
	}
}

	return 0;
}

Measured memory_bytes: 3016
#include<iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin>>H>>W;
        if(H==0&&W==0){
            break;
        }
        else{
            for ( int i = 1; i <= H; i++ ){
                for ( int j = 1; j <= W; j++ ){
                    if(i==1){
                        cout<<"#";
                    } 
                    else if(i==H){
                        cout<<"#";
                    }
                    else{
                        if(j==1){
                        cout<<"#";
                    }
                        else if(j==W){
                            cout<<"#";
                        }   
                        else {
                            cout<<".";
                        }
                    
                    }
                    
                }
                cout<<endl;
            }
            cout<<endl;
        }
        
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1L << 30
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int N, K;
vector<long> a(100000, 0);
vector<long> dp(100000, INF);


long rec(int i){
	if (i == 0) return 0;
	if (dp[i] < INF) return dp[i];
	//long res = INF;
	int index = 1;
	while ((i - index)>-1 && index <= K){
		chmin(dp[i], rec(i-index) + abs(a.at(i) - a.at(i-index)));
		index++;
	}
	return dp.at(i);
}

int main(){
	cin >> N >> K;
	rep(i, N) cin >> a.at(i);
	cout << rec(N-1) << endl;

	return 0;
}

Measured memory_bytes: 8064
n = int(input())

hon_list = [2, 4, 5, 7, 9]
pon_list = [0, 1, 6, 8]
bon_list = [3]

temp = n % 10
if temp in hon_list:
    ans = "hon"
elif temp in pon_list:
    ans = "pon"
elif temp in bon_list:
    ans = "bon"
print(ans)

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

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

    int h, w;
    cin >> h >> w;
    char C[h][w];
    REP(i, h) REP(j, w) cin >> C[i][j];

    int dx[4] = {-1, 1, 0, 0};
    int dy[4] = {0, 0, -1, 1};
    REP(i, h){
        REP(j, w){
            if(C[i][j] == '.'){
                continue;
            }
            int cnt = 0;
            REP(k, 4){
                int nx, ny;
                nx = i + dx[k];
                ny = j + dy[k];
                if(nx < 0 or ny < 0 or nx >= h or ny >= w){
                    continue;
                }
                if(C[nx][ny] == '#') cnt++;
            }
            if(cnt == 0){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}

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



int main() {
	//cout << fixed << setprecision(10);
	
	
	long long int n, m, a[100][100] = {}, b[100005], c, d, k, cou = 1, one = 0, zero = 0,in;
	string str[55];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> str[i];
		for (int j = 0; j < str[i].length(); j++) {
			a[i][str[i][j] - 'a']++;
		}
	}
	for (int i = 0; i<26; i++) {
		in = 99;
		for (int j = 0; j < n; j++) {
			if (in > a[j][i]) {
				in = a[j][i];
			}
		}

		for (int j = 0; j < in; j++) {
			cout << (char)(i + 'a');
		}
	}
}


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

int main() {
  
    long long N, K;

	cin >> N >> K;

    long long a = N%K;
	cout << min(a, K-a) << endl;

    return 0;
}

Measured memory_bytes: 256
def gcd(a, b)
  a, b = b, a if a < b
  loop do
    break if b == 0
    a, b = b, a%b
  end
  return a
end

while gets do
  a, b = $_.split(' ').map(&:to_i)
  gn = gcd(a, b)
  puts "#{gn} #{a*b/gn}"
end

Measured memory_bytes: 6092
#include <iostream>
#include <map>
#include <vector>

using namespace std;
typedef long long ll;

int main(){
  ll X, K, D;
  cin >> X >> K >> D;
  if (X < 0) X = -X;
  ll r = X / D;
  if (r >= K){
    cout << X - D * K << "\n";
  }
  else {
    K -= r;
    cout << abs((X % D) - (K % 2 == 0 ? 0 : D)) << "\n";
  }
  return 0;

}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>

#define PI 3.14159265359

#define INF 1000000;

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

typedef long long ll;

using namespace std;


/*
class ElectronicPetEasy
{
public:
	string isDifficult(int st1, int p1, int t1, int st2, int p2, int t2)
	{
		
	}
};
*/



int main()
{
	int n;
	
	while (cin >> n)
	{
		cout << n * (n + 1) / 2 + 1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int main(){
    string s=stin();
    cout<<s[0]<<s[1]<<s[2]<<endl;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b >= c) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int ar[n];
    vector<int> memo(k+1,2);
    memo[0]=2;
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    for(int i=1;i<=k;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(ar[j]>i)
            {
                continue;
            }
            if(memo[i-ar[j]]==2)
            {
                memo[i]=1;
            }
        }
    }
    if(memo[k]==2)
    {
        cout<<"Second\n";
    }
    else
    {
        cout<<"First\n";
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>

using namespace std;
using ll=long long int;

constexpr ll MAX = 1e9;

int main() {
    ll s;
    cin >> s;

    ll x1, y1, x2, y2;
    x1 = 1;
    y1 = MAX;
    x2 = (s + MAX - 1) / MAX;
    y2 = MAX - (s + MAX - 1) % MAX - 1;

    assert(x2*y1 - y2*x1 == s);
    cout << 0 << " " << 0 << " " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int max(int a,int b){return (a>b ? a:b);}
int min(int a,int b){return (a<b ? a:b);}

int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
//これは昇べきの順のソート

//int compare_int(const void *a, const void *b){return *(int*)b - *(int*)a;}
//これは降べきの順のソート

//qsort(配列, 長さ, sizeof(int), compare_int);

double BS(int array[],int len,int target);


void merge(long long a1[],long long len_a1,long long a2[],long long len_a2,long long a[]){
    long long i = 0,j = 0;
    while(i<len_a1 || j<len_a2){
        if(j>=len_a2 || (i<len_a1 && a1[i]<a2[j])){
            a[i+j] = a1[i];
            i++;
        }else{
            a[i+j] = a2[j];
            j++;
        }
    }
}
void mergeSort(long long a[],long long len_a){
    if(len_a > 1){
        long long m = len_a/2;
        long long n = len_a - m;
        long long a1[m];
        long long a2[n];
        for(long long i = 0;i < m;i++) a1[i] = a[i];
        for(long long i = 0;i < n;i++) a2[i] = a[m+i];
        mergeSort(a1,m);
        mergeSort(a2,n);
        merge(a1,m,a2,n,a);
    }
}
 
//////////////////////////////////////////

/*
#define MOD 998244353

int N;
int a[310];

int main(){
    scanf("%d",&N);
    for(int i = 0;i < N;i++){
        scanf("%d",&a[i]);
    }
    qsort(a,N, sizeof(int), compare_int);




    return 0;
}
*/

 
int N;
char S[200010];
 
int main(){
    scanf("%d",&N);
    scanf("%s",S);
 
    int whitenum[N+1]; //0番目からn番目までの間に含まれる白の数
    int blacknum[N+1]; //0番目からn番目までの間に含まれる黒の数
    whitenum[0] = (S[0] == '.');
    blacknum[0] = (S[0] == '#');
    for(int i = 1;i < N;i++){
        whitenum[i] = whitenum[i-1] + (S[i] == '.');
        blacknum[i] = blacknum[i-1] + (S[i] == '#');
    }
    
    if(whitenum[N-1] == N){
        printf("0\n");
        return 0;
    }

    int keep = min(whitenum[N-1],blacknum[N-1]);

    for(int i = 0;i < N-1;i++){
        if(S[i] == '.' && S[i+1] == '#'){
            keep = min(keep,blacknum[i] + whitenum[N-1] - whitenum[i]);
        }
    }

    printf("%d\n",keep);

    return 0;
}
 



///////////////////////////////////////////


double BS(int array[],int len,int target){ //(配列,長さ,見つける値)
    int low,mid,high;

    low = 0;
    high = len-1;

    int mark;

    while(low <= high){
        mid = (low + high) / 2;
        if(array[mid] == target){
            mark = 0;
            break;
        }else if(array[mid] < target){
            low = mid + 1;
            mark = 1;
        }else{
            high = mid - 1;
            mark = -1;
        }
    }
    if(mark == 0){
        return mid; //配列の何番目か（０から）
    }else if(mark == 1){
        return (double)mid + 0.5;//なかったらどこのあいだか
    }else{
        return (double)mid - 0.5;
    }
}


Measured memory_bytes: 1920
//
// Created by yamunaku on 2019/10/15.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int n;
    cin >> n;
    vl a(n);
    rep(i, n) cin >> a[i];
    set<ll> cand;
    rep(i, n){
        ll tmp = a[i];
        for(int j=2;j<=sqrt(tmp)+1;j++){
            if(a[i]%j==0) cand.insert(j);
        }
        if(a[i]!=1)
        cand.insert(a[i]);
    }
    ll ans = 0;
    for(auto m: cand){
        ll tmp = 0;
        rep(j, n){
            if(a[j] % m == 0) tmp += a[j];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	double ans = 0.;
	for (int i = 0; i < N; i++) {
		double X; string U; cin >> X >> U;
		if (U == "BTC") {
			X *= 380000.;
		}
		ans += X;
	}
	cout << setprecision(20) << fixed << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
ans = 0
cnt = 0
while True:
    if cnt == 0:
        ans+= A[0]
    else:
        ans+=A[(cnt+1)//2]
    cnt+=1
    if cnt == N-1:
        break
print(ans)

Measured memory_bytes: 31608
#include <algorithm>
    #include <bits/stdc++.h>
    #include <cctype>
    #include <cmath>
    #include <cstdio>
    #include <iomanip>
    #include <iostream>
    #include <list>

    #include <stack>
    #include <string>
    #include <vector>
    #include <bits/stdc++.h>
    #define INFINI (1000 * 1000 * 1000)

    using namespace std;
    //#define s(T) scanf("%d", &T)
    #define sl(T) scanf("%lld", &T)
    #define fill(a, val) memset(a, val, sizeof(a))
    #define mp make_pair
    #define pb push_back
    #define all(x) x.begin(), x.end()
    #define DREP(x) sort(all(x)); x.erase(unique(all(x)), x.end())
    #define INDEX(a, val) (lower_bound(all(a), val) - a.begin())

    typedef long long ll;


    bool compare_first(pair<int,int>a,pair<int,int >b)
    {
        return a.first<b.first;
    }

     bool compare_second(pair<int,pair<int , int> > a,pair<int,pair<int , int> > b)
    {
        return a.second.first<b.second.first;
    }


    ll min(ll a,ll b)
    {
        if(a>b)return b;
        return a;
    }
     ll max(ll a,ll b)
    {
        if(a>b)return a;
        return b;
    }

    ll toINT(string s)
    {
        ll a=0;
        for(ll index=0;index<s.size();index++)
            a=a*10+(s[index]-'0');
        return a;
    }



    int main() {
      ios::sync_with_stdio(false);


int a,b,c;
cin>>a>>b>>c;

int sum=a+b+c;
int mx=max(a,max(b,c));
if(mx==sum-mx)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;

return 0;
    }

/*

 }
 */


Measured memory_bytes: 256
from math import gcd


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

# setwise validation
tmp = 0
for a in A:
    tmp = gcd(tmp, a)
isSetwise = (tmp == 1)

# pairwise validation
M = 10 ** 6
sieve = [0] * (M + 1)
for a in A:
    sieve[a] += 1

cnt = 0
for i in range(2, M + 1):
    tmp = 0
    for j in range(i, M + 1, i):
        tmp += sieve[j]
    cnt = max(cnt, tmp)
isPairwise = (cnt <= 1)

# check
if isPairwise:
    ans = 'pairwise coprime'
elif isSetwise:
    ans = 'setwise coprime'
else:
    ans = 'not coprime'
print(ans)


Measured memory_bytes: 194864
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        x: usize,
        l: [usize; n]
    };

    let mut count = 1;
    let mut d = 0;

    for i in l.iter() {
        d += i;
        if d > x {
            break;
        }
        count += 1;
    }

    println!("{}", count);
}


Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long>a(n);
    for(int i = 0; i < a.size(); i++){
        cin >> a[i];
    }
    long long aMax = *max_element(a.begin(),a.end());
    long long aMin = *min_element(a.begin(),a.end());
    cout << aMax - aMin << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var m1,d1,m2,d2 int
	fmt.Scan(&m1,&d1,&m2,&d2)
	
	if d2 == 1 {
		fmt.Println("1")
		return
	}
	fmt.Println("0")
}

Measured memory_bytes: 512
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = str(iin())
sum_N = 0
for n in N:
    sum_N += int(n)

ans = 0
if N[0] != 1: ans = int(N[0])-1
ans += (len(N)-1)*9
print(max(sum_N, ans))



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

int n, ans;

int main() {
  cin >> n;
  vector<int> a(n);
  rep (i, n) {
    cin >> a[i];
  }
  ans = 0;
  rep (i, n) {
    if (i%2 == 0 && a[i]%2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=2e5+10;
const int mod=1e9+7;
main(){
    int n;
    cin>>n;
    map<int,int>m;
    int sum=0;
    for(int i=1;i<=n;++i){
        int x;
        cin>>x;
        sum+=x;
        m[x]++;
    }
    int q;
    cin>>q;
    while(q--){
        int a,b;
        cin>>a>>b;
        m[b]+=m[a];
        sum+=m[a]*(b-a);
        m[a]=0;
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 9408
#include<iostream>
using namespace std;
#define MAX 30
#define NIL -1


struct Node {
  int p,l,r;
};

int n;
Node T[MAX];

void preParse(int u) {
  if (u == NIL) {
    return;
  }
  cout << " " << u;
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u) {
  if (u == NIL) {
    return;
  }
  inParse(T[u].l);
  cout << " " << u;
  inParse(T[u].r);
}

void postParse(int u) {
  if (u == NIL) {
    return;
  }
  postParse(T[u].l);
  postParse(T[u].r);
  cout << " " << u;
}

int main() {
  cin >> n;

  // 初期化
  for (int i = 0; i < n; i++) {
    T[i].p = T[i].l = T[i].r = NIL;
  }
  // 入力
  for (int i = 0; i < n; i++) {
    int v, l, r;
    cin >> v >> l >> r;
    T[v].l = l;
    T[v].r = r;
    if (l != NIL) {
      T[l].p = v;
    }
    if (r != NIL) {
      T[r].p = v;
    }
  }

  // ルート求める
  int root;
  for (int i = 0; i < n; i++) {
    int r;
    if (T[i].p == NIL) {
      root = i;
      // cout << "root at " << root << endl;
      break;
    }
  }
  // cout << "root:" << root << endl;
  cout << "Preorder" << endl;
  preParse(root);
  cout << endl;

  cout << "Inorder" << endl;
  inParse(root);
  cout << endl;
  //
  cout << "Postorder" << endl;
  postParse(root);
  cout << endl;
  return 0;

}



Measured memory_bytes: 3068
import numpy as np
import math

def solve():
    n = int(input())
    h = list(map(int, input().split()))
    dp = [0]*(n+5)
    dp[1] = abs(h[1]-h[0])
    for i in range(n-2):
        dp[i+2] = min(dp[i]+abs(h[i+2]-h[i]),dp[i+1]+abs(h[i+2]-h[i+1]))
    print(dp[n-1])
    return 0
 
if __name__ == "__main__":
    solve()


Measured memory_bytes: 22720
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define MAX 1000000
#define mo 1000000007 
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

bool prime[MAX + 1]; 
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
  
    prime[1] = false; 
  
    for (int p = 2; p * p <= MAX; p++) { 
  
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) { 
  
            // Set all multiples of p to non-prime 
            for (int i = p * 2; i <= MAX; i += p) 
                prime[i] = false; 
        } 
    } 
} 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll modexp(ll x, ll y, ll p)
{
ll res = 1;   
x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}
class gfg 
{ 
 public : ll gcd(ll a, ll b)  
 {  
    // Everything divides 0  
    if (a == 0 || b == 0)  
        return 0;  
   
    // Base case     
    if (a == b)  
        return a;  
   
    // a is greater  
    if (a > b)  
        return gcd(a-b, b);  
    return gcd(a, b-a);  
 } 
  
   
// Function to return LCM of two numbers  
  ll lcm(ll a, ll b)  
 {  
    return (a*b)/gcd(a, b);  
 }  
} ;
ll mypow(ll b, ll e) {
    ll ans=1; for(;e;b=b*b%mo,e/=2) if(e&1) ans=ans*b%mo; return ans;}
ll power2(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return power2(x, y / 2) * power2(x, y / 2); 
    else
        return x * power2(x, y / 2) * power2(x, y / 2); 
} 
ll mod=100000000;
#define MAXN 100001
ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
}
vector <vector <ll> > store;
ll dp[100002];
ll solve(ll ind)
{
	if(dp[ind]!=-1)
	return dp[ind];
	if(store[ind].size()==0)
	{
		dp[ind]=0;
		return 0;
	}
	ll k=-1;
	rep(i,store[ind].size())
	k=max(k,solve(store[ind][i]));
	dp[ind]=k+1;
	return dp[ind];
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m;
	cin>>n>>m;
	store.resize(n+1);
	rep(i,m)
	{
		ll x,y;
		cin>>x>>y;
		store[x].pb(y);
	}
	memset(dp,-1,sizeof(dp));
	ll ans=-1;
	for(ll i=1;i<=n;i++)
	ans=max(ans,solve(i));
	cout<<ans;
	return 0;
}

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

    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	// 入力
    	int a = sc.nextInt();
    	int b = sc.nextInt();

      
      
    	int ans = 0;
    	int sum = 0;

    	for (int i = 0; true; i++){
          if (b==1) { break;
      }
    		ans++;
    		sum = sum + (a - 1);
    		if (b <= sum + 1){
    			break;
    		}
    	}

    	// 出力
    	System.out.println(ans);
    }
}

Measured memory_bytes: 22612
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n, a, b, res = 0;
    cin >> n >> a >> b;
    for (int i = 1; i <= n; i++) {
        int x = 0, t = i;//　　　t = i が大事！！
        while (t > 0) {
            x += t % 10;
            t /= 10;
        }
        if (x >= a && x <= b) res += i;
    }
    cout << res << endl;
}


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

using namespace std;

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

#define pb push_back
#define odd(x) ((x)&1)
#define even(x) (!odd(x))
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);


#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif



int main(int argv, char* argc[])
{
    FASTIO

    ll a;
    string b;
    cin>>a>>b;
    ll x = 100*(b[0]-'0')+10*(b[2]-'0')+(b[3]-'0');
    ll ans = a*x;
    ans/=100;
    cout<<ans;



    return 0;
}



Measured memory_bytes: 3644
n, m = gets.chomp.split.map(&:to_i)
arr = []
m.times{
    atari, hazure =  gets.chomp.split.map(&:to_i)
    arr << atari
}
arr.sort!.reverse!.pop

goods = m - 1
cost = 0
arr.each{|atari| cost += (n - atari) if n > atari}
puts cost


Measured memory_bytes: 6868
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef std::pair<int, int> pii;
typedef unsigned long ul;

int main() {
    int P, Q, R;

    cin >> P >> Q >> R;
    vector<int> v = {P, Q, R};

    sort(v.begin(), v.end());
    cout << v[0] + v[1] << '\n';
    return 0;
}

Measured memory_bytes: 256
def power(m, n, mod)
  return 1 if n.zero?
  n.odd? ? (power(m, n - 1, mod) * m % mod) : power(m * m % mod, n >> 1, mod);
end

def prime_factor(n)
  prime = []
  2.upto(n) do |i|
    break unless i <= n / i
    while (n % i).zero?
      prime << i
      n /= i
    end
  end
  prime << n unless n == 1
  prime
end

M=10**9+7
N=gets.to_i
A=gets.split.map(&:to_i)

lcm=Hash.new{|h,k|h[k]=0}
m=Array.new(N){Hash.new{|h,k|h[k]=0}}
A.each.with_index do |a,i|
  prime_factor(a).each do |x|
    m[i][x]+=1
    lcm[x]=[lcm[x],m[i][x]].max
  end
end

LCM = lcm.inject(1){|s,(k,v)|s*power(k,v,M)%M}

ans=0
A.each do |a|
  ans+=LCM*power(a,M-2,M)%M
  ans%=M
end
p ans

Measured memory_bytes: 18820
#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>;
using G = vector<vector<int>>;
    
int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    rep(i,k){
        if(b<=a) b *= 2;
        else c *= 2;
    }
    if(c>b && b>a) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3632
/*
 * Author       : YangDavid
 * Created Time : 2020.05.30 20:21:54
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main() {
    int n; scanf("%d", &n);
    vector<int> a(n + 1);
    ll tot = 0, fr = 1, ans = 0;
    for(auto &g : a)
        scanf("%d", &g), tot += g;
    for(auto ct : a) {
        if(fr < ct) { puts("-1"); return 0; }
        ans += ct, tot -= ct;
        ll cho = min(fr-ct, tot);
        ans += cho;
        fr = cho * 2;
    }
    printf("%lld\n", ans);


    return 0;
}



Measured memory_bytes: 3900
def solve(A):
    r = []
    for n in A:
        if n < 2:
            r.append(0)
            continue
        cnt = 0
        while n % 2 == 0:
            n //= 2
            cnt += 1
        r.append(cnt)
    return r


def resolve():
    A = [int(i) for i in input().split()]
    for a in A:
        if a % 2 == 1:
            print(0)
            return
    if min(A) == max(A):
        print(-1)
    else:
        s = solve(A)
        if min(s) == 0 or min(s) != max(s):
            print(min(s))
        else:
            print(min(s) + 1)


resolve()


Measured memory_bytes: 9212
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

ll H, W;
ll mp[55][55];
ll f[55][55];

int main(){
    
    cin >> H >> W;
    for(ll y = 1; y <= H; y++){
        for(ll x = 1; x <= W; x++){
            char c;
            cin >> c;
            if(c == '#')mp[y][x] = 1;
        }
    }
    for(ll y = 1; y <= H; y++){
        for(ll x = 1; x <= W; x++){
            if(mp[y][x] && mp[y][x + 1]){
                f[y][x] = 1;
                f[y][x + 1] = 1;
            }
            if(mp[y][x] && mp[y + 1][x]){
                f[y][x] = 1;
                f[y + 1][x] = 1;
            }
        }
    }
    ll flg = 1;
    for(ll y = 1; y <= H; y++){
        for(ll x = 1; x <= W; x++){
            if(mp[y][x] && f[y][x] == 0)flg = 0;
        }
    }
    if(flg)cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

#define MN 1001000

using namespace std;
typedef long long ll;

ll n, ans;

int main() {
    scanf("%lld", &n);

    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ll q = i, m = n / i - 1;
            if(q < m) ans += m;
        }
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class t>
t read_template(){
  t res;
  cin >> res;
  return res;
}
template<class t>
void print_template(t x){
  cout << x;
}
int main(){
  function<long long(long long,long long,long long)> FUNC = [&](long long A,long long B,long long C){
                                                              return ((A<=B)?((((C % A)==0)?1:0) + FUNC ((1 + A),B,C)):0);
                                                            };
  ;
  long long A = read_template<long long>();
  long long B = read_template<long long>();
  long long C = read_template<long long>();
  print_template(FUNC (A,B,C));
  print_template("\n");
  return 0;
}



Measured memory_bytes: 3544
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <stack>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

typedef long long ll;

const int maxn=1e5+10;
int n;
int q,k;
ll d[maxn];
int vis[maxn];
vector<pair<int,ll>> edge[maxn];


int main()
{
  //freopen("/Users/qianjay/Documents/cc/in", "r", stdin);
  scanf("%d",&n);
  for(int i=0;i<n-1;i++)
  {
    int a,b;
    ll c;
    scanf("%d%d%lld",&a,&b,&c);
    edge[a].push_back({b,c});
    edge[b].push_back({a,c});
  }
  scanf("%d%d",&q,&k);
  for(int i=0;i<=n;i++)
  {
    d[i]=1e18;
    vis[i]=0;
  }
  d[k]=0;
  vis[k]=1;
  
  queue<int> qq;
  qq.push(k);
  while(!qq.empty())
  {
    int f=qq.front();
    qq.pop();
    vis[f]=0;
    for(int i=0;i<edge[f].size();i++)
    {
      int u=edge[f][i].first;
      if(d[u]>d[f]+edge[f][i].second)
      {
        d[u]=d[f]+edge[f][i].second;
        if(!vis[u])
        {
          vis[u]=1;
          qq.push(u);
        }
      }
    }
  }
  
  for(int i=0;i<q;i++)
  {
    int x,y;
    scanf("%d%d",&x,&y);
    cout<<d[x]+d[y]<<endl;
  }
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  
  if (s[0] == s[1] && s[1] == s[2]) 
    cout << "Yes" << endl;
  else if (s[1] == s[2] && s[2] == s[3])
    cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <regex>
#include <string>

int main()
{
    int A, B;
    std::string S, pattern;
    std::cin >> A >> B >> S;
    std::smatch m;
    pattern = "\\d{" + std::to_string(A) + "}-\\d{" + std::to_string(B) + "}";
    if (std::regex_match(S, m, std::regex(pattern))) { std::cout << "Yes" << std::endl; }
    else
    {
        std::cout << "No" << std::endl;
    }

    return 0;
}

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

import sys

def get_digits(n):
    if n < 0:
        n *= -1
    return len(str(n))


def main():
    data = []
    for line in sys.stdin:
        a, b = map(int, line.split())
        digits = get_digits(a+b)
        print(digits)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7676
#include <iostream>
using namespace std;
using llong = long long;

llong n;
llong a[205];

bool isTriangle(llong a[]) {
	llong len = 200;
	while (a[len] == 0) len--;
	
	for (int i = 1; i <= len; i++) {
		if (a[i] - a[i - 1] != 1) return false;
	}
	
	return (a[0] == 1);
}

int main() {
	cin >> n;
	while (n > 0) {
		for (int i = 0; i < 105; i++) a[i] = 0;
		
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		
		int cnt = 0;
		while (1) {
			if (isTriangle(a)) break;
			if (cnt > 10000) break;
			
			llong len = 200;
			while (a[len] == 0 && len >= 0) len--;

			for (int i = 0; i <= len; i++) {
				a[i]--;
			}
			for (int i = 0; i <= len; i++) {
				if (a[i] == 0) {
					for (int j = i; j <= len; j++) {
						if (a[j] != 0) { swap(a[i], a[j]); break; }
					}
				}
			}
			
			llong ins = 200;
			while (ins >= 0 && a[ins] == 0) ins--;
			a[ins + 1] = len + 1;
			
			cnt++;
		}
		
		if (cnt > 10000) cout << -1 << endl;
		else cout << cnt << endl;
		
		cin >> n;
	}
	
	return 0;
}


Measured memory_bytes: 3088
Sa = input()
Sb = input()
Sc = input()

tmp = 'a'
while True:
    if tmp == 'a':
        if len(Sa) == 0:
            print('A')
            break
        tmp = Sa[0]
        Sa = Sa[1:]
    elif tmp == 'b':
        if len(Sb) == 0:
            print('B')
            break
        tmp = Sb[0]
        Sb = Sb[1:]
    elif tmp == 'c':
        if len(Sc) == 0:
            print('C')
            break
        tmp = Sc[0]
        Sc = Sc[1:]

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
ll n,C;
ll d[40][40],c[500][500];
ll sum[3][40];
int main(){
    cin >> n >> C;

    REP(i,C)
        REP(j,C)
        cin >> d[i][j];

    REP(i,n) {
        REP(j,n) {
            cin >> c[i][j];
        }
    }

    REP(m,3) {
        REP(cc,C){
            REP(i,n) {
                REP(j,n) {
                    ll k = i + j;
                    if(k % 3 != m)
                        continue;

                    sum[m][cc] += d[c[i][j]-1][cc];
                }
            }
        }
    }

    ll ans = 1000000000000;
    REP(i,C){
        FOR(j,i+1,C) {
            FOR(k,j+1,C) {
                ans = min(ans,sum[0][i] + sum[1][j] + sum[2][k]);
                ans = min(ans,sum[1][i] + sum[2][j] + sum[0][k]);
                ans = min(ans,sum[2][i] + sum[0][j] + sum[1][k]);
                ans = min(ans,sum[0][i] + sum[2][j] + sum[1][k]);
                ans = min(ans,sum[2][i] + sum[1][j] + sum[0][k]);
                ans = min(ans,sum[1][i] + sum[0][j] + sum[2][k]);
            }
        }
    }
    cout << ans << endl;

    return 0;
}



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

using namespace std;

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		vector<int> cnt(n + 1);
		for (int i = 1; i * i <= n; i++) {
			for (int j = 1; j * j + i * i + i * j <= n; j++) {
				for (int k = 1; k * k + j * j + i * i + i * j + j * k + k * i <= n; k++) {
					cnt[k * k + j * j + i * i + i * j + j * k + k * i]++;
				}
			}
		}
		for (int i = 1; i <= n; i++) cout << cnt[i] << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 3640
# include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;

template <typename T>
void show_all(T t) {
  rep (i, t.size()) {
    rep (j, t[0].size()) {
      cout << t[i][j];
    }
    cout << endl;
  }
}

int main() {
  vector<int> next_x = {-1, 0, 1, 0};
  vector<int> next_y = {0, -1, 0, 1};
  int N;

  while (cin >> N && N) {
    int n, d;
    vector<pair<int, int>> c;
    c.push_back(make_pair(0, 0));

    rep (i, N-1) {
      cin >> n >> d;
      // cout << "n: " << n << ", d: " << d << endl;
      // cout << c[i].first << "," << c[i].second << endl;
      // cout << "next_x: " << next_x[d] << ", next_y: " << next_y[d] << endl;

      int x = c[n].first + next_x[d];
      int y = c[n].second + next_y[d];
      // cout << "new_x: " << x << ", new_y: " << y << endl;
      c.push_back(make_pair(x, y));
    }

    int max_x = 0;
    int max_y = 0;
    int min_x = 0;
    int min_y = 0;

    rep (i, c.size()) {
      max_x = max(max_x, c[i].first);
      max_y = max(max_y, c[i].second);
      min_x = min(min_x, c[i].first);
      min_y = min(min_y, c[i].second);
      // cout << c[i].first << "," << c[i].second << endl;
    }

    cout << max_x - min_x + 1 << " " << max_y - min_y + 1 << endl;
  }
}

Measured memory_bytes: 3076
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

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

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


func main() {
	A := oneInt()
	P := oneInt()

	P += A * 3
	fmt.Print(P / 2)
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];

  sort(rng(p));
  int ans = 0;
  rep(i, k) ans += p[i];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3552