akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    int N;
    cin >> N;
    string s;
    cin >> s;
    vector<lli> sumE(N + 1, 0);
    vector<lli> sumW(N + 1, 0);
    REP(i, 0, N) {
        sumW[i + 1] += sumW[i] + (s[i] == 'W');
        sumE[N - i - 1] += sumE[N - i] + (s[N - i - 1] == 'E');
    }
    /*
    REP(i, 0, N + 1) {
        cout << sumW[i] << " \n"[i == N];
    }
    REP(i, 0, N + 1) {
        cout << sumE[i] << " \n"[i == N];
    }
    //*/
    lli ans = 1 << 30;
    REP(i, 0, N + 1) {
        ans = min(ans, sumE[i] + sumW[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5380
package main

import "fmt"

func main() {
	var n, a, b, total int
	fmt.Scan(&n, &a, &b)

	for i := 1; i <= n; i++ {
		sum := sumDigits(i)
		if sum >= a && sum <= b {
			total += i
		}
	}
	fmt.Println(total)
}

func sumDigits(n int) int {
	var sum int
	for n > 0 {
		sum += n % 10
		n /= 10
	}
	return sum
}


Measured memory_bytes: 512
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from itertools import combinations_with_replacement

n, m, q = map(int, readline().split())
abcd = [list(map(int, readline().split())) for _ in range(q)]
ans = 0
for seq in combinations_with_replacement(range(m), n):
    cnt = 0
    for a, b, c, d in abcd:
        if seq[b - 1] - seq[a - 1] == c:
            cnt += d
    ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 9264
import collections
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
blue = collections.Counter(s)
red = collections.Counter(t)
ans = ""
for k_b,v_b in blue.items():
  for k_r,v_r in red.items():
    if k_b == k_r:
      blue[k_b] = v_b - v_r
if max(blue.values()) < 0:
  print(0)
else:
  print(max(blue.values()))

Measured memory_bytes: 3316
#!/usr/bin/env python3

#from collections import defaultdict
#from heapq import heappush, heappop
#import numpy as np
import sys
from functools import reduce
import numpy as np

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7

debug_indent = 0


def debug(*x):
    global debug_indent
    x = list(x)
    indent = 0
    if x[0].startswith("enter") or x[0][0] == ">":
        indent = 1
    if x[0].startswith("leave") or x[0][0] == "<":
        debug_indent -= 1
    x[0] = "  " * debug_indent + x[0]
    print(*x, file=sys.stderr)
    debug_indent += indent


def solve(N):
    Q = reduce(
        np.convolve,
        [[1, -1]] * 16 + [[1, 1]] * 5,
        np.array([1], dtype=np.int64))
    P = np.zeros(6, dtype=np.int64)
    P[5] = 1

    def conv(X, Y):
        n = X.shape[0]
        m = Y.shape[0]
        ret = np.zeros(n + m - 1, dtype=np.int64)
        for i in range(n):
            ret[i:i + m] += X[i] * Y
            ret[i:i + m] %= MOD
        return ret

    while N:
        Qm = Q.copy()
        Qm[1::2] *= -1
        QQm = conv(Q, Qm)

        PQm = conv(P, Qm)
        if N % 2:
            P = PQm[1::2]
        else:
            P = PQm[::2]
        Q = QQm[::2]
        N //= 2
    return P[0]


def main():
    # parse input
    T = int(input())
    for i in range(T):
        N = int(input())
        print(solve(N))


# tests
T1 = """
4
4
6
10
1000000000
"""


def test_T1():
    """
    >>> as_input(T1)
    >>> main()
    0
    11
    4598
    257255556
    """

# add tests above


def _test():
    import doctest
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())

    def input():
        return bytes(f.readline(), "ascii")

    def read():
        return bytes(f.read(), "ascii")


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import solve  # pylint: disable=all
    elif sys.argv[-1] == "-t":
        print("testing")
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        # input given as file
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()


Measured memory_bytes: 27324
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include <vector>

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

using namespace std;

int main() {
	int N, a[10000];
	cin >> N;
	REP(i, N) {
		cin >> a[i];
	}

	int cnt = 0;
	REP(i, N) {
		while (a[i] % 2 == 0) {
			cnt++;
			a[i] /= 2;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
AI, AO, _, AJ, AL, _, _ = map(int, input().split())

odd = AI % 2 + AJ % 2 + AL % 2
if odd == 0 or odd == 3:
    print(AI + AO + AJ + AL)
elif odd == 1:
    print(AI + AO + AJ + AL - 1)
else:
    if AI + AJ + AL == 2:
        print(AO)
    else:
        print(AI + AO + AJ + AL - 1)


Measured memory_bytes: 38256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int dist = Math.abs(a - b) - 1;
		
		if (dist % 2 == 1) {
			System.out.println("Alice");
		} else {
			System.out.println("Borys");
		}
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 21204
#include <iostream>
#include <sstream>
#include <cstring>
//#include <fstream>

using namespace std;

int d[101];

int main()
{
//	cut here before submit 
//	freopen("testcase.patrol", "r", stdin);
	string str = "";
	memset (d, 0, sizeof (d ) );


	while (getline (cin, str ) ){
		int a, b;
		stringstream ss(str);
		ss >> a >> b;

		if (a != 0 || b != 0 ){
			++d[a];
			++d[b];
			continue;
		} // end if

		bool ng = false;
		
		if (d[1] % 2 == 0 || d[2] % 2 == 0 ){
			ng = true;
		} // end if
		
		if (!ng ){
			for (int i = 3; i <= 100; ++i){
				if (d[i] != 0 && d[i] % 2 == 1 ){
					ng = true;
					break;
				} // end if
			} // end if
		} // end if

		cout << (ng ? "NG" : "OK" ) << endl;

		memset (d, 0, sizeof (d ) );

	} // end loop
		
	return 0;
}

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

using ll=long long;

int main(){

int N;

cin >> N;

string S, T, U;

cin >> S >> T;

for(int i=0;i<N;++i){
U.push_back(S[i]);
U.push_back(T[i]);
}

cout << U << endl;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int k, a, b, tmp;

  cin >> k;
  cin >> a >> b;
  tmp = a/k;

  if(a%k==0 || b%k==0){
    cout << "OK" << endl;
    return 0;
  }else if(k>a && k>b){
    cout << "NG" << endl;
    return 0;
  }
  
  if( (tmp+1) * k <= b || a%k == b%k){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }
  return 0;
}

Measured memory_bytes: 3624
import java.io.*;
import java.util.*;


/**
 * AIZU ONLINE JUDGE
 * 3114
 *  2020/5/4
 */
public class Main {


    boolean main() throws IOException {

        Scanner sc = new Scanner(systemin);

        int N = sc.nextInt();
        int ret = -1;

        int min = Integer.MAX_VALUE;
        for(int i = 0; i < N; i++) {
            int a = sc.nextInt();
            if (a < min) {
                min = a;
                ret = i;
            }
        }

        result.printf("%d\n", ret + 1);

        sc.close();
        return false;
    }



    PrintStream log;
    PrintStream result = System.out;
    BufferedReader systemin;

    static Main instance = new Main();

    Main() {
        systemin = new BufferedReader(new InputStreamReader(System.in));
        log = new PrintStream(new OutputStream() { public void write(int b) {} } );
    }

    public static void main(String[] args) throws IOException {

        instance.main();
        instance.systemin.close();
    }


}




Measured memory_bytes: 67576
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let h1:i32 = read();
    let m1:i32 = read();
    let h2:i32 = read();
    let m2:i32 = read();
    let k:i32 = read();

    let waking = (h2-h1)*60 + (m2-m1);
    println!("{}",waking-k);

}


Measured memory_bytes: 2084
dic = {}
max_v = 0
for _ in range(int(input())):
    k = input()
    v = dic.get(k, 0) + 1
    max_v = max(max_v, v)
    dic[k] = v

lst = sorted([k for k, v in dic.items() if v == max_v])
print("\n".join(lst))


Measured memory_bytes: 35608
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
const int MOD = 1331;
using namespace std;
const int N = 2e5 + 10;
int n;
ll a[N];
int main(){
	// freopen("in.txt", "r", stdin);
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];	
	ll money = 1000,lv = 0;
	for (int i = 0; i < n; i++) {
		if (a[i + 1] == a[i]) continue;// 不动
		if (a[i + 1] > a[i]) {
			lv += money / a[i];
			money %= a[i]; 
		}
		else {
			money += lv * a[i];
			lv = 0;
		}
	}
	cout << money << endl;
	return 0;
}

Measured memory_bytes: 3600
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
    # combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n = int(input())
    a = readInt()
    c_sum = [0]
    for i in range(n):
        c_sum.append(c_sum[i]+a[i])
    ans = 0
    for i in range(n-1):
        ans += a[i] * (c_sum[-1] - c_sum[i+1])
        ans %= mod
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 31548
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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


int main(){
    ll ans=0,a,count=0;
    cin >> a;
    ll z=a;
    ll x=1;
    if (a%2==0){
        while(a>=5){
            a/=5;
            count++;
        }
        for (ll i=1;i<=count;i++){
            x*=5;
            ans+=z/x/2;
        }
        if (z<10){
            cout << 0 << endl;
            return 0;
        }
        cout << ans << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if(a * b % 2 == 0) {
        cout << "Even";
    } else cout << "Odd";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
# imos 法
N, M = map(int, input().split())

cs = [0] * N
for _ in range(M):
    L, R = map(int, input().split())
    cs[L - 1] += 1
    if R != N:
        cs[R] -= 1

for i in range(1, N):
    cs[i] += cs[i - 1]

print(cs.count(M))


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

int main(){
  int n,l[3];
  cin >> n;
  for(int i=0;i<n;i++){
	cin >> l[0] >> l[1] >> l[2];
	sort(l,l+3);
	if(l[2]*l[2] == l[0]*l[0]+l[1]*l[1]) cout << "YES" << endl;
	else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include<iostream>
using namespace std; // 575

int main() {
	int K, n;
	cin >> K;
	cout << (n = K + 3 >> 2 << 1);
	for (int i = 0, j, k;i < n;++ i) {
		cout << endl;
		for (j = 0;j < n;++ j) cout << ((k = (i & 1) * n + (i + j) % n) >= K ? (k - n) % K: k) + 1 << ' ';
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

解説AC、解けなかったの悔しい
*/

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

int main(void) {
    string N;
    cin >> N;
    bool flag = false;
    for (int i = 0; i < 3; i++) {
        if (N[i] == '7') {
            flag = true;
            break;
        }
    }
    if (flag) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 3596
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        for (int i = 1; i < s.Length; i++)
        {
            string t =  s.Substring(0, s.Length - i);
            if (t.Length % 2 != 0) continue;
            if (t.Substring(0, t.Length / 2) != t.Substring(t.Length / 2)) continue;
            Console.WriteLine(t.Length);
            return;
        }
    }
}

Measured memory_bytes: 13140
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int h, n;
    cin >> h >> n;
    
    long long sum = 0;
    int x = 0;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        sum += x;
    }

    if (sum >= h) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }


    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 100000
#define L (k<<1)
#define R (k<<1|1)
struct edge{int nx,t;}e[MN*2+5];
int n,h[MN+5],en,a[MN+5],b[MN+5],fa[MN+5],d[MN+5],s[MN+5],mx[MN+5],f[MN+5],l[MN+5],cnt;
struct node{int s,d,ms,md,mp;}t[MN*4+5];
void up(int k)
{
	if(t[L].ms<t[R].ms)t[k].ms=t[L].ms,t[k].md=t[L].md,t[k].mp=t[L].mp;
	else t[k].ms=t[R].ms,t[k].md=t[R].md,t[k].mp=t[R].mp;
}
void mark(int k,int s,int d)
{
	t[k].ms+=s;t[k].s+=s;
	t[k].md^=d;t[k].d^=d;
}
void down(int k)
{
	if(t[k].s|t[k].d)mark(L,t[k].s,t[k].d),mark(R,t[k].s,t[k].d),t[k].s=t[k].d=0;
}
void build(int k,int l,int r)
{
	if(t[k].mp=l,l==r)return;
	int mid=l+r>>1;
	build(L,l,mid);build(R,mid+1,r);
}
void modify(int k,int l,int r,int ql,int qr,int s,int d)
{
	if(l==ql&&r==qr){mark(k,s,d);return;}
	int mid=l+r>>1;down(k);
	if(qr<=mid)modify(L,l,mid,ql,qr,s,d);
	else if(ql>mid)modify(R,mid+1,r,ql,qr,s,d);
	else modify(L,l,mid,ql,mid,s,d),modify(R,mid+1,r,mid+1,qr,s,d);
	up(k);
}
inline void ins(int x,int y)
{
	e[++en]=(edge){h[x],y};h[x]=en;
	e[++en]=(edge){h[y],x};h[y]=en;
}
void pre(int x)
{
	s[x]=1;
	for(int i=h[x];i;i=e[i].nx)if(e[i].t!=fa[x])
	{
		fa[e[i].t]=x;d[e[i].t]=d[x]+1;
		pre(e[i].t);
		s[x]+=s[e[i].t];
		if(s[e[i].t]>s[mx[x]])mx[x]=e[i].t;
	}
}
void build(int x)
{
	l[x]=++cnt;
	if(!f[x])f[x]=x;
	if(mx[x])f[mx[x]]=f[x],build(mx[x]);
	for(int i=h[x];i;i=e[i].nx)
		if(e[i].t!=fa[x]&&e[i].t!=mx[x])build(e[i].t);
}
void modify(int x,int y,int z,int id)
{
	while(f[x]!=f[y])
	{
		if(d[f[x]]<d[f[y]])swap(x,y);
		modify(1,1,n,l[f[x]],l[x],z,id);
		x=fa[f[x]];
	}
	if(d[x]>d[y])swap(x,y);
	if(l[x]<l[y])modify(1,1,n,l[x]+1,l[y],z,id);
}
int main()
{
	int i,d,p;
	for(n=read(),i=1;i<n;++i)ins(read(),read()); 
	pre(1);build(1);build(1,1,n);
	modify(1,1,n,1,1,MN+5,0);
	for(i=1;i<n;++i)a[i]=read(),b[i]=read(),modify(a[i],b[i],1,i);
	for(i=1;i<n;++i)
	{
		if(t[1].ms>1)return 0*puts("NO");
		d=t[1].md;p=t[1].mp;
		modify(a[d],b[d],-1,d);
		modify(1,1,n,p,p,MN+5,0);
	}
	puts("YES");
}

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

#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define NL cout<<"\n";
#define test cerr<<"abcd\n";

int main() {
	sp;

	////////////////To Remove//////////////
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	///////////////////////////////////////
	double l;
	cin>>l;
	l = l/3.0;
	l = l*l*l;
	cout<<fixed<<setprecision(7)<<l;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int maxn=2e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	int n;
	cin>>n;
	int now=1,ans=0;
	rep(i,1,n)
	{
		int x;
		cin>>x;
		if(x==now)
		{
			now++,ans++;
		}
	}
	if(ans==0) cout<<-1<<'\n';
	else cout<<n-ans<<'\n';
    return 0;
}



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

int main() {
	int d;
	cin >> d;
	const int n = 26;
	vector<int> c(n);
	vector<vector<int>> s(d, vector<int>(n));
	rep(i, n) cin >> c[i];
	rep(i, d) rep(j, n) cin >> s[i][j];
	vector<int> t(d), last(n);
	// rep(i, d) {
	// 	cin >> t[i];
	// 	t[i]--;
	// }
	
	ll ans = 0;
	rep(i, d) {
		ll mx = 0;
		int now;
		rep(j, n) {
			if(mx < s[i][j]) {
				mx = s[i][j];
				now = j;
			}
		}
		cout << now+1 << endl;
		ans += s[i][now];
		last[now] = i+1;
		rep(j, n) {
			ans -= c[j] * (i+1-last[j]);
		}
	}
	
	
	return 0;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> h(N);
	for (int i = 0; i < N; i++) {
		cin >> h.at(i);
	}
	sort(h.begin(), h.end());
	int min_dif = h.at(N - 1) - h.at(0);
	for (int i = 0; (i + K - 1) < N; i++) {
		int tmp = h.at(i + K - 1) - h.at(i);
		if (min_dif > tmp) {
			min_dif = tmp;
		}
	}
	cout << min_dif << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const long long LINF = 1000000000000000018ll;
const int INF = 1000000009;
const int mod = 1000000007;
const int mod2 = 998244353;

int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};

const int MAX = 200005;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  std::cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::setprecision(20) << std::fixed;

  // 前処理
  COMinit();

  ll n, k;
  cin >> n >> k;

  ll ans = 0;
  for (ll i = k; i <= n + 1; i++) {
    ans += (2 * n + 1 - i) * i / 2 - i * (i - 1) / 2 + 1;
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8328
#include <iostream>
#include <vector>
#include <cmath>

int a()
{
    char a, b, c;
    std::cin >> a >> b >> c;
    
    if(a == b && b == c)
    {
        std::cout << "No";
    }
    else
    {
        std::cout << "Yes";
    }
    return 0;
}

int main(int argc, const char * argv[])
{
    a();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int64_t a, b, c;
  cin >> a >> b >> c;
  int64_t K=(c-a-b);
  if(K<=0){
    cout << "No" << endl;
    return 0;
  }
  if(4*a*b<0){
    cout << "No" << endl;
    return 0;
  }
  if(4*a*b<K*K){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}
  

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

const int mod = 1e9 + 7;
typedef long long ll;

void U(auto& x, auto y) {
	x = (x + y) % mod;
}

int n, N, m, a[22], f[22][101000];

ll K(ll x, ll y = mod - 2) {
	ll t = 1;
	for (; y; y >>= 1, x = x * x % mod)
		if (y & 1) t = t * x % mod;
	return t;
}

ll jc[101000], inv[101000];
ll C(int x, int y) {
	return jc[x] * inv[y] % mod * inv[x - y] % mod;
}

int main() {
	cin >> n >> m; N = 1 << n;
	for (int i = 0; i <= N; ++i) {
		jc[i] = i ? jc[i - 1] * i % mod : 1;
		inv[i] = K(jc[i]);
	}
	for (int i = 1; i <= m; ++i) cin >> a[i];
	sort(a + 1, a + m + 1, greater<int>());
	f[0][0] = 1;
	for (int i = 1; i <= m; ++i)
		for (int j = 0; j < N; ++j)
			if (f[i - 1][j]) {
				U(f[i][j], f[i - 1][j]);
				for (int k = 0; k < n; ++k)
					if (!(j >> k & 1)) {
						int las = N - a[i] + 1 - j;
						if (las < (1 << k)) continue;
						U(f[i][j | 1 << k], mod - f[i - 1][j] * C(las - 1, (1 << k) - 1) % mod);
					}
			}
	int ans = 0;
	for (int j = 0; j < N; ++j)
		if (f[m][j]) {
			ll tmp = f[m][j]; int las = N - 1 - j;
			for (int k = 0; k < n; ++k)
				if (!(j >> k & 1)) {
					tmp = tmp * C(las, 1 << k) % mod;
					las -= 1 << k;
				}
			U(ans, tmp);
		}
	for (int i = 0; i < n; ++i)
		ans = (ll)ans * jc[1 << i] % mod;
	cout << (ll)ans * N % mod << endl;

	return 0;
}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
ll fact[100010];
ll mod=1e9+7;
#define MAX 100010
ll Sorce[MAX];
void modcInit(ll i){
    fact[0]=1;
    rep(j,1,i+1){
        fact[j]=fact[j-1]*j;
        fact[j]%=mod;
    }
}
ll modc(ll n,ll x){
    return fact[n]*modinv(fact[n-x]*fact[x]%mod,mod)%mod;
}

int main( ){
    ll n,k;cin>>n>>k;
    vll res(k+1,0);
    irep(i,1,k+1){
        ll quem=k/i;
        res[i]=modpow(quem,n,mod)%mod;
        if(quem>=2)
        rep(p,2,quem+1){
            res[i]-=res[p*i];
            res[i]%=mod;
        }
    }
    ll ans=0;
    rep(i,1,k+1){
        ans+=res[i]*i%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}




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

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

    int ans = 1;
    for (int i = 2; i <= n - 1; i++)
    {
        int y = 2;
        int j = 2;
        while (j * j <= i)
        {
            if (i % j == 0)
            {
                y++;
                if (j != i / j)
                {
                    y++;
                }
            }
            j++;
        }
        ans += y;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(){
    char S[10],T[10],U[10];
    int A,B,ans;
    scanf("%s %s",S,T);
    scanf("%d %d",&A,&B);
    scanf("%s",U);
    if(strcmp(S,U)==0){
        A = A - 1;
    }else{
        B = B - 1;
    }
    printf("%d %d",A,B);
    return 0;
}


Measured memory_bytes: 128
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = ReadLong();
        var alphabets = "abcdefghijklmnopqrstuvwxyz";
        var result = "";
        while (n > 0)
        {
            n -= 1;
            var a = (int) (n % 26);
            n /= 26;

            var c = alphabets[a];
            result = c + result;
        }

        Console.WriteLine(result);
    }


    private static string Read() => Console.ReadLine();
    private static char[] ReadChars() => Array.ConvertAll(Read().Split(), a => a[0]);
    private static int ReadInt() => int.Parse(Read());
    private static long ReadLong() => long.Parse(Read());
    private static double ReadDouble() => double.Parse(Read());
    private static int[] ReadInts() => Array.ConvertAll(Read().Split(), int.Parse);
    private static long[] ReadLongs() => Array.ConvertAll(Read().Split(), long.Parse);
    private static double[] ReadDoubles() => Array.ConvertAll(Read().Split(), double.Parse);
}

Measured memory_bytes: 27456
n, y = gets.chomp.split(" ").map(&:to_i)
z = y / 1000
a = [n, y / 10000].min
b = [n, y / 5000].min
(0..a).each do |i|
  (0..b).each do |j|
    k = n - (i + j)
    if k >= 0 && i * 10 + j * 5 + k * 1 == z then
        puts "#{i} #{j} #{k}"
        exit
    end
  end
end

puts "-1 -1 -1"


Measured memory_bytes: 3836
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    int ans=INF;
    chmin(ans,a+b);
    chmin(ans,a+c);
    chmin(ans,b+c);
    cout<<ans<<"\n";
}


Measured memory_bytes: 3608
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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) {
            long n = in.nextLong(), m = in.nextLong();
            int end = 0;
            if (n == 1 && m == 1) {
                out.println(1);
                return;
            }
            if (n == 1) {
                out.println(m - 2);
                return;
            }
            if (m == 1) {
                out.println(n - 2);
                return;
            }
            out.println((m - 2) * (n - 2));
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<llll> vllll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair
#define endl '\n'


int render(vvi pattern) {
    int n = pattern.size();
    cout << n << endl;
    rep(r,n){
        rep(c,n){
            if (c > 0) cout << ' ';
            cout << 1+pattern[r][c];
        }
        cout << endl;
    }
    return n;
}
int solve(int K) {
    if (K == 1) {
        return render(vvi{{0}});
    }

    int n = 2*((K+3)/4);

    vvi pattern(n, vi(n, 0));
    for (int r=0; r<n; ++r) {
        for (int c=0; c<n; ++c) {
            int i = (r + c)%n;
            if (r % 2 == 0 || K <= n+i) {
                pattern[r][c] = i;
            } else {
                pattern[r][c] = n + i;
            }
        }
    }
    return render(pattern);
}

int main() {
    int K; cin >> K;
    solve(K);
    return 0;
}


Measured memory_bytes: 3200
s=input()
n=len(s)
s1=s[:(n-1)//2]
s2=s[(n+3)//2-1:]

def check(s):
  i=0
  j=len(s)-1
  while j>i:
    if s[j]!=s[i]:
      return False
    j-=1
    i+=1
  return True

if check(s) and check(s1) and check(s2):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9128
N=int(input())
def calc(n):
  return n*(n+1)//2

threshold=0
for i in range(1,N+1):
  if calc(i)>=N:
    threshold=i
    break

sub=calc(threshold)-N
#print(sub)
for a in range(1,threshold+1):
  if a!=sub:
    print(a)

Measured memory_bytes: 3408
#include <iostream>
#include <stdio.h>
#include<string>
#include<math.h>
#include<map>
#include<algorithm>
using namespace std;
int main()
{
	int N,ans =0;
	string s;
	cin >> N >> s;
	
	for (int i = 0;i < N;i++)
	{
		if (s[i] != s[i + 1])ans++;
	}
	cout << ans;


}

Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include<stack>

using namespace std;
typedef long long ll;

int main(){
  int N, M;
  cin >> N >> M;
  vector<ll> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
  }
  ll sum = 0;
  map<ll, ll> nums;
  nums[sum]++;
  for (int i = 0; i < N; i++) {
    sum += vec[i];
    nums[sum % M]++;
  }
  
  ll res = 0;
  for (auto itr = nums.begin(); itr != nums.end(); itr++) {
    res += itr->second * (itr->second - 1) / 2;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,m,ans;
signed main(){
	n=read();m=100;
	while(m<n)++ans,m=1.01*m;
	printf("%lld",ans);
}

Measured memory_bytes: 3768
fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    
    var ans = 0
    
    for (i in 1..N) {
        val (l, r) = readInputLine().split(" ").map { it.toInt() }
        ans += r - l + 1
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


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

int main(){
    vector<int> cnt(26);
    string s;
    while (getline(cin, s)){
        for (int i = 0; i < s.size(); i++){
            if ('a' <= s[i] && s[i] <= 'z') cnt[s[i]-'a']++;
            if ('A' <= s[i] && s[i] <= 'Z') cnt[s[i]-'A']++;
        }
    }
    for (int i = 0; i < 26; i++){
        cout << char('a' + i) << " : " << cnt[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
# 116a

def atc_116a(input_value: str) -> int:
    tri_length = [int(ai) for ai in input_value.split(" ")]
    tri_length.sort()
    return int((tri_length[0] * tri_length[1] / 2))

input_value = input()
print(atc_116a(input_value))


Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

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; }
constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

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

  string s;
  cin >> s;

  int ans = 1;
  if (s[0] == 'R' && s[1] == 'R') ans++;
  if (s[1] == 'R' && s[2] == 'R') ans++;

  if (s == "SSS") ans = 0;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#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)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int n;
ll h[220000];
ll a[220000];
P f[220000];
ll bit[220000];
ll dp[220000];
void set_val(ll *bit,int i,ll val){
    i++;
    while(i<220000){
        bit[i]=max(bit[i],val);
        i+=i&-i;
    }
}
ll max_val(ll *bit, int i){
    i++;
    ll res=0;
    while(i){
        res=max(bit[i],res);
        i-=i&-i;
    }
    return res;
}
int main(){
    cin >> n;
    rep(i,n){
        cin >> h[i];
        f[i]=P(h[i],i);
    }
    rep(i,n) cin >> a[i];
    sort(f,f+n);
    ll ans=0;
    for(auto p:f){
        int i=p.se;
        dp[i]=a[i];
        dp[i]=max_val(bit,i-1)+a[i];
        set_val(bit,i,dp[i]);
        chmax(ans,dp[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    s=s;
    long long m=t.size(),n=s.size(),j=0,i,k;
    vector <long long> vect1(26,0),vect2(26,0);
    for(int i=0;i<n;i++)
        vect1[s[i]-'a']=1;
    for(int i=0;i<m;i++)
        vect2[t[i]-'a']=1;
    long long flag2=0;
    for(int i=0;i<26;i++)
    {
        if(vect2[i]==1 && vect1[i]==0)
            flag2=1;
    }
    if(flag2==1)
    {
        cout<<-1;
        return 0;
    }
    vector <long long> vect3[26];
    for(int i=0;i<n;i++)
    {
        long long a1=s[i]-'a';
        vect3[a1].push_back(i);
    }

    long long count1=0,j1=-1;
    for(int i=0;i<m;i++)
    {
        long long a=t[i]-'a';
        long long q=upper_bound(vect3[a].begin(),vect3[a].end(),j1)-vect3[a].begin();
        if(q==vect3[a].size())
        {
            count1+=n;
            i--;
            j1=-1;
        }
        else j1=vect3[a][q];
    }
    cout<<count1+j1+1;
    return 0;
}


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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(N);
	for (int& i : A) cin >> i;
	for (int i = 1; i <= M; ++i) {
		for (int j = 1; j < N; ++j) {
			if (A[j - 1] % i > A[j] % i) swap(A[j - 1], A[j]);
		}
	}
	for (int& i : A) cout << i << endl;
}


Measured memory_bytes: 3064
<?php
$r = [];
fscanf(STDIN, "%d %d", $N, $Q);
$flg = array_pad(array(), $N + 1, 0);
$ans = array_pad(array(), $N + 1, 0);
for ($i = 0; $i < $N - 1; $i++) {
    fscanf(STDIN, "%d %d", $a, $b);
    $r[$a][$b] = 1;
    $r[$b][$a] = 1;
}
for ($i = 0; $i < $Q; $i++) {
    fscanf(STDIN, "%d %d", $p, $x);
    $ans[$p] += $x;
}
$pointer = [];
array_push($pointer, 1);
while($pointer) {
    $tmp = array_pop($pointer);
    $flg[$tmp] = 1;
    foreach ($r[$tmp] as $c => $dummy) {
        if ($flg[$c] === 0) {
            $flg[$c] = 1;
            $ans[$c] = $ans[$tmp] + $ans[$c];
            array_push($pointer, $c);
        }
    }
}
for ($i = 1; $i <= $N; $i++) {
    $arr[] = $ans[$i];
}
echo implode(" ", $arr);


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

using namespace std;

int main(void){
    int X, Y;
    cin >> X >> Y;
    int gr[1000] = {300000, 200000, 100000, 0,};
    int ans = gr[X - 1] + gr[Y - 1];
    if(X == 1 && Y == 1) ans += 400000;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

LL N, x;
VL a;

signed main(void) {
    scanf("%lld%lld", &N, &x);
    a.resize(N);
    REP(i, N) {
        scanf("%lld", &a[i]);
    }
    LL cnt = 0;
    REP(i, N - 1) {
        LL sum = a[i] + a[i + 1];
        if (sum <= x) continue;
        LL buf = sum - x;

        a[i + 1] -= buf;
        cnt += buf;
        if (a[i + 1] < 0) {
            a[i] += a[i + 1];
            a[i + 1] = 0;
        }
    }
    cout << cnt << endl;
}


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

using namespace std;
typedef long long ll;
int main() {
    ll k, i;
    cin >> k;
    cout << 50 << endl;
    for(i = 0; i < 50 - k % 50; i++) {
        cout << 49 + k / 50 - k % 50 << " ";
    }
    for(; i < 50; i++) {
        cout << 99 + k / 50 - k % 50 + 1 << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]
ans = 0
for i in range(n):
	if a[i] >= 2:
		ans += a[i] // 2
		a[i] = a[i] % 2
	if i != n-1:
		if a[i] >= 1 and a[i+1] >= 1:
			k = min(a[i], a[i+1])
			ans += k
			a[i] -= k
			a[i+1] -= k
print(ans)

Measured memory_bytes: 7072
n, m = map(int, input().split())
A = tuple(map(int, input().split()))

from itertools import accumulate
AS = [0] + list(accumulate(A))
counts = dict()
for a in AS:
    r = a%m
    counts.setdefault(r, 0)
    counts[r] += 1

ans = 0
for k, v in counts.items():
    ans += v*(v-1)//2
print(ans)


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

const int INF = 1000000;

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

  vector<int> dp(n+1);
  rep(i, n+1) {
    if (i == 0) continue;
    dp[i] = INF;
    int p = 1;
    while (p <= n) {
      if (i-p<0) break;
      dp[i] = min(dp[i], dp[i-p]+1);
      p *= 6;
    }
    int q = 1;
    while (q <= n) {
      if (i-q<0) break;
      dp[i] = min(dp[i], dp[i-q]+1);
      q *= 9;
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {

  public static void main(String args[]) {
    int rep = 1;
    if( args.length > 0 ) { rep = Integer.parseInt(args[0]); }
    (new Main()).__solve(rep);
  }

  void __solve(int rep) {

    try (
      Scanner cin = new Scanner(System.in);
    ) {

      for( int i = 0; i < rep; ++i ) {
        __solve(cin);
      }

    }

  }

  void __solve(Scanner cin) {
	  int N = cin.nextInt();
	  int M = cin.nextInt();
	  UnionFind uf = new UnionFind(N);
	  for( int i = 0; i < M; ++i ) {
		  int a = cin.nextInt() - 1;
		  int b = cin.nextInt() - 1;
		  int z = cin.nextInt();
		  uf.merge(a, b);
	  }
	  System.out.println(uf.numGroups());
  }

  class UnionFind {

	  private static final boolean ufDebug = false;
	  private static final int ROOT = -1;

	  private int group[];
	  private int size;
	  private int rest;

	  private int count[];
	  
	  public int numGroups() {
		  int ret = 0;
		  for( int i = 0; i < size; ++i ) {
			  if( group[i] == ROOT ) { ++ret; }
		  }
		  return ret;
	  }

	  public UnionFind(int N) {
	    size = rest = N;
	    group = new int[size];
	    for(int i=0; i<N; ++i) { group[i] = ROOT; }
	    count = new int[size];
	  }

	  public int size() {
	    return rest;
	  }

	  public int find(int index) {
	    if( index < 0 || index >= size ) { return -1; }
	    int ret = index;
	    while( group[ret] != ROOT ) { ret = group[ret]; }
	    return ret;
	  }

	  public boolean same(int a, int b) {
	    return find(a) == find(b);
	  }

	  public void merge(int a, int b) {
	    int A = find(a);
	    int B = find(b);
	    if( A == B ) { return; }
	    if( count[A] <= count[B] ) { subMerge(A, B); }
	    else { subMerge(B, A); }
	  }

	  // merge A (small) into B (large)
	  private void subMerge(int A, int B) {
	    if( group[A] != ROOT || group[B] != ROOT ) {
	      if( ufDebug ) { throw new RuntimeException("Implementation Error !"); }
	      return;
	    }
	    group[A] = B;
	    count[B] += count[A] + 1;
	    --rest;
	  }

	}

  
}


Measured memory_bytes: 90704
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
using namespace std;

int main()
{
    int N, X;
    cin >> N >> X;
    vector<int> M(N);
    for (int i = 0; i < N; i++)
    {
        cin >> M[i];
    }
    X -= accumulate(M.begin(), M.end(), 0);
    sort(M.begin(), M.end());
    cout << X / M[0] + N << endl;
    return 0;
}

Measured memory_bytes: 256