akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll N, K; cin >> N >> K;
    vll A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    vll n(0);
    ll a = 1;
    for(int i=1; i<N; i++){
        if(A[i] != A[i-1]){
            n.emplace_back(a);
            a = 1;
            if(i==N-1){
                n.emplace_back(a);
            }
        }else{
            a++;
            if(i==N-1){
                n.emplace_back(a);
            }
        }
    }
    sort(n.begin(),n.end());
    ll k = n.size() - K;
    if(k <= 0){
        cout << 0;
    }else{
        ll ans = 0;
        for(int i=0; i<k; i++){
            ans += n[i];
        }
        cout << ans;
    }
}

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

int B=300;
int a[200000]={};
int b[2000]={};
int n;

void init(){
    rep(i,200000){
        a[i]=INF;
    }
    rep(i,2000){
        b[i]=INF;
    }
}


void update(int m,int x){
    a[m]=x;
    int base=m-(int)(m%B);
    int mini=INF;
    rep(i,B){
        if(base+i<n)
            mini = min(mini,a[base+i]);
    }
    b[m/B] = mini;
}

int find(int s,int t){
    int i=s;
    t++;
    int mini = INF;
    while(i<t){
        if(i%B==0&&i+B<=t){
            mini = min(mini,b[i/B]);
            i+=B;
        }else{
            mini = min(mini,a[i]);
            i++;
        }
    }
    return mini;
}


int main(){
    int q;
    cin>>n>>q;
    init();
    rep(i,q){
        int a,b,c;
        cin>>a>>b>>c;
        if(a==0){
            update(b,c);
        }else{
            cout<<find(b,c)<<endl;
        }
    }
}

Measured memory_bytes: 1948
#include<iostream>
#include<algorithm>
#define ll long long int
using namespace std;
int N,A,B;
int main()
{
	int con;
	cin>>N>>A>>B;
	if (B>N-A+1||(ll)A*(ll)B<(ll)N)cout<<-1<<endl;
	else
	{
		for (int i=N-A+1;i<=N;i++)cout<<i<<" ";
		while (1)
		{
			N-=A;
			B--;
			if (!N&&!B)break;
			A=N%B==0?N/B:N/B+1;
			for (int i=N-A+1;i<=N;i++)cout<<i<<" ";
		}
		cout<<endl;
	}
	return 0;
}


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

int main()
{
    map<string , int>m;
    m["AC"]=0;
    m["TLE"]=0;
    m["WA"]=0;
    m["RE"]=0;
    int n;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        ++m[s];
    }
    cout<<"AC x "<<m["AC"]<<'\n';
    cout<<"WA x "<<m["WA"]<<'\n';
    cout<<"TLE x "<<m["TLE"]<<'\n';
    cout<<"RE x "<<m["RE"]<<'\n';
    return 0;
}



Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    string s; cin >> s;
    int N = s.size();
    int ans = 0;
    rep(i,N){
        if(i % 2 == 0){
            if(s[i] == 'p') ans--;
        }
        else{
            if(s[i] == 'g') ans++;
        }
    }
    cout << ans << endl;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

long mod=1e9+7;


int main() {
  string s;cin>>s;
  int y=stoi(s.substr(0,4));
  int m=stoi(s.substr(5,2));
  int d=stoi(s.substr(8,2));
  int p=y*10000+m*100+d;
  if(p<=20190430)cout<< "Heisei";
  else cout<<"TBD";
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a,b=0,c=0;
    string s;
    cin>>s;
    if(s[0]!='A'){
        b++;
    }
    for(a=2;a<s.size()-1;a++){
        if(s[a]=='C'){
            c++;
        }
        else if(int(s[a])<97 || int(s[a])>122){
            b++;
        }
    }
    if(int(s[1])<97 || int(s[1])>122){
        b++;
    }
    if(int(s[s.size()-1])<97 || int(s[s.size()-1])>122){
        b++;
    }
    if(b==0 && c==1){
        cout<<"AC";
    }
    else{
        cout<<"WA";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
inline int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int k=1,kk=0;if (c=='-')c=getchar(),k=-1;
	while (c>='0'&&c<='9')kk=kk*10+c-'0',c=getchar();return kk*k;
}using namespace std;
void write(int x){if (x<0)putchar('-'),x=-x;if (x/10)write(x/10);putchar(x%10+'0');}
void writeln(int x){write(x);puts("");}
int n,lsg,jc[1000010],N[1000010],ans,f[1000010],sum;
int ksm(int x,int y){
	int ans=1;while (y){
		if (y&1)(ans*=x)%=lsg;(x*=x)%=lsg;y>>=1;
	}return ans;
}int p(int n,int m){return jc[n]*N[m]%lsg;}
int C(int n,int m){return jc[n]*N[m]%lsg*N[n-m]%lsg;}
signed main(){
	n=read();lsg=1e9+7;if (n==2){puts("1");return 0;}
	jc[0]=1;for (int i=1;i<=n;i++)jc[i]=jc[i-1]*i%lsg;
	N[n]=ksm(jc[n],lsg-2);for (int i=n-1;i>=0;i--)N[i]=N[i+1]*(i+1)%lsg;
	for (int i=1;i<n;i++)if (i*2>=n){
		f[i]=C((n-2-(i*2-n))/2+i*2-n,i*2-n)*jc[i]%lsg*jc[n-1-i]%lsg;
		(ans+=(f[i]-f[i-1])*i%lsg+lsg)%=lsg;
	}writeln(ans);
}



Measured memory_bytes: 21632
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,_ = LI()
    N0 = 2 ** N.bit_length()
    st = [0] * (N0*2)

    def add(p,x):
        p += N0-1
        st[p] = x
        while p > 0:
            p = (p-1) // 2
            st[p] = max(st[p*2+1],st[p*2+2])

    def get(a,b,x,l,r):
        if a <= l and r <= b: return st[x]
        if a >= r or b <= l: return 0
        vl = get(a,b,x*2+1,l,(l+r)//2)
        vr = get(a,b,x*2+2,(l+r)//2,r)
        return max(vl,vr)
    A = LI()
    for e,a in enumerate(A):
        add(e+1,a)
    max_a = -1
    max_cnt = 0
    for i in range(1,N):
        a = get(i+1,N+1,0,0,N0) - A[i-1]
        if a > max_a:
            max_a = a; max_cnt = 1
        elif a == max_a:
            max_cnt += 1

    print(max_cnt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 111208
#include<iostream>
#include<vector>
#include<string>
using namespace std;
 
char od[3] = {'R', 'U', 'D'};
char ev[3] = {'L', 'U', 'D'};
 
int main(){
	string s;
	cin >> s;
	for(int i=0;i<s.length();i++){
		int fl = 0;
		if((i+1) % 2 != 0){
			for(int j=0;j<3;j++){
				if(s[i] == od[j]) fl = 1;
			}
		}else{
			for(int j=0;j<3;j++){
				if(s[i] == ev[j]) fl = 1;
			}
		}
		if(fl == 0){
            cerr << s[i] << ' '<< i <<  endl;
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main(){
    int n; cin>>n;
    int ans=0;
    for(int i=1; i<=n; i++){
        int truss = GetDigit(i);
        if(truss%2==1) ans++;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
k,a,b=map(int,input().split())
ans=0
k+=1
if a+2>b:
    ans=k
else:
    if a+2>k:
        ans=k
    else:
        ans+=b
        k-=a+2
        ans+=(b-a)*(k//2)
        ans+=k%2
print(ans)


Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
int main(){
  double a;
  int n;
  int data[100];
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> data[i];
    a += data[i];
  }
  a /= n;
  int temp = (int)a;
  if(a - (double)temp >= 0.5){
    temp++;
  }
  int cost = 0;
  for(int i = 0;i < n;i++){
    cost += (data[i] - temp) * (data[i] - temp);
  }
  cout << cost << endl;
  return 0;
}


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

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

  if ((N % 1110) < 10) {
    cout << "Yes" << endl;
  }
  else if (((N % 1000) % 111) == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << 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()
{
  long X;
  cin >> X;
  long num = X / 100;
  long dist = X % 100;
  int ans = 0;
  if (dist <= 5 * num)
    ans = 1;

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

Measured memory_bytes: 256
s,_,*q=open(0)
a=['','']
p=1
for q in q:
  p^=q[0]<'2'
  a[(q<'2 2')^p]+=q[-2]*(q[0]>'1')
print(a[p^1][::-1]+s[:-1][::p or-1]+a[p])

Measured memory_bytes: 16392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  ll N, X, T;
  cin>>N>>X>>T;
  ll Ans=0;
  while(N>0){
    N-=X;
    Ans+=T;
  }
  cout<<Ans<<endl;
}

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

int main()
{
	int n, m, i;
	int a[1000];
	int s = 0;
	int f = 0;
	scanf("%d %d", &n, &m);
	
	for(i = 0; i < n; i++)
	{
		scanf("%d", a + i);
		s += a[i];
	}
	
	double sm = s / (double) (4 * m);
	for(i = 0; i < n; i++)
	{
		if(sm <= a[i])
		{
			f++;
		}
	}
	if(f >= m) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)

template<typename T>
using V = vector<T>;

template<typename T>
using V2 = V<V<T>>;

template<typename T>
using V3 = V<V2<T>>;

void solve(){
  int n, m; string s;
  cin >> n >> m >> s;
  {
    int l=0,r=0;
    for(;l<n+1;){
      while(l<=n && s[l]=='0'){++l;}
      r = l;
      while(r<=n && s[r]=='1'){++r;}
      if(r-l>=m){
        cout << -1 << endl;
        return;
      }
      l = r;
    }
  }
  vector<int> skr;
  skr.push_back(n);
  int pre=n,t = n;
  while(pre>0){
    t = max(0,pre-m);
    for(;t<pre;++t){
      if(s[t]=='0') break;
    }
    skr.push_back(t);
    pre = t;
  }
  for(int i=skr.size()-2; i>=0; --i){
    cout << skr[i] - skr[i+1] << " ";
  }
}

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

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

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI >     VVI;
typedef long long int     LL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n        //index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n     //index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)    //Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int n;
double dp[301][301][301];
int freq[4];
double dfs(int a,int b,int c)
{
    double sum =a+b+c + 0.0;
    if(sum == 0)
        return 0.0;
    if(dp[a][b][c] > -0.5)
        return dp[a][b][c];
    double expected_steps = n/(sum);
    double ret = 0.0;
    if(a)
        ret+= (a/sum)*(dfs(a-1,b,c)+expected_steps);
    if(b)
        ret+= (b/sum)*(dfs(a+1,b-1,c)+expected_steps);
    if(c)
        ret+= (c/sum)*(dfs(a,b+1,c-1)+expected_steps);
    dp[a][b][c] = ret;
    return ret;
}
int main() {
    scanf("%d",&n);
  	int a;
    rep(i,0,n)
    {
        scanf("%d",&a);
        freq[a]++;
    }
    memset(dp,-1.00,sizeof(double)*301*301*301);
    printf("%0.10lf\n",dfs(freq[1],freq[2],freq[3]) );
    return 0;
}

Measured memory_bytes: 213376
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#pragma warning( disable:4996 )
using namespace std;

#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))


int main(void) {
	int n;
	scanf("%d", &n);
	printf("%f\n", (double)(n / 2 + n % 2) / n);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

int n;
int w[200005];
vector<int> al[200005];
int ans[200005];

vector<int> lis{-1};
vector<ii> changes;
//(-1,-1) is insert new element
//(pos,val) is overwrite pos which used to contain val

void dfs(int i,int p){
	if (lis.back()<w[i]){
		lis.push_back(w[i]);
		changes.push_back(ii(-1,-1));
	}
	else{
		int iter=lower_bound(all(lis),w[i])-lis.begin();
		changes.push_back(ii(iter,lis[iter]));
		lis[iter]=w[i];
	}

	ans[i]=lis.size();
	
	for (auto &it:al[i]){
		if (it==p) continue;
		
		dfs(it,i);
	}
	
	if (changes.back()==ii(-1,-1)) lis.pop_back();
	else{
		lis[changes.back().fi]=changes.back().se;
	}
	changes.pop_back();
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	rep(x,1,n+1) cin>>w[x];
	
	int a,b;
	rep(x,1,n){
		cin>>a>>b;
		al[a].push_back(b);
		al[b].push_back(a);
	}
	
	dfs(1,-1);
	
	rep(x,1,n+1) cout<<ans[x]-1<<endl;
}


Measured memory_bytes: 33008
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S, T = map(str, input().split())
print(T, end = "")
print(S)

Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    ll n, m;
    cin>>n>>m;
    ll a[n], b[n];
    for (int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
    pair<ll, ll> c[n];
    for (int i=0;i<n;i++)
    {
        c[i]={ a[i], i };
    }
    sort(c, c+n);
    ll  s=0;
    for (int i=0;i<n;i++)
    {
        if (m<=0)
        {
            break;
        }
        s+=c[i].first*min(b[c[i].second], m);
        m-=min(b[c[i].second], m);
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 6792
#include <bits/stdc++.h>
using namespace std;
int main() {
	priority_queue<pair<int,int>> pq;
	int a,b;char c;
	while(cin>>a>>c>>b,a)
		pq.push(make_pair(b,a));
	int k[110];
	int before, cnt = 1;
	int n=pq.size();
	for(int i=0;i<n;i++){
		pair<int,int> p=pq.top();pq.pop();
		if(i==0){k[p.second]=1;}
		else if(before==p.first);else cnt++;
		k[p.second]=cnt;
		before=p.first;
	}
	int key;
	while(cin>>key){
		cout<<k[key]<<endl;
	}
	return 0;
}

Measured memory_bytes: 2976
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.map f

let solve xs xss =
    let rec aux s = function
        | [] -> s
        | xs :: xss -> aux (Set.intersect s (Set.ofArray (Array.tail xs))) xss
    aux (Set.ofArray (Array.tail xs)) xss
    |> Set.toList
    |> List.length

[<EntryPoint>]
let main argv =
    let [|n;_|] = reads int
    let rs :: rss = List.map (fun _ -> reads int) [1..n]
    solve rs rss
    |> printfn "%i"
    0

Measured memory_bytes: 15068
// A - AtCoder Group Contest

#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> n;
  vlli d(3 * n);
  rep(i, 0, 3 * n)
  {
    cin >> d[i];
  }
  SORTR(d);
  count = n;
  // cout << d << endl;

  // cout << d << endl;
  rep(i, 0, 2 * n)
  {
    if (i % 2 == 1)
      ans += d[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
-- SPDX-License-Identifier: X11
-- 2020-08-25
-- /\/\/\/

module Main where

import Data.List (group,sort,sortBy)

solve :: [Int] -> Int
solve = uncurry (+) . chop . split ([],[])
  where
    split :: ([a], [a]) -> [a] -> ([a], [a])
    split (xs, ys) [x,y]        = (x : xs, y : ys)
    split (xs, ys) (x : y : zs) = split (x : xs, y : ys) zs
    split _ _                   = error "split: Unhandled case"

    chop :: Ord a => ([a], [a]) -> (Int, Int)
    chop = mapP (length . concat) . initP .
             mapP (sortBy (\a b -> compare (length a) (length b)) .
                     group . sort)
      where
        initP :: Eq a => ([[a]], [[a]]) -> ([[a]], [[a]])
        initP p@(as, bs) = let (a, b) = mapP (head . last) p
                           in if a /= b
                                then (init as, init bs)
                                else let (x, y) = mapP (length . last) p
                                     in initFP ((x, as), (y, bs))
          where
            initFP :: ((Int, [[a]]), (Int, [[a]])) -> ([[a]], [[a]])
            initFP ((x, xs@[_]), (y, ys@[_]))
              | x > y     = ([], ys)
              | otherwise = (xs, [])
            initFP ((x, xs), (y, ys@[_]))
              | x > y     = (init xs, ys)
              | otherwise = (init2 xs, [])
            initFP ((x, xs@[_]), (y, ys))
              | x > y     = ([], init2 ys)
              | otherwise = (xs, init ys)
            initFP q@((x, xs), (y, ys))
              | x == y    = let (v, w) = mapP (length . last . init . snd) q
                            in if v > w
                                 then (init2 xs, init ys)
                                 else (init xs, init2 ys)
              | x > y     = (init xs, init2 ys)
              | otherwise = (init2 xs, init ys)

mapP :: (a -> b) -> (a, a) -> (b, b)
mapP f (a, b) = (f a, f b)

init2 :: [a] -> [a]
init2 l@[_] = l
init2 l     = last l : (init . init $ l)

parse :: String -> [Int]
parse = map (read :: String -> Int) . words . last . lines

main :: IO ()
main = getContents >>= \x -> print . solve . parse $ x


Measured memory_bytes: 78528
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <math.h>
#include <iomanip>

typedef long long ll;
using namespace std;

int main() {
    ll r, d, x;
    cin >> r>> d>> x;
    for(int i=0; i<10; ++i){
        x = x*r - d;
        cout << x << endl;;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int N;
  cin >> N;
  vector <int> d(N);
  rep(i,N) cin >> d.at(i);

  int ans = 0;
  for (int i = 0; i < N - 1; i++){
    for (int j = i + 1; j < N; j++){
      ans += d.at(i) * d.at(j);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll n=in();
    map<string,ll>m;
    ll foo=-1;
    for(int i=0;i<n;++i){
        foo=max(foo,++m[in<string>()]);
    }
    for(const auto&p:m){
        if(p.second==foo)cout<<p.first<<endl;
    }
}


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

int main() {
  int N,M,i,j,x,y,r=0;
  cin >> N >> M;
  map<int, vector<int>> a;
  priority_queue<int> pq;
  
  for(i=0; i<N; i++) {
    cin >> x >> y;
    if(!a.count(x))
      a[x].push_back(y);
    else
      a.at(x).push_back(y);
  }
  
  for(i=0; i<M; i++) {
    if(a.count(i+1)) {
      for(j=0; j<a.at(i+1).size(); j++)
        pq.push(a.at(i+1).at(j));
    }
    if(!pq.empty()) {
      r += pq.top();
      pq.pop();
    }
  }
  
  cout << r << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

	int n; cin >> n;
	vector<ll> a(n);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	ll res = 1e15;
	ll ruikei = 0;
	for (int i = 0; i < n-1; i++) {
		ruikei += a[i];
		res = min(res, abs(sum - ruikei * 2));
	}
	cout << res << endl;
	
}


Measured memory_bytes: 1792
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F();
		for (var h = 1; h <= 3500; h++)
			for (var n = h; n <= 3500; n++)
			{
				//(h n N)/(4 h n - h N - n N)
				var num = h * (long)N * n;
				var den = 4L * h * n - (h + n) * (long)N;
				if (den > 0 && num % den == 0)
				{
					WriteLine("{0} {1} {2}", h, n, num / den);
					return;
				}
			}
	}
}


Measured memory_bytes: 13140
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

vector<int> V[110000];
int color[110000];

//二部グラフならtrueを返す
bool dfs(int x,int c){
  color[x]=c;
  for(int i=0;i<V[x].size();i++){
    //隣接している頂点が同じ色ならfalse
    if(color[V[x][i]]==c) return false;
    //隣接している頂点がまだ塗られていないなら-cで塗る
    if(color[V[x][i]]==0 && !dfs(V[x][i],-c)) return false;
  }
  return true;
}


int main(){
    ll N,M;
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        a--; b--;
        V[a].push_back(b);
        V[b].push_back(a);
    }
    if(dfs(0,1)){
        ll count=0;
        for(int i=0;i<N;i++){
            if(color[i]==1) count++;
        }
        cout<<count*(N-count)-M<<endl;
    }else{
        cout<<N*(N-1)/2-M<<endl;
    }
}



Measured memory_bytes: 6784
#include <cstdio>
#include <vector>

#define REDIRECT(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
#define CLOSEALL() fclose(stdin), fclose(stdout)
#define eprintf(...) fprintf(stderr, ##__VA_ARGS__)

using namespace std;

const int MAXN = 1e5 + 10;

int u, v;
int N, M, Q;
vector <int> Adj[MAXN];
int color[MAXN];
int V[MAXN], D[MAXN], C[MAXN];

bool vist[MAXN][11];

void solve(int cur, int dep, int col)
{
	if(vist[cur][dep] || dep < 0)
		return;
	vist[cur][dep] = true;

	if(color[cur] == 0)
		color[cur] = col;

	for(vector<int>::iterator itr = Adj[cur].begin(); itr != Adj[cur].end(); ++itr)
		solve(*itr, dep - 1, col);
	solve(cur, dep-1, col);

}

int main()
{
	//REDIRECT("splatter");

	scanf("%d%d", &N, &M);
	for(int i = 1; i <= M; i++)
		scanf("%d%d", &u, &v), Adj[u].push_back(v), Adj[v].push_back(u);

	scanf("%d", &Q);
	for(int i = Q; i >= 1; i--)
		scanf("%d%d%d", &V[i], &D[i], &C[i]);
	for(int i = 1; i <= Q; i++)
		solve(V[i], D[i], C[i]);

	for(int i = 1; i <= N; i++)
		printf("%d\n", color[i]);

	CLOSEALL();
	return 0;
}


Measured memory_bytes: 9080
package main

import "fmt"

func main() {
	var N int
	var S string
	fmt.Scan(&N)
	fmt.Scan(&S)
	cnt := 1
	t := S[:1]
	for i := 1; i < len(S); i++ {
		if S[i:i+1] != t {
			t = S[i : i+1]
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ll n,m;
	cin >> n >> m;
	ll a[m];
	ll b[m];
	rep(i,m){
		cin >> a[i] >> b[i];
	}
	bool one[n],second[n];
	rep(i,n){
		one[i]=false;
		second[i]=false;
	}
	rep(i,m){
		if(a[i]==1)
			one[b[i]-1]=true;
		if(b[i]==n)
			second[a[i]-1]=true;
	}
	rep(i,n){
		if(one[i]&&second[i]){
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 7144
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    vector<double> t(N + 1);
    vector<double> v(N + 1);
    rep(i, 0, N) cin >> t[i];
    rep(i, 0, N) cin >> v[i];
    t[N] = v[N] = 0.0;
    rrep(i, N - 1, 0)
    {
        chmin(v[i], v[i + 1] + t[i]);
    }

    double ans = 0.0;
    double vel = 0.0;
    rep(i, 0, N)
    {
        const double x = (t[i] + (v[i + 1] - vel)) * 0.5;
        assert(x >= 0.0);

        if (x <= t[i])
        {
            if ((vel + x) <= v[i])
            {
                ans += ((vel + (vel + x)) * x * 0.5) + (((vel + x) + v[i + 1]) * (t[i] - x) * 0.5);
                vel = v[i + 1];
            }
            else
            {
                if (v[i] > v[i + 1])
                {
                    const double t1 = v[i] - vel;
                    const double t2 = t[i] - (v[i] - v[i + 1]);
                    assert(t1 >= 0.0 && t1 <= t[i]);
                    assert(t2 >= 0.0 && t2 <= t[i]);
                    assert(t2 >= t1);
                    ans += ((vel + v[i]) * t1 * 0.5) + (v[i] * (t2 - t1)) + ((v[i] + v[i + 1]) * (t[i] - t2) * 0.5);
                    vel = v[i + 1];
                }
                else
                {
                    const double t1 = v[i] - vel;
                    assert(t1 >= 0.0 && t1 <= t[i]);
                    ans += ((vel + v[i]) * t1 * 0.5) + (v[i] * (t[i] - t1));
                    vel = v[i];
                }
            }
        }
        else
        {
            if ((vel + t[i]) <= v[i])
            {
                ans += (vel + (vel + t[i])) * t[i] * 0.5;
                vel = vel + t[i];
            }
            else
            {
                const double t1 = v[i] - vel;
                assert(t1 >= 0.0 && t1 <= t[i]);
                ans += ((vel + v[i]) * t1 * 0.5) + (v[i] * (t[i] - t1));
                vel = v[i];
            }
        }
    }
    printf("%.15lf\n", ans);
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N;
    map<string, int> mp;
    string s[110], t[110];
    rep(i, N) {
        cin >> s[i];
        mp[s[i]]++;
    }
    cin >> M;
    rep(i, M) {
        cin >> t[i];
        mp[t[i]]--;
    }
    int ans = 0;
    rep(i, N) {
        ans = max(ans, mp[s[i]]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/rope>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1

using namespace std;
using namespace __gnu_cxx;

const double g=10.0,eps=1e-7;
const int N=200000+10,maxn=1000000+10,inf=0x3f3f3f;

int cnt[1<<26],num[26],dp[N];
char s[N];
int main()
{
    scanf("%s",s+1);
    memset(cnt,-1,sizeof cnt);
    cnt[0]=dp[0]=0;
    int len=strlen(s+1);
    for(int i=1;i<=len;i++)
    {
        dp[i]=i;
        num[s[i]-'a']++;
        int even=0;
        for(int j=0;j<26;j++)
            if(num[j]&1)
                even++;
        if(even<=1)dp[i]=1;
    }
    memset(num,0,sizeof num);
    for(int i=1;i<=len;i++)
    {
        num[s[i]-'a']++;
        int k=0;
        for(int j=0;j<26;j++)
            if(num[j]&1)
                k+=(1<<j);
        if(cnt[k]!=-1)dp[i]=min(dp[i],dp[cnt[k]]+1);
        for(int j=0;j<26;j++)
        {
            if(k==(1<<j))dp[i]=1;
            if(cnt[k^(1<<j)]!=-1)
            {
                dp[i]=min(dp[i],dp[cnt[k^(1<<j)]]+1);
            }
        }
        cnt[k]=i;
    }
  //  for(int i=1;i<=len;i++)cout<<dp[i]<<endl;
    printf("%d\n",dp[len]);
    return 0;
}
/************
k^(1<<i)=s
************/


Measured memory_bytes: 263424
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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;
}

int main(){
    ll n;cin >> n;
    vector<vl> p(n,vl(2));
    vector<ll> zzz(n);
    rep(i,n)cin >> p[i][0]>> p[i][1] >> zzz[i] ;
    vector<ll> ans(n+1,INF);
    vvl dpx(n,vl(1<<n)),dpy(n,vl(1<<n));
    rep(bit,1<<n){
        rep(i,n){
            ll ret=abs(p[i][0]);
            ll rey=abs(p[i][1]);
            rep(j,n){
                if(bit&(1<<j)){
                    chmin(ret,abs(p[i][0]-p[j][0]));
                    chmin(rey,abs(p[i][1]-p[j][1]));
                }
            }
            dpx[i][bit]=ret*zzz[i];
            dpy[i][bit]=rey*zzz[i];
        }
    }
    rep(bit,1<<n){
        per(cit,bit+1){
            cit&=bit;
            ll ret=0;
            rep(i,n){
                ret+=min(dpx[i][cit],dpy[i][bit-cit]);
            }
            chmin(ans[__builtin_popcount(bit)],ret);
        }
    }
    rep(i,n+1){
        cout << ans[i] <<endl;
    }
}

Measured memory_bytes: 11168
import java.util.*;
import java.io.*;

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

    List<Integer> a = new ArrayList<Integer>();
    for(int i = 0; i < n; i++) {
      a.add(scan.nextInt());
    }

    double ans = 0.0;
    for(int i : a) ans += 1.0 / i;
    ans = 1.0 / ans;

    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(all(a));
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      if (a[i] == x) ans++;
      break;
    }
    if (x < a[i]) break;
    ans++;
    x -= a[i];
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a;
    long long int ans=0;
    long long int count=0;
    for(int i=0; i<n; i++){
        cin >> a;
        if(a%2==0) count++;
    }
    ans=pow(3,n)-pow(2,count);
    cout << ans << endl;
}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

int main()
{
    //freopen("IN.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s, t;
    cin>>s>>t;
    t.resize(t.size()-1);
    if(s==t)cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

const int MAX = 2000000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    COMinit();
    ll x, y;
    cin >> x >> y;
    if ((2 * x - y) % 3 == 0 && (2 * y - x) % 3 == 0)
    {
        ll a = (2 * x - y) / 3;
        ll b = (2 * y - x) / 3;
        cout << COM(a + b, a) << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 50496
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

int main(int argc, void **arg)
{
    long long n;
    double x;


    scanf("%lld", &n);

    x = ((n + n % 2) / 2.0) / (double)n;

    printf("%lf\n", x);

    return 0;
}


Measured memory_bytes: 128
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int MAX_N =10000;
 
struct edge
{
    int to,cost;
    edge(int _to,int _cost){
        to =_to;
        cost =_cost;
    }
};
 
int V;
vector<edge> cost[MAX_N];
int d[MAX_N];
bool visit[MAX_N];
void dijkstra(int s){
    d[s]=0;
    priority_queue<pii, vector<pii> ,greater<pii> > que;
    que.push(mp(0,s));
    while(!que.empty()){
        pii p =que.top();
        que.pop();
        int v =p.second;
        //if(d[v] < p.first)continue;
        for(int i =0;i <cost[v].size();i++){
            edge e =cost[v][i];
            if(d[e.to] >d[v]+e.cost){
                d[e.to] =d[v] +e.cost;
                que.push(mp(d[e.to],e.to));
            }
        }
    }
}
 
int main(){
    cin>>V;
    for(int i =0;i <V;i++){
        d[i]=INF;
        int u,k;
        cin>>u>>k;
        for(int j =0;j <k;j++){
            int to,c;
            cin>>to>>c;
            cost[u].push_back(edge(to,c));
        }
    }
     
    dijkstra(0);
    for(int i =0;i <V;i++){
        cout <<i<<" "<<d[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 6296
#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int, int>pi;
typedef     pair<long long, long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp  make_pair
#define       FOR(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
int main()
{
  ll n,i,x;
  string s;
  cin>>s;
  if(s[s.size()-1]!='s')
  {
    cout<<s<<"s"<<endl;
  }else
  {
    cout<<s<<"es"<<endl;
  }

}


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

template<typename cost_type = int>
std::vector<cost_type> dijkstra(
  const std::vector<std::vector<std::pair<int, cost_type>>> &G,
  const int st,
  const cost_type inf = std::numeric_limits<cost_type>::max() / 3) {
  
  const int SZ = G.size();
  std::vector<cost_type> dist(SZ, inf);
  dist[st] = 0;

  std::priority_queue<
    std::pair<cost_type, int>,
    std::vector<std::pair<cost_type, int>>,
    std::greater<std::pair<cost_type, int>>> pq;
  pq.emplace(0, st);
  while (!pq.empty()) {
    const auto cur_cost = std::get<0>(pq.top());
    const auto cur = std::get<1>(pq.top());
    pq.pop();
    if (dist[cur] < cur_cost) {
      continue;
    }
    for (auto &&nxt : G[cur]) {
      const auto nxt_p = std::get<0>(nxt);
      const auto nxt_cost = cur_cost + std::get<1>(nxt);
      if (dist[nxt_p] <= nxt_cost) {
        continue;
      }
      dist[nxt_p] = nxt_cost;
      pq.emplace(nxt_cost, nxt_p);
    }
  }

  return dist;
}

using namespace std;

int main() {
  int V, E, R;
  cin >> V >> E >> R;
  vector<vector<pair<int, long long>>> G(V);
  for (int i = 0; i < E; i++) {
    int s, t;
    long long d;
    cin >> s >> t >> d;
    G[s].emplace_back(t, d);
  }

  const auto inf = (long long)1e18;
  const auto dist = dijkstra(G, R, inf);
  for (int i = 0; i < V; i++) {
    if (dist[i] >= inf) cout << "INF" << '\n';
    else cout << dist[i] << '\n';
  }
}



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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    string S;
    cin >> S;

    ll cnt = 0;
    ll ans = 0;
    for(ll i=0; i<(ll)S.size(); i++)
    {
        if(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T')
        {
            cnt++;
            ans = max(cnt, ans);
        }

        else
        {
            cnt = 0;
        }
    }

    cout << ans << endl;
    

    return 0;
}

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

using namespace std;

struct pos
{
    int x, y;
};

pos arr[100010][2];

int r, c;
int idx(pos p)
{
    if(p.x != 0 && p.x != r && p.y != 0 && p.y != c)
        return -1;

    if(p.y == 0)
        return p.x;
    if(p.x == r)
        return r + p.y;
    if(p.y == c)
        return r + c + (r - p.x);
    return r + c + r + (c - p.y);
}

int mem[100010][2];

int main()
{
    int n, i;
    scanf("%d%d%d", &r, &c, &n);
    for(i = 0; i < n; i++)
        scanf("%d%d%d%d", &arr[i][0].x, &arr[i][0].y, &arr[i][1].x, &arr[i][1].y);

    vector<pair<int, int>> v;
    for(i = 0; i < n; i++)
    {
        int x = idx(arr[i][0]);
        int y = idx(arr[i][1]);
        if(x == -1 || y == -1)
            continue;
        if(y < x)
            swap(x, y);
        v.push_back({ x, y });
    }

    sort(v.begin(), v.end());
    vector<int> stk;
    for(auto p : v)
    {
        int x = p.first;
        int y = p.second;

        while(!stk.empty() && stk.back() < x)
            stk.pop_back();

        if(!stk.empty() && y > stk.back())
        {
            puts("NO");
            return 0;
        }

        stk.push_back(y);
    }

    puts("YES");
    return 0;
}

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();

		// 出力
		for (int i = 1; i <= 9; i++) {
			if (a % i == 0 && a / i >= 1 && a / i <= 9) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");

	}

}


Measured memory_bytes: 21460