akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int n,mod,f[5010][5010],x,y,s1[5010][5010],s2[5010][5010];

int main()
{
	scanf("%d%d",&n,&mod),x=1,y=0;
	if (n==2) return printf("3\n"),0;
	for (int i=1; i<=n; i++) f[i][n-i]=1;
	for (int j=1; j<=n; j++)
	{
		s2[j][n-j]=f[j][n-j];
		for (int k=n-j-1; k>=0; k--) s2[j][k]=(s2[j][k+1]+f[j][k]>=mod?s2[j][k+1]+f[j][k]-mod:s2[j][k+1]+f[j][k]);
		s1[j][n-j]=s2[j][n-j];
		for (int k=n-j-1; k>=0; k--) s1[j][k]=(s1[j][k+1]+s2[j][k]>=mod?s1[j][k+1]+s2[j][k]-mod:s1[j][k+1]+s2[j][k]);
	}
	for (int i=2,nw=n/(i-1); i<=n+1>>1; i++,nw=n/(i-1))
	{
		for (int j=1; j<=n; j++)
			for (int k=0; k<=nw&&j+k<=n; k++) f[j][k]=s1[j+k][k];
		for (int j=1,lim; j<=n; j++)
		{
			lim=min(n-j,nw);
			s2[j][lim]=f[j][lim];
			for (int k=lim-1; k>=0; k--) s2[j][k]=(s2[j][k+1]+f[j][k]>=mod?s2[j][k+1]+f[j][k]-mod:s2[j][k+1]+f[j][k]);
			s1[j][lim]=s2[j][lim];
			for (int k=lim-1; k>=0; k--) s1[j][k]=(s1[j][k+1]+s2[j][k]>=mod?s1[j][k+1]+s2[j][k]-mod:s1[j][k+1]+s2[j][k]);
		}
	}
	int ans=0;
	for (int j=1; j<=n; j++) 
		if (n&1) ans=(ans+s2[j][0])%mod;
		else ans=(ans+s1[j][0])%mod;
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    int n, m;
    cin >> n;
    map<string, int> cards;
    rep(i,n) {
        string s;
        cin >> s;
        cards[s]++;
    }
    cin >> m;
    rep(i,m) {
        string t;
        cin >> t;
        if (!cards.count(t)) cards[t] = 0;
        cards.at(t)--;
    }

    int ans = 0;
    for (auto card : cards) {
        ans = max(ans, card.second);
    }
    if (ans < 0) ans = 0;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3592
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define sort_key(struct_name,key_name) [](const struct_name &x, const struct_name &y){return x.key_name < y.key_name;}
typedef long long ll;
using namespace std;

//main
int main(){
  int H,W,h,w;
  cin >> H >> W;
  cin >> h >> w;
  cout << H*W-h*W-w*H+w*h << endl;
}


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


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

    int n, x, sum = 0, ans = 1;
    cin >> n >> x;
    for(int i=1;i<=n;i++){
        int k; cin >> k;
        sum += k;
        if(sum <= x)ans++;
    }
    cout << ans << '\n';


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdbool.h>
#include <iostream>

using namespace std;

int main()
{
	int i, j, v;
	
	cin >> v;

	for (i = 1;i < 10;i++)
	{
		
			if (v%i == 0)
			{
				if (v / i < 10)
				{
					cout << "Yes" << endl;
					return 0;
				}
			}

	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;

int main(void)
{
	int i,j,n,m,k,par[100001],len[100001],bu[100001];
	int c,a,b,a1,b1;
	scanf("%d %d %d",&n,&m,&k);
	for(i=1;i<=n;i++)	{
		par[i]=0;	len[i]=1;	bu[i]=0;
	}
	for(i=1;i<=k;i++)	{
		scanf("%d %d %d",&c,&a,&b);
		if(c==1)	{
			a1=a;
			while(par[a1]!=0)	a1=par[a1];
			b1=b;
			while(par[b1]!=0)	b1=par[b1];
//			printf(" %d %d\n",a1,b1);
			if(bu[a1]!=0 && bu[b1]!=0 && bu[a1]!=bu[b1])	break;
			if(a1!=b1)	{
				if(len[a1]>len[b1])	{
					par[b1]=a1;
					if(bu[a1]==0)	bu[a1]=bu[b1];
				}
				else if(len[a1]<len[b1])	{
					par[a1]=b1;
					if(bu[b1]==0)	bu[b1]=bu[a1];
				}
				else {
					par[b1]=a1;
					len[a1]++;
					if(bu[a1]==0)	bu[a1]=bu[b1];
				}
			}
		}
		else {
			a1=a;
			while(par[a1]!=0)	a1=par[a1];
			if(bu[a1]!=0 && bu[a1]!=b)	break;
			else bu[a1]=b;
		}
	}
	if(i>k)	printf("0\n");
	else printf("%d\n",i);
	return 0;
}
		


Measured memory_bytes: 3868
N,Y = map(int,input().split())
for a in range(N+1):
    for b in range(N+1):
        if Y== 10000*a+5000*b+1000*(N-a-b) and N-a-b>=0:
            print(str(a)+' '+str(b)+' '+str(N-a-b))
            break
    else:
            continue
    break
else:
    print('-1 -1 -1')

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

static const int N = 1010;

unordered_map<int, pair<int, int>>
guruguru(vector<vector<int>>& field, const unordered_set<int>& indices)
{
    static int dy[] = { 0, -1, 0, 1 };
    static int dx[] = { 1, 0, -1, 0 };
    int h = field.size();
    int w = field[0].size();
    int y = h / 2;
    int x = w / 2;
    int dir = 0;
    int i = 1;
    int a = 0;          // 最後に曲がってからの歩数
    int b = 1;          // 次に曲がるまでの歩数
    int c = 0;          // 最後に b が増えてからの曲がった回数
    unordered_map<int, pair<int, int>> index2pos;

    while (0 <= y && y < h && 0 <= x && x < w) {
        field[y][x] = i;
        if (indices.find(i) != end(indices))
            index2pos[i] = make_pair(y, x);

        ++i;
        y += dy[dir];
        x += dx[dir];
        ++a;
        if (a == b) {
            dir = (dir + 1) % 4;
            a = 0;
            ++c;
            if (c == 2) {
                ++b;
                c = 0;
            }
        }
    }

    return move(index2pos);
}

vector<bool> sieve(int n)
{
    vector<bool> prime(n + 1, true);
    prime[0] = prime[1] = false;
    for (int i = 2; i * i <= n; ++i) {
        if (prime[i]) {
            for (int j = i * i; j <= n; j += i)
                prime[j] = false;
        }
    }
    return move(prime);
}

int main()
{
    vector<pair<int, int>> inputs;
    unordered_set<int> indices;
    int m, n;
    for (int i = 0; cin >> m >> n, m | n; ++i) {
        inputs.emplace_back(m, n);
        indices.insert(n);
    }

    vector<vector<int>> field(N, vector<int>(N));
    auto index2pos = guruguru(field, indices);
    auto prime = sieve(N * N);

    for (int t = 0; t < (int)inputs.size(); ++t) {
        pair<int, int> ans;
        vector<vector<pair<int, int>>> dp(N, vector<pair<int, int>>(N, make_pair(-10000, 0)));
        int sy = index2pos[inputs[t].second].first;
        int sx = index2pos[inputs[t].second].second;
        ans = dp[sy][sx] = make_pair(prime[field[sy][sx]], (prime[field[sy][sx]] ? field[sy][sx] : 0));
        for (int y = sy + 1; y < N; ++y) {
            for (int x = 1; x < N - 1; ++x) {
                if (field[y][x] > inputs[t].first)
                    continue;
                auto prev = max(dp[y-1][x-1], max(dp[y-1][x], dp[y-1][x+1]));
                if (prime[field[y][x]]) {
                    dp[y][x] = make_pair(prev.first + 1, field[y][x]);
                } else {
                    dp[y][x] = prev;
                }
                ans = max(ans, dp[y][x]);
            }
        }

        cout << ans.first << ' ' << ans.second << endl;
    }
}

Measured memory_bytes: 13148
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> H){
    H[0]--;
    rep(i,N-1){
        if(H[i]<=H[i+1]-1){
            H[i+1]--;
        }
    }
    rep(i,N-1){
        if(H[i]>H[i+1]){
            op("No")
            return;
        }
    }
    op("Yes")
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, std::move(H));
    return 0;
}


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

int		main(void)
{
	int x1, y1, x2, y2;

	cin >> x1 >> y1 >> x2 >> y2;
	int x3 = x2 - (y2 - y1);
	int y3 = y2 + (x2 - x1);
	int x4 = x1 - (y2 - y1);
	int y4 = y1 + (x2 - x1);

	printf("%d %d %d %d\n", x3, y3, x4, y4);
}



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

const ll INF = (1LL << 60) * (-1);

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


int main()
{
    int n; cin >> n;
    int a[n+10][3];
    rep(i, n) rep(j, 3) cin >> a[i][j];
    ll dp[n+10][3] = {0};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j != k) chmax(dp[i+1][k], dp[i][j] + a[i][k]);
            }
        }
    }
    ll ans = 0;
    rep(i, 3) chmax(ans, dp[n][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7032
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    A,B,C,D = map(int, lines.pop(0).split(' '))
    if abs(A - C) <= D or ( abs(A - B) <= D and abs(B - C) <= D ):
        print('Yes')
    else:
        print('No')

#
# main
#

# 1. use list instead of stdin

# contents = '''\
# 10 10 10 1\
# '''
# lines = contents.split('\n')

# 2. use stdin

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,c[60],v[60],a[60],sum=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>c[i];}
		for(int i=0;i<n;i++){
			cin>>v[i];}
			for(int i=0;i<n;i++){
				a[i]=c[i]-v[i];
				if(a[i]>0)
				sum+=a[i];}
				cout<<sum;}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<tuple>
#include<complex>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

using namespace std;

ll fact(ll n) {
	ll res = 1;
	ll size = n;
	REP(i, size) {
		res *= n;
		res = res % MOD;
		--n;
	}
	return res;
}

int main() {
	int n, m;
	cin>>n>>m;
	if(n > m) swap(n, m);
	ll res = 1;
	if(m - n > 1) cout<<0<<endl;
	else if(m - n == 1) {
		res = fact(m);
		res *= fact(n);
		res = res % MOD;
		cout<<res<<endl;
	} else {
		res *= fact(n) * fact(m);
		res = res % MOD;
		res *= 2;
		res = res % MOD;
		cout<<res<<endl;
	}

}

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

int main(){
    int n, h, w;
    cin >> n >> h >> w;

    int ans = 0;
    for(int i=0; i<n; i++){
        int a, b;
        cin >> a >> b;
        if(a >= h && b >= w) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
void main()
{
    long n, m, x;
    rdVals(n, m, x);
    long[] c = new long[n];
    long[][] a = new long[][](n, m);
    foreach (i; 0 .. n)
    {
        long[] tmp = rdRow;
        c[i] = tmp[0], a[i] = tmp[1..$];
    }

    long result = inf;
    foreach (i; 1 .. 1L<<n)
    {
        long money;
        long[] list = new long[m];
        foreach (j; 0 .. n)
        {
            if ((i >> j) & 1)
            {
                money += c[j];
                foreach (k; 0 .. m)
                {
                    list[k] += a[j][k];
                }
            }
        }
        if (list.all!(y => y >= x))
        {
            result = min(result, money);
        }
    }

    writeln(result == inf ? -1 : result);
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

#define pll pair<ll,ll>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const ll mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

const int N = 2e5 + 10;
int ans[N];

void solve()
{
    ll n, k; cin>>n>>k;
    ll ans = 0;
    REP(i, k, n+1)
    {
        ll mn = 1LL*i*(i-1)/2;
        ll mx = 1LL*n*(n+1)/2 - 1LL*(n-i)*(n+1-i)/2;
        // watch(mn); watch(mx);
        ans = (ans + mx-mn + 1) % mod;
    }
    cout<<ans;
}

int main()
{
    // clock_t start, end;
    // start = clock();
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    int t = 1;
    // cin>>t;
    REP(i, 1, t)
    {
        solve();
        
    }
    // end = clock();
    // double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    // watch(time_taken);
    return 0;
    
}



/*before sub
TEST: 0, 1, equal, -ve, bounds(random and ez)
ERR/WA: loop vars, out of bounds, endl, finish taking inputs, large doubles, larger INF, corr mod, t
RE: double dec, integer overflow(ll or 1LL mult)
*/





Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    string s, t;
    cin >> s >> t;
    ll i, j, m = s.size(), n = t.size();
    ll dp[m + 1][n + 1];
    memset(dp, 0, sizeof dp);
    for(i = 1; i <= m; i++)
    {
        for(j = 1; j <= n; j++)
        {
            if(s[i - 1] == t[j - 1])
                dp[i][j] = 1 + dp[i - 1][j - 1];
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    ll ans = dp[m][n];
    string temp = "";
    for(i = m; i >= 1 && ans; i--)
    {
        for(j = n; j >= 1 && ans; j--)
            if(s[i - 1] == t[j - 1] && dp[i][j] == ans)
            {
                temp += t[j - 1], ans--;
                break;                
            }
    }
    reverse(all(temp));
    cout << temp << endl;
    return 0;
}

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

int main() {
  int a,b,sub;
  cin >> a >> b;
  sub = a+b;
  if(sub%2 == 0){
    cout << sub/2 << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int s, ans;
    vector<int> a;
    cin >> s;
    a.push_back(s);
    for (int i = 1; i <= 1000000; ++i) {
        int tmp, n = a[i-1];
        if (n % 2) {
            tmp = 3 * n +1;
        } else {
            tmp = n / 2;
        }
        if (find(a.begin(), a.end(), tmp) != a.end()) {
            ans = i;
            break;
        }
        a.push_back(tmp);
    }
    cout << ++ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n=int(input())
l=tuple(map(int,input().split()))
ret=[]
ll=[0]*n
ans=0
for i in range(n,0,-1):
    s=l[i-1]
    for j in range(2,n//i+1):
        s-=ll[j*i-1]
        s%=2
    ll[i-1]=s
    ans+=s
    if s:ret.append(i)
print(ans)
if ans:print(*ret,sep=" ")

Measured memory_bytes: 14008
def main():
    N = int(input())
    A = list(map(int, input().split()))

    MOD = 10 ** 9 + 7

    lst = [0] * 65
    for a in A:
        tmp = a
        for i in range(61):
            lst[i] += tmp % 2
            tmp //= 2
            if tmp == 0:
                break

    calc = [1]
    for i in range(65):
        calc.append((calc[-1] * 2) % MOD)

    ans = 0
    for a in A:
        tmp = a
        for i in range(61):
            n = tmp % 2
            tmp //= 2
            if n == 1:
                ans += (calc[i] * (N - lst[i])) % MOD
            else:
                ans += (calc[i] * lst[i]) % MOD
        ans %= MOD

    def modinv(a, m): #mod m でのaの逆元 a^{-1}を計算する
        b = m
        u = 1
        v = 0
        while b:
            t = a//b
            a -= t * b
            a, b = b, a
            u -= t * v
            u, v = v, u
        
        u %= m
        if u < 0:
            u += m
        return u

    # print (ans)
    ans *= modinv(2, MOD)
    print (ans % MOD)

if __name__ == '__main__':
    main()

Measured memory_bytes: 123056
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, M = list(map(int, sys.stdin.buffer.readline().split()))
AB = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]

AB.sort()

counts = np.zeros(N, dtype=int)
stack = []
ans = 0
p = 0
for a, b in AB:
    a -= 1
    b -= 1
    while True:
        if counts[p] > 0:
            while stack:
                r = stack.pop()
                counts[r] -= 1
            ans += 1
        if p >= a:
            break
        p += 1
    stack.append(b)
    counts[b] += 1
    # print(a, b, p, ans)
if stack:
    ans += 1
print(ans)


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

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? " " : "");
    outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? "\n" : "");
    outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
    cout << head;
    outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

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

    var(int, H, W, a, b);

    auto mat = make_v(0, H, W);

    rep(i, b) rep(j, a) mat[i][j] = 1;
    reps(i, b, H - 1) reps(j, a, W - 1) mat[i][j] = 1;

    rep(i, H) {
        outn(mat[i]);
        outl();
    }

    return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
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 ans = 0;
	for( int i = 0; i < N - 2; i++ ) {
		for( int j = i + 1; j < N - 1; j++ ) {
			for( int k = j + 1; k < N; k++ ) {
				int a = L[i];
				int b = L[j];
				int c = L[k];
				if( c >= a + b ) break;
				if( a < b + c && b < c + a && c < a + b ) ans++;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
=begin
Volume0-0024
=end
require 'bigdecimal'
fh=STDIN
#fh=open("x.txt")

while fh.gets do
  vl = BigDecimal.new($_.chomp)
  y=(vl/9.8)**2*4.9
  yl=((y + 5.0) / 5.0).ceil
  puts yl
end

Measured memory_bytes: 8772
#include <stdio.h>
#define MAX 100000

typedef struct {
  char design;
  int number;
} CARD;

int Partition(CARD*, int, int);
void Swap(CARD*, CARD*);
void QuickSort(CARD*, int, int);
void merge(CARD*, int, int, int);
void mergeSort(CARD*, int, int);

main(){
  int n, i, j, x;
  char c;
  CARD A[MAX], B[MAX];

  scanf("%d", &n);

  for( i = 0; i < n; i++){
    scanf(" %c%c%d", &A[i].design, &c, &A[i].number);
    B[i] = A[i];
  }

  QuickSort(A, 0, n-1);

  mergeSort(B, 0, n);

  for( i = 0; i < n; i++){
    if( A[i].number == B[i].number && A[i].design != B[i].design ){
      printf("Not stable\n");
      break;
    }
    if( i == n-1 ) printf("Stable\n");
  }

  for( i = 0; i < n; i++){
    printf("%c %d\n", A[i].design, A[i].number);
  }

  return 0;

}



void QuickSort(CARD *A, int p, int r){
  int q;

  if( p < r ){
    q = Partition(A, p, r);
    QuickSort(A, p, q-1);
    QuickSort(A, q+1, r);
  }

}


int Partition(CARD *A, int p, int r){
  int x, i, j, k;

  x = A[r].number;
  i = p-1;

  for( j = p; j < r; j++){

    if( A[j].number <= x ){
      i = i+1;
      Swap(&A[i], &A[j]);
    }

  }

  Swap(&A[i+1], &A[r]);

  return i+1;

}



void Swap(CARD *A, CARD *B){
  CARD x;

  x = *A;
  *A = *B;
  *B = x;

}


void merge(CARD *seq, int left, int mid, int right){
  int n1, n2, i, j, k;
  CARD L[MAX], R[MAX];

  n1 = mid - left;
  n2 = right - mid;

  for( i = 0; i < n1; i++){
    L[i] = seq[left+i];
  }

  for( i = 0; i < n2; i++){
    R[i] = seq[mid+i];
  }

  L[n1].number = 1000000000;
  R[n2].number = 1000000000;

  i = 0;
  j = 0;

  for( k = left; k < right; k++){

    if( L[i].number <= R[j].number ){
      seq[k] = L[i];
      i = i + 1;
    }

    else{
      seq[k] = R[j];
      j = j + 1;
    }

  }

}


void mergeSort(CARD *seq, int left, int right){
  int mid;

  if( left+1 < right ){

    mid = ( left + right ) / 2;

    mergeSort(seq, left, mid);

    mergeSort(seq, mid, right);

    merge(seq, left, mid, right);

  }

}

Measured memory_bytes: 2960
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
using namespace std;

int main() {
	int n, k;
	string s;
	cin >> n >> k>>s;
	if (s[k-1]=='A') {
		s[k-1] = 'a';
	}else if (s[k-1] == 'B') {
		s[k-1] = 'b';
	}else {
		s[k-1] = 'c';
	}
	cout << s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int64_t N,A,B;
  cin>>N>>A>>B;
  if(N==1&&A!=B){cout<<0<<endl;}
  else if(N>=2&&A>B){cout<<0<<endl;}
  else{cout<<(N-2)*(B-A)+1<<endl;}
  return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;
const ll inf = 1001001001;
const ll mod = 1000000007;

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<int>a(n);
    vector<int>b(n);
    ll b2 =0, c2=0;
    vector<int>c(n);
    rep(i, 0, n)cin >> a[i];
    rep(i, 0, n){
        rep(j, i, n){
            if(a[i] > a[j])b2++;
        }
        rep(j, 0, i){
            if(a[j] < a[i])c2++;
        }
    }
    ll d = ((k+1)*k)/2;
    ll e = ((k-1)*k)/2;
    ll ans = ((b2*(d%mod))%mod+(c2*(e%mod))%mod)%mod;

    cout << ans << endl;
}

Measured memory_bytes: 3652
import numpy as np
import sys
sys.setrecursionlimit(10 **9)


S = str(input())
dp = [0] * (2 * len(S))

#再帰関数
def check(i): #i最初の文字
    flag0 = False
    flag1 = False
    flag2 = False
    flag3 = False
    flag4 = False
    flag5 = False
    if dp[i+5] != 0 or dp[i+6] != 0 or dp[i+7] != 0:
        return dp[i+5] or dp[i+6] or dp[i+7]
    #S[i:]=残りが条件を満たす
    if S[i:] == 'dream' or S[i:] == 'dreamer' or S[i:] == 'erase' or S[i:] == 'eraser':
        return True
    if S[i:i+7] == 'dreamer': #dreamerを使った時に、条件を満たすかを再帰で計算
        dp[i+7] = check(i+7)
        flag2 = dp[i+7]
    if S[i:i+5] == 'dream':
        dp[i+5] =  check(i+5)
        flag3 =  dp[i+5]
    if S[i:i+6] == 'eraser':
        dp[i+6] =  check(i+6)
        flag4 =  dp[i+6]
    if S[i:i+5] == 'erase':
        dp[i+5] =  check(i+5)
        flag5 = dp[i+5]
    return flag0 or flag1 or flag2 or flag3 or flag4 or flag5 #どれかがTrueならOK

if check(0):
    print ('YES')
else:
    print ('NO')

Measured memory_bytes: 28676
def main():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    score = {"r": P, "s": R, "p": S}
    T = input()
    skip = set()
    ans = 0
    for i in range(N):
        if i >= K and T[i] == T[i-K] and (i-K) not in skip:
            skip.add(i)
            continue
        ans += score[T[i]]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 42480
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int main(){
  int X, Y;
  while(scanf("%d%d", &X, &Y) && X+Y){
    int board[15][15], dp[17][15] = {};
    rep(i, Y) rep(j, X) if(scanf("%d", &board[i][j])  && board[i][j] == 1) dp[i][j] = -1;

    rep(i, X) if(!dp[0][i]) dp[0][i] = 1;

    rep(i, Y-1) rep(j, X){
      if(board[i][j] == 1) continue;
      else if(board[i][j] == 2 && board[i+2][j] != 1) dp[i+2][j] += dp[i][j];
      else if(board[i][j] == 0){
	for(int k = -1; k < 2; k++){
	  if(j+k < 0 || j+k >= X) continue;
	  if(dp[i+1][j+k] == -1) continue;
	  if(board[i+1][j+k] == 2){
	    if(k != 0) continue;
	    dp[i+1][j+k] += dp[i][j];
	  }else{
	    dp[i+1][j+k] += dp[i][j];
	  }
	}
      }
    }

    ll res = 0;
    REP(i, Y-1, Y+2)
      rep(j, X)
      if(dp[i][j] != -1)
	res += dp[i][j];
  
    /*    rep(i, 17){ 
      rep(j, 15) printf("%d ", dp[i][j]);
      puts("");
      }*/

    printf("%lld\n", res);
  }
  return 0;
}

Measured memory_bytes: 1188
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   	map<string, ll> m;
   	m["AC"] = 0;
   	m["WA"] = 0;
   	m["TLE"] = 0;
   	m["RE"] = 0;
   	ll n;
   	cin >> n;
   	while(n--) {
   		string temp;
   		cin >> temp;
   		m[temp]++;
   	}
   	vector<string> v;
   	v.pb("AC");
   	v.pb("WA");
   	v.pb("TLE");
   	v.pb("RE");
   	for(auto u: v) {
   		cout << u << " x " << m[u] << "\n";
   	}
}

Measured memory_bytes: 3656
s1 = int(input())
s2 = int(input())
s3 = int(input())
s4 = int(input())
s5 = int(input())
s6 = int(input())
s7 = int(input())
s8 = int(input())
s9 = int(input())
s10 = int(input())

list = [s1, s2, s3, s4, s5, s6, s7, s8, s9, s10]
S = 0

for i in range(10):
    S = S + list[i]

print(S)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ll n,a[200005];
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ll h[200005];
	unsigned long long int sum=0;
	for(int i=1;i<n;i++)
	{
		if(a[i]<a[i-1])
		{
			h[i]=a[i-1]-a[i];
			a[i]+=h[i];
			sum+=h[i];
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 5100
#include<stdio.h>
int main ()
{
     int a,b,c,n,t=0,M;
    scanf("%d %d %d",&a,&b,&c);
    for(n=a;n<=b;n++)
    {
        if(c%n==0)
            t++;
    }
    printf("%d\n",t);
    return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include<string>
#include<algorithm>
#include<stdio.h>

using namespace std;

int main(){
    int a,b;
    char x;
    cin>>a>>x>>b;
    if(x=='-')cout<<a-b<<endl;
    if(x=='+')cout<<a+b<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b,x,z;
    bool s = false;
    z = 0;
    cin >> a >> b >> x;
    while(b != -1){
        if(a+z == x){
            s = true;
            break;

        }
        z++;
        b--;
    }
    if(s){
        cout << "YES";
    }else{cout << "NO";}

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		int m=s.nextInt();
		
		long ans=(n*(n-1))/2;
		ans=ans+(m*(m-1))/2;
		
		System.out.println(ans);
		
	}
	
}

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

int main(){
    long long int k,n;
    long long int a[200000] = {0};
    long long int i,max = 0;


    cin >> k >> n;
    cin >> a[0];
    for ( i = 1; i < n; i++)
    {
        cin >> a[i];
    }

    for( i = 1; i < n; i++){
        if( max < ( a[i] - a[i - 1] ) ){
            max = a[i] - a[i - 1];
        }
    }
    if( max < ( k + a[0] - a[n - 1] ) ){
        max = k + a[0] - a[n - 1];
    }

    cout << k - max << "\n";

}

Measured memory_bytes: 1920
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int a,b;
  cin >> a >>b;
  int ret = 1;

  int x=max(a,b);
  int y= min(a,b);
  	
  while(x%y!=0){
  	int tmp = x;
  	x = y;
  	y = tmp %y;
  }

  cout << y << endl;
  return 0;

}


Measured memory_bytes: 3104
S = input().strip()

wc, bc = 0, 0
wd, bd = 0, 0
for i, s in enumerate(S):
  if s == 'W':
    wc += 1
    wd += i - wc + 1
  else:
    bc += 1
    bd += len(S) - 1 - i - bc + 1
print((wd + bd) // 2)

Measured memory_bytes: 3500
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
#include<queue>
#include<map>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

int main(){

  int h,w; cin >> h >> w;
  vector<string> s(h); rep(i,h){cin>>s[i];}
  //vector< vector<int> > map(h, vector<int>(w));
  // vertical
  vector< vector<int> > ver(h, vector<int>(w));
  // horizontal
  vector< vector<int> > hor(h, vector<int>(w));

  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#') {ver[i][j]=-1;hor[i][j]=-1;}
      else {ver[i][j]=0;hor[i][j]=0;}
    }
  }

  int ans = 0;

  rep(i,h){
    rep(j,w){
      if (ver[i][j]!=-1){
        // vertical
        if (ver[i][j]==0){
          int k;
          for (k=i; k<h; k++){
            if (ver[k][j]==0){ver[i][j]++;}
            else {break;}
          }
          for (int l=i; l<k; l++){
            ver[l][j]=ver[i][j];
          }
        }

        // horizontal
        if (hor[i][j]==0){
          int k;
          for (k=j; k<w; k++){
            if (hor[i][k]==0){hor[i][j]++;}
            else {break;}
          }
          for (int l=j; l<k; l++){
            hor[i][l]=hor[i][j];
          }
        }

        if (ans<ver[i][j]+hor[i][j]-1){ans=ver[i][j]+hor[i][j]-1;}
      }
    }
  }
  
  cout << ans;

  return 0;
}


Measured memory_bytes: 35712
#include<iostream>
#include<algorithm>
#include <vector>
#include <string>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for(int i = 0; i < N; i++) cin >> S.at(i);
  sort(S.begin(), S.end());
  int counter = 1;
  for(int i = 0; i + 1 < N; i++) {
    if (S[i] != S[i+1]) ++counter;
  }
  cout << counter << endl;
}

Measured memory_bytes: 9564
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const auto mod=1e9+7;
const ld pi = (acos(-1));




int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int n,q; cin >> n >> q;
  string s; cin >> s;
  vector<int> v;
  rep(i,0,n-1){
    if(s.substr(i,2)=="AC") v.push_back(i);
  }
  rep(i,0,q){
    int l,r; 
    cin >> l >> r; l--;r--;
    int x =lower_bound(ALL(v),r)-v.begin();
    int y =lower_bound(ALL(v),l)-v.begin();
    cout << x-y << endl; 
  }
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005],b[100005],c[100005];
ll x[100005],y[100005];
int main(void)
{
	ll A,B,M;
	scanf("%lld%lld%lld",&A,&B,&M);
	ll min1=100000000000,min2=1000000000000;
	for(ll i=1;i<=A;i++)
	{
		scanf("%lld",&a[i]);
		min1=min(min1,a[i]);
	}
	for(ll i=1;i<=B;i++)
	{
		scanf("%lld",&b[i]);
		min2=min(min2,b[i]);
	}
	ll ans=100000000000;
	for(ll i=0;i<M;i++)
	{
		scanf("%lld%lld%lld",&x[i],&y[i],&c[i]);
		ans=min(ans,a[x[i]]+b[y[i]]-c[i]);
	}
	ans=min(ans,min1+min2);
	printf("%lld",ans);
}

Measured memory_bytes: 4096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader =
                new BufferedReader(new InputStreamReader(System.in));
        String input = reader.readLine();
        input = input.replaceAll("apple", "p___h");
        input = input.replaceAll("peach", "apple");
        input = input.replaceAll("p___h", "peach");
        System.out.println(input);
    }
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i = 0; i < n; ++i) cin >> d[i];
  
  sort(d.begin(), d.end());
  int l = d[n/2-1], r = d[n/2];
  
  cout << r - l << endl;
}

Measured memory_bytes: 3776
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
typedef long long int Int;
const int MAX_N = 10;
const int MAX_NUM = 101;
const int MAX_S = 1001;

//do[何個使うか][いくつまで使ったか+1][合計いくつか]
Int N, S, dp[MAX_N][MAX_NUM + 5][MAX_S];

int main() {
  REP(i, MAX_N) REP(j, MAX_NUM) REP(k, MAX_S) dp[i][j][k] = 0;
  dp[0][0][0] = 1;
  REP(i, MAX_N - 1)
    REP(j, MAX_NUM)
      REP(k, MAX_S)
        FOR(l, j, MAX_NUM){
          if(k + l > MAX_S) break;
          dp[i + 1][l + 1][k + l] += dp[i][j][k];
        }
  while(cin >>N >>S && N){
    Int ans = 0;
    REP(i, MAX_NUM + 5) ans += dp[N][i][S];
    cout <<ans <<endl;
  }
  return 0;
}

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

int main()
{
    int n;
    int i, j, judge = 0;
    string s, t;
    
    cin >> n >> s >> t;
    
    for(i = 0; (i < n) && (judge == 0); i++) {
        judge = 1;
        for(j = 0; j < n - i; j++) {
            if(s[i+j] != t[j]) {
                judge = 0;
            }
        }
    }
    
    if(judge == 0) {
        cout << n * 2 << endl;
    } else {
        cout << n + i - 1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>;
using L = vector<long long>;
using M = map<int,long long>;
using A = vector<vector<long long>>;
using Q = priority_queue<long long>;
using U = unordered_map<int,long long>; //mapとの違いはkeyの順番を保持していない

#define sorted(vector) sort(vector.begin(),vector.end()) //O(nlongn)
#define sortedreverce(vector) sort(vector.rbegin(),vector.rend()) //O(nlongn)
#define vmin(vector) *min_element(vector.begin(),vector.end()) //O(N)
#define vmax(vector) *max_element(vector.begin(),vector.end()) //O(N)
#define vsum(vector) accumulate(vector.begin(),vector.end(),0) //O(N)
#define vcount(vector,a) count(vector.begin(), vector.end(),a) //O(N)
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
//存在確認はmap!!!!!!!!!!!!!か配列に埋め込んでcontinueで回避
//__gcd(a,b)はコンパイラがGCC時のみ

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    long long n,m;
    cin>>n>>m;
    L l(m,0);
    for(int i=0  ;i<m  ;i++){
        cin>>l[i];
    }
    
    sorted(l);
    
    L l2;
    for(int i=1  ;i<m  ;i++){
        l2.push_back(abs(l[i-1]-l[i]));
    }
    
    sortedreverce(l2);
    
    if (l2.size()<n){
        cout<<0<<endl;
    }else{
        long long ans=0; 
        for(int i=n-1  ;i<l2.size()  ;i++){
            ans+=l2[i];
        }
        cout<<ans<<endl;
    }
}

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){
int N;
cin >> N;
vector<ll>a(N);
REP(i, N) cin >> a.at(i);

ll four = 0, two = 0 , odd = 0;

REP(i, N){
	if(a.at(i) % 4 == 0 ) four++;
	else if(a.at(i) % 4 != 0 && a.at(i) % 2 == 0) two++;
	else if(a.at(i) % 2 == 1) odd++;
}
// print(odd);
// print(four);

if(odd == 0) yes;
else if(four >= odd) yes;
else if(a.size() % 2 == 1 && four >= odd - 1) yes;
else no;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    bool ans=1;
    for(int i=0; i<n-1;i++){
        if(a.at(i) == a.at(i+1)){
            ans=0;
            break;
        }
    }
    if(ans == 1){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 1024
#include<iostream>
#include<set>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
  int i,n,t;
  cin >> n;
  multiset<int, std::greater<int>>a;
  for(i=0;i<n;i++){
    int t;
    cin>>t;
    a.insert(t);
  }
  int ans=0;
  while(!a.empty()){
    int x=*a.begin();
    a.erase(a.begin());
    int y=pow(2,(int)log2(x)+1)-x;
    auto it=a.find(y);
    if(it!=a.end()){
      a.erase(it);
      ans+=1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 9600
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;
using myui = uint64_t;
using myint = int64_t;

template<typename T>
T diff(const T& a, const T& b) {
    return a > b ? a - b : b - a;
}

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

    {
        myui a,b,t;
        cin >> a >> b >> t;

        cout << (t/a)*b << endl;
    }

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
input()
numbers = list(map(int, input().split()))
 
count = 0
while(True):
	if sum(list(map(lambda x: x % 2, numbers))) == 0:
		numbers = list(map(lambda x: x / 2, numbers))
		count += 1
	else:
		break
print(count)

Measured memory_bytes: 3060
import java.util.*;

public class Main {

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

        long origin = 100;
        long x = scanner.nextLong();

        long year = 0;

        while (origin < x) {
            origin = origin + (origin / 100);
            year++;
        }

        System.out.println(year);
    }
}

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

using namespace std;

#define db(x) cout << #x ": " << (x) << '\n';
#define x first
#define y second

#define int long long

typedef long double ld;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;

const int MAXN=200005;
const int oo=100000;
const double pi=acos(-1.0);
const int mod = 1000000007;

ll h,w,n;
ll fact[MAXN],ifact[MAXN];
ll jode[MAXN];

ll qp(ll b,ll e)
{
    if(!e)
    return 1;
    ll x=qp(b,e/2);
    x=(x*x)%mod;
    if(e&1)
        x=(x*b)%mod;
    return x;
}

ll c(ll n,ll m)
{
    return (((fact[m]*ifact[n])%mod)*ifact[m-n])%mod;
}

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

//    freopen("in","r",stdin);

    cin>>h>>w>>n;
    fact[0]=1;
    ifact[0]=1;
    for(int i=1;i<=h+w;i++)
    {
        fact[i]=(fact[i-1]*i)%mod;
        ifact[i] = qp(fact[i],mod-2);
    }
    vector<pii> v;
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin >> a >> b;
        v.push_back({a,b});
    }

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

    v.push_back(pii(h,w));

    for(int i=0;i<n;i++)
    {
        ll ini=c(v[i].x-1,v[i].y+v[i].x-2);
        ll cant=(ini-jode[i]+mod)%mod;

        for(int j=i+1;j<=n;j++)
        {
            int dx=v[j].x-v[i].x;
            int dy=v[j].y-v[i].y;
            if(dx<0 || dy<0)
                continue;
            jode[j]=(jode[j]+c(dx,dy+dx)*cant)%mod;
        }
    }
    cout << (c(w-1,w+h-2)-jode[n]+mod)%mod << '\n';

    return 0;
}


Measured memory_bytes: 3584