akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1000000007;
const int MAX_NM = 2000;

ll dp[MAX_NM + 5][MAX_NM + 5];

int main() {
    int n, m;
    cin >> n >> m;
    int s[n], t[m];
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 0; i < m; i++) cin >> t[i];
    dp[0][0] = 1;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (i > 0) {
                dp[i][j] += dp[i - 1][j];
                dp[i][j] %= MOD;
            }
            if (j > 0) {
                dp[i][j] += dp[i][j - 1];
                dp[i][j] %= MOD;
            }
            if (i > 0 && j > 0 && s[i - 1] == t[j - 1]) {
                dp[i][j] += dp[i - 1][j - 1];
                dp[i][j] %= MOD;
            }
            if (i > 0 && j > 0) {
                dp[i][j] -= dp[i - 1][j - 1];
                if (dp[i][j] < 0) dp[i][j] += MOD;
            }
        }
    }
    cout << dp[n][m] << endl;
}

Measured memory_bytes: 31616
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#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>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-20;
const long INF = 1e10;

int f(int n,int k){
	if(n==1)return 0;
	return (f(n-1,k)+k)%n;
}
int main(){
	int n,q;
	while(cin>>n>>q){
		if(n==0&&q==0)break;
		string str;long n1,n2;
		vector<pair<long,string> >pi;
		vector<long>bd;
		REP(i,n){
			cin>>str>>n1>>n2;
			pi.PB(MP(n2-n1+1,str));
			bd.PB(n2);
		}
		SORT(pi);SORT(bd);
		vector<long>num;vector<string>nm;
		REP(i,SZ(pi)){
			num.PB(pi[i].first);
			nm.PB(pi[i].second);
		}
		REP(i,q){
			long que;
			cin>>que;
			int cnt=upper_bound(ALL(num),que)-num.begin();
			if(cnt==0||que>bd[cnt-1]){
				cout<<"Unknown"<<endl;
			}else{
				cout<<nm[cnt-1]<<" "<<que-num[cnt-1]+1<<endl;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1348
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque


def main():
    num, a, b = map(int, input().split())
    print(min(a, b), max(0, a + b - num))





if __name__ == '__main__':
    main()
    # test()



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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template <typename P, typename Q>
ostream& operator<<(ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T> v)
{
  os << "(";
  each (i, v)
    os << i << ",";
  os << ")";
  return os;
}

int main(int argc, char* argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli x, y;
  while (cin >> x >> y) {
    int cnt = 0;
    lli z = x;
    while (z <= y) {
      z *= 2;
      ++cnt;
    }
    cout << cnt << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll pow_1(ll m,ll n,ll mod)
{	if(n==0)return 1;
	ull res=1;
	while(n>0)
	{	if(n&1) res=res*m%mod;
		m=m*m%mod;
		n/=2;
	}
	return res;
}//非递归
int main()
{	
	int m,n;
	cin>>m>>n;
	cout<<pow_1(m,n,1e9+7)<<endl;
	return 0;
}


Measured memory_bytes: 3112
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
if n < m:
    x_distance = [x2 - x1 for x1, x2 in zip(x, x[1:])]
    x_distance.sort()
    print(sum(x_distance[:m-n]))
else:
    print(0)


Measured memory_bytes: 13960
N, A, B = map(int, input().split())
S = input()

cnt = 0
cnt_b = 0
for s in S:
    if s =='a':
        if cnt < A+B:
            print('Yes')
            cnt+=1
        else:
            print('No')
    elif s=='b':
        if (cnt < A+B)&(cnt_b < B):
            print('Yes')
            cnt+=1
            cnt_b+=1
        else:
            print('No')
    else:
        print('No')


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

typedef long long ll;
typedef vector<ll> v1;
typedef vector<v1> v2;

typedef vector<vector<ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll n;
ll a[3*100000];
unordered_map<ll,ll> cnt;
unordered_map<ll,ll> xorcnt;
ll ans;
ll tmp;

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

    // for(ll i = 0;i < n;i++){
    //     for(ll j = i+1;j < n;j++){
    //         tmp += a[i]^a[j];
    //     }
    // }
    // cerr << tmp << endl;
    for(ll i = 0;i < n;i++){
        for(ll b = 1;b < (1ll << 62);b <<= 1){
            if((a[i]&b) == 0){
                xorcnt[b] += cnt[b];
            }else{
                xorcnt[b] += (i-cnt[b]);
                cnt[b]++;
            }
        }
    }
    for(auto x : xorcnt){
        ll b = x.first%mod;
        ans += (b*(x.second%mod))%mod;
        ans %= mod;
    }
    cout << ans << endl;

}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#include<cstdio>
using namespace std;
int main()
{
   int a,b;
   while(scanf("%d%d",&a,&b)==2)
   {
   if(a%3==0||b%3==0||(a+b)%3==0)
      cout<<"Possible"<<endl;
   else cout<<"Impossible"<<endl;
   }
   return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N;
int A;
int main(){
	cin>>N;
	int B[100001]={};
	for(int i=0;i<N;i++){
		cin>>A;
		B[A]++;
	}
	if(N%2==1 && B[0]!=1){
		cout<<"0"<<endl;
		return 0;
	}

	ll ans=1;
	if(N%2==0){
		for(int i=1;i<N;i+=2){
			if(B[i]!=2){
				cout<<"0"<<endl;
				return 0;
			}
			ans=(ans*2)%1000000007;
		}
		cout<<ans<<endl;
		return 0;
	}else{
		for(int i=2;i<N;i+=2){
			if(B[i]!=2){
				cout<<"0"<<endl;
				return 0;
			}
			ans=(ans*2)%1000000007;
		}
		cout<<ans<<endl;
		return 0;
	}
	cout<<"0"<<endl;


	return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{

// }}}


signed main()
{
    i64 a, b, c;
    cin >> a >> b >> c;

    int cnt = 0;
    while(cnt < 128 && a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
        i64 x = a / 2;
        i64 y = b / 2;
        i64 z = c / 2;
        a = y + z;
        b = x + z;
        c = x + y;
        ++cnt;
    }
    if (cnt == 128) cnt = -1;
    cout << (cnt) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>(b);i--)
using namespace std;

int main(void) {
	long long int x, t;
	cin >> x >> t;
	if (x - t < 0) {
		cout << 0 << endl;
	}
	else {
		cout << x - t << endl;
	}
	


	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef int ss;
#define int long long

typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

ll N,H,W;

ss main()
{
  cin>>N>>H>>W;
  cout<<(N-H+1)*(N-W+1)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define lop(i, n) for(i=0; i<n; i++)

int compare_int(const void *a, const void *b) { 
  return *(int*) a-*(int*) b;
}

int main()
{
	int n, m, i, cnt=0;
	scanf("%d %d", &n, &m);
	int x[100000], r[100000];
	lop(i, m){ scanf("%d", &x[i]); }
	
	if(n>=m){ printf("0"); return 0; }
	qsort(x, m, sizeof(int), compare_int);
	
	for(i=1; i<m; i++){
		r[i]=x[i]-x[i-1];
	}
	qsort(r, m, sizeof(int), compare_int);
	for(i=0; i<=m-n; i++){
		cnt+=r[i];
	}
	
	printf("%d", cnt);
	
return 0;
}

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

int a[12][12];
int n, m, x;
vector<int> c;
int ans = 1001001001;

int rec(vector<int> b) {
    if (b.size() == n) {
        //
        int money = 0;
        vector<int> tot(m);
        for (int i = 0; i < n; ++i) {
            if (b[i]) {
                money += c[i];
                rep(j,m) tot[j] += a[i][j];
            }
        }
        bool flag = true;
        rep(j,m) if (tot[j] < x) flag = false;
        if (flag) ans = min(ans, money);
        return 0;
    }

    b.push_back(0);
    rec(b);
    b.back()++;
    rec(b);
    return 0;
}

int main() {
    cin >> n >> m >> x;
    c = vector<int> (n);
    rep(i,n) {
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
    }

    vector<int> b;
    b.push_back(0);
    rec(b);
    b.back()++;
    rec(b);
    if (ans == 1001001001) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
void program(); int main() {cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit); program();}
#define int long long
#define endl "\n"
#define all(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>

int n;

#define N 301

double dp[N][N][N];

double f(int a, int b, int c) {
    if(a<0 || b<0 || c<0) return 0;
    if(a+b+c==0) return 0; 
    if(dp[a][b][c] != -1) return dp[a][b][c];
    double cur = a+b+c;
    return dp[a][b][c] = n/cur + ((double)a/cur)*f(a-1,b,c)
                               + ((double)b/cur)*f(a+1,b-1,c)
                               + ((double)c/cur)*f(a,b+1,c-1);
}

void program(){
    for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
    for(int k=0;k<N;k++)
    dp[i][j][k] = -1;

    cin>>n;
    int a,b,c; // 1,2,3
    a=b=c=0;
    for(int i=0;i<n;i++){
        int t; cin>>t;
        if(t==1) a++;
        if(t==2) b++;
        if(t==3) c++;
    }
    cout<<fixed<<setprecision(16)<<f(a,b,c)<<endl;
}

/*
WA:
-bounds on loops
-truncating
-intialization
-0 vs 1 indexing

TLE:
-might need unordered_set/map
-infinite while loop

Stuck:
-different perspective?
-bruteforce?
-greedy?
-reduce dimensionality with problem contraints?
*/


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 510

ll N;
ll C[MAX_N];
ll S[MAX_N];
ll F[MAX_N];

int main()
{
    cin >> N;
    REP(i, N-1) {
        cin >> C[i] >> S[i] >> F[i];
    }
    REP(i, N-1) {
        ll ret = S[i] + C[i];
        for(int j = i+1; j < N-1; ++j) {
            if(ret <= S[j]) {
                ret = S[j];
            } else {
                ret -= S[j];
                if(ret % F[j] != 0) {
                    ret = ((ret / F[j]) + 1) * F[j];
                }
                ret += S[j];
            }
            ret += C[j];
        }
        printf("%lld\n", ret);
    }
    printf("0\n");
    return 0;
}


Measured memory_bytes: 256
while True:
    try:
        a, b, c, d, e, f = map(int,input().split())
        x = (b*f - e*c) / (b*d - a*e)
        y = (a*f - c*d) / (a*e - b*d)
        if x == -0.000:
            x = 0
            
        print('{:.3f}'.format(x), '{:.3f}'.format(y))
    except:
        break


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

ll N;
vector<ll> G[101010];

ll dp[101010][2];

ll rec(ll now, ll par, ll white){
	if(dp[now][white]>=0) return dp[now][white];
	ll res = 1;
	REP(i, G[now].size()){
		ll next = G[now][i];
		if(next==par) continue;
		if(white==1){
			ll prod = rec(next, now, 1) + rec(next, now, 0);
			prod %= mod;
			res *= prod;
			res %= mod;
		}else{
			ll prod = rec(next, now, 1);
			prod %= mod;
			res *= prod;
			res %= mod;
		}
	}
	dp[now][white] = res;
	return res;
}

int main(){
	cin >> N;
	REP(i, N-1){
		ll x, y;
		cin >> x >> y;
		x--;y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	REP(i, 101010)REP(j, 2) dp[i][j] = -1;
	cout << (rec(0, -1, 1) + rec(0, -1, 0))%mod << endl;
    return 0;
}

Measured memory_bytes: 15616
a,b,c,d,e,f=map(int,input().split())
g=[-1]*9999
g[a*100]=0
g[b*100]=0
h=[a*100,0]
p=0
for i in range(1,f+1):
    if g[i]==-1:
        continue
    if (g[i]+c)/(i-g[i])<=e*0.01:
        g[i+c]=max(g[i]+c,g[i+c])
    if (g[i]+d)/(i-g[i])<=e*0.01:
        g[i+d]=max(g[i]+d,g[i+d])
    g[i+a*100]=max(g[i+a*100],g[i])
    g[i+b*100]=max(g[i+b*100],g[i])
    if g[i]/i>p:
        p=g[i]/i
        h=[i,g[i]]
print(*h)

Measured memory_bytes: 9296
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i).sort
INF = (10 ** 6)
arr = Array.new(INF+1,0)
a.each do |i|
    next if arr[i] == 2 
    i.step(INF, i) do |j| 
        arr[j] += 1 
    end
end
count = 0
a.each do |i|
    count += 1 if arr[i] == 1
end
puts count

Measured memory_bytes: 40132
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
#define pi pair<int, int>
#define vi vector<int>
#define REP(a,b)  for (int i = int(a); i < int(b); i++)
#define endl "\n"
#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define w(tc) int tc; cin>>tc; while(tc--)
using namespace std;


int main() {
	IOS
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll n, a, ans = 0;
	cin >> n;
	vector<int> v;
	v.reserve(200005);
	for (ll i = 0; i < n; i++) {cin >> a; v.push_back(a);}
	for (ll i = 1; i < n; i++) {
		if (v[i] < v[i - 1]) {ans += (v[i - 1] - v[i]); v[i] = v[i - 1];}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3972
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int dp[100][100][100];
#define UNDEF -1

int rec(int a,int b,int c){
	if(dp[a][b][c] != -1) return dp[a][b][c];

	int ret=1000000;

	if(a>=2 && rec(a-2,b,c) != -1) ret = min(ret,rec(a-2,b,c)+1);
	if(b>=2 && rec(a,b-2,c) != -1) ret = min(ret,rec(a,b-2,c)+1);
	if(c>=2 && rec(a,b,c-2) != -1) ret = min(ret,rec(a,b,c-2)+1);
	if(b>=1 && c >= 1 && rec(a,b-1,c-1) != -1) ret = min(ret,rec(a,b-1,c-1)+1);
	if(c>=1 && a >= 1 && rec(a-1,b,c-1) != -1) ret = min(ret,rec(a-1,b,c-1)+1);
	if(a>=1 && b >= 1 && rec(a-1,b-1,c) != -1) ret = min(ret,rec(a-1,b-1,c)+1);



	return dp[a][b][c]=ret;
}

int main(int argc, const char * argv[]) {
	int a,b,c;

	cin >> a >> b >> c;

	memset(dp,-1,sizeof dp);
	dp[a][b][c] = 0;
	for(int i = max(max(a,b),c);i <= 100; i++){
		if(rec(i,i,i) != 1000000){
			println((i*3-a-b-c)/2);
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int x;
	cin>>x;
	if(x>=30) cout<<"Yes"<<endl;
	else      cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	int A, B; cin >> A >> B;
	char S[12]; cin >> S;

	if (S[A] != '-') {
		cout << "No" << endl;
		return 0;
	}
	rep(i, 0, A) {
		if (!(S[i] >= '0' && S[i] <= '9')) {
			cout << "No" << endl;
			return 0;
		}
	}
	rep(i, A + 2, A + B + 1) {
		if (!(S[i] >= '0' && S[i] <= '9')) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[4];
int main(){
	cin >> s;
	sort(s,s+4);
	if(s[0]==s[1] and s[2]==s[3] and s[1]!=s[2])cout << "Yes";
	else cout << "No";
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ll x;
    cin >> x;
    ll base = 100;
    for (int i = 1; ; ++i) {
        base = base + base * 0.01;
        if (base >= x) {
            cout << i << endl;
            return 0;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
string s;
int main(void){
    cin>>s;
    int i=s.size()-1;
    while(i>=0){
        if(i>=4&&s[i]=='m'&&s[i-1]=='a'&&s[i-2]=='e'&&s[i-3]=='r'&&s[i-4]=='d'){
            i=i-5;
        }else if(i>=6&&s[i]=='r'&&s[i-1]=='e'&&s[i-2]=='m'&&s[i-3]=='a'&&s[i-4]=='e'&&s[i-5]=='r'&&s[i-6]=='d'){
            i=i-7;
        }else if(i>=4&&s[i]=='e'&&s[i-1]=='s'&&s[i-2]=='a'&&s[i-3]=='r'&&s[i-4]=='e'){
            i=i-5;
        }else if(i>=5&&s[i]=='r'&&s[i-1]=='e'&&s[i-2]=='s'&&s[i-3]=='a'&&s[i-4]=='r'&&s[i-5]=='e'){
            i=i-6;
        }else{
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;

}



Measured memory_bytes: 3700
import sys
import math

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, N = map(int, input().split())

ans = 0

if N < B - 1:
    ans = math.floor(A * N / B) - A * math.floor(N / B)
else:
    c = B - 1
    cnt = 1
    while c <= N:
        cnt += 1
        t = math.floor(A * c / B) - A * math.floor(c / B)
        ans = max(ans, t)
        c += B
        if B < cnt:
            break

print(ans)


Measured memory_bytes: 9144
h,w,k = map(int,input().split())
a = [list(input()) for i in range(h)]
acc = [[0 for i in range(w+1)] for j in range(h+1)]
for i in range(1,h+1):
  for j in range(1,w+1):
    acc[i][j] = acc[i-1][j]
    if a[i-1][j-1] == "1":
      acc[i][j] += 1
for i in range(1,h+1):
  for j in range(1,w+1):
    acc[i][j] += acc[i][j-1]
ans = 1000000
def cut(x,y,up,left):
  return acc[x][y]-acc[x][left]-acc[up][y]+acc[up][left]
for i in range(2**(h-1)):
  sep = [0]
  for r in range(h-1):
    if i&1<<r:
      sep.append(r+1)
  sep.append(h)
  anstmp = len(sep)-2
  left = 0
  for j in range(1,w+1):
    if max(list(cut(sep[x],j,sep[x-1],left) for x in range(1,len(sep)))) > k:
      break
    if j<w and max(list(cut(sep[x],j+1,sep[x-1],left) for x in range(1,len(sep)))) > k:
      anstmp += 1
      left = j
  else:
    ans = min(ans,anstmp)
print(ans)


Measured memory_bytes: 50012
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	string str;
	int a,b;
	while(cin>>str)
	{
		a=b=0;
		for(int i=0;i<str.length();i++)
		if(str[i]=='1')
		a++;
		else
		b++;
		cout<<2*min(a,b)<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

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

    int N = scanner.nextInt();
    char[] S = scanner.next().toCharArray();
    long[] freq = new long[26];
    for (char ch : S) {
      freq[ch - 'A']++;
    }
    long count = freq['R' - 'A'] * freq['G' - 'A'] * freq['B' - 'A'];
    for (int i = 1; i < N; i++) {
      for (int j = 0; j + 2 * i < N; j++) {
        if (S[j] != S[j + i] && S[j + i] != S[j + i * 2] && S[j] != S[j + i * 2]) count--;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 27368
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 1010000;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

typedef pair<int, int>P;

long long power_mod(long long x, long long n, long long m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return power_mod(x * x % m, n / 2, m);
	else
		return x * power_mod(x, n - 1, m) % m;
}

int a[303];
int dp[303][90090],dp2[303][90090];
int MOD2 = 998244353;

int mod(int x, int m) {
	while (x < 0) {
		x += m;
	}
	return x % m;
}

signed main() {
	REP(i, 303) {
		m0(dp[i]); m0(dp2[i]);
	}
	int N; cin >> N;
	int S = 0;
	REP(i, N) {
		cin >> a[i];
		S += a[i];
	}
	dp[0][0] = 1;
	dp2[0][0] = 1;
	FOR (i, 1, N + 1) {
		REP(j, 90090) {
			dp[i][j] += dp[i - 1][j]*2;
			dp[i][j] %= MOD2;
			if (j >= a[i - 1]) {
				dp[i][j] += dp[i - 1][j - a[i - 1]];
				dp[i][j] %= MOD2;
			}

			dp2[i][j] += dp2[i - 1][j];
			dp2[i][j] %= MOD2;
			if (j >= a[i - 1]) {
				dp2[i][j] += dp2[i - 1][j - a[i - 1]];
				dp2[i][j] %= MOD2;
			}
		}
	}
	int ans = 0;
	ans += power_mod(3, N, MOD2);
	for (int i = (S+1)/2; i <= S; i++)
	{
		ans -= dp[N][i] * 3;
		ans =mod(ans,MOD2);
	}
	if (S % 2 == 0) {
		ans += 3 * dp2[N][S / 2];
		ans %=MOD2;
	}
	print(ans%MOD2);
	/*REP(i, S+1) {
		pe(i)print(dp[N][i]);
	}*/
}


Measured memory_bytes: 426752
int H[100010];
int ng[100010];

int main() {
	int n, m;
	scanf("%d%d",&n, &m);

	for(int i = 1; i <= n; i++)
    scanf("%d",H + i);
	for(int i = 0; i < m; i++) {
		int a, b;
		scanf("%d%d",&a, &b);
		if(H[a] <= H[b])
        ng[a] = 1;
		if(H[a] >= H[b])
        ng[b] = 1;
	}

	int ans = 0;
	for(int i = 1; i <= n; i++)
    if(!ng[i])
    ans++;
	printf("%d\n",ans);
}


Measured memory_bytes: 2508
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;


int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; i++) cin >> H[i];
    int max_h  = 0;
    int sum = 0;
    for(int i = 0; i < N; i++) {
        max_h = max(max_h, H[i]);
        if(max_h <= H[i]) sum++;
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
object Main {
  val sc = new java.util.Scanner(System.in)

  def sin(n: Int): Seq[Int] = Seq.fill(n)(sc.nextInt())

  def iin(): Int = sc.nextLine().toInt

  def main(args: Array[String]): Unit = {
    val n = iin()
    val ls = Seq.fill(n)(sc.nextDouble(), sc.nextLine())

    println(
      ls.foldLeft(0.0)(
        (b, p) => {
          b + (if (p._2 == " JPY") p._1 else p._1 * 380000.0)
        }
      )
    )
  }
}

Measured memory_bytes: 25776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100005,p=1000000007;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,s,a[N];
ll ans,b[N];
int main(){
	n=read();s=read();
	for (int i=1;i<=n;i++) a[i]=read(),b[i]=read();
	int l=1,r=n,las=0;
	while (1){
		if (a[r]<s){ans+=s-a[l];break;}
		if (a[l]>s){ans+=a[r]-s;break;}
		if (b[l]>=b[r]) {
			if (las!=-1) ans+=a[r]-a[l];
			b[l]+=b[r--];
			las=-1;
		}
		else {
			if (las!=1) ans+=a[r]-a[l];
			b[r]+=b[l++];
			las=1;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1408
S = input()
K = int(input())

T = "N"
for i in range(len(S)):
  if S[i] != "1":
    T = "Y"
    k = i+1
    x = int(S[i])
    break
if T == "N":
  print(1)
else:
  if K < k:
    print(1)
  else:
    print(x)

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


int n;
string order;
set<string> A;
string str;

int main() {
	cin >> n;
	rep(i, n) {
		cin >> order>>str;
		if (order == "insert") A.insert(str);
		else if (order == "find") {
			int ans = A.count(str);
			if (ans == 1) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
	return 0;
}


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

int main(){
  //入力
  int A, B, C;
  cin >> A >> B >> C;

  //処理
  int ans = B / A;
  if (ans > C) ans = C;

  //出力
  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    ans = 0
    for _ in range(N):
        l, r = map(int, input().split())
        ans += r - l + 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4072
N=parse(Int,readline())
#N=1000000


sN=N*(N+1)÷2
N3=N÷3
sN3=3*N3*(N3+1)÷2
N5=N÷5
sN5=5*N5*(N5+1)÷2
N15=N÷15
sN15=15*N15*(N15+1)÷2

print(sN-sN3-sN5+sN15)

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

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

Measured memory_bytes: 256
#include <cstdio>

const int MOD = 1e9 + 7, MAX_N = 1e6 + 5;
typedef long long LL;

LL factorial[MAX_N];
LL inverse_factorial[MAX_N];

LL power_mod(LL x, LL power, LL MOD)
{
    LL answer = 1;

    while(power)
    {
        if(power%2 == 1)
            answer = (answer*x)%MOD;

        x = (x*x)%MOD;
        power = power >> 1;
    }

    return answer;
}

LL choose(LL n, LL r, LL MOD)
{
    LL numerator = factorial[n]; 
    LL denominator_inverse = (inverse_factorial[r]*inverse_factorial[n - r])%MOD;

    return (numerator*denominator_inverse)%MOD;
}

int main()
{
    const int MOD = 1e9 + 7;

    factorial[0] = 1;
    for(int i = 1; i < MAX_N; i++)
        factorial[i] = (i*factorial[i - 1])%MOD; 

    inverse_factorial[MAX_N - 1] = power_mod(factorial[MAX_N - 1], MOD - 2, MOD);
    for(int i = MAX_N - 2; i >= 0; i--)
        inverse_factorial[i] = ( (i + 1)*inverse_factorial[i + 1] )%MOD;

    int no_of_factors, n;
    scanf("%d %d", &no_of_factors, &n);

    LL answer = 1;
    for(int i = 2; i*i <= n; i++)
    {
        int exponent = 0;

        while(n%i == 0)
        {
            n = n/i;
            exponent++;
        }
        
        LL no_of_ways_of_placing_this_prime = choose(exponent + no_of_factors - 1, exponent, MOD);
        answer = (answer*no_of_ways_of_placing_this_prime)%MOD;
    }

    if(n > 1)
    {
        int exponent = 1;
        
        LL no_of_ways_of_placing_this_prime = choose(exponent + no_of_factors - 1, exponent, MOD);
        answer = (answer*no_of_ways_of_placing_this_prime)%MOD;
    }

    printf("%lld\n", answer);
    return 0;
}


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    Int ma = *max_element(all(a));
    vector<Int> prime(ma + 1);
    iota(all(prime), 0);
    for (Int i = 2; i <= ma; i++) {
        if (prime[i] < i) continue;
        for (Int j = 2; j * i <= ma; j++) {
            prime[i * j] = i;
        }
    }
    unordered_map<Int, Int> mp;
    for (Int i = 0; i < n; i++) {
        Int x = a[i];
        while (x > 1) {   
            if (mp.find(prime[x]) != mp.end()) {
                Int b = a[0];
                for (Int j = 1; j < n; j++) {
                    b = gcd(b, a[j]);
                }
                if (b == 1) {
                    print("setwise coprime");
                } else {
                    print("not coprime");
                }
                return 0;
            }         
            mp[prime[x]]++;
            Int p = prime[x];
            while (x % p == 0) {
                x /= p;
            }
        }
    }
    print("pairwise coprime");
    return 0;
}


Measured memory_bytes: 18744
H,W = map(int,input().split())
N = int(input())
a = list(map(int,input().split()))
c = []
for n in range(N):
    c += [n+1]*a[n]
ans = []
for h in range(H):
    a = c[h*W:W+h*W]
    if h%2==0: ans.append(a)
    else: ans.append(a[::-1])
for i in ans:
    print(*i)

Measured memory_bytes: 3956
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        String s1=sc.next();
        s1=s1.toUpperCase();
        String s2=sc.next();
        s2=s2.toUpperCase();
        String s3=sc.next();
        s3=s3.toUpperCase();
        char[] S1=s1.toCharArray();
        char[] S2=s2.toCharArray();
        char[] S3=s3.toCharArray();
        System.out.print(S1[0]);
        System.out.print(S2[0]);
        System.out.print(S3[0]);
        System.out.println();
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> b(n);
  rep(i, n - 1) cin >> b[i];
  vector<int> a(n);
  a[0] = b[0];
  for (int i = 1; i < n; i++) {
    a[i] = b[i - 1];
    if (i < n - 1) a[i] = min(a[i], b[i]);
  }
  int ans = 0;
  rep(i, n) ans += a[i];
  cout << ans << endl;
  return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

  string S;
  cin >> S;

  if (S[0] == 'S') {
    cout << "Cloudy" << endl;
  } else if (S[0] == 'C') {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }

  return 0;
};


Measured memory_bytes: 256
import math


def main():
    N = int(input())
    ans = [0] * N
    for x in range(1, int(math.sqrt(N)) + 1):
        for y in range(1, int(math.sqrt(N)) + 1):
            for z in range(1, int(math.sqrt(N)) + 1):
                n = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if n <= N:
                    ans[n - 1] += 1
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9152
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int A = Integer.parseInt(tokens[1]);
		int B = Integer.parseInt(tokens[2]);

		int C = N * A;
		System.out.println(Math.min(C, B));
	}
}


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

template
<
    typename TYPE,
    std::size_t SIZE
>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;

#define REP(i,n) for(ll (i) = 0 ; (i) < (n) ; ++(i))



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

    if(n < 1000){
        cout << "ABC" << endl;
    }
    else{
        cout << "ABD" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main (){
	int a,b;
	scanf("%d%d",&a,&b);
	if(-1000<=a && b<=1000){
		if(a<b){
		printf("a < b\n");
		}if(a>b){
		printf("a > b\n");
		}if(a==b){
		printf("a == b\n");
		}
	}else{
	printf("NOT\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

void solve()
{
	int N, M;
	int Num = 1;
	while(cin >> N >> M, N || M)
	{
		vector< queue<int> >Que(M + 1);
		vector< queue<int> >QueBuf(M + 1);
		for(int i = 0; i < N; ++i)
		{
			Que[0].push(0);
		}
		int count = 0;
		while(Que[M].empty())
		{ 
			for(int i = M - 1; i >= 0; --i)
			{
				while(Que[i].size() >= 2)
				{
					QueBuf[i + 1].push(Que[i].front() + 1);
					Que[i].pop();
					QueBuf[0].push(0);
					Que[i].pop();
				}
			}
			for(int i = 0; i < (M + 1); ++i)
			{
				while(!QueBuf[i].empty())
				{
					Que[i].push(QueBuf[i].front());
					QueBuf[i].pop();
				}
			}
			count++;
		}
		cout << "Case " << Num << ": " << count << endl;
		Num++;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 932
#include <cstdio>
#include <string>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N, M;
std::string S;

int main()
{
  scanf( "%d%d", &N, &M );

  rep( i, N )
    S += "*";

  bool fl = false;

  rep( i, M )
  {
    int s, c;
    scanf( "%d%d", &s, &c );

    if( S[s-1] != '*' && S[s-1] != c+'0' )
      fl = true;

    S[s-1] = c+'0';
  }

  if( fl || (N>1 && S[0] == '0') )
  {
    puts( "-1" );

    return 0;
  }

  rep( i, N )
  {
    if( S[i] == '*' )
      S[i] = N>1&&!i?'1':'0';

    printf( "%c", S[i] );
  }

  puts("");

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(void)
{
  int n = 0,k=0,q;
  int i = 0,j = 0;
  cin >> n >> k >> q;
  
  vector<int> p;
 
  for(;i<n;i++)
  {
    p.push_back(0);
  }
  
  for(i = 0;i<q;i++)
  {
    cin >> j ;
    p[j - 1]++;
  }
  
  for(i = 0 ; i < n;i++)
  {
    if(k - q + p[i] <= 0)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1144
#include <iostream>
#include <vector>
#define inf 1000000000

using namespace std;

struct edge{
	int to, cap, cost, rev;
	edge(int a, int b, int c, int d){
		to = a, cap = b, cost = c, rev = d;
	}
};

int V, E, F;
vector<edge> G[1005];
int dist[1005], prev[1005], prev_e[1005];

void BellmanFord()
{
	int v;
	bool update = true;
	
	while(update){
		update = false;
		for(int i = 0; i < V; i++){
			for(int j = 0; j < G[i].size(); j++){
				v = G[i][j].to;
				if(G[i][j].cap == 0) continue;
				if(dist[v] > dist[i] + G[i][j].cost){
					update = true;
					dist[v] = dist[i] + G[i][j].cost;
					prev[v] = i;
					prev_e[v] = j;
				}
			}
		}
		
		
	}
}

int main(void)
{
	cin >> V >> E >> F;
	
	int u, v, c, d;
	for(int i = 0; i < E; i++){
		cin >> u >> v >> c >> d;
		G[u].push_back(edge(v, c, d, G[v].size()));
		G[v].push_back(edge(u, 0, -d, G[u].size()-1));
	}
	
	int p;
	int ans = 0;
	
	while(F > 0){
		
		for(int i = 0; i < V; i++) dist[i] = inf;
		prev[0] = -1, dist[0] = 0;
		BellmanFord();
		
		if(dist[V-1] >= inf) break;
		
		p = V-1;
		int minf = F;
		while(prev[p] != -1){
			minf = min(minf, G[prev[p]][prev_e[p]].cap);
			p = prev[p];
		}
		
		p = V-1;
		while(prev[p] != -1){
			G[prev[p]][prev_e[p]].cap -= minf;
			G[p][G[prev[p]][prev_e[p]].rev].cap += minf;
			p = prev[p];
		}
		
		F -= minf;
		ans += dist[V-1] * minf;
	}
	
	if(F > 0) ans = -1;
	cout << ans << endl;
	return 0;
}

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

int main(){
    ll n;
    cin >> n;
    ll b[200000];
    ll s[200000];
    for (ll i = 0; i < n;i++){
        cin >> b[i];
        s[i] = b[i];
    }
    sort(s, s + n);
    for (ll i = 0; i < n - 1;i++)
    {
        if(s[0] != 1)
        {
            cout << "-1";
            return 0;
        }
    }
    ll ans = 0;
    ll now = 1, p = 0;
    while(p<n)
    {
        if(b[p] != now)
            ans++;
        else{
            now++;
        }
        p++;
    }
    cout << ans;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

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

    if (a <= b) {
        cout << a << endl;
    }
    else {
        cout << a-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;


     signed main(){
         cout << std::fixed << std::setprecision(15);
int a,b,k;
cin>>a>>b>>k;
for(int i=0;i<k;i++){
     if(a%2)a--;
     a/=2;b+=a;
     swap(a,b);
}
if(k%2)cout<<b<<' '<<a;
else cout<<a<<' '<<b;
cout<<endl;
     }

 


 






    





      

        


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

int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll> dp(n);
  vector<ll> l(k);
  vector<ll> r(k);
  ll M=998244353;
  rep(i,k){
    cin >> l[i] >> r[i];
  }
  rep(i,n){
    if(i==0){
      dp[i]=1;
    }else{
      dp[i]=dp[i-1];
      rep(j,k){
        if (i-r[j]-1>=0){
          dp[i]+=dp[i-l[j]];
          dp[i]-=dp[i-r[j]-1];
        }else if(i-l[j]>=0){
          dp[i]+=dp[i-l[j]];
        }
      }
      dp[i]=(dp[i]+M)%M;
    }
  }
  ll res= (dp[n-1]-dp[n-2]+M)%M;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
int num;
int main()
{
	long long n,k;
	cin>>n;
	k=sqrt(n);
	for (long long i=k;i>=1;i--)
		if (n%i==0)
		{
			long long j=n/i;
			while (j!=0)
			{
				num++;
				j/=10;
			}
			break;
		}
	cout<<num;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100
#define INFTY (1 << 21)
#define White 0
#define Gray 1
#define Black 2
void bfs(void);
void enqueue(int);
int dequeue();
int isEmpty();
int n,M[MAX][MAX];
int head=0,tail=0,Q[MAX];
int main(){
  int u,k,v;
  int i,j;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      M[i][j] = 0;
    }
  }

  for(i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      M[u-1][v-1] = 1;
    }
  }
  bfs();

  return 0;
}

void bfs(){
  int color[MAX];
  int d[MAX];
  int i,v;
  for(i = 0; i < n; i++){
    color[i] = White;
    d[i] = INFTY;
  }
  color[0] = Gray;
  d[0] = 0;
  enqueue(0);

  while(!isEmpty()){
    int u;
    u = dequeue();
    for(v = 0; v < n; v++){
      if(M[u][v] && color[v] == White){
        color[v] = Gray;
        d[v] = d[u] + 1;
        enqueue(v);
      }
    }
    color[u] = Black;
  }
  for(i = 0; i < n; i++){
    printf("%d ",i+1);
    if(d[i] == INFTY) printf("-1\n");
    else printf("%d\n",d[i]);
  }
}

void enqueue(int x){
  Q[tail] = x;
  if(tail + 1 == MAX)tail = 0;
  else tail++;
}

int dequeue(){
  int x;
  x = Q[head];
  if(head + 1 == MAX) head = 0;
  else head++;
  return x;
}

 int isEmpty(){
   if(head == tail) return 1;
   else return 0;
 }

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fi first
#define se second 
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define pp pair<ll,ll> 
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
const ll N = 1e5 + 5 ;
ll t = 1 ;
void solve() 
{
    ll n ;
    cin >> n ;
    ld ans = (n*1.0 - (n/2))/(n*1.0) ;
    cout << ans << "\n";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    cin >> t ;
    while(t--){
        solve();
    }
    return 0 ;
}


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

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

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

  vector<ll> a(n);
  rep(i,n) cin >> a.at(i);

  sort(a.begin(), a.end());

  ll ans=0;
  int j=0;
  while(j<n){
    ll now=a.at(j);
    int count=0;
    while(j<n&&a.at(j)==now){j++; count++;}
    if(count>=now) ans+=(count-now);
    else ans+=count; 
  }

  cout << ans;
}

Measured memory_bytes: 4056
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int flag=0;
	for(int i=0;i<=25;i++)
		for(int j=0;j<15;j++)
			if(i*4+j*7==n)
			{
				cout<<"Yes"<<endl;
				flag=1;
				return 0;
			}
	if(flag==0)
		cout<<"No"<<endl;
	return 0; 
}

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

using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
bool desirable[N];
int n, a[N];
int main() {
	cin >> n; for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < n; ++i)
		if (a[i] == 1) {
			desirable[1] = true;
		}
		else if (desirable[a[i] - 1])
			desirable[a[i]] = true;
	for (int i=n; i>=1; --i)
		if (desirable[i]) {
			cout << n-i << endl;
			return 0;
		}
	cout << -1 << endl;
}

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

typedef  long long int ll;
typedef  vector<int> vi;
#define  IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  pb push_back
#define  fn for(int i=0;i<n;i++)
#define  all(x) x.begin(), x.end()
#define  endl "\n"


void solve()
{
	// write your code here :
	long long n;
	cin>>n;
	ll a,b;
	ll ans=0;
	cin>>a>>b;
	ll use=n/(a+b);
	 ans+=a*use;
	ans+=min(a,n%(a+b));
	cout<<ans<<endl;
}

int main()
{
	IOS
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
	// int t;
	// cin>>t;
	// while(t--)
	solve();
}


Measured memory_bytes: 256