akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

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

    if (s.length() == 2)
        cout << s << endl;
    else
    {
        reverse(s.begin(), s.end());
        cout << s << endl;
    }
}

Measured memory_bytes: 3564
N, M = map(int,input().split())
lim = M // N
ans = 0
for i in range(1, int(M ** (1/2)) + 1):
    if M % i == 0:
        if ans < i <= lim:
            ans = i
        if ans < M // i <= lim:
            ans = M // i
print(ans)

Measured memory_bytes: 38640
n, W = map(int, input().split())
ab = [tuple(map(int, input().split()))for _ in range(n)]
ab.sort()

ans = 0
dp = [0]*W
for a, b in ab:
    if ans < dp[-1]+b:
        ans = dp[-1]+b
    for j in reversed(range(W)):
        if j-a < 0:
            break
        if dp[j] < dp[j-a]+b:
            dp[j] = dp[j-a]+b
print(ans)


Measured memory_bytes: 74864
package main

import (
	"bufio"
	"fmt"
	"os"
	"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()
}

func main() {
	sc.Split(bufio.ScanWords)

	A, B := getInt(), getInt()

	ans := "Impossible"
	if A%3 == 0 || B%3 == 0 || (A+B)%3 == 0 {
		ans = "Possible"
	}
	out(ans)
}


Measured memory_bytes: 640
import java.util.*;

public class Main {

    static long mod = 1_000_000_007L;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long all = modPow(10L, n);
        long eight = modPow(8L, n);
        long nine = modPow(9L, n);
        long ans = (all - nine - nine + eight + mod + mod) % mod;
        System.out.println(ans);
        sc.close();

    }

    static public long modPow(long base, int exp) {
        long ret = 1L;
        while(exp > 0){
            if((exp & 1) == 1){
                ret = ret * base %mod;
            }
            base = base * base %mod;
            exp >>= 1;
        }
        return ret;
    }

}


Measured memory_bytes: 35888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)

int main() {

    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N-1)cin>>A[i];
    vector<int> a(N,0);
    rep(i,N-1)a[A[i]-1]++;
    rep(i,N){
        cout << a[i] << endl;
    }
}

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

public class Main {
	
	static long mod= (long) 1e9+7;
	
		
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Reader.init(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int n=Reader.nextInt(), m=Reader.nextInt(), k=Reader.nextInt();
		long[] a1=new long[n],a2=new long[m];
		a1[0]=Reader.nextInt();
		for(int i=1;i<n;i++) a1[i]=a1[i-1]+Reader.nextInt();
		a2[0]=Reader.nextInt();
		for(int i=1;i<m;i++) a2[i]=a2[i-1]+Reader.nextInt();
		long ans=0;
		for(int i=0;i<n;i++) {
			if(a1[i]<=k) {
				long rem=k-a1[i];
				int l=0,h=m-1,a=-1;
				while(l<=h) {
					int mid=(l+h)/2;
					if(a2[mid]<=rem) {
						l=mid+1;
						a=mid;
					}
					else h=mid-1;
				}
				ans=Math.max(ans, i+1+a+1);
			}
			
		}
		for(int i=0;i<m;i++) {
			if(a2[i]<=k) ans=Math.max(ans,i+1);
		}
		out.println(ans);
		out.flush();
		
	}

}

class Seg{
	
	int[] tree,arr;
	
	Seg(int n,int[] a){
		tree=new int[4*n];arr=a;
	}
	
	void build(int index, int left, int right) {
		if(left==right) tree[index]=arr[left];
		else {
			int mid=(left+right)/2;
			build(2*index+1,left,mid);
			build(2*index+2,mid+1,right);
			tree[index]=Math.max(tree[2*index+1],tree[2*index+2]);
		}
	}
	
	int query(int index, int ql, int qr, int left, int right) {
		if(ql<=left && right<=qr) return tree[index];
		else if(ql > right || qr<left) return 0;
		else {
			int mid=(left+right)/2;
			return Math.max(query(2*index+1,left,mid,ql,qr), query(2*index+2,mid+1,right,ql,qr));
		}
	}
	
	void update(int index, int left, int right, int pos, int val) {
		if(left==right) {
			tree[index]=val;
		}
		else {
			int mid=(left+right)/2;
			if(pos<=mid) {
				update(2*index+1,left,mid,pos,val);
			}
			else update(2*index+2,mid+1,right,pos,val);
			tree[index]=Math.max(tree[2*index+1],tree[2*index+2]);
		}
	}
}


class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
    /** call this method to initialize reader for InputStream */
    static void init() throws IOException {
        reader = new BufferedReader(
                new FileReader("C:\\Users\\samee\\Desktop\\GRE prep\\confusion.txt"));
        tokenizer = new StringTokenizer("");
    }
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
    /** get next word */
    static String nextLine() throws IOException{
        return reader.readLine();
    }
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }
    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}

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

using namespace std;

int main() {
  int n;
  long long k;
  cin>>n>>k;
  vector<int>a(n);
  vector<int>f(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    cin>>f[i];
  }
  sort(a.begin(),a.end());
  sort(f.rbegin(),f.rend());
  long long l=-1;
  long long h=10e12+5;
  while(l+1<h){
    long long mid=(l+h)/2;
    bool ok=[&](){
      long long s=0;
      for(int i=0;i<n;i++){
        s+=max(0ll,a[i]-mid/f[i]);
      }
      return s<=k;
    }();
    if(ok){
      h=mid;
    }else{
      l=mid;
    }
  }
    cout<<h<<endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner inputscan = new Scanner(System.in);
		int W = inputscan.nextInt();
		int H = inputscan.nextInt();
		int x = inputscan.nextInt();
		int y = inputscan.nextInt();
		int r = inputscan.nextInt();

		int Horizontal1 = x - r;
		int Horizontal2 = x + r;
		int Vertical1 = y - r;
		int Vertical2 = y + r;

		if (Horizontal1 >=0 && Horizontal2 <=W && Vertical1 >=0 && Vertical2 <= H) {
			System.out.println("Yes");

		} else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 26336
a, b, c, d = gets.split(" ").map(&:to_i)

lcm = [c, d].inject{|a,b| a.lcm(b)}
c_divisors = (b / c) - ((a - 1) / c)
d_divisors = (b / d) - ((a - 1) / d)
common_divisors = (b / lcm) - ((a - 1) / lcm)
cd_divisors = c_divisors + d_divisors - common_divisors

ans = b - a + 1 - cd_divisors

puts ans

Measured memory_bytes: 1788
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

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

  int x; cin >> x;
  x /= 200;
  cout << 10 - x << endl;

  return 0;
}


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

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

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#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 (ll i = m; i < n; i++)

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> dp(n+1,IINF), c(m);
    REP(i,m)cin >> c[i];
    dp[0] = 0;
    REP(i,n+1){
        REP(j,m){
            if(i>=c[j])dp[i] = min(dp[i-c[j]] + 1, dp[i]);
        }
    }
    cout << dp[n] << endl;
    return 0;
}



Measured memory_bytes: 3148
while true
  a, b, c = gets.split.map(&:to_i)
  break if a == 0 && b == 0 && c == 0

  res = Array.new(a+b+c+1, 2)
  tasks = []
  gets.to_i.times do
    i, j, k, l = gets.split.map(&:to_i)
    if l == 1
      res[i], res[j], res[k] = 1, 1, 1
    else
      tasks << [i, j, k]
    end
  end

  tasks.each do |task|
    corrects = []
    task.each{ |n| corrects << n if res[n] == 1 }
    if corrects.size == 2
      incorrect = (task - corrects).first
      res[incorrect] = 0
    end
  end

  res.shift
  puts res
end

Measured memory_bytes: 6116
import scala.collection.mutable.{Map => MMap, ArrayBuffer}
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N, M = in.nextInt
  val map = MMap[Int, ArrayBuffer[Int]]()
  (1 to M).foreach {_ =>
    val a, b = in.nextInt
    map.getOrElseUpdate(a, new ArrayBuffer[Int]()) += b
    map.getOrElseUpdate(b, new ArrayBuffer[Int]()) += a
  }

  val result = new Array[Int](N)
  result(0) = 1

  def dfs(rooms: List[Int]): Unit = {
    if (rooms.nonEmpty) {
      dfs(for {
        r <- rooms
        next <- map(r)
        if result(next - 1) == 0
      } yield {
        result(next - 1) = r
        next
      })
    }
  }
  dfs(List(1))

  if (result.tail.exists(_ == 0)) println("No")
  else {
    println("Yes")
    println(result.tail.mkString("\n"))
  }
}

Measured memory_bytes: 94524
#include <iostream>

using namespace std;

int func(int ans){
    
    if(ans == 1)return 1;
    return ans *= func(ans - 1);
}

void fuck(int X[], int box, int N){
    for(int i = 1; i < N; i ++){
        if(X[i] > box)X[i] --;
        X[i - 1] = X[i];
    }
}

int main(){
    int N, P[10], Q[10], cntP = 0, cntQ = 0;

    cin >> N;
    for(int i = 0; i < N; i ++)cin >> P[i];
    for(int j = 0; j < N; j ++)cin >> Q[j];

    int box;
    while(1){
        if(N == 1)break;
        box = P[0];
        cntP += func(N - 1) * (box - 1);
        fuck(P, box, N);
        box = Q[0];
        cntQ += func(N - 1) * (box - 1);
        fuck(Q, box, N);
        N --;
    }

    cout << abs((cntP + 1) - (cntQ + 1)) << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

 
signed main(void){
    int N;
    string S;
    cin >> N >> S;
    if(N%2==1){GOODBYE;}
    REP(i,N/2){
        if(S[i]!=S[N/2+i])GOODBYE;
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 256
/*
 * WelcomeToAtCoder.cpp
 *
 *  Created on: 2020/02/19
 *      Author: black
 */
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

int top;

void push(int *a, int num){
	a[++top] = num;
}

int pop(int *a){
	return a[top--];
}

int main(){
	top = 0;
	int S[1000] = {0};
	char input[100];
	int tmp;

	while(scanf("%s", input) != EOF){
		if (input[0] == '+'){
			tmp = pop(S);
			push(S ,pop(S) + tmp);
		}
		else if(input[0] == '-'){
			tmp = pop(S);
			push(S ,pop(S) - tmp);
		}
		else if(input[0] == '*'){
			tmp = pop(S);
			push(S ,pop(S) * tmp);
		}
		else if(input[0] == '/'){
			tmp = pop(S);
			push(S ,pop(S) / tmp);
		}
		else{
			push(S, atoi(input));
		}
	}

	printf("%d\n", pop(S));

	return 0;
}



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

int main(){
  string s;
  cin >> s;
  bool e=false;
  char prev='*';
  for(char c:s){
    if(prev=='A' && c=='C'){
      e=true;
      break;
    }
    prev=c;
  }
  if(e) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
ans = H*W

for h in range(1,H+1):
  S1 = h*W
  S2 = (H-h)*(W//2)
  S3 = (H-h)*(W-W//2)
  Smax = max(S1,S2,S3)
  Smin = min(S1,S2,S3)
  tmp1 = Smax-Smin
  S4 = (H-h)//2*W
  S5 = ((H-h)-(H-h)//2)*W
  Smax = max(S1,S4,S5)
  Smin = min(S1,S4,S5)
  tmp2 = Smax-Smin
  ans = min(ans,tmp1,tmp2)
for w in range(1,W+1):
  S1 = H*w
  S2 = (W-w)*(H//2)
  S3 = (W-w)*(H-H//2)
  Smax = max(S1,S2,S3)
  Smin = min(S1,S2,S3)
  tmp1 = Smax-Smin
  S4 = (W-w)//2*H
  S5 = ((W-w)-(W-w)//2)*H
  Smax = max(S1,S4,S5)
  Smin = min(S1,S4,S5)
  tmp2 = Smax-Smin
  ans = min(ans,tmp1,tmp2)
print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        while ((str = br.readLine()) != null) {
            String[] strArray = str.split(" ");
            int[] numArray = new int[strArray.length];
            for (int count = 0; count < strArray.length; count++) {
                numArray[count] = Integer.parseInt(strArray[count]);
            }
            int output = numArray[0] + numArray[1];
            System.out.println(output);
        }
    }
}

Measured memory_bytes: 17160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const int mod = 1e5;
const int MAX = 1e7;

bool check(deque<char> q1, deque<char> q2) {
    bool ok = true;
    while(!q1.empty()) {
        char c_1 = q1.front(); q1.pop_front();
        char c_2 = q2.front(); q2.pop_front();
        if (c_1 != c_2) ok = false;
    }
    return ok;
}

int main() {
    string s, t; cin >> s >> t;
    int n = s.size();
    deque<char> q_s;
    deque<char> q_t;
    rep(i,n) q_s.push_back(s[i]);
    rep(i,n) q_t.push_back(t[i]);
    rep(i,n) {
        char c = q_s.front(); q_s.pop_front();
        q_s.push_back(c);
        if (check(q_s,q_t)) {cout << "Yes" << endl; return 0;}
    }
    cout << "No" << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int ans = 1;
  for (int i = 0; i < n - 1; i++) {
    if (a.at(i) > a.at(i + 1)) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main() {
    int n, m, Min=1000001, Max=-1000000;
    long Sum=0;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> m;
        if(m < Min){
            Min = m;
        }
        if(m > Max){
            Max = m;
        }
        Sum += m;
    }
    cout << Min << " " << Max << " " << Sum << endl;
    return 0;
}

Measured memory_bytes: 1164
from math import gcd

def count(x, c, d):
  # x以下のcでもdでも割り切れない奴を数える
  lcm = c // gcd(c, d) * d
  return x - x // c - x // d + x // lcm

a,b,c,d=map(int,input().split())
print(count(b,c,d)-count(a-1,c,d))


Measured memory_bytes: 9132
import java.util.Scanner;
import java.lang.Math;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		double r=in.nextDouble();
		System.out.println(String.format("%.6f %.6f",r*r*Math.PI,Math.PI*r*2));
	}
}

Measured memory_bytes: 28332
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(a,n) rep(i,0,n){ cout<<(i ? " ":"")<<a[i]; }cout<<endl;
#define pprint(a,m,n) rep(j,0,m){ print(a[j],n); }
const int mod = 1e9+7;
const int size=1e5;
const int INF=1e9;
int main(){
	int N,A,B;cin>>N>>A>>B;
	int ans=0;
	rep(i,1,N+1){
		int temp=i;int sum=0;
		while(temp){
			sum+=temp%10;
			temp/=10;
		}if(A<=sum&&sum<=B) ans+=i;
	}cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
import numpy as np

# N 駅の数
n = int(input())

# C　次の駅までかかる時間、S 開始後発射時間、F　間隔
act = [list(map(int, input().split())) for ii in range(n-1)]

for i in range(n):
    t = 0
    for j in range(i, n-1):
        if t < act[j][1]:
            t = act[j][1]
        elif t % act[j][2] == 0:
            pass
        else:
            t += act[j][2] - (t % act[j][2])
        t += act[j][0]
    print(t)

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  int ans = 0;
  int i = 1;
  while ((x - z) >= (y + z) * i) {
    ans++;
    i++;
  }
  cout << ans << endl;
  return 0;
}


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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;


lli layer[51]; // layer[i]: レベルi に含まれる層数
lli p[51]; // p[i]: レベルi に含まれるパティの数
int main() {
    lli n, x;
    cin2(n, x);

    layer[0] = 1;
    p[0] = 1;
    REPE(i,1,n) {
        layer[i] = layer[i-1] * 2 + 3;
        p[i] = p[i-1] * 2 + 1;
        //cout3(i, layer[i], p[i]);
    }
    lli cur = n;
    lli ans = 0;

    REPE_R(cur,n,1) {
        if (x > layer[cur-1] + 1) {
            ans += p[cur-1];
            x -= layer[cur-1]+2;
            ans++;
        }
        else {
            x--;
        }
    }
    if (x > 0)
        ans++;

    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
n = int(input())
pre = input()
suf = input()
if pre==suf:
    print(n)
    sys.exit()
slicer, ans = n-1 , n*2
for xx in range(n+1):
    if suf[:slicer] in pre:
        ans = len(pre)+(len(suf)-len(suf[:slicer]))
        break
    slicer-=1
print(ans)

Measured memory_bytes: 9116
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
d = gets.chomp.to_i
e = 0
f = 0
a.times do
  if b > e
    e += 1
    f += c
  else
    f += d
  end
end
puts f

Measured memory_bytes: 1788
kekka=list(input())
count=len(kekka)
plus=15-count
c=[]
for w in kekka:
    if w=='o':
        c.append(1)
    else:
        c.append(0)
res=sum(c)+plus
if (int(res)>7):
    print("YES")
else:
    print("NO")
        

Measured memory_bytes: 3060
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String b = sc.next();
		sc.close();
		sc = null;
		String ans = "";
		switch(b) {
		case "A":{ans="T";break;}
		case "T":{ans="A";break;}
		case "C":{ans="G";break;}
		case "G":{ans="C";break;}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#define LOCAL

#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define LLINF 100000000000000005LL
#define INF (int)1e9+1
#define pb push_back

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;
using db = double;

int main() {
	IOS;
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<int> dp(n);
	for (int i = 1; i < n; i++) {
		if (i == 1) dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
		else dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
	}
	cout << dp[n - 1];
}

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

int main(){
	int N, Q, M, temp;
	
	while(1){
		int temp2[300] = {}, ans = 0;
		cin>>N>>Q;
		
		if(N == 0 && Q == 0) break;
		
		for(int i = 1; i <= N; i++){
			cin>>M;
			for(int j = 1; j <= M; j++){
				cin>>temp;
				temp2[temp]++;
			}
		}
		
		for(int i = 1; i <= 250; i++){
			if(temp2[ans] < temp2[i])ans = i;
		}
		
		if(temp2[ans] >= Q) cout<<ans<<endl;
		else cout<<0<<endl;
	}
	return 0;
}


Measured memory_bytes: 3072
#include<cstdio>

char S[101010];

int main(){
    scanf("%s",S);

    bool app[26];
    for(int i=0;i<26;i++){
        app[i]=false;
    }
    for(int i=0;S[i]!='\0';i++){
        app[S[i]-'a']=true;
    }
    for(int i=0;i<26;i++){
        if(!app[i]){//false unexist
            printf("%c\n",(char)(i+'a'));
            return 0;
        }
    }
    puts("None");
    return 0;
}

Measured memory_bytes: 256
n = int(input())
lst = []
for i in range(n):
    w = input()
    if w in lst: #唯一性の確認
        print('No')
        exit()
    else:
        lst.append(w)
    if i==0:
        h = w[-1]
    elif w[0] != h:
        print('No')
        exit()
    else:
        h = w[-1]
print('Yes')
    
    

Measured memory_bytes: 3060
var n,i,t,p:longint;
    res,ord:array[0..1000000]of longword;
    a,b:array[0..1000000]of word;
    cnt:array[0..65535]of longint;
begin
  readln(n);
  for i:=1 to n do
  begin
    read(t);
    a[i]:=t>>16;
    b[i]:=t and pred(1<<16);
    inc(cnt[b[i]]);
  end;
  p:=1;
  for i:=0 to 65534 do
  begin
    inc(cnt[p],cnt[i]);
    inc(p);
  end;
  for i:=1 to n do
  begin
    ord[cnt[b[i]]]:=i;
    dec(cnt[b[i]]);
  end;
  fillchar(cnt,sizeof(cnt),0);
  for i:=1 to n do
    inc(cnt[a[i]]);
  p:=1;
  for i:=0 to 65534 do
  begin
    inc(cnt[p],cnt[i]);
    inc(p);
  end;
  for i:=n downto 1 do
  begin
    p:=a[ord[i]];
    res[cnt[p]]:=ord[i];
    dec(cnt[p]);
  end;
  for i:=1 to n-1 do
    if a[res[i]]<<16 or b[res[i]]=a[res[i+1]]<<16 or b[res[i+1]] then
    begin
      writeln('NO');
      halt;
    end;
  writeln('YES');
end.

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

int main() { 
    int n, k, ans = 1e9;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a+n);
    for(int i = 0; i <= n - k; ++i) {
        ans = min(ans, abs(a[i] - a[i + k - 1]));
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi 3.141592653589793283462
int main(){
	int p,q;
	cin>>p>>q;
	cout<<p*q<<" "<<2*(p+q)<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  string S,T;
  cin>>S>>T;
  int N=S.size();
  int M=T.size();

  int ans=N;
  for(int i=0;i+M-1<N;i++){
    int res=0;
    rep(j,M) if(S[i+j]!=T[j]) res++;
    chmin(ans,res);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3656
l=[[] for i in range(9)]
l[1]=[""]
l[2]=["0","1"]
for i in range(3,9):
    for s in l[i-1]:
        l[i].append("0"+s)
        if s[0]!="1":
            l[i].append("1"+s)

mod=1000000007
s=input().split()
h,w,k=int(s[0]),int(s[1]),int(s[2])
dp=[[0]*(w) for i in range(h+1)]
dp[0][0]=1
for i in range(h):
    for s in l[w]:
        s="0"+s+"0" #どの縦棒から見ても左右が参照できるように両端に0をつけておく
        for j in range(w):
            if s[j]=="0" and s[j+1]=="0": #直進
                dp[i+1][j]+=dp[i][j]
                dp[i+1][j]%=mod
            if s[j]=="0" and s[j+1]=="1": #左列に移る
                dp[i+1][j+1]+=dp[i][j]
                dp[i+1][j+1]%=mod
            if s[j]=="1" and s[j+1]=="0": #右列に移る
                dp[i+1][j-1]+=dp[i][j]
                dp[i+1][j-1]%=mod
print(dp[h][k-1])

Measured memory_bytes: 41200
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  /*
  int S,W; cin >> S >> W;
  if(W>=S) cout << "unsafe" << endl;
  else cout << "safe" << endl;
  */
  int A,B,C,D; cin >> A >> B >> C >> D;
  int a=(C+B-1)/B;
  int b=(A+D-1)/D;
  if(a<=b) Yes
  else No
  return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<math.h>
using namespace std;
int main() {
	long a, b, c, k;
	cin >> a >> b >> c >> k;
	if (a == b == c) {
		cout << 0 << endl;
		return 0;
	}
	long res;
	if (k % 2 == 0) {
		res = a - b;
	}
	else {
		res = b - a;
	}
	
	if (abs(res) >(1e18)) {
		cout << "Unfair" << endl;
		return 0;
	}
	cout << res << endl;
	return 0;
}

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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

vl v(5);
ll n;

void read() {
  cin >> n >> v[0] >> v[1] >> v[2] >> v[3] >> v[4];
}

void solve() {
  cout << max({(n - 1) / v[0], (n - 1) / v[1], (n - 1) / v[2], (n - 1) / v[3], (n - 1) / v[4]}) + 5;
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
//  cin >> t; //please do not forget to comment this if there are no queries
  while(t) {
    --t;
    read();
    solve();
  }
  return 0;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import Data.List
import Control.Monad

main = do
  [n, k] <- map read . words <$> getLine :: IO [Int]
  input <- sortBy (\x y -> compare (fst x) (fst y)) . (\[x, y] -> zip x y) . transpose <$> getInt2DListBC
  print $ solve k 0 input

bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getInt2DListBC :: IO [[Int]]
getInt2DListBC = map (map bsToInt . BC.words) . BC.lines <$> BC.getContents

solve :: Int -> Int -> [(Int, Int)] ->  Int
solve k sum ((a, b):s)
  | sum + b >= k = a
  | otherwise    = solve k (sum + b) s


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  ll ans = 0;
  for (ll i = 1; i <= N; i+= 2) {
    ll cnt = 0;
    for (ll j = 1; j <= i; j++) {
      if (i % j == 0) cnt++;
    }
    if (cnt == 8) ans++;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int counter;
	for (int i = a; i <= b; i++) {
		if (c % i == 0)	counter++;
	}
	cout << counter << endl;
}


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

int main() {
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int diffH = H2 - H1;
  int diffM = M2 - M1;
  if (diffM < 0) {
    diffH -= 1;
    diffM = 60 - abs(diffM);
  }
  int awake = diffH * 60 + diffM;
  if(diffH * 60 + diffM - K > 0)
    cout << awake - K << endl;
  else
    cout << 0 << endl;

  return 0;
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int a, b; cin >> a >> b;
    int cnt = 0;
    for(int i=1; i<=a; i++){
        if(i==a){
            for(int j=1; j<=b; j++){
                if(i==j){
                    cnt++;
                }
            }
        }
        else{
            for(int j=1; j<=31; j++){
                if(i==j){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

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


#define rep(i,n) for(int i = 0; i < n; i++)

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 1; i < N+1; i++)
    {
      cin >> a[i];
    }
  int cnt = 0;
  for(int i = 1; i < N+1; i++)
    {
      if(a[i] < i)
	{
	  continue;
	}
      if(a[a[i]] == i)
	{
	  cnt++;
	}
    }
  cout << cnt << endl;

  
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>

int main() {
        std::vector<int> panels(3);

        for (auto& v : panels) {
                std::cin >> v;
        }

        std::sort(std::begin(panels), std::end(panels));

        std::cout << panels[2] * 10 + panels[1] + panels[0] << std::endl;

        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, a, b) for (int i = a; i < (int)(b); i++)
using ll = long long;
ll item[3001][3001], dp[4][3001][3001];
ll R, C, K, r, c, v, ans;
int main()
{
  cin >> R >> C >> K;
  rep(i, K)
  {
    cin >> r >> c >> v;
    item[r - 1][c - 1] = v;
  }
  rep2(i, 1, R + 1)
  {
    rep2(j, 1, C + 1)
    {
      rep(k, 4)
      {
        dp[k][i][j] = dp[k][i][j - 1];
      }
      dp[0][i][j] = max(dp[0][i][j], dp[3][i - 1][j]);
      if (item[i - 1][j - 1] > 0)
      {
        dp[1][i][j] = max(dp[1][i][j], dp[3][i - 1][j] + item[i - 1][j - 1]);
        rep2(k, 1, 4)
        {
          dp[k][i][j] = max(dp[k][i][j], dp[k - 1][i][j - 1] + item[i - 1][j - 1]);
        }
      }
      rep2(k, 1, 4)
      {
        dp[k][i][j] = max(dp[k - 1][i][j], dp[k][i][j]);
      }
    }
  }
  rep(k, 4)
  {
    ans = max(ans, dp[k][R][C]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 355068
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))

L.sort()

ans = 0
for i in range(N - 2):
  a = L[i]
  for j in range(i + 1, N - 1):
    b = L[j]
    c = bisect_left(L, a + b)
    ans += c - j - 1

print(ans)

Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
int main(void){
  int N,i,j,temp;
  double ans=0;
  double a=2.0;
  int V[51];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&V[i]);
  }
  for(i=0;i<N-1;i++){
    for(j=i+1;j<N;j++){
      if(V[i]>V[j]){
        temp=V[i];
        V[i]=V[j];
        V[j]=temp;
        }
      }
  }
  ans=ans+(double)V[0];
  for(i=1;i<N;i++){
    ans=(ans+(double)V[i])/a;
  }
printf("%lf",(double)ans);
  return 0;
}

Measured memory_bytes: 128
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;


#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  ll               long long
#define  vi               std::vector<int>
#define  pb               push_back
#define  MAX              100007
#define  End              return 0;
#define  pi               acos(-1)

int main () {
    ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    while(n!=0){
        if(n%10==7){
            cout<<"Yes"<<endl;
            End;
        }
        n/=10;
    }
    cout<<"No"<<endl;
    End
}
/* pray for me
Do before die
*/


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    A.push_back(0);
    lint ans = 0, sum = 0;
    rep(i, N + 1) {
        if (A[i] == 0) {
            ans += sum / 2;
            sum = 0;
        } else {
            sum += A[i];
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1152
/*
    アリナ・グレイはかわいい
*/

#include<bits/stdc++.h>
using namespace std;
#define itn int
#define endl "\n"

int main(void){
    int n,m;
    cin >> n >> m;
    int a[m],b[m];
    int num[200001] = {};
    for(int i = 0;i < m;i++)cin >> a[i] >> b[i];
    
    for(int i = 0;i < m;i++){
        if(a[i] == 1)num[b[i]]++;
        if(b[i] == n)num[a[i]]++;
    }
    bool check = false;
    for(itn i = 2;i < n;i++){
        if(num[i] > 1)check = true;
    }
    if(!check)cout << "IM";
    cout << "POSSIBLE" << endl;
}


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

#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)
#define REP(i, n, m) for (long long i = (long long)(n); i < (long long)(m); i++)

namespace combinatorics {
  const int limit = 1000010;
  const int mod = 1000000007;

  bool initialized = false;
  long long fac_table[limit], inv_table[limit], finv_table[limit];

  void initialize() {
    fac_table[0] = fac_table[1] = 1;
    inv_table[1] = 1;
    finv_table[0] = finv_table[1] = 1;
    for (int i = 2; i < limit; i++) {
      fac_table[i] = fac_table[i - 1] * i % mod;
      inv_table[i] = mod - inv_table[mod % i] * (mod / i) % mod;
      finv_table[i] = finv_table[i - 1] * inv_table[i] % mod;
    }
    initialized = true;
  }

  long long com(int n, int k) {
    if (!initialized) initialize();
    if (n < k || n < 0 || k < 0) return 0;
    else return fac_table[n] * (finv_table[k] * finv_table[n - k] % mod) % mod;
  }
}

namespace solver {
  using namespace std;
  using combinatorics::com;
  typedef long long ll;

  ll X, Y;

  void init() {
    scanf("%lld %lld", &X, &Y);
  }

  void solve() {
    ll total = X+Y;
    if(total%3 != 0) {
      cout << 0 << endl;
      return;
    }
    ll moves = total/3;
    ll diff = abs(X-Y);
    cout << com(moves, (moves-diff)/2) << endl;
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 23680
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

var n int
var nums []string

func dfs(s string) int {
	if len(s) > len(strconv.Itoa(n))+1 {
		return math.MaxInt64
	}
	sv, _ := strconv.Atoi(s)
	if sv >= n {
		return sv
	}

	ans := math.MaxInt64
	for _, v := range nums {
		ans = min(ans, dfs(s+v))
	}
	return ans
}

func main() {
	n = scanInt()
	k := scanInt()
	d := make(map[int]bool)
	for i := 0; i < k; i++ {
		x := scanInt()
		d[x] = true
	}

	nums = make([]string, 0, 10)
	for i := 0; i <= 9; i++ {
		if !d[i] {
			nums = append(nums, strconv.Itoa(i))
		}
	}
	fmt.Println(dfs(""))
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

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

    int N;
    std::cin >> N;

    if(N == 3 || N == 5 || N == 7){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

class Main {
	static int[] segTree;
	static int[] lazy;
	static int n; // nearest power of 2 to true length of array
	// i.e. true length = 13 -> n = 16 = 2*2*2*2

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int len = scanner.nextInt();
		int q = scanner.nextInt();

		initSegTree(len);

		int type;
		for (int i = 0; i < q; i++) {
			type = scanner.nextInt();
			if(type == 0) {
				// update(s,t,x): Change a[s]...a[t] to x
				update(scanner.nextInt(), scanner.nextInt(), scanner.nextInt());
				// printArr();
			} else if(type == 1) {
				// find(s,t): Find minimum in range [s,t]
				int result = find(scanner.nextInt(), scanner.nextInt());
				System.out.println(result);
			}
		}
	}

	static void initSegTree(int _n) {
		n = 1;
		while(n < _n)
			n *= 2;

		segTree = new int[2*n-1];
		Arrays.fill(segTree, Integer.MAX_VALUE);

		lazy = new int[2*n-1];
		Arrays.fill(lazy, -1);
	}

	static void lazy_evaluate(int k) {
		if(lazy[k] == -1)
			return;

		segTree[k] = lazy[k];
		if(k < n-1) { // not leaf
			lazy[2*k+1] = lazy[k];
			lazy[2*k+2] = lazy[k];
		}
		lazy[k] = -1;
	}

	static void update(int s, int t, int x) {
		update(0, 0, n-1, s, t, x);
	}

	static void update(int k, int l, int r, int s, int t, int x) {

		lazy_evaluate(k);

		// Out of range
		if(s > t || s > r || t < l)
			return;

		// Node k is a leaf
		if(s <= l && r <= t) {
			lazy[k] = x;
			lazy_evaluate(k);
			return;
		}

		// If not a leaf node, recur for children
		int mid = (l+r)/2;
		update(k*2+1, l, mid, s, t, x);
		update(k*2+2, mid+1, r, s, t, x);

		// Use the results of children calls to update this node
		segTree[k] = Math.min(segTree[k*2+1], segTree[k*2+2]);
	}

	static int find(int s, int t) {
		return query(0, 0, n, s, t+1);
	}

	static int query(int k, int l, int r, int s, int t) {
		lazy_evaluate(k);

		// Out of range
		if(r <= s || t <= l)
			return Integer.MAX_VALUE;

		// [l,r] inside [s,t]
		if(s <= l && r <= t) 
			return segTree[k];

		// Intersect
		int mid = (l+r)/2;
		int minLeft = query(k*2+1, l, mid, s, t);
		int minRight = query(k*2+2, mid, r, s, t);

		return Math.min(minLeft, minRight);
	}
}


Measured memory_bytes: 116868
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main() {
    int n, m, result = 0;
    cin >> n >> m;
    vector<int> graph[m + n + 1];
    for (int i = 0, k; i < n; i++) {
        cin >> k;
        for (int j = 0, l; j < k; j++) {
            cin >> l;
            graph[i].emplace_back(l + n);
            graph[l + n].emplace_back(i);
        }
    }
    queue<int> queue;
    vector<bool> visited(m + n + 1);
    queue.emplace(0);
    visited[0] = true;
    do {
        if (queue.front() < n) {
            result++;
        }
        for (auto i : graph[queue.front()]) {
            if (!visited[i]) {
                visited[i] = true;
                queue.emplace(i);
            }
        }
        queue.pop();
    } while (!queue.empty());
    if (result == n) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 8824
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>
#include<iomanip>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const int MOD = 1000000007;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
template<class T>
int dp2csv(const vector<vector<T>> & dp, const string fname);
int range_check(int val, int min, int max) {
	if (val < min) {
		return min;
	}
	if (val > max) {
		return max;
	}
	return val;
}
template<class T,class T1>
bool array_find(const T& array, const T1& dst) {
	auto result = find(array.first(), array.end(), dst);
	if (result == array.end()) {
		return false;
	}
	else {
		return true;
	}
}

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if (a + b + c <= 21) {
		cout << "win" << endl;
	}
	else {
		cout << "bust" << endl;
	}
	
	return 0;
}
template<class T>
int dp2csv(const vector<vector<T>> & dp, const string fname) {
	ofstream ofs(fname);
	if (ofs.fail()) { cerr << "cannot open file. :" + fname << endl; return -1; }
	for (auto dp_row : dp) {
		for (auto dp_cell : dp_row) {
			ofs << dp_cell << ",";
		}
		ofs << endl;
	}
	ofs.close();
	return 0;
}


Measured memory_bytes: 256
import sys
n = int(input())
t, x, y = 0, 0, 0
for i in range(n):
    ti, xi, yi = map(int, input().split())
    if ti - t < abs(xi - x) + abs(yi - y) or not (abs(xi - x) + abs(yi - y) + ti - t )% 2 ==0:
        print("No")
        exit()
    else:
        t, x, y = ti, xi, yi
print("Yes")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){int a,b,m,i,ma=100000,mb=100000,ans,l,r,c;
cin>>a>>b>>m;
int A[a+1],B[b+1];
for(i=1;i<=a;i++){cin>>A[i];
    ma=min(ma,A[i]);
}
for(i=1;i<=b;i++){cin>>B[i];
    mb=min(mb,B[i]);
}
ans=mb+ma;
while(m--){
    cin>>l>>r>>c;
    ans=min(ans,A[l]+B[r]-c);
}
cout<<ans;
    return 0;}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <stack>
#include <cctype>
#include <algorithm>
#include <vector>
using namespace std;
const double PI = 3.14159265358979323846;

int main() {
	int N;
	cin >> N;
	vector<int> employees = vector<int>(N, 0);

	for (int i = 0; i < N-1; i++) {
		int a = 0;
		cin >> a;

		employees[a-1]++;
	}

	for (auto itr = employees.begin(); itr != employees.end(); itr++) {
		cout << *itr << endl;
	}
	return 0;
}

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

int main(){
    int n; cin>>n;
    set<int> set;
    for(int i=0;i<n;i++){
        int a; cin>>a;
        if(set.find(a)!=set.end()){
            set.erase(a);
        }else{
            set.insert(a);
        }
    }
    cout<<set.size()<<endl;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

/*
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    //std::map<char, int> mp
    int cnta = 0 , cntb = 0;
    for (size_t i = 0; i < 3; i++) {
        if(s[i] == 'A'){
            cnta++;
        }
        else{
            cntb++;
        }
    }
    if(cnta == 0 || cntb == 0){
        cout<<"No\n";
    }
    else{
        cout<<"Yes\n";
    }
    return 0;
}
*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int n,b,r;cin>>n>>b>>r;
    ll int rem , time;
    rem = n%(b+r);
    if(rem > b){
        rem = b;
    }
    time = n/(b+r);
    cout<<((ll)b*time) + rem;
    return 0;
}


Measured memory_bytes: 256