akhauriyash/Code-Regression huggingface dataset:
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
# from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var): sys.stdout.write(' '.join(map(str, var)) + '\n')
def out(var): sys.stdout.write(str(var) + '\n')
from decimal import Decimal
# from fractions import Fraction
# sys.setrecursionlimit(100000)
INF = float('inf')
mod = int(1e9) + 7


s=data()
t=data()
ans=INF
for i in range(len(s)-len(t)+1):
    cnt=0
    for j in range(len(t)):
        if s[i+j]!=t[j]:
            cnt+=1
    ans=min(ans,cnt)
out(ans)

Measured memory_bytes: 73068
#include <stdio.h>
int main() {
	int n, g, h, m, M = 0, i;
	scanf("%d", &n);
	for(i = 0; i < n; i++) {
		g = h;
		scanf("%d", &h);
		if(!i)
			m = 0;
		else if(h <= g)
			m++;
		else {
			M = M>m?M:m;
			m = 0;
		}
	}
	printf("%d", M>m?M:m);
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  int n = (int) s.size();
  vector<int> r(n), l(n);
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      if (s[i] == 'R') r[i] = 1;
      else r[i] = 0;
    } else {
      if (s[i] == 'R') r[i] = r[i - 1] + 1;
      else r[i] = 0;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (i == n - 1) {
      if (s[i] == 'L') l[i] = 1;
      else l[i] = 0;
    } else {
      if (s[i] == 'L') l[i] = l[i + 1] + 1;
      else l[i] = 0;
    }
  }
  vector<int> ans(n);
  for (int i = 0; i + 1 < n; i++) {
    if (s[i] == 'R' && s[i + 1] == 'L') {
      ans[i] = (r[i] + 1) / 2 + l[i + 1] / 2;
      ans[i + 1] = r[i] + l[i + 1] - ans[i];
      i++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " " ;
    cout << ans[i];
  }
  cout << endl;
  return 0;
}

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

int main() {
	int N;
  	cin>>N;
  	vector<int> a(N);
  	int ans=1;
  
  	for(int i=0;i<N;i++){
     	 cin>>a.at(i);
    }
  	
  	for(int i=0;i<N;i++){
     	 if(a.at(i)%2==0 &&a.at(i)%3!=0 &&a.at(i)%5!=0){
          	 ans=0;
         }
    }
  	
  	if(ans==0){
      cout<<"DENIED"<<endl;
    }
  	else{
     	cout<<"APPROVED"<<endl; 
    }
  	
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
ll dp[100005],a[100005],n;
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    for (int i=1;i<=n;++i) cin>>a[i];
    dp[1]=0;dp[2]=abs(a[1]-a[2]);
    for (int i=3;i<=n;++i) dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    cout<<dp[n];
    return 0; 
}

Measured memory_bytes: 1792
for i in range(input()):
	n = raw_input()
	c = 0
	while len(n) > 1:
		c += 1
		maxn = 0
		for i in range(1,len(n)):
			a = int(n[:i])
			b = int(n[i:])
			maxn = max(maxn,a*b)
		n = str(maxn)
	print c
	

Measured memory_bytes: 4216
s = input()
n = len(s)

t_list = []

for i in range(1<<(n-1)):
    t = ['' for _ in range(n)]
    for j in range(n):
        if (i >> j) & 1:
            t[j] = '+'
    t_list.append(t)

ans = 0

for i in t_list:
    formula = [x+y for x,y in zip(s,i)]
    formula = ''.join(formula)
    ans += eval(formula)
    
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
using namespace std;
typedef long long ll;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))


int cnt[100000];

int main(){
    
    int N; cin>>N;
    int sum=0;
    REP(i,N){
        int a,b; cin>>a>>b;
        sum+=a;
        sum%=86400;
        cnt[sum]++;
        sum+=b;
    }
    
    int ans=0;
    sum=0;
    REP(i,10801)sum+=cnt[i];
    REP(i,100000){
        ans=max(ans,sum);
        sum-=cnt[i%86400];
        sum+=cnt[(10801+i)%86400];
    }
    
    cout<<ans<<endl;
    
    return 0;
}




Measured memory_bytes: 640
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

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

using namespace std;
int main()
{
	int k;
	string s,ans;
	cin >> k >> s;
	if (s.size()<=k) ans=s;
		else ans=s.substr(0,k)+"...";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3048
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

struct UnionFind{
  VI par;
  VI rank;
  VL diff_weight;
  UnionFind(int n){
    par.resize(n);rank.resize(n);diff_weight.resize(n);
    rep(i,n){
      par[i]=i;
      rank[i]=0;
      diff_weight[i]=0;
    }
  }
  int root(int x){
    if(par[x]==x) return x;
    int r=root(par[x]);
    diff_weight[x]+=diff_weight[par[x]];
    return par[x]=r;
  }
  ll weight(int x){
    root(x);
    return diff_weight[x];
  }
  bool same(int x, int y){
    return root(x)==root(y);
  }
  void unite(int x, int y,ll w){
    w+=weight(x);w-=weight(y);
    x=root(x);y=root(y);
    if(x==y) return;
    if(rank[x]<rank[y]) swap(x,y),w=-w;
    if(rank[x]==rank[y]) rank[x]++;
    par[y]=x;
    diff_weight[y]=w;
  }
  ll diff(int x,int y){
    return weight(y)-weight(x);
  }
};

int main(){
  int N,M;
  cin>>N>>M;
  VL L(M),R(M),D(M);
  rep(i,M) cin>>L[i]>>R[i]>>D[i];
  UnionFind uf(N);
  int ans=1;
  rep(i,M){
    if(uf.same(L[i]-1,R[i]-1)){
      if(uf.diff(L[i]-1,R[i]-1)!=D[i]) ans=0;
    }else{
      uf.unite(L[i]-1,R[i]-1,D[i]);
    }
  }
  cout<<(ans?"Yes":"No")<<endl;
}

Measured memory_bytes: 6528
import numpy as np
import math

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

def isOK(minVal):
	tmpK=0
	for a in A:
		# math.ceil(a//minVal)-1
		tmpK+=((-(-a//minVal))-1)

	if tmpK <= K:
		return True
	else:
		return False

ok = max(A)
ng = 0

while (math.ceil(ok) != math.ceil(ng)):
	mid = (ok+ng) / 2
	if isOK(mid):
		ok = mid
	else:
		ng = mid
	#print(ok,ng)

print(math.ceil(ok))

Measured memory_bytes: 49208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i=0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
const ll INF = 1LL << 60;
//cout << fixed << setprecision(10);
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}

template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
	ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(all(a));
    ll ans = 1, th = 1;
    rep(i,18) th *= 10;
    rep(i,n){
    	if(a[i] == 0){
        	cout << 0 << endl;
            return 0;
        }
        if(ans*a[i] > th){
        	ans = -1;
            break;
        }
        ans *= a[i];
    }
    if(0 < ans && ans <= th) cout << ans << endl;
    else cout << -1 << endl;
}


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

int main(){
	int n;
	cin>>n;
	map<long long,int> a;
	long long x,b[n+1],ans=0;
	for(int i=1;i<=n;i++){
		cin>>b[i];
		a[b[i]]++;
	}
	sort(b+1,b+n+1);
	for(int i=n;i>=1;i--){
		int f=0,h=0;
		for(int j=0;;j++){
			if((1<<j)>b[i]){
				f=j;
				break;
			}
			if((1<<j)==b[i]){
				h=1;
			}
		}
		if(h){
			if(a[0]&&b[i]){
				a[0]--;
				a[b[i]]--;
				ans++;
			}
		}
		if(a[(1<<f)-b[i]]){
			a[(1<<f)-b[i]]--;
			if(a[b[i]]){
				a[b[i]]--;
				ans++;
			}else{
				a[(1<<f)-b[i]]++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 26752
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let n: usize = read();
    let k: usize = read();
    let r: u64 = read();
    let s: u64 = read();
    let p: u64 = read();
    let st: Vec<char> = read::<String>().chars().collect();
    let mut changed: Vec<bool> = (0..n).map(|_| false).collect();

    let mut ret = 0;
    for (i, &c) in (&st).into_iter().enumerate() {
        if i < k {
            if c == 'r' {
                ret += p;
            } else if c == 's' {
                ret += r;
            } else {
                ret += s;
            }
            changed[i] = true;
            continue;
        }

        if st[i - k] != c || !changed[i - k] {
            if c == 'r' {
                ret += p;
            } else if c == 's' {
                ret += r;
            } else {
                ret += s;
            }
            changed[i] = true;
        }
    }
    println!("{}", ret);
}


Measured memory_bytes: 2788
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin>>n;
	cout<<1000ll*(n/500)+5ll*(n%500/5)<<endl;
	
}






Measured memory_bytes: 256
def submit():
    h, w = map(int, input().split())
    n = int(input())
    alist = list(map(int, input().split()))

    color = [[0 for _ in range(w)] for _ in range(h)]
    cur = 1

    # 一筆書きする
    direction = 1
    for i in range(h):
        if direction == 1:
            j = 0
        else:
            j = w - 1

        while 0 <= j < w:
            if alist[cur - 1] <= 0:
                cur += 1          
            color[i][j] = cur
            alist[cur - 1] -= 1
            j += direction

        direction *= -1
                

    for c in color:
        print(" ".join(map(str, c)))


submit()

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

typedef long long ll;

const int N = 1e4 + 1;
vector<int> g[N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    int a = 0, b = 0, ba = 0;
    for(int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        for(int j = 1; j < s.size(); j++){
            if(s[j-1] == 'A' && s[j] == 'B') ans++;
        }
        if(s[0] == 'B' && s.back() == 'A') ba++;
        if(s.back() == 'A') a++;
        if(s[0] == 'B') b++;
    }
    int ab = ba;
    a -= ab;
    b -= ab;
    if(ab) {
        ans += ab-1;
        if(a) ans++, a--;
        if(b) ans++, b--;
        ans += min(a,b);
    } else {
        ans += min(a, b);
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<cmath> 
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(b<10){
		a=a*10+b;
	}
	else if(b<100){
		a=a*100+b;
	}
	else{
		a=a*1000+b;
	}
	if((int)sqrt(a)*(int)sqrt(a)==a){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {

	while (1) {
		int h;
		int dp[11][6] = {};
		
		int score = 0;

		cin >> h;
		if (h == 0) {
			break;
		}
		FOR(i, 1, h) {
			FOR(j, 1, 5) {
				cin >> dp[i][j];
			}
		}

		while (1) {
			int colum[6] = {};
			FOR(i, 1, h) {
				if (dp[i][1] == dp[i][2] && dp[i][2] == dp[i][3] && dp[i][3] == dp[i][4] && dp[i][4] == dp[i][5] && dp[i][1] != 0) {
					score += dp[i][1] * 5;
					colum[1]++;
					colum[2]++;
					colum[3]++;
					colum[4]++;
					colum[5]++;
					dp[i][1] = 0;
					dp[i][2] = 0;
					dp[i][3] = 0;
					dp[i][4] = 0;
					dp[i][5] = 0;
				}
				else if (dp[i][1] == dp[i][2] && dp[i][2] == dp[i][3] && dp[i][3] == dp[i][4] && dp[i][1] != 0) {
					score += dp[i][1] * 4;
					colum[1]++;
					colum[2]++;
					colum[3]++;
					colum[4]++;
					dp[i][1] = 0;
					dp[i][2] = 0;
					dp[i][3] = 0;
					dp[i][4] = 0;
				}
				else if (dp[i][2] == dp[i][3] && dp[i][3] == dp[i][4] && dp[i][4] == dp[i][5] && dp[i][2] != 0) {
					score += dp[i][2] * 4;
					colum[2]++;
					colum[3]++;
					colum[4]++;
					colum[5]++;
					dp[i][2] = 0;
					dp[i][3] = 0;
					dp[i][4] = 0;
					dp[i][5] = 0;
				}
				else if (dp[i][1] == dp[i][2] && dp[i][2] == dp[i][3] && dp[i][1] != 0) {
					score += dp[i][1] * 3;
					colum[1]++;
					colum[2]++;
					colum[3]++;
					dp[i][1] = 0;
					dp[i][2] = 0;
					dp[i][3] = 0;
				}
				else if (dp[i][2] == dp[i][3] && dp[i][3] == dp[i][4] && dp[i][2] != 0) {
					score += dp[i][2] * 3;
					colum[2]++;
					colum[3]++;
					colum[4]++;
					dp[i][2] = 0;
					dp[i][3] = 0;
					dp[i][4] = 0;
				}
				else if (dp[i][3] == dp[i][4] && dp[i][4] == dp[i][5] && dp[i][3] != 0) {
					score += dp[i][3] * 3;
					colum[3]++;
					colum[4]++;
					colum[5]++;
					dp[i][3] = 0;
					dp[i][4] = 0;
					dp[i][5] = 0;
				}

			}
			if (colum[1] == 0 && colum[2] == 0 && colum[3] == 0 && colum[4] == 0 && colum[5] == 0) {
				break;
			}

			FOR(i, 1, 5) {
				while (colum[i] > 0) {
					RFOR(j, h, 1) {
						if (dp[j][i] == 0) {
							dp[j][i] = dp[j - 1][i];
							dp[j - 1][i] = 0;
						}
					}
					colum[i]--;
				}
			}
		}
		

		cout << score << endl;
	}

	return 0;
}


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

#define ll long long
#define ull unsigned long long

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(void) {
    ll N;
    ll minimum = LONG_MAX;
    ll maximum = LONG_MIN;
    ll minCost = LONG_MAX;
    ll *a;
    cin >> N;
    a = new ll[N];
    for(ll i = 0;i < N;i++) {
        cin >> a[i];
        minimum = min(a[i], minimum);
        maximum = max(a[i], maximum);
    }
    for(ll i = minimum;i <= maximum;i++) {
        ll cost = 0;
        for(ll j = 0;j < N;j++) {
            ll temp = a[j] - i;
            cost += temp * temp;
        }
        minCost = min(minCost, cost);
    }
    cout << minCost << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int main() {
	int n;
	cin >> n;
	cout << "ABC" << n << endl;

	return 0;
}

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

int main() {
    int N;
    cin>>N;
    vector<ll> A(N), B(N);
    for(int i=0;i<N;++i){
        cin>>A[i]>>B[i];
    }
    sort(A.begin(), A.end());
    if(N%2==1){
        sort(B.begin(), B.end(), greater<ll>() );
        cout<<B[N/2] - A[N/2] + 1<<endl;
    }
    else{
        sort(B.begin(), B.end());
        cout<<(B[N/2]+B[N/2-1])-(A[N/2]+A[N/2-1])+1<<endl;
    }
}



Measured memory_bytes: 6376
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int k = scan.nextInt();
        int[] a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        System.out.println(a[k - 1]);
    }
}

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

signed main(){
	fastio
	int n;
	cin >> n;
	int a[n];
	for(auto &x : a) cin >> x;
	int ans = 0;
	for(int i = 0;i < n;i++){
		for(int j = i+1;j < n;j++){
			for(int k = j+1;k < n;k++){
				if(a[i]+a[j]<=a[k]||a[k]+a[j]<=a[i]||a[i]+a[k]<=a[j]||a[i]==a[j]||a[j]==a[k]||a[i]==a[k]) continue;
				ans ++;
			}
		}
	}
	cout << ans << "\n";

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define all(v) v.begin(), v.end() // sort(all(array))
#define INF 1000000000
#define mod 1000000007
using namespace std;
using ll = long long;
using vi = vector<int>; //vi array(要素数, 初期値)
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>; //vvi table(行数, vi(列数, 初期値))
using vvc = vector<vc>;
using vvs = vector<vs>;
using vvb = vector<vb>;

int main() {
    int x, y; cin >> x >> y;
    string ans = "No";
    
    rep(i, x + 1) {
        int cnt = 2 * i + 4 * (x - i);
        if (y == cnt) {
            ans = "Yes";
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3468
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e6+6;
const int mod = 1e9+7;
const int inf = 1e8;
ll ar[N];
void solve(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans = 0;
    for(int i=0;i<n;i++){
        cin>>ar[i];
    }
    for(int i=1;i<n;i++){
        ll trt = min((ar[i]-ar[i-1])*a,b);
        ans+=trt;
    }
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 2003;
int n, A, B, a[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n >> A >> B;
	for (int i = 1; i <= n; i++) cin >> a[i];
	if (n == 1) cout << abs(a[n] - B);
	else cout << max(abs(a[n] - B), abs(a[n] - a[n - 1]));
}


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

int main() {
    int N;
    cin >> N;

    int a=N, sum=0;

    while(a>0){
        sum+=a%10;
        a-=a%10;
        a/=10;
    }

    if(N%sum==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int main() {
    string s;
    cin >> s;
    int q;
    cin >> q;
    rep(i, q){
        string s1;
        cin >> s1;
        if(s1 == "print"){
            int a, b;
            cin >> a >> b;
            cout << s.substr(a, b - a + 1) << endl;
        }
        else if(s1 == "reverse"){
            int a, b;
            cin >> a >> b;
            string s2;
            s2 = s.substr(a, b - a + 1);
            std::reverse(s2.begin(), s2.end());
            for(int j = 0; j <= b - a + 1;j++){
                s.replace(a, b-a+1,s2);
            }
        }
        else if(s1 == "replace"){
            int a, b;
            cin >> a >> b;
            string s2;
            cin >> s2;
            s.replace(a, b-a+1, s2);

        }
    }
}


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

//155
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), dp[] = new int[n], length = 0;
        Arrays.fill(dp, Integer.MAX_VALUE);
        for (int i = 0; i < n; i++) {
            int tmp= sc.nextInt();
            if(i == 0){
                dp[0] = tmp;
            }else{
                if(dp[length] < tmp){
                    length++;
                    dp[length] = tmp;
                }else{
                    for(int j = 0; j <= length; j++){
                        if(dp[j] >= tmp){
                            dp[j] = tmp;
                            break;
                        }
                    }
                }
            }
        }
        System.out.println(length+1);
    }
}


Measured memory_bytes: 69380
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  ou(max(max(a*10+b+c,a+b*10+c),a+b+c*10));
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner kala=new Scanner (System.in);
        double D=kala.nextInt();
        
        double T=kala.nextInt();
        
        double S=kala.nextInt();
        
        double reach=D/S;
        
        if(reach<=T) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 35740
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	vector<long long> a(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	a.emplace_back(0);

	long long max_val = 1e18;
	vector<vector<long long>> dp(n+1, vector<long long>(2 , -max_val));
	dp[0][0] = 0;

	for (int i = 0; i < n; i++) {
		dp[i+1][0] = max({dp[i+1][0], dp[i][0] + a[i], dp[i][1] - a[i]});
		dp[i+1][1] = max({dp[i+1][1], dp[i][0] - a[i], dp[i][1] + a[i]});
	}

	// printf("n %d\n", n);
	// for (int i = 1; i < dp.size(); i++) {
	// 	printf("%2d: %5lld %5lld\n", i, dp[i][0], dp[i][1]);
	// }

	long long ans = dp[n][0];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6512
#include<stdio.h>
int main(void){
int i;
char str[10];
  
for(i=0;i<10;i++)
scanf("%s",str);

if(str[0]==str[1]||str[1]==str[2]||str[2]==str[3])
printf("Bad");
else
printf("Good");

return 0;
}

Measured memory_bytes: 128
import java.util.*;
// import java.util.stream.*;

public class Main {
  public static void main(String[] args) {
    Main main = new Main();
    System.out.println(main.solve());
  }

  int[] town = new int[4];

  public Main() {
    Scanner sc = new Scanner(System.in);
    try {
      for (int i = 0; i < 3; i++) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        town[--a]++;
        town[--b]++;
      }
    } finally {
      sc.close();
    }
  }

  String solve() {
    return any() ? "NO" : "YES";
  }

  boolean any() {
    for (int i = 0; i < 4; i++) if (town[i] == 3) return true;
    return false;
  }
}


Measured memory_bytes: 35536
import java.io.IOException;
import java.util.Scanner;


public class Main{
	public static void main(String args[]) throws IOException{
		Scanner bf = new Scanner(System.in);
		int N = Integer.parseInt(bf.nextLine());
		int[] ans = new int[80];
		for(int i=0; i<N; i++){
			for(int j=0; j<80; j++){
				ans[j] = 0;
			}

			String str1 = bf.nextLine();
			int len1 = str1.length();
			String str2 = bf.nextLine();
			int len2 = str2.length();
			if(len1 > 80 || len2 > 80){
				System.out.println("overflow");
				continue;
			}
			for(int k=0; k<len1; k++){
				ans[80-len1+k] = Integer.parseInt(""+str1.charAt(k));
			}
			for(int k=0; k<len2; k++){
				ans[80-len2+k] += Integer.parseInt(""+str2.charAt(k));
			}

			for(int k=79; k>0; k--){
				if(ans[k]>=10){
					ans[k] -= 10;
					ans[k-1]++;
				}
			}
			if(ans[0]>=10) System.out.println("overflow");
			else{
				boolean start = false;
				for(int j=0; j<80; j++){
					if(start) System.out.print(ans[j]);
					else if(ans[j] != 0){
						start = true;
						System.out.print(ans[j]);
					}
				}
				if(start) System.out.println();
				else System.out.println("0");
			}
		}
	}
}

Measured memory_bytes: 17304
N,M = map(int,input().split())
A = []
B = []
for _ in range(N):
  A.append(input())
for _ in range(M):
  B.append(input())
for a,b in zip(A,B):
  if b in a:
    flag = True
  else:
    flag = False
    break;
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
  string n;
  int x;
  x=0;
  cin >> n;
  for (int i=0; i<n.length(); i++){
     x=x+n[i]-48;
  }
   if(x%9==0)
  {
    cout<<"Yes"<<endl;
  }
  else
    cout<<"No"<<endl;
  return 0;
}

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

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

Measured memory_bytes: 256
s = gets.chomp
# s,t = gets.split.map(&:to_s)
# a = gets.split.map(&:to_i)

# s = gets.chomp.chars.uniq
# puts gets.chomp.chars.uniq.size != 1 ? "Yes" : "No"

p 7-(%w(SUN MON TUE WED THU FRI SAT SUN).index(s))

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	// debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, left, right)  (a).begin()+(left),(a).begin()+(right)	// left to (right-1)

int main() {
	string s;
	cin >> s;
	int len = s.size();
	int bcnt = 0;
	int lastw = 0;
	ll res = 0;
	FOR(i, 0, len - 1) {
		if (s[i] == 'B') {
			bcnt++;
		}
		else {
			lastw += bcnt;
			bcnt = 0;
			res += lastw;
		}
	}
	pv(res)
	return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <algorithm>

#define INF 1e9

using namespace std;

int N, M, R;
int r[9], G[201][201], res;
bool used[9];

void dfs(int c, int las, int dist) {
    if (c == R) {
        if (res > dist) { res = dist; }
        return ;
    }
    for (int i = 0; i < R; i++) {
        if (!used[i]) {
            used[i] = true;
            if (las == -1) { dfs(c+1, i, 0); }
            else { dfs(c+1, i, dist + G[r[las]][r[i]]); }
            used[i] = false;
        }
    }
}

int main() {
    cin >> N >> M >> R;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N ; j++) {
            G[i][j] = (i == j) ? 0 : INF;
        }
    }

    for (int i = 0; i < R; i++) {
        cin >> r[i]; r[i]--;
    }

    sort(r, r + R);

    for (int i = 0; i < M; i++) {
        int A, B, C;
        cin >> A >> B >> C;
        G[A-1][B-1] = G[B-1][A-1] = C;
    }

    // Warshall–Floyd Algorithm
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }

    res = INF;
    dfs(0, -1, 0);
    cout << res << endl;

    return 0;
}

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

int main() {
	int a,b;
	double d = 0,r = 0,f = 0;
	cin >> a >> b;
	d = a / b;
	r = a%b;
	f = 1.0 * a / b;
	printf("%.f %.f %.5lf",d,r,f);
	return 0;
}

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

int main() {
  int N,M,a,b;
  cin>>N>>M;
  int c[N]={};
  for(int i=0;i<M;i++){
    cin>>a>>b;
    c[a-1]++;
    c[b-1]++;
  }
  for (int i=0;i<N;i++)
  cout<<c[i]<<endl;
}
    
  

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    cin >> n;
    vll a(n);
    for(ll i = 0; i < n; i++) cin >> a[i];
    reverse(a.begin(), a.end());
    if(a[0] != 2) {
        cout << -1 << endl;
        return;
    }
    vll l(n + 1), r(n + 1);
    l[0] = r[0] = 2;
    for(ll i = 0; i < n; i++) {
        l[i + 1] = ((l[i] - 1) / a[i] + 1) * a[i];  // min multiple between l[i] and r[i]
        if(!(l[i] <= l[i + 1] && l[i + 1] <= r[i])) {   // multiple not found
            cout << -1 << endl;
            return;
        }
        r[i + 1] = r[i] / a[i] * a[i] + a[i] - 1;
    }
    cout << l[n] << ' ' << r[n] << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int n, k;
    while (cin >> n >> k)
    {
        if (n == 0 && k == 0)
        {
            break;
        }
        vector<int> s(n);
        rep(i, n) cin >> s[i];

        vector<ll> cum(n + 1, 0);
        rep(i, n)
        {
            cum[i + 1] += cum[i] + s[i];
        }
        ll ans = 0;
        rep(i, n + 1 - k)
        {
            ans = max(ans, cum[k + i] - cum[i]);
        }
        cout << ans << endl;
    }

    return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n;cin>>n;
    n--;
    vl c(n),s(n),f(n);
    rep(i,n)cin>>c[i]>>s[i]>>f[i];
    
    for(int start = 0;start <=n;start++){
        if(start == n){
            out(0);
            continue;
        }
        ll now = 0;
        for(int i = start;i<n;i++){
            if(now < s[i]){
                now = s[i] + c[i];
            }
            else{
                if(now % f[i] == 0){
                    now += c[i];
                }
                else{
                    now += f[i] - (now % f[i]);
                    now += c[i];
                }
            }
        }
        out(now);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll Maxn=2e5+10;
const ll Mod=1e9+7;
ll sum[Maxn],a[Maxn];
int main() {
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++)    cin>>a[i];
    for(ll i=1;i<=n;i++)    sum[i]=(sum[i-1]+a[i])%Mod;
    ll ans=0;
    for(ll i=1;i<=n-1;i++){
        ans=((ans+a[i]*(sum[n]-sum[i])%Mod)+Mod)%Mod;
    }
    cout<<ans%Mod;
    return 0;
}


Measured memory_bytes: 6740
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)
#include <iostream>
#include <vector>
#include <cstdlib>
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int main(){
ll n;cin>>n;
vl a(n);rep(i,n)cin>>a[i];
sort(a.begin(),a.end());
bool x=0;

ll ans=a[0];


for(int i=1;i<n;i++){
    if(a[0]==0)break;
    if(ans>1000000000000000000/a[i]){
        x=1;break;
    }
    else{ans=ans*a[i];}
}

if(x==1){cout<<-1<<endl;}
else{cout<<ans<<endl;}








}


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

using namespace std;

const double dis = 1e-8;
const double PI = 3.14159265358979323846264338328;

int a, b, x;
double res;

int main()
{
    scanf("%d %d %d", &a, &b, &x);
    double half = a*a*b/2;
    if (abs(half-x) < dis) {
        res = 45;
    } else if (half < x) {
        res = atan(2.0*(a*a*b-x)/a/a/a)/PI*180;
    } else if (half > x) {
        res = atan(a*b*b/2.0/x)/PI*180;
    }
    printf("%.10lf\n", res);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

using ipair = pair<int,int>;

int INF = 1e9+7;

using ipair = pair<int,int>;
bool operator>(const ipair a,const ipair b){return a.first > b.first;}

int mod = 998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){

  int N;
  cin >> N;

  int max_d = 0;
  vector<int> d(N);
  vector<int> cnt(N);

  // 入力
  rep(i, N){
    int tmp_d;
    cin >> tmp_d;
    d[i] = tmp_d;;
    cnt[tmp_d]++;
    max_d = max(max_d, tmp_d);
  }

  // コーナーケース
  if(d[0]!=0 || cnt[0]!=1){
    cout << 0 << endl;
    return 0;
  }

  for(int i=1; i<=max_d; i++){
    if(d[i] == 0){
      cout << 0 << endl;
      return 0;
    }
  }

  // カウント
  mint ans(1);
  for(ll i=1; i<=max_d; i++){
    ans = ans * mint(cnt[i-1]).pow(cnt[i]);
  }

  cout << ans.x << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INF 1000000000000 //10^12

int main(){
    ll n,m;

    cin >>n>>m;
    map<ll,ll> sc;
    ll ans =0;
    REP(i,m){
        ll s,c;
        cin >>s;
        cin >>c;
        if(sc.count(s) && sc.at(s)!=c || n>1 && s==1 && c==0){
            cout << -1 <<endl;
            return 0;
        }
        sc.emplace(s,c);
    }
    if(m==0 && n==1){
        cout <<0<<endl;
        return 0;
    }
    for(ll i=1; i<=n;i++){
        if(sc.count(i))
            ans+=sc.at(i)*pow(10,n-i);
        else
            if(i==1)
                ans+=pow(10,n-1);
        
    }
    cout <<ans<<endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#include <math.h>
#include <iomanip>
#include <fstream>
#include <random>
#include <set>
#include <queue>
#include <complex>
#include <stack>
#include <numeric>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
using namespace std;
int main() {
    //cin.tie(0);
    //ios::sync_with_stdio(false);
   // std::ifstream in("input.txt");std::cin.rdbuf(in.rdbuf());
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    
    
    int ans=0;
    int hata=0;
    ans+=(a[2]-a[0])/2;
    ans+=(a[2]-a[1])/2;
    if((a[2]-a[0])%2==0){a[0]=a[2];}else{a[0]=a[2]-1;hata++;}
    if((a[2]-a[1])%2==0){a[1]=a[2];}else{a[1]=a[2]-1;hata++;}
    if(hata==2){cout<<ans+1<<endl;return 0;}
    if(hata==1){cout<<ans+2<<endl;return 0;}
    if(hata==0){cout<<ans<<endl;return 0;}
    return 0;
}

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

namespace AtCoder
{
    class Program
    {
        private static long mod = 1000000007;
        static void Main(string[] args)
        {
            //var k = int.Parse(ReadLine());
            var line = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();

            var n = line[0];
            var x = line[1];
            var t = line[2];

            WriteLine(n / x * t + (n % x == 0 ? 0 : t));
        }
    }
}

Measured memory_bytes: 28196
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <unordered_map>

using namespace std;

int main()
{
  int N;
  cin >> N;
  unordered_map<int, bool> A;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    if (A.find(a) == A.end()) {
      A[a] = true;
    } else {
      A.erase(a);
    }
  }
  cout << A.size() << endl;
  /*
  sort(A.begin(), A.end());

  int answer = 0;
  int i = 0;
  while (i < N) {
    int now = 0;
    for (int j = i + 1; j < N and A[j] == now; ++j);
    answer += j - i
  }
  */

  return 0;
}


Measured memory_bytes: 4388
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    r,D,x = map(int, input().split())
    res = [0]*11
    res[0] = x
    for i in range(1,11):
        res[i] = res[i-1]*r-D
        print(res[i])


if __name__ == '__main__':
    main()

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;
int main(){

    int n,m;
    cin >> n >> m;
    vector<int> v(n);
    rep(i,n) v[i]=i+1;
    vector<vector<int>> l(n+1);
    int a,b;
    rep(i,m){
        cin >> a >> b;
        l[a].push_back(b);
        l[b].push_back(a);
    }

    int sum=0;
    bool ans;
    do{
        if(v[0]!=1) break;
        int p=1;
        rep2(i,1,n){
            ans=false;
            rep(j,l[p].size()){
                if(v[i]==l[p][j]){
                    ans=true;
                    p=v[i];
                    break;
                }
            }
            if(!ans) break;
        }
        if(ans) sum++;
    }while(next_permutation(v.begin(),v.end()));

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdio>
#include<utility>
#include<set>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
#define all(L) L.begin(),L.end()
using ll=long long;
#define RO 1
#define SI 2
#define PA 3

int N,K;
string S,T;

void dfs(int m,int bits,int &count){
    if(m>N) return;
    if(bits==0b111) count++;
    dfs(10*m+7,bits|0b100,count);
    dfs(10*m+5,bits|0b010,count);
    dfs(10*m+3,bits|0b001,count);
}

int main(){
    int n,k;cin>>n>>k;
    vector<char> D(k);
    rep(i,0,k) cin>>D[i];
    int ans=n;
    bool flag=true;
    while(flag){
        flag=false;
        string s=to_string(ans);
        int m=s.size();
        rep(i,0,k){
            rep(j,0,m){
                if(D[i]==s[j]){
                    flag=true;
                    break;
                }
            }
            if(flag) break;
        }
        if(flag) ans++;
    }
    cout<<ans<<endl;
    return 0;
}   




Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new java.util.Scanner(System.in);

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

		StringBuilder sb = new StringBuilder();

		while (true) {
			int n = Integer.parseInt(br.readLine());
			if (n==0) break;
			int[] s = new int[n];

			String[] dataset = br.readLine().split(" ");

			for (int i = 0; i < n; i++) {
				s[i] = Integer.parseInt(dataset[i]);
			}
			int goukei = 0;

			for (int i : s) {
				goukei += i;
			}
			double m = (double)goukei / (double)n;

			double alfa2 = 0.0;

			for (int i : s) {
				alfa2 += (i - m) * (i - m);
			}

			alfa2 = alfa2 / n;

			double alfa = Math.sqrt(alfa2);
			System.out.println(alfa);
		}
	}

}

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

int64_t mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> eigyo(N, vector<int>(10));
    for (int i = 0; i < N; i++)
        for (int j = 0; j < 10; j++)
            cin >> eigyo[i][j];

    vector<vector<int>> rieki(N, vector<int>(11));
    for (int i = 0; i < N; i++)
        for (int j = 0; j < 11; j++)
            cin >> rieki[i][j];
    int64_t ans = -mod;
    for (int i = 1; i < (1 << 10); i++)
    {
        bitset<10> bt(i);
        int64_t tmp = 0;
        for (int j = 0; j < N; j++)
        {
            int count = 0;
            for (int k = 0; k < 10; k++)
            {
                if (bt.test(k) && eigyo[j][k])
                    count++;
            }
            tmp += rieki[j][count];
        }
        ans = max(ans, tmp);
    }
    cout << ans;
}

Measured memory_bytes: 256