akhauriyash/Code-Regression huggingface dataset:
#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;

#define MAX_N 202020

typedef long long int64;

inline int64 modPow(int64 x, int64 n)
{
  if(n == 0) return 1;
  int64 ret = modPow(x, n/2);
  (ret *= ret) %= mod;
  if(n & 1) (ret *= x) %= mod;
  return ret;
}

inline int64 modInv(int64 a)
{
  return modPow(a, mod - 2);
}

inline int64 modFact(int n)
{
  int64 ret = 1;
  while(n > 1) (ret *= n--) %= mod;
  return ret;
}

inline int64 modComb(int64 n, int64 r)
{
  static int64 fact[MAX_N], invfact[MAX_N];
  if(fact[0] == 0) {
    fact[0] = invfact[0] = 1;
    for(int i = 1; i < MAX_N; i++) {
      fact[i] = fact[i-1] * i % mod;
      invfact[i] = modInv(fact[i]);
    }
  }
  if(r < 0 || n < r) return 0;
  return fact[n] * invfact[r] % mod * invfact[n-r] % mod;
}


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

  int n;
  cin >> n;
  vint a(n+1);
  vint c(n+1, -1);
  int idx;
  rep(i, n+1) {
    cin >> a[i];
    if(c[a[i]] == -1) c[a[i]] = i;
    else idx = i;
  }
  rep(i, n+1) {
    //cout<<n-idx<<" "<<i<<endl;
    cout << (modComb(n+1, i+1)-modComb(c[a[idx]]+n-idx, i)+mod)%mod << endl;
  }

  return 0;
}


Measured memory_bytes: 5888
import java.util.*;

public class Main{
	static Scanner sc = new Scanner(System.in);
	static int n = 0;
	
	public static void main(String[] args){
		n = sc.nextInt();
		int ub = 1 << n;
		int[] a = new int[n];
		int[][] x = new int[n][];
		int[][] y = new int[n][];
		for(int i = 0; i < n; ++i){
			a[i] = sc.nextInt();
			x[i] = new int[a[i]];
			y[i] = new int[a[i]];
			for(int j = 0; j < a[i]; ++j){
				x[i][j] = sc.nextInt();
				y[i][j] = sc.nextInt();
			}
		}
		
		int ans = 0;
		for(int num = 0; num < ub; ++num){
			int[] info = getBinary(num, n);
			//System.out.println(Arrays.toString(info));
			int numHonest = count1(info);
			//System.out.println("numHonest = " + numHonest);
			for(int i = 0; i < n; ++i){
				if(info[i] == 0) continue;
				for(int j = 0; j < a[i]; ++j){
					if(info[x[i][j] - 1] != y[i][j]){
						//System.out.println(x[i][j] + " person is not " + y[i][j]);
						numHonest = -1;
						break;
					}
				}
				if(numHonest < 0) break;
			}
			//System.out.println("numHonest = " + numHonest);
			ans = (numHonest > ans) ? numHonest : ans;
			//System.out.println("ans = " + ans);
		}
		System.out.println(ans);
	}
	
	static int[] buildBinExps(int w){
		int[] res = new int[w];
		for(int i = 0; i < w; ++i){
			res[i] = (i == 0) ? 1 : 2 * res[i - 1];
		}
		return res;
	}
	
	static int[] getBinary(int num, int w){
		int[] res = new int[w];
		for(int i = 0; i < w; ++i){
			res[i] = (num % 2 == 1) ? 1 : 0;
			num /= 2;
		}
		return res;
	}
	
	static int count1(int[] info){
		int res = 0;
		for(int i = 0; i < n; ++i){
			if(info[i] == 1) ++res;
		}
		return res;
	}
}

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

typedef long long ll;
typedef pair<int, int> pii;

int main() {
    string o, e;
    cin >> o;
    cin >> e;
    string ans = "";
    for (int i = 0; i < o.size(); i++) {
        ans += o[i];
        if (i < e.size()) {
            ans += e[i];
        }
    }
    cout << ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define MM <<" "<<
#define Endl endl

signed main(void){
    int r;
    cin >> r;
    cout << 3*r*r << endl;
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector <ll>
#define vii vector <int>
#define vpii vector <pii>
#define vpll vector <pll>
#define ff first
#define ss second
#define matrix vector <vll>
#define all(v) v.begin(),v.end()
#define PQ priority_queue
using namespace std;
ll pow(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b&1) res*=a;
		b/=2;
		a*=a;
	}
	return res;
}
int main()
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	int n;
	cin >> n;
	vii v(n);
	for(int i = 0; i < n; i++) cin >> v[i];
	int cnt = 0;
	vii t = v;
	sort(all(t));
	if(v == t){
		cout << "YES\n";return 0;
	}
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			if(v[i] > v[j]){
				swap(v[i],v[j]);
				if(v == t){
					cout << "YES\n";
					return 0;
				}
				swap(v[i],v[j]);
			}
		}
	}
	cout <<  "NO\n";
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.util.*

fun main() = nomura2020a()

@OptIn(ExperimentalStdlibApi::class)
fun nomura2020a() = SimpleFastIOWithToken_nomura2020a().exec {
    val (h1, m1, h2, m2, k) = readIntList(5)

    val wakeupMinutes = (h2 * 60 + m2) - (h1 * 60 + m1)

    val answer = wakeupMinutes - k

    println(answer)
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_nomura2020a(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readStringList(size: Int): List<String> = List(size) { readString() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readIntList(size: Int): List<Int> = List(size) { readInt() }
    fun readLong(): Long = java.lang.Long.valueOf(readString())
    fun readLongList(size: Int): List<Long> = List(size) { readLong() }
    inline fun <reified T> readArray(size: Int, init: () -> T) = Array(size) { init() }
    inline fun <T> readList(size: Int, init: () -> T) = List(size) { init() }

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = print(any.toString() + separator)

    fun exec(action: SimpleFastIOWithToken_nomura2020a.() -> Unit) = run {
        Thread(null, { action() }, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()
    }.run { kotlin.io.print(sb) }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)


Measured memory_bytes: 34648
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
 
        Scanner scan = new Scanner(System.in);
        // Scanner scan = new Scanner(new
        // File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_6_A-in9.txt"));
 
        int h = scan.nextInt();
 
        int[] a = new int[h + 1];
 
        for (int i = 1; i <= h; i++)
            a[i] = scan.nextInt();
 
        for (int i = 1; i <= h; i++)
            print(a, i);
 
        scan.close();
        System.exit(0);
    }
 
    private static void print(int[] aaa, int iii) {
        System.out.print("node " + iii + ": ");
        System.out.print("key = " + aaa[iii] + ", ");
        if (iii > 1)
            System.out.print("parent key = " + aaa[iii / 2] + ", ");
        if (iii * 2 < aaa.length)
            System.out.print("left key = " + aaa[iii * 2] + ", ");
        if (iii * 2 + 1 < aaa.length)
            System.out.print("right key = " + aaa[iii * 2 + 1] + ", ");
        System.out.print("\n");
    }
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

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

  int Q;
  cin >> Q;
  int Nmax = 100100;
  vector<bool> is2017(Nmax);
  for(int i = 1; i <= Nmax; i = i + 2){
    if(IsPrime(i) && IsPrime((i+1)/2)){
      is2017[i] = true;
    }else{
      is2017[i] = false;
    }
  }

  vector<int> sum_is2017(Nmax);
  sum_is2017[0] = 0;
  for(int i = 1; i <= Nmax; i++){
    if(is2017[i]){
      sum_is2017[i] = sum_is2017[i-1] + 1;
    }else{
      sum_is2017[i] = sum_is2017[i-1];
    }
  }

  vector<pair<int, int>> lr(Q);
  int l, r;
  for(int i = 0; i < Q; i++){
    cin >> l >> r;
    lr[i] = make_pair(l, r);
  }

  for(int i = 0; i < Q; i++){
    cout << sum_is2017[lr[i].second] - sum_is2017[lr[i].first-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
    
for i in range(M):
    b.append(b[i] + B[i])
    ans, j = 0, M

for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47540
# ABC113 B

def main():
    n = int(input())
    t, a = map(int, input().split())
    H = list(map(int, input().split()))

    differences = []

    for height in H:
        temp = t - height * 0.006
        differences.append(abs(temp - a))
    
    print(differences.index(min(differences)) + 1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
count = 0;
while True:
    if count == 3000:
        break
    i = list(map(int,input().split()))
    x = i[0]
    y = i[1]
    if x == 0 and y == 0:
        break
    if x < y:
        print(x, y)
    if y < x:
        print(y, x)
    if x == y:
        print(x, y)
    count+= 1


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

int main(){
    long K, A, B, b(1);
    cin >> K >> A >> B;
    if(K < A - 1 || A + 2 >= B)return 0 & printf("%ld\n", 1 + K);
    K -= A - 1;
    b = A + (K & 1);
    cout << (K / 2) * (B - A) + b << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

#define MOD 998244353
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);

ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}




ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}

ll pow(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }

return ans;
}


/*const int N=200000;

ll fac[N+1];
ll inv[N+1];
ll p=998244353;

ll c(ll a, ll b,ll m)
{
  if(a<b)return 0;
  return (fac[a]*inv[b]%m)*(inv[a-b])%m;
}

void fill()
{
inv[0]=1;
fac[0]=1;

for(int i=1;i<=N;i++)
{
  fac[i]=fac[i-1]*i%p;
  inv[i]=powM(fac[i],p-2,p);
}

}
*/
//ld dp[2001][2001];

ll dp[3001][3001];  // dp[i][j] ways to make sum i using j numbers.


int main()
{  fast

ll n,s;
cin>>n>>s;



vl a(n+1);



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

//sort(all(a));

dp[0][0]=powM(2,n,MOD);

for(int i=1;i<=n;i++)
{
  for(int j=0;j<=3000;j++)
  {
     dp[i][j]+=dp[i-1][j];
    if(j>=a[i]) dp[i][j]+=dp[i-1][j-a[i]]*powM(2,MOD-2,MOD)%(MOD);
    dp[i][j]=newmod(dp[i][j],MOD);
  }
}


cout<<dp[n][s]<<"\n";

 return 0;

}


Measured memory_bytes: 73920
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] p = new int[n];
            for (int i = 0; i < n; i++) {
                p[i] = in.nextInt();
            }
            int[] a = new int[n+1];
            int[] b = new int[n+1];
            for (int i = 1; i <= n; i++) {
                a[i] = i * (n + 1);
            }
            for (int i = n, j = 1; i >= 1; i--, j++) {
                b[i] = j * (n + 1);
            }
            for (int i = 0; i < n; i++) {
                a[p[i]] += i;
                b[p[i]] += i;
            }
            for (int i = 1; i <= n; i++) {
                System.out.print(a[i] + " ");
            }
            System.out.println();
            for (int i = 1; i <=n; i++) {
                System.out.print(b[i] + " ");
            }
            System.out.println();


        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

Measured memory_bytes: 46456
use std::io;
use std::collections::HashMap;


fn main() {
    let x = read_one::<u64>();
    let mut hm = HashMap::new();
    for i in 1..x + 1 {
        let mut m = i;
        while let Some(f) = divide(m) {
            m /= f;
            *hm.entry(f).or_insert(0) += 1;
        }
        *hm.entry(m).or_insert(0) += 1;
    }

    *hm.entry(1).or_insert(0) = 1;
    // 75 = 3, 5, 5
    let mut c2 = 0;
    let mut c4 = 0;
    let mut c14 = 0;
    let mut c24 = 0;
    let mut c74 = 0;
    for v in hm.values() {
        if v >= &74 { c74 += 1; }
        if v >= &24 { c24 += 1; }
        if v >= &14 { c14 += 1; }
        if v >= &4 { c4 += 1; }
        if v >= &2 { c2 += 1; }
    }

    let mut ans = c74;
    if c4 >= 2 && c2 >= 3 {
        ans += ncr(c4, 2) * (c2 - 2);
    }

    if c14 >= 1 && c4 >= 2 {
        ans += c14 * (c4 - 1);
    }

    if c24 >= 1 && c2 >= 2 {
        ans += c24 * (c2 - 1);
    }

    println!("{}", ans);
}

fn divide(n: u64) -> Option<u64> {
    for i in 2..(n as f64).sqrt().ceil() as u64 + 2 {
        if n % i == 0 {
            return Some(i);
        }
    } 
    return None;
}

fn ncr(n: u64, r: u64) -> u64 {
    if r > n { return 0; }
    match (n, r) {
        (0, _) | (_, 0) => 1,
        _ => ((ncr(n, r - 1) * (n - r + 1) / r)),
    }
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
n,k = map(int, input().split())
a = list(map(int, input().split()))

# 約数リスト
def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if(n%i == 0):
            divisors.append(i)
            if(i!= n//i):
                divisors.append(n//i)

    return  divisors

sum_a = sum(a)
divisors = sorted(make_divisors(sum_a), reverse=True)

for div in divisors:
    if(sum_a % div != 0):
        continue

    mod_a = []
    for ai in a:
        mod_a.append(ai % div)
    mod_a = sorted(mod_a)

    sum_mod_a = sum(mod_a)
    k_min = sum(mod_a[: (n-sum_mod_a//div) ])

    if(k_min <= k):
        print(div)
        exit()

# 絶対1で割り切れるからここにはこないけど。。。
print(-1)

Measured memory_bytes: 42476
def main():
    from fractions import gcd

    n, *a = map(int, open(0).read().split())
    a = tuple([0] + a + [0])
    l = [0 for _ in range(n + 1)]
    r = [0 for _ in range(n + 1)]
    tmpl = 0
    tmpr = 0
    for i in range(1,n+1):
        tmpl = gcd(tmpl, a[i-1])
        tmpr = gcd(tmpr, a[-i])
        l[i] = tmpl
        r[-i] = tmpr

    ans = []
    for i, j in zip(l, r):
        ans.append(gcd(i, j))

    print(max(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 16140
#include <iostream>

const int ms = 505;

int a[ms][ms];

int main()
{
	int n, m, h, w;
	while(std::cin >> n >> m >> h >> w)
	{
		if(h == w && h == 1)
		{
			std::cout << "No\n";
			continue;
		}
		int area = n * m;
		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j < m; j++)
			{
				if(i % h == 0 && j % w == 0)
					a[i][j] = area - 1;
				else if(i % h == h - 1 && j % w == w - 1)
					a[i][j] = -area;
				else
					a[i][j] = 0;
			}
		}
		int sum = 0;
		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j < m; j++)
			{
				sum += a[i][j];
			}
		}
		if(sum > 0)
		{
			std::cout << "Yes\n";
			for(int i = 0; i < n; i++)
			{
				for(int j = 0; j < m; j++)
				{
					if(j)
						std::cout << ' ';
					std::cout << a[i][j];
				}
				std::cout << '\n';
			}
		}
		else
		{
			std::cout << "No\n";
		}
	}
}

Measured memory_bytes: 3072
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
 
using namespace std;
 
int main() {
	int n, k;
	cin >> n >> k;
	if (k >= n)cout << "unsafe";
	else cout<<"safe";
}

Measured memory_bytes: 3632
start, dist, stopover = gets.strip.split.map(&:to_i)
if start < dist
  if stopover.between?(start, dist)
    puts 'Yes'
  else
    puts 'No'
  end
else
  if stopover.between?(dist, start)
    puts 'Yes'
  else
    puts 'No'
  end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
#define int long long

int sum(int a, int n) {
  return n*(a + a + n-1) / 2;  
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  // cout << sum(16, 1) << endl;
  int N;
  while ( cin >> N, N ) {
    int f = 2e9, s = 0;    
    for ( int i = 1; i*i <= 2*N; i++ ) {
      if ( 2*N % i != 0 ) continue;
      int n = i;
      {	
	int l = 1, r = N+1;
	while ( r-l > 1 ) {
	  int mid = (r+l)/2;
	  if ( sum(mid, n) > N ) r = mid;
	  else l = mid;	
	}	
	if ( sum(l, n) == N && s < n ) {
	  f = l;
	  s = n;	  
	}
      }
      n = N/i;      
      {	
	int l = 1, r = N+1;
	while ( r-l > 1 ) {
	  int mid = (r+l)/2;
	  if ( sum(mid, n) > N ) r = mid;
	  else l = mid;	
	}	
	if ( sum(l, n) == N && s < n ) {
	  f = l;
	  s = n;	  
	}
      }
    }

    cout << f << " " << s << endl;
  }

  return 0;
}



Measured memory_bytes: 3036
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
inline int read()
{
	int num=0, w=0;
	char ch=0;
	while (!isdigit(ch))
	{
		w|=ch=='-';
		ch = getchar();
	}
	while (isdigit(ch))
	{
		num = (num<<3) + (num<<1) + (ch^48);
		ch = getchar();
	}
	return w? -num: num;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=2e6+10;
int a[N];
int fa[N];
int n;
int find(int p)
{
	return p==fa[p]?p:p=find(fa[p]);
}
signed main()
{
	int n;
	int m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		fa[i]=i;
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		int pa=find(a);
		int pb=find(b);
		if(pa!=pb)
			fa[pb]=pa;
	}
	int num=0;
	for(int i=1;i<=n;i++)
		if(fa[i]==i)
			num++;
	cout<<num-1<<endl;
	return 0;
}



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

using namespace std;

int main()
{
	char n;
	cin>>n;
	if(n>='a'&&n<='z')
	{
		cout<<"a";
	}
	else if(n>='A'&&n<='Z')
	{
		cout<<"A";
	}
	return 0;
}



Measured memory_bytes: 3548
n = int(input())
k = [int(i) for i in input().split()]

for i in range(n):
    v = k[i]
    j = i-1
    while j >= 0 and k[j] > v:
        k[j+1] = k[j]
        j-=1
    k[j+1] =v
    print(' '.join(map(str, k)))
    

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

int main(){
	int A, B, C; cin >> A >> B >> C;
	
	int ma = max({A, B, C});
// 	int mi = min({A, B, C});
// 	int mid = A + B + C - ma - mi;
// 	int ans = ma*10 + mid + mi;
	int ans = A + B + C + ma*9;
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> r(n),b(n);
  
  rep(i,n){
    int x,y;
    cin >> x >> y;
    r[i] = make_pair(x,y);
  }
  rep(i,n){
    int x,y;
    cin >> x >> y;
    b[i] = make_pair(x,y);
  }
  sort(all(r));
  sort(all(b));
  
  vector<bool> used(n,false);
  int ans = 0;
  
  
  rep(i,n){
    int c, d; tie(c,d) = b[i];
    int k = -1, maxy= -1;
    rep(j,n){
      int a, b; tie(a,b) = r[j];
      if (a >= c) break;
      if (b >= d) continue;
      if (used[j]) continue;
      if (b > maxy){
        k = j;
        maxy = b;
      }
    }
    if (k != -1){
      ans++;
      used[k] = true;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
l = []

for i in range(0, N - 1):
    if len(l) == 2:
        break
    if A[i] == A[i + 1] and not A[i] == 0:
        l.append(A[i])
        A[i + 1] = 0
        
if len(l) == 2:
    print(l[0] * l[1])
else:
    print('0')

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

int main()
{
	int n;
	vector<int> change;

	while (cin >> n, n != -1){
		while (1){
			change.push_back(n % 4);
			if (n / 4 == 0){
				break;
			}
			n /= 4;
		}
		reverse(change.begin(), change.end());

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

		change.clear();
	}

	return (0);
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
int main(){
    long N;
    cin >> N;
    long ans = 0;
    for(int i = 0; i< N;i++){
        long a;
        cin >> a;
        if(a != 2 && a%2 == 0){
            continue;
        }
        if(a <= 1){
            continue;
        }
        bool flag = false;
        long c = pow(a, 0.5);
        for(int j = 3; j<=c;j+=2){
            if(a % j == 0){
                flag = true;
                break;
            }
        }
        if(flag == true)continue;
        if(flag == false){
            ans ++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3272
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main() {

    int n; cin >>n;
    int mx = -1;
    int mn = INF;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        mx = max(a, mx);
        mn = min(a, mn);
    }

    cout << mx - mn << endl;
    return 0;
}


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

int main() {
	int t, n, i;
	for(i = 1; i <= 4; i++) {
		cin >> t >> n;
		if (t == 1) {
			cout << 6000 * n << endl;
		}else if (t == 2) {
			cout << 4000 * n << endl;
		}else if (t == 3) {
			cout << 3000 * n << endl;
		}else if (t == 4) {
			cout << 2000 * n << endl;
		}
	} 
}


Measured memory_bytes: 3084
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

LL N,cnt[2],p;

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

    int x;
    for (int i=1; i<=N; i++){
        cin >> x;
        cnt[x%2]++;
    }

    if (cnt[1]==0){
        if (p) cout << 0 << "\n";
        else cout << (1LL<<cnt[0]) << "\n";
        return 0;
    }

    cout << (1LL<<(cnt[1]-1+cnt[0])) << "\n";

    return 0;
}


Measured memory_bytes: 256
from itertools import*
H,W=map(int,input().split())
C=[list(map(int,input().split()))for _ in range(10)]
for i,j,k in product(range(10),repeat=3):C[j][k]=min(C[j][k],C[j][i]+C[i][k])
l=[0]*11
for _ in range(H):
 for i in input().split():l[int(i)]+=1
print(sum(C[i][1]*v for i,v in enumerate(l[:-1])))

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[2005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, Z, W;
    cin >> N >> Z >> W;
    REP(i, N) {
        cin >> A[i];
    }

    ll ans = abs(A[N - 1] - W);
    if (N >= 2) {
        ans = std::max(ans, abs(A[N - 1] - A[N - 2]));
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ans;
    if (a-b == 0){
        ans = c;
    }else if (b-c == 0){
        ans = a;
    }else{
        ans = b;
    }

    cout << ans << endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> P(N);
    for (int i = 0; i < N; i++){
        cin >> P.at(i);
    }

    int wrong_count = 0;
    for (int i = 0; i < N; i++){
        if (P.at(i) != i + 1){
            wrong_count++;
        }
    }

    if (wrong_count == 0 || wrong_count == 2){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
K = int(input())
if K % 2 == 0 or K % 5 == 0:
  print(-1)
elif K % 7 == 0:
  L = 9 * K / 7
  i = 1
  x = 1
  while True:
    y = x * 10
    if y % L == 1:
      print(i)
      exit()
    else:
      x = y % L
      i += 1
else:
  L = 9*K
  i = 1
  x = 1
  while True:
    y = x * 10
    if y % L == 1:
      print(i)
      exit()
    else:
      x = y % L
      i += 1


Measured memory_bytes: 9184
n=int(input())
a=list(map(int,input().split()))

from fractions import gcd
from functools import reduce
def lcm(x,y):
  return x*y//gcd(x,y)

q=reduce(lcm,a)

ans=0
for i in a:
  ans+=(q-1)%i
print(ans)

Measured memory_bytes: 66792
import sys
inputs = sys.stdin.readlines()

N, K = map(int, inputs[0].split())
S = inputs[1].strip()

from collections import deque

count = 1
A = deque()
for i in range(len(S)):
  try:
    if S[i] == S[i+1]:
      count += 1
    else:
      A.append(count)
      count = 1
  except:
    A.append(count)

for _ in range(K):
  if len(A) >= 3:
    A.append(A.pop() + A.pop() + A.pop())
  elif len(A) == 2:
    A.append(A.pop() + A.pop())
  else:
    break

print(sum(A)-len(A))

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

int main()
{
	int i,j,num,sum=0;
	string number;

while(1){
sum =0;
	cin >>number;

	if(number == "0") break;
	for(i=0;i<number.size();i++){
	num = number[i] - '0';
		sum += num;
		}
	cout <<sum <<"\n";
	}
return 0;

}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
//#define pb push_back
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define td(v) v.begin(),v.end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define re(v) {for(auto &_re : v) cin >> _re;}
#define pr(v) {for(auto _pr : v) cout << _pr << " "; cout << endl;}
#define prr(v) {for(auto _prr : v) cout << _prr.ff << " " << _prr.ss << endl;}
using namespace std;
const ll M = 1e9 + 7;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector<ll> crivo(n+1);
    ll ans = 0;
    for(int i=1;i<=n;i++){
    	for(int j=i;j<=n;j+=i){
    		crivo[j]++;
    	}
    	ans += i * crivo[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 81368
#include <stdio.h>
int main() {
        int a, b;
        scanf("%d %d", &a, &b);
        
        if (a < b) {
                for(int i =0; i < b; i++) printf("%d",a);
        }else {
                for(int i =0; i < a; i++) printf("%d",b);

        }
       
        return 0;
}



Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
typedef long long ll;
typedef std :: pair <ll, ll> pll;
const int N = 2e5;
inline int Get() {
	char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	int Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Num;
}
ll flag;
int n, tot, first[N], next[N << 1], end[N << 1], cap[N << 1];
std :: vector <pll> que[N];
inline void AddEdge(int x, int y, int w) {
	next[++tot] = first[x], first[x] = tot, end[tot] = y, cap[tot] = w;
	next[++tot] = first[y], first[y] = tot, end[tot] = x, cap[tot] = w;
}
inline bool cmp1(const pll &a, const pll &b) {
	return a.first == b.first ? a.second < b.second : a.first < b.first;
}
inline bool cmp2(const pll &a, const pll &b) {
	return a.second == b.second ? a.first < b.first : a.second < b.second;
}
void Merge(int x, int l, int r) {
	if (que[l].size() > que[r].size()) std :: swap(l, r);
	
	if (!que[l].size()) return;
	
	std :: sort(que[l].begin(), que[l].end(), cmp1);
	std :: sort(que[r].begin(), que[r].end(), cmp2);
	ll w = -1;
	for (int sze = que[l].size(), i = sze - 1, j = 0; i >= 0; --i) {
		while (j < que[r].size() && que[r][j].second + que[l][i].first <= flag) {
			if (w < 0) w = que[r][j].first;
			else w = std :: min(w, que[r][j].first);
			++j;
		}
		
		if (w >= 0) que[x].push_back(std :: make_pair(w, que[l][i].second));
	}
	
	std :: sort(que[l].begin(), que[l].end(), cmp2);
	std :: sort(que[r].begin(), que[r].end(), cmp1);
	w = -1;
	for (int sze = que[l].size(), i = sze - 1, j = 0; i >= 0; --i) {
		while (j < que[r].size() && que[r][j].first + que[l][i].second <= flag) {
			if (w < 0) w = que[r][j].second;
			else w = std :: min(w, que[r][j].second);
			++j;
		}
		
		if (w >= 0) que[x].push_back(std :: make_pair(que[l][i].first, w));
	}
}
void solve(int x, int fa) {
	que[x].clear();
	
	int xl = 0, xr = 0, wl = 0, wr = 0;
	for (int k = first[x], v; v = end[k], k; k = next[k])
		if (v != fa) {
			solve(v, x);
			if (!xl) xl = v, wl = cap[k];
			else xr = v, wr = cap[k];
		}
	
	if (!xl) {
		que[x].push_back(std :: make_pair(0, 0));
		return;
	}
	
	for (int i = 0, sze = que[xl].size(); i < sze; ++i) que[xl][i].first += wl, que[xl][i].second += wl;
	for (int i = 0, sze = que[xr].size(); i < sze; ++i) que[xr][i].first += wr, que[xr][i].second += wr;
	
	Merge(x, xl, xr);
}
int main() {
	n = Get();
	for (int i = 2, x, w; i <= n; ++i) 
		x = Get(), w = Get(), AddEdge(i, x, w);
	
	ll l = 0, r = (ll)N * n, ans = 0;
	while (l <= r) {
		ll mid = l + r >> 1;
		flag = mid, solve(1, 0);
		if (que[1].size()) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 31732
#include <cstdio>

#define fo(x,y,z) for(int (x)=y;x<z;x++)

int m,n,k,c[1005][1005][3];
char ma[1005][1005];

int f(int a){
	return (a>=0)?a:1004;
}

int main(){
	scanf("%d%d%d ",&m,&n,&k);
	fo(i,0,m){
		scanf(" %s ",ma[i]);
		fo(j,0,n){
			if(ma[i][j]=='J') c[i][j][0]++;
			else if(ma[i][j]=='O') c[i][j][1]++;
			else c[i][j][2]++;
			fo(x,0,3)
				c[i][j][x]+=c[i][f(j-1)][x];
		}
	}

	fo(i,0,m)
		fo(j,0,n)
			fo(x,0,3)
				c[i][j][x]+=c[f(i-1)][j][x];

	int lx,ly,rx,ry;
	fo(i,0,k){
		scanf("%d%d%d%d",&lx,&ly,&rx,&ry);
		lx--;ly--;rx--;ry--;
		fo(x,0,3){
			printf("%d",c[rx][ry][x]-c[f(lx-1)][ry][x]-c[rx][f(ly-1)][x]+c[f(lx-1)][f(ly-1)][x]);
			if(x<2) printf(" ");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 13672
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ms(a,b) memset(a,b,sizeof(a))
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int maxn=1e6+10;
const int mod=1e9+7;
const int maxm=1e3+10;
using namespace std;
int main(int argc, char const *argv[])
{
    #ifndef ONLINE_JUDGE
        // freopen("in.txt", "r", stdin);
        // freopen("out.txt", "w", stdout);
        srand((unsigned int)time(NULL));
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a[4];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if((a[0]!=a[1]&&a[0]!=a[2]&&a[1]!=a[2])||(a[0]==a[1]&&a[0]==a[2]))
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    #ifndef ONLINE_JUDGE
        cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<" s.\n";
    #endif
    return 0;
}

Measured memory_bytes: 256
//OPTIMIZATONS
#pragma GCC optimize("02")
//CODE
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin>>n;
	vector<int> ans(n+1,0);
	int temp;
	for(int i=1;i<n;i++){
		cin>>temp;
		ans[temp]++;
	}
	for(int i=1;i<=n;i++)cout<<ans[i]<<endl;
	return 0;
}



Measured memory_bytes: 4780
#include<stdio.h>
int main()
{
  int A[1000],N,j,i,v;
  scanf("%d",&N);
  for(i=1;i<=N;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=N;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;

    for(j=1;j<N;j++)printf("%d ",A[j]);
    printf("%d\n",A[N]);
  }
  return 0;
}




Measured memory_bytes: 2092
#include <stdio.h>

int main(void)
{
	int S,h, m, s;
	scanf("%d", &S);
	h = S / 3600;
	m = S / 60 - h * 60;
	s = S - h * 3600 - m * 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A1 = scanner.nextInt();
		int A2 = scanner.nextInt();
		int A3 = scanner.nextInt();
		scanner.close();

		int[] A = { A1, A2, A3 };
		Arrays.sort(A);

		System.out.println(A[2] - A[0]);
	}
}


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

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

  int s = 0;
  int m = 1e9;
  int j = 0;
  for(int i = 1; i <= N; i++) {
    int t =  L + i - 1;
    s += t;
    if(abs(t) < m) {
      m = abs(t);
      j = i;
    }
  }

  cout << s - L - j + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vt<int>>;

int main(){

  int n,r=0,w=0;
  string S;

  cin >> n >> S;

  rep(i,n){
    if(S[i]=='R') r++;
    else w++;
  }

  int ans = min(r,w);
  int w_left = 0, w_right = w, r_left = 0, r_right = r;

  rep(i,n){

    if(S[i]=='W'){
      w_left++; w_right--;
    }

    else{
      r_left++; r_right--;
    }

    if(w_left <= r_right){
      ans = min(ans, r_right);
    }

    if(w_left > r_right){
      ans = min(ans, w_left);
    }

  }

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


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

const int MOD = pow(10, 9) + 7;
int main() {
  ll N; cin >> N;
  ll all_a = 1;
  ll all_b = 1;
  ll all_c = 1;
  REP(i, N) {
    all_a *= 10;
    all_a %= MOD;
    all_b *= 8;
    all_b %= MOD;
    all_c *= 9;
    all_c %= MOD;
  }
  all_c *= 2;
  all_c %= MOD;
  ll res = (all_c - all_b);
  res %= MOD;
  if(res < 0) res += MOD;
  ll ans = all_a - res;
  ans %= MOD;
  if(ans < 0) ans += MOD;
  cout << ans % MOD << endl;
}

Measured memory_bytes: 3628
require 'set'
doc=Set.new
n=gets.to_i
n.times do
  x=gets.split(" ")
  case x[0]
  when "insert" then
    doc<<x[1]
  when "find" then
    if doc.include?(x[1]) then
      print "yes\n"
    else
      print "no\n"
    end
  end
end


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

int main() {
	int x;
	while(1){
		string str;
		cin >> str;
		if(str=="0") break;
		int ans = 0;
		rep(i,0,str.length()){
			ans += str[i]-'0';
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3172
<?php
define("MOD", 10**9+7);
$str = str_split(str());
$n = count($str);
for($j = 0; $j < 13; $j++){
  $dp[$n-1][$j] = 0;
}
if($str[$n-1] == "?"){
  for($i = 0; $i < 10; $i++){
    $dp[$n-1][$i] = 1;
  }
}else{
  $dp[$n-1][$str[$n-1]] = 1;
}
$c = 0;
$m = 1;
for($i = $n-2; $i>=0; --$i){
  $m*=10;
  $m%=13;
  for($j = 0; $j < 13; ++$j){
    $dp[$i][$j] = 0;
  }
  $dpi = &$dp[$i];
  $dpip = $dp[$i+1];
  if($str[$i] != "?"){
    $diff = $m*intval($str[$i])%13;
    for($j = 0; $j < 13; ++$j){
      $dpi[($j+$diff)%13] = $dpip[$j];
    }
  }else{
    for($k = 0; $k < 10; ++$k){
      $diff = $m*intval($k)%13;
      for($j = 0; $j < 13; ++$j){
        $dpi[($j+$diff)%13] += $dpip[$j];
        $c+=$dpip[$j];
      }
    }
  }
  for($j = 0; $j < 13; $j++){
    $dp[$i][$j] = $dp[$i][$j] % MOD;
  }
}
echo $dp[0][5];


function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}


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

long long N, W;
vector<vector<int>> G;

long long solve(long long *dp, long long v);

int main() {
    cin >> N >> W;
    G.assign(N, vector<int>());

    // dp[v]: v を始点としたときの、G の有効パスの長さの最大値
    long long dp[N];

    for (int i = 0; i < N; i++) {
        dp[i] = -1;
    }

    for (int i = 0; i < W; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        G[x].push_back(y);
        // cout << x << " connected to " << y << endl;
    }

    long long res = 0;
    for (int i = 0; i < N; i++) {
        long long tmp = solve(dp, i);
        // cout << i << " " << tmp << endl;
        if (res < tmp) {
            res = tmp;
        }
    }

    std::cout << res;
    return 0;
}

long long solve(long long *dp, long long v) {
    if (dp[v] != -1) {
        return dp[v];
    }

    long long res = 0;
    for (int edge : G[v]) {
        long long tmp = solve(dp, edge) + 1;
        if (res < tmp) {
            res = tmp;
        }
    }
    dp[v] = res;
    return res;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define INF 99999999

using namespace std;

typedef long long ll;

int main(){
	int num[100005];
	fill(num,num+100005,INF);
	num[0]=0;
	for(int i = 0; i < 100005; i++){
		int six=1;
		while(i+six < 100005){
			num[i+six]=min(num[i+six],num[i]+1);
			six*=6;
		}
		int nine=1;
		while(i+nine < 100005){
			num[i+nine]=min(num[i+nine],num[i]+1);
			nine*=9;
		}
	}
	int n;
	cin >> n;
	cout << num[n] << endl;
    return 0;
}

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

int main()
{
  int N, K;
  cin >> N >> K;
  
  int a[N+1] = {0};
  int x;
  for (int i = 0; i < N; i++) {
    cin >> x;
    a[x]++;
  }
  
  sort(a, a+N+1);

  int ans = 0;
  for (int i = 0; i < N-K+1;i++) ans += a[i];
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int N =sc.nextInt();
        int M =sc.nextInt();
        int count=0;
        int K,A;
        int ans[] =new int[M];
        
        for(int i=0; i < N; i++){
            K =sc.nextInt();
            for(int j = 0; j < K; j++){
                A =sc.nextInt();
                ans[A-1] += 1;
            }
        }
        for(int i = 0; i < M; i++){
            if(ans[i] == N){
                count += 1;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 38676
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ n, k ] <- readIntegers
	let
		m1 = n `mod` k
		m2 = negate ( m1 - k ) `mod` k
	print $ min m1 m2

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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;++i)cin>>a[i];
    vector<ll> dp(n+1);
    dp[1] = 1000;
    for(int i=2;i<=n;++i){
        dp[i] = dp[i-1];
        for(int j=1;j<i;++j){
            ll num = dp[j]/a[j];
            ll w = dp[j] + (a[i] - a[j])*num;
            dp[i] = max(dp[i],w);
        }
    }
    cout << dp[n] << endl;
    return 0;
    
}


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

int main() {
    int N;
    cin >> N;
    int A[N], B[N];
    for(int i = 0; i < N; i++) {
        B[i+1] = 0;
    }
    for(int i = 2; i <= N; i++) {
        cin >> A[i];
        B[A[i]]++;
    }
    for(int i = 0; i < N; i++) {
        cout << B[i+1] << endl;
    }
}


Measured memory_bytes: 5132
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <iomanip>
#include <cassert>
#include <numeric>
using namespace std;
 
#define ff first
#define ss second
#define pb push_back 
 
using LL = long long int;
using VL = vector<LL>;
using VI = vector<int>;
using VVL = vector<VL>;
using PLL = pair<LL,LL>;
using PII = pair<int ,int>;
 
#ifdef DEBUG
void _print()
{
  cout << endl;
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
  cout << first_elem << " ";
  _print(args...);
}
#else
void _print()
{
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
}
#endif
 
 
// NOTE: Please dont implement _print() as function in your program. It is reserved
// for debug purpose.

int main()
{
    ios::sync_with_stdio(false);
    LL n, k;
    cin >> n >> k;
    vector<PLL> inter(k);
    for (int i = 0; i < k; i++) {
        cin >> inter[i].ff >> inter[i].ss;
    }

    VL dp(n + 1, 0);
    dp[1] = 1;
    LL mod = 998244353;
    for (int i = 2; i <= n; i++) {
        for (int j = 0; j < k; j++) {
            if (i - inter[j].ff >= 0) {
                dp[i] = (dp[i] + dp[i - inter[j].ff]) % mod;
                if (i - inter[j].ss > 0) {
                    dp[i] = (dp[i] - dp[i - inter[j].ss - 1]) % mod;
                }
            }
        }

        dp[i] = (dp[i] + dp[i - 1]) % mod;
        _print(i, dp[i]);
 
    }

    dp[n] = (dp[n] - dp[n - 1]) % mod;
    dp[n] += mod;
    dp[n] %= mod;
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 4368