akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A[3][3];
    int C[3][3] = {0};
    rep(i,3) {
        rep(j,3) {
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;
    vector<int> B(N);
    rep(i,N) {
        cin >> B[i];
        rep(k,3) {
            rep(j,3){
                if(A[k][j]==B[i]) C[k][j] = 1;
            }
        } 
    }
    int ans = 0;
    rep(i,3) {
        int flag = 0;
        rep(j,3){
            if(C[i][j]==1) flag++;
        }
        if(flag == 3) ans = 1; 
    } 
    rep(i,3) {
        int flag = 0;
        rep(j,3){
            if(C[j][i]==1) flag++;
        }
        if(flag == 3) ans = 1; 
    } 
    int flag2 = 0;
    rep(i,3) {
        if(C[i][i]==1) flag2++;
    }  
    if(flag2 == 3) ans = 1;  
    //cout << flag2 << endl;
    //cout << C[0][0] << endl;
    if(C[2][0]==1 && C[1][1]==1 && C[0][2]==1) ans = 1;  
    if(ans == 1) cout << "Yes"  << endl;
    else cout << "No"  << endl;
    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
s=[list(map(int,input().split())) for i in range(M)]

#print(A)
def main():
    if N==1 and M==0:
        return 0
    if N==2 and M==0:
        return 10
    if N==3 and M==0:
        return 100

        
    if N==1:
        for i in range(0,10**N):
            for j in range(M):
                if str(i)[s[j][0]-1]!=str(s[j][1]):
                    break
                if j==M-1:
                    return i
            if i==10**N-1:
                return -1
    else:
        for i in range(10**(N-1),10**N):
            for j in range(M):
                if str(i)[s[j][0]-1]!=str(s[j][1]):
                    break
                if j==M-1:
                    return i
            if i==10**N-1:
                return -1
                    

print(main())
            


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n; cin >> n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n;i++) cin >> b[i];
  vector<P> p(n);
  for(int i=0;i<n;i++) p[i]=P(b[i],a[i]);
  sort(p.begin(),p.end());
  sort(a.begin(),a.end()); sort(b.begin(),b.end());
  bool ans=true;
  int cnt=0;
  for(int i=0;i<n;i++){
    if(a[i]>b[i]) ans=false;
    if(i!=n-1&&a[i+1]<=b[i]) cnt++;
  }
  if(!ans){
    cout << "No" << endl; return 0;
  }
  int f=1;
  vector<P> q(n);
  for(int i=0;i<n;i++) q[i]=P(p[i].second,i);
  sort(q.begin(),q.end());
  bool flag=false;
  for(int i=0;i<n-1;i++) if(q[i].first==q[i+1].first) flag=true;
  int now=q[0].second;
  while(now!=0){
    f++;
    now=q[now].second;
  }
  if(f==n&&!flag) ans=false;
  if(cnt) ans=true;
  cout << (ans?"Yes":"No") << endl;
}

Measured memory_bytes: 2560
s = input()

if len(set(s)) == len(s):
    print(len(s)//2)
    exit()

ans = len(s)
for ml in [chr(i) for i in range(ord('a'), ord('z')+1)]:
    tmp = -1
    tmp_ans = 0
    for i in range(len(s)):
        if s[i] == ml:
            tmp_ans = max(tmp_ans, i - tmp - 1)
            tmp = i
    tmp_ans = max(tmp_ans, len(s) - tmp - 1)
    ans = min(ans, tmp_ans)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N=1005,M=200005;
int n,m,num,X[M],Y[M],cnt[N][N],flag1[N],flag2[N];
bool vis[N],ok[N][N],ok2[N][N];
vector<int> e[N];
void dfs(int u,int fa){
	vis[u]=1;
	ok[fa][u]=1;
	for(int i=0;i<e[u].size();i++){
		int v=e[u][i];
		if(vis[v])continue;
		dfs(v,fa);
	}
}
void dfs2(int u){
	vis[u]=1;
	for(int i=0;i<e[u].size();i++){
		int v=e[u][i];
		if(vis[v])continue;
		flag1[v]=cnt[u][v];
		dfs2(v);
	} 
}
void dfs3(int u){
	vis[u]=1;
	for(int i=e[u].size()-1;i>=0;i--){
		int v=e[u][i];
		if(vis[v])continue;
		flag2[v]=cnt[u][v];
		dfs3(v);
	} 
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		e[u].push_back(v);
		cnt[u][v]=++num;
		X[num]=u;
		Y[num]=v;
	}
	for(int i=1;i<=n;i++){
		dfs(i,i);
		memset(vis,0,sizeof(vis));
	}
	for(int i=1;i<=n;i++){
		dfs2(i);
		memset(vis,0,sizeof(vis));
		dfs3(i);
		memset(vis,0,sizeof(vis));
		for(int j=0;j<e[i].size();j++){
			int v=e[i][j];
			if(flag1[v]!=cnt[i][v]||flag2[v]!=cnt[i][v])ok2[i][v]=1;
		}
		memset(flag1,0,sizeof(flag1));
		memset(flag2,0,sizeof(flag2));
	}
	for(int i=1;i<=m;i++){
		if((ok[Y[i]][X[i]]^ok2[X[i]][Y[i]])==0)puts("same");
		else puts("diff");
	}
	return 0;
}

Measured memory_bytes: 12704
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf  = 1 << 61;
    static int[] x4 = {-1, 0, 0, 1};
    static int[] y4 = {0, -1, 1, 0};

    static int n, m, q;
    static int[] L, R;
    static int[][] X, C;

    public static void main(String[] args) {
        L = new int[2000009];
        R = new int[2000009];
        X = new int[509][509];
        C = new int[509][509];

        Scanner in = new Scanner(System.in);
        n = in.nextInt(); m = in.nextInt(); q = in.nextInt();
        for(int i = 1; i <= m; i++) {
            L[i] = in.nextInt(); R[i] = in.nextInt(); X[L[i]][R[i]]++;
        }

        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) C[i][j] = C[i][j-1] + X[i][j];
        }

        for(int i = 1; i <= q; i++) {
            int l = in.nextInt(), r = in.nextInt();
            int ans = 0;
            for(int j = l; j <= r; j++) ans += C[j][r] - C[j][l-1];
            System.out.println(ans);
        }
    }
}

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

typedef long long LL;

void fastIO_test(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve(void)
{
    LL d, t, s;
    cin >> d >> t >> s;
    float time = d/((float)s);
    if(time<=((float)t))
        cout << "Yes\n";
    else 
        cout << "No\n";
}

int main()
{
    fastIO_test();

    LL t=1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

using namespace std;

int main()
{
    int n;
    char conv[256];
    int conv2[256];
    
    for (int i = 0; i < 26; i++){
        conv[i] = 'a' + i;
        conv[i + 26] = 'A' + i;
        conv2['a' + i] = i;
        conv2['A' + i] = i + 26;
    }
    
    while (scanf("%d", &n) && n){
        int a[128];
        char s[128];
        
        for (int i = 0; i < n; i++) scanf("%d", &a[i]);
        
        scanf("%s", s);
        
        for (int i = 0; s[i]; i++){
            printf("%c", conv[(conv2[s[i]] - a[i % n] + 52) % 52]);
        }
        printf("\n");
    }
    
    return (0);
}

Measured memory_bytes: 1164
PROGRAM TypicalStairs
      IMPLICIT NONE
      integer(16) :: n,m,a(10**5)
      integer(16) :: i,pattern(-1:10**5),aCnt=1
      
      read*,n,m
      do i = 1,m
        read*,a(i)
      end do
      
      pattern = 0
      !i=1
      if( a(aCnt)==1 )then
        pattern(1) = 0
        aCnt = aCnt + 1
      else
        pattern(1) = 1
      end if
      
      !i=2
      if( a(aCnt)==2 )then
        pattern(2) = 0
        aCnt = aCnt + 1
      else
        pattern(2) = pattern(1) + 1
      end if
      
      do i = 3,n
        if( a(aCnt)==i )then
          pattern(i) = 0
          aCnt = aCnt + 1
        else
          pattern(i) = pattern(i-2) + pattern(i-1)
          pattern(i) = mod(pattern(i),10**9+7)
        end if
      end do
      
      print*,pattern(n)
  !    print*,pattern(1:n)
      
      
      
      
      END PROGRAM

Measured memory_bytes: 5892
#include <stdio.h>

int main(void)
{
	int A,B;
	scanf("%d %d",&A,&B);
	if(B == 1){
		printf("0");
		return 0;
	}
	int ans = 1;
	B = B - A;
	while(B > 0){
		B = B - (A-1);
		ans++;
	}
	printf("%d",ans);
		
	
	
	return 0;
}



Measured memory_bytes: 128
#include <cstdio>

int calc(int aa[31], int l){
	int a[31], f = 1;
	for(int i = 0;i < 31;i++)a[i] = aa[i];
	
	for(int i = 1;i < l+1;i++)if(a[i-1] < a[i])f = 0;
	for(int i = 0;f && i < l;i++)printf("%d ", a[i]);
	if(f)printf("%d\n", a[l]);
	
	while(a[l] > 1){
		if(a[l-1] < a[l]){a[l+1] += a[l] - a[l-1];a[l] -= a[l] - a[l-1];}
		else a[l]--, a[l+1]++;
		calc(a, l+1);
	}
	return 0;
}

int main(){
	int n;int a[31];
	
	while(scanf("%d", &n), n){
		for(int i = 0;i < 31;i++)a[i] = 0;a[0] = n;
		printf("%d\n", n);
		for(int i = 0;i < n-1;i++){a[0]--;a[1]++;calc(a, 1);}
	}
	return 0;
}

Measured memory_bytes: 2576
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>

#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}


int main(void) {
	int i = 1, j, k, ans = 0;

	int cnt = 1, tmp;
	int A, B;
	

	scanf("%d %d", &A, &B);
	if (B == 1) {
		printf("0\n");
		return 0;
	}

	int a = A, b;
	while (1) {
		if (a >= B) {
			break;
		}
		a += A - 1;
		cnt++;
	}
	printf("%d", cnt);

	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <list>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#define INF 2147483647

using namespace std;




int main()
{
	int n, x;
	int m[105], a[105], b[105];
	int tmp;
	int j, k, l;
	while(1) {
		cin >> n;
		if (n == 0) break;
		x = 0;
		tmp = 0;
		int min_a = INF;
		int min_b = INF;
		j = k = 0;
		for (int i = 0; i < n; i++) {
			cin >> m[i] >> a[i] >> b[i];
			if (b[i] > x) {
				x = b[i];
				l = i;
			} 
		}

		while (b[l] != INF) {
			int min_a = INF;
			int min_b = INF;
		for (int i = 0; i < n; i++) {
			if (a[i] < min_a) {
				min_a = a[i];
				j = i;
			} 
		}
		for (int i = 0; i < n; i++) {
			if (b[i] < min_b) {
				min_b = b[i];
				k = i;
			} 
		}

		if (min_a == min_b) {
			tmp += m[j];
			tmp -= m[k];
			a[j] = b[k] = INF;
		} else if (min_a < min_b) {
			tmp += m[j];
			a[j] = INF;
		} else {
			tmp -= m[k];
			b[k] = INF;
		}
		if (tmp > 150) {
			cout << "NG" << endl;
			goto next;
		}
		
		}
		cout << "OK" << endl;
		next:;
	}

	return (0);
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX
#define eps LDBL_EPSILON
#define moder 100000
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
#define ggr getchar();getchar();return 0
using namespace std;
int n,q,l,r;
string s;
int a[100010];
signed main() {
	cin>>n>>q>>s;
	rep(i,s.size()-1){
		if(s[i]=='A'&&s[i+1]=='C')a[i]++;
	}
	rep(i,s.size()){
		if(i)a[i]+=a[i-1];
	}
	rep(i,q){
		cin>>l>>r;
		if(l-2>=0)cout<<a[r-2]-a[l-2]<<endl;
		else cout<<a[r-2]<<endl;
	}
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a[5];
    for(int i=0;i<5;i++) cin>>a[i];
    int sum=0;
    for(int i=0;i<5;i++){
        sum+=a[i]/10*10;
        a[i]%=10;
    }
    sort(a,a+5);
    int num=4;
    for(int i=0;i<5;i++){
        if(a[i]==0) continue;
        else{
            num=i;
            sum+=a[i];
            break;
        }
    }
    sum+=(4-num)*10;
    
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h> 

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


Measured memory_bytes: 1712
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func max(a, b int) int {
	return int(math.Max(float64(a), float64(b)))
}

func min(a, b int) int {
	return int(math.Min(float64(a), float64(b)))
}

func abs(a, b int) int {
	return int(math.Abs(float64(a) - float64(b)))
}

type pair struct {
	first  int
	second int
}

func intToPair(i int) pair {
	a := i % 10
	iStr := strconv.Itoa(i)
	b := (int)(iStr[0] - '0')
	return pair{
		first:  a,
		second: b,
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := make(map[pair]int)

	for i := 1; i <= n; i++ {
		p := intToPair(i)
		m[p]++
	}

	ans := 0
	for i := 0; i <= n; i++ {
		p := intToPair(i)
		q := pair{first: p.second, second: p.first}
		ans += m[q]
	}

	fmt.Print(ans)
}


Measured memory_bytes: 3328
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007
#define INF 1001001001

char s[111111];
int a[111111], b[111111];

main(){
    scanf("%s", s);
    int l = strlen(s);
    for(int i=0; i<l; i++){
        if(s[i] == 'R'){
            a[i] = i+1;
        }else {
            a[i] = i-1;
        }
    }
    ll k = 1LL<<60;
    while(k){
        for(int i=0; i<l; i++){
            b[i] = a[a[i]];
        }
        for(int i=0; i<l; i++){
            a[i] = b[i];
            b[i] = 0;
        }
        k >>= 1;
    }
    for(int i=0; i<l; i++){
        b[a[i]]++;
    }
    for(int i=0; i<l; i++){
        if(i)putchar(32);
        printf("%d", b[i]);
    }
    putchar(10);
    return 0;
}

Measured memory_bytes: 1280
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define RG register
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)
#define clear(x, y) memset(x, y, sizeof(x))

inline int read()
{
	int data = 0, w = 1; char ch = getchar();
	while(ch != '-' && (!isdigit(ch))) ch = getchar();
	if(ch == '-') w = -1, ch = getchar();
	while(isdigit(ch)) data = data * 10 + (ch ^ 48), ch = getchar();
	return data * w;
}

const int _A_(15), N(110);
int d[_A_][_A_], f[N][N], A, B;

int main()
{
	A = read(), B = read();
	for(RG int i = 1; i <= A; i++)
		for(RG int j = 1; j <= B; j++)
			d[i][j] = read();
	for(RG int i = 0; i <= 100; i++)
		for(RG int j = 0; j <= 100; j++)
			for(RG int p = 1; p <= A; p++)
				for(RG int q = 1; q <= B; q++)
					f[i][j] = std::max(f[i][j], d[p][q] - i * p - j * q);
	for(RG int i = 1; i <= A; i++)
		for(RG int j = 1; j <= B; j++)
		{
			int min = 1e9;
			for(RG int p = 0; p <= 100; p++)
				for(RG int q = 0; q <= 100; q++)
					min = std::min(min, f[p][q] + i * p + j * q);
			if(min != d[i][j]) return puts("Impossible"), 0;
		}
	puts("Possible\n202 10401");
	for(RG int i = 1; i <= 100; i++)
		printf("%d %d X\n", i, i + 1);
	for(RG int i = 102; i < 202; i++)
		printf("%d %d Y\n", i, i + 1);
	for(RG int i = 0; i <= 100; i++)
		for(RG int j = 0; j <= 100; j++)
			printf("%d %d %d\n", i + 1, 202 - j, f[i][j]);
	puts("1 202");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <queue>
#include <time.h>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;

ll gcd(ll m, ll n);		//最大公倍数
ll lcm(ll m, ll n);		//最小公倍数

int main(void) {

	int ans = 0;

//	int n;
//	cin >> n;
	vector<int> v;
	
	for (int i = 0; i < 3; i++) {
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}
	sort(v.begin(), v.end());

	ans = v[2] - v[0];
			

	cout << ans << endl;

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  

#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif

Measured memory_bytes: 256
using System;

namespace procon
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var dt = new DateTime(2000, 1, 1).AddSeconds(n);
            
            Console.WriteLine("{0}:{1}:{2}",dt.Hour, dt.Minute, dt.Second);
            Console.Out.Flush();
        }
    }
}

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

int main(){
	int n;
	cin>>n;
	n=n%10;
	if(n==3){
		cout<<"bon"<<endl;
	}
	else if((n==0)||(n==1)||(n==6)||(n==8)){
			cout<<"pon"<<endl;
	}
	else{
		cout<<"hon"<<endl;
	}
	

	return 0;
}

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

int main()
{
    int n,i;
    cin>>n;
    double a[n],sum;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=1/a[i];
    }
    sum = 1/sum;
    printf("%f",sum);
    return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

sum = 0

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

print(sum)
            

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
    int W, H, N;
    cin >> W >> H >> N;

    int x, y, a;
    int a1_max_x = 0;
    int a2_min_x = W;
    int a3_max_y = 0;
    int a4_min_y = H;

    for (int i = 0; i < N; i++) {
    	cin >> x >> y >> a;

        switch (a) {
            case 1:
                if (x > a1_max_x) {
                    a1_max_x = x;
                }
                break;

            case 2:
                if (x < a2_min_x) {
                    a2_min_x = x;
                }
                break;

            case 3:
                if (y > a3_max_y) {
                    a3_max_y = y;
                }
                break;

            case 4:
                if (y < a4_min_y) {
                    a4_min_y = y;
                }
                break;
        }
    }

    int w = (a2_min_x - a1_max_x > 0) ? a2_min_x - a1_max_x : 0;
    int h = (a4_min_y - a3_max_y > 0) ? a4_min_y - a3_max_y : 0;
    int ans = w * h;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        int[] s = new int[N];
        for (int i = 0; i < K; i++) {
            int d = scan.nextInt();
            for (int j = 0; j < d; j++) {
                int x = scan.nextInt()-1;
                s[x] += 1;
            }
        }
        int ans = 0;
        for (int i = 0; i < N; i++) {
            if (s[i] == 0) {
                ans += 1;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 46340
N = int(input())
text_ls = []
for _ in range(N):
    text_ls.append(sorted(input()))

text_ls.sort()

num = 0
tmp_add = 0
for i in range(N-1):
    if text_ls[i] == text_ls[i+1]:
        num+=(1+tmp_add)
        tmp_add +=1
    else:
        tmp_add =0

print(num)

Measured memory_bytes: 24652
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    std::vector<std::vector<int>> c(3, std::vector<int>(3, 0));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            std::cin>>c[i][j];
        }
    }
    int cnt = 0;
    for(int i = 1; i < 3; i++){
        int k = c[i][0] - c[0][0];
        if(c[i][1] == c[0][1] + k && c[i][2] == c[0][2] + k){
            ++cnt;
        }
    }
    std::cout<<(cnt == 2 ? "Yes" : "No")<<std::endl;
    return 0;
}


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

#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007

int main(){
	fast;
    int d,t,s;
    cin>>d>>t>>s;
    if(ceil(d*1.0/s*1.0) <=t)
        cout<<"Yes";
    else
        cout<<"No";
	return 0;
}


Measured memory_bytes: 3548
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int d=scanner.nextInt();
		int k=scanner.nextInt();
		int r=scanner.nextInt();
		int[] a={d,k,r};
		Arrays.sort(a);
		System.out.println(a[0]+a[1]);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 167, task d, 2020/09/03
//ms,
/*
*/

int main(void){
  int N;
  int64_t K;
  vector<int> a;
  map<int, int> report;//key:訪れた町, value:遷移回数
  int loc=0;
  int mv_ctr=0;
  int cycle;
  int ans_ctr;
  int ans;

  cin >>N >>K;
  for(int i=0;i<N;i++){
    int tmp;
    cin >>tmp;
    tmp--;
    a.push_back(tmp);
  }

  while(report.count(loc)==0 && mv_ctr<=K){
    report[loc]=mv_ctr;
    mv_ctr++;
    loc=a[loc];
  }

  cycle=mv_ctr-report[loc];
  ans_ctr=(K-report[loc])%cycle+report[loc];//ここに問題ありでは？？

  for(pair<int, int> p:report){
    int loc=p.first;
    int ctr=p.second;
    if(ctr==ans_ctr) {
      ans=loc;
      break;
    }
  }

  ans++;
  cout <<ans <<endl;;
  return 0;
}
/*
Kが大きい。
ループして戻ってくるまでやり続けるのは余裕で間に合う。
mapかなあ。
順番を保存していて検索がNオーダー未満のデータ構造とかあったっけ。
mapを使ってうまいことやる、かなあ。
一応方針は合ってる。

ループしないときを忘れてる！
*/


Measured memory_bytes: 11520
program prob4
    implicit none
    integer, allocatable::c(:,:), p(:), nn(:)
    integer::n, m, i, j
    read(*,*) n, m
    allocate(c(m,2),p(n),nn(n))
    do i = 1, m
        read(*,*) c(i,:)
    end do

    p = 0
    nn = 0
    do i = 1, m
        if(c(i,1) == 1) then
            p(c(i,2)) = 1
        else if(c(i,2) == n) then
            nn(c(i,1)) = 1
        end if
    end do
    if(nn(1) == 1) then
        write(*,'(a)') "POSSIBLE"
        stop
    else
        do i = 2, n
            if(nn(i) == 1 .and. p(i) == 1) then
                write(*,'(a)') "POSSIBLE"
                stop
            end if
        end do
    end if
    write(*,'(a)') "IMPOSSIBLE"
    stop
end program

Measured memory_bytes: 6048
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i64 = input();
    let a: i64 = input();
    println!("{}", n * n - a);
}


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

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
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};

int main(){
    int N;
    cin >> N;
    vector<int> x(N), y(N), h(N);
    rep(i, N) cin >> x[i] >> y[i] >> h[i];
    
    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            ll H = -1;
            bool flag = true;
            for(int k = 0; k < N; k++){
                if(h[k] != 0){
                    if(H != -1 && H != h[k] + abs(x[k] - i) + abs(y[k] - j)){
                        flag = false;
                    }else{
                        H = h[k] + abs(x[k] - i) + abs(y[k] - j);
                    }
                }
            }

            if(flag == false) continue;

            for(int k = 0; k < N; k++){
                if(h[k] == 0){
                    if(0 < H - abs(x[k] - i) - abs(y[k] - j) ){
                        flag = false;
                    }
                }
            }

            if(flag){
                printf("%d %d %lld\n", i, j, H);
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;


class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        Dictionary<char, int> dic = new Dictionary<char, int>();



        string inpt = Reader.ReadLine();
        inpt.ToList().ForEach(a =>
        {
            if (dic.ContainsKey(a))
            {
                dic[a]++;
            }
            else
            {
                dic[a] = 1;
            }
        });

        string ans = "Yes";
        if (dic.Count(a => a.Value % 2 > 0) > 0)
        {
            ans = "No";
        }
        Console.WriteLine(ans);



    }








    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"

hthth


";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
void fail() { cout << "IMPOSSIBLE" << '\n'; exit(0); }
int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<vector<int>> children(N);
    for (int i = 1; i < N; i++) {
        int P; cin >> P; P--;
        children[P].push_back(i);
    }
    vector<int> X(N); for (auto &x : X) cin >> x;
    vector<int> Y(N, -1);
    function<void(int)> recur = [&](int node) {
        for (auto child : children[node]) recur(child);
        vector<char> A(X[node]+1);
        A[0] = 1;
        int sum = 0;
        for (auto child : children[node]) {
            sum += X[child] + Y[child];
            vector<char> B(X[node]+1);
            for (int i = 0; i <= X[node]; i++) if (A[i]) {
                if (i + X[child] <= X[node]) {
                    B[i + X[child]] = 1;
                }
                if (i + Y[child] <= X[node]) {
                    B[i + Y[child]] = 1;
                }
            }
            A.swap(B);
        }
        for (int i = X[node]; i >= 0; i--) {
            if (A[i]) {
                Y[node] = sum - i;
                return;
            }
        }
        fail();
    };
    recur(0);
    cout << "POSSIBLE\n";
    return 0;
}


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

int main() {
  std::vector<size_t> paths_of_town(4, 0);

  for (size_t i=0; i<3; i++) {
    size_t a, b;
    std::cin >> a >> b;

    paths_of_town[a-1]++;
    paths_of_town[b-1]++;
  }

  size_t ans_1 = 0;
  size_t ans_2 = 0;

  for (size_t i=0; i<4; i++) {
    if (paths_of_town[i] == 1) {
      ans_1++;
    } else if (paths_of_town[i] == 2) {
      ans_2++;
    }
  }

  std::cout << (ans_1 == 2 && ans_2 == 2 ? "YES" : "NO") << std::endl;

  return 0;
}


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


struct Sieve {
        int n;
        vector<int> f,primes;
        
        Sieve(int n=1):n(n),f(n+1){
                f[0] = f[1] = -1;
                for(long long i=2;i<=n;++i){
                        if(f[i]) continue;
                        primes.push_back(i);
                        f[i] = i;
                        for(long long j = i*i;j <= n;j += i) {
                                if(!f[j]) f[j] = i;
                        }
                }
        }
        
        bool isPrime(int x){return f[x] == x;}
        
        vector<int> factorList(int x){
                vector<int> res;
                while(x != 1){
                        res.push_back(f[x]);
                        x /= f[x];
                }
                return res;
        }
        
        vector<pair<int,int>> factor(int x){
                vector<int> fl = factorList(x);
                if(fl.size() == 0) return {};
                vector<pair<int,int>> res(1,pair<int,int>(fl[0],0));
                for(int p:fl){
                        if(res.back().first == p){
                                res.back().second ++;
                        }else{
                                res.emplace_back(p,1);
                        }
                }
                return res;
        }
        
};
 
int main() {
  Sieve sieve(100005);
  int MX = 100005;
  vector<int> like(MX+1,0);
  for(int i=1;i<MX+1;i+=2){
    if(sieve.isPrime(i) && sieve.isPrime((i+1)/2)) like.at(i) = 1;
  }
  vector<int> sum_like(MX+1,0);
  for(int i=1;i<MX+1;i++) sum_like.at(i) = like.at(i) + sum_like.at(i-1);
  int q;
  cin >> q;
  rep(i,q){
    int l,r;
    cin >> l >> r;
    cout << sum_like.at(r) - sum_like.at(l-1) << endl;
  }
    
  
  return 0;
}

   



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

#define ulli unsigned long long int
#define ll long long
#define ld long double

using namespace std; 
void solve(); 
int main() 
{ 
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
  
    int t = 1; 
    // cin >> t; 
    while (t--) { 
        solve(); 
    } 
  
    cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
    return 0; 
} 

void solve() 
{ 
	vector<vector<int> > card;
    int temp;

    card.resize(3);

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> temp;
            card[i].push_back(temp);
        }
    }

    int num;
    cin >> num;

    for (int i = 0; i < num; i++) {
        cin >> temp;
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (temp == card[j][k]) {
                    card[j][k] = 0;
                }
            }
        }
    }

    for (int i = 0; i < 3; i++) {
        if (card[i][0] == 0 && card[i][1] == 0 && card[i][2] == 0 ) {
            cout << "Yes\n";
            return;
        }

        if (card[0][i] == 0 && card[1][i] == 0 && card[2][i] == 0 ) {
            cout << "Yes\n";
            return;
        }

        if (card[0][0] == 0 && card[1][1] == 0 && card[2][2] == 0 ) {
            cout << "Yes\n";
            return;
        }

        if (card[0][2] == 0 && card[1][1] == 0 && card[2][0] == 0 ) {
            cout << "Yes\n";
            return;
        }
    }

    cout << "No\n";
}

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

int main(){
    while(1){
        int H,W;
        cin>>H>>W;
        if(H==0){
            break;
        }
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(i==0||i==H-1||j==0||j==W-1){
                    cout<<"#";
                }
                else{
                    cout<<".";
                }
            }
            cout<<endl;
          
        }
        cout<<endl;
     
    }
}


Measured memory_bytes: 3004
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  vector<bool> memo(1000005, true);
  vector<int> cnt(1000005, 0);
  rep(i, n) {
    cnt[a[i]]++;
    if(cnt[a[i]] == 1) {
      int b = 2 * a[i];
      while(b <= 1000000) {
        memo[b] = false;
        b += a[i];
      }
    }
  }
  int ans = 0;
  rep(i, n) {
    if(cnt[a[i]] == 1 && memo[a[i]]) ans++;
  }
  cout << ans << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 7948
#coding: utf-8

args = input().split()
N = int(args[0])

count = 0
for i in range(1, N+1):
    num_count = 0
    i = str(i)
    for s in i:
        num_count = num_count + 1
    if num_count % 2 ==0:
        pass
    else:
        count = count + 1

print(count)


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

int main(int argc, char* argv[]) {
    int H;
    cin >> H;
    int A[H+1];
    for (int i = 1; i < H+1; i++) scanf("%d", &A[i]);

    for (int i = 1; i < H+1; i++){
        printf("node %d: key = %d, ", i, A[i]);
        if (i/2 >= 1){
            printf("parent key = %d, ", A[i/2]);
        }
        if (2*i <= H){
            printf("left key = %d, ", A[2*i]);
        }
        if (2*i+1 <= H){
            printf("right key = %d, ", A[2*i+1]);
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 3220
from itertools import *
n, m, q = map(int, input().split())

aaa = []
for i in range(1, m+1):
    aaa.append(i)
l = []
for i in range(q):
    a = list(map(int, input().split()))
    l.append(a)
    
a = list(combinations_with_replacement(aaa, n))
ans = 0

for i in a:
    aa = 0
    for j in l:
        if i[j[1]-1] - i[j[0]-1] == j[2]:
            aa+=j[3]
        if aa > ans:
            ans = aa
print(ans)

Measured memory_bytes: 21480
def comb_mod(n,r):
    mod = 10**9+7
    ans = 1
    for i in range(r):
        ans *= n-i
        ans %= mod
    for i in range(1,r+1):
        ans *= pow(i,mod-2,mod)
        ans %= mod
    return ans

def solve():
    n, a, b = map(int, input().split())
    mod = 10**9+7
    ans = pow(2,n,mod)-comb_mod(n,a)-comb_mod(n,b)-1
    ans %= mod
    return ans
print(solve())

Measured memory_bytes: 38768
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void LCS(char *x, char *y){
	int m = strlen(x+1);
	int n = strlen(y+1);
	int i, j, **c;
	
	c = malloc(sizeof(int)*(2000));
	for (i = 0; i <= m; i++)
		c[i] = malloc(sizeof(int)*(1900));
	
	for (i = 0; i <= m; i++){
		for (j = 0; j <= n; j++){
			c[i][j] = 0;
		}
	}
	
	for (i = 1; i <= m; i++){
		for (j = 1; j <= n; j++){
			if (x[i] == y[j])
				c[i][j] = c[i - 1][j - 1] + 1;
			else if (c[i - 1][j] >= c[i][j - 1])
				c[i][j] = c[i - 1][j];
			else
				c[i][j] = c[i][j - 1];
		}
	}
	
	printf("%d\n", c[i-1][j-1]);
	for (i = 0; i < m; i++)free(c[i]);
	free(c);
	
}

int main(){
	int i, n;
	char x[1001], y[1001];

	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%s%s", x + 1, y + 1);
		LCS(x, y);
	}
	return 0;
}

Measured memory_bytes: 8200
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;
 
void solve(){
  int n,k; cin >>n >>k;
  string s; cin >>s;
  int cnt=0;
  for(int i=0; i<n-1; i++){
    if(s[i]!=s[i+1]) cnt++;
  }   
  if(k<=cnt/2) cout <<n-1-cnt+2*k;
  else cout <<n-1;
}

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

Measured memory_bytes: 3760
#include <stdio.h>
#include <math.h>

int main(void){
  int i, j, k = 3, n, s, sosu[5140];
  int max, min, mid;

  sosu[0] = 1;
  sosu[1] = 2;
  sosu[2] = 3;
  for(i = 5; i <= 50050; i += 2){
    s = 0;
    for(j = 2; sosu[j] <= sqrt((double)i); j++){
      if(i % sosu[j] == 0){
        s++;
        break;
      }
    }
    if(s == 0){
      sosu[k++] = i;
    }
  }

  while(scanf("%d", &n) != EOF){
    min = 0;
    max = k;
    mid = (min + max) / 2;
    while(min+1 != max){
      if(sosu[mid] < n){
        min = mid;
      }else if(sosu[mid] > n){
        max = mid;
      }else{
        break;
      }
      mid = (min + max) / 2;
    }
    if(sosu[mid] == n){
      printf("%d ", sosu[mid-1]);
    }else{
      printf("%d ", sosu[mid]);
    }
    printf("%d\n", sosu[mid+1]);
  }
  return 0;
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using plll=pair<ll,pll>;
using graph=vector<vector<int>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modInv(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modInv(fact))%p;
}

void pushHeap(vector<int>& h,int n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]<h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

int popHeap(vector<int>& h){
  int n=h.size()-1;
  if(n==-1)return 0;
  int i,ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]<h[j+1])j++;
    if(h[i]<h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

vector<int> ver;
void dfs(const graph &g,int v){
  ver[v]=1;
  for(auto i:g[v]){
    if(ver[i]!=1)continue;
    dfs(g,i);
  }
}

ll a[6]={1,10,9,12,3,4},b[6]={0},c[6]={0};

int main(){
  int i,j,k,cnt=0;
  string s,t="";
  cin>>s;
  int n=s.size();
  ll ans=0;
  for(i=0;i<n;i++)t+=s[n-1-i];
  ll d[n][13];
  for(i=0;i<n;i++){
    for(j=0;j<13;j++){
      d[i][j]=0;
    }
  }
  if(t[0]=='?'){
    for(i=0;i<=9;i++){
      d[0][i]=1;
    }
  }else{
    d[0][(int)(t[0]-'0')]=1;
  }
  for(i=1;i<n;i++){
    for(j=0;j<13;j++){
      if(t[i]=='?'){
        for(k=0;k<=9;k++){
          int p=(j-a[i%6]*k)%13;
          if(p<0)p+=13;
          d[i][j]+=d[i-1][p];
        }
      }
      else{
        int p=(j-a[i%6]*(ll)(t[i]-'0'))%13;
        if(p<0)p+=13;
        d[i][j]+=d[i-1][p];
      }
      if(d[i][j]>=MOD)d[i][j]%=MOD;
    }
  }
  cout<<d[n-1][5]<<endl;
}


Measured memory_bytes: 10752
#include <iostream>

using namespace std;

int sum(int x) {
    int ret = 0;
    while (x) {
        ret += x % 10;
        x /= 10;
    }
    return ret;
}

int main() {
    int a, n, m;
    cin >> a >> n >> m;

    int ans = 0;
    int x;
    for (int y = 1; y <= 72; y++) {
        x = 1;
        for (int i = 0; i < n; i++) {
            x *= y + a;
            if (x > m) goto outer;
        }
        if (sum(x) == y) ans++;
    }

    outer:
    cout << ans << endl;
}


Measured memory_bytes: 3100
# -*- coding: utf-8 -*-
"""
Set - Multi-Set
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_7_D&lang=jp

"""
from bisect import insort, bisect_right, bisect_left

class Multi_set:
    def __init__(self):
        self.total = 0
        self.ms = dict()
        self.lr = []

    def insert(self, x):
        self.total += 1
        if x in self.ms:
            self.ms[x] += 1
        else:
            self.ms[x] = 1
            insort(self.lr, x)
        print(self.total)

    def find(self, x):
        print(self.ms.get(x, 0))

    def delete(self, x):
        if x in self.ms:
            self.total -= self.ms[x]
            self.ms[x] = 0

    def dump(self, l, r):
        lb = bisect_left(self.lr, l)
        ub = bisect_right(self.lr, r)
        for i in range(lb, ub):
            k = self.lr[i]
            v = self.ms[k]
            print(f'{k}\n' * v, end='')


ms = Multi_set()
for _ in range(int(input())):
    op, x, y = (input() + ' 1').split()[:3]
    if op == '0':
        ms.insert(int(x))
    elif op == '1':
        ms.find(int(x))
    elif op == '2':
        ms.delete(int(x))
    else:
        ms.dump(int(x), int(y))



Measured memory_bytes: 16788
#include<bits/stdc++.h>
using namespace std;
 
//keep coding
//-Roshan Mitra (SIT Pune) 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define f0(i,n) for(int i=0;i<n;i++) 
#define f1(i,n) for(int i=1;i<=n;i++)
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define pb push_back
#define MP make_pair
#define FF first
#define SS second
#define int long long
#define MOD 1000000007
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 int frogb(int ind,vector<int>&dp,int n,int k,int arr[]){
     if(ind==n-1)
        return 0;
    if(dp[ind]!=-1)
        return dp[ind];
    int miniCost = INT_MAX; 
    for(int i=ind+1;i<=min(n-1,ind+k);i++) {
        int cost = abs(arr[ind] - arr[i]) + frogb(i,dp,n,k,arr); 
        miniCost = min(cost, miniCost); 
        dp[ind]=miniCost;
    }
    return dp[ind];
 }
signed main()
{

 FIO;
 int n,k;
 cin>>n>>k;
 int arr[n];
 for(int i=0;i<n;i++)
    cin>>arr[i];
 vector<int>dp(n+1,-1);
 cout<<frogb(0,dp,n,k,arr)<<endl;
   
}

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

int digit(int n){
    int d = 1;
    for(;n != 0; n /= 10){
        if(n/10 != 0){
            ++d;
        }
    }
    return d;
}

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

    for(int i = 1; i <= n; ++i){
        if(digit(i) % 2 == 1)  ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import scala.util.control.TailCalls._

object Main {
  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readInt()
    val h = io.StdIn.readLine().split(" ").map(_.toInt).toVector

    def count(vector: Vector[Int], acc: Int): TailRec[Int] = {
      if (vector.isEmpty) done(acc)
      else if (vector.forall(_ > 0)) tailcall(count(vector.map(_ - 1), acc + 1))
      else if (vector.forall(_ == 0)) done(acc)
      else {
        val idx = vector.indexOf(0)
        for {
          x <- tailcall(count(vector.take(idx), 0))
          y <- tailcall(count(vector.drop(idx + 1), acc))
        } yield x + y
      }
    }

    println(count(h, 0).result)
  }
}


Measured memory_bytes: 27532
#include <iostream>

using namespace std;

typedef long long int ll;
#define REP(i, I, N) for (int i = I; i < N; ++i)
#define rep(i, N) REP(i, 0, N)

bool isMonth(int v) {
    return (0 < v && v < 13);
}

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

    string head, end;
    head = S.substr(0, 2);
    end = S.substr(2, 2);
    int ihead = stoi(head);
    int iend = stoi(end);

    if (head == "00") {
        if (iend > 12 || iend <= 0) {
            cout << "NA" << endl;
            return 0;
        }
    }
    if (end == "00") {
        if (ihead > 12 || ihead <= 0) {
            cout << "NA" << endl;
            return 0;
        }
    }

    if (isMonth(ihead) && isMonth(iend)) {
        cout << "AMBIGUOUS" << endl;
        return 0;
    } else if (isMonth(ihead) && !isMonth(iend)) {
        cout << "MMYY" << endl;
        return 0;
    } else if (!isMonth(ihead) && isMonth(iend)) {
        cout << "YYMM" << endl;
        return 0;
    }

    cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int D, N;

int main() {
  cin >> D >> N;
  if (D == 0) {
    if (N != 100) {
      cout << N << endl;
    } else {
      cout << 101 << endl;
    }
    return 0;
  }

  if (D == 1) {
    if (N != 100) {
      cout << N * 100 << endl;
    } else {
      cout << 10100 << endl;
    }
  } else {
    if (N != 100) {
      cout << N * 10000 << endl;
    } else {
      cout << 1010000 << endl;
    }
  }
}


Measured memory_bytes: 256