akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        int c = s.IndexOf('C');
        int f = s.LastIndexOf('F');
        if (c >= 0 && f >= 0 && f > c)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 11092
def coin(dice,k)
    if dice == 1 then
        value = Math.log(k.to_f) / Math.log(2.to_f)
        return 0.5**(value.ceil)
    else
        kari = (k.to_f/dice.to_f)
        value = Math.log(kari) / Math.log(2.0)
        return 0.5**(value.ceil)
    end
end

num = gets.split(" ").map{|item|item.to_i}
    ans = 0
    num[0].times{|xi|
        if xi+1 < num[1] then
            ans += coin(xi+1,num[1])/num[0].to_f
        else
            ans += 1.0/num[0].to_f
        end
    }
    print ans





Measured memory_bytes: 1916
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
using namespace std;

int max(int a,int b){
	if(a>b)return a;
	return b;
}

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

int compare_char(char *a,char *b){
	return strcmp(a,b);
}

int intsort(const void *a, const void *b){
	return *(int*)b - *(int*)a;
	/*qsort(a,aの配列数,sizeof(int),intsort);*/
}

int longsort(const void *a, const void *b){
	long *A=(long *)a;
	long *B=(long *)b;
	if(*A>*B) return -1;
	if(*A<*B) return 1;
	return 0;
}

int main(){
  int a,b,c;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);

  printf("%d\n",(c/a)*b);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define N 100001
#define prob "DP_A"
#define io freopen(prob".inp","r",stdin); freopen(prob".out","w",stdout);
using namespace std;
int n,k,h[N];
int f[N];
void read()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>h[i],f[i]=INT_MAX;
    f[1]=0;
    f[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i-j==0) break;
            f[i]=min(f[i],f[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<f[n];
}
int main()
{
//    io
    read();
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int abcd[4];
int temp;

void dfs() {
    const int n = 4;
    REP(i, 1 << n) {
        int sum = 0;
        string ops;

        REP(j, n) {
            if ((i & (1 << j))) {
                sum += abcd[j];
                ops += '+';
            } else {
                sum -= abcd[j];
                ops += '-';
            }
        }
        if (sum == 7) {
            cout << to_string(abcd[0]) + ops[1] + to_string(abcd[1]) + ops[2] + to_string(abcd[2]) +
                    ops[3] + to_string(abcd[3]) + "=7" << endl;
            return;
        }
    }
}

void solve() {
    dfs();
}

int main() {
    cin >> temp;
    abcd[0] = temp / 1000;
    abcd[1] = (temp - abcd[0] * 1000) / 100;
    abcd[2] = (temp - abcd[0] * 1000 - abcd[1] * 100) / 10;
    abcd[3] = (temp - abcd[0] * 1000 - abcd[1] * 100 - abcd[2] * 10) / 1;
    solve();
    return 0;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n;
	string s;
	cin >> n;
	cin >> s;

	int x = 0;
	int ans = 0;
	for(int i=0; i<s.size(); i++){
		if(s[i] == 'I') x++;
		else if(s[i] == 'D') x--;
		ans = max(ans, x);
	}

	cout << ans << endl;



	
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> t3;

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <stack> 
#include <map>
#include <queue>
#include <unordered_map>
#include <cassert>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
#define pb 					push_back
#define FAST_IO          ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
template<typename T,typename S>
ostream& operator <<(ostream& os, pair<T, S> input) {
	os<<"("<<input.first<<", "<<input.second<<")";
	return os;
}
template<typename T>
ostream& operator <<(ostream& os, vector<T> input) {
	for(auto t: input)
		os << t <<"\n";
	return os;
}
template<typename T>
ostream& operator <<(ostream& os, set<T> input) {
	for(auto t: input)
		os << t <<"\n";\
	return os;
}

int main() {
	long long a, b, n;
	cin >> a >> b >> n;
	long long x =n;
	if(n>=b-1)
		x = b-1;
	cout <<(a*x)/b - a*(x/b)<< "\n";
	
	return 0;
}

Measured memory_bytes: 3636
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#include<vector>
using namespace std;
int main(){
    int N; cin >> N;
    int W[128];
    for(int i=0;i<N;i++){
        cin >> W[i];
    }

    vector<int> ans;
    for(int i=0;i<N;i++){
        
        int SmallGroup = 0;
        int BigGroup = 0;
        int Sa = 0;

        for(int j = i; j>=0 ;j--)
        {
            SmallGroup += W[j];
        }
        for(int k = i+1;k<N;k++)
        {
            BigGroup += W[k];
        }

        Sa = BigGroup - SmallGroup;

        // 絶対値対策
        if(Sa < 0)
        {
            Sa = 0-Sa;
        }
        ans.push_back(Sa);
    }
    
    cout << *min_element(ans.begin(), ans.end()) << endl;
}

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

string S;

//それぞれの文字列を逆から読んだ文字列
string T[4]={"maerd","remaerd","esare","resare"};

int main(){
    cin>>S;
    
    for(int i=S.size()-1; i>=0;){
        string s;
        for(int j=0; j<5; j++){
            s+=S[i-j];
        }
        if(s==T[0] || s==T[2]){
            i-=5;
            continue;
        }
        s+=S[i-5];
        if(s==T[3]){
            i-=6;
            continue;
        }
        s+=S[i-6];
        if(s==T[1]){
            i-=7;
            continue;
        }
        cout<<"NO"<<endl;
        return 0;
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 512
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(long long int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
//#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); vect(A);for(long long i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
int main()
{
    /*
    #ifndef ONLINE_JUDGE
       freopen ("input.txt" , "r" , stdin);
		// freopen ("OUTPUT.txt" , "w" , stdout);
	#endif
    */
    fio;
    ll a,b,n;
    cin>>n>>a>>b;
    ll ans=0;
    if((b-a)%2==0)
    {
        ans=(a+b)/2;
        ans=(b-ans);
    }
    else
    {
        ans+=(min(a-1,n-b));
        //cout<<ans<<endl;
        if(ans==(a-1))
        {
            b=b-(a-1);
            a=1;
            ans+=(a+b)/2;
        }
        else
        {
            a=(n-b)+a;
            b=n;
            ans+=b-(a+b)/2 ;
        }
        //cout<<a<<" "<<b<<endl;
        
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

d = []
for ai, aa in enumerate(a, 1):
    for bi, bb in enumerate(b, 1):
        for ci, cc in enumerate(c, 1):
            if ai * bi * ci > k:
                break
                # (ai,bi,ci)より合計の大きい選び方がk通り以上存在する
                # (ai,bi)を含む組み合わせは、これ以上調べる必要がない
            d.append(aa + bb + cc)

d.sort(reverse=True)

print(*d[:k], sep='\n')


Measured memory_bytes: 8692
// Problem : B - Easy Linear Programming
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
#define mod 1000000007
int lcm(int x,int y){
	return x/__gcd(x,y)*y;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<a){
    	cout<<k<<endl;
    }else if(k<=a+b){
    	cout<<a<<endl;
    }else{
    	cout<<2*a-k+b<<endl;
    }
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 998244353;
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; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 

vector<pair<ll, ll> > pairs;

int main()
{
    int N, B;
    cin >> N;
    vector<int> A(N);
    rep(i, N){
        cin >> B;
        if (B % 2 == 0 && (B % 3 != 0 && B % 5 != 0)){
            cout << "DENIED";
            return 0;
        } 
    }
    cout << "APPROVED";
    return 0;    
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final char[] S = sc.next().toCharArray();
			final int w = sc.nextInt();
			
			for(int i = 0; i < S.length; i += w) {
				System.out.print(S[i]);
			}
			System.out.println();
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21332
def is_ok1(a,b,c):
    return L[b] < L[c] + L[a]
def is_ok2(a,b,c):
    return L[c] < L[a] + L[b]
def meguru_bisect(ng, ok, is_ok, a, b):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(a, b, mid):
            ok = mid
        else:
            ng = mid
    return ok
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for a in range(N):
    for b in range(a+1, N):
        ans += max(0, meguru_bisect(N, b, is_ok2, a, b)-meguru_bisect(b, N, is_ok1, a, b)+1)
print(ans)


Measured memory_bytes: 74988
/*
क्षमाशील हो रिपु-समक्ष
तुम हुये विनत जितना ही
दुष्ट कौरवों ने तुमको
कायर समझा उतना ही।
*/
#include<bits/stdc++.h>
using namespace std;
 
#define int                 long long int
#define ull                 unsigned int
#define ld                  long double
#define pb                  push_back
#define ff                  first
#define ss                  second
#define S(arr)              sort(arr.begin(),arr.end());
#define all(p)              p.begin(), p.end()
#define RS(arr)             sort(arr.rbegin(),arr.rend());
#define R(arr)              reverse(arr.begin(),arr.end());
#define pii                 pair <int, int>
#define vpi                 vector <pii>
#define vi                  vector <int>
#define vld                 vector <ld>
#define vvi                 vector <vector <int>>
#define vs                  vector <string>
#define si                  set <int>
#define spi                 set <pii>
#define setbits(x)          __builtin_popcountll(x)
#define zrobits(x)          __builtin_ctzll(x)
#define mii                 map <int, int>
#define mci                 map<char, int>
#define mpi                 map <pii, int>
#define T                   int tcf;cin>>tcf;while(tcf--)
#define que_max(t)          priority_queue <t>
#define que_min(t)          priority_queue <t, vector<t>, greater<t>>
#define endl                "\n"
#define dba(a, l, r)        for(auto x:a)cout<<x<<" ";cout<<endl;
#define db1(x)              cout << #x " = " << x << endl;
#define db2(x,y)            cout << #x " = " << x << " " << #y " = " << y << endl;
#define db3(x,y,z)          cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define db4(x,y,z,w)        cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << endl;
#define db5(x,y,z,w,v)      cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << " " << #w " = " << w << " " << #v " = " << v << endl;
#define db6(x,y,z,w,v,a)    db3(a, y, x)db3(w, v, a)
#define p2d(v)              for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)              for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppi(v)              for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;

// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;  
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//  // *( hsh.find_by_order(k) ) kth smallest, from 0
//  // hsh.order_of_key(k) num of ele str less than k
//  // change less to less_equal for multiset pbds
 
void read(int n=10){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<setprecision(n)<<fixed;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt",  "r",  stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
}
 
int M = 1e9 + 7;
int M1 = 998244353;
#define qqq 4000005
#define pi 3.14159265358979323851



int32_t main(){
    read();
    int n,m;
    cin>>n>>m;
    cout<<(n*(n-1))/2+(m*(m-1))/2<<endl;
}  

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int M=105;
int read(){
	int ans=0,f=1,c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1; c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}
	return ans*f;
}
int a[M],tot,ans,sum;
int main()
{
	int n,k;
	n=read();
	for(int i=1;i<=n;i++){
		k=read(); tot+=k;
		if(k%10) a[++sum]=k;
	}
	if(tot%10) printf("%d\n",tot);
	else{
		sort(a+1,a+1+sum);
		if(!sum) printf("0\n");
		else printf("%d\n",tot-a[1]);
	}
	return 0;
} 

Measured memory_bytes: 128
import sys
read = sys.stdin.buffer.read#全部読み込むやつ
readline = sys.stdin.buffer.readline#1行読み込むやつ
readlines = sys.stdin.buffer.readlines#リストで読み込むらしい


import itertools

N = int(readline())

syougen = []
for i in range(N):
    A = int(readline())
    hoge = []
    for i in range(A):
        s = tuple(map(int,readline().split()))
        hoge.append(s)
    syougen.append(hoge)
    
ans = 0
for i in list(itertools.product([0,1],repeat = N)):
    test = True
    for j in range(N):
        if i[j] == 0:
            pass
        else:
            for k,m in syougen[j]:
                if i[k-1] == int(m):
                    continue
                else:
                    test = False
    if test:ans = sum(i)
print(ans)

Measured memory_bytes: 48748
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  ll k;
  cin >> s >> k;
  ll n = s.size();
  ll dp[n + 1][k + 2][2] = {};
  dp[0][0][0] = 1;
  rep(i, n) {
    ll d = s[i] - '0';
    rep(j, k + 1) {
      if(d == 0)
        dp[i + 1][j][0] += dp[i][j][0];
      else {
        dp[i + 1][j][1] += dp[i][j][0];                // 0
        dp[i + 1][j + 1][1] += (d - 1) * dp[i][j][0];  // 1 ~ d-1
        dp[i + 1][j + 1][0] += dp[i][j][0];            // d
      }
      dp[i + 1][j][1] += dp[i][j][1];
      dp[i + 1][j + 1][1] += 9 * dp[i][j][1];
    }
  }
  cout << dp[n][k][0] + dp[n][k][1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll h, w;
  cin >> h >> w;

  ll ans = (h * w + 1) / 2;

  if (h == 1 || w == 1) {
    ans = 1;
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int k,x,s,e,i;
  scanf("%d%d",&k,&x);
  s=x-k+1<-1000000 ? -1000000 : x-k+1;
  e=x+k-1>1000000 ? 1000000 : x+k-1;
  
  for (i=s;i<e;i++){
    printf("%d ",i);
  }
  printf("%d",i);
    
  
  return 0;
}

Measured memory_bytes: 128
import collections
n = int(input())
neibors = [dict() for i in range(n + 1)] # index to name
edges = []
for i in range(n-1):
    e = [int(s) for s in input().split()]
    edges.append(e)
for a,b in edges:
    neibors[a][b] = None
    neibors[b][a] =  None

colorCount = 0
for i in range(1,n+1):
    colorCount = max(colorCount, len(neibors[i]))

visited = set()
queue = collections.deque()

visited.add(1)
color = 0
for node in neibors[1]:
    color += 1
    neibors[1][node] = color
    queue.append(node)

while queue:
    x = queue.popleft()
    for node in neibors[x]:
        if node in visited:
            fatherColor = neibors[node][x]
            neibors[x][node] = fatherColor
    color = 0
    for node in neibors[x]:
        if neibors[x][node] is None:
            color += 1
            if color == fatherColor:
                color += 1
            neibors[x][node] = color
            queue.append(node)
    visited.add(x)

print(colorCount)
for a, b in edges:
    print(neibors[a][b])

Measured memory_bytes: 59296
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author hakamada
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TPBC_2 solver = new TPBC_2();
        solver.solve(1, in, out);
        out.close();
    }

    static class TPBC_2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int K = in.nextInt();

            int AB[] = {A, B};
            int cycle = 0;

            for (int i = 0; i < K; i++) {
                if ((AB[cycle] % 2) > 0) {
                    AB[cycle] -= 1;
                }
                if (cycle == 0) {
                    AB[cycle + 1] += AB[cycle] / 2;
                    AB[cycle] /= 2;
                    cycle = 1;
                } else {
                    AB[cycle - 1] += AB[cycle] / 2;
                    AB[cycle] /= 2;
                    cycle = 0;
                }

            }
            out.println(AB[0] + " " + AB[1]);
            return;


        }

    }
}



Measured memory_bytes: 21844
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def s_list(): return list(input())
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def num__grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]


s = input()
t = input()
ns = len(s)
nt = len(t)
alpha = "abcdefghijklmnopqrstuvwxyz"
aldi = {}
for i in alpha:
    aldi[i] = []

for i in range(ns):
    aldi[s[i]].append(i + 1)


num = []
if aldi[t[0]] == []:
    print("-1")
    exit()
mae = aldi[t[0]][0]
num.append(mae)
for i in range(1, nt):
    if aldi[t[i]] == []:
        print("-1")
        exit()
    else:
        kk = bisect_right(aldi[t[i]], mae)
        if kk == len(aldi[t[i]]):
            kk = aldi[t[i]][0]
        else:
            kk = aldi[t[i]][kk]
        mae = kk
        num.append(kk)

ans += num[0]
for i in range(1, len(num)):
    if num[i] <= num[i - 1]:
        ans += ns - num[i - 1] + num[i]
    else:
        ans += num[i] - num[i - 1]

if ans > 10 ** 100:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 11096
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
int main() {
	double x1, x2, y1, y2, D;
	cin >> x1 >> y1 >> x2 >> y2;
	D = pow(x1 - x2, 2) + pow(y1 - y2, 2);
	D = pow(D, 0.5);
	printf("%.6lf\n", D);
}

Measured memory_bytes: 1276
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll sum(ll l,ll r) {
    return (l+r)*(r-l+1)/2;
}

int main() {
int n,k;
cin >> n >> k;
mint ans;
for(int i = k;i <= n + 1;i++){
    ll l = sum(0,i-1), r = sum(n-i+1,n);
    ans += r-l+1;
}
 cout << ans << endl;
return 0;

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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; }
ll mod = 1e9+7;


int main(){
    int r,d,x; cin >>r>>d>>x;
    ll ans=x;
    for(int i=0;i<10;i++){
        ans = r*ans-d;
        cout << ans << endl;
    }
}

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

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

    vector<int> f(m,0);

    for(int i = 0; i < n; ++i){
        int k;
        cin >> k;
        for(int j = 0; j < k; ++j){
            int a;
            cin >> a;
            f[a-1]++;
        }
    }

    int ans = 0;

    for(int i = 0; i < m; ++i){
        if(f[i] == n) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import heapq
import collections

INF = 10 ** 16

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

class edge:
    def __init__(self, to, cost): self.to, self.cost = to, cost

def main():
    N = Z()
    E = collections.defaultdict(list)
    for _ in range(N-1):
        a, b, c = ZZ()
        E[a].append(edge(b, c))
        E[b].append(edge(a, c))
    Q, K = ZZ()

    def dijkstra(s):
        que = list()
        heapq.heapify(que)
        newd = [INF] * (N+1)
        newd[s] = 0
        heapq.heappush(que, [newd[s], s])

        while que:
            p = heapq.heappop(que)
            v = p[1]
            if newd[v] < p[0]: continue
            for e in E[v]:
                if newd[e.to] > newd[v] + e.cost:
                    newd[e.to] = newd[v] + e.cost
                    heapq.heappush(que, [newd[e.to], e.to])
        return newd

    dist = dijkstra(K)
    output = []

    for _ in range(Q):
        x, y = ZZ()
        output.append(dist[x] + dist[y])
    print(*output, sep='\n')

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 76532
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 5005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int64 x,y;
void Solve() {
    read(x);read(y);
    if(x * y >= 0) {
        if(y >= x) {out(y - x);enter;}
        else if(x * y != 0) {out(x - y + 2);enter;}
        else {out(x - y + 1);enter;}
    }
    else {
        out(abs(abs(x) - abs(y)) + 1);enter;
    }
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    bool a = false;
    string s;
    cin>>s;
    for(int k = 1;k<3;k++){
        if(s[k-1] != s[k]) a = true;
    }
    a?cout<<"Yes":cout<<"No";
    return 0;
}


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

l = list([input() for _ in range(N)])

is_good = True

if len(set(l)) < N:
    is_good = False

for i in range(N-1):
    if l[i][-1] != l[i+1][0]:
        is_good = False
        break

if is_good:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38256
n,k = [int(x) for x in input().split()]
ds = {int(x) for x in input().split()}
ns = {0,1,2,3,4,5,6,7,8,9} -ds
#print(ds)
#print(ns-ds)
temp=0
d ={}
a=1
b = {}
m = len(str(n)) +1 
over=False
while(a<=m and not over ):
  c = []
  d = 10**(a-1) 
  for v in ns:
    if a>1:
      for bv in b[a-1]:
        t = v*d + bv
        c += [t]
        if t >= n:
          print(t)
          over=True
          break
      if over:
        break
    else:
      t = v*d
      c += [t]
      if t >= n:
          print(t)
          over=True
          break
      
  b[a] = c
  a+=1
  
#for j in b:    
#    print(j,b[j])



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

using namespace std;

#define int long long
#define MOD 1000000007

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

    int n;
    cin >> n;
    cout << 3 * n * n ;

    return 0;
}

Measured memory_bytes: 256
//ABC086
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
int main(){
    int a,b;
    cin >> a >> b;
    if(a*b %2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
// #define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
// ll MOD=1e9+7;
const int maxn=2e5+5;

int ans[maxn];
int val[2];

ll power(ll a, ll b, ll MOD){
    ll x = 1, y = a;
    while (b > 0){
        if (b%2){
            x = (x*y)%MOD;
        }
        y = (y*y)%MOD;
        b /= 2;
    }
    return x%MOD;
}  

int calc(int x){
	int temp = __builtin_popcount(x);
	temp = x%temp;
	return 1+ans[temp];
}

int32_t main(){
    fast_io;
    int n;
    cin>>n;
    string s;
    cin>>s;
    fo(i,1,maxn-1){
    	ans[i] = calc(i);
    }
    // show(ans[8]);
    vi v;
    int tot = 0;
    for (int i = 0; i < n; ++i)
    {
    	v.emplace_back(s[i]-'0');
    	tot += v[i];
    }
    if(tot == 1){
    	if(n == 1){
    		show(0);
    		return 0;
    	}
    	for (int i = 0; i < n-1; ++i)
    	{
    		if(v[i]) {show(0);}
    		else {
    			show(1+v[n-1]);
    		}
    	}
    	if(v.back()){
    		show(0);
    	}
    	else show(2);
    	return 0;
    }
    // show(tot);
    for (int i = 0; i < n; ++i)
    {
    	if(v[i]) {
    		val[0] += power(2,n-1-i,tot-1);
    		val[1] += power(2,n-1-i,tot+1);
    	}
    }
    // let(val[0],val[1]);
    for (int i = 0; i < n; ++i)
    {
    	if(v[i]){
    		int temp = val[0] - power(2,n-1-i,tot-1);
    		temp %= (tot-1);
    		// let(i,temp);
    		show(1 + ans[temp]);
    	}
    	else{
    		int temp = val[1] + power(2,n-1-i,tot+1);
    		temp %= (tot+1);
    		// let(i,temp);
    		show(1+ ans[temp]);
    	}
    }
    return 0;
}

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

using namespace std;

bool CompareMin(int a, int b) {
	return a > b;  
}
typedef long long ll;
int main(){
    int a,b,c,r=0;
    cin >>a >> b >>r;

    for(int i=0;i<10;i++){
        
        
        r= a*r - b;
        cout << r << endl ;
        
    }
    
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll a,v,b,w,t;
	cin >> a >> v >> b >> w >> t;
	if((v-w)*t>=abs(a-b))
		cout << "YES" << "\n";
	else
		cout << "NO" << "\n";
}

Measured memory_bytes: 3656
import sys
from collections import defaultdict

input = sys.stdin.readline


def main():
    n = int(input().strip())
    tree = defaultdict(list)
    parent = [-1] * n

    for i in range(n):
        line = [int(j) for j in input().strip().split()]
        tree[line[0]] += line[2:]
        for j in line[2:]:
            parent[j] = line[0] 

    depth = [9999] * n
    _root = parent.index(-1)
    depth[_root] = 0

    def fill_depth(tree, n, d):
        depth[n] = d
        links = tree[n]
        for l in links:
            fill_depth(tree, l, d + 1)
    
    fill_depth(tree,_root,0)
    
    def get_attr(tree, n, root):
        if n == root:
            return "root"
        elif len(tree[n]) > 0:
            return "internal node"
        else:
            return "leaf"
    
    for i in range(n):
        print("node {}: parent = {}, depth = {}, {},".format(i,parent[i],depth[i],get_attr(tree,i,_root)),tree[i])

if __name__ == "__main__":
    main()


Measured memory_bytes: 28152
#include<cstdio>

int main(){
	
	double l[10],v[2];
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v[0],&v[1]) != EOF){
		int ans=1;
		double v_sum=v[0]+v[1];
		double l_sum=0;
		for(int i=0;i<10;i++)l_sum+=l[i];
		double s=l_sum/v_sum;
		double hit=v[0]*s;
		l_sum=0;
		for(int i=0;i<10;i++){
			l_sum+=l[i];
			if(l_sum>=hit)break;
			ans++;
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

template <ll Modulus = 1000000007>
class modint {
 public:
  ll a;

  constexpr modint(const ll x = 0) noexcept : a(x % Modulus) {}
  constexpr ll& value() noexcept { return a; }
  constexpr const ll& value() const noexcept { return a; }
  constexpr modint operator+(const modint& rhs) const noexcept { return modint(*this) += rhs; }
  constexpr modint operator-(const modint& rhs) const noexcept { return modint(*this) -= rhs; }
  constexpr modint operator*(const modint& rhs) const noexcept { return modint(*this) *= rhs; }
  constexpr modint operator/(const modint& rhs) const noexcept { return modint(*this) /= rhs; }
  constexpr modint& operator+=(const modint& rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint& operator-=(const modint& rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint& rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    ll exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
using mint = modint<2019>;

int main() {
  ll L, R;
  cin >> L >> R;
  ll icount = 0;
  ll jcount = 0;
  ll ans = 2020;
  for (ll i = L; i <= R - 1; i++, icount++) {
    if (icount > 2019) break;
    for (ll j = i + 1; j <= R; j++, jcount++) {
      if (jcount > 2019) {
        jcount = 0;
        break;
      }
      mint mi = i;
      mint mj = j;
      ans = min(ans, (mi * mj).a);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,j,n,m,a[1001],ten[1001],x[1001],max,maxi;
	scanf("%d",&n);
	scanf("%d",&m);
	for(j=1;j<=n;j++)  scanf("%d",&x[j]);
	for(i=1;i<=m;i++)  scanf("%d",&a[i]);
	for(j=1;j<=n;j++)  ten[j]=0;
	for(i=1;i<=m;i++){
		for(j=1;j<=n;j++){
			if(a[i]>=x[j]){
				ten[j]=ten[j]+1;
				break;
			}
		}
	}
//	for(i=1;i<=n;i++)	printf(" ten=%d\n",ten[i]);
	max=0;
	maxi=0;
	for(i=0;i<n;i++){
		if(max<ten[i]){
			max=ten[i];
			maxi=i;
		}
	}
	printf("%d\n",maxi);
	
	return 0;
	
}



Measured memory_bytes: 2696
s=input()
k=int(input())
m=0
j=0
if len(set(list(s)))==1:print((len(s)*k)//2);exit()
for i in range(len(s)):
 if len(s)<=j+1:
  a=m*k
  if s[0]==s[-1]==s[len(s)//3]:print(a+k-1)
  else:print(a)
  break
 if s[j]==s[j+1]:
  m+=1
  j+=1
 j+=1

Measured memory_bytes: 3064
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, a: [usize; n]);
    let mut ar: Vec<Vec<usize>> = vec![];

    for i in 0..n {
        let array: Vec<usize> = vec![a[i], i];
        ar.push(array);
    }

    ar.sort();

    for v in ar {
        println!("{}", v[1] + 1);
    }
}


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

int main(){
  int N;
  cin >> N;
  vector<pair<pair<string, int>, int>> restaurant(N);
  string s;
  int p;
  for (int i=0; i<N; i++) {
    cin >> s >> p;
    restaurant.at(i) = make_pair(make_pair(s, -p), i);
  }
  sort(restaurant.begin(), restaurant.end());
  for (int i=0; i<N; i++) {
    cout << restaurant.at(i).second + 1 << endl;
  }
}

Measured memory_bytes: 256
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

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

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

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

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

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

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

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

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    i64 n;
    std::cin >> n;
    i64 a, b;
    std::cin >> a >> b;
    i64 ans = n / (a + b) * a;
    ans += std::min(a, n % (a + b));
    std::cout << ans << std::endl;
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<limits>

using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX], n;

    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> R[i];
    }

    auto maxv = -2000000000;
    auto minv = R[0];

    for(int i = 1; i < n; i++)
    {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;    
}



Measured memory_bytes: 3864
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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

int main(){
    std::ios::sync_with_stdio(false);
    int n,t,h,l;
    int val = 0, turn = 0 , change;
    cin >> n >> t >> h >> l;
    int ten[n], hand[n];
    for(int i=0;i<n;i++){
        cin >> ten[i] >> hand[i];
    }

    while(1){
        if(ten[turn] == 0 && hand[turn] == 0) break;

        if(ten[turn] > 0){
            val += 10;
            t++;
            ten[turn]--;
            if(t > l) break;
        }else{
            val += 100;
            h++;
            hand[turn]--;
        }
        change = 0;
        if(val >= 90){
            val -= 90;
            change = val;
            val = 0;
        }
        if(change > t * 10) break;
        ten[turn] += change / 10;
        t -= change / 10;
        turn = (turn + 1) % n;
    }
    cout << turn+1 << endl;

}

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

using namespace std;
const int INF=1e9+5;
typedef long long ll;
int main(){
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	bool dp[k+1];
	for(int i=0;i<k+1;i++){
		dp[i]=false;
		for(int j=0;j<n;j++){
			if(i-a[j]>=0){
				dp[i]=dp[i] || !dp[i-a[j]];
				if(dp[i])  break;}
			else 
			break;
		}}
	if(dp[k])  cout<<"First\n";
	else cout<<"Second\n";
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define AC 0
#define WA 1
#define TLE 2
#define RE 3
using namespace std;

int main(){
    int n;
    string s;
    int ans[5];
    cin >> n;
    for(int i=0;i<5;i++){
        ans[i] = 0;
    }
    for(int i=0;i<n;i++){
        cin >> s;
        if ( s == "AC" ){
            ans[AC]++;
        }
        if ( s == "WA" ){
            ans[WA]++;
        }
        if ( s == "TLE" ){
            ans[TLE]++;
        }
        if ( s == "RE" ){
            ans[RE]++;
        }
    }
    cout << "AC x " << ans[AC] << "\n";
    cout << "WA x " << ans[WA] << "\n";
    cout << "TLE x " << ans[TLE] << "\n";
    cout << "RE x " << ans[RE] << "\n";
}

Measured memory_bytes: 3620
#include <stdio.h>

int main()
{
    int n, count;
    char a[105], b[105], c[105];
    scanf("%d", &n);
    scanf("%s%s%s", a, b, c);
    count = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] == b[i])
        {
            if (a[i] != c[i])
                count += 1;
        }
        else if (a[i] == c[i] || b[i] == c[i])
            count += 1;
        else
            count += 2;
    }
    printf("%d\n", count);
}

Measured memory_bytes: 128