akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main()
{
    int a,b;
    
    cin >> a >> b;
    
    if( a > b )
    {
        cout << "a > b"<<endl;
    }
    else if( a < b )
    {
        cout<< "a < b"<<endl;
    }
    else if( a==b )
    {
        cout << "a == b"<<endl;
    }
}



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

int digit(int C, int d);
int f(int C);

int A, B, j=0;

int main() {
  cin >> A >> B;
  for (A; A<B+1; A++){
    j += f(A);
  }
  cout << j << endl;
}

int digit(int C, int d){
  int x=0, y=1;
  for(int i=0; i<d; i++){
    x = (C%(y*10) -x)/y;
    y *= 10;
  }
  return x;
}

int f(int C){
  bool i;
  if(digit(C, 1) == digit(C, 5) && digit(C, 2) == digit(C, 4)){
    i = 1;
  } else {
    i = 0;
  }
  return i;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>

using namespace std;

class NODE {
public:
	int p=-1, id, left, right;
	NODE(int id) {
		this->id = id;
	}
};

vector<NODE> U;

void Pre(int a) {
	if (a != -1) {
		cout << " " << U[a].id;
		Pre(U[a].left);
		Pre(U[a].right);
	}
}

void In(int a) {
	if (a != -1) {
		In(U[a].left);
		cout << " " << U[a].id;
		In(U[a].right);
	}
}

void Post(int a) {
	if (a != -1) {
		Post(U[a].left);
		Post(U[a].right);
		cout << " " << U[a].id;
	}
}

int main() {
	int n, id, left, right, root=-1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		NODE u(i);
		U.push_back(u);
	}
	for (int i = 0; i < n; i++) {
		cin >> id >> left >> right;
		U[id].left = left; U[id].right = right;
		if (left != -1) U[U[id].left].p = id;
		if (right != -1) U[U[id].right].p = id;
	}
	for (int i = 0; i < n; i++) {
		if (U[i].p == -1) root = i;
	}

	cout << "Preorder" << endl; Pre(root); cout << endl;
	cout << "Inorder" << endl; In(root); cout << endl;
	cout << "Postorder" << endl; Post(root); cout << endl;

	return 0;
}


Measured memory_bytes: 3124
from io import StringIO


UP = 0
LEFT = 1
LEFTUP = 2


def lcs(s, t):
    m = len(s)
    n = len(t)
    # dp[i][j] = LCS-length of (s[:i], t[:j])
    dp = [[0] * (n + 1) for i in range(m + 1)]

    for i in range(1, m + 1):
        for j in range(1, n + 1):
            if s[i - 1] == t[j - 1]:
                dp[i][j] = dp[i - 1][j - 1] + 1
            else:
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])
    buf = StringIO()
    i = m
    j = n
    while i > 0 and j > 0:
        if dp[i][j] == dp[i - 1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j - 1]:
            j -= 1
        elif dp[i][j] == dp[i - 1][j - 1] + 1:
            buf.write(s[i - 1])
            i -= 1
            j -= 1
    buf.seek(0)
    ans = buf.read()[::-1]
    return ans


if __name__ == "__main__":
    print(lcs(input(), input()))


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

def main():
    sa = input().split(' ')
    N = int(sa[0])
    Y = int(sa[1])

    f = False
    for x in range(N + 1):
        if Y < 10000 * x:
            break
        for y in range(N + 1 - x):
            z = N - x - y
            if 10000 * x + 5000 * y + 1000 * z == Y:
                f = True
                break
            if Y < 10000 * x + 5000 * y:
                break
        if f:
            break

    if f:
        print('{} {} {}'.format(x, y, z))
    else:
        print('-1 -1 -1')


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define rep(i,b,n) for(ll i=(b);i<(n);i++)
using namespace std;
ll n,s;
bool cal(ll i){
    ll sc=0,nc=n;
    if(i>=2)while(nc!=0){
        sc+=nc%i;
        nc/=i;
    }
    if(sc==s)return true;
    return false;
}
int main(){
    cin>>n>>s;
    bool f=false;
    if(n==s){
        cout<<n+1<<endl;
        f=true;
    }
    if(!f)rep(i,2,sqrt(n)){
        if(cal(i)){
            cout<<i<<endl;
            f=true;
            break;
        }
    }
    
    if(n>s)if(!f)
    for(ll int i=sqrt(n)+1;i>0;i--){
        if((n-s)%i==0)if(cal((n-s)/i+1)){
            cout<<(n-s)/i+1<<endl;
            f=true;
            break;
        }
    }
    if(!f)cout<<-1<<endl;
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

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

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

    int soFar = inf;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] < soFar) {
            ans++;
            soFar = a[i];
        }
    }


    cout << ans;





    return 0;
}


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

public class Main{


	
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner();
		PrintWriter out=new PrintWriter(System.out);
		int n=sc.nextInt(),q=sc.nextInt();
		char []s=("a"+sc.next()).toCharArray();
		int []ans=new int [n+1];
		for(int i=1;i<=n;i++) {
			if(i!=n && s[i]=='A' && s[i+1]=='C')
				ans[i]++;
			ans[i]+=ans[i-1];
		}
		while(q-->0) {
			int l=sc.nextInt(),r=sc.nextInt();
			out.println(ans[r-1]-ans[l-1]);
		}
	
		out.close();

	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		Scanner(String fileName) throws FileNotFoundException{
			br=new BufferedReader(new FileReader(fileName));
		}
		String next() throws IOException {
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		String nextLine() throws IOException {
			return br.readLine();
		}
		int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		long nextLong()  throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 40100
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int n,cnt;
int a[500000];

int main(){
  int n;cin>>n;
  int a[100000], b[100000],c[100000];
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  rep(i,n)cin>>c[i];
  sort(a,a+n);sort(c,c+n);
  ll ans = 0;
  rep(i,n){
    ans += (distance(a,lower_bound(a,a+n,b[i]))*distance(upper_bound(c,c+n,b[i]),c+n));
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
	int H, W, K; 
	cin >> H >> W >> K; 
	char C[11][1010] = {}; 
	for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			cin >> C[i][j]; 
		}
	}
	int A[11][1010] = {}; 
	for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			A[i][j] = A[i-1][j] + A[i][j-1] - A[i-1][j-1] + (C[i][j] == '1'); 
		}
	}
	int ans = 114514; 
	for(int bit = 0; bit < (1 << (H-1)); bit++){
		vector<int> D; 
		D.push_back(0); 
		int cnt = 0; 
		for(int i = 0; i < H-1; i++){
			if((bit >> i) & 1){
				D.push_back(i+1); cnt ++; 
			}
		}
		D.push_back(H); 
		vector<int> cut = {}; 
		cut.push_back(0);
		bool possible = true;  
		for(int i = 1; i <= W; i++){
			int r = cut.back(); 
			bool ok = true;
			for(int j = 0; j + 1 < D.size(); j++){
				if(A[D[j+1]][i] - A[D[j]][i] - A[D[j+1]][r] + A[D[j]][r] > K){
					ok = false; 
				}
			}
			if((!ok) && i == r+1){
			     possible = false; break;
			}
			else if(!ok){
				cut.push_back(i-1); r = i-1; i--; 
			}
			else if(i == W){
				cut.push_back(W); 
			}
		}
		if(!possible) continue; 
		cnt += cut.size() - 2; 
		ans = min(ans, cnt); 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 256
local n, m = io.read("*n", "*n")
local s, t = io.read("*n", "*n")
local edge = {}
for i = 1, n do edge[i] = {} end
for i = 1, m do
  local u, v = io.read("*n", "*n")
  local a, b = io.read("*n", "*n")
  edge[u][v] = {a, b}
  edge[v][u] = {a, b}
end


local function getlength(start_idx, ci)
  local taskstate = {}
  for i = 1, n do taskstate[i] = false end
  local tasks = {}
  local tasknum = 0
  local done = 0

  local len = {}
  local inf = -1
  for i = 1, n do len[i] = inf end
  len[start_idx] = 0

  local function addtask(idx)
    if not taskstate[idx] then
      taskstate[idx] = true
      tasknum = tasknum + 1
      tasks[tasknum] = idx
    end
  end
  addtask(start_idx)

  while done < tasknum do
    local tmp = {}
    done = done + 1
    local src = tasks[done]
    taskstate[src] = false
    for dst, cost in pairs(edge[src]) do
      if len[dst] < 0 or len[src] + cost[ci] < len[dst] then
        len[dst] = len[src] + cost[ci]
        table.insert(tmp, dst)
      end
    end
    table.sort(tmp, function(a, b) return len[a] < len[b] end)
    for i = 1, #tmp do addtask(tmp[i]) end
  end
  return len
end

local yen = getlength(s, 1)
local snk = getlength(t, 2)
local ret = {}
for i = 1, n - 1 do ret[i] = 0 end
ret[n] = yen[n] + snk[n]
local mmi = math.min
for i = n - 1, 1, -1 do
  ret[i] = mmi(ret[i + 1], yen[i] + snk[i])
end
for i = 1, n do
  local a = 1000000000000000LL
  a = a - ret[i]
  local str = tostring(a):gsub("LL", "")
  print(str)
end


Measured memory_bytes: 55880
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc168_a solver = new abc168_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc168_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            String s[] = String.valueOf(N).split("");

            if ((s[s.length - 1].compareTo("0") == 0) ||
                    (s[s.length - 1].compareTo("1") == 0) ||
                    (s[s.length - 1].compareTo("6") == 0) ||
                    (s[s.length - 1].compareTo("8") == 0)) {
                out.println("pon");
                return;
            } else if (s[s.length - 1].compareTo("3") == 0) {
                out.println("bon");
            } else {
                out.println("hon");
            }

        }

    }
}



Measured memory_bytes: 35800
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N;
    cin >> N;

    vector<pair<ll, ll> > A;
    FOR(i, 0, N){
        ll a, b;
        cin >> a >> b;
        auto p = make_pair(a, b);
        A.push_back(p);
    }
    sort(ALL(A));

    // 一番点数低い人の点数
    ll low_score = A.back().second;
    ll num = A.back().first + low_score;

    p(num);
    
    return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,s;
int main(){
    cin>>a>>b>>c>>n;
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++)
            if((n-i*500-j*100>=0)&&(n-i*500-j*100<=c*50)) s+=1;
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
M = 10**9 + 7
N, A, AB, ABC = 1, 0, 0, 0
idx = {'A': 1, 'B': 2, 'C': 3}
for c in input():
    if c == '?':
        N, A, AB, ABC = (N * 3) % M, (A * 3 + N) % M, (AB * 3 + A) % M, (ABC * 3 + AB) % M
    else:
        dp = [N, A, AB, ABC]
        dp[idx[c]] += dp[idx[c] - 1]
        N, A, AB, ABC = dp
print(ABC % M)

Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))
s = s_in()
t = s_in()

if s == t[:len(s)]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 61676
import sys
from collections import defaultdict as dd
import heapq
input = sys.stdin.readline
N = int(input())
p = [tuple(map(int, input().split())) for _ in range(N)]
e = dd(list)
p = [(i, p[i][0], p[i][1]) for i in range(N)]
p.sort(key = lambda x: x[1])
for i in range(N - 1):
  x = p[i][0]
  y = p[i + 1][0]
  e[x].append((y, abs(p[i][1] - p[i + 1][1])))
  e[y].append((x, abs(p[i][1] - p[i + 1][1])))
p.sort(key = lambda x: x[2])
for i in range(N - 1):
  x = p[i][0]
  y = p[i + 1][0]
  e[x].append((y, abs(p[i][2] - p[i + 1][2])))
  e[y].append((x, abs(p[i][2] - p[i + 1][2])))
class prim:
  def __init__(self, n, e):
    self.e = e
    self.n = n
  def MSTcost(self):
    h = []
    visited = [0] * (self.n + 1)
    ks = list(self.e.keys())
    b = pow(10, 10)
    for edge in self.e[ks[0]]:
      heapq.heappush(h, edge[1] * b + edge[0])
    res = 0
    visited[ks[0]] = 1
    while len(h):
      p = heapq.heappop(h)
      p0 = p // b
      p1 = p % b
      if visited[p1]: continue
      visited[p1] = 1
      for q in self.e[p1]:
        if visited[q[0]]:
          continue
        heapq.heappush(h, q[1] * b + q[0])
      res += p0
    return res
pri = prim(N, e)
print(pri.MSTcost())

Measured memory_bytes: 121564
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			double A = scan.nextDouble();
			double B = scan.nextDouble();
			double H= scan.nextDouble();
			double M = scan.nextDouble();
			
			double a = 0;
			double b = 0;
			/*
			if(30*H>180)a = 360-30*H;
			else a = 30*H;
			
			if(6*M>180)b = 360-6*M;
			else b = 6*M;
			*/
					
			
			
			double ra = Math.toRadians(30*H+0.5*M);
			double rb = Math.toRadians(6*M);
			
			double ab = Math.sqrt(A*A+B*B-2*A*B*Math.cos(rb-ra));
			
			
			System.out.println(ab);
		
			
			
			
			
		}
	}
		

}


Measured memory_bytes: 37548
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long dp[3030][3030] = { 0 };
pair<long long, long long> pa[3030];
int main() {
    long long n, t;
    cin >> n >> t;
    for (int i = 0; i < n; i++) {
        long long a, b;
        cin >> a >> b;
        pa[i] = make_pair(a, b);
    }
    sort(pa, pa + n);
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < t; j++) {
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            if (j + pa[i - 1].first < t) {
                dp[i][j + pa[i - 1].first] = max(dp[i - 1][j + pa[i - 1].first], dp[i - 1][j] + pa[i - 1].second);
            }
        }
        long long now = dp[i - 1][t - 1] + pa[i - 1].second;
        if (ans < now) {
            ans = now;
        }
    }
    cout << ans << endl;
    return 0;
}


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


typedef struct tree_t{
	int parent;
	int depth;
	int box_n;
	int *box;
} TREE_T;

TREE_T *TREE;


void Add_depth(TREE_T *box, int soeji, int depth)
{
	int i;

	box[soeji].depth = depth;

	for(i = 0; i < box[soeji].box_n; i++)
		Add_depth(box, box[soeji].box[i], depth + 1);
}


int main()
{
	int n;
	int id, k, sub_id;
	int i, j;

	scanf("%d", &n);

	TREE = (TREE_T *)malloc(sizeof(TREE_T) * n);

	for(i = 0; i < n; i++)
		TREE[i].parent = -1;

	for(i = 0; i < n; i++){
		scanf("%d %d", &id, &k);
		TREE[id].box_n = k;
		TREE[id].box = (int *)malloc(sizeof(int) * k);

		if(k){
			for(j = 0; j < k; j++){
				scanf("%d", &sub_id);
				TREE[id].box[j] = sub_id;
				TREE[sub_id].parent = id;
			}
		}
	}

	// depthの更新
	i = -1;
	while(TREE[++i].parent != -1);
	Add_depth(TREE, i, 0);

	/* 節情報の表示 */
	for(i = 0; i < n; i++){
		printf("node %d: parent = %d, depth = %d, ", i, TREE[i].parent, TREE[i].depth);

		if(TREE[i].parent == -1)
			printf("root, ");
		else if(TREE[i].box_n >= 1)
			printf("internal node, ");
		else
			printf("leaf, ");

		printf("[");
		for(j = 0; j < TREE[i].box_n; j++){
			printf("%d", TREE[i].box[j]);
			if(j != TREE[i].box_n - 1)
				printf(", ");
		}
		printf("]\n");
	}

	return 0;
}


Measured memory_bytes: 7720
from operator import itemgetter
n = int(input())
st = []
for i in range(n):
    x, l = map(int, input().split())
    st.append([x-l, x+l])
st.sort(key = itemgetter(1))

i = 1
last = 0
count = 1
while i < n:
    if st[i][0] >= st[last][1]:
        last = i
        count += 1
    i += 1
print(count)      

Measured memory_bytes: 21348
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int A, B, T;
 
	cin >> A >> B >> T;
 
	int ans = 0;
	for( int i = 1; i <= 20; i++ ) {
		if( A * i > T ) {
			break;
		}
		ans += B;
	}
 
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    string s;
    cin >> s;
    cout << s;
    if (s[s.size()-1]=='s') cout << "es" << endl;
    else cout << "s" << endl;
    //printf("%.12f", ans);
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    int v[n];
    for( int &i: v ) {
        cin >> i;
    }
    long double ans = 0;
    for(int i = 0; i < n; i++ ) {
        ans += (long double)1/v[i];
    }
    cout << fixed << setprecision(10) << 1/ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int n, m, signW, signH, tmpW, tmpH;
  cin >> n >> m;
  string a[n], b[m];
  string ans = "No";
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) cin >> b[i];
  int start = b[0][0];
  for (int i = 0; i < n - m + 1; i++) {
    for (int j = 0; j < n - m + 1; j++) {
      if (start == a[i][j]) {
        int tmpI = i;
        int cnt = 0;
        for (int k = 0; k < m; k++) {
          int tmpJ = j;
          if (cnt == 0 || cnt % m == 0) {
            for (int h = 0; h < m; h++) {
              if (a[tmpI][tmpJ] == b[k][h]) {
                cnt++;
                tmpJ++;
              }
              if (cnt == m * m) ans = "Yes";
            }
            tmpI++;
          }
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 1e9
typedef long long ll;
typedef pair<char, char> P;

int main() {
    int n, T;
    cin >> n >> T;
    vector<int> t(n);
    rep(i, n) cin >> t[i];

    ll ans = 0, tmp = 0;
    int i = 0;
    int cnt = 0;
    while (i < n) {
        tmp = t[i] + T;
        while (i+1<n && t[i+1] <= tmp) {
            i++;
            tmp = t[i] + T;
        }
        ans += tmp - t[cnt];
        i++;
        cnt = i;
    }
    
    cout << ans << endl;

}

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

void judge(int X){
  
  int Y = X;
  int fx = 0;
  
  while(X > 0){
    fx += (X % 10);
    X /= 10;
  }
  
  if(Y % fx == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

int main(){
  
  int N;
  cin >> N;
  
  judge(N);  
}

Measured memory_bytes: 256
import scala.math.abs

object Main extends App {
  val sc = new java.util.Scanner(System.in) 
  sc.useDelimiter("\n")
  val n = sc.nextInt()
  val d = sc.next().split(" ").map(_.toInt).toList.sorted
  val abc = d(n/2-1)
  val arc = d(n/2)
  println(arc - abc)
}

Measured memory_bytes: 67700
#include<iostream>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int count_number = 0;
	for (int i = a;i <= b;i++) {
		if (c%i == 0) {
			count_number = count_number + 1;
		}
		
	}
	cout << count_number << endl;
}

Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  string result = "Three";
  rep(i, N) { string h; cin >> h; if (h=="Y") result = "Four"; }
  cout << result << endl;
  return 0;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	
	vector<int> v(n);
	for (int i=0; i<n; ++i) {
		cin >> v.at(i);
	}
	
	sort(v.begin(), v.end());
	
	double res = v.at(0);
	for (int i=1; i<n; ++i) {
		res = (res + v.at(i)) / 2;
	}
	
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

using namespace std;

int main()
{
    char s[3];
    cin >> s;
    if (s[0] == 'T' && s[1] == 'U'){
        cout << "5" << endl;
    }
    else if (s[0] == 'W'){
        cout << "4" << endl;
    }
    else if (s[0] == 'T' && s[1] == 'H'){
        cout << "3" << endl;
    }
    else if (s[0] == 'F'){
        cout << "2" << endl;
    }
    else if (s[0] == 'S' && s[1] == 'A'){
        cout << "1" << endl;
    }
    else if (s[0] == 'M'){
        cout << "6" << endl;
    }
    else {
        cout << "7" << endl;
    }
    
        
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
int main(){
	int a,b;scanf("%d%d",&a,&b);
	if(!(b%a)) cout<<a+b;
	else cout<<b-a;
	return 0;
}


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

#define INF 2e9

#define REP(i,n) for(int i = 0; i < n;++i)
#define REPA(i,a,n) for(int i = a; i < n; ++i)
#define ALL(a) a.begin, a.end()

using namespace std;

int main(void) {

	int N;

	cin >> N;

	int ans = 0;

	ans += min(9, N);
	
	if (N > 99) {
		ans += min(N - 99, 900);
	}
	if (N > 9999) {
		ans += min(N - 9999, 90000);
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX=500000;

int H,A[MAX+1];
void maxHeapify(int i){ 
    int l,r,largest;
    l=2*i;
    r=2*i+1;

    if(l<=H&&A[l]>A[i])largest=l;
    else largest=i;
    if(r<=H&&A[r]>A[largest])largest=r;

    if(largest!=i){
        swap(A[i],A[largest]);
        maxHeapify(largest);
    }   
}
int main(){
    cin>>H;
    for(int i=1;i<=H;i++)cin>>A[i];
    for(int i=H/2;i>=1;i--)maxHeapify(i);
    for(int i=1;i<=H;i++)cout<<" "<<A[i];
    cout<<"\n";
    return 0;                                                             
}



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

using namespace std;

#define ll long long
#define INF 100000000000


int n, val[120];
ll wgt[120];
ll dp[120][100005];

ll knapsack( int pos, int value ) {


    if( value == 0 ) return 0LL;
	if( pos >= n || value<0) return INF;

	ll &ret = dp[pos][value];
	if( ret != -1 ) return ret;


	ret = knapsack( pos + 1, value );
    ret =min(ret,wgt[pos] + knapsack( pos + 1, value - val[pos]));

	return ret;
}


int main()
{

    ll w;
    cin >> n >> w;
    for( int i = 0; i < n; i++ )
    	cin >> wgt[i] >> val[i];

    memset( dp, -1, sizeof(dp) );
    for( int i = n*1000; i >= 0; i-- ) {
    	ll ans = knapsack( 0, i );
    	if( ans <= w ) {
    		cout << i << endl;
    		return 0;
    	}
    }

	return 0;

}


Measured memory_bytes: 93952
A,B = list(map(int,input().split(" ")))
c = [0,0,0]
for i in range(3):
    if 0 == i:
        c[i] = A + B
    elif 1 == i:
        c[i] = A - B
    elif 2 == i:
        c[i] = A * B
print(max(c))

Measured memory_bytes: 3060
a,b,c = [int(input()) for i in range(3)]
x = int(input())
cnt = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k == x:
                cnt = cnt+1

print(cnt)

Measured memory_bytes: 9092
#include<stdio.h>

int main(void){
    int N;
    scanf("%d",&N);
    int R[N];
    for(int i = 0; i < N; i++){
        scanf("%d",&R[i]);
    }    
    int max = R[1]-R[0];
    int min = R[0];
    for(int i = 1; i < N; i++){
        if(max < R[i]-min){
            max = R[i]-min;
        }
        if(min > R[i]){
            min = R[i];
        }
    }
    printf("%d\n",max);
    return 0;
}


Measured memory_bytes: 2508
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] x = new int[n];
    for(int i = 0; i < n; i++) {
      x[i] = sc.nextInt();
    }
    int ans = Integer.MAX_VALUE;
    for(int t = -100; t <= 100; t++) {
      int s = 0;
      for(int j = 0; j < n; j++) {
        s += ((x[j] - t) * (x[j] - t));
      }
      ans = Math.min(s, ans);
    }
    System.out.println(ans);
  }
}

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

int main(){
  int n;
  int ans = 0;
  int count = 0;
  cin >> n;
  
  if ( n < 105 ){
    cout << 0 << endl;
    return 0;
  }
  
  for ( int i = 105; i <= n; i += 2 ){
    for ( int j = 1; j <= i; j += 2 ){
      if ( i % j == 0 ){
        count++;
      }
    }
    if ( count == 8 ){
      ans++;
    }
    count = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int Q;
   cin >> Q;
   long long B=0;
   priority_queue<long long> v;
   priority_queue<long long, vector<long long>, greater<long long> > v2;
   long long SumL=0;
   long long SumR=0;
   for(int i=0;i<Q;i++){
      int q;
      cin >> q;
      if(q == 1){
         long long a,b;
         cin >> a >> b;
         B+=b;
         if(v.size()==0){
            v.push(a);
            SumL=a;
         }
         else if(v2.size()==0){
            long long left = min(v.top(),a);
            long long right = max(v.top(),a);
            v.pop();
            v.push(left);
            v2.push(right);
            SumL=left;
            SumR=right;
         }
         else{
            int size1 = v.size();
            int size2 = v2.size();
            if(size1 <= size2){
               long long right = v2.top();
               v2.pop();
               int i = min(right,a);
               int j = max(right,a);
               SumL += i;
               SumR += j-right;
               v.push(i);
               v2.push(j);
            }
            else{
               long long left = v.top();
               v.pop();
               long long i = max(left,a);
               long long j = min(left,a);
               SumR += i;
               SumL += j-left;
               v2.push(i);
               v.push(j);
            }
            /*
            priority_queue<long long> v_ = v;
            priority_queue<long long, vector<long long>, greater<long long>> v_ = v;
            while(!v_.empty()){
               cout << v_.top() <<" ";
               v_.pop();
            }
            cout << endl;
            while(!v2_.empty()){
               cout << v2_.top() <<" ";
               v2_.pop();
            }
            cout << endl;
            */
         }
      }
      else{
         long long size1 = v.size();
         long long size2 = v2.size();
         long long left = v.top();
         long long ans = B;
         ans += SumR;
         ans -= size2*left;
         ans += size1*left;
         ans -= SumL;
         cout << left <<" " << ans << endl;
      }
   }
   return 0;
}


Measured memory_bytes: 3828
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int l = scan.nextInt();
			if(l == 0){
				break;
			}
			int cost = 0;
			boolean sw = true;
			for(int i = 0;i < 12;i++){
				cost += scan.nextInt() - scan.nextInt();
				if(l <= cost && sw){
					System.out.println(i+1);
					sw = false;
				}else if(i == 11 && sw){
					System.out.println("NA");
				}
			}
		}
	}
}

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

char f(char a, char b, char k)
{
    if((k=='o'&&b=='S')||(k=='x'&&b=='W'))return a;
    else
    {
        if(a=='S')return 'W';
        else return 'S';
    }
}

int main()
{
    int n;string s;
    cin>>n>>s;
    string d[4]={"SS","SW","WS","WW"};
    for(int i=0;i<4;i++)
    {
        string ans=d[i];
        for(int i=0;i<n-2;i++)
        {
            ans+=f(ans[i],ans[i+1],s[i+1]);
        }
        if(f(ans[n-2],ans[n-1],s[n-1])!=ans[0])continue;
        if(f(ans[n-1],ans[0],s[0])!=ans[1])continue;
        cout<<ans<<endl;
        return 0;
    }
    cout<<-1<<endl;

}


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

int main() {
    long long n, k, q;
    cin >> n >> k >> q;
    vector<long long> a(q);
    for (int i = 0; i < q; i++) cin >> a[i];

    if (k > q) {
        for (int i = 0; i < n; i++) {
            cout << "Yes" << endl;
        }
        return 0;
    }

    long long cnt[100100] = {0};
    for (int i = 0; i < q; i++) {
        cnt[a[i]]++;
    }

    long long b[100100];
    for (int i = 1; i <= n; i++) {
        b[i] = k;
    }
    for (int i = 1; i <= n; i++) {
        b[i] -= (q - cnt[i]);
    }

    /*
    for (int i = 1; i <= n; i++) {
        cout << b[i] << endl;
    }
    */

    for (int i = 1; i <= n; i++) {
        if (b[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>
int main() {
	int n;
	scanf("%d",&n);
	if (n % 10 == 9 || n % 10 == 7 || n % 10 == 5 || n % 10 == 4 || n % 10 == 2)
		printf("hon");
	if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
		printf("pon");
	if (n % 10 == 3)
		printf("bon");
}

Measured memory_bytes: 2152
from operator import itemgetter

N = int(input())
SP = [[0,"none",0]]*N
for i in range(N):
	s, p = input().split()
	SP[i] = [i+1, s, int(p)]

SP.sort(key=itemgetter(2), reverse=True)
SP.sort(key=itemgetter(1))
[ print(i[0]) for i in SP ]

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;

int N, A[2020];
vp P;
int dp[2020][2020];

void solve() {
    for (int l = 0; l <= N; l++) {
        for (int r = N + 1; r >= l + 1; r--) {
            int n = l + (N + 1 - r) - 1;
            if (n < 0)
                continue;
            if (l > 0) {
                chmax(dp[l][r], dp[l - 1][r] + P[n].first * abs(l - P[n].second));
            }
            if (r < N + 1) {
                chmax(dp[l][r], dp[l][r + 1] + P[n].first * abs(r - P[n].second));
            }
            //cerr << l << " " << r << " " << dp[l][r] << " " << n << " " << P[n].first << " " << P[n].second << endl;
            //cerr << l << " " << r << " " << dp[l][r] << " " << P[n].first << " " << P[n].second << endl;
        }
    }
    int ans = 0;
    for (int i = 0; i <= N; i++) {
        chmax(ans, dp[i][i + 1]);
    }
    cout << ans << endl;
}

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

    cin >> N;
    FOR (N)
        cin >> A[i];
    FOR (N) {
        P.pb({A[i], i + 1});
    }
    sort(all(P));
    reverse(all(P));

    solve();
    return 0;
}


Measured memory_bytes: 26396
#pragma GCC optimize("O3") 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") 
#define __USE_MINGW_ANSI_STDIO 0
#include<bits/stdc++.h>                               
using namespace std;

#define PI acos(-1)
#define pb push_back
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(c) (c).begin(), (c).end()
#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair <int, int> pii;
typedef vector <vi> vvi;
typedef vector <pii> vpii;
typedef vector<string> vs;

const int MAXN = 1e5 + 9;
const int MOD = (int)(1e9 + 7);
const int INF = 100500;

void input() {
	int n;
	cin >> n;
	vi aa(n);
	for(int i = 0; i < n; i++) cin >> aa[i];
	int s = accumulate(all(aa), 0);
	if(s % 10 != 0) {
		cout << s;
		return;
	}
	sort(all(aa));
	for(int i = 0; i < n; i++) {
		if(aa[i] % 10 != 0) {
			cout << s - aa[i] << endl;
			return;
		}		
	}
	cout << 0;
}

void solve() {

}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef LOCAL
	freopen("xxx.in", "r", stdin);
	freopen("xxx.out", "w", stdout);
#else
	//freopen("xxx.in", "r", stdin);
	//freopen("xxx.out", "w", stdout);
#endif	
	input();
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#include <assert.h>
#define FOR(i,a,n) for(i=(a);i<(n);i++)
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define LOCAL
#ifdef LOCAL
    #define DEBUG(...) printf(" "__VA_ARGS__)
#else
    #define DEBUG(...)
#endif /* LOCAL */
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
ll a[100000];
int main(void)
{
	int n,i;
	ll min,max;
	scanf("%d",&n);
	FOR(i,0,n) scanf("%lld",a+i);
	if(a[n-1]!=2){
		puts("-1");
		return 0;
	}
	min=2,max=3;
	for(i=n-2;i>=0;i--){
		if(a[i]>max){
			puts("-1");
			return 0;
		}
		min=(min+a[i]-1)/a[i]*a[i];
		max=max/a[i]*a[i]+a[i]-1;
		if(min>max){
			puts("-1");
			return 0;
		}
	}
	printf("%lld %lld\n",min,max);
	return 0;
}
    
    


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

using namespace std;

int main(){
  char s[3];
  scanf("%s", s);
  int ans = 0;
  for(int i = 0; i < 3; ++i){
    ans += ('1' == s[i]);
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
 
using namespace std;
 
const int N = 5000;
 
int dp[N + 1][N + 1];
 
int main() {
	int n; cin >> n;
	string s; cin >> s;
	for (int i = n - 1; i >= 0; i--)
		for (int j = i + 1; j < n; j++)
			if (s[i] == s[j])
				dp[i][j] = dp[i + 1][j + 1] + 1;
	int ans = 0;
	for (int i = 0; i < n; i++)
		for (int j = i + 1 + ans; j < n; j++)
			ans = max(ans, min(dp[i][j], j - i));
  
  
	cout << ans << '\n';
  
  
	return 0;
}

Measured memory_bytes: 70268
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		UINT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

int main()
{
	string S = "";
	ll ans = 700;

	cin >> S;

	Rep(i, S.length()) {
		if (S[i] == 'o') {
			ans += 100;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import collections


def dfs(graph, start):
    visited = set()
    stack = [start]
 
    while stack:
        v = stack.pop()
        if v not in visited:
            stack.extend(graph[v])
            visited.add(v)
            yield v

def read_graph(nodes, edges):
    graph = [set() for _ in range(nodes)]
    for _ in range(edges):
        a, b = (int(x) - 1 for x in input().split())
        graph[a].add(b)
        graph[b].add(a)
 
    return graph

N, M, K = map(int, input().split())

friends = read_graph(N, M)
blockings = read_graph(N, K)

candidates = [None for _ in range(N)]
for i in range(N):
    if candidates[i] is not None:
        continue

    s = set()
    for j in dfs(friends, i):
        s.add(j)
        candidates[j] = s

def num_suggestions(i):
    return len(candidates[i]) - len(friends[i]) - len(blockings[i].intersection(candidates[i])) - 1

print(
    " ".join(
        str(num_suggestions(i)) for i in range(N)
    )
)


Measured memory_bytes: 105788
#include <stdio.h>

int main() {
  int alice_card, bob_card;
  scanf("%d %d", &alice_card, &bob_card);
  if(alice_card == 1) {
    alice_card = 14;
  }
  if(bob_card == 1) {
    bob_card = 14;
  }
  if(alice_card > bob_card) {
    printf("Alice\n");
  } else if(alice_card == bob_card) {
    printf("Draw\n");
  } else {
    printf("Bob\n");
  }
  return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG //vectorの範囲外アクセスなどのエラーメッセージが分かりやすくなるらしい


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
//#include <algorithm>

// using namespace std;
#include<numeric>

#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<cmath>
#include<complex>


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

#define FOR(i,c) for(typeof((c).begin())i=(c).begin();i!=(c).end();++i)


#define EXIST(e,s)((s).find(e)!=(s).end())
#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))

 



#define ll long long

using namespace std;

int main(void){
  int n;
  int p;

  int temoto[50];
  int wan;
  bool flag;

  while(cin >> n >> p, n || p){
    flag = false;
    memset(temoto, 0, sizeof(temoto[0])*50);
    wan = p;
    while(1){
      for(int i=0; i<n; i++){
	if(wan > 0){
	  wan--;
	  temoto[i]++;
	  if(temoto[i] == p){
	    cout << i << endl;
	    flag = true;
	    break;
	  }
	}else{
	  wan += temoto[i];
	  temoto[i] = 0;
	}
      }
      if(flag){
	break;
      }
    }
  }
    
    
    
    return 0;
}

Measured memory_bytes: 1144
/*
  Contest 065
  C - Reconciled?
  Rakesh Kumar --> 01/09/2020
 */

#include <bits/stdc++.h>

using ll = long long int;
const ll M = (1e9 + 7);

inline ll fact(ll n) {
    ll r = 1;
    for (ll i = 2; i <= n; ++i)
        r = (r * i) % M;
    return r;
}

/*
  combinations maths questions.
  for example
  D --> dog, M --> Monkey
  if abs(D - M) == 0
  let's D = M = 2
  can be 2 combinations where DMDM or MDMD therefore (D! * M!) * 2
  if abs(D - M) = 1
  DMD, MDM so D! * M!
  else abs(D - M) > 1
  0, because dog and monkey can't stand each other
 */

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);

    ll n = 0, m = 0;
    std::cin >> n >> m;
    if (std::abs(n - m) <= 1) {
        ll result = fact(n);
        result = (result * fact(m)) % M;
        if (n == m)
            result = (result << 1) % M;
        std::cout << result << std::endl;
    } else {
        std::cout << 0 << std::endl;
    }


    return 0;
}


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

using namespace std;
const int maxn =  1e6 + 10;
#define ll long long
#define ios std::ios::sync_with_stdio(false)
const ll INF(0x3f3f3f3f3f3f3f3fll);
const int inf(0x3f3f3f3f);
/*


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);}
ll pow_mod(ll x,ll n,ll mod){ll res=1;while(n){if(n&1)res=res*x%mod;x=x*x%mod;n>>=1;}return res;}//xµÄn´Î·½mod


ll mult(ll a,ll b,ll p){a%=p;b%=p;ll r=0,v=a;while(b){if(b&1){r+=v;if(r>p)r-=p;}v<<=1;if(v>p)v-=p;b>>=1;}return r;}
ll quick_pow(ll a,ll b,ll p){ll r=1,v=a%p;while(b){if(b&1)r=mult(r,v,p);v=mult(v,v,p);b>>=1;}return r;}
bool CH(ll a,ll n,ll x,ll t)
{ll r=quick_pow(a,x,n);ll z=r;for(ll i=1;i<=t;i++){r=mult(r,r,n);if(r==1&&z!=1&&z!=n-1)return true;z=r;}return r!=1;}
bool Miller_Rabin(ll n)
{if(n<2)return false;if(n==2)return true;if(!(n&1))return false;ll x=n-1,t=0;while(!(x&1)){x>>=1;t++;}srand(time(NULL));
ll o=8;for(ll i=0;i<o;i++){ll a=rand()%(n-1)+1;if(CH(a,n,x,t))return false;}return true;}


*/

#define int long long
#define sc(t) scanf("%lld",&t)
#define pr(ans) printf("%lld\n",ans)
ll pow_mod(ll x,ll n,ll mod){ll res=1;while(n){if(n&1)res=res*x%mod;x=x*x%mod;n>>=1;}return res;}//xµÄn´Î·½mod
template<typename T>void read(T &res){bool flag=false;char ch;while(!isdigit(ch=getchar()))(ch=='-')&&(flag=true);
for(res=ch-48;isdigit(ch=getchar());res=(res<<1)+(res<<3)+ch - 48);flag&&(res=-res);}
typedef unsigned long long ULL;

int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
#define debug(x) cout << #x << " : " << x << '\n';
#define sb cout << "sb\n" << '\n';
#define fi first
#define se second
#define pb(a) push_back(a)
#define cn cout << '\n'


int a[100];
signed main()
{
    ios;
    cin.tie(0);///
    int n;
    cin >> n;
    int l , r;
    cin >> l >> r;
    for(int i = l ; i <= r ; i ++){
        if(i % n == 0){
            cout << "OK";
            cn;
            return 0;
        }
    }
    cout << "NG";
    cn;
    return 0;
}
/*
1
1025
*/


Measured memory_bytes: 3576
def main():
    import numpy as np
    from bisect import bisect_left as bl
    mod = 10**9+7
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    dp = np.zeros(k, dtype=np.int32)
    dp[0] = 1
    m = bl(a, k)
    for i in range(m):
        aa = a[i]
        dp[aa:] = (dp[aa:]+dp[:k-aa]) % mod

    def b_search(ok, ng):
        while abs(ok-ng) > 1:
            mid = (ok+ng)//2
            if value(mid):
                ok = mid
            else:
                ng = mid
        return ok

    def value(i):
        if i == -1:
            return True
        if i == m:
            return False
        aa = a[i]
        dp2 = np.zeros(k, dtype=np.int32)
        dp2[:aa] = dp[:aa]
        for j in range(aa, k):
            dp2[j] = (dp[j]-dp2[j-aa]) % mod
        for j in range(k-aa, k):
            if dp2[j] != 0:
                return False
        return True
    print(b_search(-1, m)+1)


main()

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

int main(){

  int i,j,len_s,len_p;
  char s[110];
  char p[110];

  scanf("%s",s);
  scanf("%s",p);

  len_s=strlen(s);
  len_p=strlen(p);

  for(i=0;i<len_s;i++){
    for(j=0;j<len_p;j++){
      if(i+j<=len_s-1){
        if(s[i+j]!=p[j]) break;
      }else{
        if(s[i+j-len_s]!=p[j]) break;
      }
    }
    if(j==len_p) break;
  }
  if(i==len_s){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}


Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

ll dp[110][4][2];

int main(){
    string S;
    ll K;
    cin >> S >> K;
    ll N = S.size();
    dp[0][0][0] = 1;
    dp[0][0][1] = 0;
    rep(i,N){
        ll c = S[i] - '0';
        rep(j,K){
            dp[i+1][j+1][1] += dp[i][j][1]*9;
        }
        rep(j,K+1){
            dp[i+1][j][1] += dp[i][j][1]*1;
        }
        if(c == 0){
            rep(j,K+1){
                dp[i+1][j][0] += dp[i][j][0];
            }
        }else{
            rep(j,K){
                dp[i+1][j+1][0] += dp[i][j][0]; 
            }
            rep(j,K+1){
                dp[i+1][j][1] += dp[i][j][0]; 
            }
            rep(j,K){
                //dp[i+1][j+1][0] += dp[i][j][0];
                dp[i+1][j+1][1] += dp[i][j][0]*(c-1);
            }
        }
    }
    cout << dp[N][K][1] + dp[N][K][0] << endl;
        /*
        rep(j,K){
            dp[i+1][j][1] += dp[i][j][0]*max((c-1), 0LL);
            if(c > 0){
                dp[i+1][j+1][1] += dp[i][j][0];
            }
        }
        rep(j,K+1){
            if(c > 0){
                dp[i+1][j][0] += dp[i][j][0];
            }
        }*/
    //}
}

Measured memory_bytes: 3624