akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VI w(n);
    REP(i,0,n) cin >> w[i];
    VI ru(n+1);
    REP(i,0,n) ru[i+1] = ru[i] + w[i];
    int ans = ru[n];
    REP(i,0,n) {
        int diff = abs(ru[i+1] - (ru[n] - ru[i+1]));
        ans = min(ans, diff);
    }
    cout << ans << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
class Dice:
    def __init__(self,t,f,r,l,ba,bo):
        self.t = t
        self.f = f
        self.r = r
        self.l = l
        self.ba = ba
        self.bo = bo
    
    def E(self):
        a = self.t
        b = self.r
        c = self.bo
        d = self.l
        self.r = a
        self.bo = b
        self.l = c
        self.t = d
    
    def N(self):
        a = self.t
        b = self.ba
        c = self.bo
        d = self.f
        self.ba = a
        self.bo = b
        self.f = c
        self.t = d
    
    def S(self):
        a = self.t
        b = self.ba
        c = self.bo
        d = self.f
        self.f = a
        self.t = b
        self.ba = c
        self.bo = d
    
    def W(self):
        a = self.t
        b = self.r
        c = self.bo
        d = self.l
        self.l = a
        self.t = b
        self.r = c
        self.bo = d

def hantei(dice1,dice2):
    global flag
    if dice1.t == dice2.f:
        dice2.N()
    elif dice1.t == dice2.r:
        dice2.W()
    elif dice1.t == dice2.l:
        dice2.E()
    elif dice1.t == dice2.ba:
        dice2.S()
    elif dice1.t == dice2.bo:
        dice2.E()
        dice2.E()
    if dice1.bo != dice2.bo:
        dice2.N()
        for i in range(4):
            if dice1.t == dice2.t and dice1.bo == dice2.bo:
                break
            dice2.E()
    for i in range(4):
        if dice1.t == dice2.t and dice1.f == dice2.f and dice1.r == dice2.r and dice1.l == dice2.l and dice1.ba == dice2.ba and dice1.bo == dice2.bo:
            flag = 1
            break
        dice2.N()
        dice2.E()
        dice2.S()
        

n = int(input())
dice = []
flag = 0
for i in range(n):
    s = input().split(" ")
    dice.append(Dice(s[0],s[1],s[2],s[3],s[4],s[5]))
hantei(dice[0],dice[1])
for i in range(n-1):
    if flag == 1:
        break
    for j in range(i+1,n):
        hantei(dice[i],dice[j])
        if flag == 1:
            break

if flag == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 7852
#include<iostream>
#include<cstdio>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra() {
	int minv;
	int d[MAX], color[MAX];

	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
		color[i] = WHITE;
	}

	d[0] = 0;
	color[0] = GRAY;
	while (1) {
		minv = INFTY;
		int u = -1;
		for (int i = 0; i < n; i++) {
			if (minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}
		if (u == -1)break;
		color[u] = BLACK;
		for (int v = 0; v < n; v++) {
			if (color[v] != BLACK && M[u][v] != INFTY) {
				if (d[v] > d[u] + M[u][v]) {
					d[v] = d[u] + M[u][v];
					color[v] = GRAY;
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		printf("%d ", i);
		if (d[i] == INFTY) {
			printf("-1\n");
		}
		else {
			printf("%d\n", d[i]);
		}
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			M[i][j] = INFTY;
		}
	}

	int k, c, u, v;
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &u, &k);
		for (int j = 0; j < k; j++) {
			scanf("%d%d", &v, &c);
			M[u][v] = c;
		}
	}

	dijkstra();
	return 0;
}



Measured memory_bytes: 3228
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int N = scanner.nextInt();
            int L = scanner.nextInt();

            long all = 0;
            for (int i = 1; i <= N; i++) {
                all += (L + i - 1);
            }
            long min = Long.MAX_VALUE;
            long answer = 0;
            for (int i = 1; i <= N; i++) {
                long apple = (L + i - 1);
                long rest = all - apple;
                long diff = all - rest;
                if (diff < 0) {
                    diff *= -1;
                }
                if (diff < min) {
                    min = diff;
                    answer = all - apple;
                }
            }
            System.out.println(answer);
        }
    }

}


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

#define P pair
#define X first
#define Y second
#define VSORT(v) sort(v.begin(), v.end())
#define VREV(v) reverse(v.begin(), v.end())
#define VMAX_P(v) max_element(v.begin(), v.end())
#define VMIN_P(v) min_element(v.begin(), v.end())
#define VMAX_IDX(v) distance(v.begin(), VMAX_P(v))
#define VMIN_IDX(v) distance(v.begin(), VMIN_P(v))
#define VCOPY(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define SUPPER(src, dst) transform(src.begin(), src.end(), dst.begin(), toupper);
#define SLOWER(src, dst) transform(src.begin(), src.end(), dst.begin(), tolower);

using namespace std;
using ll = long long;

int main(int argc, const char *argv[])
{
    int n, d, cnt = 0;
    cin >> n >> d;
    int a[n][d];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            cin >> a[i][j];
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            double dis = 0;
            for (int k = 0; k < d; k++)
            {
                dis += pow(a[i][k] - a[j][k], 2);
            }
            dis = sqrt(dis);
            if (dis == (int)dis)
            {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<bitset>
#include<iomanip>
#include<cctype>

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

using namespace std;
const int inf = 1001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

//mod計算用のクラス
class ModInt{
public:
    long long int x;
    long long int mod;
	ModInt(){}
    ModInt(long long int _x, long long int _mod = 1000000007){
        this->x = _x % _mod;
        this->mod = _mod;
    }
	ModInt operator+(ModInt other){
		return ModInt(this->x + (other.x % this->mod),this->mod);
	}
	ModInt operator-(ModInt other){
		long long int res = this->x - (other.x % this->mod);
		if (res < 0) return ModInt(res + this->mod, this->mod);
		return ModInt(res);
	}
	ModInt operator*(ModInt other){
		return ModInt(this->x * (other.x % this->mod),this->mod);
	}
	ModInt operator/(ModInt other){
		return ModInt(*this * other.inv());
	}
	ModInt pow(long long int n){
		ModInt res(1, this->mod), a(this->x, this->mod);
		while (n){
			if (n & 1){
				res = res * a;
			}
			n >>= 1;
			a = a * a;
		}
		return res;
	}
	ModInt inv(){
		return ModInt(this->pow(this->mod - 2));
	}
	void disp(){
		cout << this->x << endl;
	}
};
ostream& operator<<(ostream& stream, const ModInt m){
	stream << to_string(m.x);
	return stream;
}

//mod nCrを返す関数.ModIntが必要.
ModInt modcomb(long long int n, long long int r, long long int _mod = 1000000007){
	ModInt x(1, _mod), y(1, _mod);
	for (long long int i = 0; i < r; i++){
		x = x * ModInt(n - i);
		y = y * ModInt(i + 1);
	}
	return x / y;
}


int main(){
	int x, y; cin >> x >> y;
	if ((2*y-x) % 3 != 0 || 2*y < x){
		cout << 0 << endl;
		return 0;
	}
	if ((2*x-y) % 3 != 0 || 2*x < y){
		cout << 0 << endl;
		return 0;
	}
	int a = (2 * y - x) / 3;
	int b = (2 * x - y) / 3;

	cout << modcomb(a + b, a) << endl;

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import math
from sys import stdin
N,D = map(int,input().split())

data = [stdin.readline().rstrip().split() for _ in range(N)]
#print(data)

cnt = 0
for i in range(N):
    j = int(data[i][0])
    k = int(data[i][1])
    l = math.sqrt(j*j+k*k)
    if l<=D:
        cnt = cnt +1
print(cnt)

Measured memory_bytes: 67608
h,w,n=map(int,input().split())
r,c=map(int,input().split())
s=input()
t=input()
import sys
l_l=c
r_l=w+1-c
u_l=r
d_l=h+1-r
s_count=[0,0,0,0]
t_count=[0,0,0,0]
if s[0]=='L':
    s_count[0]=s_count[0]+1
elif s[0]=='R':
    s_count[1]=s_count[1]+1
elif s[0]=='U':
    s_count[2]=s_count[2]+1
elif s[0]=='D':
    s_count[3]=s_count[3]+1
if s_count[0]-t_count[1]>=l_l:
    print('NO')
    sys.exit()
if s_count[1]-t_count[0]>=r_l:
    print('NO')
    sys.exit()
if s_count[2]-t_count[3]>=u_l:
    print('NO')
    sys.exit()
if s_count[3]-t_count[2]>=d_l:
    print('NO')
    sys.exit()
for i in range(n-1):
    if t[i]=='L' and t_count[0]+1-s_count[1]<l_l:
        t_count[0]=t_count[0]+1
    elif t[i]=='R' and t_count[1]+1-s_count[0]<r_l:
        t_count[1]=t_count[1]+1
    elif t[i]=='U' and t_count[2]+1-s_count[3]<u_l:
        t_count[2]=t_count[2]+1
    elif t[i]=='D' and t_count[3]+1-s_count[2]<d_l:
        t_count[3]=t_count[3]+1
    if s[i+1]=='L':
        s_count[0]=s_count[0]+1
    elif s[i+1]=='R':
        s_count[1]=s_count[1]+1
    elif s[i+1]=='U':
        s_count[2]=s_count[2]+1
    elif s[i+1]=='D':
        s_count[3]=s_count[3]+1
    if s_count[0]-t_count[1]>=l_l:
        print('NO')
        sys.exit()
    if s_count[1]-t_count[0]>=r_l:
        print('NO')
        sys.exit()
    if s_count[2]-t_count[3]>=u_l:
        print('NO')
        sys.exit()
    if s_count[3]-t_count[2]>=d_l:
        print('NO')
        sys.exit()
print('YES')


Measured memory_bytes: 49120
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]
if (
       (A[0][0] in B and A[0][1] in B and A[0][2] in B)
    or (A[1][0] in B and A[1][1] in B and A[1][2] in B)
    or (A[2][0] in B and A[2][1] in B and A[2][2] in B)
    or (A[0][0] in B and A[1][0] in B and A[2][0] in B)
    or (A[0][1] in B and A[1][1] in B and A[2][1] in B)
    or (A[0][2] in B and A[1][2] in B and A[2][2] in B)
    or (A[0][0] in B and A[1][1] in B and A[2][2] in B)
    or (A[0][2] in B and A[1][1] in B and A[2][0] in B)
    ):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <stdio.h>

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

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

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        //out.println("AMAN");
        int n = sc.nextInt(), s=sc.nextInt();
        int[] w = new int[n];
        int[] v = new int[n];
        for(int i=0;i<n;i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }

        long dp[] = new long[s+1];
        
        for(int i=0;i<n;i++) {
            for(int j=s;j>=0;j--) {
                if(j-w[i]>=0)
                    dp[j] = Math.max(dp[j],dp[j-w[i]]+v[i]);
            }
        }
        long res=0;
        for(int i=0;i<=s;i++) {
            res = Math.max(res,dp[i]);
        }
        out.print(res);

        out.flush();
        out.close();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

Measured memory_bytes: 21456
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *D = map(int, read().split())

sum = 0

for i in range(N):
    for j in range(N):
        if i == j : continue
        else:
            sum += D[i]*D[j]

print(int(sum/2))



Measured memory_bytes: 2940
#include<stdio.h>

int partition(int A[], int p, int r){
	int x = A[r-1], temp;
	int i = p-1, j;
	for( j = p; j < r-1; j++ ){
		if( A[j] <= x ){
			i++;
			temp = A[i];
			A[i] = A[j];
			A[j] = temp;
		}
	}
	temp = A[i+1];
	A[i+1] = A[r-1];
	A[r-1] = temp;
	return i+1;
}

int main(){
	int n, i, p;
	int A[100000];
	scanf("%d", &n);
	for( i = 0; i < n; i++ ){ scanf("%d", &A[i]); }
	p = partition(A, 0, n);
	if( p == 0 ){ printf("["); }
	printf("%d", A[0]);
	if( p == 0 ){ printf("]"); }
	for( i = 1; i < n; i++ ){
		if( p == i ){
			printf(" [");
		}else{
			printf(" ");
		}
		printf("%d", A[i]);
		if( p == i ){ printf("]"); }
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 996
using System;
using System.Linq;

namespace _023_CirclesIntersection
{
	class Program
	{
		static void Main ( string[] args )
		{
			int dataCount = int.Parse (Console.ReadLine ());

			for (int lp = 0; lp < dataCount; lp++)
			{
				double[] inputData = Console.ReadLine ().Split (' ').Select (str => double.Parse (str)).ToArray ();

				double x1 = inputData[0]; double y1 = inputData[1]; double radius1 = inputData[2];
				double x2 = inputData[3]; double y2 = inputData[4]; double radius2 = inputData[5];

				double distance = Math.Sqrt (
					(x1 - x2) * (x1 - x2) +
					(y1 - y2) * (y1 - y2));

				if (distance + radius2 < radius1)
					Console.WriteLine ("2");			//B in A
				else if (distance + radius1 < radius2)
					Console.WriteLine ("-2");			//A in B
				else if (distance <= radius1 + radius2)
					Console.WriteLine ("1");			//intersect
				else
					Console.WriteLine ("0");			//not intersect
			}
		}
	}
}

Measured memory_bytes: 9644
<?php

fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%s", $s);
$s = str_split($s);

$cnt = 1;
$tmp = $s[0];
for ($i = 1; $i < $n; ++$i) {
    if ($s[$i] !== $tmp) {
        ++$cnt;
        $tmp = $s[$i];
    }
}

echo $cnt, PHP_EOL;


Measured memory_bytes: 10744
def find_triangle_count(d):
    n = len(d)
    d.sort()
    res = 0
    for i in range(n - 2):
        k = i + 2
        for j in range(i + 1, n - 1):
            while k < n and d[i] + d[j] > d[k]:
                k += 1
            if k > j:
                res += k - j - 1
    return res


def solve():
    input()
    input_list = list(map(lambda x: int(x), input().split()))
    print(find_triangle_count(input_list))


if __name__ == '__main__':
    solve()

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

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

    /* string outputS=s[0]+ (string)(s.size()-2) +s[s.size()-1];
    cout<<outputS<<endl; */
    cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
    return 0;
    
}

Measured memory_bytes: 256
from collections import deque

n = int(input())
a = list(map(int, input().split()))

b = deque()
for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
if n % 2 == 1:
    b.reverse()

print(" ".join(map(str, b)))


Measured memory_bytes: 29124
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main _ =
    let [|M1;D1|] = reada int
    let [|M2;D2|] = reada int

    if M1 = 12 then
        if M2 = 1 then printfn "1"
        else printfn "0"
    else
        if M1 < M2 then printfn "1"
        else printfn "0"
    0


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int prime[] = new int[1000000];
		int n;
		int sum;

		Arrays.fill(prime, 1);
		prime[0] = 0;
		prime[1] = 0;
		for (int i = 2; i <= 1000000 / 2; i++) {
			for (int j = i * 2; j < 1000000; j += i) {
				prime[j] = 0;
			}
		}

		while (true) {
			n = sc.nextInt();
			if (n == 0) {
				break;
			}
			sum = 0;
			for (int i = 0; i < n; i++) {
				int p = sc.nextInt();
				int m = sc.nextInt();
				for (int j = 0 <= p - m ? p - m : 0; j <= p + m && j < 1000000; j++) {
					sum += prime[j];
				}
			}
			System.out.println(sum - n);
		}
	}
}

Measured memory_bytes: 32968
from collections import Counter

n=int(input())
a=list(map(int,input().split()))

is_p=[1 for i in range(10**6+1)]

for i in set(a):
  v=i
  if is_p[v]:
    for j in range(v+v,10**6+1,v):
      is_p[j]=0

c=Counter(a)

cnt=0
for i in a:
  if is_p[i]==1 and c[i]==1:
    cnt+=1

print(cnt)

Measured memory_bytes: 47752
N, M = map(int, input().split())

if N == 1:
    num_list = [0]
    done_list = [False]
else:
    num_list = [1] + [0] * (N-1)
    done_list = [False] * (N)

result = 0
for i in range(M):
    s, c = map(int, input().split())
    if not done_list[s-1]:
        num_list[s-1] = c
        done_list[s-1] = True
    elif num_list[s-1] == c:
        pass
    else:
        result = -1
        break
    if N > 1 and s == 1 and c == 0:
        result = -1
        break

if result == 0:
    result = "".join(map(str, num_list))
print(result)


Measured memory_bytes: 38256
n=int(input())
mod=10**9+7
ans=1
pre=0
s,t=input()+"#",input()+"#"
now=0
yoko=[6,2,3]
tate=[3,2,1]
while now<n:
    if s[now]==s[now+1]:
        ans=ans*yoko[pre]%mod
        pre=2
        now+=2
    else:
        ans=ans*tate[pre]%mod
        pre=1
        now+=1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  string S;
  
  cin >> S;
  
  int num = S.size();
  
  int num2 = 0;
  
  int num3 = num / 2;
  
  for(int i = 0;i < num3;++i){
    if(!(S[i] == S[num - 1 - i])){
      num2++;
    }
  }
  
  cout << num2 << 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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int H1, M1, H2, M2, K; cin >> H1 >> M1 >> H2 >> M2 >> K;
    int N = (H2 - H1) * 60 + M2-M1;
    cout << N-K << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1000000007;
int ksm(int b,int p)
{
	int ans=1;
	for(;p;p>>=1)
	{
		if(p&1)
			ans=ans*b%mod;
		b=b*b%mod;
	}
	return ans;
}
signed main()
{
	int n,i;
	cin>>n;
	if(n==1)
		cout<<0;
	else
		cout<<((ksm(10,n)+mod+mod+mod-2*ksm(9,n))%mod+ksm(8,n))%mod;
	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);

    long long N, K;
    cin >> N >> K;
    vector<int> dest(N+1);
    for (int i = 1; i <= N; ++i) cin >> dest[i];
    if (K == 0) {
        cout << 1 << endl;
        return 0;
    }

    vector<int> path;
    vector<bool> visited(N+1, false);
    vector<int> pos(N+1);
    int i;
    for (i = 1; !visited[i]; i = dest[i]) {
        pos[i] = path.size();
        path.push_back(i);
        visited[i] = true;
    }
    int cycleStart = pos[i];
    int cycleLen = path.size() - cycleStart;

    if (K <= cycleStart) {
        cout << path[K] << endl;
    }
    else {
        K -= cycleStart;
        K %= cycleLen;
        cout << path[cycleStart + K] << endl;
    }

    return 0;
}

Measured memory_bytes: 5924
import java.util.Scanner;

/**
 * @author kep
 * @date 2020-09-14
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long ans = 0;
        long[] max = new long[4];
        long[] min = new long[4];
        for(int i = 0;i<4;i++){
            max[i] = Long.MIN_VALUE;
            min[i] = Long.MAX_VALUE;
        }
        for(int i = 0;i<n;i++){
            long x = scanner.nextLong();
            long y = scanner.nextLong();
            for(int j = 0;j<4;j++){
                long tmp_x = (j >> 1) == 1?-x:x;
                long tmp_y = (j & 1) == 1?-y:y;
                long tmp = tmp_x + tmp_y ;
                min[j] = Math.min(min[j],tmp);
                max[j] = Math.max(max[j],tmp);
                ans = Math.max(ans,max[j]-min[j]);
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 60208
import sys
import math
import collections
import bisect
import copy

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, m = ns()
    e = [[] for _ in range(n)]
    prnt_cnt = [0 for _ in range(n)]
    ans = [-1 for _ in range(n)]

    for _ in range(n - 1 + m):
        a, b = ns()
        a, b = a - 1, b - 1
        e[a].append(b)
        prnt_cnt[b] += 1

    root_idx = prnt_cnt.index(0)

    que = collections.deque([root_idx])

    while que:
        q = que.popleft()
        for ei in e[q]:
            prnt_cnt[ei] -= 1
            if prnt_cnt[ei] == 0:
                ans[ei] = q
                que.append(ei)

    for ansi in ans:
        print(ansi + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24276
#include<iostream>

using namespace std;

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

int main(){
  int i,j,k;
  int S,h=0,m=0,s;

  cin >> S;
  s = S % 60;
  S = (S - s) / 60;
  m = S % 60;
  h = (S - m) / 60;
  cout << h << ":" << m << ":" << s << endl;
    
  return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define f(ii,n) for(ii=0;ii<n;ii++)
#define F(ii,a,n) for(ii=a;ii<n;ii++)
#define read(array,n) for(ll i=0;i<n;i++) cin>>array[i];
#define inf 1000000007;
// function to transform string to lowercase --> transform(s.begin(),s.end(),s.begin(),::tolower)
void swap(ll *xp,ll *yp){
	ll temp = *xp;
	*xp = *yp;
	*yp = temp;
}

ll power(ll i,ll j){
	ll prod=1;
	while(j>0){
		if(j&1){
			prod=prod*i;
		}
		j=j>>1;
		i=i*i;
	}
	return prod;
}

void solve(){
	ll n,i,j;
	cin>>n;
	ll ar[n+1],v[n+1]={0};
	for(i=2;i<=n;i++){
		cin>>ar[i];

	}
	for(i=2;i<=n;i++){
		v[ar[i]]++;
	}
	for(i=1;i<=n;i++){
		cout<<v[i]<<endl;
	}
	
}
int main(){
	solve();
	//freopen("filename.txt","r",stdin);
	// ll t;
	// cin>>t;
	// while(t--){
	// 	solve();
	// }
}

Measured memory_bytes: 6756
S = input()
s1 = int(S[:2])
s2 = int(S[2:])

def may_month(s):
  return 1<=s<=12

# どっちもMMかもしれない
if may_month(s1) and may_month(s2):
  print("AMBIGUOUS")
  
# どっちもMMじゃない
elif not (may_month(s1) or may_month(s2)):
  print("NA")

# 前半がMMかもしれない
elif may_month(s1):
  print("MMYY")
  
# 後半がMMかもしれない
elif may_month(s2):
  print("YYMM")

Measured memory_bytes: 3060
#include <stdio.h>
int main(){
  int a[3],max=0,i;
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  for(i=0;i<3;i++){
    if(max<a[i]){
      max=a[i];
    }
  }
  if(max*2==a[0]+a[1]+a[2]){
    printf("Yes\n");
  }else{
    printf("No\n");

  }
   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
	 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
#define clr(a) memset(a,0,sizeof(a))
#define umap unordered_map
#define uset unordered_set
#define fr first
#define sc second
#define pb push_back
#define M int(1e9+7)
#define endl '\n'	
#define largest(a,b,c) (a>b?(a>c? a:c):(b>c? b:c))
#define smallest(a,b,c) (a<b?(a<c? a:c):(b<c? b:c))	

using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;

 
int main(){
	fast_io; cout_precision;
	ll x,k,d;	cin >> x >> k >> d;
	ll res ;
	if(x != 0){
		x = abs(x);
		if(k <= x/d)	res = x- (k)*d;
		else{
			res = x - (x/d)*d;
			k-=(x/d);
			if(k&1){
				res = min(abs(res+d) , abs(res - d));
			}
		}
	}
	else if(x == 0){
		if(k&1)	res = d;
		else	res = 0;
	}
	cout << res <<endl;

	return 0;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main( void ){
  double a,b,x; cin >> a >> b >> x;
  double ans;
  if(x == a*a*b/2){
    ans = 45;
  }else if( x < a*a*b/2){
    double rad = atan2(b, 2*x/a/b);
    ans = rad*180.0/M_PI;
  }else{
    double rad = atan2(2*b-2*x/a/a, a);
    ans = rad*180.0/M_PI; 
  }
  printf("%.12f\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007

int main() {
    ll n,w;
    cin>>n>>w;
    ll a[105],b[105],i,j;
    for(i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];
    }
    ll value=n*1000;
    ll dp[n+1][value+1];
    for(i=0;i<=value;i++)
    dp[1][i]=INT_MAX;
    dp[1][0]=0;
    dp[1][b[1]]=a[1];
    for(i=2;i<=n;i++)
    {
        for(j=0;j<=value;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(b[i]-j>0)
            continue;
            dp[i][j]=min(dp[i][j],a[i]+dp[i-1][j-b[i]]);
        }
    }
    ll k=0;
    for(i=0;i<=value;i++)
    {
        if(dp[n][i]<=w)
        k=i;
    }
    cout<<k<<"\n";
	return 0;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
#define MOD 1000000007
#define int long long

using namespace std;

int Map[1000001];

signed main()
{
	int x=0,y=0;
	cin >> x >> y;
	if ((x+y)%3!=0)
	{
		cout << 0;
		return 0;
	}		
	int m = (2*y-x)/3;	
	if ((2*y-x)<0 || (2*y-x)%3!=0)
	{
		cout << 0;
		return 0;
	}
	int n = (x-m)/2;		
	if ((x-m)<0 || (x-m)%2!=0)
	{
		cout << 0;
		return 0;
	}
	for (int i=n+1; i<=n+m; i++)
	{
		int ii = i;
		while (ii%2==0)
		{
			ii/=2;
			Map[2]++;
		}
		int sqrtII = round(sqrt(ii));
		for (int j=3; j<=sqrtII; j+=2)
		{
			while (ii%j==0)
			{
				ii/=j;
				Map[j]++;
			}
		}
		if (ii!=1)
			Map[ii]++;
	}
	for (int i=2; i<=m; i++)
	{
		int ii = i;
		while (ii%2==0)
		{
			ii/=2;
			Map[2]--;
		}
		int sqrtII = round(sqrt(ii));
		for (int j=3; j<=sqrtII; j+=2)
		{
			while (ii%j==0)
			{
				ii/=j;
				Map[j]--;
			}
		}
		if (ii!=1)
			Map[ii]--;
	}
	int res=1;
	for (int i=2; i<=1000000; i++)
	{
		for (int j=1; j<=Map[i]; j++)
		{
			res = (res*i)%MOD;
		}
	}	
	cout << res;
	return 0;
}


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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> p(m);
  for (auto&& e : p) cin >> e.second >> e.first;
  sort(begin(p), end(p));
  int x(0);
  int ans(0);
  for (auto&& e : p) {
    if (e.second >= x) {
      ans++;
      x = e.first;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int left, right;
  left = A + B;
  right = C + D;
  
  if (left == right) cout << "Balanced" << endl;
    else if (left > right) cout << "Left" << endl;
  	else cout << "Right" <<endl;
}

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

int main()
{
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;
}

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

int main(void)
{
    int N,K;
    cin>>N>>K;
    int min=1;
    int max=N-K+1;
    if(K==1){
        cout<<0;
    }else{
        cout << max-min;
    }
    return 0;
}

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

vector<ll> color(220,0);
vector<vector<ll>> edges(220);

vector<vector<ll>> d(220,vector<ll>(220,(ll)1e15));

bool bi(ll v, ll c){
    color[v] = c;
    for (auto e : edges[v]) {
        if( color[e] == c ) return false;
        
        if( color[e] == 0 && !bi(e,-c)) return false; 
    }
    return true;
}

int main() {
    ll n;
    std::cin >> n;
    vector<string> s(n);
    
    for (int i = 0; i < n; i++) {
        std::cin >> s[i];
        for (int j = 0; j < n; j++) {
            if(s[i][j]=='1'){
                edges[i].push_back(j);
                d[i][j] = 1;
            }
            if(i==j){
                d[i][j] = 0;
            }
        }
    }
    
    if(!bi(0,1)){
        std::cout << -1 << std::endl;
        return 0;
    }
    
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    ll res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            res = max(res,d[i][j]);
        }
    }
    
    std::cout << res+1 << std::endl;
    
    
    
}


Measured memory_bytes: 1152
S = list(input())
odd = []
even = []
for i, v in enumerate(S):
    if i % 2 == 0:
        if v == "R" or v == "U" or v == "D":
            pass
        else:
            odd.append(v)

    else:
        if v == "L" or v == "U" or v == "D":
            pass
        else:
            even.append(v)

if odd or even:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3060
def prime_factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n //=2
    f=3
    while f**2<=n:
        if n%f==0:
            a.append(f)
            n //=f
        else:f +=2
    if n!=1:a.append(n)
    return a


mod=10**9+7
n=int(input())
cnt={}
for i in range(1,n+1):
    for j in prime_factorize(i):
        if j not in cnt:cnt[j]=1
        else:cnt[j] +=1

ans=1
for i in cnt.values():
    ans=ans*(i+1)%mod
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long dp[3001][3001];
int main()
{
    int n;
    cin>>n;
    long long a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    //dp[i][j]=i-dp[i+1][j-1]||j-dp[]
    for(int gap=1;gap<=n;gap++)
    {
        for(int i=0;i<n;i++)
        {
            int j=i+gap-1;
            if(i==j) dp[i][j]=a[i];
            else if(j<n)
            {
                dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
            }

        }
    }
    cout<<dp[0][n-1]<<endl;
}

Measured memory_bytes: 70016
N = int(input())
S = [[0, 0, 0]]
S.extend([list(map(int, input().split())) for i in range(N)])

for i in range(N):
    t = abs(S[i][0] - S[i + 1][0])
    d = abs(S[i][1] - S[i + 1][1]) + abs(S[i][2] - S[i + 1][2])
    if t < d:
        print("No")
        exit()
    if t % 2 != d % 2:
        print("No")
        exit()

print("Yes")


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

int main() {
  string s;
  cin >> s;
  if(s == "SUN") cout << 7 << endl;
  if(s == "MON") cout << 6 << endl;
  if(s == "TUE") cout << 5 << endl;
  if(s == "WED") cout << 4 << endl;  
  if(s == "THU") cout << 3 << endl;
  if(s == "FRI") cout << 2 << endl;
  if(s == "SAT") cout << 1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
using namespace std;
vector<int> mp[200001];
bool go1[200001],go2[200001];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;++i)
	{
		int t1,t2;
		scanf("%d%d",&t1,&t2);
		mp[t1].push_back(t2);
		mp[t2].push_back(t1);
	}
	for (size_t i=0;i<mp[1].size();++i)
		go1[mp[1][i]]=true;
	for (int i=1;i<=n;++i)
		if (go1[i])
			for (size_t j=0;j<mp[i].size();++j)
				go2[mp[i][j]]=true;
	printf("%s",go2[n]?"POSSIBLE":"IMPOSSIBLE");
	return 0;
}


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

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

    vector<int> p(n + 1, INT_MAX);
    for (size_t i = 1; i <= n; i++)
    {
        int num;
        cin >> num;
        p[num] = i;
    }

    int cnt = 0;
    int idx = INT_MAX;
    for (size_t i = 1; i <= n; i++)
    {
        idx = min(p[i], idx);
        if (idx == p[i])
        {
            cnt++;
        }

    }

    cout << cnt << endl;
}


Measured memory_bytes: 1024
import sys
n = int(input())
L = [int(i) for i in input().split()]
now = [0, 0, 0] # [R, G, B]

s = 1
now[0] = 1
if L[0] != 0:
  print(0)
  sys.exit()

  
for i in range(n-1):
  c = L[i+1]
  s = s*now.count(c)
  for j in range(3):
    if now[j] == c:
      now[j] += 1
      break

print((s*3)%1000000007)

Measured memory_bytes: 14396
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int H,W; cin >> H >> W;
    int c[10][10]; REP(i,10)REP(j,10) cin >> c[i][j];
    int A[H][W]; REP(i,H)REP(j,W) cin >> A[i][j];

    REP(k,10)REP(i,10)REP(j,10) chmin(c[i][j], c[i][k]+c[k][j]);

    int ans = 0;
    REP(i,H)REP(j,W){
        if(A[i][j] == -1) continue;
        ans += c[A[i][j]][1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import sys
nm =input().rstrip().split(" ")
n =int(nm[0])
m =int(nm[1])
direcs=[]
for i in range(m):
    direcs.append(input().rstrip().split(" "))
#print(direcs)
trdirecs=list(map(list, set(map(tuple, direcs))))
#print(trdirecs)
first=[]
second=[]
third=[]
for j in trdirecs:
    if int(j[0])==1:
        first.append(int(j[1]))
    if int(j[0])==2:
        second.append(int(j[1]))
    if int(j[0])==3:
        third.append(int(j[1]))
if len(first)!=0 and first[0]==0 and (n==2 or n==3):
    answer=-1
    print(answer)
    sys.exit()
    
'''print(first)
print(second)
print(third)'''
'''if len(first)>1 or len(second)>1 or len(third)>1:
    print(-1)'''
if len(first)==0:
    first.append(0)
if len(second)==0:
    second.append(0)
if len(third)==0:
    third.append(0)
#数字が条件を満たしているかどうか判定する
if n==1:
    for i in range(0,10):
        if i==first[0]:
            answer=i
elif n==2:
    for i in range(0,100):
        d1=int((i-i%10)/10)
        d2=i%10
        if d1==first[0] and d2 ==second[0]:
            answer=i
            if answer<=9:
                answer=10+i
elif n==3:
    for i in range(0,1000):
        d3=i%10
        a=int((i-d3)/10)
        d2=a%10
        d1=int((a-a%10)/10)
        #print(d1,d2,d3)
        if d1==first[0] and d2==second[0] and d3==third[0]:
            answer=i
            if answer<100:
                answer=100+i
if len(first)>1 or len(second)>1 or len(third)>1:
    answer=-1
print(answer)

Measured memory_bytes: 3192
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<tuple>
#include<utility>
typedef long long LL;
typedef unsigned long long ULL;
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define pb push_back
#define mp make_pair

int main() {
	int n, h = 0, count = 0;
	cin >> n;
	rep(i, 0, n) {
		int H;
		cin >> H;
		if (h <= H) {
			count++;
		}
		h = max(h, H);
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
	int a,b,c,d,x,y,z;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a>=b)
	{
		x=a-b;
	}
	else
	{
		x=b-a;
	}
		if(b>=c)
	{
		y=b-c;
	}
	else
	{
		y=c-b;
	}
		if(a>=c)
	{
		z=a-c;
	}
	else
	{
		z=c-a;
	}
	
	if(x<=d && y<=d || z<=d)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
	
}

Measured memory_bytes: 1716
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int r, d, x;

signed main() {
    cin >> r >> d >> x;
    rep(i,10) {
        x = r*x - d;
        cout << x << endl;
    }
}


Measured memory_bytes: 256
function Main(input) {
    var N = parseInt(input[0], 10);
    var V = input.slice(1, 1 + N).map(v => parseInt(v, 10))
    var C = input.slice(1 + N, 2 * N + 1).map(v => parseInt(v, 10))

    // console.log(N);
    // console.log(V);
    // console.log(C);

    var result = 0;

    for (var i = 0; i < N; i++) {
        var value = V[i] - C[i]
        if (value > 0) {
            result += value;
        }
    }
    console.log(result);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 21064
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))
#from collections import deque

N, K = mi()
D = li()

r = [i for i in range(10) if i not in D]

if r[0]==0:
    #que = deque(r[1:])
    que = r[:][1:]
else:
    #que = deque(r)
    que = r[:]

for num in que:
    if N <= num:
        print(num)
        exit()
i = 0
while True:
    base = que[i]*10
    for num in r:
        new = base + num
        if new >= N:
            print(new)
            exit()
        que.append(new)
    #if que[-1] >= 10**6:
        #break
    i += 1

#ind = bisect.bisect_left(que, N)
#print(que)
#print(ind)
#print(que[ind])


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
int main(){
    ll n, k;
    cin >> n >> k;
	char d[k];
    for (ll i = 0; i < n;i++){
        cin >> d[i];
    }
    ll i = n;
    while (true) {
        bool flag = false;
        string price = to_string(i);
        for (ll j = 0; j < k; j++) {
            if (count(price.begin(), price.end(), d[j])) flag = true;
        }
		if(flag){
            i++;
            continue;
        }
		else
            break;
	}
    cout << i << endl;
}


Measured memory_bytes: 3744
import Data.List.Split (splitOn)
import Data.List (transpose)

stat :: [String] -> [Int]
stat ts = map howMany ["A", "B", "AB", "O"]
    where howMany t = length $ filter (== t) ts

main :: IO ()
main = putStr . unlines . map show . (\[_, l] -> stat l) . transpose . map (splitOn ",") . lines =<< getContents

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

int main() {
  int X, N;
  cin >> X >> N;
  
  int count = 0;
  
  while(X > 0){
    X /= N;
    count++;
    
    }
    
    cout << count  << endl;
  }
  

  
    



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi pair<ll,ll>
#define pii pair<pi,ll>
#define fr freopen("in.txt","r",stdin)
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define frep(i,n) for(int i=1;i<=n;i++)
#define ll long long
#define f first
#define s second
int t[101];
int v[101];
double dp[101][101];
double INF = 1e18;
bool vis[101][101];
int N;
double rec(int i,int cur) {
    if(i==N) {
        if(cur==0) return 0;
        return -INF;
    }

    if(vis[i][cur]) {
        return dp[i][cur];
    }
    vis[i][cur] = 1;
    double ans = -INF;
    double x,t1,t2,t3;
    for(int j=0;j<=v[i+1];j++) {
        int lim = min(j,v[i]);
        x = min((double)v[i],((double)(cur+lim+t[i]))/2);
        t1 = x-cur;
        t3 = x-lim;
        t2 = t[i]-t1-t3;
        if(t1>=0 and t2>=0 and t3>=0) {
            double val = 0;
            val += cur*t1+0.5*t1*t1;
            val += x*t2;
            val += x*t3-0.5*t3*t3;
            ans = max(ans,val+rec(i+1,lim));
        }
    }
    return dp[i][cur] = ans;
}
int main() {
    cin >> N;
    rep(i,N) {
        cin >> t[i];
    }
    rep(i,N) {
        cin >> v[i];
    }
    cout << setprecision(10) << fixed<<rec(0,0);
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    int a;
    int x = -1;
    int id = -1;
    FOR(i, 1, n + 1) {
        cin >> a;
        if (i != a) {
            if (x == -1) {
                x = a;
                id = i;
            } else {
                if (i != x || id != a) {
                    cout << "NO" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 256
N, X, Y = map(int, input().split())
ans = [0] * N

for fr in range(1, N + 1):
    for to in range(fr + 1, N + 1):
        cost = min(to - fr, abs(X - fr) + abs(to - Y) + 1)
        ans[cost] += 1

print(*ans[1:], sep="\n")


Measured memory_bytes: 46428
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int count = 0;
		
		for(int i = a; i <= b; i++){
			if(c % i == 0){
				count++;
			}
		}
		System.out.println(count);
		
	sc.close();
	}
}

Measured memory_bytes: 26172