akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n, H;
    cin >> n >> H;

    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    ll maxA = *max_element(all(a));

    typedef pair<ll, ll> P;
    vector<P> p(b.size());
    rep(i, b.size()) p[i] = P(b[i], a[i]);
    sort(all(p));
    reverse(all(p));
    
    ll res = 0;
    rep(i, n) {
        ll B = p[i].first;
        if (maxA < B) {
            H -= B;
            res++;
            if (H <= 0) {
                put(res);
                return;
            }
        }
        else {
            break;
        }
    }

    res += (H + maxA - 1) / maxA;
    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 6340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200025,inf=0x3f3f3f3f,p=998244353;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,m,ans,f[N];
char ch[N];
void check(int &x,int y){x=(x+y<p) ? (x+y) : (x+y-p);}
int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	n=read();
	scanf(" %s",ch);
	for (int i=1;i<=n;i+=2)
	if (n%i==0){
		m=n/i;
		for (int j=0;j<m;j++)
		f[i]=(f[i]*2+ch[j]-'0')%p;
		int fl=1;
		for (int j=m;j<n;j++)
		if (ch[j]!=(ch[j%m]^(j/m&1))){fl=(ch[j]>(ch[j%m]^(j/m&1)));break;}
		check(f[i],fl);
	}
	for (int i=n;i;i--){
		for (int j=i+i;j<=n;j+=i) check(f[i],p-f[j]);
		ans=(ans+(ll)n/i*2*f[i])%p;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define int long long
#define rep(a,b) for(int (a)=0; (a)<(int)(b); ++(a))
#define all(a) (a).begin(),(a).end()
#define prec(a) fixed<<setprecision(a)
using namespace std;

constexpr int MOD=1000000007;
using ull=unsigned long long;
using vec=vector<ull>;
using dvec=vector<vec>;

void print(void){cout<<"\n";}

template<class HEAD,class... TAIL>
void print(HEAD&& head,TAIL&&... tail){
  cout<<head<<" ";
  print(forward<TAIL>(tail)...);
}

ull nCr(int n,int r){
  dvec c(n+1,vec(n+1,0));
  rep(i,n+1) c[i][i]=c[i][0]=1;
  for(int i=1;i<n+1;++i){
    for(int j=1;j<i;++j){
      c[i][j]=c[i-1][j-1]+c[i-1][j];
    }
  }
  return c[n][r];
}

signed main(void){
  int N,A,B; cin>>N>>A>>B;
  vector<int> v(N);
  map<int,int> cnt;
  rep(i,N){
    cin>>v[i];
    ++cnt[v[i]];
  }
  sort(all(v)); reverse(all(v));
  double ave=0;
  map<int,int> mp;
  rep(i,A){
    ave+=v[i];
    ++mp[v[i]];
  }
  ave/=A;
  ull ans=1;
  for(auto &i : mp){
    int n,r;
    n=cnt[i.first],r=i.second;
    ull x=nCr(n,r);
    //print(n,r,":",x);
    ans*=x;
  }
  if(mp.size()==1){
    int n,r;
    n=cnt[v[0]],r=A+1;
    for(int i=r;i<=min(n,B);++i){
      ull x=nCr(n,i);
      //print(n,i,":",x);
      ans+=x;
    }
  }
  cout<<prec(10)<<ave<<endl;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
/* Author rumoisen */
/* created 2018/11/17 */

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

void no() { cout << "No" << endl;exit(0);}
void yes() { cout << "Yes" << endl;exit(0);}
void No() { cout << "NO" << endl;exit(0);}
void Yes() { cout << "YES" << endl;exit(0);}

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

int main()
{
    string year;
    cin >> year;
    year.at(3) = '8';
    cout << year << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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 ans;
    ans = d[n/2] - d[n/2 - 1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.math.*;

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

        int[] A = new int[M];
        long sum = 0;
        for (int i = 0; i < M; i++) {
            A[i] = sc.nextInt();
            sum += A[i];
        }
        if (N - sum < 0) {
            System.out.println(-1);
        } else {
            System.out.println(N - sum);
        }
    }
}

Measured memory_bytes: 46392
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    sort(all(a));
    sort(all(b));
    if(n % 2) {
        int left = a[n / 2];
        int right = b[n / 2];
        cout << abs(right - left) + 1 << endl;
    } else {
        int left = a[n / 2] + a[n / 2 - 1];
        int right = b[n / 2] + b[n / 2 - 1];
        cout << right - left + 1 << endl;
    }
}

Measured memory_bytes: 6436
a, b, c = map(int, input().split())

n1 = a*b*(c-c//2)- a*b*(c//2)
n2 = c*b*(a-a//2)- c*b*(a//2)
n3 = a*c*(b-b//2)- a*c*(b//2)

print(min(n1, n2, n3))

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC73_C
{
    class Program
    {
        static void Main(string[] args)
        {

            var n = int.Parse(Console.ReadLine());
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = long.Parse(Console.ReadLine());
            }
            var x = new Dictionary<long, bool>();
            for (int i = 0; i < n; i++)
            {
                if (!x.ContainsKey(a[i]) || !x[a[i]]) { x[a[i]] = true; }
                else if (x[a[i]]) x[a[i]] = false;
            }

            Console.WriteLine(x.Values.Count(y=>y));
        }
    }
}


Measured memory_bytes: 21980
#include <cstdio>
int n; char s[20][20];
int solve(int l, int r, int d) {
	if (r - l == 1) return s[l][d] - 48;
	int ret = (s[l][d] == '+' ? 0 : 1);
	int prev = -1;
	for (int i = l + 1; i < r; i++) {
		if (s[i][d + 1] != '.') {
			if (prev != -1) {
				if (s[l][d] == '+') ret += solve(prev, i, d + 1);
				else ret *= solve(prev, i, d + 1);
			}
			prev = i;
		}
	}
	if (s[l][d] == '+') ret += solve(prev, r, d + 1);
	else ret *= solve(prev, r, d + 1);
	return ret;
}
int main() {
	while (scanf("%d", &n), n) {
		for (int i = 0; i < n; i++) scanf("%s", s[i]);
		printf("%d\n", solve(0, n, 0));
	}
}

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define fo(i,s,e) for (int i=(s); i < (e); i++)
#define all(obj) (obj).begin(), (obj).end()
#define int long long
//素数判定 https://qiita.com/EqualL2/items/b3c2530c458f8450d390
bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}
signed main () {
  int x;cin >> x;
  for (int i = x; i <INT_MAX; i++){
    if(is_prime(i)){
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,sum=0;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    sort(all(a));
    if(sum%10==0){
        rep(i,n){
            if(a[i]%10 != 0){
                sum-=a[i];
                break;
            }
        }
    }
    cout<<(sum%10==0 ? 0 : sum)<<endl;
    return 0;
}

Measured memory_bytes: 3572
package main

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

func main() {
	var N int
	fmt.Scan(&N)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	v := make([]int, N)
	var a int

	for i := 1; i < N; i++ {
		scanner.Scan()
		a, _ = strconv.Atoi(scanner.Text())
		v[a-1]++
	}

	w := bufio.NewWriter(os.Stdout)
	for _, e := range v {
		fmt.Fprintln(w, e)
	}
	w.Flush()

}


Measured memory_bytes: 5924
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    string s;
    cin >> s;
    ll n = s.size();

    vvl dp(n+1, vl(4));  // dp[i+1][j] : s[i]まででj個丸をつける方法の数
    dp[0][0] = 1;
    rep(i, n) {
        exrep(j, 0, 3) {
            if(s[i] == '?') {
                dp[i+1][j] = 3*dp[i][j];
                if(j > 0) {
                    dp[i+1][j] += dp[i][j-1];
                }
            }
            else {
                dp[i+1][j] = dp[i][j];
                if(j > 0 && s[i] == "ABC"[j-1]) {
                    dp[i+1][j] += dp[i][j-1];
                }
            }
            dp[i+1][j] %= mod;
        }
    }
    
    out(dp[n][3]);
    re0;
}

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

using std::cin;
using std::cout;
using std::endl;

struct data_t {
	int time;
	int sent;
	int res;

	bool operator<(const data_t& right) const {
		return ( time == right.time ) || ( time < right.time );
	}
};

int main(void) {
	int N,M;
	cin >> N;
	cin >> M;

	while (N != 0 || M != 0) {
		std::vector<data_t> record(M);

		for (int i = 0; i < M; i++) {
			cin >> record[i].time;
			cin >> record[i].sent;
			cin >> record[i].res;
		}

		std::sort(record.begin(), record.end());

		std::vector<bool> infected(N, false);
		infected[0] = true;
		int count = 1;

		for (int i = 0; i < M; i++) {
			if (infected[record[i].sent-1]) {
				if (!(infected[record[i].res-1])) {
					infected[record[i].res-1] = true;
					count++;
				}
			}
		}
		cout << count << endl;
		cin >> N;
		cin >> M;
	}

	return 0;
}

Measured memory_bytes: 3220
from collections import deque
k=int(input())
q=deque([i for i in range(1,10)])

ans=0
cnt=0

while 1:
    x=q.popleft()
    cnt+=1
    if cnt==k:
        ans=x
        break
    xmod10 = x % 10
    if xmod10 != 0:
        q.append(10*x+(xmod10-1))
    q.append(10*x+(xmod10))
    if xmod10 != 9:
        q.append(10*x+(xmod10+1))

print(ans)


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

int get_w_col(vector<string> g) {
  int w = g[0].length();
  int rt = -1;

  for ( int j = 0; j < w; j++ ) {
    bool f = true;
    for ( int i = 0; i < g.size(); i++ ) {
      if ( g[i][j] == '#' ) { f = false; break; }
    }
    if ( f ) { rt = j; break; }
  }

  return rt;
}

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> g;
  
  for ( int i = 0; i < h; i++ ) {
    string t;
    cin >> t;
    bool f = false;
    for ( int j = 0; j < w; j++ ) {
      if ( t[j] == '#' ) { f = true; break; }
    }
    if ( f ) { g.push_back(t); }
  }

  int p = get_w_col(g);
  while ( p != -1 ) {
    for ( int i = 0; i < g.size(); i++ ) {
      g[i].erase(p, 1);
    }
    p = get_w_col(g);
  }

  for ( int i = 0; i < g.size(); i++ ) {
    cout << g[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys
mod = pow(10, 9) + 7
sys.setrecursionlimit(pow(10, 8))

def power(x, y):
    if   y == 0: return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else: return power(x, (y-1)//2)**2 * x % mod
    
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, power(b, mod-2))
def div2(a, b):
    return mul(a, modinv(b))

def modinv(a):
    b, u, v = mod, 1, 0
    while b:
        t = a//b
        a, u = a-t*b, u-t*v
        a, b, u, v = b, a, v, u
    u %= mod
    return u

def cmb(n, r):
    x = 1
    for i in range(r):
        x = mul(x, n-i)
    return x * g2[r] % mod

NNN = (3*10**5)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
N, a, b = map(int, input().split())
print((power(2, N) - 1 - cmb(N, a) - cmb(N, b))%mod)


Measured memory_bytes: 100592
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
struct edge {
	ll to, cost;
};
struct Gragh {
	vector<vector<edge>> G;
	ll N;
	vl visited;
	void init(ll n) {
		N = n;
		G.resize(N);
		visited = vl(N, 0);
	}

	void add(ll a, ll b, ll c = 1) {
		G[a].push_back((edge){b,c});
	}

	void resetv(void) {
		visited = vl(N, 0);
	}

	vl Dijkstra(ll r) {
		vl cost(N,INF);
		resetv();
		priority_queue<PP, vector<PP>, greater<PP>> pq;
		ll a, b = r;
		cost[b] = 0;
		visited[b] = 1;

		for (edge i : G[b]) {
			if (cost[b] + i.cost < cost[i.to]) {
				pq.push(make_pair(cost[b] + i.cost, i.to));
			}
		}
		while (!pq.empty()) {
			a = pq.top().first;
			b = pq.top().second;
			pq.pop();
			if (visited[b] == 1)continue;
			visited[b] = 1;
			cost[b] = a;
			for (edge i : G[b]) {
				if (cost[b] + i.cost < cost[i.to]) {
					pq.push(make_pair(cost[b] + i.cost, i.to));
				}
			}
		}

		return cost;
	}
};

int main() {
	cin >> n >> m >> x;
	Gragh g;
	g.init(n);
	rep(i, m) {
		cin >> a >> b >> c;
		g.add(a, b, c);
	}

	vl A = g.Dijkstra(x);

	rep(i, n) {
		if (A[i] < INF) {
			cout << A[i] << endl;
		}
		else {
			cout << "INF" << endl;
		}
	}
}


Measured memory_bytes: 23160
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)
//string s = to_string(i);
int a = 0, b = 0, c = 0, x = 0, y = 0, z = 0, n = 0, sum = 0, i = 0;
string s = ""; asas; cncn;

int main(void) {
	char c;
	cin >> c;
	if (c == 'a')cnt++;
	if (c == 'e')cnt++;
	if (c == 'i')cnt++;
	if (c == 'o')cnt++;
	if (c == 'u')cnt++;
	if (cnt != 0) {
		cout << "vowel" << rt;
	}
	else cout << "consonant" << rt;//consonantのスペル違ったやんけ(-_-メ)
	please AC;
}

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

int main() {
  
  int R=0;
  
  cin >> R;
  
  if(R<1200) {
    
    cout << "ABC" << endl;
    
    return 0;
    
  } else if(1200<=R && R<2800) {
    
    cout << "ARC" << endl;
    
    return 0;
    
  } else if(2800<=R) {
    
    cout << "AGC" << endl;
    
    return 0;
    
  }
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void)
{
  int n, k;
  char s[MAX];
  scanf("%d %d %s", &n, &k, s);

  int nsize = 0, nums[MAX]; // 1-0-...-0-1と並ぶ配列
  int now = 1;              // 今見ている数
  int cnt = 0;              // 今見ている数の連続して並んでいる数
  rep(i, 0, n) {
    if (s[i] == (char)('0' + now)) cnt++;
    else {
      nums[nsize++] = cnt;
      now = 1 - now;
      cnt = 1;
    }
  }
  nums[nsize++] = cnt;

  // 最後が0で終わっている場合(1-0-...1-0)
  // 最後を1で終わっている配列にする(1-0-...-0-1)
  if (nsize % 2 == 0) nums[nsize++] = 0;

  int range = 2 * k + 1;
  int ans = 0;

  for (int i = 0; i < nsize; i += 2) {
    int left  = i;
    int right = min(i + range, nsize);
    int tmp = 0;
    for (int j = left; j < right; j++) {
      tmp += nums[j];
    }
    ans = max(ans, tmp);
  }
  printf("%d\n", ans);
  return 0;
}


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

int main()
{
	string str;
	string temp;
	string::size_type index;
	int count = 0;
	int i = 0;

	while (std::cin >> temp) {
		str += temp;
	}
	char c = 'a';
	while (c != 'z' + 1) {

		count = 0;
		for (string::iterator it = str.begin(); it != str.end(); it++) {
			if (c == *it) {
				count++;
			}
			else if (c - 32 == *it) {
				count++;
			}
		}
		cout << c << " : " << count << endl;
		c += 1;
	}

    return 0;
}

Measured memory_bytes: 3220
def main():
    s = input()
    ans = 0
    pre = ""
    is_same = False

    for i in range(len(s)):
        if is_same:
            pre += s[i]
            ans += 1
            is_same = False
            continue

        if pre != s[i]:
            ans += 1
            pre = s[i]
        else:
            is_same = True

    print(ans)


if __name__ == "__main__":
    main()


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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int M, D;

void MAIN() {
    scanf("%d%d", &M, &D);
    int ans = 0;
    for (int d=10; d<=D; d++) {
	int a = d % 10;
	int b = d / 10;
	if (a >= 2 && b >= 2 && 1 <= a * b && a * b <= M) {
	    ans++;
	}
    }
    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine().ToArray();
            var result = 1;
            for (var i = 1; i < n; i++)
            {
                if (s[i] != s[i - 1]) result++;
            }

            Console.WriteLine(result);
        }

    }
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int n,x;
	std::cin >> n;
	x = n;
	int c = 0;
	while (x > 0) {
		c += (x%10);
		x /= 10;
	}
	if (n % c == 0) {
		std::cout << "Yes" << '\n';
	}
	else {
		std::cout << "No" << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

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


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define MAX_N 2002
using namespace std;

typedef long long ll;
typedef pair<int,int> P1;
typedef pair<P1,P1> P2;
const ll INF=100000000000000001;
int dp1[MAX_N][MAX_N]={};
int dp2[MAX_N][MAX_N]={};
bool d[MAX_N][MAX_N]={};
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
queue<P1> que;
vector<string> v;

int main() {
	string s;
	cin>>s;
	int t=0;
	bool flg=true;
	while(flg){
		flg=false;
		int j=0;
		string s1=s;
		int ls=s.length();
		rep(i,ls-2){
			if(s[i+2]!=s1[j]){
				t++;
				flg=true;
			}else{
				s1[j+1]=s[i+1];
				j++;
			}
		}
		s1[j+1]=s[ls-1];
		s=s1.substr(0,j+2);
//		cout<<s<<endl;
	}
	if(t%2==0){
		cout<<"Second"<<endl;
	}else{
		cout<<"First"<<endl;
	}
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#define Nmax 10000
#define Qmax 500

int  LinerSearch(int );
int n,S[Nmax];
int main(){
  int q,i;
  int T[Qmax];
  int sum=0;
  int ans;

  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0 ; i<q ; i++){
    scanf("%d",&T[i]);
  }
  
  for(i=0 ; i<q ; i++){
    ans = LinerSearch(T[i]);
    if(ans == T[i]) sum++;
  }

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

  return 0;
}

int LinerSearch(int key){
  int i;

  for(i=0 ; i<n ; i++){
    if (S[i] == key) return S[i];
  }

  return S[i];
}

Measured memory_bytes: 636
import math
a, b, c = map(int, input().split())

def printing(x):
    print('{:.8f}'.format(x))
    
printing(0.5 * a * b * math.sin(math.radians(c)))
printing(a + b + math.sqrt((a ** 2) + (b ** 2) - 2 * a * b * math.cos(math.radians(c))))
printing(b * math.sin(math.radians(c)))


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

 using namespace std;
 typedef long long ll;

 int main() {
   ll A, B, C;

   cin >> A >> B >> C;

   ll ans;

   if (A + B + 1 >= C) ans = B + C;

   else ans = (ll)(A + 2 * B + 1);

   cout << ans << endl;
   }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n,m;
	cin>>n>>m;
	if(n==m){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
  
	var num = parseInt(tmp[0], 10);
    while(!isPrime(num)) {
        num++
    }
    console.log(num)
}
function isPrime(num) {
    for(var i = 2; i < num; i++)
      if(num % i === 0) return false;
    return num;
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#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 >> m;
    
    int ans = (m * (m-1) / 2) + (n * (n-1) / 2);
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int r,D,x;

int main(){
    cin>>r>>D>>x;
    rep(i,10){
        x=r*x-D;
        out(x);
    }
    
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

int testcase_ends() {
  size_t N;
  scanf("%zu", &N);

  if (N == 0) return 1;

  double pw;
  scanf("%lf", &pw);

  std::vector<double> vw(N), pf(N), vf(N), th(N);
  for (size_t i=0; i<N; ++i)
    scanf("%lf %lf %lf %lf", &vw[i], &pf[i], &vf[i], &th[i]);

  auto f=[&](double W)->double {
    double res=0;
    res += W*pw;
    for (size_t i=0; i<N; ++i) {
      double th_i=th[i]-W*vw[i];
      if (th_i > 0) {
        res += th_i/vf[i]*pf[i];
      }
    }
    // fprintf(stderr, "f(%f) = %f\n", W, res);
    return res;
  };

  double lb=0, ub=1e10;
  for (int i=0; i<300; ++i) {
    double midl=(2*lb+ub)/3, midu=(lb+2*ub)/3;
    double fl=f(midl), fu=f(midu);
    if (fl < fu) {
      ub = midu;
    } else {
      lb = midl;
    }
  }
  // fprintf(stdout, "%.6f:", lb);
  printf("%.12f\n", f(lb));
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 5616
#include <iostream>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n], b[n] , c[n-1];
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    rep(i, n) a[i]--;
    
    int ans = 0;
    rep(i, n) ans += b[a[i]];
    rep(i, n-1){
        if(a[i] + 1 == a[i+1]){
            ans += c[a[i]];
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int h1, s1, h2, s2;
	cin >> h1 >> s1 >> h2 >> s2;
	while(h1 > 0 and h2 > 0){
		h2 -= s1;
		if(h2 > 0) h1 -= s2;
		else break;
	}
	if(h1 > 0) cout << "Yes";
	else cout << "No";

	return 0;
}



Measured memory_bytes: 3640
#include<stdio.h>
#define mod 1000000007

int main(){
    long long i,j,k,dp[128][256]={0},n,r=0,w;
    long long a[4];
    for(i=0;i<64;i++){
        dp[3][i]=1;
    }
    dp[3][6]=0;
    dp[3][9]=0;
    dp[3][18]=0;
    scanf("%lld",&n);
    for(i=4;i<=n;i++){
        for(j=0;j<256;j++){
            dp[i][(j*4)%256]+=dp[i-1][j];
            dp[i][(j*4+1)%256]+=dp[i-1][j];
            dp[i][(j*4+2)%256]+=dp[i-1][j];
            dp[i][(j*4+3)%256]+=dp[i-1][j];
            dp[i][(j*4)%256]%=mod;
            dp[i][(j*4+1)%256]%=mod;
            dp[i][(j*4+2)%256]%=mod;
            dp[i][(j*4+3)%256]%=mod;
        }
        for(j=0;j<256;j++){
            if(j%64==6 || j%64==9 || j%64==18){dp[i][j]=0;}
            w=j;
            for(k=3;k>=0;k--){
                a[k]=w%4;w/=4;
            }
            if(a[0]==0 && a[1]==1 && a[3]==2){dp[i][j]=0;}
            if(a[0]==0 && a[2]==1 && a[3]==2){dp[i][j]=0;}
        }
    }
    for(i=0;i<256;i++){r+=dp[n][i];r%=mod;}
    printf("%lld\n",r);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	ios::sync_with_stdio(false);
	string s;
	int a[26] = {};
	cin >> s;
	for (int i = 0 ; i < s.length() ; i++) a[s[i] - 96]++;
	for (int i = 0 ; i < 26 ; i++)  {
		if (a[i] > 1) {
			cout << "no\n";
			return 0;
		}
	}
	cout << "yes\n";
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  char str1[3], str2[3];
  cin >> str1;
  cin >> str2;
  int ans=0;
  for(int i=0;i<3;i++){
    if(str1[i]==str2[i]){
      ans++;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  
    int n;
    cin>>n;
    vector<pair<string,int>> v;
    set<string> l;
    for(int i=0;i<n;i++){
      string s;
      cin>>s;
      v.push_back(make_pair(s,i));
      l.insert(s);
    }
    
    if(v.size()==l.size()){
      int f=1;
      for(int i=1;i<n;i++){
        string d=v[i-1].first;
        string e=v[i].first;
        int x=d.length();
        if(e[0]==d[x-1]){
          f=1;
        }else{
          f=0;
          i=n;
        }

      }
      if(f){
        cout<<"Yes";
      }else{
        cout<<"No";
      }

    }else{
      cout<<"No";
    }
    

}

Measured memory_bytes: 256
n = int(input())

zei = 1.08
result = int(n / zei)
if int(result*zei) == n:
    print(result)
    exit()
big = int(result*zei) > n
while True:
    if big:
        result -=1
    else:
        result +=1
    if int(result*zei) == n:
        print(result)
        exit()
    if big != (int(result*zei) > n):
        print(":(")
        exit()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<int> c(n-1,0);
    vector<int> s(n-1,0);
    vector<int> f(n-1,0);
    for(int i=0;i<n-1;i++){
        cin>>c[i]>>s[i]>>f[i];
    }
    for(int i=0;i<n-1;i++){
        int t=0;
        t+=s[i];
        for(int j=i;j<n-1;j++){
            if(t<s[j]){
                t+=s[j]-t;
            }
            if((t-s[j])%f[j]!=0){
                t+=f[j]-((t-s[j])%f[j]);
            }
            t+=c[j];
        }
        cout<<t<<endl;
    }
    cout<<0<<endl;
}


Measured memory_bytes: 256
(let* ((n (sort (read-line) #'char<)))
  (if (and (char= (aref n 0) (aref n 1)) (char= (aref n 2) (aref n 3)) (not (char= (aref n 1) (aref n 2))))
      (princ "Yes")
      (princ "No")))

Measured memory_bytes: 9184
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        int ans = 0, endA = 0, startB = 0, both = 0;
        for (int i = 0; i < n; ++i) {
            char[] s = scanner.next().toCharArray();
            for (int j = 0; j < s.length - 1; ++j) {
                if (s[j] == 'A' && s[j + 1] == 'B') {
                    ++ans;
                }
            }
            if ((s[0] == 'B') && (s[s.length - 1] == 'A'))
                ++both;
            else if (s[0] == 'B')
                ++startB;
            else if (s[s.length - 1] == 'A')
                ++endA;
        }
        if (both > 0) {
            ans += both - 1;
            if (startB != 0 || endA != 0) {
                ans += Math.min(startB, endA) + 1;
            }
        } else
            ans += Math.min(startB, endA);
        writer.println(ans);

        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 26964
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b){
    if(b==c){
      cout<<1<<endl;
    }
    else{
      cout<<2<<endl;
    }
  }
  else if(a!=b){
    if(b==c){
      cout<<2<<endl;
    }
    else if(a==c){
      cout<<2<<endl;
    }
    else {
      cout<<3<<endl;
    }
  }
}

Measured memory_bytes: 256
import math
while True:
  x = list(input().split())
  a = int(x[0])
  op =x[1]
  b = int(x[2])
  if op =='+':
      print(a+b)
  elif op =='/':
      print(math.floor(a/b))
  elif op =='*':
      print(a*b)
  elif op =='-':
      print(a-b)
  elif op =='?':
      break


Measured memory_bytes: 5664
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	
	ll N; cin >> N;
	N--;
	cout << N*(N+1)/2 << endl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

// int a[(int)1e9+1];
// int a[(int)1000+1];

int main()
{
    int n;
    cin >> n;
    vector<ll> x;
    for (int i=0; i<n; ++i)
    {
        ll tmp;
        cin >> tmp;
        x.push_back(tmp);
    }

    sort(x.begin(), x.end());
    double max = x.back();
    ll r = 0;
    double dif = 1e9;
    for (int i=0; i<n-1; ++i)
    {
        if(dif>abs(x[i]-max/2))
        {
            dif = abs(x[i]-max/2);
            r = x[i];
        }
        else//更新されなくなったら
        {
            break;
        }
    }
    cout << (ll)max << " " << (ll)r << endl;
    return 0;
}

Measured memory_bytes: 1400
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [-1]*(N+1)
dp[0]=0  
for i in range(N+1):
    for j in A:
        if i + B[j] <= N:
            dp[i+B[j]]= max(dp[i]*10+j, dp[i+B[j]])
print(dp[N])

Measured memory_bytes: 51036
#include <cstdio>
#include <random>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <chrono>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
// #define int long long


using namespace std;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;


const int maxn = 2e5;
pii a[maxn];


signed main()
{
#ifndef ONLINE_JUDGE
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#endif
    int n, m;
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    set<int> s;
    for(int i = 0; i < n; ++i) {
        cin >> a[i].se >> a[i].fi;
    }
    sort(a, a + n);
    for(int i = 1; i <= m; ++i) {
        s.insert(i);
    }
    reverse(a, a + n);
    long long res = 0;
    for(int i = 0; i < n; ++i) {
        auto it = s.lower_bound(a[i].se);
        if(it != s.end()) {
            s.erase(it);
            res += a[i].fi;
        }
    }
    cout << res << endl;

    
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
long long mod = 1000000000+7;

int main(){

	int n;
	cin>>n;
	string s[n];
	rep(i,n)cin>>s[i];
	int ans[4]={};
	rep(i,n){
		if(s[i]=="AC")ans[0]++;
		else if(s[i]=="WA")ans[1]++;
		else if(s[i]=="TLE")ans[2]++;
		else ans[3]++;
	}

	cout<<"AC x "<<ans[0]<<endl;
	cout<<"WA x "<<ans[1]<<endl;
	cout<<"TLE x "<<ans[2]<<endl;
	cout<<"RE x "<<ans[3]<<endl;



	return 0;
}



Measured memory_bytes: 6748
<?php

function input() {
    return trim(fgets(STDIN));
}
function input_array() {
    return explode(' ', input());
}
//最大公約数
function gcd($m, $n){
    if($n > $m) list($m, $n) = array($n, $m);
     
    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
}
 
//最小公倍数
function lcm($m, $n){
    return $m * $n / gcd($m, $n);
}

list($N, $M) = input_array();
$S = input();
$T = input();

$gcd = gcd($N, $M);
$step_n = $N / $gcd;
$step_m = $M / $gcd;
$counter_n = 0;
$counter_m = 0;
$flag = true;
for ($i = 0; $i < $gcd; $i++) {
    if ($S[$counter_n] !== $T[$counter_m]) {
        $flag = false;
        break;
    }
    $counter_n += $step_n;
    $counter_m += $step_m;
}

if ($flag) {
    echo lcm($N, $M) . "\n";
} else {
    echo (-1) . "\n";
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long x[] = new long[N];
		long y[] = new long[N];
		long temp[] = new long[N];
		for(int i=0;i<N;i++) {
			x[i] = sc.nextLong();
			y[i] = sc.nextLong();
			temp[i] = x[i]+y[i];
		}
		Arrays.sort(temp);
		long max =temp[N-1]-temp[0];
		for(int i=0;i<N;i++) {
			temp[i] = x[i]-y[i];
		}
		Arrays.sort(temp);
		if (max<temp[N-1]-temp[0]) {
			max = temp[N-1]-temp[0];
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 65668
# coding: utf-8
# Your code here!

#n,k=[int(i) for i in input().split()]

n=int(input())
a=[]

if n==0:
    a=["0"]

while n != 0:
        a.append(str(n%2))
        n=-(n-n%2)//2

print("".join(list(reversed(a))))


Measured memory_bytes: 2940
s = input()

for i in range(len(s)):
	th = i + 1
	if (th % 2 == 1 and s[i] == "L"):
		print("No")
		exit()
	if (th % 2 == 0 and s[i] == "R"):
		print("No")
		exit()

print("Yes")


Measured memory_bytes: 2940
<?php
fscanf(STDIN,"%d",$a);

$stdins = array();
$i=1;
    while(true)
    {
    	$stdin = trim(fgets(STDIN));
      if ($stdin != '')
        {
    		$stdin =$stdin." ".$i;
      }
  $team = explode(" ", $stdin);
        
        if ($stdin === '')
        {
         break;
        }
          
        $stdins[] = $team;
        $i++;
    }
     
foreach ((array) $stdins as $key => $value) {
    $city[$key] = $value[0];
    $score[$key] = $value[1];
}
array_multisort( $city,SORT_ASC,$score,SORT_DESC,$stdins);

for($i=0;$i<$a;$i++){
echo $stdins[$i][2]."\n";
}


?>


Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(void){
    int n;
    string s;
    cin >> n;
    cin >> s;

    int ans = 1;
    for(int i=0; i<n-1; i++){
        if(s[i] != s[i+1]) ans += 1;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    char A,B;
    cin >> A >> B;
    if (A=='H'){
        cout << B << endl;
    }
    else{
        if (B=='H'){
            cout << 'D' << endl;
        }
        else{
            cout << 'H' << endl;
        }
    }
}

Measured memory_bytes: 256
def extgcd(a, b):
    r = [1, 0, a]
    w = [0, 1, b]
    while w[2] != 1:
        q = r[2] // w[2]
        r2 = w
        w2 = [r[0] - q * w[0], r[1] - q * w[1], r[2] - q * w[2]]
        r = r2
        w = w2
    return [w[0], w[1]]


def mod_inv(a, m):
    x = extgcd(a, m)[0]
    return (m + x % m) % m


X, Y = map(int, input().split())
MOD = 10 ** 9 + 7

if (X + Y) % 3:
    print(0)
    exit()

n = (X + Y) // 3
nx, ny = X - n, Y - n

if nx < 0 or ny < 0:
    print(0)
    exit()

ans = 1
for i in range(1, nx + ny + 1):
    ans = ans * i % MOD
for i in range(1, nx + 1):
    ans = ans * mod_inv(i, MOD) % MOD
for i in range(1, ny + 1):
    ans = ans * mod_inv(i, MOD) % MOD

print(ans)


Measured memory_bytes: 41964
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= d; j++){
            int a = j / 10, b = j % 10;
            ans += a >= 2 && b >= 2 ? i == a * b : 0;
        }
    }
    cout << ans << '\n';
}


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

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

  long int sum;
  int a,b,c;

  sum = 0;
  for(int i=1;i<=K;++i){
    for(int j=1;j<=K;++j){
      for(int k=1;k<=K;++k){
        if(i>=j){
          a = i;
          b = j;
        }else{
          a = j;
          b = i;
        }
        while(true){
          c = a%b;
          if(c==0) break;
          a = b;
          b = c;
        }
        if(k>=b) a = k;
        else{
          a = b;
          b = k;
        }
        while(true){
          c = a%b;
          if(c==0) break;
          a = b;
          b = c;
        }
        //cout<<i<<" "<<j<<" "<<k<<" b="<<b<<endl;
        sum = sum + b;
      }
    }
  }
  
  cout<<sum<<endl;
  
}

Measured memory_bytes: 3644