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

#define sz(x) ((int)x.size())

using namespace std;








const int MAXN = 100 * 1000 + 23;




struct cmp { bool operator () (const vector<int>& x, const vector<int>& y) const { return x.back() > y.back(); } };


int n, m, a[MAXN], nc;
long long ans;
vector<int> g[MAXN];
priority_queue<vector<int>, vector<vector<int>>, cmp> sv;
bitset<MAXN> mark, mirk;


void inpre();
vector<int>& dfs(int);
void efs(int);


int main() {
    inpre();
    for (int i = 0; i < nc - 2; i++) {
        if (sv.empty())
            return cout << "Impossible", 0;
        vector<int> x = sv.top();
        sv.pop();
        ans += x.back();
        x.pop_back();
        if (!x.empty())
            sv.push(x);
    }
    cout << ans;
    return 0;
}
void inpre() {
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v), g[v].push_back(u);
    }
    for (int i = 0; i < n; i++)
        if (!mirk[i]) {
            efs(i);
            nc++;
        }
    if (nc == 1) {
        cout << 0;
        exit(0);
    }
    vector<int> v;
    for (int i = 0; i < n; i++) {
        if (!mark[i]) {
            v = dfs(i);
            sort(v.begin(), v.end(), [](int x, int y) { return x > y; });
            ans += v.back();
            v.pop_back();
            if (!v.empty())
                sv.push(v);
        }
    }
}
vector<int>& dfs(int v) {
    mark[v] = true;
    vector<int>& ret = *new vector<int>{a[v]}, &tmp = *new vector<int>;
    for (auto u : g[v])
        if (!mark[u]) {
            tmp = dfs(u);
            if (tmp.size() > ret.size()) {
                for (auto i : ret)
                    tmp.push_back(i);
                swap(ret, tmp);
            }
            else
                for (auto i : tmp)
                    ret.push_back(i);
        }
    return ret;
}
void efs(int v) {
    mirk[v] = true;
    for (auto u : g[v])
        if (!mirk[u])
            efs(u);
}

Measured memory_bytes: 106332
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	string S; cin >> S;
	string str = S.substr(0, 4);
	if (str == "YAKI") {
		yes;
		return 0;
	}
	no;
}

Measured memory_bytes: 256
#include <stdio.h>

int ori[45];

int fibonacci(int );

int main()
{
  int i,n;
  
  ori[0]=1;
  ori[1]=1;
  

  for(i=2;i<45;i++) ori[i]=-1;

  scanf("%d",&n);
  printf("%d\n",fibonacci(n));

  return 0;
}

int fibonacci(int n)
{
  if(n==0 || n==1) return ori[0];
  if(ori[n]!=-1) return ori[n];
  return ori[n]=fibonacci(n-1)+fibonacci(n-2);
}


Measured memory_bytes: 2112
path = [0 for _ in range(4)]
for _ in range(3):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a] += 1
    path[b] += 1
ans = 0
for i in range(4):
    if path[i] % 2 == 1:
        ans += 1
if ans ==  2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9160
#include <iostream>
#include <ios>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

using i64 = long long int;

using namespace std;

const int MAX = 1010000;
const int MOD = 1000000007;

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

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

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

int main() {
    COMinit();
    i64 x, y;
    cin >> x >> y;
    i64 ans = 0;
    i64 op1, op2;
    op1 = op2 = -1;
    for (int i = 0; i <= x; ++i) {
        if ((x - i) % 2 == 0) {
            i64 top1 = i;
            i64 top2 = (x - i) / 2;
            if (top1 * 2 + top2 == y) {
                op1 = top1;
                op2 = top2;
            }
        }
    }
    if (op1 == -1) {
        cout << 0 << endl;
        return 0;
    }
    else {
        cout << (fac[op1 + op2] * finv[op1]% MOD) * finv[op2] % MOD << endl;
    }
    
}

Measured memory_bytes: 23936
#include <stdio.h>

int main(void)
{

	long s;
	long hh, mm, ss;

	scanf("%ld", &s);

	hh = s / 3600;
	mm = (s - 3600 * hh) / 60;
	ss = s - 3600 * hh - 60 * mm;

	printf("%ld:%ld:%ld\n", hh, mm, ss);

	getchar();

	return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int W =sc.nextInt();
        int H =sc.nextInt();
        int x =sc.nextInt();
        int y =sc.nextInt();
        int r =sc.nextInt();
        if(W>=r+x && H>=r+y && x>0 && y>0){
        System.out.println("Yes");
        }else{
        System.out.println("No");  
        }
    }
}
        
        


Measured memory_bytes: 26304
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        new Main().run2();
    }
	double allCount = 0;
	double ansCount = 0;
	int[] dx = {-1,0,0,1};
	int[] dy = {0,-1,1,0};
	int s;
	int t;
	int b;
	int n;
	int[][][][] memo;
	public void run2(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			n = Integer.parseInt(scan.nextLine());
			if(n == 0){
				break;
			}
			allCount = 0;
			ansCount = 0;
			char[] ch = scan.nextLine().replaceAll(" ","").toCharArray();
			s = (ch[0] - 'A');
			t = ch[1] - 'A';
			b = ch[2] - 'A';
			memo = new int[n+1][2][3][3];
			for(int i = 0;i < n+1;i++){
				for(int j = 0;j < 3;j++){
					for(int k = 0;k < 3;k++){
						memo[i][0][j][k] = -1;
						memo[i][1][j][k] = -1;
					}
				}
			}
			int[] ans = dfs2(s/3,s%3,0);
			System.out.printf("%.6f\n",(double)ans[1] / (double)ans[0]);
		}
	}
	public int[] dfs2(int y,int x,int count){
		int[] a = {0,0};
		if(memo[count][0][x][y] >= 0){
			a[0] += memo[count][0][x][y];
			a[1] += memo[count][1][x][y];
			return a;
		}
		if(count == n){
			memo[count][0][x][y] = a[0] = 1;
			memo[count][1][x][y] = a[1] = 0;
			if(x == t % 3 && y == t/3){
				memo[count][1][x][y] = a[1] = 1;
			}
			return a;
		}
		int[] c = new int[2];
		for(int i = 0;i < 4;i++){
			if(x+dx[i] >= 0 && x+dx[i] < 3 && y+dy[i] >= 0 && y+dy[i] < 3){
				if(x+dx[i] == b % 3 && y+dy[i] == b / 3){
					c = dfs2(y,x,count+1);
				}else{
					c = dfs2(y+dy[i],x+dx[i],count+1);
				}
			}else{
				c = dfs2(y,x,count+1);
			}
			a[0] += c[0];
			a[1] += c[1];
			memo[count][0][x][y] = a[0];
			memo[count][1][x][y] = a[1];
		}
		return a;
	}
}

Measured memory_bytes: 23632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] ins = br.readLine().split(" ");
		int n = Integer.parseInt(ins[0]);
		int T = Integer.parseInt(ins[1]);

		ins = br.readLine().split(" ");
		int t[] = new int[n];
		for ( int i = 0; i < n; i++ ) {
			t[i] = Integer.parseInt(ins[i]);
		}
		br.close();

		long total = 0;
		for ( int i = 1; i < n; i++ ) {
			int diff = t[i] - t[i - 1];
			total += (diff > T) ? T : diff;
		}
		System.out.println(total + T);
	}
}

Measured memory_bytes: 50652
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string.h>
 
using namespace std;
typedef long long ll;

int dp[150000000];

int main()
{
	int H, N;
	int A[10000], B[10000];
	
	scanf("%d %d", &H, &N);
	for(int i = 0; i < N;i++){
		scanf("%d %d", &A[i], &B[i]);
	}
	
	int jCount = 1000000;
	if(N <= 10){
		jCount *= 110;
	}
	
//	for(int i = 0; i < N+1; i++){
		for(int j = 0; j < jCount; j++){
			dp[j] = 0;
		}
//	}
	
	for(int i = 1; i < N+1; i++){
		for(int j = 0; j < jCount; j++){
			if(j >= B[i-1]){
				int tmp = dp[j-B[i-1]]+A[i-1];
				dp[j] = max(dp[j], tmp);
			}else{
				// dp[j] = dp[j];
			}
		}
	}
	
	ll min = 9999999999;

	for(int j = 0; j < jCount; j++){
		if(dp[j] >= H){
			if(j < min){
				min = j;
			}
		}
	}
	
	printf("%lld\n", min);
	
	return 0;
}

Measured memory_bytes: 430208
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int x = 0, y = 0;
	for(char c:s) {
		if (c=='a') {
			if (x < a+b) {
				x++;
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
		else if (c == 'b') {
			if (x < a + b && y < b) {
				x++;
				y++;
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
		else {
			cout << "No" << endl;
		}
	}


	return 0;
}

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

L_max = 0
R_min = N

for i in range(M):
    L, R = map(int, input().split())
    R_min = min(R,R_min)
    L_max = max(L,L_max)

print(max(R_min-L_max+1,0))

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





void bubbleSort(int A[],int N){
    int flag = 1;
    int tmp;
    int count=0;
    while (flag){
        flag= 0;
        for ( int j = N-1; j>0; j--){
            if (A[j] < A[j-1]){
                tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                flag = 1;
                count++;
            }
        }
    }
    for (int k=0; k < N-1; k++) cout << A[k] <<" ";
    cout << A[N-1] << endl;
    cout << count << endl;
}


int main(){
    int N;
    int A[100];
    
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    bubbleSort(A,N);  
    
    
}


Measured memory_bytes: 3084
#include<iostream>
#include<string>
using namespace std;
int main(void){
    string S;
    int N,A,B,m;
    cin>>S;
    N=S.size();
    m=1000;

    for(int i=0;i<=N-3;i++){
        A=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
        B=abs(A-753);
        m=min(m,B);

    }

    cout<<m<<endl;




    return 0;
}

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

int main()
{
    long long N;
    cin >> N;

    vector<long long> A(N + 1, 0);
    map<long long, long long> m;
    m[0]++;
    for (int i = 1; i <= N; i++)
    {
        cin >> A[i];
        A[i] += A[i - 1];
        m[A[i]]++;
    }

    long long ans = 0;
    for (auto x : m)
    {
        ans += x.second * (x.second - 1) / 2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 14336
def isPrime(x):
    if x <= 1:
        return 0
    for i in range(2, int(x**0.5) + 1):
        if x % i == 0:
            return 0
    return 1

n = int(input())
sum = 0

for i in range(n):
    if isPrime(int(input())):
        sum += 1
print(sum)


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

constexpr int64_t mod = 998244353;

int main() {
  string s;
  int k;
  cin >> s >> k;
  s += '0';
  int len = s.size();
  vector<int> v;
  int m = 0;
  for (char c : s) {
    if (c == '0') {
      v.push_back(m);
      m = 0;
    } else {
      m++;
    }
  }
  int n = v.size();
  k = min(k, len - n);
  vector dp(n + 1, vector(k + 1, vector(k + 1, 0L)));
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= k; j++) {
      for (int l = j; l <= k; l++) {
        dp[i][j][l] %= mod;
        for (int x = 0; l + x <= k; x++) {
          dp[i+1][j][l+x] += dp[i][j][l];
        }
        for (int x = 1; x <= v[i]; x++) {
          if (j + x > k) break;
          dp[i+1][j+x][l] += dp[i][j][l];
        }
      }
    }
  }
  int64_t ans = 0;
  for (int i = 0; i <= k; i++) {
    ans += dp[n][i][i];
  }
  cout << ans % mod << endl;
}


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

using namespace std;

const int N = (1e5)+5, MOD = 1e9+7;
long long fac[N], invfac[N];

int ppow(int a, int b)
{
    if (b == 0) return 1;
    long long x = ppow(a, b/2);
    x = x * x % MOD;
    if (b % 2 == 1) {
        x = x * a % MOD;
    }
    return x;
}

int nCr(int n, int r)
{
    return 1ll * fac[n] * invfac[r] % MOD * invfac[n-r] % MOD;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    fac[0] = 1;
    for (int i = 1; i < N; ++i) {
        fac[i] = fac[i-1] * i % MOD;
    }
    for (int i = 0; i < N; ++i) {
        invfac[i] = ppow(fac[i], MOD-2);
    }
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    long long an = 0;
    for (int i = 0, j = n-1, x = n-1, y = k-1; x >= y; ++i, --j, --x) {
        an -= 1ll * a[i] * nCr(x, y) % MOD;
        an += 1ll * a[j] * nCr(x, y) % MOD;
    }
    an = (an + MOD) % MOD;
    cout << an << endl;
    return 0;
}


Measured memory_bytes: 2176
n,m=gets.split.map &:to_i

res = 1
if (n-m).abs > 1
    puts 0
    exit
end
if n==m
    res = 2
end
n,m = m,n if m>n

while n != 1
    res = res*n*m
    res %= 10**9+7
    n-=1
    m-=1
end
puts res

Measured memory_bytes: 1788
n, m, l = map(int, input().split())

matrix_A = [list(map(int, input().split())) for _ in range(n)]
matrix_B = [list(map(int, input().split())) for _ in range(m)]

matrix_B_transposed  = list(map(list, zip(*matrix_B)))

for a in matrix_A:
    c = []
    for bt in matrix_B_transposed:
        c.append(sum(x * y for (x, y) in zip(a, bt)))
    print(*c)


Measured memory_bytes: 6680
#include <iostream>

using namespace std;

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

    int n, v[20], c[20];
    int x[20];

    cin >> n;

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

    int aux1 = 0;
    int aux2 = 0;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        if ((v[i] - c[i]) > 0) {
            aux1 += v[i];
            aux2 += c[i];
        }
    } 


    if ((aux1-aux2) <= 0) {
        cout << 0 << endl;
    }
    else {
        cout << aux1 - aux2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
//#include <map>

//using namespace std;
//map<int> m;

#define BUF (100)

int N, M;
int a[BUF], b[BUF];

void input(void){
	scanf("%d %d",&N,&M);

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


int f(int k, int n, int *d) {


	d[n] = 1;

	int i;
	int ret = 0;
	/*
	for (i = 1; i <= N; i++) {
		if (d[i] == 0) ret == 0;
	}
	if (ret) return 1;//

	if (k == N-1) return 0;//
	*/
	if (k == N) {
		d[n] = 0;
		return 1;
	}

	for (i = 0; i < M; i++) {
		if (a[i] == n && d[b[i]]== 0) {
			ret += f(k + 1, b[i], d);
		}

		if (b[i] == n && d[a[i]] == 0) {
			ret += f(k + 1, a[i], d);
		}
	}
	
	d[n] = 0;

	return ret;
}



int main(void){
	input();

	int d[N+1];
	memset(d,0,sizeof(d));
	printf("%d",f(1,1,d));
	return 0;
}



Measured memory_bytes: 128
#include <iostream> 
using namespace std;
int main()
{   int a,b,c;
    cin>>a>>b>>c;
    int p=a+b; int q=b+c; int r=a+c;
    if(p<q){  (p<r)?(cout<<p) : (cout<<r) ;}
    else if (q<p){ (q<r)? (cout<<q) : (cout<<r)   ;}
    else {cout<<p;}
    return 0;
 
}

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

typedef long long ll;
using namespace std;

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

	int n,m; 
	int a[205];

	cin >> n >> m;

	for (int i = 0;i < n*2;i++){
		a[i] = i+1;
	}

	int nex[205];

	for (int i = 0;i < m;i++){
		int k; cin >> k;
		if(k > 0){
			for (int j = 0;j < n*2;j++){
				if(j < k) nex[2*n-(k-j)] = a[j];
				else nex[j-k] = a[k+j-k];
			} 
		}else{
			for (int j = 0;j < n;j++){
				nex[j*2] = a[j];
				nex[j*2+1] = a[n+j];
			}
		}
		for (int j  = 0;j < 2*n;j++){
			a[j] = nex[j];
		}
	}

	for (int i = 0;i < 2*n;i++){
		cout << a[i] << endl;
	}

	return 0;

}


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

const int maxn = 10005;
const int maxm = 1050;

int N, W;
int v[105], w[105];
int f[105][10050];

int main()
{
	cin >> N >> W;
	for (int i = 1; i <= N; i++)
		cin >> v[i] >> w[i];
	memset(f, 0, sizeof(f));
	for (int i = 1; i <= N; i++)
		for (int j = 1; j <= W; j++)
		{
			f[i][j] = (i == 1 ? 0 : f[i - 1][j]);
			if (j >= w[i])
				f[i][j] = max(f[i][j], f[i - 1][j - w[i]] + v[i]);
		}
	cout << f[N][W] << endl;
	return 0;
}

Measured memory_bytes: 7192
#include<iostream>

using namespace std;

int main()
{
	int n,k,i;
	string s;
	cin >> n >> k;
	cin >> s;
		if(s[k-1] == 'A')
		{
			s[k-1] = 'a';
		}
		else if(s[k-1] == 'B')
		{
			s[k-1] = 'b';
		}
		else if(s[k-1] == 'C')
		{
			s[k-1] = 'c';
		}
	
	cout << s << endl;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int y,x,d,w,h;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
string s;
int main(){
  while(cin>>w>>h,w){
    y=x=d=0;
    while(cin>>s){
      if(s=="STOP"){cout<<x+1<<' '<<y+1<<endl;break;}
      else if(s=="RIGHT")d=(d+1)%4;
      else if(s=="LEFT")d=(d-1+4)%4;
      else{
	int n=d,c;
	if(s=="BACKWARD")n=(n+2)%4;
	cin>>c;
	while(c--){
	  int yy=y+dy[n];
	  int xx=x+dx[n];
	  if(0<=yy&&yy<h)y=yy;
	  if(0<=xx&&xx<w)x=xx;
	}
      }
    }
  }
}

Measured memory_bytes: 3156
n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
cnt={}
for i in range(n):
  for j in range(n):
    if i==j:
      continue
    p=arr[i][0]-arr[j][0]
    q=arr[i][1]-arr[j][1]
    if (p,q) not in cnt:
      cnt[(p,q)]=1
    else:
      cnt[(p,q)]+=1
if n==1:
  print(1)
else:
  ans=n-max(cnt.values())
  print(ans)

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


int main() {
  
  string S;
  cin>>S;
  
  if((S[0]==S[1]&&S[2]==S[3]&&S[0]!=S[2])
     ||(S[0]==S[2]&&S[1]==S[3]&&S[0]!=S[1])
     ||(S[0]==S[3]&&S[1]==S[2]&&S[0]!=S[2])){
       cout<<"Yes"<<endl;
     }else{
       cout<<"No"<<endl;
     }
     
}


 
  
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(j,n) for(int j=0;j<n;j++)
using namespace std;
int main (void){
	stack<int> s;
	char b[200];
	int temp,temp1;
	while(scanf("%s",b) != EOF){
		if(b[0] == '-'){	
				temp = s.top();
				s.pop();
				temp1 = s.top();
				s.pop();
				s.push(temp1 - temp);
			}
		else if(b[0] == '+'){	
				temp = s.top();
				s.pop();
				temp1 = s.top();
				s.pop();
				s.push(temp + temp1);
			}
		else if( b[0] =='*'){	
				temp = s.top();
				s.pop();
				temp1 = s.top();
				s.pop();
				s.push(temp * temp1);
		}
		else if(b[0] =='/'){	
				temp = s.top();
				s.pop();
				temp1 = s.top();
				s.pop();
				s.push(temp1 / temp);
			}
		else{
				s.push(atoi(b));
		}
	 }
	
	cout << s.top() << endl;
	return 0;
}

Measured memory_bytes: 1204
#include<iostream>

using namespace std;




unsigned long long Lucas(int j){
	unsigned long long  memo[120] = {2,1};
	for(int i = 2; i < 90; i++){
		memo[i] = memo[i-1] + memo[i-2] ;
	}
	
	return memo[j] ;
	
	


}


int main(void){
	int N ;
	cin >> N ;
	
	
	cout << Lucas(N) << endl;
	
	
	
	
	return 0;
	
}

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

int main() {
  int A,B,N,x;
  cin >> A >> B;
  N = B - A;
  x = 0;

  for (int i = -1; i < N; i++) {
    if ((A / 10000 == A % 10) && (A % 10000 / 1000 == A % 100 /10)) {
      x++;
    }
    A++;
  }
  cout << x << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <math.h>
#include <iomanip>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;


int const static limit = 100;
int t[limit][limit];

int H,W;
int h,w;
int main(){
  cin>>H>>W>>h>>w;
  rep(i,H)rep(j,W)t[i][j] = 1;
  rep(i,h)rep(j,W)t[i][j] = 0;
  rep(j,w)rep(i,H)t[i][j] = 0;
  int sum = 0;
  rep(i,H)rep(j,W) if(t[i][j] == 1) sum++;
  cout<< sum << endl;

}

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

int st,h[100010];
int memo[100010];

int go(int ind)
{
    if(ind == st-1) return 0;
    if(memo[ind]!=-1) return memo[ind];

    int x = 1<<20 ,y = 1<<20;
    if(ind+1<st) x = abs(h[ind]-h[ind+1]) + go(ind+1);
    if(ind+2<st) y = abs(h[ind]-h[ind+2]) + go(ind+2);
    return memo[ind] = min(x,y);
}

int main()
{
    cin>>st;
    for(int i = 0;i<st;i++) cin>>h[i];
    memset(memo,-1,sizeof memo);

    cout<<go(0)<<endl;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int gcd(int a,int b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

ll N,M;


int main()
{
	int c[3][3];
	REP(i,3){
		REP(j,3){
			cin >> c[i][j];
		}
	}

	if(c[1][0]-c[0][0]==c[1][1]-c[0][1]&&c[1][0]-c[0][0]==c[1][2]-c[0][2]&&
	c[2][0]-c[0][0]==c[2][1]-c[0][1]&&c[2][0]-c[0][0]==c[2][2]-c[0][2]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner stdIn=new Scanner(System.in);

        int N=stdIn.nextInt();
        int M=stdIn.nextInt();
        int []h=new int[N];
        int []a=new int[M];
        int []b=new int[M];
        int []c=new int[N];
        int sum=0;

        for(int i=0; i<N; i++){
            h[i]=stdIn.nextInt();
        }
        for(int i=0; i<M; i++){
            a[i]=stdIn.nextInt();
            b[i]=stdIn.nextInt();
        }
        
        for(int i=0; i<M; i++){
            if(h[a[i]-1]>h[b[i]-1]){
                c[b[i]-1]++;
            }
            else if(h[a[i]-1]<h[b[i]-1]){
                c[a[i]-1]++;
            }
            else{
                c[a[i]-1]++;
                c[b[i]-1]++;
            }
        }
        for(int i=0; i<c.length; i++){
            if(c[i]>=1){
                sum++;
            }
        }
        System.out.println(N-sum);
        
        
    }

}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  ll sum=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum +=a[i];
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    ans +=(sum-a[i])*a[i];
  }
  ans /=2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        // cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    cin >> s;
    REP(i, H) {
        REP(j, W) {
            if (s[i][j] == '#') {
                bool ok = false;
                REP(d, 4) {
                    int ii = i + DY[d];
                    int jj = j + DX[d];
                    if (OUTOFRANGE(ii, jj, H, W)) continue;
                    if (s[ii][jj] == '#') ok = true;
                }
                if (!ok) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout  << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long LL;
const LL mod = 1e9+7;
LL quick_pow(LL x, LL n, LL p)// 快速幂求x^n mod p 的结果
{
    if(n==0)
        return 1;
    if(n==1)
        return x%p;
    LL ans = 1;
    LL tmp = x%p;
    while(n)
    {
        if(n&1)
        {
            ans = (ans*tmp)%p;
        }
        tmp = tmp*tmp%p;
        n>>=1;
    }
    return ans%p;
}
LL inv(LL b,LL p) //求数 b mod p 的逆元
{
    return quick_pow(b,p-2,p);
}
LL C(LL n,LL m,LL p)//组合数取模
{
    if(m==0|| m== n)
        return 1;
    if(m==1||m==n-1)
        return n%p;
        m = min(m,n-m);
    LL up = 1,down = 1;
    for(LL i = n-m+1;i<=n;i++)
        up=(up*i)%p;
    for(LL i = 1;i<=m;i++)
    {
         down=(down*i)%p;
         //cout << down << "\n";
    }

  //  cout << up << " " << down <<"\n";
    up%=p;
    down%=p;
    return (up*(inv(down,p)%p))%p;
}
LL lucas(LL n,LL m,LL p)//递归lucas函数
{
    if(m==0)
        return 1;
    return lucas(n/p,m/p,p)*C(n%p,m%p,p)%p;
}
int main()
{

    LL n,a,b;
    cin >> n >> a >> b;
    //cout << quick_pow(2,n,mod)-1 << " "<<lucas(n,a,mod) << " " << lucas(n,b,mod) << "\n";
    cout << (quick_pow(2,n,mod)+mod-1LL-lucas(n,a,mod)-lucas(n,b,mod)+mod)%mod << "\n";
    return 0;
}


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

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

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	COMinit();

	ll n,k;
	cin>>n>>k;
    ll ans[n];
    ans[0] = 1;

    rep(i,n-1){
        ans[i+1] = (ans[i] + COM(n,(i+1))*COM(n-1,i+1)%MOD)%MOD;
    }

    if(k>=n){
        cout<<ans[n-1]<<"\n";
    }else{
        cout<<ans[k]<<"\n";
    }


	return 0;
}

Measured memory_bytes: 6528
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();

		int ans = 0;
		for (int i = 0; i < K; i++){
			if (A > B){
				if (A > C){
					A *= 2;
				}else{
					C *= 2;
				}
			}else{
				if (B > C){
					B *= 2;
				}else{
					C *= 2;
				}
			}

		}

		System.out.println(A + B + C);
	}
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		 Scanner sc = new Scanner(System.in);
		 double[] A=new double[11];
		while(sc.hasNext()){
			double sum=0;
			double a=sc.nextDouble();
			A[1]=a;
			for(int i=2; i<=10; i++){
				if(i%2==0){
					A[i]=2*A[i-1];
				}else{
					A[i]=A[i-1]/3.0;
				}
				
				
			}
			System.out.println(add(A));
		}
	}
	public static double add(double[] A){
		double sum=0;
		for(int i=1; i<=10; i++){
			sum+=A[i];
		}
		return sum;
	}


















	}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  for(int N, M; ~scanf("%d%d", &N, &M) && N;) {
    int sum[N + 1]; sum[0] = 0;

    int res = 0;
    rep(i, N) {
      int A; scanf("%d", &A); A %= M;
      sum[i + 1] = sum[i] + A;
      sum[i + 1] %= M;
      maximize(res, sum[i + 1]);
    }

    set<int> st = {M};

    REP(i, 1, N + 1) {
      maximize(res, sum[i] + M - *st.upper_bound(sum[i]));
      st.insert(sum[i]);
    }

    cout << res << endl;

  }
  
  return 0;
}

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

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

  vector<int> A(N);
  for (int i = 0; i < A.size(); i++) {
    cin >> A.at(i);
  }

  int flag = 1;
  int swapTimes = 0;
  int i = 0;
  while (flag) {
    flag = 0;
    for (int j = N - 1; j > i; j--) {
      if (A.at(j) < A.at(j - 1)){
        swap(A.at(j), A.at(j - 1));
        flag = 1;
        swapTimes++;
      }
    }
    i++;
  }

  for (int i = 0; i < A.size(); i++) {
    cout << A.at(i);
    if (i < A.size() - 1) {
      cout << " ";
    }
    else {
      cout << endl;
    }
  }

  cout << swapTimes << endl;

  return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<algorithm>
#include<set>

using namespace std;
typedef long long ll;

ll ans = 0;
int N;
ll s[100000];

ll dp[101000];//dp[k]だった時のans cは配列の使いまわしのよってカバー
set<int> used;

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

	ll ans = 0;// == 0の時の答えが0

	for (int C = 1; C <= N - 2; C++) {
		used.clear();
		//kを決めてる
		dp[0] = 0;
		for (int k = 1;; k++) {
			if (N - 1 - C * k <= 0)break;
			if (k * C >= N - 1)break;
			if (N - 1 - C * k - C <= 0)break;
			if (2 * C * k == N - 1)continue;
			if (used.find(C * k) != used.end() || used.find(N - 1 - C * k) != used.end())break;
			dp[k] = dp[k - 1] + s[N - 1 - k * C] + s[C * k];
			ans = max(ans, dp[k]);
			used.insert(C * k), used.insert(N - 1 - k * C);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    vl ans(n,0);
    rep(i,n-1){
        ll t;
        cin>>t;
        ans[t-1]++;
    }
    rep(i,n)puta(ans[i]);
    return 0;
}

Measured memory_bytes: 4768
MOD = 10**9 + 7

N,M = map(int,input().split())
a = [0] * N
b = [0] * N
c = [0] * M
d = [0] * M
min = [MOD] * N
min_num = [0] * N
for i in range(N): a[i],b[i] = map(int,input().split())
for t in range(M): c[t],d[t] = map(int,input().split())

for j in range(N):
    for q in range(M):
        dist = abs(a[j] - c[q]) + abs(b[j] - d[q])
        if dist < min[j]:
            min[j] = dist
            min_num[j] = q + 1
for k in min_num: print(k)


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

using namespace std;
    long long a,d[2],n;
    map<long long,long long> m;
    vector<long long> v;
int main(){
    scanf("%lld",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a);
        m[a]++;
        if(m[a]%2==0){
            v.push_back(-a);
        }
        //printf("%d %d %d\n",m[a],d[0],d[1]);
    }
    sort(v.begin(),v.end());
    if(v.size()<2) printf("0");
    else printf("%lld",v[0]*v[1]);
    return 0;
}


Measured memory_bytes: 6528
N = gets.to_i
As = gets.split.map(&:to_i)

mx = ->(a, b){a > b ? a : b}
ab = ->(a, b){(a - b).abs}
as = As.map.with_index.sort_by(&:first).reverse
dp = Array.new(N + 1){Array.new(N + 1, 0)}
(0 ... N).each do |n|
  a, i = as[n]
  (0 .. n).each do |l|
    r = n - l
    dp[l + 1][r] = mx[dp[l +1][r], dp[l][r] + a*ab[i, l]]
    dp[l][r + 1] = mx[dp[l][r + 1], dp[l][r] + a*ab[i, N - r - 1]]
  end
end
puts (0 ... N).map{dp[_1][N - _1]}.max

Measured memory_bytes: 45728
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

from collections import defaultdict


dic = defaultdict(int)

N = int(input())
for _ in range(N):
    dic[str(input())] += 1

M = int(input())
for _ in range(M):
    dic[str(input())] -= 1

ans = 0
for tmp in dic:
    ans = max(ans, dic[tmp])

print (ans)

Measured memory_bytes: 3316
// ~/SolverToBe/Developers/Corvus
// ~/sudo apt-get verdict Accpeted

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <functional>
#include <assert.h>
#include <complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int N = 100005, M = 505;
const ll MOD = 1e9 + 7;
const double eps = 1e-9;
const double PI = acos(-1.0);

int n, k;

int check(int x) {
	int cnt = 0;
	while (x < k) {
		x <<= 1;
		cnt++;
	}
	return cnt;
}

int main() {
	scanf("%d%d", &n, &k);
	double ans = 0;
	for (int i = 1; i <= n; i++) {
		double cur = (1.0 / (1.0*n));
		cur *= pow(0.5, check(i));
		ans += cur;
	}
	printf("%.9lf\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

using namespace std;

int cntSwap;

void bubbleSort(int A[], int N) {
	//i?????????????????¨???????????????????????????????????¨???
	for (int i = 0; i < N - 1; i++) {
		for(int j = N - 1; i < j; j--) {
			if(A[j -1] > A[j]) {
				swap(A[j -1], A[j]);
				cntSwap++;
			}
		}
	}
}

void printArray(int A[], int N) {
	for (int i = 0; i < N - 1; i++)
		cout << A[i] << " ";
	cout << A[N - 1] << endl;
}

int main() {
	int N;
	cin >> N;
	int A[N];
	for (int i = 0; i < N; i++)
		cin >> A[i];
	bubbleSort(A, N);
	printArray(A, N);
	cout << cntSwap << endl;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

vector<int> to[200005];

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    for (int e: to[0]) {
        for (int x: to[e]) {
            if (x==n-1) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    
    
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 14928
package main

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


func main () {
	var n int
	fmt.Scan(&n)

	scanner := bufio.NewScanner(os.Stdin)
	vs := strToIntSlice(scanLine(scanner))
	cs := strToIntSlice(scanLine(scanner))

	sumDiff := 0
	for index := 0; index < n; index++ {
		if vs[index] > cs[index] {
			sumDiff += vs[index] - cs[index]
		}
	}

	fmt.Println(sumDiff)
}


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

func strToIntSlice(line string) []int {
	strSlice := strings.Split(line, " ")

	var intSlice []int
	for _, str := range strSlice {
		intValue, _ := strconv.Atoi(str)
		intSlice = append(intSlice, intValue)
	}

	return intSlice
}


Measured memory_bytes: 640
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int d[20][20];
int dd[20][20][2];
int used[110][110];
int adder[20][20];

int main()
{
  int i,j,a,b,k,l,ss,tt,n,st1,st2,b1,b2,o,p,prev;
  vector<pair<pair<int,int>,int> > ans;
  scanf("%d%d",&a,&b);
  for (i=1;i<=a;i++)
    for (j=1;j<=b;j++)
    {
      scanf("%d",&d[i][j]);
    }
  memset(dd,-1,sizeof(dd));
  
  for (i=1;i<=a;i++)
    for (j=1;j<=b;j++)
    {
      b1=0;
      for (k=0;k<110;k++)
      {
        for (l=0;l<110;l++)
        {
          if (k*i+l*j>d[i][j]) continue;
          b2=1;
          adder[i][j]=d[i][j]-k*i-l*j;
          for (o=1;o<=a;o++)
            for (p=1;p<=b;p++)
              if (adder[i][j]+o*k+p*l<d[o][p]) b2=0;
          if (b2==0) continue;
          b1=1;
          dd[i][j][0]=k;
          dd[i][j][1]=l;
          break;
        }
        if (b1==1) break;
      }
      if (b1==0)
      {
        printf("Impossible\n");
        return 0;
      }
    }
  printf("Possible\n");
  ans.clear();
  ss=0;
  st1=0;
  n=1;
  prev=0;
  for (i=0;i<110;i++)
  {
    ans.push_back(make_pair(make_pair(prev,n),-1));
    prev=n;
    n++;
  }
  tt=n;
  st2=n;
  prev=n;
  n++;
  for (j=0;j<110;j++)
  {
    ans.push_back(make_pair(make_pair(n,prev),-2));
    prev=n;
    n++;
  }
  memset(used,0,sizeof(used));
  //cout<<dd[1][1][0]<<" "<<dd[1][1][1]<<" "<<adder[1][1]<<endl;
  for (i=1;i<=a;i++)
    for (j=1;j<=b;j++)
    {
      if (used[dd[i][j][0]][dd[i][j][1]]==0)
      {
        used[dd[i][j][0]][dd[i][j][1]]=1;
        ans.push_back(make_pair(make_pair(st1+dd[i][j][0],st2+dd[i][j][1]),adder[i][j]));
      }
    }
  printf("%d %d\n",n,(int)ans.size());
  for (i=0;i<ans.size();i++)
  {
    printf("%d %d ",ans[i].first.first+1,ans[i].first.second+1);
    if (ans[i].second==-1) printf("X\n");
    else if (ans[i].second==-2) printf("Y\n");
    else printf("%d\n",ans[i].second);
  }
  printf("%d %d\n",ss+1,tt+1);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pll pair<ll,ll>
#define vll vector<ll,ll>
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>b;i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define gcd(a,b) __gcd((a),(b))
#define EPS 1e-12
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sqrt sqrtl
#define PI 3.14159265
#define cbrt cbrtl
using namespace std;

ll n,dp[200005];
int main()
{
  ll k;
  cin>>n>>k;
  ll a[n+5];
  ll i,j;
  for(i=1;i<=n;i++)
    cin>>a[i];
  dp[1]=0;
  for(i=2;i<=n;i++)
  {
     dp[i]=1e18;
     for(j=i-1;j>=max(i-k,1LL);j--)
     dp[i]=min(dp[j]+abs(a[j]-a[i]),dp[i]);
  }
  cout<<dp[n];
  return 0; 
}


Measured memory_bytes: 1792
#include<iostream>
#include<climits>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
int main(){

	int n;
	cin >> n;

	int tmp = n;
	int sum = 0;
	while(n > 0){
		sum += n % 10;
		n = n/10;
	}

	if (tmp % sum == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
t1,n1=map(int,input().split())
t2,n2=map(int,input().split())
t3,n3=map(int,input().split())
t4,n4=map(int,input().split())

I=[t1,n1,t2,n2,t3,n3,t4,n4]
i=0
while i<8:
    if I[i]==1:
        print(6000*I[i+1])
    elif I[i]==2:
        print(4000*I[i+1])
    elif I[i]==3:
        print(3000*I[i+1])
    else:
        print(2000*I[i+1])
    i=i+2


Measured memory_bytes: 5600
n = int(input())

str_n = len(str(n))
if str_n == 6:
	ans = 90909
elif str_n == 4:
	ans = 909
elif str_n == 2:
	ans = 9
elif str_n == 5:
	ans = 909 + n - 9999
elif str_n == 3:
	ans = 9 + n - 99
else:
	ans = n

print(ans)

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

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

  vi a(n+1), b(n+1);
  rep(i, 0, n) a[i+1] = a[i] + (s[i]=='#');
  for(int i = n; i > 0; i--) b[i-1] = b[i] + (s[i]=='.');

  int ans = inf;
  rep(i, 0, n+1){
    chmin(ans, a[i]+b[i]);
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;
#define ll long long


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    for (auto &x:a) cin >> x;
    for (auto &x:b) cin >> x;
    for (auto &x:c) cin >> x;
    vector<ll> temp(x * y);
    int indx = 0;
    for (int i = 0; i < x; i++)for (int j = 0; j < y; j++) temp[indx++] = a[i] + b[j];
    sort(temp.rbegin(), temp.rend());
    temp.resize(min(k, (int) temp.size()));
    vector<ll> res(temp.size() * c.size());
    indx = 0;

    for (int i = 0; i < temp.size(); i++) for (int j = 0; j < c.size(); j++) res[indx++] = temp[i] + c[j];
    sort(res.rbegin(), res.rend());

    for (int i = 0; i < k; i++) cout << res[i] << "\n";
    return 0;
}

Measured memory_bytes: 31616
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7

def resolve():
    n = int(input())
    if n % 2 != 0:
        print(0)
        exit()
    L = n // 2
    res = 0
    while L:
        res += L // 5
        L //= 5
    print(res)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9036
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;
const ll inf2 = 0x3f3f3f3f3f3f3f3f;

template<class T>void read(T &x){
    T s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    x = s*w;
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}
int N;
void solve(){
	ll ans = 0;
	for(int i = 1;i<=N;i++){
		if(N%i) ans += N/i;else ans += N/i-1;
	}
	cout<<ans<<'\n';
}	
int main(){
	// debug;

	read(N);
	solve();
	
	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
#define LLINF 1LL << 60
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

ll dp[100100];
int main() {
    int n, k; cin >> n >> k;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    rep(i,100100) {
        dp[i] = LLINF;
    }
    dp[0] = 0;
    rep(i,n) {
        REP(j,1,k+1) {
            dp[i+j] = min(abs(v[i]-v[i+j])+dp[i],dp[i+j]); 
        }
    }
    cout << dp[n-1] << endl;


    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
  int n, c;
  int d[30][30];
  int col[500][500];
  cin >> n >> c;
  REP(i, c) REP(j, c) cin >> d[i][j];
  REP(i, n) REP(j, n) cin >> col[i][j];

  int s[3][30];
  REP(i, 3) REP(j, 30) s[i][j] = 0;
  REP(i, n){
    REP(j, n){
      int k = (i + j) % 3;
      s[k][col[i][j]-1]++;
    }
  }
  ll int ans = -1;
  REP(i, c){
    REP(j, c){
      REP(k, c){
        if(i == j || i == k || j == k) continue;
        ll int tmpans = 0;
        REP(ii, c) tmpans += d[ii][i] * s[0][ii];
        REP(ii, c) tmpans += d[ii][j] * s[1][ii];
        REP(ii, c) tmpans += d[ii][k] * s[2][ii];
        // cout << tmpans << endl;
        if(ans < 0) ans = tmpans;
        else ans = min(ans, tmpans);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1280