akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    string s;cin>>s;
    rrep(i,s.size()-2,1){
        string t=s.substr(0,i);
        string u=s.substr(0,i/2);
        u+=u;
        if(t==u){
            cout<<i<<endl;
          return 0;
        }
    }
    
}


Measured memory_bytes: 256
#include <stdio.h>
struct point {int x;int y;};
struct point array[200];

int main(){
  int n,a,b,i,j,k,count;
  int xmax,xmin,ymax,ymin;
  while(1){
    scanf("%d",&n);
    xmax=xmin=ymax=ymin=0;
    if(n==0)
      break;
    if(n==1){
      printf("1 1\n");
    }else{
    
     array[0].x = 0;
     array[0].y = 0;
     for(i=1;i<n;i++){
	scanf("%d %d",&a,&b);
	switch(b){
	  case 0:
	    array[i].x = array[a].x-1;
	    array[i].y = array[a].y;
	    break;
	  case 1:
	    array[i].x = array[a].x;
   	    array[i].y = array[a].y -1;
	    break;
	  case 2:
	    array[i].x = array[a].x+1;
	    array[i].y = array[a].y;
	    break;
	  case 3:
	    array[i].x = array[a].x;
	    array[i].y = array[a].y+1;
	    break;  
	}
     }
     for(i=0;i<n;i++){
       if(array[i].x>xmax)
	 xmax=array[i].x;
       if(array[i].x<xmin)
	 xmin=array[i].x;
       if(array[i].y>ymax)
	 ymax=array[i].y;
       if(array[i].y<ymin)
	 ymin=array[i].y;
     }
     
     printf("%d %d\n",xmax-xmin+1,ymax-ymin+1);
     
    }
  }
  
  return 0;
}

Measured memory_bytes: 0
N, K = map(int, input().split())
ans = N
if N < K:
    if N != 0:
        q, mod = divmod(K, N)
        ans = min(N, K - N)
    elif N == 0:
        ans = 0
elif N == K:
    ans = 0
else:
    q, mod = divmod(N, K)
    ans = min(mod, abs(K - mod))
print(ans)

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

using namespace std;

int main() {
    long long n;
    cin >> n;
    vector<long long> a(n);
    for(auto &x: a) {
        cin >> x;
    }
    sort(a.begin(), a.end());
    long long ans = a[n-1], j = n - 1;
    for(long long i = 2; i < n; ++i) {
        if(!(i & 1)) {
            --j;
        }
        ans += a[j];
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int x_rest = x;
    int y_rest = y;
    int min_s = min(x, y);
    int ans = 0;
    if ( a + b >= c * 2 ) {
        ans += c * 2 * min_s;
        x_rest -= min_s;
        y_rest -= min_s;
    }
    bool flg = false;
    if ( x_rest > y_rest ) {
        flg = true;
    }
    if ( flg ) {
        if ( x_rest > 0 ) {
            if ( a * x_rest > c * x_rest * 2 ) {
                y_rest -= x_rest;
                ans += c * x_rest * 2;
            }
            else {
                ans += a * x_rest;
            }
        }
        if ( y_rest > 0 ) {
            ans += min(b * y_rest, c * y_rest * 2 );
        }
    }
    else {
        if ( y_rest > 0 ) {
            if ( b * y_rest > c * y_rest * 2 ) {
                x_rest -= y_rest;
                ans += c * y_rest * 2;
            }
            else {
                ans += b * y_rest;
            }
        }
        if ( x_rest > 0 ) {
            ans += min(a * x_rest, c * x_rest * 2 );
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>

using namespace std;

static const int MAX = 1000;
static const int MAXS = 10005;

int s = MAXS;
int C[MAXS] = {0};
int minCostSort(int A[], int n)
{
	int cost = 0;
	int i,B[MAX];
	bool V[MAX];

	for (i = 0; i < n; i++)
	{
		V[i] = false;
		B[i] = A[i];
	}
	sort(&B[0],&B[n]);

	for (i = 0; i < n; i++)
	{
		C[B[i]] = i;
	}

	for (i = 0; i < n; i++)
	{
		int a = i;
		int S = 0;
		int mini = MAXS;
		int num = 0;
		while (1)
		{
			V[a] = true;
			num++;
			mini = min(mini, A[a]);
			S = S + A[a];
			a = C[A[a]];
			if (V[a]==true)
				break;				
		}

		cost += min(S+mini*(num-2),S+mini+(num+1)*s);
	}

	return cost;
}

int main()
{
	int cost;
	int n,i, A[MAX];
	scanf("%d",&n);

	for (i = 0; i < n; i++)
	{
		scanf("%d", &A[i]);
		s = min(A[i],s);
	}

	cost = minCostSort(A,n);
	printf("%d\n", cost);

	return 0;
}


Measured memory_bytes: 2804
import sys
H,W,d=map(int,input().split())
if d%2==1:
  l=W//4+1
  reg=list("RYGB"*l)
  for j in range(H):
    a=reg.pop(0)
    reg+=a
    print("".join(map(str,reg))[:W])
else:
  for i in range(H):
      c="RYGB"
      ans = []
      for j in range(W):
          b1 = ((i-j) // d) % 2
          b2 = ((i+j) // d) % 2
          ans+= c[b1 * 2 + b2]
      print("".join(ans))

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

int main(){
    int N,K;cin>>N>>K;
    vector<int> a(200001);
    for(int i=0,p;i<N;i++){
        cin>>p;
        a.at(p)++;
    }
    sort(a.begin(),a.end(),greater<int>());
    ll count=0;
    for(int i=0;i<K;i++)count+=a.at(i);
    cout<<N-count<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define dbg(x) cerr<<#x": "<<(x)<<endl
#define dbg_p(x) cerr<<#x": "<<(x).first<<' '<<(x).second<<endl
#define dbg_v(x, n) {cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<(x)[_]<<' ';cerr<<endl;}
#define all(v) v.begin(), v.end()
#define fi first
#define se second

template<typename T1, typename T2>
ostream& operator <<(ostream &out, const pair<T1, T2> &item) {
	out << '(' << item.first << ", " << item.second << ')';
	return out;
}

template <typename T>
ostream& operator <<(ostream &out, const vector<T>& v) {
	for(const auto &item : v) out << item << ' ';
	return out;
}

const int P = 3010;

struct Poly {
	int p, d;
	int c[P];

	Poly(int p) : p(p) {}

	Poly& operator *=(int a) {
		for(int i = 0; i < d; ++i) c[i] = (c[i] * a) % p;
		return *this;
	}

	Poly& polyMul(int a) {
		// multiply by x - a
		for(int i = d; i >= 0; --i) {
			c[i] = -a * c[i];
			if(i) c[i] += c[i - 1];
			c[i] %= p;
			if(c[i] < 0) c[i] += p;
		}

		++d;

		return *this;
	}

	Poly& polyDiv(int a) {
		// divide by x - a
		int last = 0;
		for(int i = d - 1; i >= 0; --i) {
			int newval = (a * c[i + 1] + last) % p;
			last = c[i];
			c[i] = newval;
		}

		--d;
		
		return *this;
	}

	Poly& operator +=(const Poly &poly) {
		for(int i = 0; i < P; ++i) c[i] = (c[i] + poly.c[i]) % p;
		return *this;
	}
};

int a[P], fact[P];

int pw(int base, int exp, int mod) {
	int res;
	for(res = 1; exp; exp >>= 1) {
		if(exp & 1) res = (1LL * res * base) % mod;
		base = (1LL * base * base) % mod;
	}
	return res;
}

int inv(int x, int mod) {
	return pw(x, mod - 2, mod);
}

int main()
{
	ios_base::sync_with_stdio(false);
	
	int p;

	cin >> p;
	for(int i = 0; i < p; ++i) cin >> a[i];

	fact[0] = 1;
	for(int i = 1; i < p; ++i) fact[i] = (fact[i - 1] * i) % p;

	Poly poly(p);
	poly.d = 1;
	poly.c[0] = 1;

	for(int i = 0; i < p; ++i) poly.polyMul(i);

	Poly res(p);
	res.d = poly.d;

	for(int i = 0; i < p; ++i) {
		if(!a[i]) continue;

		Poly tmp(p);
		tmp.d = poly.d;
		memcpy(tmp.c, poly.c, sizeof poly.c);

		tmp.polyDiv(i);

		int coef = fact[i];
		int coef2 = fact[p - 1 - i];
		//dbg(coef);
		//dbg(coef2);
		coef = (coef * coef2) % p;
		if(coef && (p - 1 - i) % 2 == 1) coef = p - coef;
		//dbg(i);
		//dbg(coef);

		tmp *= inv(coef, p);
		//dbg_v(tmp.c, 10);

		//dbg_v(res.c, 10);
		for(int i = 0; i < P; ++i) res.c[i] = (res.c[i] + tmp.c[i]) % p;
		//dbg_v(res.c, 10);
	}

	//dbg_v(res.c, res.d);

	for(int i = P - 1; i >= p; --i) res.c[i - p] = (res.c[i - p] + res.c[i]) % p;

	for(int i = 0; i < p; ++i) cout << res.c[i] << ' ';
	cout << '\n';

	return 0;
}


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

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vec vector<int>
#define vecll vector<ll>

using namespace std;
///////////////////////////////////////////////////////////



int main() {
    int n, k, s;
    cin >> n >> k >> s;

    if (s < 1000000000) {
        rep(i,n) {
            if (i < k)
                cout << s << " ";
            else
                cout << s+1 << " ";
        }
    } else {
        rep(i,n) {
            if (i < k)
                cout << s << " ";
            else
                cout << 1 << " ";
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    long H,W,minimum,i,k,count;
    
    
    
    cin>>H>>W;
    
    while(H!=0 || W!=0)
    {
        
        
        for(i=0;i<H;i++)
        {
            
            for(k=0;k<W;k++)
            {
                if((i+k)%2==0)
                {
                    cout<<"#";
                }
                else
                {
                    cout<<".";
                }
                
            }
            
            cout<<endl;
        }
        
        
        
        
        
        cin>>H>>W;
        cout<<endl;
        
    }
    
    

    

    
    
    
    
    return 0;
    
}



Measured memory_bytes: 3096
a, b, c = map(int, input().split())
k = int(input())
for i in range(k):
  if a < b < c:
    break
  elif a >= c  or b >= c:
    c *= 2
  else:
    b *= 2
if a < b < c:
  ans = 'Yes'
else:
  ans = 'No'
print(ans)

Measured memory_bytes: 9156
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

import collections

n,k = iim()
c = collections.Counter(iil())
#print(c)
l = sorted(c.values(),reverse=True)
#print(l)
print(sum(l[k:]))

Measured memory_bytes: 32540
#include <iostream>
#include <string>

int main()
{
  std::string S;
  std::cin >> S;
  int n = std::stoi(S), m=0;
  for(int i = 0;i < S.size(); ++i){
    m += (S[i] - '0');
  }
  ////↓でもok
  //for(const auto& v : S){
  //  m += (v - '0');
  //}
  std::cout << ((n%m==0)?"Yes":"No") << std::endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll K; cin >> K;
    for(int a = 1; a <= K; a++){
        for(int b = 1; b <= K; b++){
            for(int c = 1; c <= K; c++){
                res += gcd(gcd(a,b),c);
            }
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 3692
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		String s = sc.next();
		String t = sc.next();
		int zure = -1;
		for (int i = 0; i < n; i++) {
			boolean bre = false;
			for (int j = 0; j + i < n; j++) {
				if (s.charAt(j + i) != t.charAt(j)) {
					bre = true;
					break;
				}
			}
			if (!bre) {
				zure = i;
				break;
			}
		}
		if (zure == -1) {
			zure = n;
		}
		System.out.println(n + zure);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 21076
n = int(input())
_ = [list(map(int, input().split())) for _ in range(n)]
_.insert(0, [0, 0, 0])

dt = [_[i + 1][0] - _[i][0] for i in range(n)]
dx = [_[i + 1][1] - _[i][1] for i in range(n)]
dy = [_[i + 1][2] - _[i][2] for i in range(n)]

ans = "Yes"

for i in range(n):
    man_d = abs(dx[i]) + abs(dy[i])
    if not (dt[i] >= man_d and (dt [i]- man_d) % 2 == 0):
        ans = "No"

print(ans)

Measured memory_bytes: 68696
#include<cstdio>
#include<cstring>
#define mod 100000
using namespace std;

int dp[50][3001];
int main()
{
	int n,m,s;
	while(scanf("%d%d%d",&n,&m,&s),n){
		n*=n;
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		for(int i=1;i<=m;i++){
			for(int j=n;j>0;j--){
				for(int l=i;l<=s;l++){
					dp[j][l]=(dp[j][l]+dp[j-1][l-i])%mod;
				}
			}
		}
		printf("%d\n",dp[n][s]);
	}
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  
  int n =N%10;
  
  if(n==3){
    cout<<"bon"<<endl;
  }
  else if(n==0 || n==1 || n==6 || n==8){
    cout<<"pon"<<endl;
  }
  else{
    cout<<"hon"<<endl;
  }
  
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;

int main() {
  int N, Y; cin >> N >> Y;
  int x = -1,y = -1,z = -1;
  for ( int i = 0; i <= N; i++ ) {
    for ( int j = 0; j <= N; j++ ) {
      int rem = N - (i+j);
      int tmp = Y;
      tmp -= 1000*i+5000*j;
      if ( tmp >= 0 && tmp == rem*10000 ) {
	x = rem;
	y = j;
	z = i;
	break;
      }
    }
  }
  /* 
  for ( int i = 0; i <= N; i++ ) {
    for ( int j = 0; j <= N; j++ ) {
      int rem = N - (i+j);
      int tmp = Y;
      tmp -= 5000*i+10000*j;
      if (tmp >= 0 && tmp == rem*1000 ) {
	x = j;
	y = i;
	z = rem;
	break;
      }
    }
  }

  for ( int i = 0; i <= N; i++ ) {
    for ( int j = 0; j <= N; j++ ) {
      int rem = N - (i+j);
      int tmp = Y;
      tmp -= 10000*i+1000*j;
      if ( tmp >= 0 && tmp == rem*5000 ) {
	x = i;
	y = rem;
	z = j;
	break;
      }
    }
  } 
  */
  if( x == -1 || y == -1 || z == -1 ) cout << -1 << " " << -1 << " "
					   <<-1 << endl;
  else cout << x << " " << y << " " << z << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
double eps=1e-8;
struct S{
  P s,t;
  S(P s=P(),P t=P()): s(s),t(t) {}
};
struct C{
  P p;
  double r;
  C(P p=P(),double r=0):p(p),r(r){}
};
 
 
bool eq(double a,double b){
  return (-eps<a-b&&a-b<eps);
}
 
double Sqrt(double a){
  if(a<0)return 0;
  return sqrt(a);
}

bool isIntersect(C a,C b){
  double k=abs(a.p-b.p);
  return (a.r+b.r>=k-eps&& abs(a.r-b.r)<=k+eps);
}

P crossPoint(C a,C b){
  P base=b.p-a.p;
  double k=(-b.r*b.r+a.r*a.r+norm(base));
  double w=k/(2.0*abs(base)),h=Sqrt(a.r*a.r-w*w);
  base/=abs(base);
  return a.p+base*P(w,h);
}


bool isIntersect(vector<C> &vec){
  vector<P> t;
  for(int i=0;i<(int)vec.size();i++){
    t.push_back(vec[i].p);
    for(int j=0;j<i;j++){
      if(isIntersect(vec[i],vec[j])){
        t.push_back(crossPoint(vec[i],vec[j]));
        t.push_back(crossPoint(vec[j],vec[i]));
      }
    }
  }
  for(int i=0;i<(int)t.size();i++){
    bool flg=true;
    for(int j=0;j<(int)vec.size();j++)
      if(vec[j].r*vec[j].r+eps<norm(vec[j].p-t[i]))flg=false;
    if(flg)return true;
  }
  return false;
}

int n;
vector<P> t;
vector<double> u;

double check(double M){
  vector<C> nt(n);
  for(int i=0;i<n;i++){
    nt[i].p=t[i];
    nt[i].r=Sqrt(u[i]*u[i]-M*M);
  }
  return isIntersect(nt);
}

double solve(){
  double L=0,R=1e8,M;
  for(int i=0;i<n;i++)R=min(R,u[i]);
  
  for(int i=0;i<100;i++){
    M=(L+R)/2;
    if(check(M))L=M;
    else R=M;
  }
  
  return L;
}

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    t.clear();t.resize(n);
    u.clear();u.resize(n);
    for(int i=0;i<n;i++){
      double x,y;
      cin>>x>>y>>u[i];
      t[i]=P(x,y);
    }
    printf("%.10f\n",solve());
  }
}

Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const int mod=1e9+7;
const int inf=1e9+7;
   
const int maxn=105;

int num1[maxn];

int num2[maxn];
  
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    int n;
    
    while(cin>>n)
    {
    	for(int i=0;i<n;i++)
    	{
    		cin>>num1[i];
    		num2[i]=num1[i];
		}
		
		sort(num2,num2+n);
		
		int cnt=0;
		
		for(int i=0;i<n;i++)
		{
			if(num1[i]!=num2[i])
				cnt++;
		}
		
		if(cnt==0||cnt==2)
		{
			cout<<"YES"<<endl;
			continue;
		}
		
		cout<<"NO"<<endl;
	}
    
      
      
    return 0;
}

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

int main() {
    int n; cin >> n;
    vector<ll> a(n);

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

    int ans = 0;
    rep(i, n) {
        while (a.at(i) % 2 != 1) {
            ans++;
            a.at(i) /= 2;
        }
    }

    cout << ans << endl;
}

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

int main(void) {
	string s;
	cin >> s;
	int num = 0;
	if (s[0] == '1') num++;
	if (s[1] == '1') num++;
	if (s[2] == '1') num++;
	cout << num << endl;
}

Measured memory_bytes: 256
#include<iostream>
    #include<vector>
#include<string>
    using namespace std;
     
    int main() {
    	int N;
        std::string S, T,Sub;
    	cin >> N;
    	cin >> S >> T;
        Sub="";

      for (int i = 0; i < N; ++i){
        Sub=Sub + S[i]+T[i];
     }
	
	cout << Sub << endl;

}

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

using namespace std;

#define int_64 long long

const int N = 2e5 + 10;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
  int n;
  cin >> n;
  map<string, int> m;
  while (n--) {
    string s;
    cin >> s;
    ++m[s];
  }
  cout << "AC x " << m["AC"] << '\n';
  cout << "WA x " << m["WA"] << '\n';
  cout << "TLE x " << m["TLE"] << '\n';
  cout << "RE x " << m["RE"];
  return 0;
}

Measured memory_bytes: 3664
#include<stdio.h>
int main(void)
{
    int n,i,b,j=0;
    int k[4][13]={{0}};
    char a,t='0';
    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%c",&t);
        scanf("%c %d",&a,&j);
        if(a=='S')b=0;
        else if(a=='H')b=1;
        else if(a=='C')b=2;
        else if(a=='D')b=3;
        k[b][j]=1;
    }
    for(i=0;i<4;i++){
        for(j=1;j<=13;j++){
            if((k[i][j])!=1){
                if(i==0)a='S';
                else if(i==1)a='H';
                else if(i==2)a='C';
                else a='D';
                printf("%c %d\n",a,j);
            }
        }
    }
    return 0;
}



Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        for(;;) {
        	int x=in.nextInt();
        	int y=in.nextInt();
        	if(x==y&&x==0) break;
        	if(x>y) {
        		int k=y;
        		y=x;
        		x=k;
        	}
        	System.out.println(x+" "+y);
        }
    }
}


Measured memory_bytes: 36768
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
      	
          int[] food;
      food = new int[M];
      
        for(int k=0;k<M;k++) {
      food[k] = 0;
        }
        
    	for(int i=0;i<N;i++){
        int K = sc.nextInt();
        
        for(int j=0;j<K;j++){
          int F = sc.nextInt();
          
          food[F-1]++;
          }
		}
		int count = 0;
		for(int w=0;w<M;w++){
    	if(food[w] == N) {
    		count++;
    	}   	
    	}
		System.out.println(count);
  	}
}

Measured memory_bytes: 23380
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
using namespace std;
using ll = long long;

int main(){
    int N,K;
    cin >>N>>K;
    vector<vector<int>> graph(N,vector<int>());
    vector<ll> muls(N,-1);
    queue<pair<int,int>> q;
    
    for(int i = 0;i < N-1;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    
    muls[0] = K;
    for(int i  = 0;i < graph[0].size();i++){
        muls[graph[0][i]] = K-1-i;
        q.push(pair<int,int>(graph[0][i], 0));
    }
    while(q.size() > 0){
        pair<int,int> p = q.front();q.pop();
        int point = p.first;int parent = p.second;
        int cnt = 0;
        for(int i = 0;i < graph[point].size();i++){
            if(graph[point][i] == parent)continue;
            muls[graph[point][i]] = K-2-cnt;
            q.push(pair<int,int>(graph[point][i],point));
            cnt++;
        }
    }
    int res = 1;
    for(int i = 0;i < N;i++){
        res = (res * muls[i]) % (int)(1e9+7);
    }
    cout << res << endl;

}

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

int main() {
	int n;
	cin >> n;
	int a[100000];
  int z[100000];
  bool sign[100000];
  int count = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
    z[i] = abs(a[i]);
    if(a[i] >= 0){
      sign[i] = 0;
    }else{
      sign[i] = 1;
      count++;
    }
	}

  if(count%2 == 0){
    ll sum=0;
    for(int i=0;i<n;i++){
      sum+=z[i];
    }
    cout<<sum;
  }else{
    ll sum=0;
    int min=INT_MAX;
    for(int i=0;i<n;i++){
      sum+=z[i];
      if(min>z[i]){
        min=z[i];
      }
    }
    sum -= min*2;
    cout << sum;
  }
	return 0;
}


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

int main(void)
{
	unsigned long int N, K;
	cin >> N >> K;

	unsigned long int min_num = N % K;

	if (min_num > -1 * (min_num - K)) min_num = -1 * (min_num - K);
	cout << min_num << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
  string c;
  cin >> c;
  string target_list = "aiueo";
  if(target_list.find(c) != string::npos){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }

  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<ll> a(N+1), sum(N+1);
    a[0] = 0;
    sum[0] = 0;
    for (int i = 1; i <= N; i++) {
        scanf("%lld", &a[i]);
        sum[i] = sum[i-1]+a[i];
    }
    ll ans = abs(sum[N] - sum[1] * 2);
    for (int i = 1; i <= N-1; i++) {
        ans = min(ans, abs(sum[N] - 2 * sum[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
# 問題
# https://atcoder.jp/contests/abc083/tasks/arc088_a

# 方針 greedy
# Xから初めて、2倍2倍していってYに達する手前で止めればよい
# この倍々操作の回数が数列の長さだが、これは簡単に数値計算で求まる
# つまり log_2(X/Y) を整数に丸め込んだやつ
# log2の丸め込み誤差に注意


from math import log2
X, Y = list(map(int, input().split()))

# print(int(log2(Y / X)+1)) #いや、あってるが…
print(len(bin(Y // X))-2)


Measured memory_bytes: 2940
import java.io.{PrintWriter, _}
import java.util._


object Main {
  def main(args: Array[String]): Unit = {
    val inputStream = System.in
    val outputStream = System.out
    val in = new InputReader(inputStream)
    val out = new PrintWriter(outputStream)
    val solver = new Task
    solver.solve(1, in, out)
    out.close()
  }

  class Task {
    def solve(testNumber: Int, in: InputReader, out: PrintWriter): Unit = {
      val a = in.nextInt
      val b = in.nextInt
      val c = in.nextInt
      out.println(if (a <= c && c <= b) "Yes" else "No")
    }
  }

  class InputReader(val stream: InputStream) extends AutoCloseable {
    //reader = new BufferedReader(new FileReader(stream), 32768);
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer = new StringTokenizer("")


    def next: String = {
      while ( {
        tokenizer == null || !tokenizer.hasMoreTokens
      }) try
        tokenizer = new StringTokenizer(reader.readLine)
      catch {
        case e: IOException =>
          throw new RuntimeException(e)
      }
      tokenizer.nextToken
    }

    def nextLine: String = {
      try
        return reader.readLine
      catch {
        case e: IOException =>
          e.printStackTrace()
      }
      ""
    }

    def nextInt: Int = next.toInt

    def nextLong: Long = next.toLong

    override def close(): Unit = {
    }
  }

}


Measured memory_bytes: 25516
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)

/*
bool isprime(int x){
	for(int i = 2;i*i<=x;i++){
		if(x%i == 0)return false;
	}
	return x!=1;
}
int gcd(int a, int b) 
{ 
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    if (a == b) 
        return a; 
   
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 
*/


//3111111111111111111111111111111






	void solve(){
		
		ini(n);
		ini(n1);
		ini(k);
		int ma= 0;
		if(k<1000){
			FOR(i,1,k+1){
				int tmp = (n*i)/n1-n*(i/n1);
				ma = max(ma,tmp);
			}
			return out(ma);
		}
		else{
			if(k<=n1-1)out((n*k)/n1-n*(k/n1));
			else out((n*(n1-1))/n1-n*((n1-1)/n1));
			return;
		}
	}









































int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


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

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, k, cnt[101];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> k;
	for(int i = 0; i < k; i++){
		int d;
		cin >> d;
		for(int j = 0; j < d; j++){
			int a;
			cin >> a;
			cnt[a]++;
		}
	}
	int sum = 0;
	for(int i = 1; i <= n; i++) sum += (cnt[i] == 0);
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll md = 1000000007;
vector<ll> fact(1e6 + 7), invfact(1e6 + 7);

ll fn(ll a, ll r, ll n, ll mod = md) {
    ll res = 1, x = r%mod;
    ll ans = 0;
    while(n) {
        if(n&1) ans = (x*ans + res)%mod;
        res = ((res*x)%mod + res%mod)%mod;
        x = (x*x)%mod;
        n = n/2;
    }
    ans = (ans*a)%mod;
    return ans;
}

ll nCr(ll n, ll r) {
    if(r == 0) return 1;
    ll num = fact[n];
    ll den = (invfact[r] % md *invfact[n-r] % md)%md;
    return (num*den)%md;
}

ll mul(ll a, ll b, ll mod = md) {
    ll res = (a%mod * b%mod)%mod;
    return res;
}

ll mulm(ll a, ll b, ll mod = md) {
    ll r = 0;
    a %= mod;
    while (b) {
        if (b & 1) r = (r+a)%mod;
        a = (a+a)%mod;
        b = b/2;
    }
    r %= mod;
    return r;
}

ll power(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = n/2;
        x = (x*x)%mod;
    }
    return res;
}

ll power2(ll x, ll n) {
    ll res = 1;
    while (n)  
    {  
        if (n & 1)  res = (res*x);  
        n = n/2; 
        x = (x*x);  
    }  
    return res;
}

bool is_prime(ll x) {
    if(x == 1 || x == 0) return false;
    for(int i=2; i*i <= x; i++) {
        if(x%i == 0) return false;
    }
    return true;
}

ll compgcd(ll n, vector<ll> const &primes) { 
    ll res = n; 
    for (ll i=0; primes[i]*primes[i] <= n; i++) {
        if (n % primes[i]== 0) { 
            res -= (res / primes[i]); 
            while (n%primes[i]== 0) {
               n/=primes[i]; 
            }
        } 
    } 
    if (n > 1) {
       res -= (res / n); 
    }
    return res; 
} 

void sieve(vector<bool> &prime, vector<ll> &primes, ll lim) {
    for(int i = 2; i*i <= lim; i++) {
        if(prime[i]) {
            for(int j = 2; j*i <= lim; j++) {
                prime[j*i] = false;
            }
        }
    }
    for(int i = 2; i <= lim; i++) {
        if(prime[i]) {
            primes.push_back(i);
        }
    }
}

void sieveGCD(ll lim, vector<ll> &tab, vector<ll> const &primes) {
    for(int  i = 1; i <= lim; i++) {
        tab[i] = i;
    }
    for(int i = 0; i<primes.size() && primes[i] <= lim; i++) {
        tab[primes[i]] = primes[i]-1;
        for(int j = 2; primes[i]*j <= lim; j++) {
            tab[primes[i]*j] = (tab[primes[i]*j]/primes[i])*(primes[i]-1);
        }
    }
}

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, count = 0;
    cin >> n;
    ll up = floor(log10(n)) + 1;
    for(int l = 1; l <= up; l++) {
        if (l&1) {
            count += (l == up ? n + (n != power2(10, l) ? 1 : 0): power2(10, l)) - power2(10, l-1);
        }
    }
    cout << count << '\n';
    return 0; 
}

Measured memory_bytes: 16000
from collections import Counter
import sys

N, K = map(int, input().split())
A = list(map(int, input().split()))

d = Counter(A)

d_keys = d.keys()
d_values = d.values()

# print(d_keys, d_values)

if len(set(d_keys)) <= K:
    print(0)
    sys.exit()

d_values = sorted(d_values)
ans = sum(d_values[: len(d_values) - K])

print(ans)


Measured memory_bytes: 39856
#include<iostream>
using namespace std;
int main(){
  string S;
  cin >> S;
  bool flag=true;
  for(int i=1; i<=S.length(); i++){
    if(i%2==1){
      if (S[i-1]=='L'){
        flag = false;
     	break;
      }
    }else{
      if (S[i-1]=='R'){
        flag = false;
     	break;
      }
    }
  }
  if(flag == true) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
/*
░░░░░░░░░░░░░░░░░░░░░░░░░
░░█▀▀▄░░░░░░░░░░░▄▀▀█░░░░
░░█░░░▀▄░▄▄▄▄▄░▄▀░░░█░░░░
░░░▀▄░░░▀░░░░░▀░░░▄▀░░░░░
░░░░░▌░▄▄░░░▄▄░▐▀▀░░░░░░░
░░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█░
░░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█░
░▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█░
░█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀░
░░▀▄░░▀░░▀▀▀░░▀░░░▄█▀░░░░
░░░░█░░░░░░░░░░░▄▀▄░▀▄░░░
░░░░█░░░░░░░░░▄▀█░░█░░█░░
░░░░█░░░░░░░░░░░█▄█░░▄▀░░
░░░░█░░░░░░░░░░░████▀░░░░
░░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░
*/
 
// I want to be the very best, like no one ever was, I will battle everyday to claim my rightful place
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
// I am questioning life and universe and 
// everything else after looking at this

void solve(){
    ll N; cin>>N;

    ll ans = 0;

    FOR(i,1,N){
        ll x = i;
        ll c = 0;

        while(x){
            c++;
            x = x/10;
        }

        if(c&1) ans++;
    }

    cout<<ans<<endl;
} 
 
signed main(){
 
   FastRead;    
 
 
    ll t;
    t = 1; 
    //cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
hoge = [list(map(int, input().split())) for _ in range(N)]
hoge = sorted(hoge)

def foo():
  total = 0
  n = 0
  for e in hoge:
    for i in range(e[1]):
      total += e[0]
      n += 1
      if n >= M:
        return total
  return 0

print(foo())

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

main() {
  int N, L; cin >> N >> L;
  vector<string> S(N); for (int i = 0; i < N; i++) cin >> S[i];
  sort(S.begin(), S.end());

  for (int i = 0; i < N; i++) cout << S[i];
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
void chmin(ll& a,ll b){
    a = min(a, b);
}
void chmax(ll& a,ll b){
    a = max(a, b);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int ans = 0;
    int n = s.size();
    string bef = "", now = "";
    rep(i,n){
        now += s[i];
        if (bef!=now){
            bef = now;
            now = "";
            ans++;
        }
    }
    cout << ans << ENDL;
}

Measured memory_bytes: 720
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;
int main(){
  string s,t,ans,comp;
  int m,n,i,j,k=0,ans1=0,l=0;
  cin >> s >> t;
  m=s.size(),n=t.size();
  ans=s;
  for(i=0;i<m-n+1;i++){
    for(j=0;j<m;j++){
      comp[j]=s[j];
    }
    for(j=i;j<n+i;j++,l++){
      if(s[j]!=t[l] && s[j]!='?' ){
        k=1;
        break;
      }
      else{
        comp[j]=t[l];
      }
    }
    l=0;
    for(j=0;j<m;j++){
      if(comp[j]=='?'){
        comp[j]='a';
      }
    }
    if(k==0 && comp<ans){
      for(j=0;j<m;j++){
        ans[j]=comp[j];
      }
      ans1=1;
    }
    k=0;
  }
  if(ans1==0){
    printf("UNRESTORABLE\n");
  }
  else{
    for(i=0;i<m;i++){
      cout << ans[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		sc.close();
		if(N * A < B) {
			System.out.println(N*A);
		}else {
			System.out.println(B);
		}
	}
}

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

const int MOD = 1000000007;

// mod. mでのaの逆元a{-1}を計算する
long long modinv(long long a, long long m)
{
  long long b = m, u = 1, v = 0;
  while (b)
  {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

int main()
{
  long long N;
  cin >> N;
  long long MOD = 1000000007;
  vector<long long> x(N);
  for (int i = 0; i < N; i++)
  {
    cin >> x[i];
  }
  vector<long long> c(N);
  c[0] = 0;
  for (int i = 1; i < N; i++)
  {
    c[i] = c[i - 1] + 1 * modinv(i, MOD);
  }
  vector<long long> deltax(N);
  deltax[0] = 0;
  for (int i = 1; i < N; i++)
  {
    deltax[i] = x[i] - x[i - 1];
  }
  long long sum = 0;
  for (int i = 1; i < N; i++)
  {
    sum += c[i] * deltax[i];
    sum %= MOD;
  }
  for (int i = N - 1; i >= 1; i--)
  {
    sum *= i;
    sum %= MOD;
  }
  cout << sum << endl;
}

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

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

int main() {
    string S; cin >> S;
    int ans = 0;
    char c;
    rep(i, S.size()-1){
        if(S[i] == S[i+1]) ans = 1;
    }
    cout << (ans ? "Bad" : "Good") << endl;
    return 0;
}


Measured memory_bytes: 256
import math

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def modinv(a, m):
    g, x, y = xgcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def combination(n,r,mod):
    r = min(r,n-r)

    res = 1
    for i in range(r):
        res = res * (n-i) * modinv(i+1,mod) % mod
    
    return res

mod = 10**9+7

n,a,b = map(int,input().split())

ans = pow(2,n,mod) - 1

ans -= combination(n,a,mod)
ans -= combination(n,b,mod)

print(ans % mod)


Measured memory_bytes: 41708
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);
    final int N = scanner.nextInt();

    int count = 0;
    for (int A = 1; A < N; A++) {
      for (int B = 1; B < N; B++) {
        if (N - (A * B) >= 1) {
          count++;
        } else {
          break;
        }
      }
    }

    System.out.println(count);
  }
}

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

int N, K;
int main(void){
    // Your code here!
    cin >> N >> K;
    double mot = double(1) /N;
    double sum = 0.0;
    for(int i = 1; i <= N; i++){
        int now = i;
        double p = 1.0;
        while(now < K){
            p *= 0.5;
            now *= 2;
        }
        sum += p;
    }
    
    printf("%.12f\n", mot*sum);
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

const int N = 3000;
double dp[N][N];
double p[N];

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%lf", &p[i]);

	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) dp[0][i] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			dp[i][j] = dp[i-1][j] * (1 - p[i]);
			if (j > 0) dp[i][j] += dp[i-1][j-1] * p[i];
		}
	}
	double ans = 0;
	for (int i = n/2 + 1; i <= n; i++)
		ans += dp[n][i];
	printf("%.10f\n", ans);
}


Measured memory_bytes: 70528
#include<stdio.h>

int main() {
    long long int a, b, c, d,ac,ad,bc,bd, A, B;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    ac = a * c;
    ad = a * d;
    bc = b * c;
    bd = b * d;
    A = 0;
    B = 0;
    if (ac <= ad) { A = ad; }
    else if (ad < ac) { A = ac; }
    if (bc <= bd) { B = bd; }
    else if (bd < bc) { B = bc; }
    if (A <= B) { printf("%lld", B); }
    else if (B < A) { printf("%lld", A); }
    return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    string s; cin >> s;
    vec<string> words = {"dream", "dreamer", "erase", "eraser"};
    vec<bool> dp(s.size() + 10);

    dp[0] = 1;
    for(int i = 0; i < s.size(); ++i) {
        
        rep(j,4) {
            string word = words[j];

            if(!dp[i]) continue;
            if(s.substr(i, word.size()) == word) {
                dp[i+word.size()] = 1;
            }
        }
    }
    cout << (dp[s.size()] ? "YES" : "NO") << '\n';
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) { 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}

void solve() {
	string s;
	cin >> s;
	for (auto &i : s)
		i = 'x';
	cout << s;
}   

Measured memory_bytes: 384