akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int H,W,h,w;

void input(){
    cin >> H >> W;
    cin >> h >> w;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    cout << (H-h)*(W-w) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int> pii;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
ll D,ans;
ll pw[20];

int main(){
	cin>>D;
	if(D%9!=0){
		cout<<0<<endl;
		return 0;
	}
	
	pw[0]=1;
	for(int i=1;i<20;i++)pw[i]=pw[i-1]*10;
	
	for(int i=2;i<=18;i++){
		int k=i/2;
		for(int msk=0;msk<(1<<k);msk++){
			ll way=i%2?10:1;
			ll tmp=D;
			for(int j=0;j<k;j++){
				ll d=llabs(tmp)%10LL;
				
				if(tmp<0){
					d=10LL-d;
					d%=10LL;
				}
				
				if(msk>>j&1){
					ll nm=10LL-d;
					if(j==0)nm--;
					way*=nm;
					tmp-=d;
					tmp+=pw[i-1-j*2]*d;
				}else{
					ll nm=d;
					if(j==0)nm--;
					if(nm<0){
						way=0;
						break;
					}
					way*=nm;
					tmp+=(10LL-d);
					tmp-=pw[i-1-j*2]*(10LL-d);
				}
				tmp/=10LL;
			}
			if(tmp==0)ans+=way;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3596
//ダイクストラにて。
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <functional>
using namespace std;
//int INF = 1 << 24;

int mins(int p,int q){
  if(p<0)return q;
  else if(q<0 || p<q)return p;
  else return q;
}
int n,i,j;
int a,b,c;
int ari,man;
int lo,no,tai,mi;
typedef pair<int,int> mp;
mp pa;
int mati[10][11][2];
int daiyo[11][2];
//mati[i][0][0]に辺の数
//daiyo[i][0]は確認フラグ
//mati[i][n][0]に先の街
//mati[i][n][1]に距離
//daiyo[i][1]は距離
int main(void){
  scanf("%d",&n);
  while(n!=0){
    memset(mati,0,sizeof(mati));
    man=0;
    for(i=0;i<n;i++){
      scanf("%d%d%d",&a,&b,&c);
      mati[a][0][0]++;
      mati[a][mati[a][0][0]][0]=b;
      mati[a][mati[a][0][0]][1]=c;
      mati[b][0][0]++;
      mati[b][mati[b][0][0]][0]=a;
      mati[b][mati[b][0][0]][1]=c;
      man=(man<a)?a:man;
      man=(man<b)?b:man;
    }
    //mati[i][0][0]に辺の数
    //daiyo[i][0]は確認フラグ
    //mati[i][n][0]に先の街
    //mati[i][n][1]に距離
    //daiyo[i][1]は距離
    int ans=-1;
    int saima=-1;
    for(i=0;i<=man;i++){
      memset(daiyo,-1,sizeof(daiyo));
      priority_queue<mp,vector<mp>,greater<mp> > que;
      que.push(make_pair(0,i));
      daiyo[i][1]=0;
      while(!(que.empty())){
	pa=que.top();
	que.pop();
	no=pa.second;
	if(daiyo[no][0]==-1){
	  lo=pa.first;
	  for(j=1;j<=mati[no][0][0];j++){
	    tai=mati[no][j][0];
	    mi=mati[no][j][1];
	    daiyo[tai][1]=mins(daiyo[tai][1],lo+mi);
	    //printf("%d%d",daiyo[tai][1],lo+mi);
	    que.push(make_pair(daiyo[tai][1],tai));
	  }
	  daiyo[no][0]=1;
	}
      }
      int taans=0;
      for(j=0;j<=man;j++){
	taans+=daiyo[j][1];
      }
      if(ans==-1 || taans<ans){
	ans=taans;
	saima=i;
      }
      //printf("%d %d %d\n",daiyo[0][1],daiyo[1][1],taans);
    }
    printf("%d %d\n",saima,ans);
    scanf("%d",&n);
  }
  return 0;
}

Measured memory_bytes: 1036
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
int i;
long long int n, k, x;
cin>>n>>k;
map <long long int, long long int> m;
for(i=0; i<n; i++) {
    cin>>x;
    m[x]++;
}
if(k>=m.size())  cout<<0;
else{
vector <long long int> v;
for (map<long long int, long long int> :: iterator it = m.begin(); it != m.end(); ++it){
v.push_back(it->second);
}
sort(v.begin(), v.end());
     
    x=0;
for( i=0; i<v.size(); i++){
    if(k<m.size()){x+=v[i]; k++;}
    else break;
}
    cout<<x;
}
return 0;
}

Measured memory_bytes: 14964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n, k, x, y; cin >> n >> k >> x >> y;
    int ans = 0;
    FOR(i, 0, min(n, k))ans += x;
    FOR(i, k, n)ans += y;
    cout << ans << "\n";
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int Ma = sc.nextInt();
        int Mb = sc.nextInt();
        int[] a = new int[N];
        int[] b = new int[N];
        int[] c = new int[N];
        for (int i = 0; i < N; ++i) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        System.out.println(solve(a, b, c, Ma, Mb));

        sc.close();
    }

    static int solve(int[] a, int[] b, int[] c, int Ma, int Mb) {
        Map<State, Integer> stateToCost = new HashMap<>();
        stateToCost.put(new State(0, 0), 0);

        for (int i = 0; i < a.length; ++i) {
            Map<State, Integer> nextStateToCost = new HashMap<>(stateToCost);
            for (State state : stateToCost.keySet()) {
                State nextState = new State(state.sumA + a[i], state.sumB + b[i]);

                nextStateToCost.put(nextState, Math.min(nextStateToCost.getOrDefault(nextState, Integer.MAX_VALUE),
                        stateToCost.get(state) + c[i]));
            }

            stateToCost = nextStateToCost;
        }

        return stateToCost.keySet().stream().filter(state -> state.sumA != 0 && state.sumA * Mb == state.sumB * Ma)
                .mapToInt(stateToCost::get).min().orElse(-1);
    }
}

class State {
    int sumA;
    int sumB;

    State(int sumA, int sumB) {
        this.sumA = sumA;
        this.sumB = sumB;
    }

    @Override
    public int hashCode() {
        return Objects.hash(sumA, sumB);
    }

    @Override
    public boolean equals(Object obj) {
        State other = (State) obj;

        return sumA == other.sumA && sumB == other.sumB;
    }
}

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

#define ll long long int
#define Mod 1000000007

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m; cin>>n>>m;
    vector<string>v(1<<n);
    for(int i=0;i<(1<<n);i++)
    {
        string s;
        int tt=n,x=i;
        while(tt--)
        {
            s=char('0' + x%2)+s;
            x/=2;
        }
        v[i]=s;
        //cout<<s<<" ";
    }
    vector<vector<int>>q(m);
    for(int i=0;i<m;i++)
    {
        int k; cin>>k;
        vector<int>qq(k+1);
        qq[0]=k;
        for(int j=0;j<k;j++)
        {
            cin>>qq[j+1];
        }
        q[i]=qq;
    }
    vector<int>p(m);
    for(int i=0;i<m;i++) cin>>p[i];
    int ans=0;
    for(int i=0;i<(1<<n);i++)
    {
        int count=0;
        for(int j=0;j<m;j++)
        {
            int k=q[j][0];
            int a=0;
            for(int x=0;x<k;x++)
            {
                if(v[i][q[j][x+1]-1]=='1') a++;
            }
            if(a%2!=p[j]) break;
            count++;
        }
        if(count==m) ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 200005
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;

vector<int> to[N];
int v[N];
int ans[N];
void dfs(int no,int p){
	for(auto &s:to[no]){
		if(s==p) continue;
        ans[s]+=ans[no]+v[s];
		dfs(s,no);
		
	}
}
int main(){
	int n,q;
    cin>>n>>q;
    REP(i,n-1){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    REP(i,q){
        int a,b;
        cin>>a>>b;
        a--;
        v[a]+=b;
    }
    ans[0]=v[0];
    dfs(0,-1);
    REP(i,n){
        OUT(ans[i]);
    }

 	return 0;
}

Measured memory_bytes: 24320
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    T = Scanner.string()
    N = len(T)
    T = T.replace('?', 'D')
    print(T)


def main():
    # sys.stdin = open("sample.txt")
    # print('YNEOS'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10832
n = int(input())
a = list(map(int, input().split()))

l = [False] * 8
top = 0
for i, val in enumerate(a):
    if 1 <= val <= 399:
        l[0] = True
    if 400 <= val <= 799:
        l[1] = True
    if 800 <= val <= 1199:
        l[2] = True
    if 1200 <= val <= 1599:
        l[3] = True
    if 1600 <= val <= 1999:
        l[4] = True
    if 2000 <= val <= 2399:
        l[5] = True
    if 2400 <= val <= 2799:
        l[6] = True
    if 2800 <= val <= 3199:
        l[7] = True
    if 3200 <= val:
        top += 1

c = l.count(True)
mn = c if c != 0 else 1
mx = c + top
print("{} {}".format(mn, mx))

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>

using namespace std;
using ll = long long;

constexpr int MaxN = 100000 + 10;
constexpr ll Mod = 1000000000 + 7;
int n, m;
ll X[MaxN], Y[MaxN];

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

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

    for (size_t i = 0; i < m; i++) {
        cin >> Y[i];
    }

    ll xsum = 0, ysum = 0;

    for (int i = 0; i < n; i++) {
        xsum += X[i] * (n - 2 * i - 1);
        xsum %= Mod;
    }

    for (int i = 0; i < m; i++) {
        ysum += Y[i] * (m - 2 * i - 1);
        ysum %= Mod;
    }

    ll ans = (xsum * ysum) % Mod;
    cout << ans << endl;
}


Measured memory_bytes: 1792
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();

		System.out.printf("%d %d %.5f\n", a/b,a%b,(double)a/(double)b);
	}
}


Measured memory_bytes: 26528
import bisect
def main():
    n,m,l=map(int,input().split(' '))
    g=[[float('inf')if i != j  else 0  for i in range(n)] for j in range(n)]
    for i in range(m):
        a,b,c=map(int,input().split(' '))
        if c <=l:
            g[a-1][b-1]=c
            g[b-1][a-1]=c
    q=int(input())
    q_list=[tuple(map(int,input().split(' '))) for i in range(q)]
    for k in range(n):
        for i in range(n):
            for j in range(i,n):
                g[i][j]= min(g[i][j],g[i][k]+g[k][j])
                g[j][i]=g[i][j]

    for i in range(n):
        for j in range(n):
            if g[i][j]<=l:
                if g[i][j] != 0:
                    g[i][j] = 1
                else:
                    g[i][j] = 0
            else:
                g[i][j] = float('inf')

    for k in range(n):
        for i in range(n):
            for j in range(n):
                g[i][j] = min(g[i][j],g[i][k]+g[k][j])
    for i,j in q_list:
        if g[i-1][j-1] != float('inf'):
            print(g[i-1][j-1]-1)
        else:
            print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 125660
#include <bits/stdc++.h>
using namespace std;
int n, cnt = 0;
int main () {
	cin >> n;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			for(int l = 0; l < n; l++) {
				cnt++;
			}
		}
	}
	cout << cnt;
}

Measured memory_bytes: 256
import fractions
A, B, C, D = map(int, input().split())

lcm_cd = C * D // fractions.gcd(C, D)

under_c = (A - 1) // C
under_d = (A - 1) // D
under_cd = (A - 1) // lcm_cd

top_c = B // C
top_d = B // D
top_cd = B // lcm_cd

ans = (B -
       (A - 1)) - (top_c - under_c) - (top_d - under_d) + (top_cd - under_cd)

print(ans)


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

long long d[200000] = {};
long long t[200000] = {};

int aaa(const void *x, const void *y)
{
	long long *X = (long long *)x;
	long long *Y = (long long *)y;
	if (*X > *Y) return 1;
	if (*X < *Y) return -1;
	return 0;
}

int main()
{
	long long n, m;
	int ans = 0;
	long long check;
	scanf("%lld", &n);
	for (long long i = 0; i < n; i++)
	{
		scanf("%lld", &d[i]);
	}
	scanf("%lld", &m);
	for (long long i = 0; i < m; i++)
	{
		scanf("%lld", &t[i]);
	}
	//
	qsort(d, n, sizeof(long long), aaa);
	qsort(t, m, sizeof(long long), aaa);


	long long j = 0;
	for (long long i = 0; i < m; i++)
	{
		if (m > n || j >= n)
		{
			ans = 1;
			break;
		}
		else
		{
			check = t[i];
			if (d[j] == check)
			{
				j++;
			}
			else if (d[j] < check)
			{
				j++;
				i--;
			}
			else
			{
				ans = 1;
			}
		}
	}
	if (ans == 0)
	{
		printf("YES");
	}
	else
	{
		printf("NO");
	}
	return 0;
}

Measured memory_bytes: 4860
import sys
input = sys.stdin.readline
def main():
    card = []
    for _ in range(3):
        card.append(list(map(int, input().split())))
    bingo = [[0 for _ in range(3)] for _ in range(3)]
    N = int(input())
    for _ in range(N):
        b = int(input())
        for i in range(3):
            for j in range(3):
                if card[i][j] == b:bingo[i][j] = 1
    is_bingo = False
    for i in range(3):
        if bingo[i][0] == 1 and bingo[i][1] == 1 and bingo[i][2] == 1:
            is_bingo = True
            break
        if bingo[0][i] == 1 and bingo[1][i] == 1 and bingo[2][i] == 1:
            is_bingo = True
            break
    if bingo[0][0] == 1 and bingo[1][1] == 1 and bingo[2][2] == 1:
        is_bingo = True
    if bingo[0][2] == 1 and bingo[1][1] == 1 and bingo[2][0] == 1:
        is_bingo = True
    if is_bingo:
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()

Measured memory_bytes: 38256
<?php
while (True) {  
  fscanf(STDIN, "%d %d", $h, $w);
  if ($h === 0 && $w === 0) {
    break;
  }
  for($i = 0; $i < $h; $i++) {
    echo str_repeat("#", $w)."\n";
  }
  echo "\n";
  unset($h);
  unset($w);
}


Measured memory_bytes: 9216
n, m = map(int, input().split())
c_list = [0]*n
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    c_list[a] += 1
    c_list[b] += 1

ok = True
for c in c_list:
    if c % 2 != 0:
        ok = False
if ok:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3828
n = int(input())
h = list(map(int,input().split()))
a = [0]
b = []

for i in range(1,n):
    if h[i] > h[i-1]:
        a.append(i)
        
a.append(n)

for j in range(1,len(a)):
    b.append((a[j] - a[j-1]) - 1)

print(max(b))

Measured memory_bytes: 14224
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>
#include <queue>

using namespace std;

typedef long long ll;

int N, M, P[100005];
vector<int> G[100005];
bool visited[100005];

void dfs(int n, vector<int> &v) {
  if (visited[n]) return;
  visited[n] = true;
  v.push_back(n);
  for (int i = 0; i < G[n].size(); i++) {
    dfs(G[n][i], v);
  }
}

int main() {
  scanf("%d %d", &N, &M);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &P[i]);
  }
  for (int i = 0; i < M; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int res = 0;
  for (int i = 1; i <= N; i++) {
    if (visited[i]) continue;
    vector<int> v1, v2, v3;
    dfs(i, v1);
    for (int j = 0; j < v1.size(); j++) {
      v2.push_back(P[v1[j]]);
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    set_intersection(v1.begin(), v1.end(), v2.begin(), v2.end(), back_inserter(v3));
    res += (int)v3.size();
  }
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 10744
N, T = map(int, input().split(' '))
CT = [list(map(int, input().split(' '))) for _ in range(N)]
C_lt_T = [ct[0] for ct in CT if ct[1] <= T]

if len(C_lt_T) == 0:
    print('TLE')
else:
    print(min(C_lt_T))

Measured memory_bytes: 3060
# s=int(input())
# b=input()
# c=[]
# for i in range(b):
#     c.append(a[i])
a = list(map(int,input().split()))
#b = list(map(int,input().split()))

if (a[0]+a[1])<10:
    print(a[0]+a[1])
else:
    print("error")

Measured memory_bytes: 9092
#include <iostream> // c++の標準入出力
#include <stdio.h> // c言語の標準入出力
#include <string>
#include <algorithm>
#include <functional>
#include<math.h>

using namespace std;

int main()
{
	int a, b;
	std::cin >> a;
	b = 3*pow(a,2) ;
	std::cout << b;
		
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;

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

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


int main() {

	int n; cin >> n;
	vector<int>  h(n);
	rep(i,n) cin >> h[i];
	ll dp[100010];
	rep(i,100010) dp[i] = INF;
	dp[0] = 0;
	for (int i = 1; i < n; ++i){
		chmin(dp[i], dp[i-1] + abs(h[i] - h[i -1]));
		if(i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i - 2]));
	}
	
	cout << dp[n-1] << endl;




	return 0;
}



Measured memory_bytes: 4340
#include<bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<ll >    vecll;
typedef vector<string > vecstr;
////////////////////////////////////////////////
int main()
{
  int n;
  cin >> n;
  int i =0;
  while(i*(i + 1)/2 < n){
    i++;
  }
  cout << i << endl;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*約数の個数(x含む)*/ll divi(ll x){ll i,ans=0;rep(i,2,x+1){if(x%i==0){ans++;}}return ans;}
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
llfor;ll ans=0;///////////////////////////////////////////
ll x,y,n,k;
ll a[200010];
int main(){
 char s[7];
 sc(s);
 if(s[2]==s[3]&&s[4]==s[5])py;
 else pn;
return 0;}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





int main() {
  ll n,p;
  cin>>n>>p;

  ll ki=0;
  ll gu=0;
  rep(i,n){
    ll x;
    cin>>x;
    if(x%2==0) gu++;
    else ki++;
  }

  ll ans=0;
  ll now=1;
  rep(i,ki){
    if(i%2==p) ans+=now;
    now=now*(ki-i)/(i+1);
  }
  if(ki%2==p) ans+=now;

  ans*=pow(2,gu);

  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
long long gcd(long long a,long long b){
    if(b > a){
        swap(a,b);
    }
    bool flag = true;
    long long gcdl;
    while(flag){
        if(a%b == 0){
            flag = false;
            gcdl = b;
        }
        else{
            swap(a,b);
            b = b % a;
        }
    }
    return gcdl;
}
int main(){
    int n;
    cin >> n;
    long long a[n];
    rep(i,n){
        cin >> a[i];
    }
    long long b[n],c[n];
    b[0] = a[0];
    c[n-1] = a[n-1];
    rep(i,n-1){
        b[i+1] = gcd(b[i],a[i+1]);
        c[n-i-2] = gcd(c[n-i-1],a[n-i-2]);
    }
    long long tem = max(b[n-2],c[1]);
    rep(i,n-2){
        tem = max(tem,gcd(b[i],c[i+2]));
    }
    cout << tem << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;


int main()
{
	char a, b;
	cin >> a >> b;

	if (a == 'H')
	{
		if (b == 'H')
			cout << 'H'<<endl;
		else
			cout << 'D' << endl;
	}
	else if(b=='H')
		cout << 'D' << endl;
	else
		cout << 'H' << endl;

}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	//for(int i=0;i<N;i++) {}
	
	
	
	
	
	public static void main(String[] args) {
		int X=sc.nextInt();
		
		int i=1;
		int ans=0;
		while(true) {
			ans+=i;
			
			if(ans>=X) {
				p(i);
				break;
			}i++;
		}
		
		
		
		
		
	}
	
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 21844
package main

import (
	"fmt"
)

const (
	N = 10
)

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func main() {
	var a [N]int
	var k int
	n := 5
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	fmt.Scan(&k)

	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			if abs(a[i]-a[j]) > k {
				fmt.Println(":(")
				return
			}
		}
	}
	fmt.Println("Yay!")

}


Measured memory_bytes: 1772
n=int(input())
rates=list(map(int,input().split()))
over3200=sum(1 for i in rates if i>=3200)
fixed=set()
for i in rates:
  if i//400<=7:
    fixed.add(i//400)
f=len(fixed)
if f==0:
  print(1,over3200)
else:
  print(f,f+over3200)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  char data[100][100];
  cin >> H >> W;
  for(int i = 0;i < H;i++){
    for(int j = 0;j < W;j++){
      cin >> data[i][j];
    }
  }
  for(int i = 0;i < H * 2;i++){
    for(int j = 0;j < W;j++){
      cout << data[i / 2][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
const int N = 1e5+5, inf = 1e9+5;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll a[N][3];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n; cin >> n;
    rep (i, 0, n) rep (j, 0, 3) cin >> a[i][j];
    for (int i = 0; i < n-1; ++i) {
        a[i+1][0] = max(a[i+1][0]+a[i][1], a[i+1][0]+a[i][2]);
        a[i+1][1] = max(a[i+1][1]+a[i][0], a[i+1][1]+a[i][2]);
        a[i+1][2] = max(a[i+1][2]+a[i][0], a[i+1][2]+a[i][1]);
    }
    cout << max({a[n-1][0], a[n-1][1], a[n-1][2]}) << endl;
    
    return 0;
}

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

int main(){
  string s;
  string t;
  cin >> s >> t;
  int m=100000;
  int c;
  int k=0;
  for(int i=0; i<s.size()-t.size()+1; i++){
    c=0;
    k=i;
    for(int j=0; j<t.size(); j++){
      if(s[k] != t[j])c++;
      k++;
    }
    m = min(m,c);
  }
  cout << m << endl;
}


Measured memory_bytes: 3604
import sys
input = sys.stdin.readline

N, X, Y = map(int, input().split())
X -= 1; Y -= 1

graph = [[] for _ in range(N)]
for i in range(N-1):
    graph[i].append(i+1)
    graph[i+1].append(i)

graph[X].append(Y)
graph[Y].append(X)

def bfs(a):
    D = [-1]*N
    D[a] = 0
    q = [a]
    while q:
        qq = []
        for p in q:
            for np in graph[p]:
                if D[np] == -1:
                    D[np] = D[p] + 1
                    qq.append(np)
        q = qq
    return D

ans = [0]*(N-1)
for n in range(N):
    D = bfs(n)
    for m in range(N):
        if m == n: continue
        ans[D[m]-1] += 1

for a in ans:
    print(a//2)

Measured memory_bytes: 50268
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;
#define REPP(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)
#define PER(i,a) for(int i = (a) - 1; i >= 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair

typedef long long ll;
typedef pair<int, int> pii;

const int mod = 1e9 + 7;
int n, a[55][55];
ll k;

void add(int& x, int y) {
    x += y;
    if (x >= mod) x -= mod;
}

int mul(int x, int y) {
    return 1LL * x * y % mod;
}

struct Matrix {
    vector<vector<int> > v;
    Matrix() {
        v.resize(n, vector<int>(n));
    }
    Matrix operator * (const Matrix& b) const {
        Matrix c = Matrix();
        REP(i, n) REP(j, n) REP(k, n) {
            add(c.v[i][j], mul(v[i][k], b.v[k][j]));
        }
        return c;
    }
};


int main() {
    cin >> n >> k;
    REP(i, n) REP(j, n) cin >> a[i][j];
    Matrix m = Matrix(), base = Matrix();
    REP(i, n) m.v[i][i] = 1;
    REP(i, n) REP(j, n) base.v[i][j] = a[i][j];
    while (k) {
        if (k & 1) {
            m = m * base;
        }
        base = base * base;
        k /= 2;
    }
    int ans = 0;
    REP(i, n) REP(j, n) add(ans, m.v[i][j]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
      //取得
	  int N = sc.nextInt();
      String[] test = new String[N];
      int ac=0;
      int wa=0;
      int tle=0;
      int re=0;
      for(int i=0;i<N;i++){
        test[i] = sc.next();
        if(test[i].equals("AC")){
          ac++;
        }else if(test[i].equals("WA")){
          wa++;
        }else if(test[i].equals("TLE")){
          tle++;
        }else{
          re++;
        }
      }
      System.out.println("AC x "+ac);
      System.out.println("WA x "+wa);
      System.out.println("TLE x "+tle);
      System.out.println("RE x "+re);
    }
}

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

c = [[0 for i in range(10)] for j in range(10)]

for i in range(1, n+1):
  s = str(i)
  j = int(s[0])
  k = int(s[-1])
  c[j][k] += 1
  
count = 0
for i in range(10):
  for j in range(10):
    count += c[i][j] * c[j][i]
    
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long

int X;

signed main() {
  cin >> X;
  int y=1;
  int m = 100;
  while(true) {
    m = (int)(m * 1.01);
    if(m>=X) {
      cout << y << endl;
      return 0;
    }
    y++;
  }
}



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

using namespace std;

int main()
{
  int n,a;
  cin>>n;
  vector<int>v;
  for(int i=0;i<n;i++)
  {
    cin>>a;
    v.push_back(a);
  }
  sort(v.begin(),v.end());
  cout<<accumulate(v.begin(),v.end(),0)-v[n-1]+v[n-1]/2<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#define INF 2147483647
#define lli long long int

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

void printv(vector<double> v){
	for(int i = 0; i < v.size(); i++){
		cout << v[i] << " ";
		}cout << endl;
		return ;
		}

void swap(double &a,double &b){
	int tmp = a;
	a = b;
	b = tmp;
}
int main() {
	while(1){
		int n,m; cin >> n >> m;
		if (n + m == 0) break;

		vpii dp(n);
		for (int i = 0; i < n; i++){
			int d,p; cin >> d >> p;
			dp[i] = make_pair(p,d);
		}

		sort(dp.begin(),dp.end());
		reverse(dp.begin(),dp.end());
		
		int ans = 0;
		for (int i = 0; i < n ; i++){
			if (m >= dp[i].second){
				m -= dp[i].second;
			}else{
				dp[i].second -= m;
				m = 0;
				ans += dp[i].first * dp[i].second;
			}
		}
		cout << ans << endl;
		
	}
	return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <queue>
using namespace std;

struct node{
    int x,y;
    node(){}
    node(int a,int b):x(a),y(b){}
};
char mp[100][100];
int minn,h,w;
int visit[100][100];
int step[100][100];
int dir[4][2] = {0,1,1,0,0,-1,-1,0};
queue<node>q;

int main(){
    int sum=0,flag=0;
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++){
        getchar();
        for(int j=0;j<w;j++){
            scanf("%c",&mp[i][j]);
            if(mp[i][j]=='#') sum++;
        }
    }
    visit[0][0]=1;
    q.push(node(0,0));
    while(!q.empty()){
        if(flag) break;
        node temp=q.front();
        q.pop();
        for(int i=0;i<4;i++){
            int tx = temp.x + dir[i][0];
            int ty = temp.y + dir[i][1];
            if(tx<0||tx>=h||ty<0||ty>=w) continue;
            if(tx==h-1&&ty==w-1)  flag=step[temp.x][temp.y]+1;
            if(visit[tx][ty]==0&&mp[tx][ty]=='.'){
                visit[tx][ty]=1;
                q.push(node(tx,ty));
                step[tx][ty]=step[temp.x][temp.y]+1;
            }
        }
    }


    if(flag) printf("%d\n",h*w-flag-sum-1);
    else printf("-1\n");
    return 0;
}

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

ll dp[100000][4];
int main()
{
    string s;
    cin >> s;

    dp[0][0] = (s[0] == '?')? 3: 1;
    dp[0][1] = (s[0] == 'A' or s[0] == '?')? 1: 0;
    for (int i = 1; i < s.size(); i++)
    {
        rep(j, 4)
            dp[i][j] = (dp[i - 1][j] * (s[i] == '?' ? 3LL : 1LL)) % MOD;
        
        if (s[i] == 'A' or s[i] == '?')
            dp[i][1] = (dp[i][1] + dp[i - 1][0]) % MOD;
        if (s[i] == 'B' or s[i] == '?')
            dp[i][2] = (dp[i][2] + dp[i - 1][1]) % MOD;
        if (s[i] == 'C' or s[i] == '?')
            dp[i][3] = (dp[i][3] + dp[i - 1][2]) % MOD;

    }
    cout << dp[s.size() - 1][3] << endl;;
}

Measured memory_bytes: 3584
package main

import "fmt"

func main() {
	var x, a, b int
	fmt.Scan(&x, &a, &b)
	switch {
	case b-a <= 0:
		fmt.Println("delicious")
	case b-a <= x:
		fmt.Println("safe")
	default:
		fmt.Println("dangerous")
	}
}


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

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

    sort(a, a + 3);

    int ans = 0;
    while(a[1] != a[2]){
        a[0]++;
        a[1]++;
        ans++;
    }
    while(a[0] < a[2]){
        a[0] += 2;
        ans++;
    }

    if(a[0] == a[2]){
        cout << ans << endl;
    }else{
        cout << ans + 1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int a,b,n=0;
	while(cin>>a>>b){
		if(a==0&&b==0) break;
		if(n) cout<<endl;
		int c=0;
		rer(i,a,b){
			if(i%4==0&&i%100!=0||i%400==0){
				o(i); c++;
			}
		}
		if(c==0) o("NA");
		n++;
	}
}

Measured memory_bytes: 1160
/********************/
                    /*user -> tushar284*/
                    /******************/
#include<bits/stdc++.h>
                                                    /*********/            
using namespace std;                             /*   __   __   */
#define  f              first                    /*   @ ) ( @   */
#define  s              second                   /*     / \     */            
#define  mp             make_pair                /*  __  -  __  */
#define  loop(i,s,e)    for(int i=s;i<e;i++)     /*    ..^..    */
#define  rev(i,s,e)     for(int i=s;i>=e;i--)     /*     |     */
#define  mod            1000000007                  /*   |   */
#define  pb             push_back                      /***/
#define  start	        int main()                     
#define  fast           ios_base::sync_with_stdio(false);cin.tie(0);
#define  test           fast int t; cin>>t;while(t--)
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
int no_of_fact(int num){
    int cnt =0;
    loop(i,1,int(sqrt(num))+1){
        if(num%i==0){
            cnt++;
            if(num/i != i)cnt++;
        }
    }
    return cnt;
}

start
{   
    ll n,m;
    cin>>n>>m;
    ll a,sum=0;
    loop(i,0,m){
        cin>>a;
        sum+=a;
    }
    ll ans = n-sum;
    if(ans<0)cout<<"-1";
    else cout<<ans;
    return 0;
}


Measured memory_bytes: 3680
#!/usr/bin/env python3
import sys


def solve(N: int, Y: int):
    def f(n, y):
        if y > 10000*n:
            return "-1 -1 -1"
        if y < 1000*n:
            return "-1 -1 -1"

        for i in range(n+1):
            for j in range(n+1):
                if n-i-j >= 0:
                    if 10000*i+5000*j+1000*(n-i-j) == y:
                        return "{} {} {}".format(i, j, n-i-j)
        return "-1 -1 -1"

    print(f(N, Y))

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(N, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

// 先頭以外全部 9
bool all9(int64_t n)
{
    while (n >= 10)
    {
        if (n % 10 != 9)
        {
            return false;
        }
        n /= 10;
    }
    return true;
}

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

    const int64_t orig_n = n;

    int sum = 0;
    int last = 0;
    while (n > 0)
    {
        sum += 9;
        last = n % 10;
        n /= 10;
    }
    sum += last - 9;
    if (!all9(orig_n))
    {
        sum--;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int Y,M,D;
    scanf("%d/%d/%d",&Y,&M,&D);
    if(Y<=2019){
        if(M<=4){
            printf("Heisei\n");
        }else{printf("TBD\n");}
    }else if(Y>2019){
        printf("TBD\n");
    }else{printf("Heisei\n");}
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def main():
	n = I()
	divisors_dict = {}
	for i in range(2,n+1):
		tmp_divisors = factorization(i)
		for tmp_divisor, num in tmp_divisors:
			if tmp_divisor in divisors_dict:
				divisors_dict[tmp_divisor] += num
			else:
				divisors_dict[tmp_divisor] = num
	ans = 1
	for divisor_num in divisors_dict.values():
		ans *= (divisor_num + 1)
		ans %= MOD
	print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 27148
#include <bits/stdc++.h>
#define ll long long
#define INF (ll) 1e9+7
#define maxn 200009
#define MOD 1000000007
#define inp freeopen("input.txt","r",stdin);
#define out freeopne("output.txt","w",stdout);
using namespace std; 
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int vet[maxn];
    for(int i =0;i<n;i++){
        cin>>vet[i];
    }
    int vet2[maxn];
    for(int i=0;i<n;i++){
        cin>>vet2[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if((vet[i]-vet2[i])>0)ans+=vet[i]-vet2[i];
    }
    cout<<ans<<endl;
}   

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

int cla[4];

int main()
{
    int n;
    cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        cla[a % 4]++;
    }
    if(cla[2] == 0) {
        if(cla[1] + cla[3] <= cla[0] + 1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else {
        if(cla[1] + cla[3] <= cla[0]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3680
#c
import math
a, b, h, m = [float(i) for i in input().split()]
omega_b  = 2*math.pi/(60**2) # 分針の角速度
omega_a  = omega_b/12 # 時針の角速度

theta_a = omega_a * (h*60**2 + m*60)
theta_b = omega_b * m*60
# print(theta_a, theta_b, math.cos(abs(theta_a - theta_b)))
# 三角形の辺の長さを求める
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(abs(theta_a-theta_b)))
print(c)

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

int main(){
  int N;
  string S;

  cin >> N >> S;

  int mid = N/2;

  if(N%2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  for(int i=0; i<mid; i++) {
    if(S[i]!=S[mid+i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int n,m; cin >> n >> m;
    cout << (n==m ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
void depth_search(int);
void depth();
int n,M[N][N];
int color[N],d[N],f[N],t;
int main(){

  int u,v,k,i,j;

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


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

}
void depth_search(int u){
  int v;
  color[u]=GRAY;
  d[u]=++t;
for(v=0;v<n;v++){
  if(M[u][v]==0)
    continue;
  if(color[v]==WHITE){
    depth_search(v);}
 }
 color[u]=BLACK;
 f[u]=++t;
}
void depth(){
  int u;

  for(u=0;u<n;u++)color[u]=WHITE;
  t=0;
  for(u=0;u<n;u++){
    if(color[u]==WHITE)
      depth_search(u);
  }
  for(u=0;u<n;u++){

    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
  }









Measured memory_bytes: 2792
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

void print3(int x, int y, int z) {
  printf("%d %d %d\n",x,y,z);
}

int main() {
  int l;
  cin >> l;
  int n = 0;
  while(l >= (1 << n)) {
    n++;
  }
  int m = (n-1)*2 + __builtin_popcount(l) - 1;
  cout << n << " " << m << endl;
  rep(i,1,n) {
    print3(i,i+1,0);
    print3(i,i+1,1<<(i-1));
  }
  int k = l;
  rep(i,0,n-1) {
    if (l & (1 << i)) {
      k -= (1<<i);
      print3(i+1,n,k);
    }
  }
  return 0;
}


Measured memory_bytes: 3704