akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
const ll MOD = 998244353;

ll k[maxn],a[maxn];
inline ll qpow(ll a,ll b){
	ll res = 1;
	while(b){
		if(b & 1) res = (res*a) % MOD;
		a = (a*a) % MOD;
		b >>= 1;
	}
	return res % MOD;
}

int main()
{
	ll x,n,maxs = -2e18;
	scanf("%lld",&n);
	for(int i = 1;i <= n;++i){
		scanf("%lld",&a[i]);
		k[a[i]]++;
		maxs = max(maxs,a[i]);
	}ll ans = 1;for(int i = 0;i < maxs;++i){
		if(!k[i]){
			ans = 0;
			break;}ll t = qpow(k[i],k[i+1]);ans = (ans*t) % MOD;
	}
	if(k[0] != 1 || a[1] != 0) ans = 0;printf("%lld\n",(ans+MOD)%MOD);
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int[] data=new int[3];
    for(int i=0;i<3;i++){
      data[i]=sc.nextInt();
    }
    Arrays.sort(data);
    if(data[0]==data[1]){
      if(data[1]==data[2]){
        System.out.println(1);
      }else{
        System.out.println(2);
      }
    }else{
      if(data[1]==data[2]){
        System.out.println(2);
      }else{
        System.out.println(3);
      }
    }
  }
}

Measured memory_bytes: 22868
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] T = new long[N];
        for (int i = 0; i < N; i++) {
            T[i] = sc.nextLong();
        }
        long now = T[0];
        for (int i = 0; i < N-1; i++) {
            long mod = gcd(now, T[i+1]);
            now = now/mod*T[i+1];
        }
        System.out.println(now);
    }
    
    private static long gcd(long a, long b) {
        long mod = a%b;
        long retval = 0;
        if (mod == 0) {
            retval = b;
        } else {
            retval = gcd(b, mod);
        }
        return retval;
    }
}

Measured memory_bytes: 35836
import sys

n, q = map(int, sys.stdin.readline().split())

child = [[] for _ in range(n+1)]
for i in range(n-1):
    a, b = map(int, sys.stdin.readline().split())
    child[a].append(b)

score = [0] * (n+1)
for i in range(q):
    p, x = map(int, sys.stdin.readline().split())
    score[p] += x

wait = [1]

while True:
    target = wait.pop()
    for nex in child[target]:
        score[nex] += score[target]
        wait.append(nex)
    if len(wait) == 0:
        break

score.pop(0)

print(' '.join(map(str, score)))


Measured memory_bytes: 117836
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
tot_a=0
tot_b=0
#Aだけでどこまでいけるか
a=[0]
b=[0]
for i in range(n):
    a.append(a[-1]+A[i])
for j in range(m):
    b.append(b[-1]+B[j])
#print(a,b)
ans=0
j=m
for i in range(n+1):
    if a[i]>k:
        break
    while a[i]+b[j]>k:
        j-=1
    ans=max(ans,i+j)
print(ans)

Measured memory_bytes: 47492
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100000

int N,E;
int height[NUM],boss[NUM];
int in_num[NUM];

int get_boss(int id){
	if(id == boss[id])return id;
	else{
		return boss[id] = get_boss(boss[id]);
	}
}

void unite(int x,int y){

	int x_boss_id = get_boss(x);
	int y_boss_id = get_boss(y);

	if(x_boss_id == y_boss_id)return;

	if(height[x_boss_id] < height[y_boss_id]){

		boss[x_boss_id] = y_boss_id;

	}else{
		boss[y_boss_id] = x_boss_id;
		if(height[x_boss_id] == height[y_boss_id])height[x_boss_id]++;
	}
}

void func(){

	for(int i = 0; i < N; i++){
		boss[i] = i;
		height[i] = 0;
		in_num[i] = 0;
	}

	int from,to;
	for(int loop = 0; loop < E; loop++){
		scanf("%d %d",&from,&to);
		from--;
		to--;
		unite(from,to);
		in_num[from]++;
		in_num[to]++;
	}

	for(int i = 0; i < N; i++){
		if(in_num[i] > 2){
			printf("no\n"); //次数が3以上のノードがあればfalse
			return;
		}
	}

	int group_num = 0;
	for(int i = 0; i < N; i++){
		if(i == get_boss(i))group_num++;
	}

	/*
	 * 1本辺を引く(1回uniteする)毎にbossが1つ減るので、
	 * 辺の両端に重複がなければ、group_numはN-Eになるはず
	 * */
	if(group_num == N-E){
		printf("yes\n");
	}else{
		printf("no\n");
	}
}

int main(){

	while(true){
		scanf("%d %d",&N,&E);
		if(N == 0 && E == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 4196
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String A = sc.nextLine();
		char a = A.charAt(0);
		char b = A.charAt(2);
		if(a == 'H') {
			System.out.println(b);
		}
		if(a == 'D') {
			if(b == 'H') {
				System.out.println("D");
			}
			else {
				System.out.println("H");
			}
		}
	}
}


Measured memory_bytes: 35632
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char a = s.charAt(0);

        if ( Character.isUpperCase(a)) {
            System.out.print('A');
        } else {
            System.out.print('a');
        }
    }

}

Measured memory_bytes: 35648
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n, k = map(int, input().split())
    aa = list(map(int, input().split()))
    ff = list(map(int, input().split()))
    aa.sort(reverse=True)
    ff.sort()
    l = -1
    r = aa[0] * ff[-1]
    # print(aa)
    # print(ff)
    while l + 1 < r:
        # print(l,r)
        m = (l + r) // 2
        s = 0
        for a, f in zip(aa, ff):
            b = m // f
            s += max(a - b, 0)
            if s > k:
                l = m
                break
        else:
            r = m
    print(r)

main()


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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int gcd(int a, int b) {
    if (a<b) swap(a, b);

    if (a%b==0) return (b);
    else return(gcd(b, a%b));
}

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

    vector<int> x(n+1);
    for(int in=0;in<n;in++) {
        cin >> x.at(in);
    }

    x.at(n) = largex;

    sort(x.begin(), x.end());

    vector<int> y(n);
    int ans;
    for(int in=0;in<n;in++) {
        y.at(in) = x.at(in+1)-x.at(in);
    }

    ans = y.at(0);
    for(int in=0;in<n-1;in++) {
        ans = gcd(ans, y.at(in+1));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1152
# ABC113 D 

N,M=map(int,input().split())

P=[[] for _ in [0]*(N+1)]

for i in range(M):
    p,y=map(int,input().split())
    P[p].append((y,i))
    
from bisect import bisect_left as bl

res=[]
for p in range(N+1):
    Y=P[p][:]
    if not Y:
        continue
    
    sortY=sorted(list(set(Y)))
        
    zatY=[]
    for t_y in Y:
        zatY.append(bl(sortY,t_y))
    
    for index in zatY:
        y,i=sortY[index]
        num=10**12+p*10**6+index+1
        res.append((str(num)[1:],i))

res=[y for y,i in sorted(res,key=lambda x:x[1])]
print(*res,sep='\n')

Measured memory_bytes: 119556
#include <iostream>
using namespace std;
void week_0_C()
{
    class polygon
    {
        unsigned int sided;
        int *data;
    public:
        polygon(){;}
        ~polygon(){delete [] data;}
        polygon( unsigned int &n)
        {
            sided = n;
            data = new int[n];
        }
        void input()
        {
            if (sided <= 2)
            {
                cout << "can not form a polygon\n";
                return;
            }
            int count = sided;
            while( count -- )
            {
                unsigned int temp;
                cin >> temp;
                data[count] = temp;
            }
            return;
        }
        bool form()
        {
            int max = data[0];
            int n = sided;
            while(n--)
                if(max < data[n])
                    max = data[n];
            n = sided;
            int sum = 0;
            while (n --)
                sum += data[n];
            return (max < (sum - max));
        }
    };
    
    unsigned int sided;
    cin >> sided ;
    polygon p1(sided);
    p1.input();
    if (p1.form())
        cout << "\nYes"<<endl;
    else
        cout << "\nNo"<<endl;  
    return;
}
int main ()
{
    week_0_C();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 100100
#define pii pair<int, int>
#define pb push_back
typedef long long ll;

using namespace std;

int a, b;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> a >> b;
    cout << a + b / 2;
}

Measured memory_bytes: 256
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int N,M,A,B,C,T;
V mul(const V &a, const V &b){
	V c(N*N);
	int i=0,j;
	for(;i<N;i++)for(j=0;j<N;j++)c[i*N+j]=(a[slice(i*N,N,1)]*b[slice(j,N,N)]).sum()%M;
	return c;
}
V exp(const V &a, const int n){
	if(n==1)return a;
	if(n%2==1)return mul(exp(a,n-1),a);
	V b=exp(a,n/2);
	return mul(b,b);
}
V z(){
	V x(N*N);
	int i;
	if(T){
		for(i=0;i<N;i++){
			if(i>0)x[i*N+i-1]=A;
			x[i*N+i]=B;
			if(i<N-1)x[i*N+i+1]=C;
		}
		return exp(x,T);
	}else{
		for(i=0;i<N;i++)x[i*N+i]=1;
		return x;
	}
}
main(){
	int i;
	V s;
	for(;scanf("%d%d%d%d%d%d",&N,&M,&A,&B,&C,&T),N;){
		s.resize(N);
		for(i=0;i<N;i++)scanf("%d",&s[i]);
		const V r=z();
		for(i=0;i<N;i++){
			printf(i<N-1?"%d ":"%d\n",(r[slice(i*N,N,1)]*s).sum()%M);
		}
	}
}

Measured memory_bytes: 1080
#include<bits/stdc++.h>
#define LL long long
#define ull unsigned long long
#define ULL ull
#define mp make_pair
#define pii pair<int,int>
#define piii pair<int, pii >
#define pll pair <ll,ll>
#define pb push_back
#define big 20160116
#define INF 2147483647
#define pq priority_queue
#define rank rk124232
#define y1 y20160116
#define y0 y20160110
using namespace std;
inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
namespace Mymath{
    LL qp(LL x,LL p,LL mod){
        LL ans=1;
        while (p){
            if (p&1) ans=ans*x%mod;
            x=x*x%mod;
            p>>=1;
        }
        return ans;
    }
    LL inv(LL x,LL mod){
        return qp(x,mod-2,mod);
    }
    LL C(LL N,LL K,LL fact[],LL mod){
        return fact[N]*inv(fact[K],mod)%mod*inv(fact[N-K],mod)%mod;
    }
    template <typename Tp> Tp gcd(Tp A,Tp B){
        if (B==0) return A;
        return gcd(B,A%B);
    }
    template <typename Tp> Tp lcm(Tp A,Tp B){
        return A*B/gcd(A,B);
    }
};
namespace fwt{
    using namespace Mymath;
    void FWT(int a[],int n,LL mod)
    {
        for(int d=1;d<n;d<<=1)
            for(int m=d<<1,i=0;i<n;i+=m)
                for(int j=0;j<d;j++)
                {
                    int x=a[i+j],y=a[i+j+d];
                    a[i+j]=(x+y)%mod,a[i+j+d]=(x-y+mod)%mod;
                }
    }

    void UFWT(int a[],int n,LL mod)
    {
        LL rev=inv(2,mod);
        for(int d=1;d<n;d<<=1)
            for(int m=d<<1,i=0;i<n;i+=m)
                for(int j=0;j<d;j++)
                {
                    int x=a[i+j],y=a[i+j+d];
                    a[i+j]=1LL*(x+y)*rev%mod,a[i+j+d]=(1LL*(x-y)*rev%mod+mod)%mod;
                }
    }
    void solve(int a[],int b[],int n,LL mod)
    {
        FWT(a,n,mod);
        FWT(b,n,mod);
        for(int i=0;i<n;i++) a[i]=1LL*a[i]*b[i]%mod;
        UFWT(a,n,mod);
    }
};
const int Maxn=2e5+5;
int a[Maxn];
int b[Maxn];
int n;
int check(int v){
    for (int i=1;i<=2*n-1;i++) b[i]=(a[i]>=v)?1:0;
    if (b[n]==b[n+1] || b[n-1]==b[n]){
        return b[n];
    }
    for (int l=n,r=n;l>=1;l--,r++){
        if (b[l]==b[l+1]){
            return b[l];
        }
        if (b[r]==b[r-1]){
            return b[r];
        }
    }
    return b[n]^(n&1)^1;
}
int main(){
    n=read();
    for (int i=1;i<=2*n-1;i++) a[i]=read();
    int lo=1,hi=2*n;
    while (hi-lo>1){
        int mid=lo+hi>>1;
        if (check(mid)){
            lo=mid;
        }
        else{
            hi=mid;
        }
    }
    printf("%d\n",lo);
    return 0;
} 

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

vector<vector<int>> s;
vector<int> p;

int check(int N, vector<int> k) {
    if (N == 0) {
        for (int i = 0; i < p.size(); i++) {
            int sum = 0;
            for (int j = 0; j < s[i].size(); j++) {
                sum += k[s[i][j]];
            }
            if (sum % 2 != p[i]) {
                return 0;
            }
        }
        return 1;
    }
    else {
        vector<int> k1, k2;
        k1 = k;
        k1.push_back(0);
        k2 = k;
        k2.push_back(1);
        return check(N - 1, k1) + check(N - 1, k2);
    }
}


int main() {

    int N, M;
    cin >> N >> M;

    int k;
    int tmp;
    for (int i = 0; i < M; i++) {
        cin >> k;
        vector<int> ss;
        for (int j = 0; j < k; j++) {
            cin >> tmp;
            ss.push_back(tmp - 1);
        }
        s.push_back(ss);
    }

    for (int i = 0; i < M; i++) {
        cin >> tmp;
        p.push_back(tmp);
    }

    vector<int> ans;
    cout << check(N, ans) << endl;

    return 0;
}


Measured memory_bytes: 256
# AtCoder Beginner Contest 122
# https://atcoder.jp/contests/abc122
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, Q = i2nn()
    S = i2s()
    LR = ii2nnn(Q)
    rsw = [0] * (N+1)
    for i in range(N-1):
        rsw[i+1] = rsw[i]
        if S[i] == 'A' and S[i+1] == 'C':
            rsw[i+1] += 1
    rsw[N] = rsw[N-1]
    # 0 1 2 3 4 5
    # 0 1 1 1 2 2
    #  a c c a c
    #  1 2 3 4 5
    for l, r in LR:
        n = rsw[r-1] - rsw[l-1]
        print(n)

main()

Measured memory_bytes: 29188
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<ctime>
using namespace std;
typedef long long ll;
int n, x[200010], y[200010];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		y[i] = x[i];
	}
	sort(x, x + n);
	for (int i = 0; i < n; i++) {
		if (x[n / 2 - 1] >= y[i])cout << x[n / 2] << endl;
		else cout << x[n / 2 - 1] << endl;
	}
	return 0;
}

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

    int main()
    {
	int t = 1;
	// cin >> t;
	while (t--) {
		int n;
		cin >> n;
		int x, o = 0;
		while (n--) {
			cin >> x;
			if (x & 1) {
				o++;
			}
		}
		if(o%2==0)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
	}
}


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

    // define
# define loop(i,a,n) for(int i=a;i<n;++i)
# define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(0);
# define ll long long int 
# define endl '\n'
# define mp make_pair
# define mt make_tuple
# define pb push_back
# define eb emplace_back
# define in insert
# define rev(i,a,n) for(int i=n-1;i>=a;--i)
# define test int t; cin>>t; while(t--)

/* debug */
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _itRS(_ss); err(_itRS, args); }

void err(istream_iterator<string> itRS) {}
template<typename T, typename... Args>
void err(istream_iterator<string> itRS, T a, Args... args) {
    cerr << *itRS << " = " << a << endl;
    err(++itRS, args...);
}


const int MOD=1000000007;


int T[10001];
int main()
{
    fast
    int h,a;
    cin>>h>>a;
    ll d[h];
    ll sum=0;
    for(int i=0;i<h;i++)
    {
        cin>>d[i];
       
    }
    sort(d,d+h);
    for(int i=0;i<h-a;i++)
    {
        sum=sum+d[i];
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;

void sub_self(int& a, int b){
    a-=b;
    if (a < 0) a+=mod;
}

void add_self(int& a, int b){
    a += b;
    if (a >= mod) a-=mod;
}
int main(){
    int n, k;
    cin >> n>> k;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i];
    /*
    vector<vector<int>> dp(n + 1, vector<int>(k + 1, 0));
    dp[0][0] = 1;

    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= k; j++){
            if (j - a[i] >= 0){
                for (int h = j - a[i]; h <= j; h++){
                    dp[i][j] = (dp[i][j] + dp[i-1][h]) % mod;
                }
            } else
                for (int h = 0; h <= j; h++)
                    dp[i][j] = (dp[i][j] + dp[i-1][h]) % mod;

        }
    }
   // cout << dp[2][1] << endl;
    cout << dp[n][k];
    */
    vector<int>dp(k + 1);

    dp[0] = 1;
    for (int i = 1; i <= n; i++){
        vector<int>fake(k + 1, 0);
        for (int j = k; j >= 0; j--){
            //for (int h = max(0, j - a[i]); h <= j; h++)
            //for (int h = j; h >= max(0, j - a[i]); h--)
            // So luong keo ma tre co the lay
            // do j = 0 roi nen di tu 1
            int tmp = dp[j];
            int L = j + 1;
            int R = j + min(a[i], k - j);
            /*
            for (int used = 1; used <= min(a[i], k - j); used++)
                dp[j + used] = (dp[j + used] + dp[j]) % mod;
            */
            if (L <= R) {
                //fake[L] = (fake[L] + dp[j]) % mod;
                add_self(fake[L], tmp);
                if (R + 1 <= k) sub_self(fake[R + 1], tmp);
            }
        }
        int presum = 0;
        for (int j = 0; j <= k; j++){
            //presum += fake[j];
            add_self(presum, fake[j]);
            add_self(dp[j], presum);
            //dp[j] += presum;
        }
    }
    cout << dp[k];
}


Measured memory_bytes: 1024
import Data.Array.IO
import Control.Monad

main = do
  n <- getLine
  ary <- newArray ((0,0,0),(3,2,9)) 0 :: IO (IOArray (Int,Int,Int) Int)
  forM_ [1..read n] $ \i -> do
    m <- getLine
    let [b,f,r,v] = map (read :: String->Int) . words $ m
    vOld <- readArray ary (b-1,f-1,r-1)
    writeArray ary (b-1,f-1,r-1) (vOld+v)

  forM_ [0..3] $ \i -> do
      forM_ [0..2] $ \j -> do
          forM_ [0..9] $ \k -> do
            vNew <-  readArray ary (i,j,k)
            putStr $ " " ++ show vNew
          putStrLn ""
      if i < 3 then putStrLn "####################" else return ()

Measured memory_bytes: 4192
package main

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

func main() {
	io := newIo()
	defer io.Flush()
	A := io.Next()
	n := len(A)
	runeCount := map[rune]int{}
	for _, s := range A {
		runeCount[s] = runeCount[s] + 1
	}
	rcount := 0
	for _, v := range runeCount {
		if v > 1 {
			rcount += (v * (v - 1)) / 2
		}
	}
	result := (n * (n - 1) / 2) + 1 - rcount
	fmt.Println(result)
}

type io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}


Measured memory_bytes: 1920
face = [0]*6
class Dice():

    def __init__(self):
        self.one = inp[0]
        self.two = inp[1]
        self.three = inp[2]
        self.four = inp[3]
        self.five = inp[4]
        self.six = inp[5]

    def setnumbers(self, n0, n1, n2, n3, n4, n5):
        self.one = n0
        self.two = n1
        self.three = n2
        self.four = n3
        self.five = n4
        self.six = n5


    def spin(self, command):
        face[0] = self.one
        face[1] = self.two
        face[2] = self.three
        face[3] = self.four
        face[4] = self.five
        face[5] = self.six
        if command == 'S':
            self.setnumbers(face[4], face[0], face[2], face[3], face[5], face[1])
            # print('command is S')
        elif command == 'N':
            self.setnumbers(face[1], face[5], face[2], face[3], face[0], face[4])
            # print('command is N')
        elif command == 'E':
            self.setnumbers(face[3], face[1], face[0], face[5], face[4], face[2])
            # print('command is E')
        elif command == 'W':
            self.setnumbers(face[2], face[1], face[5], face[0], face[4], face[3])
            # print('command is W')

inp = list(map(int, input().split()))
command = list(input())

dice = Dice()

dice.setnumbers(inp[0], inp[1], inp[2], inp[3], inp[4], inp[5])
face = inp
for i in range(len(command)):
    dice.spin(command[i])
print(dice.one)



Measured memory_bytes: 5608
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#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;

const double pi = 3.141592653589793;
// -------------------------------------------------------
long double A, B, H, M;

int main() {
  cin >> A >> B >> H >> M;
  long double rad = abs(pi * M / 30.0 - (pi * H / 6.0 + pi * M / 360.0));
  if (rad > 180) {
    rad = 360 - rad;
  }
  long double cc = A * A + B * B - 2.0 * A * B * cos(rad);
  long double c = sqrt(cc);
  cout << fixed << setprecision(20) << c << endl;
}

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

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



Measured memory_bytes: 3116
n = int(input())
al=[chr(ord('a') + i) for i in range(26)]
INF = 10**9 + 1
#各アルファベットの出現回数の最小値
minAl = [INF for _ in range(26)]
#Cards = ["" for _ in range(n)]
for i in range(n):
    c = input()
    for j in range(26):
        minAl[j] = min(minAl[j],c.count(al[j]))
for i in range(26):
    if minAl[i] != INF:
        for j in range(minAl[i]):
            print(al[i], end="")

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;
int cnt = 0;
int ans[300000][4];
int a[500][500];
int f[500] = { 0 };

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(ll a, ll b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}void hSwap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}

void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}

void doChangeH(int i, int j) {
	ans[cnt][0] = i;
	ans[cnt][1] = j;
	ans[cnt][2] = i + 1;
	ans[cnt++][3] = j;
	a[i][j]--;
	a[i + 1][j]++;
	f[i] == 0;
	f[i + 1] = 1 - f[i + 1];
}
void doChangeW(int i, int j) {
	ans[cnt][0] = i;
	ans[cnt][1] = j;
	ans[cnt][2] = i;
	ans[cnt++][3] = j+1;
	a[i][j]--;
	a[i][j+1]++;
}

int main() {
	int h, w;
	scanf("%d%d", &h, &w);
	int sum;
	REP(i, h) {
		sum = 0;
		REP(j, w) {
			scanf("%d", &a[i][j]);
			sum += a[i][j];
		}
		if (sum % 2 == 1)f[i] = 1;
	}
	REP(i, h) {
		if (f[i] == 1 && i != h-1) {
			REP(j, w) {
				if (a[i][j] % 2 == 1) {
					doChangeH(i, j);
				}
			}
		}
		REP(j, w-1) {
			if (a[i][j] % 2 == 1) {
				doChangeW(i, j);
			}
		}
	}
	PRINTD(cnt);
	REP(i, cnt) {
		printf("%d %d %d %d\n", ans[i][0]+1, ans[i][1]+1, ans[i][2]+1, ans[i][3]+1);
	}
}

Measured memory_bytes: 6144
//
//  sum_of_large_number.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;


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

  int n, k;
  std::cin >> n >> k;

  // ll C[n+2];

  // C[0] = 1;  // nC0 is 1
  // C[1] = n+1;

  //   for (int i = 2; i < n+1; i++)
  //   {
  //       C[i] = (((n - i + 2) * C[i-1] / i)) % mod;
  //   }
  // C[n+1] = 1;
  // ll sum = 0;
  // for (int i = k; i <= n+1; i++) {
  //   int repeat = ((n+1) / i) - 1;
  //   sum = (sum + C[i] - repeat + mod) % mod;
  // }
  // std::cout << sum << std::endl;
  ll sum = 0;
  for (ll i=k; i<=n+1; i++) {
    ll smallest = (i*(i-1)/2) ;
    ll largest = ((n-i+1+n)*i/2) ;
    (sum += (largest - smallest + 1)) %= mod;
  }
  std::cout << sum << std::endl;

  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long int

#define MAX 100000

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    int N, t=0; bool b=false;
    cin>>N;
    for(int i = 1; i <= N; i++){
        int n; cin>>n;
        if(i==n){
            if(b){
                b=false;
            }else{
                b=true; t++;
            }
        } else b=false;
    }
    cout<<t<<endl;
    return 0;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

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

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    vi r(1000010);
    rep(i,n) r[a[i]]++;
    sort(rall(a));

    if(r[1] == 1){
        cout << 1 << endl;
        return 0;
    }
    if(r[1] > 1){
        cout << 0 << endl;
        return 0;
    }

    ll ans = n;
    rep(i,n){
        for(int x=a[i]; x<1000010; x+=a[i]){
            if(x == a[i] && r[x] == 1){
                continue;
            }else{
                ans -= r[x];
                r[x] = 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8020
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] d = new int[k];
		for (int i = 0; i < k; i++) {
			d[i] = sc.nextInt();
		}

		int have = haveNoD(n, d);
		while (have != -1) {
			n += Math.pow(10, have - 1);
			if (have != 1) {
				n -= Integer.parseInt(String.valueOf(n).substring(String.valueOf(n).length() - have + 1));
			}
			have = haveNoD(n, d);
		}

		System.out.println(n);
		sc.close();

	}

	public static int haveNoD(int n, int[] d) {
		String ns = String.valueOf(n);
		for (int i = 0; i < ns.length(); i++) {
			for (int j = 0; j < d.length; j++) {
				if (Integer.parseInt(ns.substring(i, i + 1)) == d[j]) {
					return ns.length() - i;
				}
			}
		}
		return -1;
	}
}


Measured memory_bytes: 21716
def count(n,juge=true,k=0)
  max= juge ? ("9"*n).to_i : k
  min=("1"+"0"*(n-1)).to_i
  max-min+1
end

a=gets.chomp
len=a.length
sum=0
for i in 1..len-1
 sum+= count(i) if i%2!=0
end

puts len%2==0 ? sum : sum+count(len,false,a.to_i)

Measured memory_bytes: 1788
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            var An = Sarray();
            var dic = new Dictionary<long, long>();
            foreach(var A in An)
            {
                if (dic.ContainsKey(A)) dic[A]++;
                else dic.Add(A, 1);
            }
            for(var i = 0;i<M;i++)
            {
                var tmp = Sarray();
                if (dic.ContainsKey(tmp[1])) dic[tmp[1]] += tmp[0];
                else dic.Add(tmp[1], tmp[0]);
            }
            var ad = dic.OrderByDescending(x => x.Key).ToArray();
            long ans = 0;
            for(var i=0;;i++)
            {
                if(0<=N-ad[i].Value)
                {
                    N -= ad[i].Value;
                    ans += ad[i].Key * ad[i].Value;
                }
                else
                {
                    ans += ad[i].Key * N;
                    break;
                }
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 40132
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define mp make_pair
#define pb push_back
#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define for1(i, n) for(int i = 1; i < (int)(n); ++i)
#define nfor(i, n) for(int i = int(n) - 1; i >= 0; --i)
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define correct(x, y, n, m) (0 <= x && x < n && 0 <= y && y < m)
#define all(x) (x).begin(), (x).end()
#define fst first
#define snd second
#define endl "\n"

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

template<typename T> inline T abs(T a){ return ((a < 0) ? -a : a); }
template<typename T> inline T sqr(T a){ return a * a; }
template<class T> T gcd(T a, T b) { return a ? gcd (b % a, a) : b; }
template<class T> T lcm(T a, T b) { return a / gcd (a, b) * b; }
template<class T> T sign(T a) { return a > 0 ? 1 : (a < 0 ? -1 : 0); }

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}

template<typename T>
vector<T> make_unique(vector<T> v) {
    sort(all(v));
    return v.resize(unique(all(v)) - v.begin());
}

int nxt() {
    int x;
    cin >> x;
    return x;
}

const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int dxKn[8] = {-2, -1, 1, 2,  2,  1, -1, -2};
const int dyKn[8] = { 1,  2, 2, 1, -1, -2, -2, -1};
const int dxK[8] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dyK[8] = {1, -1, 0, 0, 1, -1, 1, -1};

const int MOD = int(1e9) + 7;
const int INF = int(1e9) + 100;
const ll INF64 = 2e18;
const ld PI = ld(3.1415926535897932384626433832795);
const ld e = ld(2.7182818284590452353602874713527);
const ld EPS = 1e-9;

//#############################
const int MAXN = 1000005;

int main() {
    fastIO(); 
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    // debug_out(a, b,c,d);
    ll ans = max({a*c, a*d, b*c, b*d});

    cout << ans << endl;

    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int c = 0;
  if(s[0] == '1') c++;
  if(s[1] == '1') c++;
  if(s[2] == '1') c++;
  cout << c;
 
  return 0;
}
  


Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import sys
if __name__ == "__main__":
    s = list(input())
    t = list(input())
    for tmp in range(0, len(t)):
        factor = []
        factor.append(s.pop())
        factor.extend(s)
        s = factor
        if ''.join(factor) ==''.join(t):
            print("Yes")
            sys.exit(0)
    else:
        print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define IT iterator
#define vi vector<int>
#define TP template<class o>
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=1e6+10,size=1<<20,mod=(int)1e9+7,inf=2e9;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
    char c=gc; x=0; int f=1;
    while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
    while(isdigit(c)) x=x*10+c-'0',c=gc;
    x*=f;
}
template<class o> void qw(o x) {
    if(x/10) qw(x/10);
    putchar(x%10+'0');
}
template<class o> void pr1(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar('\n');
}

int n;
ll f[N][4];

ll power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=c*a%mod;
		b /= 2; a=a*a%mod;
	}
	return c;
}

void ad(ll &x,ll y) {x=(x+y)%mod;}

int main() {
	qr(n);
	f[0][0]=1;
	for(int i=1;i<=n;i++) {
		for(int j=0;j<4;j++) 	
			ad(f[i][j],f[i-1][j]*8),
			ad(f[i][j|2],f[i-1][j]),
			ad(f[i][j|1],f[i-1][j]);
	}
	pr2(f[n][3]);
	return 0;
}


Measured memory_bytes: 34640
my ($h, $w) = split(' ', <>);
my @board = map {my $in=<>;chomp$in;[(split'',$in)]} (1..$h);

my @d = (0, -1, 1);
for my $i (0..$h-1) {
    for my $j (0..$w-1) {
        if ($board[$i][$j] eq '.') {
            my $count =
                grep { $board[$_->{i}][$_->{j}] eq '#' }
                grep { 0 <= $_->{i} && $_->{i} < $h }
                grep { 0 <= $_->{j} && $_->{j} < $w }
                map { +{i=>$i+$_->{i}, j=>$j+$_->{j}} }
                map { my $di = $_; map {+{i=>$di, j=>$_}} @d } @d;
            $board[$i][$j] = $count;
        }
    }
}

for (@board) {
  print $_ for @$_;
  print "\n";
}

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

int main(void) {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  int ans = 1;
  for (int i = 1; i < N; i++) {
    bool flag = true;
    for (int j = 0; j < i; j++) {
      if (H[j] > H[i]) {
        flag = false;
        break;
      }
    }
    if (flag) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		int n;
		cin>>n;
		ll a[n];
		ll presum[n];
		for(int i =0;i<n;i++)
            {cin>>a[i];
            presum[i] =a[i];
                //cout<<presum[i]<<" ";
            }
            
            for(int i =n-2;i>=0;i--)
            {
               ll sum = presum[i] + presum[i+1];
               sum = sum%(mod);
               presum[i] =sum;
               //cout<<presum[i]<<" ";
            }
            ll res =0;
            for(int i=1;i<n;i++)
            {
                ll ans = a[i-1]*(presum[i]);
                ans =ans%mod;
                res += ans;
                res = res%mod;
            }
            cout<<res<<endl;
		return 0;
	
	}


Measured memory_bytes: 6760
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int clz(int x) { return 31 - __builtin_clz(x); }
int clz(ll x) { return 63 - __builtin_clzll(x); }
int ctz(int x) { return __builtin_ctz(x); }
int ctz(ll x) { return __builtin_ctzll(x); }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

class pcompare {
public:
	bool operator()(pll a, pll b) {
		return (a.sc < b.sc);
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;
	cin>>s>>t;
	rep(ii,(s.size()-t.size()+1)){
		int i=(s.size()-t.size()-ii);
		bool ok=true;
		rep(j,t.size()){
			if(s[i+j]!='?'&&s[i+j]!=t[j])ok=false;
		}
		if(ok){
			rep(j,s.size()){
				if(i<=j&&j<i+t.size())cout<<t[j-i];
				else cout<<(s[j]=='?'?'a':s[j]);
			}
			cout<<endl;
			return 0;
		}
	}
	cout<<"UNRESTORABLE"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>

int main()
{
    std::unordered_map<std::string,int> dic{
        {"SUN", 7},
        {"MON", 6},
        {"TUE", 5},
        {"WED", 4},
        {"THU", 3},
        {"FRI", 2},
        {"SAT", 1},
    };
    std::string S;
    std::cin >> S;
    std::cout << dic[S] << std::endl;
    return 0;
}

Measured memory_bytes: 256
n, h = map(int, input().split())
li = list(map(int, input().split()))
li_a = [[0] for i in range(n)]
for i in range(h):
  a, b = map(int, input().split())
  li_a[a-1].append(li[b-1])
  li_a[b-1].append(li[a-1])
ans = 0
for j in range(n):
  if li[j] > max(li_a[j]):
    ans += 1
print(ans)

Measured memory_bytes: 26104
n,k,q=map(int,input().split())
ans0=[k-q for i in range(n)]
#print(ans0)
p=[]
for i in range(q):
  p.append(int(input()))
#print(p)
import collections
c = collections.Counter(p)
cc=[]
for i in range(n):
  cc.append(c[i+1])
#print(cc)
ans=[]
for d,e in zip(ans0,cc):
  ans.append(d+e)
#print(ans)

for f in ans:
  if f<=0:
    print("No")
  else:
    print("Yes")

Measured memory_bytes: 19844
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <iostream>

#define NIL -1

struct Node{
    int parent, leftChild, rightSibling;
};

void getDepth(int *arr, Node *nodes, int label, int depth);
std::string getProperty(Node node);
std::vector<int> getChildren(Node *nodes, int label);

int main(int argc, char** argv) {
    Node* nodes;
    int len, *depth, root = NIL;

    scanf("%d", &len);
    nodes = (Node *) calloc(sizeof(Node), len + 1);
    depth = (int *) calloc(sizeof(int), len + 1);

    for (int i = 0; i < len; i++) {
        nodes[i].parent = nodes[i].leftChild = nodes[i].rightSibling = NIL;
    }

    for (int i = 0; i < len; i++) {
        int label, degree, child1 = NIL, child2 = NIL;
        scanf("%d %d", &label, &degree);

        for (int j = 0; j < degree; j++) {
            scanf("%d", &child1);

            nodes[child1].parent = label;

            if (j == 0) {
                nodes[label].leftChild = child1;
            } else {
                nodes[child2].rightSibling = child1;
            }

            child2 = child1;
        }
    }

    for (int i = 0; i < len; i++) {
        if (nodes[i].parent == NIL) {
            root = i;
            break;
        }
    }

    getDepth(depth, nodes, root, 0);

    for (int i = 0; i < len; i++) {
        printf("node %d: parent = %d, depth = %d, ", i, nodes[i].parent, depth[i]);
        std::cout << getProperty(nodes[i]) << ", ";

        std::vector<int> children = getChildren(nodes, i);
        std::cout << "[";
        if (children.size() > 0) {
            std::cout << children[0];
        }
        if (children.size() > 1) {
            for (std::vector<int>::iterator it = children.begin() + 1; it != children.end(); it++) {
                std::cout << ", " << *it;
            }
        }
        std::cout << "]" << std::endl;
    }

    free(nodes);
    free(depth);
    return 0;
}

void getDepth(int *arr, Node *nodes, int label, int depth) {
    arr[label] = depth;

    if (nodes[label].leftChild != NIL) {
        getDepth(arr, nodes, nodes[label].leftChild, depth + 1);
    }

    if (nodes[label].rightSibling != NIL) {
        getDepth(arr, nodes, nodes[label].rightSibling, depth);
    }
}

std::string getProperty(Node node) {
    if (node.parent == NIL) {
        return "root";
    } else {
        if (node.leftChild == NIL) {
            return "leaf";
        } else {
            return "internal node";
        }
    }
}

std::vector<int> getChildren(Node *nodes, int label) {
    std::vector<int> results;
    Node node = nodes[label];

    if (node.leftChild != NIL) {
        results.push_back(node.leftChild);
        node = nodes[node.leftChild];

        while (node.rightSibling != NIL) {
            results.push_back(node.rightSibling);
            node = nodes[node.rightSibling];
        }
    }

    return results;
}



Measured memory_bytes: 5156
#include <iostream>
using namespace std;
struct node{
    int key,r,l,p,no;
};
int main(void){
    int n;
    cin >> n;
    node a[n+1];
    for(int i=1;i<n+1;i++){
        a[i].no=i;
        cin >> a[i].key;
    }
    for(int i=1;i<n+1;i++){
        a[i].p=a[i/2].key;
        a[i].l=a[2*i].key;
        a[i].r=a[2*i+1].key;
    }
    for(int i=1;i<n+1;i++){
        cout << "node " << i << ": key = "<<a[i].key<<", ";
        if(i/2>0)cout <<"parent key = "<<a[i].p<< ", ";
        if(2*i<n+1)cout << "left key = "<<a[i].l<< ", ";
        if(2*i+1<n+1)cout << "right key = "<< a[i].r<<", ";
        cout << endl;
    }
    
}



Measured memory_bytes: 3100
#include<iostream>
#include <string>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
	long long N;
	cin >> N;
	
	long long A;
	for (int i = sqrt(N); i >= 1; i--) {
		if (N%i == 0) {
			A = N / i;
			break;
		}
	}

	string a = to_string(A);
	cout << a.size() << endl;

}


Measured memory_bytes: 256