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

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

typedef uint64_t ulint;
typedef int64_t lint;
using namespace std;

lint a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
bool flagdebug = false;

int main(){
//////////////////////////////////////////////////////
    // flagdebug = true;

    cin >> a >> b >> c >> d;
    e = (a + d - 1) / d;
    f = (c + b - 1) / b;

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

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a[200200];

li cnt[1001000];
li cnt1[1001000];

int main() {
    li n;
    cin >> n;
    set<li> st;
    rin{
        cin >> a[i];
        st.insert(a[i]);
        cnt1[a[i]]++;
    }
    for (auto v : st) {
        for (li j = 1; v * j <= 1000000; j++) {
            cnt[j * v]++;
        }
    }
    li res = 0;
    rin{
        if (cnt[a[i]] <= 1 && cnt1[a[i]] <= 1) {
            res++;
        }
    }
    cout << res << endl;


    return 0;
}

Measured memory_bytes: 29288
from itertools import cycle
S = input()

ans = [0]*len(S)

i = 0
for j,s in enumerate(S):
    if s == 'L':
        r = (j-i)//2
        ans[j-1] += (j-i)-r
        ans[j] += r
        i = j+1

i = len(S)-1
for j,s in zip(reversed(range(len(S))), reversed(S)):
    if s == 'R':
        r = (i-j)//2
        ans[j+1] += (i-j)-r
        ans[j] += r
        i = j-1

print(*ans)

Measured memory_bytes: 6400
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  int a, b;
  readf("%s %s", &a, &b);
  if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) {
    writeln("Possible");
  } else {
    writeln("Impossible");
  }
}


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

int main() {

  int A, B, K;

  cin >> A >> B >> K;

  int length = B - A + 1;

  for (int i = 0; i < length; i++) {
    if (i < K || length - K <= i) {
      cout << A + i << endl;
    }
  }

}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main(void){
    map<int, int> flag;
    int N;
    cin >> N;
    int A[N];
    string ans = "YES";
    for(int i = 0; i < N; i++){
        cin >> A[i];
        if(flag[A[i]] == 1){
            ans = "NO";
            break;
        }else{
            flag[A[i]] = 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10624
import itertools
N, M, X= map(int, input().split())

p = []
u = []

for i in range(N):
  t = list(map(int, input().split()))
  p.append(t[0])
  u.append(t[1:])

candidate = []
for i in range(1, N+1):
  for comb in itertools.combinations(range(N), i):
    price = 0
    understand = [0]*M
    for j in range(i):
      price += p[comb[j]]
      understand = [x + y for (x, y) in zip(understand, u[comb[j]])]
    if all(elem >= X for elem in understand):
      candidate.append(price)

if candidate == []:
  print(-1)
else:
  print(min(candidate))

Measured memory_bytes: 9276
#include <bits/stdc++.h>
using namespace std;
int main () {
  vector<int> data(3), dual(3, 0);
  for(int i = 0; i < 3; i++) {
    cin >> data.at(i);
  }
  sort(data.begin(), data.end());
  int count = 0;
  for(int i = 0; i < 3; i++) {
    if(data.at(i) % 2 == 1) {
      dual.at(i)++;
      count++;
    }
  }
  int ans = 0;
  if (count == 1) {
    for(int i = 0; i < 3; i++) {
      if(dual.at(i) == 0) data.at(i)++;
    }
    ans++;
  } else if (count == 2) {
    for(int i = 0; i < 3; i++) {
      if(dual.at(i) == 1) data.at(i)++;
    }
    ans++;
  }
  ans += data.at(2) - (data.at(1) + data.at(0)) / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    A,B,C,D,E,F = MI()
    A*=100
    B*=100
    water = []
    can = [False]*3001
    can[0] = True
    for i in range(3001-A):
        if can[i]:
            can[i+A] = True
    for i in range(3001-B):
        if can[i]:
            can[i+B] = True
    for i in range(1,3001):
        if can[i]:
            water.append(i)

    can = [False]*3001
    can[0] = True
    for i in range(3001-C):
        if can[i]:
            can[i+C] = True
    for i in range(3001-D):
        if can[i]:
            can[i+D] = True
    
    suger = []
    for i in range(1,3001):
        if can[i]:
            suger.append(i)
    
    # print(water)
    # print(suger)

    ans = 0
    ans_water = A
    ans_suger = 0
    for w in water:
        want = min(F-w, (w//100)*E)
        idx = bisect_right(suger, want)
        if idx:
            s = suger[idx-1]
            if ans < s/(w+s):
                ans = s/(w+s)
                ans_water=w
                ans_suger=s
                
    print(ans_water+ans_suger,ans_suger)
if __name__ == '__main__':
    main()

Measured memory_bytes: 39792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int k;
    cin >> n >> k;
    int h[n];
    for(int i=0;i<n;i++)cin >> h[i];

    vector<long>dp(n,1<<30);
    dp[0] = 0;
    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            if(i+j<n){
                dp[i+j] = min(dp[i+j],dp[i] + abs(h[i] - h[i+j]));
            }
        }
    }
    cout << dp[n-1]<<endl;
}

Measured memory_bytes: 4256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MD 1000000007
typedef long long int ll;


int main(){
    int a,b;
    cin>>a>>b;
    if(a+b==15){
        cout<<"+"<<endl;
    }else if(a*b==15){
        cout<<"*"<<endl;
    }else{
        cout<<"x"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N, x;
  while (cin >> N >> x) {
    int M = 2 * N - 1;
    if (x == 1 || x == M) {
      cout << "No" << endl;
      continue;
    }
    --x;
    vector<int> ans(M);
    ans[N - 2] = x + 1;
    ans[N - 1] = x;
    ans[N] = x - 1;
    for (int i = 2; i < N; i++) {
      ans[N - 1 - i] = (x - i + M) % M;
      ans[N - 1 + i] = (x + i) % M;
    }
    cout << "Yes" << endl;
    for (int x : ans) {
      cout << x + 1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 2304
#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys


class Node(object):
    def __init__(self):
        # init node as a single leaf node.
        self.parent = -1
        self.type = 'leaf'
        self.depth = 0
        self.children = []
        self.degree = 0
        self.sibling = -1
        self.height = 0


def get_depth(v, depth=0):
    if not v.children:
        # print('rt', v.parent, v.depth, depth)
        v.depth = depth
        return v.depth
    v.depth = depth
    # print('out', v.parent, v.depth, v.children, depth)
    if v.children[0] != -1:
        get_depth(node_list[v.children[0]], depth + 1)

    if v.children[1] != -1:
        get_depth(node_list[v.children[1]], depth + 1)
    return v.depth


def get_height(v):
    h1, h2 = 0, 0

    # leaf's height is 0, children: []
    if not v.children:
        return 0

    if v.children[0] != -1:
        h1 = get_height(node_list[v.children[0]]) + 1

    if v.children[1] != -1:
        h2 = get_height(node_list[v.children[1]]) + 1

    v.height = max(h1, h2)
    return v.height


def generate_tree(_array):
    # add info of each node of a ordered tree
    for each in _array:
        idx, *children = [int(x) for x in each]
        # assert len(children) == 2
        if children != [-1, -1]:
            node_list[idx].type = 'internal node'
            node_list[idx].children = children
            node_list[idx].degree = 1 if (-1 in children) else 2
        else:
            # node is leaf as default, children: []
            continue

        for child_idx in children:
            # non-existent node: no parent or sibling
            if child_idx == -1:
                continue
            node_list[child_idx].parent = idx
            node_list[child_idx].sibling = sum(children) - child_idx

    root_idx = [i for i, x in enumerate(node_list) if x.parent == -1][0]
    node_list[root_idx].type = 'root'

    # add node depth info -- using DFS
    get_depth(node_list[root_idx])
    get_height(node_list[root_idx])

    return node_list


def print_result(_node):
    print('parent = ' + str(_node.parent) + ',', end=' ')
    print('sibling = ' + str(_node.sibling) + ',', end=' ')
    print('degree = ' + str(_node.degree) + ',', end=' ')
    print('depth = ' + str(_node.depth) + ',', end=' ')
    print('height = ' + str(_node.height) + ',', end=' ')
    print(_node.type)
    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(lambda x: x.split(), _input[1:]))
    # assert len(array) == array_length

    node_list = [Node() for _ in range(array_length)]
    ans = generate_tree(_array=array)
    for key, node in enumerate(ans):
        print('node ' + str(key) + ':', end=' ')
        print_result(_node=node)

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

void calc(const vector<vector<int> >& G, vector<int>& D,
                                        queue<int>& Q, int dim) {
    if (Q.empty()) return;
    queue<int> Q2;
    while (!Q.empty()) {
        int i = Q.front();
        for (int j = 1; j < G[i].size(); j++) {
            if (G[i][j] && D[j] == -1) {
                Q2.push(j);
                D[j] = dim;
            }
        }
        Q.pop();
    }
    calc(G, D, Q2, dim + 1);
}

int main(){
    int n;
    cin >> n;
    vector<vector<int> > G(n + 1, vector<int>(n + 1, 0));
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            G[u][v] = 1;
        }
    }
    vector<int> D(n + 1, -1);
    queue<int> Q;
    Q.push(1);
    D[1] = 0;
    calc(G, D, Q, 1);

    for (int i = 1; i <= n; i++) {
        cout << i << " " << D[i] << endl;
    }

    return 0;
}

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

void solve() 
{
    int n,m;cin>>n>>m;
    int a[m];REP(i,m){
        int x;cin>>x;n-=x;
    }
    if(n<0)cout<<-1<<endl;
    else cout<<n<<endl;
}

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

Measured memory_bytes: 3652
#include<stdio.h>

typedef struct{
	char c;
	int v;
}Card;

void setCard(Card *card, char _c, int _v){
	card->c = _c;
	card->v = _v;
	return;
}

void swapCard(Card *c0, Card *c1){
	Card temp;
	setCard(&temp, c0->c, c0->v);
	setCard(c0, c1->c, c1->v);
	setCard(c1, temp.c, temp.v);
	return;
}

int partition(Card A[], int p, int r){
	int x = A[r-1].v;
	int i = p-1, j;
	for( j = p; j < r-1; j++ ){
		if( A[j].v <= x ){
			i++;
			swapCard(&A[i], &A[j]);
		}
	}
	swapCard(&A[i+1], &A[r-1]);
	return i+1;
}

void quickSort(Card A[], int p, int r){
	if( p < r ){
		int q = partition(A, p, r);
		quickSort(A, p, q);
		quickSort(A, q+1, r);
	}
	return;
}

int main(){
	int n, i, j, isStable = 1;
	char t;
	Card card[100000], iCard[100000];
	scanf("%d", &n);
	scanf("%c", &t);
	for( i = 0; i < n; i++ ){
		scanf("%c %d", &card[i].c, &card[i].v);
		setCard(&iCard[i], card[i].c, card[i].v);
		scanf("%c", &t);
	}
	quickSort(card, 0, n);
	int bv = -1;
	for( i = 0; i < n; i++ ){
		if( card[i].v != bv ){ j = 0; }
		bv = card[i].v;
		for( ; j < n; j++ ){
			if( card[i].v == iCard[j].v ){
				if( card[i].c == iCard[j].c ){
					j++;
					break;
				}else{
					isStable = 0;
					break;
				}
			}
		}
	}
	printf("%s\n", (isStable?"Stable":"Not stable"));
	for( i = 0; i < n; i++ ){ printf("%c %d\n", card[i].c, card[i].v); }
	return 0;
}



Measured memory_bytes: 4128
#!/usr/bin/env python3
import numpy as np


H, N = [int(str) for str in input().strip().split()]
AB = np.array([[int(str) for str in input().strip().split()] for _ in range(N)])

dp = np.zeros(H + 1)
for h in range(1, H + 1):
    dp[h] = min(AB[:, 1] + dp[np.maximum(0, h - AB[:, 0])]) 
print(int(dp[-1]))

Measured memory_bytes: 12532
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] input = line.split(" ");
        int v = Integer.parseInt(input[0]);
        int h = Integer.parseInt(input[1]);
        
        System.out.printf("%d %d%n", v * h, v *2 + h * 2);
    }
}


Measured memory_bytes: 26096
# median を import する
from statistics import median

# N と Ai を標準入力
N = int(input())
listNumsAs = list(map(int,input().split()))

# 空のリスト listNumsBs を用意
listNumsBs = []

# listNumAs の各要素から、その (index + 1) の数を引いた (Ai - (i + 1)) をリスト listNumsBs に順番に代入
for index in range(len(listNumsAs)):
    listNumsBs.append(listNumsAs[index] - index - 1)

# listNumsBs を昇順にソートする
listNumsBs.sort()

# listNumsBs の中央値を med に代入する
med = int(median(listNumsBs))

listSadnessA1 = [abs(s - med - N) for s in listNumsBs]
minimumSum = sum(listSadnessA1)

# listNumsBs の中央値 ± N の範囲の変数 b で処理を繰り返す
for b in range(med - 10, med + 10):
    
    # 悲しさ指数のリスト listSadness に (Bi - b) の絶対値の計算結果を順番に代入する
    listSadness = [abs(s - b) for s in listNumsBs]
       
    if sum(listSadness) < minimumSum:
        minimumSum = sum(listSadness)
        listTruthSadness = listSadness
        truthB = b

print(minimumSum)

Measured memory_bytes: 52672
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var h=new int[]{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
		Console.WriteLine("{0}",h[n-1]);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, k, ans;
int main()
{
	cin >> n >> k;
	for(ll b=k+1; b<=n; ++b){
		ll qmx = n/b;
		while(qmx * b + (b-1) > n) --qmx;
		ans += max(0ll, (++qmx) * (b-k) - (k==0));
		ans += max(0ll, n-b*qmx-k+1);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#define z 1000000
a[z],b[z],n,i=1,x,c;main(){for(;i++<z;i)a[i]=i;for(i=-1;i++<z;)if(a[i]!=0){b[x++]=i;for(c=i;c<z;c+=i)a[c]=0;}while(scanf("%d",&n)!=-1){c=0;while(b[c]<=n && b[c]!=0){c++;}printf("%d\n",c);}exit(0);}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
typedef long long ll;

int main(){
    ll n,x;
    cin >> n >> x;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin >> a[i];
    sort(a,a+n);
    ll count = 0,i;
    for(i=0;i<n;i++){
        if(x-a[i]>=0){
            x -= a[i];
            count++;
        }
        else
            break;
    }
    if(x==0 || count==0 || i<n)
        cout << count;
    else
        cout << count-1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll x, k, d;
  cin >> x >> k >> d;
  ll v = abs(x) / d;
  bool pos = x > -1;
  if (pos) {
    x -= d * min(v, k);  
  } else {
    x += d * min(v, k);
  }
  k -= min(v, k);
  if (k == 0) {
    cout << abs(x) << endl;
    return 0;
  }
  if (k % 2) {
    cout << min(abs(x + d), abs(x - d)) << endl;
  } else {
    cout << abs(x) << endl;
  }

  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 100001
#define dmp make_pair
#define dpb push_back
#define P pair<int,int>
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int dp[101][101][4];
int main(){
	int w, h;
	while(1){
		scanf("%d%d", &w, &h);
		if(!w)break;
		for(int i = 1;i <= w;i++){
			for(int j = 1;j <= h;j++){
				dp[i][j][0] = dp[i][j-1][0]+dp[i][j-1][2];
				dp[i][j][1] = dp[i-1][j][1]+dp[i-1][j][3];
				dp[i][j][2] = dp[i-1][j][1];
				dp[i][j][3] = dp[i][j-1][0];
				rep(x,4)dp[i][j][x] = dp[i][j][x]%100000;
				dp[1][2][0] = dp[2][1][1] = 1;
				dp[1][2][3] = dp[2][1][2] = 1;
			}
		}
		
		int ans = dp[w][h][0]+dp[w][h][1];
		printf("%d\n", ans%100000);
	}
	return 0;
}

Measured memory_bytes: 3284
S = int(input())
p = 10 ** 9 + 7
max_column = S // 3
fact = [1,1]
inv = [1,1]
inv_2 = [0,1]
n = 2001
if S <= 2:
    print(0)
else:
    for i in range(2, n+1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        inv_2.append((inv_2[-1] * inv[-1]) % p)
    def c(N,r):
        if (r < 0) or (N < r):
            return 0
        r = min(r, N-r)
        return fact[N] * inv_2[r] * inv_2[N-r] % p
    ans = 1
    for i in range(2, max_column+1):
        nokori = S - i * 3
        if nokori == 0:
            ans += 1
        ans += c(i+nokori-1,nokori)
        ans %= p
    print(ans)

Measured memory_bytes: 9388
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		// 表の作成と入力
		int[][] table = CreateTable(sc.nextInt(), sc.nextInt());

		// 表示
		Print(table);
	}

	// 表の生成と入力し、表(2次元配列)を返す
	static int[][] CreateTable(int r, int c) {
		int table[][] = new int[r + 1][c + 1]; // 表を生成(+1は合計行列分)

		for (int y = 0; y < r; y++) {

			for (int x = 0; x < c; x++) {

				table[y][x] = sc.nextInt();

				table[y][c] += table[y][x]; // 最後列(行の合計)に値を加算
			}
		}

		// 最下行(列の合計)の計算
		for (int x = 0; x < c + 1; x++) {

			for (int y = 0; y < r; y++) {

				table[r][x] += table[y][x]; // 最下行(列合計)に値を加算
			}
		}
		return table;
	}

	// 表示処理
	static void Print(int[][] table) {
		// 出力用のループ
		for (int y = 0; y < table.length; y++) {

			System.out.print(table[y][0]);
			for (int x = 1; x < table[y].length; x++) {

				System.out.print(" " + table[y][x]);
			}
			System.out.println();
		}
	}

}



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


int main()
{
	int x, y, z;
	
	scanf("%d%d%d", &x, &y, &z);
	int s = 1;
	if (y != x) s++;
	if (z != y && z != x) s++;
	printf("%d\n", s);
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
using namespace std;
#define Rep(i,n) for(int i = 0; i < n; ++i)
#define For(i, s, e) for(int i = s; i <= e; ++i)
int N, M;
int P[100001];
int X[100001];
int Y[100001];
int C[100001];

int main()
{
	ios::sync_with_stdio(false);
	cin >> N >> M;
	For(i, 1, N) {
		cin >> P[i];
		C[i] = i;
	}
	For(i, 1, M)
		cin >> X[i] >> Y[i];

	For(i, 1, M){
		int a = X[i];
		int b = Y[i];
		while (a != C[a]) a = C[a];
		while (b != C[b]) b = C[b];
		if (a < b) C[b] = a;
		if (a > b) C[a] = b;
	}
	int k = 0;
	for (int i = N; i > 0; --i) {
		int a = i;
		int b = P[i];
		while (a != C[a]) a = C[a];
		while (b != C[b]) b = C[b];
		if (a == b)
			++k;
	}
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    string S; cin >> S;
    if(S == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1;
        return 0;
    }

    if(S.size() < 26){
        bool used[26];
        fill(used, used + 26, false);
        REP(i, S.size()) used[(int)(S[i] - 'a')] = true;
        REP(i, 26){
            if(!used[i]){
                cout << S + (char)('a' + i);
                return 0;
            }
        }
    }else{
        bool used[26];
        fill(used, used + 26, false);
        used[(int)(S[25] - 'a')] = true;
        IREP(i, S.size() - 1){
            int n = (int)(S[i] - 'a');
            FOR(j, n + 1, 26){
                if(used[j]){
                    cout << S.substr(0, i) + (char)('a' + j);
                    return 0;
                }
            }
            used[n] = true;
        }
    }
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

const int mxN = 1e5;
string s,t;
const long long inf =1e18l+7;
int dp[mxN+1],N,M,ans=0,vis[mxN],inDegree[mxN];

vector<int> adj[mxN];


void dfs(int u)
{
    
    vis[u]=1;
    for(int v : adj[u]){
       dp[v]=max(dp[v],dp[u]+1);
       inDegree[v]--;
       if(inDegree[v]==0){ 
           dfs(v);
       }   
    }
}
int main(){
    cin >> N >> M;

    for(int i=0,a,b ; i<M ;++i){
       cin >> a >> b,--a,--b;
       adj[a].push_back(b);
       inDegree[b]++;
    }

    for(int i=0 ;i<N ;++i)
    {
        if(!vis[i] && inDegree[i]==0){
            dfs(i);
        }
    }
    //for(int i=0 ; i<N ;++i)ans=max(ans,dp[i]);

    cout << *max_element(dp,dp+N);     
           
}

Measured memory_bytes: 14960
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-8
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	vector<bool> b(10,true);
	REP(i,k) {
		int k;
		cin>>k;
		b[k]=false;
	}
	while(1) {
		string buf=to_string(n);
		bool f=true;
		REP(i,buf.size()) {
			if(!b[buf[i]-'0']) f=false;
		}
		if(f) {
			break;
		}
		++n;
	}
	cout<<n<<endl;
}


Measured memory_bytes: 256
n = int(input())
a = [0]
for i in input().split(): a.append(int(i))
a.append(0)
s = sum([abs(a[i+1] - a[i]) for i in range(n+1)])
for i in range(n):
    print(s - abs(a[i] - a[i+1]) - abs(a[i+1] - a[i+2]) + abs(a[i] - a[i+2]))

Measured memory_bytes: 14048
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool divisor(int n){
     int c = 0;
     for(int i= 1; i*i <= n; i++){
          if(n%i==0){
               if(i==(n/i)){
                   // cout << i << " ";
                   ++c;
               }
               else{
                    c+=2;
                   // cout << i <<" "<< n/i <<" ";
               }
          }
     }
     if(c>=8) return 1;
     return 0;
}
int32_t main()
{
     int n;
     cin >> n;
     int ans = 0;
     for(int i = 105; i <= n; i+=2){
          bool f = divisor(i);
          if(f){
               ++ans;
          }
     }
     cout << ans;
     return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nfs ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,a,b) for(i=a;i>=b;i--)
#define m_p make_pair
#define p_b push_back
#define MOD 1000000007
int main()
{
	nfs;
	int t;
	t=1;
//	cin >> t;

	while(t--)
	{
		ll r,g,b,n;
		cin >> r >> g >> b >> n;
		ll i;
		ll count = 0;
		F(i,0,n+1)
		{
			ll temp = n- (r*i);
			if(temp<0)
			{
				break;
			}
			ll j;
			F(j,0,temp+1)
			{
				ll temp2 = temp - (g*j);
				if(temp2<0)
				{
					break;
				}
				if((temp2%b)==0)
				{
					count++;
				}
			}
		}
		cout << count << endl;
		
	}
	return 0;

}



Measured memory_bytes: 256
import copy
n=int(input())
l=[int(input()) for i in range(n)]
a=max(l)
ind=l.index(a)
del l[ind]
b=max(l)
for i in list(range(ind)):
  print(a)
print(b)
for s in list(range(n-ind-1)):
  print(a)

Measured memory_bytes: 20960
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out= new PrintWriter(System.out);
		int k= in.nextInt();
		int s= in.nextInt();
		int res=0;
		for (int i = 0; i <=k; i++) {
			for(int j=0; j<=k; j++){
				int z= s-i-j;
				if(z>=0&&z<=k){
					res++;
				}
			}
		}
		System.out.println(res);
		
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}


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

int main(void){
    int n,t=0,x=0,y=0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        int t0,x0,y0;
        scanf("%d%d%d",&t0,&x0,&y0);
        {
            int dt=t0-t,dx=x0-x,dy=y0-y;
            if(dx+dy>dt || (dt-dx-dy)%2){
                puts("No");
                return 0;
            }
        }
        t=t0;x=x0;y=y0;
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
  double get_money;
  String cur;

  Main(double get_money, String cur){
    if(cur.equals("JPY")){
      this.get_money = get_money;
      this.cur = cur;
    }else if(cur.equals("BTC")){
      this.get_money = get_money * 380000;
      this.cur = cur;
    }
  }

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

    int n = sc.nextInt();
    double sum = 0;
    Main[] d = new Main[n];

    for(int i=0; i<n; i++){
      d[i] = new Main(sc.nextDouble(),sc.next());
      sum += d[i].get_money;
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#define il inline
#define vd void
#define rg register
#define rep(i,x,y) for(rg int i=x;i<=y;++i)
#define drp(i,x,y) for(rg int i=x;i>=y;--i)
using namespace std;
const int Len=2333333;
char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf;
il char gc(); il int rd(); il vd pc(char c); il vd rt(int x); il vd flush();
int n;
struct P{
	char r[12];
	il int operator <(const P &p)const{return strcmp(r,p.r)<0;}
}s[100005];
il char Get(){char c;
	while(!islower(c=gc()));
	return c;
}
int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%s",s[i].r),sort(s[i].r,s[i].r+10);
	sort(s+1,s+n+1);
	int t=1;
	long long ans=0;
	rep(i,2,n){
		if(!strcmp(s[i].r,s[i-1].r)){
			++t;
		}
		else{
			ans+=1ll*t*(t-1)/2ll,t=1;
		}
	}
	cout<<ans+1ll*t*(t-1)/2ll;
	return flush(),0;
}

il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
il int rd(){char c;
	while(!isdigit(c=gc())&&c!='-');
	int f=c=='-'?c=gc(),1:0,x=c^48;
	while(isdigit(c=gc())) x=((x+(x<<2))<<1)+(c^48);
	return f?-x:x;
}
il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
il vd rt(int x){x<0?pc('-'),x=-x:0,pc((x>=10?rt(x/10),x%10:x)+48);}
il vd flush(){fwrite(duf,1,q1-duf,stdout);}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int n,i,a;
  
  cin >> n;
  for (i=0;i<n;i++){
    cin >> a;
    if (a%2==0 && a%3>0 && a%5>0){
      break;
    }
  }
  
  if (i==n) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  
  return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int N;
vint d, t;
vector<vint> q;
int sum[60000];
int psum[25][60000];

int lcm(int a, int b) {
  return a / __gcd(a, b) * b;
}

bool avoid(int a) {
  return a==13||a==17||a==19||a==23;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(cin >> N, N) {
    resz(d, N), resz(t, N), resz(q, N);
    rep(i, N) {
      cin >> d[i] >> t[i];
      resz(q[i], d[i]);
      rep(j, d[i]) cin >> q[i][j];
    }
    int LCM = 1;
    rep(i, N) if(!avoid(d[i])) LCM = lcm(LCM, d[i]);
    memset(sum, 0, sizeof(sum));
    memset(psum, 0, sizeof(psum));
    rep(i, N) {
      if(avoid(d[i])) {
	rep(j, d[i]) psum[d[i]][j] += q[i][(t[i]+j)%d[i]];
      } else {
	rep(j, LCM) sum[j] += q[i][(t[i]+j)%d[i]];
      }
    }
    int ans = *max_element(sum, sum+60000);
    ans += *max_element(psum[13], psum[13]+60000);
    ans += *max_element(psum[17], psum[17]+60000);
    ans += *max_element(psum[19], psum[19]+60000);
    ans += *max_element(psum[23], psum[23]+60000);
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 15336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){ 
	ll n;
	cin>>n;
	ll sum=0;
	for(ll i=1;i<=n;i++){ 
		if(i%3!=0&&i%5!=0) sum+=i; 
	}
	cout<<sum<<endl;
	return 0;
 } 

Measured memory_bytes: 3620
N = int(input())
W = list(map(int, input().split()))
sum_W = sum(W)

ans = 1000000000
for i in range(N):
    W_tmp = W[:i]
    sum_W_tmp = sum(W_tmp)
    if ans > abs(sum_W - 2 * sum_W_tmp):
        ans = abs(sum_W - 2 * sum_W_tmp)

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */


int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  size_t n;
  int64_t cap;
  cin >> n >> cap;

  vector<pair<int64_t, int64_t>> xs(n);  // weight, value
  cin >> xs;

  map<int64_t, vector<int64_t>> cnt;
  for(const auto & pr: xs)
    cnt[pr.first].push_back(pr.second);

  DEBUG(cnt);

  vector<pair<int64_t, vector<int64_t>>> wv(begin(cnt), end(cnt));
  for(auto & pr: wv)
  {
    auto & v = pr.second;
    sort(begin(v), end(v), greater<int64_t>());
    partial_sum(begin(v), end(v), begin(v));
  }

  while(wv.size() < 4)
    wv.push_back({wv.back().first + 1, {}});

  DEBUG(wv);

  int64_t out = 0;

  for(size_t i = 0; i < wv[0].second.size() + 1; ++i)
    for(size_t j = 0; j < wv[1].second.size() + 1; ++j)
      for(size_t k = 0; k < wv[2].second.size() + 1; ++ k)
      {
        auto v = (i ? wv[0].second[i - 1] : 0)
          + (j ? wv[1].second[j - 1] : 0)
          + (k ? wv[2].second[k - 1] : 0);

        const auto w = ((int64_t) i) * wv[0].first
          + ((int64_t) j) * wv[1].first
          + ((int64_t) k) * wv[2].first;

        if(w < cap + 1)
        {
          const auto x = min((int64_t) wv[3].second.size(), (cap - w) / wv[3].first);
          out = max(out, v + (x ? wv[3].second[x - 1] : 0));
        }
      }

  cout << out;
  return EXIT_SUCCESS;
}



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

using namespace std;
using ll = long long;

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

  int n;
  cin >> n;

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

  vector<ll> lf(3*n), rg(3*n);
  priority_queue<int, vector<int>, greater<int>> l;
  ll sum = 0;
  for(int i = 0; i < 2*n; ++i) {
    sum += a[i];
    l.emplace(a[i]);
    if(l.size() > n) {
      auto f = l.top();
      sum -= f;
      l.pop();
    }
    lf[i] = sum;
  }

  sum = 0;  
  priority_queue<int> r;
  for(int i = 3*n-1; i >= n; --i) {
    sum += a[i];
    r.emplace(a[i]);
    if(r.size() > n) {
      auto f = r.top();
      sum -= f;
      r.pop();
    }
    rg[i] = sum;
  }

  ll ans = -1e18;
  for(int i = n-1; i < 2*n; ++i)
    ans = max(ans, lf[i]-rg[i+1]);

  cout << ans << endl;
}

Measured memory_bytes: 7288
#include<cstdio>
#include<algorithm>
#include<cstring>
char str[1000011]={0};
int dp[1000011]={0};
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n),n){
        memset(str,0,sizeof(str));
        int m;
        scanf("%d",&m);
        for(int i = 0;i < m; i++){
            scanf(" %c",str + i + 1);
        }
        int ans = 0;
        memset(dp,0,sizeof(dp));
        for(int i = 1; i<= m; i++){
            if(str[i-1] == 'I'&&str[i] == 'O'&&str[i+1] == 'I'){
                dp[i] = dp[i-2] + 1;
                if(dp[i] >= n)ans++;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

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

    if(    (s[0]==s[1] && s[2]==s[3] && s[0]!=s[2])
        || (s[0]==s[2] && s[1]==s[3] && s[0]!=s[1])
        || (s[0]==s[3] && s[1]==s[2] && s[0]!=s[1]))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

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

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

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

    int N, M; cin >> N >> M;
    vector<int> a(N);
    rep(i, N) { cin >> a[i]; a[i] /= 2; }
    ll l = 1;
    rep(i, N) l = lcm(l, a[i]);

    int cnt = 0;
    while(a[0]%2==0) { cnt++; a[0]/=2; }
    repr(i, 1, N) {
        int tmp = 0;
        while(a[i]%2==0) { tmp++; a[i]/=2; }
        if (tmp != cnt) { cout << 0 << endl; return 0; }
    }

    cout << M/l - M/l/2 << endl;
    

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int nenrei=sc.nextInt();
	    if(nenrei==1) {
	    	System.out.println("Hello World");
	    }else {
	    	int a=sc.nextInt();
	    	int b=sc.nextInt();
	    	System.out.println(a+b);
	    }
		

	}

}

Measured memory_bytes: 21968
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr long long int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){
    llint n;
    cin >> n;
    FOR(i,1,50001){
        if((llint)(i*1.08)==n){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;

typedef unsigned long long ll;

const long long MOD = 1000000000 + 7;

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

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    vector<char> c_a,c_b,c_c;
    rep(i,a.size()){
        c_a.push_back(a[i]);
    }
    rep(i,b.size()){
        c_b.push_back(b[i]);
    }
    rep(i,c.size()){
        c_c.push_back(c[i]);
    }
    int turn = 0;
    while(true){
        char card;
        if(turn == 0){
            if(c_a.size() == 0){
                cout << "A" << endl;
                return 0;
            }
            card = c_a.front();
            c_a.erase(c_a.begin());
        }else if(turn == 1){
            if(c_b.size() == 0){
                cout << "B" << endl;
                return 0;
            }
            card = c_b.front();
            c_b.erase(c_b.begin());
        }else{
            if(c_c.size() == 0){
                cout << "C" << endl;
                return 0;
            }
            card = c_c.front();
            c_c.erase(c_c.begin());
        }
        if(card == 'a') turn = 0;
        else if(card == 'b') turn = 1;
        else turn = 2;
        
    }

    return 0;
}


Measured memory_bytes: 256
# ABC075C

import sys
input=sys.stdin.readline

class UnionFind:
    def __init__(self, n):
        self.p=[-1]*n
        
    def root(self, x):
        st=[]
        while(self.p[x]>=0):
            st.append(x)
            x=self.p[x]
        for y in st:
            self.p[y]=x
        return x
    def find(self, x, y):
        return self.root(x)==self.root(y)
    def union(self, x, y):
        r1=self.root(x)
        r2=self.root(y)
        if r1==r2:
            return
        up=self.p
        p1=up[r1]
        p2=up[r2]
        if p1<=p2:
            up[r2]=r1
            if p1==p2:
                up[r1]-=1
        else:
            up[r1]=r2
            
def main():
    N,M=map(int,input().split())
    AB=[tuple(map(lambda x: int(x)-1,input().split())) for i in range(M)]
    
    ans=0
    for i in range(M):
        uft=UnionFind(N)
        for j in range(M):
            if i!=j:
                uft.union(AB[j][0],AB[j][1])
        ps=0
        for x in range(N):
            if uft.p[x]<0:
                ps+=1
        if ps!=1:
            ans+=1
    print(ans)
        
    
    
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 74028