akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define ll			long long
#define ALL(s)			(s).begin(),(s).end()
#define ALLn(s,n)		s,s+n
#define F			first
#define S			second
#define pb			push_back
#define tc(t)			int t; cin >> t; while(t--)
#define _			ios_base::sync_with_stdio(false); cin.tie(NULL);
#define PI 3.141592653589793238
const ll MOD = 1e9 + 7;
const ll INF = INT_MAX;
const ll MAX_N = 1e6 + 7;

ll power(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p;
   
    if (x == 0) return 0;
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
 
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
void solve() {
    ll n,k;
    cin >> n >> k;

    //ll p = power(2,n+1, MOD);
    //ll pk = power(2,k, MOD);

    ll sum = 0;
    for(ll i = k; i <= n + 1; ++i) {
		(sum += i*(n-i+1) + 1) %= MOD;
	}

	cout << sum<< "\n";
	
}

int32_t main() {_
    //tc(t) 
	solve();
}


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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		2505

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

vector<pair<ll, ll> > prime_factorize(ll n) {
	vector<pair<ll,ll> > res;
	for (ll p = 2; p * p <= n; ++p) {
		if (n % p != 0) continue;
		int num = 0;
		while (n % p == 0) { ++num; n /= p; }
		res.push_back(make_pair(p, num));
	}
	if (n != 1) res.push_back(make_pair(n, 1));
	return res;
}

//
int main(){
	int N;cin >> N;

	ll ans = 1;
	map<int,int> m;
	REPS(i,2,N+1){
		auto t = prime_factorize(i);
		for(auto itr : t){
			m[itr.first] += itr.second;
		}
	}

	for(auto itr : m){
		//cout << itr.first << " " << itr.second << endl;
		ans = ( ans * (itr.second+1)) % MOD;
	}

	cout << ans << endl;

	return 0;
}




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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x, y) for ((x) = (y).begin(); (x) != (y).end(); (x)++)
#define all(x) (x).begin(),(x).end()
#define _end '\n'
template<typename T> inline bool __max__(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool __min__(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using vvec = vector<vector<T> >;

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;

    cin >> n;

    int ans[n];
    int time, next;
    int c[n], s[n], f[n];

    ans[n - 1] = 0;

    int i, j, len = n - 1;

    rep(i, n) cin >> c[i] >> s[i] >> f[i];

    rep(i, len) {
        time = s[i] + c[i];
        repi(j, len, i + 1) {
            next = s[j];

            while (next < time) next += f[j];

            time = next + c[j];
        }

        ans[i] = time;
    }

    rep(i, n) cout << ans[i] << _end;

    return 0;
}


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

using namespace std;
int main() {
    long long N, M;
    long long A[100000];
    cin >> N >> M;
    for (int i=0; i<N; i++) cin >> A[i];

    priority_queue<long long> q;
    for (int i=0; i<N; i++) q.push(A[i]);

    for (int i=0; i<M; i++) {
        long long x = q.top();
        q.pop();
        q.push(x / 2);
    }
    
    long long money = 0;
    while (!q.empty()) {
        long long x = q.top();
        q.pop();
        money += x;
    }
    cout << money << endl;
    return 0;
}



Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
 
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;

int main(){
    ll x, n;
    cin >> x >> n;
    vll a(n);
    rep(i,0,n){
        cin >> a[i];
    }
    sort(all(a));
    ll ans;
    ll i = 0;
    while(1){
        if(!(binary_search(all(a),x - i))){
            ans = x - i;
            break;
        }
        if(!(binary_search(all(a),x + i))){
            ans = x + i;
            break;
        }
        i++;
    }
    cout << ans;
}

Measured memory_bytes: 3632
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S().split("/")
ans = "TBD"
month = ["01","02","03","04"]
if s[1] in month:
    ans = "Heisei"
print(ans)

Measured memory_bytes: 3316
#include<stdio.h>
#define LEN 100000
#define NIL -1

typedef struct{
  int parent;
  int left;
  int right;
}Tree;

Tree t[LEN];
int Depth[LEN];
int n;

void print(void);
int caldepth(int key,int depth);

int main(){
  int key,numchild,l,x,root;
  int i,j;
  
  //in
  scanf("%d",&n);

  //ini
  for(i=0;i<n;i++){
    t[i].parent=NIL;
    t[i].left=NIL;
    t[i].right=NIL;
  }
  
  //in
  for(i=0;i<n;i++){
    scanf("%d%d",&key,&numchild);
    for(j=0;j<numchild;j++){
      scanf("%d",&x);
      if(j)t[l].right=x;
      else t[key].left=x;
      l=x;
      t[x].parent=key;
    }
  }

  //find root
  for(i=0;i<n;i++)
    if(t[i].parent==NIL){
      root=i;
    }

  caldepth(root,0);

  print();

  return 0;
}

int caldepth(int key,int depth){
  Depth[key]=depth;
  if(t[key].left!=NIL)  caldepth(t[key].left, depth+1);
  if(t[key].right!=NIL) caldepth(t[key].right,depth);
}

void print(void){
  int i,j,k;
  int l,tmp;
  
  for(i=0;i<n;i++){

    printf("node %d: ",i);
    printf("parent = %d, depth = %d, ",t[i].parent,Depth[i]);

    if(t[i].parent==NIL)
      printf("root, ");
    else if(t[i].left==NIL)
      printf("leaf, ");
    else if(t[i].left!=NIL)
      printf("internal node, ");

    printf("[");
    for(k=0;;k++){
      if(k){
	printf(", ");
	printf("%d",t[l].right);
	l=t[l].right;
	if(t[l].right==NIL)break;
      }
      else{
	if(t[i].left==NIL)break;
	printf("%d",t[i].left);
	l=t[i].left;
	if(t[l].right==NIL)break;
      }
    }
    printf("]");

    printf("\n");
  }
}



Measured memory_bytes: 3284
X = int(input())
if X <= 599:
  print(8)
elif X <= 799:
  print(7)
elif X <= 999:
  print(6)
elif X <= 1199:
  print(5)
elif X <= 1399:
  print(4)
elif X <= 1599:
  print(3)
elif X <= 1799:
  print(2)
else:
  print(1)

Measured memory_bytes: 9172
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
k,n=mii()
arr0=limii()
p=k+arr0[0]
arr=arr0+[p]

ans=0
arr.sort()
for i in range(n):
    ans=max(ans,arr[i+1]-arr[i])

print(k-ans)

Measured memory_bytes: 101744
#include <stdio.h>

int main(void)
{
	int n,a[100],i,j,t;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	for(i=0;i<n;i++){
		t=a[i];
		j=i-1;
		while(j>=0&&a[j]>t){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=t;
		for(j=0;j<n-1;j++)printf("%d ",a[j]);
		printf("%d\n",a[n-1]);
	}
	return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
const int N=110;
const double inf=1e18;
const double pi=3.14159265357932384626433832795;
const double eps=1e-12;
int n,x[N],y[N],up[N][N];
double s[N][N];
inline double slope(int a,int b,int c,int d){
	if(b==d)return inf;
	return 1.0*(c-a)/(b-d);
}
inline double solve(int x){
	double lu=-90,ld=90,ru=-90,rd=90;
	for(int i=1; i<=n; ++i)
		if(i!=x){
			if(up[x][i])lu=max(lu,atan(-s[x][i])/pi*180),ru=max(ru,atan(s[x][i])/pi*180);
			else ld=min(ld,atan(-s[x][i])/pi*180),rd=min(rd,atan(s[x][i])/pi*180);
		}
	return (max(ld-lu,0.0)+max(rd-ru,0.0))/360;
}
int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; ++i)scanf("%d%d",&x[i],&y[i]);
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=n; ++j)
			if(i!=j)s[i][j]=slope(x[i],y[i],x[j],y[j]),up[i][j]=(y[i]==y[j]?x[i]<x[j]:y[i]>y[j]);
	for(int i=1; i<=n; ++i)printf("%.5lf\n",solve(i));
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

long DP[2005][2005];

int main() {
    int N;
    cin>>N;
    vector<pair<long, int> > A(N);
    long tmp;
    for(int i=0;i<N;++i){
        cin>>tmp;
        A[i] = make_pair(tmp, i);
    }
    sort(A.begin(), A.end(), greater<pair<long, int> >() );
    int r;
    for(int i=1;i<=N;++i){
        for(int l=0;l<=i;++l){
            r = i - l;
            if(l==0){
                DP[l][r] = DP[l][r-1]+A[i-1].fi*abs(A[i-1].se-(N-r));
            }
            else if(r==0){
                DP[l][r] = DP[l-1][r]+A[i-1].fi*abs(A[i-1].se-(l-1));
            }
            else{
                DP[l][r] = max(DP[l-1][r]+A[i-1].fi*abs(A[i-1].se-(l-1)), DP[l][r-1]+A[i-1].fi*abs(A[i-1].se-(N-r)));
            }
        }
    }
    long ans = 0;
    for(int i=0;i<=N;++i){
        if(DP[N-i][i]>ans)ans = DP[N-i][i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 26312
using System;

struct Dice
{
    private int area1, area2, area3, area4, area5, area6;

    public Dice(int[] cube)
    {
        area1 = cube[0];area2 = cube[1];area3 = cube[2];
        area4 = cube[3];area5 = cube[4];area6 = cube[5];
    }

    public int MoveDice(char ch)
    {
        int temp;
        switch(ch)
        {
            case 'N':
                temp = area1;
                area1 = area2;
                area2 = area6;
                area6 = area5;
                area5 = temp;
                break;
            case 'S':
                temp = area1;
                area1 = area5;
                area5 = area6;
                area6 = area2;
                area2 = temp;
                break;
            case 'E':
                temp = area1;
                area1 = area4;
                area4 = area6;
                area6 = area3;
                area3 = temp;
                break;
            case 'W':
                temp = area1;
                area1 = area3;
                area3 = area6;
                area6 = area4;
                area4 = temp;
                break;
            default:
                break;

        }
        return area1;
    }
}

class Program
{
    static void Main()
    {
        int ans=0;
        string[] s = Console.ReadLine().Split(' ');
        int[] cube = new int[6];
        for(int i =0;i<6;i++)
        {
            cube[i] = int.Parse(s[i]);
        }
        Dice dice = new Dice(cube);
        string order = Console.ReadLine();
        for(int i=0;i<order.Length;i++)
        {
            ans = dice.MoveDice(order[i]);
        }
        Console.WriteLine(ans);

    }
}

Measured memory_bytes: 9092
#テストファイルで実行する時
import sys
if sys.platform =='ios':
	sys.stdin=open('input_file.txt')

h,w = map(int,input().split())
s = [str('#'+input())+'#' for i in range(h)]

test = ''
for i in range(w+2):
	test = test + '#' 

#リストsの頭にtestを追加
s.insert(0,test)

#リストsの最後にtestを追加
s.insert(len(s),test)

#for i in range(h+2):
#	print(''.join(s[i]))

check = 0

for i in range(1,h+1):
	for j in range(1,w+1):
		if s[i][j]=='#':
			if s[i-1][j]=='.' and s[i+1][j]=='.' and s[i][j+1]=='.' and s[i][j-1]=='.':
				check = check + 1

print('Yes' if check ==0 else 'No')



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define UNVISITED 0
#define VISITED 2
#define MAXV 100000
#define INF 200000
typedef vector<int> vi;
vector< vi > adj(MAXV, vi());;
vi visited(MAXV,0);
int dp[MAXV+1];
int n, m;

void dfs_visit(int u) {
  visited[u]=1;
  for (int v : adj[u]) {
    if (!visited[v]) { 
      dfs_visit(v);
    }
    dp[u]=max(dp[u],1+dp[v]);
  }
}

int main() {
  int x,y,i, respuesta;
  scanf("%d %d",&n,&m);
  for (i = 0; i < m; i++) {
    scanf("%d %d",&x,&y);
    adj[x - 1].push_back(y - 1);
    
  }
  for (i=0; i<n; i++) {
  	if (!visited[i]) {
  		dfs_visit(i);
  	}
  }
  for (respuesta=i=0; i<n; i++) {
  	respuesta=max(respuesta,dp[i]);
  }
  printf("%d\n", respuesta);
  return 0;
}

Measured memory_bytes: 11456
#include<iostream>
#include<cctype>
#include<queue>
#include<cstdio>
#include<cmath>
#include<sstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<ctime>
#include<cstdlib>
#include<map>
#include<utility>
#include<iomanip>
#include<set>
#include<stack>
//#include<Windows.h>
using namespace std;
typedef long long ll;typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vii;typedef vector<pii> vpi;
typedef vector<ll> vll;typedef vector<pll> vpl;
typedef queue<int> qii;typedef queue<pii> qpi;
int n,k,a,b;
vii v[2005];
int dfs(int now,int pre,int depth,int mx){
	int ans=1;
	if(depth!=mx){
		for(int i=0;i<v[now].size();i++){
			if(v[now][i]==pre) continue;
			ans+=dfs(v[now][i],now,depth+1,mx);
		}
	}
	return ans;
}
int main()
{
// 	freopen("","r",stdin);
	cin>>n>>k;
	for(int i=0;i<n-1;i++){
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int ans=0;
	if(k%2==0){
		for(int i=1;i<=n;i++)
			ans=max(ans,dfs(i,-1,0,k/2));
	}else{
		for(int i=1;i<=n;i++)
			for(int j=0;j<v[i].size();j++){
				ans=max(ans,dfs(i,v[i][j],0,k/2)+dfs(v[i][j],i,0,k/2));
			}
	}
	cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>

int main()
{
	int i,j,k,n, m;
	std::cin >> n >> m;
	int a[100000];
	for (k = 0;k < n*m;k++) {
		std::cin >> a[k];
	}
	int b[1000];
	for (i = 0;i < m;i++) {
		std::cin >> b[i];
	}
	k = 0;
	for (j = 0;j < n;j++) {
		int nSum = 0;
		for (i = 0;i < m;i++) {
			nSum += a[k] * b[i];
			k++;
		}
		std::cout << nSum << std::endl;
	}
    return 0;
}

Measured memory_bytes: 3124
#include <stdio.h>

int main(void){
    int H, W;
    while (1){
        scanf ("%d %d", &H, &W);
        if (H == 0 && W == 0)
            break;
        for (int i = 0; i < H; i++){
            for (int j = 0; j < W; j++){
                if (i == 0 || i == H - 1 || j == 0 || j == W - 1){
                    printf("#");
                }
                else {
                    printf(".");
                }
            }
            printf("\n");
        }
	printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2084
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod1 1000000007
#define mod2 1000000009
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class AKyuInAtCoder {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int x;
        cin>>x;
        if (x>=400&&x<600)
            cout<<"8"<<endl;
        if (x>=600&&x<800)
            cout<<"7"<<endl;
        if (x>=800&&x<1000)
            cout<<"6"<<endl;
        if (x>=1000&&x<1200)
            cout<<"5"<<endl;
        if (x>=1200&&x<1400)
            cout<<"4"<<endl;
        if (x>=1400&&x<1600)
            cout<<"3"<<endl;
        if (x>=1600&&x<1800)
            cout<<"2"<<endl;
        if (x>=1800&&x<2000)
            cout<<"1"<<endl;

	}
};


int main() {
	AKyuInAtCoder solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3628
s = input()
ans = 0
for i in range(len(s)):
    for j in range(i, len(s) + 1):
        a = s[i:j]
        flag = 1
        for k in a:
            if k not in ["A", "C", "G", "T"]:
                flag = 0
        if flag:
            ans = max(ans, len(a))
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } else return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } else return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;

int main() {
	int A, B;
	cin >> A >> B;
	cout << A * B - (A + B - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if(A == B) {
			System.out.println("Draw");
			return;
		}
		if(A == 1) {
			System.out.println("Alice");
		} else if (B == 1) {
			System.out.println("Bob");
		} else {
			System.out.println(A > B ? "Alice" : "Bob");
		}
	}
}

Measured memory_bytes: 21972
#include<stdio.h>
int main(void)
{
	int a[2000],b[1000],n,m,k,card[2000],x,y,z,i,s;
	scanf("%d %d",&n,&m);
	for(x=0;x<n*2;x++){
		a[x]=x+1;
	}
	for(x=0;x<m;x++){
		scanf("%d",&k);
		i=2*n-k;
		if(k>=1 && k<=2*n-1){
			for(y=0;y<i;y++){
				card[y]=a[k+y];
			}
			for(y=0;y<k;y++){
				card[i]=a[y];
				++i;
			}}
		else if(k==0){
			s=1;
			for(y=0;y<n;y++){
				b[y]=a[n+y];
				card[s-1]=a[y];
				card[s]=b[y];
				s+=2;
			}}
		for(y=0;y<2*n;y++){
			a[y]=card[y];
		}}
	for(x=0;x<2*n;x++){
		printf("%d\n",a[x]);
	}
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define int long long
using namespace std;

int calc(int a) {
    int ret = (a + 1) / 2 % 2;
    if (a % 2 == 0) ret ^= a;
    return ret;
}
signed main() {
    int A, B;
    cin >> A >> B;

    cout << (calc(B) ^ calc(A - 1)) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {
	
	int R, G;
	scanf("%d%d", &R, &G);

	printf("%d", 2 * G - R);





}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define lol __int128
#define ld long double
#define pii pair<int, int>
#define dbg(x) cerr << #x << " = " << x << "\n"
using namespace std;
ll a, b, c, d;
ll res;
int32_t main() {
	//srand(chrono::steady_clock::now().time_since_epoch().count());
	boost;
	cin >> a >> b >> c >> d;
	res = max({a * c, a * d, b * c, b * d});
	cout << res;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;
int n,m;
const int md=998244353,MX=1000011;
typedef long long LL;

int fac[MX],inv[MX],facinv[MX];
inline int Inv(int x){return x<=1?x:(LL)(md-md/x)*Inv(md%x)%md;}
int main(){
	scanf("%d%d",&n,&m);
	if(n<m)swap(n,m);
	fac[0]=facinv[0]=1;
	for(int i=1;i<=n<<1;i++)fac[i]=(LL)fac[i-1]*i%md;
	inv[1]=1;
	for(int i=2;i<=n<<1;i++)inv[i]=(LL)(md-md/i)*inv[md%i]%md;
	for(int i=1;i<=n<<1;i++)facinv[i]=(LL)facinv[i-1]*inv[i]%md;
	#define C(x,y) ((LL)fac[x]*facinv[y]%md*facinv[(x)-(y)]%md)
	int ans=n,s=0;
	for(int i=1;i<=m;i++)s=((LL)s+(LL)C(2*i,i)*C(n+m-2*i,n-i)%md)%md;
	ans=((LL)ans+(LL)s*Inv(C(n+m,n)*2%md)%md)%md;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 11904
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        InputReader.OutputWriter out = new InputReader.OutputWriter(outputStream);


        int n = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        out.println(Math.min(n*a,b));
        out.flush();
    }
    static int f(LinkedList<Integer> q) {
        int size = q.size();
        int count = 0;
        size/=2;
        while (size-->0) {
            int first = q.pollFirst();
            int second = q.pollFirst();
            if(first+second>=10) count++;
            int newValue = (first+second)%10;
            q.addLast(newValue);
        }
        return count;
    }
}

class InputReader extends BufferedReader {
    StringTokenizer tokenizer;

    public InputReader(InputStream inputStream) {
        super(new InputStreamReader(inputStream), 32768);
    }

    public InputReader(String filename) {
        super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return tokenizer.nextToken();
    }

    public Integer nextInt() {
        return Integer.valueOf(next());
    }
    public Long nextLong() {return  Long.valueOf(next());}

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public OutputWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

        public void close() {
            super.close();
        }
    }
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,m,r[2201],c[2201],rslot[2201],cslot[2201];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>r[i];
	for(int i=1;i<=m;i++)cin>>c[i];
	sort(r+1,r+1+n);
	sort(c+1,c+1+m);
	int p1=n,p2=m;
	long long ans=1;
	for(int i=n*m,full=0;i;i--,full++)
		if(r[p1]==i&&c[p2]==i)p1--,p2--;
		else if(r[p1]==i)
		{
			p1--;
			ans=ans*(m-p2)%mod;
		}
		else if(c[p2]==i)
		{
			p2--;
			ans=ans*(n-p1)%mod;
		}
		else ans=ans*((n-p1)*(m-p2)-full)%mod;
	cout<<ans<<'\n';
}


Measured memory_bytes: 256
N=int(input())
MOD=10**9+7
dp=[[[[0]*5 for _ in range(5)] for _ in range(5)]for _ in range(N+1)]
ans=0
dp[0][0][0][0]=1
for n in range(N):
    for i in range(5):
        for j in range(5):
            for k in range(5):
                for l in range(1,5):
                    if j==1 and k==2 and l==3:continue
                    if j==1 and k==3 and l==2:continue
                    if j==3 and k==1 and l==2:continue
                    if i==1 and j==3 and l==2:continue
                    if i==1 and k==3 and l==2:continue
                    dp[n+1][j][k][l]+=dp[n][i][j][k]
for j in range(1,5):
    for k in range(1,5):
        for l in range(1,5):
            ans+=dp[N][j][k][l]
print(ans%MOD)

Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

int H, W, D, A;
int Q, L, R;
int px[90001], py[90001];
int d[90001];

int main()
{
	cin >> H >> W >> D;
	rep(i, H){
		rep(j, W) {
			cin >> A;
			px[A] = i; py[A] = j;
		}
	}
	for (int i = D + 1; i <= H * W; i++) {
		d[i] = d[i - D] + abs(px[i] - px[i - D]) + abs(py[i] - py[i - D]);
	}
	cin >> Q;
	while (Q--) {
		cin >> L >> R;
		cout << d[R] - d[L] << endl;
	}
}

Measured memory_bytes: 2176
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<numeric>
#define INF 1e+8
#define EPS 1e-8
#define PB push_back
#define fi first
#define se second
#define reps(i,j,k) for(int i = j; i < k; i++)
#define rep(i,j) reps(i,0,j)
using namespace std;
const int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
typedef long long ll;
typedef pair<int,int> Pii;

int main(){
	string data;
	vector< string > type;
	type.PB("* = ****");
	type.PB("* =* ***");
	type.PB("* =** **");
	type.PB("* =*** *");
	type.PB("* =**** ");
	type.PB(" *= ****");
	type.PB(" *=* ***");
	type.PB(" *=** **");
	type.PB(" *=*** *");
	type.PB(" *=**** ");

	bool flg = false;
	while(cin >> data){
		vector < string > ans;
		string sub="";
		if(flg)puts("");
		rep(i,5-data.size())sub+="0";
		sub += data;
		swap(sub,data);
		rep(i,5){
			ans.PB(type[data[i]-48]);
		}
		rep(i,8){
			rep(j,5){
				cout << ans[j][i];
			}
			puts("");
		}
		flg = true;
	}
	return 0;
}

Measured memory_bytes: 1172
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := makeWordScanner()
	a := eGetInt(scanner)
	b := eGetInt(scanner)
	a = a - 1
	b = b - 1
	fmt.Println((a + b - 1) / a)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(a: int, b: int):
    if a < 0 and b < 0:
        if (abs(a)-abs(b)+1)%2 == 0:
            print("Positive")
        else:
            print("Negative")
    
    elif a > 0 and b > 0:
        print("Positive")

    else:
        print("Zero")

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

/*

*/

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String match1 = "[A-Z]";
        String match2 = "[a-z]";

        if (a.matches(match1)) {
            System.out.println("A");
        } else {
            System.out.println("a");
        }

    }
}

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

using namespace std;


int main() {

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    int n,tmp;

    cin>>n;

    vector<long long>v(n);

    vector<long long>freq(n+1,0);

    for(int i=0;i<n;i++){
        cin>>v[i];
    }

    for(int i=0;i<n;i++){
        freq[v[i]]++;
    }

    long long totalComb = 0;
   // vector<long long> combination(n);

    for(int i=0;i<=n;i++){
        //combination[i] = ;
        //totalComb += combination[i];

        totalComb += (freq[i] * (freq[i]-1))/2;
    }

    for(int i=0;i<n;i++){
        long long ans = totalComb - ((freq[v[i]] * (freq[v[i]]-1))/2);
        ans += (((freq[v[i]]-1) * (freq[v[i]]-2))/2);
        cout<<ans<<endl;
    }




    return 0;
}


Measured memory_bytes: 5760
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int sx = sc.nextInt();
        int sy = sc.nextInt();
        int tx = sc.nextInt();
        int ty = sc.nextInt();
        StringBuilder ans = new StringBuilder();
        for(int i = 0; i < (ty-sy); i++) ans.append("U");
        for(int i = 0; i < (tx-sx); i++) ans.append("R");
        for(int i = 0; i < (ty-sy); i++) ans.append("D");
        for(int i = 0; i < (tx-sx); i++) ans.append("L");
        ans.append("D");
        for(int i = 0; i < (tx-sx+1); i++) ans.append("R");
        for(int i = 0; i < (ty-sy+1); i++) ans.append("U");
        ans.append("L");
        ans.append("U");
        for(int i = 0; i < (tx-sx+1); i++) ans.append("L");
        for(int i = 0; i < (ty-sy+1); i++) ans.append("D");
        ans.append("R");
        System.out.println(ans.toString());
    }
}



Measured memory_bytes: 23892
while true
  n, k, m, r = gets.split.map(&:to_i)
  break if n == 0
  x, y = 1, n
  x, y = (1...n).reduce([1, 1]){ |b, i| [b[0] * i + b[1], b[1] * i]}.zip([x, y]).map{ |a, b| a * b } if m == 1
  g = x.gcd(y)
  x /= g; y /= g
  print  (x / y).to_s + "."
  x = (x - y * (x / y)) * 10
  r.times.reduce(x){ |t, _| print t / y; (t - y * (t / y)) * 10 }
  puts
end

Measured memory_bytes: 90920
from itertools import product

n, m, x = map(int, input().split())
book = [[int(i) for i in input().split()] for j in range(n)]
cost = []

for p in product((0, 1), repeat=n):
    ex = [0] * m
    pre_cost = 0
    for i in range(n):
        if p[i] == 1:
            pre_cost += book[i][0]
            for j in range(m):
                ex[j] += book[i][j + 1]
    if min(ex) >= x:
        cost.append(pre_cost)
if cost:
    print(min(cost))
else:
    print(-1)

Measured memory_bytes: 9196
MOD = 998244353
n,k = map(int,input().split())
ns = [list(map(int,input().split())) for i in range(k)]
    
dp = [0 for j in range(n+1)]
cum = [0 for j in range(n+1)]
dp[1] = 1
cum[1] = 1
for i in range(2, n+1):
    for j in range(k):
        l, r = ns[j]
        if i - l >= 0:
            dp[i] += cum[i-l]
        if i - (r+1) >= 0:
            dp[i] -= cum[i-(r+1)]
    dp[i] = (dp[i] % MOD + MOD) % MOD
    cum[i] = (cum[i-1] + dp[i]) % MOD
print(dp[n])

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl
#define DEV_VAL 1000000007

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

  ll val = 8 - ((n-400) /200);

  cout << fixed << val << endl;

  return 0;
}

Measured memory_bytes: 3636
SX = 100
SY = 100
dx = [-1, -1, 0, 0, 1, 1]
dy = [-1, 0, -1, 1, 0, 1]

loop do
  t, n = gets.chomp.split.map(&:to_i)

  if t | n == 0
    break
  end

  visited = Array.new(200) {
    Array.new(200, 0)
  }

  field = Array.new(200) {
    Array.new(200, 0)
  }
  
  n.times do
    x, y = gets.chomp.split.map(&:to_i)
    field[y + SY][x + SX] = 1
  end

  sx, sy = gets.chomp.split.map(&:to_i)
  sx += SX
  sy += SY

  queue = [[sx, sy, 0]]
  visited[sy][sx] = 1

  while !queue.empty? do
    tmp = queue.shift

    if tmp[2] + 1 > t
      next
    end
    
    6.times do |i|
      nx = tmp[0] + dx[i]
      ny = tmp[1] + dy[i]
      
      if field[ny][nx] == 1 || visited[ny][nx] == 1
        next
      end

      visited[ny][nx] = 1
      queue.push([nx, ny, tmp[2] + 1])
    end
  end

  ans = 0;
  200.times do |i|
    200.times do |j|
      if visited[i][j] == 1
        ans += 1
      end
    end
  end
                          
  puts ans
end

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

#define INF 1LL<<60



  int main(){
    int M, D, M2, D2;
    cin >> M >> D >> M2 >> D2;
    if(M < M2){
      print(1);
      return 0;
    }
    if(M == 12 && M2 == 1){
      print(1);
      return 0;
    }

    print(0);
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}

int main() {
    int n,m;
    cin >> n >> m;
    vector<int>a(n),b(n);
    vector<int>c(m),d(m);
    rep(i,n) cin >> a[i] >> b[i];
    rep(i,m) cin >> c[i] >> d[i];
    
    rep(i,n) {
        int ans = 0;
        int tmp = 1e9;
        rep(j,m) {
            int dist = abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(tmp > dist) {
                tmp = dist;
                ans = j+1;
            }
        }
        cout << ans << endl;
    }
}

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

using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

Node * find(Node *u, int k) {
	while(u != NIL && k != u->key) {
		if(k < u->key) u = u->left;
		else u = u->right;
	}
	return u;
}

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key   = k;
	z->left  = NIL;
	z->right = NIL;
	
	while(x != NIL) {
		y = x;
		if(z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if(y == NIL) {
		root = z;
	} else {
		if( z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
	
int main(void) {
	int n, i, x;
	string com;
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		cin >> com;
		if(com[0] == 'f') {
			scanf("%d",&x);
			Node *t = find(root,x);
			if(t != NIL) printf("yes\n");
			else printf("no\n");
		} else if(com == "insert") {
			scanf("%d",&x);
			insert(x);
		} else if(com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}


Measured memory_bytes: 22036
#include<iostream>
#include<math.h>

using namespace std;

int main(){
	long long ans=0, N;
	cin >> N;
	if(N==1){
		cout <<0;
		return 0;
	}
	for(int i=1;i<=sqrt(N);i++){
		if(N%(N/i-1)==N/(N/i-1))ans+=N/i-1;
	}
	cout << ans;
	
}

Measured memory_bytes: 256
using System;

class Program
{
	static void Main(string[] args)
	{
      int cnt = 0;
      int difference = 0;
      int profit = 0;
      
      int sum = int.Parse(Console.ReadLine());
	  string[] strBuff1 = Console.ReadLine().Split(' ');
      string[] strBuff2 = Console.ReadLine().Split(' ');
      
      
      for( cnt = 0; cnt < sum; cnt++ )
      {
        difference = int.Parse(strBuff1[cnt]) - int.Parse(strBuff2[cnt]);
        
        if( difference > 0 )
        {
          profit += difference;
        }
      }
      
      Console.WriteLine(profit);
	}
}

Measured memory_bytes: 11220
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
public class Main {
  public static void main(String[] args){
        
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int cnt = 0;
    for (int i = 1; i < K+1; i++) {
      for (int j = 1; j < K+1; j++) {
        for (int j2 = 1; j2 < K+1; j2++) {
          //gcd
          cnt += gcd(i, j, j2);
        }
      }
    }
    System.out.println(cnt);
    
   
    sc.close();
  }
  static int gcd (int a, int b, int c){
    int result = gcd(a, b);
    return gcd(c, result);
  }
  static int gcd (int a, int b) {
    return b>0?gcd(b,a%b):a;
  }

}

Measured memory_bytes: 27232
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

long long bin_pow(long long x, int n){
    long long res = 1;
    while(n > 0){
        if(n & 1)res = res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

int main(){
    int n, r, l, a, i;
    long long res;
    cin >> n;
    int c[n+1] = {};
    long long fact[n+2], inv[n+2];
    for(i=1; i<=n+1; i++){
        cin >> a;
        if(c[a] != 0){
            l = c[a];
            r = i;
        }else{
            c[a] = i;
        }
    }
    fact[0] = 1;
    for(i=1; i<=n+1; i++){
        fact[i] = fact[i-1]*i%MOD;
    }
    for(i=0; i<=n+1; i++){
        inv[i] = bin_pow(fact[i], MOD-2);
    }
    for(i=1; i<=n+1; i++){
        if(i == 1){
            cout << n << '\n';
        }else{
            res = fact[n+1]*inv[i]%MOD*inv[n+1-i]%MOD;
            if(l+n-r >= i-1 && l+n-r > 0){
                res = (res - fact[l+n-r]*inv[i-1]%MOD*inv[l+n-r-i+1]%MOD)%MOD;
            }
            if(res < 0){
                res += MOD;
            }
            cout << res << '\n';
        }
    }
    return 0;
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

signed main() {
  int a[4];
  for (int i = 0; i < 4; ++i) {
    scanf("%1d", &a[i]);
  }

  for (int b = 0; b < 2; ++b) {
    for (int c = 0; c < 2; ++c) {
      for (int d = 0; d < 2; ++d) {
        int n = a[0];
        n += (b ? 1 : -1) * a[1];
        n += (c ? 1 : -1) * a[2];
        n += (d ? 1 : -1) * a[3];
        if (n == 7) {
          cout << a[0] << (b ? "+" : "-") << a[1] << (c ? "+" : "-") << a[2] << (d ? "+" : "-") << a[3] << "=7" << endl;
          return 0;
        }
      }
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
#define allsort(X) sort(X.begin(),X.end())

typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;






ll i,j,k;


int main(){
    ll N;
    cin>>N;
    ll ans=N%1000;
    if(ans==0)cout<<0<<endl;
    else cout<<1000-ans<<endl;
    
  

}

Measured memory_bytes: 3592
import sys
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3
#sys.setrecursionlimit(int(1e+6))
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
MOD = int(1e+9) + 7

def main():
    A, P = i2nn()
    print((3 * A + P) // 2)

main()


Measured memory_bytes: 38256
// https://atcoder.jp/contests/abc175/tasks/abc175_c
#include <bits/stdc++.h>
using namespace std ;
#define int long long
#define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ;
const int MOD = 1000000007 ;
void solve() {
    int x , k , d ;
    cin >> x >> k >> d ;
    x = abs(x) ;
    if( k <= ( x / d ) )
        cout << x - ( k * d ) << endl ;
    else
    {
        k -= x / d;
        if ( k % 2 )
            cout << abs( ( x % d ) - d ) << endl ;
        else
        {
            cout << x % d << endl ;
        }
        
    } 
}

int32_t main() {
    fast;
    int testcases = 1 ;
    //cin >> testcases ;
    while (testcases--) {
        solve() ;
    }
    return 0;
}
/*  CODED BY:-
 ___________________________________
|                       ___         |
|  /\   /\  \ /  |  |  |___   |__|  |        
| /~~\ /~~\  |   |__|   ___|  |  |  |
|___________________________________|
*/

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,ans=100000;
	cin >> n;
	for(int i=0;i<n;i++){
		ans+=ans/20;
		if(ans%1000>0){
			ans/=1000;
			ans++;
			ans*=1000;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3016
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main() {
    int N, T;
    cin >> N >> T;
    int A = 1001;
    for (int i = 0; i < N; i++) {
        int c, t;
        cin >> c >> t;
        if (t <= T) {
            A = min(A, c);
        }
    }
    if (A == 1001) {
        cout << "TLE" << endl;
    }
    else {
        cout << A << endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <list>
#include<utility>
#include <new>
#include <string>
#include<cmath>
#include<unordered_set>
#include<iomanip>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define forloop(i,x,z) for (int i=x;i<z;i++)
using ll = unsigned long long int;
/*bool cmp(pair<ll,ll>a,pair<ll,ll>b){
return a.second<b.second;
}*/
int main()
{int x;
	cin >> x;
	if(x>=400&&x<=599){
        cout<<8;
	}else if(x>=600&&x<=799){
        cout<<7;
	}else if(x>=800&&x<=999){
        cout<<6;
	}else if(x>=1000&&x<=1199){
        cout<<5;
	}else if(x>=1200&&x<=1399){
        cout<<4;
	}else if(x>=1400&&x<=1599){
        cout<<3;
	}else if(x>=1600&&x<=1799){
        cout<<2;
	}else if(x>=1800&&x<=1999){
        cout<<1;
	}
	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
using namespace std;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i] == ',') cout<<" ";
		else cout<<s[i];
	}
	cout<<endl;
	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int win[100][100];
bool f(int x, int y){
  if(win[x][y]) return win[x][y] > 0;
  for(int i=2;i<=x;i+=2)
	if(!f(x-i,y+i/2)){
	  win[x][y] = 1;
	  return true;
	}
  for(int i=2;i<=y;i+=2)
	if(!f(x+i/2,y-i)){
	  win[x][y] = 1;
	  return true;
	}
  win[x][y] = -1;
  return false;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  /*
  REP(i,10) REP(j,i+1)
	cout << i << ", " << j << ": " << f(i,j) << endl;
  return 0;
  */
  LL X, Y; cin >> X >> Y;
  if(X < Y) swap(X, Y);
  cout << (X-2 >= Y? "Alice": "Brown") << endl;

  return 0;
}


Measured memory_bytes: 256
import numpy as np
N,H=map(int,input().split())
ab=[input().split() for i in range(N)]
a = [int(ab[i][0]) for i in range(N)]
maxa = max(a)
b = np.array([int(ab[i][1]) for i in range(N)])
b_effective = b[b > maxa]
d = 0
if sum(b_effective) < H:
    c = len(b_effective)
    rest = H - sum(b_effective)
    if rest % maxa == 0:
        d = rest//maxa
    else:
        d = rest//maxa + 1
else:
    b = np.sort(b_effective)[::-1]
    s = 0
    for i in range(len(b)):
        s += b[i]
        if s >= H:
            c = i + 1
            d = 0
            break
print(c+d)

Measured memory_bytes: 51588