akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int a1, a2, a3; cin >> a1 >> a2 >> a3;
    if(a1 + a2 + a3 >= 22){
        cout << "bust" << endl;
    }
    else {
        cout << "win" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

int main() {
  double R;
  cin >> R;
  std::cout << fixed << setprecision(10) << std::endl;
  std::cout << R * 2 * std::acos(-1) << std::endl;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    string s,t = "AKIHABARA";
    cin >> s;
    rep0(i, 9){
        if (s[i] != t[i]) {
            if (i == 8) {
                s += 'A';
            }else{
                s = s.substr(0,i) + 'A' + s.substr(i);
            }
        }
    }
    if (s == t) {
        YES;
    }else{
        NO;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define M 1000000
#define L 12
#define MIL (-1)

char  H[M][L];

int h1(int key) {return key%M;}

int h2(int key) {return 1+(key%(M-1));}

int getChar(char ch) {
    if (ch=='A') return 1;
    else if (ch=='C') return 2;
    else if (ch=='G') return 3;
    else if (ch=='T') return 4;
    return 0; 
}
long long getkey(char str[]) {
    long long sum=0,p=1,i;
    for (int i=0; i<strlen(str); i++) {
        sum+=p*(getChar(str[i]));
        p*=5;
    }
    return sum;
}
int insert(char str[]) {
    long long key,i,h;
    key = getkey(str);
    for (i=0; ; i++) {
        h = (h1(key)+i*h2(key))%M;
        if (strcmp(H[h],str)==0) {
            return 1;
        } 
        else if (strlen(H[h])==0) {
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;
}
int find(char str[]) {
    long long key,i,h;
    key = getkey(str);
    for (i=0; ; i++) {
        h = (h1(key)+i*h2(key))%M;
        if (strcmp(H[h],str)==0) {
            return 1;
        }
        else if (strlen(H[h])==0) {
            return 0;
        }
    }
    return 0;
}
int main() {
    int i;
    for (int i=0; i<M; i++) {
        H[i][0]='\0';
    }
    int n;
    scanf("%d",&n);
    char str[L],com[9];
    for (int i=0; i<n; i++) {
        scanf("%s %s",com,str);
        if (com[0]=='i') {
            insert(str);
        } 
        else {
            if (find(str)) {
                printf("yes\n");
            }
            else {
                printf("no\n");
            }
        } 
    }
    return 0;
}


Measured memory_bytes: 13448
n,k=map(int,input().split())

a=list(map(int,input().split()))
f=list(map(int,input().split()))
cnt=[0]*n
a.sort()
f.sort(reverse=True)
for i in range(n):
    cnt[i]=a[i]*f[i]
def judge(s):
    tmp=k
    for i in range(n):
        if cnt[i]>s:
            if (cnt[i]-s)%f[i]==0:
                vv=(cnt[i]-s)//f[i]
            else:
                vv=1+(cnt[i]-s)//f[i]
            tmp-=vv
    if tmp<0:
        return False
    return True

left=-1
right=10**18

while left+1<right:
    mid=(left+right)//2
    if judge(mid):
        right=mid
    else:
        left=mid

print(right)

Measured memory_bytes: 119500
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
using ll = long long;
#define pi 3.1415926
 
int a[3];
 
int main(){
    int n;
    cin >> n;
    if(n%2 == 0)
        cout << n;
    else 
        cout << 2*n;
    

}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a[100000]={0},i;
    int n,temp;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&temp);
        a[temp]=i;
    }
    
    for(i=1;i<=n;i++)
    printf("%d ",a[i]);
    
    
}

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

const int mod = 1000000007;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}

mint f(int n, int k) {
  if (n < k) return 0;
  if (k == 0) return 1;
  return c[n][k];
}

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

  for (int i = 1; i <= k; i++) {
    mint blue = f(k-1,i-1);
    mint red = f(n-k+1,i);
    mint ans = blue*red;
    printf("%lld\n", ans.x);
  }
  return 0;
}


Measured memory_bytes: 125568
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
#define PI acos(-1)
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>in;
  rep(i,n){
    int tmp;
    cin>>tmp;
    pb(in,tmp);
  }
  sort(all(in));
  if(n==3){loop(i,1,in[0]+1)if(in[0]%i==0&&in[1]%i==0&&in[2]%i==0)cout<<i<<endl;}
  else{loop(i,1,in[0]+1)if(in[0]%i==0&&in[1]%i==0)cout<<i<<endl;}

}

Measured memory_bytes: 1216
N, X, Y = map(int, input().split())

ans = [0] * N

X -= 1
Y -= 1
for i in range(N):
    for j in range(i+1, N):
        distance = min(abs(i-j), abs(i-X) + 1 + abs(j-Y))
        ans[distance] += 1

for k in range(1, N):
    print(ans[k])


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

set<string> ans;

void go(string& s)
{
	if (ans.count(s)) return;
	ans.insert(s);
	FOR(i, 0, SZ(s) - 1) if (s[i] != s[i + 1])
	{
		char a = s[i], b = s[i + 1];
		char c = 'a';
		while(a == c || b == c) c++;
		s[i] = s[i + 1] = c;
		go(s);
		s[i] = a;
		s[i + 1] = b;
	}
}

const int N = 1 << 18;
int dp[N][3][3][2];
const int mod = 998244353;

int add(int x, int y)
{
	if (x + y < mod) return x + y;
	return x + y - mod;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	string s;
	cin >> s;
	bool vse = 1;
	FOR(i, 1, SZ(s)) vse &= s[i] == s[0];
	if (vse || SZ(s) <= 7)
	{
		go(s);
		cout << SZ(ans) << endl;
		return 0;
	}
	
	int sum = 0;
	for(auto& i: s) i -= 'a', sum += i;
	sum %= 3;
	
	bool was = 0;
	FOR(i, 0, SZ(s) - 1) was |= s[i] == s[i + 1];
	
	FOR(i, 0, 3) dp[1][i][i][0] = 1;
	FOR(n, 2, SZ(s) + 1)
		FOR(zara, 0, 3) FOR(pered, 0, 3) FOR(bulo, 0, 2)
		{
			if (!bulo && zara != pered)
			{
				FOR(su, 0, 3)
					dp[n][zara][(su + zara) % 3][0] = add(dp[n][zara][(su + zara) % 3][0],
					dp[n - 1][pered][su][0]);
			}else
			{
				FOR(su, 0, 3)
					dp[n][zara][(su + zara) % 3][1] = add(dp[n][zara][(su + zara) % 3][1],
					dp[n - 1][pered][su][bulo]);
			}
		}
		
	int ans = 0;
	FOR(i, 0, 3) ans = add(ans, dp[SZ(s)][i][sum][1]);
	if (!was) ans = add(ans, 1);
	cout << ans << endl;
		
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s;
    int n, m;
    cin >> s;
    n = s.size();
    m = (n-1) / 2;
    for(int i=0;i<n-1-i;++i){
        if(s[i] != s[n-1-i]){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i=0;i<m-1-i;++i){
        if(s[i] != s[m-1-i]){
            cout << "No" << endl;
            return 0;
        }
        if(s[m+1+i] != s[n-1-i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
        
    return 0;
}

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

using namespace std;

int main(void){
  int a, b, c;

  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  
  if ((a*100 + b*10 + c)%4==0) {
    printf("YES");
  }else{
    printf("NO");
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N;
	char S[100];
	char R[200];
	int n[4]={0,0,0,0};
	int i,c;
	
	cin>>N;
	for(i=0;i<N;i++){
		c=0;
		cin>>S[i];
		if(S[i]=='('){
			n[0]++;
		}else{
			if(n[0]==0){
				n[1]++;
			}else{
				n[0]--;
			}
		}
		
	}
	
	
	for(i=0;i<n[1];i++){
		cout<<"(";
	}
	for(i=0;i<N;i++){
		cout<<S[i];
	}
	for(i=0;i<n[0];i++){
		cout<<")";
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

int d(P a, P b) {
    return abs(a.first-b.first)+abs(a.second-b.second);
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<P> a(n), c(m);
    rep(i, n) cin >> a[i].first >> a[i].second;
    rep(i, m) cin >> c[i].first >> c[i].second;

    rep(i, n) {
        int dis = mod;
        int ans = -1;
        rep(j, m) {
            int now = d(a[i], c[j]);
            if (now<dis) {
                ans = j+1;
                dis = now;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3488
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define in              insert
#define pb              push_back
#define mp              make_pair
#define lb              lower_bound
#define ub              upper_bound
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n]
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	int n; cin >> n;
	mk(h, n, int);
	for (int i = 0; i < n; i++)
		cin >> h[i];

	int dp[n] = {};
	dp[1] = abs(h[1] - h[0]);

	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}

	cout << dp[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 5164
#include <iostream>
using namespace std;
int main(){
  int n,p[15],c = 0,w;
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> p[i];
    if(c < p[i]){
      c = p[i];
      w = i;
    }
  }
  c/=2;
  for(int i = 0;i < n;i++){
    if(i != w){
      c+= p[i];
    }
  }
  cout << c << endl;
  return(0);
}


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

vector<int> get_primes(int n) {
  vector<bool> b(n + 1, true);
  b[0] = false, b[1] = false;
  for (int i = 0; i * i <= n; i++)
    if (b[i]) {
      int j = i * i;
      while (j <= n) {
        b[j] = false;
        j += i;
      }
    }

  vector<int> primes;
  for (int i = 0; i < b.size(); i++)
    if (b[i])
      primes.push_back(i);

  return primes;
}

int quick_power(int a, int b, int mod) {
  long long p = 1, q = a;
  while (b) {
    if (b & 1) p = p * q % mod;
    b >>= 1;
    q = q * q % mod;
  }
  return p;
}

static const int maxp = floor(sqrt(1e6));
static const int mod = 1000000007;

int main() {
  auto primes = get_primes(maxp);

  int n;
  scanf("%d", &n);
  vector<int> a(n);
  
  unordered_map<int, int> fe;
  long long lcm = 1;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    int t = a[i];
    
    for (auto prime : primes) {
      int e = 0;
      while (t % prime == 0) {
        e++;
        t /= prime;
      }

      if (e)
        if (!fe.count(prime) || (fe.count(prime) && fe[prime] < e)) {
          lcm = lcm * quick_power(prime, e - fe[prime], mod) % mod;
          fe[prime] = e;
        }
    }

    if (t > 1) {
      primes.push_back(t);
      fe[t] = 1;
      lcm = lcm * t % mod;
    }
  }
  
  unordered_map<int, int> reci;
  for (int prime : primes)
    reci.insert(pair<int, int>(prime, quick_power(prime, mod - 2, mod)));

  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long t = lcm;
    for (auto prime : primes) {
      int e = 0;
      while (a[i] % prime == 0) {
        e++;
        a[i] /= prime;
        t = t * reci[prime] % mod;
      }
    }

    ans = (ans + t) % mod;
  }

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

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int a[32] = {
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    };
    int k;
    cin >> k;
    cout << a[k-1] << endl;
}


Measured memory_bytes: 256
import sys
import itertools
input = sys.stdin.readline


def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def main():
    n = I()
    mylist = ("M", "A", "R", "C", "H")
    mylist2 = [0 for i in range(5)]
    for i in range(n):
        word = input().rstrip()[0]
        for i, k in enumerate(mylist):
            if word == k:
                mylist2[i] += 1
    mylist2 = [i for i in mylist2 if i != 0]
    
    
    if len(mylist2) <= 2:
        print(0)
        sys.exit()
    result = 0
    for a, b, c in itertools.combinations(mylist2, 3):
        result += a * b * c
    print(result)
    
main()

Measured memory_bytes: 41068
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int limW = sc.nextInt();
        int[] w = new int[n+1], v = new int[n+1];
        for(int i = 1; i <= n; i++) {
        	w[i] = sc.nextInt();
        	v[i] = sc.nextInt();
        }

        System.out.println(solve(n, limW, w, v));

    }

	private static long solve(int n, int limW, int[] w, int[] v) {
		long[][] dp = new long[n+1][limW+1];

		for(int i = 0; i < limW; i++) {
			dp[0][i] = 0;
		}

		for(int i = 1; i <= n; i++) {
			for(int j = 1; j <= limW; j++) {
				if(j < w[i]) {
					dp[i][j] = dp[i-1][j];
				}else {
					dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
				}

			}
		}
		long maxValue = dp[n][limW];
		return maxValue;

	}
}

Measured memory_bytes: 127696
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<climits>
#include<cstdlib>
#include<map>
#include<math.h>
#include<utility>
using namespace std;
typedef long long ll;

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  x -= a;
  while(x>=b){
    x -= b;
  }
  cout << x << endl;
  return 0;
}


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

using namespace std;

using ll = long long;

const int MAXN = 200200;
const int LG = 18;
const int MOD = 1e9 + 7;
const int INV2 = 5e8 + 4;

int N;
vector<int> adj[MAXN];
int dist[MAXN];
int par[LG][MAXN];
int tin[MAXN], tout[MAXN], tt;
vector<int> cpAdj[MAXN];
vector<int> byDist[MAXN];

void precalc(int v) {
   tin[v] = ++tt;
   for (int i = 1; i < LG; ++i) {
      par[i][v] = par[i - 1][par[i - 1][v]];
   }
   for (int u : adj[v]) {
      par[0][u] = v;
      dist[u] = dist[v] + 1;
      precalc(u);
   }
   tout[v] = tt;
}

int lca(int v, int u) {
   if (dist[v] > dist[u]) swap(v, u);
   for (int i = LG - 1; i >= 0; --i) {
      if (dist[par[i][u]] >= dist[v]) {
         u = par[i][u];
      }
   }
   if (v == u) return true;
   for (int i = LG - 1; i >= 0; --i) {
      if (par[i][v] != par[i][u]) {
         v = par[i][v];
         u = par[i][u];
      }
   }
   return par[0][v];
}

int dp[MAXN];

void solve(int v) {
   if (cpAdj[v].empty()) {
      dp[v] = INV2;
      return;
   }
   vector<int> z(2, 0);
   z[0] = 1;
   for (int u : cpAdj[v]) {
      solve(u);
      vector<int> nz(2);
      nz[0] = ll(z[0]) * (MOD + 1 - dp[u]) % MOD;
      nz[1] = ll(z[1]) * (MOD + 1 - dp[u]) % MOD;
      nz[1] += (ll(z[0]) * dp[u] % MOD);
      if (nz[1] >= MOD) nz[1] -= MOD;
      z = nz;
   }
   dp[v] = z[1];
}

bool isAnc(int v, int u) {
   return tin[v] <= tin[u] && tout[u] <= tout[v];
}

int go(vector<int> verts) {
   sort(verts.begin(), verts.end(), [&](int v, int u) {
      return tin[v] < tin[u];
   });
   for (int i = int(verts.size()) - 1; i > 0; --i) {
      verts.emplace_back(lca(verts[i], verts[i - 1]));
   }
   sort(verts.begin(), verts.end(), [&](int v, int u) {
      return tin[v] < tin[u];
   });
   verts.resize(unique(verts.begin(), verts.end()) - verts.begin());
   vector<int> st;
   for (int v : verts) cpAdj[v] = {};
   for (int v : verts) {
      while (st.size() && !isAnc(st.back(), v)) {
         st.pop_back();
      }
      if (st.size()) {
         cpAdj[st.back()].emplace_back(v);
      }
      st.emplace_back(v);
   }
   solve(verts[0]);
   return dp[verts[0]];
}

int main() {
   ios_base::sync_with_stdio(false);
   cin >> N;
   for (int i = 1; i <= N; ++i) {
      int par;
      cin >> par;
      adj[par].emplace_back(i);
   }
   precalc(0);
   for (int i = 0; i <= N; ++i) {
      byDist[dist[i]].emplace_back(i);
   }
   int ans = 0;
   for (int d = 0; byDist[d].size(); ++d) {
      ans += go(byDist[d]);
      if (ans >= MOD) ans -= MOD;
   }
   for (int i = 0; i <= N; ++i) {
      ans += ans;
      if (ans >= MOD) ans -= MOD;
   }
   cout << ans << "\n";
   return 0;
}


Measured memory_bytes: 53376
import math

k = int(input())

box = [0]*(k+1)
ans = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        box[math.gcd(a,b)] += 1

for a in range(1,k+1):
    for c in range(1,k+1):
        ans += math.gcd(a,c)*box[a]

print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
int Max(int c1, int c2, int c3){
	int h = max(c1, c2);
	return max(h, c3);
}

int main(){
	int a, b, c=0;
	cin >> a >> b;
	int c1 = 2*a-1, c2 = 2*b-1, c3 = a+b;
	cout << Max(c1, c2, c3);
	return 0;	
}

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

int main() {
  string s;
  cin >> s;
  bool flg = true;
  if(s.size() % 2 != 0) flg = false;
  for(int i = 1; i <= s.size(); i++){
    if(i % 2 == 1){
      if(s[i-1] != 'h') flg = false;
    }else{
      if(s[i-1] != 'i') flg = false;
    }
  }
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    int count = 0;
    for (int i = a; i <= b; i++) {
        if (i/10000 == i%10 && (i/1000)%10 == (i/10)%10) {
            count++;
        }
    }
    cout << count << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
#define fr first
#define sc second
#define pii pair<int, int>
#define all(v) v.begin(), v.end()

using namespace std;

const ll MOD = 1000000007;

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

    // int tc;
    // cin >> tc;
    // while (tc--) {
    int n;
    cin >> n;
    if (n % 1000 == 0)
        cout << 0;
    else
        cout << 1000 - (n % 1000);
    // }

    return 0;
}


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

typedef long long int ll;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string s,t;
    cin>>s>>t;

    int n = (int)s.length();
    int m = (int)t.length();

    int ans = INT_MAX; 

    for(int i = 0;i < n - m + 1; i++){
        int count = 0;
        for(int j = 0;j < m ;j++){
            if(s[i+j] != t[j])count++;
        }
        ans = min(ans,count);
    }

    cout<<ans;

    return 0;

}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	bool flag=false;
	while(n!=0){
		if(n%10==7) flag=true;
		n/=10;
	}
	if(flag) cout<<"Yes";
	else cout<<"No";
 	
	return 0;
}

Measured memory_bytes: 3652
# -*- coding: utf-8 -*-

s_list = list(input())
t_list = list(input())

# 昇順ソート
s_list.sort()
# 降順ソート
t_list.sort(reverse=True)

# 文字列の並び順も比較演算子で大小比較できる
if "".join(s_list) < "".join(t_list):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define PB push_back
#define EB emplace_back
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
using namespace std;
typedef long long LL;
const int N=131080;
int n,fa[N];
LL val[N];
vector<int>G[N];
vector<pair<LL,LL> >f[N];
bool chk(LL mid){
	for(int k1=n;k1>=1;--k1){
		f[k1].clear();
		if(G[k1].empty()){
			f[k1].EB(val[k1],val[k1]);
			continue;
		}
		vector<pair<LL,LL> >A,B;
		int L=G[k1][0],R=G[k1][1];
		LL lim=mid+2*val[k1];
		for(int i=0,j=0;i<SZ(f[L]);++i){
			while(j<SZ(f[R])&&f[L][i].fi+f[R][j].se>lim)++j;
			if(j==SZ(f[R]))break;
			A.EB(f[L][i].se,f[R][j].fi);
			B.EB(f[R][j].fi,f[L][i].se);
		}
		reverse(A.begin(),A.end());
		vector<pair<LL,LL> >C(SZ(A)+SZ(B));
		merge(A.begin(),A.end(),B.begin(),B.end(),C.begin());
		if(SZ(C)==0)return 0;
		for(int i=0;i<SZ(C);++i){
			if(i==0||C[i].se<f[k1].back().se)f[k1].PB(C[i]);
		}
	}
	return 1;
}
int main(){
	scanf("%d",&n);
	for(int i=2;i<=n;++i)scanf("%d%lld",&fa[i],&val[i]),val[i]+=val[fa[i]],G[fa[i]].PB(i);
	LL l=0,r=1LL<<40,ans=0;
	while(l<=r){
		LL mid=(l+r)>>1;
		if(chk(mid))ans=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 38128
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
class lazy_segment_tree{
    private:
        static int calc_size(int n){
            int m = 1;
            while(m < n){
                m *= 2;
            }
            return m;
        }

        void eval(int i, int l, int r){
            if(lazy[i] != INF){
                node[i] = lazy[i];
                if(r - l > 1){
                    lazy[i * 2 + 1] = lazy[i] / 2;
                    lazy[i * 2 + 2] = lazy[i] / 2;
                }
                lazy[i] = INF;
            }
        }

        void update(int s, int t, int x, int i, int l, int r){
            eval(i, l, r);

            if(t <= l || r <= s){
                return ;
            }

            if(s <= l && r <= t){
                lazy[i] = (r - l) * x;
                eval(i, l, r);
                return;
            }

            int m = l + (r - l) / 2;
            update(s, t, x, 2 * i + 1, l, m);
            update(s, t, x, 2 * i + 2, m, r);
            node[i] = f(node[2 * i + 1], node[2 * i + 2]);
        }

        T query(int s, int t, int i, int l, int r){
            eval(i, l, r);

            if(t <= l || r <= s){
                return init;
            }

            if(s <= l && r <= t){
                return node[i];
            }

            int m = l + (r - l) / 2;
            T vl = query(s, t, i * 2 + 1, l, m);
            T vr = query(s, t, i * 2 + 2, m, r);
            return f(vl, vr);
        }

    public:
        int n;
        vector<T> node, lazy;
        T init;
        function<T(T, T)> f;

        lazy_segment_tree(int n, T init, function<T(T, T)> f)
            : n(calc_size(n)), node(calc_size(n) * 2, init) , lazy(calc_size(n) * 2, INF), init(init), f(f) {}

        T query(int s, int t){
            return query(s, t, 0, 0, n);
        }

        void update(int s, int t, int x){
            update(s, t, x, 0, 0, n);
        }
};

signed main(){
    int n, q;
    cin >> n >> q;

    lazy_segment_tree<int> lst(n, 0, [](int a, int b){return a+b;});

    rep(i, q){
        int que, s, t;
        cin >> que >> s >> t;

        if(que == 0){
            int x;
            cin >> x;
            lst.update(s, t+1, x);
        }else{
            cout << lst.query(s, t+1) << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 7040
#include <iostream>
#include <cmath>
#include <vector>
#include <numeric>
using namespace std;

int main () {
    int n;
    cin >> n;
    while (0 < n) {
        vector<double> s(n);
        for (int i = 0; i < n; i++) {
            cin >> s[i];
        }
        double avg = accumulate(s.begin(), s.end(), 0) / (double)s.size();
        double result = 0;
        for (int i = 0; i < n; i++) {
            result += pow((s[i] - avg), 2);
        }
        result = sqrt(result / (double)n);
        printf("%.8f\n", result);
        cin >> n; 
    }
}


Measured memory_bytes: 3216
n = gets.chomp.to_i
alist = gets.chomp.split.collect{ |item| item.to_i}
ballList = Array.new(n)
result = Array.new()
n.times do |ni|
  ballList[ni] = false
end
def set_ball(zo,ni,ballList,n)
  data_r = 0
  data_b = 0
  clist = 0
  2.upto(n) do |nii|
    checkn = (nii*(ni+1))
    break if checkn > n
    clist += ballList[checkn-1]
  end
  clist = clist%2
  if clist == 0
    data_r = zo
    data_b = zo
  else
    data_r = zo == 1 ? 0 : 1
    data_b = zo == 1 ? 0 : 1
  end
  return data_r,data_b
end

er = false
(n-1).downto(0) do |ni|
  zeroOne = alist[ni]
  data_r,data_b = set_ball(zeroOne,ni,ballList,n)
  ballList[ni] = data_b
  result.unshift(ni+1) if (data_r == 1)
  if data_r == false
    er = true
    break
  end
end

if er
  puts -1
else
  puts result.size
  puts result.join(" ") if result.size >= 1
end


Measured memory_bytes: 23328
/*
  Reference:-
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int,int>
#define all(vec) vec.begin(),vec.end()
ll mod=1000000007;
const int N=2e5 + 5;
string s;
int n,d;
ll dp[10005][105][2];
ll sol(int pos,int rem,int fl){
    ll one=1,zero=0;
    if(pos==n){
        if(rem==0)return one;
        else return zero;
    }
    if(dp[pos][rem][fl]!=-1)return dp[pos][rem][fl];
    int lim=9;
    if(fl==1)lim=s[pos]-'0';
    ll ans=0;
    forn(i,lim+1){
        int fl1=fl;
        if(fl==1&&i<lim)fl1=0;
        ans=(ans+sol(pos+1,(rem+i)%d,fl1))%mod;
    }
    dp[pos][rem][fl]=ans;
    return ans;
}
int main(){
    std::ios::sync_with_stdio(false);
    cin>>s>>d;
    n=s.size();
    memset(dp,-1,sizeof(dp));
    ll ans=sol(0,0,1);
    ans=(ans-1+mod)%mod;
    cout<<ans;

    return 0;
}


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

int N,n;
pair<int,int>p[300000],dat[1200000];
void init(int n){N=1;while(N<n)N<<=1;rep(i,2*N-1)dat[i]={0,0};}
void update(int k,int x){k+=N-1;dat[k]={x,k-N+1};while(k>0)k=(k-1)/2,dat[k]=max(dat[k*2+1],dat[k*2+2]);}
bool ok(int t){init(t);ll s=0,sum=0;for(int i=n-1;i>=n-t+1;i--)update(s++,p[i].second),sum+=p[i].second;if(p[n-t].first*(ll)t>=(ll)sum+p[n-t].second)return 1;for(int i=n-t;i>0;i--){if(dat[0].first>p[i].second)sum-=dat[0].first-p[i].second,update(dat[0].second,p[i].second);if(p[i-1].first*(ll)t>=(ll)sum+p[i-1].second)return 1;}return 0;}
int main() {
	scanf("%d",&n);
	rep(i,n){
		int a,b;scanf("%d%d",&a,&b);
		p[i]={b,a};
	}sort(p,p+n);
	int a=0,b=n;while(a!=b){int t=(a+b)/2;if(b-a==1)t=b;if(ok(t))a=t;else b=t-1;}
	printf("%d\n",a);
}

Measured memory_bytes: 13684
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

    set<vector<int>> s;
    rep2(h, 1, 150 + 1) {
        rep2(w, h + 1, 150 + 1) {
            s.insert(vector<int>{h * h + w * w, h, w});
        }
    }

    int h, w;
    while (cin >> h >> w, h) {
        auto t = *upper_bound(all(s), vector<int>{h * h + w * w, h, w});
        cout << t[1] << " " << t[2] << endl;
    }
}

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	ll n,d;
	cin>>n>>d;
	d*=d;
	int count=0;
	for(int i=0;i<n;i++){
		ll val,x,y;
		cin>>x>>y;
		val=x*x+y*y;
		if(val<=d)
			count++;
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3608
from heapq import heappush, heappop
 
N,M = map(int,input().split())

allhiyatoi = [[] for j in range(M+1)]
for i in range(N):
    temp = list(map(int,input().split()))
    if temp[0] > M:
        continue
    allhiyatoi[temp[0]].append(temp[1])
 
reward = 0
Q = []
for i in allhiyatoi:
    for j in i:
        heappush(Q,j*-1)
    if len(Q) == 0:
        continue
    reward -= (heappop(Q))

print(reward)

Measured memory_bytes: 71328
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1000000007LL;
char S[12][13];
char T[12][13];
bool used[12];
bool row[12];
int perm[12];
int H, W;
bool check(int c) {
	if (c == W / 2) {
		for (int i = 0; i < W; i++) {
			if (used[i]) continue;
			perm[W / 2] = i;
			break;
		}
		for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) T[i][j] = S[i][perm[j]];
		int cnt = 0;
		memset(row, 0, sizeof(row));
		for (int i = 0; i < H; i++) {
			if (row[i]) continue;
			bool ok = 0;
			for (int j = i + 1; j < H; j++) {
				if (row[j]) continue;
				bool match = 1;
				for (int k = 0; k < W; k++) {
					if (T[i][k] != T[j][W - 1 - k]) {
						match = 0;
						break;
					}
				}
				if (match) {
					ok = 1;
					row[i] = row[j] = 1;
					break;
				}
			}
			if (!ok) {
				for (int j = 0; j < W; j++) if (T[i][j] != T[i][W - 1 - j]) return 0;
			}
			else cnt++;
		}
		if (cnt == H / 2) return 1;
		return 0;
	}
	for (int i = 0; i < W; i++) {
		if (used[i]) continue;
		used[i] = 1;
		perm[c] = i;
		for (int j = i + 1; j < W; j++) {
			if (used[j]) continue;
			used[j] = 1;
			perm[W - 1 - c] = j;
			if (check(c + 1)) return 1;
			used[j] = 0;
		}
		used[i] = 0;
	}
	return 0;
}
int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> S[i];
	if (check(0)) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int i,l[n],s=1,ss=0;
	for(i=0;i<n;i++){
		cin>>l[n];
		ss+=l[n];
		if(ss<=m)s++;
	}
	cout<<s;
	return 0;
}

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

/* constant */

const int MAX_N = 10000;
const int INF = 1 << 29;

/* typedef */

typedef pair<int,int> pii;
typedef vector<pii> vpii;

struct Edge {
  int i, d, c;
  Edge() {}
  Edge(int _i, int _d, int _c): i(_i), d(_d), c(_c) {}
};

typedef vector<Edge> ve;

/* global variables */

int n, m;
ve nbrs[MAX_N];
pii dists[MAX_N];

/* subroutines */

/* main */

int main() {
  for (;;) {
    cin >> n >> m;
    if (n == 0) break;

    for (int i = 0; i < n; i++)
      nbrs[i].clear(), dists[i] = pii(INF, INF);
    
    for (int i = 0; i < m; i++) {
      int u, v, d, c;
      cin >> u >> v >> d >> c;
      u--, v--;

      nbrs[u].push_back(Edge(v, d, c));
      nbrs[v].push_back(Edge(u, d, c));
    }

    dists[0] = pii(0, 0);

    priority_queue<pii,vpii,greater<pii> > q;
    q.push(pii(0, 0));

    while (! q.empty()) {
      pii u = q.top(); q.pop();

      int& ud = u.first;
      int& ui = u.second;
      if (ud > dists[ui].first) continue;

      ve& nbru = nbrs[ui];
      for (ve::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
	int& vi = vit->i;
	int& vd = vit->d;
	int nvd = ud + vd;
	pii vdist(nvd, vit->c);

	if (dists[vi] > vdist) {
	  if (dists[vi].first > nvd) q.push(pii(nvd, vi));
	  dists[vi] = vdist;
	}
      }
    }

    int sum = 0;

    for (int i = 1; i < n; i++)
      sum += dists[i].second;

    cout << sum << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		
		char a;
		cin>>a;

		if(isupper(a)) {
			cout<<"A"<<endl;
		}		
		else {
			cout<<"a"<<endl;
		}

		return 0;
	}



Measured memory_bytes: 3628
s = input()
K = int(input())
 
sub_s = []
for i in range(1, K+1):
    for j in range(len(s) - i + 1):
        sub_s.append(s[j:j+i])
 
sub_s = sorted(list(set(sub_s)))        
#print(sub_s)
print(sub_s[K-1])

Measured memory_bytes: 5068
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}

ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

void solve(){
  ll x;
  cin>>x;
  ll sum=0;
  ll y=x/500;
  x-=y*500;
  ll z=x/5;
  sum=y*1000+z*5;
  cout<<sum;
}

int main(){
    ios::sync_with_stdio(false);
  cin.tie(0);
    cout<<fixed<<setprecision(15);
  solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define rep(i,n) for(re int (i)=1;(i)<=(n);++(i))
typedef long long ll;
const int maxn=1e5+5;
int n,m,a[maxn];
il int read(){
	re char ch(getchar());
	re int f(1),x(0);
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
int main(){
	cin>>n>>m;
	cout<<max(n+m,max(n-m,n*m));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
#define int long long
using namespace std;
using namespace atcoder;
constexpr int mod=1e9+7;
signed main(){
    int n,m,a,b;
    cin>>n>>m;
    dsu d(n);
    while(cin>>a>>b)
        d.merge(a-1,b-1);
    cout<<d.groups().size()-1<<endl;
}


Measured memory_bytes: 8948
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;

static class MainClass
{
    public static void Main(string[] args)
    {
        var ab = Console.ReadLine().SplittedStringToInt32List();
        if (ab[0] == ab[1])
        {
            Console.WriteLine("Draw");
        }
        else
        {
            if (ab[0] == 1)
            {
                ab[0] = 14;
            }
            if (ab[1] == 1)
            {
                ab[1] = 14;

            }
            Console.WriteLine(ab[0] > ab[1] ? "Alice" : "Bob");
        }
    }



    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();

    public const int INF = int.MaxValue / 2;
    #endregion
}


Measured memory_bytes: 11348
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int n, m; cin >> n;
  v1i v(n); rep(i, n) cin >> v[i];
  long ans = 0;
  m = v[0];
  rep(i, n){
    m = max(m, v[i]);
    ans += max(m - v[i], 0);
  }
  cout << ans << endl;
  return 0;
}

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

int segment_tree_size = 1;
vector<int> minimum_segment_tree;

void item_change(int point, int number){
    point += segment_tree_size - 1;
    minimum_segment_tree[point] = number;
    while(point > 0){
        point = (point - 1) / 2;
        minimum_segment_tree[point] = min(minimum_segment_tree[point * 2 + 1], minimum_segment_tree[point * 2 + 2]);
    }
}

int range_minimum(int left, int right, int point_left, int point_right, int now){
    if(point_right <= left || right <= point_left){
        return 2147483647;
    }else if(left <= point_left && point_right <= right){
        return minimum_segment_tree[now];
    }else{
        return min(range_minimum(left, right, point_left, (point_left + point_right) / 2, now * 2 + 1),
                   range_minimum(left, right, (point_left + point_right) / 2, point_right, now * 2 + 2));
    }
}

int main(){
    int N, Q;
    cin >> N >> Q;
    while(segment_tree_size < N){
        segment_tree_size *= 2;
    }
    minimum_segment_tree.resize(segment_tree_size * 2 + 1);
    fill(minimum_segment_tree.begin(), minimum_segment_tree.end(), 2147483647);
    for(int i = 0; i < Q; i++){
        int com, x, y;
        cin >> com >> x >> y;
        if(com){
            cout << range_minimum(x, y + 1, 0, segment_tree_size, 0) << endl;
        }else{
            item_change(x, y);
        }
    }
}



Measured memory_bytes: 3812
#include <stdio.h>
#include <math.h>

int main(void)
{
  long int w, h, result;
  
  scanf("%ld %ld", &w, &h);
  result = w*h/2;
  
  if( w == 1 || h == 1 ){
    printf("%d", 1);
    return 0;
  }
  
  if( w*h % 2 == 0 ){
    printf("%ld\n", result);
  } else {
    printf("%ld\n", result + 1);
  }
  
  return 0;
}

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

using namespace std;

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

    int a;
    cin >> a;
    string s;
    cin >> s;
    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
}

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

double dis(long long int p, long long int q){
    double ans;
    p *= p;
    q *= q;
    ans = sqrt(p + q);
    return ans;
}

int main(){
    int n, d, count;
    count = 0;
    cin >> n >> d;
    long long int x, y;
    rep(i,0,n){
        cin >> x >> y;
        if(dis(x, y) <= d) count += 1;
    }
    cout << count << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> pa;

#define fst first
#define snd second
#define pb push_back

const int maxn=1000005,maxm=3006;
const double pi=acos(-1.0);
//const ll mod=1000000007;
const ll mod=998244353;
const double eps=1e-8;

int n,s;
int a[maxn];

int dp[maxm][maxm]={0};


int main()
{
	int i,j;
	scanf("%d %d",&n,&s);
	for(i=0;i<n;i++) scanf("%d",a+i);
	dp[0][0]=1;
	for(i=0;i<n;i++)
    {
        for(j=0;j<=s;j++)
        {
            dp[i+1][j]+=dp[i][j]*2%mod;
            dp[i+1][j]%=mod;
            if(j+a[i]<=s)
            {
                dp[i+1][j+a[i]]+=dp[i][j];
                dp[i+1][j+a[i]]%=mod;
            }
        }
    }
    printf("%d\n",dp[n][s]);
    return 0;
}


Measured memory_bytes: 39064