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

int main()
{
  string n; cin >> n;
  int sum = 0;
  for(char c: n)
  {
    int a = c - '0';
    sum += a;
  }
  if (sum == 1)
  {
    cout << 10 << endl;
  }
  else
  {
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i;
    cin>>n;
    ll a[3*n];
    for (i=0;i<3*n;i++)
        cin>>a[i];
    priority_queue<int,vector<int>,greater<int>> left_part;
    priority_queue<int> right_part;
    ll left[3*n],right[3*n];
    ll cur_sum=0;
    for (i=0;i<3*n;i++)
    {
        left_part.push(a[i]);
        cur_sum+=a[i];
        while (left_part.size()>n)
        {
            cur_sum-=left_part.top();
            left_part.pop();
        }
        left[i]=cur_sum;
    }
    cur_sum=0;
    for (i=3*n-1;i>=0;i--)
    {
        right_part.push(a[i]);
        cur_sum+=a[i];
        while (right_part.size()>n)
        {
            cur_sum-=right_part.top();
            right_part.pop();
        }
        right[i]=cur_sum;
    }
    ll ans=-1e18;
    for (i=n-1;i<2*n;i++)
        ans=max(ans,left[i]-right[i+1]);
    cout<<ans<<endl;
}

Measured memory_bytes: 8312
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using static Reader;

public static class P
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long n = nm[0];
        var m = nm[1];
        var queries = Enumerable.Repeat(0, m).Select(_ => Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray()).ToArray();
        UnionFind uf = new UnionFind((int)n);
        long curval = n * (n - 1) / 2;
        var res = new List<long>();
        foreach (var query in queries.Reverse())
        {
            res.Add(curval);
            if (uf.Find(query[0]) == uf.Find(query[1])) continue;
            curval -= (long)uf.GetSize(query[0]) * uf.GetSize(query[1]);
            uf.TryUnite(query[0], query[1]);
        }
        res.Reverse();

        Console.WriteLine(string.Join("\n", res));
    }
}


class UnionFind
{
    public int Size { get; private set; }
    public int GroupCount { get; private set; }
    public IEnumerable<int> AllRepresents => Parent.Where((x, y) => x == y);
    int[] Sizes;
    int[] Parent;
    public UnionFind(int count)
    {
        Size = count;
        GroupCount = count;
        Parent = new int[count];
        Sizes = new int[count];
        for (int i = 0; i < count; i++) Sizes[Parent[i] = i] = 1;
    }
    public bool TryUnite(int x, int y)
    {
        int xp = Find(x);
        int yp = Find(y);
        if (yp == xp) return false;
        if (Sizes[xp] < Sizes[yp]) { var tmp = xp; xp = yp; yp = tmp; }
        GroupCount--;
        Parent[yp] = xp;
        Sizes[xp] += Sizes[yp];
        return true;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int GetSize(int x) => Sizes[Find(x)];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int Find(int x)
    {
        while (x != Parent[x]) x = (Parent[x] = Parent[Parent[x]]);
        return x;
    }
}

static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = BUF_SIZE - 1;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }

    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (int)(Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }
}


Measured memory_bytes: 32952
#include<iostream>
#include<string>

using namespace std;

int main(){
	string s,ans;
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		switch (s[i]) {
		case '0':
			ans.push_back('0');
			break;
		case '1':
			ans.push_back('1');
			break;
		case 'B':
			if (!ans.empty())ans.pop_back();
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
// 2020-08-23 00:17:26
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int h, w, m;
  cin >> h >> w >> m;
  vector<P> t(m);
  vector<int> hc(h), wc(w);
  int hm = 0, wm = 0;
  rep(i, m) {
    int hi, wi;
    cin >> hi >> wi;
    hi--; wi--;
    t[i] = P(hi, wi);
    chmax(hm, ++hc[hi]);
    chmax(wm, ++wc[wi]);
  }
  int hm_sz = 0;
  int wm_sz = 0;
  rep(i, h) hm_sz += (hc[i] == hm);
  rep(i, w) wm_sz += (wc[i] == wm);
  int rem = hm_sz * wm_sz;
  for(const auto [hi, wi] : t) {
    if(hc[hi] == hm && wc[wi] == wm) rem--;
  }
  int ans = hm + wm;
  if(rem == 0) ans--;
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    string z = "ACGT";
    int cnt = 0, bst = 0;;
    for (char c : s)
    {
        if (z.find(c) != z.npos)
            cnt++;
        else
            cnt = 0;
        bst = max(bst, cnt);
    }
    cout << bst;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define ll long long
#define str string
using namespace std;
int main(){
	string s;
    cin>>s;
    ll cnt=0;
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[s.size()-1-i]){
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
}

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

int ary[110],dat[1010][3],kek[1010];
int main(){
	int a,b,c,N,cnt;
	while(true){
		cin>>a>>b>>c;
		if(a==0&&b==0&&c==0) break;
		cin>>N;
		for(int i=1;i<=a+b+c;i++){
			ary[i]=2;
		}

		for(int i=1;i<=N;i++){
			cin>>dat[i][0]>>dat[i][1]>>dat[i][2]>>kek[i];
			if(kek[i]==1){
				for(int j=0;j<3;j++){
					ary[dat[i][j]]=1;
				}
			}
		}
		for(int i=1;i<=N;i++){
			if(kek[i]==0){
				cnt=0;
				for(int j=0;j<3;j++){
					if(ary[dat[i][j]]==1) cnt++;
				}
				if(cnt==2){
					for(int j=0;j<3;j++){
						if(ary[dat[i][j]]==2) ary[dat[i][j]]=0;
					}
				}
			}
		}
		for(int i=1;i<=a+b+c;i++){
			cout<<ary[i]<<endl;
		}
	}
	return 0;
}

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

int main(){
int a;
cin >> a;
int c=a;
for (int i=0;i<=a;i++){
  	int b=0;
	int d=i;
	while (d>0) {b+=d%6; d/=6; }
	d=a-i;
  	while (d>0){b+=d%9; d/=9;}
	if (b<=c) c=b;
}

cout <<c << endl;
  
  return 0;
}


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

#define                          ll                          long long int
#define                          mk                          make_pair
#define                          in(x)                       scanf("%lld",&x)
#define                          out(x)                      printf("%lld\n",x)
#define                          cy                          printf("YES\n")
#define                          cn                          printf("NO\n")
#define                          mx                          100005
#define                          inf                         1e17
#define                          pi                          pair<ll,ll>
#define                          fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


using namespace std;
vector<pi> adj[mx];
bool vis[mx];
ll dis[mx];
int main(){
    fast;
 ll edge ,vertex;
 cin>>vertex>>edge;
 ll i,c,u,v;
 for(i=1;i<=edge;i++){
    cin>>u>>v>>c;
    adj[u].push_back({v,c});
    adj[v].push_back({u,c});

 }
 for(i=2;i<=vertex;i++){
       adj[i].push_back({i-1,0});
 }
priority_queue<pi,vector<pi>,greater<pi> > q;

 for(i=1;i<=vertex;i++){
       dis[i]=inf;
 }
 dis[1]=0;
 q.push({dis[1],1});

 while(!q.empty()){
    pi temp;
    temp=q.top();
    q.pop();
    u=temp.second;
    ll cost=temp.first;
    if(vis[u])continue;
        vis[u]=1;
        for(auto x: adj[u]){
                v=x.first;
                c=x.second;

                if(dis[v]<=c+cost) continue;
                dis[v]=c+cost;
                q.push({dis[v],v});

        }

 }
   if(dis[vertex]>=inf) dis[vertex]=-1;
   cout<<dis[vertex]<<endl;
   return 0;
}


Measured memory_bytes: 15768
#include<bits/stdc++.h>
using namespace std;
int main(void){
  	int a;
  cin >> a;
  	if(a % 10 == 2 || a % 10 == 4 || a % 10 == 5 || a % 10 == 7 || a % 10 == 9){
      	cout << "hon" << endl;
    }else if(a % 10 == 0 || a % 10 == 1 || a % 10 == 6 || a % 10 == 8){
      	cout << "pon" << endl;
    }else{
      	cout << "bon" << endl;
    }
}
	


Measured memory_bytes: 3616
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, X;
  cin>>N>>X;
  ll A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  ll ans = 0;
  for(int i=0;i<N;++i) {
    if(A[i]>X) {
      ans += A[i]-X;
      A[i] = X;
    }
  }
  for(int i=1;i<N;++i) {
    if(A[i-1]+A[i]>X) {
      ans += A[i-1]+A[i]-X;
      A[i] = X-A[i-1];
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4420
#include<bits/stdc++.h>
#define il inline
#define vd void
typedef long long ll;
il ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int n,p[200010];
int f[2][200010],ismx[200010];
struct segtree{
#define mid ((l+r)>>1)
	int rt[200010],ls[6000010],rs[6000010],mx[6000010],cnt;
	il vd update(int&x,int l,int r,const int&p,const int&d){
		++cnt;ls[cnt]=ls[x],rs[cnt]=rs[x],mx[cnt]=mx[x];x=cnt;
		if(l==r){mx[x]=d;return;}
		if(d>mx[x])mx[x]=d;
		if(p<=mid)update(ls[x],l,mid,p,d);
		else update(rs[x],mid+1,r,p,d);
	}
	il int query(int x,int l,int r,const int&L){
		if(L<=l)return mx[x];
		if(L<=mid)return std::max(query(ls[x],l,mid,L),query(rs[x],mid+1,r,L));
		else return query(rs[x],mid+1,r,L);
	}
#undef mid
}T0,T1;
char ans1[200010],ans2[200010];
il int Query(int c,int l,int p){
	if(l>n)return c?-1e9:0;
	if(!c)return T0.query(T0.rt[l],1,n,p);
	else return T1.query(T1.rt[l],1,n,p);
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	n=gi();
	for(int i=1;i<=n;++i)p[i]=gi();
	int la1=0,lb1=0,la2=0,lb2=0,mxa1=0,mxa2=0,mxb1=0,mxb2=0,rest=0;
	for(int i=1,mx=0;i<=n;++i)if(p[i]>mx)mx=p[i],ismx[i]=1,++rest;
	memset(T1.mx,-63,sizeof T1.mx);
	for(int i=n;i;--i){
		T0.rt[i]=T0.rt[i+1];T1.rt[i]=T1.rt[i+1];
		if(ismx[i])f[0][i]=T0.query(T0.rt[i],1,n,p[i])+2,f[1][i]=T1.query(T1.rt[i],1,n,p[i])+2;
		else f[0][i]=T1.query(T1.rt[i],1,n,p[i])+1,f[1][i]=T0.query(T0.rt[i],1,n,p[i])+1;
		T0.update(T0.rt[i],1,n,p[i],f[0][i]);T1.update(T1.rt[i],1,n,p[i],f[1][i]);
	}
	auto adda1=[&](int x){if(x>mxa1)++la1,mxa1=x;};
	auto adda2=[&](int x){if(x>mxa2)++la2,mxa2=x;};
	auto addb1=[&](int x){if(x>mxb1)++lb1,mxb1=x;};
	auto addb2=[&](int x){if(x>mxb2)++lb2,mxb2=x;};
	for(int i=1;i<=n;++i){
		int c=la1+rest-lb1+(p[i]>mxa1)-ismx[i];
		if(c>=0&&Query(c&1,i+1,mxb1)>=c)ans1[i]='0',adda1(p[i]);
		else ans1[i]='1',addb1(p[i]);
		c=la2+rest-lb2-(p[i]>mxb2)-ismx[i];
		if(c>=0&&Query(c&1,i+1,std::max(p[i],mxb2))>=c)ans2[i]='0',addb2(p[i]);
		else ans2[i]='1',adda2(p[i]);
		if(ismx[i])--rest;
	}
	if(la1==lb1&&la2==lb2){
		if(strcmp(ans1+1,ans2+1)<0)printf("%s",ans1+1);
		else printf("%s",ans2+1);
	}else if(la1==lb1)printf("%s",ans1+1);
	else if(la2==lb2)printf("%s",ans2+1);
	else puts("-1");
	return 0;
}



Measured memory_bytes: 111360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dbl;
#define sqr(int) (int * int)
#define sqr3(int) (int * int * int)
#define pi M_PI
#define nl "\n"



 
  int main(){
	ios::sync_with_stdio(true);
	cin.tie(0);
	int a,sum=0;
	cin >> a;
	while(sum < a){
		sum+=1000;
	}
		cout << sum - a;
		
		}
    
	
	
		
		
		
		
	

	



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

int main() {
  int n,d,x,j=0;
  int sum = 0;
  cin >> n >> d >> x;
  vector<int>num(n);
  for (int i = 0; i < n; i++) {
    cin >> num.at(i); 
  } 
  for (int i = 0; i < n; i++) {
    j = 0;
    while(num.at(i)*j+1 <= d){
      sum++;
      j++;
    }
  }
  cout << sum+x << endl;
}  

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

string w;
map<char, int> cnt;

int main() {
  cin >> w;
  for (auto c : w) {
    cnt[c]++;
  }
  for (auto e : cnt) {
    if (e.second % 2 != 0) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;

const ll INF = (1LL<<60);

int main(){

    ll n; cin >> n;
    vll d(n);
    rep(i, n) cin >> d[i];

    ll ans = 0;
    rep(i, n){
        rep2(j, i+1, n){
            ans += d[i]*d[j];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '2') {
            cnt++;
        }
    }
    cout << cnt << endl;
}


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

using namespace std;

int n, m;
vector<vector<pair<int,int>>> B;

int check(int postpone) {
	vector<bool> marked(m+1);
	priority_queue<pair<int, int>, vector<pair<int,int>>, greater<pair<int,int>>> H;

	int placed = 0;

	for (int i = 0; i <= 2*m; ++i) {
		for (auto el : B[i]) {
			H.push(el);
		}

		if (i == 0 || i <= postpone || marked[i % m])
			continue;

		while (!H.empty() && H.top().first < i) {
			H.pop();
		}

		if (!H.empty()) {
			++placed;
			marked[i % m] = true;
			H.pop();
		}
	}

	return placed;
}

void Solve() {
	cin >> n >> m;

	B = vector<vector<pair<int,int>>>(2*m+1);

	for (int i = 1; i <= n; ++i) {
		int l, r;
		cin >> l >> r;

		B[r].push_back({l + m, i});
	}

	int lo = 0, hi = m+1;

	while (hi - lo > 1) {
		int mid = (lo + hi) >> 1;
		if (check(mid) - check(mid-1) < 0) {
			hi = mid;
		} else {
			lo = mid;
		}
	}
	// cerr << lo << "\n";

	cout << n - check(lo) << "\n";
}

int main() {
	int tests = 1;

	for (;tests; --tests) {
		Solve();
	}
}

Measured memory_bytes: 17068
#coding:utf-8

a,b = list(map(int,input().split()))

ha = 0
hb = 1

for i in range(1,1000):
    j = i + 1
    
    ha += i
    hb += j

    #while ha > a and hb > b:
    if (ha - a) == (hb - b):
        ans = ha - a
        break
    else:
        continue

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

// #define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
ll mod = (1000000007LL);
inline ll Mod(ll a, ll b){return (a%b);}
inline ll poww(ll a, ll b){ll res = 1;while (b > 0){if(b & 1) res = (res * a)%mod;a = (a * a)%mod;b >>= 1;}return res;}
ll gcd (ll a, ll b) { while (b) { a %= b,swap(a, b);}return a;}
void read(vector<int> &w, int n){w.resize(n);for(int i = 0; i < n; i++) cin>>w[i];}
void print(vector<int> &w){for(int i =0; i < sz(w); i++){if(i == sz(w) - 1) cout<<w[i]<<"\n";else cout<<w[i]<<" ";}}
int prodmod(vector<int> w);
int summod(vector<int> w);
///CUIDADO COM MAXN
#define N 300050

int n, m, q, k, v[N], ans;
pii w[N];
string s;

int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0);
	int x, y;
	cin>>x>>y;
	for(int a = 0; a <= x; a++){
		int C = 2*a;
		int D  = y - C;
		if(D >=0 and D%4 == 0 and D/4 + a == x){
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
}
/*
    CUIDADO COM MAXN, MOD, OVERFLOW 
    >Colocar (>DEFINE INT LONG LONG<) no inicio do template
    >mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
    >NAO ESQUECER DEFINE INT LONG LONG
    > N = 1 ? 
*/
int summod(vector<int> w){int curr=0;for(int i=0;i<sz(w); i++){curr = (curr+w[i])%mod;if(curr<0)curr+=mod;}return curr;}
int prodmod(vector<int> w){int curr = 1;
for(int i = 0; i < sz(w); i++){if(w[i] >= mod) w[i] %= mod;curr = (curr * w[i]) % mod;if(curr < 0) curr += mod;}return curr;}

Measured memory_bytes: 3628
s1 = input()

r1 = ""
if int(s1[0:4]) <= 2019:
    if  int(s1[0:4]) == 2019 and int(s1[5:7]) <= 4:
        r1 = "Heisei"
    elif  int(s1[0:4]) == 2019:
        r1  = "TBD"
else:
    r1  = "TBD"

print(r1)

Measured memory_bytes: 3060
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int[][] nums=new int[n][3];
        int[][] dp=new int[n][3];
        for(int i=0;i<n;i++){
            for(int j=0;j<3;j++){
                nums[i][j]=sc.nextInt();
            }
        }
        dp[0][0]=nums[0][0];
        dp[0][1]=nums[0][1];
        dp[0][2]=nums[0][2];
        for(int i=1;i<n;i++){
            dp[i][0]=Math.max(dp[i-1][1],dp[i-1][2])+nums[i][0];
            dp[i][1]=Math.max(dp[i-1][0],dp[i-1][2])+nums[i][1];
            dp[i][2]=Math.max(dp[i-1][0],dp[i-1][1])+nums[i][2];
        }
        System.out.println(Math.max(dp[n-1][0], Math.max(dp[n-1][1], dp[n-1][2])));
    }
}

Measured memory_bytes: 103156
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

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


Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  string S; cin >> S;
  if(S=="SUN") cout << 7 << endl;
  else if(S=="MON") cout << 6 << endl;
  else if(S=="TUE") cout << 5 << endl;
  else if(S=="WED") cout << 4 << endl;
  else if(S=="THU") cout << 3 << endl;
  else if(S=="FRI") cout << 2 << endl;
  else if(S=="SAT") cout << 1 << endl;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(std::string S, long long K){
    bool flag = true;
    REP(i, S.size()) {
        if(S[0] != S[i]){
            flag = false;
            break;
        }
    }

    if(flag) {
        cout << (S.size() * K / 2) << endl;
        return;
    }

    LL cnt = 0;
    REP(i, S.size()-1) {
        if(S[i] == S[i+1]) {
            cnt++;
            i++;
        }
    }
    int c1 = 0, c2 = 0;
    REP(i, S.size()) {
        if(S[0] == S[i]) {
            c1++;
        } else {
            break;
        }
    }

    RREP(i, S.size()-1) {
        if(S[0] == S[i]) {
            c2++;
        } else {
            break;
        }
    }
    if(S[0] == S[S.size()-1] && c1 % 2 == 1 && c2 % 2 == 1 && K != 1) {
        cout << (cnt * K + (K-1)) << endl;
    } else {
        cout << (cnt * K) << endl;
    }
}
// xaxaxaxaxaxaxaxaxaxa
// axaxaxaxa
// AAABAAA
// AAABAAAAAABAAA
// A-ABA-A-A-BA-A  AB^AB-ABA
// AAABAAA -> A-ABA-A
// AAABAAA = 2
// A-AB-A-A-ABA-A = 5
// A-ABA-A-A-BA-A-A-BA-A = 8
//   
int main(){
    std::string S;
    std::cin >> S;
    long long K;
    scanf("%lld",&K);
    solve(S, K);
    return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let n = input::<usize>();
    let q = input::<usize>();
    let s = input::<String>().chars().collect::<Vec<char>>();
    let lr = (0..q)
        .map(|_| {
            let l = input();
            let r = input();
            (l, r)
        })
        .collect::<Vec<(usize, usize)>>();

    let sum = {
        let mut v = Vec::with_capacity(n);
        let mut cnt = 0;
        v.push(cnt);
        for i in 0..n - 1 {
            if s[i] == 'A' && s[i + 1] == 'C' {
                cnt += 1;
            }
            v.push(cnt);
        }
        v
    };

    let stdout_ = std::io::stdout();
    let mut stdout = stdout_.lock();
    for (l, r) in lr {
        let ans = sum[r - 1] - sum[l - 1];
        writeln!(stdout, "{}", ans).unwrap();
    }
}


Measured memory_bytes: 6908
#include<bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for(ll (i)=0 ;i <(n); ++(i))
using namespace std;
#define REP(i,m,n) for(ll (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
#define all(x) (x).begin(), (x).end()

vector<ll> divisor(ll n) {
  vector<ll> res;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      res.push_back(i);
      if(i*i != n) res.push_back(n/i);
    }
  }
  sort(all(res));
  return res;
}

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

ll lcm(ll x, ll y) {
  return x*y/gcd(x, y);
}

vector<ll> digitNumber(ll x) {
  vector<ll> res;
  while(x) {
    res.push_back(x%10);
    x /= 10;
  }
  return res;
}

ll numberOfDigit(ll x) {
  ll res;
  while(x) {
    x /= 10;
    res++;
  }
  return res;
}

int main() {
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int len=s.size(),k=len;
	for(int i=0;i+1<len;i++)
	if(s[i]!=s[i+1])
		k=min(k,max(i+1,len-i-1));
		cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    xor=0
    max_digit=0
    for a in A:
        xor^=a
        max_digit=max(max_digit,a.bit_length())
    # xorのうち、bitが立っていない部分だけでスクリーニング
    for i in range(n): A[i]&=(~xor)
    # このAに対してsweeping
    r=0 # Aのrank
    for d in reversed(range(max_digit)): # digit
        for i in range(r,n):
            if A[i]&(1<<d): # 候補のiをfixする
                for j in range(i+1,n): # sweep(確定してる奴は掃き出さなくてよい)
                    if A[j]&(1<<d): A[j]^=A[i]
                A[i],A[r]=A[r],A[i] # swap
                r+=1
                break
    # sweepしたAに対し、最上位bitから確定させていく
    x=0
    for i in range(r):
        d=A[i].bit_length()
        if not x&(1<<(d-1)):
            x^=A[i]
    print(xor+2*x)
resolve()


Measured memory_bytes: 76144
#import sys
#import numpy as np
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=input()
k=int(input())
if k==1:
    a=int(n[0])
    l=len(n)
    ans=9*(l-1)+a
elif k==2:
    a=int(n[0])
    A=len(n)
    for i in range(1,A):
        if n[i]!="0":
            b=int(n[i])
            B=A-i
            break
    else:
        B=1
        b=0
    ans=9*(a-1)*(A-1)+(B-1)*9+b
    for i in range(2,A):
        ans+=81*(i-1)
else:
    a=int(n[0])
    A=len(n)
    for i in range(1,A):
        if n[i]!="0":
            b=int(n[i])
            B=A-i
            for j in range(i+1,A):
                if n[j]!="0":
                    c=int(n[j])
                    C=A-j
                    break
            else:
                c=0
                C=1
            break
    else:
        c=b=0
        C=B=1
    ans=(a-1)*81*(A-1)*(A-2)//2+81*(B-1)*(B-2)//2+(b-1)*9*(B-1)+9*(C-1)+c
    for i in range(3,A):
        ans+=729*(i-1)*(i-2)//2
print(ans)

Measured memory_bytes: 65620
N = int(input())
b = [int(i) for i in input().split()]
ans = []
for i in range(len(b)):
    removed = False
    for j in reversed(range(len(b))):
        if b[j] == j + 1:
            ans.append(b.pop(j))
            removed = True
            break
    if not removed:
        print(-1)
        exit()
print('\n'.join(map(str, reversed(ans))))

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector < int > v(n + 1);
	for (int i = 1; i < n; i++) {
		cin>>v[i];
	}
	int res = v[1] + v[n - 1];
	for (int i = 1; i + 1 < n; i++)
		res += min(v[i], v[i + 1]);
	cout<<res;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import fractions


def solve(N: int, X: int, x: "List[int]"):
    x.sort()
    gMax = None
    last = None
    begin = 0
    if abs(X - x[0]) > 0:
        last = abs(X-x[0])
        gMax = last
    else:
        begin = 1
        last = x[1]-x[0]
        gMax = last
    for i in range(begin, N-1):
        next = x[i+1] - x[i]
        gMax = fractions.gcd(gMax, next)
    print(gMax)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X, x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 17876
#include <stdio.h>

int main() {
    int a, b;

    scanf("%i %i", &a, &b);

    if (a == b) {
        printf("Draw\n");
    } else if (b == 1 || (b > a && a != 1)) {
        printf("Bob\n");
    } else if (a == 1 || (a > b && b != 1)) {
        printf("Alice\n");
    }

    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:


vector<ll> ans;

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

	if(n == 3){
		ans.push_back(2);
		ans.push_back(5);
		ans.push_back(63);
	}else{
		ans.push_back(3);
		ans.push_back(9);

		ans.push_back(2);
		ans.push_back(4);
		
		n -= 4;

		{
			int cur = 15;
			while(cur <= 30000 and n >= 2){
				ans.push_back(cur);
				cur += 6;
				ans.push_back(cur);
				cur += 6;
				n-=2;
			}
		}

		{
			int cur = 8;
			while(cur <= 30000 and n >= 2){
				ans.push_back(cur);
				cur += 2;
				ans.push_back(cur);
				cur += 4;
				n-=2;
			}
		}

		{
			int cur = 6;
			while(cur <= 30000 and n >= 1){
				ans.push_back(cur);
				cur += 6;
				n--;
			}
		}
	}


	
	ll total = 0LL;
	for(auto &elem:ans) total += elem;

	ll total_gcd = 0;
	for(auto &elem:ans) total_gcd = __gcd(total_gcd,elem);

	ll gcd_one = 0;
	for(auto &elem:ans) if(__gcd(elem,total-elem) == 1) gcd_one++;

	n = ans.size();
	
	//set<int> s;
	//rep(i,n) s.insert(ans[i]);
	//assert(n == s.size());
	//cerr << total_gcd << " " << gcd_one << endl;
	

	rep(i,n) cout << (i?" ":"") << ans[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
long long pre[200005]={0};
const int mod = 1000000007;
int main()
{
    int n,k;
    cin >> n >> k;
    long long num = 0;
    for(int i=1;i<=n;i++)
        pre[i]=i+pre[i-1];
    pre[n+1]=pre[n];
    long long ans =0 ;
    for(int i=k;i<=n+1;i++){
		//cout <<  pre[n]-pre[n-i]-pre[i-1]+1 << endl;
        ans = (ans + pre[n]-pre[n-i]-pre[i-1]+1)%mod+mod;
    }
	if(k>n)
		cout << 1 << endl;
	else
    	cout << ans%mod << endl;
    return 0;
}


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

int main(void)
{
  int a,b;
  int n=0,res=0;

  cin>>a>>b;

  n=b-a;

  for(int i=1; i<=n; i++)
  {
    res+=i;
  }
  cout<<res-b<<endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = sum(b)
for i in range(0,n-1):
  if a[i] == a[i+1]-1:
    ans += c[a[i]-1]
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int D = sc.nextInt();

		int X[][] = new int[N][D];

		for (int i=0; i<N; i++){
			for (int j=0; j<D; j++){
				X[i][j] = sc.nextInt();
			}
		}
		int cnt = 0;
		for (int i=0; i<N; i++){
			for (int j=i+1; j<N; j++){
				int tmp=0;
				double sqrt;
				for (int k=0; k<D; k++){
					tmp += Math.pow((X[i][k] - X[j][k]),2);
				}
				sqrt = Math.sqrt(tmp);
				if (Math.floor(sqrt) == sqrt){
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}


}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define ll long long
#define all(x) x.begin(),x.end()
#define TESTCASES 0

using namespace std;

const int MaxA = 1e5 + 1;
const int Mod = 1e9 + 7;

inline ll zaed(ll x,ll y){
  return (x + y) % Mod;
}

inline ll naes(ll x,ll y){
  return (x - y + Mod) % Mod;
}

inline ll darb(ll x,ll y){
  return (x * y) % Mod;
}

inline ll Exp(ll x,ll y){
  if(!y) return 1ll;
  if(y & 1) return darb(Exp(darb(x,x),y >> 1),x);
  return Exp(darb(x,x),y >> 1);
}

int n,k;
vector<ll> Mul(MaxA,0);
vector<ll> Dp(MaxA,0);

void Init(){

  Mul[1] = k;

  for(int i = 2 ; i < MaxA ; ++i)
    for(int j = i ; j < MaxA ; j += i)
      if(j > k) break;
      else Mul[i]++;
}

int Go(){


  scanf("%d %d",&n,&k);

  Init();
  
  ll Ans = 0;
 
  for(int i = k ; 1 <= i ; --i){
    
    Dp[i] = Exp(Mul[i],n);

    for(int j = i + i ; j <= k ; j += i)
      Dp[i] = naes(Dp[i],Dp[j]);

    Ans = zaed(Ans,darb(i,Dp[i]));
  }

  printf("%lld\n",Ans);

  return 0;
}


int main(){

  int t;
  if(TESTCASES) scanf("%d",&t); 
  else          t = 1;
  
  while(t--) Go();
} 

Measured memory_bytes: 4696
import math


def div_with_mod(x, y, mod):
    # Fermat's little theorem
    return x*pow(y, mod - 2, mod)


def comb(n, r, mod):
    # calculates C(n,r) with mod (assuming mod is prime)
    nc = n
    for rc in range(1, r):
        nc -= 1
        n = n*nc % mod
        r = r*rc % mod

    return div_with_mod(n, r, mod)


def solve():
    N = int(input())
    list = [chr(ord("a")+i) for i in range(10)]

    def dfs(w, i):
        if len(w) == N:
            return print(w)

        for j in range(i):
            dfs(w+list[j], i)

        dfs(w + list[i], i + 1)

    dfs("", 0)


# Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 61016
#include <stdio.h>
#include <stdlib.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    char s[ 16 ] = { '1' };
    int a, b;

    scanf ( " %d.%s", &a, s + 1 );
    if ( a < 0 )  break ;

    for ( b = atoi ( s ); b < 10000; b *= 10 );
    b -= 10000;
    if ( a >= 0x100 || !!( b % 625 ) )
    {
      puts ( "NA" );
      continue ;
    }

    for ( i = 0x80; i; i >>= 1 )
    {
      putchar ( '0' + !!( a & i ) );
    }
    putchar ( '.' );
    for ( i = 10000; i != 625; i /= 2 )
    {
      putchar ( '0' + !!( ( b % i ) * 2 / i ) );
    }
    puts ( "" );
  }

  return ( 0 );
}

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

using namespace std;

bool noprime[100000];

int main(){
  vector<int> prime;
  for(long long i=2;i<100000;++i) {
    if(noprime[i]) continue;
    prime.push_back(i);
    for(long long j=i*i;j<100000;j+=i) noprime[j]=true;
  }
  int m,a,b;
  while(cin >> m >> a >> b,m) {
    int tmp=0,ans1,ans2;
    for(int i=0;i<prime.size();++i) {
      if(prime[i]*prime[i]>m) break;
      int t=min(prime[i]*b/a,m/prime[i]);
      int h=*(upper_bound(prime.begin(),prime.end(),t)-1);
      if(prime[i]*h>tmp) {
        tmp=prime[i]*h;
        ans1=prime[i],ans2=h;
      }
    }
    cout << ans1 << " " << ans2 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3344
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define dump(x) cerr << #x << "=" << x <<endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);

void solve()
{
	/*--------------------------*/

	int N, K, Q; cin >> N >> K >> Q;
	vi v(N, 0);
	rep(i, Q) {
		int a; cin >> a;
		v[a - 1]++;
	}
	rep(i, N) {
		if (v[i] + K - Q > 0) cout << "Yes" << endl;
		else cout << "No" << endl; 
	}

	/*--------------------------*/
}

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

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

int main(){
 long long a,b;
 cin >> a >> b;
 if(a < b) swap(a,b);
 long long amari ;
 long long waru = b;
 long long warareru = a;

 while(amari != 0){
     amari = warareru%waru;
     if(amari == 0) break;
     warareru = waru;
     waru = amari;
 }
 long long gcd = waru;
 int ans = 0;
 for(long long i=2;i*i<=gcd;i++){
     if(gcd%i == 0){
         ans++;
         while(gcd%i == 0) gcd/=i;
     }
 }
 if(gcd!=1) ans++;
 ans++;
 cout << ans; 
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char *argv[]){
    int N,K;
    std::cin >> N >> K;
    int KMax = ((N-1)*(N-2))/2;
    if(K>KMax){
        std::cout << -1 << std::endl;
        return 0;
    }

    int M = N-1 + KMax - K;
    std::cout << M << std::endl;

    int E = 0;
    int pred,suc;
    for(pred=1; pred<N; ++pred){
        for(suc=pred+1; suc<=N; ++suc){
            ++E;
            std::cout << pred << " " << suc << std::endl; 
            if(E>=M){
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<list>
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define CL(a,b) memset(a,b,sizeof(a))
#define ll rt<<1
#define rr rt<<1|1
#define mid int m=(x+((y-x)>>1))
#define lson x,m,rt<<1
#define rson m+1,y,rt<<1|1
#define lowbit(x) (x&-x)
#define PB push_back
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define fi freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
using namespace std;

const int N = 1e5 + 10;
const int inf = 1e9;

int main()
{
#ifndef ONLINE_JUDGE

#endif

    int n; SC(n);
    int mi = 1e9;
    int all = 0, sum = 0;
    FF(i, 1, n)
    {
        int x; SC(x);
        if(x % 10 == 0){
            all += x;
        }
        else{
            sum += x;
            mi = min(mi, x);
        }
    }
    if(sum % 10 == 0){
        sum -= mi;
    }
    int ans = sum + all;
    PR(max(0, ans));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//一括include
using namespace std;
int main()
{
    string s;
    cin >> s;
    int p = 700;
    if (s[0] == 'o')
        p += 100;
    if (s[1] == 'o')
        p += 100;
    if (s[2] == 'o')
        p += 100;
    cout << p << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (1e9)
ll N, M;
vector<ll> A;
ll sum[105000];

ll f(ll x) {
    ll ret = 0;
    int j = N - 1;
    for(int i = 0; i < N; i++) {
        while( j >= 0 && A[i] + A[j] >= x) j--;
        ret += N - j - 1;
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    A.resize(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    for(int i = 0; i < N; i++) {
        sum[i+1] = sum[i] + A[i];
    }
    ll ok = 0;
    ll ng = 2e5 + 1;
    while(abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if(f(mid) >= M) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    ll ans = 0;
    // cerr << ok << endl;
    for(int i = 0; i < N; i++) {
        auto itr = lower_bound(A.begin(), A.end(), ok - A[i]);
        int index = distance(A.begin(), itr);
        ans += distance(itr, A.end()) * A[i];
        ans += sum[N] - sum[index];
    }
    ans -= (f(ok) - M) * ok;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
  int n,m,sum=0;
  cin>>n>>m;
  int arr[10000];
  for(int i=0;i<m;i++)
  {
    cin>>arr[i];
  }
  for(int i=0;i<m;i++)
  {
    sum+=arr[i];
  }
  if(sum>n)
    cout<<-1<<endl;
  else
    cout<<(n-sum)<<endl;
  return 0;
}

Measured memory_bytes: 3220
import math

A, B = list(map(lambda x : int(x), input().split(" ")))

minPA = A * 12.5
maxPA = (A + 1) * 12.5
minPB = B * 10
maxPB = (B + 1) * 10

if max([maxPA, maxPB]) - min([minPA, minPB]) >= 22.5:
  print(-1)
else:
  m = max([minPA, minPB])
  M = min([maxPA, maxPB])
  if M - m >= M - int(M):
    print(math.ceil(m))
  else:
    print(-1)


Measured memory_bytes: 9148
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

enum Face{
    TOP,
    SOUTH,
    EAST,
    WEST,
    NORTH,
    BOTTOM,
};
 
class Dice{
private:
    std::vector<int> faces_;  
 
public:
    Dice(const std::vector<int> &labels);
 
    ~Dice();
 
    void roll_north();
 
    void roll_east();
 
    void roll_west();
 
    void roll_south();
 
    void roll_left();
 
    void roll_right();
 
    void roll_to(char d);
 
    int get_cur_label(char f);
 
    bool operator ==(Dice &r);
};
 
Dice::Dice(const std::vector<int> &labels) : faces_(labels){
    return;
}
 
Dice::~Dice(){
    return;
}
 
void Dice::roll_north(){
    int tmp = faces_[TOP];
    faces_[TOP] = faces_[SOUTH];
    faces_[SOUTH] = faces_[BOTTOM];
    faces_[BOTTOM] = faces_[NORTH];
    faces_[NORTH] = tmp;
    return;
}
 
void Dice::roll_east(){
    int tmp = faces_[TOP];
    faces_[TOP] = faces_[WEST];
    faces_[WEST] = faces_[BOTTOM];
    faces_[BOTTOM] = faces_[EAST];
    faces_[EAST] = tmp;
    return;
}
 
void Dice::roll_west(){
    int tmp = faces_[TOP];
    faces_[TOP] = faces_[EAST];
    faces_[EAST] = faces_[BOTTOM];
    faces_[BOTTOM] = faces_[WEST];
    faces_[WEST] = tmp;
    return;
}
 
void Dice::roll_south(){
    int tmp = faces_[TOP];
    faces_[TOP] = faces_[NORTH];
    faces_[NORTH] = faces_[BOTTOM];
    faces_[BOTTOM] = faces_[SOUTH];
    faces_[SOUTH] = tmp;
    return;
}
 
void Dice::roll_left(){
    int tmp = faces_[SOUTH];
    faces_[SOUTH] = faces_[WEST];
    faces_[WEST] = faces_[NORTH];
    faces_[NORTH] = faces_[EAST];
    faces_[EAST] = tmp;
    return;
}
 
void Dice::roll_right(){
    int tmp = faces_[SOUTH];
    faces_[SOUTH] = faces_[EAST];
    faces_[EAST] = faces_[NORTH];
    faces_[NORTH] = faces_[WEST];
    faces_[WEST] = tmp;
    return;
}
void Dice::roll_to(char d){
    switch(d){
    case 'N':
        roll_north();
        break;
    case 'E':
        roll_east();
        break;
    case 'W':
        roll_west();
        break;
    case 'S':
        roll_south();
        break;
    case 'R':
        roll_right();
        break;
    case 'L':
        roll_left();
        break;
    default:
        break;
    }
    return;
}
 
int Dice::get_cur_label(char f){
    return faces_[f];
}
 
bool Dice::operator==(Dice &r){
    return this->faces_ == r.faces_;
}

int main(int argc, char **argv){
	int n;
	std::vector<int> labels(6);
	for(int i = 0; i < 6; i++){
		labels[i] = i + 1;
	}
	std::string buf;
	int sum = 1;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

	for(;;){
		Dice d(labels);
#if INPUT_FROM_FILE
		std::getline(ifs, buf);
		n = std::stoi(buf);
#else
		std::getline(std::cin, buf);
		n = std::stoi(buf);
#endif
		if(n == 0){ break; }

		sum = 1;
		for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
			std::getline(ifs, buf);
#else
			std::getline(std::cin, buf);
#endif
			d.roll_to(buf[0]);

			sum += d.get_cur_label(TOP);
		}
		std::cout << sum << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3100
// https://atcoder.jp/contests/abc168/tasks/abc168_d

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;
const int M_MAX = 2*1e5;
const int INF = 1e9;

int N, M;
// int A[M_MAX];
// int B[M_MAX];

vector<int> G[N_MAX];
int d[N_MAX];
int nxt[N_MAX];

void add_edge(int u, int v) {
  G[u].push_back(v);
  G[v].push_back(u);
}

void bfs() {
  queue<int> que;
  que.push(0);
  fill(d, d + N, INF);
  d[0] = 0;
  while (!que.empty()) {
    int v = que.front(); que.pop();
    for (int u : G[v]) {
      int d2 = d[v] + 1;
      if (d2 < d[u]) {
        d[u] = d2;
        nxt[u] = v;
        que.push(u);
      }
    }
  }
}

void solve() {
  bfs();
  puts("Yes");
  FOR(i, 1, N - 1) printf("%d\n", nxt[i] + 1);
}

void input() {
  scanf("%d%d", &N, &M);
  REP(i, M) {
    int A, B;
    scanf("%d%d", &A, &B);
    add_edge(A - 1, B - 1);
  }
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 11072