akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

#define pi 3.141592653589793
#define mod 1000000007


int main() {
	int x, y, z;
	cin >> x >> y >> z;
	int count = 0;
	while (true) {
		if (x >= y * (count + 1) + z * (count + 2))count++;
		else break;
	}
	cout << count << endl;
	return 0;
}

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

l = [1] * n
for i in range(m):
    a, b = map(int,input().split())
    if h[a - 1] < h[b - 1]:
        l[a - 1] = 0
    elif h[a - 1] == h[b - 1]:
        l[a - 1] = 0
        l[b - 1] = 0
    else:
        l[b - 1] = 0
print(sum(l))

Measured memory_bytes: 84848
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int A[2][3];
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> A[i][j];
		}
	}

	int mx = 0;
	int s;
	for (int z = 0; z < 2; z++) {
		mx = 0;
		int tt = 1 + (N / A[z][0]);
		for (int i = 0; i <= tt; i++) {
			if (i == 5001)i = max(i, tt - 5001);

			int zz = 1 + ((N - i * A[z][0]) / A[z][1]);
			for (int j = 0; j <= zz; j++) {
				if (j == 5001)j = max(j, zz - 5001);


				int r = N - i * A[z][0] - j * A[z][1];
				if (r < 0) {
					break;
				}
				else {
					s = A[1 - z][0] * i + A[1 - z][1] * j;
					mx = max(mx, r + s);

					int k = r / A[z][2];
					r -= k * A[z][2];

					mx = max(mx, r + s + A[1 - z][2] * k);
				}
			}
		}
		N = mx;
	}


	cout << N << endl;
}


Measured memory_bytes: 256
x,k,d=map(int,input().split())
if abs(x)//d>k:
    if x<0:
        print(abs(x+k*d))
    else:
        print(x-k*d)
else:
    if x<0:
        if (k-abs(x)//d)%2==0:
            print(abs(x+d*(abs(x)//d)))
        else:
            print(x+d*(abs(x)//d+1))
    else:
        if (k-abs(x)//d)%2==0:
            print(x-d*(abs(x)//d))
        else:
            print(abs(x-d*(abs(x)//d+1)))

Measured memory_bytes: 9108
A, B = map(int, input().split())

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

x = gcd(A, B)

res = 1
temp = x
for i in range(2, int(-(-x**0.5//1))+1):
    if temp%i==0:
        cnt=0
        while temp%i==0:
            cnt+=1
            temp //= i
        res += 1

if temp!=1:
    res += 1

print(res)

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

#include <string>
void _150() {
    int n;
    string s;
    cin >> n;
    cin >> s;

    int count = 0;
    for (int i = 0; i < s.size() - 2; ++i) {
        if (s.substr(i, 3) == "ABC") {
            count++;
        }
    }
    cout << count << endl;
}

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,str,flag=1;
	char a[101000],b[101000];
	cin>>a;
	str=strlen(a);
	for(i=0;i<str;i++)
	{
		b[str-i-1]=a[i];
	}
	for(i=0;i<str;i++)
	{
		if(b[i]=='b')b[i]='d';
		else if(b[i]=='d')b[i]='b';
		else if(b[i]=='p')b[i]='q';
		else if(b[i]=='q')b[i]='p';
	}
	for(i=0;i<str;i++)
	{
		if(a[i]!=b[i])
		{
			cout<<"No"<<endl;
			flag=0;
			break;
		}
	}
	if(flag==1)cout<<"Yes"<<endl;
} 

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string t,s;
	cin >> t >> s;
	int n = t.length();
	int ans = 0;
	for(int i=0; i<n; i++) {
		if(t[i]!=s[i]) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3824
from collections import deque

n = int(input())
g = {i: set() for i in range(n)}
edge = []
for i in range(n-1):
    a, b = map(lambda x: int(x)-1, input().split())
    edge.append('{} {}'.format(a, b))
    g[a].add(b)
    g[b].add(a)

k = 0
ans = dict()
p_color = [0] * n
used = [1] + [0] * (n - 1)
que = deque([0])
while que:
    now = que.popleft()
    k = max(k, len(g[now]))
    color = 1
    for i in g[now]:
        if used[i]:
            continue
        if p_color[now] == color:
            color += 1
        p_color[i] = ans['{} {}'.format(now, i)] = ans['{} {}'.format(i, now)] = color
        color += 1
        used[i] = 1
        que.append(i)

print(k)
for e in edge:
    print(ans[e])


Measured memory_bytes: 87424
local k = io.read("*n")
local dig = 1
local dp = {}
dp[1] = {}
for i = 1, 10 do
  dp[1][i] = 1
end
-- dp[1][10] = 0
if k <= 9 then
  print(k)
else
  local sum = 9
  while true do
    dig = dig + 1
    dp[dig] = {}
    for i = 1, 10 do
      local c = dp[dig - 1][i]
      if i == 1 then
        c = c + dp[dig - 1][10]
      elseif i < 10 then
        c = c + dp[dig - 1][i - 1]
      end
      if i == 10 then
        c = c + dp[dig - 1][1]
      elseif i ~= 9 then
        c = c + dp[dig - 1][i + 1]
      end
      dp[dig][i] = c
    end
    local csum = 0
    for i = 1, 9 do
      csum = csum + dp[dig][i]
    end
    if k <= sum + csum then
      -- found digit
      k = k - sum
      local ret = {}
      for i = 1, 9 do
        if k <= dp[dig][i] then
          table.insert(ret, i)
          break
        else
          k = k - dp[dig][i]
        end
      end
      for idig = dig - 1, 1, -1 do
        local cand = {}
        if 0 < ret[#ret] then
          table.insert(cand, ret[#ret] - 1)
        end
        table.insert(cand, ret[#ret])
        if ret[#ret] < 9 then
          table.insert(cand, ret[#ret] + 1)
        end
        for ic = 1, #cand do
          local i = cand[ic]
          local zi = i
          if i == 0 then i = 10 end
          if k <= dp[idig][i] then
            table.insert(ret, zi)
            break
          else
            k = k - dp[idig][i]
          end
        end
      end
      print(table.concat(ret))
      break
    else
      sum = sum + csum
    end
  end
end


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#define INF 100000000000000
#define int long long
using namespace std;

signed main(){
    int N;
    cin >> N;
    int ans = INF;

    for( int i = 1; i <= sqrt(N); i++ ){
        if( N % i == 0 ){
            //cout << i << " " << N / i << endl;
            int tmp;
            tmp = i + (N / i) - 2;
            ans = min ( ans, tmp );
        }
    }
    cout << ans << endl; 
}

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

int_fast32_t n, h, w, a, b, ans;
int main(){
	scanf("%ld %ld %ld", &n, &h, &w);
	while(n--){
		scanf("%ld %ld", &a, &b);
		ans += (a>=h && b>=w);
	}
	printf("%ld\n", ans);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            string S = strs[0];
            string T = strs[1];
            line = Console.ReadLine();
            strs = line.Split(' ');
            int A = int.Parse(strs[0]);
            int B = int.Parse(strs[1]);
            line = Console.ReadLine();
            string U = line;

            if (S == U)
            {
                Console.WriteLine(A-1 + " " + B);
            }
            else
            {
                Console.WriteLine(A + " " + (B - 1));
            }

        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

class RMQ2{
public:
  int n,dat[1555555];
  void init(int _n){
    n=1;
    while(n<_n)n*=2;
    fill(dat,dat+2*n-1,-MAX);
  }
  void update(int k,int a){
    k+=n-1;dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=max(dat[k*2+1],dat[k*2+2]);
    }
  }
  int query(int a,int b){return query(a,b,0,0,n);}
  int query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return -MAX;
    if(a<=l&&r<=b) return dat[k];
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return max(vl,vr);
  }
};

RMQ2 t;

void Main() {
  ll n,m,k;
  cin >> n >> m >> k;
  vector<ll> a[n],b[m];
  rep(i,k) {
    int x,y;
    cin >> x >> y;
    x--,y--;
    a[x].pb(y);
    b[y].pb(x);
  }
  t.init(m);
  rep(i,m) t.update(i,b[i].size());
  int ans=0;
  rep(i,n) {
    rep(j,a[i].size()) {
      ll d=t.query(a[i][j],a[i][j]+1);
      t.update(a[i][j],d-1);
    }
    ans=max(ans,(int)a[i].size()+t.query(0,m));
    rep(j,a[i].size()) {
      ll d=t.query(a[i][j],a[i][j]+1);
      t.update(a[i][j],d+1);
    }
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 40572
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

int main(){
  int N, X, Y;
  cin >> N >> X >> Y;
  vector<vector<int>> dis;
  X--; Y--;
  for (int i=0; i<N; i++){
    vector<int> tmp(N, 0);
    for (int j=i; j<N; j++){
      tmp[j] = j - i;
    }
    dis.emplace_back(tmp);
  }
  
  dis[X][Y] = 1;
  for (int i=0; i<=Y; i++){
    dis[i][Y] = min(dis[i][Y], abs(i - X) + 1);
  }
  for (int i=0; i<=Y; i++){
    for (int j=i+1; j<N; j++){
    	dis[i][j] = min(dis[i][j], abs(j - Y) + dis[i][Y]);
    }
  }
  unordered_map<int, int> ans;
  for (int i=0; i<N; i++){
    for (int j=i+1; j<N; j++){
      ans[dis[i][j]]++;
    }
  }
  
  for (int i=0; i<N-1; i++){
    cout << ans[i+1] << endl;
  }
  return 0;
}

Measured memory_bytes: 16000
k , n = map(int,input().split())
a = list(map(int,input().split()))
b = []
for i in range(n):
    if i < n-1:
        b.append(a[i+1]-a[i])
    elif i == n-1:
        b.append(k - a[i] + a[0])
print(k - max(b))

Measured memory_bytes: 26444
#include <iostream>
#include <cstdio>
#define ll long long
#define int long long
using namespace std;
const int N = 2e5 + 5, M = 1e6 + 5;
int n, a[N], mx, v[M], prime[M], tot, mu[M];
ll ans, t[M], inv[M], f[M], sum, F[M];
const int mod = 998244353;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
void init(int n)
{
	mu[1] = 1;
	for(int i = 2; i <= n; i ++)
	{
		if(!v[i]) {prime[++ tot] = i; mu[i] = -1;}
		for(int j = 1; j <= tot && prime[j] * i <= n; j ++)
		{
			v[i * prime[j]] = 1;
			if(i % prime[j] == 0)
			{
				mu[i * prime[j]] = 0;
				break;
			}
			mu[i * prime[j]] = - mu[i];
		}
	}
	inv[0] = inv[1] = 1;
	for(int i = 2; i <= n; i ++) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
}
void work()
{
	n = read();
	for(int i = 1; i <= n; i ++) a[i] = read(), t[a[i]] ++, mx = max(mx, a[i]), sum = (sum + a[i]) % mod;
	init(mx);
	for(int i = 1; i <= mx; i ++)
	{
		for(int j = i; j <= mx; j += i) F[i] = (F[i] + t[j] * j) % mod;
		F[i] = (F[i] * F[i]) % mod;
	}
	for(int i = 1; i <= mx; i ++) for(int j = i; j <= mx; j += i) f[i] = (f[i] + (F[j] * mu[j / i] % mod + mod)) % mod;
	for(int d = 1; d <= mx; d ++) ans = (ans + inv[d] * f[d] % mod) % mod;
	ans = (ans - sum + mod) % mod * inv[2] % mod;
	printf("%lld\n", (ans + mod) % mod);
}
signed main() {return work(), 0;}


Measured memory_bytes: 52352
c = [list(map(int, input().split())) for _ in range(3)]

count = 0
for j in range(100):
    b1 = []
    a1 = []
    a = j

    for i in range(3):
        b1.append(c[0][i] - a)
        a1.append(c[i][0] - b1[0])

    for i in range(3):
        for j in range(3):
            if a1[i] + b1[j] != c[i][j]:
                count = 1


if count == 1:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static int n_;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        n_ = Integer.parseInt(scan.next());
        scan.close();

        dfs("a", 'a');

    }

    private static void dfs(String s, char max) {
        // 終了条件
        if (s.length() == n_) {
            System.out.println(s);
            return;
        }

        for (char c = 'a'; c <= max + 1; c++) {
            if (c > max) {
                dfs(s + c, c);
            } else {
                dfs(s+c,max);
            }
        }

    }
}


Measured memory_bytes: 45448
import java.util.Scanner;

/**
 *  http://abc047.contest.atcoder.jp/tasks/abc047_b
 * @author おとうさん
 */
public class Main {
    public static void main(String[] args) {
        String S ;
        Scanner sc = new Scanner(System.in);
        S = sc.next();
        char[] s ;
        s = S.toCharArray() ;
        int cnt = 0 ;
        for (int i=1 ; i< s.length; i++){
            if (s[i-1] != s[i]) cnt ++ ;
        }
        System.out.println(cnt) ;      

    }
    
}


Measured memory_bytes: 13852
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.Scanner;
 class Main
{
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String input = sc.nextLine();
		
		StringBuilder output = new StringBuilder();
		
		for (int i=0; i<input.length(); ++i) {
		    
		    if (input.charAt(i) != 'B') {
		        output.append(input.charAt(i));
		    }else {
		        int len = output.length();
		        if (len > 0) {
		            output.deleteCharAt(len-1);
		        }
		    }
		}
		
		sc.close();
		System.out.println(output);
	}
}


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

int main()
{	
	int ans=0, i, j, k;
	int n, l;
	cin >> n >> l;

	int min = INT_MAX;
	for (i = 0; i < n;i++){
		ans += l + i;
		int sum = 0;
		sum += l + i;
		if(abs(sum) < abs(min)){
			min = sum;
		}
	}
	cout << ans - min << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>

using namespace std;

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

  if (a < b)
  {
    for (int i = 0; i < b; ++i) cout << a;
  }
  else
  {
    for (int i = 0; i < a; ++i) cout << b;
  }
}

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

L=[]
for i in range(n):
    k,v=input().split()
    L.append({'num':i,'name':k,'score':int(v)})
L.sort(key=lambda x: (x['name'],-x['score']))
l_n = [d.get('num') for d in L]

for i in range(n):
    print(l_n[i]+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;

int main(){
    ll a,b,c; cin>>a>>b>>c;
    if(a+b+1<=c){
        cout<<a+2*b+1<<endl;
    }else {
        cout<<c+b<<endl;
    }
}

Measured memory_bytes: 256
x, k, d = map(int, input().split())

if abs(x) - (d * k) >= 0:
    print(abs(x) - (d * k))
    exit()

k -= abs(x) // d
a = abs(x) % d
b = abs(a - d)

if k % 2 == 0:
    print(a)
else:
    print(b)

Measured memory_bytes: 9172
#include<iostream>

int main(void){
    int n, k;
    std::string s;
    std::cin >> n >> k >> s;
    k--;
    if(s[k] == 'A') s[k] = 'a';
    else if(s[k] == 'B') s[k] = 'b';
    else s[k] = 'c';
    std::cout << s << std::endl;
    return 0;
}

Measured memory_bytes: 3580
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    P = list(int(input()) for _ in range(n))

    res = [0] * (n + 1)
    for p in P:
        res[p] = res[p - 1] + 1
    print(n - max(res))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 24488
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] l = new int[n];
        for(int i = 0;i < n; i++){
            l[i] = scanner.nextInt();
        }
        Arrays.sort(l);
        int count = 0;
        for(int i = 0; i < n-2; i++){
            for(int j = i+1; j < n-1; j++){
                for(int k = j+1; k < n; k++){
                    //System.out.println(l[i] + " " + l[j] + " " + l[k]);
                    if(l[i] + l[j] > l[k]){count++;}
                    else{break;}
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 28044
#include<stdio.h>
    
int main(){
    
int x,y,i;

scanf("%d %d",&x,&y);

for(i=0;x!=0 || y!=0 ;i++){
if(x < y)
printf("%d %d\n",x,y);
else
printf("%d %d\n",y,x);
scanf("%d %d",&x,&y);
}

return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pown(ll fi,ll se){
  ll ans=1;
  rep(i,se){
    ans*=fi;
  }
  return ans;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
 vec(a,3);
 a=getv<ll>(3);
 sort(all(a));
  ll k;
  cin>>k;
  rep(i,k){
    a[2]*=2;
  }
  op(a[2]+a[1]+a[0]);
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n, k int
	var s string
	fmt.Scan(&n, &k, &s)
	cs := []rune(s)
	ans := string(cs[0:k-1]) + strings.ToLower(string(cs[k-1:k])) + string(cs[k:n])
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  int k,a,b;
  cin>>k>>a>>b;
  int ans = 0;
  if(a >= b - 2) {
    ans = k + 1;
  } else {
    if(k >= a + 1) {
      ans += b;
      int rem = k - (a + 1);
      int cnt = rem / 2;
      if(rem % 2 == 1) {
        ans += cnt * (b - a) + 1;
      } else {
        ans += cnt * (b - a);
      }
      ans = max(k+1, ans);
    } else {
      ans = k + 1;
    }
  }
  cout << ans << endl;

  return 0;
}


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

long double between_two(double ax, double ay, double bx, double by){
  return sqrt(pow(ax-bx,2) + pow(ay-by,2));
}

bool incircle(double x, double y, double r, double ax, double ay){
  return between_two(x,y,ax,ay) <= r;
}

long double gaisin_y(double a, double b, double c, double d, double e, double f){
  long double bunshi = (e-a)*(a*a + b*b - c*c - d*d) - (c-a)*(a*a + b*b - e*e - f*f);
  long double bunbo = 2*(e-a)*(b-d) - 2*(c-a)*(b-f);
  return bunshi / bunbo;
}

long double gaisin_x(double a, double b, double c, double d, double e, double f){
  long double bunshi, bunbo;
  if(c != a){
    bunshi = 2*(b-d)*gaisin_y(a,b,c,d,e,f) - a*a - b*b + c*c + d*d;
    bunbo = 2*(c-a);
  }
  else{
    bunshi = 2*(b-f)*gaisin_y(a,b,c,d,e,f) - a*a - b*b + e*e + f*f;
    bunbo = 2*(e-a);
  }
  return bunshi / bunbo;
}
  

int main(){
  int N;
  cin >> N;
  vector<vector<double>> vec(N,vector<double>(2));
  for(int i=0; i<N; i++){
    for(int j=0; j<2; j++){
      cin >> vec[i][j];
    }
  }
  double ans = 1000000;
  //2点の中点が中心の場合
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      double x = (vec[i][0] + vec[j][0])/2.0;
      double y = (vec[i][1] + vec[j][1])/2.0;
      double r = between_two(vec[i][0], vec[i][1], vec[j][0], vec[j][1]) / 2.0;
      bool ok = true;
      for(int k=0; k<N; k++){
        if(!incircle(x,y,r,vec[k][0],vec[k][1])){
          ok = false;
        }
      }
      if(ok){
        ans = min(ans,r);
      }
    }
  }
  
  
  //3点の外接円が中心の場合
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      for(int k=j+1; k<N; k++){
        double x = gaisin_x(vec[i][0],vec[i][1],vec[j][0],vec[j][1],vec[k][0],vec[k][1]);
        double y = gaisin_y(vec[i][0],vec[i][1],vec[j][0],vec[j][1],vec[k][0],vec[k][1]);
        double r = between_two(vec[i][0], vec[i][1],x,y);
        bool ok = true;
        for(int l=0; l<N; l++){
          if(!incircle(x,y,r,vec[l][0],vec[l][1])){
            ok = false;
          }
        }
        if(ok){
          ans = min(ans,r);
        }
      }
    }
  }
  cout << setprecision(20) << ans << endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int x = C - A, y = D - B;
	cout << C - y << " " << D + x << " " << A - y << " " << B + x;
}


Measured memory_bytes: 256
#pragma warning (disable:4996)
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[200005];
ll c[200005];
int main()
{
	ll n;
	cin >> n;
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
		c[i] = a[i] - (i+1);
	}
	sort(c, c + n);
	ll b = c[n / 2];
	ll sadness=0;

	for (ll i = 0; i < n; i++)
	{
		sadness = sadness + abs(c[i] - b);
	}

	cout << sadness << endl;
	return 0;
}

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

using namespace std;

typedef long long int ll;

const ll MAXN = 305;

vector < vector < ll > > d(MAXN, vector < ll > (MAXN, 1e18));

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

  ll n, m, l;
  cin >> n >> m >> l;
  for(int i = 0; i < m; i++){
    ll u, v, wt;
    cin >> u >> v >> wt;
    d[u][v] = wt;
    d[v][u] = wt;
  }

  for(int i = 1; i <= n; i++) d[i][i] = 0;

  for(int k = 1; k <= n; k++){
    for(int i = 1; i <= n; i++){
      for(int j = 1; j <= n; j++){
        if(d[i][k] != 1e18 && d[k][j] != 1e18 && d[i][j] > d[i][k] + d[k][j]){
          d[i][j] = d[i][k] + d[k][j];
        }
      }
    }
  }

  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      if(d[i][j] > l) d[i][j] = 1e18;
      else d[i][j] = 1;
    }
    d[i][i] = 0;
  }

  for(int k = 1; k <= n; k++){
    for(int i = 1; i <= n; i++){
      for(int j = 1; j <= n; j++){
        if(d[i][k] != 1e18 && d[k][j] != 1e18 && d[i][j] > d[i][k] + d[k][j]){
          d[i][j] = d[i][k] + d[k][j];
        }
      }
    }
  }

  ll q;
  cin >> q;
  while(q--){
    ll u, v;
    cin >> u >> v;
    if(d[u][v] == 1e18){
      cout << -1 << '\n';
      continue;
    }
    cout << d[u][v] - 1 << '\n';
  }
}


Measured memory_bytes: 1280
/*If my response is late, it's just how long it takes
To hit my fuckin' radar, I'm so far away
*/


#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

using ll = long long;
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define tc() int t; cin>>t; while(t--)
#define print(n) cout<<n<<"\n"
#define inp(n) int n; cin>>n
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define maxn 1000010
#define mod 1e9+7
#define ff  first
#define ss  second
#define fora(var, start, end) for(int var = start; var < end; var++)
int main()
{
    fast();
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
    return 0;
}

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

int main() {
	int n, W; cin >> n >> W;
	vector<int> w(n + 1), v(n + 1);
	int V = 0;
	for (int i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
		V += v[i];
	}
	vector<vector<long long> > dp(n + 1, vector<long long>(V + 1, W + 10));
	dp[0][0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= V; j++) {
			if (v[i] > j) {
				dp[i][j] = dp[i - 1][j];
			} else {
				dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
			}
		}
	}
	for (int j = V; j >= 0; j--) {
		if (dp[n][j] <= W) {
			cout << j << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	double r;
	cin>>r;
	cout<<fixed<<setprecision(7)<<3.1415926*r*2<<endl;
	//fixed<<setprecision(3)
	return 0;
}

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

#define all(a) a.begin() , a.end()
#define print(x)   cout<<x<<"\n";

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; if (i != v.size() - 1) os << ", "; } os << "]\n"; return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
    os << "["; for (auto it : v) {os << it; if (it != *v.rbegin())os << ", ";} os << "]\n"; return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v) {
    for (auto it : v)os << it.first << " : " << it.second << "\n"; return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v) {
    os << "("; os << v.first << ", " << v.second << ")"; return os;
}
void go() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
/************************************************************************/
double long a[3005];
int n;
double long dp[3005][3005];
double long solve(int idx, int head)
{

    if (idx == n)
    {
        if (2 * head > n)
            return 1.00;
        else
            return 0.0;
    }

    if (dp[idx][head] != -1.0)
        return dp[idx][head];

    return dp[idx][head] = a[idx] * solve(idx + 1, head + 1) + (1.0 - a[idx]) * solve(idx + 1, head);
}
int main()
{
    //go();
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];

    for (int i = 0; i < 3005; i++)
        for (int j = 0; j < 3005; j++)
            dp[i][j] = -1.0;


    cout << fixed << setprecision(20) << solve(0, 0) << '\n';
    return 0;
}

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

typedef __int128_t Long;

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> as(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }
    long long ans = 1ll * x * n;
    Long nin = 1e18;
    vector<long long> sum(n + 1);
    for (int i = 0; i < n; i++) {
        sum[i + 1] = sum[i] + as[i];
    }
    for (int k = 1; k <= n; k++) {
        Long cost = Long(5) * (sum[n] - sum[n - k]);
        for (int i = 1; n - k * i > 0; i++) {
            cost += (sum[n - k * i] - sum[max(0, n - k * (i + 1))]) * Long(2 * i + 3);
        }
        nin = min(nin, cost + 1ll * x * k);
    }
    cout << (long long) nin + ans << endl;
}

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

int main() {
  string S,T;
  int i,N;
  
  cin >> N ;
  
  int *A = new int[N];
  int *answer = new int[N];

  for ( i = 0; i < N; i++)
  {
    cin >> A[i];
    answer[A[i]-1]=i+1;
  }
  for ( i = 0; i < N; i++)
  {
    cout << answer[i] << endl;
  }
}

Measured memory_bytes: 1536
($a,$b,$c,$x)=<>;
$r = 0;
for($i=0;$i*500<=$x;$i++){
  for($j=0;$j*100+$i*500<=$x;$j++){
    if($i<=$a&&$j<=$b&&($x-$j*100-$i*500)%50==0&&($x-$j*100-$i*500)/50<=$c){
      $r+=1;
    }
  }
}
print$r

Measured memory_bytes: 4700
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    int sum = 0;
    rep(i, N){
        cin >> A[i];
        sum += A[i];
    }
    sort(all(A));
    reverse(all(A));
    int c = 0;
    double sum_rate = (double)sum / (4.0 * (double)M);
    rep(i, N){
        if ((double)A[i] >= sum_rate){
            c++;
        }
        else{
            break;
        }
    }

    if (c >= M){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, os
range = xrange

def main():
    inp = [int(x) for x in os.read(0, os.fstat(0).st_size).split()]
    n, m = inp[0],inp[1]
 
    wi, vi = inp[2], inp[3]
 
 
    dp = [0] * (m + 1)
    for j in range(wi, m + 1):
        dp[j] = vi
 
    for i in range(n - 1):
        wi = inp[2*i + 4]
        vi = inp[2*i + 5]
        for j in range(m, wi-1, -1):
            x = vi + dp[j - wi]
            if dp[j] < x:
                dp[j] = x
 
    print(dp[-1])
main()

Measured memory_bytes: 31084
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int maxn=1e5+1e2;
int n;
int l[maxn],r[maxn];

inline void file() {
	freopen("AGC025C.in","r",stdin);
	freopen("AGC025C.out","w",stdout);
}

inline int read() {
	int x=0,p=1;
	char c=getchar();
	while (!isdigit(c)) { if (c=='-') p=-1; c=getchar();}
	while (isdigit(c)) { x=(x<<1)+(x<<3)+(c-'0'); c=getchar();}
	return x*p;
}

inline bool cmp(int a,int b) { return a>b; }

int main() {
//	file();
	n=read();
	For (i,1,n) l[i]=read(),r[i]=read(),r[i]=-r[i];
	sort(l+1,l+n+1,cmp); sort(r+1,r+n+1,cmp);
	ll ans=0,Ans=0;
	For (i,1,n*2) {
		if (i%2==1) ans+=l[i/2];
		else ans+=r[i/2];
		chkmax(Ans,ans);
	}
	ans=0;
	For (i,1,n*2) {
		if (i%2==1) ans+=r[i/2];
		else ans+=l[i/2];
		chkmax(Ans,ans);
	}
	printf("%lld",Ans*2);
	return 0;
}

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

int main() {
    int A, B, C; cin >> A >> B >> C;
    int arr[B - 1];
    string ans = "NO";
    for (int i = 1; i <= B; i++) {
        int num = i * A % B;
        if (num == C) {
            ans = "YES";
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S=input()

c=Counter(S)

if abs(c['a']-c['b'])<=1 and abs(c['b']-c['c'])<=1 and abs(c['c']-c['a'])<=1:
    YES()
else:
    NO()


Measured memory_bytes: 3572
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let v: Vec<T> = read_vec();
    (v[0], v[1])
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    let (N, X) = read_tuple::<i32>();
    let x: Vec<i32> = read_vec();
    let x: Vec<i32> = x.iter().map(|y| (y - X).abs()).collect();
    let ans = x.iter().fold(x[0], |a, &b| gcd(a as i64, b as i64) as i32);
    println!("{}", ans);
}


Measured memory_bytes: 6396
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 20:50:00 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

S = input()
T = input()

ans = 'Yes'
if len(S) != len(T) - 1:
    ans = 'No'
else:    
    for i in range(len(S)):
        if S[i] != T[i]:
            ans = 'No'
print(ans)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

const int N=500;
bool isprime[1000010];
vector<ll> ps;
ll res[N][N];
int di[]={-1,0,1,0};
int dj[]={0,1,0,-1};

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

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

  repl(i,2,1000000)isprime[i]=true;
  repl(i,2,1000000){
    if(isprime[i]){
      ps.push_back(i);
      for(ll j=i*2;j<1000000;j+=i)isprime[j]=false;
    }
  }

  while(ps.size()>1000)ps.pop_back();


    rep(i,N)rep(j,N)res[i][j]=1;
    for(ll s=0;s<2*N-1;s+=2){
      rep(i,N){
        ll j=s-i;
        if(j>=N||j<0)continue;
        res[i][j]*=ps[s/2];
      }
      rep(i,N){
        ll s2=s-N+2;
        ll j=i-s2;
        if(j>=N||j<0)continue;
        res[i][j]*=ps[N+(s/2)];
      }
    }

    rep(i,N)rep(j,N){
      if(res[i][j]==1){
        ll lc=1;
        rep(dir,4){
          int ni=i+di[dir],nj=j+dj[dir];
          if(ni<0||ni>=N||nj<0||nj>=N)continue;
          lc=lcm(lc,res[ni][nj]);
        }
        res[i][j]=lc+1;
      }
    }

  int n;
  cin>>n;
  rep(i,n){
    rep(j,n){
      cout<<res[i][j]<<" ";
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 6772
#![allow(unused_imports, unused_macros, dead_code)]
use std::f64::*;
use std::cmp::*;
use std::collections::*;

macro_rules! dump{
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

const INF: i64 = 0x3f3f3f3f3f3f3f3f;
const MOD: i64 = 1000000007;
const NOTHING: usize = std::usize::MAX;
const DX: [usize; 4] = [1, 0, std::usize::MAX, 0];
const DY: [usize; 4] = [0, 1, 0, std::usize::MAX];

fn main() {
    let n: usize = readln();
    let mut pt: isize = 0;
    let mut px: isize = 0;
    let mut py: isize = 0;
    for _ in 0..n {
        let (t, x, y): (isize, isize, isize) = readln();
        let dt = (t - pt).abs();
        let dx = (x - px).abs();
        let dy = (y - py).abs();
        pt = t;
        px = x;
        py = y;
        if !(dx + dy <= dt && (dt - dx - dy) % 2 == 0) {
            println!("No");
            return;
        }

    }

    println!("Yes");
}

trait Read {
    fn read(s: &str) -> Self;
}

fn readln<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

macro_rules! read_impl{
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl Read for String {
    fn read(s: &str) -> Self {
        s.to_string()
    }
}

impl Read for Vec<char> {
    fn read(s: &str) -> Self {
        s.chars().collect()
    }
}

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

impl<A: Read, B: Read, C: Read, D: Read> Read for (A, B, C, D) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]), D::read(tokens[3]))
    }
}


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


int find(int n){
  int sum = 0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(void) {
  int N, A, B;
  cin >> N >> A >> B;
  int total = 0;
  for(int i = 1; i <= N; i++){
    int sum = find(i);
    if(A <= sum && sum <= B){
      total += i;
    }
  }
  cout << total << endl;
  return 0;
}

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

int main(){
    int n,k,tmp;
    while(cin >> n >> k,n||k){
        bool ju = true;
        vector <int> blood(k+1);
        for(int i=1;i<=k;i++) cin >> blood[i];
        for(int i=0;i<n;i++){
            for(int j=1;j<=k;j++){
                cin >> tmp;
                if(blood[j] < tmp) ju = false;
                else blood[j] -= tmp;
            }
        }
        cout << ((ju)? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 1188
N = int(input())
blue = [input() for i in range(N)]
M = int(input())
red = [input() for i in range(M)]

list_all = list( set(blue) | set(red) )
dict_all = dict.fromkeys(list_all, 0)

for i in range(len(blue)) :
    dict_all[blue[i]] += 1

for i in range(len(red)) :
    dict_all[red[i]] -= 1

if max(dict_all.values()) >= 0 :
    print(max(dict_all.values()))
else :
    print(0)


Measured memory_bytes: 3064
#include<stdlib.h>
p(int*a,int*b){return*a-*b;}c,V,i,f[999];main(d){for(;f[1]=scanf("%d%d",&V,&d)+1;printf("%d\n",c)){for(f[0]=i=2;i<V;i++)f[i]=(f[i-1]+f[i-2])%1001;qsort(f,V,4,p);for(i=c=1;i<V;f[i]-f[i++-1]<d?:c++);}exit(0);}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()


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

  int x;
  cin >> x;
  int n = x/100;
  if(100 * n <= x && x <= 105 * n){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
}


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

int A, B, M, mn, ans;
int a[100010], b[100010];

int main()
{
	scanf("%d %d %d", &A, &B, &M); mn = 0x7fffffff;
	for(int i = 1; i <= A; ++i) scanf("%d", &a[i]), mn = min(mn, a[i]);
	ans = mn; mn = 0x7fffffff;
	for(int i = 1; i <= B; ++i) scanf("%d", &b[i]), mn = min(mn, b[i]);
	ans += mn;
	for(int i = 1; i <= M; ++i)
	{
		int x, y, z;
		scanf("%d %d %d", &x, &y, &z);
		ans = min(ans, a[x] + b[y] - z);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
using ll = long long int;
using ui = unsigned int;

const ll mod = 1e9+7;


ll dfs (int K, const vector<vector<int>>&graph, int now, int from) {

    int can_use_color_num;
    if (from==-1) {
        can_use_color_num = K-1;
    }
    else {
        can_use_color_num = K-2;
    }
    if (K < (int)graph[now].size()) {
        return 0;
    }
    else {
        ll case_num=1;
        for (auto e: graph[now]) {
            if(e==from) continue;

            case_num*=can_use_color_num;
            can_use_color_num--;
            case_num%=mod;
        }
        for (auto e : graph[now]) {
            if(e==from) continue;
            case_num *=dfs(K,graph, e, now);
            case_num %= mod;
        }
        return case_num;
    }
}
int main() {
    int N,K; cin>>N>>K;

    vector<vector<int>>graph(N);
    for (int i = 0; i < N - 1; i++)
    {
        int a, b; cin>>a>>b; a--, b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    
    ll ans = K*dfs(K, graph, 0, -1) % mod;
    cout << ans << "\n";
}

Measured memory_bytes: 11520
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt()

  val ar = for {
    _ <- 0 to (n - 1)
  } yield sc.nextInt()

  val m = ar.max
  val sum = ar.sum
  println(sum - m / 2)
}


Measured memory_bytes: 25936
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

a,b,x=map(int,input().split())
if a<=x<=a+b:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 38452
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
const int N = 55;
int dp[N * N * N], n, head[N], tot, X, d;
struct node{int to, nex;}e[N];
struct data{int v, w, id;}a[N];
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
void add(int x, int y) {e[++ tot].to = y; e[tot].nex = head[x]; head[x] = tot;}
void dfs(int x)
{
	a[x].w = 1; a[x].id = x;
	for(int i = head[x]; i; i = e[i].nex)
	{
		int y = e[i].to; dfs(y);
		a[x].v += a[y].v; a[x].w += a[y].w;
	}
}
bool cmp(const data & a, const data & b) {return a.w * b.v > b.w * a.v;}
signed main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read(); X = read(); d = read(); a[1].v = read();
	for(int i = 2; i <= n; i ++) a[i].v = read(), add(read(), i);
	dfs(1); int mx = n * n * n, L = min(n, d);
	memset(dp, 0x3f, sizeof(dp)); dp[0] = 0;
	for(int i = 1; i <= n; i ++)
	{
		int x = L;
		for(int j = 0; (1 << j) <= x; j ++)
		{
			int w = a[i].w * (1 << j), v = a[i].v * (1 << j);
			for(int k = mx; k >= w; k --) dp[k] = min(dp[k], dp[k - w] + v);
			x -= (1 << j);
		}
		if(x)
		{
			int w = a[i].w * x, v = a[i].v * x;
			for(int j = mx; j >= w; j --) dp[j] = min(dp[j], dp[j - w] + v);
		}
	}
	sort(a + 1, a + n + 1, cmp); while(a[n].id != 1) n --;
	int ans = 0;
	for(int i = 0; i <= mx; i ++)
	{
		if(dp[i] > X) continue; int w = i, v = dp[i];
		for(int j = 1; j < n; j ++)
		{
			int c = min(d - L, (X - v) / a[j].v);
			w += c * a[j].w; v += c * a[j].v;
		}
		int c = (X - v) / a[n].v;
		w += c * a[n].w; v += c * a[n].v;
		ans = max(ans, w);
	}
	printf("%lld\n", ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<int>p(n),q(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  for(int i=0;i<n;i++){
    cin>>q[i];
  }
  vector<int>a(n);
  for(int i=0;i<n;i++){
    a[i]=i+1;
  }
  map<vector<int>,int>mp;
  do{
    mp[a]=mp.size();
  }while (next_permutation(a.begin(),a.end()));
  int ans=abs(mp[p]-mp[q]);
  cout<<ans<<endl;
}
          
          
      
  
    

  


Measured memory_bytes: 5248
#include <stdio.h>

int d,n,ans ;

int main(void){

    scanf ("%d%d",&d,&n) ;
    
    if ( n==100 ){ n=101 ; }
    
    if ( d==0 ){
        
        ans = n ;
    }
    else if ( d==1 ){
        
        ans = n*100 ;
    }
    else if ( d==2 ){
        
        ans = n*10000 ;
    }
    
    printf ("%d\n",ans) ;
    
    return 0 ;
    
}

Measured memory_bytes: 128
#include <stdio.h>

class Dice3{
public:
	Dice3(){
		number = new int[6];
		checkTable = new int[101];
		for(int i = 0; i < 101; i++) checkTable[i] = -1;
	};
	~Dice3(){
		delete[] number;
		delete[] checkTable;
	};

	void setLabel(int index,int num){
		number[index] = num;
		checkTable[num] = index;
	};

	void roll(char dst){
		switch(dst){
		case 'E':
			setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
			break;
		case 'N':
			setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
			break;
		case 'S':
			setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
			break;
		case 'W':
			setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
			break;
		}
	};

	bool isValidMember(int inputed[]){
		for(int i = 0; i < 6; i++)
		{
			if(checkTable[inputed[i]] == -1)
				return false;
		}
		return true;
	}
	bool isSameDice(int inputed[]){
		char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
		for(int i = 0; i < 24; i++){
			roll(order[i]);
			for(int j = 0; j < 6; j++){
				if(inputed[j] != number[j])
					break;
				if(j == 5)
					return true;
			}
		}
		return false;
	}

private:
	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

private:
	int* number;
	int* checkTable;
};

int main(){
	Dice3 dice3;
	int tmp,inputed[6];
	for(int i = 0; i < 6; i++){
		scanf("%d",&tmp);
		dice3.setLabel(i,tmp);
	}
	for(int i = 0; i < 6; i++) scanf("%d",&inputed[i]);

	if(dice3.isValidMember(inputed) && dice3.isSameDice(inputed))
		printf("Yes\n");
	else{
		printf("No\n");
	}
}


Measured memory_bytes: 2620