akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////




int main(){
    
    string s,t;cin>>s>>t;
    ll ns=s.size(),nt=t.size();
    ll dp[ns+1][nt+1];memset(dp,0,sizeof(dp));
    rep(i,1,ns){
        rep(j,1,nt){
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            if(s[i-1]==t[j-1])Max(&dp[i][j],dp[i-1][j-1]+1);
        }
    }
    string ans;
    ll ipos=ns-1,jpos=nt-1;
    while(ipos>=0&&jpos>=0){
        if(dp[ipos+1][jpos+1]==dp[ipos+1][jpos]){
            jpos--;
        }else if(dp[ipos+1][jpos+1]==dp[ipos][jpos+1]){
            ipos--;
        }else if(dp[ipos][jpos]+1==dp[ipos+1][jpos+1]){
            ans+=s[ipos];
            ipos--;
            jpos--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    
   /* rep(i,0,ns){
        rep(j,0,nt){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }*/
    
    return 0;
}


Measured memory_bytes: 70656
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;


int path[10][10];
int cost[10][10];
int maximum = 0;
int current = 0;
vector<int> pa;
vector<int> mapa;
int n,m;

int p[20];
int memo[1<<20];

int Abs(int x){
	return x < 0 ? -x : x;
}
int dfs(int bit){
	if( memo[bit] != -1 ) return memo[bit];
	
	vector<int> card;
	for(int i = 0 ; i < 20 ; i++)
		if( bit >> i & 1 )
			card.push_back(i);
	
	int ans = __builtin_popcount(bit);
	for(int i = 0 ; i < card.size() ; i++){
		for(int j = i+1 ; j < card.size() ; j++){
			if( p[card[i]] == p[card[j]] ){
				int dx = Abs(i%4-j%4);
				int dy = Abs(i/4-j/4);
				if( max(dx,dy) <= 1 ) ans = min( ans , dfs(bit-(1<<card[i])-(1<<card[j])) );

			}
		}
	}
	return memo[bit] = ans;
}
int main(){
	int T;
	cin >> T;
	while(T--){
		memset(memo,-1,sizeof(memo));
		for(int i = 0 ; i < 20 ; i++) cin >> p[i];
		cout << dfs((1<<20)-1) << endl;
	}
}

Measured memory_bytes: 5320
N,M = [int(i) for i in input().split()]
P = 10**9+7
nn = 500000
fa = [1] * (nn+1)
fainv = [1] * (nn+1)
for i in range(nn):
    fa[i+1] = fa[i] * (i+1) % P
fainv[-1] = pow(fa[-1], P-2, P)
for i in range(nn)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % P
C = lambda a, b: fa[a] * fainv[b] % P * fainv[a-b] % P if 0 <= b <= a else 0

ans = ((fa[M]*fainv[M-N]%P)**2)%P
for i in range(1,N+1):
  ans += (-1)**i * C(N,i) * fa[M]%P * fa[M-i]%P * fainv[M-N]%P * fainv[M-N]%P
  ans %= P
print(ans)

Measured memory_bytes: 92732
A=int(input())
B=int(input())
C=int(input())
X=int(input())
cnt=0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k==X:
                cnt+=1
print(cnt)
          

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define ranger(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define repr(i, b) for (int i = (b)-1; i >= 0; i--)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S>& p) {
	os << '(' << p.first << ',' << p.second << ')';
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

const int M = 1000000007;

vector<vector<int>> g, dp;

enum C { B = 0, W = 1 };

void dfs(int cur, vector<bool>& used) {
	used[cur] = true;

	dp[cur][0] = dp[cur][1] = 1;
	for (auto to : g[cur]) {
		if (used[to]) continue;
		dfs(to, used);
		dp[cur][W] *= (dp[to][W] + dp[to][B] % M);
		dp[cur][B] *= dp[to][W];
		dp[cur][W] %= M;
		dp[cur][B] %= M;
	}
}

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

	g = vector<vector<int>>(n);
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}

	dp = vectors(n, 2, 0LL);
	vector<bool>used(n, false);
	dfs(0, used);
	cout << (dp[0][B] + dp[0][W]) % M << endl;
}


Measured memory_bytes: 16768
#include <bits/stdc++.h>
using namespace std;
#define int long long
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,d,a;
    cin >> n >> d >> a;
    int t2d = 2*d;
    vector <int> e(n);
    vector <pair <int,int> > sd(n);
    
    for(int i = 0; i < n; ++i)cin >> sd[i].first >> sd[i].second;
    sort(sd.begin(), sd.end());
    int c = 0;
    int o = 0;
    for(int i = 0; i < n; ++i){
        int h = sd[i].second;
        h -= c;
        if(h > 0){
            //cerr << "in i " << i << '\n';
            int f = (h+a-1)/a;
            o += f;
            c += f*a;
            auto it = upper_bound(sd.begin(), sd.end(), pair <int,int> {sd[i].first + t2d,(int)1e12});
            --it;
            int p = it - sd.begin();
            e[p] += f*a;
        }
        c -= e[i];
    }
    cout << o << '\n';
}


Measured memory_bytes: 4992
// test1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include<iostream>

#include<string>

using namespace std;
int main()
{
    string inputStr;

    cin >> inputStr;

    int strSize = inputStr.length();

    for (int i = 0; i < strSize; i++) {
        cout << "x";
    }

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                // 整数の入力
                int n = sc.nextInt();
                // 出力
                if(n%1000 == 0) {
                        System.out.println(0);
                } else {
                        System.out.println(1000-(n%1000));
                }
        }
}

Measured memory_bytes: 35760
N,M,C=[int(x) for x in input().split()]
B=[int(x) for x in input().split()]
ans=0
for n in range(N):
    A=[int(x) for x in input().split()]
    if sum([A[i]*B[i] for i in range(M)])+C > 0:
        ans+=1
print(ans)



Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	vint T;
	ll sum=0;
	for(int i=0;i<N;i++){
		int t;
		cin>>t;
		T.pb(t);
		sum+=t;
	}
	int M;
	cin>>M;
	for(int i=0;i<M;i++){
		int P,X;
		cin>>P>>X;
		cout<<sum-T[P-1]+X<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
fun main (args:Array<String>){
    var(cokkieT, cokkieA, loopT) = readLine()!!.split(" ").map(String::toLong)
    if(cokkieT + cokkieA < loopT || cokkieT + cokkieA == loopT){
        print("0 0")
        return
    }
    if(cokkieT >= loopT){
        cokkieT -= loopT
        print("$cokkieT $cokkieA")
        return
    }
    cokkieA -= loopT - cokkieT
    print("0 $cokkieA")
}

Measured memory_bytes: 36280
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<list>
#include<vector>
#include<string>
#include<cmath>
using namespace std;
int main(){
    int n,k; //n人のすぬけ、k種類のお菓子
    int d; // お菓子を持っている人の数
    int people =0; //お菓子を持っている人
    int itazura=0; //いたずらされる人の数
    cin >> n >> k;
    int A[100]={};
    for(int i=0;i<k;i++){
        cin >>  d;
        for(int j =0;j<d;j++){
            cin >> people;
            A[people-1]++;
        }
    }
    for(int i=0;i<n;i++){
        if(A[i] == 0){
            itazura++;
        }
    }
    cout << itazura << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(void)
{
        int a,b,s1,s2,s3;
        scanf("%d%d",&a,&b);

        s1=a+b;
        s2=a-b;
        s3=a*b;

        if(s1>=s2 && s1>=s3)  printf("%d\n",s1);
        else if(s1<=s2 && s2>=s3)printf("%d\n",s2);
        else if(s1<=s3 && s2<=s3) printf("%d\n",s3);
        return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll d,s,t;
    cin>>d>>t>>s;
    if(t*s>=d)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    


    
}

Measured memory_bytes: 3620
n = int(input())
h = list(map(int,input().split()))
ans = 0
running = 0
for i in range(1,n):
  if h[i] <= h[i-1]:
    running += 1
  else:
    ans = max(ans, running)
    running = 0
ans = max(ans, running)
print(ans)

Measured memory_bytes: 63984
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

typedef struct{
    int parent, left, right;
} Node;
Node t[1002];

void dfs(map<int, string> m, int u, int d){
    rep(i,d) cout << '.';
    cout << m[u] << endl;

    if(t[u].left != INF){
        dfs(m, t[u].left, d + 1);
    }
    if(t[u].right != INF){
        dfs(m, t[u].right, d);
    }
}

int brotherNum(int u){
    if(t[u].right == INF){
        return u;
    }else{
        return brotherNum(t[u].right);
    }
}

int main(){
    rep(i,1002) t[i].parent = t[i].left = t[i].right = INF;
    map<int, string> m;
    int n;

    cin >> n;
    rep(i,n){
        int inp;
        string s;

        cin >> inp >> s;
        m[i + 1] = s;

        t[i + 1].parent = inp;
        if(t[inp].left == INF){
            t[inp].left = i + 1;
        }else{
            t[brotherNum(t[inp].left)].right = i + 1;
        }
    }
    //range(i,1,n + 1){ cout << t[i].parent << ' ' << t[i].left << ' ' << t[i].right << endl; }
    dfs(m, 1, 0);
}

Measured memory_bytes: 65980
def main():
    S = input()
    if S[0] != 'k':
        if S[-7:] == 'keyence':
            print('YES')
            return
        else:
            print('NO')
            return
    if S[1] != 'e':
        if S[-6:] == 'eyence':
            print('YES')
            return
        else:
            print('NO')
            return
    if S[2] != 'y':
        if S[-5:] == 'yence':
            print('YES')
            return
        else:
            print('NO')
            return
    if S[3] != 'e':
        if S[-4:] == 'ence':
            print('YES')
            return
        else:
            print('NO')
            return
    if S[4] != 'n':
        if S[-3:] == 'nce':
            print('YES')
            return
        else:
            print('NO')
            return
    if S[5] != 'c':
        if S[-2:] == 'ce':
            print('YES')
            return
        else:
            print('NO')
            return
    if S[6] != 'e':
        if S[-1:] == 'e':
            print('YES')
            return
        else:
            print('NO')
            return
    print('YES')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#B-Qualification simulator
N, A, B = map(int, input().split())
S = input()
a = 0
b = 0

for i in S:
    if i == "a":
        if a + b < A + B:
            print ("Yes")
            a += 1
        else:
            print ("No")
    elif i == "b":
        if (a + b <A + B) and (b < B):
            print ("Yes")
            b += 1
        else:
            print ("No")
    else:
        print ("No")


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

int main() {
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    string u;
    rep(i,n){
        u += s[i];
        u += t[i];
    }
    
    cout << u << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

ll hsh(ll x) {
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9LL;
    x = (x ^ (x >> 27)) * 0x94d049bb133111ebLL;
    x = x ^ (x >> 31);
    return x;
}

ll hsh2(ll x, ll y){
	return hsh(hsh(x) + 3*hsh(y));
}

const ll md = 1e9+7;

const int mx = 200;
ll tv[mx];

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

	tv[0] = 1;
	rep(i,1,mx) tv[i] = tv[i-1]*2 % md;

	int n, m;
	cin >> n >> m;
	vector<vi> gr(n);
	rep(_,0,m){
		int x,y;
		cin >> x >> y;
		--x, y--;
		gr[y].push_back(x);
	}
	vector<vi> cnt(n, vi(n));
	map<ll, ll> dp;

	auto ways = [&](int v, vector<ll> &w){
		w[0] = 1;
		rep(i,0,n-1-v)
			w[i+1] = w[i]*(tv[cnt[v][i]]-1) % md;
		int gt = 0;
		rrep(i,0,n-v){
			gt += cnt[v][i];
			w[i] = w[i]*tv[gt] % md;
		}
		rep(i,0,n-1-v)
			w[i] -= w[i+1];
		trav(x, w) x %= md;
	};

	function<ll(int)> calc = [&](int v){
		ll myhash = hsh(v);
		rep(i,0,v+1) rep(j,0,n-2) myhash = hsh2(myhash, cnt[i][j]);
		if(!dp.count(myhash)){
			ll myans = 0;	
			if(v == 1){
				vector<vector<ll>> ws(2, vector<ll>(n));
				rep(i,0,2) ways(i, ws[i]);
				rep(i,0,n-1) myans += ws[0][i]*ws[1][i] % md;
				myans %= md;
				dp[myhash] = myans;
			} else {
				vector<ll> w(n-v);
				ways(v, w);
				ll myans = 0;
				rep(i,0,n-v) if(w[i]){
					trav(u, gr[v]) cnt[u][i]++;
					myans += w[i]*calc(v-1) % md;
					trav(u, gr[v]) cnt[u][i]--;
				}
				dp[myhash] = myans;
			}
		}
		return dp[myhash];
	};
	ll ans = tv[m] - calc(n-1);
	ans %= md;
	if(ans < 0) ans += md;
	cout << ans << endl;
}

Measured memory_bytes: 15488
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		String s = sc.next();
		int s_length = s.length();
		String dots = "...";
		String ans = "";
		if (k >= s_length) {
			System.out.println(s);
		} else {
			ans = s.substring(0,k);
			ans = ans.concat(dots);
			System.out.println(ans);
		}
		sc.close();


	}

}

Measured memory_bytes: 27040
#define REP(i,n) for (int i=0;i<(n);i++)
#include <bits/stdc++.h>
using namespace std;int n,k,x,y,b,h[2001][2001];char c;int main(){cin>>n>>k;REP(i,n){cin>>x>>y>>c;b=c=='B';x%=2*k;if(x>=k){x-=k;b^=1;}y%=2*k;if(y>=k){y-=k;b^=1;}if(b){h[0][0]++;h[x][0]--;h[0][y]--;h[x][y]+=2;}else{h[0][y]++;h[x][y]-=2;h[x][0]++;}}REP(i,k)REP(j,k)h[i][j+1]+=h[i][j];REP(i,k)REP(j,k){h[i+1][j]+=h[i][j];b=max(b,max(n-h[i][j],h[i][j]));}cout<<b<<endl;}

Measured memory_bytes: 8448
#include <stdio.h>

int main(void)
{
	char str[1201];
	int i;

	i = 0;
	while((str[i] = getchar()) != '\n')
	{
		if( ('a' <= str[i] && str[i] <= 'z') || ('A' <= str[i] && str[i] <= 'Z') )
			str[i] ^= 32;
		i++;
	}
	str[i] = '\0';
	printf("%s\n", str);

	return (0);
}



Measured memory_bytes: 2132
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
  int n, ans = 0;
  cin >> n;
  int a[n];
  for (int i=0; i<n; ++i){
    cin >> a[i];
    while((a[i]%2)==0){
      ans++;
      a[i] /= 2;
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
import re
n = int(input().split()[1])
s = input()

counts = [0]
for i in range(len(s)):
  counts.append(counts[i] + (1 if s[i : i + 2] == 'AC' else 0))

for i in range(n):
  l, r = map(int, input().split())
  print(counts[r - 1] - counts[l - 1])

Measured memory_bytes: 7916
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
ll a[200005],b[200005],res[200005],hell=pow(10,10);
void solve(){
	ll n,m;
	cin>>n>>m;
	for(ll i=1;i<=n;i++){
		cin>>a[i]>>b[i];
		res[i]=(-1);
	}
	res[n+1]=(-1);
	map<ll,ll> st;
	multiset<ll> gum;
	for(ll i=1;i<=m;i++){
		if(i>=a[1]&&i<=b[1])
			continue;
		st.insert({i,0});
		gum.insert(0);
	}
	for(ll i=2;i<=n+1;i++){
		if(gum.empty())
			break;
		res[i]=(*gum.begin())+i-1;
		auto it=st.lower_bound(a[i]);
		map<ll,ll> dum;
		ll val=hell;
		while(it!=st.end()&&it->first<=b[i]){
			dum.insert(*it);
			val=min(val,b[i]+1-it->first+it->second);
			gum.erase(gum.find(it->second));
			it++;
		}
		if(b[i]!=m&&val!=hell){
			it=st.find(b[i]+1);
			if(it!=st.end()){
				val=min(val,it->second);
				gum.erase(gum.find(it->second));
				st.erase(it);
			}
			st.insert({b[i]+1,val});
			gum.insert(val);
		}
		for(auto ut=dum.begin();ut!=dum.end();ut++)
			st.erase(ut->first);
	}
	for(ll i=2;i<=n+1;i++)
		cout<<res[i]<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++)
        solve();
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 30368
#include <bits/stdc++.h>
using namespace std;
int main () {
string s;
cin >>s;
if (s[0]!='a'&&s[0]!='b'&&s[0]!='c'||s[1]!='a'&&s[1]!='b'&&s[1]!='c'||s[2]!='a'&&s[2]!='b'&&s[2]!='c')cout<<"No";
else if (s[0]==s[1]||s[1]==s[2]||s[0]==s[2])cout<<"No";
else cout<<"Yes";



return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;

@SuppressWarnings({"rawtypes", "unchecked"})
class Main {
    final static int INF = 1 << 28;
    final static long LNF = 1L << 60;
    final static double EPS = 1e-9;
    final static double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0;

    static final long MOD = 1_000_000_007;

    public static void main(String[] args) throws Exception {
        final MyScanner sc = new MyScanner();
        long N;
        N = sc.nextLong();
        String S;
        S = sc.next();
        String T;
        T = sc.next();
        solve(N, S, T);
    }

    static void solve(long N, String S, String T){
        String[] hoge = S.split(" ");
        ArrayList<Character> ans = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            ans.add(hoge[0].charAt(i));
            ans.add(hoge[1].charAt(i));
        }
        System.out.println(ans.stream().map(e->e.toString(e)).collect(Collectors.joining()));
    }


    static class MyScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }
 
        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        String next() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }
 
        char nextChar() {
            return nn().charAt(0);
        }
 
        int nextInt() {
            return Integer.parseInt(nn());
        }
 
        long nextLong() {
            return Long.parseLong(nn());
        }
 
        double nextDouble() {
            return Double.parseDouble(nn());
        }
 
        Integer[] niArr0(int n) {
            Integer[] ar = new Integer[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Integer[] niArr1(int n) {
            Integer[] ar = new Integer[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Long[] nlArr0(int n) {
            Long[] ar = new Long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
 
        Long[] nlArr1(int n) {
            Long[] ar = new Long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
    }

}


Measured memory_bytes: 27476
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;

  int tap = 0;
  int free = 1;
  int add = A - 1;
  while (free < B) {
    if (free == 1) {
      free = A;
    } else {
      free += add;
    }
    tap++;
  }

  cout << tap << endl;
}

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

using namespace std;


#ifdef zxc

#include <sys/resource.h>
#include "debug.h"
#include "profile.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define profile(X) LOG_DURATION(X)
#else
#define debug(...) 42
#define profile(...) 42
#endif

using ll = int64_t;
using ld = double;
const ld EPS = 1e-9;
//const ll MOD = 924844033;
const ld PI = 3.141592653589793;
const int maxn = 600001;
const int MOD = 1e9 + 7;
using cd = complex<double>;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}


signed main() {
#ifdef zxc
    struct rlimit rl;
    const rlim_t kStackSize = 512L * 1024L * 1024L;
    assert(!getrlimit(RLIMIT_STACK, &rl));
    rl.rlim_cur = kStackSize;
    assert(!setrlimit(RLIMIT_STACK, &rl));
    freopen("../input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
    //            freopen("", "r", stdin);
    //        freopen("hack.out", "w", stdout);
#endif
    profile("all");

    auto solve = [](int _) {
        int n;
        cin >> n;
        map<ll, int> cnt;
        for (int i = 1; i <= n; ++i) {
            int a;
            cin >> a;
            ++cnt[a];
        }
        ll ans = 0;
        for (auto it: cnt) {
            if (it.second >= 4) {
                ans = max(ans, it.first * it.first);
            }
        }
        ll mx = 0;
        for (auto it:cnt) {
            if (it.second >= 2) {
                ans = max(ans, it.first * mx);
                mx = max(mx, it.first);
            }
        }
        cout << ans;

    };


    fast_io();
    cout.precision(9);
    cout << fixed;

    solve(1);


}


Measured memory_bytes: 6528
import java.util.Arrays;
 
public class Main {
	
	public static void main(String[] args) {
		
		java.util.Scanner scan = new java.util.Scanner(System.in);
 
		
		int N = scan.nextInt();
		int K = scan.nextInt();
		long[] H = new long[N];
		long sum = 0;
		
		
		for (int i = 0; i < N; i++) {
			H[i] = scan.nextLong();
		}
		
		if(K >= N ) {
			System.out.println(0);
			return;
		} 
		
		Arrays.sort(H);
		
		
		for(int i =N-1; K>0  ; i--) {
			H[i] = 0;
			K--;
		}
	
		for(long h : H) {
			sum += h;
		}
	
			System.out.println(sum);
		}
	
	}


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

using namespace std;

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

typedef long long ll;

int main() {
    int K, X;
    cin >> K >> X;
    int a = K-1;
    if(K-1 < 0){
        a = K+1;
    }
    for(int i = X-a; i <= X+a;i++){
        cout<<i<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
#include<ctype.h>


int main() {
	
	float R;
	scanf("%f",&R);
	
	float answer = R*2*3.14;
	
	printf("%f",answer);
	
	return 0;
}

Measured memory_bytes: 1740
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    int a,b,c=1,d;
    cin>>a>>b;
    d=(a*2)-1;
    for(int i=0; i<d; i++){
    cout<<b-(a-c)<<" ";
    c++;
    }
    cout<<'\n';
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    ll N;
    cin >> N;
    vc<pair<ll, ll>> A(N);
    rep(i, N) cin >> A[i].first >> A[i].second;

    bool isok = false;
    rep(i, N - 2){
        if ((A[i].first == A[i].second) and (A[i + 1].first == A[i + 1].second) and (A[i + 2].first == A[i + 2].second)) isok = true;
    }

    cout << (isok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3660
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iterator>
#include <iostream>
#define MAX_CARD 51
using namespace std;

int main(void) {
	int n, r;
	for (;;) {
		cin >> n >> r;
		if (n == 0 && r == 0) {
			break;
		}
		vector<int> card;
		for (int i = n; i > 0; i--) {
			card.push_back(i);
		}

		for (int i = 0; i < r; i++) {
			int p, c;
			cin >> p >> c;
			vector<int> buf;
			for (int i = p - 1; i < p + c - 1; i++) {
				buf.push_back(card[i]);
				// printf("%d\n", card[i]);
			}

			for (int i = 0, j = buf.size(); i < p - 1; i++, j++) {
				buf.push_back(card[i]);
				// printf("%d\n", card[i]);
			}

			for (int i = p + c - 1, j = buf.size(); i < card.size(); i++, j++) {
				buf.push_back(card[i]);
				// printf("%d\n", card[i]);
			}

			for (int i = 0; i < card.size(); i++) {
				card[i] = buf[i];
				//printf("%d\n", card[i]);
			}
			//printf("\n");

			// shuffle(card, p, c);
		}
		printf("%d\n", card[0]);
	}
	return 0;
}

Measured memory_bytes: 1200
#include <stdio.h>
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int n,m;
string s[20];
int swaped[20];
int used[20];
int ans = 0;
bool check()
{
	memset(used,0,sizeof used);
	for(int i=0;i<m;i++){
		for(int j=0;j<m;j++){
			if(used[i]||used[j]||i==j) continue;
			int cur=1;
			for(int k=0;k<n;k++){
				if(s[swaped[k]][i]!=s[k][j]){
					cur=0;
					break;
				}
			}
			if(cur){
				used[i]=used[j]=1;
			}
		}
	}
	int cnt=0,to=0;
	for(int i=0;i<m;i++){
		if(!used[i]){
			cnt++;to=i;
		}
	}
	if(cnt>=2||(m%2==0&&cnt)){
		return false;
	}
	if(!cnt) return true;
	for(int i=0;i<n;i++){
		if(s[swaped[i]][to]!=s[i][to]){
			return false;
		}
	}
	return true;
}


void dfs(int now,bool ji)
{
	if(now==(n+1)/2){
		if(check()){
			ans=1;
		}
		return;
	}
	for(int i=now;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(swaped[i]==-1&&swaped[j]==-1){
				swaped[i]=j;
				swaped[j]=i;
				dfs(now+1,ji);
				swaped[i]=-1;
				swaped[j]=-1;
			}
		}
		if(ji&&swaped[i]==-1){
			swaped[i]=i;
			dfs(now+1,false);
			swaped[i]=-1;
		}
	}

}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		cin>>s[i];
		swaped[i]=-1;
	}
	if(n&1){
		dfs(0,true);
	}else{
		dfs(0,false);
	}
	if(ans) printf("YES\n");
	else printf("NO\n");
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n = ii()
    print(2 * n) if n % 2 == 1 else print(n)


if __name__ == "__main__":
    main()


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++) cin >> vec.at(i);
  sort(vec.begin(), vec.end());
  int ans=1;
  for(int i=0; i<N-1; i++){
    if(vec.at(i)!=vec.at(i+1)) ans++;
  }
  cout << ans << endl;
}


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

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

  vector<int> l(n);
  for(int i = 0; i < n; i++) cin >> l[i];

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

  int sum = 0;
  for(int i = 0; i < n-1; i++) sum += l[i];

  if(l[n-1] < sum) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;

}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np

N = int(input())
H = list(map(int, input().split()))

dp = np.zeros(N)
dp[0] = 0
dp[1] = abs(H[1] - H[0])

for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(H[i]-H[i-1]), 
                dp[i-2] + abs(H[i]-H[i-2]))

print(int(dp[N-1]))

Measured memory_bytes: 22684
import sys

def S(): return sys.stdin.readline().rstrip()

N,L = map(int,S().split())

A = [L+i for i in range(N)]

if A[0] >= 0:
    print(sum(A)-A[0])
elif A[-1] <= 0:
    print(sum(A)-A[-1])
else:
    print(sum(A))

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

int main() {
  long int N, a0, a1, m = 1000;
  cin >> N;
  cin >> a0;
  for (int i = 1; i < N; i++){
    cin >> a1;
    if (a0 < a1){
      m = (m/a0)*a1 + m%a0;
    }
    a0 = a1;
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 3572
def main():
    N = int(input())
    s = [input() for i in range(N)]
    M = int(input())
    t = [input() for i in range(M)]

    dic_s = {}
    for i in range(N):
        if s[i] in dic_s:
            dic_s[s[i]] += 1
        else:
            dic_s[s[i]] = 1
            
    dic_t = {}
    for i in range(M):
        if t[i] in dic_t:
            dic_t[t[i]] += 1
        else:
            dic_t[t[i]] = 1
    
    ans = 0
    for c in list(dic_s):
        if c not in dic_t:
            ans = max(ans, dic_s[c])
            # print(c)
        else:
            if dic_s[c] > dic_t[c]:
                ans  = max(ans, dic_s[c] - dic_t[c])
                # print(c)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
# -*- coding: utf-8 -*-

def main():
    from collections import deque
    import sys
    input = sys.stdin.readline

    n, x, y = map(int, input().split())
    x -= 1
    y -= 1
    inf = 10 ** 7
    ans = [0 for _ in range(n)]

    # See:
    # https://www.youtube.com/watch?v=zG1L4vYuGrg&feature=youtu.be
    # KeyInsight:
    # △: 全探索 + 深さ優先探索
    # ×: どのように実装すればいいか、見当がつかなかった
    for i in range(n):
        # グラフを陽に持たない場合
        # 始点からの距離を管理
        dist = [inf for _ in range(n)]  # 距離無限大で初期化
        dist[i] = 0

        # キューを用意して、頂点を管理
        d = deque()
        d.append(i)

        # BFS
        while d:
            v = d.popleft()  # 最も左側の内容(=最初に突っ込んだ値)を取り出す
            dj = dist[v]

            # 場合分け
            # 範囲外参照を回避しながら、次の頂点に移動したときの距離を計算
            if v - 1 >= 0 and dist[v - 1] == inf:
                dist[v - 1] = dj + 1
                # 次の頂点をキューに突っ込む
                d.append(v - 1)
            if v + 1 < n and dist[v + 1] == inf:
                dist[v + 1] = dj + 1
                d.append(v + 1)
            if v == x and dist[y] == inf:
                dist[y] = dj + 1
                d.append(y)
            if v == y and dist[x] == inf:
                dist[x] = dj + 1
                d.append(x)

        # 距離ごとの個数を計算
        for j in range(n):
            ans[dist[j]] += 1

    # 始点と終点を区別
    for k in range(n):
        ans[k] //= 2

    # 答えを出力
    for ii in range(1, n):
        print(ans[ii])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9572
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;
int dp[2][2019];

int main(){
    string s; cin >> s;
    rep(i,2019) dp[1][i]=0;
    ll ans=0;
    int now=0;
    rep(i,s.length()){
        rep(j,2019) dp[now][(j*10+(s[i]-'0'))%2019]=dp[now^1][j];
        dp[now][s[i]-'0']++;
        ans+=dp[now][0];
        now=now^1;
    }
    cout << ans << endl;
return 0;
}



Measured memory_bytes: 3708
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> a(n),b(n);
	for(int i=0;i<n;++i){
		cin>>a[i];
	}
	for(int i=0;i<n;++i){
		cin>>b[i];
	}
	double r1,r2,r3,r4;
	r1=r2=r3=r4=0;
	for(int i=0;i<n;++i){
		r1+=abs(a[i]-b[i]);
		r2+=pow(a[i]-b[i],2.0);
		r3+=abs(pow(a[i]-b[i],3.0));
		r4 = max(r4,abs((double)a[i]-b[i]));	
	}
	r2=pow(r2,0.5);
	r3=pow(r3,1/3.0);
	printf("%.6f\n%.6f\n%.6f\n%.6f\n",r1,r2,r3,r4);
	return 0;
}



Measured memory_bytes: 3332
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 998244353;
const ll INF = 1e18;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()

template<typename T>
struct BIT {
    int N;
    vector<T> data;
    BIT(int N) : N(N) {
        data.resize(N+1,0);
    }
    T sum(int k) {
        T res=0;
        for(;k>0;k-=k&-k) {
            res+=data[k];
        }
        return res;
    }
    void add(int k, T x) {
        for(;k<=N;k+=k&-k) {
            data[k]+=x;
        }
    }
    int lowerBound(int w) {
        if (w<=0) return 0;
        int x=0;
        int k=1;
        while(k*2<=N) k*=2;
        for (;k>0;k/=2) {
            if(x+k<=N&&data[x+k]<w){
                w-=data[x+k];
                x+=k;
            }
        }
        return x+1;
    }
};

int main(){
	ll n, q; cin >> n >> q;
	BIT<int> rr(n), uu(n);
	ll ans=(n-2)*(n-2);
	while(q--){
		int t, x;
		cin >> t >> x;
		x=n-x;
		if(t==1){
			int y=n-2-rr.sum(x);
			ans-=y;
			int z=uu.sum(n-y-1);
			if(z<x){
				uu.add(n-y-1,x-z);
			}
		}
		else{
			int y=n-2-uu.sum(x);
			ans-=y;
			int z=rr.sum(n-y-1);
			if(z<x){
				rr.add(n-y-1,x-z);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4764
#include<iostream>
#include<cstring>
typedef long long ll;
using namespace std;
char in[10000000];
char go[10000000];
int main(void){


    ll n;
    char before[1000];
    char after[1000];

    for(;;){
    cin >> n;
    if(n==0)break;
    for(int i=0;i<n;i++){
        cin >> before[i];
        cin >> after[i];
    }
    ll m;
    cin >> m;
    for(int i=0;i<m;i++){
        cin >> in[i];
        go[i]=in[i];

    }



        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                if(in[i]==before[j]){
                    go[i]=after[j];
                    }



            }
        }




        cout<<go<<endl;


    }
	return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

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

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

    ll N;
    string S;
    cin >> N;
    vector<ll> vec(N);
    REP(i,N){
        cin >> vec.at(i);
    }

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

    ll size = 1;

    REP(i,N-1){
        if(!(vec.at(i)==vec.at(i+1))){
            size++;
        }
    }

    vector<ll> nakami(size+2);
    vector<ll> kazu(size+2);

    REP(i,size){
        kazu.at(i) = 1;
    }

    nakami.at(0) = vec.at(0);
    ll j = 0;

    REP(i, N - 1)
    {
        if (vec.at(i) == vec.at(i + 1))
        {
            kazu.at(j)++;
        }
        else{
            j++;
            nakami.at(j) = vec.at(i + 1);
        }
    }
    nakami.at(size) = 0;
    nakami.at(size + 1) = 0;
    kazu.at(size) = 0;
    kazu.at(size + 1) = 0;

    ll ans = 0;

    REP(i,size){
        ll tmp = 0;
        if(nakami.at(i+1)<=nakami.at(i)+2&&nakami.at(i)<nakami.at(i+1)){
            tmp += kazu.at(i) + kazu.at(i + 1);
            if (nakami.at(i + 2) <= nakami.at(i) + 2 && nakami.at(i) < nakami.at(i + 2)){
                tmp += kazu.at(i + 2);
            }
        }
        else{
            tmp += kazu.at(i);
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;

    /*vector<ll> sa(N-1);

    REP(i,N-1){
        sa.at(i) = vec.at(i + 1) - vec.at(i);
    }

    ll tmp = 0;
    ll count = 1;
    ll ans = 1;
    REP(i, N - 1)
    {
        tmp += sa.at(i);
        
        if (tmp > 2)
        {
            ans = max(ans, count);
            count = 1;
            tmp = 0;
        }
        else{
            count++;
        }
    }
    if(tmp<=2){
        ans = max(ans, count);
        count = 1;
    }
    else{
        ans = 1;
    }
    cout << ans << endl;*/
}


Measured memory_bytes: 2048
#include <iostream>
#include <cstdio>
#include <algorithm>
#define int long long
#define N 100002
using namespace std;
int n,i,j,k,a[N],b[N],c[N];
int read()
{
	char c=getchar();
	int w=0;
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0'){
		w=w*10+c-'0';
		c=getchar();
	}
	return w;
}
signed main()
{
	n=read();
	for(i=1;i<=n;i++) a[i]=read();
	for(i=1;i<=n;i++) b[i]=read();
	for(i=1;i<=n;i++) c[i]=read();
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	int ans=0;
	for(i=j=k=1;j<=n;j++){
		while(a[i]<b[j]&&i<=n) i++;
		while(c[k]<=b[j]&&k<=n) k++;
		ans+=(i-1)*(n-k+1);
	}
	printf("%lld\n",ans);
	return 0;
}


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

typedef long long ll;
const int N = 300005;
int n,m,a[N];
ll p[N];
int main()
{
	ll all = 0;
	cin >> n >> m;
	for(int i = 0;i < n;i++)
		scanf("%d",&a[i]);
	for(int i = 1;i < n;i++)
	{
		int l = a[i-1],r = a[i];
		if(l > r) r += m;
		all += r-l;
		if(r-l > 1)
		{
			p[l+2]++;
			p[r+1] -= (r-(l+2)+1) + 1;
			p[r+2] += (r-(l+2)+1);
		}
	}

	for(int i = 1;i <= m*2;i++) p[i] += p[i-1];
	for(int i = 1;i <= m*2;i++) p[i] += p[i-1];
	ll ans = -1;
	for(int i = 1;i <= m;i++)
		ans = max(ans,p[i]+p[i+m]);
	cout << all-ans << endl;
	return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
long long int n, a[100005], val[100005],set[100005];
int findSet(int x) {
	if (set[x] == x)
		return x;
	return set[x] = findSet(set[x]);
}

void unionSet(int x, int y)
{
	int fx = findSet(x);
	int fy = findSet(y);
	if(fx!=fy)
		set[fx] = fy;
}
struct road {
	long long int len,turn1,turn2;
};
struct road rx[100005],ry[100005];
struct point {
	long long int x,y,turn;
};
struct point po[100005],po2[100005];
bool cmp(struct point p1, struct point p2)
{
	if(p1.x<p2.x)	return true;
	if(p1.x>=p2.x)	return false;
}
bool cmp2(struct point p1, struct point p2)
{
	if(p1.y<p2.y)	return true;
	if(p1.y>=p2.y)	return false;
}

bool cmprx(struct road r1, struct road r2)
{
	if(r1.len<r2.len)	return true;
	if(r1.len>=r2.len)	return false;
}
bool cmpry(struct road r1, struct road r2)
{
	if(r1.len<r2.len)	return true;
	if(r1.len>=r2.len)	return false;
}
int main()
{
	int i,j;
	scanf("%lld",&n);
	for(int i=0; i<=n; i++)	set[i] =i;
	for(i=0; i<n; i++)
    {
		scanf("%lld%lld",&po[i].x,&po[i].y);
		po2[i].x = po[i].x;
		po2[i].y = po[i].y;
		po[i].turn = i+1;
		po2[i].turn = i+1;
	}
	sort(po,po+n,cmp);
	sort(po2,po2+n,cmp2);
	for(i=1; i<n; i++)
    {
		rx[i-1].turn1 = po[i-1].turn;
		rx[i-1].turn2 = po[i].turn;
		rx[i-1].len = fabs(po[i-1].x - po[i].x);
	}
	for(i=1; i<n; i++)
    {
		ry[i-1].turn1 = po2[i-1].turn;
		ry[i-1].turn2 = po2[i].turn;
		ry[i-1].len = fabs(po2[i-1].y - po2[i].y);
	}
	sort(rx,rx+n-1,cmprx);
	sort(ry,ry+n-1,cmpry);
	long long int ans = 0;
	int fc1=0,fc2=0;
	int count = 0;
	for(; count<n-1; )
    {
		long long int r1 = rx[fc1].len, r2 = ry[fc2].len;
		if(r1<r2) {
			if(findSet(rx[fc1].turn1)!=findSet(rx[fc1].turn2))
            {
				ans+=rx[fc1].len;
				unionSet(rx[fc1].turn1,rx[fc1].turn2);
				count++;
			}
			fc1++;
		} else {
			if(findSet(ry[fc2].turn1)!=findSet(ry[fc2].turn2))
            {
				ans+=ry[fc2].len;
				unionSet(ry[fc2].turn1,ry[fc2].turn2);
				count++;
			}
			fc2++;
		}
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 10496
#include<stdio.h>
long long int gcd(long long int a,long long int b){
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
    int main()
    {
    	long long int a,b;
    	while(scanf("%lld %lld",&a,&b)!=EOF){
    		
    		printf("%lld %lld\n",gcd(a,b),a/gcd(a,b)*b);
    		
		}
    	return 0; 	
	}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int n,k;cin>>n>>k;
    vector<ll> h(n);
    rep(i,n) cin>>h[i];
    sort(h.begin(),h.end());
    ll res=1e+10;
    for(int i=0;i+k-1<n;i++){
        res=min(res,h[i+k-1]-h[i]);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1024
#-*- coding: utf-8 -*-
"""
https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_a
"""

from collections import defaultdict
def sol(n, m, Ss):
    stack = defaultdict(int)
    all_like = 0

    for S in Ss:
        #print("S: %s," % S)
        for i, s in enumerate(S):
            if i == 0: continue
            #print("i:%s, s:%s" % (i, s))
            stack[s] += 1
            #print("stack: %s" % stack)
            if stack[s] == n:
                all_like +=1
    return all_like



test = False
#test = True
if test:
    n, k = 3, 4
    Ss = [
        [2, 1, 3],
        [3, 1, 2, 3],
        [2, 3, 2]
    ]
    #S =list( map(int, "1 6 3".split()))
    print(sol(n, k, Ss))


else:
    n, k = map(int, input().split())
    #print("%s %s %s %s" % (type(n), type(k), n, k))
    Ss = []
    for i in range(n):
        S =list( map(int, input().split()))
        Ss.append(S)
    print(sol(n, k, Ss))




Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define INF 10000000000

ll a, b, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s;

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

    cin >> s;
    char tmp = 'a';
    if(s.size() < 26){
        while(s.find(tmp) != string::npos){
            tmp++;
        }
        cout << s << tmp << endl;
    }else{
        rep(i, 25){
            if(s[24 - i] < s[24 - i + 1]){
                char c = s[24 - i + 1];
                rep(j, 24 - i + 1, 26){
                    if(s[j] > s[24 - i]){
                        c = min(c, s[j]);
                    }
                }
                cout << s.substr(0, 24 - i) << c << endl;
                return 0;
          }
      }
      cout << -1 << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    unsigned long int x;
    cin>>x;
    vector <pair<int,int>> v;
    v.push_back(make_pair(500,1000));
    v.push_back(make_pair(5,5));
    int happiness = 0;
    for (auto k:v){
        while (x >= k.first){
            x -= k.first;
            happiness += k.second;
        }
    }
    cout<<happiness<<"\n";
    return 0;

}

Measured memory_bytes: 256