akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    queue<long long> q;
    for(int i = 1; i <= 9; ++i){
        q.push(i);
    }
    int k;
    cin >> k;
    ll x;
    while(k--){
        x = q.front();
        q.pop();
        if(x % 10 != 0){
            q.push(10 * x + (x % 10) - 1);
        }
        q.push(10 * x + (x % 10));
        if(x % 10 != 9){
            q.push(10 * x + (x % 10) + 1);
        }
    }
    cout << x << endl;

}
int main(int argv, char **argc){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int t;
    t = 1;
    while(t--)
        solve();
}



Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define rs (x<<1|1)
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) (int((x).size()))
#define All(x) (x).begin(),(x).end()
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
const int maxn=2e5+5;
int n;
int p[maxn],f[maxn],t[maxn],pos[maxn];
bool check(int a,int b,int c){
	if(a<b&&b<c)return 1;
	if(b<c&&c<a)return 1;
	if(c<a&&a<b)return 1;
	return 0;
}
int main(){
	read(n);
	rep(i,1,n)read(p[i]),pos[p[i]]=i;
	t[n]=0;
	per(i,n-1,1){
		if(!t[i+1]){
			if(pos[i]<pos[i+1])t[i]=0;
			else t[i]=1,f[i]=i+1;
		}else{
			if(check(pos[f[i+1]],pos[i],pos[i+1]))t[i]=t[i+1],f[i]=f[i+1];
			else t[i]=t[i+1]+1,f[i]=i+1;
		}
	}
	printf("%d\n",t[1]);
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <limits>
using ll = long long;
constexpr int INF = std::numeric_limits<int>::max() / 2;
constexpr ll LNF = std::numeric_limits<ll>::max() / 2;

using namespace std;
int main() {
    int H, W;
    cin >> H >> W;
    vector<string> field(H);
    for (int i = 0; i < H; i++) {
        cin >> field[i];
    }

    function<int(int, int)> dfs = [&](int y, int x) {
        if (!(0 <= y && y < H && 0 <= x && x < W)) {
            return 0;
        }
        if (field[y][x] == '.') return 0;
        field[y][x] = '.';
        int res = 1;
        res += dfs(y+1, x);
        res += dfs(y-1, x);
        res += dfs(y, x+1);
        res += dfs(y, x-1);
        return res;
    };

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (dfs(i, j) == 1) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 512
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

print(chr(ord(input()) + 1))


Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
 
class Main{
    public static void main(String[] args){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            String input_str;
            while((input_str = br.readLine()) != null){
                String[] input_strs = input_str.split(" ");
 
                // まずノードを生成
                Node node1 = new Node(input_strs[1]);
                Node node2 = new Node(input_strs[2]);
                Node result_node = new Node();
 
                // intersection
                if(input_strs[0].equals("i")){
                    result_node.intersection(node1, node2);
                }
 
                // union
                if(input_strs[0].equals("u")){
                    result_node.union(node1, node2);
                }
 
                System.out.println(result_node.toString());
            }
        }catch(Exception e){
            System.out.println("Error");
        }
    }
}
 
class Node{
    Node left;
    Node right;
 
    Node(){
        left = null;
        right = null;
    }
 
    Node(String str){
        int lvl = 0;
        for(int i = 0; i < str.length(); i++){
            char ch = str.charAt(i);
            if(ch == '(') lvl++;
            if(ch == ')') lvl--;
            if(ch == ',' && lvl == 1){
                // 左辺
                String left_str = str.substring(1, i);
                if(left_str.length() == 0){
                    left = null;
                }else{
                    left = new Node(left_str);
                }
 
                // 右辺
                String right_str = str.substring(i+1, str.length()-1);
                if(right_str.length() == 0){
                    right = null;
                }else{
                    right = new Node(right_str);
                }
            }
        }
    }
 
    public String toString(){
        String result = "(";
        if(left != null) result += left.toString();
        result += ",";
        if(right != null) result += right.toString();
        result += ")";
        return result;
    }
 
    public Node intersection(Node node1, Node node2){
        // left
        if(node1.left != null && node2.left != null){
            left = new Node();
            left.intersection(node1.left, node2.left);
        }
        // right
        if(node1.right != null && node2.right != null){
            // どちらも null でない
            right = new Node();
            right.intersection(node1.right, node2.right);
        }
        return this;
    }
 
    public Node union(Node node1, Node node2){
        // left
        if(node1.left == null){
            left = node2.left;
        }else if(node2.left == null){
            left = node1.left;
        }else{
            left = new Node();
            left.union(node1.left, node2.left);
        }
        // right
        if(node1.right == null){
            right = node2.right;
        }else if(node2.right == null){
            right = node1.right;
        }else{
            right = new Node();
            right.union(node1.right, node2.right);
        }
        return this;
    }
}

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

int main()
{
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int sum = 0;
  while (k != 0)
  {
    if (a > 0)
    {
      a--;
      sum++;
    }
    else if (b > 0)
    {
      b--;
    }
    else if (c > 0)
    {
      c--;
      sum--;
    }
    k--;
  }
  cout << sum;
}

Measured memory_bytes: 3632
#include<stdio.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#define rep(i,N) for(int i=0;i<(int)N;i++)
#define swap(a,b) (a+=b,b=a-b,a-=b)
const int MOD=1e9+7;
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void Radix32(int *a,const int sz)
{
  int temp[sz];
  rep(j,4)
  {
    int u[256]={},v[256]={};
    rep(i,sz)u[a[i]>>8*j&255]++;
    rep(i,255)u[i+1]+=u[i];
    rep(i,sz){temp[--u[a[sz-1-i]>>8*j&255]]=a[sz-1-i];}j++;
    rep(i,sz)v[temp[i]>>8*j&255]++;
    rep(i,255)v[i+1]+=v[i];
    rep(i,sz)a[--v[temp[sz-1-i]>>8*j&255]]=temp[sz-1-i];
  }
}
int main()
{
  int N=IN(),K=IN(),l,m=0,r,accum=1,sign=1,A[N];long x,y;
  rep(i,N)A[i]=IN(),m+=A[i]<0?1:0;
  Radix32(A,N);
  rep(i,m/2)swap(A[N-m+i],A[N-1-i]);
  rep(i,(N-m)/2)swap(A[i],A[N-m-1-i]);
  rep(i,N/2)swap(A[i],A[N-1-i]);
  if(K&1)accum=A[N-1],sign=(A[N-1]<0?-1:1),N--,K--;
  l=0,r=N-1;
  while(K)
  {
    x=1l*A[l]*A[l+1],y=1l*A[r]*A[r-1];
    if(x*sign>y*sign)x%=MOD,accum=1l*accum*x%MOD,l+=2;
    else y%=MOD,accum=1l*accum*y%MOD,r-=2;
    K-=2;
  }
  return printf("%ld\n",(1l*accum%MOD+MOD)%MOD),0;
}

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

using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    ll a, sum = 0;
    unordered_map<int, int> cnt;
    for (int i = 0; i < n; i++) {
        cin >> a;
        sum += a;
        cnt[a]++;
    }
    int q;
    cin >> q;
    while (q--) {
        int b, c;
        cin >> b >> c;
        sum += (c - b) * cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << "\n";
    }
}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  map<int, int> mpi, mpj;
  for(int i = 0; i < n; ++i){
    mpi[a[i] + i]++;
  }

  ll ans = 0;
  for(int i = 0; i < n; ++i){
    ans += mpi[i - a[i]];
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 21212
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using std::cout;
using std::cin;
using std::endl;
using std::pow;
using std::vector;
using std::string;

int main(){
    long n,res=0;
    bool nao;
    int i,j,k,l;
    string s;
    cin >> n;
    cin >> s;
    for(i=0;i<1000;i++){
        int cnt = 0;
        for(j=0;j<n;j++){
            if(int(s[j])-48 == i/100 && cnt == 0) cnt++;
            else if(int(s[j])-48 == (i/10)%10 && cnt == 1) cnt++;
            else if(int(s[j])-48 == i % 10 && cnt == 2) cnt++;
            
        }
        if(cnt == 3) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int f[10][10];
 
int main() {
  int n; cin >> n;
  for (int x = 1; x <= n; x++) {
    string cur = to_string(x);
    int l = cur[0] - '0';
    int r = cur.back() - '0';
    f[l][r]++;
  }
  ll ans = 0;
  for (int l = 0; l < 10; l++) {
    for (int r = 0; r < 10; r++) {
      ans += f[l][r] * 1ll * f[r][l];
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String str[]=br.readLine().split(" ");
        int n=Integer.parseInt(str[0]);
        int x=Integer.parseInt(str[1]);
        int t=Integer.parseInt(str[2]);
        pw.println((int)Math.ceil((double)n/x)*t);
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 32860
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
  int N , K;
  cin >> N >> K;
  int Kh = K-1;
  vector<int> X;
  X= igets(N);
  vector <int> listup;
  REP(i,N-K+1){
    listup.PB(abs(X[i]-X[i+K-1])+min(abs(X[i+K-1]),abs(X[i])));
  }

  cout << *min_element(listup.begin(),listup.end()) << endl;
}


int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 10000000000;
const ll MOD = 1000000007;

using namespace std;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	long long g = gcd(a, b);
	return a / g * b;
}

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

	ll ans = k * pow(k - 1, n - 1);
	cout << ans << "\n";
	
}


Measured memory_bytes: 384
S = input()
flag = True
if S[0] != "A":
    flag = False
S = S[1:]
idx = S.find("C")
if idx not in range(1, len(S) - 1):
    flag = False
if idx >= 0:
    S = S[:idx] + S[idx+1:]
if not S.islower():
    flag = False
print("AC") if flag else print("WA")

Measured memory_bytes: 3064
#include<stdio.h>
char s[500050],c;
int main(){
  int t=200010,r,i,n,q,f=1;
  scanf("%s %d",s+t,&n);
  for(r=t;s[r];r++);
  while(n--){
    scanf("%d",&q);
    if(q==1)f=1-f;
    else{
      scanf("%d %c",&q,&c);
      if(q%2==f)s[--t]=c;
      else      s[r++]=c;
    }
  }
  if(f){
    for(i=t;i<r;i++)printf("%c",s[i]);
  }
  else{
    for(i=r;i>t;i--)printf("%c",s[i-1]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 768
x, n = map(int, input().split())
if n:
	p = list(map(int, input().split()))
	for i in range(n+1):
		if not x - i in p:
			print(x-i)
			break
		if not x + i in p:
			print(x+i)
			break
else:
	print(x)

Measured memory_bytes: 9168
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int N;
    int a[110];
    cin >> N;
    for(int i = 0;i < N; ++i){
        cin >> a[i];
    }
    sort(a,a + N,greater<int>());
    int Alice = 0;
    int Bob = 0;
    for (int i = 0;i < N;++i){
        if(i % 2 == 0){
            Alice += a[i];
        }else{
            Bob += a[i];
        }
    }
    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
N,M = gets.split.map(&:to_i)
es = (0..N).map{ [] }
rs = (0..N).map{ [] }
(N+M-1).times{
  a,b = gets.split.map(&:to_i)
  es[a] << b
  rs[b] << a
}
rh = (0..N).map{ |m| Hash[rs[m].map{ |n| [n,1] }] }

Root = (1..N).find{ |n| rs[n].size == 0 }
rs[Root] << 0
dp = Array.new(N+1, 0)
dp[Root] = 1

nodes = [Root]
cnt = 0
visited = Array.new(N+1, nil)
#p rh
while n = nodes.pop
  v = dp[n] + 1
  es[n].each{ |m|
    rh[m].delete(n)
    if rh[m].size == 0 && !visited[m]
      visited[m] = 1
      nodes << m
    end
    dp[m] = v if v > dp[m]
    cnt += 1
  }
#  p nodes
end

#p cnt

puts (1..N).map{ |n|
  v = dp[n]
  rs[n].find{ |m| v - dp[m] == 1 }
}

Measured memory_bytes: 51368
#include <iostream>
#include <cstdio>
using namespace std;
int a,b,aa,bb;
void go1(int x,int y)
{
    printf("U");
    y++;
    while(x<aa-2)
    {
        printf("R");
        x++;
    }
    while(y!=bb)
    {
        printf("U");
        y++;
    }
    while(x!=aa)
    {
        printf("R");
        x++;
    }
}
void go2(int x,int y)
{
    printf("L");
    x--;
    printf("U");
    y++;
    printf("U");
    y++;
    if(y>bb)
    {
        while(x!=aa)
        {
            printf("R");
            x++;
        }
        printf("D");
        return;
    }
    while(x<aa-3)
    {
        printf("R");
        x++;
    }
    while(y<bb+1)
    {
        printf("U");
        y++;
    }
    while(x<aa)
    {
        printf("R");
        x++;
    }
    printf("D");
}
void back1(int x,int y)
{
    printf("D");
    y--;
    if(aa-a>1)
    {
        printf("L");
        x--;
    }
    while(y!=b)
    {
        printf("D");
        y--;
    }
    while(x!=a)
    {
        printf("L");
        x--;
    }

}
void back2(int x,int y)
{
    printf("R");
    x++;
    printf("D");
    y--;
    printf("D");
    y--;
    if(y<b)
    {
        while(x>a)
        {
            printf("L");
            x--;
        }
        printf("U");
        return;
    }
    if(aa-a>=2)
    {
        printf("L");
        x--;
    }
    while(y!=b-1)
    {
        printf("D");
        y--;
    }
    while(x!=a)
    {
        printf("L");
        x--;
    }
    printf("U");

}
int main()
{
    scanf("%d%d%d%d",&a,&b,&aa,&bb);
    aa=aa-a+1;
    bb=bb-b+1;
    a=1,b=1;
    go1(a,b);
    back1(aa,bb);
    go2(a,b);
    back2(aa,bb);
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  
  if(s=="SUN"){
    cout << 7 << endl;
  }
  else if(s=="MON"){
    cout << 6 << endl;
  }
  else if(s=="TUE"){
    cout << 5 << endl;
  }
  else if(s=="WED"){
    cout << 4 << endl;
  }
  else if(s=="THU"){
    cout << 3 << endl;
  }
  else if(s=="FRI"){
    cout << 2 << endl;
  }
  else{
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
st1 = [input() for _ in range(n)]
m = int(input())
st2 = [input() for _ in range(m)]

st1_cnt = Counter(st1)
st2_cnt = Counter(st2)

gain = []
for key in st1_cnt.keys():
    gain.append(st1_cnt[key] - st2_cnt[key])
gain.append(0)

print(max(gain))

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

int walk(int current,
         int N,
         int M,
         int visited[10],
         vector<pair<int, int> > edge) {
    int num = 0;
    int all_visited = 1;

    if (visited[current]) return 0;

    visited[current] = 1;
    for (int i = 0; i < N; ++i) {
        if (!visited[i]) all_visited = 0;
    }
    if (all_visited) {
        visited[current] = 0;
        return 1;
    }

    for (int i = 0; i < M; ++i) {
        int ai = edge[i].first;
        int bi = edge[i].second;
        if ( ai == current ) {
            num += walk(bi, N, M, visited, edge);
        }
        if ( bi == current ) {
            num += walk(ai, N, M, visited, edge);
        }
    }

    visited[current] = 0;
    return num;
}

int main() {
    int N, M;
    vector<pair<int, int> > edge;
    int visited[10] = {0};

    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        edge.push_back(make_pair(a-1, b-1));
    }

    cout << walk(0, N, M, visited, edge) << endl;
}


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

using namespace std;

int main ()
{
    long long x,y;
    y=1;

    cin>>x;

    if(1<= x <= 20)
    {
        for(int i = x; i>0; i--)
        {
            y*=i;
        }
        cout<<y<<endl;
    }

    return 0;
}



Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

struct Point{
	int x,y;
};

const Point DIR[4] = {{1,0},{0,1},{-1,0},{0,-1}};

bool inField(int w,int h, int x,int y){
	return 0<= x && x < w && 0<= y && y<h;
}

int main(){
	while(true){
		int w,h;
		cin >> w >> h;
		if(w == 0){
			break;
		}
		char map[20][20];
		bool visited[20][20];
		Point init;//初期位置
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> map[i][j];
				visited[i][j] = false;
				if(map[i][j] == '@'){
					init = (Point){j,i};
					map[i][j] = '.';
				}
			}
		}
		//入力終わり。探索開始

		int cnt=1;//初期位置の分を含める
		visited[init.y][init.x] = true;//初期位置の処理
		
		queue<Point> open;
		open.push(init);
		while(open.empty()==false){
			Point now = open.front();//先頭の要素をget
			open.pop();//front()とセットで使う。先頭の要素をremove
			for(int i=0;i<4;i++){
				Point next = {now.x + DIR[i].x, now.y + DIR[i].y};
				if(inField(w,h,next.x,next.y)==true){
					if(visited[next.y][next.x] == false && map[next.y][next.x] == '.'){
						visited[next.y][next.x] = true;
						cnt++;
						open.push(next);
					}
				}
			}
		}
		cout << cnt << endl;
	}

}
//(特にboolの)代入時にcheck == trueなんてしないように注意

Measured memory_bytes: 1216
import sys
k = int(sys.stdin.read())
if k==2:
  print(-1)
  sys.exit()
value = 0
index = 0
while index < 1000000:
  index += 1
  value = (value*10+7)%k
  if value == 0:
    print(index)
    sys.exit()

print(-1)

Measured memory_bytes: 9084
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.Delayed;
import java.util.logging.Logger;


public class Main {
	public static void main(String[] args){
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		int K=sc.nextInt();
		int sum=0;
		sum+=Math.min(K, A);
		K-=A;
		if (K>0) {
			K-=B;
			if (K>0) {
				sum-=Math.min(K, C);
			}
		}
		System.out.println(sum);
	}
	static class InputReader { 
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
 
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}
 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
 
		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}
 
		public boolean hasNext() {
			skip();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 32464
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
x = na()
xx = sorted(x, reverse=True)
mid = n // 2 - 1
ans = xx[mid]
for i in range(n):
    if x[i] >= ans:
        print(xx[mid+1])
    else:
        print(ans)


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	char c;
	cin >> c;
	if (c <= 'Z' && c >= 'A') cout << "A" << endl;
	else cout << "a" << endl;
    
    return 0;
}


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

int max_elem(vector<int> X){
  vector<int> Y = X;
  sort(Y.begin(), Y.end());
  return Y[Y.size() - 1];
}

int main(){
  int N;
  cin >> N;
  vector<int> h(N);
  rep(i, N) cin >> h[i];

  // 連続する1を要素とするベクトルを足した回数
  int ans = 0;

  // 全てが0になるまで繰り返す
  while (true){
    // 全てが0ということは最大値が0ということ
    if (max_elem(h)==0) break;

    // みている花のインデックス
    int cnt = 0;
    // 1が連続する区間の最初であるかどうかのフラグ
    bool flag = true;

    // 全ての花を見る
    while (cnt < N){
      // もし見ている花の高さが0であればflagをtrueにする
      if (h[cnt]==0) flag=true;
      // 高さが0でないとき
      else{
        // 連続する区間の最初であればansをインクリメント
        if (flag) ans++;
        // 区間の最初はすぎたのでflagはfalseにする
        flag = false;
        h[cnt]--;
      }
      cnt ++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
def times(money, mod):
  ans = 0
  while(money != 0):
    ans +=  money % mod
    money = money // mod
  return ans
 
c = []
n = int(input())
for i in range(n+1):
  c.append(times(i,6)+times(n-i,9))
print(min(c))

Measured memory_bytes: 3864
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }



struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};


// ***************************************


int main(){

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

    UnionFind uf(N);
    vll dame(N);

    int a, b;
    REP(i, M){
        cin >> a >> b;
        a--; b--;
        uf.merge(a, b);
        dame[a]++;
        dame[b]++;
    }
    int c, d;
    REP(i, K){
        cin >> c >> d;
        c--; d--;
        if (uf.issame(c, d)){
            dame[c]++;
            dame[d]++;
        }
    }

    REP(i, N){
        cout << uf.size(i) - dame[i] - 1;
        if(i < N-1){
            cout << " ";
        } else{
            cout << endl;
        }
    }


    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
  int n,k;
  cin>>n>>k;
  set<int>s;
  map<ll,ll>m;
  for(int i=0;i<n;i++)
  {
    int x;
    cin>>x;
    s.insert(x);
    m[x]++;
  }
  if(m.size()<=k)
    cout<<0<<endl;
  else
  {
    vi v;
    for(auto t:m)
      v.pb(t.se);
    sort(v.begin(),v.end());
    ll s=0;
    for(int i=0;i<v.size()-k;i++)
    {
       s+=v[i];
    }
    cout<<s<<endl;
  }
  
}
return 0;
}

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

int main()
{
	ll n;
	cin>>n;
	if(n%2 !=0)
	{
		cout<<0;
	}
	else
	{
		ll sum = 0;
	n/=2;
	while(n)
	{
		sum += (n/5);
		n/=5;
	}
	//sum /=2;
	cout<<sum;
	}
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, R;
    cin >> N >> R;

    if(N>=10)
        cout << R << endl;
    else
        cout << R + 100 * (10 - N) << endl;
}

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

int countDigit(long long n)
{
    return floor(log10(n) + 1);
}

int main()
{
    ll n1;
    cin>>n1;
    int n = countDigit(n1);
    if(n==1)
        cout<<n1;
    else if (n==2)
    {
        cout<<9;
    }
    else if(n==3)
    {
        ll ans = 9 + (n1-100) + 1;
        cout<<ans;
    }
    else if(n==4)
    {
        ll ans = 900 + 9;
        cout<<ans;
    }
    else if(n==5)
    {
        ll ans = 9 + 900 + (n1-10000) + 1;
        cout<<ans;
    }
    else if(n==6)
    {
        ll ans = 9 + 900 + 90000;
        cout<<ans;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>


int main(){
    long N;
    std::cin >> N;
    std::string S[100000];
    long count[4]={};
    for(long i=0; i<N; i++){
        std::cin >> S[i];
        if(S[i]=="AC"){
            count[0]++;
        }else if(S[i]=="WA"){
            count[1]++;
        }else if(S[i]=="TLE"){
            count[2]++;
        }else{
            count[3]++;
        }
    }
    std::cout << "AC x " << count[0] << std::endl;
    std::cout << "WA x " << count[1] << std::endl;
    std::cout << "TLE x " << count[2] << std::endl;
    std::cout << "RE x " << count[3] << std::endl;
    return 0;
}

Measured memory_bytes: 6752
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input[] = br.readLine().split(" ", 0);
        
        int a = Integer.valueOf(input[0]);
        int b = Integer.valueOf(input[1]);
        
        int d = a / b;
        int r = a % b;
        String f = String.format("%.7f", Double.valueOf(a) / b);
        
        System.out.println(d + " " + r + " " + f);
    }
}


Measured memory_bytes: 24864
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long n,k,s;
    cin>>n>>k>>s;
    if(s!=1000000000){
        for(int i=1;i<=n;i++){
            if(i<=k){
                cout<<s<<" ";
            }
            else{
                cout<<s+1<<" ";
            }
        }
    }
    else{
        for(int i=1;i<=n;i++){
            if(i<=k){
                cout<<s<<" ";
            }
            else{
                cout<<1<<" ";
            }
        }
    }
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <queue>

const int MAX   = 10000;
const int INFTY = (1<<20);
const int WHITE = 0;
const int GRAY  = 1;
const int BLACK = 2;

int n;
std::vector<std::pair<int, int>> adj[MAX];

void Dijkstra() {
    std::priority_queue<std::pair<int, int>> PQ;
    int color[MAX];
    int d[MAX];

    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    PQ.push(std::make_pair(0, 0));
    color[0] = GRAY;

    while (!PQ.empty()) {
        std::pair<int, int> f = PQ.top(); PQ.pop();
        int u = f.second;
        color[u] = BLACK;

        if (d[u] < f.first * (-1)) continue;

        for (int j = 0; j < adj[u].size(); j++) {
            int v = adj[u][j].first;
            if (color[v] == BLACK) continue;
            if (d[v] > d[u] + adj[u][j].second) {
                d[v] = d[u] + adj[u][j].second;
                PQ.push(std::make_pair(d[v] * (-1), v));
                color[v] = GRAY;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        std::cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << std::endl;
    }
}

int main() {
    int k, u, v, c;

    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> u >> k;
        for (int j = 0; j < k; j++) {
            std::cin >> v >> c;
            adj[u].push_back(std::make_pair(v, c));
        }
    }
    Dijkstra();

    return 0;
}


Measured memory_bytes: 7996
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		int m = 1;
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int ans = 0;
			for(int j = 0; j < n; j++) {
				ans += a[j] - 1;
			}
		System.out.println(ans);
	}
}


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

namespace AtCoders {
	class Program {
		static void Main(string[] args) {

			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}

			var X = inputArray[0];

			//できる限り500円玉でおつりをもらい、残りに関してはなるべく5円玉でもらう

			var num500 = X / 500;
			var num5 = (X - 500 * num500) / 5;

			var ureshisa = num500 * 1000 + num5 * 5;


			//答えの出力
			var ans = ureshisa;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray =  Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 13396
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
root = [1]
for i in range(2*n+1000):
    next_num = a[root[-1]]
    root.append(next_num)

if k < n+1:
    print(root[k])

else: 
    loop_end = n 
    loop_start = n-1
    while(root[loop_start]!=root[loop_end]):
        loop_start -= 1
    period = loop_end - loop_start
    k %= period
    while k < n:
        k += period
    print(root[k])





Measured memory_bytes: 32256
main :: IO ()                                                                                                              
main = do                                                                                                                  
  [c11,c12,c13] <- map read . words <$> getLine                                                                            
  [c21,c22,c23] <- map read . words <$> getLine                                                                            
  [c31,c32,c33] <- map read . words <$> getLine                                                                            
                                                                                                                           
  putStrLn $ if c11-c21 == c12-c22 && c12-c22 == c13-c23 &&                                                                
                c21-c31 == c22-c32 && c22-c32 == c23-c33 &&                                                                
                c11-c12 == c21-c22 && c21-c22 == c31-c32 &&                                                                
                c12-c13 == c22-c23 && c22-c23 == c32-c33                                                                   
             then "Yes"                                                                                                    
             else "No"

Measured memory_bytes: 508
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

ll op(ll a, ll b) { return max(a, b); }
ll e() { return -1; }
ll target;
bool f(ll v) { return v < target; };

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, q;
    cin >> n >> q;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    segtree<ll, op, e> st(a);
    rep(i, q) {
        ll t;
        cin >> t;
        if (t == 1) {
            ll x, v;
            cin >> x >> v;
            x--;
            st.set(x, v);
        }
        else if (t == 2) {
            ll l, r;
            cin >> l >> r;
            l--;
            cout << st.prod(l, r) << endl;
        }
        else {
            ll x;
            cin >> x >> target;
            x--;
            cout << (st.max_right<f>(x) + 1) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 9024
n = int(input())
robot = [0]*n
for i in range(n):
    x,l = map(int,input().split())
    robot[i] = (x+l, x-l)
robot.sort()

#print(robot)

ans = 1
right = robot[0][0]
for i in range(1,n):
    if right <= robot[i][1]:
        right = robot[i][0]
        ans += 1
print(ans)

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

typedef long long ll;

int main() {
	ll n, m;
	cin >> n >> m;
	if (n * 2 >= m) {
		cout << m / 2 << endl;
	}
	else {
		ll ans = n, left = m - 2 * n;
		cout << ans + left / 4 << endl;
	}
}

Measured memory_bytes: 256
import math

d = input().split(" ")
a = int(d[0])
b = int(d[1])
ans = 1
p = a
if b <= p:
	p = b
for i in range(2, p+1):
	while(a % i == 0 and b % i == 0):
		ans *= i
		a = int(a/i)
		b = int(b/i)
ans = ans * a * b
print(ans)

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


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

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

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

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

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

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

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

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

// 円周率
// M_PI

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

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

signed main() {
  int64_t n,m;
  cin >> n >> m;
  int64_t p;
  priority_queue<int64_t> price;
  
  for(int i=0;i<n;i++){
    cin >> p;
    price.push(p);
  }
  
  while(m>0){
    p = price.top();price.pop();
    p /= 2;
    price.push(p);
    m--;
  }
  
  int64_t cost = 0;
  while(!price.empty()){
    cost += price.top();price.pop();
  }
  cout << cost << endl;
  return 0;
}




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


int main(){
    int N; cin >> N;
    vector<int> P(N), Q(N);
    rep(i,N) cin >> P[i];
    rep(i,N) cin >> Q[i];

    vector<int> T(N);
    for(int i = 1; i <= N; i++){
        T[i-1] = i;
    }

    int a, b;
    a = b = 0;
    int index = 0;
    do{
        bool isA = true;
        bool isB = true;
        rep(i,N){
            if (P[i] != T[i]){
                isA = false;
            }
            if (Q[i] != T[i]){
                isB = false;
            }
        }
        if (isA) a = index;
        if (isB) b = index;

        index++;
    } while(next_permutation(T.begin(),T.end()));
    
    cout << abs(a-b) << endl;
   
} 

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

ll n,k;
vector<ll> a,f;
const ll lim = 1e18+7;

bool check(ll x){
	ll left = k;
	for(int i=0; i<n; ++i){
		ll should_be = x/f[i];
		if( a[i] <= should_be ){ continue; }
		ll leftover = a[i] - should_be;
		if( leftover > left ){ return false; }
		left -= leftover;
	}
	return (true);
}

ll binsearch(ll lo, ll hi){
	while( lo < hi ){
		ll mid = ( lo + hi )/2;
		if( check(mid) == false ){ lo = mid + 1; }
		else{ hi = mid ; }
	}
	return lo;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>n>>k;
	for(int i=0; i<n; ++i){
		ll x; cin>>x; a.push_back(x);
	}
	for(int i=0; i<n; ++i){
		ll x; cin>>x; f.push_back(x);
	}
	sort(a.begin(),a.end());
	sort(f.rbegin(),f.rend());
	ll ans = binsearch(0, lim);
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 4848