akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)


int main() {
	int n;
	cin >> n;
	vector<vector<long long>> v(10);
	rep(i, 10) v[i].resize(10, 0);
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		int A = i;
		int a, b;
		a = A % 10;
		if (a == 0) continue;
		while (A >= 10) A /= 10;
		b = A;
		v[a][b]++;
	}
	rep(i, 10) {
		rep(j, 10) {
			ans += v[i][j] * v[j][i];
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

//---------------------------------------
void seiseki(int m, int f, int r);
//---------------------------------------

int main(void)
{
	int m, f, r; //m_??????????¨?, f_??????????¨?, r_???????¨?

	while(1){
		scanf("%d %d %d", &m, &f, &r);
		if(m == -1 && f == -1 && r == -1){
			break;
		}
		else{
			seiseki(m, f, r);
		}
	}
   return 0;
}
//-----------------------------------------
void seiseki(int m, int f, int r)
{
	if(m == -1 || f == -1){  //??????????¨??????????????¨????????????????????¬????????????´???????????? F
		printf("F\n");
	}
	else if((m + f) >= 80){  //??????????¨???¨??????????¨????????¨??????°??? 80 ??\???????????°????????? A
		printf("A\n");
	}
	else if(((m + f) >= 65) && ((m + f) < 80)){  //??????????¨???¨??????????¨????????¨??????°??? 65 ??\??? 80 ??????????????°????????? B
		printf("B\n");
	}
	else if(((m + f) >= 50) && ((m + f) < 65)){  //??????????¨???¨??????????¨????????¨??????°??? 50 ??\??? 65 ??????????????°????????? C
		printf("C\n");
	}
	else if(((m + f) >= 30) && ((m + f) < 50)){  //??????????¨???¨??????????¨????????¨??????°??? 30 ??\??? 50 ??????????????°????????? D??? 
	    if(r >= 50){
	    	printf("C\n");
	    }                                         //???????????????????¨?????????°??? 50 ??\???????????°????????? C
		else{
			printf("D\n");
		}
	}
	else{
		printf("F\n");
	}
}

Measured memory_bytes: 2596
#include<stdio.h>
#include<string.h>
 
int main(void){
 
  int i,j;
  char str[1000][32];
  int num[1000];
  int maxlen;
  int maxnum;
  int fre;
  int frenum;
  int len;
 
  for(i=0;i<1000;i++)num[i] = 1;
 
  i = 0;
  maxlen = 0;
 
  while(fscanf(stdin,"%s ",str[i]) != EOF){
    len = strlen(str[i]);
    if(maxlen < len){
      maxlen = len;
      maxnum = i;
    }
    for(j=0;j<i;j++){
      if( !strcmp(str[i],str[j]) ){
    num[j]++;
    i--;
    break;
      }
    }
    i++;
  }
 
  fre = 0;
  for(j=0;j<i;j++){
    if(fre < num[j]){
      fre = num[j];
      frenum = j;
    }
  }
 
  printf("%s %s\n",str[frenum],str[maxnum]);
 
  return 0;
}

Measured memory_bytes: 568
import java.util.Scanner;

/**
 * A - Harmony
 * 相違なる整数 A, B があります
 * |A−K|=|B−K| となるような整数 K を出力してください。
 * そのような整数が存在しなければ、代わりに IMPOSSIBLE を出力してください。
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 1の容器の容量
        int a = sc.nextInt();
        // 1の容器に入っている水の量
        int b = sc.nextInt();

        // 入力値A, Bが偶数と奇数で異なる場合、IMPOSSIBLE
        if( a % 2 != b % 2 ) {
            System.out.println( "IMPOSSIBLE" );
        } else {
            System.out.println( ( a + b ) / 2 );
        }

        sc.close();
    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define FOR(i, n) for (int i = 0; i < (int)(n); ++i)
#define pb push_back
#define debug(x) std::cout << #x << ": " << x << '\n';
typedef long long ll;
const int N = 210, mod = 998244353;
int dp[N][N][2];
char a[N][N];
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n, m;
    std::cin >> n >> m;
    FOR(i, n) {
        FOR(j, m) {
            std::cin >> a[i][j];
        }
    }
    memset(dp, 0x3f, sizeof(dp));
    dp[0][0][a[0][0] == '#'] = (a[0][0] == '#');
    FOR(i, n) {
        FOR(j, m) {
            for (int last = 0; last < 2; ++last) {
                bool check = a[i][j] == '#';
                if (i - 1 >= 0) {
                    dp[i][j][check] = std::min(dp[i][j][check], dp[i - 1][j][last] + (last != check && check == 1));
                }
                if (j - 1 >= 0) {
                    dp[i][j][check] = std::min(dp[i][j][check], dp[i][j - 1][last] + (last != check && check == 1));
                }
            }
            // debug(i << ' ' << j << ' ' << dp[i][j][a[i][j] == '#']);
        }
    }
    std::cout << std::min(dp[n - 1][m - 1][0], dp[n - 1][m - 1][1]);
}

Measured memory_bytes: 1280
from collections import deque

def bfs(s):
    que = deque([(s, 0)])
    dist = [None]*n
    while que:
        cur, cst = que.popleft()
        if dist[cur] != None:
            continue
        dist[cur] = cst
        for nxt in es[cur]:
            que.append((nxt, cst+1))
    return dist

n,u,v = map(int,input().split())
es = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    es[a-1].append(b-1)
    es[b-1].append(a-1)
dist_u = bfs(u-1)
dist_v = bfs(v-1)
ans = 0

for i in range(n):
    if dist_v[i]-dist_u[i] >= 1:
        ans = max(ans, dist_v[i])
print(max(0, ans-1))

Measured memory_bytes: 76960
#include <iostream>
#include <vector>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;
typedef long long ll;
ll dp[maxn][2];
vector<int> G[maxn];
void test(int x,int y)
{
	dp[x][0] = dp[x][1] = 1;
	for(auto u : G[x])
	{
		if(y != u)
		{
			test(u,x);
			dp[x][0] = dp[x][0] * (dp[u][0] + dp[u][1]) % mod;
			dp[x][1] = dp[x][1] * dp[u][0] % mod;
		}
	}
}
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	for(int i = 1;i < n; ++i)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	test(1,0);
	for(int i = 0;i < 900000000; ++i);
	printf("%lld\n",(dp[1][0] + dp[1][1]) % mod);
	return 0;
}

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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll a[5],k;

int main(){
    for(int i = 0; i < 5; i++)  cin >> a[i];
    cin >> k;
    sort(a,a+5);
    if(a[4]-a[0] <= k)  cout << "Yay!\n";
    else{
        cout << ":(\n";
    }
}

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

int main() {
	//cout<<"GfG!";
	unsigned long long int n, i, c1 = 0, j, x, y, c2;
	cin>>n;
	if (n % 2 != 0)
	    cout<<"0";
	else
	{
	   y = 10;
	   while (n/y  != 0)
	   {
	       c1 += n/y;
	       y = y * 5; 
	   } 
	    //c2 = m1;
	    cout<<c1;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace Maximum_Difference
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int min = int.MaxValue;
            int max = int.MinValue;

            foreach (var input in inputs)
            {
                min = (input < min) ? input : min;
                max = (input > max) ? input : max;
            }

            Console.WriteLine(max - min);
        }
    }
}


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

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

int N;
vector<string> as, bs;
string S, G;

struct state {
  int cost;
  string s;
  state(int cost, string s): cost(cost), s(s) {}  
};

int dij() {
  queue<state> Q;
  map<string, bool> used;
  Q.push(state(0, S));
  while ( !Q.empty() ) {    
    state q = Q.front(); Q.pop();
    int cost = q.cost;
    string s = q.s;

    if ( s == G ) return cost;
    if ( s.size() >= G.size() ) continue;

    if ( used[s] ) continue;
    used[s] = true;    

    for ( int i = 0; i < N; i++ ) {
      int al = as[i].size();      
      string t = "";
      for ( int j = 0; j < (int)s.size(); j++ ) {
	if ( j+al > (int)s.size() ) t.push_back(s[j]);	
	else if ( as[i] == s.substr(j, al) ) {
	  t += bs[i];
	  j += (al-1);	  
	} else {
	  t.push_back(s[j]);	
	}
      }
      // cout << s << " " << t << endl;
      Q.push(state(cost+1, t));      
    }
  }

  return -1;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while ( cin >> N, N ) {
    as.clear();
    bs.clear();
    as.resize(N);
    bs.resize(N);
    for ( int i = 0; i < N; i++ ) {
      cin >> as[i] >> bs[i];      
    }
    cin >> S >> G;

    int ans = dij();
    cout << ans << endl;
  }
  
  return 0;
}



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

int main() {
    int n;
    cin >> n;
    string ans = "APPROVED";
    rep(i, n) {
        int a;
        cin >> a;
        if (a % 2 == 0){
            if (a % 3 != 0) {
                if (a % 5 != 0) ans = "DENIED";
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
	long long n, a = 1;
	cin >> n;
	for (long long i = 1; i <= n; i++)
		a = a * i % 1000000007;  //求a的阶乘
	cout << a;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
	static int A[];
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		int n=cin.nextInt();A=new int[n];
		for(int i=0;i<n;i++)A[i]=Integer.parseInt(cin.next());
		
		int q=cin.nextInt();
		PrintWriter out=new PrintWriter(System.out);
		for(int i=0;i<q;i++) {
			int w=Integer.parseInt(cin.next());
			if(solve(0,w))out.println("yes");
			else out.println("no");
		}
		out.flush();
	}
	
	static boolean solve(int i,int m) {
		
		if(m==0)return true;
		if(i==A.length)return false;
		
		if(solve(i+1,m-A[i]) || solve(i+1,m))return true;
		else return false;
	}

}



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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')

typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const int maxn = 210000;
int a[maxn];
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    int cur = 1;
    for (int i = 1; i <= n; i++)
    {
        if (a[i] == cur)
        {
            cur++;
        }
    }
    if (cur == 1)
        cout << -1 << "\n";
    else
        cout << n - cur + 1 << "\n";
    return 0;
}

Measured memory_bytes: 4396
arr = []
5.times{arr << gets.to_i}
k = gets.to_i

ok = true
for i in 0..3
    for j in (i+1)..4
        if arr[j] - arr[i] > k
            ok = false
            break
        end
    end
    break if !ok
end
puts ok ? "Yay!" : ":("

Measured memory_bytes: 1788
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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 ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   ll K;
   cin >> N >> K;
   ll A[N];
   for (int i = 0; i < N; i++) cin >> A[i];

   ll part[N];
   ll full[N];
   memset(part, 0, sizeof(part));
   memset(full, 0, sizeof(part));

   for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
         if (A[i] > A[j]) {
            full[j]++;
            if (i < j) part[j]++;
         }
      }
   }
   /*
   for (int i = 0; i < N; i++) {
      cout << i << " " << full[i] << " "  << part[i] << endl;
   }
   */
   ll ans = 0;
   for (int i = 0; i < N; i++) {
      ll tmp = part[i] * K;
      tmp %= MOD;
      add(ans, tmp);
      tmp = K * (K - 1) / 2;
      tmp %= MOD;
      tmp *= full[i];
      tmp %= MOD;
      add(ans, tmp);
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

    ll N;
    cin >> N;
    vector<string> S(N);
    Rep (i, N) {
        cin >> S[i];
    }

    ll ans = 0;
    Rep (i, N) {
        ans += N;
        Rep (j, N) {
            Rep (k, N) {
                if (S[(i+j)%N][k] != S[(i+k)%N][j]) {
                    ans -= N;
                    j = k = N;
                }
            }
        }
    }

    cout << ans << "\n";
}

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

using namespace std;

int const N = 5e5+10;

int main() {
    int n,aa[N];
    cin>>n;
    for(int i=0;i<n;i++)cin>>aa[i];
    sort(aa,aa+n);
    double pr = aa[0];
    for(int i=1;i<n;i++){
        pr+=aa[i];
        pr/=2.0;
    }
    cout<<fixed<<setprecision(5)<<pr<<endl;
    return 0;
}






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

#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define mod (ll)(1e9+7)


ll solve(int i,int j,vector <vector <char> >& grid,vector <vector <ll> >& dp){
	if(dp[i][j]>=0) return dp[i][j];
	int m=grid.size();
	int n=grid[0].size();
	if(i==m-1&&j==n-1){dp[i][j]=1; return 1;}
	ll cnt=0;
	if(i+1<m && grid[i+1][j]=='.') cnt=(cnt+solve(i+1,j,grid,dp))%mod;
	if(j+1<n && grid[i][j+1]=='.') cnt=(cnt+solve(i,j+1,grid,dp))%mod;
	dp[i][j]=cnt;
	return cnt;
	}
int main(){
	int m,n;
	cin>>m>>n;
	vector <vector <char> > grid (m,vector <char> (n,'.'));
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			cin>>grid[i][j];
		}
	}
	vector <vector <ll> > dp (m,vector <ll> (n,-1));
	cout<<solve(0,0,grid,dp)<<"\n";
	return 0;
}


Measured memory_bytes: 9216
#include<stdio.h>

 int main(void){
   int div;
   int i,s,sum,count;
   while(fscanf(stdin,"%d %d",&i,&s) != EOF){
     sum = i + s;
     div = 1;
     count = 0;
     while(1){
       if(sum/div == 0){
         break;
       }
       div *= 10;
       count++;
     }

     printf("%d\n",count);
   }

   return 0;
 }

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

using namespace std;

int main(){
  string s,t,u;
  while(cin>>s>>t){
    u=(s.size()>t.size())?t:s;
    if(s==u) s=t;
    int c=u.size(),d=s.size();
    int a=0,b=0;
    for(int i=0;i<c;++i){
      for(int j=0;j<d;++j){
	if(u[(j+i)%c]==s[j]){
	  ++b;
	  if(i+j==c-1){
	    a=max(a,b);b=0;
	  }
	}
	else{
	  a=max(a,b);b=0;
	}
      }
      a=max(a,b);b=0;
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
s=input()
k=int(input())
n=len(s)
s=[s[i] for i in range(n)]
l={"a":26,"b":25,"c":24,"d":23,"e":22,"f":21,"g":20,"h":19,"i":18,"j":17,"k":16,"l":15,"m":14,"n":13,"o":12,"p":11,"q":10,"r":9,"s":8,"t":7,"u":6,"v":5,"w":4,"x":3,"y":2,"z":1}
for i in range(n):
    c=s[i]
    if c=="a":
        continue
    if l[c]>k:
        continue
    k-=l[c]
    s[i]="a"
if k>0:
    k=k%26
    c=s[-1]
    for i in l:
        if l[i]==l[c]-k:
            s[-1]=i
s=''.join(s)
print(s)

Measured memory_bytes: 4212
N, Y = gets.chomp.split.map(&:to_i)

x = -1
y = -1
z = -1
0.upto(N) do |i|
  0.upto(N) do |j|
    if (N-i-j >= 0) && 10_000*i + 5_000*j + 1_000*(N-i-j) == Y
      x = i
      y = j
      z = N-i-j
    end
  end
end

print("#{x} #{y} #{z}")

Measured memory_bytes: 14240
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  int r, g, b;
  cin >> r >> g >> b;
  cout << (((10*g+b)%4 == 0)?"YES":"NO") << endl;
}


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

int solve(int price){
  int temp;
  for(int i=0;i<9;i++){
    cin>>temp;
    price-=temp;
  }
  return price;
}

int main(){
  int price;
  cin>>price;
  while(price){
    cout<<solve(price)<<endl;
    cin>>price;
  }
  return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;

int main() {
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n-1);
    int ans=0;
    rep(i,n) cin >> a.at(i);
    rep(i,n) cin >> b.at(i);
    rep(i,n-1) cin >> c.at(i);
    rep(i,n){
        ans+=b.at(a.at(i)-1);
        if (i!=0){
            if (a.at(i)-1==a.at(i-1)) ans+=c.at(a.at(i-1)-1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
while(1):
    indata=raw_input().split()
    if indata==["0"]:
        break
    else:
        [q1,b,c1,c2,q2]=[int(x) for x in indata]
        #try to buy jidori
        jideal=b/c1
        jqmax=min(jideal,q2)
        if jqmax==0:
            print"NA"
        else:
            jq=jqmax
            while jq>0:
                b1=b-jq*c1
                cq=b1/c2
                if (jq+cq)>=q1:
                    print jq,cq
                    break
                else:
                    jq=jq-1
            if jq==0:
                print "NA"

Measured memory_bytes: 4228
#include <bits/stdc++.h>
using namespace std;
typedef string str;
typedef long double ld;

typedef long long ll;
//typelower_bounddef priority_queue<long long> pq;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//typedef set<int>::iterator sit;
//typedef map<int,int>::iterator mit;
//typedef vector<int>::iterator vit;


#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repn(i,a,b) for(int i=(a);i<=(b);i++)
#define repin(i,a,b,x) for(int i=(a);i<(b);i+=x)
#define repnin(i,a,b,x) for(int i=(a);i<=(b);i+=x)
#define MAX(a,blower_bound) a=max(a,b)
#define MIN(a,b) a=min(a,b)

int main() {

    int n,x,t;
    cin >> n >> x >>t;

    cout << ((n-1)/x +1)*t;


    return 0;
}


Measured memory_bytes: 3624
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N,K = MI()
	n = N
	ans = 1
	while N >= K:
		N //= K
		ans += 1
	print(ans)


if __name__ == '__main__':
	main()

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

int main()
{
    long long x;
    cin >> x;
    
    long long ans = 0;
    while(x >= 5)
    {
        if(x >= 500)
        {
            ans += 1000;
            x -= 500;
        }
        else if(x >= 5)
        {
            ans += 5;
            x -= 5;
        }
    }

    cout << ans << endl;
}

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

x = y = t = 0
for ti,xi,yi in src:
    dist = abs(x-xi) + abs(y-yi)
    if ti - t >= dist and (ti-t)%2 == dist%2:
        t,x,y = ti,xi,yi
    else:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 17312
def get_neighbors(r, c):
    if 0 < r:
        yield r - 1, c
    if r < h - 1:
        yield r + 1, c
    if 0 < c:
        yield r, c - 1
    if c < w - 1:
        yield r, c + 1


def solve(h, w, s):
    for r in range(h):
        for c in range(w):
            if s[r][c] == '#':
                if all(s[nr][nc] == '.' for nr, nc in get_neighbors(r, c)):
                    return False
    return True


if __name__ == '__main__':
    h, w = map(int, input().split())
    s = [input() for _ in range(h)]

    print('Yes' if solve(h, w, s) else 'No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int, int>;

int main() {
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int m=max({a,b,c});
  cout << (pow(2, k)-1)*m+a+b+c << endl;
}


Measured memory_bytes: 4132
(defun solver ()
  (let ((c1 (make-array 9 :fill-pointer 0))
        (c2 (make-array 9))
        (a (make-array 3))
        (b (make-array 3)))
    (loop repeat 9 do
          (vector-push (read) c1))
    (setf (aref a 0) 0
          (aref b 0) (aref c1 0)
          (aref b 1) (aref c1 1)
          (aref b 2) (aref c1 2)
          (aref a 1) (- (aref c1 3) (aref b 0))
          (aref a 2) (- (aref c1 6) (aref b 0)))
    (loop for i from 0 to 2 do
          (setf (aref c2 i) (+ (aref a 0) (aref b i))
                (aref c2 (+ i 3)) (+ (aref a 1) (aref b i))
                (aref c2 (+ i 6)) (+ (aref a 2) (aref b i))))
    (if (equalp c1 c2)
        (format t "Yes~%")
        (format t "No~%"))))

(solver)


Measured memory_bytes: 6632
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
#include <stdlib.h>
int n,max=0,walk[2][2]={{0,1},{1,0}},a[2][100];
void dfs(int count,int h,int l){
    int i;
    if(h==1&&l==n-1){
        if(count>max){
            max=count;
        }
        return;
    }
    for(i=0;i<2;i++){
        if(a[h+walk[i][0]][l+walk[i][1]]!=0){
            dfs(count+a[h+walk[i][0]][l+walk[i][1]],h+walk[i][0],l+walk[i][1]);
        }
    }
    return;
}
int main(){
    int i,j;
    scanf("%d",&n);
    for(i=0;i<2;i++){
        for(j=0;j<n;j++){
            scanf("%d",&a[i][j]);
        }
    }
    dfs(a[0][0],0,0);
    printf("%d\n",max);
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define i_love_u_Phuong ios_base::sync_with_stdio(0); cin.tie(0);
using ll = long long;
using namespace std;
using ld = long double;






int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif // ONLINE_JUDGE
    i_love_u_Phuong;
    char t;
    cin >> t;
    if (t=='A') cout << "T"; else
    if (t=='C') cout << "G"; else
    if (t=='G') cout << "C"; else cout << "A";
    return 0;
}



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

const int64_t MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int n,m;
  cin >> n >> m;
  
  int k[m] = {};
  int s[m][n] = {};
  int tmp = 0;
  for(int i=0;i<m;i++){
    cin >> k[i];
    for(int j=0;j<k[i];j++){
      cin >> tmp;
      tmp--;
      s[i][tmp] = 1;
    }
  }
  int p[m] = {};
  for(int i=0;i<m;i++){
    cin >> p[i];
  }
  
  ll count = 0;
  for(int i=0;i<pow(2,n);i++){
    char switchCount[m] = {};
    for(int j=0;j<n;j++){
      if( (i>>j)&1 != 0){ // j番目はOn
        for(int k=0;k<m;k++){
          if(1==s[k][j]) switchCount[k] += 1;
          switchCount[k] %= 2;
        }
      }
    }
    bool isOK = true;
    for(int k=0;k<m;k++){
      if(switchCount[k] != p[k]){
        isOK = false;
        break;
      }
    }
    if(isOK) count++;
  }

  cout << count << endl;

  return 0;
}



Measured memory_bytes: 4092
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;
typedef vector< pll >   vpll;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(l,r)     ((l)+((r)-(l))/2) 

#define fo(i,a,b)    for(ll i = (ll)(a); i <= (ll)(b); i++)
#define rf(i,a,b)    for(ll i = (ll)(a); i >= (ll)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***




void solve()
{
    ll n;rd(n);
    if(n>=30)cout<<"Yes\n";
    else cout<<"No\n";   
    
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

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

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>

int selectionSort(int A[], int N){
	int i,j,t,sw=0,minj;
	
	for(i=0; i<N-1; i++){
		minj=i;
		
		for(j=i; j<N; j++){
			if( A[j]<A[minj] ){
				minj=j;
			}
		}
			t=A[i];
			A[i]=A[minj];
			A[minj]=t;
			
			if(i != minj){sw++;}
		}
	return sw;

}

int main(void)
{
	int A[100],N,i,sw;
	
	scanf("%d",&N);
	
	for(i=0; i<N; i++){
		scanf("%d",&A[i]);
	}
	
	sw = selectionSort(A,N);
	
	for(i=0; i<N; i++){
			if(i>0){printf(" ");}
		printf("%d",A[i]);
	}
	printf("\n");
	printf("%d\n",sw);
	
	return 0;
}

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

using namespace std;

using int64 = long long;

constexpr int64 P = 1000000007;

// Verified: ABC133E, ABC132D, ABC130E
struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {
    if (x > P || x < 0) { cerr << "Invalied FiniteField!" << endl; exit(1); }
  }
  FiniteField() : x(0) {}
  int64 Value() { return x; }
  inline FiniteField operator+(FiniteField o) {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

vector<FiniteField> MakeFactorialTable(int n) {
  vector<FiniteField> values(n + 1);
  values[0] = 1;
  for (int i = 1; i <= n; i++) {
    values[i] = values[i - 1] * i;
  }
  return values;
}

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

  int n;
  cin >> n;
  vector<FiniteField> xs(n);
  for (int i = 0; i < n; i++) {
    int64 x_raw;
    cin >> x_raw;
    xs[i] = x_raw;
  }

  vector<FiniteField> factorials = MakeFactorialTable(n + 1);
  vector<FiniteField> bases(n + 1);
  bases[0] = factorials[n];
  for (int i = 1; i <= n; i++) {
    bases[i] = factorials[n] / i;
  }

  FiniteField current = 0;
  for (int i = 1; i <= n; i++) {
    current += bases[i];
  }

  FiniteField ans = 0;
  for (int i = 0; i < n; i++) {
    if (i > 0) {
      current -= bases[n + 1 - i];
      current += bases[i + 1];
    }
    ans += current * xs[i];
  }
  cout << ans.Value() << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;


int main(){
    int n, m; cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
   
} 

Measured memory_bytes: 3588
N = int(input())
robot = []
ans = 1
chk = [0]*N
for i in range(N):
    robot.append([int(i) for i in input().split()])
robot.sort()
max_left = robot[0][0] + robot[0][1]
for i in range(N-1):
    if max_left <= (robot[i+1][0] - robot[i+1][1]):
        ans += 1
        max_left = robot[i+1][0] + robot[i+1][1]
    else:
        if max_left > robot[i+1][0] + robot[i+1][1]:
            max_left = robot[i+1][0] + robot[i+1][1]
print(ans)

Measured memory_bytes: 63912
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
const ll N=998244353;
void solve()
{
    ll n, k;
    cin>>n>>k;
    ll sum=0;
    ll count=0;
    while(n)
    {
        n-=(n%k);
        count++;
        n/=k;
    }
    cout<<count<<endl;
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  int x, y, z;
  cin >> x >> y >> z;
  x -= 2 * z;
  int diff = x - (y + z) * (x / (y + z));
  int ans = x / (y + z);
  if (diff >= y)
    out(++ans);
  else
    out(ans);
}
int main(void) { solve(); }


Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
#define fi first
#define se second
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<vi> vvi;
int main() {
	int a,b;
	cin>>a>>b;
	if(a%b)cout<<'1'<<endl;
	else cout<<'0'<<endl;
    return 0;
}


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

int main () {
    string C1, C2;
    cin >> C1 >> C2;

    if ((C1[0] == C2[2]) && (C1[1] == C2[1]) && (C1[2] == C2[0])) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <cmath>

using namespace std;

const long long bigNum = 1000000007;

int gcd(int a, int b)
{
	int buffer = a;
	if (b > a)
	{
		a = b;
		b = buffer;
	}

	int remainder = a%b;
	while (remainder != 0)
	{
		a = b;
		b = remainder;
		remainder = a%b;
	}
	return b;
}

long long comb(int n, int k)
{
	vector<int> setofNums;
	long long ret = 1;
	for (int i = 1; i <= k; i++)
	{
		setofNums.push_back(i);
	}
	for (int i = 0; i < k; i++)
	{
		ret = ret * (n - i);
		for (auto it : setofNums)
		{
			if (ret % it == 0)
			{
				ret /= it;
				it = bigNum;
			}
		}
		if (ret > bigNum)
			ret %= bigNum;
	}
	return ret;
}

int main()
{
	int N,H,W;
	
	cin >> N >> H >> W;
	int output = 0;
	for(int i = 0; i < N; i++)
	{
		int A, B;
		cin >> A >> B;
		if(A >= H && B >=W)
			output++;
	}

	cout << output << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())

#U:0~9の整数でN桁の数列 = 10**N
#A:0を含まないN桁の数列 = 9**N
#B:9を含まないN桁の数列 = 9**N

#ans = |U-(A∪B)| = |U|-|A|-|B|+|A∩B|

MOD = 10**9 + 7
ans = pow(10, N, MOD) - pow(9, N, MOD) - pow(9, N, MOD) + pow(8, N, MOD)
ans %= MOD

print(ans)

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

using namespace std;
typedef long long int ll;

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);

    int cnt = 0;
    int plug = 1;
    while (plug < b)
    {
        plug += a - 1;
        cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;

ll  n, k;
vector<ll> vs;
vector<ll> ps;
vector<ll> ms;
ll pp;
ll mm;
ll pCount;
ll mCount;

struct BSearch {
	ll solve1(ll left, ll right, ll k) {
		while (right - left > 1) {
			ll middle = left + right;
			middle /= 2;
			ll uSum = 0;
			ll lSum = 0;
			rep(i, mm) {
				ll c = vs[i];
				auto u = upper_bound(vs.end() - pp, vs.end(), middle / c);
				//kより小さい
				uSum += vs.end() - u;
				auto l = lower_bound(vs.end() - pp, vs.end(), middle / c);
				//k以上
				lSum += l - (vs.end() - pp);
			}
			if (uSum > k) {
				right = middle;
			}
			else if (lSum > mCount - k) {
				left = middle;
			}
			else return middle;
		}
		return right;
	}
	ll solve2(ll left, ll right, ll k) {
		while (right - left > 1) {
			ll middle = left + right;
			middle /= 2;
			ll uSum = 0;
			ll lSum = 0;
			for (int i = 0; i < mm;i++) {
				ll c = ms[i];
				//kより大きい
				auto u = upper_bound(ms.begin() +  i , ms.end(), middle / c);
				uSum += ms.end() - u;
				//以上
				auto l = lower_bound(ms.begin() + i, ms.end(), middle / c);
				lSum += l - (ms.begin() + i);
			}
			for (int i = 0; i < pp; i++) {
				ll c = ps[i];
				//kより大きい
				auto u = upper_bound(ps.begin() + i, ps.end(), middle / c);
				uSum += ps.end() - u;
				//以上
				auto l = lower_bound(ps.begin() + i, ps.end(), middle / c);
				lSum += l - (ps.begin() + i);
			}
			if (uSum > k) {
				right = middle;
			}
			else if (lSum > pCount - k) {
				left = middle;
			}
			else return middle;
		}
		return right;
	}
};


int main(void)
{
	int n, r;
	cin >> n >> r;
	if (n >= 10) {
		cout << r << endl;
	}
	else {
		cout << (r + 100 * (10 - n)) << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	vi b=a;
	sort(b.begin(),b.end());
	int A=b[n/2-1],B=b[n/2];
	for(int i=0;i<n;i++){
		if(a[i]<=A) cout<<B<<endl;
		else cout<<A<<endl;
	}
}

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


int main() {

	vector<int> vways;
	int number;
	int flag = 0;

	for (int i = 0; i < 4; i++) {
		number = 0;
		vways.push_back(number);
	}

	for (int i = 0; i < 6; i++) {
		cin >> number;
		vways.at(number-1)++;
	}

	for (int i = 0; i < 4; i++) {
		if (vways.at(i) >= 3) {
			flag = 1;
		}
	}


	if (flag == 1) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}


	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n,K;
    cin >> n >> K;
    vector<ll> x, y;
    vector<P> v(n);
    REP(i,n){
        cin >> v[i].first >> v[i].second;
        x.emplace_back(v[i].first);
        y.emplace_back(v[i].second);
    }
    sort(ALL(x));
    sort(ALL(y));
    ll ans = LLONG_MAX;
    REP(i,n){
        for(int j = i + 1; j < n; j++){
            REP(k,n){
                for(int l = k + 1; l < n; l++){
                    ll x_left = x[i], x_right = x[j], y_bottom = y[k], y_top = y[l];
                    int cnt = 0;
                    REP(m,n){
                        if(x_left <= v[m].first && v[m].first <= x_right && y_bottom <= v[m].second && v[m].second <= y_top){
                            cnt++;
                        }
                    }
                    if(cnt >= K){
                        ans = min(ans, abs(x_right - x_left) * abs(y_top - y_bottom));
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/**
    AUTHOR:JUNSH
    TIME:19/5/25
**/
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rev(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
inline int read(){
    int f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
const int inf=0x3f3f3f3f;
int main(){
    int a,b;
    cin>>a>>b;
    if(a>=13)cout<<b<<endl;
    else if(a<=5)cout<<0<<endl;
    else cout<<b/2<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int N;
int a[100000];
int b[100000];

int b_search(int x){
  int l,h,m;
  l=0;h=N;
  while(1){
    
    m=(l+h)/2;
    if(x==b[m])return m;
    else if(x<b[m])h=m;
    else l=m;
  }
}
int comp_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int main(){
  int i,j;
  scanf("%d",&N);
  int ans=0;
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
    b[i]=a[i];
  }
  qsort(b,N,sizeof(int),comp_int);
  for(i=0;i<N;i++){
    if(i%2!=b_search(a[i])%2)ans++;
  }
  printf("%d\n",ans/2);
  return 0;
}


Measured memory_bytes: 1276
num_lines = int(input())
if num_lines<1 or num_lines>10**5:
	print ('Illegal')
	exit()
#print(num_lines)
a=list(map(int,input().split(" ")))
b=list(map(int,input().split(" ")))

if len(a) !=num_lines +1 or len(b)!=num_lines:
	print ('Illegal')
	exit()

#print (a)

s=0
r=0
for i in range(num_lines):
	x=min(a[i]-r,b[i])
	s+=x
	r=0
	if(x<b[i]):
		y=min(a[i+1],b[i]-x)
		s+=y
		r=y
print(s)


Measured memory_bytes: 19004
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
template <typename T> T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;

int main() {
    string a;
    cin >> a;
    string res;
    res += a[0];
    for(int S = 0; S < (1 << 3); ++S) {
        int val = a[0] - '0';
        for(int i = 0; i < 3; ++i) {
            if(S & (1 << i)) {
                val += a[i + 1] - '0';
            } else {
                val -= a[i + 1] - '0';
            }
        }
        if(val == 7) {
            for(int i = 0; i < 3; ++i) {
                res += (S & (1 << i) ? "+" : "-");
                res += a[i + 1];
            }
            break;
        }
    }
    res += "=7";
    cout << res << endl;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> a){
    ll num2=0, num1=0, num0=0;
    for(ll i=0; i< N; i++){
        if(a[i]%2) num0++;
        else if(a[i]%4==0) num2++;
        else num1++;
    }

    if(num2>=num0){
        cout << YES << endl;
        return;
    }
    else if(num2 >= num0-1 && num1 == 0){
        cout << YES << endl;
        return;
    }
    else
        cout << NO << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


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

using ll = long long;
using namespace std;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)

int main() {
  ll n,k; cin>>n>>k;
  vector<bool> bits(n);
  rep(i,k){
    ll d; cin>>d;
    rep(j,d){
      ll x; cin>>x;
      bits[x-1]=true;
    }
  }
  ll cnt=0;
  rep(i,n) if(bits[i]==false) cnt++;
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3640
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
typedef long long int ll;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define MOD 1000000007
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);  
//*s.find_by_order(p)   returns the value of pth largest starting from 0 
//s.order_of_key(p)   returns no. of items that are strictly < p 
//string bin = bitset<64>(m).to_string();     convert decimal m to binary 
vector<int> primeFactors(int n)  
{  
      vector<int> v;
    while (n % 2 == 0)  
    {  
        v.push_back(2); 
        n = n/2;  
    }   
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {    
        while (n % i == 0)  
        {  
            v.push_back(i); 
            n = n/i;  
        }  
    }  
    if (n > 2)  {v.push_back(n);}
    return v;
}
int main()
{
      fast;ll t;t=1;
      while(t--)
      {
            //sieve();
            ll n,i,a,j,g;
            cin>>n;
            ll k=0;
            map<ll,ll>m;
            for(i=0;i<n;i++)
            {
                  cin>>a;
                  if(i==0){g=a;}
                  else{g=__gcd(g,a);}
                  vector<int>v=primeFactors(a);
                  v.pb(1);
                  sort(v.begin(),v.end());
                  for(j=1;j<v.size();j++)
                  {
                        if(v[j]!=v[j-1]){
                              if(m[v[j]]==1){k=1;}
                              m[v[j]]++;
                            //  cout<<v[j]<<" ";
                        }
                  }
            }
            if(k==0){cout<<"pairwise coprime\n";}
            else if(g==1){cout<<"setwise coprime\n";}
            else{cout<<"not coprime\n";}
      }
}

Measured memory_bytes: 8588