akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	ans := 1
	for ans <= N {
		ans *= 2
	}
	out(ans / 2)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int M = 1000000007;
const double eps = 1e-9;
const double PI = acos(-1);
const int oo = 1000000000;
#define pb push_back
int n,v[201],an=-1;
char g[201][201];


void go(int u){
	bool vis[201]={};
	v[u]=0;
	queue<int> q;
	q.push(u);
	vis[u]=true;
	int mx=0;
	while(!q.empty()){
		int u=q.front();
		mx=max(mx, v[u]);
		q.pop();
		for(int i=0; i<n; ++i){
			if(g[u][i] && !vis[i]){
				vis[i]=true;
				v[i]=v[u]+1;
				q.push(i);
			}
		}
	}
	bool win=1;
	for(int i=0; i<n; ++i)
		for(int j=0; j<n; ++j)
			if(g[i][j] && abs(v[i]-v[j])!=1)
				win=0;
	if(win)
		an=max(an, mx+1);
}

int main(){
	cin>>n;
	for(int i=0; i<n; ++i){
		scanf("%s", g[i]);
		for(int j=0; j<n; ++j)
			g[i][j]-='0';
	}
	for(int i=0; i<n; ++i)
		go(i);
	cout<<an<<endl;
	return 0;
}

Measured memory_bytes: 256
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
B = [0] * N
for i in range(Q):
  B[A[i]-1] += 1
for j in range(N):
  if B[j] <= Q - K:
    print('No')
  else:
    print('Yes')

Measured memory_bytes: 8672
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  rep(i, 1000) {
    char c[3];
    c[0] = '0' + (i / 100);
    c[1] = '0' + (i % 100) / 10;
    c[2] = '0' + (i % 10);
    int keta = 0;
    rep(j, s.size()) {
      if(s[j] == c[keta]) {
        if(keta == 2) {
          ans++;
          break;
        } else {
          keta++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,s,d,f,g,ave;
  scanf("%d",&a);
scanf("%d",&s);
scanf("%d",&d);
scanf("%d",&f);
scanf("%d",&g);

 if(a>39)
   {
     a=a;
   }
 else{
   a=40;
 }
if(s>39)
   {
     s=s;
   }
 else{
   s=40;
 }
 
if(d>39)
   {
     d=d;
   }
 else{
   d=40;
 }

if(f>39)
   {
     f=f;
   }
 else{
   f=40;
 }
if(g>39)
   {
     g=g;
   }
 else{
   g=40;
 }



ave=(a+s+d+f+g)/5;
 printf("%d\n",ave);
 return 0;
}

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

using namespace std;

constexpr int MOD = 1e9+7;

int main() {
    int N,M; cin >> N >> M;
    vector<bool> stairs(N+2, true);
    //if i-th stair is broken, then stairs[i] = false
    //N+1/N+2 th stairs do not exsist, so stairs[N+1] = stairs[N+2] = false
    stairs[N+1] = false; stairs[N+2] = false;

    int a;
    for(int i=0;i<M;i++) {
        cin >> a;
        stairs[a] = false;
    }
    
    vector<int> count(N+1,0);
    // count[i] = the number of ways to step on i-th stair.
    // if stairs[i] = false, count[i] should be 0

    count[0] = 1;
    for(int i=0;i<N;i++) {
        if(stairs[i+1]) {
            count[i+1] += count[i];
            count[i+1] %= MOD;
        }
        if(stairs[i+2]) {
            count[i+2] += count[i];
            count[i+2] %= MOD;
        }
    }

    cout << count[N] << endl;
    return 0;
}


Measured memory_bytes: 640
//23
#include<iostream>
#include<complex>
#include<vector>
#include<cmath>

using namespace std;

typedef complex<double> P;

int main(){
  for(int n;cin>>n,n;){
    vector<P> v(n);
    for(int i=0;i<n;i++){
      int x,y;
      cin>>x>>y;
      v[i]=P(x,y);
    }
    P c=P(0,0),p(0,-1);
    double l=0;
    while(!v.empty()){
      double ma=9;
      double md=1<<30;
      int x;
      for(int i=0;i<v.size();i++){
	double ca=(arg(c-p)-arg(v[i]-c));
	if(ca<0){
	  ca+=acos(-1)*2;
	}
	double cd=abs(v[i]-c);
	if(ca<ma||ca==ma&&cd<md){
	  ma=ca;
	  md=cd;
	  x=i;
	}
      }
      l+=md;
      p=c;
      c=v[x];
      v.erase(v.begin()+x);
    }
    cout.precision(1);
    cout<<fixed<<l<<endl;
  }
  return 0;
}

Measured memory_bytes: 1364
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main{
	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		try{

			//数値読み取る。
			List<Integer> list = new ArrayList<Integer>();
			int intSum = 0;
			while(true){
				String[] strLine = insBR.readLine().split("");
				if(!"0".equals(strLine[0])){
					for(int j = 0; j < strLine.length; j++){
						intSum += Integer.parseInt(strLine[j]);
					}
				}else{
					break;
				}
				list.add(intSum);
				intSum = 0;
			}

			//出力。
			for(int i = 0; i < list.size(); i++){
				System.out.println(list.get(i));
			}

		}catch(IOException e){
			e.printStackTrace();
		}catch(NumberFormatException e){
			e.printStackTrace();
		}
	}

}



Measured memory_bytes: 25556
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
constexpr long long mod = 1e9 + 7;

long long extgcd(long long a, long long b, long long &x, long long &y){
  //a*x - b*y = gcd(a, b)
  long long d = a;
  if(b){
    d = extgcd(b, a%b, y, x);
    y -= (a / b)*x;
  }else{
    x = 1;
    y = 0;
  }
  return d;    
}

long long combination(long long n, long long k){
  if(n < k) return 0;
  long long ret = 1LL;
  for(long long i = 0; i < k; ++i){
    ret *= (n-i)%mod;
    ret %= mod;
  }
  long long d = 1LL;
  for(long long i = 1; i <= k; ++i){
    d *= i%mod;
    d %= mod;
  }
  long long d_inv, y;
  extgcd(d, mod, d_inv, y);
  d_inv %= mod;
  d_inv += mod;
  d_inv %= mod;
  //cout << ret << " " << d << " " << d_inv << " " << d*d_inv%mod << endl;
  assert((d*d_inv)%mod == 1);
  ret *= d_inv%mod;
  ret %= mod;
  return ret;
}

int main(){
  long long N, D, X;
  while(cin >> N >> D >> X, N){
    vector< vector<long long> > DP(N+1, vector<long long>(N+1,0));
    DP[0][0] = 1;
    for(int i = 1; i <= N; ++i){
      long long t = 0;
      for(int j = 0; j <= N; ++j){
        if(j >= X){
          t -= DP[i-1][j-X];
          t %= mod;
          t += mod;
          t %= mod;
        }
        DP[i][j] = t;
        t += DP[i-1][j];
        t %= mod;
      }
    }
    long long ans = 0;
    for(int i = 1; i <= N; ++i){
      //cout << DP[i][N] << " ";
      //cout << combination(D, i) << endl;
      ans += combination(D, i)*DP[i][N]%mod;
      ans %= mod;
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 34164
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static int mod = (int) (1e9+7),n;
	static long cf = 998244353;
    static final int MAX = (int) 1e6;
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static int col = 20;
    public static long[] Bit;
    public static long[] fact,inv;
    public  static int[] prime; 
    public static long[] seg,lazy;
	public static FastReader sc = new FastReader();
	public static void main(String[] args) {
	//	Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();
		long sub = Math.min(a, k);
		a-=sub;
		k-=sub;
		sub = Math.min(k, b);
		b-=sub;
		    out.print(a+" "+b);
		out.close();
	}
	 
	
}

Measured memory_bytes: 21844
def main():
    n = int(input())

    if str(n)[-1] == '3':
        res = 'bon'
    elif str(n)[-1] in ['0', '1', '6', '8']:
        res = 'pon'
    else:
        res = 'hon'
    
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
   long long int e,o,ans;
   //vector<long long int> v,v1,v2;
   //vector< pair <long long int,long long int> >p,p1,p2;
   cin>>e>>o;
   ans=(e*(e-1))/2;
   ans=ans+((o*(o-1))/2);
   cout<<ans<<endl;
   return 0;
}


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


void solve(){
    int n, l;
    cin >> n >> l;
    vector<string> vs;
    for(int i = 0; i < n; i++){
        string s; cin >> s;
        vs.push_back(s);
    }
    sort(vs.begin(), vs.end());
    for(string s : vs)
        cout << s;
}

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

    bool multitest = false;
//    multitest = true;
    if(multitest){
        int t; cin >> t;
        while(t--)
            solve();
    }
    else
        solve();
}






Measured memory_bytes: 3596
#include <cstring>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
#define X first
#define Y second
typedef long long LL;
typedef pair<int, int> pii;

const int N = 3e5 + 100;
int ans[N];
int main() {
    int K, n;
    cin >> K >> n;
    if(K % 2 == 0) {
        printf("%d", K / 2);
        for(int i = 2; i <= n; i ++) 
            printf(" %d", K);
        puts("");
    } else {
        for(int i = 1; i <= n; i ++) ans[i] = K / 2 + 1;
        int c = n / 2;
        int tail = n;
        while(c --) {
            ans[tail] --;
            if(ans[tail] == 0) tail --;
            else if(tail != n) {
                for(int i = tail + 1; i <= n; i ++) ans[i] = K;
                tail = n;
            }
        }
        for(int i = 1; i <= tail; i ++) 
            printf("%d%c", ans[i], i == tail ? '\n' : ' ');
    }
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,q,l,r;
  cin>>n>>m>>q;
  vector<vector<int>> d(n+1,vector<int>(n+1,0));
  for(int i=0;i<m;i++){
    cin>>l>>r;
    d[l][r]++;
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      d[i][j]+=d[i][j-1];
    }
  }
  for(int i=0;i<q;i++){
    cin>>l>>r;
    int c=0;
    for(int j=l;j<=r;j++){
      c+=d[j][r]-d[j][l-1];
    }
    cout<<c<<endl;
  }
}

Measured memory_bytes: 1920
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int L,R,d;cin>>L>>R>>d;
    int ans = 0;
    for(int i=L;i<=R;i++){
        if(i%d==0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define umap unordered_map 
#define uset unordered_set 

#define F0r(i, a, b) for(int i=a; i<(b); i++)
#define For(i, a)    for(int i=0; i<(a); i++)
#define F0rb(i,a,b)  for(int i = (b); i >= a; i--)
#define Forb(i,a)    for(int i = (a); i >= 0; i--)

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

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

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x)  __builtin_ctzll(x)
#define all(x) x.begin(), x.end()
#define ins insert
#define w(x) int x; cin >> x ; while(x--)
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';



int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int n;
	cin >> n;
	int ac,wa,tle,re;
	ac = wa = tle = re = 0;
	
	For(i,n){
		string s = "";
		cin >> s;
		if(s == "AC") ac++;
		if(s == "WA") wa++;
		if(s == "TLE") tle++;
		if(s == "RE") re++;
	}
	cout << "AC x " << ac << nl; 
	cout << "WA x " << wa << nl; 
	cout << "TLE x " << tle << nl; 
	cout << "RE x " << re << nl; 
	return 0;
}


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

typedef long long ll;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> mp(h);
    int c = 0;
    vector<pair<int, int>> v;
    for (int i = 0; i < h; i++) {
        cin >> mp[i];
        for (int k = 0; k < w; k++)
            if (mp[i][k] == '#') {
                v.push_back({i, k});
                c++;
            }
    }
    int dx[] = {1, -1, 0, 0};
    int dy[] = {0, 0, 1, -1};
    int ans = 0;
    if (c == h*w) {
        cout << 0;
        return 0;
    }
    while (++ans) {
        vector<pair<int, int>> new_v;
        for (int i = 0; i < (int)v.size(); i++) {
            int cur_h = v[i].first;
            int cur_w = v[i].second;
            for (int i = 0; i < 4; i++) {
                int new_h = cur_h + dx[i];
                int new_w = cur_w + dy[i];
                if (new_h < 0 || h <= new_h)
                    continue;
                if (new_w < 0 || w <= new_w)
                    continue;
                if (mp[new_h][new_w] != '#') {
                    mp[new_h][new_w] = '#';
                    new_v.push_back({new_h, new_w});
                    c++;
                }
            }
        }
        v = new_v;
        if (c == h*w)
            break;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 15076
///17571@nith.ac.in @Ankit Verma
#include <bits/stdc++.h>
using namespace std;
#define ff          first
#define ss          second
#define pb          push_back
#define MP          make_pair
#define int         long long
#define ll          long long
#define inf         0x3f3f3f3f
#define MOD         1000000007
#define ld          long double
#define eb          emplace_back
#define pii         pair<int,int>
#define ull         unsigned long long
#define all(v)      v.begin(), v.end()
#define f(i,x,n)    for(int i=x;i<n;i++)
#define fr(i,x,n)   for(int i=x;i>=n;i--)
#define fastio      ios::sync_with_stdio(false)

#define n_l '\n'
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define debug(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl

void IO() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {
    //IO();
    fastio;
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, k; cin >> n >> k;
    vector <int> ar(n);
    for (auto &i : ar) cin >> i;
    vector <bool> dp(k + 1, false);
	for (int i = 1; i <= k; i++) {
		for (int j = 0; j < n; j++) {
			if (i - ar[j] < 0) break;
			if (dp[i - ar[j]] == false) {
				dp[i] = true;
			}
		}
	}
	if (dp[k]) {
		cout << "First" << endl;
	} else cout << "Second" << endl;
    

    return 0;
}


Measured memory_bytes: 256
d,d_=dict(),dict()
s,t=input(),input()
l=len(s)
for i in range(l):
    if s[i] not in d:
        d[s[i]]=[i]
    else:
        d[s[i]].append(i)
for i in range(l):
    if t[i] not in d_:
        d_[t[i]]=[i]
    else:
        d_[t[i]].append(i)
x=[sorted(i[1]) for i in list(d.items())]
y=[sorted(i[1]) for i in list(d_.items())]
x.sort()
y.sort()
print("Yes" if x==y else "No")

Measured memory_bytes: 23472
// <llg.cpp> - Sun Feb 19 20:49:59 2017
// This file is created by XuYike's black technology automatically.
// Copyright (C) 2015 ChangJun High School, Inc.
// I don't know what this program is.

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long lol;
#define rep(i,l,r) for(int i=l;i<=r;i++)
template<typename T>
inline void gg(T &res){
    res=0;T fh=1;char ch=getchar();
    while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
    if(ch=='-')fh=-1,ch=getchar();
    while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
    res*=fh;
}
inline int gi(){int x;gg(x);return x;}
inline lol gl(){lol x;gg(x);return x;}
const int MAXN=100010;
const int INF=1e9;
int a[MAXN],b[MAXN];
int main(){
    int n=gi();lol sb=1ll*n*(n+1)>>1;
    for(int i=1;i<=n;i++)a[i]=gi();a[n+1]=a[1];
    int r=-INF;
    for(int i=1;i<=n;i++)r=max(r,b[i]=a[i+1]-a[i]);
    for(int i=1;i<=n;i++){
        if((r-b[i])%n){printf("NO");return 0;}
        if(1ll*(r-b[i])*(n-i+1)/n>a[1]){printf("NO");return 0;}
        a[1]-=1ll*(r-b[i])*(n-i+1)/n;
    }
    printf(a[1]%sb?"NO":"YES");
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); ++i)
#define INF 100000000
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll h, n;
    cin >> h >> n;
    ll ab[n][2];
    REP(i, n){
        cin >> ab[i][0] >> ab[i][1];
    }

    ll max_ = 100000;
    ll dp[100000];
    REP(i, 100000){
        dp[i] = INF;
    }
    dp[0] = 0;
    REP(i, n){
        REP(j, max_){
            if(j - ab[i][0] >= 0){
                dp[j] = min(dp[j - ab[i][0]] + ab[i][1], dp[j]);
            }
        }
    }
    ll ans = INF;
    REP_AB(i, h, 100000){
        if(ans > dp[i]){
            ans = dp[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <set>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#define ll long long
#define read(x) scanf("%d",&x);
#define readll(x) cin>>x;
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define MP make_pair
#define PB push_back
#define pii pair<int,int>
#define piii pair<int,pair<int,int> >

#define readN(N,X) for(int i=0;i<N;i++) scanf("%d",&X[i]);
using namespace std;
int M;
int N;
int kagi[99];

int main(){
	read(N);
	read(M);
	FOR(i,0,M){
		int a, b;
		read(a);
		read(b);
		kagi[a]++;
		kagi[b]++;
	}

	FOR(i,0,N){
		printf("%d\n", kagi[i+1]);
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100009
using namespace std;
char s[3][11];

int main()
{
    while(scanf("%s%s%s",s[0],s[1],s[2])!=-1)
    {
        for(int i=0;i<3;i++)
        {
            if(s[i][0]>='a'&&s[i][0]<='z')
                printf("%c",s[i][0]-'a'+'A');
            else
                printf("%c",s[i][0]);
        }
        puts("");
    }
    return 0;
}



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

def divider(n):
  dividers = []
  for i in range(1, int(n**0.5) + 1):
    if n % i == 0:
      dividers.append(i)
      if i != n // i:
        dividers.append(n // i)
  dividers.sort()
  dividers.remove(1)
  return dividers
#nの約数を抽出する関数を定義(1以外)

cnt = len(divider(N - 1))
for k in divider(N):
  n = N
  while n % k == 0:
    n /= k
  if n % k == 1:
    cnt += 1
print(cnt)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pcont(x) for(auto i: x){cout << i << " ";} cout << "\n";

int main(){
    IOS;
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for(int i = 0; i<n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    int dp[n][3];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(int i = 1; i<n; i++){
        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][1], dp[i-1][0]);
    }

    int ans;
    if(dp[n-1][0] > dp[n-1][1] && dp[n-1][0] > dp[n-1][2]){
        ans = dp[n-1][0];
    } else if(dp[n-1][1] > dp[n-1][0] && dp[n-1][0] > dp[n-1][2]){
        ans = dp[n-1][1];
    } else{
        ans = dp[n-1][2];
    }

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

Measured memory_bytes: 5580
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
void wf(vector<vector<int> > &dist, int n)
{
    for(int k = 0;k < n;k++)
    {
        for(int i = 0;i < n;i++)
        {
            for(int j = 0;j < n;j++)
            {
                dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j]);
            }
        }
    }
}
int main()
{
    int n,m;
    cin >> n >> m;
    const int INF = 1e5;
    vector<vector<int> > dist(n,vector<int>(n,INF)),dist2;
    pair<int,int> p[m];
    for(int i = 0;i < n;i++)
    {
        dist[i][i] = 0;
    }
    for(int i = 0;i < m;i++)
    {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        p[i] = make_pair(a,b);
        dist[a][b] = 1;
        dist[b][a] = 1;
    }
    int ans = 0;
    for(int i = 0;i < m;i++)
    {
        dist2 = dist;
        dist2[p[i].first][p[i].second] = INF;
        dist2[p[i].second][p[i].first] = INF;
        wf(dist2,n);
        bool flag = false;
        for(int j = 0;j < n;j++)
        {
            for(int k = 0;k < j;k++)
            {
                if(dist2[j][k] >= INF)
                {
                    flag = true;
                    break;
                }
            }
            if(flag)
            {
                break;
            }
        }
        if(flag)
        {
            ans++;
        }
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define LL long long
#define MOD 1e9+7
#define pi acos(-1.0)
#define ULL unsigned long long
#define mem_1(str) memset(str,-1,sizeof(str))
#define mem0(str) memset(str,0,sizeof(str))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
using namespace std;
const int maxn = 110;
const int INF = 0x3f3f3f3f;
int num[1005];
int main()
{
	int n,sum;
	while(scanf("%d%d",&n,&sum))
	{
		int ans=-1;
		if(n==0&&sum==0) break;
		else 
		{
			int k=0;
			for(int i=1;i<=n;i++)
			{
				scanf("%d",&num[i]);
			}
			for(int i=1;i<=n;i++)
			{
				for(int j=i+1;j<=n;j++)
				{
					if(num[i]+num[j]<=sum)
					{
						ans=max(num[i]+num[j],ans);
					}
				}
			}
			if(ans==-1) printf("NONE\n");
			else
		printf("%d\n",ans);
	    }
		
	}

	return 0;
}


Measured memory_bytes: 3152
N,W = list(map(int,input().split()))

w = []
v = []

for i in range(N):
    a,b = list(map(int,input().split()))
    w.append(a)
    v.append(b)

DP = [[-float('inf')]*(W+1) for i in range(N+1)]
DP[0][0] = 0
for i in range(N):
    for j in range(W+1):
        DP[i+1][j] = DP[i][j]
        if j>=w[i]:
            DP[i+1][j] = max(DP[i+1][j],DP[i][j-w[i]]+v[i])

print(max(DP[N]))

Measured memory_bytes: 306296
x1, y1, x2, y2 = gets.split.map(&:to_i)
vx = x2 - x1
vy = y2 - y1
x3 = x2 - vy
y3 = y2 + vx
x4 = x3 - vx
y4 = y3 - vy
puts "#{x3} #{y3} #{x4} #{y4}"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  char a;
  cin >> a;
  
  if((int)a <= 122 && 97 <= (int)a){
    cout << 'a' << endl;
  }
  else{
    cout << 'A' << endl;
  }
    
  

}

Measured memory_bytes: 3600
hoge = input().split()
N = int(hoge[0])
X = int(hoge[1])
L = []
huga = input().split()
for i in range(N):
  L.append(int(huga[i]))
  
now = 0
count = 1
for i in range(len(L)):
  now += L[i]
  if now <= X:
    count += 1

print(count)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;

int n;
LL A, B, C, D;

int main()
{
	scanf("%d%lld%lld%lld%lld", &n, &A, &B, &C, &D);
	bool ok = 0;
	for(int i = 1; i <= n; i++) {
		LL ll = A + C * (i - 1);
		LL lr = A + D * (i - 1);
		LL rl = B + C * (n - i);
		LL rr = B + D * (n - i);
		if(ll >= rl && ll <= rr) ok = 1;
		if(lr >= rl && lr <= rr) ok = 1;
	}
	if(ok) printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N)
    {
        ll a;
        cin >> a;
        A[--a]++;
    }
    sort(A.rbegin(), A.rend());
    ll sub = 0;
    rep(i, K)
    {
        sub += A[i];
    }
    cout << N - sub << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int p[6] = {380,550,850,1520,1870,2244};
int w[6] = {200,300,500,1000,1200,1500};

int dp[5001];
const int INF = 1000000;

int main(void){
    rep(i,5001) dp[i]=1<<30;
    dp[0]=0;
    rep(i,6){
        loop(j,w[i],5001){
            dp[j]=min(dp[j-w[i]]+p[i],dp[j]);
        }
    }
    int W;
    while(cin>>W,W){
        cout<<dp[W]<<endl;
    }
}

Measured memory_bytes: 1180
from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
#from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.readline().strip()
def mdata(): return map(int, data().split())
out=sys.stdout.write
#sys.setrecursionlimit(100000)

n,k=mdata()
H=list(mdata())
d=[1e9]*n
d[0]=0
for i in range(1,n):
    for j in range(i-1,max(i-k-1,-1),-1):
        d[i]=min(d[i],d[j]+abs(H[i]-H[j]))
print(d[-1])


Measured memory_bytes: 54880
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e11


int main(){
	ll n,m,c;
	cin>>n>>m>>c;
	vector<vector<mp> > g(n);
	ll bredge = 0;
	for(ll i=0;i<m;i++){
		ll a,b,d;
		cin>>a>>b>>d;
		a--,b--;
		g[a].push_back( mp(d,b) );
		g[b].push_back( mp(d,a) );
		bredge +=d;
	}
	vector<ll> cost(n,inf);
	vector<bool> used(n,true);
	priority_queue<mp,vector<mp> , greater<mp> > q;
	q.push(mp(0,0) );
	while(!q.empty() ){
		mp now = q.top();
		q.pop();
		ll nn = now.second;
		ll nc = now.first;
		if( !used[nn] ) continue;
		if( used[nn] ){
			used[nn] = false;
			cost[nn] = nc;
		}
		for(ll i=0;i<g[nn].size();i++){
			ll next = g[nn][i].second;
			ll nextc = nc + g[nn][i].first;
			if(used[next]){
				q.push(mp(nextc,next) );
			}
		}
	}
	/*for(ll i = 0;i<n;i++){
		cout<<cost[i]<<endl;
	}*/
	priority_queue<mp,vector<mp>,greater<mp> > qq;
	for(ll i=0;i<n;i++){
			qq.push( mp(cost[i],i) );
	}
	ll ans = inf;
	set<ll> del;
	while(!qq.empty()){
		mp now = qq.top();
		qq.pop();
		ll nn = now.second;
		ll nc = now.first;
		for(ll i = 0;i<g[nn].size();i++){
			ll next = g[nn][i].second;
			if(del.find(next) != del.end() ) bredge -= g[nn][i].first;
		}
		del.insert(nn);
		ans = min(ans , nc * c + bredge);
	}


	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 23472
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

int main() {
  map<char,string> s;
  string player = "abc";
  
  FOREACH(ch, player){
    cin >> s[ch];
  }

  map<char, int> mp;
  FOREACH(ch, player){
    mp[ch] = -1;
  }
  char cur = 'a';

  while(true){
    if(++mp[cur] == s[cur].size()) break;
    cur = s[cur][mp[cur]];
  }

  int offset = 'A' - 'a';
  char ans = cur + offset;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,ans=0,i,j;
  scanf("%d",&n);
 int a[n+1];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  a[n]=-1;
  for(i=0;i<=n;i++){
    for(;a[i]>0;){
    for(j=0;a[i+j]>0;j++){
    a[i+j]-=1;
  }
    ans++;
    }
}
  printf("%d\n",ans);
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n;
    cin >> n;

    vector<ll> L(n);
    for (int i = 0; i < n; i++) {
        cin >> L[i];
    }
    sort(L.begin(), L.end());

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            if (L[i] == L[j]) continue;
            for (int k = 0; k < j; k++) {
                if (L[k] == L[i] || L[k] == L[j]) continue;
                if (L[i] < L[j] + L[k]) ++ans;
            }
        }
    }
    cout << ans << newl;

    return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main () {
    
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    for (int i = 0; i < a; ++i) cin >> p[i];
    for (int i = 0; i < b; ++i) cin >> q[i];
    for (int i = 0; i < c; ++i) cin >> r[i];
    vector<int> res;
    res.reserve(x + y);
    sort(p.begin(), p.end(), std::greater<int>());
    sort(q.begin(), q.end(), std::greater<int>());
    sort(r.begin(), r.end(), std::greater<int>());
    for (int i = 0; i < x; ++i) res.push_back(p[i]);
    for (int i = 0; i < y; ++i) res.push_back(q[i]);
    for (int i = 0; i < r.size(); ++i) res.push_back(r[i]);
    sort(res.begin(), res.end(), std::greater<int>());
    size_t sum = 0;
    for (int i = 0; i < x + y; ++i) sum += res[i];
    cout << sum;
    return 0;
}


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

int main(){
    string s, t;
    cin >> s >> t;
    int a[26][26] = {}, b[26][26] = {};
    for(int i = 0; i < s.size(); ++ i){
        a[s[i] - 'a'][t[i] - 'a']++;
        b[t[i] - 'a'][s[i] - 'a']++;
    }

    for(int i = 0; i < 26; ++ i){
        int sum1 = 0, sum2 = 0;
        for(int j = 0; j < 26; ++ j){
            sum1 += (a[i][j] != 0);
            sum2 += (b[i][j] != 0);
        }
        if(sum1 > 1 || sum2 > 1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 776
#include <stdio.h>
#include <math.h>
#define N 10000

int prime(int);

int main() {
  int A[N], i, p, number, count=0;
  scanf("%d", &number);
  for(i=0; i<number; i++) {
    scanf("%d", &A[i]);
    p = prime(A[i]);
    if(p==1) count++;
  }

  printf("%d\n", count);
  return 0;
}
int prime(int a)
{
  int i;
  if(a==2) return 1;
  if(a<2 || a%2==0) return 0;
  i = 3;
  while(i<=sqrt(a)){
    if(a%i==0) return 0;
    i = i+2;
  }
  return 1;
}

Measured memory_bytes: 628
main = do
    n <- read <$> getLine
    xus <- map words <$> sequence (replicate n getLine)
    let xs = map (read . head) xus
        us = map last xus
    print $ foldl (\acc (x, u) -> acc + if u == "JPY" then 1.0 * x else 380000.0 * x) 0 (zip xs us)

Measured memory_bytes: 636
#include <iostream>
using namespace std;
int main(){
	string ball[10] = {"* = ****","* =* ***","* =** **","* =*** *","* =**** "," *= ****"," *=* ***"," *=** **"," *=*** *"," *=**** "};
	string i;
	int b = 0;
	while(cin >> i,!cin.eof()){
		if(b)cout<<endl;
		else{b=1;}
		while(i.size() < 5)i = '0' + i;
		for(int k=0;k<8;k++){
			for(int l=0;l<5;l++){
				cout << ball[i[l]-'0'][k];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define VALS(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define pf push_front
#define LLINF ((long long)1e18)
#define INF 1234567890ll
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define ll long long int 
#define ld long double
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define f first
#define s second
typedef pair <int, int> pi;
typedef pair <ll, ll> pl;
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
const int MOD = 1e9 + 7;
int n; string s;
bool check(int x) 
{
	FOR(i, 0, n-x-1) {
		string str; 
		FOR(j, i, i+x-1) {
			str += s[j];
		}
		if (s.find(str, i+x) != string::npos) return true;
	}
	return false;
}

int main()
{
	IAMSPEED
	cin >> n >> s;
	int ans = 0;
	int lo = 0, hi = 5000;
	while (lo <= hi) {
		int mid = (lo + hi) / 2;
		if (check(mid)) {
			ans = mid;
			lo = mid + 1;
		} else {
			hi = mid - 1;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int x,y,amari,i,found;
  scanf("%d%d",&x,&y);
  if(x == y) found = x;
  else if(x>y)
    {
      amari=x%y;
      for(i=1;i<amari;i++)
	{
	  if(y%i==0 && amari%i==0)
	  found = i;
	}
    }
  else
    {
      amari=y%x;
      for(i=1;i<amari;i++)
	{
	  if(x%i==0 && amari%i==0)
	    found = i;
	}
	
    }
  printf("%d\n",found);
  return 0;
}

 





Measured memory_bytes: 2104
#include <cstdio>
using namespace std;

const int MAXN=200005;
int n,a[MAXN],b[MAXN];

inline int read(){
	char c; int x;
	while(c=getchar(),c<'0' || '9'<c);
	x=c-'0';
	while(c=getchar(),'0'<=c && c<='9')
		x=x*10+c-'0';
	return x;
}

int main(){
	n=read();
	for(int i=1;i<=n;++i)
		a[i]=read();
	if(n%2){
		for(int i=n;i>=1;i-=2)
			printf("%d ",a[i]);
		for(int i=2;i<n;i+=2)
			printf("%d ",a[i]);
	}
	else{
		for(int i=n;i;i-=2)
			printf("%d ",a[i]);
		for(int i=1;i<n;i+=2)
			printf("%d ",a[i]);
	}
	return 0;
}

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

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

    cout<<max(a-b*2,0)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long long a[3];
    cin>>a[0]>>a[1]>>a[2];
    int flag=0;
    long long t=0;
    long long s=0;
    for(int i=0;i<3;i++)
    {
        if(a[i]%2==0)
        {
            flag=1;
            break;
        }else
        {
            if(t<a[i])
            {
                t=a[i];
                s=a[(i+1)%3]*a[(i+2)%3];
            }
        }
    }
    if(flag)
    {
        cout<<0<<endl;
    }else
    {
        cout<<s<<endl;
    }
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define MAX_C 1000000001

int main() {
  int r;
  cin >> r;

  printf("%lf", 2 * 3.141592653589 * r);
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pub push_back
#define pob pop_back
#define loops(i, s, n) for (int i = s; i < n; i++)
#define loop(i, n) for (int i = 0; i < n; i++)
#define loopr(i, s, e) for (int i = s; i >= e; i--)
#define eps 1e-9
#define loopitr(mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define pii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int, int>>
#define even_set 0xAAAAAAAA ... 1010101010
#define odd_set 0x55555555 ... 01010101
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vall(v) v.begin(), v.end()
#define mkp make_pair
#define ret return
#define cont continue
#define nl endl
#define ff first
#define ss second
#define cnt_bits __builtin_popcount
#define endl "\n"
#define test  \
    int T;    \
    cin >> T; \
    while (T)
#define arrinit \
    int n;      \
    cin >> n;   \
    int arr[n]; \
    loop(i, n) { cin >> arr[i]; }
#define init(arr, n, val)       \
    for (int i = 0; i < n; i++) \
        arr[i] = val;
const int mod = 1000000007;

ll gv(ll num, ll k)
{
    if (num < k)
        ret 0;

    ll d = num / k;
    while (num > d * k)
    {
        num -= (d + 1);
        if (num % k == 0)
            break;
    }

    if (num % k == 0)
        return num / k;

    return gv(num, k);
}

int main()
{
    int t;
    cin >> t;
    ll ans = 0;
    loop(T, t)
    {
        ll num, k;
        cin >> num >> k;
        ans ^= gv(num, k);
    }

    if (ans)
        cout << "Takahashi\n";
    else
        cout << "Aoki\n";
}

Measured memory_bytes: 3604
// ABC.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << 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 F first
#define S second
#define pb push_back
#define powerof2 ()
using ll = long long;
const ll M = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> is;
ll power(ll x,ll y){
    if(y==0)
    return 1;
    ll res=power(x,y/2);
    res=(res*res)%M;
    if(y&(ll)1)
    res=(res*x)%M;
    return res;
}


/*int n,ma=0;
vector<vector<int>> gr;
vector<int> color;
void dfs(int c,int p)
{
    vector<int> v;
    int j;
    for(j=1;j<gr[c].size()+2;j++)
    {
        if(j==color[c]||j==color[p])
        continue;
        //cout<<j<<" ";
        v.pb(j);
    }
    //cout<<endl;
    j=0;
    for(int i=0;i<gr[c].size();i++)
    {
        if(gr[c][i]!=p)
        {
            color[gr[c][i]]=v[j];j++;
            dfs(gr[c][i],c);
        }
    }
}*/
void solve(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll s=a+b;
    if(s==0)
    {
        cout<<0<<endl;
    }
    else
    cout<<n/s*a+min(a,n%s)<<endl;
}
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin>>t;
    // while(t--)
    solve();
    return 0;
}

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

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

    for (int deleted { 1 }; deleted < s.length(); ++deleted) {
        const int len { s.length() - deleted };
        if (len % 2 != 0) continue;

        const int half { len / 2 };
        int iterator { 0 };
        while (iterator < half) {
            if (s[iterator] != s[iterator + half]) break;
            ++iterator;
        }
        if (iterator == half) {
            cout << len << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int A[90005][2], D, H, W, Q;
int L[100005], R[100005];
int M[90005], SUM[90005];

void init() {
  // D前との魔力の差分
  for (int i=D; i<H*W; i++) {
    M[i] = abs(A[i][0]-A[i-D][0])+abs(A[i][1]-A[i-D][1]);
  }
  for (int i=D; i<H*W; i++) {
    SUM[i]=SUM[i-D]+M[i];   
  }
}

int main() {
  INCANT;
  cin >> H >> W >> D;
  int a;
  rep(i, H) {
    rep(j, W) {
      cin >> a;
      a--;
      A[a][0]=i;
      A[a][1]=j;
    }
  }
  init();
  cin >> Q;
  rep(i, Q) cin >> L[i] >> R[i];
  rep(i, Q) {
    int l =L[i],r=R[i];
    l--;r--;
    cout << SUM[r]-SUM[l] << endl; 
  }
  
  return 0;
}

Measured memory_bytes: 3328
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
T=[int(input()) for i in range(D)]
l=[0]*26
v=0
for d in range(D):
    x=[S[d][i]-sum([(d+1-l[j])*C[j] for j in range(26) if i!=j]) for i in range(26)]
    l[T[d]-1]=d+1
    v+=x[T[d]-1]
    print(v)

Measured memory_bytes: 9496
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll x,k,d;
    cin >> x >> k >> d;
    x = abs(x);

    ll st = min(k, x/d);
    k -= st;
    x -= st * d;
    
    if(k%2 == 0) cout << x << endl;
    else cout << d - x << endl;

    return 0;
}

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

X = input().split()
x1 = [int(x) for x in X]
x2 = [int(x) for x in X]

x2.sort()
ml = x2[int((N/2)-1)]
mr = x2[int(N/2)]

for i in range(N):
    if x1[i] <=  ml:
        print("%d"%mr)
    else:
        print("%d"%ml)
        
    

Measured memory_bytes: 36220
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

void build(ll node, ll start, ll end){
	if(start == end)
		segtree[node] = A[start];
	else{
		ll mid = (start + end)/2;
		build(left(node), start, mid);
		build(right(node), mid+1, end);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

void update(ll node, ll start, ll end, ll l, ll r, ll val){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(start > end or l > start or r < end)
		return ;
	else if(start >= l and r >= end){
		segtree[node] += val;
		if(start != end){
			lazy[left(node)] += val;
			lazy[right(node)] += val;
		}
	}
	else{
		ll mid=(start + end)/2;
		update(left(node), start, mid, l, r, val);
		update(right(node), mid+1, end, l, r, val);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

ll sums(ll node, ll start, ll end, ll l, ll r){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l > end or r < start or start > end)
		return 0;
	if(l <= start and r >= end)
		return segtree[node];
	ll mid = (start+end)/2;
	return sums(left(node), start, mid, l , r) + sums(right(node), mid + 1, end, l , r);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	string st;
	cin >> st;
	string sq = st;
	ll ev=0, od=0;
	char c[] = {'0','1'};
	for(ll i=0; st[i]; i++){
		if(st[i] != c[(i+1)%2])
			od++;
		if(st[i] != c[(i%2)])
			ev++;
	}
	cout << min(ev, od);
	return 0;
}

Measured memory_bytes: 3704