akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
const int N = 26;
string s, t;
vector<int> a[N];
long long pv = -1, ans[N], req, idx[N], n;
int main() {
	cin >> s >> t;

	for (auto c : t)
		if (s.find(c) == string::npos)
			return 0 * printf("-1");

	for (int i = 0; i < s.size(); i++)
		a[s[i] - 'a'].push_back(i);

	n = s.size();
	for (auto c : t) {
		int i = c - 'a';

		while (idx[i] < a[i].size() and pv >= a[i][idx[i]]) {
			idx[i]++;
		}

		if (idx[i] == a[i].size()) {
			req++;
			for (int i = 0; i < N; i++)
				idx[i] = 0;
		}

		ans[i] = 1ll * req * n + a[i][idx[i]];
		pv = a[i][idx[i]];
		idx[i]++;
	}

	cout << 1ll * req * n + pv + 1;
}

Measured memory_bytes: 1216
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
int x;
cin>>x;
if(x==3 ||x==5 || x==7){
    cout<<"YES"<<endl;

}
else{
    cout<<"NO"<<endl;
}


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    string s;
    cin>>s;
    int ans=0;
    for(auto c:s){
        if(c=='1')ans++;
    }
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int N,M;
  cin >> N >> M;
  
  vector<int> vec(2*M);
  
  for(int i = 0 ; i < 2*M ; i++){
    cin >> vec.at(i);
  }
    
  for(int j = 1 ; j < N+1 ; j++){
    int sum = 0;
    for(int k = 0 ; k < 2*M ; k++ ){
      if(vec.at(k) == j){
        sum += 1;
      }
    }
    cout << sum << endl;
  }
}

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

using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    bool ret = true;
    char c[100];
    memset(c, 0, 100);
    for (int i = 0; i < S.length(); i++) {
        if (c[S[i] - 'a'] == 0) c[S[i] - 'a'] = T[i];
        else if (c[S[i] - 'a'] != T[i]) ret = false;
    }
    memset(c, 0, 100);
    for (int i = 0; i < T.length(); i++) {
        if (c[T[i] - 'a'] == 0) c[T[i] - 'a'] = S[i];
        else if (c[T[i] - 'a'] != S[i]) ret = false;
    }
    if(ret) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 776
#include <cstdio>
#include <cstdlib>
#include <cstring>

int top, s[1010];

void push(int x)
{
    s[++top] = x;
}

int pop()
{
    top--;
    return s[top+1];
}

int main()
{
    int a, b;
    char buf[100];

    top = 0;
    while (scanf("%s", buf) == 1) {
        switch (buf[0]) {
            case '+' : b = pop(); a = pop(); push(a + b); break;
            case '-' : b = pop(); a = pop(); push(a - b); break;
            case '*' : b = pop(); a = pop(); push(a * b); break;
            default  : push(atoi(buf));
        }
    }
    printf("%d\n", pop());

    return 0;
}

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

map<int, int> counter;
void push(int num) {
	if (counter.find(num) == counter.end())
		counter[num]=1;
	else
		counter[num]++;
}
int query(int num) {
	if (counter.find(num) == counter.end())
		return 0;
	return counter[num];
}

int main() {
	int n,m;
	int sum=0;
	long long ans=0;
	push(0);
	cin>>n>>m;
	for (int i=0; i<n; i++) {
		int a; cin>>a;
		sum = (sum+a%m)%m;
		ans += (long long)query(sum);
		push(sum);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


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

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  string n;
  cin >> n;
  Yes(count(rng(n),'7'));

  return 0;
}


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll a, b;
    cin >> a >> b;
    if((a + b) % 2 == 1) cout << "IMPOSSIBLE";
    else cout << (a + b) / 2;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
const int N=1000010;
int n,m,p[N],q[N],f[N],L,R,M,ans,fg;string a,b;
int main(){
	cin>>n>>a>>b;a=" "+a;b=" "+b;
	ref(i,1,n)fg|=(a[i]!=b[i]);
	if(!fg){puts("0");return 0;}
	ref(i,1,n)if(b[i]!=b[i-1])p[++m]=i;
	for(int i=m,j=n;i>0&&j>0;q[i--]=j--)
		while(j>p[i]||j&&a[j]!=b[p[i]])
			f[i]|=(a[j]!=b[p[i]]),j--;
	if(!q[1]){puts("-1");return 0;}q[m+1]=N;
	ref(i,1,m)if(!f[i])q[i]=min(p[i],q[i+1]-1);
	ref(i,1,m){L=i,R=m+1;
		while(L<R)M=(L+R)>>1,(q[M]-M>=p[i]-i)?R=M:L=M+1;
		ans=max(ans,L-i);
	}
	cout<<ans+1<<endl;
}

Measured memory_bytes: 13792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
char a[100001];
int c;
int main()
{
	scanf("%s",a);
	int str=strlen(a);
	for(int i=0;i<str;i++)
	{
		if(a[i]=='+')c++;
		else c--;
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include<cstdio>
    #include<vector>
    #include<cmath>
    #include<cstring>
    #include<fstream>
    #include<algorithm>
    using namespace std;
    typedef long long LL;
    const int INF=0x3f3f3f3f;
    const int MAXN=1e5+5;
    int tot,head[MAXN];
    LL dist[MAXN];
    bool vis[MAXN];

    struct Edge
    {
        int from,to,nxt;
        LL cost;
    }e[MAXN*2];

    void addedge(int u,int v,int w)
    {
        e[tot].from=u;
        e[tot].to=v;
        e[tot].cost=w;
        e[tot].nxt=head[u];
        head[u]=tot++;
    }

    void dfs(int u,int fa)
    {
        for(int i=head[u];i!=-1;i=e[i].nxt)
        {
            int to=e[i].to;
            if(to==fa) continue;
            dist[to]=dist[u]+e[i].cost;
            dfs(to,u);
        }
    }

    int main()
    {
        int n;
        while(scanf("%d",&n)!=EOF)
        {
            tot=0;
            memset(head,-1,sizeof(head));
            memset(dist,0,sizeof(dist));
            int u,v;
            LL w;
            for(int i=1;i<=n-1;i++)
            {
                scanf("%d%d%lld",&u,&v,&w);
                addedge(u,v,w);
                addedge(v,u,w);
            }
            int q,k;
            scanf("%d%d",&q,&k);
            dfs(k,-1);
    //        for(int i=1;i<=n;i++)
    //            cout<<dist[i]<<" ";
    //        cout<<endl;
            int x,y;
            for(int i=1;i<=q;i++)
            {
                scanf("%d%d",&x,&y);
                printf("%lld\n",dist[x]+dist[y]);
            }
        }
        return 0;
    }

Measured memory_bytes: 15740
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

long P = 10^^9+7;
long[10^^5*2+50] F, RF;

void init()
{
    F[0] = F[1] = 1;
    foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P;

    {
        RF[$-1] = 1;
        auto x = F[$-1];
        auto k = P-2;
        while (k) {
            if (k%2 == 1) RF[$-1] = (RF[$-1] * x) % P;
            x = x^^2 % P;
            k /= 2;
        }
    }
    foreach_reverse(i, ref x; RF[0..$-1]) x = (RF[i+1] * (i+1)) % P;
}

void main()
{
    init();
    auto hwab = readln.split.to!(long[]);
    auto H = hwab[0];
    auto W = hwab[1];
    auto A = hwab[2];
    auto B = hwab[3];

    long r;

    auto free_h = H - A;
    auto free_w = W - B;
    foreach (y; 1..free_h+1) {
        auto m = ((F[B + y - 2] * RF[B-1])%P * RF[y-1])%P;
        auto o = ((F[free_w + (H-y) - 1] * RF[free_w-1])%P * RF[H-y])%P;
        r = (r + (m * o)%P)%P;
    }
    writeln(r);
}

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

int main(){
  int N; cin >> N;
  vector<int> L(N);
  for(int i = 0;i < N;i++){
    cin >> L[i];
  }
  sort(L.begin(), L.end());
  
  int ans = 0;
  for(int a = 0; a < N; a++){
    for(int b = a+1; b < N; b++){
      for(int c = b+1; c < N; c++){
        if( L[a] < L[b] + L[c] &&
            L[b] < L[a] + L[c] &&
            L[c] < L[b] + L[a] ){
			ans++;
        }
      }
    }
  }
  cout << ans;
  return 0;
}

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

int main()
{
    int h,w,br=0;
    bool t=true;
    char c[52][52];
    cin >> h >> w;
    for (int i=1;i<=h;i++)
        for (int j=1;j<=w;j++)
            cin >> c[i][j];
    for (int i=1;i<=h&&t;i++)
        for (int j=1;j<=w&&t;j++)
        {
            if(c[i][j]=='#')
            {
            br=0;
            if(c[i-1][j]=='#')
                br++;
            if(c[i][j-1]=='#')
                br++;
            if(c[i+1][j]=='#')
                br++;
            if(c[i][j+1]=='#')
                br++;
            if(br==0)
            {
                t=false;
                break;
            }
            }
        }
    if(t==true)
        cout << "Yes";
    else cout << "No";
}


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

using namespace std;

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

    int a, b, c;
    cin >> a >> b >> c;
    int sum = a + b + c;
    int mnum = max(a, max(b, c));
    if ((sum & 1) == (mnum & 1))
        cout << (mnum * 3 - sum) / 2 << endl;
    else 
        cout << ((mnum + 1) * 3 - sum) / 2 << endl;

    return 0;
}


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

using namespace std;

int main() {
    ll n, k;
    cin >> n >> k;
    ll arr[n];
    for (ll i = 0; i < n; i++) {
        cin >> arr[i];
    }
    ll c[n] = {0};
    for (ll i = 1; i < n; i++) {
        c[i] = c[i-1] + abs(arr[i] - arr[i-1]);
        for (ll j = 2; j <= min(i, k); j++) {
            c[i] = min(c[i], c[i-j] + abs(arr[i] - arr[i-j]));
        }
    }
    cout << c[n-1] << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<ll, ll> P;
typedef pair<double, double >pd;
typedef pair<string, string> sP;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 5e14;
const double eps = 1e-10;
const double PI = acos(-1);
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second


ll dp[1010][1010];
string s, t;

int main() {
	cin >> s >> t;
	for (int i = 0;i < s.size();i++) {
		for (int j = 0;j < t.size();j++) {
			dp[i + 1][j] = dp[i][j];
			if (s[i] == t[j]) {
				if (j == 0)dp[i + 1][j]++;
				else dp[i + 1][j] += dp[i][j - 1];
			}
			dp[i + 1][j] %= MOD;
		}
	}
	cout << dp[s.size()][t.size() - 1] << endl;
	return 0;
}


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

string whichFormat (int, int);

int main () {

    string S;
    cin >> S;

    int high, low;
    high = 10 * (S[0] - '0') + (S[1] - '0');
    low = 10 * (S[2] - '0') + (S[3] - '0');

    cout << whichFormat(high, low) << endl;

    return 0;
}

string whichFormat (int high, int low) {

    if (1 <= high && high <= 12) {
        if (1 <= low && low <= 12) {
            return "AMBIGUOUS";
        }
        else {
            return "MMYY";
        }
    }
    else if (1 <= low && low <= 12) {
        if (1 <= high && high <= 12) {
            return "AMBIGUOUS";
        }
        else {
            return "YYMM";
        }
    }
    else {
        return "NA";
    }
}

Measured memory_bytes: 256
x, y = map(int, input().split())
if (0 <= x  < y) or (x < y <= 0):
  print(y - x)
elif (0 < y < x) or (y < x < 0):
  ans = 2 + abs(x - y)
  print(ans)
else:
  ans = 1 + abs(abs(x) - abs(y))
  print(ans)

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

string s;

int ans;

int main(void){
  // Here your code !
  cin >> s;

  ans = 700;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'o') ans += 100;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less_equal<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;
    x = x % p; 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 
  
ll inv(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 

ll fac[500005];

ll ncr(ll n, ll r) 
{ 
    ll p=A;
    if (r==0)
        return 1; 
    return (fac[n]* inv(fac[r], p) % p * inv(fac[n-r], p) % p) % p; 
} 

ll npr(ll n, ll r) 
{ 
    ll p=A;
    if (r==0)
        return 1; 
    return (fac[n] * inv(fac[n-r], p) % p) % p; 
} 

int main() 
{
    FAST;
    fac[0] = 1; 
    for (int i=1 ; i<=500005; i++) 
        fac[i] = (fac[i-1]*i)%A; 
    ll n,m;
    cin>>n>>m;
    ll ans=0;
    for(int i=0;i<=n;i++)
    {
        ll x=(ncr(n,i)*npr(m,i))%A, y=(npr(m-i,n-i)*npr(m-i,n-i))%A;
        x=(x*y)%A;
        if(i&1)
            ans=(ans-x)%A;
        else
            ans=(ans+x)%A;
    }
    cout<<(ans+A)%A;
    subt;
    return 0;
}

Measured memory_bytes: 7672
#include <iostream>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) begin(c), end(c)
template<class T> void read(T& x){ cin>>x; }
void read(int& x){ scanf("%d", &x); }
void read(int64_t& x){ scanf("%lld", &x); }
void read(double& x){ scanf("%lf", &x); }
template<class T, class U, class... V>
void read(T& x, U& y, V&... z){ read(x); read(y, z...); }

int main(){
    int a,b,c,k;
    read(a,b,c,k);
    if(b > a) swap(a,b);
    if(c > a) swap(a,c);
    REP(i,k) a*=2;
    printf("%d",a+b+c);
}

Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::HashMap;

fn main() {
	input! {
		n: usize,
		mut a: [usize; n],
	}

	let mut h = HashMap::new();

	for i in 0..a.len() {
		let count = h.entry(a[i]).or_insert(0);
		*count += 1;
	}

	a.sort_by_key(|&x| std::cmp::Reverse(x));
	a.dedup();
	let mut t = 0usize;
	let mut ans = [0; 2];
	for i in 0..a.len() {
		if h.get(&a[i]).unwrap() >= &4 && t == 0 {
			println!("{}", a[i]*a[i]);
			return;
		}

		if h.get(&a[i]).unwrap() >= &2 {
			ans[t] = a[i];
			t += 1;
			if t == 2 {
				println!("{}", ans[0]*ans[1]);
				return;
			}
		}
	}
	println!("0");
}



Measured memory_bytes: 7168
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cassert>
#define maxn 2000001
#define INF (1<<30)
using namespace std;
int n=0,t[maxn];

void Swap(int a,int b)
{
    int m=t[a];
    t[a]=t[b];
    t[b]=m;
    return;
}

void maxheapify(int num)
{
    int l,r,largest;
    l=2*num;
    r=2*num+1;
    if(l<=n&&t[num]<t[l]) largest=l;
    else largest=num;
    if(r<=n&&t[largest]<t[r]) largest=r;
    if(largest!=num)
    {
        Swap(largest,num);
        maxheapify(largest);
    }
}

void increasekey(int i,int key)
{
	if(key<t[i]) return;
	t[i]=key;
	while(i>1&&t[i/2]<t[i])
	{
		Swap(i,i/2);
		i=i/2;
	}
}

void insert(int key)
{
    t[++n]=-INF;
    increasekey(n,key);
}

void extract()
{
	int maxv;
	assert(n>=1); 
	maxv=t[1];
	t[1]=t[n--];
	maxheapify(1);
	printf("%d\n",maxv);
	return;
}

int main()
{
    char s[11];
    while(scanf("%s",s)==1)
    {
        if(s[2]=='d') break;
        if(s[2]=='s')
        {
            int x;
            scanf("%d",&x);
            insert(x);
        }
        if(s[2]=='t')
        {
        	extract();
		}
    }
    return 0;
}

Measured memory_bytes: 6992
from collections import deque
k = int(input())
q = deque(list(range(1, 10)))

for _ in range(k-1):
    d = q.popleft()

    if d%10 > 0:
        q.append(d*10 + d%10 - 1)

    q.append(d*10 + d%10)
    
    if d%10 < 9:
        q.append(d*10 + d%10 + 1)

print(q.popleft())

Measured memory_bytes: 11912
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct S {//辺の情報を入れる変数
	int from, to, cost;
};
struct H {
	int x, y;
};
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
	return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad＝座標上の2点間の距離
 //---------------------------------------------------
 //+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	set<int>a;
	int b, c, d;
	cin >> b >> c >> d;
	a.insert(b);
	a.insert(c);
	a.insert(d);
	cout << a.size() << endl;
	getchar(); getchar();
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    string a;string b;
    cin>>a;
    b=a;
    reverse(b.begin(),b.end());
    if (a==b){
        cout<<"Yes";
    }else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <math.h>

using namespace std;

int main()
{
    int a;
    double n;
    scanf("%d", &a);
    while(a > 0){
        n = sqrt(a);
        if(n==(int)n){
            printf("%d", a);
            break;
        }
        else{
            a--;
        }
    }
    return 0;
}


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

using namespace std;
int main() {
    int N;

    cin >> N;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        if (s[0] == 'Y') {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
#include <chrono>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)
#define ff first
#define ss second

using namespace std;
//using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll mod = 1791791791;
const double eps = DBL_EPSILON;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL_DEBUG
    //freopen("input.txt", "r", stdin);
#endif
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) cin >> a[i][j];
    }
    int ans = INT_MAX;
    for (int mask = 0; mask < (1 << n); mask++) {
        vector<int> cnt(m);
        int cost = 0;
        for (int i = 0; i < n; i++) {
            if (mask & (1 << i)) {
                cost += c[i];
                for (int j = 0; j < m; j++) cnt[j] += a[i][j];
            }
        }
        if (*min_element(all(cnt)) >= x) ans = min(ans, cost);
    }
    if (ans == INT_MAX) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        int C=sc.nextInt();
        int X=sc.nextInt();
        int res=0;
        for(int a=0;a<=A;a++){
            for(int b=0;b<=B;b++){
                int c=(X-a*500-b*100)/50;
                if(c>=0&&c<=C)res++;
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char a[1001][1001];
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
            cin>>a[i][j];
    }
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<2;j++)
            puts(a[i]);
    }
}

Measured memory_bytes: 384
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            var cin = new MyInputStream();
            var a = cin.ReadInt();
            var b = cin.ReadInt();
            var c = cin.ReadInt();

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

    public class MyInputStream
    {
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(char separator = ' ')
        {
            this.separator = separator;
            inputStream = new Queue<string>();
        }

        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = Console.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; i++)
            {
                inputStream.Enqueue(tmp[i]);
            }
            return inputStream.Dequeue();
        }
        public string ReadLine() => Console.ReadLine();
        public int ReadInt() => int.Parse(Read());
        public long ReadLong() => long.Parse(Read());
        public double ReadDouble() => double.Parse(Read());
    }
}


Measured memory_bytes: 13268
#include <iostream>
using namespace std;
#include <stdio.h>
int main()
{
	int HW[10000][2], i = 0, j, l, k;
	while (1){
		cin >> HW[i][0] >> HW[i][1];
		if (HW[i][0] == 0 && HW[i][1] == 0)break;
		i++;
	}
	for (j = 0; j<i; j++){
		for (l = 0; l<HW[j][0]; l++){
			for (k = 0; k<HW[j][1]; k++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
}

Measured memory_bytes: 1116
#include <stdio.h>
#include <iostream>
#include <algorithm>
#define ll longlong
using namespace std;

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

    int a, left, right;
    left = 1001;
    right = -1;
    for(int i=0; i<n; i++){
        cin >> a;
        if(a > right) right = a;
        if(left > a) left = a;
    }
    cout << right - left << endl;
    return 0;
}

Measured memory_bytes: 256
n = input()
l = [int(x) for x in list(str(n))]
ans = [0,0,0]
for cnt in range(3):
	if l[cnt] == 1:
		ans[cnt] = 9
	elif l[cnt] == 9:
		ans[cnt] = 1
	else:
		ans[cnt] = l[cnt]
ansn =  ans[0] * 100 + ans[1] * 10 + ans[2]
print(ansn)


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#define MAXN 105
int a[MAXN][MAXN];
int c, num[MAXN*MAXN];

int main() {
	int h, w, n, k = 0, s = 1;
	scanf("%d %d", &h, &w);
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &c);
		while(c--) 
			num[++k] = i;
	}
	for(int i = 1; i <= h; i++) {
		if(i & 1) {
			for(int j = 1; j <= w; j++) 
				a[i][j] = num[s++];
		}else {
			for(int j = w; j >= 1; j--) 
				a[i][j] = num[s++];
		}
	}
	for(int i = 1; i <= h; i++) {
		for(int j = 1; j <= w; j++) 
			printf("%d ", a[i][j]);
		printf("\n");
	}
	return 0;
} 

Measured memory_bytes: 384
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import defaultdict 
def main():
    s = input() 
    n = len(s)
    T = [0]
    P = 2019
    dd = defaultdict(int) 
    dd[0] += 1
    for i in range(1, n+1):
        x = (int(s[-i])*pow(10, i-1, P) + T[i-1])%P
        T.append(x)
        dd[x] += 1
    ans = 0
    for i in dd.values():
        ans += i*(i-1)//2
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 16792
// Parasparopagraho Jīvānām

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std ;
using namespace  __gnu_pbds ;
using namespace __gnu_cxx ;

typedef long long ll ;
typedef long double ld ;

typedef pair<int, int> pii ;
typedef pair<int, ll> pil ;
typedef pair<ll,ll> pll ;

typedef vector<int> vi ;
typedef vector<ll> vll ;
typedef vector<pii> vpi ;
typedef vector<pll> vpl ;
typedef vector<int,pil> edges ;

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

#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define per(i,b,a) for (int i = (b); i >= (a); i--)

#define mp make_pair
#define eb emplace_back
#define pb push_back
#define fi first
#define se second

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int mod1 = 1000000007 ;
const int mod2 = 998244353 ;
const ll  infl = 2e18 ;
const int infi = 2e9 ;
const int maxn = 2e5 + 5 ;
const int block = 500 ;
const int logn = 60 ;
const int alpha = 27 ;
const ld pi = 3.141592653589793238462643383279 ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) ;

/* Careful when using long long
__builtin_clz(int x) {} //: the number of zeros at the beginning of the number
__builtin_ctz(int x) {} //: the number of zeros at the end of the number
__builtin_popcount(int x) {} //: the number of ones in the number
__builtin_parity(int x) {} //: the parity (even or odd) of the number of ones*/
ll modpow(ll a, ll b, int MOD) { ll res = 1 ; while(b) { if(b&1) { res = res*a ; res %= MOD ; } a *= a ; a %= MOD ; b >>= 1 ; } return res%MOD ; }
void upmin(int &a, int b) { if(a < b) { a = b ; } }
void relax(int &a, int b) { if(a > b) { a = b ; } }
ll add(ll a, ll b, int MOD) { a += b ; if(a >= MOD) { a -= MOD ; } return  a ; }
ll sub(ll a, ll b, int MOD) { a -= b ; if(a < 0) { a += MOD ; } return a ; }
ll mul(ll a, ll b, int MOD) { b %= MOD ; a *= b ; a %= MOD ; return a ; }
ll inverse(ll a, ll MOD) { a = modpow(a, MOD - 2, MOD) ; return a ; }
ll lcm(ll a, ll b) { ll ret ; ll g = __gcd(a, b) ; ret = a/g ; ret = ret*b ; return ret ; }


int main()
{
    ios::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    int x ;
    cin >> x ;
    int g = __gcd(360, x) ;
    int m = x/g ;
    int res = 360*m ;
    res /= x ;
    cout << res << endl ;

    return 0 ;
}


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


public class Main {
	public static void main(String[] args) {
		new Main().io();
	}
	
	String solve(int n){
		n = n%39;
		if(n==0) n=39;
		
		String str = Integer.toString(n);
		if(0<=n && n<=9) str = "0" + str;
		
		return "3C" + str;
	}
	
	void io(){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int n = sc.nextInt();
			System.out.println(solve(n));
		}
		
		sc.close();
	}
	
	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
n = int(input())
a = [input() for i in range(n)]
ac=0
wa=0
tle=0
re=0
for i in range(n):
    if a[i]=='AC':
        ac += 1
    if a[i]=='WA':
        wa += 1
    if a[i]=='TLE':
        tle += 1
    if a[i]=='RE':
        re += 1
print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))


Measured memory_bytes: 16188
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int[] num = new int[3];
		num[0] = sc.nextInt();
		num[1] = sc.nextInt();
		num[2] = sc.nextInt();
		Arrays.sort(num);
		int dis1 = num[2] - num[0];
		int dis2 = num[2] - num[1];
		int ans = 0;
		if( dis1%2==0 && dis2%2==0 ){
			ans = dis1/2 + dis2/2;
		}else if( dis1%2!=0 && dis2%2!=0 ){
			ans = dis1/2 + dis2/2 + 1;
		}else{
			ans = dis1/2 + dis2/2 + 2;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22740
N, M = map(int, input().split())
K = [0] * (N+1)
for i in range(M):
    L, R = map(int, input().split())
    K[L-1] += 1
    K[R] -= 1
S = 0
ans = 0
for k in K:
    S += k
    if S == M:
        ans += 1
print(ans)

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

ll a, b, n, g, ans;
int main(){
  cin >> a >> b;
  n = min(a,b)+1;
  
  rep(i, n+1) {
    if (i == 0) continue;
    if (a%i == 0 && b%i == 0){
      g = i;
    }
  }
  ans = a*b/g;
    cout << ans << endl;
}

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

const int inf = 1e9;
const ll linf = 1e18;

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

    int a, b; cin >> a >> b;
    char c = '0' + a, d = '0' + b;
    string s, t;
    for (int i = 0; i < b; i++) s.push_back(c);
    for (int i = 0; i < a; i++) t.push_back(d);
    cout << ((s < t) ? s : t) << endl;
    return 0;
}

Measured memory_bytes: 256
/*
    author : Aryan Agarwal, IIT KGP
    created : 27-04-2020 17:13:51
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long ull;
#define int ll

int MOD = 1000000007; /*more than (10)^9*/  /*7 + 1e9*/
int PEG = 998244353; /*less than (10)^9*/   /*1 + 7*17*(2)^23*/
long double pie=acos(-1);

// for creating a 2d vector with n rows & m columns then initialise it with it 0
// vvi vec(n,vi(m,0));
// vector<vector<int> > vec( n , vector<int> (m, 0));
typedef vector< int > vi;
typedef vector< vi > vvi;
#define X first
#define Y second
#define pb push_back
#define sz(a) (ull)(a).size()
#define all(a) (a).begin(),(a).end()
 
#define F(i,a,b) for (ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define in1(a,n) F(i,1,n)cin>>a[i]
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<"\n"
#define out1(a,n) F(i,1,n)cout<<a[i]<<" ";cout<<"\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pfy cout<<"YES"
#define pfn cout<<"NO"
#define pfn1 cout<<"-1"  // printf negative 1
#define pf1 cout<<"1"
#define nl cout<<"\n"

#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>void __f(const char* name,Arg1&& arg1){std::cout<<name<<" : "<<arg1<<endl;}template <typename Arg1,typename... Args>void __f(const char* names,Arg1&& arg1,Args&&... args){const char* comma=strchr(names+1, ',');std::cout.write(names,comma-names)<<" : "<<arg1<<"\n";__f(comma+1,args...);}

ll binpow(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ll res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpow(n,p-2,p);}
ll popcount(ll n)/*__builtin_popcount doesn't work for big no.s*/{ll ans=0;while(n){if(n%2)ans++;n/=2;}return ans;}
ll gcd(ll a, ll b)/*__gcd doesn't work for big no.s*/{if (b == 0)return a;return gcd(b, a % b);}

signed main()
{
    #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    #endif
    fast;

    int n;
    cin>>n;

    vector <string> s(n);

    F(i,0,n-1)
    {
        cin>>s[i];
    }

    sort(all(s));

    int ans=1;

    F(i,1,n-1)
    {
        if(s[i]!=s[i-1])ans++;
    }

    cout<<ans;



    return 0;
}

Measured memory_bytes: 9544
#include <stdio.h> 

int main(void)
{
	int count[4][3][10] = {0};
	int n, b, f, r, v, i, j, k;

	scanf("%d",&n);

	for(i = 0; i < n; i++)
	{
		scanf("%d %d %d %d", &b, &f, &r, &v);
		count[b-1][f-1][r-1] = count[b-1][f-1][r-1] + v;
	}

	for(i = 0; i < 4; i++)
	{
		for(j = 0; j < 3; j++)
		{
			for(k = 0; k < 10; k++)
			{
				printf(" %d",count[i][j][k]);
			}

			printf("\n");
		}
		if((i+1) < 4)
		{
			printf("####################\n");
		}
	}
	return 0;
}

Measured memory_bytes: 612
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n;
int c[1111],s[1111],f[1111];
signed main(){
	cin>>n;
	rep(i,n-1)cin>>c[i]>>s[i]>>f[i];
	rep(i,n-1){
		int time=s[i];
		for(int j=i;j<n-1;j++){
			if(time<s[j])time=s[j];
			if(time%f[j]!=0)time+=f[j]-time%f[j];
			time+=c[j];
		}
		cout<<time<<endl;
	}
	cout<<0<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int h, w, j1[100], i1[100], j2=0, i2=0;
	char a1[100], a[10000];
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; ++i)
	{
		scanf("%s", a1);
		for (int j = 0; j < w; ++j)
		{
			a[100*i+j]=a1[j];
		}
	}
	for (int i = 0; i < h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			if (a[100*i+j]=='#')
			{
				i1[i2]=i;
				i2++;
				break;
			}
		}
	}
	for (int j = 0; j < w; ++j)
	{
		for (int i = 0; i < i2; ++i)
		{
			if (a[100*i1[i]+j]=='#')
			{
				j1[j2]=j;
				j2++;
				break;
			}
		}
	}
	for (int i = 0; i < i2; ++i)
	{
		for (int j = 0; j < j2; ++j)
		{
			printf("%c", a[100*i1[i]+j1[j]]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
<?php
$N = intval(trim(fgets(STDIN)));
$A = array_map("intval", explode(" ", trim(fgets(STDIN))));
$B = array_map("intval", explode(" ", trim(fgets(STDIN))));
$dp = array_fill(0, 1<<$N, array_fill(0,51,PHP_INT_MAX));
$dp[0][0] = 0;
for($bit = 0, $NN = 1<<$N; $bit < $NN; ++$bit){
    $con = 0;
    $x = $bit;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    $ords = [];
    $iter = $con;
    for($i = 0; $i < $N; ++$i)
        if(!($bit & (1<<$i)))
            $ords[$i] = $iter++;
    for($s = 0; $s <= 50; ++$s){
        if($dp[$bit][$s] == PHP_INT_MAX)continue;
        foreach($ords as $p0 => $p1){
            $ns = ($p0-$con) & 1 ? $B[$p0] : $A[$p0];
            if($ns >= $s){
                $nb = $bit | (1<<$p0);
                $dp[$nb][$ns] = min($dp[$nb][$ns], $dp[$bit][$s] + abs($p1 - $con));
            }
        }
    }
}
$min = min($dp[(1<<$N)-1]);
if($min == PHP_INT_MAX){
    echo -1;
}else{
    echo $min;
}


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

int main() {
  long long int n;
  cin>>n;
  if(n%2!=0){
    cout<<0<<endl;
  }
  else{
    n/=2;
    long long int p=0;
    while(n>=5){
      n/=5;
      p+=n;
    }
    cout<<p<<endl;
  }
}

Measured memory_bytes: 256
int main(void)
{
	int table[101][101];
	int r,c;
	
	int i,j;
	
	for(i = 0;i < 101;i++){
		for(j = 0;j < 101;j++){
			table[i][j] = 0;
		}
	}
	
	scanf("%d %d",&r,&c);
	
	for(i = 0;i < r;i++){
		for(j = 0;j < c;j++){
			scanf("%d",&table[i][j]);
			table[i][c] += table[i][j];
			table[r][j] += table[i][j];
			table[r][c] += table[i][j];
		}
	}
	
	for(i = 0;i <=r;i++){
		for(j = 0;j <=c;j++){
			if(j == c)
				printf("%d",table[i][j]);
			else 
				printf("%d ",table[i][j]);
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 644
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    int a, b;
    cin >> a >> b ;
    if (a + b >= 10) {
        cout << "error" << endl;
    }
    else {
        cout << a + b << endl;
    }
    return 0;
}


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

#define PrintLn(X) cout << X << endl
int main(void)
{
	int a;
	cin >> a;
	if(a % 10 == 9 || a / 10 == 9){
		PrintLn("Yes");
	}else{
		PrintLn("No");
	}
	return 0;
}


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

int main(){
    int nc[26]={};
    string s;

    while(getline(cin, s)){
        for(int i=0; i<(int)s.length(); i++){
            if('a' <= s[i] && s[i] <= 'z') nc[s[i]-'a']++;
            if('A' <= s[i] && s[i] <= 'Z') nc[s[i]-'A']++;
        }
    }
    for(int i=0; i<26; i++){
        cout << (char)('a'+i) << " : " << nc[i] << endl;
    }
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9+10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair

int read() {
	int xx=0,ww=1;
	char ch=getchar();
	while(ch>'9'||ch<'0') {
		if(ch=='-') ww=-ww;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		xx=10*xx+ch-48;
		ch=getchar();
	}
	return xx*ww;
}

int n;
int a[100010];
int maxn=-INF,sum;

int main() {
	n=read();
	for(int i=1; i<=n; i++) a[i]=read();
	for(int i=1; i<=n; i++) {
		sum+=a[i];
		maxn=max(maxn,a[i]);
	}
	if(2*maxn>=sum) puts("No");
	else puts("Yes");
	return 0;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	double denominator = 0;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		denominator += 1.0 / A;
	}
	cout << fixed << setprecision(5) << 1 / denominator << endl;
	return 0;
}

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



int main(){
    int D,G;cin >> D >> G;
    vector<int> P(D);vector<int> C(D);vector<int> S(D);
    int mim = 0;
    for (int i = 0;i < D;i++){
        cin >> P[i] >> C[i];
        S[i] = (i + 1) * 100;
        mim += P[i];
    }
    for (int bit = 0;bit < (1 << D);bit++){
        int sum = 0;int count = 0;
        for (int i = 0;i < D;i++){
            if (bit & (1 << i)){
                sum += (P[i] * S[i]) + C[i];
                count += P[i];
            }
        }
        if (sum < G){
            for (int i = D - 1;i >= 0;i--){
                if (bit & (1 << i)) continue;
                for (int j = 0;j < P[i];j++){
                    if (sum >= G) break;
                    sum += S[i];
                    count++;
                }
            }
        }
        mim = min(mim,count);
    }
    cout << mim << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 55;
char s[N],t[N];
int len1,len2;
char p[N];

int main(){
	scanf("%s",s+1);
	scanf("%s",t+1);
	len1 = strlen(s+1);
	len2 = strlen(t+1);
	for(int i = len1-len2+1;i >= 1;i--){
		bool flag = true;
		for(int j = 1;j <= len2;j++)
			if(s[i+j-1] != '?' && s[i+j-1] != t[j]){
				flag = false;
				break;
			}
		if(flag){
			for(int j = 1;j <= len2;j++)
				s[i+j-1] = t[j];
			for(int j = 1;j <= len1;j++)
				if(s[j] == '?')
					s[j] = 'a';
			printf("%s\n", s+1);
			return 0;
		}
	}
	printf("UNRESTORABLE\n");
	return 0;
}

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

int main() {
	long long int a, b;
	int p=1;
	long long int c=10;
	
	while(cin>>a>>b) {
		p=1;
		c=10;
		while(c<=a+b) {
			p++;
			c*=10;
		}

		cout<<p<<endl;
	}
}

Measured memory_bytes: 0
N = int(input())
p = []
if N > 0:
    for i in range(500):
        if (2**(2*i)-1)/3 < N <= (2**(2*(i+1))-1)/3:
            q = 2*i + 1
if N < 0:
    for i in range(1,500):
        if -(2**(2*i+1)-2)/3 <= N < -(2**(2*i-1)-2)/3:
            q = 2*i
if N == 0:
    q = 1
def cal(n,i):
    if i % 2 != 0:
        if (2**(i-1)-1)/3 < n <= (2**(i+1)-1)/3:
            p.append(1)
            n = n - (-2)**(i-1)
            i = i-1
            if i > 0:
                cal(n,i)
        else:
            p.append(0)
            i = i-1
            if i > 0:
                cal(n,i)
    elif n == 0:
        p.append(0)
        i = i-1
        if i > 0:
            cal(n,i)
    else:
        if -(2**(i+1)-2)/3 <= n < -(2**(i-1)-2)/3:
            p.append(1)
            n = n - (-2)**(i-1)
            i = i-1
            if i > 0:
                cal(n,i)
        else:
            p.append(0)
            i = i-1
            if i > 0:
                cal(n,i)
            
    return p
ans = cal(N,q)
for i in range(len(ans)):
    ans[i] = str(ans[i])
print(''.join(ans))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define int lint
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
signed main(){
    string s;
    cin >> s;
    int cc = 0;
    int j = 0;
    rep(i, s.size())
    {
        if(s[s.size()-1-i]!='/'){
            cc += (s[s.size() - 1 - i] - '0')*pow(10,j);
            j++;
        }
    }
    if (cc > 20190430)
    {
        cout << "TBD" << endl;
    }else{
        cout << "Heisei" << endl;
    }
    return 0;
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  bool ok=false;
  for (int i = 1; i < b; i++)
  {
    /* code */
    if (a*i%b==c)
    {
      /* code */
      ok=true;
      break;
    }
    
  }
  if (ok)
  {
    /* code */
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }
  
  
  
  }

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
minans = inf ;ans = 0 ;count = 0 ;pro = 1

s=input()
a=s.find("A")
s=s[::-1]
z=s.find("Z")
print(len(s)-z-a)

Measured memory_bytes: 3896
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> pll;
const lli inf = 1e18;

int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    for(int i=0; i<n; i++){
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    int xmin = (n%2==0)? a[n/2]+a[n/2-1]: a[n/2];
    int xmax = (n%2==0)? b[n/2]+b[n/2-1]: b[n/2];
    cout << xmax-xmin+1 << endl;
    return 0;
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	set <int> s;
	
	s.insert(a);
	s.insert(b);
	s.insert(c);
	
	cout << s.size();
	
	return 0;
}


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

int main(){
	int s, a, b;
	cin >> s;

	a = s / 100;
	b = s % 100;
	if (a == 0) {
		if (b > 0 && b < 13) cout << "YYMM";
		else cout << "NA";
	}
	else if (a >= 13){
		if (b > 0 && b < 13) cout << "YYMM";
		else cout << "NA";
	}
	else if (a < 13){
		if (b > 0 && b < 13) cout << "AMBIGUOUS";
		else cout << "MMYY";
	}
	
}

Measured memory_bytes: 256
import sys
import re

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7

S = 'keyence'
N = len(S)
T = input()
M = len(T)

for i in range(N+1):
    S1 = S[:i]
    S2 = S[i:]
    exp = '^{0}(.*){1}$'.format(S1, S2)
    if re.match(exp, T):
        YES()
        exit()
NO()


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

int main() {
    int a;
    cin >> a;
    cout << 3 * a * a << endl;
}


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

using namespace std;

#define int long long
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
const int N=1e5+5;
int mod=1e9+7;

int n,w;
int W[N],v[N];
int cache[105][N];

int dp(int idx,int wt){



    if(wt>w) {
//        cout<<"ehi";
        return INT64_MIN;
    }
    if(idx>=n) return 0;

    int &ans=cache[idx][wt];
    if(ans!=-1)
        return ans;

    ans=max(dp(idx+1,wt),v[idx]+dp(idx+1,wt+W[idx]));

    return ans;
}

int32_t main() {
    faster;


    cin>>n>>w;
//    cout<<w;
    memset(cache,-1,sizeof(cache));

    for(int i=0;i<n;i++){
        cin>>W[i]>>v[i];
    }

    cout<<dp(0,0)<<endl;
}

Measured memory_bytes: 82304
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  string s, t;
  cin >> s >> t;
  string a= "";
  for(int i= 0; i< s.size()+ t.size(); i++){
    if(i% 2== 0){
      a+= s.at(i/ 2);
    }
    else{
      a+= t.at((i- 1)/ 2);
    }
  }
  
  cout << a << endl;
}

Measured memory_bytes: 256