akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node *Node;
#define NIL NULL

Node root;
Node treeMinimum(Node);
Node treeMaximum(Node);
Node treeSearch(Node,int);
Node treeSuccessor(Node);
void treeDelete(Node);
void insert(int);
void inorder(Node);
void preorder(Node);

int main(){
  int n,i,x;
  char com[7];
  scanf("%d",&n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}

Node treeMinimum(Node x){
  while(x->left !=  NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node x,int k){
  if(x==NIL || k == x->key){
    return x;
  }
  if(k < x->key){
    return treeSearch(x->left,k);
  }
  else{
    return treeSearch(x->right,k);
  }
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL){
    return treeMinimum(x->right);
  }
  y = x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y;
  Node x;
  if(z->left == NIL || z->right ==NIL){
    y = z;
  }
  else{
    y=treeSuccessor(z);
  }
  if(y->left != NIL){
    x = y->left;
  }
  if(x != NIL){
    x->parent = y->parent;
  }
  if(y->parent == NIL){
    x = root;
  }
  else if(y==y->parent->left){
    y->parent->left = x;
  }
  else{
    y->parent->right =x;
  }
  if(y != z){
    z->key = y->key;
  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct 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 x){
  if(x!=NIL){
    inorder(x->left);
    printf(" %d",x->key);
    inorder(x->right);
  }
}
void preorder(Node x){
  if(x != NIL){
    printf(" %d",x->key);
    preorder(x->left);
    preorder(x->right);
  }
}



Measured memory_bytes: 20452
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
  int n, x, four, odd;
  while(cin>>n){
    four=odd=0;
    for(int i=0; i<n; ++i){
      scanf("%d",&x);
      if(x%2){
        ++odd;
      }
      if(x%4==0){
        ++four;
      }
    }
    if(odd+four==n){
      if(four+1>=odd){
        cout<<"Yes"<<endl;
      }
      else{
        cout<<"No"<<endl;
      }
    }
    else{
      if(four>=odd){
        cout<<"Yes"<<endl;
      }
      else{
        cout<<"No"<<endl;
      }
    }
  }
  return 0;
}




Measured memory_bytes: 256
N=int(input())
S=list(map(int,input().split()))
d=len(S)
S.sort()
r=0
x=1
b=1
for i in range(N):
  x=1
  while d-2>=i+x:
    b=1
    a=S[i]+S[i+x]
    z=abs(S[i]-S[i+x])
    while d-1>=i+x+b:
      if z<S[i+x+b]<a and S[i]!=S[i+x] and S[i]!=S[i+x+b] and S[i+x]!=S[i+x+b]:
        r+=1
      b+=1
    x+=1
print(r)

Measured memory_bytes: 9224
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <queue>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;

int a[101][2];
int d[101][2];

int main()
{
    int n;
    cin >> n;
    REP(i, 2) {
        REP(j, n) {
            cin >> a[j][i];
            if (i == 0 && j != 0) {
                a[j][i] += a[j - 1][i];
            }
            else if (i == 1 && j != 0) {
                a[j][i] += max(a[j - 1][i], a[j][0]);
            }
            else if (i == 1 && j == 0) {
                a[j][i] += a[j][0];
            }
        }
    }
    cout << a[n-1][1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  string s;
  cin >> s;

  int K;
  cin >> K;

  int N = s.size();

  int dp[1100][5][5];
  dp[0][0][0] = 1;

  REP(i, N) REP(j, K+1) REP(k, 2){
    int lim = k ? 9 : (s[i]-'0');
    if(lim == 0) dp[i+1][j][k] += dp[i][j][k];
    else{
      dp[i+1][j][1] += dp[i][j][k];
      dp[i+1][j+1][1] += (lim-1)*dp[i][j][k];
      dp[i+1][j+1][k] += dp[i][j][k];
    }
  }

  int ans = 0;
  REP(k, 2) ans += dp[N][K][k];
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    bool check = false;
    for (int i = 0; i < s.length(); i++)
    {
        if(i%2==0){
            if (s[i]=='L') check=true;
        }
        else{
            if(s[i]=='R') check =true;
        }
    }
    if(check) cout << "No"<<endl;
    else cout << "Yes"<<endl;
    
}

Measured memory_bytes: 256
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    ll fac[N],facinv[N];ll C(int n,int m){return n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void main()
	{
        fac[0]=1;fo(i,1,N-1) fac[i]=fac[i-1]*i%MOD;
        facinv[N-1]=invm(fac[N-1]);fd(i,N-1,1) facinv[i-1]=facinv[i]*i%MOD;
        int n=qread(),m=qread();if(n>m) swap(n,m);
        int ans=0;fo(i,1,n) add(ans, (MOD+1)/2*C(i+i,i)%MOD*C(n+m-i-i,n-i)%MOD );
        ans=ans*invm(C(n+m,n))%MOD;write(mm(ans+m));
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 15872
#include<stdio.h>

int main(){
  int i,j,A[1000],v,n,k;

  scanf("%d",&n);

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

  for(i=1;i<n;i++){
    for(k=0;k<n-1;k++){
    printf("%d ",A[k]);

  }
    printf("%d",A[n-1]);
    printf("\n");
    v=A[i];
    
  
  
    j=i-1;
    while((j>=0)&&(A[j]>v)){
      A[j+1]=A[j];
      j--;
      A[j+1]=v;}}
for(k=0;k<n-1;k++){
    printf("%d ",A[k]);

  }
 printf("%d",A[n-1]);
 printf("\n");
    
  
 return 0;
  
}



Measured memory_bytes: 2128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.function.BiConsumer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int a = in.nextInt();
			int b = in.nextInt();
			int ans = -1;
			int n = Math.max(a, b);
			for (int i = 0; i < n * 100; i++) {
				if ((int) (i * 0.08) == a && (int) (i * 0.1) == b) {
					ans = i;
					break;
				}
			}
			out.println(ans);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

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

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


Measured memory_bytes: 23380
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 3456;
int dp[MAXN];
vector<int> G[MAXN];

int main() {
    int N, T;
    scanf("%d %d", &N, &T);
    vector<pii> V;
    for (int i = 0; i < N; i++) {
        int A, B;
        scanf("%d %d", &A, &B);
        G[A].push_back(B);
    }
    for (int i = 0; i < MAXN; i++) {
        sort(G[i].rbegin(), G[i].rend());
    }
    int ans = 0;
    for (int A = 1; A < MAXN; A++) {
        for (int B : G[A]) {
            ans = max(ans, dp[T - 1] + B);
            for (int j = T - 1; j >= A; j--) {
                dp[j] = max(dp[j], dp[j - A] + B);
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18+50;
typedef vector<ll> vi;
ll cnt_pairs(ll x, vi &arr){ 
//quantidade de pares (a,b) tal que a*b<=x
//a*b<=x -> b<=x/a se a>0
//a*b<=x -> b>=x/a se a<0
//a==0 -> reduz para o caso a>0

ll ans=0;
ll n = arr.size();
	for(int i=0;i<n;i++){
		ll l=0,r=n-1;
		ll ret = -1;
		if(arr[i]>=0){
			while(l<=r){
				ll mid = (l+r)/2;
				if(arr[i]*arr[mid]<=x){
					ret=mid;
					l=mid+1;
				}else{
					r=mid-1;
				}
			}
			if(ret!=-1){
				ans+=(ret+1);

				if(arr[i]*arr[i]<=x)ans--;
			}

		}else{
			while(l<=r){
				ll mid = (l+r)/2;
				if(arr[i]*arr[mid]<=x){
					ret=mid;
					r=mid-1;
				}else{
					l=mid+1;
				}
			}

			if(ret!=-1){
				ans+=(n - ret);

				if(arr[i]*arr[i]<=x)ans--;
			}

		}
	}

	ans/=2; // double counting

	return ans;

}
int main(){
	ll n,k;
	cin>>n>>k;
	vi arr(n);
	for(int i=0;i<n;i++)
		cin>>arr[i];

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

	ll l=-inf,r=inf;
	ll ans=-1;


	while(l<=r){
		ll mid = (l+r)/2;
		if(cnt_pairs(mid,arr)<k){
			l=mid+1;
		}else{
			ans=mid;
			r=mid-1;
		}
	}

	cout<<ans<<"\n";
	

	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class  Main{

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);

		String s=sc.next();
		if(s.charAt(0)==s.charAt(1)&&s.charAt(1)==s.charAt(2))
			System.out.println("No");
		else
			System.out.println("Yes");



	}

}

Measured memory_bytes: 22228
#include<stdio.h>
int main(void)
{
	int n, i, j, k, c[4][13], y;
	char x;

	for (i = 0; i < 4; i++) {
		for (j = 0; j < 13; j++) {
			c[i][j] = 0;
		}
	}
	scanf("%d", &n);

	for (k = 0; k < n * 2; k++) {
		scanf("%c %d", &x, &y);
		if (x == 'S') {
			c[0][y - 1] = 1;
		}
		else if (x == 'H') {
			c[1][y - 1] = 1;
		}
		else if (x == 'C') {
			c[2][y - 1] = 1;
		}
		else if (x == 'D') {
			c[3][y - 1] = 1;
		}
	}

	for (i = 0; i < 4; i++) {
		for (j = 0; j < 13; j++) {
			if (c[i][j] == 0) {
				if (i == 0) {
					printf("S %d", j + 1);
				}
				else if (i == 1) {
					printf("H %d", j + 1);
				}
				else if (i == 2) {
					printf("C %d", j + 1);
				}
				else if (i == 3) {
					printf("D %d", j + 1);
				}
				printf("\n");
			}
		}
	}
	
	return(0);
}


Measured memory_bytes: 2080
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int odd[100001], even[100001];

int main(){
	int n;
	scanf("%d", &n);
	int max1 = 0, max2 = 0, max1_id, max2_id;
	for (int i = 0; i < n >> 1; ++i){
		int tmp1, tmp2;
		scanf("%d", &tmp1);
		scanf("%d", &tmp2);
		odd[tmp1]++, even[tmp2]++;
		if(odd[tmp1] > max1) max1++, max1_id = tmp1;
		if(even[tmp2] > max2) max2++, max2_id = tmp2;
	}
	sort(odd, odd + 100001, greater<int>());
	sort(even, even + 100001, greater<int>());
	if(odd[0] == odd[1] || even[0] == even[1] || max1_id != max2_id){
		printf("%d\n", n - odd[0] - even[0]);
		return 0;
	}
	printf("%d\n", odd[0] + even[1] <= even[0] + odd[1] ? n - even[0] - odd[1] : (n - odd[0] - even[1]));
	return 0;
}

Measured memory_bytes: 896
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    A,B=map(int, input().replace('.', '').split())
    print(A*B//100)






main()



Measured memory_bytes: 9988
class Node():
    def __init__(self, id, left, right, parent=-1, degree=-1, type=None):
        self.id = id
        self.left = left
        self.right = right
        self.parent = parent
        self.degree = degree
        self.type = type
        
    def show(self):
        print 'node %d: parent = %d, degree = %d, %s' % (self.id, self.parent, self.degree, self.type)

class Stack():
    def __init__(self):
        self.el = []
    def add(self, el):
        self.el.append(el)
    def pop(self):
        return self.el.pop()
        
def hasChild(x):
    if x == -1:
        return 0
    return 1


### input ###
dict = {}
a = []
n = int(raw_input())
for i in range(n):
    tmp = map(int, raw_input().split())
    dict[tmp[0]] = Node(tmp[0], tmp[1], tmp[2], degree=hasChild(tmp[1]) + hasChild(tmp[2]))

for i in range(n):
    a.append(dict[i])

for i in range(n):
    if not a[i].degree:
        continue
    a[a[i].left].parent = a[i].id
    a[a[i].right].parent = a[i].id

rootId = -1
for i in range(n):
    if a[i].parent != -1 and a[i].degree == 0:
        a[i].type = 'leaf'
    elif a[i].parent != -1 and a[i].degree > 0:
        a[i].type = 'internal node'
    else:
        a[i].type = 'root'
        rootId = a[i].id

### preorder ###
print 'Preorder'
pos = rootId
st = Stack()
ans = []
while True:
    ans.append(pos)
    if len(ans) == n:
        break
    if a[pos].degree > 0:
        if a[pos].left != -1 and a[pos].right != -1:
            st.add(a[pos].right)
        if a[pos].left != -1:
            pos = a[pos].left
        elif a[pos].left == -1:
            pos = a[pos].right
    elif a[pos].degree == 0:
        pos = st.pop()
print '', ' '.join(map(str, ans))

### inorder ###
print 'Inorder'
pos = rootId
st = Stack()
ans = []
while True:
    if a[pos].left != -1 and a[pos].left not in ans:
        if a[pos].right != -1:
            st.add(a[pos].right)
        st.add(pos)
        pos = a[pos].left
    elif a[pos].left == -1 and a[pos].right != -1 and a[pos].right not in ans:
        ans.append(pos)
        pos = a[pos].right
    else:
        ans.append(pos)
        if len(ans) == n:
            break
        pos = st.pop()    
print '', ' '.join(map(str, ans))

### postorder ###
print 'Postorder'
pos = rootId
st = Stack()
ans = []
while True:
    if a[pos].left != -1 and a[pos].left not in ans:
        st.add(pos)
        if a[pos].right != -1:
            st.add(a[pos].right)
        pos = a[pos].left
    elif a[pos].left == -1 and a[pos].right != -1 and a[pos].right not in ans:
        st.add(pos)
        pos = a[pos].right
    else:
        ans.append(pos)
        if len(ans) == n:
            break
        pos = st.pop()
print '', ' '.join(map(str, ans))

Measured memory_bytes: 6540
#!/usr/bin/env php
<?php
// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
function solve(string $S)
{
    $white = preg_replace('/[^ACGT]/', ' ', $S);
    foreach (explode(' ', $white) as $item) {
        $c[] = strlen($item);
    }
    echo max($c).PHP_EOL;
}

fscanf(STDIN, '%s', $S);
solve($S);



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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
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);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    ll N;
    while(cin >> N) {
        vector<vector<ll>> dp(4,vector<ll>(N+1,0));
        for(int i = 0; i <= min(1000LL,N); ++i) dp[0][i]++;
        for(int k = 1; k < 4; ++k) {
            for(int i = 0; i <= N; ++i) {
                for(int j = 0; j <= 1000; ++j) {
                    if(i+j<=N) dp[k][i+j] += dp[k-1][i];
                }
            }
        }
        cout << dp[3][N] << endl;
    }



    return 0;
}



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

int main() {
	int N;
	cin >> N;
	long long ans = 0;
	vector<vector<int>> data(N, vector<int>(N)); 
	vector<vector<int>> bdata(N, vector<int>(N,false));
	for (int i = 0;i<N;++i) {
		for (int j = 0;j<N;++j) {
			cin >> data[i][j];
		}
	}
	for (int i = 0;i<N;++i) {
		for (int j = 0;j<N;++j) {
			for (int k = 0;k<N;++k) {
				if (i == j || i==k || j == k) {
					continue;
				}
				if (data[i][k] > data[i][j] + data[j][k]) {
					cout << -1 << endl;
					return 0;
				}
				if (data[i][k] == data[i][j] + data[j][k]) {
					bdata[i][k] = true;
				}
			}
		}
	}  
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= i; j++) {
			if (bdata[i][j] == false) {
				ans += data[i][j];
			}

		}
	}
	cout << ans<<endl;
	return 0;
}

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

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if(a > b)
		swap(a,b);
	if(b > c)
		swap(b,c);
	if(a > b)
		swap(a,b);
	cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
vector<pair<string,int>> l;
vector<string> my;

bool input(){
  l.clear();
  my.clear();
  int n,m;
  cin>>n>>m;
  if(n==0)return false;
  for(int i=0;i<n;i++){
    string s;
    int nn;
    cin>>s>>nn;
    l.push_back(make_pair(s,nn));
  }
  for(int i=0;i<m;i++){
    string s;
    cin>>s;
    my.push_back(s);
  }
  return true;
}

int judge2(string a,string b){
  for(int i=0;i<a.size();i++){
    if(b[i] == '*')continue;
    if(a[i] == b[i])continue;
    return false;
  }
  return true;
}

int judge(string s){
  for(auto i:l){
    if(judge2(s,i.first)){
      return i.second;
    }
  }
  return 0;
}

int solve(){
  int ans = 0;
  for(int i=0;i<my.size();i++){
    ans += judge(my[i]);
  }
  return ans;
}

int main(){
  while(input()){
    cout<<solve()<<endl;
  }
}

Measured memory_bytes: 1276
#include <stdio.h>

int main(void)
{
	int a,b,c,i;
	
	while(scanf("%d %d",&a,&b)!=EOF)
	{
		c = a + b;
		for(i=1;c >= 10;i++)
		{
			c = c / 10;
		}
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    double a, b, c, d;
    /*a:第１都市の北緯
      b:第１都市の東経
      c:第２都市の北緯
      d:第２都市の東経*/
    
    while(true){
        cin >> a >> b >> c >> d;
        if(a == -1.0 && b == -1.0 && c == -1.0 && d == -1.0) break;

        double tha = M_PI * a / 180;
        double thb = M_PI * b / 180;
        double thc = M_PI * c / 180;
        double thd = M_PI * d / 180;

        double d = acos(sin(tha) * sin(thc) + cos(tha) * cos(thc) * cos(thd - thb));
        cout << (int)(6378.1 * d + 0.5) << endl;
    }
    return 0;
}



Measured memory_bytes: 3580
// In the Name of God

#include <bits/stdc++.h>

using namespace std;

#define	ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(a) int(a.size())
#define all(v) v.begin(), v.end()
#define bpc(v) __builtin_popcountll(v)
#define itr iterator
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; --i)
#define ub upper_bound
#define lb lower_bound

const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const int mod = 1e9 + 7;
const double eps = 1e-15;
const int pw = 257;

int main() {
	#ifdef Madi
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
	#endif

	ios_base :: sync_with_stdio(false); cin.tie(NULL);

	string n;
	cin >> n;
	int ans = 0;
	rep(i, 0, sz(n) - 1)
		ans += int(n[i] - '0');
	if (ans == 1)
		ans *= 10;

	cout << ans;
	return 0;          
}

Measured memory_bytes: 256
#abc121_c
N, M = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]
AB= sorted(AB,key=lambda x:x[0])
ans = 0
for yen,num in AB:
    if num < M:
        ans += num*yen
        M-=num
    else:
        ans += M*yen
        break
print(ans)



Measured memory_bytes: 29788
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n];
		int[] q = new int[n];
		int[] array = new int[n];
		for (int i = 0; i < p.length; i++) {
			p[i] = sc.nextInt();
		}
		for (int i = 0; i < q.length; i++) {
			q[i] = sc.nextInt();
		}
		for (int i = 0; i < array.length; i++) {
			array[i] = i + 1;
		}
		int num = 0;
		int pNum = -1;
		int qNum = -1;
		do {
			num++;
			if (Arrays.equals(array, p)) {
				pNum = num;
			} 
			
			if (Arrays.equals(array, q)) {
				qNum = num;
			}
		} while (nextPermutation(array));
		System.out.println(Math.abs(pNum - qNum));
		sc.close();
	}
 
	//順列全列挙
	//nが10を超えてくると間に合わなくなる
	static boolean nextPermutation(int[] array) {
		// Find longest non-increasing suffix
		int i = array.length - 1;
		while (i > 0 && array[i - 1] >= array[i])
			i--;
		// Now i is the head index of the suffix
 
		// Are we at the last permutation already?
		if (i <= 0)
			return false;
 
		// Let array[i - 1] be the pivot
		// Find rightmost element that exceeds the pivot
		int j = array.length - 1;
		while (array[j] <= array[i - 1])
			j--;
		// Now the value array[j] will become the new pivot
		// Assertion: j >= i
 
		// Swap the pivot with j
		int temp = array[i - 1];
		array[i - 1] = array[j];
		array[j] = temp;
 
		// Reverse the suffix
		j = array.length - 1;
		while (i < j) {
			temp = array[i];
			array[i] = array[j];
			array[j] = temp;
			i++;
			j--;
		}
 
		// Successfully computed the next permutation
		return true;
	}
}

Measured memory_bytes: 36656
#include <iostream>
using namespace std;
typedef long long ll;

const ll INF = 1000000000000009;

int main()
{
    int n;
    cin >> n;
    ll a[200005];
    for(int i = 0; i < n; i++) cin >> a[i];
    ll s[200005];
    s[0] = 0;
    ll ans = INF;
    for(int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i - 1];
    for(int i = 2; i < n - 1; i++){
        ll l = lower_bound(s + 1, s + i - 1, (s[i] + 1) / 2) - s;
        ll lmax = max(s[l], s[i] - s[l]), lmin = min(s[l], s[i] - s[l]);
        if(l > 1){
            lmax = min(lmax, max(s[l - 1], s[i] - s[l - 1]));
            lmin = max(lmin, min(s[l - 1], s[i] - s[l - 1]));
        }
        ll r = lower_bound(s + i + 1, s + n - 1, (s[n] + s[i] + 1) / 2) - s;
        ll rmax = max(s[r] - s[i], s[n] - s[r]), rmin = min(s[r] - s[i], s[n] - s[r]);
        if(r > i + 1){
            rmax = min(rmax, max(s[r - 1] - s[i], s[n] - s[r - 1]));
            rmin = max(rmin, min(s[r - 1] - s[i], s[n] - s[r - 1]));
        }
        ans = min(ans, max(lmax, rmax) - min(lmin, rmin));
    }
    cout << ans << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x; cin>>x;
    while(true){
        bool ng = false;
        for(ll i=2; i*i<=x; i++){
            if (x%i==0){
                ng = true;
                break;
            }
        }
        if (!ng){
            cout<<x<<endl;
            break;
        }
        x++;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int N,now,prev,page[50];
	while (cin>>N,N) {
		prev=0;
		for (int i=0; i<N; i++) cin>>page[i];
		for (int i=0; i<N; i++) {
			if (i&&i-N+1) {
				if (page[i-1]+1==page[i]&&page[i]+1!=page[i+1]) {
					cout<<'-'<<page[i];
				} else if (page[i-1]+1!=page[i]&&page[i]+1==page[i+1]) {
					cout<<' '<<page[i];
				} else if (page[i-1]+1!=page[i]&&page[i]+1!=page[i+1]) {
					cout<<' '<<page[i];
				}
			} else if (i==0) {
				cout<<page[0];
			} else {
				if (page[i-1]+1==page[i]) {
					cout<<'-'<<page[i];
				} else {
					cout<<' '<<page[i];
				}
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

// 素因数分解 pair.firstで素数、pair.secondで対応する指数
vector<pair<long long, long long> > prime_factorize(long long n) {
	vector<pair<long long, long long> > res;
	for (long long 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;
}

const int MAX = 210000;

//二項係数を求める前処理 テーブルを作る　O(n)
// facは階乗
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

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

	int n, k;
	cin >> n >> k;
	COMinit();

	int r = n - k;

	// i回
	Rep(i, 1, k + 1) {
		ll ans = 0;

		ll tmp = 0;
		// 始めに青の分割
		// kCi
		tmp = COM(k - 1, i - 1);

		if (r == 0) {
			if (i == 1) cout << 1 << endl;
			else cout << 0 << endl;
			continue;
		}

		//cout << tmp << endl;

		// 次に赤の分割
		// i - 1, i, i + 1の3パターンある
		ll redtmp = 0;
		// i - 1:
		if (r >= i - 1 && i != 1)
			redtmp += COM(r - 1, i - 2);
		// i:
		if (r >= i)
			redtmp += COM(r - 1, i - 1) * 2;
		// i + 1:
		if (r >= i + 1)
			redtmp += COM(r - 1, i);

		ans = tmp * redtmp;
		cout << ans % mod << endl;
	}

	return 0;
}


Measured memory_bytes: 5248
#include <stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int res1=a+b;
    int res2=a-b;
    int res3=a*b;
    if(res1 >= res2 && res1>=res3)
        printf("%d\n",res1);
    else if(res2 >= res1 && res2 >= res3)
        printf("%d\n",res2);
    else if(res3 >= res1 && res3 >= res2)
        printf("%d\n",res3);
    return 0;
}

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


using namespace std;

typedef long long ll;

const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}



int main(void){
	int r, d, x;

	cin >> r >> d >> x;

	for (int i = 0; i < 10; i++){
		x = r * x - d;
		cout << x << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,x,y;cin>>a>>b>>c>>x>>y;
    ll ans = a*x + b*y;
    if(x>y){
        ans = min(c*y*2+a*(x-y), ans);
        ans = min(ans, c*x*2);
    } else{
        ans = min(c*x*2+b*(y-x), ans);
        ans = min(ans, c*y*2);
    }
    cout<<ans<<endl;

}

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

int main(){
  string s;
  cin >> s;
  int a, z;
  bool A = false;
  for(int i = 0; i < s.size() ; i++){
    if(s[i] == 'A' && A == false){
      a = i;
      A = true;
    }
    if(s[i] == 'Z'){
      z = i;
    }
  }
  cout << z - a + 1 << endl;
}


Measured memory_bytes: 640
"""
- https://atcoder.jp/contests/abc136/tasks/abc135_b
- reg:2≤N≤50
"""
n = int(input())
p = [int(e) for e in input().split()]

z = [i for i in range(n) if p[i] != (i+1)]
ans = "YES" if len(z) <= 2 else "NO"
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
  int n,i,x=0,max=0;
  char c;
  scanf("%d\n",&n);
  for (i=0;i<n;i++){
    scanf("%c",&c);
    if (c=='I'){
      x++;
      if (x>max) max=x;
    }else x--;
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
N = int(input())
X = input()
X_10 = int(X, 2)
popcount_X = X.count("1")
popcount_X_plus = popcount_X + 1
popcount_X_minus = popcount_X - 1
f_plus = X_10 % popcount_X_plus
f_minus = X_10 % popcount_X_minus if popcount_X_minus != 0 else 0

def popcount(n):
  return bin(n).count("1")

def f(n):
  if n == 0:
    return 0
  return n % popcount(n)

for i in range(N):
  j = N - (i + 1)
  n = 0
  ans = 1
  
  if X[i] == '0':
#    n = (f_plus + (2**j % popcount_X_plus)) % popcount_X_plus
    n = (f_plus + pow(2, j, popcount_X_plus)) % popcount_X_plus
  else:
    if popcount_X_minus == 0:
      print(0)
      continue
    else:
#      n = (f_minus - (2**j % popcount_X_minus) + popcount_X_minus) % popcount_X_minus
      n = (f_minus - pow(2, j, popcount_X_minus) + popcount_X_minus) % popcount_X_minus
  
  while n > 0:
    n = f(n)
    ans += 1
  print(ans)

Measured memory_bytes: 82384
#include <stdio.h>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;

struct item{
    int i;
    int d;
    item(int i, int d){
        this->i = i;
        this->d = d;
    }
};

int n;
vector<int> g[200001];

item far(int i){
    queue<item> q;
    bool b[200001];
    for(int k = 0; k <=n; k++){
        b[k] = false;
    }

    q.push(item(i, 0));
    int f = 0;
    int d = 0;
    while(!q.empty()){
        item t = q.front();
        q.pop();
        b[t.i] = true;
        f = t.i;
        d = t.d;
        for(int i = 0; i < g[t.i].size(); i++){
            if(!b[g[t.i][i]]){
                q.push(item(g[t.i][i], t.d + 1));
            }
        }
    }

    return item(f, d);
}

int main(){
    scanf("%d", &n);
    for(int i = 0; i < n - 1; i++){
        int a;
        int b;
        scanf("%d %d", &a, &b);
        g[a].push_back(b);
        g[b].push_back(a);
    }

    item t = far(1);
    t = far(t.i);
    int l = t.d;
    
    if(l % 3 == 1){
        printf("Second");
    }else{
        printf("First");
    }

    return 0;
}

Measured memory_bytes: 13836
array = gets.chomp.split(' ')
iti = gets.chomp.split(' ')
kyori = []
result = 0
for i in 0..(array[1].to_i - 1 ) do
    if i == (array[1].to_i - 1 )
        kyori.push((iti[i].to_i-array[0].to_i).abs + iti[0].to_i)
    else
        kyori.push((iti[i].to_i-iti[i+1].to_i).abs)
    end
end
kyori.sort!
for n in 0 ..(array[1].to_i - 2) do
    result += kyori[n]
end
puts result


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

namespace abc049_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            string[] output = new string[x[0]];
            for (int i = 0; i < x[0]; i++)
            {
                output[i] = Console.ReadLine();
            }
            for (int i = 0; i < x[0]; i++)
            {
                Console.WriteLine(output[i]);
                Console.WriteLine(output[i]);
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 2904
#include <iostream>
#include <string>
using namespace std;
int main()
{
        int upCase[26],ans = 0;
        for (int i = 0; i < 26; i++)
                upCase[i] = 0;
        string s;
        cin >> s;
        for (int i = 0; i < s.size(); i++)
                upCase[s[i] - 'A']++;
        for (int i = 0; i < 26; i++)
                if (upCase[i] == 2)
                        ans++;
        if (ans == 2)
                cout << "Yes" << endl;
        else
                cout << "No" << endl;
        return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

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

fn main(){
    let line = read_as_vec::<usize>();
    let (n, a, b) = (line[0], line[1], line[2]);

    let mut ans: usize = 0;
    let turns = n/(a+b);
    ans += turns*a;

    let rest_balls = n - turns*(a+b);
    ans += cmp::min(a, rest_balls);

    println!("{}", ans);
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace B_NK2
{
    class MainClass
    {

        static int[] n;
        static long[] d;

        public static void Main(string[] args)
        {
            long div = 998244353;
            n = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            d = Array.ConvertAll(ReadLine().Split().ToArray(), long.Parse);
            var dl = d.ToList();

            if (dl[0] != 0)
            {
                WriteLine(0);
                return;
            }
            dl.RemoveAt(0);
            dl.Sort();
            if (dl[0] != 1)
            {
                WriteLine(0);
                return;
            }
            long ans = 1;
            long dist = 1;

            long beforecnt = 1;
            long nextcnt = 0;

            for (int i = 0; i < n[0] - 1; i++)
            {
                if (dl[i] != dist && dl[i] != dist + 1)
                {
                    WriteLine(0);
                    return;
                }
                else if (dl[i] == dist)
                {
                    ans = ans * beforecnt % div;
                    nextcnt++;
                }
                else
                {
                    beforecnt = nextcnt;
                    nextcnt = 1;
                    dist = dl[i];
                    ans = ans * beforecnt % div;
                }


            }
            WriteLine(ans);
        }
    }
}


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


#define fi first
#define se second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define el '\n'

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int N = 2e5 + 10;

int n;
ll ar[N];
ll ans;

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

    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> ar[i];
    }
    sort(ar + 1, ar + n + 1, greater<ll>());
    int sisa = n;
    for (int i=1;i<=n;i++){
        if (sisa){
            sisa--;
            ans += ar[i];
            if (sisa){
                sisa--;
                ans += ar[i];
            }
        }
        if (!sisa) break;
    }
    cout << ans - ar[1] << el;

    return 0;
}

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

int main(){
  int n,k, q;cin >>n>> k >>q;
  int a[n];
  for(int i=0;i<n;i++){
    a[i]=k-q;
  }
  for(int i=0;i<q;i++){
    int j;cin >>j;
    a[j-1]=a[j-1]+1;
  }
  for(int i=0;i<n;i++){
    if(a[i]>0){
      cout << "Yes" <<endl;
    }else{
      cout << "No" <<endl;
    }
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> answer(N);
  
  for(int i = 0; i < 2 * M; i++){
    int a;
    cin >> a;
    a -= 1;
    answer.at(a) += 1;
  }
  for(int j = 0; j < N; j++){
  cout << answer.at(j) << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
using namespace std;
int main(){
  int n;
  int a[251];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=n-1;i>0;i--){
    cout<<a[i]<<' ';
  }
  cout<<a[0]<<endl;
  return(0);
}

Measured memory_bytes: 3016
#include <stdio.h>

int main(int argc,char*argv[]){

    int a, b, c, x;

    while(c != 1){

    scanf("%d  %d",&a, &b);

    if(a<1 || a>100 || b<1 || b>100){
        c = 0;
    }else{
        x = a * b;
        c = 1;
        printf("%d",x);
    }


    }

}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,k;
	set<int> s;
	cin>>a>>b>>k;
	
	if(k>b-a+1){
		for(int i=a;i<=b;i++){
			cout<<i<<endl;
		}
		return 0;
	}
	for(int i=a;i<a+k;i++){
		s.insert(i);
		//cout<<i<<endl;
	}
	for(int i=b-k+1;i<=b;i++){
		s.insert(i);
		//cout<<i<<endl;
	}
	for(auto it=s.begin();it!=s.end();it++){
		cout<<*it<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define For(i,n) for(int i=0;i<n;i++)
#define mem(a,b) memset(a,b,sizeof(a))
#define int long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define MAXN 1000001

int a[MAXN], b[MAXN];
int dp[MAXN];
int fen[MAXN];
int n;
void update(int i, int add)
{
	while (i <= n)
	{
		fen[i] = max(fen[i], add);
		i = i + (i & (-i));
	}
}

int query(int i)
{
	int s = 0;
	while (i > 0)
	{
		s = max(s, fen[i]);
		i = i - (i & (-i));
	}
	return s;
}
int32_t main()
{
	cin >> n;

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

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

	for (int i = 0; i < n; i++)
	{
		dp[i] = query(a[i] - 1) + b[i];
		update(a[i], dp[i]);
	}
	cout << *max_element(dp, dp + n);

}


Measured memory_bytes: 14080
s = int(input())
a = []
nun = 1
for i in range(1,1000000):
    a.append(s)
    if s%2 ==0:
        s=s/2
    else:
        s=3*s+1
    nun += 1
    if s in a:
        break
    i += 1

print(int(nun))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MAX = 1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    ll temp, ans = 1;
  	for (int i = 0; i < n; ++i)
    {
        cin >> temp;
        if (temp == 0) ans = 0;
        else if (ans > MAX / temp) ans = -1;
        else if (ans > 0) ans *= temp;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3612
N = int(input())
A = list(map(int,input().split()))
n = 0
F = 0

while 1:
    #すべてが偶数か確認
    for i in range(N):
        if A[i] % 2 == 0:
            continue
        else:
            F = 1
    
    if F == 1 : break 

    for i in range(N):
        A[i] = A[i]/2
    n += 1


print(n)

Measured memory_bytes: 3060
import java.io.*;
public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(
				new InputStreamReader (System.in));
		String str=br.readLine();
		//String[] str = line.split(" ");
		int time=Integer.parseInt(str);
		int hour=time/3600;
		int min=(time-hour*3600)/60;
		int sec=time%60;
		System.out.println(hour+":"+min+":"+sec);
	}
}

Measured memory_bytes: 24424
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};

int main () {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n-k) {
        if (a[i] < a[i+k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

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

int main (){
  int N; cin >> N;
  bool res = false;
  
  for (int i=0; i<=N/4; i++) {
    for (int j=0; j<=N/7; j++) {
      int sum = i*4 + j*7;
      if (sum == N) res=true;
    }
  }
      if (res) cout << "Yes" << endl;
      else cout << "No" << endl;
}

Measured memory_bytes: 256