akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <numeric>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;

//template<typename Int = int>
using Int = int;
struct PrimalDual {
    struct Edge {
        int dst;
        Int cap, flow, cost;
        int rev;
        bool isRev;
        Edge(int dst, Int cap, Int flow, Int cost, int rev, bool isRev)
            :dst(dst), cap(cap), flow(flow), cost(cost), rev(rev), isRev(isRev) {
        }
    };

    int n;
    vector<vector<Edge>> g;
    PrimalDual(int n_) : n(n_), g(vector<vector<Edge>>(n_)) {}
    void addEdge(int src, int dst, Int cap, Int cost) {
        g[src].emplace_back(dst, cap, 0, cost, g[dst].size(), false);
        g[dst].emplace_back(src, cap, cap, -cost, g[src].size() - 1, true);
    }

    vector<Int> h, dist;
    vector<int> prevv, preve;
    Int solve(int s, int t, Int f) {
        Int res = 0;
        h.assign(n, 0);
        dist.assign(n, 0);
        prevv.assign(n, 0);
        preve.assign(n, 0);
        while (f > 0) {
            if (!dijkstra(s,t)) return -1;
            for (int i = 0; i < n; ++i) h[i] += dist[i];
            Int d = f;
            for (int v = t; v != s; v = prevv[v]) {
                Edge &e = g[prevv[v]][preve[v]];
                d = min(d, residue(e));
            }
            f -= d;
            res += d * h[t];
            for (int v = t; v != s; v = prevv[v]) {
                Edge &e = g[prevv[v]][preve[v]];
                e.flow += d;
                g[v][e.rev].flow -= d;
            }
        }
        return res;
    }

    bool dijkstra(int s, int t) {
        constexpr Int INF = numeric_limits<Int>::max();
        dist.assign(n, INF);
        dist[s] = 0;
        priority_queue<pair<Int, int>> q;
        fill(dist.begin(), dist.end(), INF);
        dist[s] = 0;
        q.emplace(0, s);
        while (q.size()) {
            int d, v;
            tie(d, v) = q.top();
            q.pop();
            d = -d;
            if (dist[v] < d) continue;
            for (int i = 0; i < (int)g[v].size(); ++i) {
                Edge &e = g[v][i];
                if (residue(e) > 0 && dist[e.dst] > dist[v] + e.cost + h[v] - h[e.dst]) {
                    dist[e.dst] = dist[v] + e.cost + h[v] - h[e.dst];
                    prevv[e.dst] = v;
                    preve[e.dst] = i;
                    q.emplace(-dist[e.dst], e.dst);
                }
            }
        }
        return dist[t] != INF;
    }

    Int residue(const Edge& e) { return e.cap - e.flow; }
};

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m, f;
    cin >> n >> m >> f;
    PrimalDual pd(n);
    for (int i = 0; i < m; i++) {
        int u, v, c, d;
        cin >> u >> v >> c >> d;
        pd.addEdge(u, v, c, d);
    }
    cout << pd.solve(0, n - 1, f) << endl;
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int K = in(),N = in();
    vector<int> A(N);
    REP(i,N)A[i] = in();
    vector<int> miss(N);
    REP(i,N){
        if(i == 0){
            miss[i] = K + A[i] - A[N-1];
        }else{
            miss[i] = A[i] - A[i-1];
        }
    }
    sort(ALL(miss),greater<>());
    cout << K - miss[0] << "\n";
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    if (n % 2 == 0)
        cout << n << endl;
    else
        cout << 2 * n << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split(" "))

sws = []

for _ in range(M):
	items = list(map(int, input().split(" ")))
	sws.append([items[i + 1] - 1 for i in range(items[0])])

plist = list(map(int, input().split(" ")))

def check(sw):
	for i in range(M):
		items = sws[i]
		c = 0
		for j in items:
			c += sw[j]
		if c % 2 != plist[i]:
			return False
	return True

f = "{:0" + str(N) + "b}"
count = 0
for i in range(2 ** N):
	sw = [s == "1" for s in f.format(i)]
	if check(sw):
		count += 1
print(count)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define lsb(x) (x & -x)

using namespace std;

const int MOD = 1000000007;

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

int main() {
    ios::sync_with_stdio(false);

    cin.tie(0);
    cout.tie(0);
    //freopen("a.in", "r", stdin);

    string s;
    int d;
    cin >> s >> d;
    int ndigits = s.size();

    vector<vector<int>> dp(d, vector<int> (ndigits + 1, 0));
    dp[0][0] = 1;

    for(int i = 0; i < ndigits; i ++)
        for(int r = 0; r < d; r ++)
            for(int digit = 0; digit < 10; digit ++)
                dp[(r + digit) % d][i + 1] = (dp[(r + digit) % d][i + 1] + dp[r][i]) % MOD;

    int ans = dp[0][ndigits - 1];
    ans --; // il scot pe 0
    if(ans < 0)
        ans += MOD;

    int sumofdigits = (d * 10 - (s[0] - '0')) % d;
    for(int digit = 1; digit < s[0] - '0'; digit ++) {
        ans += dp[(d * 10 - digit) % d][ndigits - 1];
        mod(ans);
    }

    for(int i = 1; i < s.size(); i ++) {
        for(int digit = 0; digit < s[i] - '0'; digit ++) {
            ans += dp[(sumofdigits + d * 10 - digit) % d][ndigits - i - 1];
            mod(ans);
        }

        sumofdigits = (sumofdigits + d * 10 - (s[i] - '0')) % d;
    }

    if(sumofdigits == 0) {
        ans ++;
        mod(ans);
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 4224
n, m = map(int, input().split())

A_B = []
for _ in range(m):
    a, b = map(int, input().split())
    A_B.append((a,b))

One_to = []
for i in range(m):
    if A_B[i][0] == 1:
        One_to.append(A_B[i][1])
    elif A_B[i][1] == 1:
        One_to.append(A_B[i][0])

N_to = []
for i in range(m):
    if A_B[i][0] == n:
        N_to.append(A_B[i][1])
    elif A_B[i][1] == n:
        N_to.append(A_B[i][0])

One_to_set = set(One_to)
N_to_set = set(N_to)
inter = One_to_set & N_to_set
if len(inter) >= 1:
    ans = 'POSSIBLE'
else:
    ans = 'IMPOSSIBLE'

print(ans)

Measured memory_bytes: 39256
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func main() {
	input := scanNums(2)
	a := input[0]
	b := input[1]

	if a >= 13 {
		fmt.Println(b)
	} else if a >= 6 {
		fmt.Println(b / 2)
	} else {
		fmt.Println(0)
	}
}

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func scanNums(n int) (nums []int) {
	str := readLine()
	s := strings.Split(str, " ")
	for i := 0; i < n; i++ {
		num, _ := strconv.Atoi(s[i])
		nums = append(nums, num)
	}
	return nums
}

func scanStrings() []string {
	str := readLine()
	s := strings.Split(str, " ")

	return s
}

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

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}


Measured memory_bytes: 640
#include"bits/stdc++.h"
#include<cstring>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;

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

	for (int i = 1; i <= 1250; ++i)
	{
		if((int)(i*0.08)==a&&(int)(i*0.1)==b){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
	
}

Measured memory_bytes: 256
n,m=map(int,input().split())
x = []
y = []
for i in range(m):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

mn=min(y)
mx=max(x)

ans=max(mn-mx+1,0)
print(ans)


Measured memory_bytes: 56920
import numpy as np
import math

def d(a, b):
  return np.sum((a - b)**2)**0.5
  
N = int(input())

xy = np.array([list(map(int, input().split())) for _ in range(N)])

a = sum([[d(xy[i], xy[j]) for j in range(i+1, N)] for i in range(0, N)], [])

print(2*sum(a)/N)

Measured memory_bytes: 12168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007


int main() {
	ll n,t;
	cin>>n>>t;
	ll ans=0,next;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		if(next>=x){
			ans-=next-x;
		}
		ans+=t;
		next=x+t;
		
	}
	cout << ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int e,y,ans;
  scanf("%d %d",&e,&y);
  if(e==0 && 1989<=y && y<=2016){
    ans=y-1989;
    ans++;
    printf("H%d\n",ans);
  }else if(e==0 && 1926<=y && y<=1988){
    ans=y-1926;
    ans++;
    printf("S%d\n",ans);
  }else if(e==0 && 1912<=y && y<=1925){
    ans=y-1912;
    ans++;
    printf("T%d\n",ans);
  }else if(e==0 && 1868<=y && y<=1911){
    ans=y-1868;
    ans++;
    printf("M%d\n",ans);
  }else if(e==1){
    ans=1868+y;
    ans--;
    printf("%d\n",ans);
  }else if(e==2){
    ans=1912+y;
    ans--;
    printf("%d\n",ans);
  }else if(e==3){
    ans=1926+y;
    ans--;
    printf("%d\n",ans);
  }else if(e==4){
    ans=1989+y;
    ans--;
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 2760
// abc138_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll N;
    cin >> N;

    ll ans = N * (N - 1) / 2;

    print(ans);
    return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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; }

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    int a, b;
    cin >> a >> b;

    if((a+b)%2 == 0){
        cout << (a+b)/2 << endl;
    }else{
        cout << (a+b+1)/2 << endl;
    }
    
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

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

ll mod = 1000000007;

int main(){
  int n; cin >> n;
  vector <ll> a(n);
  rep(i, n) cin >> a[i];
  ll x = 0;
  ll ans = 0;
  rep(i, n){
    ans = (ans + a[i]*x)%mod;
    x = (x+a[i])%mod;
  }
  cout << ans % mod << endl;
}

Measured memory_bytes: 4816
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <queue>

using namespace std;
typedef long long LL;
const int maxn = 55;
const int mod = 1e9+7;

void upd(int &x,int y) {
	x+=y;x>=mod?x-=mod:0;
}
int dp[maxn][maxn<<1][maxn<<1],a[maxn<<1],n;
int main()
{
	#ifdef Amberframe
		freopen("agc012f.in","r",stdin);
		freopen("agc012f.out","w",stdout);
	#endif
	scanf("%d",&n);
	for (int i=1;i<(n<<1);i++)
		scanf("%d",&a[i]);
	sort(a+1,a+(n<<1));
	dp[1][0][0]=1;
	for (int i=2;i<=n;i++)
	{
		int sum=a[n+i-2]-a[n-i+2];
		for (int j=0;j<=sum;j++)
		for (int k=0;k+j<=sum;k++)
		if (int w=dp[i-1][j][k]) {
			int L=j+(a[n-i+1]!=a[n-i+2]),R=k+(a[n+i-1]!=a[n+i-2]);
			for (int u=1;u<=L;u++) upd(dp[i][L-u][R+1],w);
			for (int v=1;v<=R;v++) upd(dp[i][L+1][R-v],w);
			upd(dp[i][L][R],w);
		}
	}
	int ans=0;
	int sum=a[(n<<1)-1]-a[1];
	for (int j=0;j<=sum;j++)
	for (int k=0;k+j<=sum;k++)
		upd(ans,dp[n][j][k]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
int intager[101]={0};

int main(){
	int a;
	int max=0;
	while(std::cin>>a){
		intager[a]+=1;
		if(intager[a]>max)max=intager[a];
	}
	for(int i=1;i<101;++i){
		if(intager[i]==max)std::cout<<i<<std::endl;
	}
	return 0;
}

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

int main() {
unsigned long long ans=1;
ll n;
cin>>n;
vector<unsigned long long>a(n);
rep(i,n)
{cin>>a[i];
if(a[i]==0){cout<<"0"<<endl;return 0;}}
rep(i,n)
{unsigned long long x=a[i];
  unsigned long long oldans=ans;
  ans=x*ans;
  //cout<<ans<<" "<<x<<" "<<oldans<<" "<<endl;
  if(oldans!=0&&x!=0&&oldans>ans){cout<<-1<<endl;return 0;}//オーバーフローの場合
  if(ans>1000000000000000000){cout<<-1<<endl;return 0;}
  
}
cout<<ans<<endl;

}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

Measured memory_bytes: 4048
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define MAX 305

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

string s;
int ans=0;

int main(){
  cin >> s;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()-1-i]){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int[] i = Arrays.stream(line.split(" ")).mapToInt(Integer::parseInt)
                                                .toArray();
        if (i[0] < i[1] && i[1] < i[2]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 31668
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;
 
int main()
{
  int n;
  cin >> n;
  if(n == 1){
    cout << 1 << endl;
    return 0;
  }
  priority_queue<int> q;
  q.push(1);
  for(int i = 2; i*i <= n; i++){
    int j= i;
    while(j*i <= n){
      q.push(j*i);
      j *= i;
    }
  }
  cout << q.top() << endl;
  system("pause");
}

Measured memory_bytes: 504
function main(input){
    let lines = input.split("\n");
    let i = 0;
    let length = 0;
    let chars = "";
    while(lines[i]!=="-"){
        if(chars===""){
            chars=lines[i];
        }else if(length===0){
            length = lines[i];
        }else{
            for(let j=0;j<length;j++){
                let count = parseInt(lines[i+j]);
                let sliced = chars.slice(0,count);
                let rest = chars.slice(count);
                chars = rest+sliced;
            }
            i+=length-1;
            console.log(chars);
            chars="";
            length=0;
        }
        i++;
    }
    
}

main(require("fs").readFileSync("/dev/stdin","utf-8"));


Measured memory_bytes: 15356
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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(){
    vvl g(110,vl(220));
    rep(i,220)g[0][i]=i%2;
    repl(i,1,101){
        rep(j,220){
            set<ll> st;
            if(j!=0)st.ins(g[i][j-1]);
            if(j<=219-i)st.ins(g[i-1][j+1]);
            ll t=i;
            rep(k,j){
                t--;if(t<0)break;
                st.ins(g[t][j]);
            }
            rep(k,110){
                if(!st.count(k)){
                    g[i][j]=k;
                    break;
                }
            }
        }
    }
    /*rep(i,5){
        rep(j,5){
            cout << g[i][j] <<" ";
        }
        cout << endl;
    }*/
    ll n;cin >> n;
    ll ans=0;
    while(n--){
        ll a,b;cin >> a >> b;
        ans^=g[b][a];
    }
    if(ans==0)cout << 1 <<endl;
    else cout << 0 <<endl;
}


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

int main(){
	int n;
	cin >> n;
	vector<ll>a(n), b(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	for (int i = 0;i < n;i++) {
		cin >> b[i];
	}

	ll c1 = 0;
	ll c2 = 0;
	for (int i = 0;i < n;i++) {
		if (a[i] < b[i]) {
			ll diff = b[i] - a[i];
			c2 += diff / 2;
			if (diff % 2 != 0) {
				c2++;
				c1++;
			}
		}
		else if (a[i] > b[i]) {
			c1 += a[i] - b[i];
		}
	}
	if (c2 >= c1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

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

int main(){
while(1){
	int a[100000+2],n,k,ans=0,sum=0;
	scanf("%d%d",&n,&k);
if(n==0&&k==0)break;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<k;i++){
		sum+=a[i];
	}
	ans=sum;
	for(int i=k;i<n;i++){
		sum+=a[i]-a[i-k];
		if(ans<sum)ans=sum;
	}
	printf("%d\n",ans);
}
}

Measured memory_bytes: 1564
#include<iostream>
#include<string>

using namespace std;

int main(){
  char N[4];
  cin >> N;
  int flg = 0;
  for (int i=0;i<3;i++){
    if (N[i] == '7'){
      flg = 1;
    }
  }
  if (flg == 0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3040
/*
Author: Babin Dutta
*/
 
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
//#define endl "\n"
#define inf 1e18
#define mm 998244353
 
ll power(ll x, ll y, ll p)
{
    ll res = 1;  
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; 
        x = (x*x) % p;  
    }
    return res;
}
ll modInverse(ll A,ll M)
{
    return power(A,M-2,M);
}

void solve(){
	ll a,b,c; cin>>a>>b>>c;
	ll ans = (a/b) * c;
	if(a%b != 0) ans += c;
	cout<<ans<<endl;
}
 
int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ignore ignore
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define bitcount(x)  __builtin_popcount(x)
#define bitcountll(x)  __builtin_popcountll(x)
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define YES printf("YES\n")
#define NO printf("NO\n")
#define yes printf("Yes\n")
#define no printf("No\n")
#define lin printf("\n")
// Iterator
#define rep(i,n) for(i=0;i<n;++i)
#define rrep(i,n) for(i=n-1;i>=0;--i)
#define lp(i,a,b) for(i=a;i<b;++i)
#define rlp(i,a,b) for(i=a;i>=b;--i)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// function
#define sz(x) x.size()
#define inrange(i,a,b) (i>=a && i<=b)
#define FLUSH fflush(stdout)
#define precision(x) cout << setprecision(x) << fixed
#define remax(a,b) a=max(a,b)
#define remin(a,b) a=min(a,b)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
// Constant
const double PI = acos(-1);
const double eps = (1e-9);
const ll INF = 2e9;
const int M = (1e9)+7;
const int N = (1e6)+3;  // check the limit, man
int main()
{
    int i;
    ll n;
    cin >> n;
    vector<ll> v(5);
    rep(i,5)
        cin >> v[i];
    ll x=v[0];
    rep(i,5)
        remin(x,v[i]);
    ll ans=5-1;
    ans+=(n/x+min(1ll,n%x));
    llout(ans);
}








Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
dp = [float("inf")]*n #足場0>>iへ行くときのコストの最小値
dp[0] = 0
for i in range(1,n):
    if i >1:
        dp[i] = min(dp[i],dp[i-2] + abs(h[i]-h[i-2]))
    dp[i] = min(dp[i],dp[i-1] + abs(h[i]-h[i-1]))
print(dp[n-1])

Measured memory_bytes: 13928
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int64_t needK(vector<int64_t> & A, vector<int64_t> & F, int64_t x) {
    int64_t needk = 0;
    for (int i = 0; i < A.size(); ++i) {
        if (A[i] * F[i] <= x)
            continue;
        needk += (A[i] * F[i] - x + F[i] - 1) / F[i];
    }
    return needk;
}

int main(int argc, char * argv[]) {
    int64_t N, K;
    cin >> N >> K;

    vector<int64_t> A(N), F(N);
    for (auto & x : A)
        cin >> x;
    for (auto & x : F)
        cin >> x;

    std::sort(A.begin(), A.end());
    std::sort(F.rbegin(), F.rend());

    int64_t pos = 0, can = 0;
    for (int i = 0; i < N; ++i) {
        can = std::max(can, A[i] * F[i]);
    }

    while (pos != can) {
        int64_t t = (pos + can) / 2;
        
        if (needK(A, F, t) <= K) {
            can = t;
        } else {
            pos = t + 1;
        }
    }
    cout << can << endl;

    return 0;
}


Measured memory_bytes: 3328
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N =Integer.parseInt(sc.next());
        long[] l = new long[N];
        for(int i = 0 ;i < N ; i++){
            l[i] = Long.parseLong(sc.next());
        }
        Map<Long,Long> m = new HashMap<Long,Long>();
        long total = 0;
        for(int i = 0 ;i < N ; i++){
            if(m.containsKey(i+1-l[i])){
                total += m.get(i+1-l[i]);
            }
            if(m.containsKey(l[i]+1+i)){
                m.put(l[i]+1+i, m.get(l[i]+1+i)+1);
            }else{
                m.put(l[i]+1+i, 1l);
            }
        }
        System.out.println(total);
    }
}

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

import sys

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

N = INT()

# dp[i] := i円引き出すのに必要な最小回数
dp = [INF] * (N+1)
dp[0] = 0
for i in range(N):
    # 3種類の引き出し方に対応する遷移をする
    dp[i+1] = min(dp[i+1], dp[i] + 1)
    j = 1
    while i+6**j <= N:
        dp[i+6**j] = min(dp[i+6**j], dp[i] + 1)
        j += 1
    j = 1
    while i+9**j <= N:
        dp[i+9**j] = min(dp[i+9**j], dp[i] + 1)
        j += 1
print(dp[N])


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

int main() {
    int N, L;
    cin >> N >> L;
    int aji=0;
    for (int i=0; i<N; i++) aji+=(L+i);
    int ans=aji;
    int res=0;
    for (int i=0; i<N; i++) {
        if (abs(ans)>abs(aji-(aji-(L+i)))) {
            ans = abs(aji-(aji-(L+i)));
            res = aji-(L+i);
        }
    }
    cout << res;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    n = N % 10
    honli = [2, 4, 5, 7, 9]
    ponli = [0, 1, 6, 8]
    if n in honli:
        print("hon")
    elif n in ponli:
        print("pon")
    else:
        print("bon")


if __name__ == "__main__":
    main()


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a, b;

int main() {
	cin >> a >> b;
	
	cout << (max(a, b) <= 8 ? "Yay!" : ":(") << endl;
	
	return 0;
}


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

int main () {
    int r, D, x, x_next;
    cin >> r >> D >> x;
    for (int i = 0; i < 10; i++) {
        x_next = r * x - D;
        cout << x_next << endl;
        x = x_next;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n';
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    string s,t; cin >> s >> t;
    int ans = 0;
    REP(i,s.size()) if(s[i]==t[i]) ans++;
    out(ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A;
    int B;
    cin >> A >> B;
    if(A >= 13){
        cout << B << endl;
    }
    if(6 <= A && A <= 12){
        cout << B/2 << endl;
    }
    if(0 <= A && A <= 5) {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long i,j,a,b;
    while(scanf("%ld %ld",&a,&b)==2)
    {
        long sum=a+b;
        i=0;
        while(sum!=0)
        {
            sum/=10;
            i++;
        }
        printf("%d\n",i);
    }
    return 0;
}

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

#define vi vector<int>
#define vii vector<int, int>
#define ll long long
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...) 42
#endif

const int MOD = 1000000007;

int main(){
    IOS;
    string s;
    cin >> s;
    sort(s.begin(), s.end());

    if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) cout << "Yes" <<endl;
    else cout << "No" << endl;


    #ifdef LOCAL
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif

    return 0;
}



Measured memory_bytes: 256
N, X = map(int, input().split())
L = list(map(int, input().split()))

cnt = 0
before = 0
d = 0
L.insert(0, 0)

#d_recode = []

for i in range(1, N + 2):
    d = before + L[i - 1]

    if d <= X:
        cnt += 1

    #d_recode.append(d)
    before = d

#print(d_recode)
print(cnt)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

#define NIL  -1

struct MyStruct
{
	ll p = NIL;    // 親
	ll key = NIL;  // 節の番号
	ll left = NIL;       // 左の子の番号
	ll right = NIL;      // 右の子の番号
	ll val;
};

vector<MyStruct>list(500000);
vector<ll>senlist, tyulist;
ll m, root, cnt = 0;

int insert(ll no, ll cnt) {

	if (cnt == 0) {
		list[cnt].key = cnt;
		list[cnt].val = no;
		return 0;
	}

	ll x = 0, y;

	while (x != NIL)
	{
		y = list[x].key;

		if (list[x].val > no) {
			x = list[x].left;
		}
		else {
			x = list[x].right;
		}
	}

	list[cnt].p = y;
	list[cnt].key = cnt;
	list[cnt].val = no;

	if (no < list[y].val) {
		list[y].left = cnt;
	}
	else {
		list[y].right = cnt;
	}

	return 0;
}

int tyu(ll no) {

	if (no == -1) {
		return 0;
	}

	if (list[no].left == NIL && list[no].right == NIL) {
		tyulist.push_back(list[no].val);
		return 0;
	}

	tyu(list[no].left);
	
	tyulist.push_back(list[no].val);

	tyu(list[no].right);

	return 0;
}

int sen(ll no) {

	if (no == -1) {
		return 0;
	}

	if (list[no].left == NIL && list[no].right == NIL) {
		senlist.push_back(list[no].val);
		return 0;
	}

	senlist.push_back(list[no].val);

	sen(list[no].left);
	sen(list[no].right);

	return 0;
}

signed main() {
	
	cin >> m;

	for (int i = 0; i < m; i++) {
		string s;
		cin >> s;

		ll num;
		if (s == "insert") {
			cin >> num;

			insert(num, cnt);
			cnt++;
		}
		else {
			tyu(0);
			for (int j = 0; j < tyulist.size(); j++) {
				cout << " " << tyulist[j];
			}
			vector<ll>tmplist;
			tyulist = tmplist;
			cout << endl;

			sen(0);

			for (int j = 0; j < senlist.size(); j++) {
				cout << " "  << senlist[j];

			}
			senlist = tmplist;
			cout << endl;
		}
		
	}


	return 0;
}


Measured memory_bytes: 32380
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	vector<vector<int>> dp(n, vector<int>(2));
	dp[0][0] = 1;
	dp[0][1] = 1;
	for (int i = 1; i < n; ++i) {
		for (int b1 = 0; b1 < 2; ++b1) {
			for (int b2 = 0; b2 < 2; ++b2) {
				int cur = a[i] - b2;
				int prev = a[i - 1] - b1;
				if (cur >= prev) {
					dp[i][b2] |= dp[i - 1][b1];
				}
			}
		}
	}
	cout << (dp[n - 1][0] | dp[n - 1][1] ? "Yes\n" : "No\n");
 	return 0;
}


Measured memory_bytes: 6144
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        n:u64,
        a:u64,
        b:u64,
    }

    let ab = a + b;
    let repeat = n / ab;
    let remain = n - ab * repeat;

    println!("{}", a * repeat + min(remain, a));
}


Measured memory_bytes: 2116
fun main(args: Array<String>) {
    var (n, k) = readLongList()
    val arr = readIntList()
    var next = 1

    // ループを見つけるまで
    val visited = BooleanArray(n.toInt()) { false }
    var loop = -1
    while (k-- > 0) { // 街にきた
        if (visited[next - 1]) { // その街が訪問済みなら
            loop = next
            next = arr[next - 1]
            break
        }
        visited[next - 1] = true
        next = arr[next - 1]
    }

    //println(loop)

    var count = 1
    // 何ステップでループするか見つける
    while (k-- > 0) {
        if (arr[next - 1] == loop) {
            count++
            next = arr[next - 1]
            //println("k = $k")
            //println("count = $count")
            k %= count.toLong()
            //println("k = $k")
            break
        }
        count++
        next = arr[next - 1]
    }

    // 残り
    while (k-- > 0) {
        next = arr[next - 1]
    }

    println(next)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

Measured memory_bytes: 63820
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

int visited[1000005];

int main(void) {
  int a, b;
  while (scanf("%d%d", &a, &b) == 2) {
    if (a == 0 && b == 0) break;

    int curr = a % b;
    int t = 0;
    memset(visited, -1, sizeof visited);
    while (1) {
      if (curr == 0) { printf("%d %d\n", t, 0); break; }
      if (visited[curr] != -1) {
        printf("%d %d\n", visited[curr], t-visited[curr]);
        break;
      }
      visited[curr] = t++;
      curr = (curr * 10) % b;
    }
  }
  return 0;
}

Measured memory_bytes: 7080
#include<bits/stdc++.h>
using namespace std;
int isprime(int a){
  int l;
    if(a==2||a==3){
      l=1;
    }
    for(int i=4;i<a;i++){
      if(a%i==0 ){
        l=0;
        i=a;
      }
    }
    return l;
}



int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int c;
  for(int i=n;i<n+1000;i++){
    int d=isprime(i);
    if(d==1){
      
      c=i;
      i=n+1000;
    }else{
      ;
    }
  }
   cout<<c;
  

  
  }




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

int main() {
  string S;
  cin>>S;
  int A=0;
  if(S.at(0)!='A'){
    A+=2;
  }
  for(int i=1;i<S.size();i++){
    if(S.at(i)=='C'&&i!=1&&i!=S.size()-1){
      A++;
    }
    else if(S.at(i)>='A'&&S.at(i)<='Z'){
      A+=2;
    }
  }
  if(A==1){
    cout<<"AC"<<endl;
  }
  else{
    cout<<"WA"<<endl;
  }
}


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

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int oo = 1e9 + 7;

map<int, int> cnt[2];
vector<ii> f[2];
int n;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int a, m = i % 2;
    cin >> a;
    cnt[m][a]++;
  }
  for (int k = 0; k < 2; ++k) {
    for (ii p : cnt[k]) {
      f[k].push_back(make_pair(p.second, p.first));
    }
    sort(f[k].rbegin(), f[k].rend());
  }
  int sz[2] = { int(f[0].size()), int(f[1].size()) };
  int ans = 1e9 + 7;
  for (int i = 0; i < min(2, sz[0]); ++i) {
    for (int j = 0; j < min(2, sz[1]); ++j) {
      if (f[0][i].second != f[1][j].second) {
        ans = min(ans, n / 2 + (n + 1) / 2 - f[0][i].first - f[1][j].first);
      }
      else {
        ans = min(ans, min(n / 2 + (n + 1) / 2 - f[1][j].first, (n + 1) / 2 + n / 2 - f[0][i].first));
      }
    }
  }
  cout << ans;
  return 0;
}


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

using namespace std;

typedef long long ll;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(15);
    int N, T;
    cin >> N >> T;
    int c, t;
    int minc(1001);
    for (int i = 0; i < N; ++i) {
        cin >> c >> t;
        if (t <= T) {
            minc = min<int>(minc, c);
        }
    }
    if (minc == 1001) {
        cout << "TLE\n";
        return 0;
    } else {
        cout << minc << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A[] = new int[N];
    int B[] = new int[N];
    
    for(int i=0; i<N; i++) {
      A[i] = sc.nextInt();
    }
    
    for(int j=0; j<N; j++) {
      B[A[j]-1] = j + 1;
    }
    for(int k=0; k<N; k++) {
      System.out.print(B[k]);
      if(k != N - 1){
        System.out.print(" ");
      }
    }
  }
}

Measured memory_bytes: 63200
const n,k=parse.(split(readline()))
const I=Int[]
ans=nc=nmc=1
M=10^9+7
for i=1:min(n-1,k)
  r=i==1 ? 1 : (M-div(M,i))*I[M%i]%M
  push!(I,r)
  nc=nc*(n-i+1)%M*r%M
  nmc=nmc*(n-i)%M*r%M
  ans+=nc*nmc%M
end
println(ans%M)

Measured memory_bytes: 179856
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename T> class segtree{
private:
    int n,sz;
    vector<T> node;
public:
    segtree(vector<T>& v){
        sz = (int)v.size();
        n = 1;
        while(n < sz){
            n *= 2;
        }
        node.resize(2*n-1, numeric_limits<T>::min());
        rep(i,sz){
            node[i+n-1] = v[i];
        }
        for(int i=n-2; i>=0; i--){
            node[i] = max(node[i*2+1],node[i*2+2]);
        }
    }
    void update(int k,T a){
    	k += n-1;
    	node[k] = a;
    	while(k>0){
    		k = (k-1)/2;
    		node[k] = max(node[2*k+1],node[2*k+2]);
    	}
    }
    T query(int a,int b,int k=0,int l=0,int r=-1){
        if(r < 0) r = n;
    	if(r <= a || b <= l){
    		return numeric_limits<T>::min();
    	}
    	if(a <= l && r <= b){
    		return node[k];
    	}else{
    		T vl = query(a,b,2*k+1,l,(l+r)/2);
    		T vr = query(a,b,2*k+2,(l+r)/2,r);
    		return max(vl,vr);
    	}
    }
    void print(){rep(i,sz)cout<<query(i,i+1)<< " ";cout<<endl;}
};


int main(){
	int n;
	cin >> n;
	vector<int> b(n+1);
	rep(i,n)cin >> b[i+1];
	vector<int> c(n+1);
	for(int i=1;i<=n;i++){
		c[i] = c[i-1]-b[i];
	}
	segtree<int> sg(c);
	vector<pair<int,int> > query;
	int q;
	cin >> q;
	rep(i,q){
		int l,r;
		cin >> l >> r;
		query.PB(MP(l,r));
	}
	sort(query.begin(),query.end());
	int id = 1;
	rep(i,q){
		int l = query[i].first;
		int r = query[i].second;
		while(id <l){
			if(b[id]==0){
				int p = max(sg.query(id,id+1),sg.query(id-1,id)+1);
				sg.update(id,p);
			}else{
				int p = max(sg.query(id,id+1),sg.query(id-1,id)-1);
				sg.update(id,p);
			}
			id++;
		}
		int k = sg.query(l-1,r+1);
		sg.update(r,k);
	}
	while(id <=n){
		if(b[id]==0){
			int p = max(sg.query(id,id+1),sg.query(id-1,id)+1);
			sg.update(id,p);
		}else{
			int p = max(sg.query(id,id+1),sg.query(id-1,id)-1);
			sg.update(id,p);
		}
		id++;
	}
	int ans = sg.query(n,n+1);
	ans-= c[n];
	// for(int i=1;i<=n;i++){
	// 	cout << sg.query(i,i+1) - c[i] << " ";
	// }
	// cout << endl;
	cout << n - ans << endl;
	return 0;
}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const lint inv = MOD - 2;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

lint dp[2010][2010];

int main(){
    lint n, x;
    cin >> n >> x;
    vector<lint> a(n);
    rep(i, n){
        cin >> a[i];
    }
    rep(i, n){
        rep(j, n){
            if(i == 0){
                dp[i][j] = a[j];
            }else{
                if(i > j){
                    dp[i][j] = min(dp[i-1][j], a[j-i+n]);
                }else{
                    dp[i][j] = min(dp[i-1][j], a[j-i]);
                }
            }
        }
    }
    lint ans = LLINF;
    rep(i, n){
        lint tmp = 0;
        rep(j, n){
            tmp += dp[i][j];
        }
        ans = min(ans, i*x + tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 31744