akhauriyash/Code-Regression huggingface dataset:
def integerornot(n):
    if isinstance(n,int):
        return True
    if isinstance(n,float):
        return n.is_integer()
    return False

n = int(input())
k = 1
for i in range(2,int(n**(0.5)+1)):
    if integerornot(n/i):
        k = i
print(k+n//k-2)

Measured memory_bytes: 3064
class Problem
  attr_accessor :a, :b, :n, :s, :ans

  def initialize
    @n = gets.to_s.to_i
    @a = gets.chomp.chars.map { _1 == "(" ? 1 : -1 }
  end

  def solve
    puts ans
  end

  def ans
    @ans ||= (left + a + right).map { _1 == 1 ? "(" : ")" }.join
  end

  def total
    @total ||= a.sum
  end

  def mini
    @mini ||= a.each_with_object([0]) { |v, h| h << h[-1] + v }.min
  end

  def left
    return @left ||= [] if total >= 0 && mini >= 0
    @left ||= [1] * [-total, -mini].max
  end

  def right
    @right ||= [-1] * (left.size + total)
  end
end

pr = Problem.new
pr.solve
# pp pr if ENV["USER"] == "tamura"

Measured memory_bytes: 14308
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int n, m, a[50], b[50];
int v[51][51];

bool warshall() {
	int t[51][51];
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			t[i][j] = v[i][j];
			if (t[i][j] == 0)
				t[i][j] = 100;
		}
	}

	for (int k = 1; k <= n; ++k) {
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= n; ++j) {
				t[i][j] = min(t[i][j], t[i][k] + t[k][j]);
			}
		}
	}

	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			if (t[i][j] == 100)
				return true;
		}
	}
	return false;
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> a[i] >> b[i];
		v[a[i]][b[i]] = 1;
		v[b[i]][a[i]] = 1;
	}

	int ans = 0;
	for (int i = 0; i < m; ++i) {
		v[a[i]][b[i]] = v[b[i]][a[i]] = 0;
		if (warshall())
			ans++;
		v[a[i]][b[i]] = v[b[i]][a[i]] = 1;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from copy import deepcopy
N, K = map(int, input().split())
A = [int(a) for a in input().split()]
Sum = [0]
for i in range(N):
    Sum.append(Sum[-1] + A[i])
Asum = []
for i in range(N):
    for j in range(i+1, N+1):
        Asum.append(Sum[j] - Sum[i])

Search = deepcopy(Asum)
x = 0
for i in reversed(range(1, 41)):
    new = []
    for s in Search:
        if (x + 2 ** (i-1)) & s == x + 2 ** (i-1):
            new.append(s)
    if len(new) >= K:
        Search = new
        x += 2 ** (i-1)
print(x)

Measured memory_bytes: 28312
#include <stdio.h>

int main(void)
{
  	int N, A[100000], B[100000], i, j;
  
  	scanf("%d", &N);
  
  	for(i=0; i<N; i++){
      	scanf("%d", &A[i]);
    }
  
  	/*for(j=1; j<=N; j++){
      	for(i=0; i<N; i++){
      		if(A[i] == j){
          		printf("%d ", i+1);
            }
		}
    }*/
  
  	for(i=0; i<N; i++){
      	//if(A[2]==7) -> B[6] = 3;
  		j = A[i]; //i = 2 -> j = 7;
      
      	B[j-1] = i + 1;
    }
  
  	for(i=0; i<N; i++){
      	printf("%d ", B[i]);
    }
      
  	return 0;
}

Measured memory_bytes: 1536
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <memory>
#include <string>
#include <map>
using namespace std;
#define MAX 33
#define NIL -1

struct Node{
    int prt,id,ls,rs;
};
Node bt[MAX];
int root,n;
void solve(){
   int tmp;
   scanf("%d",&n);
   for(int i=0;i<n;i++) bt[i].prt = NIL ;

   for(int i=0;i<n;i++){
        scanf("%d",&tmp);
        bt[tmp].id = tmp;
        scanf("%d%d",&bt[tmp].ls,&bt[tmp].rs);
        if(bt[tmp].ls!=NIL) bt[bt[tmp].ls].prt = tmp;
        if(bt[tmp].rs!=NIL) bt[bt[tmp].rs].prt = tmp;
   }
   for(int i=0;i<n;i++) if(bt[i].prt!=NIL)continue;else {root = i;break;}

}
void preorder(int id){
    printf(" %d",bt[id].id);
    if(bt[id].ls!=NIL) preorder(bt[id].ls);
    if(bt[id].rs!=NIL) preorder(bt[id].rs);
}
void inorder(int id){

    if(bt[id].ls!=NIL) inorder(bt[id].ls);
    printf(" %d",bt[id].id);
    if(bt[id].rs!=NIL) inorder(bt[id].rs);
}
void postorder(int id){
   if(bt[id].ls!=NIL) postorder(bt[id].ls);
    if(bt[id].rs!=NIL) postorder(bt[id].rs);
    printf(" %d",bt[id].id);
}
void print(){
    printf("Preorder\n");
    preorder(root);
    printf("\nInorder\n");
    inorder(root);
    printf("\nPostorder\n");
    postorder(root);
    putchar('\n');
}
int main(){
   // freopen("in","r",stdin);
    solve();
    print();
    return 0;
}

Measured memory_bytes: 3204
import java.util.*;

public class Main {
	static final int r = 1000000000 + 7;

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt(), w = sc.nextInt();
		String an[] = {"unsafe", "safe"};
		int a = 1;
		if(w >= s)a = 0;
		sc.close();
		System.out.println(an[a]);
	}
}


Measured memory_bytes: 35768
#include <iostream>

using namespace std;

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

	long long int w = a * c;
	long long int x = a * d;
	long long int y = c * b;
	long long int z = d * b;

	long long int p;
	long long int q;

	if (w > x) {
		p = w;
	}
	else p = x;

	if (y > z) {
		q = y;
	}
	else q = z;

	if (p > q) cout << p;
	else cout << q;

	return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

string f(string s) {
    if (s[5] - '0' > 0) {
        return "TBD";
    }
    if (s[6] - '0' > 4) {
        return "TBD";
    }
    return "Heisei";
}

int main() {

    string s;
    cin >> s;

    string result = f(s);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
A=[]
for i in range(H):
  d=list(input())
  A.append(d)
D=[[1000]*W for i in range(H)]
if A[0][0]=='.':
  D[0][0]=0
else:
  D[0][0]=1
cnt=D[0][0]
for i in range(1,W):
  if A[0][i]==A[0][i-1]:
    D[0][i]=D[0][i-1]
  else:
    D[0][i]=D[0][i-1]+1
for i in range(1,H):
  if A[i][0]==A[i-1][0]:
    D[i][0]=D[i-1][0]
  else:
    D[i][0]=D[i-1][0]+1
for i in range(1,H):
  for j in range(1,W):
    if A[i][j]==A[i-1][j]:
      a=D[i-1][j]
    else:
      a=D[i-1][j]+1
      
    if A[i][j]==A[i][j-1]:
      b=D[i][j-1]
    else:
      b=D[i][j-1]+1
    D[i][j]=min(a,b) 
e=D[-1][-1]
if e%2==0:
  print(e//2)
else:
  print((e+1)//2)

Measured memory_bytes: 3316
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**9)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

x = INT()

for i in range(1,10**6+1):
    if i*100<=x<=i*105:
        print(1)
        exit()
print(0)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  string s, t;
  cin >> s >> t;
  
  int n = s.size();
  int i = 0;
  
  while(i < n){
    
    if(s == t)
      break;
    
    if(s != t){
      
      int j = n - 1;
      
      while(j > 0){
        swap(s.at(j - 1), s.at(j));
        j--;
      }
      
      j = n - 1;
      i++;
      
    }
    
  }
  
  if(i == n)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int32_t main()
{
  ll a,b;
  cin>>a>>b;
  if(a>=1&&a<=9&&b>=1&&b<=9)
  {
    cout<<a*b<<endl;
  }
  else
  {
    cout<<-1<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int x,a;
    cin>>x>>a;
    if(x<a) cout<<0<<endl;
    else cout<<10<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;
#define SAY_YES cout<<"YES"<<endl;
#define SAY_Yes cout<<"Yes"<<endl;
#define SAY_NO cout<<"NO"<<endl;
#define SAY_No cout<<"No"<<endl;
#define IFYES(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;} 
#define IFYes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;} 
#define IFyes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"yes"<<endl;}else{cout<<"no"<<endl;} 

const long long int mod=1000000007;
const long long int INF=99999999999999999;




long long int N,M,K,S,P[2000],tmp,res=0;
long double x[200],y[200];
vector<long long int>Q;
int main() {
	cout << fixed << setprecision(18);
    cin>>K>>S;
    for(int i=0;i<=K;i++){
        if(i>S){
            break;
        }
        if(S-i>2*K){continue;}
        res+=K+1-abs(S-i-K);
    }
    
    cout<<res<<endl;
    
} 


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    foreach (a; A)
        if (a % 2 == 0)
        {
            if (a % 3 != 0 && a % 5 != 0)
            {
                writeln("DENIED");
                return;
            }
        }
    writeln("APPROVED");
}


Measured memory_bytes: 256
h,w,k = list(map(int,input().split()))
arr = [[int(i) for i in input()] for _ in range(h)]

from itertools import product
ans = 2000

for idx,cond in enumerate(product((True,False),repeat=h-1)):
    div = sum(cond)
    spl = [arr[0][:]]
    for i in range(h-1):
        if cond[i]:
            spl.append(arr[i+1][:])
        else:
            spl[-1] = [spl[-1][j] + arr[i+1][j] for j in range(w)]
    num = len(spl)
    cnt = [0]*num
    
    for v in range(w):
        tmp = [spl[i][v] for i in range(num)]
        if max(tmp) > k:
            break
        if max([cnt[i] + tmp[i] for i in range(num)]) > k:
            div += 1
            cnt = tmp[:]
        else:
            cnt  = [cnt[i] + tmp[i] for i in range(num)]
    else:    
        ans = min(ans,div)
            
print(ans)

Measured memory_bytes: 53208
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    to = defaultdict(list)
    for _ in range(m):
        s, t = map(int, input().split())
        s, t = s - 1, t - 1
        to[s].append(t)
    ev = [0] * n
    for u in range(n - 2, -1, -1):
        s = 0
        for ku in to[u]:
            s += ev[ku]
        ev[u] = s / len(to[u]) + 1
    ans = ev[0]
    for nu in range(n - 1):
        if len(to[nu]) == 1: continue
        mx = 0
        mv = 0
        for nv in to[nu]:
            if ev[nv] > mx:
                mx = ev[nv]
                mv = nv
        for u in range(nu, -1, -1):
            s = 0
            for ku in to[u]:
                if (u, ku) == (nu, mv): continue
                s += ev[ku]
            od = len(to[u])
            if u == nu: od -= 1
            ev[u] = s / od + 1
        ans = min(ans, ev[0])
    print(ans)

main()


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

int main()
{
  int n;
  cin>>n;
  set<int> hon,bon,pon;
  hon = {2,4,5,7,9};
  bon = {3};
  pon = {0,1,6,8};
  int num = n%10;
  if(hon.count(num)) cout<<"hon"<<endl;
  else if(bon.count(num)) cout<<"bon"<<endl;
	else cout<<"pon"<<endl;
}


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

struct card {
    char mark;
    int number;
};

void BubbleSort (card A[], int n){

    int  flag = 1;

    while (flag){
        flag = 0;
        for (int i = n - 1; i >= 1; i--){
            if(A[i].number < A[i - 1].number){
                swap(A[i],A[i - 1]);
                flag = 1;
            }
        }
    }
}

void SelectionSort (card A[], int n){

    int minj;

    for (int i = 0; i <= n - 1; i++){
        minj = i;
        for (int j = i; j <= n - 1; j++){
            if (A[j].number < A[minj].number){
                minj = j;
            }
        }
        swap(A[i],A[minj]);
    }
}

bool isStable (card A[], card B[], int n){

    int flag = 1;

    for (int i = 0; i < n; i++){
        if (!(A[i].mark == B[i].mark && A[i].number == B[i].number)){
            flag = 0;
        }
    }
    
    if (flag == 1){
        return 1;
    } else {
        return 0;
    }

}

int main(){

    card A[100],B[100],S[100];

    int n;
    cin >> n;

    for (int i = 0; i < n; i++){
        scanf (" %c%d*c",&A[i].mark,&A[i].number);
        B[i] = A[i];
        S[i] = A[i];
    }

    BubbleSort (B, n);
    SelectionSort (S,n);

    for (int i = 0; i < n; i++){
            if (i != n - 1){
                cout << B[i].mark << B[i].number << " ";
            } else {
                cout << B[i].mark << B[i].number << endl;
            }
    }

    cout << "Stable" << endl;

    for (int i = 0; i < n; i++){
            if (i != n - 1){
                cout << S[i].mark << S[i].number << " ";
            } else {
                cout << S[i].mark << S[i].number << endl;
            }
    }

    if (isStable(B, S, n)){
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;

}


Measured memory_bytes: 3232
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	a := getNextInt(scanner)
	b := getNextInt(scanner)
	c := getNextInt(scanner)
	d := getNextInt(scanner)

	cm := Com{}
	cm.init(n + 1)
	ysp48 := b - a + 1
	mod := int64(1e9 + 7)
	dp := makeInts(ysp48+1, n+1)
	dp[0][0] = 1
	for i := 0; i < ysp48; i++ {
		for j := n; j >= 0; j-- {
			dp[i+1][j] += dp[i][j]
			dp[i+1][j] %= mod
			x := cm.invs[c]
			for y := c; y > 0 && j-(a+i)*c >= 0; y-- {
				x *= cm.calc(n-(j-(a+i)*y), (a + i))
				x %= mod
			}

			for k := c; k <= d && j-(a+i)*k >= 0; k++ {
				if k > c {
					x *= cm.invs[k]
					x %= mod
					x *= cm.facs[k-1]
					x %= mod
					x *= cm.calc(n-(j-(a+i)*k), (a + i))
					x %= mod
				}
				dp[i+1][j] += (dp[i][j-(a+i)*k] * x) % mod
				dp[i+1][j] %= mod
			}
		}
	}

	fmt.Println(dp[ysp48][n])
	writer.Flush()
}
func makeInts(h, w int) [][]int64 {
	index := make([][]int64, h, h)
	data := make([]int64, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

// Com ...
type Com struct {
	facs, invs []int64
	mod        int64
}

func (cm *Com) init(n int) {
	cm.facs = make([]int64, n+1)
	cm.invs = make([]int64, n+1)

	cm.facs[0] = 1
	cm.mod = int64(1e9 + 7)
	for i := 1; i <= n; i++ {
		cm.facs[i] = (cm.facs[i-1] * int64(i)) % cm.mod
	}
	cm.invs[n] = cm.inv(cm.facs[n])
	for i := n - 1; i >= 0; i-- {
		cm.invs[i] = cm.invs[i+1] * int64(i+1) % cm.mod
	}
}

func (cm *Com) inv(n int64) int64 {
	var ii [32]int64
	ii[0] = n
	for i := 1; i < 31; i++ {
		ii[i] = (ii[i-1] * ii[i-1]) % cm.mod
	}
	var ans int64
	ans = 1
	m := cm.mod - 2
	for i := 30; i >= 0; i-- {
		for m >= 1<<uint(i) {
			ans = (ans * ii[i]) % cm.mod
			m -= 1 << uint(i)
		}
	}

	return ans
}

func (cm *Com) calc(n, k int) int64 {
	ans := cm.facs[n] * cm.invs[k]
	ans %= cm.mod
	ans = ans * cm.invs[n-k]
	ans %= cm.mod
	return ans
}


Measured memory_bytes: 8704
#include <iostream>
using namespace std;
void swap_(int* a,int* b){
	int temp=*a;*a=*b;*b=temp;
}
int main(){
	int hight[10];
	for(int i=0;i<10;i++) cin >> hight[i];
	for(int i=1;i<=3;i++){
		for(int j=9;j>=i;j--){
			if(hight[j-1]<hight[j]) swap_(&hight[j],&hight[j-1]);
		};};
	for(int i=0;i<3;i++) cout << hight[i] << '\n' ;
}

Measured memory_bytes: 1160
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,a[5],k;
    for(int i=0;i<5;i++){
        cin >>a[i];
    }
    cin>>k;

    {
        if(a[4]-a[0]<=k)cout <<"Yay!"<<endl;
        else cout <<":("<<endl;
    }

    dbg cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

	int  i, j, H, W;

	while (1) {

		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0) {
			break;
		}

		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {

				printf("#");

			}

			printf("\n");

		}

		printf("\n");

	}

	return(0);

}


Measured memory_bytes: 2048
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <bitset>

using namespace std;

typedef bitset<4000010> bs;

bs a;

int main() {
  int n;
  scanf("%d",&n);
  a[0]=1;
  int sum=0;
  for(int i=1;i<=n;i++) {
  	int x;
  	scanf("%d",&x);
  	a|=(a<<x);
  	sum+=x;
  }
  int p=((sum+1)>>1);
  for(int i=p;i<=sum;i++)
    if (a[i]) {
    	printf("%d\n",i);
    	return 0;
	}
  return 0;
}

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

int main (int argc,char **argv)
{
	int a ,n;  
	int i = 0;

	scanf("%d%d",&n,&a);

	
		i = n % 500;
		if (i <= a)
		{
			printf("Yes\n");
		}
		else if(i > a)
		{
			printf("No\n");
		}


}

Measured memory_bytes: 128
A , B , C  = map(int,input().split()) 
tmp = 0

if A > B:
    tmp = A
    A = B
    B = tmp

if B > C:
    tmp = B
    B = C
    C= tmp

if A > B:
    tmp = A
    A = B
    B = tmp

print(A,B,C)


Measured memory_bytes: 5592
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int H, W;
char ans1[505][505], ans2[505][505];

int main(){
  scanf("%d%d", &H, &W);
  for (int i = 0; i < H; i++){
    if (i % 2 == 0){
      for (int j = 0; j < W - 1; j++) ans1[i][j] = '#';
    }else{
      ans1[i][0] = '#';
    }
  }

  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      if (ans1[i][j] == '#'){
        ans2[i][j] = '.';
      }else{
        ans1[i][j] = '.';
        ans2[i][j] = '#';
      }
    }
  }
  
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      char C; cin >> C;
      if (C == '#'){
        ans1[i][j] = '#';
        ans2[i][j] = '#';
      }
    }
  }
  
  for (int i = 0; i < H; i++) printf("%s\n", ans1[i]);
  printf("\n");
  for (int i = 0; i < H; i++) printf("%s\n", ans2[i]);

  return 0;
}


Measured memory_bytes: 1280
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        mut k: usize,
    }

    let mut set = HashSet::new();
    let mut rem = 7;
    for i in 1.. {
        if rem % k == 0 {
            println!("{}", i);
            return;
        } else if set.contains(&rem) {
            println!("-1");
            return;
        }
        set.insert(rem);
        rem = (rem * 10 + 7) % k;
    }

}


Measured memory_bytes: 29692
from sys import stdin


def get_result(data):
    N = data[0][0]
    A = data[1:]
    tmp = set()
    for i in range(int(N)):
        tmp.add(A[i][0])
    return len(tmp)


if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(str, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


Measured memory_bytes: 58452
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    vll num(N, 0);
    REP(i, 0, K) {
        ll d;
        cin >> d;
        REP(j, 0, d) {
            ll a;
            cin >> a;
            num[a - 1]++;
        }
    }
    ll ans = 0;
    REP(i, 0, N) {
        if (num[i] == 0) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define fora(i,a,b) for(int i = a ; i<=b ;i++)
typedef long long ll;
typedef int i;
typedef vector<i>vi;
typedef pair<i,i>pi;
int v[100010];
int dp[100010];
int f(int i){
	if(i < 0) return 1e8;
	if(dp[i]!=-1) return dp[i];
	int &r = dp[i];
	r = min(f(i-1)+abs(v[i]-v[i-1]) , f(i-2)+abs(v[i]-v[i-2]));
	return r;

}

int main(){
	//freopen("in.txt","r",stdin);
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;cin>>n;
	fora(i,0,n){
		cin>>v[i];
	}
	memset(dp, -1,sizeof dp);
	dp[0] = 0;
	dp[1] = abs(v[1]-v[0]);
	cout<<f(n-1)<<"\n";
	
	return 0;
}

Measured memory_bytes: 6708
use std::char;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        c: char
    }
    let a = char::from_u32(c as u32 + 1);
    println!("{}", a.unwrap());
}


Measured memory_bytes: 2164
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define repl(i,n) for(i=0;i<n;++i)

int main() {
	int X;//動物合計数
	int Y;//足合計
	int able=0;//一致するかどうか
	int leg;//足合計
	int i;
	cin >> X >> Y;
	leg = 2 * X;
	rep(i, X+1) {
		if (leg == Y) {
			able = 1;
		}
		leg = leg + 2;
	}
	if (able == 1) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3620
// Xor sum 2
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

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

    int n;
    cin >> n;
    vector<int> a(n);
    VCIN(a);

    int right, left = 0;
    lint xor_sum = 0;
    lint ans = 0;
    for(right=0; right<n; right++){
        ans++;
        if((xor_sum ^ a[right]) == xor_sum + a[right]){
            xor_sum = xor_sum + a[right];
        }else{
            while(true){
                xor_sum = xor_sum ^ a[left++];
                if((xor_sum ^ a[right]) == xor_sum + a[right]){
                    break;
                }
            }
            xor_sum = xor_sum + a[right];
        }

        // cout << "[l-r]: " << left << ' ' << right << " xor: " << xor_sum << endl;
        ans += right - left;
    }
    
    COUT(ans);

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
    int n = 0;
    scanf("%d", &n);
    int a[2000000] = {0};
    int c[10000] = {0};
    int max = 0;
    for (int i = 0; i < n; i++){
        scanf("%d", &a[i]);
        if (a[i] > max) max = a[i];
        c[a[i]]++;
    }
    for (int i = 1; i <= max; i++){
        c[i] += c[i-1];
    }
    int b[2000000] = {0};
    for (int i = n-1; i >= 0; i--){
        b[c[a[i]]-1] = a[i];
        c[a[i]]--;
    }
    for (int i = 0; i < n-1; i++) printf("%d ", b[i]);
    printf("%d\n", b[n-1]);
}


Measured memory_bytes: 18376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

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

  ll n, l;
  cin >> n >> l;
  vector<ll> rope(n);
  for (int i = 0; i < n; i++) cin >> rope[i];

  ll len_rope = 0;
  int cut;
  bool fl = false;
  for (int i = 0; i < n-1; i++) {
    len_rope = rope[i] + rope[i+1];
    if (len_rope >= l) {
      cut = i+1;
      fl = true;
      break;
    }
  }

  if (!fl) {
    cout << "Impossible" << endl;
    return 0;
  }

  cout << "Possible" << endl;
  for (int i = 0; i < cut-1; i++) cout << i+1 << endl;
  for (int i = n-1; i >= cut; i--) cout << i << endl;  
}


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

#define inte long long int
const inte M = 1e9+7;
inte A, AB,ABC, ALL =1;
int main(){
	string str;
	cin >> str;
	for(int i = 0;i<str.size();i++){
	
			if(str[i] == 'A'){
				A+=ALL;
			}else if(str[i] == 'B'){
				AB+=A;
			}else if(str[i] == 'C'){
				ABC+=AB;
			}else{
				ABC = AB + 3*ABC;
				AB = A + 3*AB;
				A = 3*A + ALL;
				ALL *=3;
			}
			A%=M;
			ABC%=M;
			AB%=M;
			ALL%=M;
			
		
	}
	cout<<ABC;

}

Measured memory_bytes: 512
import sys
import itertools

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()
N, M, Q = map(int, input().split())
sum_list = [[0 for _ in range(N)] for _ in range(N)]
for i in range(M):
    L, R = map(int, input().split())
    sum_list[L - 1][R - 1] += 1
for i in range(N):
    sum_list[i] = list(itertools.accumulate(sum_list[i]))
    sum_list[i].append(0)
for i in range(Q):
    p, q = map(int, input().split())
    ans = 0
    for l in range(p - 1, q):
        ans += sum_list[l][q - 1] - sum_list[l][l - 1]
    print(ans)


Measured memory_bytes: 61276
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    let p: Vec<usize> = read_vec();
    let mut count = 0;
    for i in 0..n {
        if p[i] != i+1 {
            count += 1;
        }
    }
    println!("{}", if count <= 2 {"YES"} else {"NO"});
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,A,B,C;cin >> n >> A >> B >> C;
	vector<int> l(n);
	rep(i,n) cin >> l.at(i);
	int ans=1000000000;
	rep(i,(1<<(n<<1))){
		int sum=0,a=0,b=0,c=0;
		rep(j,n){
			if(((i>>(j<<1))&3)==0){
				if(a!=0) sum+=10;
				a+=l.at(j);
			}
			else if(((i>>(j<<1))&3)==1){
				if(b!=0) sum+=10;
				b+=l.at(j);
			}
			else if(((i>>(j<<1))&3)==2){
				if(c!=0) sum+=10;
				c+=l.at(j);
			}
		}
		if(a==0 || b==0 || c==0) continue;
		sum+=abs(A-a)+abs(B-b)+abs(C-c);
		ans=min(ans,sum);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
def insertion(A, n, g):
    global cnt
    for i in range(g, n):
        while i >= g and A[i - g] > A[i]:
            A[i], A[i - g] = A[i - g], A[i]
            i -= g
            cnt += 1

def main():
    global cnt
    cnt = 0
    n = int(raw_input())
    A = [int(raw_input()) for i in range(n)]

    G = list()
    h = 1
    k = 1
    while h <= n:
        G.append(h)
        h = (4 ** k) + (3 * (2 ** (k - 1)) + 1)
        k += 1
    G = G[::-1]

    for i in G:
        insertion(A, n, i)

    print(len(G))
    print(" ".join(map(str, G)))
    print(cnt)
    for j in A: print(j)

main()

Measured memory_bytes: 75572
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}
int last_digit(int n)
{
    int ans = 0;
    while (n != 0)
    {
        ans = n % 10;
        n /= 10;
    }
    return ans;
}
int main()
{
    int n;
    cin >> n;
    int a[n];
    cn(a, n);
    ll res = 0;
    for (int i = 1; i < n; i++)
    {
        if (a[i] < a[i - 1])
        {
            res += abs(a[i] - a[i - 1]);
            a[i] = a[i - 1];
        }
    }
    cout << res;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int main(){ 
  int N;
  cin >> N;
  vector<int> H(N);
  REP(i, N){
    cin >> H[i];
  }
  bool ans = true;
  REPR(i, N-2){
    if(H[i] > H[i+1]) H[i]--;
    if(H[i] > H[i+1]) ans = false;
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,a;
    cin>>n;
    vector<pair<int,int> > v;
    for(int i=0;i<n;i++){
    	cin>>a;
    	v.push_back({a,0});
    }
    for(int i=0;i<n;i++){
    	cin>>a;
    	v.push_back({a,1});
    }
    sort(be(v));
    ll num=0,ans=1;
    n<<=1;
    for(int i=0;i<n;i++){
    	if(v[i].second){
    		if(num<0)ans*=(-num);
    		num++;
    	}
    	else{
    		if(num>0)ans*=num;
    		num--;
    	}
    	ans%=mod;
    }
    cout <<ans<<endl;
    return 0;
}


Measured memory_bytes: 2420
from collections import Counter
n=int(input())
A=list(map(int,input().split()))
C=Counter(A)
cnt2=[]
cnt4=[]
for k,v in C.items():
    if v>=4:
        cnt4.append(k)
    if v>=2:
        cnt2.append(k)
ans=0
if len(cnt4)!=0:
    S_4=max(cnt4)**2
    ans=S_4
if len(cnt2)>=2:
    cnt2=sorted(cnt2,reverse=True)
    S_2=cnt2[0]*cnt2[1]
    ans=max(ans,S_2)
print(ans)

Measured memory_bytes: 18600
#include<bits/stdc++.h>
using namespace std;
long long dp[100001];


long long solve(long long  start,long long n,long long k,long long h[])
{
	if(dp[start]!=-1)
	{
		return dp[start];
	}
	
    if(start==n)
    {
        return 0;
    }
    long long  ans=INT_MAX;
    for(int i=start+1;i<=min(start+k,n);i++)
    { 
	 long long   a=abs(h[start]-h[i])+solve(i,n,k,h);
     ans=min(a,ans);
    
    }
    dp[start]=ans;
    return ans;
}

int main()
{

    long long   n,k;
    cin>>n>>k;
    long long   a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
memset(dp,-1,sizeof(dp));
    cout<<solve(1,n,k,a)<<endl;
}



Measured memory_bytes: 11136
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

const int mod = 998244353;
struct mint
{
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    mint p(int n, int k)
    {
        return fact[n] * ifact[n - k];
    }
} c(1000005);

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<int> l(k), r(k);
    for (int i = 0; i < k; i++)
    {
        cin >> l[i] >> r[i];
    }
    vector<mint> dp(n + 1, 0);
    vector<mint> dpsum(n + 1, 0);
    dp[1] = 1;
    dpsum[1] = 1;
    for (int i = 2; i <= n; i++)
    {
        for (int j = 0; j < k; j++)
        {
            int li = i - r[j], ri = i - l[j];
            if (ri < 0)
                continue;
            li = max(1, li); // 1-indexed
            dp[i] += dpsum[ri] - dpsum[li - 1];
        }
        dpsum[i] = dpsum[i - 1] + dp[i];
    }
    cout << dp[n] << endl;
    return 0;
}
// dp[i]:=iに行く場合の数 dp[1] = 1 求: dp[N] 貰うDP
// 累積和　dpテーブルを構築すると同時に累積和を計算する．


Measured memory_bytes: 21912
import math
a=[]#入力画面の二文字を別々の文字に格納
a=input().split(" ")
N=int(a[0])
K=int(a[1])

q=0
if K<=N:
    for i in range(1,K):
        p=(0.5)**(math.ceil(math.log2(K/i)))
        q=p+q
    x=q/N
    y=(N-K+1)/N
    print(x+y)
elif N<K:
    for i in range(1,N+1):
        p=(0.5)**(math.ceil(math.log2(K/i)))
        q=p+q
    print(q/N)


Measured memory_bytes: 3064
N = int(input())
S = [input() for _ in range(N)]

d = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for s in S:
    d[s] += 1
print('AC x', d['AC'])
print('WA x', d['WA'])
print('TLE x', d['TLE'])
print('RE x', d['RE'])


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

    using namespace std;
    template <typename T>
    void debug(string t, T input) {
        cout<<t<<"-> "<<input<<"\n";
    }
    template <typename T>
    void debug(int i,string t, T input) {
        cout<<"Case#"<<i<<" "<<t<<"-> "<<input<<"\n";
    }

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        string s;
        cin>>s;
        if(s=="ABC")
            cout<<"ARC";
        else
            cout<<"ABC";
        return 0;
    }


Measured memory_bytes: 3576
leng=int(input())
nums=input().split()
x=1

if "0" in nums:
    print(0)
    exit()

for i in range(leng):
    a=int(nums[i])
    x=x*a
    if x>10**18:
        break

if x>10**18:
    print(-1)
else:
    print(x)


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

int a, b, m, A[100010], B[100010], M[100010], ma = 1e9, mb = 1e9;
int main() {
    cin >> a >> b >> m;
    for(int i = 1; i <= a; i++) {
        cin >> A[i];
        if(A[i] < ma) ma = A[i];
    }
    for(int i = 1; i <= b; i++) {
        cin >> B[i];
        if(B[i] < mb) mb = B[i];
    }
    int ans = ma + mb;
    int x, y, z;
    for(int i = 0; i < m; i++) {
        cin >> x >> y >> z;
        if(A[x] + B[y] - z < ans) ans = A[x] + B[y] - z;
    }
    cout << ans;
}

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

long long N, A[1 << 18];

int main() {
	cin >> N;
    long long S = 0;
	for (int i = 1; i <= N; i++){ cin >> A[i]; S += A[i]; }

	long long minx = S, sum = 0;
	for (int i = 1; i <= N; i++) {
		sum += A[i];
		minx = min(minx, abs(sum - (S - sum)));
	}
	cout << minx << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<fstream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<cctype>
#include<cmath>
#include<vector>
#include<climits>
#include<queue>

using namespace std;


int main()
{
    int i,a,flag;
    char s[100];
    scanf("%s",s);
    if(s[0]!='A')
    {
        printf("WA\n");
        return 0;
    }
    a=strlen(s);
    for(i=2,flag=0; i<a-1; i++)
    {
        if(s[i]=='C')
        {
            flag++;
            s[i]='c';
        }
    }
    if(flag!=1)
    {
        printf("WA\n");
        return 0;
    }
    for(i=1; i<a; i++)
    {
        if(s[i]>='A'&&s[i]<='Z')
        {
            printf("WA\n");
            return 0;
        }
    }
    printf("AC\n");
    return 0;
}


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

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

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

constexpr ull mod = 1e9+7;
constexpr int N = 13;
ull dp[100010][N];

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	ll x;
	cin >> x;
	//=======================================
	// 解法2　動的計画法
	// dp[i] を 「i円の買い物ができる->1」、「できない=>0」とする
	// dp[0] は 「0円の買い物ができる」なので1.
	// *　のif文の条件式について
	// 0から入力値xまでを見ていく。
	// ある時点のj番目の自分がtrueの場合、
	// j+100～j+105を足した自分も当然trueになっているはず
	// なぜなら、jの時点で変えるんだから、
	// どの商品を1つ足しても変えるはずという前提条件がある
	// ある時点(j番目)の自分がtrueであり、
	// j+100～j+105の値がxを超えていないならば、
	// その未来の自分(j+100～j+105)の自分をtrueとする作業を行う
	// こうすることで、dpテーブルを作成し、
	// x番目の自分がtrueなのか、falseなのかで
	// 今回の問題は解ける
	//=======================================
	vector<int> tb = {100, 101, 102, 103, 104, 105};
	vector<int> dp(x+1, false);

	dp[0] = true;
	for (int i = 0; i < tb.size(); i++) {
		for (int j = 0; j < x + 1; j++) {
			if (dp[j] && j + tb[i] <= x) { // *
				dp[j + tb[i]] = true;
			}
		}
	}
	if(dp[x]){
		cout << 1 << endl;
	}else{
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 640
while 1:
  a,op,b=map(str,input().split())
  if op=='+':
    print(int(a)+int(b))
  elif op=='-':
    print(int(a)-int(b))
  elif op=='*':
    print(int(a)*int(b))
  elif op=='/':
    print(int(a)//int(b))
  elif op=='?':
    break


Measured memory_bytes: 5592
#include<bits/stdc++.h>
#define P 1000000007
#define ll long long
using namespace std;
int n,k,f[100005],a[100005],ly;
int pw(int x,int y)
{
	int ans=1;
	for (;y;y>>=1,x=(ll)x*x%P)
		if (y&1) ans=(ll)ans*x%P;
	return ans;
}
int main()
{
	scanf("%d%d",&n,&k);
	int Ans=0;
	for (int i=1;i*i<=n;i++)
		if (n%i==0)
		{
			a[++ly]=i;
			if (i*i!=n) a[++ly]=n/i;
		}
	sort(a+1,a+ly+1);
	for (int i=1;i<=ly;i++)
	{
		f[i]=pw(k,(a[i]+1)/2);
		for (int j=1;j<i;j++)
			if (a[i]%a[j]==0) f[i]=(f[i]+P-f[j])%P;
		if (a[i]&1) Ans=(Ans+(ll)f[i]*a[i]%P)%P;
		else Ans=(Ans+(ll)f[i]*(a[i]/2)%P)%P;
	}
	/*
	for (int i=1;i<=n;i++)
	{
		dp[i]=pw(k,(i+1)/2);
		for (int j=1;j<i;j++)
			if (i%j==0) dp[i]=(dp[i]+P-dp[j])%P;
		//cout<<i<<' '<<dp[i]<<' '<<n/i<<endl;
		if (n%i==0)
			if (i&1) Ans=(Ans+(ll)dp[i]*i%P)%P;
			else Ans=(Ans+(ll)dp[i]*(i/2)%P)%P;
	}*/
	printf("%d\n",Ans);
}

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

struct dice{
	int top;
	int front;
	int left;
	int right;
	int back;
	int bottom;
};

void ClockwiseTop(struct dice *X){
	int c = X->front;
	X->front  = X->right;
	X->right  = X->back;
	X->back   = X->left;
	X->left   = c;
}

void ClockwiseFront(struct dice *X){
	int c = X->top;
	X->top    = X->left;
	X->left   = X->bottom;
	X->bottom = X->right;
	X->right  = c;
}

void ClockwiseRight(struct dice *X){
	int c = X->top;
	X->top    = X->front;
	X->front  = X->bottom;
	X->bottom = X->back;
	X->back   = c;
}

int Rotation(struct dice X, int t, int f){
	if(t == X.front ) ClockwiseRight(&X);
	if(t == X.left  ) ClockwiseFront(&X);
	if(t == X.right ) ClockwiseFront(&X), ClockwiseFront(&X), ClockwiseFront(&X);
	if(t == X.back  ) ClockwiseRight(&X), ClockwiseRight(&X), ClockwiseRight(&X);
	if(t == X.bottom) ClockwiseRight(&X), ClockwiseRight(&X);
	if(f == X.left  ) ClockwiseTop(&X), ClockwiseTop(&X), ClockwiseTop(&X);
	if(f == X.right ) ClockwiseTop(&X);
	if(f == X.back  ) ClockwiseTop(&X), ClockwiseTop(&X);
	return X.right;
}

int main(){
	//????????????????????¢?????°????????\?????????
	struct dice X;
	cin >> X.top;
	cin >> X.front;
	cin >> X.right;
	cin >> X.left;
	cin >> X.back;
	cin >> X.bottom;
	//???????????°????????????
	int q;
	cin >> q;
	//??????????????????????????????
	int T[24], F[24], R[24];
	for(int i = 0; i < q; i++) cin >> T[i] >> F[i];
	//?????¢?????????????¨??????????
	for(int i = 0; i < q; i++) R[i] = Rotation(X, T[i], F[i]);
	//?????¢??????????????¨?????????
	for(int i = 0; i < q; i++) cout << R[i] << endl;
	return 0;
}

Measured memory_bytes: 1160