akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		in.nextInt();
		int m = in.nextInt();
		int city[][] = new int[m][4]; // id, pref, year, number in pref
		for ( int id = 0; id < m; id++ ) {
			city[id][0] = id;
			city[id][1] = in.nextInt();
			city[id][2] = in.nextInt();
		}
		Arrays.sort(city, (c1, c2) -> {
			return (c1[1] != c2[1]) ? c1[1] - c2[1] : c1[2] - c2[2];
		});

		city[0][3] = 1;
		for ( int i = 1; i < m; i++ ) {
			city[i][3] = (city[i][1] == city[i - 1][1] ? city[i - 1][3] + 1 : 1);
		}
		Arrays.sort(city, (c1, c2) -> {
			return c1[0] - c2[0];
		});

		DecimalFormat df = new DecimalFormat("000000");
		StringBuilder sb = new StringBuilder();
		for ( int c[] : city ) {
			sb.append(df.format(c[1])).append(df.format(c[3])).append("\n");
		}
		System.out.println(sb);
		in.close();
	}
}

Measured memory_bytes: 98144
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    string S,T;cin >> S >> T;
    int ans = T.size();
    rep(i,S.size()){
        int dif = 0;
        int ct = 0;
        int same = 0;
        rep(j,T.size()){
            if(i+j >= S.size())break;
            ct++;
            if(S[i+j] == T[j]){
                same++;
            }
            else dif++;
        }
        if(ct == T.size()){
            ans = min(ans,dif);
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3596
#include <iostream>

int main()
{
	int n;
	std::cin >> n;
	int a[n];
	for (int i=n; i!=0; --i) std::cin >> a[i-1];
	for (int i=0; i!=n; ++i) std::cout << a[i] << (i==n-1 ? '\n' : ' ');
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int s=2*n;
  int a[s];
  int sum=0;
  for(int i=0;i<s;i++)
  {
    cin>>a[i];
  }
  sort(a,a+s);
  for(int i=0;i<s;i+=2)
  {
    if(a[i]<=a[i+1]){sum+=a[i];}
    else
    {
      sum+=a[i+1];
    }
  }
  cout<<sum<<"\n";
  return 0;
  }

Measured memory_bytes: 256
n = int(input())
R = []
for i in range(n):
    R.append(int(input()))

maxv = -20000000000
minv = R[0]

for i in range(1, n):
    maxv = max(maxv, R[i] - minv)
    minv = min(minv, R[i])

print(maxv)



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

const int N = 3e5 + 9;

int a[N];
int32_t main()
{
    int n, m; cin >> n >> m;
    int sum = 0;
    for(int i = 1; i <= n; i++) cin >> a[i], sum += a[i];
    sort(a + 1, a + n + 1);
    for(int i = n; i >= n - m + 1; i--){
        if(a[i] * 4 * m < sum) return cout << "No\n", 0;
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	int n, m;
	in2(n, m);
	cout<<(n*(n-1))/2 + (m*(m-1))/2<<en;
}

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


Measured memory_bytes: 256
import heapq
n,m=map(int,input().split())
A=list(map(lambda x: -int(x),input().split()))
heapq.heapify(A)
for _ in range(m):
    a=heapq.heappop(A)
    a*=-1
    #print(a)
    a//=2
    #print(a)
    heapq.heappush(A,-a)
ans=0
#print(A)
for a in A:
    ans-=a
print(ans)

Measured memory_bytes: 72216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef vector<int> vi;
typedef pair<int, int> pi;
#define SQ(a) (a) * (a)
#define deb(x) cout << #x << " = " << x << '\n'
#define deb2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
 
 
int main(int argc, char const *argv[])
{
 
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char a;
    cin>>a;
    if(a-'a'>=0){
        cout<<"a";
    }
    else{
        cout<<"A";
    }

 
    return 0;
}

Measured memory_bytes: 3640
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).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; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;
#define int long long
const int N = (int) 105, mod = (int) 0;
int a[N];
int32_t main() {
	int n, bud;
	cin >> n >> bud;
	for (int j = 0; j < n; ++j) cin >> a[j];
	sort(a, a + n);
	int sum = 0, cnt = 0;
	for (int j = 0; j < n; ++j) {
		sum += a[j];
		if (sum <= bud) {
			cnt++;	
		}
	}
	if (cnt == n && sum != bud) cnt = n - 1;
	cout << cnt << endl;
}



















Measured memory_bytes: 764
#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
using ll = long long;

int main()
{
	int h,w,n;
	cin >> h >> w >> n;
	int sr,sc;
	cin >> sr >> sc;
	sr--;
	sc--;
	string s,t;
	cin >> s >> t;

	int now = sc;
	for(int i = 0;i<n;i++)
	{
		if(s[i]=='L')now--;
		if(now<0)
		{
			cout<<"NO"<<endl;
			return 0;
		}
		if(t[i]=='R'&&now<w-1)now++;
	}
	now = sc;
	for(int i = 0;i<n;i++)
	{
		if(s[i]=='R')now++;
		if(now>=w)
		{
			cout<<"NO"<<endl;
			return 0;
		}
		if(t[i]=='L'&&now>0)now--;
	}
	now = sr;
	for(int i = 0;i<n;i++)
	{
		if(s[i]=='D')now++;
		if(now>=h)
		{
			cout<<"NO"<<endl;
			return 0;
		}
		if(t[i]=='U'&&now>0)now--;
	}
	now = sr;
	for(int i = 0;i<n;i++)
	{
		if(s[i]=='U')now--;
		if(now<0)
		{
			cout<<"NO"<<endl;
			return 0;
		}
		if(t[i]=='D'&&now<h-1)now++;
	}
	cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 3888
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
using namespace std;

const double EPS = 1e-9;

struct data{
  double lm, rm, m;//l-min, r-max
  int bit; 
  data(double l=0, double r=0, double m=0, int b=0):lm(l),rm(r),m(m),bit(b){}
};

bool equal(double a, double b){
  return fabs(a-b) < EPS;
}

int n;
double r;
vector<double> v;

void solve(){
  if(n == 1){
    cout << 0.0 << endl;
    return;
  }

  vector<data> res[7];
  double ans = -1.0;
  for(int i=0;i<n;i++) res[1].push_back(data(0,0,v[i],(1<<i)));
  for(int i=2;i<=n;i++){
    for(int j=1;j<i;j++){
      int x1 = j, x2 = i - j;
      for(int k=0;k<res[x1].size();k++){
        for(int l=0;l<res[x2].size();l++){
          if((res[x1][k].bit & res[x2][l].bit) != 0) continue;
          data pos;
          double a = res[x2][l].m / (res[x1][k].m + res[x2][l].m);
          double b = 1.0 - a;
          pos.lm = min(-a + res[x1][k].lm, b + res[x2][l].lm);
          pos.rm = max(b + res[x2][l].rm, -a + res[x1][k].rm);
          pos.m = res[x1][k].m + res[x2][l].m;
          pos.bit = res[x1][k].bit | res[x2][l].bit;
          if(pos.rm - pos.lm > r || equal(pos.rm-pos.lm,r)) continue;
          else if(i == n) ans = max(ans, pos.rm - pos.lm);
          else res[i].push_back(pos);
        }
      }
    }
  }
  if(ans < 0) cout << -1 << endl;
  else printf("%.9f\n",ans);
}

int main(){
  int T;
  cin >> T;
  while(T--){
    cin >> r >> n;
    v.clear();
    for(int i=0;i<n;i++){
      int x;
      cin >> x;
      v.push_back(x);
    }
    solve();
  }
}

Measured memory_bytes: 2108
//#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int memo[204][204];

int gcd(int a, int b){
  int maxval = std::max(a, b);
  int minval = std::min(a, b);
  if (memo[maxval][minval]!=0){
    return memo[maxval][minval];
  } else if (minval==0){ 
    memo[maxval][minval] = maxval;
    return maxval;
  } else {
    int ans = gcd(maxval%minval, minval);
    memo[maxval][minval]=ans;
    return ans;
  }
}

int main(){
  int K;
  scanf("%d", &K);
  long long ans = 0;
  for (int i=1; i<=K; i++){
    for (int j=1; j<=K; j++){
      for (int k=1; k<=K; k++){
        ans += gcd(i, gcd(j, k));
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 3384
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var n int
	fmt.Fscan(r, &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &a[i])
	}

	m := make(map[int]int)
	for i := 0; i < n; i++ {
		m[a[i]]++
	}

	cnt := make([]int, n+1)
	for _, v := range m {
		cnt[v]++
	}

	kd := make([]int, n+1)
	d := make([]int, n+1)

	for i := 0; i <= n; i++ {
		kd[i] = i * cnt[i]
		d[i] = cnt[i]
	}

	for i := 1; i <= n; i++ {
		kd[i] += kd[i-1]
		d[i] += d[i-1]
	}

	f := make([]int, n+1)
	for i := 1; i <= n; i++ {
		f[i] = (kd[i] + i*(d[n]-d[i])) / i
	}

	f = f[1:]
	for k := 1; k <= n; k++ {
		ans := sort.Search(len(f), func(i int) bool { return f[i] < k })
		fmt.Println(ans)
	}
}


Measured memory_bytes: 31360
#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;
int main(void){
    
    while(1){
        int h, w;
        cin >> h >> w;
        if(h == 0 && w == 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 << "#" << (j != w-1 ? "" : "\n");
                else cout << ".";
                
            }
        }cout << endl;
    }
    
    
    
}



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

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
typedef long long ll;
int main()
{
	int x,y;
	cin>>x>>y;
	int ans=max(x+y,x-y);
	ans=max(ans,x*y);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <deque>
using namespace std;

void rev(deque<char> &line){
  deque<char> ret;
  for(char s : line){
    ret.push_front(s);
  }
  line.swap(ret);
}

int main(){
  string S;
  cin >> S;
  deque<char> line;
  deque<char> tmp;
  for(char s : S){
    line.push_back(s);
  }

  int Q;
  cin >> Q;
  int T,F;
  char C;
  int flip=0;
  for(int i=0;i<Q;i++){
    cin >> T;
    if(T==1){
      flip++;
    }
    else{
      cin >> F >> C;
      if(flip%2==0){
	if(F==1) line.push_front(C);
	else line.push_back(C);
      }
      else{
	if(F==2) line.push_front(C);
	else line.push_back(C);
      }
    }
  }
  if(flip%2==1) rev(line);
  for(char s : line){
    cout << s;
  }
  cout << endl;
  return 0;
}


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

int main() {
	using namespace std;
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int T; cin >> T;
	while (T--) {
		int N; cin >> N;
		vector<uint64_t> A(N); for (auto& a : A) cin >> a;
		string S; cin >> S;

		vector<uint64_t> basis; basis.reserve(64);
		bool ans = 0;
		for (int i = N-1; i >= 0; i--) {
			uint64_t v = A[i];
			for (uint64_t b : basis) {
				v = min(v, b ^ v);
			}
			if (v) {
				if (S[i] == '0') {
					basis.push_back(v);
				} else if (S[i] == '1') {
					ans = 1;
					break;
				} else assert(false);
			}
		}
		cout << ans << '\n';
	}

	return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];
//平方根　= sqrt

int solve() {
  int a,b;
  cin >> a >> b;
  if (b%a==0) {
    cout << a+b << endl;
  }
  else {
    cout << b-a << endl;
  }
}


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


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;
#define def 1000

int main(void){
  int i,j,n,len,tmp,max,digits,A[def],B[def],C[def];
  char str[def];

  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d",&n);
  for(i=0;i<n;i++){
    memset(A,0,sizeof(A));
    memset(B,0,sizeof(B));
    memset(C,0,sizeof(C));
    tmp = 0;
    digits = 0;
    /*for(j=0;j<5;j++){
      printf("%d",A[j]);
    }
    printf("\n");*/
    fgets(str,sizeof(str),stdin);
    len = strlen(str)-2;
    max = len;
    digits = max+1;
    //printf("%d\n",len);
    for(j=len;j>=0;j--){
      A[len-j] = str[j]%48;
      //printf("%d",A[len-j]);
    }
    //printf("\n");
    fgets(str,sizeof(str),stdin);
    len = strlen(str)-2;
    if(len>max){
      max = len;
      digits = max+1;
    }
    for(j=len;j>=0;j--){
      B[len-j] = str[j]%48;
      //printf("%d",A[len-j]);
    }
    for(j=0;j<=max;j++){
      //printf("%d ",(A[j] + B[j] + tmp)%10);
      C[max+1-j] = (A[j] + B[j] + tmp)%10;
      tmp = (A[j] + B[j] + tmp)/10;
      //printf("%d\n",tmp);
      if(j==max && tmp!=0){
        C[0] = tmp;
        digits += 1;
      }
      if(digits>80){
        printf("overflow");
        goto end;
      }
      //printf("%d",B[len-j]);
    }
    for(j=0;j<=max+1;j++){
      if(j==0 && C[j]==0) continue;
      printf("%d",C[j]);
    }
    end:;
    printf("\n");
    //Calculation(A,B);
  }
  return 0;
}

Measured memory_bytes: 2704
S=str(input())   #10文字

ans='Yes'

Odd=[i for i in range(1,len(S)+1) if i%2==1]
Even=[j for j in range(1,len(S)+1) if j%2==0]

Odd_right=['R','U','D']
Even_right=['L','U','D']

for k in Odd:
    if S[k-1] not in Odd_right:
        ans='No'

for l in Even:
    if S[l-1] not in Even_right:
        ans='No'

print(ans)




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

using namespace std;

#define ll long long int
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define MOD 1000000007

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

    ll k; 
    cin>>k;
    queue<ll> q;
    ll x = 0;
    for(int i = 1; i<10; i++){
        q.push(i);
    }
    for(int i = 0; i<k; i++){
        x = q.front();
        q.pop();
        
        if(x%10 != 0){
            q.push(x*10 + (x%10) - 1);
        }
        q.push(x*10 + (x%10));
        if(x%10 != 9){
            q.push(x*10 + (x%10)+1);
        }
    }
    cout<<x<<" ";

}

Measured memory_bytes: 1792
import collections

N = int(input())
Ds = list(map(int, input().split()))
M = int(input())
Ts = list(map(int, input().split()))

Ds = collections.Counter(Ds)
Ts = collections.Counter(Ts)

if N < M:
  print('NO')
  exit()
  
for k in Ts:
  if Ts[k] > Ds[k]:
    print('NO')
    exit()

print('YES')

Measured memory_bytes: 127572
#include<cstdio>
#include<algorithm>
using namespace std;
int n,ans;
int a[205];
int main()
{
	scanf("%d",&n);
	n=n*2;
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i=i+2)
		ans+=a[i];
	printf("%d\n",ans);
}

Measured memory_bytes: 128
x=input()
y=x[0::2]
z=x[1::2]
y=y.replace("U","")
y=y.replace("D","")
y=y.replace("R","")
z=z.replace("U","")
z=z.replace("D","")
z=z.replace("L","")
if y=="" and z=="":
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <sstream>
#include <complex>
#include <map>
#include <set>
#include <functional>
#include <vector>

using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
#define IREP(i,n) for(ll i=1;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG(x) cerr << x << "\n"

int main(){
    int a,b;
    cin >> a >> b;
    if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0) cout << "Possible\n";
    else cout << "Impossible\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define pi M_PI

typedef struct xy{
double x;
double y;
}P;

P koch(P pre,P nex,int i){
P PREV,MID,NEXT,DIS;
if(i == 0)printf("%f %f\n",pre.x,pre.y);
else{
DIS.x = nex.x - pre.x;
DIS.y = nex.y - pre.y;
PREV.x = pre.x + DIS.x/3.0;
NEXT.x = pre.x + DIS.x*2.0/3.0;
PREV.y = pre.y + DIS.y/3.0;
NEXT.y = pre.y + DIS.y*2.0/3.0;
MID.x = PREV.x + (DIS.x/3.0)*cos(pi/3.0) - (DIS.y/3.0)*sin(pi/3.0);
MID.y = PREV.y + (DIS.x/3.0)*sin(pi/3.0) + (DIS.y/3.0)*cos(pi/3.0);

koch(pre,PREV,i - 1);
koch(PREV,MID,i - 1);
koch(MID,NEXT,i - 1);
koch(NEXT,nex,i - 1);
}
}

int main(int argc,char argv[]){
P pre={0,0},nex={100,0};
int a;
scanf("%d",&a);
koch(pre,nex,a);
printf("%f %f\n",nex.x,nex.y);
return 0;
}



Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int M, D;
    cin >> M >> D;
    int ans = 0;
    rep(i, 1, M + 1) {
        rep(j, 10, D + 1) {
            int d1 = j % 10;
            int d2 = j / 10;
            if (d1 < 2 || d2 < 2) continue;
            if (d1 * d2 == i) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include<algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REPR(i,n) for(int i=n-1; i>=(int)(0); i--)
#define FOR(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define FORR(i,a,b) for(int i=(int)(b)-1; i>=(int)(a); i--)
#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()
//**関数リスト**//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
int nod(ll F) {
	int keta = 1;
	while (F/10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
int gcd(int x, int y) {
	int r;
	if(x<y){
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int isPrime(int x) {
	int i;
	if (x < 2) {
		return 0;
	}
	else if(x==2){
		return 1;
	}
	else if (x % 2 == 0) {
		return 0;
	}
	else {
		for (i = 3; i * i <= x; i += 2) {
			if (x % 1 == 0) {
				return 0;
			}
		}
		return 1;
	}
}
void eratos(vi isPrime) {
	//(注)isPrimeのサイズはN+1にする！実際にはmain内に配置して使用
	int ii, jj;
	REP(ii, isPrime.size()) {
		isPrime[ii] = 1;
	}
	isPrime[0] = 0; isPrime[1] = 0;
	for (ii = 2; ii * ii <= isPrime.size() - 1; ii++) {
		if (isPrime[ii] == 1) {
			jj= ii * 2;
			while (jj <= isPrime.size() - 1) {
				isPrime[jj] = 0;
				jj = jj + ii;
			}
		}
	}
}
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
void bitSearch(int n) {
	//実際にはコピーして中身を改変して使う
	int ii;
	REP(ii, pow(2, n)) {
		ll p = ii;
		REP(ii, n) {
			cout << p % 2;
			p /= 2;
		}
		cout << endl;
	}
}
//**定義場所**//
ll i, j, k, l, m, n;
ll N, M, K, H, W;
ll MOD = 1000000000 + 7;
ll ans = 0;
//***********//
int main() {
	string S;
	cin >> S;
	if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
		cout << "Bad";
	}
	else {
		cout << "Good";
	}
}

Measured memory_bytes: 256
a = int(input()) # 500
b = int(input()) # 100
c = int(input()) # 50
x = int(input())

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

Measured memory_bytes: 40176
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    long long   int num,r;
    while(cin>>num){
        while(num){
            r= num%26;
            if( r==0 ){
                str+= 'z';
                num= num/26 -1;
            }
            else {str+= (96+r);
            num/=26;}

        }

        for(int i=str.length()-1;i>=0;i--){
            cout<<str[i];
        }
        cout<<endl;
        str.clear();
    }
    return 0;
}


Measured memory_bytes: 3572
// 3 6 10 15 21 28 36 45 55 ... はいけるんだなこれが それ以外いけるかどうかは知りませんがヨシ！
// サンプル1をみると、最下段に「それまで出てないやつを集める」、最下段以外の右端に「最下段と共通にしたいやつを加える」をしていく感じだとわかる
// 実装、よくわからんかったので最大値までのテーブルを無理やり作ることにした
// N=1の場合、卑怯じゃないですか？？？？？？？？？？？？？？
package main
import "fmt"
func main(){
	var N int
	fmt.Scan(&N)
	if N==1{
		fmt.Println("Yes")
		fmt.Println(2)
		fmt.Println(1, 1)
		fmt.Println(1, 1)		
		return
	}
	ai := 3
	idx := 0
	accept := false
	for ai<=N{
		if ai == N{
			accept = true
		}
		ai=ai+3+idx
		idx++
	}
	if !accept{
		fmt.Println("No")
		return
	}
	T := make([][]int, 500)	// なんでかはしらん 適当
	for i:=0; i<len(T); i++{
		T[i] = make([]int, 500)
	}
	// 基礎 手打ちで作成...
	T[0][0], T[1][0] = 1, 1
	T[1][1], T[2][1] = 2, 2
	T[0][1], T[2][0] = 3, 3

	// 構築
	tmp := 4
	hight := 3
	for j:=2; j<500; j++{
		for i:=0; i<hight; i++{
			T[i][j] = tmp
			tmp++
		}
		hight++
	}
	tmp = 4
	width := 3
	for i:=3; i<500; i++{
		for j:=0; j<width; j++{
			T[i][j] = tmp
			tmp++
		}
		width++
	}
	fmt.Println("Yes")
	fmt.Println(idx+2)
	for i:=0; i<=idx+1; i++{
		fmt.Printf("%d ", idx+1)
		for j:=0; j<=idx; j++{
			fmt.Printf("%d ", T[i][j])
		}
		fmt.Println()
	}
}

Measured memory_bytes: 5672
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int a,b,c,d,e;
  scanf("%d", &a);
  b = a/1000;
  c = (a/100)%10;
  d = (a/10)%10;
  e = a%10;
  if((b==c && d==c) ||(c==d&&d==e)){
  	printf("Yes");
  }else{
    printf("No");
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;


int main(){
	int N;
	int a[100];

	scanf("%d", &N);
	for(int i=0;i<N;i++) scanf("%d", &a[i]);

	int ans = 0;
	for(int i=1;i<N;i++){
		if(a[i]==a[i-1]){
			a[i] = 10000;
			ans++;
		}
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);
int n,M[N][N];
int d[N];
void bfs(int s){
  queue<int> q;
  q.push(s);
  for(int i=0;i<n;i++) d[i]=INFTY;
  d[s]=0;
  int u;
  while(!q.empty()){
    u=q.front();q.pop();
    for(int v=0;v<n;v++){
      if(M[u][v]==0) continue;
      if(d[v] != INFTY) continue;
      d[v]=d[u]+1;
      q.push(v);
    }
  }
  for(int i=0;i<n;i++){
    cout << i+1 << " " << ( (d[i] == INFTY) ? (-1) : d[i]) << endl;
  }
}
int main(){
  int u,k,v;
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++) M[i][j]=0;
  }
  for(int i=0;i<n;i++){
    cin >> u >> k;
    u--;
    for(int j=0;j<k;j++){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }
  bfs(0);
  return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define N 1001
const ll INF=1e15+7;
ll a,b,c,d;

int main(){
	cin>>a>>b>>c>>d;
	cout<<min(a,b)+min(c,d)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>

bool NotMatch( const std::string& str )
{
	return str.find("the") == std::string::npos && str.find("this") == std::string::npos && str.find("that") == std::string::npos;
}

int main()
{
	std::string str;
	while( getline(std::cin,str) )
	{
		while( NotMatch(str) )
		{
			for( unsigned i=0; i<str.length(); ++i )
			{
				if( str[i]=='.' || str[i]==' ' || str[i]=='\n' )
				{
					continue;
				}

				if( str[i] == 'z' )
				{
					str[i] = 'a';
				}
				else
				{
					++str[i];
				}
			}
		}

		std::cout << str << '\n';
	}
}

Measured memory_bytes: 1176
#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 modRev(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*modRev(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);
  }
}

int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int ordfact(int n,int p){
  int ret=0;
  while(n!=0){
    n/=p;
    ret+=n;
  }
  return ret;
}

int main(){
  int i,j,k,cnt=0;
  int n;
  cin>>n;
  if(n==1){
    cout<<0<<endl;
    return 0;
  }
  vector<int> p;
  for(i=2;i<=n;i++){
    for(j=2;j<i;j++){
      if(i%j==0)break;
    }
    if(j==i)p.push_back(i);
  }
  vector<int> d;
  for(i=0;i<p.size();i++){
    d.push_back(ordfact(n,p[i]));
  }
  if(d[0]>=74)cnt++;
  int c[25];
  for(i=0;i<25;i++)c[i]=0;
  for(i=0;i<d.size();i++){
    if(d[i]>=24)c[24]++;
    if(d[i]>=14)c[14]++;
    if(d[i]>=4)c[4]++;
    if(d[i]>=2)c[2]++;
  }
  cnt+=c[24]*(c[2]-1);
  cnt+=c[14]*(c[4]-1);
  cnt+=(c[4]*(c[4]-1)/2)*(c[2]-2);
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/python

s = input()
n = len(s)

def cond1(s):
    n = len(s)
    for i in range(n // 2):
        if s[i] != s[-1-i]:
#            print("{}: False".format(s))
            return False
    return True

if cond1(s[:((n-1)//2)]) and cond1(s[(n+3)//2-1:]) and cond1(s):
    print("Yes")
else:
    print("No")

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

dp = [[10**10 for B in range(1 << N)] for i in range(M+1)]
dp[0][0] = 0

for i in range(M):
    a, b = map(int, input().split())
    c = [int(j) for j in input().split()]
    C = sum([1 << (x-1) for x in c])

    for B in range(1 << N):
        dp[i+1][B] = min(dp[i][B], dp[i+1][B])
        dp[i+1][B | C] = min(dp[i+1][B | C], dp[i][B]+a)

if dp[M][(1 << N)-1] == 10**10:
    print(-1)
else:
    print(dp[M][(1 << N)-1])


Measured memory_bytes: 82524
#!/usr/bin/env python

nm = []
ml = []
nl = []

n, m, l = input().split()
n = int(n)
m = int(m)
l = int(l)

for i in range(n):
    r = input()
    rSplit = r.split()
    for j in range(m):
        rSplit[j] = int(rSplit[j])
    nm.append(rSplit)

for i in range(m):
    r = input()
    rSplit = r.split()
    for j in range(l):
        rSplit[j] = int(rSplit[j])
    ml.append(rSplit)

for i in range(n):
    nlrow = []
    for k in range(l):
        value = 0
        for j in range(m):
            value += nm[i][j]*ml[j][k]
        nlrow.append(value)
    nl.append(nlrow)

for i in range(n):
    for j in range(l):
        nl[i][j] = str(nl[i][j])

for x in nl:
    print(" ".join(x))

Measured memory_bytes: 9120
import itertools

n = int(input())
weights = list(map(int, input().split()))
ls = list(itertools.accumulate(weights, ))
ls_rev = list(itertools.accumulate(reversed(weights)))
ans = min([abs(ls[i - 1] - ls_rev[n - i - 1]) for i in range(1, n)])
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cstring>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
void run_case()
{
    int n, r;
    cin >> n >> r;
    if (n >= 10)
        cout << r << "\n";
    else
        cout << r + 100 * (10 - n) << "\n";
}
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    return 0;
}

Measured memory_bytes: 3660
fn main() {
    // 数列の長さ
    let n: usize = read()[0];

    // ランダムな数列
    let mut s: Vec<i32> = read();

    let count = merge_sort(&mut s, 0, n);
    println!("{}", s.iter().map(|x| x.to_string()).collect::<Vec<String>>().join(" "));
    println!("{}", count);
}

// 一行読み込みを行う
fn read<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let stdin = std::io::stdin();
    stdin.read_line(&mut buf).unwrap();
    buf.split_whitespace().flat_map(str::parse).collect()
}

fn merge_sort(a: &mut Vec<i32>, left: usize, right: usize) -> usize {
    let mut count = 0;
    if left + 1 < right {
        let mid: usize = (left + right) / 2;
        count += merge_sort(a, left, mid);
        count += merge_sort(a, mid, right);
        count += merge(a, left, mid, right);
    }
    count
}

fn merge(a: &mut Vec<i32>, left: usize, mid: usize, right: usize) -> usize {
    // リストの左側を作成
    let mut left_array = a[left..mid].to_vec();

    // リストの右側を作成
    let mut right_array = a[mid..right].to_vec();

    // 終端追加
    left_array.push(std::i32::MAX);
    right_array.push(std::i32::MAX);

    let mut i = 0;
    let mut j = 0;
    for k in left..right {
        if left_array[i] <= right_array[j] {
            a[k] = left_array[i];
            i += 1;
        } else {
            a[k] = right_array[j];
            j += 1;
        }
    }

    // iとjを合算が比較回数となる
    i + j
}


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

public class Main {
    public  static void main(String[] args) {
        FastScanner sc = new FastScanner();

        String A = sc.next();
        if(A.equals("ABC")) {
        	System.out.print("ARC");
        } else {
        	System.out.print("ABC");
        }
    }
}

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();
    }
}

Measured memory_bytes: 32352
import java.util.*;
import java.io.*;
import static java.lang.System.*;

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());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int N = sc.nextInt();
    if(N >= 10000){
      if(N == 100000) out.println(9 + 900 + 90000);
      else out.println(9 + 900 + N - 9999);
    }else if(N >= 100){
      if(N >= 1000) out.println(9 + 900);
      else out.println(9 + N - 99);
    }else{
      if(N >= 10) out.println(9);
      else out.println(N);
    }
  }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#include <queue>
using namespace std;
int main(){
	int N; cin >> N; 
	vector<pair<int, long long int>> V[100010] = {}; 
	for(int i = 0; i < N-1; i++){
		int a, b; long long int c; 
		cin >> a >> b >> c; 
		V[a].push_back(pair<int, long long int> (b, c)); 
		V[b].push_back(pair<int, long long int> (a, c)); 
	}
	long long int D[100010] = {};
	for(int i = 2; i <= N; i++){
		D[i] = 1e16;
	}
	queue<int> que;
	que.push(1); 
	while(que.size()){
		int p = que.front(); que.pop(); 
		for(int i = 0; i < V[p].size(); i++){
			int n = (V[p].at(i)).first;  
			if(D[n] == 1e16){
				que.push(n); 
				D[n] = D[p] + (V[p].at(i)).second; 
			}
		}
	}
	for(int i = 1; i <= N; i++){
		if(D[i] % 2) cout << 0 << endl; 
		else cout << 1 << endl; 
	}
}

Measured memory_bytes: 8704
const log = console.log;

const createScanFunctions = (input: string) => {
  const str = input.trim();
  const len = str.length;
  let index = 0;

  const scan = () => {
    const startIndex = index;

    while (index < len) {
      const char = str[index];

      if (char === " " || char === "\n")
        return str.substring(startIndex, index++);

      index++;
    }

    return str.substr(startIndex);
  };

  const scanInt = () => parseInt(scan());

  return { scan, scanInt };
};

// ----

const createWeightedUnionFindTree = (elementCount: number) => {
  const parent = new Array<number>(elementCount);
  const rank = new Array<number>(elementCount);
  const weightDifference = new Array<number>(elementCount);

  for (let i = 0; i < elementCount; i++) {
    parent[i] = i;
    rank[i] = 0;
    weightDifference[i] = 0;
  }

  const getRoot = (id: number): number => {
    if (parent[id] === id) return id;

    const root = getRoot(parent[id]);
    weightDifference[id] += weightDifference[parent[id]];

    return (parent[id] = root);
  };

  const getWeight = (id: number) => {
    getRoot(id);

    return weightDifference[id];
  };

  const getWeightDifference = (idA: number, idB: number) =>
    getWeight(idA) - getWeight(idB);

  const uniteTrees = (idA: number, idB: number, weightDiff: number): void => {
    weightDiff += getWeight(idA) - getWeight(idB);

    const rootA = getRoot(idA);
    const rootB = getRoot(idB);

    if (rootA === rootB) return;

    if (rank[rootA] < rank[rootB]) {
      parent[rootA] = rootB;
      weightDifference[rootA] = -weightDiff;
    } else {
      parent[rootB] = rootA;
      weightDifference[rootB] = weightDiff;
      if (rank[rootA] === rank[rootB]) rank[rootA]++;
    }
  };

  const sameTree = (idA: number, idB: number) => getRoot(idA) === getRoot(idB);

  return {
    getRoot,
    uniteTrees,
    sameTree,
    getWeight,
    getWeightDifference
  };
};

const isOdd = (n: number) => (n & 1) === 1;

// ----

function Main(input: string): void {
  const { scanInt } = createScanFunctions(input);
  const n = scanInt();

  const { uniteTrees, getWeightDifference } = createWeightedUnionFindTree(n);

  const edgeCount = n - 1;

  for (let i = 0; i < edgeCount; i++) {
    const vertexIdA = scanInt() - 1;
    const vertexIdB = scanInt() - 1;
    const distance = scanInt();

    uniteTrees(vertexIdA, vertexIdB, distance);
  }

  const vertexColors = new Array<number>(n).fill(0);
  for (let i = 1; i < n; i++)
    if (isOdd(getWeightDifference(0, i))) vertexColors[i] = 1;

  log(vertexColors.join("\n"));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 19680
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
int v[510][510];
int main(){
    vector<pair<int, int> > ans1;
    vector<pair<int, int> > ans2;
    int H, W; cin >> H >> W;
    for(int i=0; i<H; ++i) for(int j=0; j<W; ++j) cin >> v[i][j];
    
    int cnt=0;
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            if(v[i][j]%2!=0){
                if(v[i][j+1]%2!=0){
                    v[i][j]--;
                    v[i][j+1]++;
                    ans1.push_back({i+1, j+1});
                    ans2.push_back({i+1, j+2});
                    cnt++;
                    continue;
                }
                if(v[i+1][j]%2!=0){
                    v[i][j]--;
                    v[i+1][j]++;
                    ans1.push_back({i+1, j+1});
                    ans2.push_back({i+2, j+1});
                    cnt++;
                    continue;
                }
                
                if(v[i+1][j]%2==0&&i+1<H){
                    v[i][j]--;
                    v[i+1][j]++;
                    ans1.push_back({i+1, j+1});
                    ans2.push_back({i+2, j+1});
                    cnt++;
                    continue;
                }
                if(v[i][j+1]%2==0&&j+1<W){
                    v[i][j]--;
                    v[i][j+1]++;
                    ans1.push_back({i+1, j+1});
                    ans2.push_back({i+1, j+2});
                    cnt++;
                    continue;
                }
            }
        }
    }
    
    cout << cnt << endl;
    for(int i=0; i<(int)ans1.size(); ++i) cout << ans1[i].first << " " << ans1[i].second << " " << ans2[i].first << " " << ans2[i].second << endl;
        
    return 0;
}



Measured memory_bytes: 5228
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int

ll max(ll a,ll b)
{
    if(a>b)
    {
        return a;
    }
    return b;
}

ll min(ll a,ll b)
{
    if(a<b)
    {
        return a;
    }
    return b;
}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a, b);
}



int main() {

ll n,m;
cin>>n>>m;
if(n==m)
{
    cout<<"Yes";
} else{
    cout<<"No";
}
    return 0;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

cost = [0] * N
for i in range(1, N):
    if i > 1:
      c1 = abs(h[i - 1] - h[i])
      c2 = abs(h[i - 2] - h[i])
      cost[i] = min(cost[i - 1] + c1, cost[i - 2] + c2)
    else:
      cost[i] = abs(h[i - 1] - h[i])
print(cost[N-1])



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

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素


int main(){
    int n;
    cin>>n;
    int ans=n/2+n%2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<utility>
#include<math.h>
#include<queue>
#include<vector>
#include<limits>
#include<cmath>
#include <cstdio>
#include <iomanip>


using namespace std;
int main(){
  double a,b,x;
  cin>>a>>b>>x;
  
  long double atanX;
  long double HOWlong;
  
  
  if(x>a*a*b/2){
  	HOWlong=2*x/(a*a)-b;
    b-=HOWlong;
    x-=HOWlong*a*a;
    //cout<<b<<endl;
    //cout<<x<<endl;
  }
  
  atanX=atan(x*2/(a*b*b));
  
  cout << fixed << setprecision(10);
  if(x==a*a*b){
  	cout<<0;
  }else{
    
  cout<<90-atanX*360/(2*M_PI);
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
#include <stack>
#include <ctime>
using namespace std;
typedef unsigned long long LL;
const LL INF=987654321;
const LL MOD=1e9+7;
const int N=1000010;
typedef pair<int,int> P;
LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}
LL a[N];
int main(void)
{
//	freopen("in.txt","r",stdin);
	LL n,m;
	while(cin>>n){
		for(int i=0;i<n;i++)
			cin>>a[i];
		LL ans=1;
		for(int i=0;i<n;i++){
		//	LL t=;
		//	cout<<t<<"#"<<endl;
			ans=ans/gcd(a[i],ans)*a[i];
		}
		cout<<ans<<endl;
	}
    return 0;
}

Measured memory_bytes: 256
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

int main()
{
  int a,b;
  cin >> a >> b;
  int res = 0;
  for (int i = a; i <= b; i++){
    string tmp = to_string(i);
    if (tmp[0] == tmp[4] && tmp[1] == tmp[3]) {
      res++;
    }
  }

  cout << res << endl;


}


Measured memory_bytes: 256