akhauriyash/Code-Regression huggingface dataset:
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
for i in range(1, n + 1):
    a[i] += a[i - 1]
for i in range(1, m + 1):
    b[i] += b[i - 1]

ans = 0
for i in range(len(a)):
    rest = k - a[i]
    if rest < 0:
        break
    left, right = -1, len(b)
    while right - left > 1:
        mid = (left + right) // 2
        if rest - b[mid] >= 0:
            left = mid
        else:
            right = mid
    # print(f"{rest}を越えない最大のBiは{b[left]}")
    ans = max(ans, i + left)
print(ans)

Measured memory_bytes: 40020
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
bool check(vector<int> v){
	int n=(int)v.size();
	int sum=0;
	for(int i=0;i<n-1;i++)sum+=v[i];
	return(v[n-1]<sum);
}
void solve(){
   int n;
  cin>>n;
  vector<int> v(n);
  for(auto &it:v)cin>>it;
  sort(all(v));
  cout<<(check(v)?"Yes":"No")<<endl;	
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}

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

int main() {
	long long int A, B, K;
	cin >> A >> B >> K;
	A -= K;
	if (A < 0) {
		K = A * -1;
		A = 0;
		B -= K;
		if (B < 0) B = 0;
	}
	cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
int n;
cin>>n;
if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
cout<<"hon";
else if(n%10==0||n%10==1||n%10==6||n%10==8)
cout<<"pon";
else if(n%10==3)
cout<<"bon";
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, K;
    cin >> N >> K;
    if (N % K == 0) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
s = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
t = s.split(", ")
k = int(input())
print(t[k-1])

Measured memory_bytes: 2940
//FIRST THINK THEN CODE.

  #include <bits/stdc++.h>


  using namespace std;

  typedef long long ll;

  #define rep(i,a,b) for(ll i=a;i<b;++i)
  #define rrep(i,a,b) for(ll i=a;i>b;--i)
  #define FOR(i,n)  for(ll i=0;i<n;i++)
  #define vi vector<int>
  #define vl vector<ll>
  #define ld long double
  #define vld vector<ld>
  #define vvi vector<vector<int>>
  #define vvl vector<vector<long long>>
  #define vvld vector<vector<ld>>
  #define pii pair<int,int>
  #define pll pair<long,long>
  #define vpii vector<pii>
  #define vpll vector<pll>
  #define ff first
  #define ss second
  #define pb push_back
  #define pf push_front
  #define mp make_pair
  #define lb lower_bound
  #define ub upper_bound
  #define bs binary_search
  #define d1(x) cout<<(x)<<endl
  #define d2(x,y) cout<<(x)<<" "<<(y)<<endl
  #define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
  #define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
  #define PI 3.1415926535897932384626433832795
  #define fix(f,n) fixed<<setprecision(n)<<f
  #define all(x) x.begin(),x.end()
  #define rev(p) reverse(p.begin(),p.end());
  #define endl "\n"
  #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  #define popcount(x) __builtin_popcountll(x)
  #define sz(x) ((ll)x.size())
  const ll M=1000000007;
  const ll MM=998244353;
  ll begtime = clock();
  #define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
  //#define _Find_next 
  //#define _Find_first 



  ll newmod(ll a,ll b)
  {
  return ((a%b)+b)%b;
  }


  ll powM(ll a,ll b,ll m )
  { 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
  if(b&1)ans=ans*a%m;
  a=a*a%m;
  b>>=1;
  }

  return ans;
  }



  ll poww(ll a,ll b)
  { 

  ll ans=1;
  while(b)
  {
  if(b&1)ans=ans*a;
  a=a*a;
  b>>=1;
  }

  return ans;

  }

  template<typename T,typename F>
  void chmax( T &a,F b){
  if(b>a)a=b;
  }

  template<typename T,typename F>
  void chmin( T &a,F b){
  if(b<a)a=b;
  }

string tostring(ll x){
  stringstream sss;
  sss<<x;
  string ans=sss.str();
  return ans;
}


  const ll N=2e5+5;

ll par[N];

ll find(ll x){
if(x==par[x])return x;
return par[x]=find(par[x]);

}

void unio(ll a,ll b){
  a=find(a),b=find(b);
if(a==b)return ;
par[a]=b;
}


  int main()
  { 

    IOS;


ll n;cin>>n;

for(ll i=1;i<=n;i++)par[i]=i;

  ll m;cin>>m;

while(m--){
  ll a,b;
  cin>>a>>b;
  unio(a,b);
}

vl f(n+1);
ll ans=0;

for(ll i=1;i<=n;i++){
  ll x=find(i);
  f[x]++;
}
for(ll i=1;i<=n;i++){
  chmax(ans,f[i]);
}


cout<<ans;

//end_routine();

  return 0;

  }

Measured memory_bytes: 12632
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

int abs(int x){
    return x >= 0 ? x : -x;
}


int main(){
    int n; cin >> n;
    int a[n],b[n] , c[n];

    rep(i,n){
        cin >> a[i] >> b[i] >> c[i];
    }

    int da[n],db[n], dc[n];
    int check = 0;
    
    da[0] = a[0];
    db[0] = b[0];
    dc[0] = c[0];
 
    for(int i=1 ; i<n ; i++){ 
        da[i] = db[i] = dc[i] = 0;

        da[i] = a[i] + max(db[i-1],dc[i-1]);
        db[i] = b[i] + max(da[i-1],dc[i-1]);
        dc[i] = c[i] + max(db[i-1],da[i-1]);

        
    }

    int ans = max(da[n-1],max(db[n-1],dc[n-1]));
    cout << ans << endl;

    

}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n,b,c,i,t,res;
  string s;
  cin >> n;
  cin >> s;
  c=0;
  for(i=1;i<=n;i++)
    if(s.substr(i-1,1)=="#") c++;
  res=n-c;
  b=0;
  for(i=1;i<=n;i++){
    if(s.substr(i-1,1)=="#") b++;
    t=n-i-c+2*b;
    if(t<res) res=t;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (ll)1000000007

int main()
{
    int N;
    ll K;
    cin >> N >> K;
    int A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    ll c = 0; //i桁目の数字よりも大きい数の総数（1≦i≦N）
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (i != j)
            {
                if (A[j] > A[i])
                {
                    c++;
                    c %= INF;
                }
            }
        }
    }
    ll count = 0; //(0≤i<j≤N−1)であって A[i]>A[j]のものの数の総数
    for (int i = N - 1; i >= 0; i--)
    {
        for (int j = i - 1; j >= 0; j--)
        {

            if (A[j] > A[i])
            {
                count++;
                count %= INF;
            }
        }
    }
    ll ans = 0;
    ll k = K;
    K = K * (K - 1) / 2 %INF;
    ans = k * count % INF + K * c % INF;
    cout << ans % INF << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
long long mod = 1000000007;
long long power(long long m,long long n){
    long long res = 1;
    if(n > 0){
        res = power(m,n / 2);
        if(n % 2 == 0){
            res = (res * res) % mod;
        }
        else{
            res = (((res * res) % mod) * m) % mod;
        }
    }
    return res;
}
//modはグローバル変数にしておく
int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> factorial(3000);
  factorial[0] = 1;
  factorial[1] = 1;
  for(int i = 2;i < 3000;i++)factorial[i] = factorial[i - 1] * i,factorial[i] %= mod;
  for(int i = 1;i <= k;i++){
    ll res = 0;
    res = 1;
    if(n - k + 1 < i)res = 0;
    else{
    res *= factorial[n - k + 1],res %= mod;
    //if(i == 50)cout<<res<<endl;
    res *= power(factorial[i],mod - 2),res %= mod;
      //if(i == 50)cout<<res<<endl;
    res *= power(factorial[n - k + 1 - i],mod - 2),res %= mod;
      //if(i == 50)cout<<res<<endl;
    res *= factorial[k - 1],res %= mod;
      //if(i == 50)cout<<res<<endl;
    res *= power(factorial[i - 1],mod - 2),res %= mod;
      //if(i == 50)cout<<res<<endl;
    res *= power(factorial[k - i],mod - 2),res %= mod;
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 256
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: usize = read();
    let xyv: Vec<Vec<i64>> = read_vec2(n);
    if n == 1 {
        println!("1");
        return;
    }
    let mut v: Vec<(i64, i64)> = vec![];
    for i in 0..n {
        for j in i + 1..n {
            let x = xyv[i][0] - xyv[j][0];
            let y = xyv[i][1] - xyv[j][1];
            if x > 0 || (x == 0 && y > 0) {
                v.push((x, y));
            } else {
                v.push((-x, -y));
            }
        }
    }
    v.sort_by(|p, q| {
        if p.0 != q.0 {
            p.0.partial_cmp(&q.0).unwrap()
        } else {
            p.1.partial_cmp(&q.1).unwrap()
        }
    });
    let mut max: usize = 1;
    let mut cnt: usize = 1;
    for i in 1..v.len() {
        if v[i] == v[i - 1] {
            cnt += 1;
        } else {
            if cnt > max {
                max = cnt;
            }
            cnt = 1;
        }
    }
    if cnt > max {
        max = cnt;
    }
    println!("{}", n - max);
}


Measured memory_bytes: 4352
import java.util.Scanner;

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

        double x1 = scanner.nextDouble();
        double y1 = scanner.nextDouble();
        double x2 = scanner.nextDouble();
        double y2 = scanner.nextDouble();

        System.out.println(Math.sqrt(Math.pow(x2-x1, 2) + Math.pow(y2-y1, 2)));

        scanner.close();
    }
}



Measured memory_bytes: 27820
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <cstring>
#include <utility>
#include <vector>
#include <climits>
#include <cstdio>
#include <cmath>
#include <unordered_map>
using namespace std;
void solve()
{
	int n;
	cin>>n;
	int temp,f=1;
	for(int i=0;i<n;i++) {cin>>temp;
		if(!(temp&1))
		{
			if(temp%3)
			{
				if(temp%5)
					f=0;
			}
		}
	}
	if(f)
		cout<<"APPROVED\n";
	else cout<<"DENIED\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(12);

	// int t;
	// cin>>t;
	// while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define rep(i, n) for(int i=0;i<n;i++)

  
int main(){
  int n;
  cin >> n ;
  if(n%111==0) cout << n << endl;
  else cout << (n/111+1)*111 <<endl;
}

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



int main(){
    int64_t n, m, s, t;
    cin>> n >> m >> s >> t;
    vector<vector<P>> G_yen(n+1), G_snuuk(n+1);
    rep(i,m){
        int64_t u,v,a,b;
        cin>>u>>v>>a>>b;
        G_yen[u].push_back(make_pair(v,a));
        G_yen[v].push_back(make_pair(u,a));
        G_snuuk[u].push_back(make_pair(v,b));
        G_snuuk[v].push_back(make_pair(u,b));
    }

    //スタート地点から各都市までの最小のyenを求める
    priority_queue<P,vector<P>,greater<P>> pq_yen; 
    vector<ll> yen_min_map(n+1,-1); 
    pq_yen.push(make_pair(0,s));

    while(pq_yen.size()!=0){
        P temp1 = pq_yen.top();
        pq_yen.pop();
        ll node_num = temp1.second;
        ll edge_cost  = temp1.first;

        if(yen_min_map[node_num]!=-1){
            continue;
        }
        yen_min_map[node_num] = edge_cost;

        //pqをアプデする
        rep(i,G_yen[node_num].size()){
            P temp2 = G_yen[node_num].at(i);
            ll node_num2 = temp2.first;
            ll edge_cost2 = temp2.second;
            pq_yen.push(make_pair(edge_cost+edge_cost2,node_num2));
        }
    }

    priority_queue<P,vector<P>,greater<P>> pq_snuuk; 
    vector<ll> snuuk_min_map(n+1,-1); 
    pq_snuuk.push(make_pair(0,t));

    while(pq_snuuk.size()!=0){
        P temp1 = pq_snuuk.top();
        pq_snuuk.pop();
        ll node_num = temp1.second;
        ll edge_cost  = temp1.first;
        if(snuuk_min_map[node_num]!=-1){
            continue;
        }

        snuuk_min_map[node_num] = edge_cost;

        //pqをアプデする
        rep(i,G_snuuk[node_num].size()){
            P temp2 = G_snuuk[node_num].at(i);
            ll node_num2 = temp2.first;
            ll edge_cost2 = temp2.second;
            pq_snuuk.push(make_pair(edge_cost+edge_cost2,node_num2));
        }
    }


    vector<ll> total_min_map(n+1); 
    rep(i,n){
        total_min_map[i+1] = yen_min_map[i+1] + snuuk_min_map[i+1];
    }

    ll first_money = pow(10,15);
    /*
    for(ll i=0;i<n;i++){
        ll min = *std::min_element(total_min_map.begin()+i+1, total_min_map.end());
        cout<<first_money-min<<endl;
    }
    */
   vector<ll> min_cost(n+1);
   rep(i,n){
       if(i==0){
           min_cost[n-i] = total_min_map[n-i];
       }else{
           if(total_min_map[n-i]<min_cost[n-i+1]){
               min_cost[n-i] = total_min_map[n-i];
           }else{
               min_cost[n-i] = min_cost[n-i+1];
           }
       }
   }
   rep(i,n){
       cout<<first_money-min_cost[i+1]<<endl;
   }






}


Measured memory_bytes: 22132
#include<iostream>

int main(){
    int i,a,b;
    char op='+';


    while(op!='?'){
        std::cin>>a>>op>>b;

        if(op=='+'){
            std::cout<<a+b<<std::endl;
        }else if(op=='-'){
            std::cout<<a-b<<std::endl;
        }else if(op=='*'){
            std::cout<<a*b<<std::endl;
        }else if(op=='/'){
            std::cout<<a/b<<std::endl;
        }
    }   

    return 0;
}   


Measured memory_bytes: 3088
def root(i):
  if par[i] == i:
    return i
  par[i] = root(par[i])
  return par[i]

def union(x, y):
  rx = root(x)
  ry = root(y)
  if rx != ry:
    par[ry] = rx

def same(x, y):
  return par[x] == par[y]

n,m = map(int, input().split(" "))
p = [0] + list(map(int, input().split(" ")))
a = [(list(map(int, input().split(" ")))) for i in range(m)]
par = list(range(n + 1))
count = 0
for i, j in a:
  union(i, j)
  #print(par)
#print(p)
for i in range(1, n + 1):
  if same(root(par[p[i]]), root(par[i])):
    count += 1
print(count)

Measured memory_bytes: 35420
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using namespace std;
using ll = mp::cpp_int;

int main() {
	ll n;
	cin >> n;
	ll t_ans = 1;
	ll a_ans = 1;
	for (ll i = 0; i < n; ++i) {
		ll t, a;
		cin >> t >> a;
		ll Min = 0;
		ll Max = (ll)1e18 + 1;
		while (Max - Min > 1) {
			ll Mid = (Min + Max) / 2;
			if (t_ans > t * Mid || a_ans > a * Mid) {
				Min = Mid;
			}
			else {
				Max = Mid;
			}
		}
		t_ans = t * Max;
		a_ans = a * Max;
	}
	cout << t_ans + a_ans << endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int main() {
	ll K, A, B;
	cin >> K >> A >> B;
	if (A >= B || B - A < 2) {
		cout << K + 1 << endl;
	}
	else {
		if (K <= A) cout << K + 1 << endl;
		else cout << A + (K - A + 1) / 2 * (B - A) + (K - A + 1) % 2 << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=85,low=80*80*3;
int a[N][N],b[N][N];
bitset<N*N*8>dp[N][N];
int mx[N][N];
int n,m;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        scanf("%d",&a[i][j]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        scanf("%d",&b[i][j]);
    dp[1][1].set(a[1][1]-b[1][1]+low,1);
    dp[1][1].set(b[1][1]-a[1][1]+low,1);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
    {
        if(i==1&&j==1) continue;
        int x=abs(a[i][j]-b[i][j]);
        dp[i][j]=(dp[i-1][j]<<x)|(dp[i-1][j]>>x)|(dp[i][j-1]<<x)|(dp[i][j-1]>>x);
    }
    int ans=1e9;
    for(int i=0;i<=low*3;i++)
        if(dp[n][m][i])
        {
            ans=min(ans,abs(i-low));
        }
    printf("%d\n",ans);
}


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

//?????§????????????P?????¨??????k??°???????????????????????¶?????¨?????§?????????????????°(?????§??§n???)????????????
int C_num(int P,int k,vector<int> w,int n){
  int i=0,cnt=0,sum,j=0;
  while(i<k){
    sum=0;
    while(sum+w[j]<=P){
      sum+=w[j];
      j++;
      if(j==n) return n;
    }
    i++;
  }
  return cnt;
}

int solve(int k,vector<int> w,int n){
  int left=0;
  int right=10000*100000; //?????§?????????????????§??????
  int mid;
  while(right-left>1){
    mid=(right+left)/2;
    int v=C_num(mid,k,w,n);
    if(v>=n) right=mid;
    else left = mid;
  }
  return right;
}

int main(){
  vector<int> w;
  int n,k,temp;
  cin >> n >> k;
  for(int i=0;i<n;i++) {
    cin >> temp;
    w.push_back(temp);
  }
  int ans=solve(k,w,n);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2328
#include<bits/stdc++.h>
#define int long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--) 
#define mod 1000000007
using namespace std;

void Onigiri()
{
  int n;
  cin>>n;
  int sum=0;
  rep(i,1,n+1)
  { 
    if(i%3!=0&&i%5!=0)sum+=i;
  }
  cout<<sum;

}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
   #endif  
 
   int t=1; 
   //cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}

Measured memory_bytes: 3800
#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
  ll a, b, c;
  cin >> a >> b >> c;
  if(a % 2 == 0 or b % 2 == 0 or c % 2 == 0) cout << 0 << endl;
  else cout << min(a * b, min(b * c, c * a)) << endl;
}

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

int main(){
    int A, B;
    cin >> A >> B;
    int ans = 0;
    if((B - 1) % (A - 1)){
        ans = (B - 1) / (A - 1) + 1;
    }
    else{
        ans = (B - 1) / (A - 1);
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int a[10010], ans[105][105];
signed main(void)
{
  int h, w;
  cin >> h >> w;
  int n;
  cin >> n;
  REP(i, n) cin >> a[i];

  int x = 0, y = 0;
  bool flag = true;
  REP(i, n) {
    while(a[i]) {
      // cout << i << " " << a[i] << " " << x << " " << y << endl;
      ans[y][x] = i+1;
      if(flag) {
        x++;
        if(x >= w) {
          x = w-1;
          y++;
          flag = false;
        }
      } else {
        x--;
        if(x < 0) {
          x = 0;
          y++;
          flag = true;
        }
      }
      a[i]--;
    }
  }

  REP(i, h) {
    REP(j, w) {
      cout << ans[i][j];
      if(j != w-1) cout << " ";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 384
def sigm(nk):
    s=3**3*(3**(nk-2)-1)/(3-1)
    s=s-3*2**3*(2**(nk-2)-1)/(2-1)
    s=s+(nk-2)*3
    return int(s)
    
n=int(input())

if n<357:
    print(0)
else:
    x0=[357,375,537,573,735,753]
    x1=[3,5,7]
    m=0
    nk=len(str(n))
    if nk==3:
        for j in range(6):
            x=x0[j] 
#            print(x)
            if x<=n:
                m=m+1
    else:
        m=sigm(nk-1)
        for i in range(3**nk):
            ii=i
            x=0
            for j in range(nk):
                iii=ii//3
                ir=ii-iii*3
                ii=(ii-ir)//3
                x=x+int(x1[ir])*10**j
            xstr=str(x)
            if xstr.find("3")>=0 and xstr.find("5")>=0 and xstr.find("7")>=0 and n>=x:
                m=m+1                 
    print(m)


Measured memory_bytes: 3064
import numpy as np
N, M = map(int, input().split())
if N >= M:
    res = 0
else:
    array = np.array(sorted([int(i) for i in input().split()]))
    res = np.sort(np.diff(array, n=1))[::-1]
    res = sum(res[N-1:])
print(res)

Measured memory_bytes: 23008
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int s,w;
    cin >> s >> w;
    if(s<=w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}

int main() {
	cin >> n;
	double a;
	if (n % 2 == 0) {
		a = n / 2;
	}
	else {
		a = (n-1) / 2 + 1;
	}
	cout << setprecision(7)<< a / n << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <map>
#include <queue>
#include <stack>
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
using namespace std;
typedef long long ll;

int main(){
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    loop {
        let (n, x) = input();
        if (n, x) == (0, 0){
            break;
        }
        let mut y = 0;
        if x > 5{
            for i in 1..x/3{
                if n > i{
                    let z = two(n-i, x-3*i);
                    y += z;
                }
            }
        }
        println!("{}", y);
    }
}

fn two(n: i64, x: i64) -> i64{
    if x % 2 == 0{
        if x / 2 < n && x / 2 <= n - (x / 2){
            (x / 2) - 1 
        }
        else if x / 2 < n && x / 2 > n - (x / 2){
            n - (x / 2) 
        }
        else {
            0
        }
    }
    else {
        if (x - 1) / 2 < n && (x - 1) / 2 <= n - (x - 1) / 2{
            (x - 1) / 2 
        }
        else if (x - 1) / 2 < n && (x - 1) / 2 > n - (x - 1) / 2{
            n - (x - 1) / 2
        }
        else{
            0
        }
    }
}

fn input() -> (i64, i64) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();

    let n: i64 = iter.next().unwrap().parse().unwrap();
    let x: i64 = iter.next().unwrap().parse().unwrap();

    (n, x)
}


Measured memory_bytes: 5020
#include <stdio.h>
#include <string.h>
int main(){
int a,b,x,y;
char c[100];
scanf("%d",&a);
getchar();
scanf("%[^\n]",&c);

x=strlen(c);
y=x-a;
if(x>a){
	for (int i=0;i<a;i++){
		printf("%c",c[i]);
	}
	printf("...\n");
}

else{
	for(int i=0;i<x;i++){
		printf("%c",c[i]);
	}
}
}

Measured memory_bytes: 1612
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
 
int dp[3111][3111];
ii par[3111][3111];
 
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s,t;
	cin>>s>>t;
	int m=s.length();
	int n=t.length();
	for(int i=1; i<=m; i++) 
    { 
		for(int j=1; j<=n; j++) 
		{ 
			dp[i][j]=0;
			if(dp[i-1][j]>=dp[i][j])
			{
				par[i][j]=mp(i-1,j); dp[i][j]=dp[i-1][j];
			}
			if(dp[i][j-1]>=dp[i][j])
			{
				par[i][j]=mp(i,j-1); dp[i][j]=dp[i][j-1];
			}
			if(s[i-1]==t[j-1]&&dp[i-1][j-1]+1>=dp[i][j]) 
			{
				dp[i][j]=dp[i-1][j-1]+1; par[i][j]=mp(i-1,j-1);
			}
		}
	}
	ii cur = mp(m,n);
	string ans;
	while(cur.fi>0&&cur.se>0)
	{
		ii tmp=par[cur.fi][cur.se];
		if(tmp.fi==cur.fi-1&&tmp.se==cur.se-1) ans+=s[tmp.fi];
		cur=tmp;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<'\n';
}

Measured memory_bytes: 186624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
const int INF=1001001001;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int main(){
    int n;
    cin >> n;
    rep2(i, 1, 10)
    {
        rep2(j,1,10){
            if(n==i*j){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    
    """
    dp[i][j]はi番目までで，重さ合計がjとなるときの価値の最大値にしたい．
    s<10**4　なので，jは10**4 + 10**4まで．
    ただし，上から積む時に実際には優先度がつくので，重りを適切な基準でソートすべき．
    
    現状，重さがXで，a番目とj番目を使うとして，
    「X,a,bの順番ならおけるけど，X,b,aの順だとおけない」
    という状況を考える．
    
    この時，S_j>=X+w_i かつ，s_i<X+w_j　なので．
    S_j - w_i >= X > s_i - w_j　である．
    Xを消去して移項すると，
    s_j+w_j > s_i+w_i
    
    これを基準にソートですね．
    
    """
    N=I()
    wsv=[]
    for i in range(N):
        w,s,v=MI()
        wsv.append([w,s,v])
        
    wsv.sort(key=lambda x:(x[0]+x[1]))
    
    N2=2*(10**4) +1
    dp=[[0]*N2 for _ in range(N+1)]
    
    for i in range(N):
        w,s,v=wsv[i]
        for j in range(N2):
            dp[i+1][j]=max(dp[i][j],dp[i+1][j])
            if s>=j and j+w<=(N2-1):
                dp[i+1][j+w]=max(dp[i+1][j+w],dp[i][j]+v)
                
    print(max(dp[-1]))
            
        

main()


Measured memory_bytes: 189852
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<int> h;
  rep(i,N){
    int a;
    cin >> a;
    h.push_back(a);
  }

  int ret = 0;
  vector<vector<int>> v;
  v.push_back(h);
  while(v.size() > 0){
    vector<vector<int>> w;
    rep(i,v.size()){
      vector<int> tmp;
      rep(j,v[i].size()){
        if(v[i][j] == 0){
          if(tmp.size() > 0){
            w.push_back(tmp);
            tmp.clear();
          }
        }else{
          tmp.push_back(v[i][j]);
        }
      }
      if(tmp.size() > 0) w.push_back(tmp);
    }
    v = w;
    rep(i,v.size()){
      ret++;
      rep(j,v[i].size()){
        v[i][j]--;
      }
    }
  }

  cout << ret << endl;
  
  return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}
template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}
template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}


int main()
{
	string s,t,u;
	ll a,b;
	cin >> s >> t >> a >> b >> u;
	if(u == s)a--;
	if(u == t)b--;
	cout << a << " " << b << endl;
    return 0;
}

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

int main(){
    string S;
    long K;
    long count, ans, count_first;
    bool flag,flag2;
    cin >> S;
    cin >> K;
    count=1;
    ans=0;
    count_first=0;
    flag=true; // one character or not
    flag2=false; // last character flag
    for(long i=1; i<S.size(); i++){
        if( S[i]==S[i-1] ){
            count++;
        }else{
            ans+=count/2;
            if(flag){
                flag=false;
                count_first=count;
            }
            count=1;
        }

        if( i==S.size()-1 ){
            if( count%2==1 && K!=1 ){
                if( S[i]==S[0] ){
                    ans+=count/2;
                    if(flag){
                        count_first=count;
                    }
                    if( (count+count_first)%2==0 ){                    
                        ans+=1;
                        flag2=true;
                    }
                }else{
                    ans+=count/2;
                    flag=false;
                }
            }else{
                ans+=count/2;
                flag=false;
            }
        }
    }

    ans=ans*K;
    if(flag){
        if( S.size()==1 ){
            ans= K/2;
        }else{
            ans=ans-(K+1)/2; // aaa aaa aaa -> aba bab aba (2*3 - 2 )
        }
    }else if(flag2){
        ans=ans-1;        
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
	int n;
  	string s;
    cin >> n >> s;
  	string t = s.substr(0, n/2);
  
  	if (n % 2 == 0 && s == t + t) {
      cout <<  "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N;
    string S;
    cin >> N >> S;
    ll ans = 0;
    rep(i, 0, N){
        map<char, ll> mp1, mp2;
        rep(j, 0, i){
            mp1[S[j]]++;
        }
        rep(j, i, N){
            mp2[S[j]]++;
        }
        ll cnt = 0;
        for(char c = 'a'; c <= 'z'; c++){
            if(mp1.count(c) > 0 && mp2.count(c) > 0) cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

//X+Y = C and Y=C-X. 
//Therefore X-Y = 2X - C. So A tries to maximise X and B tries to maximize X as C=(sum of A[i]) is constant

//State
//dp[i][j][k]: The number of points A has
//	when the queue to choose from is (A[i]....A[j]) where player k starts first

//Initialization
//dp[i][i] = A[i]

//Transitions
//if(i+N-1-j %2 == 0) dp[i][j] = max(dp[i+1][j]+A[i], dp[i][j-1]+A[j])
//else dp[i][j] = min(dp[i+1][j]+A[i], dp[i][j-1]+A[j])

//Order of evaluation
//Diagonally or Length of substring wise

//Answer
//dp[0][N-1]

long long dp[3005][3005][2];
int A[3005];

int main(){
	int N; long long C=0;
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> A[i];
		dp[i][i][0] = A[i];
		dp[i][i][1] = 0;
		C = C+A[i];
	}
	
	for(int rMinusl=1; rMinusl<N; rMinusl++){
		for(int l=0; l<N; l++){
		    int r = l+rMinusl;
			if(r<N){
				dp[l][r][0] = max(dp[l+1][r][1]+A[l], dp[l][r-1][1]+A[r]);
			    dp[l][r][1] = min(dp[l+1][r][0], dp[l][r-1][0]);
			}   
		}
	}
	
	cout << 2*dp[0][N-1][0]-C << endl;
}


Measured memory_bytes: 85296
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<string> c(2);
  for(int i=0;i<2;i++)
    cin>>c.at(i);
  bool f=1;
  for(int i=0;i<2;i++)
    for(int j=0;j<3;j++)
      f=(c.at(i).at(j)!=c.at(1-i).at(2-j)?0:f);
  cout<<(f?"YES":"NO")<<endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;

int main(){
    int K, N;
    int di = 0;
    cin >> K >> N;
    vector<int> A(N);
    for(int i=0; i<N; ++i){
        cin >> A[i];
    }
    for(int j=1; j<N; ++j){
        di = max(di, A[j]-A[j-1]);
    }
    di = max(di, A.front()+K-A.back());
    int ans = K-di;
    cout << ans << endl;

}


Measured memory_bytes: 1024
from itertools import groupby
S = input()
K = int(input())
lenS = len(S)

cnt1 = 0

idx = 0
for key, values in groupby(S):
  len_values = len(list(values))
  if idx == 0:
    fst_key = key
    fst_len_values = len_values

  if len_values >= 2:
    cnt1 += len_values//2
  idx += 1

if idx == 1:
  print((lenS*K)//2)
  exit()

cnt2 = cnt1
cnt3 = 0
if key == fst_key:
  if fst_len_values >= 2:cnt2 -= fst_len_values//2
  if len_values >= 2:cnt2 -= len_values//2 
  cnt3 = (fst_len_values+len_values)//2
    
print(cnt1 + (cnt2+cnt3)*(K-1))
#print(cnt1, cnt2, K, fst_len_values, len_values)

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int INF = 1e9;

int main(){
	int n, m, k;
	cin >> n >> m >> k;
	VI d(n, -1);
	REP(i,m){
		int x;
		cin >> x;
		d[x-1] = i;
	}
	VVI e(m, VI(k));
	REP(i,n) REP(j,k){
		int x;
		cin >> x;
		if (d[i] == -1) continue;
		e[d[i]][j] = d[x-1];
	}

	VI dist(1<<m, INF);
	dist[(1<<m)-1] = 0;
	queue<int> que;
	que.push((1<<m)-1);
	while (dist[0] == INF){
		int a = que.front();
		que.pop();
		REP(j,k){
			int x = 0;
			REP(i,m){
				if ((a>>i) & 1 && e[i][j] >= 0){
					x |= (1<<e[i][j]);
				}
			}
			if (dist[x] != INF) continue;
			dist[x] = dist[a] + 1;
			que.push(x);
		}
	}

	cout << dist[0] << endl;

    return 0;
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define pb push_back
#define eb emplace_back
#define fst first
#define snd second
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

signed main(){
  int n, l; cin >> n >> l;
  vi a(n); rep(i,n) a[i] = l+i;
  dump(a);
  int pos, minv = inf;
  rep(i,n){
    if(chmin(minv,abs(a[i]))) pos = i;
  }
  cout << accumulate(all(a),0ll) - a[pos] << endl;
}


Measured memory_bytes: 256
n=int(input())
s=[]
for i in range(n):
    if i==0:
        x=input()
        s.append(x)
        letter=set(x)
    else:
        x=input()
        s.append(x)
        letter=set(x) & letter
letter=sorted(letter)
count={}
for j in letter:
    for k in s:
        if not j in count:
            count[j]=k.count(j)
        else:
            if count[j]>k.count(j):
                count[j]=k.count(j)
ans=""
for x in letter:
    ans=ans+x*count[x]
print(ans)

    

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    LL A, B, N;
    cin >> N >> A >> B;

    LL r = N / (A+B);

    LL ans = r*A + min(N-r*(A+B), A);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main()
{
    ll n,k,ans = 0;
    cin >> n >> k;
    vector<ll> h(n);
    rep0(i, n)cin >> h[i];
    sort(all(h));
    rep0(i, n - k)ans += h[i];
    pf(ans);
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    int res = 1;

    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);

        y = y>>1;
        x = (x*x);
    }
    return res;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}
vector<int>primeFactors(int n)
{
    vector<int>v;
    while (n % 2 == 0)
    {
        v.pb(2);
        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            v.pb(i);
            n = n/i;
        }
    }
    if (n > 2)
        v.pb(n);
    return v;
}

void solve()
{
int s,w;
cin>>s>>w;
if(w>=s)
    cout<<"unsafe"<<endl;
else
    cout<<"safe"<<endl;
}

signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{
  solve();
}
}


Measured memory_bytes: 3616
#!/usr/bin/env python
# coding: utf-8

# In[3]:


import numpy as np


# In[42]:


N = int(input())
data = []
for i in range(N):
    data.append((list(map(int, input().split()))))


# In[43]:


data = np.array(data)


# In[44]:


sorted_data = data[np.argsort(data[:, 1])]
cumsum_data = np.cumsum(sorted_data[:,0])


# In[45]:


flag = 0
for i in range(N):
    if cumsum_data[i] > sorted_data[i, 1]:
        flag = 1
        break

if flag == 0:
    print("Yes")
else:
    print("No")


# In[ ]:






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

int main() {
    int a,b,k,mini=0,max=0;
    cin>>a>>b>>k;
    set<int> ans;
    for (int i=a; i<a+k; i++) {
        if (a<=i&&i<=b) ans.insert(i);
    }
    for (int i=b-k+1; i<=b; i++) {
        if (a<=i&&i<=b) ans.insert(i);
    }
    for (auto v: ans) cout<<v<<endl;
}


Measured memory_bytes: 256
x,n = map(int,input().split())
ps = list(map(int,input().split()))
ps.sort()

allowed = []
for i in range(102):
    if i not in ps:
        allowed.append(i)

for j in range(len(allowed)-1):
    if x-allowed[j+1] == 0:
        print(x)
        exit()
    elif (x-allowed[j]) * (x-allowed[j+1]) > 0:
        continue
    else:
        if x-allowed[j] <= allowed[j+1] - x:
            print(allowed[j])
        else:
            print(allowed[j+1])

Measured memory_bytes: 9212
n,m,c = (int(i) for i in input().split())
b = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for i in range(n)]
x = 0
for i in a:
    num = 0
    for j in range(m): num+=i[j]*b[j]
    if num+c>0: x+=1
print(x)

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

using namespace std;

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

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

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define  endl 			"\n"
#define  FOR(i, a, n)   for (ll i = a; i < n; i++)
#define  ROF(i, a, n)   for (ll i = a; i >= n; i--)
#define  all(x)         (x).begin(), (x).end()
#define  mset(x, val)   memset(x,val,sizeof(x))
#define  dline          cout<<"///REACHED///\n";

typedef long long ll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  4e+5+7;



int main() {
	string s;
	bool ans = false;
	bool sawC=false;
	cin>>s;
	if(s[0]!='A') {cout<<"WA"<<endl;return 0;}
	if(!islower(s[1]) or s[1]=='C') {ans=false; sawC=true;}
	FOR(i,2,s.size()-1){
		if(!islower(s[i])){
			if(s[i]=='C' and !sawC){
				sawC=true;
				ans=true;
			}
			else{

			ans=false;
			}
		}
		// debug(ans);

	}
	if(!islower(s[s.size()-1])){
		ans=false;
	}
	
	if(ans)cout<<"AC"<<endl;
	else{ cout<<"WA"<<endl;}
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

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

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	vector<int> line(10);
	int va, vb;
	while(~scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &line[0], &line[1], &line[2], &line[3], &line[4], &line[5], &line[6], &line[7], &line[8], &line[9], &va, &vb)) {
		int linesum = accumulate(all(line), 0);
		double dist = linesum * ((double)va / (va + vb));
		vector<int> ls(10);
		ls[0] = line[0];
		for(int i = 1; i < 10; i++) ls[i] = ls[i - 1] + line[i];
#if 0
		cerr << dist << endl;
		cerr << "begin" << endl;
		for(int i=0,n=ls.size(); i<n;i++) cerr << ls[i] << endl;
		cerr << "end" << endl;
#endif
		cout << (lower_bound(all(ls), dist) - ls.begin()) + 1 << endl;
	}
	return 0;
}

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

const int N  = 100;

int cnt[N];
int n, m;

int main(){
	scanf("%d%d", &n, &m);
	for (int i = 0, u, v; i < m; ++ i){
		scanf("%d%d", &u, &v);
		++ cnt[u];
		++ cnt[v];
	}
	for (int i = 1; i <= n; ++ i){
		printf("%d\n", cnt[i]);
	}
	return 0;
}

Measured memory_bytes: 256