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

#define N 190

int dp[2][N][N][N];
char s[N][N];

int sum[N][N];
int n, m;

void chkmax(int &a, int b) {if (a < b) a = b;}

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i ++) scanf("%s", s[i]+1);
	for (int j = 1; j <= m; j ++) {
        for (int i = 1; i <= n; i ++) sum[j][i] += sum[j][i-1] + (s[i][j] == '.');
	}
    for (int i = 1; i <= n; i ++) {
        for (int j = i; j <= n; j ++) {
            if (j == i) dp[0][i][j][m] = m+1;
            else dp[0][i][j][m] = (s[j][m] == s[j-1][m] ? dp[0][i][j-1][m] : m);
            dp[0][i][j][m+1] = dp[1][i][j][m+1] = m+1;
        }
    }
    for (int c = m-1; c >= 1; c --) {
        for (int i = 1; i <= n; i ++) {
			for (int j = i; j <= n; j ++) {
                int g = sum[c][j] - sum[c][i-1];
                if (g == j-i+1 || g == 0) {
                    dp[0][i][j][c] = (s[i][c] == s[i][c+1]) ? dp[0][i][j][c+1] : c+1;
                }
                else dp[0][i][j][c] = c;
			}
        }
    }
    int ans = 0;
    int u = 0, v = 1;
    while (dp[u][1][n][1] <= m) {
		ans ++;
        for (int c = m; c >= 1; c --) {
            for (int i = 1; i <= n; i ++) {
                int p = i;
				for (int j = i; j <= n; j ++) {
                    int &res = dp[v][i][j][c];
                    res = dp[u][i][j][dp[u][i][j][c]];
                    while (p < j && dp[u][i][p][c] >= dp[u][p+1][j][c]) p ++;
                    chkmax(res, dp[u][i][p][c]);
                    chkmax(res, dp[u][p][j][c]);
				}
            }
        }
		swap(u, v);
    }
    printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 53248
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);


int main(){
  string S;
  cin >> S;
  int N = S.size();
  ll dp[100005][13] = {0};
  dp[0][0]=1;
  rep(i, N){
    if(S[i] !='?'){
      int add = S[i] - '0';
      rep(j, 13){
        int k = (j*10 + add) % 13;
        dp[i+1][k] += dp[i][j];
        dp[i+1][k] %= MOD;
      }
    }
    else{
      rep(j, 13){
        rep(k, 10){
          int l = (j*10 + k) % 13;
          dp[i+1][l] += dp[i][j];
          dp[i+1][l] %= MOD;
        }
      }
    }
  }
  cout << dp[N][5] << endl;     
  
}

Measured memory_bytes: 10624
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << "\n";

	return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

bool has_dislikes(int n, vector<int>D) {
  bool has = false;

  while (n > 0) {
    if (std::find(D.begin(), D.end(), n % 10) != D.end()) {
      has = true;
      break;
    } else {
      n /= 10;
    }
  }

  return has;
}

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

  vector<int> D;
  int d;
  rep(i, K) {
    cin >> d;
    D.push_back(d);
  }

  int n = N;
  while(true) {
    if (has_dislikes(n, D)) {
      n++;
    } else {
      cout << n << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        boolean flag = false;
        List<String> lst = new ArrayList();
        int countA=0,countB=0;


        if (S.length() != 4) {
            flag = false;
        } else {
            for (int i = 0; i < S.length(); i++) {
                if (!lst.contains(S.substring(i, i + 1))) {
                    lst.add(S.substring(i, i + 1));

                }


            }

            if(lst.size()!=2){
                flag=false;
            }else{

                for (int i = 0; i < S.length(); i++) {
                    if (S.substring(i,i+1).equals((String)lst.get(0))) {
                       countA++;

                    }else if (S.substring(i,i+1).equals((String)lst.get(1))) {
                        countB++;
                    }


                }

                if(countA==countB&&countA==2){
                    flag=true;
                }else{
                    flag=false;
                }

            }



        }

        if(flag){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }



    }
}



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

using namespace std;

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

int main(){
  const int INF = 1 << 24;
  int n, m;
  cin >> n >> m;
  vector<int> v(1 << n, INF);
  REP(i, m){
    int a, b;
    cin >> a >> b;
    int p = 0;
    REP(j, b){
      int k;
      cin >> k;
      --k;
      p |= 1 << k;
    }
    v[p] = min(v[p], a);
  }
  vector<int> dp(1 << n, INF);
  dp[0] = 0;
  REP(i, 1 << n){
    REP(j, 1 << n){
      dp[i | j] = min(dp[i | j], dp[i] + v[j]);
    }
  }
  if(dp[(1 << n) - 1] >= INF){
    cout << -1 << endl;
  }else{
    cout << dp[(1 << n) - 1] << endl;
  }
  return 0;
}

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

int main() {
  int A,B;
  cin >> A >> B;
  
  if(A % 2 != B % 2){
 cout << "IMPOSSIBLE" << endl;
  }
  
  else{
    cout << (A + B) / 2 << endl;
  }
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll N,ans;
  vl a;
  cin >> N;
  REP(i,N){
		int x;
		cin >> x;
		a.push_back(x);
	}
  ans =0;
  REP(i,N-1){
    if(a[i]==a[i+1]){
      a[i+1] = N+i;
      ans = ans+1;
    }
  }
  cout << ans<< endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i=0;
    char a[100002];
    scanf("%s", a);

    while(a[i]!='\0'){
        if(i%2==0){
            printf("%c", a[i]);
        }
        i+=1;

    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
constexpr int MOD{1000000000 + 7};
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr array<int, 4> dx = {1, 0, -1, 0};
constexpr array<int, 4> dy = {0, 1, 0, -1};

struct Key
{
    int _value;
    bitset<12> _unlock;
};

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

    int n, m;
    cin >> n >> m;
    vector<Key> keys(m);
    for (auto &&key : keys)
    {
        int a, b;
        cin >> a >> b;
        bitset<12> c;
        for (int i = 0; i < b; i++)
        {
            int tmp;
            cin >> tmp;
            c.set(tmp - 1);
        }
        key._value = a;
        key._unlock = c;
    }

    vector<vector<int>> dp(m + 1, vector<int>(1 << n, MOD));
    dp[0][0] = 0;

    for (int i = 0; i < m; i++)
    {
        dp[i + 1] = dp[i];
        for (int j = 0; j < 1 << n; j++)
        {
            int idx = j | keys[i]._unlock.to_ullong();
            dp[i + 1][idx] = min(dp[i + 1][idx], dp[i][j] + keys[i]._value);
        }
    }

    cout << (dp[m][(1 << n) - 1] != MOD ? dp[m][(1 << n) - 1] : -1) << endl;
}


Measured memory_bytes: 32384
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
    int N, A;
    int alice, bob;
    cin >> N;

    vector< int > a(N);

    alice = 0;
    bob = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    sort(a.begin(), a.end(), greater< int >());

    bool flag = true;
    for (int i = 0; i < N; i++) {
        // cout << a[i] << " ";
        if (flag) {
            flag = false;
            alice += a[i];
        } else {
            flag = true;
            bob += a[i];
        }
    }

    cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	char s[10];
	int i,max=0,cnt=0;
	scanf("%s",s);
	for(i=0;s[i]!='\0';i++){
		if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
			cnt++;
		}
		else{
			cnt=0;
		}
		max=max<cnt?cnt:max;
	}
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 1728
import java.io.*;
 
 
class Main{
  public static void main(String[] args)throws IOException{
     
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
 
    String[] strAry = str.split(" ");
     
    int x = Integer.parseInt(strAry[0]);
    int y = Integer.parseInt(strAry[1]);
 
    System.out.println(x*y +" "+ 2*(x+y));
  }
}

Measured memory_bytes: 24312
n=int(input())
N=[n]
import collections
def prime_factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n //= 2
  f = 3
  while f * f <= n:
    if n % f == 0:
      a.append(f)
      n //= f
    else:
      f += 2
  if n != 1:
    a.append(n)
  return a
t=prime_factorize(n-1) # n-1の素因数
c = collections.Counter(t)
w=1
for i in c.values():
  w *= 1+i
w-=1
#print(w)
# wはn-1の約数の個数（1以外）

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0 and i!=1:
      divisors.append(i)
      if i != n // i and n//i!=1:
        divisors.append(n//i)
  return divisors
t=make_divisors(n)+[n]

for i in t:
  n=N[0]
  while n%i==0:
    n//=i
  if n%i==1:
    w+=1
print(w)

Measured memory_bytes: 3700
import math
n,k = map(int, input().split())
mod = 10**9 + 7
ans = 0

for i in range(k, n+2):
    max = (i*(n + n-i+1))//2
    min = (i*(i-1))//2
    ans += max - min + 1
    ans %= mod
    
print(ans)

Measured memory_bytes: 9192
import java.util.*;

public class Main {

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

        int[] a = new int[n + 1];
        for (int i = 0; i < n + 1; i++) {
            a[i] = sc.nextInt();
        }

        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }

        long sum = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] >= b[i]) {
                sum += b[i];
                b[i] = 0;
            } else {
                sum += a[i];
                b[i] -= a[i];
            }

            if (b[i] > 0) {
                if (a[i + 1] >= b[i]) {
                    sum += b[i];
                    a[i + 1] -= b[i];
                } else {
                    sum += a[i + 1];
                    a[i + 1] = 0;
                }
            }
        }
        System.out.print(sum);
    }
}

Measured memory_bytes: 63560
from collections import deque
import sys
input = sys.stdin.readline

N = int(input())
A = [deque([int(i)-1 for i in input().split()]) for _ in range(N)]

def solve() :
    q = list(range(N))
    count = 0
    ret = 0
    while count != N * (N - 1) :
        if len(q) == 0 :
            return -1
        
        schedule = set()
        for i in q :
            j = A[i][0]
            if i in schedule or j in schedule :
                continue
                
            if i == A[j][0] :
                schedule.add(i)
                schedule.add(j)
                
        ret += 1
        q = []
        for i in schedule :
            A[i].popleft()
            if len(A[i]) > 0 :
                q.append(i)
        count += len(schedule)
        
    return ret
    
print(solve())


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

int N, A[200005], freq[1000005];
bool isPossible(int currIdx)
{
	int currNum = A[currIdx];
	for(int i = 2; i * i <= currNum; i++)
	{
		if(currNum % i == 0)
		{
			if(freq[i] > 0 || freq[currNum / i] > 0)
				return false;
		}
	}
	
	if(freq[currNum] > 1)
		return false;
		
	if(currNum != 1 && freq[1] > 0)
		return false;
		
	return true;
}

int main()
{
	scanf("%d", &N);
	
	for(int i = 1; i <= N; i++)
	{
		scanf("%d", &A[i]);
		freq[A[i]]++;
	}
	
	int ans = 0;
	for(int i = 1; i <= N; i++)
	{
		if(isPossible(i))
			ans++;
	}
	
	printf("%d", ans);
}


Measured memory_bytes: 8316
// AGC022
// C - Remainder Game

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

const int MAX_N = 50;

int N;
int a[MAX_N], b[MAX_N];

bool can(ll pat) {
    bool g[MAX_N + 1][MAX_N + 1];
    memset(g, 0, sizeof(g));

    for (int i = 0; i < MAX_N; i++) {
        g[i][i] = true;
    }
    for (int i = 1; i <= MAX_N; i++) {
        if ((pat >> (i - 1)) & 1) {
            for (int j = 0; j <= MAX_N; j++) {
                g[j][j % i] = true;
            }
        }
    }

    for (int k = 0; k <= MAX_N; k++) {
        for (int i = 0; i <= MAX_N; i++) {
            for (int j = 0; j <= MAX_N; j++) {
                g[i][j] = g[i][j] || (g[i][k] && g[k][j]);
            }
        }
    }

    for (int i = 0; i < N; i++) {
        if (!g[a[i]][b[i]]) {
            return false;
        }
    }
    return true;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> b[i];
    }

    ll ans = 0;
    for (int i = MAX_N; i >= 0; i--) {
        ll b = ((1LL << i) - 1) | ans;
        if (!can(b)) {
            if (i == MAX_N) {
                cout << -1 << endl;
                return 0;
            }
            ans |= (1LL << i);
        }
    }

    ans <<= 1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
import math


def koch(p1, p2):
    d = ((p2[0] - p1[0]) / 3, (p2[1] - p1[1]) / 3)
    s = (p1[0] + d[0], p1[1] + d[1])
    t = (p1[0] + d[0] * 2, p1[1] + d[1] * 2)
    u = (
        s[0] + (1 / 2) * d[0] - (math.sqrt(3) / 2) * d[1],
        s[1] + (math.sqrt(3) / 2) * d[0] + (1 / 2) * d[1]
    )
    return [p1, s, u, t]


ps = [(0, 0), (100, 0)]
n = int(sys.stdin.readline())
for _ in range(n):
    points = []
    for i in range(len(ps) - 1):
        points += koch(ps[i], ps[i + 1])
    points += [ps[-1]]
    ps = points

for p in ps:
    print(' '.join('{0:.8f}'.format(x) for x in p))



Measured memory_bytes: 6252
l, r = map(int,input().split())

ans = 2019

for i in range(l,r):
	for j in range(i+1,r+1):
		temp = (i*j)%2019
		#print("{} {}".format(i,j))
		if ans > temp:
			ans = temp
			if ans == 0:
				print(ans)
				exit()
if ans == 2019:
	ans = l*r
print(ans)



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

typedef long long ll;

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

    int n; cin >> n;
    set<ll> st;
    for(int i=0;i<n;i++){
        ll a;
        cin >> a;
        if(st.count(a)==0) st.insert(a);
        else st.erase(a);
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 4992
h,n=map(int,input().split())
a=[]
b=[]
for i in range(n):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)

cost=[float("inf")]*(h+1)
cost[0]=0
for i in range(1,h+1):
    for j in range(0,n):
        cost[i]=min(cost[i],cost[max(i-a[j],0)]+b[j])

print(cost[-1])

Measured memory_bytes: 42476
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    String   in_number_str;
    int      in_N;
    int      in_K;
    int[]    in_A;

    int   cnt;
    int   ans;
    int[] kind_num;
    int   kind_total;

    try
    {
      in_stream    = new BufferedReader(new InputStreamReader(System.in));
      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");

      in_N          = Integer.parseInt(in_str_split[0]);
      in_K          = Integer.parseInt(in_str_split[1]);

      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");

      in_A = new int[in_N];
      for(cnt=0; cnt<in_N; cnt++)
      {
        in_A[cnt] = Integer.parseInt(in_str_split[cnt]);
      }


      if(in_K < in_N)
      {
        kind_num = new int[in_N];
        for(cnt=0; cnt<in_N; cnt++)
        {
          kind_num[cnt] = 0;
        }

        for(cnt=0; cnt<in_N; cnt++)
        {
          kind_num[in_A[cnt]-1]++;
        }

        Arrays.sort(kind_num);

        ans        = 0;
        kind_total = in_N;
        for(cnt=0; cnt<in_N; cnt++)
        {
          ans += kind_num[cnt];
          kind_total--;
          if(kind_total <= in_K)
          {
            break;
          }
        }
      }
      else
      {
        ans = 0;
      }

      UtilLog.ans_ln("" + ans);
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}

class UtilLog
{
  private static boolean is_debug_mode = false;



  public static void ans_ln
  (
    String i_message
  )
  {
    System.out.println(i_message);
  }



  public static void ans_f
  (
    String i_message
  )
  {
    System.out.printf(i_message);
  }



  public static void inf_ln
  (
    String i_message
  )
  {
    StackTraceElement[] stack;


    if(is_debug_mode)
    {
    stack = new Throwable().getStackTrace();

    System.out.println
      (
        String.format
          (
            "[inf][%s:%s():%5d]",
            stack[1].getClassName(),
            stack[1].getMethodName(),
            stack[1].getLineNumber(),
            i_message
          )
      );
    }
  }
}


Measured memory_bytes: 48220
#include <vector>
#include <iostream>
#include <algorithm>
#define INF (1LL << 60)
using namespace std;
int n, u[3], mode, tar; long long d, x[30], y[30], ret, seg[33554432], val[14348907]; pair<long long, long long> t[2][14348907];
inline void rec(int pos, long long a, long long b) {
	if (pos == tar) {
		if (b <= 0) t[mode][u[mode]++] = make_pair(a, b);
		return;
	}
	rec(pos + 1, a + x[pos], b + y[pos]);
	rec(pos + 1, a - x[pos], b - y[pos]);
	rec(pos + 1, a, b);
}
inline long long query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) return INF;
	if (a <= l && r <= b) return seg[k];
	long long lch = query(a, b, 2 * k, l, (l + r) / 2);
	long long rch = query(a, b, 2 * k + 1, (l + r) / 2, r);
	return min(lch, rch);
}
int main() {
	scanf("%d%lld", &n, &d);
	for (int i = 0; i < n; i++) scanf("%lld%lld", &x[i], &y[i]);
	mode = 0; tar = n / 2; rec(0, 0, 0);
	mode = 1; tar = n; rec(n / 2, 0, 0);
	sort(t[1], t[1] + u[1]);
	for (u[2] = 1; u[2] <= u[1]; u[2] <<= 1);
	for (int i = 0; i < u[1]; i++) val[i] = t[1][i].first;
	for (int i = 0; i < u[1]; i++) seg[i + u[2]] = t[1][i].second;
	for (int i = u[2]; i >= 1; i--) seg[i] = min(seg[2 * i], seg[2 * i + 1]);
	for (int i = 0; i < u[0]; i++) {
		int pl = lower_bound(val, val + u[1], -t[0][i].first - d) - val;
		int pr = upper_bound(val, val + u[1], -t[0][i].first + d) - val;
		long long res = query(pl, pr, 1, 0, u[2]);
		ret = max(ret, -t[0][i].second - res);
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 405020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, k; ll now = 1;
int dig(ll x) {
	return x ? dig(x / 10) + x % 10 : 0;
}
int main() {
	scanf("%d", &k);
	while (k--) {
		printf("%lld\n", now);
		ll tmp = 1;
		while (dig(now + tmp * 10) * (now + tmp) > dig(now + tmp) * (now + tmp * 10)) tmp *= 10;
		now += tmp;
	}
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int d,i,S;

    while(scanf("%d",&d)!=EOF){
        S=0;
        for(i=1;i<600/d;i++){
            S+=d*i*d*i*d;
        }
        printf("%d\n",S);
    }
    return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

bool is_prime(int N) {
  for (int p = 2; p * p <= N; p++) {
    if (N % p == 0) return false;
  }
  return true;
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    int M = N;
    while (!is_prime(M)) ++M;
    cout << M << endl;
  }
  return 0;
}


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

using namespace std;

int main() {
	int n, h[111];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> h[i];
	for (int i = 0;; i++) {
		int j = 0;
		while (j < n && !h[j]) j++;
		if (j == n) {
			cout << i << endl;
			return 0;
		}
		while (j < n&&h[j])
			h[j++]--;
	}
}


Measured memory_bytes: 256
n, m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
r = any([r[j:j+m] for r in a[i:i+m]]==b for i in range(n-m+1) for j in range(n-m+1))
print('Yes' if r else 'No')

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

int main()
{
	int64_t n;
	cin >> n;
	vector<int64_t> ls(n);
	for (auto &&l : ls)
	{
		cin >> l;
	}

	sort(ls.begin(), ls.end());

	int64_t ans = 0;

	for (int64_t i = 0; i < n; i++)
	{
		for (int64_t j = i + 1; j < n; j++)
		{
			ans += distance(ls.begin() + j, lower_bound(ls.begin(), ls.end(), ls[i] + ls[j])) - 1;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char a[4];
	scanf("%s",a);
	bool flag=1;
	for(int i=0;i<3;i++)
	{
		if(a[i]==a[i+1])
		{
			flag=0;
			break;
		}
	}
	if(flag)
	{
		printf("Good\n");
	}
	else
	{
		printf("Bad\n");
	}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
 
ll MOD = 1000000007;
ll INF =1<<29;

int main() {
     int n,k,q;
     cin >> n >> k >> q;
     vector<int> a(q);
     rep(i,q) cin >> a[i];
     vector<int> A(n+1,k-q);
     rep(i,q){
         A[a[i]]++;
     }
     for(int i = 1;i<=n;++i){
         if(A[i]>0){
              cout << "Yes" <<endl;

         }
         else cout << "No" <<endl;
     }
}

Measured memory_bytes: 1408
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

const long long MOD = 1000000007;

const LL INF = 10e15;
void solve(long long N){
    VI a(N+1);
    REP(i, N+1)a[i]=0;
    for(int i=1; i<=N; i++){
        LL v = i;
        for(LL j = 2; j <= v; j++){
            while(v%j==0){
                v=v/j; a[j]++;
            }
        }
    }
    // REP(i,N+1)debug(a[i]);
    LL ans=1;
    REP(i, N+1){
        if(a[i]!=0)ans = ans*(a[i]+1)%MOD;

    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int main()
{
	int N = 0;
	int a = 0, i = 0;

	std::vector<int> A;

	std::cin >> N;
	while (std::cin >> a)
	{
		A.push_back(a);
		i++;
		if (i == N) break;
	}
	
	std::vector<int> ans(N);
	for (int j = 0; j < N; j++)
	{
		ans[A[j] - 1] = j + 1;
	}

	for (int j = 0; j < N; j++)
	{
		std::cout << ans[j] << " ";
	}
	
	return 0;
}

Measured memory_bytes: 1784
using System;
using System.Collections.Generic;

namespace ABC142_B
{
    class Program
    {
        static void Main(string[] args) {
            string[] input = Console.ReadLine().Split();
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);

            input = Console.ReadLine().Split();
            var list = new List<int>();
            int ans = 0;
            for(int i = 0; i < n; i++) {
                list.Add(int.Parse(input[i]));
                if (list[i] >= k) ans++;
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 18656
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(;;){
			int n=sc.nextInt();
			int m=sc.nextInt();
			if((n|m)==0){
				break;
			}
			class R{
				int id, count;
			}
			R[] rs=new R[m];
			for(int i=0; i<m; i++){
				rs[i]=new R();
				rs[i].id=i+1;
			}
			for(int j=0; j<n; j++){
				for(int i=0; i<m; i++){
					rs[i].count+=sc.nextInt();
				}
			}
			Arrays.sort(rs, new Comparator<R>(){
				@Override
				public int compare(R r1, R r2){
					if(r1.count!=r2.count){
						return r2.count-r1.count;
					}else{
						return r1.id-r2.id;
					}
				}
			});
			for(int i=0; i<m; i++){
				print(rs[i].id+(i==m-1?"\n":" "));
			}
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pi(n,m) n.insert(n.begin(),m);
#define ee(n) n.erase(n.end()-1)
#define eb(n) n.erase(n.begin())
#define check(n) reverse(all(n));rep(z,0,n.size())cout<<n[z];co("");reverse(all(n));
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int n,m,c=0,ans=0;
  bool f=true;
  cin>>n>>m;
  vector<string> s(n);
  rep(i,0,n) cin>>s[i];
  int x[n][m],y[n][m];
  rep(i,0,n){
    rep(j,0,m){
      x[i][j]=0;
      y[i][j]=0;
    }
  }
  
  rep(i,0,n){
    rep(j,0,m){
      if(s[i][j]=='#'){
        c=0;
        continue;
      }
      c++;
      x[i][j]=c;
    }
    c=0;
  }
  rep(i,0,m){
    rep(j,0,n){
      if(s[j][i]=='#'){
        c=0;
        continue;
      }
      c++;
      y[j][i]=c;
    }
    c=0;
  }
  int a=0;
  rep(i,0,n){
    rep(j,0,m){
      if(a==0) a=x[i][m-j-1];
      else if(x[i][m-j-1]!=0) x[i][m-j-1]=a;
      else a=0;
    }
    a=0;
  }
  a=0;
  rep(i,0,m){
    rep(j,0,n){
      if(a==0) a=y[n-j-1][i];
      else if(y[n-j-1][i]!=0) y[n-j-1][i]=a;
      else a=0;
    }
    a=0;
  }
  rep(i,0,n) rep(j,0,m) x[i][j]+=y[i][j];

  rep(i,0,n) rep(j,0,m) ans=max(ans,x[i][j]);
  co(ans-1);
  
  return 0;
}

Measured memory_bytes: 35584
#include <stdio.h>
#include <algorithm>

void trace(int a[], int size) {
    for (int i = 0; i < size; ++i) {
        if (i > 0) {
            printf(" ");
        }
        printf("%d", a[i]);
    }
    printf("\n");
}

void BubbleSort(int A[], int N) {
    int count  = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = N - 1; j > i; --j) {
            if ( A[j] < A[j-1] ){
                std::swap(A[j], A[j-1]);
                ++count;
            }
        }
    }

    trace(A, N);
    printf("%d\n", count);
}

int main() {
    int N;
    int A[100];

    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    BubbleSort(A, N);
    return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n;
  cin >> n;

  vector<int> a(n+5);
  reps(i, 1, n) {
    cin >> a[i];
  }

  vector<bool> exist(n+5, false);
  int cnt = 0;
  int now = 1;
  while (true) {
    if (now == 2) {
      cout << cnt << "\n";
      return 0;
    }

    if (exist[now]) {
      cout << -1 << "\n";
      return 0;
    }

    exist[now] = true;
    now = a[now];
    ++cnt;
  }

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

int64_t gcd(int64_t a, int64_t b) {
    int64_t c;
    while (a) {
        c = a;
        a = b % a;
        b = c;
    }
    return b;
}

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

int main() {
    i64 A, B;
    cin >> A >> B;
    cout << lcm(A, B) << endl;
    return 0;
}



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

int main() {
  string S;
  int N;

  cin >> N;
  cin >> S;

  int K = N / 2;
  if (N % 2 ==0 && S.substr(0, K) == S.substr(K, K)) {
    cout << "Yes" << '\n';
  }
  else{
    cout << "No" << '\n';
  }
  return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
ans = 'APPROVED'
for i in range (N):
  if A[i]%2 == 0:
    if A[i]%3 != 0 and A[i]% 5 != 0:
      ans = 'DENIED'
      break
print(ans)

Measured memory_bytes: 2940
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ld r;
    cin >> r;
    ld pi = 3.1415926535;
    cout << fixed << setprecision(10) << r * 2.0 * pi << endl;
}

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

using ll = long long;
using Pi = pair < int, int >;
using Ti = pair < Pi , int >;

constexpr int INF = (1 << 30) - 1;
constexpr int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
constexpr int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

template < typename T > T gcd(T a, T b) { return ( b ? gcd(b, a % b) : a ); }
template < typename T > T lcm(T a, T b) { return ( a / gcd(a, b) * b ); }

int main()
{
	const int offset = 8500;
	string S;
	int x, y;
	vector < int > yoko, tate;

	bitset < 17000 > bp1, bp2;
	
	cin >> S >> x >> y;
	
	bool f = false;
	int cnt = 0;
	for ( int i = 0; i < S.size(); i++ ) {
		if ( S[i] == 'F' ) {
			cnt++;
		} else {
			if ( f ) tate.push_back(cnt);
			else     yoko.push_back(cnt);
			cnt = 0;
			f = !f;
		}
	}

	if ( f ) tate.push_back(cnt);
	else yoko.push_back(cnt);
	
	bp1[offset + yoko[0]] = true;
	bp2[offset] = true;

	for ( int i = 1; i < yoko.size(); i++ ) {
		bp1 = (bp1 << yoko[i]) | (bp1 >> yoko[i]);
	}

	for ( int i = 0; i < tate.size(); i++ ) {
		bp2 = (bp2 << tate[i]) | (bp2 >> tate[i]);
	}

	if ( bp1[offset + x] && bp2[offset + y] ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return ( 0 );
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int a, b, sum = 0, q = 0, num = 0;
  while(scanf("%d,%d", &a, &b) != EOF) {
    sum += a * b;
    q++;
    num += b;
  }
  double ave = (double)num / (double)q;
  if(ave - (int)ave >= 0.5) ++ave;
  printf("%d\n%d\n", sum, (int)ave);
  return 0;
}


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

import io
import sys
import math

def format_multi_line_answer(lst):
    ans = ""
    ans += f"{len(lst)}\n"  # Line count
    for y in lst:
        ans += f"{y}\n"
    return ans

def solve():
    # implement process
    pass

def main():
    # input
    n,l = map(int, input().split())
    a_lst = sys.stdin.read().split()
        
    # process
    a_lst.sort()
    ans = "".join(a_lst)
    
    # output
    print(ans)
    return ans
        
### DEBUG I/O ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
3 3
dxx
axx
cxx
"""


_EXPECTED = """\
axxcxxdxx
"""

def logd(str):
    """usage:
    if _DEB: logd(f"{str}")
    """
    if _DEB: print(f"[deb] {str}")

### MAIN ###
if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

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

long long a[210];
char s[210];

long long bit[70];

void insert(long long x) {
	for (int i = 0; i < 60; i++) {
		if (x >> i & 1) {
			if (!bit[i]) {
				bit[i] = x;
				return ;
			}
			x ^= bit[i];
		}
	}
}

bool check(long long x) {
	for (int i = 0; i < 60; i++) {
		if (x >> i & 1) {
			x ^= bit[i];
		}
	}
	return x == 0;
}

int main () {
	int T; scanf("%d", &T);
	while (T--) {
		int n; scanf("%d", &n);
		for (int i = 0; i < n; i++) {
			scanf("%lld", &a[i]);
		}
		scanf("%s", s);
		memset(bit, 0, sizeof(bit));
		for (int i = n - 1; i >= 0; i--) {
			if (s[i] == '0') insert(a[i]);
			else {
				if (!check(a[i])) {
					printf("1\n");
					goto END;
				}
			}
		}
		printf("0\n");
		END:;
	}
	return 0;
}


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

using namespace std;
using ll=int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi=vector<int>;
using vii=vector<vi>;
using vl=vector<ll>;
using vll=vector<vl>;
using tpi=tuple<int, int, int>;

using vqi=vector<queue<int>>;

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

    int ans = 0;
    for (int i = 0; i < S.size() / 2; i++) {
        if (S[i] != S[S.size() - 1 - i]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, a, b, c, d;

int main(){
	cin >> n;
	a = n/1000%10;
	b = n/100%10;
	c = n/10%10;
	d = n%10;
	if(a+b+c+d==7){
		cout << a << "+" << b << "+" << c << "+" << d << "=7" <<  endl;
		return 0;
	}
	if(a+b+c-d==7){
		cout << a << "+" << b << "+" << c << "-" << d << "=7" <<  endl;
		return 0;
	}
	if(a+b-c+d==7){
		cout << a << "+" << b << "-" << c << "+" << d << "=7" <<  endl;
		return 0;
	}
	if(a+b-c-d==7){
		cout << a << "+" << b << "-" << c << "-" << d << "=7" <<  endl;
		return 0;
	}
	if(a-b+c-d==7){
		cout << a << "-" << b << "+" << c << "-" << d << "=7" <<  endl;
		return 0;
	}
	if(a-b-c+d==7){
		cout << a << "-" << b << "-" << c << "+" << d << "=7" <<  endl;
		return 0;
	}
	if(a-b-c-d==7){
		cout << a << "-" << b << "-" << c << "-" << d << "=7" <<  endl;
		return 0;
	}
	if(a-b+c+d==7){
		cout << a << "-" << b << "+" << c << "+" << d << "=7" <<  endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
/*
止まる駅はMlogMなので愚直にやっても間に合う？
駅の種類をいい感じに数えられない気がする
*/
/*
区間を短い順でsort
dを1から順番に見て行く
dでは現在の区間ストックの個数を足した後BITに入ってるものを各dの倍数で見る
dが上がるたびに区間長がd未満のものをBITに入れてあげる
*/
int N=1;

int bit0[1000000],bit1[1000000];
int sum(int *b,int i){
  int res=0;
  while(i){
    res+=b[i];
    i-=i&-i;
  }
  return res;
}
void add(int *b,int i,int v){
  while(i<=N){
    b[i]+=v;
    i+=i&-i;
  }
}
//main
signed main(){

  int n,m;cin>>n>>m;
  while(m>N)N*=2;
  memset(bit0,0,sizeof(bit0));
  memset(bit1,0,sizeof(bit1));
  std::vector<int> l(n),r(n);
  for(int i=0;i<n;i++)cin>>l[i]>>r[i];
  typedef pair<int,int> P;
  priority_queue<P,vector<P>,greater<P>> que;
  for(int i=0;i<n;i++)que.push(P(r[i]-l[i]+1,i));
  for(int d=1;d<=m;d++){
    while(que.size()&&que.top().first<d){
      P p=que.top();que.pop();
      int ql=l[p.second],qr=r[p.second];
      add(bit0,ql,-1*(ql-1));
      add(bit1,ql,1);
      add(bit0,qr+1,qr);
      add(bit1,qr+1,-1);
    }
    int res=que.size();
    for(int i=d;i<=m;i+=d){
      res+=sum(bit0,i)+sum(bit1,i)*i;
      res-=sum(bit0,i-1)+sum(bit1,i-1)*(i-1);
    }
    cout<<res<<endl;
  }
}
/*
解説AC
区間がd以上だと絶対に入る
逆に区間がd未満だと二つにまたがることはない
この二つの特徴に気付けるかどうかって感じなのかな
綺麗な問題で好き
*/


Measured memory_bytes: 30700
#coding:utf-8
'''
S、あるいはTに含まれる文字Xを一つとってきたときに、
Xが配置されている場所群が、SとTとで同じであればYes、そうでなければNoと出力すればよい。
'''

S = input()
T = input()

S_dict = {}
for i,s in enumerate(S):
    if s not in S_dict:
        S_dict[s] = i

T_dict = {}
for i,t in enumerate(T):
    if t not in T_dict:
        T_dict[t] = i

for s, t in zip(S, T):
    if S_dict[s] == T_dict[t]:
        pass
    else:
        print('No')
        break
else:
    print('Yes')
    
    


Measured memory_bytes: 3760
s=input()
k=int(input())

words=[]
for i in range(len(s)):words.append(s[i:])
words.sort()

record=[]
for i in words:
    for j in range(len(i)):
        word="".join(i[:j+1])
        if word not in record:
            record.append(word)
    if len(record)>=k:
        print(record[k-1])
        exit()

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

int n;
int main ()
{
    cin >> n;
    int t = n,c = 0;

    while(t > 0){
        c += t % 10, t /= 10;
    }
    
    if(n % c == 0){
        puts("Yes");
    }else{
        puts("No");
    }
}


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

int main(){
  int W,a,b,dis;
  cin >> W >> a >> b;
  dis = abs(a-b);
  
  if(W >= dis){
    cout << 0 << endl;
  }
  else{
    cout << dis - W << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#include <algorithm>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

using namespace std;
typedef long long ll;
int main()
{
    int n;
	cin >> n;
    vector<int> vec(n);
	rep(i,n) cin >> vec.at(i);
    bool is_even = false;
    bool flg = true;
    //偶数なし
    rep(i,n){
      if(vec.at(i) % 2 == 0){
        is_even = true;
        if(vec.at(i) % 3 != 0 && vec.at(i) % 5 != 0){
          flg = false;
        }          
      }
    }      

	if(!is_even || flg) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a = 0;
    int b = 0;
    int c = 0;
    scanf("%d %d %d", &a, &b, &c);
    
    if(a < b &&  b < c){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 580
#include<stdio.h>
#include<string.h>


int get_gcd(int x, int y){
    int r = 0;
    while ((r = x % y ) != 0){
        x = y;
        y = r;
    }
    return y;
}

int main(){

    int a, b, r= 0;
    int gcd, lcm = 0;

    while ( (fscanf(stdin, "%d %d", &a, &b)) != EOF){

        // ?????§??¬?´???°
        gcd = get_gcd(a, b);

        // ????°???¬?????°
        lcm =  b / gcd;
        lcm *= a;

        printf("%d %d\n", gcd, lcm);
    }

    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>
#include <bitset>
#include <fstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

#define INF 1000000007ll
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define err(x) cerr << #x << " = " << x << endl;
#define SIZE 3501

int main() {
   ll N, n = -1, h = -1, w = -1;
   cin >> N;
   for (ll i = 1 ; i < SIZE ; ++i) {
      for (ll j = 1 ; j < SIZE ; ++j) {
         ll nr = (N * i * j), dr = 4 * i * j - N * (i + j);
         if (dr <= 0) continue;
         if (nr % dr == 0) {
            h = i;
            w = j;
            n = nr / dr;
            break;
         }
      }
      if (n != -1) break;
   }
   cout << h << " " << w << " " << n << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  double x=0,y=0,d,a,b=90;
  for(;;){
    scanf("%lf,%lf",&d,&a);
    if(d == 0 && a == 0) break;
    x+=d*cos(M_PI*b/180);
    y+=d*sin(M_PI*b/180);
    b-=a;
  }
  cout <<(int)x<<endl<<(int)y<<endl;
  return 0;
}

Measured memory_bytes: 1236
#pragma GCC optimize("Ofast","inline")
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef vector <int> vi;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=100005;
int n;
int a[N],b[N];
LL sa=0,sb=0;
int main(){
	n=read();
	For(i,1,n)
		a[i]=read(),sa+=a[i];
	For(i,1,n)
		b[i]=read(),sb+=b[i];
	LL sc=0;
	For(i,1,n)
		if (a[i]>b[i])
			sc+=a[i]-b[i];
		else if ((b[i]-a[i])%2)
			sc++;
	puts(sb-sa>=sc?"Yes":"No");
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<set>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>

using namespace std;

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

const int MX = 100005;

int K, N;

bool chk(int cur, int K, int off){ // cur^K >= off
	for(int i = 0; i < cur && off; i++) off /= K;
	return off;
}

void dfs(ll off, int lv, int ch)
{
	if( lv <= 0 ){
		return;
	}
	if( ch == 0 && !chk(lv-2, K, off) ){
		printf("%d ", (K+1)/2);
		dfs(off+1, lv-1, 0);
		return;
	}
	ll P = off;
	ll cur = 1, tot = 0, t;
	for(int i = 1; i <= lv; i++) cur *= K, tot += cur;
	t = tot - cur + 1;
	if( ch == 0 ){
		P = (tot + P - 1) / 2 - P;
	}
	for(int i = 1; i <= K; i++){
		if( P >= t ) P -= t;
		else{
			printf("%d ", i);
			if( P == 0 ) return;
			dfs(P - 1, lv-1, 1);
			return;
		}
	}
}

int main()
{
	scanf("%d%d", &K, &N);
	if( K == 1 ){
		for(int i = 1; i <= (N+1)/2; i++) printf("%d ", 1);
		printf("\n");
	}
	else if( K%2 == 0){
		printf("%d ", K/2);
		for(int i = 1; i < N; i++) printf("%d ", K);
		printf("\n");
	}
	else{
		dfs(0, N, 0);
		printf("\n");
	}
}


Measured memory_bytes: 2304