akhauriyash/Code-Regression huggingface dataset:
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

root = None

def insert(key):
    global root
    x, y = root, None
    while x: x, y = x.left if key < x.key else x.right, x
    if y is None: root = Node(key)
    elif key < y.key: y.left = Node(key)
    else: y.right = Node(key)

def find(target):
    result = root
    while result and target != result.key:
        result = result.left if target < result.key else result.right
    return result is None

def delete(target):
    def remove_node(p, c, a):
        if p.left == c: p.left = a
        else: p.right = a
    p, c = None, root
    while c.key != target: p, c = c, c.left if target < c.key else c.right
    if c.left is None:
        remove_node(p, c, c.right)
    elif c.right is None:
        remove_node(p, c, c.left)
    elif c.right.left is None:
        c.right.left = c.left
        remove_node(p, c, c.right)
    else:
        g = c.right
        while g.left.left: g = g.left
        c.key = g.left.key
        g.left = g.left.right

def inorder(node):
    return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
def preorder(node):
    return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''

input()
for e in sys.stdin:
    if e[0] == 'i': insert(int(e[7:]))
    elif e[0] == 'd': delete(int(e[7:]))
    elif e[0] == 'f': print(['yes','no'][find(int(e[5:]))])
    else: print(inorder(root)); print(preorder(root))



Measured memory_bytes: 53584
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;


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

	int N, M, A, B, C, X, Y;
	string S, T;

	cin >> S >> T;
	REP(i, S.size()) {
		if (S[i] != T[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
	return 0;
}



Measured memory_bytes: 3616
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  N = readline() |> parseInt
  a,b=zeros(Int,N-1),zeros(Int,N-1)
  for i in 1:N-1
    a[i],b[i]=readline() |> split |> parseArray
  end
  c=readline() |> split |> parseArray

  sort!(c)

  t=[[] for i in 1:N]
  for i in 1:N-1
    push!(t[a[i]], b[i])
    push!(t[b[i]], a[i])
  end

  d=zeros(Int,N)

  dfs(i, i_prev)=begin
    d[i]=pop!(c) #大きいものから取り出す
    for j in t[i]
      if j==i_prev
        continue
      end
      dfs(j, i)
    end
  end
  dfs(a[1], 0)

  M=sum(1:N-1)do i
    min(d[a[i]], d[b[i]])
  end
  println(M)

  print(d[1])
  for i in 2:N
    print(" ")
    print(d[i])
  end
  println()
end

main()


Measured memory_bytes: 181244
S = list(input())

SA = S[0::2]
SB = S[1::2]
c =0

A = ["R","U","D"]
B = ["L","U","D"]

for i in SA:
  if i in A:
    continue
  else:
    c =1
    break
      
for i in SB:
  if i in B:
    continue
  else:
    c =1
    break
    
if c == 1:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
main = do
  [a,b] <- (map read) . words <$> getLine :: IO [Int]
  putStrLn $ if
    a `mod` 3 == 0 then "Possible"
  else if
    b `mod` 3 == 0 then "Possible"
  else if
    (a+b) `mod` 3 == 0 then "Possible"
  else
    "Impossible"

Measured memory_bytes: 508
n,y=map(int,input().split())
x=[-1,-1,-1]
for i in range(n+1):
  for j in range(n-i+1):
    if 10000*i+5000*j+1000*(n-i-j)==y:
      x=[i,j,n-i-j]
      break
for _ in range(3):
  print(x[_])

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef ONLINE_JUDGE
const int N = 1e6+50;
#else
const int N = 1e2+10;
#endif




int main() {
	int n;
	scanf("%d", &n);
	multiset<int> s;
	map<int,int> q;
	REP(i,1,n) {
		int t = rd();
		if (++q[t]==2) s.insert(t),q[t]=0;
	}
	if (s.size()<2) return puts("0"),0;
	auto t = --s.end();
	int A = *t, B = *(--t);
	printf("%lld\n",(ll)A*B);
}








Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
using namespace std;
using ll = long long;

ll gcd(ll a, ll b) {
  while (1) {
    if (a < b) swap(a, b);
    if (!b) break;
    a %= b;
  }
  return a;
}

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  a--;
  ll t = (c * d / gcd(c, d));
  ll e = ((b / c) + (b / d))  - ((a / c) + (a / d))  - ((b / t)  - (a / t));
  cout << b - a - e << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int n;
pair<int,int> a[200010];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i].second>>a[i].first; 
	}
	sort(a,a+n);
	int cnt=0;
	bool flag=0;
	for(int i=0;i<n;i++){
		cnt+=a[i].second;
		if(cnt>a[i].first)flag=1;
	}
	if(flag)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}


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

ll mod=1e9+7;
ll dp[10004][105][2];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  cout<<c<<' '<<a<<' '<<b<<endl;
  return 0;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = inf + 7;
const int N = (int)2e5 + 5;

bool isPal(string s){
	string t=s;
	reverse(all(s));
	return s==t;	
}

string toString(int n){
	int r=n;
	string s="";
	while(r!=0){
		s+=r%10;
		r/=10;
	}
	return s;
}

void solve(){
	int a,b;
	cin>>a>>b;
	int cnt=0;
	Rep(i,a,b){
		if(isPal(toString(i)))cnt++;
	}
	cout<<cnt;
}


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

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

int main()
{
  long double a;
  long double b;
  long double c;
  long double s;
  long double l;
  long double h;
  
  cin >> a >> b >> c;
  
  c=c*(M_PI/180.0);
  
  
  s=0.5*a*b*sin(c);
  l=a+b+sqrt(a*a+b*b-2.0*a*b*cos(c));
  h=b*sin(c);
  
  cout << fixed << setprecision(5) << s << "\n";
  cout << fixed << setprecision(5) << l << "\n";
  cout << fixed << setprecision(5) << h << "\n";
}

Measured memory_bytes: 1300
#include<iostream>
#include<vector>
main(){for(int p,q,i;std::cin>>p>>q;puts("")){std::vector<int>r,u(q,1);for(;(p%=q)*u[p];u[p]=i=0,printf("%d",(p*=10)/q))r.push_back(p);if(p)for(puts("");i<r.size();printf(q?" ":"^"))q=r[i++]^p?q:0;}}

Measured memory_bytes: 5056
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define endl '\n'
#define mod 1000000007
#define inf 1000000000000000000
ll n,m;
vector<vector<char>>grid;
vector<vector<ll>>dp;
ll solve(int i, int j) {
	if(i <= 0 || j <= 0 || i > grid.size() || j > grid[i].size() || grid[i][j] == '#') return 0;
	if(dp[i][j] != -1) return dp[i][j];
	return dp[i][j] = (solve(i, j-1)%mod+solve(i-1,j)%mod)%mod;
}
int main() {
	io
	cin>>n>>m;
	grid.resize(n+1, vector<char>(m+1));
	dp.resize(n+1, vector<ll>(m+1, -1));
	for(int i = 1; i<n+1; i++) {
		for(int j = 1; j<m+1; j++) {
			cin>>grid[i][j];
		}
	}
	dp[1][1] = 1;
	cout<<solve(n, m)%mod;
}




Measured memory_bytes: 9216
from sys import stdin
input = stdin.readline

N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]

A = []
B = []
for a, b in ab:
    A.append(a)
    B.append(b)

A.sort()
B.sort()

if N % 2 == 0:
    a1 = A[N // 2 - 1]
    b1 = B[N // 2 - 1]
    a2 = A[N // 2]
    b2 = B[N // 2]
    xa = (a2 + a1) / 2
    xb = (b2 + b1) / 2
    print(int((xb - xa) * 2 + 1))
else:
    xa = A[N // 2]
    xb = B[N // 2]
    print(xb - xa + 1)


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

int main(void) {

    int fact;
    int min,max;
    scanf("%d",&fact);
    scanf("%d %d",&min,&max);

    for (int i = min;i <= max;i++){
        if(i%fact == 0){
            printf("OK\n");
            return 0;
        }
    }
    printf("NG\n");

    return 0;
}

Measured memory_bytes: 2092
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

int N;
string s[200];

int main(){
    cin>>N;
    rep(i,N) cin>>s[i];

    int ans=-1;
    rep(start,N){
        vector<int> num(N,0);
        int v=1;
        num[start]=v;
        vector<int> tmp;
        queue<int> q;
        q.push(start);
        q.push(-1);
        while(!q.empty()){
            int p=q.front(); q.pop();
            //cout<<p<<endl;
            if(p==-2) break;
            if(p==-1){
                //repr(e,tmp) cout<<e<<' ';cout<<endl;
                repr(e1,tmp){
                    repr(e2,tmp){
                        if(s[e1][e2]=='1'){
                            //cout<<"break"<<endl;
                            goto a;
                        }
                    }
                }
                if(!q.empty()){
                    v++;
                    repr(e,tmp){
                        num[e]=v;
                    }
                    tmp.clear();
                    q.push(-1);
                }else{
                    break;
                }
                continue;
            }
            rep(i,N){
                if(s[p][i]=='1' && num[i]==0){
                    num[i]=INF;
                    q.push(i);
                    tmp.push_back(i);
                }
            }
        }
        //cout<<start<<' '<<v<<endl;
        //rep(i,N) cout<<num[i]<<' ';cout<<endl;
        ans=max(ans,v);
        a:;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3696
N, W = map(int, input().split())
weight, value = [0]*N, [0]*N
for i in range(N):
	weight[i], value[i] = map(int, input().split())


dp=[[0]*(W+1) for _ in range(N+1)]
#初期条件
#dp[0]=0
for i in range(N):
	for w in range(W+1):
		if w>=weight[i]:
			dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
		else:
			dp[i+1][w]=dp[i][w]
print(dp[-1][-1])


"""
def solveDP(N, W, value, weight):
    dp = np.zeros((N+1, W+1))
    
    for i in range(N):
        for w in range(W+1):
            if w >= weight[i]:
                dp[i + 1, w] = max(dp[i, w - weight[i]] + value[i], dp[i, w])
            else:
                dp[i + 1, w] = dp[i, w]
    
    return dp[N , W]




import numpy as np
N,W = map(int,input().split())
 
dp=np.zeros(W-1, dtype=np.int64)
for _ in range(N):
	w, v = map(int, input().split())



for _ in range(N):
    w,v = map(int,input().split())
    np.maximum(dp[w:], dp[:-w] + v, out = dp[w:])
 
answer = dp.max()
print(answer)
"""

Measured memory_bytes: 147056
#include<iostream>
#include<sstream>

using namespace std;


int main() {

	unsigned int A;
	unsigned int B;
	unsigned int M;
	unsigned int i;

	cin >> A >> B >> M;

	unsigned int* Ax = new unsigned int[A];
	unsigned int* Bx = new unsigned int[B];

	for (i = 0; i < A; i++) {

		cin >> Ax[i];

	}

	for (i = 0; i < B; i++) {

		cin >> Bx[i];

	}

	unsigned int* Ma = new unsigned int[M];
	unsigned int* Mb = new unsigned int[M];
	unsigned int* Mc = new unsigned int[M];

	for (i = 0; i < M; i++) {

		cin >> Ma[i] >> Mb[i] >> Mc[i];

	}


	unsigned int j;
	long int ans1;
	long int ans2;

	ans2 = 1000000000;


	for (i = 0; i < M; i++) {

		ans1 = Ax[Ma[i] - 1] + Bx[Mb[i] - 1] - Mc[i];

		ans2 > ans1 ? ans2 = ans1 : ans2 = ans2;
	}
	int AA = 10000000;
	for (i = 0; i < A; i++) {
		(AA > Ax[i]) ? AA = Ax[i] : AA;
	}

	int BB = 10000000;
	for (i = 0; i < B; i++) {
		(BB > Bx[i]) ? BB = Bx[i] : BB;
	}
	ans1 = AA + BB;
	ans2 > ans1 ? ans2 = ans1 : ans2 = ans2;

	delete[] Ma;
	delete[]Mb;
	delete[]Mc;
	delete[]Ax;
	delete[]Bx;


	cout << ans2 << endl;

	return 0;


}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int n,s;
int ans;
void solve(int sum,int idx,int n){
  if(n==0 && sum==s){
    ans++;
    return;
  }else if(n==0 || idx==10){
    return;
  }

  solve(sum+idx,idx+1,n-1);
  solve(sum,idx+1,n);
  return;
}

int main(){
  while(1){
    ans=0;
    cin>>n>>s;
    if(n==0 && s==0) break;
    solve(0,0,n);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define pb push_back
#define SZ(a) ((int)a.size())
//#define TEST
 
const int oo = 1e9;
const int Maxn = 1e5;
const int N = 1e6 + 100;
const double PI = (-2.00) * asin(-1);
 
typedef pair<int, pair<int, int> > iii;
typedef pair<int, int> ii;    

int n;
int cnt[N];
bool check[N];

signed main()
{
    #ifdef TEST
        freopen("test.inp", "r", stdin);
    #endif // TEST  
    ios_base::sync_with_stdio(false);                                      
    cin.tie(0); cout.tie(0);
    
    cin >> n;
    FOR(i, 1, n) {
        int x; cin >> x;
        cnt[x] ++;
    }

    int res = 0;
    FOR(i, 1, (int)1e6) {
        if(cnt[i] == 1 && !check[i]) res ++;
        if(cnt[i]) {
            for(int tmp = 2; i * tmp <= int(1e6); tmp ++)
                check[i * tmp] = 1;
        }
    }
    cout << res;
}


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

public class Main {

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

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[][] graph = new int[n][n];
      String[] vInfo;
      int degree;

      for(int i=0,v=0; i<n; i++) {
        vInfo = br.readLine().split(" ");
        degree = Integer.parseInt(vInfo[1]);
        for(int j=0,k=2; j<degree; j++) {
          v = Integer.parseInt(vInfo[k++]);
          graph[i][v-1] = 1;
        }
      }

      StringBuilder buf = new StringBuilder(n*n);
      for (int[] vertex : graph) {
        for (int v : vertex) {
          buf.append(v).append(" ");
        }
        buf.setLength(buf.length()-1);
        buf.append("\n");
      }

      System.out.print(buf);
    }
    catch (IOException e) {
      System.out.println("IOException!");
    }
  }
}


Measured memory_bytes: 25488
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    int a,b;
    cin>>a>>b;
    cout<<a*b;

}


Measured memory_bytes: 3624
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

double L[22],a[22],b[22];
double d[22][22];
int now[20];
double dist(double x1,double y1,double z1,double x2,double y2,double z2)
{
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2);
}
int main()
{
    int n,m;
    while (scanf("%d%d",&n,&m)>0)
    {
        for (int i=0;i<n;i++) scanf("%lf%lf%lf",&L[i],&a[i],&b[i]);
        for (int i=0;i<n;i++)
            for (int j=0;j<n;j++)
                d[i][j]=dist(L[i],a[i],b[i],L[j],a[j],b[j]);
        double maxi=0;
        for (int i=0;i<(1<<n);i++)
        {
            int cnt=0;
            for (int j=0;j<n;j++)
                if (i&(1<<j))
                    now[cnt++]=j;
            if (cnt!=m) continue;
            double sum=0;
            for (int j=0;j<cnt;j++)
                for (int k=j+1;k<cnt;k++)
                    sum+=d[now[j]][now[k]];
            maxi=max(maxi,sum);
        }
        printf("%.8f\n",maxi);
    }
}

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

long long int chk(long long int A){
  if (A%2==1) return ((A+1)/2)%2;
  else return ((A/2)%2)^A;
}

int main(){
  long long int A,B;
  cin >> A >> B;
  long long int ans=0;
  if (A!=0) ans = chk(A-1)^chk(B);
  else ans = B;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int N;
	int i;
	
	scanf("%d", &N);
	
	for(i=1; i<10; i++){
		if(N/i<=9 && N%i==0){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,x,p;
bool f=false;
int main()
{
    scanf("%d",&n);scanf("%d",&p);
    ll cnt=1;
    for(int i=1;i<=n;i++)
    {
        cnt*=2;
        scanf("%d",&x);
        if(x&1) f=true;
    }
    if(f) printf("%lld\n",cnt/2);
    else {if(p==0) printf("%lld\n",cnt); else puts("0");}
    return 0;
}



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

using namespace std;
const int MOD = 100000007;

int dp[11][10][3][60000] = { { { { 0 } } } };

inline int fall(int bits, int i){
	return (bits >> (i * 2)) & 0x03;
}

int main(){
	int r, c;
	cin >> r >> c;
	vector<string> field(r);
	for(int i = 0; i < r; ++i){ cin >> field[i]; }
	vector<int> state_dic(1 << (c * 2));
	vector<int> state_rdic(1 << (c * 2));
	int state_count = 0;
	for(int i = 0; i < (1 << (c * 2)); ++i){
		if(i & (i >> 1) & 0x55555555){ continue; }
		state_dic[i] = state_count;
		state_rdic[state_count] = i;
		++state_count;
	}
	dp[0][0][0][0] = 1;
	for(int i = 0; i < r; ++i){
		for(int j = 0; j + 1 < c; ++j){
			int v = field[i][j] - '0';
			if(field[i][j] == '.'){ v = -1; }
			for(int k = 0; k <= 2; ++k){
				for(int s = 0; s < state_count; ++s){
					int cur = dp[i][j][k][s];
					if(cur == 0){ continue; }
					int raw_s = state_rdic[s];
					int f = fall(raw_s, j);
					if(v < 0){
						if(k == 0 || f == 0){
							dp[i][j + 1][k][s] =
								(dp[i][j + 1][k][s] + cur) % MOD;
						}
					}else{
						int masked = raw_s & ~(3 << (j * 2));
						int cv = v - f - k;
						if(cv < 0){ continue; }
						for(int a = 0; a <= 2; ++a){
							for(int b = 0; b <= 2; ++b){
								if(a + b != cv){ continue; }
								int c = masked | (a << (j * 2));
								int cc = state_dic[c];
								dp[i][j + 1][b][cc] =
									(dp[i][j + 1][b][cc] + cur) % MOD;
							}
						}
					}
				}
			}
		}
		{
			int j = c - 1;
			int v = field[i][j] - '0';
			if(field[i][j] == '.'){ v = -1; }
			for(int k = 0; k <= 2; ++k){
				if(v < 0 && k >= 1){ continue; }
				for(int s = 0; s < state_count; ++s){
					int cur = dp[i][j][k][s];
					if(cur == 0){ continue; }
					int raw_s = state_rdic[s];
					int f = fall(raw_s, j);
					if(v < 0){
						if(k == 0 || f == 0){
							dp[i + 1][0][0][s] =
								(dp[i + 1][0][0][s] + cur) % MOD;
						}
					}else{
						int masked = raw_s & ~(3 << (j * 2));
						int cv = v - f - k;
						if(cv < 0 || cv > 2){ continue; }
						int c = masked | (cv << (j * 2));
						int cc = state_dic[c];
						dp[i + 1][0][0][cc] =
							(dp[i + 1][0][0][cc] + cur) % MOD;
					}
				}
			}
		}
	}
	cout << dp[r][0][0][0] << endl;
	return 0;
}

Measured memory_bytes: 79020
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>
#include<random>



#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;

int dp[100010];
vector<int> G[100010], Ginv[100010];
bool visited[100010][3];
int dist[100010][3];


void BFS(int n) {
	queue<P>que;
	REP(i, 100010) {
		REP(j, 3) {
			dist[i][j] = INF;
		}
	}
	que.push({ n,0 });
	dist[n][0] = 0;
	int k = 0;
	visited[n][0] = true;
	while (!que.empty()) {
		P p = que.front(); que.pop();
		k = p.second;
		int k2 = (p.second + 1) % 3;
		int pos = p.first;
		for (auto x : G[pos]) {
			if (visited[x][k2])continue;
			dist[x][k2] = min(dist[x][k2], dist[pos][k] + 1);
			que.push({ x,k2 });
			visited[x][k2] = true;
		}
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	REP(i, M) {
		int u, v; cin >> u >> v;
		u--, v--;
		G[u].pb(v);
	}
	int s, t; cin >> s >> t;
	s--,t--;
	BFS(s);
	if (dist[t][0] == INF) {
		print(-1); return 0;
	}
	else {
		print(dist[t][0] / 3);

	}
}


Measured memory_bytes: 10752
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	int n;
	cin >> n;
	int open[101][10];
	for(int i=0; i<n; i++){
		for(int j=0; j<10; j++){
			cin >> open[i][j];
		}
	}
	int profit[101][11];
	for(int i=0; i<n; i++){
		for(int j=0; j<=10; j++){
			cin >> profit[i][j];
		}
	}

	int ans=-1000000000,sum;
	for(int i=1; i<1<<10; i++){
		sum=0;
		for(int j=0; j<n; j++){
			int count=0;
			for(int k=0; k<10; k++){
				if(i>>k&1 && open[j][k])count++;
			}
			sum+=profit[j][count];
		}
		ans=max(ans,sum);
	}
	cout << ans << endl;
	return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll H1, M1, H2, M2, X, Y;
  cin >> H1 >> M1 >> H2 >> M2 >> X;
  Y = (H2*60+M2)-(H1*60+M1) - X;
  if(Y > 0) cout << Y;
  else cout << 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <cmath>

#include <list>
#include <queue>
#include <algorithm>

#define INF 1000000000

using namespace std;
using ll = long long;

int main(void)
{
    string str;
    cin >> str;
    // for(std::string::iterator it = str.begin(); it != str.end(); ++it) {
    //     cout << atoi(*it);
    // }
    int sum = 0;
    for(char& c : str) {
        int num = (int)(c - '0');
        sum = (sum + num) % 9;
        // cout << (int)(c - '0');
    }
    // cout << sum;
    if (sum == 0) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3720
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            s = s.Substring(0, s.Length - 2);

            while (2 <= s.Length)
            {
                var b = true;
                for (var i = 0; i < s.Length / 2; i++)
                {
                    if (s.Length % 2 == 1 || s[i] != s[s.Length / 2 + i])
                    {
                        b = false;
                        break;
                    }
                }

                if (b)
                {
                    break;
                }

                s = s.Substring(0, s.Length - 2);
            }

            Console.WriteLine(s.Length);
        }
    }
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

struct cake {
	ll x;
	ll y;
	ll z;
};

int main()
{
	int N, M;
	cin >> N >> M;
	vector<cake> C;
	fw(N) {
		ll x, y, z;
		cin >> x >> y >> z;
		cake c;
		c.x = x;
		c.y = y;
		c.z = z;
		C.push_back(c);
	}
	ll ans = 0;
	fx(2) {
		fy(2) {
			fz(2) {
				vecl(V);
				fw(N) {
					ll x1 = x % 2 == 0 ? C[w].x : -C[w].x;
					ll y1 = y % 2 == 0 ? C[w].y : -C[w].y;
					ll z1 = z % 2 == 0 ? C[w].z : -C[w].z;
					pb(V, x1 + y1 + z1);
				}
				sorts(V)
				ll sum = 0;
				fw(M) {
					sum += V[N - 1 - w];
				}
				ans = max(ans, sum);
			}
		}
	}

	ce(ans)


    return 0;
}



Measured memory_bytes: 256
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

using namespace std;

ll n;
int main() {
	#ifdef wws
		freopen ("in.txt", "r", stdin);
	#endif
	cin >> n;
	ll len = 1;
	for (len = 1; ; len++) {
		ll add = 1;
		rep(i, 1, len) add *= 26;
		if (add >= n) {
			break;
		}
		n -= add;
	}
	per(i, len, 1) {
		ll cur = 1;
		rep(j, 1, i - 1)  cur *= 26;
		rep(j, 1, 26) {
			if (cur < n) {
				n -= cur;
			}
			else {
				cout << (char)(j + 'a' - 1);
				break;
			}
		}
	}
	assert(n == 1);
	ioi
}


Measured memory_bytes: 3636
using System;

namespace hellounihara
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			int[] arr = new int[10];
			//Random rmd = new Random ();

			for (int i = 0; i < 10; i++) {

				arr [i] = int.Parse(Console.ReadLine());

				//Console.WriteLine(arr[i]);

			}
			for (int i = 0; i < arr.Length-1; i++) {
				for (int j = arr.Length-1; i < j; j--) {
					if (arr [j] < arr [j - 1]) {
						int t = arr [j];
						arr[j] = arr[j-1];
						arr[j-1]= t;
					}
				}
			}
			for (int k = 9; k > 6; k--) {
				Console.WriteLine(arr[k]);
			}
	        
		}
	}
}

Measured memory_bytes: 5596
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
	int X, Y, Z, K;
	cin >> X >> Y >> Z >> K;

	vector<long long> A(X), B(Y), C(Z);
	for (int i = 0; i < X; i++)
		cin >> A[i];
	for (int i = 0; i < Y; i++)
		cin >> B[i];
	for (int i = 0; i < Z; i++)
		cin >> C[i];

	sort(A.rbegin(), A.rend());
	sort(B.rbegin(), B.rend());
	sort(C.rbegin(), C.rend());

	vector<long long> abc;
	for (int i = 0; i < X; i++) {
		int a = i + 1;
		if (a > K)
			break;

		for (int j = 0; j < Y; j++) {
			int b = j + 1;
			if (a*b > K)
				break;

			for (int k = 0; k < Z; k++) {
				int c = k + 1;
				if (a*b*c > K)
					break;

				abc.push_back(A[i] + B[j] + C[k]);
			}
		}
	}
	
	sort(abc.rbegin(), abc.rend());

	for (int i = 0; i < K; i++) {
		cout << abc[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 1404
#include <iostream>
#include <algorithm>
#define MOD 1000000007

using namespace std;

long long pow(long long x, int p = MOD - 2) {
    if (p == 0) return 1;
    if (p % 2) return pow(x, p - 1) * x % MOD;
    long long y = pow(x, p / 2);
    return y * y % MOD;
}

long long fact[200010];

long long binom(int n, int k) {
    return fact[n] * pow(fact[k] * fact[n - k] % MOD) % MOD;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    fact[0] = 1;
    for (int i = 1; i < 200010; i++) fact[i] = fact[i - 1] * i % MOD;
    int n; cin >> n;
    int c[n]; for (int i = 0; i < n; i++) cin >> c[i];
    sort(c, c + n);
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        long long tot = pow(2, i + n - i - 1 + n);
        tot *= c[n - 1 - i]; tot %= MOD;
        tot *= i + 2; tot %= MOD;
        tot *= pow(2); tot %= MOD;
        ans += tot; ans %= MOD;
    }
    cout << ans;
    // ans[i] = sum from k = 1 to i + 1 of
    // (# of subsets of (k - 1) elements from i) * k * cost[i]
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>

int main()
{
	int i, D, G, p[11], c[11];
	scanf("%d %d", &D, &G);
	for (i = 1; i <= D; i++) scanf("%d %d", &(p[i]), &(c[i]));
	
	int ans = 1000, rest, count, comp[11] = {};
	while (comp[0] == 0) {
		rest = G / 100;
		count = 0;
		for (i = 1; i <= D; i++) {
			if (comp[i] == 1) {
				count += p[i];
				rest -= p[i] * i + c[i] / 100;
			}
		}
		for (i = D; i >= 1 && rest > 0; i--) {
			if (comp[i] == 1) continue;
			else if (rest > (p[i] - 1) * i) break;
			else {
				count += (rest + i - 1) / i;
				rest = 0;
			}
		}
		if (rest <= 0 && count < ans) ans = count;
		
		for (i = D; i >= 1 && comp[i] == 1; i--);
		for (comp[i++] = 1; i <= D; comp[i++] = 0);
	}
	
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1700
h,w=gets.chomp.split.map(&:to_i)
s=[]
h.times do |i|
    s[i]=gets.chomp
end
dx=[-1,0,1,-1,1,-1,0,1]
dy=[-1,-1,-1,0,0,1,1,1]
h.times do |i|
    w.times do |j|
        if s[i][j]=="."
            d=0
            dx.length.times do |k|
                if i+dx[k]<0 or i+dx[k]>h-1 or j+dy[k]<0 or j+dy[k]>w-1
                elsif s[i+dx[k]][j+dy[k]]=="#"
                    d+=1
                end
            end
            s[i][j]=d.to_s
        end
    end
end
puts s


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n; cin >> n;
	vector<int> a(n),b(n);
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	int ans = 0;
	rep(bit,30){
		vector<int> B;
		rep(i,n) B.push_back(b[i]%(1<<(bit+1)));
		sort(all(B));
		int cnt = 0;
		int beki = 1<<bit;
		rep(i,n){
			int t = a[i] % (2*beki);
			if(t > beki){
				cnt += upper_bound(all(B),2*beki-1-t) - B.begin();
				cnt += B.end() - lower_bound(all(B),3*beki-t);
			}else{
				cnt += upper_bound(all(B),2*beki-1-t) - lower_bound(all(B),beki-t);
			}
		}
		if(cnt & 1) ans += beki;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3680
#include "bits/stdc++.h"
using namespace std;

typedef long long ll; // −9·10^18 to 9·10^18
typedef __int128_t lll; //−10^38 to 10^38
typedef vector<int> vi;
typedef pair<int,int> pi;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl "\n"
#define EPS 1e-9
#define INF LLONG_MAX
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int mod = 1000*1000*1000 + 7; //1e9+7

void solve()
{
	int n,m; cin>>n>>m;
    int _n=n;
	vector <int> a[n+1];
	vi h; h.pb(0); 
	int ans=0;
	int i;
	while(_n-- && cin>>i) {
		h.pb(i);
	}
	unordered_set<int> node;
	while(m--){
		int s,d; cin>>s>>d;
		a[s].pb(d);
		a[d].pb(s);
		node.insert(s); node.insert(d);
	}
	ans += (n-node.size()); // degree(node)=0 => good observatory.
	for(int i=1;i<n+1;i++)
	{
        if(!a[i].size()) continue; //already counted
        
		bool good = true;
		for(auto j: a[i])
		{
			if(h[i]<=h[j]){
                good =false; break; 
            }
		}
        if(good) ans++;
 
	}
	cout<<ans<<endl;
}

int main()
{
	fio;
	solve();
}

Measured memory_bytes: 12568
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n, a, ans=0;
	cin >> n;
	map<int, int>mp;
	rep(i, n) {
		cin >> a;
		mp[a]++;
	}
	if (mp.size() == 1) {
		if (mp[0] == n)ans = true;
	}
	else if (mp.size() == 2) {
		if (n % 3 == 0) {
			if (mp[0] == n / 3)ans = true;
		}
	}
	else if (mp.size() == 3) {
		int x, y, z,tmp=0;
		auto p = mp.begin();
		x = (*p).first; p++;
		y = (*p).first; p++;
		z = (*p).first;
		tmp = x ^ y;
		tmp ^=z;
		if (tmp == 0 && mp[x] == mp[y] && mp[x] == mp[z] && mp[y] == mp[z])ans = true;
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 7096
n = int(input())
a = list(map(int, input().split())) + [0]

b = []
left, right = 0, 1
while right != n + 2:
    if a[left:right] == list(sorted(a[left:right])):
        right += 1
    else:
        b.append(a[left:right - 1])
        left = right - 1

score = 1000
for a_lr in b:
    stock, score = divmod(score, a_lr[0])
    score += stock * a_lr[-1]
print(score)


Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;
const int MOD = 1'000'000'007;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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

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

const int MAX = 100010;

int main()
{
    while (true)
    {
        int n;
        cin >> n;
        if (n == 0)
        {
            return 0;
        }
        ll dp[n + 5];
        dp[0] = 1;
        dp[1] = 1;
        dp[2] = 2;
        for (int i = 3; i <= n; i++)
        {
            dp[i] = dp[i - 3] + dp[i - 2] + dp[i - 1];
        }
        cout << (((dp[n] + 9) / 10) + 364) / 365 << endl;
    }
}


Measured memory_bytes: 3084
//bismillah....
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb2l(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve(){
  ll n,r;
  cin>>n>>r;
  if(n>=10)
  cout<<r;
  else cout<<r+(100*(10-n));
  }
int main(){
    ll t=1;
   // cin>>t;
    while(t--){
        solve();
        //cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-



def main():
  N,D = map(int, input().split())
  Xn = []
  for _ in range(N):
    Xn.append(list(map(int, input().split())))

  ans = 0
  ansset = [i**2 for i in range(1001)]
  for i in range(N):
    for j in range(i+1,N):
      sm = 0
      for k in range(D):
        sm += (Xn[i][k]-Xn[j][k])**2
      if sm in ansset:
        ans += 1
  print(ans)


if __name__ == "__main__":
  main()

Measured memory_bytes: 38384
H, W = map(int, input().split())
A = [[0 for w in range(W)] for h in range(H)]
for h in range(H):
    A[h] = list(map(int, input().split()))
    
ans = []
for h in range(H-1):
    for w in range(W):
        if A[h][w] % 2 == 1:
            A[h][w] -= 1
            A[h+1][w] += 1
            ans.append([h+1, w+1, h+2, w+1])
            
for w in range(W-1):
    if A[H-1][w] % 2 == 1:
        A[H-1][w] -= 1
        A[H-1][w+1] += 1
        ans.append([H, w+1, H, w+2])
    
print(len(ans))
for a in ans:
    print(a[0], a[1], a[2], a[3])

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define vi vector<int>

#define ll long long int

int ctoi(char c) {return c-'0';}
int ord(char c) {return c-'a';}
int len(string s) {return s.length();}
int itoc(int i) {return i+'a';}


int main() {
int N;
cin>>N;
string s,v;
cin>>s>>v;
for(int i=0;i<N;i++) {cout<<s[i]<<v[i];}
cout<<endl;
return 0;
}


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

int main(){
    int n;
	cin >> n;
	vector<vector<int>> plan(n, vector<int>(n - 1));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n - 1; j++) {
			int x;
			cin >> x;
			x--;
			plan.at(i).at(j) = x;
		}
	}
	
	queue<int> que;
	vector<vector<bool>> first_game(n, vector<bool>(n));
	for (int i = 0; i < n; i++) {
		que.push(i);
	}
	vector<int> ptr(n);
	
	int cnt_game = 0, day = 0;
 	while (!que.empty()) {
		int num = (int)que.size();
        bool can_decide = false;
		for (int i = 0; i < num; i++) {
			int a = que.front(); que.pop();
			if (ptr.at(a) == n - 1) continue;
			
			int b = plan.at(a).at(ptr.at(a));
			
			if (first_game.at(a).at(b) || first_game.at(b).at(a)) {
				ptr.at(a)++;
				ptr.at(b)++;
				que.push(a);
				que.push(b);
				cnt_game++;
				first_game.at(a).at(b) = first_game.at(b).at(a) = false;
                can_decide = true;
			}
			else {
				first_game.at(a).at(b) = first_game.at(b).at(a) = true;
			}
		}
        if (can_decide) day++;
	}
	
	if (cnt_game == n * (n - 1) / 2) cout << day << endl;
	else cout << -1 << endl;
}


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


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
#define vci vector<ll>
#define vcs vector<string>
#define vcp vector<pair<ll, ll>>
#define vct vector<tuple<ll, ll, ll>>
using namespace std;
//vector<vector<ll>> vv(n, vector<ll>(n));

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	ll n, minans = 0, maxans = 0, ora = 0;
	cin >> n;
	map<ll, ll> mp;
	REP(i, n)
	{
		ll r;
		cin >> r;
		if (r < 3200) mp[r / 400]++;
		else {
			maxans++;
			ora++;
		}
	}
	REP(i, 8)
	{
		maxans += mp[i] ? 1 : 0;
		minans += mp[i] ? 1 : 0;
	}
	if (!minans&&ora) minans++;
	cout << minans << " " << maxans << endl;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))
l.sort()
while len(l)>1:
  x = l.pop(0)
  y = l.pop(0)
  l.append((x+y)/2)
  l.sort()
ans = l.pop()
if ans-int(ans)>0:
  print(ans)
else:
  print(int(ans))

Measured memory_bytes: 3060
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, *a = map(int, read().split())
    allxor = a[0]
    for ae in a[1:]:
        allxor = allxor ^ ae
    for ae in a:
        print(allxor ^ ae, end = ' ')

if __name__ == '__main__':
    main()

Measured memory_bytes: 110552
#include<stdio.h>
long long a[200001],b[200001];
long long x=0;
void Merge(long long A[],long long B[],int left,int mid,int right)
{
    int n1,n2;
    n1=left;
    n2=mid+1;
    int k=left;
    while(n1!=mid+1&&n2!=right+1)
    {
        if(A[n1]>A[n2])
        {
            B[k++]=A[n2++];
            x=x+mid+1-n1;
        }
        else
            B[k++]=A[n1++];
    }
    while(n1!=mid+1)
        B[k++]=A[n1++];
    while(n2!=right+1)
        B[k++]=A[n2++];
    for(int i=left;i<=right;i++)
        A[i]=B[i];
    return;
}
void MergeSort(long long A[],long long B[],int left,int right)
{
    int mid;
    if (left < right)
    {
        mid=(left + right)/2;
        MergeSort(A,B,left,mid);
        MergeSort(A,B,mid+1,right);
        Merge(A,B,left,mid,right);
    }
    return;
}
int main(){
    long long n;
    scanf("%d",&n);
    for(long long i=0;i<n;i++)
        scanf("%d",&a[i]);
    MergeSort(a,b,0,n-1);
    printf("%ld\n",x);
    return 0;
}

Measured memory_bytes: 5752
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    ll h, w; cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
    } else {
        cout << (h*w+1)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i =0;i<a.length;i++){
            a[i]=sc.nextInt();
        }
        int t = 0;
        int sum = 0;
        for(int i=0;i<a.length;i++){
            if(i+1-n==0){
                t = Math.max(k+a[0]-a[n-1],t);
                sum += k+a[0]-a[n-1];
            } else {
                t = Math.max(t,a[i+1]-a[i]);
                sum += a[i+1]-a[i];
            }
        }
        System.out.println(sum-t);
    }
}

Measured memory_bytes: 59820