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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

struct edge{int from, to, cost;};
bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}
bool pCom(const pii& a, const pii& b) {
	if (a.se!=b.se) return a.se < b.se;
	else return a.fi < b.fi;
}
bool comx(const pair<int,pii>& a, const pair<int,pii>& b) {return a.se.fi < b.se.fi;}
bool comy(const pair<int,pii>& a, const pair<int,pii>& b) {return a.se.se < b.se.se;}

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, x, y;
pair<int,pii> c[100000];
vector<edge> es;

//----------------↓UnionFind↓----------------

int par[100000], rnk[100000];

void init(ll n) {
	for (int i=0; i<n; i++) {
		par[i] = i;
		rnk[i] = 0;
	}
}

int find(int x) {
	if (par[x]==x) return x;
	else return par[x] = find(par[x]);
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x==y) return;
	
	if (rnk[x]<rnk[y]) par[x] = y;
	else {
		par[y] = x;
		if (rnk[x]==rnk[y]) rnk[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}

//----------------↑UnionFind↑----------------

ll Kruskal() {
	sort(all(es), comp);
	init(n);
	ll res = 0;
	for (int i = 0; i < es.size(); ++i) {
		edge e = es[i];
		if (!same(e.from, e.to)) {
			unite(e.from, e.to);
			res += e.cost;
		}
	}
	return res;
}



int main() {
	cin >> n;
	rep(i,n) {
		cin >> c[i].se.fi >> c[i].se.se;
		c[i].fi = i;
	}
	
	// 全ての点の間に辺を伸ばそうとすると約10^10本必要になる
	// A(s,i) < B(t,j) < C(u,k)と並んだ3点があるとして、
	// ACを繋ぐ辺1本 と ABを繋ぐ辺とBCを繋ぐ辺の2本 ではコストは一緒なので明らかに後者を選んだほうがいい
	// つまりx座標 / y座標それぞれでソートして全ての隣接する点の間のみに辺を伸ばせばいい
	// x座標
	sort(c, c+n, comx);
	reps(i,1,n) es.pb(edge{c[i-1].fi, c[i].fi, c[i].se.fi-c[i-1].se.fi});
	// y座標
	sort(c, c+n, comy);
	reps(i,1,n) es.pb(edge{c[i-1].fi, c[i].fi, c[i].se.se-c[i-1].se.se});
	ll ans = Kruskal();
	cout << ans << ln;
}

Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
  
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
  
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)

#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(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
  
typedef long long int ll;
  
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn =5*100001;
ll power(ll x, ll n) {
  ll res = 1;
  for (; n > 0; n >>= 1) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
  }
  return res;
}

int32_t main()
{
    
   

  
    IOS
	ll n;
	cin>>n;
	for(ll i=1;i<=9l;i++)
	{
		for(ll j=1;j<=9;j++)
		if(i*j==n)
		return cout<<"Yes",0;
	}
	cout<<"No";	
	
}
  
           
         
       


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

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



Measured memory_bytes: 3080
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//211
	string s;
	cin>>s;
	int p = 0;
	for(char c:s)if(c=='p')p++;
	cout<<s.length()/2-p;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3768
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll x;
	cin >> x;
	if(x>=400 && x<=599)
		cout << 8;
	else if(x>=600 && x<=799 )
		cout << 7;
	else if(x>=800 && x<=999 )
		cout << 6;
	else if(x>=1000 && x<=1199 )
		cout << 5;
	else if(x>=1200 && x<=1399 )
		cout << 4;
	else if(x>=1400 && x<=1599 )
		cout << 3;
	else if(x>=1600 && x<=1799 )
		cout << 2;
	else
		cout << 1;
	cout << "\n";
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <set>
#include <cmath>
#include <math.h>

using namespace std;
        
int main(){
    char x,y;
    cin>>x>>y;
    if(x<y){
        cout<<"<"<<endl;
    }else if(x>y){
        cout<<">"<<endl;
    }else{
        cout<<"="<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    string s; cin >> s;
    ll q; cin >> q;
    ll cnt1 = 0;
    string tp="" , bk="";
    rep(i,q){
        ll t; cin >> t;
        if(t==1){
            cnt1++;
        }else if(t==2){
            ll f; cin >> f;
            char c; cin >> c;
            if(cnt1%2==0){
                if(f==1){
                    tp.push_back(c);
                }else{
                    bk.push_back(c);
                }
            }else{
                if(f==1){
                    bk.push_back(c);
                }else{
                    tp.push_back(c);
                }
            }
        }else{
            cout << "?" << endl;
        }
    }
    if(cnt1%2==0){
        for(int i=(int)(tp.size())-1;i>=0;i--){
            cout << tp.at(i) ;
        }
        for(int i=0;i<(int)(s.size());i++){
            cout << s.at(i);
        }
        for(int i=0;i<(int)(bk.size());i++){
            cout << bk.at(i);
        }
    }else{
        for(int i=(int)(bk.size())-1;i>=0;i--){
            cout << bk.at(i) ;
        }
        for(int i=(int)(s.size())-1;i>=0;i--){
            cout << s.at(i);
        }
        for(int i=0;i<(int)(tp.size());i++){
            cout << tp.at(i);
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1088
import java.util.*;

public class Main {
    static int n;
    static int k;
    static ArrayList<Integer>[] edge;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        k = sc.nextInt();
        edge = new ArrayList[n];
        int[][] ab = new int[n-1][2];
        for(int i=0; i<n; i++) edge[i] = new ArrayList<Integer>();
        for(int i=0; i<n-1; i++){
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            edge[a].add(b);
            edge[b].add(a);
            ab[i][0] = a;
            ab[i][1] = b;
        }
        sc.close();

        if(k == 1){
            System.out.println(n-2);
            return;
        }

        int ans = Integer.MAX_VALUE;
        if(k%2 == 0){
            for(int i=0; i<n; i++){
                ans = Math.min(ans, countDelNum(i, i));
            }
        }else{
            for(int i=0; i<n-1; i++){
                ans = Math.min(ans, countDelNum(ab[i][0], ab[i][1])
                                +countDelNum(ab[i][1], ab[i][0])-n);
            }
        }
        // for(int i=0; i<n; i++){
        //     int tmp = countDelNum(i);
        //     if(tmp < ans){
        //         ans = tmp;
        //     }
        // }
        System.out.println(ans);
    }

    public static int countDelNum(int root, int root2){
        int count = n;
        ArrayDeque<Integer[]> que = new ArrayDeque<Integer[]>();
        boolean[] use = new boolean[n];
        que.add(new Integer[]{root, 0});
        use[root] = true;
        use[root2] = true;
        while(que.size()>0){
            Integer[] cur = que.poll();
            if(cur[1] > k/2) break;
            for(int i=0; i<edge[cur[0]].size(); i++){
                Integer next = edge[cur[0]].get(i);
                if(!use[next]){
                    que.add(new Integer[]{next, cur[1]+1});
                    use[next] = true;
                }
            }
            count--;
        }
        return count;
    }
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n+1);
	for (int i=1;i<=n;++i)
	{
		cin >> a[i];
	}

	int count=0;
	for (int i=1;i<=n;++i)
	{
		if ( ((i&1)!=0) && ((a[i]&1)!=0) )
		{
			++count;
		}
	}
	cout << count << endl;
}







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

int32_t main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  int r = n%10;
  switch(r){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout<<"hon\n";
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout<<"pon\n";
      break;
    case 3:
      cout<<"bon\n";
      break;
  }
}


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

int main() {
    int K, S;
    cin >> K >> S;
    int count = 0;
    for(int x = 0; x <= K; ++x) {
        for(int y = 0; y <= K; ++y) {
            int z = S - x - y;
            if(0 <= z & z <= K) ++count;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
n,a,b = map(int, input().split())
if (b-a)%2 == 0:
    print((b-a)//2)
    exit()
if (n-b) <= (a-1):
    print(n-b+(b-a)//2+1)
    exit()
print(a-1+ (b-a)//2+1)


Measured memory_bytes: 2940
N, X, M = map(int, input().split())

known_set = set()
known_list = []
x_tmp = X

for _ in range(M):
    if x_tmp in known_set:
        break
    else:
        known_set.add(x_tmp)
        known_list.append(x_tmp)
        x_tmp = x_tmp**2%M


idx = known_list.index(x_tmp)
len_loops = len(known_set)-idx
r, s = divmod(N-idx ,len_loops)
idx = known_list.index(x_tmp)

res = sum(known_list[:idx]) + r * sum(known_list[idx:]) + sum(known_list[idx:idx+s])

print(res)

Measured memory_bytes: 77024
n = [int(n) for n in input().split()]
D = input()

class Dice():

    def __init__(self,faces):
        self.top = faces[0]
        self.south = faces[1]
        self.east = faces[2]
        self.west = faces[3]
        self.north = faces[4]
        self.bottom = faces[5]

    def rotate(self,d):

        if d == "N":
            tmp = self.top
            self.top = self.south
            self.south = self.bottom
            self.bottom = self.north
            self.north = tmp

        elif d == "S":
            tmp = self.top
            self.top = self.north
            self.north = self.bottom
            self.bottom = self.south
            self.south = tmp

        elif d == "E":
            tmp = self.top
            self.top = self.west
            self.west = self.bottom
            self.bottom = self.east
            self.east = tmp

        elif d == "W":
            tmp = self.top
            self.top = self.east
            self.east = self.bottom
            self.bottom = self.west
            self.west = tmp

    def get_top_value(self):
        return self.top


N = Dice(n)
for d in D:
    N.rotate(d)

print(N.get_top_value())


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  if(b==100)b++;
  cout << fixed << setprecision(0) << pow(100,a)*b << endl;
}


Measured memory_bytes: 384
/*
dreamerer
*/
#include <bits/stdc++.h>
using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; const int N = 5e5 + 5, M = 998244353, INF = 0x3f3f3f3f; const ll LNF = 0x3f3f3f3f3f3f3f3f; void Main();
void debug() { cerr << endl; } template <typename T, typename... Ts> void debug(T x, Ts... y) { cerr << "\033[31m" << x << "\033[0m"; if (sizeof...(y) > 0) cerr << ' '; debug(y...); } template <typename T> void debug(const T& a, int l, int r, char c) { for (int i = l; i <= r; ++i) cerr << "\033[31m" << a[i] << "\033[0m" << (i == r ? '\n' : c); }
void print() { cout << '\n'; } template <typename T, typename... Ts> void print(T x, Ts... y) { cout << x; if (sizeof...(y) > 0) cout << ' '; print(y...); } template <typename T> void print(const T& a, int l, int r, char c) { for (int i = l; i <= r; ++i) cout << a[i] << (i == r ? '\n' : c); }
void input() {} template <typename T, typename... Ts> void input(T& x, Ts&... y) { cin >> x; input(y...); } template <typename T> void input(T* a, int l, int r) { for (int i = l; i <= r; ++i) cin >> a[i]; } template <typename T> void input(vector<T>& a, int l, int r) { for (int i = l; i <= r; ++i) cin >> a[i]; }
template <typename T> void Max(T& a, T b) { if (a < b) a = b; } template <typename T> void Min(T& a, T b) { if (a > b) a = b; } template <typename T> void Add(T& a, T b) { a += b; if (a > M) a -= M; if (a < 0) a += M; } template <typename T> void Mul(T& a, T b) { a = a * b % M; } template <typename T> T Mod(T a) { return (a % M + M) % M; }
int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); /* cout << setprecision(10) << fixed; */
#ifdef Zmm
    if (argc) { freopen((string(*(argv)).substr(2, string(*(argv)).size() - 6) + string(".cpp")).c_str(), "r", stdin); string x; cin >> x; }
#endif
    Main();
}
// void replace(string& s, const string& t) {
    
// }
// bool replace(std::string& str, const std::string& from, const std::string& to) {
//     size_t start_pos = str.find(from);
//     if(start_pos == std::string::npos)
//         return false;
//     str.replace(start_pos, from.length(), to);
//     return true;
// }
void replaceAll(std::string& str, const std::string& from, const std::string& to) {
    if(from.empty())
        return;
    size_t start_pos = 0;
    while((start_pos = str.find(from, start_pos)) != std::string::npos) {
        str.replace(start_pos, from.length(), to);
        start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx'
    }
}
/*
s=input()
s=s.replace('eraser','')
s=s.replace('erase','')
s=s.replace('dreamer','')
s=s.replace('dream','')
if s=='':
    print("YES")
else :
    print("NO")
*/
void Main() {
    string s;
    input(s);
    replaceAll(s, "eraser", "");
    replaceAll(s, "erase", "");
    replaceAll(s, "dreamer", "");
    replaceAll(s, "dream", "");
    print(s.size() == 0 ? "YES" : "NO");
}

Measured memory_bytes: 3788
N,K = map(int,input().split())
d = [0]*K
a = [0]*K
for i in range(K):
  d[i]=int(input())
  a[i]=list(map(int,input().split()))
#print(a)
A=[]
for i in range(len(a)):
  for j in range(len(a[i])):
    A.append(a[i][j])
#print(A)
print(N-len(set(A)))

Measured memory_bytes: 9232
import itertools
import string

n = int(input())
alphabets = string.ascii_lowercase

digit = 0
counter = 0
while counter < n:
	digit += 1
	counter += 26**digit

answer = ""
for d in range(digit):
	if d == 0:
		alphabet = n % 26 - 1
		if alphabet == -1:
			alphabet = 25
		answer = alphabets[alphabet] + answer
		n = n - alphabet
	else:
		n = n // 26
		alphabet =  n % 26 - 1
		if alphabet == -1:
			alphabet = 25
		answer = alphabets[alphabet] + answer
		n = n - alphabet

print(answer)

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

const int MOD = 1e9 + 7, N = 15;

namespace {
  int Add(int x, int y) { return (x += y) >= MOD ? x - MOD : x; }
  int Dec(int x, int y) { return (x -= y) < 0 ? x + MOD : x; }
  int Mul(int x, int y) { return 1LL * x * y % MOD; }
}

int n, m, Real;
int pw[N * N], f[1 << N], G[N];

int main(void) {
  scanf("%d%d", &n, &m);
  for(int i = 1, x, y; i <= m; i++) {
    scanf("%d%d", &x, &y);
    x--; y--;
    G[x] |= 1 << y;
  }
  pw[0] = f[0] = 1;
  for(int i = 1; i <= m; i++)
    pw[i] = Mul(pw[i - 1], 2);		

  for(int S = 1; S < (1 << n); S++)
    if((S & 1) == (S >> 1 & 1))
      for(int T = S & (S - 1); ; T = S & (T - 1))
	if((T & 1) == (T >> 1 & 1)) {
	  int ways = 1;
	  for(int i = 0; i < n; i++)
	    if(S >> i & 1) {
	      if(T >> i & 1) ways = Mul(ways, Dec(pw[__builtin_popcount(G[i] & (S ^ T))], 1));
	      else ways = Mul(ways, pw[__builtin_popcount(G[i] & T)]);
	    }
	  f[S] = Add(f[S], Mul(ways, f[T]));
	  //cerr << S << " " << T << " " << ways << " " << f[S] << endl;
	  if(!T) break;
	}
  cout << Dec(pw[m], f[(1 << n) - 1]) << endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	String n = scan.nextLine();
	int cnt = Integer.valueOf(n);
	int taro = 0;
	int hanako = 0;
	for (int i = 0; i < cnt; i++) {
	    String fuda = scan.nextLine();
	    String[] cards = fuda.split(" ");
	    if (cards[0].compareTo(cards[1]) == 0) {
		taro += 1;
		hanako += 1;
	    } else if (cards[0].compareTo(cards[1]) < 0) {
		hanako += 3;
	    } else if (cards[0].compareTo(cards[1]) > 0) {
		taro += 3;
	    }
	}
	System.out.println(taro + " " + hanako);
    }
}

Measured memory_bytes: 30972
(* O(n) *)
open Array
open Hashtbl
let n = Scanf.scanf " %d" @@ (+) 0
let a_s = init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let sums = make (n + 1) 0
let h = create @@ n + 1
let f s = try let c = find h s in replace h s @@ c + 1 with _ -> add h s 1
let _ =
  iteri (fun i a -> sums.(i + 1) <- sums.(i) + a) a_s;
  Array.iter f sums;
  fold (fun _ c acc -> acc + c * (c - 1) / 2) h 0 |> Printf.printf "%d\n"

Measured memory_bytes: 14464
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int ans = 0;
    for(int i = a; i < b; i++){
        if(c <= i && i < d) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  int a,b;
  cin>>a>>b;
  cout<<max({a+b,a-b,a*b}) <<endl;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int gcm=1;
  int i=1;
  while(a/i>0){
    if (a%i==0 and b%i==0) gcm = i;
    i++;
  }
  cout << (c%gcm==0 ? "YES":"NO") << endl;
}

Measured memory_bytes: 256
/*           pmaik
    ░▒▓█►─═ Maneesh ═─◄█▓▒░


          ( •̪●)
        ███████]▄▄▄▄▄▄▄▄▃  ▃  ▃ 
    ▂▄▅█████████▅▄▃▂
   [███████████████████]
  ...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤......  */

#include<bits/stdc++.h>
using namespace std;
#define inf() ifstream cin("in00.txt")
#define onf() ofstream cout("out00.txt")
#define ll long long int
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<ll,ll>
#define fi first
#define se second
#define M 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);

 
int main()
{
    fastio;
    ll n,d;
    cin>>n>>d;
    ll a[n][2];
    ll x,y;

    ll res=0;
    for(int i=0; i<n; i++)
    {
        cin>>x>>y;
        ll d1=x*x+y*y;
        double d2=d;
        double d3=sqrt(d1);

        if(d3<=d2)
        {
            res++;
        }
    }
    cout<<res;



    return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int L,R,d; cin >> L >> R >>d;
    int ans = 0;
    for(int i = L; i <= R; i++) if(i%d == 0) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3628
h, w, k = map(int, input().split())
cake = [input() for _ in range(h)]
ans = [[0] * w for _ in range(h)]
num = 0
yet = 1
for y in range(h):
	l = cake[y]
	if "#" in l:
		yet = 0
		x = 0
		num += 1
		while l[x]!="#":
			ans[y][x] = num
			x += 1
		ans[y][x] = num
		x += 1
		while 1:
			while x < w and l[x]!="#":
				ans[y][x] = num
				x += 1
			if x==w:
				break
			if l[x]=="#":
				num += 1
				ans[y][x] = num
				x += 1
	else:
		if yet:
			ans[y + 1] = ans[y]
		else:
			ans[y] = ans[y - 1][:]
for l in ans:
	print(" ".join(map(str, l)))


Measured memory_bytes: 7156
#include<stdio.h>
int main(){
	int n,k,i,j,a[1001],b,c=0;
	scanf("%d%d",&n,&k);
	for(i=0;i<k;i++)scanf("%d%d",&a[i],&b);
	for(i=0;i<k-1;i++){
		for(j=i+1;j<k;j++){
			if(a[i]>a[j]){
				b=a[i];
				a[i]=a[j];
				a[j]=b;
			}
		}
	}
	for(i=1;i<k;i++){
		if(a[i]<n)c+=n-a[i];
		else break;
	}
	printf("%d\n",c);
	return 0;
}


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

using namespace std;

int main()
{
    float A, N, T, inp,X,curr = 9999;
    vector<float> arr;
    cin>>T;
    cin>>N>>A;
    int ans = 0;
    for(int i = 0; i < T; i++)
    {
        cin>>inp;
        X = abs(N - (0.006*inp) - A);
        if(X < curr)
        {
            curr = X;
            ans = i +1;
        }
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s; cin >> s;
  vector<int> v;
  {
    int l = 1;
    for (int i = 1; i < s.size(); i++) {
      if (s[i] == s[i-1]) l++;
      else {
        v.push_back(l);
        l = 1;
      }
    }
    v.push_back(l);
  }
  int res = 0;
  for (int i = 0; i + 1 < v.size(); i++) {
    if (v[i] % 3 == 0) {
      res += v[i] / 3 * 2;
    } else if (v[i] % 3 == 1) {
      res += v[i] / 3 * 2 + 1;
    } else {
      res += v[i] / 3 * 2 + 2;
      v[i+1]--;
    }
  }
  int x = v.back();
  if (x % 3 == 0) {
    res += x / 3 * 2;
  } else if (x % 3 == 1) {
    res += x / 3 * 2 + 1;
  } else {
    res += x / 3 * 2 + 1;
  }
  cout << res << endl;
}


Measured memory_bytes: 4468
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> input = Arrays.asList(br.readLine().split(" "));
            List<Integer> numbers = new ArrayList<>();

            for (String s : input) {
                numbers.add(Integer.parseInt(s));
            }

            int ApulsB = numbers.get(0) + numbers.get(1);
            int AmultiplyB = numbers.get(0) * numbers.get(1);
            int AminusB = numbers.get(0) - numbers.get(1);

            List<Integer> calculatedNubmers = Arrays.asList(ApulsB, AmultiplyB, AminusB);
            sortNatualOrder(calculatedNubmers);
            
            System.out.println(calculatedNubmers.get(calculatedNubmers.size() - 1));
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }

    private static void sortNatualOrder(List<Integer> intList) {
        for (int i = 0; i < intList.size() - 1; i++) {
            for (int j = intList.size() - 1; j > i; j--) {
                if (intList.get(j - 1) > intList.get(j)) {
                    int tmp = intList.get(j - 1);
                    intList.set(j - 1, intList.get(j));
                    intList.set(j, tmp);
                }
            }
        }
    }
}

Measured memory_bytes: 23252
import java.util.Scanner;

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

		long[] arr = new long[50];

		long start = k / 50;
		long time = k % 50;

		for (int i = 0; i < 50; i++) {
			arr[i] = start + i;
		}

		for (int i = 0; i < time; i++) {
			for(int j = 0; j < 50; j++) {
				if(i!=j) arr[j]--;
				else arr[j] += 50;
			}
		}
		System.out.println(50);
		for (long i : arr) {
			System.out.print(i + " ");
		}
	}
}

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

using namespace std;

long long gcd(long long x, long long y) {
  if (y == 0) { return x;}
  return gcd(y, x % y);
}

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  vector<int> left(n+1, 0);
  for (int i = 0; i < n; i++) {
    left[i+1] = gcd(left[i], a[i]);
  }
  vector<int> right(n+1, 0);
  for (int i = n-1; i >= 0; i--) {
    right[i] = gcd(right[i+1], a[i]);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int t = gcd(left[i], right[i+1]);
    ans = max(ans, t);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main() {
	long long int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	
	for (int i = 0; i < N; i++) {
		if (a[i] == 1) break;
		if (i == N - 1) {
			cout << -1 << endl;
			return 0;
		}
	}

	long long int cnt = 1;
	long long int ans = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] != cnt) ans++;
		else cnt++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1024
import math
N,M = map(int,input().split())
A = list(map(int,input().split()))
SUM = sum(A)
ans = 0
for i in range(N):
	if A[i] >= math.ceil(SUM/4/M):
		ans +=1
if ans >= M:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define vl vector
using namespace std;
int main()
{
    ll n,m,a=0,i,j;
    cin>>m>>n;
    ll arr[n];
    for(i=0;i<n;i++) cin>>arr[i];
    ll sum=0;
    for(i=0;i<n;i++) sum+=arr[i];
    if(sum>=m) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 4336
#include <cstdio>
#include <vector>
using namespace std;

bool isnp[1121];
int dp[15][1121];

int main(){
	for(int i = 2; i < 40; ++i){
		if( !isnp[i] ){
			for(int j = i * i; j <= 1120; j += i){
				isnp[j] = true;
			}
		}
	}

	dp[0][0] = 1;
	for(int i = 2; i < 1120; ++i){
		if( !isnp[i] ){
			for(int k = 14; k > 0; --k){
				for(int j = 1120; j >= i; --j){
					dp[k][j] += dp[k-1][j-i];
				}
			}
		}
	}
	
	int n, k;
	while(scanf("%d%d", &n, &k), n != 0){
		printf("%d\n", dp[k][n]);
	}
}

Measured memory_bytes: 1092
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int l, r;
    cin >> l >> r;
    if( r - l  >= 2018 ) cout << 0 << endl;
    else {
        LL res = INF;
        for( int i = l; i <= r; ++i ) {
            for( int j = i + 1; j <= r; ++j ) {
                res = min( res, (LL)i * (LL)j % 2019 );

            }
        }
        cout << res << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<
//        pair<long long, int>, // change type
//        null_type,
//        less<pair<long long, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

//template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
#define debug(x) cerr << #x << " : " << (x) << endl
const double PI = 3.14159265358979323846;
const double eps = (1e-5);
int isGreater(long double x, long double y)
{
    if (abs(x - y) < eps)
        return 0;
    if (x > y)
        return 1;
    return -1;
}

const int MAX_N = 1e5 + 5;
long long dist[MAX_N];
int n, q;
vector<long long> add[MAX_N], rmv[MAX_N];
vector<pair<int, int> >Q[MAX_N];
#define INF 1e17
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> q;
    rep(i,0,q){
        int l, r, c;
        cin >> l >> r >> c;
        --l; --r;
        Q[l].push_back({r, c});

    }

    fill(dist, dist + n + 1, INF);

    add[0].push_back(0);
    rmv[1].push_back(0);
    multiset<long long> possibleDistance;
    for (int i = 0; i < n; ++i){
        for (long long item : add[i])
            possibleDistance.insert(item);
        for (long long item : rmv[i])
            possibleDistance.erase(possibleDistance.find(item));

        if (!possibleDistance.empty())
            dist[i] = min(dist[i], *possibleDistance.begin());
        for (auto p : Q[i]){
            int c = p.second, r = p.first;
            add[i + 1].push_back(min((ll)INF, dist[i] + c));
            rmv[r + 1].push_back(min((ll)INF, dist[i] + c));
        }
    }

    long long ans = dist[n - 1];

    if (ans >= INF){
        cout << -1;
    }
    else
        cout << ans;
    return 0;
}

Measured memory_bytes: 17280
# -*- coding: utf-8 -*-
N = int(input())
num_list = list(map(int, input().split(' ')))

list_sum = sum(num_list)

ans = 0
for i in range(N-1):
    list_sum -= num_list[i]
    ans += num_list[i] * list_sum

print(ans % (10**9 + 7))

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

int main() {
  int N, K;
  cin >> N >> K;
  int d;
  int tmp;
  vector<int> memberList(N);
  for (int i = 0; i < K; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      cin >> tmp;
      if (memberList.at(tmp-1) == 0) {
        memberList.at(tmp-1) = -1;
      } else {
        continue;
      }
    }
  }
  int sum = 0;
  int length = memberList.size();
  for (int i = 0; i < length; i++) {
    sum += memberList.at(i);
  }
  cout << N + sum << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,t;
    cin>>n>>t;
    map<ll,ll>m;
    for(int i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        if(y<=t)
        {
            m[x]=y;
        }
        //m[y]=x;
    }
    if(m.size()==0)
    {
         cout<<"TLE"<<endl;
    }
    else{
    auto it=m.begin();
    
    
        cout<<it->fi<<endl;
}
}
return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<iomanip>
#include<sstream>
#include<cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
typedef long long int ll;
typedef long double ld;
const ll inf = (1 << 30);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
const int MAX = 510000;
const ll MOD = 1000000007;
ll sum = 0;
int main() {
    int n; cin >> n; string s;
    while (n != 0) {
        if (n % 2==0) s = '0'+s;
        else {
            n--; s = '1'+s;
        }
        n /= -2;
    }if (s == "")s = "0";
    cout << s << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<ll> x(n), y(n);
  rep(i,n) {
    cin >> x[i] >> y[i];
  }
  ll res = 0;
  ll l = INF, r = -INF;
  for (int i = 0; i < n; i++) {
    l = min(x[i] + y[i], l);
    r = max(x[i] + y[i], r);
  }
  res = max(res, abs(l - r));
  l = INF, r = -INF;
  for (int i = 0; i < n; i++) {
    l = min(-(x[i] - y[i]), l);
    r = max(-(x[i] - y[i]), r);
  }
  res = max(res, abs(l - r));
  l = INF, r = -INF;
  for (int i = 0; i < n; i++) {
    l = min(x[i] - y[i], l);
    r = max(x[i] - y[i], r);
  }
  res = max(res, abs(l - r));
  l = INF, r = -INF;
  for (int i = 0; i < n; i++) {
    l = min(-(x[i] + y[i]), l);
    r = max(-(x[i] + y[i]), r);
  }
  res = max(res, abs(l - r));
  cout << res << endl;
  return 0; 
}


Measured memory_bytes: 6420
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 1e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
inline ll kissme(ll x,ll y)
{
	ll res=1;
	if(x==0)return 1;
	if(x==1)return y;
	res=kissme(x/2,y);
	res=res*res%mod;
	if(x%2==1)res=res*y%mod;
	return res;
}
int n; 
signed main()
{
	Very_fast;
	cin>>n;
	n%=10;
	if(n%10==3)cout<<"bon\n";
	else if(n==0||n==1||n==6||n==8)cout<<"pon\n";
	else cout<<"hon\n";
	return 0;
}

Measured memory_bytes: 3636
import scala.io.StdIn._
import scala.collection._

object Main {

  class Sieve(val n: Int){
    private[this] val top = (n - 3) / 2 + 1
    private[this] val cmpsts = new Array[Int]((top >>> 5) + 1)
    private[this] val sqrtLimit = (Math.sqrt(n).toInt - 3) / 2

    def isPrime(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) == 0
    def setCmpst(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)

    private def innerLoop(j: Int, p: Int): Unit = {
      if(j <= top){
        setCmpst(j)
        innerLoop(j + p, p)
      }
    }

    private def loop(i: Int): Unit = {
      if(i <= sqrtLimit){
        if(isPrime(i)){
          val p = 2 * i + 3
          innerLoop((p * p - 3) >>> 1, p)
        }
        loop(i + 1)
      }
    }

    private def next(i: Int): Int = if((i > top) || isPrime(i)) 2 * i + 3 else next(i + 1)

    def exec: Iterator[Int] = {
      loop(0)
      Iterator.single(2) ++ Iterator.iterate(3)(p => next((p - 1) >>> 1)).takeWhile(_ <= n)
    }
  }

  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else if(n==2)println(1)
       else println(new Sieve(n).exec.size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit = loop(readLine)
}

Measured memory_bytes: 66128
#include <bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX
#define LINF LLONG_MAX
#define mod 1000000007
#define pie 3.141592653589793238462643383279
#define P pair<int,int>
#define prique priority_queue
#define F first
#define S second
using namespace std;
signed main(){
	int a,ans=0;
	cin>>a;
	f(i,6){
		ans+=a%10;
		a/=10;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
import copy
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
X=[A[n]-B[n] for n in range(N)]
if sum(X)<0:
    print(-1)
else:
    Y=copy.copy(X)
    minus_list=[y for y in Y if y<0]
    plus_list=sorted([y for y in Y if y>0])[::-1]
    count=len(minus_list)
    minus=sum(minus_list)
    plus=0
    for z in plus_list:
        if plus+minus>=0:
            break
        count+=1
        plus+=z
    print(count)

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

using namespace std;

void doc() {
    freopen("OB.inp", "r", stdin);
    freopen("OB.out", "w", stdout);
}

const   int MaxN = 1e5 + 5;
const   int MOD = 1e9 + 7;

void solve(){
    int n, m;
    cin >> n >> m;
    string s[n];
    for(int i = 0; i < n; i++)
        cin >> s[i];
    long long f[n + 1][m + 1];
    memset(f, 0, sizeof(f));

    for(int i = 0; i < n ; i++)
        for(int j = 0; j < m; j++){
            int x = i + 1;
            int y = j + 1;
            if (s[i][j] == '.'){
                if (i == 0 && j == 0) f[x][y] = 1;
                else
                f[x][y] = (f[x - 1][y] + f[x][y - 1]) % MOD;
               // cout << x << " " << y << " " << f[x][y] << '\n';
            }
        }
//    cout << f[3][0] << '\n';
    cout << f[n][m];
}

int main()
{
//    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
 //   doc();
    solve();
}



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

int main()
{
  int n;
  cin >> n;
  
  int w[n];
  rep(i,n){cin >> w[i];}
  
  int sum1 = 0;
  int sum2 = 0;
  int ans = 1e9;
  rep(i,n){
    rep(j,n){
      if(j <= i){
        sum1 += w[j];
      }else{
        sum2 += w[j];
      }//else
    }//rep
    if(abs(sum1 - sum2) < ans){
      ans = abs(sum1 - sum2);
    }//if
    sum1 = 0;
    sum2 = 0;
  }//rep
  
  cout << ans << endl;

}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define vi vector <int>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; ll k;
    cin>>n>>k;
    vll a(n);
    forn(i,n) cin>>a[i];
    if(k==0)
    {
        ll mx = 0;
        forn(i,n) mx = max(mx,a[i]);
        cout<<mx; return 0;
    }
    ll L = 0, R = *max_element(all(a)) + 1;
    while(R-L>1)
    {
        ll mid = (L+R)/2;
        ll c = 0;
        forn(i,n)
        {
            ll g = (a[i]+mid-1)/mid - 1;
            c += g;
        }
        //cout<<mid<<' '<<c<<endl;
        if(c>k) L = mid;
        else R = mid;
    }
    cout<<R;

	return 0;
}


Measured memory_bytes: 4816
from bisect import bisect_left

n, m = map(int, input().split())

st = set()
i = 1
while i * i <= m:
    if m % i == 0:
        st.add(i)
        st.add(m // i)
    i += 1

divs = tuple(sorted(st))
i = bisect_left(divs, n)
print(m // divs[i])


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

int main()
{
    long long n,A,B,ans=0,pr;
    cin>>n>>A>>B;
    cin>>pr;
    for(int i=1;i<n;i++)
    {
        long long x;
        cin>>x;

        if((x-pr)*A<B)
        {
            ans+=(x-pr)*A;
        }
        else
            ans+=B;
        pr=x;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  /// freopen("input.txt","r",stdin);
  /// freopen("output.txt","w",stdout);
	lli t=1;
    //cin>>t;
	while(t--)
	{
        lli n,k,i,j;
        string s;
        cin>>n>>k>>s;
        if(s[k-1]=='A')
        s[k-1]='a';
        else if(s[k-1]=='B')
        s[k-1]='b';
        else
        s[k-1]='c';
        cout<<s<<endl;
    }
}
/*

*/


Measured memory_bytes: 256
def func(n, x, i):
    sum = 0
    for j in range(n):
        sum = sum + (x[j] - i) * (x[j] - i)
    return sum


n = int(input())
x = list(map(int, input().split()))
minnum = 9999999
for i in range(min(x), max(x) + 1):
    f = func(n, x, i)
    if f < minnum:
        minnum = f
print(minnum)


Measured memory_bytes: 38896
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    int N;
    cin >> N;
    vector<int> d(N);
    for(int& x: d) cin >> x;

    int s = 0;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            s += d[i]*d[j];
        }
    }

    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

template<typename T>
inline bool chmin(T& x, T a) {
	if (x >= a) { x = a; return true; }
	return false;
}

template<typename T>
inline bool chmax(T& x, T a) {
	if (x <= a) { x = a; return true; }
	return false;
}

int main() {
	ios::sync_with_stdio(false);
	std::cin.tie(0);
	int c = 0;
	int L, R, d; cin >> L >> R >> d;
	for (int i = L; i <= R; i++) {
		if (i % d == 0) { c++; }
	}

	cout << c << endl;

	return 0;
}

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

class UnionFind{
public:
	vector<int> par;
	UnionFind(int n) :
		par(n)
	{
		iota(par.begin(),par.end(),0);
	}
	int Find(int x){
		return (par[x]==x?x:par[x]=Find(par[x]));
	}

	void Unite(int x, int y){
		x = Find(x);
		y = Find(y);
		if(x < y)
			swap(x, y);
		par[y]=par[x];
	}
};

int main(){
	int n,m,k;
	cin >> n >> m >> k;
	UnionFind uni(2000001);
	for(int kk = 0; kk < k; ++kk){
		int type, a, b;
		cin >> type >> a >> b;
		if(type == 1){
			int club_a = uni.par[uni.Find(a)];
			int club_b = uni.par[uni.Find(b)];
			if(club_a != club_b && club_a > 100000 && club_b > 100000){
				cout << kk + 1 << endl;
				return 0;
			}
			uni.Unite(a, b);
		}
		else{
			int club = uni.par[uni.Find(a)];
			b += 100000;
			if(club != b && club > 100000){
				cout << kk + 1 << endl;
				return 0;
			}
			uni.Unite(b, a);
		}
	}

	cout << 0 << endl;
}



Measured memory_bytes: 10752