akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


int main()
{
	
	string s,t;
	cin>>s;
	cin>>t;
	int m=s.length();
	int n=t.length();
	int dp[m+1][n+1];
	for (int i=0;i<=m;i++) 
	{
	for (int j=0;j<=n;j++)
	{
		if (i==0 || j==0) dp[i][j]=0;
		else if (s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
		else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
	}
}
	
	int ii=m,jj=n;
	string st="";
	while(ii>0 and jj>0)
	{
		if (s[ii-1]==t[jj-1]) 
		{st=s[ii-1]+st;
		ii--;jj--;}
		else if (dp[ii-1][jj]>dp[ii][jj-1]) ii--;
		else jj--;
	}
	cout<<st<<endl;
}

Measured memory_bytes: 35456
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

vector<LL> v1;

int main(){
	LL n,m;
	int i,j,k;
	LL a,b,c;
	cin>>n>>m;
	LL v,p;
	cin>>v>>p;
	for(i=0;i<n;i++){
		cin>>a;
		v1.push_back(a);
	}
	sort(v1.rbegin(),v1.rend());
	LL s=p;
	a=0;
	for(i=p;i<n;i++){
		a+=v1[i-1];
		b=(LL)(v1[i]+m)*(i-p+1);
		if(v1[i]+m<v1[p-1])break;
		c=(v-(n-(i-p+1)))*m;
		if(b-a<c)break;
		s++;
	}
	cout<<s<<endl;
}

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

int main(){
  int X;
  cin >> X;
  bool isNotPrime = true;
  int num = X;
  while(isNotPrime){
    bool isDiv = false;
    for(int i = 2; i <= sqrt(num); i++){
      if(num % i == 0){
        isDiv = true;
        break;
      }
    }
    if(!isDiv) break;
    num++;
  }
  cout << num << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  char s[4];
  char t[4];
  int cnt = 0;
  int i;
  
  scanf("%s %s", s, t);
  for (i = 0; i < 3; i++)
    if (s[i] == t[i])
      cnt++;
  
  printf("%d", cnt);
  
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int a,b;
int main()
{
	while(~scanf("%d%d",&a,&b))
	{
		int sum;
		if(b<10)
			sum=a*10+b;
		else if(b<100)
			sum=a*100+b;
		else sum=a*1000+b;
		int root=(int)sqrt(sum);
		if(root*root==sum)
			printf("Yes\n");
		else printf("No\n");
	}
	return 0;
	 
 } 

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,K,ans=0;
  char c='a';
  cin>>N>>K>>c;
  for(int i=1;i<N;i++){
    char a;
    cin>>a;
    if(c==a)ans++;
    c=a;
  }
  cout<<min(ans+2*K,N-1)<<endl;
}

Measured memory_bytes: 3636
l = list(map(int, input().split()))

ans = 0
while True:
  diff = max(l) - min(l)
  if diff == 0:
    break
  elif diff % 2 == 0:
    l[l.index(min(l))] += 2
    ans += 1
  else:
    add_nums = [i for i in range(3) if i != l.index(max(l))]
    for num in add_nums:
      l[num] += 1
    ans += 1

print(ans)

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

int main(){
 int a,b,c,d,e,f;
 cin>>a;
 if(a>=400&&a<=599){
 	cout<<"8";
 }	
 if(a>=600&&a<=799){
 	cout<<"7";
 }	
 if(a>=800&&a<=999){
 	cout<<"6";
 }	
 if(a>=1000&&a<=1199){
 	cout<<"5";
 }	
 if(a>=1200&&a<=1399){
 	cout<<"4";
 }	
 if(a>=1400&&a<=1599){
 	cout<<"3";
 }	
 if(a>=1600&&a<=1799){
 	cout<<"2";
 }	
 if(a>=1800&&a<=1999){
 	cout<<"1";
 }	
 
	
}

Measured memory_bytes: 3684
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            Double[] l = Stream.of(sc.next().split(",")).map(Double::parseDouble).toArray(Double[]::new);
            if (l[1] / l[2] / l[2] >= 25)
                System.out.println(l[0].intValue());
        }
    }
}


Measured memory_bytes: 31704
import itertools

h, w, k = map(int, input().split())
c = [[x for x in input()] for i in range(h)]

ans = 0

for hi in range(2**h):
  for wi in range(2**w):
    c_cp = [[n for n in i] for i in c]
    
    for hj in range(h):
      if (hi & (1<<hj)) != 0:
        c_cp[hj] = ['R' for n in c_cp[hj]]
    
    for wj in range(w):
      if (wi & (1<<wj)) != 0:
        for hk in range(h):
          c_cp[hk][wj] = 'R'
    
    cnt = list(itertools.chain.from_iterable(c_cp)).count('#')
    
    if cnt == k:
      ans += 1

print(ans)

Measured memory_bytes: 9248
#include<iostream>
#include<stdio.h>

int main()
{
	double a, b, c, d, e, f;
	while( scanf( "%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f ) != EOF ){
		double x, y;
		double det = b * d - a * e;
		y = ( c * d - a * f ) / det;
		x = ( c - b * y ) / a;
		printf( "%.3f %.3f\n", x, y );
	}

 	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string sprime, t; cin >> sprime >> t;
    string s = sprime;
    
    if (sprime.size() < t.size()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) == '?') s.at(i) = 'z';
    }
    
    bool does_exist = 0;
    for (int i = 0; i <= sprime.size() - t.size(); i++) {
        bool t_flag = 1;
        for (int j = 0; j < t.size(); j++) {
            if (sprime.at(i + j) != '?' && sprime.at(i + j) != t.at(j)) {
                t_flag = 0;
                break;
            }
        }
        if (!t_flag) continue;
        // the above is tested only for candidates.
        
        does_exist = 1;
        string temp_ans = sprime;
        for (int j = 0; j < t.size(); j++) temp_ans.at(i + j) = t.at(j);
        for (int j  = 0; j < temp_ans.size(); j++) {
            if (temp_ans.at(j) == '?') temp_ans.at(j) = 'a';
        }
        if (temp_ans < s) s = temp_ans;
    }
    
    cout << (does_exist ? s : "UNRESTORABLE") << endl;
    
    return 0;
}


Measured memory_bytes: 256
// AGC012A - AtCoder Group Contest

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

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

	vector<int> a(3 * N);
	for (int i = 0; i < 3 * N; i++) {
		cin >> a.at(i);
	}

	sort(a.begin(), a.end(), greater<int>());

	// long long にしないと結果が治まらないことがある。
	long long int ans = 0;
	for (int i = 1; i < 2 * N; i += 2) {
		ans += (long long int)a.at(i);
	}

//	最初、完全に勘違いしたロジックを組んでいた。
//	解説を読むまで間違いに気づかず。例も巧妙に組まれていた。
//	for (int i = N; i < 2 * N; i++) {
//		ans += (long long int)a.at(i);
//	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i,0,(n))
#define pb(n) push_back(n)
#define mp(n,m) make_pair(n, m)
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;

int m, n, x, y;
int d[25][25];
vi ans;

bool check(){
	for(int i = 0; i < m; i++){
		for(int j = i+1; j < m; j++){
			if(d[ans[j]][ans[i]]){
				x= i; y = j;
				return true;;
			}
		}
	}
	return false;
}

int main(){
	cin>>m>>n;
	rep(i, n){
		cin>>x>>y;
		d[x][y]=1;
	}
	rep(i, m){
		ans.pb(i+1);
	}
	while(check()){
		swap(ans[x], ans[y]);
	}
	for(int i = 0; i < m; i++){
		cout<<ans[i]<<endl;
	}
}

Measured memory_bytes: 1216
// BROWNIE TK
 
#include <bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
 
#define forz(i, n) for (int i = 0; i < n; i++)
#define bui(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define mui(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
 
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define osetlli tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order

using namespace std;
 
/*STD fucntions*/
lli power(lli x,lli y,lli p)
{
    lli res=1;
    x=x%p;
    while(y>0)
    {
        if(y&1)
            res=(res*x)%p;
        //y must be even now
        y=y>>1; //y=y/2
        x=(x*x)%p;
    }
    return res;
}
lli gcd(lli a, lli b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{ return a * b / gcd(a, b); }
lli modi(lli a,lli m)
{
// fermat little thm where m is prime
return power(a,m-2,m);
}
/*CODE BEGINS*/
int main()
{
 kira;
 lli n,k;
 cin>>n>>k;
 lli a[n];
 forz(i,n)cin>>a[i];
 lli inf=1e9+5;
 lli dp[n+1];
 memset(dp,inf,sizeof(dp));
 dp[0]=0;
 for(int i=0;i<=n;i++)
 {
   for(int j=1;j<=k;j++)
   {
     if(i-j>=0)
     {dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));}
   }
   //p1(dp[i]);
 }
 cout<<dp[n-1];
 return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int M = 1000000007;
const double PI = atan(1) * 4;
const int oo = 1000000000;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define pb push_back 
#define all(c) (c).begin(),(c).end()
int n,m,ct,sz;
vi g[N];
bool vis[N],is=true,col[N];
ll ans;
void dfs(int u, bool cl){
	vis[u]=true;
	col[u]=cl;
	ct+=cl;
	for(int i=0; i<g[u].size(); ++i){
		int d=g[u][i];
		if(!vis[d])
			dfs(d,cl^1);
		if(col[d]==col[u])
			is=false;
	}
}
int main(){
	#ifndef ONLINE_JUDGE
//		freopen("input.txt", "r", stdin);
	#endif
	cin>>n>>m;
	for(int a,b,i=0; i<m; ++i){
		scanf("%d%d",&a,&b);
		--a;--b;
		g[a].pb(b);
		g[b].pb(a);
	}
	dfs(0,0);
	if(!is)
		ans=1ll*n*(n-1)/2-m;
	else
		ans=1ll*ct*(n-ct)-m;
	cout<<ans<<endl;
}




Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
const int MAX = 100009;
int x,y,z;
int a[MAX],b[MAX], c[MAX];
long long ans, mx[MAX], my[MAX];
main(){
    cin >>x >> y >> z;
    vector<pair<int,int > > v;
    for(int i = 0; i < x + y + z; i++){
        cin >> a[i] >> b[i] >> c[i];
        ans += c[i];
        a[i] -= c[i];
        b[i] -= c[i];
        v.push_back({a[i] - b[i], i});
    }
    sort(v.rbegin(), v. rend());
    priority_queue<int> q;
    long long s = 0;
    for(int i = 0; i < v.size(); i++){
        int j = v[i].second;
        s += a[j];
        q.push(-a[j]);
        if(q.size() > x){
            s += q.top();
            q.pop();
        }
        mx[i] = s;
    }
    while(q.size())
        q.pop();
    s = 0;
    for(int i = v.size() - 1; i >= 0; i--){
        int j = v[i].second;
        s += b[j];
        q.push(-b[j]);
        if(q.size() > y){
            s += q.top();
            q.pop();
        }
        my[i] = s;
    }
    long long ans1 = -1e18;
    for(int i = 0; i < x + y + z; i++){
        if(i + 1 >= x && x + y + z - i - 1 >= y)
            ans1 = max(ans1, mx[i] + my[i + 1]);
    }
    cout << ans1 + ans << endl;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;

ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

ll C(ll n,ll k)
{
  ll x=1,y=1;
  for(int i=1;i<=k;i++)
  {
    x=x*(n-i+1)%mod;
    y=y*i%mod;
  }
  return x * power(y,mod-2) % mod;
}

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

    ll n,k; cin>>n>>k;
    ll ans;
    FOR(i,1,k){
        ans = C(k-1,i-1) ;
        // cout << ans << endl;
        ans *= C(n-k+1,i) ;
        // cout << ans << endl;
        ans %= mod;
        cout<<ans<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var s = input.ReadLine();
                
        StringBuilder bu = new StringBuilder(s);

        for(int i=0; i<s.Length; i++) {
            int c = bu[i] + (n % 26);
            if (c > 'Z') c -= 26;
            bu[i] = (char)c;
        }

        return bu;
    }
}

Measured memory_bytes: 13140
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<string.h>
#include<map>

using namespace std;

#define ll long long 

int main(){

    int n,k;
    cin>>n>>k;
    int arr[n];
    int dp[k+1];

    for(int i=0;i<n;i++) cin>>arr[i];
    sort(arr,arr+n);
    dp[0] = 0;
    for(int i=1;i<=k;i++) dp[i] = 0;

    for(int i=1;i<=k;i++) {
        for(int j=0;j<n;j++){
            if(arr[j]<=i) {
                if(dp[i-arr[j]]==0) { 
                    dp[i] = 1;
                    break;
                }
            }
            else{
                continue;
            }
        } 
    }
    if(dp[k]) cout<<"First";
    else cout<<"Second";

    return 0;
}

Measured memory_bytes: 3928
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
typedef std::pair<int,int> P;
P wpos[10];
int n;
int dfs(int x, int y, int i){
	if(i == n)return 1;//ÅãÜÅ¶«cê½

	std::vector<P> flog, water;
	for(int j=-1;j<=1;j++){
		flog.push_back(P(x-2,y+j));
		flog.push_back(P(x+2,y+j));
		flog.push_back(P(x+j,y-2));
		flog.push_back(P(x+j,y+2));
	}

	for(int j=-1;j<=1;j++){
		for(int k=-1;k<=1;k++){
			water.push_back(P(wpos[i].first+k, wpos[i].second+j));
		}
	}

	for(int j=0;j<flog.size();j++){
		if(std::find(water.begin(), water.end(), flog[j]) != water.end() && flog[j].first >= 0 && flog[j].second >= 0 && flog[j].first < 10 && flog[j].second < 10){
			if(dfs(flog[j].first, flog[j].second, i+1))
				return 1;
		}
	}

	return 0;//Ç¤ ª¢Äàâ]
}

int main(){
	int posX, posY;
	while(std::cin >> posX >> posY, posX && posY){
		std::cin >> n;
		for(int i=0;i<n;i++){
			int wposX, wposY;
			std::cin >> wposX >> wposY;
			wpos[i] = P(wposX, wposY);
		}
		
		if(dfs(posX, posY, 0))puts("OK");
		else puts("NA");
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<math.h>
#include<cstdio>
#include<bitset>
using namespace std;
int main(){
    int h,w,k,ans;
    int maskR,maskC;
    cin>>h>>w>>k;
    char c[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>c[i][j];
        }
    }
    ans=0;
   for(maskR=0;maskR< (1<<h);maskR++){
    for(maskC=0;maskC< (1<<w);maskC++){
        int black=0;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if( (((maskR>>i)&1)==0) && (((maskC>>j)&1)==0)
               &&(c[i][j] == '#')){ black++;}}
               }
        if (black == k){ans++;}
}}
cout<<ans;
   }



Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)


int N, M;
int visited[1000000];
set<int> inEdge[1000000], outEdge[1000000];

void dfs(int v)
{
    int m = 0;
    if (outEdge[v].size() == 0) {
        visited[v] = 0;
    }
    else {
        for(auto itr = outEdge[v].begin(); itr != outEdge[v].end(); ++itr) {
            int child = (*itr);
            if (visited[child] == -1) dfs(child);
            m = max(m, visited[child]);
        }
        visited[v] = m + 1;
    }
}

int main(int argc, char **argv)
{
    cin >> N >> M;
    int x[M], y[M];
    REP(i, M) cin >> x[i] >> y[i];

    REP(i, M) {
        outEdge[x[i] - 1].insert(y[i] - 1);
        inEdge[y[i] - 1].insert(x[i] - 1);
    }

    vector<int> svs;
    REP(i, N) {
        if (inEdge[i].size() == 0) svs.push_back(i);
    }

    REP(i, N) visited[i] = -1;
    for (auto itr = svs.begin(); itr != svs.end(); ++itr) {
        int startVertex = (*itr);
        dfs(startVertex);
    }
    int m = 0;
    REP(i, N) {
        if (m < visited[i]) m = visited[i];
    }
    cout << m << endl;

    return 0;
}


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

int main() {
	string S;
	string ans = "NO";
	int A = 0;
	cin >> S;
	size_t Ssize = S.length();

	for(int i = 0; i < Ssize; i++){
		if(S.at(i) == 'o')A += 1;
	}
	if(15 - Ssize + A >= 8)ans = "YES";

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const int N=2e5+1;
int n;
ll a[N];
pair<ll,int>b[N];
vector<int>adj[N];

ll dp[N];
ll tmp[N];
const int ts=1<<19;
ll mx[ts];
void upd(int id,int l,int r,int p,int v){
	if(l==r){
		mx[id]=v;
		return;
	}
	int mid=(l+r)/2;
	if(p<=mid) upd(id*2,l,mid,p,v);
	else upd(id*2+1,mid+1,r,p,v);
	mx[id]=max(mx[id*2],mx[id*2+1]);
}
ll qry(int id,int l,int r,int ql,int qr){
	if(l>qr || r<ql) return 0;
	if(ql<=l && r<=qr) return mx[id];
	int mid=(l+r)/2;
	return max(qry(id*2,l,mid,ql,qr),qry(id*2+1,mid+1,r,ql,qr)); 
}
void dfs(int id,int p){
	if(a[id]!=1) dp[id]=qry(1,1,n,1,a[id]-1)+1;
	else dp[id]=1;
	tmp[id]=qry(1,1,n,a[id],a[id]);
	upd(1,1,n,a[id],dp[id]);
	for(auto x:adj[id]){
		if(x==p) continue;
		dfs(x,id);
	}
	upd(1,1,n,a[id],tmp[id]);
}
void dfs2(int id,int p){
	dp[id]=max(dp[id],dp[p]);
	for(auto x:adj[id]){
		if(x==p) continue;
		dfs2(x,id);
	}
}
int main(){
	ios::sync_with_stdio(false);
	ll x,y,z;cin >> x;
	ll ans=0;
	ll cur=100;
	while(cur<x){
		cur=cur*1.01;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 8388
#include <iostream>
using namespace std;
int main() {
    int number;
    int digit = 0;
    int a, b;
    while (cin >> a >> b) {
        digit=0;
        number = a + b;
        while (number != 0) {
            number = number / 10;
            ++digit;
        }
        cout << digit << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<string.h>
#define LEN 1000050


typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head,tail,num,q;

void enqueue(P);
P dequeue(void);


/*main??¢??°*/
int main(){
  int elaps = 0;
  int i, q;
  P proce;

  /*??\???*/
  scanf("%d %d", &num, &q);

  for ( i = 1; i <= num ; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  /*tail,head????????????*/
  head = 1;
  tail = num+1;

  while(head!=tail){

    proce=dequeue();
    if(proce.t > q){
      elaps += q;
      proce.t -= q;
    }

    else{
      elaps += proce.t;
      proce.t = 0;
    }

    if(proce.t == 0){
      printf("%s",proce.name);
      printf(" %d\n",elaps);
      num = num-1;
  }
    else {
      enqueue(proce);
    }
  }

  return 0;
}


/*?????\??????????´? x ?????????????????¢??° enqueue(x)*/
/*Q[tail] ??? x ?????£??\??????tail ??????????¢????????????????*/

void enqueue(P x){
  Q[tail] = x;
  tail++;
}

/*?????\??????????????????????´??????????????????¢??° dequeue( )*/
/*Q[head] ??????????????????head ??????????¢????????????????*/
P dequeue(){
  head++;
  return Q[head-1];
}

Measured memory_bytes: 21080
#include<iostream>
#include<vector>
#include<string>
#include<cmath>


using namespace std;



int main(){
	int a;
	int b;
	int	ans=0;
	cin >> a >> b;
	ans = a + b;

	if (ans >= 10) {
		cout << "error";
	}
	else {
		cout << ans;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FASTIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vi vector<ll>
#define all(a) (a).begin(), (a).end()
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define tr(it, a)   for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define endl  "\n"
const ll MAX=1e5+5;
const ll mod=1e9+7;
vi v(MAX);
vi pref(MAX);
ll dp[405][405];
ll  fun(ll i,ll k)
{
    if(k==i)
        return 0;
        if(dp[i][k]!=-1)
            return dp[i][k];
    ll ans=1e18;
    for(ll j=i;j<k;j++)
    {
        ans=min(ans,fun(i,j)+fun(j+1,k)+pref[k]-pref[i-1]);
        // cout<<j<<"--> "<<ans<<endl;
    }

    return dp[i][k]=ans;
}
int main()
{
    ll t=1;
   // cin>>t;
    while(t--)
    {

   ll n,k;
   cin>>n;
   pref[0]=0;
   rep(i,1,n+1)
   {
       cin>>v[i];
       pref[i]=pref[i-1]+v[i];

   }
   memset(dp,-1,sizeof(dp));
   cout<<fun(1,n);
    }
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();
    
    int x1, y1, w1, h1; cin >> x1 >> y1 >> w1 >> h1;
    int x2, y2, w2, h2; cin >> x2 >> y2 >> w2 >> h2;
    
    auto a = vec<int>(2000, 2000);
    FOR(i, x1, x1 + w1)FOR(j, y1, y1 + h1) {
        a[i][j] ^= 1;
    }
    FOR(i, x2, x2 + w2)FOR(j, y2, y2 + h2) {
        a[i][j] ^= 1;
    }
    int ans = 0;
    FOR(i, 0, 2000)FOR(j, 0, 2000)ans += a[i][j];
    print(ans);

    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, H;
    cin >> N >> H;

    vector<ll> A(N);
    vector<ll> B(N);

    ll amax = 0;

    REP(i, N){
        cin >> A[i] >> B[i];
        amax = max(amax, A[i]);
    }

    sort(B.rbegin(), B.rend());

    ll ans = 0;

    REP(i, N){
        if(B[i] <= amax) break;
        H -= B[i];
        ans++;
        if(H <= 0){
            cout << ans << endl;
            return 0;
        }
    }

    ans += (H-1)/amax + 1;

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m,d;
    cin >> m >> d;
    int ans = 0;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=d;j++){
            int d1 = j%10;
            int d2 = j/10;
            if(d1>=2&&d2>=2&&d1*d2==i){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	int n;cin>>n;
	int ma=0,m;
	rep(i,n-1){
		cout<<"? "<<i+1<<" "<<n<<endl;
		int a;cin>>a;
		if(ma<a){
			ma=a;
			m=i;
		}
	}
	vi out(n);
	out[0]=m;
	rep(i,n)if(i!=m){
		cout<<"? "<<i+1<<" "<<m+1<<endl;
		int a;cin>>a;
		out[a]=i;
	}
	cout<<"!";
	rep(i,n)cout<<" "<<out[i]+1;cout<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n; cin >> n;
    int cnt = 0;
    int flag = 0;
    rep(i,n){
        int a, b;
        cin >> a >> b;
        if(a == b){
            cnt++;
        }else{
            cnt = 0;
        }
        if(cnt >= 3) flag = 1;
    }
    if(flag) yn;
    return 0;
}




Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

ld dp[305][305][305];
ld pp[305][305][305];

ll cnt[4];

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n;
	for (ll i = 0; i < n; i++) {
		ll t; cin >> t; cnt[t]++;
	}
	pp[cnt[1]][cnt[2]][cnt[3]] = 1;

	for (ll k = n; k >= 0; k--) {
		for (ll j = n; j >= 0; j--) {
			for (ll i = n; i >= 0; i--) {
				if (i + j + k > n) continue;
				if (i == 0 && j == 0 && k == 0) continue;
				ld p = (ld)(n - (i + j + k)) / n;
				ld w = p / (1 - p);
				dp[i][j][k] += (w + 1) * pp[i][j][k];
				if (i) {
					dp[i - 1][j][k] += ((ld)i / (i + j + k)) * (dp[i][j][k]);
					pp[i - 1][j][k] += ((ld)i / (i + j + k)) * (pp[i][j][k]);
				}
				
				if (j) {
					dp[i + 1][j - 1][k] += ((ld)j / (i + j + k)) * (dp[i][j][k]);
					pp[i + 1][j - 1][k] += ((ld)j / (i + j + k)) * (pp[i][j][k]);
				}
				if (k) {
					dp[i][j + 1][k - 1] += ((ld)k / (i + j + k)) * (dp[i][j][k]);
					pp[i][j + 1][k - 1] += ((ld)k / (i + j + k)) * (pp[i][j][k]);
				}

			}
		}
	}

	cout << fixed; cout.precision(16);
	cout << dp[0][0][0] << endl;
	return 0;
}

/*
3
0 1
3 0
1 0
*/

Measured memory_bytes: 874752
#include<iostream>
using namespace std;
long long int knapsack(long long int** item,long long int** dp,long long int i,long long int w,long long int n)
{
  if(i==n)
    return 0;
  if(dp[i][w]!=-1)
    return dp[i][w];
  long long int val1,val2=0;
  val1=knapsack(item,dp,i+1,w,n);
  if(w-item[i][0]>=0)
    val2=knapsack(item,dp,i+1,w-item[i][0],n)+item[i][1];
  dp[i][w]=val1>val2?val1:val2;
  return dp[i][w];
}
int main(void)
{
  long long int n,w,i,j;
  cin>>n>>w;
  long long int** item=new long long int*[n];
  long long int** dp=new long long int*[n];
  for(i=0;i<n;i++)
  {
    item[i]=new long long int[2];
    dp[i]=new long long int[w+1];
    cin>>item[i][0]>>item[i][1];
    for(j=0;j<w+1;j++)
    {
      dp[i][j]=-1;
    }
  }
  long long int ans=knapsack(item,dp,0,w,n);
  cout<<ans;
  return 0;
}


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

int main(){
  unsigned int N,M;
  cin >>N>>M;
  long ans=0;
 
 priority_queue<int> q;
 int k;
  for(int i=0;i<N;i++){cin >>k;
    q.push(k);}
  
 
  
 while(M>0){
   int s=q.top();
   q.pop();
   s=s/2;
   
  
 q.push(s);

   
  
                       
    M=M-1;
 
}
  
for(int i=0;i<N;i++){ans+=q.top();
                    q.pop();}
cout <<ans<<endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
//---------------------------------------------------------------------------------------------------

int dp[10003];
int main(void){
    // Your code here!
    int h,n; cin >> h >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];
    memset(dp,INF,sizeof(dp));
    dp[0] = 0;
    rep(i,n) {
        rep(j,h) {
            int nj = min(j+a[i],h);
            dp[nj] = min(dp[nj],dp[j] + b[i]);
        }
    }
    cout << dp[h] << endl;
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;
  cin>>n>>m;
  while(n!=0){

    map<ll,ll> mp;
    FOR(i,0,n){
      ll in;
      cin>>in;
      mp[in]++;
    }
    ll res=0;
    FOR(i,0,m){
      ll in;
      cin>>in;
      mp[in]--;
      res+=in;
    }
    FORm(i,mp){
      if(i->second > 0){
        res += (i->first)*(i->second);
      }
    }

    cout<<res<<endl;
    cin>>n>>m;
  }
}



Measured memory_bytes: 3172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ctype.h>

#define INF 100000000

using namespace std;

int main()
{
    string s;
    cin >> s;
    int ans[(int)'z'] = {0};
    char result;
    for (int i = 0; i < s.length(); i++)
    {
        ans[(int)s[i] - 'a']++;
    }
    for (int i = 0; i <= (int)'z' - 'a'; i++)
    {
        if (ans[i] == 0)
        {
            result = 'a' + i;
            //cout << i << " OK\n";
            cout << result << endl;
            return 0;
        }
    }
    cout << "None\n";
    return 0;
}


Measured memory_bytes: 512
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int K = sc.nextInt();

		long count = 0;

		long val;
		for(long t = K+1; t<=N;t++){
			val = N/t;
			count += val * (t-K);
			long v2 = N - (val*t + K -1);
			if(v2>0) count += v2;
		}

		if(K==0) count -= N;
		System.out.println(count);
	}


}

Measured memory_bytes: 23764
use proconio::input;

fn main() {
  input! {
    n: usize,
    a: [usize; n]
  }

  let mut bits = 0;
  let mut vec_a = vec![0;n];

  for i in 0..n {
    vec_a[i] = a[i];
    bits ^= a[i];
  }

  for b in vec_a {
    print!("{} ", b^bits);
  }
  println!();

  //println!("Hello, AtCoder!");
}


Measured memory_bytes: 7952
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long N = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();
		if(A+B == 0) {
			pl(0);
			System.exit(0);
		}
		long itr = N/(A+B);
		long ans = 0L;
		ans += A * itr;
		if(N%(A+B) >= A) {
			ans += A;
		}
		else {
			ans += (N%(A+B));
		}
		pl(ans);
	}
	public static void pl(Object o) {
		System.out.println(o);
	}

}

Measured memory_bytes: 23636
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line = null;

        int num = Integer.parseInt(sc.nextLine());

        String[] a = sc.nextLine().split(" ");
        int[] array = new int[num];

        for(int i=0; i<num; i++) {
            array[i] = Integer.parseInt(a[i]);
        }

        printResult(array);

        for (int i = 1; i < num; i++) {
            int v = array[i];
            int j = i - 1;
            while ( j>=0 && array[j]>v ) {
                array[j+1] = array[j];
                j--;
            }
            array[j+1] = v;

            printResult(array);
        }
    }

    public static void printResult(int[] array) {
        StringBuilder sb = new StringBuilder();
        for(int i=0; i<array.length; i++) {
            if (i!=0) { sb.append(" "); }
            sb.append(array[i]);
        }

        System.out.println(sb.toString());
    }
}

/*
1 insertionSort(A, N) // N個の要素を含む0-オリジンの配列A
2   for i が 1 から N-1 まで
3     v = A[i]
4     j = i - 1
5     while j >= 0 かつ A[j] > v
6       A[j+1] = A[j]
7       j--
8     A[j+1] = v
*/


Measured memory_bytes: 28576
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-21 16:00:36
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

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

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

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

int64 dp[2020][2020];

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

  int n; cin >> n;
  vector<pair<int64, int>> v;

  for (int i = 0; i < n; ++i) {
    int64 a; cin >> a;
    v.emplace_back(a, i);
  }

  sort(rall(v));

  for (int i = 0; i < n; ++i) {
    for (int j = 0; i + j < n; ++j) {
      // right
      dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + v[i + j].first * int64{(n - 1 - v[i + j].second - j)});
      // left
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + v[i + j].first * int64{(v[i + j].second - i)});
    }
  }

  int64 ans = 0;

  for (int i = 0; i <= n; ++i) {
    ans = max(ans, dp[i][n - i]);
  }

  cout << ans << endl;

  return 0;
}

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

void  cal(int t)
{
	int answer[50];
	for (int i = 0;i < t;++i) {
		int n, k, a[1000000], b[1000000], sum = 0;
		cin >> n >> k;
		for (int j = 0;j < n;++j) {
			cin >> a[j];
		}
		for (int j = 0;j < n - 1;++j) {
			b[j] = a[j + 1] - a[j];
		}
		sort(b, b + n - 1);
		for (int j = n - 2;n - k - 1 < j;--j) {
			sum += b[j];
		}
		answer[i] = a[n - 1] - a[0] - sum;
	}
	for (int i = 0;i < t;++i) {
		cout << answer[i] << endl;
	}
}

int main()
{
	int t;
	cin >> t;
	cal(t);
}

Measured memory_bytes: 7428
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef tuple<int, int, int> ituple;

// const int INF = INT_MAX;
// const ll INF = LLONG_MAX;
// const int MOD = ((int)1e9 + 7);
// const ld EPS = (1e-10);
#define PI acosl(-1)
#define MAX_N (100000 + 2)

void exec(){
  int n, a, b;
  int t, num_1 = 0, num_2 = 0, num_3 = 0;
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++){
    scanf("%d", &t);
    if (t <= a){
      num_1++;
    }
    else if (a < t && t <= b){
      num_2++;
    }
    else{
      num_3++;
    }
  }

  cout << min(num_1, min(num_2, num_3)) << endl;

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

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


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

using namespace std;

int main(){
    int N,K,Q;
    int P[100010] = {0};
    int A;
    cin >> N >> K >> Q;

    for(int i=0;i<Q;i++)
    {
        cin >> A;
        P[A-1] += 1;
    }

    for(int i=0;i<N;i++)
    {
        if(P[i]+K-Q>0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
        
    }

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

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

ll lcm(ll x, ll y) {
    return x /gcd(x,y) * y;
}

int main(void)
{
    IOS
    int n; cin >> n;
    vector<ll> v(n);
    REP(i,n) cin >> v[i];
    ll ans = 1;
    const ll pten = 1e9;
    REP(i,n) {
        ans = lcm(ans,v[i]);
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

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

#define F first
#define S second

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;	cin >> n;
	for (ll i = 1; i <= 3500; i++)
		for (ll j = 1; j <= 3500; j++){
			ll a = i+j;
			ll b = i*j;
			if (4*b <= a*n) continue;
	
			a = a*n-b*4;;
			a = -a;
			b *= n;
			if (b % a == 0){
				cout << i << " " << j << " " << b/a << "\n";
				return 0;
			}
		}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
typedef long long int lli;
static const int MOD = 10000007;
static const int MAX = 100005;


int N;
string s;


int gcd(int a, int b) {
  if ( b > a ) swap(a, b);
  int r = 1;
  while (r > 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}

int main(){
  cin >> s;
  if (s == "Sunny") {
    s = "Cloudy";
  } else if (s ==  "Cloudy") {
    s = "Rainy";
  } else {
    s = "Sunny";
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
    ll X;
    ll a = 100;

    cin >> X;

    ll ans = 0;
    while (true) {
        ans++;
        a = ll(a * 1.01);
        if (ll(a) >= X) {
            break;
        }
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3596