akhauriyash/Code-Regression huggingface dataset:
void main() {
	auto ip = readAs!(ulong[]), N = ip[0], K = ip[1];
	auto A = readAs!(ulong[]);
	ulong[ulong] bits;
	foreach(i; 0..64) bits[i] = 0;
	foreach(i; A) {
		auto arr = i.bitsSet;
		debug arr.writeln;
		foreach(j; arr) bits[j]++;
	}
	debug bits.writeln;
	debug writefln("k: %b", K);
	debug writefln("%(%.6b %)", A);
	bool[ulong] visited;
	foreach(i; 0..64) visited[i] = false;
	
	ulong k = K;
	while(k != 0) {
		auto a = k.bitsSet.array.back;
		if(!visited[a]) {
			visited[a] = true;
			if(N / 2 >= bits[a]) {
				foreach(ref v; A) v ^= (1UL << a);
				k -= (1UL << a);
				debug writefln("k: %d, a: %d", k, a);
				continue;
			}
		}
		k = (1UL << a) - 1;
		debug writefln("k: %d, here %d", k, a);
	}
	debug writefln("%(%.6b %)", A);
	A.sum.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define nl cout<<"\n"
#define fr(n) for(int i = 0; i<n; i++)
#define frr(j, n) for(int i = j; i<n; i++)
using namespace std;
typedef long long int lli;
int main(){
    string s;
    cin>>s;
    lli sum = 0;
    fr(s.length())sum += s[i] - '0';
    if(sum%9==0)cout<<"Yes";
    else cout<<"No";
}

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

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

        }
        
      }
      cout << endl;
    }
  }

  
  return 0;
}


Measured memory_bytes: 2996
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
int main(){
  ll n,x,count=0,sum=0;
  cin >> n;
  ll a[n];
  bool havezero = false;
  for(int i=0;i<n;i++){
    cin >> x;
    a[i] = abs(x);
    if(x < 0){
      count++;
    }else if(x == 0){
      havezero = true;
    }
    sum += abs(x);
  }
  //cout << count << endl;
  if(havezero || count % 2 == 0){
    cout << sum;
  }else{
    sort(a,a+n);
    //cout << a[0] << endl;
    cout << sum - a[0] * 2;
  }
}


Measured memory_bytes: 1024
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (int i = 1;; i++) {
            int x = sc.nextInt();
            if (x == 0) break;
            System.out.printf("Case %d: %d\n", i,x);
        }
 
    }
}


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

#define rep(i,N) for(int i=0;i<(int)(N);i++)
#define REP(i,N,k) for(int i=k;i<(int)(N);i++)

#define vi vector<int>
#define pb push_back

#define pii pair<int,int>
#define fi first
#define se second
int main(){


//    ifstream in("b_in.txt");
//    cin.rdbuf(in.rdbuf());

    int w,h;
    while(cin >> w >> h,w){
        int sx,sy;
        string s[30];
        rep(i,h) cin >> s[i];
        rep(y,h)rep(x,w) if(s[y][x]=='@') s[y][x]='.',sx=x,sy=y;

        queue<pii> que;
        que.push(pii(sx,sy));
        bool u[30][30] = {};
        u[sy][sx] = true;
        int cnt = 1;
        while(!que.empty()){
            int x,y;
            tie(x,y) = que.front();
            que.pop();
            rep(i,4){
                const int dx[] = {0,1,0,-1,0};
                int nx = x + dx[i];
                int ny = y + dx[i+1];
                if(nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
                if(s[ny][nx] == '#') continue;
                if(u[ny][nx]) continue;
                u[ny][nx] = true;
                cnt += 1;
                que.push(pii(nx,ny));
            }
        }
        cout << cnt << endl;
    }

    return 0;
}


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

int main(){
	int d,n;
	cin >> d >> n;
    if(n == 100){
        int ans = pow(100,d) * 101;
        cout << ans << endl;
        return 0;
    }
	int ans = pow(100,d) * n;
	cout << ans << endl;
}

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

typedef long long ll;
typedef pair<ll,ll> ii;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
const int INF=2012345678;
const ll LLINF=4012345678012345678LL;
const ll MOD=998244353; //1000000007
const ld PI=3.1415926535898;
const ld EPS=1e-9;
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(b==0)return a;return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll expo(ll b,ll p,ll m){ll res=1; while(p){if(p&1)res=(res*b)%m; b=(b*b)%m; p>>=1;} return res;}
inline ll modinv(ll a,ll m){return expo(a,m-2,m);}

int main(){
	int h1,m1,h2,m2,k;
	scanf("%d%d%d%d%d",&h1,&m1,&h2,&m2,&k);
	int t=(h2-h1)*60+(m2-m1);
	printf("%d",t-k);
}


Measured memory_bytes: 3816
N=int(input())
S=input()
R,G,B=0,0,0
for i in range(N):
    if(S[i]=='R'):
        R+=1
    elif(S[i]=='G'):
        G+=1
    else:
        B+=1
res=R*G*B
cnt=0
for i in range(N):
    lr=0
    while(i-lr>=0 and i+lr<N):
        s=set([S[i],S[i-lr],S[i+lr]])
        if(len(s)==3):
            res-=1
        lr+=1
print(res)

Measured memory_bytes: 68168
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++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 all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define VECV(a,n,m) vector<vector<int>> a(n, vector<int>(m));
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H,N;
  cin>>H>>N;
  VEC(A,N);
  int sum=0;
  rep(i,N){
    cin >>A[i];
    sum=sum+A[i];
  }
  if(sum>=H)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;


  
}


Measured memory_bytes: 640
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx - sx, ty - sy
print('U' * dy + 'R' * dx
      + 'D' * dy + 'L' * dx
      + 'L' + 'U' * (dy + 1) + 'R' * (dx + 1)
      + 'DR' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U')


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

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;

int main(){
	ll n, k; cin >> n >> k;
	ll ans = 0;
	ll t = n / k;
	ans += t * t * t;
	if(k % 2 == 0){
		ll s = n / (k / 2) - t;
		ans += s * s * s;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll n, x, p, ans;

int main() {
    fast_io; cout_precision;
    cin >> n >> x >> p;
    ans = 0;
    for (ll i = 1, a; i < n; i++) {
        cin >> a;
        if (a + p >= x) {
            ans += a + p - x;
            a = max(x - p, ll(0));
        }
        p = a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	double x, y, z, r;
} Coord;

typedef struct {
	int parent, rank;
} Node;

typedef struct {
	int from, to;
	double weight;
} Edge;

Coord coord[ 100 ];
Node node[ 100 ];
Edge edge[ 4950 ];

int compare( const void *a, const void *b ) {
	double at = (*(Edge *)a).weight, bt = (*(Edge *)b).weight;

	if ( at < bt )
		return -1;
	if ( at > bt )
		return 1;
	return 0;
}

int find( int x ) {
	if ( node[ x ].parent == x )
		return x;
	else
		return node[ x ].parent = find( node[ x ].parent );
}

int uniteSame( int x, int y ) {
	int xSet = find( x ), ySet = find( y );

	if ( xSet == ySet )
		return 0;

	if ( node[ xSet ].rank < node[ ySet ].rank )
		node[ xSet ].parent = ySet;
	else {
		node[ ySet ].parent = xSet;
		if ( node[ xSet ].rank == node[ ySet ].rank )
			node[ xSet ].rank++;
	}

	return 1;
}

double kruskal( int v, int e ) {
	int i;
	double sum;

	qsort( edge, e, sizeof(Edge), &compare );

	for ( i = 0; i < v; i++ ) {
		node[ i ].parent = i;
		node[ i ].rank = 0;
	}

	sum = 0.0;
	for ( i = 0; i < e; i++ )
		if ( uniteSame( edge[ i ].from, edge[ i ].to ) )
			sum += edge[ i ].weight;

	return sum;
}

int main( void ) {
	int i, j;
	int n, cnt;

	while ( scanf( "%d", &n ), n ) {
		for ( i = 0; i < n; i++ )
			scanf( "%lf %lf %lf %lf", &coord[ i ].x, &coord[ i ].y, &coord[ i ].z, &coord[ i ].r );

		cnt = 0;
		for ( i = 0; i < n; i++ )
			for ( j = i + 1; j < n; j++ ) {
				edge[ cnt ].from = i;
				edge[ cnt ].to = j;
				edge[ cnt ].weight = fmax( sqrt( ( coord[ i ].x - coord[ j ].x ) * ( coord[ i ].x - coord[ j ].x ) + ( coord[ i ].y - coord[ j ].y ) * ( coord[ i ].y - coord[ j ].y ) + ( coord[ i ].z - coord[ j ].z ) * ( coord[ i ].z - coord[ j ].z ) ) - coord[ i ].r - coord[ j ].r, 0.0 );
				cnt++;
			}

		printf( "%.3f\n", kruskal( n, n * ( n - 1 ) / 2 ) );
	}

	return 0;
}

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


typedef long long int ll;
# define PI 3.14159265358979323846

int main(){
  ll n;
  cin>>n;
  map <ll,ll> m;
  ll i;
  for(i=0;i<n-1;i++){
    ll x;
    cin>>x;
    m[x]++;
  }
  for(i=1;i<=n;i++){
    cout<<m[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 16128
import java.util.*;

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

        boolean flag = false;
        for(int i = 0; i < 26; i++){
            for(int j = 0; j < 16; j++){
                if(4 * i + 7 * j == N) flag = true;
            }
        }
        
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 23764
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func readInt() (read int) {
	scanner.Scan()
	read, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := readInt()
	mins := make([]int, n)
	maxs := make([]int, n)

	for i := 0; i < n; i++ {
		mins[i] = readInt()
		maxs[i] = readInt()
	}

	sort.Ints(mins)
	sort.Ints(maxs)

	cnt := 0
	if n%2 == 0 {
		c1 := mins[n/2-1] + mins[n/2]
		c2 := maxs[n/2-1] + maxs[n/2]
		cnt = c2 - c1 + 1
	} else {
		c1 := mins[n/2]
		c2 := maxs[n/2]
		cnt = c2 - c1 + 1
	}
	fmt.Println(cnt)
}


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

using namespace std;

int n;

int a[120], ans;

int main () {
    cin >> n;
    for (int i = 1;i < n;i ++) {
        cin >> a[i];
    }ans = a[1];
    for (int i = 2;i < n;i ++) {
        ans += min (a[i], a[i - 1]);
    }ans += a[n - 1];
    cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,x,y;
int fir[100005],nxt[200005],to[200005],cnt;
int dp[100005][2],son[100005][2],ans,S;
int a[100005],tot,vis[100005],b[100005],Ans[2][100005];

int read(){
	int x=0;char ch=getchar();
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x;
}

void DP(int x,int f){
	for(int i=fir[x];i;i=nxt[i]){
		if(to[i]==f) continue;
		DP(to[i],x);
		if(dp[to[i]][0]+1>dp[x][0]){
			dp[x][1]=dp[x][0],son[x][1]=son[x][0];
			dp[x][0]=dp[to[i]][0]+1,son[x][0]=to[i];
		}
		else if(dp[to[i]][0]+1>dp[x][1]) dp[x][1]=dp[to[i]][0]+1,son[x][1]=to[i];
	}
	if(ans<dp[x][0]+dp[x][1]+1) ans=dp[x][0]+dp[x][1]+1,S=x;
}

void lian(int x,int op){
	vis[x]=1;
	if(op) a[++tot]=x;
	if(son[x][0]) lian(son[x][0],op);
	if(!op) a[++tot]=x;
}

void dfs(int x,int pos,int dep){
	if(dep>1){puts("-1");exit(0);}
	b[pos]++,vis[x]=1;
	for(int i=fir[x];i;i=nxt[i]) if(!vis[to[i]]) dfs(to[i],pos,dep+1);
}

int com(){
	for(int i=1;i<=n;i++){
		if(Ans[0][i]<Ans[1][i]) return 0;
		if(Ans[0][i]>Ans[1][i]) return 1;
	}
	return 0;
}

int main(){
	n=read();
	for(int i=1;i<n;i++){
		x=read(),y=read();
		to[++cnt]=y,nxt[cnt]=fir[x],fir[x]=cnt;
		to[++cnt]=x,nxt[cnt]=fir[y],fir[y]=cnt;
	}
	DP(1,0);
	if(son[S][0]) lian(son[S][0],0);
	a[++tot]=S,vis[S]=1;
	if(son[S][1]) lian(son[S][1],1);
	for(int i=1;i<=tot;i++) dfs(a[i],i,0);
	int s=0;
	for(int i=1;i<=tot;i++){
		for(int j=s+1;j<s+b[i];j++) Ans[0][j]=j+1;
		Ans[0][s+b[i]]=s+1,s+=b[i];
	}
	s=0;
	for(int i=tot;i>=1;i--){
		for(int j=s+1;j<s+b[i];j++) Ans[1][j]=j+1;
		Ans[1][s+b[i]]=s+1,s+=b[i];
	}
	int id=com();
	for(int i=1;i<=n;i++) printf("%d ",Ans[id][i]);

	return 0;
}

Measured memory_bytes: 8704
import numpy as np

D=int(input())
c=[int(i) for i in input().split()]
s=[]
for d in range(D):
    s.append([int(i) for i in input().split()])

t=[]
for d in range(D):
    t.append(int(input()) - 1)

v = [0]*D
last = [[0 for i in range(26)] for d in range(D)]

for d in range(D):
    if d>=1:
        last[d] = last[d-1][:]
    last[d][t[d]] = d+1

for d in range(D):
    v[d] = s[d][t[d]] - sum([c[i]*(d+1 - last[d][i]) for i in range(26)])

v_sum=0
for d in range(D):
    v_sum+=v[d]
    print(v_sum)

Measured memory_bytes: 27296
N = int(input())
h_list = list(map(int, input().split(' ')))

def grouping(h_list):
    groups = []
    group = []
    for h in h_list:
        if h == 0:
            if group != []:
                groups.append(group)
            group = []
            continue
        group.append(h)
    if group:
        groups.append(group)
    return groups


sum_mizuyari = []
def groups_mizuyari(h_list):
    num_mizuyari = min(h_list)
    h_list = [h - num_mizuyari  for h in h_list]
    sum_mizuyari.append(num_mizuyari)
    groups = grouping(h_list)
    for group in groups:
        groups_mizuyari(group)

groups_mizuyari(h_list)
print(sum(sum_mizuyari))

Measured memory_bytes: 3188
while True:
    H,W = map(int, input().split())
    i = 0

    if H == 0 and W == 0:
        break
    for i in range(H):
        if i == 0 or i == H-1:
            print('#'*W)
        else:
            print('#',end='')
            print('.'*(W-2),end='')
            print('#')
    print()



Measured memory_bytes: 5636
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
//
struct poi{
  int X;int Y;int Z;
  bool operator<(const poi&R)const{
    return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
  }
};
//
//
int N;
int P[200000],Q[200000];
int main(){
	cin>>N;
	FOR(i,0,N){
		cin>>P[i];
		P[i]--;
		Q[P[i]]=i;
	}
	int cnt=1,ans=1;
	FOR(i,1,N){
		if(Q[i]>Q[i-1]){
			cnt++;
		}else{
			cnt=1;
		}
		ans=max(ans,cnt);
	}
	cout<<N-ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
def solve(idx, end_idx, money, prices, current, understandings, target)
  return money if current.all? { |u| u >= target }
  return -1 if idx >= end_idx

  s1 = solve(idx + 1, end_idx, money, prices, current.dup, understandings, target)
  M.times do |i|
    current[i] += understandings[idx][i]
  end
  s2 = solve(idx + 1, end_idx, money + prices[idx], prices, current.dup, understandings, target)

  if s1 == -1 && s2 == -1
    -1
  elsif s2 == -1
    s1
  elsif s1 == -1
    s2
  else
    [s1, s2].min
  end
end

N, M, X = gets.split.map(&:to_i)
a = N.times.map { gets.split.map(&:to_i) }
prices = []
understandings= []
a.each do |a1|
  prices << a1[0]
  understandings << a1[1..-1]
end

current = Array.new(M, 0)
puts solve(0, N, 0, prices, current, understandings, X)


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

#define INF 0x3f3f3f3f

using namespace std;

typedef long long ll;
// typedef priority_queue<int, vector<int>, greater<int>> min_pq;

std::random_device rd_device;
std::mt19937 rng(rd_device());

template<typename T>
void printVec(vector<T> &vec) {
    for (auto &v : vec) cout<<v<<" ";
    cout<<endl;
}

void sleep(int ms) {
    std::this_thread::sleep_for(std::chrono::milliseconds(ms));
}

int main() {
    std::srand(std::time(0));
    ios::sync_with_stdio(false);
//    cin.exceptions(ios_base::failbit);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(10);
    cout<<fixed;
    
    int n;
    cin>>n;
    vector<vector<int>> graph(n);
    for (int i=0;i<n-1;i++) {
        int u, v;
        cin>>u>>v;
        u--;v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    queue<int> q;
    vector<int> used(n);
    q.push(0);
    used[0] = 1;
    int last = 0;
    while (!q.empty()) {
        int curr = q.front();
        q.pop();
        for (auto next : graph[curr]) {
            if (used[next]) continue;
            q.push(next);
            used[next] = 1;
        }
        if (q.empty()) last = curr;
    }
    queue<vector<int>> qq;
    used = vector<int>(n);
    int u = last;
    used[u] = 1;
    qq.push({u, 0});
    int m = 0;
    int l = -1;
    while (!qq.empty()) {
        vector<int> curr = qq.front();
        qq.pop();
        for (auto next : graph[curr[0]]) {
            if (used[next]) continue;
            qq.push({next, curr[1]+1});
            if (curr[1]+1 > m) {
                m = curr[1]+1;
                l = next;
            }
            used[next] = 1;
        }
    }
    m++;
    if (m%3 == 2) cout<<"Second"<<endl;
    else cout<<"First"<<endl;

    return 0;
}


Measured memory_bytes: 23908
n = int(input())
s = [input() for i in range(n)]

m = int(input())
t = [input() for i in range(m)]

mojiretsu = {}

for item in s:
    if not item in mojiretsu:
        mojiretsu.setdefault(item, 1)
    else:
        mojiretsu[item] += 1

for item in t:
    if not item in mojiretsu:
        mojiretsu.setdefault(item, -1)
    else:
        mojiretsu[item] -= 1

# mojiretsu_sorted = sorted(mojiretsu.items(), key=lambda x:x[1], reverse=True)

# print("{}".format(mojiretsu_sorted.values()))

max_coin = 0
for i in mojiretsu.values():
    if max_coin < i:
        max_coin = i

print("{}".format(max_coin))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 3005;

int dp[MAX_N][MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    int n = len(s), m = len(t);
    dp[0][0] = 0;
    rep(i,n+1){
        rep(j,m+1){
            if(j < m) cmx(dp[i][j+1], dp[i][j]);
            if(i < n) cmx(dp[i+1][j], dp[i][j]);
            if(i < n && j < m){
                if(s[i] == t[j]){
                    cmx(dp[i+1][j+1], dp[i][j]+1);
                }
            }
        }
    }
    string ans;
    int x = n, y = m;
    while(x + y != 0){
        if(x > 0){
            if(dp[x-1][y] == dp[x][y]){
                x--;
                continue;
            }
        }
        if(y > 0){
            if(dp[x][y-1] == dp[x][y]){
                y--;
                continue;
            }
        }
        x--, y--;
        ans.pb(s[x]);
    }
    // cout << dp[n][m] << "\n";
    reverse(all(ans));
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 35456
#include <iostream>

using namespace std;
 
int main(void){
	
	int r,D,x2000[11];
	
	cin>>r>>D>>x2000[0];
	
	for(int i=0;i<10;i++){
		x2000[i+1]=r*x2000[i]-D;
		cout<<x2000[i+1]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long  a[1000][1000], b[1000][1000], c[1000][1000];
int main() {
	int n, m, l;
	cin >> n >> m >> l;
	for (int x = 0; x < n; x++) {
		for (int y = 0; y < m; y++) {
			cin >> a[x][y];

		}
	}
	for (int y = 0; y < m; y++) {
		for (int z = 0; z < l; z++) {
			cin >> b[y][z];
		}
	}
	for (int x = 0; x < n; x++) {
		for (int z = 0; z < l; z++) {
			c[x][z] = 0;
		}
	
	}
	for (int x = 0; x < n; x++) {
		for (int z = 0; z < l; z++) {
			for (int k = 0; k < m; k++) {
				c[x][z] += a[x][k] * b[k][z];
			}
		}
	}
	for (int x = 0; x < n; x++) {
		for (int z = 0; z < l; z++) {
			cout << c[x][z];
if(z!=l-1)	cout << ' ';
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 4548
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>

using namespace std;
using  ull = unsigned long long int;

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


int main() {

	int N, M;
	cin >> N >> M;

	vector<int>num(N, 1);
	int from, to;

	vector<bool>red_list(N, false);
	red_list[0] = true;
	

	rep(i, 0, M) {

		cin >> from >> to;

		num[from - 1]-- ;
		num[to - 1]++;
		if (red_list[from - 1] == true) {
			if (num[from - 1] == 0) {
				red_list[from - 1] = false;
				red_list[to - 1] = true;
			}
			else
			{
				red_list[to - 1] = true;
			}
		}
		

	}

	int cnt = 0;
	rep(i, 0, red_list.size()) {
		if (red_list[i])cnt++;
	}

	cout << cnt << endl;


	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
#include <fstream>
using namespace std;

main(void){
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());
    int N,M,L,R,minL,maxR;

    cin >> N>>M;
    minL=0;
    maxR=N;
    for (int i = 1;i<=M;i++){
        cin >>L>>R;
        if(L>minL){
            minL=L;
        }
        if(R<maxR){
            maxR=R;
        }
    }
    int ans = maxR-minL+1;
    if (ans <0){
        ans=0;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] a) throws NumberFormatException, IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        String line;
        int num = 0;
        // データ読み込み
        while ((line = in.readLine()) != null && num < 200) {
            String res = String.valueOf(Integer.parseInt(line.split(" ")[0]) + Integer.parseInt(line.split(" ")[1]));
            System.out.println(res.length());
            num++;
        }
    }
}

Measured memory_bytes: 17080
import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
while(true){
int A=scan.nextInt();
int B=scan.nextInt();
if(A==0&&B==0)
break;
for(int a=0;a<A;a++){
for(int b=0;b<B;b++){
	if(a==0||a==A-1||b==0||b==B-1)
System.out.print("#");
	else
		System.out.print(".");
}
System.out.println();
}
System.out.println();
}
}
}

Measured memory_bytes: 32616
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	Raghav();
	int n, ans = 0;
	cin >> n;
	int a[n + 1];
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		if (i % 2 != 0)
		{
			if (a[i] % 2 != 0)
				ans++;
		}

	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3628
N = int(input())
board = list(map(int, input().split()))

count = 0
has_odd = False
while True:
    for i, num in enumerate(board):
        if num % 2 == 0:
            board[i] //= 2
        else:
            has_odd = True
    if has_odd:
        break
    count += 1

print(count)

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

using namespace std;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '+') {
      ans++;
    } else {
      ans--;
    }
  }
  cout << ans << '\n';
  return 0;
}


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

key = [0 for i in range(M)]
cost = []

for i in range(M):
    a,b = list(map(int,input().split()))
    c = list(map(int,input().split()))
    cost.append(a)
    for j in range(b):
        key[i] += pow(2,c[j]-1)

INF = float('inf')

DP = [[INF]*(2**N) for i in range(M+1)]
DP[0][0] = 0
for i in range(M):
    for j in range(2**N):
        DP[i+1][j] = min(DP[i][j],DP[i+1][j])
        DP[i+1][j|key[i]] = min(DP[i+1][j|key[i]],DP[i][j]+cost[i],DP[i][j|key[i]])

if DP[M][2**N-1]>10**27:
    print(-1)
else:
    print(DP[M][2**N - 1])

Measured memory_bytes: 138712
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char s[105];
//hahah
int main() {
    int k;
    scanf("%s", s);
    scanf("%d", &k);
    int len = strlen(s);
    int f = 0, b = 0, cnt = 0;
    for (int i = 0; s[i] == s[0]; i++) f++;
    for (int i = len - 1; i > f && s[i] == s[0]; i--) b++;
    for (int i = f + 1; i < len - b; i++) {
        if (s[i] == s[i - 1]) {
            s[i] = '#';
            cnt++;
        }
    }
    // printf("\t%d %d %d\n", f, cnt, b);
    if (f == len) printf("%lld", ((long long)k * f) >> 1);
    else printf("%lld", cnt * (long long)k + (f >> 1) + (b >> 1) + ((f + b) >> 1) * ((long long)k - 1));
    return 0;
}

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

using namespace std;

int main()
{

int ns[10001];

for(int i=0;i<10001;i++)
{
    ns[i]=0;
}

int n;
scanf("%d",&n);

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

int frst=1;

for(int i=0;i<10001;i++)
{
    if(ns[i]!=0)
    {
        for(int j=0;j<ns[i];j++)
        {
            if(!frst){printf(" ");}
            else{frst=0;}
            printf("%d",i);
        }
    }
}

printf("\n");

return 0;
}

Measured memory_bytes: 3248
a=str(input())
i=0
sw=0
cou1=0
cou2=0
while i<len(a):
  if sw==0:
    if a[i]!="0":
      cou1+=1
    sw=1
  else:
    if a[i]!="1":
      cou1+=1
    sw=0
  i+=1
sw=1
i=0

while i<len(a):
  if sw==0:
    if a[i]!="0":
      cou2+=1
    sw=1
  else:
    if a[i]!="1":
      cou2+=1
    sw=0
  i+=1

if cou2>=cou1:
  print(cou1)
else:
  print(cou2)

Measured memory_bytes: 3188
tbl = [[False for i in range(13)] for j in range(4)]
pattern = ["S","H","C","D"]

n = int(input())

for k in range(n):
    egara,suji = input().split()
    rank = int(suji)
    tbl [pattern.index(egara)][rank-1] = True

for i in range(4):
    for j in range(13):
        if tbl[i][j] == False:
            print(pattern[i],j+1)


Measured memory_bytes: 5604
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
bc = []
for i in range(M):
  l = list(map(int,input().split()))
  bc.append(l)

bc.sort(key=lambda x:x[1],reverse=True)
ind = 0
for i in range(N):
  if A[i] < bc[ind][1] and bc[ind][0] >0:
    A[i] = bc[ind][1]
    bc[ind][0] -= 1
    if bc[ind][0] == 0:
      ind = min(ind+1,M-1)
  else:
    ind = min(ind+1,M-1)
    
print(sum(A))
  

Measured memory_bytes: 32968
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	int sum = 0;
	int minv = LINF;
	rep(i,n){
		cin >> a[i];
		sum += a[i];
	}
	int sum2 = 0;
	rep(i,n-1){
		sum2 += a[i];
		chmin(minv,abs(sum - sum2 - sum2));
	}
	cout << minv << '\n';
	return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<MOD>;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S; cin >> S;
    int N = S.size();

    vector<vector<mint>> dp(N+1, vector<mint>(13));
    dp[0][0] = 1;
    vector<int> C(13);
    rep(i,13) C[i] = i*10%13; 
    rep(i,N) {
        if (S[i] == '?') {
            rep(k,10) {
                rep(j,13) {
                    dp[i+1][(C[j]+k)%13] += dp[i][j];
                }
            }
        } else {
            int k = S[i] - '0';
            rep(j,13) {
                dp[i+1][(C[j]+k)%13] += dp[i][j];
            }
        }
    }

    cout << dp[N][5].a << endl;
}


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

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

	int n;
	cin >> n;

	string newBoard;
	cin >> newBoard;

	int ans = 0;
	for(int i = 0; i < n; ++i) {
		string oldBoard;
		cin >> oldBoard;

		for(int j = 0; j < oldBoard.size(); ++j) {
			if(newBoard[0] != oldBoard[j])
				continue;

			for(int k = j + 1; k < oldBoard.size(); ++k) {
				if(newBoard[1] != oldBoard[k])
					continue;

				for(int l = 2; l < newBoard.size(); ++l) {
					int tmp = j + l * (k - j);
					if(tmp >= oldBoard.size() || newBoard[l] != oldBoard[tmp])
						goto ng;
				}

				++ans;
				goto next;
			ng:;
			}
		}

	next:;
	}

	cout << ans << endl;

	return EXIT_SUCCESS;
}

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

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

//階乗
int factorial(int k){
    int result=1;
    for (int i=1;i<=k;++i){
        result*=i;
    }
    return result;
}

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

    vector<ll>x(n+1);
    rep(i,n)cin>>x[i];
    x[n]=X;

    sort(x.begin(),x.end());

    vector<ll>sub(n);
    rep(i,n)sub[i]=x[i+1]-x[i];

    ll ans=sub[0];

    rep2(i,1,n-1) ans=__gcd(ans,sub[i]);

    cout<<ans<<endl;

}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
def solve():
    H, W = map(int, input().split())
    S = [list(input())for _ in range(H)]
    Map = [[0]*W for _ in range(H)]
    Map1 = [[0]*W for _ in range(H)]
    for i in range(H):
        if S[i][0]=='.':
            Map[i][0]=1
        for j in range(1, W):
            if S[i][j]=='.':
                Map[i][j]=Map[i][j-1]+1
        tmp=0
        for j in range(W)[::-1]:
            if Map[i][j]>0:
                if tmp==0:
                    tmp = Map[i][j]
                Map[i][j]=tmp
            else:
                tmp = 0
    for i in range(W):
        if S[0][i]=='.':
            Map1[0][i]=1
        for j in range(1, H):
            if S[j][i]=='.':
                Map1[j][i]=Map1[j-1][i]+1
        tmp = 0
        for j in range(H)[::-1]:
            if Map1[j][i]>0:
                if tmp==0:
                    tmp = Map1[j][i]
                Map1[j][i]=tmp
            else:
                tmp = 0
    ans = 0
    for i in range(H):
        for j in range(W):
            ans = max(ans, Map[i][j]+Map1[i][j])
    print(ans-1)
        
solve()

Measured memory_bytes: 245768
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "No" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> x(N),y(N);
    rep(i,N) cin>>x[i]>>y[i];
    ll ans=0;
    rep(i,N){
        rep(j,N){
            if(i==j) continue;
            ll p=x[i]-x[j];
            ll q=y[i]-y[j];
            ll buf=0;
            rep(k,N){
                rep(l,N){
                    if(k==l) continue;
                    if(x[k]-x[l]==p and y[k]-y[l]==q) ++buf;
                }
            }
            maxi(ans,buf);
        }
    }
    cout<< N-ans <<"\n";

}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const Arr = (input.trim()).split("\n");

const binarySearch = (key, arr, N) => {
  let mid;
  let left = 0;
  let right = N;
  if (key < arr[0] || arr[N-1] < key) return 0;
  while (left < right) {
    mid = Math.floor((left + right) / 2);
    if (key < arr[mid]) right = mid;
    else if (key > arr[mid]) left = mid + 1;
    else return 1;
  }
  return 0;
}


(function main() {
  const N1 = Number(Arr[0]);
  const arr1 = Arr[1].split(" ").map(Number);
  // const N2 = Number(Arr[2]);
  const arr2 = Arr[3].split(" ").map(Number);
  console.log(arr2.map(e => binarySearch(e, arr1, N1)).reduce((a, b) => a + b, 0));
})();



Measured memory_bytes: 34932
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n, r; cin >> n >> r;
    if (n >= 10) {
        cout << r;
    } else {
        cout << r + 100 * (10 - n);
    }
}


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

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

int main() {
  ll n, ans = 0, x;
  vector<ll> a(4, 0);
  rep(i, 6) cin >> x, x--, a[x]++;
  int one = 0, two = 0, three = 0, four = 0;
  for (auto b : a) {
    if (b != 2 && b != 1) {
      puts("NO");
      return 0;
    }
  }

  puts("YES");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int A,B;
int main(){
    cin >> A >> B;
    int ct = 0;
    repi(i,A,B){
        string rs = to_s(i);
        reverse(ALL(rs));
        if(to_s(i) == rs) ct++;
    }
    pr(ct);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug(x) cerr<<"\tDEBUG: "<<#x<<" = "<<(x)<<endl
#define debug2(a,x) cerr<<#a<<"\tDEBUG: "<<#x<<" = "<<(x)<<endl
using namespace std;
const int maxn=1e5+100,maxm=maxn*40,P=1e9+7;
int tot,head[maxn],to[maxn<<1],nxt[maxn<<1],col[maxn<<1],w[maxn<<1];
void add_edge(int u,int v,int c,int d){
	to[++tot]=v;
	nxt[tot]=head[u];
	col[tot]=c;
	w[tot]=d;
	head[u]=tot;
}
int n,q;
int id,rt[maxn],lson[maxm],rson[maxm],sum[maxm],cnt[maxm];
int fa[maxn][20];
int dep[maxn];
void insert(int &rt,int l,int r,int x,int d){
	if(!rt)rt=++id;
	cnt[rt]++;
	sum[rt]+=d;
	if(l==r)return;
	int mid=l+r>>1;
	if(x<=mid)insert(lson[rt],l,mid,x,d);
	else insert(rson[rt],mid+1,r,x,d);
}
int merge(int a,int b,int l,int r){
	if(!a||!b)return a|b;
	int p=++id;
	cnt[p]=cnt[a]+cnt[b];
	sum[p]=sum[a]+sum[b];
	if(l==r)return p;
	int mid=l+r>>1;
	lson[p]=merge(lson[a],lson[b],l,mid);
	rson[p]=merge(rson[a],rson[b],mid+1,r);
	return p;
}
void dfs(int f,int x){
	fa[x][0]=f;
	dep[x]=dep[f]+1;
	for(int i=1;i<17;i++)
		fa[x][i]=fa[fa[x][i-1]][i-1];
	for(int i=head[x];i;i=nxt[i]){
		int y=to[i];
		if(y==f)continue;
//		puts("?");
		insert(rt[y],1,n-1,col[i],w[i]);
		rt[y]=merge(rt[y],rt[x],1,n-1);
		dfs(x,y);
	}
}
void up(int &a,int k){
	for(int i=0;i<17;i++)
		if(1<<i&k)a=fa[a][i];
}
int LCA(int a,int b){
	if(dep[a]<dep[b])swap(a,b);
	up(a,dep[a]-dep[b]);
	if(a==b)return a;
	for(int i=16;i>=0;i--)
		if(fa[a][i]!=fa[b][i])
			a=fa[a][i],b=fa[b][i];
	return fa[a][0];
}
int Cnt,Sum;
void Query(int rt,int l,int r,int x,int p){
	if(!rt)return;
	if(l==r){
		Cnt+=cnt[rt]*p;
		Sum+=sum[rt]*p;
		return;
	}
	int mid=l+r>>1;
	if(x<=mid)Query(lson[rt],l,mid,x,p);
	else Query(rson[rt],mid+1,r,x,p);
}
int main(){
	cin>>n>>q;
	for(int i=1,x,y,z,c;i<n;i++){
		scanf("%d%d%d%d",&x,&y,&c,&z);
		add_edge(x,y,c,z);
		add_edge(y,x,c,z);
	}
	dfs(0,1);
	for(int i=1,x,y,u,v;i<=q;i++){
		scanf("%d%d%d%d",&x,&y,&u,&v);
		int lca=LCA(u,v);
		int d=sum[rt[u]]+sum[rt[v]]-sum[rt[lca]]*2;
		Cnt=0,Sum=0;
		Query(rt[u],1,n-1,x,1);
		Query(rt[v],1,n-1,x,1);
		Query(rt[lca],1,n-1,x,-2);
//		debug(d);
		printf("%d\n",d-Sum+Cnt*y);
	}
    return 0;
}

Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;
typedef pair<int,int>P;
map<P,int>p;
int dx[]={0,1,1,1,0,-1,-1,-1,0};
int dy[]={-1,-1,0,1,1,1,0,-1,0};
ll ans[19];

int main(){
  ll h,w,n;
  cin>>h>>w>>n;
  rep(i,n){
    int x,y;
    cin>>y>>x;
    y--;x--;
    rep(j,9){
      int nx=x+dx[j];
      int ny=y+dy[j];
      if(0<nx&&nx<w-1&&0<ny&&ny<h-1){
        p[P(nx,ny)]++;
      }
    }
  }

  ans[0]=(h-2)*(w-2);
  for(auto pi:p){
    ans[pi.se]++;
  }
  for(int i=1;i<=9;i++){
    ans[0]-=ans[i];
  }
  rep(i,10){
    cout<<ans[i]<<endl;
  }
  return(0);
}



Measured memory_bytes: 56448
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        String str = scan.next();
        int count=0;
        for(int i=0;i<3;i++)
        {
            if(str.charAt(i)=='1')
            {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 20948
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#define REP(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)

using namespace std;

typedef long long int lli;

int main(){
  string s;
  cin>>s;
  int size = s.size();
  lli sum = 0;
  REP(i,0,size){
    vector<bool> v(size - 1,false);
    REP(j,0,i) v[j] = true;
    sort(v.begin(),v.end());
    do{
      lli temp = s[0]-'0';
      REP(j,0,size-1){
	if(v[j]){
	  sum += temp;
	  temp = 0;
	}
	temp = temp*10 + (s[j + 1]-'0');
      }
      sum += temp;
    }while(next_permutation(v.begin(),v.end()));
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] a = new int[4];
    for(int i = 0;i < 4;i++)a[i]=sc.nextInt();
    Arrays.sort(a);
    if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9)System.out.println("YES");
    else System.out.println("NO");
  }
}

Measured memory_bytes: 23636
package main

	import (
		"fmt"
		"sort"
	)

	func main()  {
		var n int
		var incorrectOrderNum int
		fmt.Scan(&n)
		nums := ScanNums(n)
		sortedNums := make([]int, n)
		copy(sortedNums, nums)
		sort.Ints(sortedNums)

		for i := 0; i < n; i++ {
			if nums[i] != sortedNums[i] {
				incorrectOrderNum++
			}
		}

		if incorrectOrderNum == 2 || incorrectOrderNum == 0 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

	func ScanNums(len int) (nums []int) {
		var num int
		for i := 0; i < len; i++ {
			fmt.Scan(&num)
			nums = append(nums, num)
		}
		return
	}


Measured memory_bytes: 512