akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
int lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}

int main()
{
	int A=read(),B=read();
	string s;
	cin>>s;
	int cnt=0,pos=0;
	while(s.find('-',pos+1)!=string::npos)
	{
		pos=s.find('-',pos+1);
		cnt++;
	}
	puts((A==s.find('-') && B==s.size()-s.find('-')-1 && cnt==1)?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;


int dp[10001]={};

int main(){
	int N,W,v[110]={},w[110]={};
	cin>>N>>W;
	rep(i,0,N) cin>>v[i]>>w[i];
	rep(i,0,N){
		rep(j,w[i],W+1)
		/*for(int j=W;j>=w[i];j--)*/{
			dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
		}
	}
	o(dp[W]);
}

Measured memory_bytes: 1204
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	rep(i,n)cin>>v[i];
	
	int m;
	cin>>m;
	vector<int> mp(m);
	vector<pii> call(m);
	rep(i,m){
		int b,c;
		cin>>mp[i]>>b>>c;
		b--,c--;
		call[i] = pii(b,c);
	}
	
	bool dp[100][100][10];
	memset(dp,0,sizeof(dp));
	
	rep(i,n){
		rep(j,mp.size()){
			if(v[i]==mp[j]){
				dp[i][i][j]=true;
			}
		}
	}
	
	for(int width = 2; width<=n; width++){
		for(int l = 0; l<n; l++){
			int r = l+width-1;
			if(r>=n)continue;
			for(int i=0;i<m;i++){
				int x,y;
				tie(x,y) = call[i];
				for(int p=l; p<=r-1; p++){
					dp[l][r][i] |= (dp[l][p][x] & dp[p+1][r][y]);
				}
			}
		}
	}
	if(dp[0][n-1][0])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 10000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

vint pos(5);
int k;
bool check=true;

int main(){
    string s;
    cin>>s;
    rep(i,s.length()){
        if(s[i]=='1')s[i]='9';
        else if(s[i]=='9')s[i]='1';
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int w,h,x,y,r;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	if(w<(x+r)||h<(y+r)||0>(x-r)||0>(y-r)){
		printf("No\n");
	}else{printf("Yes\n");}
	return 0;
}

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

int main(void) {
	int n, w;
	cin >> n >> w;
	long long int dp[n+1][w+1];
	for (int i = 0; i <= w; i++) {
		dp[0][i] = 0;
	}
	for (int i = 1; i <= n; i++) {
		long long int weight, value;
		cin >> weight >> value;
		for (int j = 0; j <= w; j++) {
			if (weight > j) {
				dp[i][j] = dp[i-1][j];
			}
			else {
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-weight] + value);
			}
		}
	}
	cout << dp[n][w];
}

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

using namespace std;
using ll = long long;

////cout << std::fixed << std::setprecision(15) << y << endl;

int main() {
    ll n = 0;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n);
    for(int i = 0;i < n;i++)cin >> a[i];
    for(int i = 0;i < n;i++)cin >> b[i];
    for(int i = 0;i < n;i++)cin >> c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll sum = 0;
    for(ll i = 0;i < n;i++){
        auto ai = lower_bound(a.begin(),a.end(),b[i]);
        ll aa = ai - a.begin();
        auto ci = upper_bound(c.begin(),c.end(),b[i]);
        ll ca = c.end() - ci;
        sum += aa * ca;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 5632
s = input()
k = int(input())

slist = list(s)
i = 0
count = 0
while slist[i] == "1":
    count += 1
    i += 1
    if i >= len(slist):
        break
    
if count >= k:
    print(1)
else:
    print(slist[i])

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


#define lp(i, n)         for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)     for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)     for(int i=(j);i>=(int)(n);--i)
#define sci(a)	scanf("%d",&a)
#define scll(a)	scanf("%lld",&a)
#define scii(a, b)	scanf("%d%d",&a, &b)
#define pri(a)	printf("%d\n",a)
#define prll(a)	printf("%lld\n",a)
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)


const double eps = 1e-8;

typedef  long long ll;

const ll mod = 1e9+7;

const int inf = 1<<30;
const int maxn = 1000500;//2e5+5;

//template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
//    return out << "(" << a.x << ", " << a.y << ")";
//}
//
//template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
//    out << "[";
//    forn(i, sz(v)) {
//        if(i) out << ", ";
//        out << v[i];
//    }
//    return out << "]";
//}



int n;
int a[maxn];
ll d;
vector<int> ans;

char s[maxn];

int f[10];

int norm(int x){
    x %= n;
    if(x < 0) x += n;
    return x;
}


inline void err(){
    puts("NO"); exit(0);
}

bool dp[1000500], vs[1000500];
bool rec(int n){
    if(n < 0) return 0;
    if(n <= 3) return 1;
    bool &ret = dp[n];
    if(vs[n]) return ret;
    vs[n] = 1;
    if(!rec(n-1) || !rec(n-2) || !rec(n-3))
        ret = 1;
    else
        ret = 0;
    return ret;
}
char st[maxn];
void solve() {
    int n; sci(n);
    set<string> s;
    lp(i,n){
        scanf("%s",st);
        s.insert(st);
    }
    pri(s.size());
}


int main(){
 //   freopen("in.txt","r",stdin);
    int tc = 1;
    //sci(tc);
    lp(tt,tc){
  //      printf("Case #%d: ",tt+1);
        solve();
    }
}

Measured memory_bytes: 19372
#include <iostream>

int main()
{
	int s;
	std::cin >> s;
//	int a[1000001];
	int a[100000];

	a[1] = s;
	for (int i = 2; i < 1000001; i++) {
		if (a[i-1] % 2 == 0) {//even
			a[i] = a[i - 1] * 0.5;
		}
		else {//odd
			a[i] = 3 * a[i - 1] + 1;
		}
//		std::cout << i << " " << a[i] << std::endl;
		for (int j = 1; j < i ; j++) {
			if (a[i] == a[j]) {
				std::cout << i;
				goto OUT;
			}
		}
	}

OUT:
	int i = 0;
}

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


int main() {
int n,sum = 0;
cin >> n;
vector<int>v(n);
 vector<int>p(n);

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

for(int i = 0;i < n;i++){
  if((v[i]-p[i] > 0)){
    sum += (v[i]-p[i]);
  }
}


cout << sum <<endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int MAX = 1001;

typedef struct{
  int x,y;
} Point;

int main(){
  int T;

  cin >> T;
  while(T--){
    int dist = 0;
    int x = 0,y = 0;
    Point p,q;
    p.x = p.y = 0;

    while(cin >> q.x >> q.y){
      if(q.x == 0 && q.y == 0) break; 
      x += q.x; y += q.y;

      if(dist < (x*x+y*y)){
	p.x = x;
	p.y = y;
	dist = x*x+y*y;
      }
      else if(dist == (x*x+y*y) && p.x < x){
	p.x = x;
	p.y = y;
	dist = x*x+y*y;
      }

    }
    cout << p.x << " " << p.y << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
//using Graph = vector<vector<pair<ll,ll>>>;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};
const ll INF=1e10;

int main(){
    ll n; cin>>n;
    vector<vector<ll>>f(n,vector<ll>(10));
    rep(i,n){
        rep(j,10){
            cin>>f[i][j];
        }
    }
    vector<vector<ll>>p(n,vector<ll>(11));
    rep(i,n){
        rep(j,11)cin>>p[i][j];
    }
    ll ans=-INF;
    ll mx=0;
    for(int tmp=1;tmp<(1<<10);tmp++){
        bitset<10>b(tmp);
        mx=0;
        rep(i,n){
            string s="";
            rep(j,10){
                s+=to_string(f[i][j]);
            }
            bitset<10>S(s);
            ll num=(S&b).count();
            mx+=p[i][num];
        }
        ans=max(ans,mx);
    }
    cout<<ans<<endl;
}











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

int main() {
    int n, x;
    while (cin >> n >> x, n) {
        int ans = 0;
        for (int i = 1; i <= n; ++i) {
            for (int j = i + 1; j <= n; ++j) {
                for (int k = j + 1; k <= n; ++k) {
                    if (i + j + k == x) ans++;
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<set>
#include<iomanip>
#include<string.h>
#include<iterator>
#include<queue>
//#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
#define ll long long
#define inf 244000000000000000
#define mod 1000000007
#define endl '\n'
ll qpow(ll base, ll n)
{
    ll res = 1;
    while (n)
    {
        if (n & 1)res =res*base%mod;
        base =base*base%mod;
        n >>= 1;
    }
    return res;
}
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll n;
    cin >> n;
    if (n <= 1) { puts("0"); return 0; }
    ll t = qpow(10, n);
    ll t2 = 2*qpow(9, n)%mod;
    ll t3 = qpow(8, n);
    ll ans = (t - t2 + mod) % mod;
    ans =(ans + t3)% mod;
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N, K;
  cin >> N >> K;
  
  double coin_prob=0;
  for(int i=1; i<=N; i++){
    if(i>=K){
      // (The pip of the dice) >= K ---> This game will be terminated.  
      coin_prob+=1;
    }
    else{
      // (The pip of the dice) < K ---> The player tosses a coin.
      double x=log2((double)K/i);
      int time=ceil(x);
      coin_prob+=pow(0.5, (double)time);
    }
  }
  double ans=(double)coin_prob/N;
  cout << fixed << setprecision(12) << ans <<endl;
}

Measured memory_bytes: 256
N, M = map(int,input().split())
A = [str(input()) for _ in range(N)]
B = [str(input()) for _ in range(M)]

res = "No"

for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j:j+M] == B[0]:
            for k in range(1,M):
                if A[i+k][j:j+M] == B[k]:
                    pass
                else:
                    break
            else:
                res = "Yes"
                break

print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;cin>>s;
  int n=s.size();
  map<int,int>f;
  f[0]=1;
  int mod=0,cur=1,ans=0;
  for(int i=n-1;i>=0;i--)
  {
    mod=(mod+cur*(s[i]-'0'))%2019;
    cur=(cur*10)%2019;
    ans+=f[mod];f[mod]++;
  }cout<<ans;
  return 0;
}


Measured memory_bytes: 3740
// file creato da gio il 2020-09-14 17:13:19.374937

#include <bits/stdc++.h>

#ifdef FAST
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#endif

#define MOD 1000000007
#define S second
#define F first
#define PB push_back
#define ll long long 

using namespace std;


#define MN 200000
int unf[MN];
int sub[MN];

int find(int a){
    if(a==unf[a]) return a;
    else return unf[a]=find(unf[a]);
}

void conc(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)return;
    if(sub[a]<sub[b])swap(a,b);
    sub[a]+=sub[b];
    unf[b]=a;
}

int main(){
	//freopen("output","w",stdout);
	//freopen("input","r",stdin);
#ifdef FAST
	ios::sync_with_stdio(0);
  	cin.tie(0);
#endif

	int n,q;
	cin >> n>>q;
    for(int i=0;i<n;i++){unf[i]=i;sub[i]=1;}
    for(int i=0;i<q;i++){
        int a,b,c;
        cin >>a>>b>>c;
        if(a)
            cout <<(find(b)==find(c)?1:0)<<endl;
        else
            conc(b,c);

    }

}


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

using namespace std;


long long f(long long A, long long B, long long C) {
    return A * B * (C % 2);
}

int main() {
    string x, y;
    cin >> x;
    cin >> x >> y;
    for (int i = 0; i <= x.size(); i++) {
        string a = x.substr(0, i);
        a += y;
        if( a.substr(0, x.size()) == x && a.substr(a.size()-y.size()) == y){
            cout << i + y.size() << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse = True)

def f():
    for i in range(M):
        if sum(A) / (4 * M) > A[i]: return False
    return True

if f():
    print("Yes")
else:
    print("No")

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

const int INF = 0x3f3f3f3f, MAX_H = 1005, MAX_W = 1005;
const int MOD = 1e9+7;
using ll = long long;

int H, W;
char g[MAX_H][MAX_W];
int dp[MAX_W];

void solve()
{
	memset(dp, 0, sizeof(dp));
	for(int i=0; i<= W; ++i){
		if(g[1][i]=='#') break;
		dp[i] = 1;
	}
	for(int i=2; i<=H; ++i)for(int j=1; j<=W; ++j){
		if(g[i][j] == '#') dp[j]=0;
		else{
			if(j>1) dp[j] = (dp[j]+dp[j-1])%MOD;
		}
	}
    cout << dp[W] << endl;
}

int main()
{
	cin >> H >> W;
	for(int i=1;i<=H;++i)for(int j=1;j<=W;++j){
		cin >> g[i][j];
	}
	solve();
	return 0;
}

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

using namespace std;

const float ex = 0.0001;
int main()
{
long long int a,b,c;
cin >> a >> b >> c;

c-=a+b;
if (c<=0){ cout << "No"; return 0;}

c*=c;

if (c> 4*a*b) cout << "Yes"; else cout << "No";

/*
cout << sqrt(a) << " " << sqrt(b) << " " << sqrt(c) << "\n";
cout << sqrt(a) + sqrt(b) << "\n";
*/
//if (  (sqrt(a) + sqrt(b) - sqrt(c))>ex       cout << "No"; else cout << "Yes";


}




















/*
8 9
1 3
1 2
2 3
3 4
4 5
5 6
4 6
6 7
6 8





*/


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

const int MOD = 1e9 + 7;

void ModSum(int& x, int y) {
    x += y;
    if (x >= MOD) {
        x -= MOD;
    }
    if (x < 0) {
        x += MOD;
    }
}

void ModMul(int& x, int y) {
    x = (1LL * x * y) % MOD;
}

int GetBinaryPow(int x, int pw) {
    int r = 1;
    while (pw > 0) {
        if (pw & 1) {
            ModMul(r, x);
        }
        ModMul(x, x);
        pw >>= 1;
    }
    return r;
}

int GetInv(int x) {
    return GetBinaryPow(x, MOD - 2);
}

const int MAX_FACT = 3e5;

int fact[MAX_FACT];
int invFact[MAX_FACT];

void BuildFact() {
    fact[0] = 1;
    for (int i = 1; i < MAX_FACT; ++i) {
        fact[i] = fact[i - 1];
        ModMul(fact[i], i);
    }
    for (int i = 0; i < MAX_FACT; ++i) {
        invFact[i] = GetInv(fact[i]);
    }
}

int GetC(int n, int k) {
    if (k > n) {
        return 0;
    }
    int r = fact[n];
    ModMul(r, invFact[n - k]);
    ModMul(r, invFact[k]);
    return r;
}

int GetCount(int fx, int fy, int tx, int ty) {
    int dx = tx - fx;
    int dy = ty - fy;
    return GetC(dx + dy, dx);
}

int main() {
    BuildFact();

    int h, w, a, b;
    scanf("%d%d%d%d", &h, &w, &a, &b);

    int result = GetCount(0, 0, h - 1, w - 1);
    for (int i = 0; i < b; ++i) {
        int curResult = GetCount(0, 0, h - a - 1, i);
        ModMul(curResult, GetCount(h - a, i, h - 1, w - 1));

        ModSum(result, -curResult);
    }

    printf("%d\n", result);

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int gcd(int a, int b)
{
    return b ? gcd(b % a, b) : a;
}

int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    int count = 1;
    vector<int> c;
    while(count < 101){
        if(a % count == 0 && b % count == 0){
            c.push_back(count);
        }
        count++;
    }
    cout << c[c.size() - k] << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
import numpy as np

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
a = na()
f = 1
cnt = 0
for ai in a:
    if ai == f:
        f += 1
        cnt += 1
if cnt == 0:
    print(-1)
else:
    print(n - cnt)

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

int n,m,ans;
vector<int> visit;
vector<set<int>> adj;

void dfs(int i){
  visit[i]=1;
  for(int a:adj[i])if(visit[a]==0)dfs(a);
}

int main(){
  cin>>n>>m;
  visit.resize(n+1);
  adj.resize(n+1);
  for(int i=0; i<m; ++i){
    int x,y,z; cin>>x>>y>>z;
    adj[x].insert(y);
    adj[y].insert(x);
  }

  for(int i=1; i<=n; ++i){
    if(visit[i]==0){
      ++ans;
      dfs(i);
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 17792
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

//std out
template<typename T>
void print_container(const vector<T> vals) {
    REPinit(i, 0, vals.size() - 1) cout << vals.at(i) << " ";
    cout << vals.back();
}


bool judge(int a, int b, int c) {
    if ((a > b && b > c) || (a < b && b < c)) return true;
    return false;
}

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

    string s, t;
    cin >> s >> t;

    int ans = 0;
    REPinit(i, 0, 3) ans += (s[i] == t[i]);
    cout << ans;

    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include <stdio.h>
#include<string>
using namespace std;
int a,z,j,ans;
int main() {
	while (cin>>a&&a!=0)
	{
		ans = 0;
		for (int i = 1; i < a / 2+1; i++) {

			z = a;
			j = i;
			while (1) {
				z -= j;
				if (z == 0){ans++; break;
				}
				else if (z < 0)break;

				j++;
			}
		}

		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
int kaizyo(int n){
    int res=1;
    while(n>=1){
        res*=n;
        n--;
    }
    return res;
}
int main(){
    int N;cin>>N;
    vector<int>A(N);
    vector<int>B(N);
    for (int i=0;i<N;i++)cin>>A[i];
    for(int i=0;i<N;i++)cin>>B[i];
    int count=N-1;
    int res=0;
    for(int i=0;i<N;i++){
        res+=kaizyo(count)*(B[i]-A[i]);
        //cout<<res<<endl;
        count--;
        for(int j=0;j<N;j++){
            if(A[j]>A[i])A[j]--;
            if(B[j]>B[i])B[j]--;
        }
        
        
    }
    cout<<abs(res)<<endl;


}

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

int x[4] = {1, 1, -1, -1};
int y[4] = {1, -1, 1, -1};
string c = "W_S";

int main(){
  int n; cin >> n;
  string ss; cin >> ss;
  vector<int> s;
  for (int i = 0; i < n; i++) {
    int k;
    if (ss[i] == 'o') k = 1;
    else k = -1;
    s.push_back(k);
  }

  for (int p = 0; p < 4; p++) {
    vector<int> v(n+1, 0);
    v[0] = x[p]; v[1] = y[p];
    for (int i = 1; i < n; i++) {
      v[i+1] = v[i-1] * v[i] * s[i];
    }
    if (v[n] == v[0] && v[n-1] == v[1] * v[0] * s[0]) {
      for (int i = 0; i < n; i++) {
        printf("%c", c[v[i]+1]);
      }
      printf("\n");
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}


Measured memory_bytes: 1392
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
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; }
ll gcd(ll a, ll b){
    if(a < b)  swap(a,b);
    if(a%b==0) return b;
    else return gcd(b,a%b);
}
ll ngcd(vector<ll> a){
    ll res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
ll nlcm(vector<ll> numbers) {
    ll res;
    res = numbers[0];
    for (ll i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}
ll nCr(ll n, ll r){
    ll a = 1;
    ll b = 1;
    rep(i,r){
        a *= n - i;
        b *= r - i;
        ll c = gcd(a,b);
        a /= c;
        b /= c;
    }
    return a/b;
}
ll max(ll a,ll b){
    if(a > b) return a;
    else return b;
}
int main(){
    cout << fixed << setprecision(10);
    int n,p;
    cin >> n >> p;
    int a = 0, b = 0;
    rep(i,n){
        int x;
        cin >> x;
        if(x%2 == 0) a++;
        else b++;
    }
    ll ans = 0;
    if(p == 0){
        rep(i,b+1){
            if(i%2 != 0) ans += nCr(b,i);
        }
        cout << max(ans,1LL) * (1LL<<a) << endl;
    }else{
        rep(i,b+1){
            if(i%2 == 0) ans += nCr(b,i);
            //cout << nCr(n,i) << endl;
        }
        if(b == 0){
            cout << 0 << endl;
            return 0;
        }
        // cout << "roop end" << endl;
        // cout << ans << endl;
        // cout << (1LL<<a) << endl;
        cout << ll(max(ans,1LL)) * (1LL<<a) << endl;
    }
    return 0;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw				"\n"
int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	cin>>n;
	ll arr[n];ll lala[n];
	for(auto &i:arr){
		cin>>i;
		lala[x++]=i;
	}
	sort(arr,arr+n);
	
	for(ll i=0;i<n;i++){
		if(arr[n-1]==lala[i])cout<<arr[n-2]<<nw;
		else cout<<arr[n-1]<<nw;
	}

}

Measured memory_bytes: 6792
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;

int main(){
  int n;
  cin>>n;
  int x[n],y[n];ll h[n];
  rep(i,n){
    cin>>x[i]>>y[i]>>h[i];
    }
  rep(nx,101)rep(ny,101){
    ll memo[n];
    ll nh =0;
    bool f = true;
    rep(i,n){
      int dis = abs(x[i]-nx)+abs(y[i]-ny);
      memo[i]=dis;
      if(h[i]!=0){
      nh = h[i]+dis;}
    }
    rep(i,n){
      if(h[i]!=max(nh-memo[i],(ll)0)){
        f=false;break;
      }
    }
    if(f){
    cout<<nx<<" "<<ny<<" "<<nh<<endl;
    return 0;
    }
  }  

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


int main(){
    LL n;
    cin >> n;
    LL ans = n+1;
    for(LL i = 1; i*i <= n; ++i){
        if(n % i != 0) continue;
        ans = min(ans, i + n/i - 2);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    //cout << s.substr(5, 1);
    if (stoi(s.substr(5, 1)) == 1) {
        cout << "TBD";
    } else if (stoi(s.substr(6, 1)) > 4) {
        cout << "TBD";
    } else {
        cout << "Heisei";
    }   
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		int[] a = new int[26];
		for(int i = 0 ; i < n ; i++) {
			char c = s.charAt(i);
			a[(int)(c - 'a')] = 1;
		}
		for(int i = 0 ; i < 26 ; i++) {
			if(a[i] == 0) {
				System.out.println((char)(i + 'a'));
				return;
			}
		}
		System.out.println("None");
	}
}

Measured memory_bytes: 25684
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<queue>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;

int main(){

	long A, B; cin >> A >> B;
	long res = 0;

	if (B - A == 0) { cout << A; return 0; }
	if (B - A == 1) { cout << (A ^ B); return 0; }

	if (A % 2 == 1) { res ^= A; A++; }
	if (B % 2 == 0) { res ^= B; B--; }

	res ^= ((B - A + 1) % 4) / 2;

	cout << res << endl;
}

Measured memory_bytes: 256
//  IT'S NEVER TOO LATE...

		    #include <bits/stdc++.h>
			#include <complex>
		    #define ll long long

			#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
			#define forn(i, n) fore(i, 0, n)
			#define fori(i, l, r) fore(i, l, (r) + 1)
			#define sz(v) int((v).size())
			#define all(v) (v).begin(), (v).end()
			#define pb push_back
			#define mp make_pair
		    #define ff first
		    #define ss second
			#define inf 1e9
		    
			#define C complex<int>
			#define X real()
			#define Y imag()

		    using namespace std; 

		    const double PI = atan(1)*4;

		    const int mod=1e9+7;


		    bool isprime(int n)
		    {
		        for(int i=2;i*i<=n;i++)
		            if(n%i==0)
		                return false;
		        return true;
		    }
		     
		    bool comp(pair<double,int> a, pair<double,int> b)
		    {
		    	if( b.ff == a.ff )
		    		return a.ss < b.ss ;
		    	return b.ff < a.ff ;
		    }

		    int modpow(int b,int p,int m)
		    {
		    	if(p==0) return 1%m;
		    	if(p%2) return (b*modpow(b,p-1,m))%m;
		    	int u=modpow(b,p/2,m);
		    	return (u*u)%m;
		    }

		    vector<int> ar[100005];
		    int vis[100005],from[100005];
		    double dis[100005];
		    
		     
		/*    void dikstra(int s,int n)
		    {
		    	forn(i,n+3)
		    	{
		    		dis[i]=inf;
		    		vis[i]=0;
		    		from[i]=-1;
		    	}

		    	dis[s]=0;
		    	priority_queue<pair<int,int>> q;
		    	q.push({0,s});
		    	from[s]=s;

		    	while(!q.empty())
		    	{
		    		pair<int,int> a;
		    		a=q.top();
		    		q.pop();
		    		//cout<<a.ss<<" ";

		    		if(vis[a.ss]) continue;
		    		vis[a.ss]=1;

		    		for(pair<int,int> b:ar[a.ss])
		    		{
		    			if(dis[b.ff]>dis[a.ss] + b.ss)
		    			{
		    				dis[b.ff]=dis[a.ss] + b.ss;
		    				from[b.ff]=a.ss;
		    				q.push({-dis[b.ff],b.ff});
		    			}
		    		}
		    	}
		    }*/


		    int main()
		    {
		    	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		     
		    	#ifndef ONLINE_JUDGE
		        freopen("input.txt","r", stdin);
		        freopen("output.txt", "w", stdout);
		        #endif
		     
		    	int tt=1;
		    	//cin>>tt;
		    	
		    	while(tt--)
		    	{
		    		int n;
		    		cin>>n;

		    		string s;

		    		int ac=0,wa=0,tle=0,re=0;

		    		forn(i,n)
		    		{
		    			cin>>s;
		    			if(s=="AC")
		    				ac++;
		    			else
		    				if(s=="WA")
		    					wa++;
		    				else
		    					if(s=="TLE")
		    						tle++;
		    					else
		    						re++;
		    		}

		    		cout<<"AC x "<<ac<<"\n"<<"WA x "<<wa<<"\n"<<"TLE x "<<tle<<"\n"<<"RE x "<<re<<"\n";
		    	}

		    	cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";

		    	return 0;
		    }
		    				//              NOW IT'S TIME TO WAKE UP...

Measured memory_bytes: 6192
n,x = map(int, input().split())
l = [int(i) for i in input().split()]

a = [0]*(n+1)
for i in range(len(l)):
    a[i+1] = a[i] + l[i]

ans = 0
for i in a:
    if i <= x:
        ans += 1
    else:
        break

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

int main() {

  int r, c, sum = 0, allsum = 0;
  int i, j;
  int a[101][101];
  scanf("%d %d", &r, &c);

  for(i = 0; i < 101; i++) {
    for(j = 0; j < 101; j++) {
      a[i][j] = 0;
    }
  }

  for(i = 0; i < r; i++) {
    for(j = 0; j < c; j++) {
      scanf("%d", &a[i][j]);
    }
  }

   for(i = 0; i < r; i++) {
    for(j = 0; j < c; j++) {
      a[r][j] += a[i][j];
    }
   }

  for(i = 0; i < r; i++) {
    for(j = 0; j < c; j++) {
      printf("%d ", a[i][j]);
      sum += a[i][j];
    }
    printf("%d\n", sum);
    allsum += sum;
    sum = 0;
  }

  for(i = 0; i < c; i++) {
    printf("%d ", a[r][i]);
  }
    printf("%d\n", allsum);
    return 0;
}  

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, k;
vector <int> a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    a.resize(n);
    for(auto &i : a) cin >> i;
    sort(a.begin(), a.end());
    ll ans = 0;
    for(int i = 0 ; i < k ; i++){
        ans += a[i];
    }
    cout << ans << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;

#define REP(i, N) for (int i = 0; i < N; i++)
#define REP1(i, N) for (int i = 1; i < N; i++)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ANS(a) cout << a << endl;
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())

#define DBG(V) for (auto v : V) cout << v << " "; cout << endl

int N, K;
vector<int> H;

int
main()
{
  cin >> N >> K;
  REP(i, N) { int tmp; cin >> tmp; H.emplace_back(tmp); }

  SORT(H);

  int ans = H[0 + K - 1] - H[0];
  REP1(i, N - K + 1) {
    ans = min(ans, H[i + K - 1] - H[i]);
  }

  ANS(ans);

  return 0;
}
/*
5 3
10 15 11 14 12
*/


Measured memory_bytes: 892
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main(){
	ll N, K;
	cin >> N >> K;

	ll a = N % K;

	ll ans = min(a, abs(a - K));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n, m = gets.chomp.split.map(&:to_i)

a = []

n.times do
  a << gets.chomp.split.map(&:to_i)
end

b = []
m.times do
  b << gets.chomp.to_i
end

n.times do |i|
  ans = 0

  m.times do |j|
    ans += a[i][j] * b[j]
  end
  puts ans
end


Measured memory_bytes: 8912
package main

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

func main() {
	N := getStdinInt()
	AC := 0
	WA := 0
	TLE := 0
	RE := 0
	for i := 0; i < N; i++ {
		s := getStdin()
		if s == "AC" {
			AC++
		} else if s == "WA" {
			WA++
		} else if s == "TLE" {
			TLE++
		} else if s == "RE" {
			RE++
		}
	}
	fmt.Printf("AC x %d\n", AC)
	fmt.Printf("WA x %d\n", WA)
	fmt.Printf("TLE x %d\n", TLE)
	fmt.Printf("RE x %d\n", RE)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 4176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e9;
int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    int q; cin >> q;
    rep(i,q){
        int k, b, e, cnt = 0;
        cin >> b >> e >> k;
        REP(j,b,e)if(a[j] == k)cnt++;
        cout << cnt << endl;
    }
    return 0;
} 


Measured memory_bytes: 3108
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll h[100001] = {};
ll k[100001] = {};

ll n, a, b;
bool holocost(ll x) {
	rep(i, 0, n) {
		k[i] = h[i];
	}
	rep(i, 0, n) k[i] -= x * b;
	ll cnt = 0;
	rep(i, 0, n) {
		if (k[i] > 0) {
			cnt += k[i] / (a - b);
			if (k[i] % (a - b) != 0)cnt++;
		}
	}
	return cnt <= x;
}

int main() {
	cin >> n >> a >> b;
	rep(i, 0, n) cin >> h[i];

	ll l = -1;
	ll r = (ll)1 << 30;
	ll m;
	while (r - l > 1) {
		m = (l + r) / 2;
		if (holocost(m)) {
			r = m;
		}
		else {
			l = m;
		}
	}
	cout << r << endl;

	return 0;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define vpll        vector<pair<ll,ll>>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))


void solve(){
    int a,b;cin>>a>>b;
    if(a+b>9)cout<<"error";
    else cout<<a+b;


}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 896
import sys


n,a,b=map(int,input().split())
s=input()
pas=0
fo=0
for i in s:
    if(i=="c"):print("No")
    elif(i=="a"):
        if(pas<(a+b)):
            print("Yes")
            pas+=1
        else:print("No")
    elif(i=="b"):
        if(pas<(a+b) and fo<b):
            print("Yes")
            pas+=1
            fo+=1
        else:print("No")

Measured memory_bytes: 4016
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cmath>

#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{


    long long n, k;
    int a[200001];
    long long tmp[200001] = {0};
    long long res = 1;
    long long loop = 0;
    long long lpc = 0;
    long long init = 0;
    
    cin >> n >> k;
    
    for(long long i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    for(long long i = 0; i < n; i++)
    {
        tmp[res - 1]++;
        if(tmp[res - 1] > 1)
        {
            loop = res - 1;
            break;
        }
        res = a[res - 1];
    }
    
    res = 1;
    
    for(long long i = 0; i < n; i++)
    {
        if(res - 1 == loop)
        {
            break;
        }
        else
        {
            init++;
            res = a[res - 1];
        }
    }
    
    res = loop + 1;
    
    for(long long i = 0; i < n; i++)
    {
        if(a[res - 1] == loop + 1)
        {
            lpc++;
            break;
        }
        res = a[res - 1];
        lpc++;
    }
    
    
    res = 1;
    
    if(k <= init)
    {
        for(int i = 0; i < k; i++)
        {
            res = a[res - 1];
        }
    }
    else
    {
        res = loop + 1;
        
        k -= init;
        
        k = k % lpc;
        

            for(int i = 0; i < k; i++)
            {
                res = a[res - 1];
            }
    }

    cout << res;
    
}

Measured memory_bytes: 5976
import java.util.*;

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

    int n = sc.nextInt();
    int l = sc.nextInt();

    int min = 300;
    int apl = 0;
    for (int i = 1; i <= n; i++) {
      int t = Math.abs(l + i - 1);
      if (t < min) apl = i;
      min = Math.min(t, min);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
      if (i != apl) ans += l + i - 1;
    }
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
from functools import reduce
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

def gcd(m,n):
    if n == 0:
        return m
    return gcd(n,m%n)
    
def lcm(m,n):
    return m * n//gcd(m,n)

print(reduce(lcm,T))

Measured memory_bytes: 3684
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const double PI=3.1415926535897932;
using namespace std;
typedef long long ll;

vector< vector< int > > grid_bfs(vector<string> &s, char start, const string &wall="#") {
  const int vx[] = {0, 1, 0, -1}, vy[] = {1, 0, -1, 0};
  vector< vector< int > > min_cost(s.size(), vector< int >(s[0].size(), -1));
  queue< pair< int, int > > que;
  for(int i = 0; i < s.size(); i++) {
    for(int j = 0; j < s[i].size(); j++) {
      if(s[i][j] == start) {
        que.emplace(i, j);
        min_cost[i][j] = 0;
      }
    }
  }
  while(!que.empty()) {
    auto p = que.front();
    que.pop();
    for(int i = 0; i < 4; i++) {
      int ny = p.first + vy[i], nx = p.second + vx[i];
      if(nx < 0 || ny < 0 || nx >= s[0].size() || ny >= s.size()) continue;
      if(min_cost[ny][nx] != -1) continue;
      if(wall.find(s[ny][nx]) != string::npos) continue;
      min_cost[ny][nx] = min_cost[p.first][p.second] + 1;
      que.emplace(ny, nx);
    }
  }
  return min_cost;
}

int main(void){
    int h,w;
    cin>>h>>w;
    vector<string> s(h);
    rep(i,h){
        cin>>s[i];
    }
    int c=-1;
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='.')c++;
        }
    }
    //string wa="#";
    s[0][0]='s';
    
    vector<vector<int>> mincost;
    mincost=grid_bfs(s,'s');
    if(mincost[h-1][w-1]==-1)cout<<-1<<endl;
    else cout<<c-mincost[h-1][w-1]<<endl;
    //cout<<mincost[h-1][w-1]<<endl;
}

Measured memory_bytes: 3664
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> s;
	for(i=1;i<s.size();i++) {
		if (s[i-1] != s[i]) ans++;
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using ll = long long;
using P = pair<long long, long long>;
using MATRIX = vector< vector<ll> >;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

long long dist[100000];
long long visited[100000] = {0};

int main() {
  long long N;
  cin >> N;
  vector<P> e[100000];
  rep(i, N-1) {
    long long u, v, w;
    cin >> u >> v >> w;
    u--;v--;
    e[u].push_back({w, v});
    e[v].push_back({w, u});
  }

  dist[0] = 0;
  queue<long long> que;
  que.push(0);
  while(que.size()) {
    long long x = que.front();
    que.pop();
    visited[x] = 1;
    rep(i, e[x].size()) {
      P p = e[x][i];
      long long w = p.first;
      long long to = p.second;
      if(visited[to] != 1) {
        dist[to] = (dist[x] + w) % 2;
        que.push(to);
      }
    }
  }
  rep(i, N) {
    cout << dist[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 12544
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define rep(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long int ll;
using namespace std;
ll mod =1e9+7;
class Combination
{
    vector<long long> fact;
    vector<long long> factinv;
    long long MOD = 1e9 + 7;
    long long modpow(long long a, long long n)
    {
        if (n == 0)
            return 1;
        if (n % 2 == 0)
        {
            long long t = modpow(a, n / 2);
            return t * t % MOD;
        }
        return a * modpow(a, n - 1) % MOD;
    }

    long long modinv(long long a)
    {
        // mod is prime
        return modpow(a, MOD - 2);
    }

public:
    Combination(int n) : fact(n), factinv(n)
    {
        fact[0] = 1;
        for (int i = 1; i < n; i++)
        {
            fact[i] = fact[i - 1] * i % MOD;
        }
        factinv[n - 1] = modinv(fact[n - 1]);
        for (int i = n - 2; i >= 0; i--)
        {
            factinv[i] = factinv[i + 1] * (i + 1) % MOD;
        }
    }

    long long ncr(long long n, long long r)
    {
        if (r < 0 || r > n)
            return 0;
        return fact[n] * factinv[r] % MOD * factinv[n - r] % MOD;
    }

    long long npr(long long n, long long r)
    {
        if (r < 0 || r > n)
            return 0;
        return fact[n] * factinv[n - r] % MOD;
    }

    long long nhr(long long n, long long r)
    {
        if (n == 0 && r == 0)
            return 1;
        return ncr(n + r - 1, r);
    }
};

int main()
{
    int n,k;
    cin >> n >> k;
    Combination comb(10000);
    for (int i = 1; i <= k; i++)
    {
        if (n - k + 1 < i)
            cout << 0 << endl;
        else
            cout << (comb.ncr(k - 1, i - 1) * comb.ncr(n - k + 1, i)) % mod << endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n,m;
  cin>>n>>m;
  vector<int> ans(n,0);
  rep(i,m){
  int a,b;
  cin>>a>>b;
  ans.at(a-1)++;
  ans.at(b-1)++;
  }
  rep(i,n){
  cout<<ans.at(i)<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int N = cin.nextInt();
			if(N==0){
				break;
			}
			int[] a = new int[N];
			
			HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
			for(int i = 0;i < N;i++){
				a[i]=cin.nextInt();
				if(map.containsKey(a[i])){
					map.put(a[i], map.remove(a[i])+1);
				}
				else{
					map.put(a[i], 1);
				}
			}
			int count=0;
			while(true){
				count++;
				HashMap<Integer, Integer> ne = new HashMap<Integer, Integer>();
				int[] next = new int[N];
				for(int i = 0; i < N;i++){
					next[i]=map.get(a[i]);
					if(ne.containsKey(next[i])){
						ne.put(next[i], ne.remove(next[i])+1);
					}
					else{
						ne.put(next[i], 1);
					}
				}
				if(Arrays.equals(a, next)){
					break;
				}
				else{
					a = next;
					map = ne;
				}
				
			}
			System.out.println(count-1);
			System.out.print(a[0]);
			for(int i = 1; i < N;i++){
				System.out.print(" "+a[i]);
			}
			System.out.println();
		}

	}
}

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

using namespace std;

int main(){
  int a,b,c;
  
 int l, m;
  m = 0;
  cin >> a >> b >> c;
  l = a;
  if(l < b){
    m += l;
    l = b;
  }
  else m += b;
  
  if(l < c) {
    m += l;
    l = c;
  }
  else m += c;
  cout << l*10 + m << endl;
  return 0;
}

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

int main()
{
    int n,ans;
    string s;
    char c[4];

    cin >> n >> s;

    ans = 0;
    for (int i = 0;i <= 999;++i) {
        c[0] =  i / 100;
        c[1] = (i - c[0] * 100)/10;
        c[2] = i - c[0] * 100 - c[1] * 10;
        int p = 0;
        for (int j = 0;j < n;++j) {
            if ((s.at(j)-'0') == c[p]) {
                ++p;
            }
            if (p == 3)
                break;
        }
        if (p == 3)
            ++ans;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3688
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <climits>
using namespace std;



long long sum(int left, int right){
  long long n = (left + right) * right;
  return  n / 2;
}



int main() {
  long long X;
  cin >> X;

  for (int i = 1; i < INT64_MAX; ++i) {
    if(X <= sum(1, i)){
      cout << i << endl;
      break;
    }
  }


  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
  char a,b;
  cin >> a >> b;
  if(a=='H'&&b=='H')
    cout << 'H' <<endl;
  else if(a=='H'&&b=='D')
    cout << 'D' << endl;
  else if(a=='D'&&b=='H')
    cout << 'D' << endl;
  else
    cout << 'H' << endl;
  return 0;
}


Measured memory_bytes: 256