akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    a73(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a73(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val (orig, diff) = args[0].split(" ").map { it.toInt() }
    println(if (orig < diff) 0 else orig - diff)
}


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

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

    int n = s.length();

    if(s[n - 1] == 's'){
        s += "es";
    }else{
        s += "s";
    }

    cout << s << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#define maxn 200005
using namespace std;
typedef long long ll;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = getchar();c < '0' || c > '9';c = getchar()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res * sig;
}
int h,w,n,sr,sc;
char s[maxn],t[maxn];
int lb,rb,ub,db;
int main(){
  h = getint(), w = getint(), n = getint();
  sr = getint(), sc = getint();
  scanf("%s",s);
  scanf("%s",t);
  for(int i = n - 1;i >= 0;i--){
    if(t[i] == 'L'){ if(rb) rb--; }
    else if(t[i] == 'R'){ if(lb) lb--; }
    else if(t[i] == 'U'){ if(db) db--; }
    else{ if(ub) ub--; }
    if(s[i] == 'L') lb++;
    else if(s[i] == 'R') rb++;
    else if(s[i] == 'U') ub++;
    else db++;
    if(lb + rb == w || ub + db == h){
      puts("NO");
      return 0;
    }
  }
  if(sr > ub && sr <= h - db && sc > lb && sc <= w - rb) puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    int n;cin>>n;
    int i=1;
    while(i*2<=n){
        i*=2;
    }
    cout<<i<<endl;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    int N, K, C;
    cin >> N >> K >> C;
    string s;
    cin >> s;

    vector<int> L(K), R(K);
    int cnt = 100000000; //休んだ日数
    int id = 0; //L(K)R(K)のidx

    for(int i = 0; i < N; i++) {
        if(s[i] == 'o') {
            if(cnt >= C) {
                if(id >= K) break;
                L[id] = i;
                id++;
                cnt = 0;
            } else {
                cnt++;
            }
        }
        else {
            cnt++;
        }
    }

    id = K - 1;
    cnt = 100000000;
    for(int i = N - 1; i >= 0; i--) {
        if(s[i] == 'o') {
            if(cnt >= C) {
                if(id < 0) break;
                R[id] = i;
                id--;
                cnt = 0;
            } else {
                cnt++;
            }
        }
        else {
            cnt++;
        }
    }

    for(int i = 0; i < K; i++) {
        if(L[i] == R[i]) cout << L[i] + 1 << endl;
    }

    /*
    for(int i = 0; i < K; i++) {
        cout << L[i] << " " << R[i] << endl;
    }
    */

    return 0;
}


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

const ll mod = 1e9+7;
ll dp[2][2020];

ll extgcd(ll a, ll b, ll &x, ll &y){
  ll d = a;
  if(b){
    d = extgcd(b,a%b,y,x);
    y -= (a/b)*x;
  }else{
    x = 1; y = 0;
  }
  return d;
}

ll mod_inv(ll a){
  ll x,y;
  extgcd(a,mod,x,y);
  return (mod+x%mod)%mod;
}

ll mod_comb(ll n, ll k){
  if(k<0 || n<k)return 0;
  ll res = 1;
  rep(i,k){
    (res *= (n-i)%mod) %= mod;
    (res *= mod_inv(i+1)) %= mod;
  }
  return res;
}

int main(){
  ll n,d,x;
  while(cin >> n >> d >> x, n){
    x--;
    if(x*d<n){ cout << 0 << endl; continue; }
    rep(i,n+1)dp[0][i] = 0; dp[0][0] = 1;

    ll ans = 0;
    rep(i,n){
      int cur = i&1, nxt = 1-cur, sum = 0;
      rep(j,n+1)dp[nxt][j] = 0;

      rep(j,n){
	(sum += dp[cur][j]) %= mod;
	if(j>=x)(sum += mod-dp[cur][j-x]) %= mod;
	dp[nxt][j+1] = sum;
      }
      if(i<d){
	(ans += dp[nxt][n] * mod_comb(d,i+1)) %= mod;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1192
#include <iostream>


int main()
{
    int lgt_a; //??????????????????
    int lgt_b; //??????????????????

    //???????????\???
    std::cin >> lgt_a >> lgt_b;

    //?¨????????????????
    std::cout << lgt_a * lgt_b << " " << (lgt_a + lgt_b) * 2 << std::endl;

    return 0;
}

Measured memory_bytes: 1168
#include <algorithm>
#include <iostream>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> X(N), Y(N);
  rep (i, N) cin >> X[i] >> Y[i];
  double ans = 0;
  rep (i, N) {
    double tmp = 0;
    rep (j, N) {
      if (i == j) continue;
      tmp += pow((X[i]-X[j]) * (X[i]-X[j]) + (Y[i]-Y[j]) * (Y[i]-Y[j]), 0.5); 
    }
    tmp /= N;
    ans += tmp;
  }
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 512
n, m = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
a.sort(reverse=True)
bc = [[int(item) for item in input().split()] for _ in range(m)]
bc.append([1,0])
bc.sort(key=lambda x: -x[1])

a_index = 0
bc_index = 0
ans = 0
for i in range(n):
    if a[a_index] >= bc[bc_index][1]:
        ans += a[a_index]
        a_index += 1
    else:
        ans += bc[bc_index][1]
        bc[bc_index][0] -= 1
        if bc[bc_index][0] == 0:
            bc_index += 1
print(ans)

Measured memory_bytes: 29816
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e9;



signed main(){
	int N,M;
	cin >> N >> M;
	vector<int>a(M);
	REP(i,M)cin >> a[i];
	int as = accumulate(ALL(a),0ll);
	if(as <= N)out(N - as);
	else out(-1);
}

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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MOD 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;
typedef pair<ll,ll> Pl;
typedef vector<ll> vl;
typedef vector<Pl> vpl;

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b <= 0) return -1;
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

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


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

    int a = N%10;
    string ans;

    if(a == 3) ans = "bon";
    else if(a == 0 || a == 1 || a==6 || a==8) ans = "pon";
    else ans = "hon";


    //string ans = ( flag ? "Yes" : "No" );
    //printf("%.8lf", ans);
    cout << ans;
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a*n, b) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////

ll dist(ll a, ll b) {
	if (a > 0) { return b; }
	if (b < 0) { return -a; }
	return min(b - 2 * a, 2 * b - a);
}




int main() {

	ll N, K;
	cin >> N >> K;

	ll x[MAX];
	repn(i, N) cin >> x[i];

	ll ans = INF;

	repn(i, N - K + 1) {
		ans = min(ans, dist(x[i], x[i + K - 1]));
	}

	cout << ans;
	
	

	system("PAUSE");
}

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

N,A,B,C=input().split()
D=dict()
D["A"]=int(A)
D["B"]=int(B)
D["C"]=int(C)

S=[]
for i in range(int(N)):
    S.append(input())

ans="Yes"
F=[]
for i,s in enumerate(S):
    if D[s[0]]==0 and D[s[1]]==0:
        ans="No"
        break
    if D[s[0]]==1 and D[s[1]]==1:
        if D["A"]+D["B"]+D["C"]==2:
            if i!=int(N)-1:
                if S[i+1] != s:
                    s0=S[i+1][0]
                    s1=S[i+1][1]
                    if s[0]==s0 or s[0]==s1:
                        F.append(s[0])
                    if s[1]==s0 or s[1]==s1:
                        F.append(s[1])
    if len(F)!=i+1:
        if D[s[0]]<D[s[1]]:
            F.append(s[0])
        if D[s[0]]>D[s[1]]:
            F.append(s[1])
        if D[s[0]]==D[s[1]]:
            F.append(s[0])

    D[F[-1]]+=1
    if s[0]==F[-1]: D[s[1]]-=1
    if s[1]==F[-1]: D[s[0]]-=1
    #print(D)
    #print(F)

print(ans)
if ans=="Yes":
    for f in F:
        print(f)



Measured memory_bytes: 16860
#include <cstdio>

int main() {
  int seconds;
  scanf("%d", &seconds);

  int count_per_second;
  scanf("%d", &count_per_second);

  int finish_seconds;
  scanf("%d", &finish_seconds);

  int latest_seconds;
  latest_seconds = finish_seconds / seconds;

  int total_count;
  total_count = latest_seconds * count_per_second;

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

  return 0;
}


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

int ans[4], in[4];

int main(){
  int a, b, c, d;
  while(cin >> a >> b >> c >> d){
    int hit=0, blow=0;
    ans[0]=a; ans[1]=b; ans[2]=c; ans[3]=d;
    cin >> in[0] >> in[1] >> in[2] >> in[3];
    for(int i=0; i<4; i++){
      for(int j=0; j<4; j++){
        if(ans[i]==in[j]){
          if(i==j) hit++;
          else blow++;
        }
      }
    }
    cout << hit << ' ' << blow << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include<math.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<stdlib.h>
using namespace std;
double x[200];
double y[200];
double EPS=1e-9;
struct L{ // ax+by+c=0
	double a,b,c;
	L(){}
	L(double A,double B,double C){
		a=A;
		b=B;
		c=C;
	}
};
double Abs(double a){return max(a,-a);}
struct P{
	double x,y;
	P(){}
	P(double X,double Y){
		x=X;
		y=Y;
	}
};
P inter(L s,L t){
	double det=s.a*t.b-s.b*t.a;
	if(Abs(det)<EPS){
		return P(1000000009,1000000009);
	}
	return P((-t.b*s.c+s.b*t.c)/det,(-t.c*s.a+s.c*t.a)/det);
}
double dot(P a,P b){
	return a.x*b.x+a.y*b.y;
}
double cross(P a,P b){
	return a.x*b.y-a.y*b.x;
}
double norm(P a){
	return a.x*a.x+a.y*a.y;
}
int ccw(P a,P b,P c){
	b.x-=a.x;
	b.y-=a.y;
	c.x-=a.x;
	c.y-=a.y;
	if(cross(b,c)>0)return 1;
	if(cross(b,c)<0)return -1;
	if(dot(b,c)<0)return 2;
	if(norm(b)<norm(c))return -2;
	return 0;
}
double dist(L s,P t){ // 点と直線の距離
	return Abs(s.a*t.x+s.b*t.y+s.c)/sqrt(s.a*s.a+s.b*s.b);
}
L convLine(P s,P t){ // (x1,y1),(x2,y2)を通る直線の型変換
	double theta=atan2(t.y-s.y,t.x-s.x);
	double A=sin(theta);
	double B=-cos(theta);
	double C=-(s.x*A+s.y*B);
	return L(A,B,C);
}
L lines[200];
L poly[102];
P point[102];
int main(){
	int a;
	int n=0;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			scanf("%lf%lf",x+i,y+i);
		}
		x[a]=x[0];
		y[a]=y[0];
		for(int i=0;i<=a;i++)point[i]=P(x[i],y[i]);
		for(int i=0;i<a;i++){
			poly[i]=convLine(point[i],point[i+1]);
		//	printf("%f %f %f\n",poly[i].a,poly[i].b,poly[i].c);
		}
		double left=0;
		double right=10000;
		for(int i=0;i<50;i++){
			double M=(left+right)/2;
			for(int j=0;j<a;j++){
				lines[j*2]=L(poly[j].a,poly[j].b,poly[j].c-M);
				lines[j*2+1]=L(poly[j].a,poly[j].b,poly[j].c+M);
			}
			vector<P> points;
			for(int j=0;j<2*a;j++){
				for(int k=j+1;k<2*a;k++){
					P val=inter(lines[j],lines[k]);
					if(Abs(val.x-1000000009)>EPS){
						points.push_back(val);
					}
				}
			}
			bool ok=false;
			for(int j=0;j<points.size();j++){
				bool OK=true;
				for(int k=0;k<a;k++){
					if(dist(poly[k],points[j])+EPS<M){
						OK=false;
						break;
					}
					if(ccw(point[k],points[j],point[k+1])!=-1)OK=false;
				}
				if(OK){
					ok=true;
					break;
				}
			}
			if(ok){
				left=M;
			}else right=M;
		}
		printf("%.8f\n",left);
		n++;
	}
	if(n>29)return 1;
	
}

Measured memory_bytes: 1816
# https://atcoder.jp/contests/abc120/tasks/abc120_d

import itertools
import collections
import bisect
import sys
input = sys.stdin.readline

# Union find
class UnionFind():
    #負の値の場合根を表す。絶対値はツリーの高さ
    #正の値は次の要素を返す、根まで続く
    def __init__(self,size):
        self.table = [-1 for _  in range(size)]
        self.size_table = [1 for _  in range(size)]

        # 集合の代表を求める
    def find(self, x):
        while self.table[x] >= 0:
            # 根に来た時,self.table[根のindex]は負の値なのでx = 根のindexで値が返される。
            x = self.table[x]
        return x

        # 併合
    def union(self, x, y):
        s1 = self.find(x)  # 根のindex,table[s1]がグラフの高さ
        s2 = self.find(y)
        if s1 != s2:  # 根が異なる場合
            if self.table[s1] != self.table[s2]:  # グラフの高さが異なる場合
                if self.table[s1] < self.table[s2]:
                    self.table[s2] = s1
                    self.size_table[s1] += self.size_table[s2]
                else:
                    self.table[s1] = s2
                    self.size_table[s2] += self.size_table[s1]
            else:
                # グラフの長さが同じ場合,どちらを根にしても変わらない
                # その際,グラフが1長くなることを考慮する
                self.table[s1] += -1
                self.table[s2] = s1
                self.size_table[s1] += self.size_table[s2]
        return

    def size(self, x):
        return self.size_table[self.find(x)]


def main():
    N, M = map(int, input().split())
    bridges = [list(map(int, input().split())) for _ in range(M)]
    bridges = list(map(lambda l: [i-1 for i in l], bridges))
    # print(bridges)

    fuben = N * (N-1) // 2
    answers = []
    uf = UnionFind(N)
    for j in range(len(bridges)-1, 0, -1):
        br = bridges[j]

        if uf.find(br[0]) != uf.find(br[1]):  # 新しく繋がってる
            fuben -= (uf.size(br[0]) * uf.size(br[1]))

        answers.append(fuben)

        uf.union(br[0], br[1])

    # print(answers)

    for a in reversed(answers):
        print(a)

    # 最後
    print(N * (N-1) // 2)


if __name__ == '__main__':
    main()



Measured memory_bytes: 41324
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		ABC051CSolve solve = new ABC051CSolve();
		solve.main();
	}
}

class ABC051CSolve {
	
	int sx;
	int sy;
	int tx;
	int ty;
	
	ABC051CSolve() {
		Scanner cin = new Scanner(System.in);
		this.sx = cin.nextInt();
		this.sy = cin.nextInt();
		this.tx = cin.nextInt();
		this.ty = cin.nextInt();
	}
	
	void main() {
		StringBuffer sb = new StringBuffer();
		
		int width = tx - sx;
		int height = ty - sy;
		
		// 1st start to goal
		for (int i = 0; i < width; i++) {
			sb.append("R");
		}
		for (int i = 0; i < height; i++) {
			sb.append("U");
		}
		
		// 1st goal to start
		for (int i = 0; i < width; i++) {
			sb.append("L");
		}
		for (int i = 0; i < height; i++) {
			sb.append("D");
		}
		
		// 2nd start to goal
		sb.append("L");
		for (int i = 0; i < height + 1; i++) {
			sb.append("U");
		}
		for (int i = 0; i < width + 1; i++) {
			sb.append("R");
		}
		sb.append("D");
		
		// 2nd goal to start
		sb.append("R");
		for (int i = 0; i < height + 1; i++) {
			sb.append("D");
		}
		for (int i = 0; i < width + 1; i++) {
			sb.append("L");
		}
		sb.append("U");
		
		System.out.println(sb.toString());
	}
	
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int n; cin >> n;
  vector<int> sw(n);
  rep(i, n) {
    int t; cin >> t; t--;
    sw[i] = t;
  }
  set<int> touched;
  int curr = 0;
  int ans = 0;
  while(true) {
    ans++;
    curr = sw[curr];
    if (curr == 1) {
      cout << ans;
      return 0;
    } else {
      auto r = touched.insert(curr);
      if (!r.second) {
        cout << -1;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 5376
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var mod = 1e9+7;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}
var fac=[],finv=[],invs=[],pow2=[];
function fset(n){
  fac.length=n+1,fac[0]=fac[1]=1;
  for(var i=2;i<=n;)fac[i]=mul(fac[i-1],i++);
  finv.length=n+1,finv[0]=finv[1]=1,finv[n]=inv(fac[n]);
  for(i=n;2<i;)finv[i-1]=mul(finv[i],i--);
  invs.length=n+1,invs[0]=invs[1]=1;
  for(i=2;i<=n;)invs[i]=mul(fac[i-1],finv[i++]);
  pow2.length=n+1,pow2[0]=1;
  for(i=1;i<=n;i++)pow2[i]=pow2[i-1]*2%mod;
}
function inv(b){for(var a=mod,u=0,v=1,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function pow(a,n){for(var r=1;n;a=mul(a,a),n>>=1)if(n&1)r=mul(a,r);return r;}
function ncr(n,r){return mul(fac[n],finv[r],finv[n-r]);}
function npr(n,r){return mul(fac[n],finv[r]);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);
function main(){
  var n = o.a();
  var a = o.l();
  var c = xArray(0,1e6+1);
  for(var i = 0; i < n; i++){
    f(a[i]);
  }
  var l = 1;
  for(var i = 2; i <= 1e6; i++){
    while(c[i]){
      l = l*i%mod;
      c[i]--;
    }
  }
  var ans = 0;
  for(var i = 0; i < n; i++){
    ans += mul(l,inv(a[i]));
  }
  return ans % mod;
  function f(x){
    for(var i = 2; i*i <= x; i++){
      var s = 0;
      while(x%i === 0){
        s++;
        x /= i;
      }
      if(s > c[i])c[i] = s;
    }
    if(x > 1 && c[x] === 0)c[x] = 1;
  }
}

Measured memory_bytes: 28320
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
#include <boost/multiprecision/cpp_int.hpp>
#endif
#define p std::pair
#define ll long long
#define ull unsigned long long
#define pi (acos(-1))
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
#define oreq |=

using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
ll extgcd(ll a, ll b, ll &x, ll &y);
ll nCr(ll n, ll r);
void stat();
constexpr ll mod = 1000000000 + 7;
int main()
{
    stat();
    int n,k;
    cin>>n>>k;
vec<int> v(n);
rep(i,n){
	cin>>v[i];
}
sort(all(v));
#ifdef local
dbg(v);
#endif
int sum=0;
rep(i,k){
sum+=v[i];
}
cout<<sum<<endl;
    return 0;
}
ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat() {
#ifdef local
    rep(i, 2) {std::cout << "local enable" << std::endl;
}
#endif
#ifdef hacks
rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}

ll nCr(ll n, ll r)
{
    ll num = 1;
    for (ll i = 1; i <= r; i++) { num = num * (n - i + 1) / i; }
    return num;
}


Measured memory_bytes: 3644
#include<iostream>
#include<vector>
using namespace std;
#define mod (long long)(1e9+7)

int main()
{
  int N,M;
  cin>>N>>M;
  
  vector<bool> can(N+1,true);
  for(int i=0;i<M;i++){
    int tmp;
    cin>>tmp;
    can.at(tmp)=false;
  }
  
  vector<long long> dp(N+1,0);
  dp.at(0)=1;
  for(int now=0;now<N;now++){
    for(int next=now+1;next<=min(N,now+2);next++){
      if(can.at(next)){
        dp.at(next)+=dp.at(now);
        dp.at(next)%=mod;
      }
    }
  }
  cout<<dp.at(N);
}
  

Measured memory_bytes: 1024
#include <iostream>
#include <set>
#include <string>
using namespace std;
int main(){
    int n;
    set<string>st;
    cin >>n;
    for(int i=0; i < n; i++){
        string s;
        cin >> s;
        st.insert(s);
    }
    cout <<st.size()<<endl;
}


Measured memory_bytes: 19088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    string a, b, c;
    cin >> a >> b >> c;

    int A = a.length();
    int B = b.length();
    int C = c.length();

    bool ab[8001], ac[8001], bc[16001];
    for (int i = 0; i <= 8000; i++) {
        ab[i] = ac[i] = true;
    }
    for (int i = 0; i <= 16000; i++) bc[i] = true;
    
    for (int i = -B + 1; i < A; i++) {
        for (int j = max(0, i); j < min(A, i + B); j++) {
            if (a[j] != '?' && b[j - i] != '?' && a[j] != b[j - i]) ab[i + 4000] = false;
        }
    }
    for (int i = -C + 1; i < A; i++) {
        for (int j = max(0, i); j < min(A, i + C); j++) {
            if (a[j] != '?' && c[j - i] != '?' && a[j] != c[j - i]) ac[i + 4000] = false;
        }
    }
    for (int i = -C + 1; i < B; i++) {
        for (int j = max(0, i); j < min(B, i + C); j++) {
            if (b[j] != '?' && c[j - i] != '?' && b[j] != c[j - i]) bc[i + 8000] = false;
        }
    }

    int ans = 10000;
    for (int i = -4000; i <= 4000; i++) for (int j = -4000; j <= 4000; j++) {
        if (ab[i + 4000] && ac[j + 4000] && bc[j - i + 8000]) {
            int l = min(0, min(i, j));
            int r = max(A, max(i + B, j + C));
            ans = min(ans, r - l);
        }
    }

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

Measured memory_bytes: 384
//  Created by liszt on 2019/07/27.
#include<bits/stdc++.h>
using namespace std;

int P[10]={0,0,0,0,0,0,1,1,1,2};
int Q[10]={1,1,1,2,2,3,2,2,3,3};
int R[10]={2,3,4,3,4,4,3,4,4,4};

int main(){
    long long n,MARCH[5]={0}; cin>>n;
    for(int i=0;i<n;i++){
        string S; cin>>S;
        if(S[0]=='M')MARCH[0]++;
        else if(S[0]=='A')MARCH[1]++;
        else if(S[0]=='R')MARCH[2]++;
        else if(S[0]=='C')MARCH[3]++;
        else if(S[0]=='H')MARCH[4]++;
    }
    
    long long ans=0;
    for(int i=0;i<10;i++){
        ans+=MARCH[P[i]]*MARCH[Q[i]]*MARCH[R[i]];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n) 

int main(void){  
  /*
  string tmp;
  bool first=true;
  while(cin>>tmp){
    if(!first) cout << " ";
    if(tmp=="apple")
      cout << "peach";
    else if (tmp=="peach") 
      cout << "apple";
    else 
      cout << tmp;
    first = false;
  }
  cout << endl;
  */
  string line;
  getline(cin,line);
  string tmp1 = line;
  string tmp2 = line;
  string out = line;
  while(tmp1.find("apple")!=string::npos){
    out.replace(tmp1.find("apple"),5,"peach");
    tmp1.replace(tmp1.find("apple"),5,"peach");
  }
  while(tmp2.find("peach")!=string::npos){
    out.replace(tmp2.find("peach"),5,"apple");
    tmp2.replace(tmp2.find("peach"),5,"apple");
  }
  cout<<out<<endl;
  return 0;
}

Measured memory_bytes: 0
N = int(input())
S = input()
Rcnt = S.count('R')
Wcnt = N-Rcnt
# Wのが少ないとき
if Wcnt < Rcnt:
    cnt = S[-Wcnt:].count('W')
    print(Wcnt - cnt)
else:
    cnt = S[:Rcnt].count('R')
    print(Rcnt-cnt)


Measured memory_bytes: 63040
typedef long unsigned int size_t;
extern int printf (const char *__restrict __format, ...);
extern int scanf (const char *__restrict __format, ...) ;
extern int getchar (void);
extern int putchar (int __c);
int nextInt(){int f=0;char s=0;char c=getchar();while((c<48)||(57<c)){if(c==45){s=1;c=getchar();break;}c=getchar();}while((48<=c)&&(c<=57)){f=f*10+(c-48);c=getchar();}return s?-f:f;}
char nextChar(){char f=0;char s=0;char c=getchar();while((c<48)||(57<c)){if(c==45){s=1;c=getchar();break;}c=getchar();}while((48<=c)&&(c<=57)){f=f*10+(c-48);c=getchar();}return s?-f:f;}
short int nextShort(){short f=0;char s=0;char c=getchar();while((c<48)||(57<c)){if(c==45){s=1;c=getchar();break;}c=getchar();}while((48<=c)&&(c<=57)){f=f*10+(c-48);c=getchar();}return s?-f:f;}
long long int nextLong(){long long int f=0;char s=0;char c=getchar();while((c<48)||(57<c)){if(c==45){s=1;c=getchar();break;}c=getchar();}while((48<=c)&&(c<=57)){f=f*10+(c-48);c=getchar();}return s?-f:f;}
void println(){putchar(10);}
void print(char *f){while(*f){putchar(*f);f++;}}
void printInt(int f){char c[10];if(!f){putchar(48);return;}if(f<0){f=-f;putchar(45);}char i=0;while(f){c[++i]=(f%10)+48;f/=10;}while(i){putchar(c[i--]);}}
void printLong(long long int f){char c[19];if(!f){putchar(48);return;}if(f<0){f=-f;putchar(45);}char i=0;while(f){c[++i]=(f%10)+48;f/=10;}while(i){putchar(c[i--]);}}
int min(int a, int b){return a>b?b:a;}
int d, i;
int g, p[11], c[11];
int n, a;
int ans;
int s1, need;
int main(){
 d=nextInt();
 g=nextInt();
 for(i = 0; i < d; ++i){
  p[i]=nextInt();
  c[i]=nextInt();
 }
 ans = 1e9;
 n = 1<<d;
 for(a=0; a<n; a++){
  int s = 0, num = 0, rest_max = -1;
  for(i=0; i<d; i++){
   if(a>>i&1){
    s += 100 * (i+1) * p[i] + c[i];
    num += p[i];
   }else{
    rest_max = i;
   }
  }
  if(s<g){
   s1 = 100 * (rest_max + 1);
   need = (g - s + s1 - 1) / s1;
   if(need >= p[rest_max]){
    continue;
   }
   num += need;
  }
  ans = min(ans, num);
 }
 printInt(ans);
 println();
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	int mmax = min(a,b);
	int mmin = max(a+b-n, 0);
	cout << mmax << " " << mmin << endl;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int n = read();
  vi a;
  REP(i, n) { a.PB(read()); }
  sort(ALL(a));
  print(a[n - 1] - a[0]);
}


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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
// #define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for(int i = (int)(n - 1); i >= 0; --i)
#define RFOR(i, a, b) for(int i = (int)(b - 1); i >= (int)(a); --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)
#define BIT(x, i) (((x) >> (i)) & 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<vll> vvll;

const int HINF = 30;
const int DINF = 200;

int interview[100];

int main() {
  int T, N;
  while(cin >> T, T) {
    int maxinterview = 0;
    fill_n((int *)interview, 100, HINF);

    vi cycle(T);
    REP(i, T){
      cin >> cycle[i];
      cycle[i]--;
    }

    cin >> N;
    REP(i, N) {
      int d, m;
      cin >> d >> m;
      d--; m--;
      interview[d] = min(interview[d], m);
      maxinterview = max(maxinterview, d);
    }
    maxinterview++;

    vvi dp(maxinterview + 1, vi(T, DINF));
    dp[0][T - 1] = 0;

    // LOG("\n[%d]\n", 0);
    // REP(i, T) {
    //   LOG("%d ", dp[0][i]);
    // }
    // LOG("\n");

    REP(d, maxinterview) {
      REP(i, T) {
        if (dp[d][i] == DINF) continue;
        int sc;
        // yes caffeine
        sc = 0;
        dp[d + 1][0] = min(dp[d + 1][0], dp[d][i] + 1);
        // no caffeine
        sc = (i + 1) % T;
        if (interview[d] >= cycle[sc]) {
          dp[d + 1][sc] = min(dp[d + 1][sc], dp[d][i]);
        } else {
          // LOG("nesugosi\n");
        }
      }

      // LOG("\n[%d]\n", d + 1);
      // REP(i, T) {
      //   LOG("%d ", dp[d + 1][i]);
      // }
      // LOG("\n");
    }
    cout << *min_element(ALL(dp[maxinterview])) << endl;
  }
}

Measured memory_bytes: 3136
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#define N 300005
using namespace std;

int n, s[N];
bool v[N];
priority_queue<int> pq[2];
int main()
{
	int i, j;
	cin >> n;
	for (i = 0; i < 1 << n; i++) {
		scanf("%d", &s[i]);
	}
	sort(s, s + (1 << n), greater<int>());
	pq[0].push(s[0]);
	for (i = 0; i < n; i++) {
		for (j = 1; j < 1 << n; j++) {
			if (!v[j] && s[j] < pq[i % 2].top()) {
				v[j] = 1;
				pq[1 - i % 2].push(pq[i % 2].top());
				pq[1 - i % 2].push(s[j]);
				pq[i % 2].pop();
				if (pq[i % 2].empty()) break;
			}
		}
		if (!pq[i % 2].empty()) {puts("No"); return 0;}
	}
	puts("Yes");
    return 0;
}

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

using namespace std;

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<numeric>

using namespace std;

int main(){
    int a;
    string s ,st;
    cin >> a;
    cin >> s >> st;
    for(int i = 0; i < a; i++){
        cout << s[i] << st[i];
    }

}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<math.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
const long double pi = 3.14159265358979323846264338327950288;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b)
		cout << "YES\n";
	else cout << "NO\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
long long a[200005];
long long k,l,r,mid,ans;
long long work(long long a,long long b) {
	return a / b + (((a ^ b) >= 0) and a % b);
}
long long _work(long long a, long long b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
long long check(long long w){
	long long cnt=0,div;
	for (register int i=1;i<=n;++i){
		if (a[i]==0){
			if (w>=0) cnt+=n-1; 
		}
		if (a[i]>0){
		    div=_work(w,a[i]);
			int pos=upper_bound(a+1,a+1+n,div)-a;
			--pos;
			if (pos>=i) cnt+=pos-1;
			else cnt+=pos;
		}
		if (a[i]<0){
			div=work(w,a[i]);
			int pos=lower_bound(a+1,a+1+n,div)-a;
			if (pos<=i) cnt+=n-pos;
			else cnt+=n-pos+1;
		}
	}
	return cnt/2;
}
int main(){
	scanf ("%d%lld",&n,&k);
	for (register int i=1;i<=n;++i) scanf ("%lld",&a[i]);
	sort (a+1,a+1+n);
	l=-1e18;r=1e18;
	while (l<=r){
		mid=l+r>>1;
		if (check(mid)>=k) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf ("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap



@mt
def slv(N, XY):
    from collections import defaultdict
    g = defaultdict(set)
    yo = 10**6
    V = set()
    for x, y in XY:
        y += yo
        g[x].add(y)
        g[y].add(x)
        V.add(x)
        V.add(y)


    rem = set(v for v in V)
    done = set()
    ans = 0
    while rem:
        u = rem.pop()
        s = [u]
        done.add(u)
        xs = set()
        ys = set()
        if u >= yo:
            ys.add(u)
        else:
            xs.add(u)
        while s:
            u = s.pop()
            if u >= yo:
                ys.add(u)
            else:
                xs.add(u)
            for v in g[u]:
                if v in done:
                    continue
                s.append(v)
                done.add(v)
        rem -= xs
        rem -= ys
        e = 0
        for u in xs:
            e += len(g[u])
        ans += len(xs) * len(ys) - e

    return ans





def main():
    N = read_int()
    XY = [read_int_n() for _ in range(N)]
    print(slv(N, XY))


if __name__ == '__main__':
    main()


Measured memory_bytes: 116564
// syakyo http://d.hatena.ne.jp/simezi_tan/20120906/1346880190

#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int n;
vector<int> x, y, v;

inline double d(int i, double a, double b){
    return sqrt((x[i] - a)*(x[i] - a) + (y[i] - b)*(y[i] - b));
}

inline double g(double a, double b){
    double res = 0;
    rep(i, n){
        res = max(res, d(i, a, b)/v[i]);
    }
    return res;
}

inline double f(double x){
    double l = 0, r = 100, a, b;
    double ans;
    rep(i, 100){
        a = (l * 2 + r) / 3;
        b = (l + r * 2) / 3;
        if ((ans = g(x, a)) > g(x, b)) l = a;
        else r = b;
    }
    return ans;
}

int main(){
    while (cin >> n, n){
        x = vector<int>(n), y = vector<int>(n), v = vector<int>(n);
        rep(i, n){
            cin >> x[i] >> y[i] >> v[i];
        }
        double l = 0, r = 100, a, b;
        double ans;
        rep(i, 100){
            a = (l * 2 + r) / 3;
            b = (l + r * 2) / 3;
            if ((ans = f(a)) > f(b)) l = a;
            else r = b;
        }
        cout << fixed << setprecision(20);
        cout << f(l) << endl;
    }
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const double DINF = 5e14, eps = 1e-10;
const long long MOD = 1e9 + 7, INF = 5e18;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()

ll n, l, r, cnt[100010];
bool fl = 0;
vector<int>ans[10000];

int main() {
	cin >> n;
	for (int i = 1;i <= n;i++) {
		if (n * 2 % i == 0) {
			if (n * 2 / i == i + 1) {
				fl = 1;
				l = i, r = i + 1;
				break;
			}
		}
	}
	if (!fl) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	for (int j = 1;j <= l;j++) {
		ans[0].eb(j);
	}
	int now = 0, nex = 1, b = 1, nn = l + 1, t = 0;
	while (b <= l) {
		for (int i = 0;i < r - b;i++) {
			ans[nex].eb(ans[now][t + i]);
			nex++;
		}
		nex = b + 1;
		now++;
		for (int i = 0;i < l - b;i++) {
			ans[now].eb(nn + i);
		}
		nn += l - b;
		b++;
		t++;
	}
	cout << r << endl;
	for (int i = 0;i < r;i++) {
		cout << ans[i].size() << ' ';
		for (int j = 0;j < ans[i].size();j++) {
			cout << ans[i][j] << ' ';
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 2560
def make_prime(n):
    prime = []
    temp = n
    for i in range(2, n):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            prime.append([i, cnt])
    if temp!=1:
        prime.append([temp, 1])
    if prime==[]:
        prime.append([n, 1])

    return prime


from collections import defaultdict
d=defaultdict(lambda :1)
num = int(input())
w=10**9+7
for i in range(2,num+1):
    prime_num_list = make_prime(i)
    for j in range(len(prime_num_list)):
        key = prime_num_list[j][0]
        d[key] += prime_num_list[j][1]
cnt=1
for val in d.values():
    cnt*=val%w
print(cnt%w)

Measured memory_bytes: 43484
#include <bits/stdc++.h>
using namespace std;
const int IINF = INT_MAX;
const int MAX_N = int(1e5 + 5);

int main() {
    int n, dp[MAX_N];
    vector<int> pos[26];
    string w[MAX_N];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> w[i];
        pos[w[i][0]-'a'].push_back(i);
    }
    for(int i=0;i<26;i++){
        pos[i].push_back(IINF);
    }
    fill(dp,dp+n+1,IINF);
    dp[0] = 0;
    for(int i=0;i<n;i++){
        dp[i+1] = min(dp[i+1],dp[i]+1);
        int m = w[i][0]-'a';
        int j = *upper_bound(pos[m].begin(), pos[m].end(), i);
        if(j < IINF){
            dp[j] = min(dp[j], dp[i]);
        }
    }
    cout << dp[n] << endl;
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    string S;
    cin >> S;
    cout << (S.substr(0, 4) == "YAKI" ? "Yes" : "No") <<endl;
    return 0;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    int all = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        all = all ^ a[i];
    }
    for (int i = 0; i < n; i++) {
        cout << (all ^ a[i]) << " ";
    }
}



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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

ll dp[101][100001]={0};
int main(void){
    int n;
    ll W;
    cin>>n>>W;
    vector<ll> w(n),v(n);
    rep(i,0,n)cin>>w[i]>>v[i];
    rep(i,0,n){
        rep(j,0,W+1){
            if(j>=w[i]){
                dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
            }else{
                dp[i+1][j]=dp[i][j];
            }
        }
    }
    cout<<dp[n][W]<<endl;
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s[0] == s[1] && s[0] == s[2]){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}

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


int main()
{
    int n;
    std::cin >> n;
    std::vector<std::vector<int>> a(n,std::vector<int>(10));
    for(int i = 0; i < n; i++){
        std::vector<int> x(5),y(5);
        for(int j = 0; j < 10; j++){
           if(j < 5)std::cin >> x[j];
           else std::cin >> y[j - 5];  
        }
        for(int j = 0; j < 10; j++){
            if(j % 2 == 0)a[i][j] = x[j / 2];
            else a[i][j] = y[j / 2];
        }
    }
    std::vector<std::vector<int>> p(n,std::vector<int>(11));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 11; j++){
            std::cin >> p[i][j];
        }
    }

    std::vector<bool> s;
    //bit全探索
    int max = -2000000000;
    for(int bit = 1; bit < (1 << 10); bit++){
        int cnt = 0;
        std::vector<bool> jo(10);
        for(int i = 0; i < 10; i++){
            if(bit & (1 << i))jo[i] = true;
        }

        //各店について
        for(int i = 0; i < n; i++){
            int mise_cnt = 0;
            for(int j = 0; j < 10; j++){
                if(jo[j] && a[i][j])mise_cnt++;
            }
            cnt += p[i][mise_cnt];
        }
        if(cnt > max){
       // max = std::max(cnt,max);
        max = cnt;
        s = jo;
        }
    }
    std::cout << max << std::endl;
} 

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

int main()
{
    int n, p[100010];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> p[i];

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] == i + 1) swap(p[i], p[i + 1]), cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 640
def kyu_atcoder():
    x = int(input())
    if x in range(400, 599+1):
        print("8")
    elif x in range(600, 799+1):
        print("7")
    elif x in range(800, 999+1):
        print("6")
    elif x in range(1000, 1199+1):
        print("5")
    elif x in range(1200, 1399+1):
        print("4")
    elif x in range(1400, 1599+1):
        print("3")
    elif x in range(1600, 1799+1):
        print("2")
    elif x in range(1800, 1999+1):
        print("1")
    else:
        pass

kyu_atcoder()

Measured memory_bytes: 9200
/* ****GT_18**** */

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define INF			1000000000000000
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;
using namespace __gnu_pbds;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll n;
		cin>>n;
		ll ans=0;
		rep(i,1,n){
			ll bc = (n+i-1)/i;
			ans+=bc-1;
		}	
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
int main(){
  int n,m,g,s,flag=0;
  long y;
  scanf("%d %ld",&n,&y);
  for(s=n;s>=0;s--){
    for(g=0;g<=n-s;g++){
      if(y==s*1000+g*5000+(n-s-g)*10000){
        printf("%d %d %d\n",n-s-g,g,s);
        flag=1;
        break;
      }
    }
    if(flag) break;
  }
  if(!flag) printf("-1 -1 -1\n");
}


Measured memory_bytes: 256
len = int(input())
arr = []
for i in range(len):
    arr.append(list(map(int, input().split())))
arr.sort(key=lambda x: x[1])
work = 0
schedule = 0
STATUS = "Yes"
for j in arr:
  work += j[0]
  schedule = j[1]
  if work > schedule:
    STATUS = "No"
    break
print(STATUS)

Measured memory_bytes: 53596
#include<stdio.h>
int main(int argc, char const *argv[])
{
    int n,k;
    int a;
    int ans=0;
    scanf("%d%d",&n,&k);
    n--;
    a = k-1;

    while(n > 0){
        n = n - a;
        ans++;
    }

    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128