akhauriyash/Code-Regression huggingface dataset:
W, H, N = map(int, input().split())
xya = [tuple(map(int, input().split())) for _ in range(N)]

l = 0
r = W
d = 0
u = H

for x, y, a in xya:
    if a==1:
        l = max(l,x)
    elif a==2:
        r = min(r,x)
    elif a==3:
        d = max(d,y)
    else:
        u = min(u,y)

if r>l and u>d:
    print((r-l)*(u-d))
else:
    print(0)

Measured memory_bytes: 3064
# include <bits/stdc++.h>
# define LL long long
using namespace std;
int main(){
	LL n, a, b;
	cin >> n >> a >> b;
	if((a - b) % 2 == 0){
		cout << (b - a) / 2 << endl;
	}else{
		cout << min(n - b, a - 1) + (b - a + 1) / 2 << endl;
	}
}


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

int main(){
    char a,b,c;
    cin >> a >> b >> c;
    if(a=='A'&&b=='A'&&c=='A')cout << "No" << endl;
    else if(a=='B'&&b=='B'&&c=='B')cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar()
#define pc(x) putchar(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=char(n%10+48);n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;
using ll = long long;
const int MM = 2e5+5;
const ll mod = 1e9+7;

int n;
ll a[MM], sum, ans;

int main(){
	scan(n);
	for(int i = 0; i < n; i++){
		scan(a[i]);
		ans += sum*a[i];
		ans %= mod;
		sum += a[i];
		sum %= mod;
	}
	print(ans);
}

Measured memory_bytes: 5188
#include<stdio.h>
#define max 100000
int high;

double parent(int h){
    return h/2;
}
int left(int i){
    return 2*i;
}
int right(int i){
    return 2*i+1;
}

int main(){
    int A[max+1],i,p,r,l;
    scanf("%d",&high);
    //二分岐には0が存在しないので１から始める
    for(i=1;i<=high;i++){
        scanf("%d",&A[i]);
    }
    for(i=1;i<=high;i++){
        printf("node %d: key = %d, ",i,A[i]);
        if((p=parent(i)) >= 1){
             printf("parent key = %d, ",A[p]);
        }
        if((l=left(i))<= high){
            printf("left key = %d, ",A[l]);
        }else{
            //printf("\n");
        }
         if((r=right(i)) <= high){
            printf("right key = %d, \n",A[r]);
        }else{
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>

int main(void){
	while(1){
		long n, i;
		long a[7] = {0};
		int age;
		
		scanf(" %ld", &n);
		if(n==0) break;
		
		for(i=0; i<n; i++){
			scanf(" %d", &age);
			if(age>60) age=60;
			
			a[age/10]++;
		}
	
		for(i=0; i<7; i++)
			printf("%ld\n", a[i]);

	}

	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int main()
{
	int N, M;
	scanf ("%d %d", &N, &M);
	
	int x = 0;
	for (int a = 1; a < N; a++)
	{
		x = x + a;
	}
	
	int y = 0;
	for (int b = 1; b < M; b++)
	{
		y = y + b;
	}
	
	if (N + M >= 2)
	{
		printf ("%d", x + y);
	}
	
	return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a));
#define all(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
int n, m, k, t, T, x, y, sum, cnt, ans;
ll a[3005], dp[3005][3005], p[3005];
ll recur(int l, int r) {
  if (l == r) return a[l];
  if (dp[l][r]) return dp[l][r];
  ll one = p[r] - p[l] - recur(l + 1, r) + a[l];
  ll two = p[r-1] - p[l-1] - recur(l, r - 1) + a[r];
  return dp[l][r] = max(one, two); 
}
int main () {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  FOR(i, 1, n) {
    cin >> a[i];
    p[i] = p[i-1] + a[i];
  }
  ll A = recur(1, n);
  cout << A + A - p[n] << endl;
  return 0;
}


Measured memory_bytes: 50028
#include<iostream>
using namespace std;
int book[200001];
long long sm[200001];
int a[200001];
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;++book[a[i++]])
		cin>>a[i];
unsigned long long s=0;
	for(int i=1;i<=n;s+=sm[i++])
		sm[i]=(long long)(book[i])*(book[i]-1)/2;
	for(int i=1;i<=n;++i)
	{
		cout<<s-sm[a[i]]+(long long)(book[a[i]]-1)*(book[a[i]]-2)/2<<endl;
	}
}

Measured memory_bytes: 5248
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int[] primeList = new int[5200];
        int n = 50023;
        primeList[0] = 2;
        primeList[1] = 3;
        int count = 2;
        for (int i = 5; i <= n; i += 2) {
            boolean wflag = true;
            for (int j = 1; primeList[j] * primeList[j] <= i; j++) {
                if (i % primeList[j] == 0) {
                    wflag = false;
                    break;
                }
            }
            if (wflag) {
                primeList[count++] = i;
            }
        }
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int m = sc.nextInt();
            int a = 0;
            int b = 0;
            for (int i = 0; i < primeList.length; i++) {
                if (primeList[i] >= m) {
                    if (primeList[i] == m) {
                        b = i + 1;
                    } else {
                        b = i;
                    }
                    a = i - 1;
                    break;
                }
            }
            System.out.println(primeList[a] + " " + primeList[b]);
        }
    }
}



Measured memory_bytes: 26632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pown(ll fi,ll se){
  ll ans=1;
  rep(i,se){
    ans*=fi;
  }
  return ans;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
vec(a,5);
a=getv<ll>(5);
ll k;
cin>>k;
rep(i,5){
  repf(j,i+1,5){
    if((a[j]-a[i])>k){
      op(":(");
      return 0;
    }
  }
}
op("Yay!");
return 0;
}

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

ll adj[305][305], path[305][305];
ll n,m,u,v,d,l,q,ct,st,end1;
int flag;
ll MAX = 1e18;

int main(){
	cin>>n>>m>>l;

	for(int i = 1; i<=n; i++){
		for(int j = 1; j<=n; j++){
			if(i == j)continue;
			adj[i][j] = MAX;
		}
	}

	for(ll i = 0; i<m; i++){
		cin>>u>>v>>d;
		if(d <= l){
			adj[u][v] = d;
			adj[v][u] = d;
			path[u][v] = u;
			path[v][u] = v;
		}
	}
	//cout<<1;

	for(int i = 1; i<=n; i++){
		for(int j = 1; j<=n; j++){
			for(int k = 1; k<=n; k++){
				if(adj[j][k] > adj[j][i] + adj[i][k]){
					adj[j][k] = adj[j][i] + adj[i][k];
				}
			}
		}
	}
	
	for(int i = 1; i<=n; i++){
		for(int j = 1; j<=n; j++){
			if(i == j) continue;
			adj[i][j] = (adj[i][j] <= l)? 1 : MAX; 
		}
	}

	for(int i = 1; i<=n; i++){
		for(int j = 1; j<=n; j++){
			for(int k = 1; k<=n; k++){
				if(adj[j][k] > adj[j][i] + adj[i][k]){
					adj[j][k] = adj[j][i] + adj[i][k];
				}
			}
		}
	}

	cin>>q;
	for(int i = 1; i<=q; i++){
		cin>>u>>v;
		if(adj[u][v] == MAX)
			cout<<-1<<endl;
		else
			cout<<adj[u][v]-1<<endl;
	}
	
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main() {
	ll q, h, s, d; cin >> q >> h >> s >> d;
	ll n; cin >> n;
	ll Min = min({ q * 8,h * 4,s * 2,d });
	ll Min2 = min({ q * 4,h * 2,s });
	cout << (n / 2)*Min + (n % 2)*Min2 << endl;
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
import fractions
h=int(c*d/fractions.gcd(c,d))
if(a%c!=0):
    e=(b//c)-(a//c)
else:
    e=(b//c)-(a//c)+1
if(a%d!=0):
    f=(b//d)-(a//d)
else:
    f=(b//d)-(a//d)+1
if(a%(h)!=0):
    g=(b//(h))-(a//(h))
else:
    g=(b//(h))-(a//(h))+1
print('{0}'.format(b-a+1-e-f+g))


Measured memory_bytes: 5048
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cctype>

#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i,l,n) for(int (i)=(int)(l);(i)<(int)(n);(i)++)
#define d_arr(arr, h, w) rep(i,(h) ){ cout << "["; rep(j,(w) ) { cout << (arr)[i][j] << ", "; } cout << "]" << endl;}

typedef pair<int ,int> P;

class car
{
    int id;
    int num;
    public:
        car(int x, int y){ id=x; num=y; }
};

vector<double> ans;
int ini_m, years, n;
int style, fee;
double per;

double fukuri();
double tanri();
int main()
{
    int m;
    while ( cin >> m )
    {
        if( m == 0) { break; }
        //各データセットに対して
        rep(i,m) 
        {
            ans.clear();
            //cout << "--------------------------------------------------" << endl;
            cin >> ini_m >> years >> n;
            //各運用方法に対して
            rep(t,n) 
            {
                cin >> style >> per >> fee;
                double tmp;
                if     ( style == 0) { tmp = tanri();  ans.push_back(tmp);} //printf("tanri = %lf\n", tmp); }
                else if( style == 1) { tmp = fukuri(); ans.push_back(tmp);} //printf("fukuri = %lf\n", tmp); }
            }
            sort(ans.rbegin(), ans.rend() );
            //cout << ans[0] << endl;
            printf("%.0lf\n", ans[0] );
        }
    }
}

double tanri()
{
    double ret = ini_m;
    double interest = 0.0;
    double interest_sum = 0.0;
    rep(j,years)
    {
        interest = ret * per;
        interest_sum += floor(interest);
        ret -= fee;
    }
    return ret + interest_sum;
}

double fukuri()
{
    double ret = ini_m;
    double interest = 0.0;
    rep(j, years)
    {
        interest = ret * per;
        interest = floor(interest);
        ret += interest;
        ret -= fee;
    }
    return ret;
}

Measured memory_bytes: 1268
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from collections import Counter
def resolve():
    n, m = map(int, input().split())
    E = [[] for _ in range(n)]

    for _ in range(m):
        u, v = map(int, input().split())
        u -= 1; v -= 1
        E[u].append(v)
        E[v].append(u)


    cnt = 0
    color = [-1] * n
    def dfs(v):
        if color[v] != -1:
            return False
        color[v] = cnt
        queue = [v]
        for v in queue:
            for nv in E[v]:
                if color[nv] == -1:
                    color[nv] = cnt
                    queue.append(nv)
        return True

    for v in range(n):
        cnt += dfs(v)

    for key, val in Counter(color).most_common():
        print(val)
        return
resolve()

Measured memory_bytes: 124512
#include "iostream"
using namespace std;

int main() {
  int n, t;
  cin >> n >> t;
  int c[100], s[100];
  int min = 10000;
  for (int i = 0; i < n; i++) {
    cin >> c[i] >> s[i];
    if (s[i] <= t && c[i] < min) min = c[i];
  }
  if (min == 10000) {
    cout << "TLE" << endl;
  }
  else {
    cout << min << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int A, B, C, D, E, F;
set<int> W, S;

void solve() {
	cin >> A >> B >> C >> D >> E >> F;
	rep(i, 0, F / (100 * A) + 1) {
		rep(j, 0, F / (100 * B) + 1) {
			W.insert(i * 100 * A + j * 100 * B);
		}
	}
	rep(i, 0, F / C + 1) {
		rep(j, 0, F / D + 1) {
			S.insert(-(i * C + j * D));
		}
	}
	int anss = 0, answ = 100 * A;
	for(int w : W) {
		int ms = min(E * w / 100, F - w);
		auto ps = S.lower_bound(-ms);
		if(ps != S.end()) {
			int s = -(*ps);
			if(w * anss <= s * answ) {
				anss = s; answ = w;
			}
		}
	}
	cout << anss + answ << " " << anss << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
int main(){
	int n,i,j;
	int **matrix;
	while(1){
		scanf("%d",&n);
		if(n == 0)
			break;
		matrix  = (int**)malloc(sizeof(int*)*(n+1));
		for(i=0;i<n+1;i++){
			matrix[i] = (int*)malloc(sizeof(int)*(n+1));
		}
		for(i=0;i<n+1;i++){
			for(j=0;j<n+1;j++){
				matrix[i][j]=0;
			}
		}
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				scanf("%d",&matrix[i][j]);
				matrix[n][j]+=matrix[i][j];
				matrix[i][n]+=matrix[i][j];
				matrix[n][n]+=matrix[i][j];
			}
		}
		for(i=0;i<n+1;i++){
			for(j=0;j<n+1;j++){
				printf("%5d",matrix[i][j]);
			}
			puts("");
			
		}
		for(i=0;i<n+1;i++)free(matrix[i]);
		free(matrix);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    string s;
    cin>>s;
    int i,hash[26]={0},f=0;
    for (i=0;i<s.size();i++)
    {
        if (!hash[s[i]-'a'])
            hash[s[i]-'a']++;
        else
        {
            f=1;
            break;
        }
    }
    if (f)
        cout<<"no\n";
    else
        cout<<"yes\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 2e4+1;
ll f(ll a){
  return a ? f(a/2)*2+1 : 0ll;
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a;
  cin >> a;
  cout << f(a) << endl;
}

Measured memory_bytes: 256
S = list(input())
length = len(S)
if all(S[i] == 'R' or S[i] == 'U' or S[i] == 'D' for i in range(0, length, 2)) and all(S[i] == 'L' or S[i] == 'U' or S[i] == 'D' for i in range(1, length, 2)):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRT(v) sort(v.begin(),v.end())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    ll n,x;
    cin >> n >> x;
    ll a[110000];
    REP(i,0,n){
        cin >> a[i];
    }
    //処理
    ll ans = 0;
    if(a[0]>x){
        ans = a[0]-x;
        a[0]=x;
    }
    REP(i,0,n-1){
        ll tmp = (a[i]+a[i+1])-x;
        if(tmp>0){
            a[i+1] -= tmp;
            ans += tmp;
        }
    }
    //出力
    cout << ans << ENT;
    return 0;
}

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


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

int main() {

  int N=0;
  long sum=0;
  cin >> N;
    for(int i=1 ; i<=N ; i++){
      if(i%3 == 0 || i%5 == 0){
        sum = sum+0 ;
      }
      else {
        sum = sum + i;
      }
    }
  cout << sum << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;


int main(){
  int w, a, b;
  cin >> w >> a >> b;
  if (a > b) swap(a, b);
  a += w;
  int ans = b - a;
  if (ans < 0) ans = 0;
  cout << ans << endl;
} 

Measured memory_bytes: 256
A = [0 for _ in xrange(10**5+10)]
N, K = map(int, raw_input().split())
for i in xrange(N):
    a, b = map(int, raw_input().split())
    A[a] += b
     
k = 0
for i in xrange(10**5+10):
    k += A[i]
    if k >= K:
        print i
        break

Measured memory_bytes: 4868
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
a = [[int(x) for x in input().split()] for i in range(N)]
dp = [0] * (1<<N)
for S in range(1<<N):
    tmp = 0
    for i in range(N-1):
        for j in range(i+1, N):
            if (S>>i)&1 and (S>>j)&1:
                tmp += a[i][j]
    dp[S] = max(0, tmp)
    T = (S-1)&S
    while T > 0:
        dp[S] = max(dp[S], dp[T]+dp[S^T])
        T = (T-1)&S
print(dp[(1<<N)-1])

Measured memory_bytes: 44780
#include<bits/stdc++.h>
using namespace std;
#define INF (1LL<<60)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
/*
signed main(){
  int n;
  cin>>n;
  cout<<(n-2)*180<<endl;
  return 0;
}
*/
signed main(){
  string s;
  cin>>s;
  while(1){
    if(s.size()==15) break;
    s=s+"o";
  }
  int cnt=0;
  lp(i,s.size()){
    if(s[i]=='o')cnt++;
  }
  if(cnt>=8) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}

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

int main()
{
	vector<int> heights;
	for (int i = 0; i < 10; i++) {
		int height;
		cin >> height;
		heights.push_back(height);
	}
	sort(heights.rbegin(), heights.rend());
	for (int i = 0; i < 3; i++) {
		cout << heights[i] << endl;
	}
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

string s;

ll ev(ll b,ll c,ll d){
	if(s[b]=='\0'){
		return c+d;
	}
	return ev(b+1,c*10+s[b]-'0',d)+ev(b+1,s[b]-'0',c+d);
}

int main(){
	cin>>s;
	cout<<ev(1,s[0]-'0',0)<<endl;
	return 0;
}
	

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

int main(){

  int N;
  long K;
  cin >> N >>K;
  vector<pair <int,int> > array(N);

  for(int i = 0; i < N; i++){
    int a,b;
    cin >> a >> b;
    array.at(i).first = a;
    array.at(i).second = b;
  }
  
  sort(array.begin(),array.end());


  long long counter = 0;
  int answer = 0;
  for(auto num : array){
    counter += num.second;
    if (counter >= K) {
      answer = num.first;
      break;
    }
  }
  cout << answer << endl;
}


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

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

    long long a,b,c;
    cin>>a>>b>>c;
    long long d;
    d=c-a-b;
    if(d>0 && d*d>4*a*b)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 3572
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == (lint)v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  int n = in();
  vec<lint> v(n + 1);
  rep(i, n) cin >> v[i];
  rep(i, n) {
    v[i + 1] += v[i];
  }

  lint mini = LLONG_MAX;
  rep(i, n - 1) {
    chmin(mini, abs(v[i] - (v[n - 1] - v[i])));
  }
  print(mini);
}


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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    map<pair<int,int>, ll> cnt;

    rep(i,N) {
        string a;
        cin >> a;
        ll b = 0;
        ll c = 1;
        bool t = false;
        rep(j,a.size()) {
            if (a[j]=='.') t = true;
            else {
                b = b*10 + (int) a[j] - '0';
                if (t) {
                    c*=10;
                }
            }
        }
        int two = 0;
        int five = 0;
        while(b%2==0) {
            b/=2;
            two++;
        }
        while(b%5==0) {
            b/=5;
            five++;
        }
        while(c%2==0) {
            c/=2;
            two--;
        }
        while(c%5==0) {
            c/=5;
            five--;
        }
        cnt[make_pair(two,five)] ++;
    }
    ll ans = 0;
    for (auto p1: cnt) {
        for (auto p2: cnt) {
            if (p1.first.first+p2.first.first>=0 && p1.first.second+p2.first.second>=0) {
                if (p1<p2) {
                    ans += p1.second*p2.second;
                }
                else if (p1==p2){
                    ans += p1.second*(p2.second-1)/2;
                }
            }
        }
    }
    cout << ans << endl;

}


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

ll a,b,ans;

ll gcd(ll a, ll b) {
    if(a < b) return gcd(b, a);
    ll r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
int main(){
    cin>>a>>b;
    cout<<a*b/gcd(a,b)<<endl;
}

Measured memory_bytes: 256
from math import acos
from math import sin

def ang(ax, ay, ox, oy, bx, by):
    oax, oay = ax - ox, ay - oy
    obx, oby = bx - ox, by - oy
    r1, r2 = oax ** 2 + oay ** 2, obx ** 2 + oby ** 2
    return acos((oax * obx + oay * oby) / (r1 * r2) ** 0.5)

def circumcircle(x1, y1, x2, y2, x3, y3):
    s2A = sin(2 * ang(x3, y3, x1, y1, x2, y2))
    s2B = sin(2 * ang(x1, y1, x2, y2, x3, y3))
    s2C = sin(2 * ang(x2, y2, x3, y3, x1, y1))
    px = (s2A * x1 + s2B * x2 + s2C * x3) / (s2A + s2B + s2C) + 0.
    py = (s2A * y1 + s2B * y2 + s2C * y3) / (s2A + s2B + s2C) + 0.
    r = (((x2 - x3) ** 2 + (y2 - y3) ** 2) ** 0.5) / (2 * sin(ang(x2, y2, x1, y1, x3, y3))) + 0.
    return px, py, r

n = int(input())
for i in range(n):
    print("{0[0]:.3f} {0[1]:.3f} {0[2]:.3f}".format(
          circumcircle(*tuple(map(float, input().split())))))

Measured memory_bytes: 8004
n=int(input())
h=list(map(int,input().split()))

max=0
ans=0
for i in range(n):
    if h[i]>=max:
        max=h[i]
    else:
        ans+=max
        ans-=h[i]
        max=h[i]

if max==h[n-1]:
    ans+=max
print(ans)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {

	int d, n;
	cin >> d >> n;

	long long int ans = 1;

	while (n > 0) {
		if (d == 0) {
			if (ans % 100 != 0) {
				n--;
			}
		}
		else if (d == 1) {
			if (ans % 100 == 0) {
				long long int k = ans / 100;
				if (k % 100 != 0) {
					n--;
				}
			}
		}
		else if (d == 2) {
			if (ans % 10000 == 0) {
				long long int k = ans / 10000;
				if (k % 100 != 0) {
					n--;
				}
			}
		}
		ans++;
	}

	cout << ans-1 << endl;

	return 0;
}

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

namespace AtCoder
{
    public class Program
    {
        public static void Main()
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var s = cin.Read;
            WriteLine(s.Count(x=>x=='1'));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 11348
n, sm = int(input()), 0
a = [0] + list(map(int, input().split())) + [0]
for i in range(n+1): sm+=abs(a[i]-a[i+1])
for i in range(n): print(sm-abs(a[i]-a[i+1])-abs(a[i+1]-a[i+2])+abs(a[i]-a[i+2]))

Measured memory_bytes: 14048
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N, X, Y, Z;
std::set<int>ans;

int main()
{
	in >> N;
	in >> X;
	std::vector<int>a(X);
	rep(i, X) in >> a[i];
	in >> Y;
	std::vector<int>b(Y);
	rep(i, Y) in >> b[i];
	in >> Z;
	std::vector<int>c(Z);
	rep(i, Z) in >> c[i];
	rep(i, Z)
	{
		bool flag = true;
		rep(j, X)
		{
			if (c[i] == a[j])
			{
				flag = false;
				break;
			}
		}
		if (flag) ans.insert(c[i]);
	}
	rep(i, Y)
	{
		bool flag = false;
		rep(j, Z)
		{
			if (b[i] == c[j])
			{
				flag = true;
				break;
			}
		}
		if (flag) ans.insert(b[i]);
	}
	out << ans.size() << std::endl;
	return 0;
}



Measured memory_bytes: 3104
#include <stdio.h>
#include <string.h>

int main(){

  char str[27];
  int flag = 1;
  scanf("%s", str);

  int n = strlen(str);
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      if(str[i] == str[j]){
        flag = 0;
        break;
      }
    }
    if(flag == 0) break;
  }
  if(flag == 1){
    puts("yes");
  }else{
    puts("no");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
  const int lmt = 3000;
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  ll A[X], B[Y], C[Z];
  for(int i=0; i<X; i++) cin >> A[i];
  sort(A, A+X, greater<ll>());
  for(int i=0; i<Y; i++) cin >> B[i];
  sort(B, B+Y, greater<ll>());
  for(int i=0; i<Z; i++) cin >> C[i];
  sort(C, C+Z, greater<ll>());
  
  vector<ll> v1;
  for(int i=0; i<X; i++){
    for(int j=0; j<min(lmt/(i+1), Y); j++){
      v1.push_back(A[i] + B[j]);
    }
  }
  sort(v1.rbegin(), v1.rend());
  vector<ll> v2;
  int n = v1.size();
  for(int i=0; i<n; i++){
    for(int j=0; j<min(lmt/(i+1), Z); j++){
      v2.push_back(v1[i] + C[j]);
    }
  }
  
  sort(v2.rbegin(), v2.rend());
  for(int i=0; i<K; i++){
    cout << v2[i] << endl;
  }
  
  

  return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x)     x.begin(),x.end()    
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
#define PI acos(-1.0)
using namespace std;
void comp() {
	ll i,j,k,n,m,l;
	cin>>n>>m;
	int u,v;
	vector<ll>v1[n+1];
	fl(i,m) {
		cin>>u>>v;
		v1[u].pb(v);
		v1[v].pb(u);
	}
	int parent[n+1]={0};
	queue<int>q1;
	q1.push(1);
	while(!q1.empty()) {
		int temp=q1.front();
		q1.pop();
		fl(i,v1[temp].size()) {
			if(parent[v1[temp][i]]==0) {
				q1.push(v1[temp][i]);
				parent[v1[temp][i]]=temp;
			}
		}
	}
	fli(i,2,n+1) {
		if(parent[i]==0) {
			cout<<"No\n";
			return;
		}
	}
	cout<<"Yes\n";
	fli(i,2,n+1) {
		cout<<parent[i]<<"\n";
	}
}

int main() {
    speedup;
    ll i=0,t;
    t=1;
    //cin>>t;
    while(t--) {
        comp();
    }
    return 0;
}

Measured memory_bytes: 12456
while (n = gets.to_i) != 0 do
  points = gets.split.map(&:to_f)
  ave = points.inject{|sum, i| sum + i} / n
  a = 0
  for point in points do
    a += (point - ave) ** 2
  end
  puts sprintf("%.6f", Math.sqrt(a/ n))
end

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

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m;
	cin >> n >> m;
	vector<string> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	vector<vector<int> > dp(n, vector<int>(m, (int)1e9));
	dp[0][0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(i) dp[i][j] = min(dp[i][j], dp[i-1][j] + (a[i-1][j] != a[i][j]));
			if(j) dp[i][j] = min(dp[i][j], dp[i][j-1] + (a[i][j-1] != a[i][j]));
		}
	}
	int r = dp[n-1][m-1];
	if(a[0][0] == '#') r++;
	if(a[n-1][m-1] == '#') r++;
	cout << r / 2 << '\n';
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

vector<vector<int>> dp(15, vector<int>(100005, INF));

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

    int n;
    cin >> n;
    vector<int> a;
    a.push_back(1);
    int hoge = 6;
    while(hoge <= n){
        a.push_back(hoge);
        hoge *= 6;
    }
    hoge = 9;
    while(hoge <= n){
        a.push_back(hoge);
        hoge *= 9;
    }
    int sz = a.size();

    dp[0][0] = 0;
    int res = INF;
    for(int i = 0; i < sz; ++i){
        for(int j = 0; j <= n; ++j){
            chmin(dp[i+1][j], dp[i][j]);
            if(j - a[i] >= 0)   chmin(dp[i+1][j], dp[i+1][j-a[i]] + 1);
        }
    }
    cout << dp[sz][n] << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define bg begin()
#define end end()
#define sz size()
#define vi vector<int>
#define vl vector<long long int>
int main(){
	fast;
	int x,a,b;
	cin>>x>>a>>b;
	if(b<=a)
		cout<<"delicious";
	else if(b-a<=x)
		cout<<"safe";
	else
		cout<<"dangerous";
	return 0;
}



Measured memory_bytes: 3588
#include<iostream>
using namespace std;
bool ban[52][52];
	void dfs(int x,int y){
		ban[y][x]=0;
		for(int i=-1;i<=1;i++){
			for(int j=-1;j<=1;j++){
				if(ban[y+i][x+j]==true){
					dfs(x+j,y+i);
				}
			}
		}
	}
int main(){
	int w,h;
	while(cin>>w>>h,h+w!=0){
		for(int i=0;i<h;i++)ban[i][0]=0,ban[i][h+1]=0;//番兵
		for(int i=0;i<w;i++)ban[0][i]=0,ban[0][w+1]=0;//
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++)cin>>ban[i][j];
		}
	int cnt=0;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(ban[i][j]==true){
				dfs(j,i);
				cnt++;
			}
		}	
	}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1304
#include<iostream>

using namespace std;
int main(){
  int N;
  cin >> N ;
  char s[N];
  cin >> s;
  int Rcount=0;
  int Bcount=0;
  for(int i=0;i<N;i++){
  if(s[i]=='R')
  Rcount++;
  else
  Bcount++;
  }
  if(Rcount>Bcount)
  cout << "Yes"<<endl;
  else
  cout << "No"<< endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int num = 0;
  long long seq = 0;
  
  while(num<1 || num>1000000)
    scanf("%d",&num);
  
  for(int i=0; i<=num; ++i)
  {
    if((i%3)!=0 && (i%5)!=0)
      seq+=i;
  }
  
  printf("%lld", seq);
  
  return 0;
}

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

using namespace std;

#define ll long long

int main()
{
	ll N, A, B;
	cin >> N >> A >> B;
	ll div = N / (A + B);
	ll mod = N % (A + B);

	ll ans = div * A + min(A, mod);

	cout << ans << endl;

	return 0;
}


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


void q_sort(li *A,li start,li end){
	if(start>=end) return;
	li bibot= A[start+(end-start)/2];

	li i=start;
	li j=end;
	while(i<j){
		if(A[i]>bibot) i++;
		if(A[j]<bibot){
			j--;
		}else if(!(A[i]>bibot)){
			li pos=A[j];
			A[j]=A[i];
			A[i]=pos;
		}
	}
	q_sort(A,start,i);
	q_sort(A,j+1,end);
}

int main(void){
	li A, B, M;
	cin >> A >> B >> M;
	li min, mina, minb;
	li a[A];
	li x[M];
	li y[M];
	li c[M];
	min=200000;
	mina=200000;
	minb=200000;
	for(li i=0;i<A;i++){
		cin >> a[i];
		if(a[i]< mina)mina=a[i];
	}
	li b[B];
	for(li i=0;i<B;i++){
		cin >> b[i];
		if(b[i]<minb)minb=b[i];
	}
	for(li i=0;i<M;i++){
		cin >> x[i] >> y[i]>> c[i];
	}
	for(li i=0;i<M;i++){
		if(a[x[i]-1]+b[y[i]-1]-c[i]<min){
			min = a[x[i]-1]+b[y[i]-1]-c[i];
		}
	}

	if(mina+minb<min) min = mina+minb;
	cout << min;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}


template <typename T> T gcd(T a, T b) {if(b == 0) return a;return gcd(b,a%b);}


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

    int K;
    cin >> K;
    ll ans = 0;
    reps(a,1,K+1){
        reps(b,1,K+1) reps(c,1,K+1){
            
            ans += (ll)(gcd(a,gcd(b,c)));
            
            
        }
    }
    
    cout << ans << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
using namespace std;
const ll inf=10000000000;
int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k,i,j;
    cin>>n>>k;
    ll arr[n+5];
    for(i=0;i<n;i++)
        cin>>arr[i];
   // k=2;
    vector <ll> dp(n+5,inf);
    
    // for(i=0;i<n;i++)
    //     cout<<dp[i]<<" ";
    ll zero=0;
    dp[0]=0;
    for(i=1;i<n;i++)
    {
        for(j=i-1;j>=max(zero,i-k);j--)
        {
            dp[i]=min(dp[i],dp[j]+abs(arr[i]-arr[j]));
        }
    }
    cout<<dp[n-1];
    return 0;
}
    

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;

vector<ll> depth; vector<vector<ll>> to;

ll N,K,ans;
 
ll BFS(){ 
  depth = vector<ll> (N,-1);
  
  queue<ll> Q;
  Q.push(0);
  ans = K; depth[0] = 0; 
  
  while(!Q.empty()){
    ll p = Q.front(); Q.pop(); ll cnt = 0;
      for(ll i = 0; i < to[p].size(); i++){
        ll b = to[p][i];
        if(depth[b] == -1){//まだ未探索で
         if( depth[ p] == 0){
          ans *= ( K - 1 - cnt); cnt++; ans = ans % MOD;}
         else{
          ans *= ( K - 2 - cnt); cnt++; ans = ans % MOD;}
          depth[b] = depth[p] + 1; Q.push(b);}
        } //forとじ
  }
  
  return ans;}
      
    
  


int main(){
  cin >> N >> K;
  to = vector<vector<ll>> (N);
  for(ll i = 0; i < N -1 ; i++){
    ll a,b; cin >> a >> b; a--; b--;
    to[a].push_back(b); to[b].push_back(a);}
  
  cout << BFS() << endl; return 0;}
    
  

Measured memory_bytes: 8052
#include<iostream>

using namespace std;

int main(void) {
	int n, d;
	while(cin >> n >> d) {
		int ans = 0;
		while(n >= 2*d+1) {
			n -= 2*d+1;
			ans++;
		}
		if(n > 0)
			ans++;
		cout << ans << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin>>n;
	int p[n]; rep(i,n) cin>>p[i];
	int cnt=0;
	for(int i=1;i<n-1;i++){
		if(p[i-1]<p[i]&&p[i]<p[i+1]) {
			cnt++;
		}else if(p[i+1]<p[i]&&p[i]<p[i-1]){
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int A[5050],B[5050];

template<int um> class UF {
	public:
	vector<int> par,rank,cnt;
	UF() {par=rank=vector<int>(um,0); cnt=vector<int>(um,1); for(int i=0;i<um;i++) par[i]=i;}
	void reinit() {int i; FOR(i,um) rank[i]=0,cnt[i]=1,par[i]=i;}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int count(int x) { return cnt[operator[](x)];}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		cnt[y]=cnt[x]=cnt[x]+cnt[y];
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) cin>>A[i]>>B[i], A[i]--,B[i]--;
	int ret=0;
	FOR(i,M) {
		UF<60> uf;
		FOR(j,M) if(i!=j) uf(A[j],B[j]);
		if(uf.count(0)!=N) ret++;
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

// Union-Find木
struct UnionFind {
  vector<int> par;
  
  // Constructor
  UnionFind(int n): par(n) {
    for (int i = 0; i < n; i++) par[i] = i;
  }
  
  // n要素で初期化
  void init(int n) {
    par.resize(n);
    for (int i = 0; i < n; i++) par[i] = i;
  }
  
  // 根の検索
  int find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
  }
  
  // xとyの属する集合を併合
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    par[x] = y;
    return true;
  }
  
  // xとyが同じ集合に属するか
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  vector<pair<int, int>> x(m);
  for (int i = 0; i < m; i++) cin >> x.at(i).first >> x.at(i).second;
  
  int ans = 0;
  for (int i = 0; i < m; i++) {
    UnionFind UF(n + 1);
    for (int j = 0; j < m; j++) {
      if (i != j) UF.unite(x.at(j).first, x.at(j).second);
    }
    if (!UF.same(x.at(i).first, x.at(i).second)) ans++;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <climits>
#include <cmath>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep01(i, n) for(int i = 0; i < (n) + 1; i++)
#define rep10(i, n) for(int i = 1; i < (n); i++)
#define all(a) (a).begin(), (a).end()
typedef long long int ll;
using namespace std;

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

    x = max(x, -x);
    ll m = (x % d);
    ll n = (x / d);

    if (n <= k) {
        if ((n % 2) == (k % 2)) {
            cout << m << endl;
        }
        else {
            cout << d-m << endl;
        }
    }
    else
        cout << (x-k*d) << endl;
    
    return 0;
}

Measured memory_bytes: 3600
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

S = input()

cond1 = S[0] == 'A'
cond2 = S[2:-1].count('C') == 1
cond3 = True
for i, s in enu(S):
    if i==0:
        continue
    if 2<=i<=len(S)-2 and s=='C':
        continue
    if s == s.upper():
        cond3 = False

if cond1 and cond2 and cond3:
    print('AC')
else:
    print('WA')



Measured memory_bytes: 3316
N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

ansl=[]
ans=0
for i in range(N):
    if x[i]==y[i]:
        ans+=1
    else:
        ansl.append(ans)
        ans=0
ansl.append(ans)
if max(ansl)>=3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62392