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

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

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

//combination mod prime
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
 int k, n;
 string s;
 cin >> k >> s;
 n = s.size();
combination c(n+k);
mint ans = 0;
mint now ;
 for(int i = 0; i<=k; i++){
    now = mint(25).pow(i);
    now *= mint(26).pow(k-i);
    now *= c(i+n-1,n-1);
   ans += now;
 }
cout << ans << endl;
 return 0;
}
    

Measured memory_bytes: 35560
atcodeer, topcodeer = map(str, input().split())

if atcodeer == 'H' and topcodeer == 'H':
    print('H')
elif atcodeer == 'H' and topcodeer == 'D':
    print('D')
elif atcodeer == 'D' and topcodeer == 'H':
    print('D')
elif atcodeer == 'D' and topcodeer == 'D':
    print('H')

Measured memory_bytes: 8892
#include <algorithm>
#include <iostream>
#include <functional>

using namespace std;

int main(void){
	int n, k;
	int i,j;
	int sum = 0;

	cin >> n >> k;
	int *l = new int[n];
	
	for(i=0; i<n; i++){
		cin >> l[i];
	}
	
	sort(l, l + n);
		
	for(i=n-1; i > n - k - 1; i--){
		sum += l[i];
	}
	
	cout << sum;
	cout << '\n';
	return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    vector<int> C(N);
    int ans = 0;
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) {
        int b; cin >> b;
        ans += b;
    }
    for (int i = 1; i < N; i++) cin >> C[i];
    for (int i = 1; i < N; i++) if (A[i-1] + 1 == A[i]) ans += C[A[i-1]];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, N;
    cin >> H >> N;
    vector<pii> magics;
    for(int i = 0; i < N; i++)
    {
        int A, B;
        cin >> A >> B;
        magics.emplace_back(A, B);
    }
    ll INF = 1e12;
    vector<ll> dp(H + 1, INF);
    dp.at(0) = 0;
    for(int i = 0; i < H + 1; i++){
        for(pii magic: magics){
            int damage, cost;
            tie(damage, cost) = magic;
            if(damage + i > H){
                damage = H - i;
            }
            dp.at(i + damage) = min(dp.at(i) + cost, dp.at(i + damage));
        }
    }
    cout << dp.at(H) << endl;
    return 0;
}


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

int main(){
    string str, ord, rep, tmp;
    int x, a, b;
    cin >> str >> x;
    for (int i=0; i<x; i++){
        cin >> ord;
        if (ord == "print"){
            cin >> a >> b;
            cout << str.substr(a, b-a+1) << endl;
        } else if (ord == "replace"){
            cin >> a >> b >> rep;
            str.replace(a, b-a+1, rep);
        } else {
            cin >> a >> b;
            tmp = str.substr(a, b-a+1);
            str.erase(a, b-a+1);
            reverse(tmp.begin(), tmp.end());
            str.insert(a, tmp);
        }
    }
    return 0;
}


Measured memory_bytes: 3196
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                                              NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	
	#ifndef ONLINE_JUDGE
	freopen("C:/Users/DELL/Desktop/input.txt", "r", stdin);
	#endif

	fast;
	int n,m;
	cin>>n>>m;
	if(m>=2*n && (m-2*n)%2==0 && 4*n>=m && (4*n-m)%2==0)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>

void dfs(
  const std::vector<std::vector<int>>& adj_list,
  const int node,
  const int parent_node,
  std::vector<bool>& visited,
  std::vector<long long>& score)
{
  if(parent_node!=-1){
    score[node]+=score[parent_node];
  }
  visited[node] = true;

  for(const auto& child: adj_list[node]){
    if(visited[child])continue;
    dfs(adj_list, child, node, visited, score);
  }
}

int main()
{
  int n, q;
  std::cin >> n >> q;
  std::vector<std::vector<int>> adj_list(n);
  for (int i = 0; i < n-1; i++)
  {
    int a, b;
    std::cin >> a >> b;
    a --;
    b --;
    adj_list[a].push_back(b);
    adj_list[b].push_back(a);
  }
  std::vector<long long> score(n);
  for (int i = 0; i < q; i++)
  {
    int p, x;
    std::cin >> p >> x;
    score[--p]+=x;
  }
  std::vector<bool> visited(n, false);
  dfs(adj_list, 0, -1, visited, score);
  for(const auto& s: score){
    std::cout << s << std::endl;
  }
}


Measured memory_bytes: 31232
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>*/
 
#define pb push_back
#define mp make_pair
#define sz(s) ((int)(s.size()))
#define all(s) s.begin(), s.end()
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, n, a) for (int i = n; i >= a; --i)
#define onlycin ios_base::sync_with_stdio(false); cin.tie(0) 
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
/*typedef tree<
pair < int, int >,
null_type,
less< pair < int, int > >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
// find_by_order() order_of_key()
const int MAXN = (int)5e5+228;
const char nxtl = '\n';
const int mod = (int)1e9+7;
const double eps = (double)1e-7;
template<typename T> inline bool updmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<typename T> inline bool updmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

string s;
int x, y, last[MAXN];
bitset < MAXN > dp;

int main() {
	#ifdef accepted
		freopen(".in", "r", stdin);
		freopen(".out", "w", stdout);
	#endif
	onlycin;
	cin >> s;
	cin >> x >> y;
	int cur = 0;
	vector < int > all;
	// if(s[0] == 'T') all.pb(0);
	rep(i, 0, sz(s) - 1) {
		if(s[i] == 'T') {
			last[i] = cur, cur = 0;
			all.pb(last[i]);
		}
		else cur++;
	}
	if(cur > 0) all.pb(cur);
	int C = 8000;
	if(!all.empty()) dp[all[0]+C] = 1;
	for(auto &to : all) cerr << to << ' ';
	cerr << nxtl;
	for(int i = 2; i < sz(all); i += 2) {
		dp = (dp << (all[i])) | (dp >> (all[i]));
	}
	if(dp[x+C] == 0) {
		cout << "No\n"; return 0;
	}
	dp.reset();
	dp[C] = 1;
	for(int i = 1; i < sz(all); i += 2) {
		dp = (dp << all[i]) | (dp >> all[i]);
	}
	if(dp[y+C] == 0) {
		cout << "No\n"; return 0;
	}
	cout << "Yes\n";
	
	return 0;
}

Measured memory_bytes: 768
#include	<stdio.h>

int		main(void)
{

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

	if(a < b)
		printf("a < b\n");
	else if(a > b)
		printf("a > b\n");
	else
		printf("a == b\n");

	return(0);

}

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

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

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


int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n, m, k, a;
    cin >> n >> m;
    vector<int> count(m+1, 0);
    for(int i=0;i<n;++i) {
        cin >> k;
        for(int j=0;j<k;++j) {
            cin >> a;
            ++count[a];
        }
    }

    ll ans = 0;
    for(int i=1;i<=m;++i) if(count[i] == n) ++ans;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define debug(x) cerr << #x << ": " << x << "\n";
#define INF (1<<29) //53687091
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=(int) 1e5;
static const int MOD=(int) 1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };

ll A[2*MAX+2],m1,a,m2,M,N,sum;


void solve(){
    sort(A,A+N);
    if((N+1)%2) M = A[(N+1)/2];
    else M = A[(N+1)/2-1];
    for(int i=0;i<N;i++){
        sum += abs(A[i] - M);
    }
    cout << sum << "\n";
}

int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin >> N;
    for(ll i=0ll;i<N;i++){
        cin >> a;
        A[i] = a - ( i + 1ll ); //A[i] = A[i]-i
    }
    solve();
    
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for (i=a;i<b;i++)
#define rep2(i,a,b) for (i=a;i>=b;i--)
#define mod 1000000007
#define mod2 998244353
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF  1e9+5
#define f first
#define s second
#define endl '\n'
#define ll long long
#define ii pair <int,int>
#define pll pair <ll,ll>
#define vi vector <int>
#define vl vector <ll>
#define vvi vector < vi >
#define vii vector < ii >
#define vpl vector < pll >
#define vvii vector < vii >
#define vll vector < ll >
#define vb  vector <bool>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define pg priority_queue<ll, vector<ll>, greater<ll>>
#define pq priority_queue<ll>
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define cset(a) __builtin_popcountll(a)
#define FILL(a, b, T) fill_n((T *)a, sizeof(a) / sizeof(T), b)
#define debug(x) cerr << #x << " is " << x << endl;
using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define pis pair<ll,pll>
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
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);
    }
};
// unordered_map<long long, int, custom_hash> safe_map;
// FOR VIEWERS, CODE STARTS HERE

int main()
{
    
    FIO;
    ll t, q, n, m, prev, maxx,  i, j, k1, k2, k3, k, x, y, flag, sum, cnt, ans, minn, cur;
    cin>>k;
    cin>>n>>m;
    ans = m/k - (n-1)/k;
    if( ans == 0)
        cout<<"NG\n";
    else
        cout<<"OK\n";
    return 0;    
}


Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
typedef long long LL;
const LL MX = 5052;

struct node{
	LL x,dis;
	bool operator < (const node &nd)const{
		return nd.dis < dis;
	}
}h,t;

LL ec = 0,hed[2000005] = {0},nxt[8000005],to[8000005],w[8000005];
void add_edge(LL f,LL t,LL cst){
	++ ec; to[ec] = t; w[ec] = cst; nxt[ec] = hed[f]; hed[f] = ec;
}

// dijk
priority_queue <node> q;
LL dis[6000005];
LL vis[6000005];
void dijkstra(LL s){
	memset(dis,0x3f,sizeof(dis));
	memset(vis,0,sizeof(vis));
	t.x = s; t.dis = 0; dis[s] = 0; q.push(t);
	while(!q.empty()){
		h = q.top(); q.pop();
		LL v,u = h.x; if(vis[u]) continue;
		vis[u] = 1;
		for(LL i = hed[u];i;i = nxt[i]){
			LL v = to[i];
			if(dis[v] > dis[u] + w[i]){
				dis[v] = dis[u] + w[i];
				t.x = v; t.dis = dis[v];
				q.push(t);
			}
		}
	}
}
// dijk

LL get_id(LL x,LL y){
	return (x - 1) * (MX + 1) + y + 1;
}
LL ans[2000005];

int main(){
	LL n,m,s,u,v,a,b;
	cin >> n >> m >> s;
	s = min(s,MX);
	for(LL i = 1;i <= m;i ++){
		cin >> u >> v >> a >> b;
		for(LL j = a;j <= MX;j ++){
			add_edge(get_id(u,j),get_id(v,j - a),b);
			add_edge(get_id(v,j),get_id(u,j - a),b);
		}
	}
	for(LL i = 1;i <= n;i ++){
		cin >> a >> b;
		for(LL j = 0;j <= MX;j ++) add_edge(get_id(i,j),get_id(i,min(j + a,MX)),b);
	}
	dijkstra(get_id(1,s));
	for(LL i = 1;i <= n;i ++){
		ans[i] = dis[get_id(i,0)];
		for(LL j = 1;j <= MX;j ++) ans[i] = min(ans[i],dis[get_id(i,j)]);
	}
	for(LL i = 2;i <= n;i ++) cout << ans[i] << '\n';
	return 0;
}

Measured memory_bytes: 132124
#include <iostream>
 
using namespace std;
 
int main() {
    int i,j;
    int N, A[100];
    int s_c=0; //swap_count
    int mini_sub;
    
    //input
    cin >> N;
    for(i=0;i<N;i++) cin >> A[i];
    
    //書いてある疑似コード（pseudocode）通りだと、同じところ同士を調べたりしてるけど、そのまんま書く
    for(i=0;i<N;i++){
        mini_sub=i;
        for(j=i;j<N;j++){
            if(A[j]<A[mini_sub]) mini_sub=j;
        }
        if(i!=mini_sub){
            swap(A[i],A[mini_sub]);
            s_c++;
        }
    }
    
    //output
    for(i=0;i<N;i++){
        cout << A[i];
        if(i!=N-1) cout << ' ';
        else cout << endl;
    }
    cout << s_c++ << endl;
    
        return 0;
}
 

Measured memory_bytes: 1160
#include<iostream>
#include<math.h>
#include<iomanip>
#include<algorithm>
using namespace std;

int main(){
	double x[1000],y[1000],D1=0,D2=0,D3=0,D4=0;
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>x[i];
	for(int i=0;i<n;i++)cin>>y[i];
	for(int i=0;i<n;i++){
		D1+=fabs(x[i]-y[i]);
		D2+=(x[i]-y[i])*(x[i]-y[i]);
		D3+=fabs((x[i]-y[i])*(x[i]-y[i])*(x[i]-y[i]));
		D4=max(fabs(x[i]-y[i]),D4);
	}
	cout<<fixed<<setprecision(5)<<D1<<endl;
	cout<<fixed<<setprecision(5)<<sqrt(D2)<<endl;
	cout<<fixed<<setprecision(5)<<pow(D3,1.0/3.0)<<endl;
	cout<<fixed<<setprecision(5)<<D4<<endl;
}


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

using namespace std;

#define int long long
#define endl '\n'

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

    int n;
    cin >> n;

    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    for (int j = 1; j < n; ++j) {
        if (v[j] < v[j - 1])
            return cout << "No" << endl, 0;
        else if (v[j] > v[j - 1])
            v[j]--;
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long ll;

inline char nc(){
  static char buf[100000],*p1=buf,*p2=buf;
  if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2)  return EOF; }
  return *p1++;
}

inline void read(int &x){
  char c=nc(),b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
const int N=3000005;

struct modi{  
  int x,y,r;  
}Stk[N]; int pnt;  
int fat[N],rnk[N],size[N];  
  
inline int Fat(int u){  
  return u==fat[u]?u:Fat(fat[u]);  
}

int cot[N];
int flag=0;

inline int Merge(int x,int y){  
  x=Fat(x); y=Fat(y); if (x==y) return 0;  
  if (rnk[x]>rnk[y]) swap(x,y);  
  Stk[++pnt].x=x; Stk[pnt].y=y; Stk[pnt].r=0;  
  if (rnk[x]==rnk[y]) rnk[y]++,Stk[pnt].r=1;  
  fat[x]=y; cot[size[y]]--; cot[size[x]]--; size[y]+=size[x]; cot[size[y]]++;
  if (size[y]>3) flag=1;
  return 1;  
}

inline void Back(int t){  
  for (;pnt>t;pnt--){
    int x=Stk[pnt].x,y=Stk[pnt].y;
    fat[Stk[pnt].x]=Stk[pnt].x;  
    if (Stk[pnt].r) rnk[Stk[pnt].y]--;
    cot[size[y]]--; size[y]-=size[x]; 
    cot[size[y]]++; cot[size[x]]++; 
  }  
}

const ll P=1e9+9;

ll fac[N],inv[N],iinv[N];

int tot;
int us[20],vs[20],ws[20];
int n,m;

inline ll Pow(ll a,int b){
  ll ret=1;
  for (;b;b>>=1,a=a*a%P)
    if (b&1)
      ret=ret*a%P;
  return ret;
}

inline void Pre(int n){  
  fac[0]=1; for (int i=1;i<=n;i++) fac[i]=fac[i-1]*i%P;
  inv[0]=1; for (int i=1;i<=n/3;i++) (inv[i]=inv[i-1]*6)%=P;
  for (int i=1;i<=n/3;i++) inv[i]=Pow(inv[i],P-2);
  iinv[1]=1; for (int i=2;i<=n;i++) iinv[i]=(P-P/i)*iinv[P%i]%P;  
  iinv[0]=1; for (int i=1;i<=n;i++) iinv[i]=iinv[i]*iinv[i-1]%P;  
}

inline ll Calc(int a,int b,int c){
  if (b>a) return 0;
  return fac[a]*inv[(a-b)/3]%P*iinv[(a-b)/3]%P;
}

int main(){
  read(n); read(m); n*=3;
  Pre(n);
  tot=0;
  for (int i=1;i<=n;i++) fat[i]=i,size[i]=1;
  flag=0; cot[1]=n;
  for (int i=1;i<=m;i++){
    ++tot;
    read(us[tot]),read(vs[tot]),read(ws[tot]);
    if (ws[tot]==0)
      Merge(us[tot],vs[tot]),tot--;      
  }
  if (flag){
    printf("0\n");
    return 0;
  }
  ll Ans=Calc(cot[1],cot[2],cot[3]);
  int tmp=pnt;
  for (int i=1;i<(1<<tot);i++){
    flag=0; int c=0;
    for (int j=1;j<=tot;j++)
      if (i>>(j-1)&1)
	Merge(us[j],vs[j]),c++;   
    if (!flag){
      if (c&1)
	(Ans+=P-Calc(cot[1],cot[2],cot[3]))%=P;
      else
	(Ans+=Calc(cot[1],cot[2],cot[3]))%=P;
    }
    Back(tmp);
  }
  printf("%lld\n",Ans);
  return 0;
}

Measured memory_bytes: 80704
#include<stdio.h>
int main()
{
int H,W;
int i,j;
for(;;)
{
 scanf("%d %d",&H,&W);
 if(H!=0&&W!=0)
 {
  for(i=1;i<=H;i++)
  {
   for(j=1;j<=W;j++)
   {
    if(i%2==1&&j%2==1||i%2==0&&j%2==0)
    {
     printf("#");
    }
    else if(i%2==1&&j%2==0||i%2==0&&j%2==1)
    {
     printf(".");
    }
   }
   printf("\n");
  }
  printf("\n");
 }
 else
 {
  break;
 }
}
return 0;
}

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



using namespace std;


int main(){
  int n;
  std::cin >> n;
  int S[100001];
  for(int i=0;i<n;i++){
    std::cin >> S[i];
  }
  int q;
  std::cin >> q;
  int T[50000];
  for(int i=0;i<q;i++){
    std::cin >> T[i];
  }

  int count=0;

  for(int i=0;i<q;i++){
    int left=0;
    int right=n;
    while (left<right) {
      int mid=(left+right)/2;
      if(S[mid]==T[i]){
        count++;
        break;
      }else if(T[i]<S[mid]){
        right=mid;
      }else if(T[i]>S[mid]){
        left=mid+1;
      }
    }
  }
  std::cout << count << '\n';
}



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

using namespace std;
using ll = long long;

int n, ma, mb;
vector<int> a, b, c;
int dp[50][410][410];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> ma >> mb;
  a = vector<int>(n);
  b = vector<int>(n);
  c = vector<int>(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  for (int i = 0; i < 410; i++) {
    for (int j = 0; j < 410; j++) {
      if (i > 0 && j > 0 && i * mb == j * ma) {
        dp[n][i][j] = 0;
      } else {
        dp[n][i][j] = 10000;
      }
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < 410; j++) {
      for (int k = 0; k < 410; k++) {
        dp[i][j][k] = min(dp[i + 1][j][k], dp[i + 1][j + a[i]][k + b[i]] + c[i]);
      }
    }
  }
  if (dp[0][0][0] >= 10000) {
    cout << -1 << endl;
  } else {
    cout << dp[0][0][0] << endl;
  }
  return 0;
}


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

int main(){
    int a,b;
    cin>>a>>b;
    if(a%3==0||b%3==0||(a+b)%3==0){
        cout<<"Possible"<<endl;
    }else{
        cout<<"Impossible"<<endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
	int i, j, N;
	char R[220], S[110], T[110], U[110], V[110];
	scanf("%d", &N);
	scanf("%s", &S);
	scanf("%s", &T);
//	printf("%s %s\n", S, T);

	memmove(R, S, N);
	for (i=0;i<N;i++) {
		memset(U, 0, 110);
		memset(V, 0, 110);
		memmove(U, R+i, N-i);
		memmove(V, T, N-i);
//		printf("%s %s\n", U, V);
		if (!strcmp(U,V)) {
			memmove(R+N, T+N-i, i);
			break;
		}
	}
	if (i == N) memmove(R+N, T, N);
	R[N+i] = '\0'; 

//	printf("%s\n", R);
	printf("%d\n", strlen(R));

	return 0;
}

Measured memory_bytes: 128
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


int main(){
    string s;
    cin>>s;
    stack<char> S;
    for(auto &I:s){
        if(I=='T' && !S.empty() && S.top()=='S'){S.pop();}
        else{S.push(I);}
    }
    cout<<S.size()<<endl;
    
    
    return 0;
}


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

int main(void) {
	int D, E;
	while (scanf("%d%d", &D, &E) == 2 && (D > 0 || E > 0)) {
		int x;
		double answer = -1;
		for (x = 0; x <= D; x++) {
			int y = D - x;
			double cost = sqrt(x * x + y * y);
			double score = fabs(cost - E);
			if (answer < 0 || score < answer) answer = score;
		}
		printf("%.15f\n", answer);
	}
	return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<int>> imos(1005, vector<int>(1005, 0));
    for (int n = 0; n < N; ++n){
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        ++imos[x1][y1];
        --imos[x1][y2];
        --imos[x2][y1];
        ++imos[x2][y2];
    }
    for (int i = 0; i < imos.size(); ++i) for (int j = 1; j < imos[0].size(); ++j) imos[i][j] += imos[i][j - 1];
    for (int j = 0; j < imos[0].size(); ++j) for (int i = 1; i < imos.size(); ++i) imos[i][j] += imos[i - 1][j];
    int max_overlap = 0;
    for (int i = 0; i < imos.size(); ++i) for (int j = 0; j < imos[0].size(); ++j) max_overlap = max(max_overlap, imos[i][j]);
    cout << max_overlap << endl;
    return 0;
}

Measured memory_bytes: 6784
#include<cstdio>
#include<algorithm>
typedef long long LL;
const int N=32768,md=998244353;
int A,B,a[N],W[N],rev[N],lim,b[N],fac[N],iv[N],ans;
char s[N],t[N];
inline void upd(int&a){a+=a>>31&md;}
inline int pow(int a,int b){
	int ret=1;
	for(;b;b>>=1,a=(LL)a*a%md)if(b&1)ret=(LL)ret*a%md;
	return ret;
}
void init(int n){
	int l=-1;
	for(lim=1;lim<n;lim<<=1)++l;
	for(int i=1;i<lim;++i)rev[i]=(rev[i>>1]>>1)|((i&1)<<l);
}
void FFT(int*b,const int&f){
	static unsigned long long a[N];
	for(int i=0;i<lim;++i)a[i]=b[rev[i]];
	for(int i=1;i<lim;i<<=1)
	for(int j=0;j<lim;j+=i<<1)
	for(int k=0;k<i;++k){
		const unsigned long long x=a[j+k],y=a[j+k+i]*W[i+k]%md;
		a[j+k]+=y,a[j+k+i]=x+md-y;
	}
	for(int i=0;i<lim;++i)b[i]=a[i]%md;
	if(!f){
		const int iv=pow(lim,md-2);
		for(int i=0;i<lim;++i)b[i]=(LL)b[i]*iv%md;
		std::reverse(b+1,b+lim);
	}
}
void pow(int*F,int*A,int b,int n){
	FFT(F,1),FFT(A,1);
	for(;b;b>>=1){
		if(b&1){
			for(int i=0;i<lim;++i)F[i]=(LL)F[i]*A[i]%md;
			FFT(F,0);
			for(int i=n;i<lim;++i)F[i]=0;
			FFT(F,1);
		}
		for(int i=0;i<lim;++i)A[i]=(LL)A[i]*A[i]%md;
		FFT(A,0);
		for(int i=n;i<lim;++i)A[i]=0;
		FFT(A,1);
	}
	FFT(F,0);
}
int main(){
	scanf("%s%s",s,t);
	for(int i=0;s[i];++i)
	if(s[i]=='1'&&t[i]=='1')++A;else
	if(s[i]=='1'&&t[i]=='0')++B;
	for(int i=1;i<N;i<<=1){
		const int w=pow(3,(md-1)/(i<<1));
		W[i]=1;
		for(int j=1;j<i;++j)W[i+j]=(LL)W[i+j-1]*w%md;
	}
	for(int i=*fac=1;i<=A+B+1;++i)fac[i]=(LL)fac[i-1]*i%md;
	iv[A+B+1]=pow(fac[A+B+1],md-2);
	for(int i=A+B;~i;--i)iv[i]=(i+1LL)*iv[i+1]%md;
	*a=1;
	for(int i=0;i<=A;++i)b[i]=iv[i+1];
	init(A+1<<1);
	pow(a,b,B,A+1);
	for(int i=0;i<=A;++i)upd(ans+=a[i]-md);
	ans=(LL)ans*fac[A]%md*fac[B]%md*fac[A+B]%md;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main(){
	string str;
	while(getline(cin, str)){
		while(1){
			for(int i=0; i<(int)str.length(); i++){
				if('a' <= str[i] && str[i] <'z'){
					str[i]++;
				}else if(str[i]=='z'){
					str[i]='a';
				}
			}
			if(str.find("this")==string::npos && str.find("that")==string::npos && str.find("the")==string::npos){
				continue;
			}
			cout << str << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3164
k=int(input(''))
a=[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]
print(a[k-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    cout << n * n * n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N;
  cin>>N;
  vector<ll> A(N);
  for(ll i=0;i<N;i++) {
cin>>A[i];
  }
  
  set<ll> S;
  ll B=1;
  ll count=0;
  for(ll i=0;i<N;i++) {
    if(B==2) {
cout<<count<<endl;
    return 0;
    }
    B=A[B-1];
    count++;
  }
  cout<<-1<<endl;
}
 
    
    
    
    
    


Measured memory_bytes: 3972
#!/usr/bin/env python3
ans = [0] * 10
ans[1] = '1'
for i in range(2, 10):
    ans[i] = str(i)
alpha = "0123456789"
def dfs(s):
    if len(s) == N:
        ans.append(s)
        if len(ans) >= 100001:
            return
    else:
        for c in range(int(s[-1])-1,int(s[-1])+2):
            if c >= 0:
                dfs(s+str(c))
            if c == 9:
                break
K = int(input())
N = 2
while len(ans) < 100001:
    for i in range(1, 10):
        dfs(str(i))
        if len(ans) >= 100001:
            break
    N+=1

print(ans[K])

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

int main()
{
  int N, A, count=0;
  cin >> N;
  
  for(int i=0; i<N; i++)
  {
    cin >> A;
    int countA = 0;
    while(A%2==0)
    {
      A /= 2;
      countA++;
    }
    if(i==0)count = countA;
    else if(count>countA) count = countA;
  }
  cout << count <<endl;
}
    


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    vector<int> a(5);
    int k;
    rep(i,0,4)cin>>a[i];
    cin>>k;
    sort(a.begin(),a.end());
    if(a[4]-a[0]<=k) cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
    return 0;
}

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

using namespace std;
#define ll  long long
#define ld  long double

#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN=1e5 + 5;
int main()
{
    FAST
   int n;
   cin>>n;
   int arr[n];
   for(int i=0;i<n;i++)
    cin>>arr[i];
   int last=arr[0];
   int ans=1;
   for(int i=1;i<n;i++)
   {
       if(arr[i]>=last)
       {
           ans++;
           last=arr[i];
       }
   }
   cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int N, g, output = 1;
  scanf("%d %d", &N, &g);
  for(int i = 0; i < N; i++) {
    (output+g > output*2) ? output *= 2 : output += g;
  }
  printf("%d\n", output);
  return 0;
}

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

using namespace std;

int N, K, ans, vol[2018], old[2018], dp[2018][2018];
const int INF = 1e6;
vector < int > v[2018];

void solve (int nod, int tata)
{
    dp[nod][0] = 0, dp[nod][1] = -INF, vol[nod] = 1;
    for (auto it : v[nod])
        if (it != tata)
        {
            solve (it, nod);
            for (int i=0; i<=vol[nod]; i++)
                old[i] = dp[nod][i];
            for (int i=0; i<=vol[nod] + vol[it]; i++)
                dp[nod][i] = INF;
            for (int i=0; i<=vol[nod]; i++)
                for (int j=0; j<=vol[it]; j++)
                    if (old[i] + dp[it][j] + 1 <= K)
                        dp[nod][i + j] = min (dp[nod][i + j], max (old[i], dp[it][j] + 1));
            vol[nod] += vol[it];
        }
    for (int j=0; j<=vol[nod]; j++)
        if (dp[nod][j] <= K)
            ans = min (ans, j + N - vol[nod]);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &K), ans = N;
for (int i=1; i<N; i++)
{
    int x, y;
    scanf ("%d %d", &x, &y);
    v[x].push_back (y);
    v[y].push_back (x);
}
solve (1, -1);
printf ("%d\n", ans);
return 0;
}


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

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void){

    int N;

    cin>>N;


    vector<int> tmp_vec(2);
    vector<vector<int>> D(N,tmp_vec);


    for(int i=0;i<N;i++){
        cin>>D[i][0]>>D[i][1];
    }

    for(int i=0;i<N-2;i++){
        if(D[i][0]==D[i][1]){
            if(D[i+1][0]==D[i+1][1]){
                if(D[i+2][0]==D[i+2][1]){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }


    cout<<"No"<<endl;

    return 0;
}



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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){

  int x;
  cin >> x;
  bool flag = false;
  for(int i = 1;i <= 10000;i++){
    int a = x-100*i;
    if(a < 0)continue;
    if(5*i >= a)flag = true;
  }
  flag ? cout << 1 << endl : cout << 0 << endl;

  


  

  return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= int(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(c) begin(c), end(c)
#define MSG(a) cout << a << endl;

template <typename T>
using vec = std::vector<T>;
using vi = vec<int>;
using vvi = vec<vi>;
using pii = std::pair<int, int>;
using ll = long long;
using ld = long double;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  int K;
  cin >> K;
  MSG((K / 2) * (K - K / 2));
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  static int p = 1000000007;
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int Y = sc.nextInt();
    int Z = X+Y;
    int d = Z/3;
    int e = (d-Math.abs(X-Y))/2;
    
    //Zが3の倍数でなければ不適、eが0未満でも不適
    if(Z%3 != 0 || e < 0){
      System.out.println(0);
      return;
    }

    //C(d,e)を求める前準備
    long A = 1; // d!/(d-e)!
    long B = 1; // e!
    for(int i = 0; i < e; i++){
      A *= d-i;
      A %= p;
      B *= e-i;
      B %= p;
    }
    //直接割ることはできないのでinvメソッドで逆元を求めて掛け算
    long ans = A * inv(B, p-2) % p;
    System.out.println(ans);
  }
  // 1/n ≡ n^p-2(mod p)を求める（二分累乗法）
  public static long inv(long n, int k){
    if(k == 0){
      return 1;
    }
    
    if(k%2 == 0){
      long l = inv(n, k/2);
      return l * l % p;
    }else{
      return n * inv(n, k-1) % p;
    }
  }
}


Measured memory_bytes: 23764
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val s = inputs(0)
  val t = inputs(1)

  println(solve(s, t))

  def solve(s: String, t: String): Int = {
    val size  = s.size
    var count = 0
    (0 until size).foreach { i =>
      if(s(i) != t(i)) {
        count = count + 1
      }
    }
    return count
  }
}

Measured memory_bytes: 57208
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
 
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;
 
// /////////////////////////////////////////////
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
// ////////////////////////////////
 
#define int long long

void solve(){

	int n;
	cin>>n;
	int root = sqrt(n);
	int ans = 1;
	set<int> s;
	if(n==2){

		cout<<1<<endl;
		return ;
	}
	for(int i = 2 ; i <= root ; ++i){

		int x = n;
		while(x%i==0){

			x/=i;
		}

		if(x%i==1){
			++ans;
			s.insert(i);
		}
	}
	//debug(ans);
	root = sqrt(n-1);
	--n;
	for(int i = 2 ; i <= root ; ++i){

		if(n%i==0){
			ans++;
			if(s.find(i)!=s.end())
				--ans;
			if(n/i!=i){
				++ans;
				if(s.find(n/i)!=s.end())
					--ans;
			}
		}
	}
	ans++; // for n-1


	cout<<ans<<endl;
}
 
 
signed main(){
 
    fast;
    int t = 1;
    //cin>>t;
    for(int i = 1 ; i <= t; ++i){
 
    	solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
std::map<long long, long long> m;
long long k;
long long n, a, b;
std::vector<std::pair<long long, long long>> vec;

int main() {
    std::cin >> n >> k;
    for (long long i = 0; i < n; i++) {
        std::cin >> a >> b;
        m[a] += b;
    }
    
    for (auto e: m) {
        vec.push_back(e);
    }
    std::sort(vec.begin(), vec.end());
    long long sum = 0;
    for (long long i = 0; i < vec.size(); i++) {
        sum += vec[i].second;
        if (k <= sum) {
            std::cout << vec[i].first << std::endl;
            return 0;
        }
    }
}


Measured memory_bytes: 5368
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;

    ll a[x], b[y], c[z];
    REP(i, x){
        cin >> a[i];
    }
    REP(i, y){
        cin >> b[i];
    }
    REP(i, z){
        cin >> c[i];
    }

    sort(a, a+x, greater<ll>());
    sort(b, b+y, greater<ll>());
    sort(c, c+z, greater<ll>());

    vector<ll> ab;
    REP(i, x){
        REP(j, y){
            ll res = a[i] + b[j];
            ab.push_back(res);
        }
    }

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

    vector<ll> abc;
    REP(i, min(x*y, 3001)){
        REP(j, z){
            ll res = ab[i] + c[j];
            abc.push_back(res);
        }
    }

    sort(abc.rbegin(), abc.rend());
    REP(i, k){
        cout << abc[i] << endl;
    }
}

Measured memory_bytes: 44112
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

ll dp[1010][1 << 13];

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

	int N, M;
	cin >> N >> M;
	for (int i = 0; i < 1010; i++) {
		for (int j = 0; j < (1LL<<13); j++) {
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;

	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		ll temp = 0;
		for (int j = 0; j < b; j++) {
			int p;
			cin >> p;
			p--;
			temp += 1LL << p;
		}
		for (int j = 0; j < (1LL << N); j++) {
			if (dp[i][j] == inf)continue;
			dp[i+1][j|temp]=min(dp[i][j] + a,dp[i+1][j|temp]);
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
		}
	}


	ll temp = 0;
	for (int i = 0; i < N; i++)temp += (1LL << i);
	if (dp[M][temp] == inf)puts(-1);
	else puts(dp[M][temp]);
	return 0;
}

Measured memory_bytes: 65024
N, H = list(map(int, input().split()))

swing = []
throw = []

for _ in range(N):
    a, b = list(map(int, input().split()))
    swing.append(a)
    throw.append(b)

max_swing = max(swing)
throw = sorted(throw, reverse=True)
throw = (list)(filter(lambda x: x > max_swing, throw))

attack_co = 0
for d in throw:
    H -= d
    attack_co += 1
    if H <= 0:
        break

if H >= 0:
    attack_co += ((-H)//max_swing)*(-1)


print(attack_co)


Measured memory_bytes: 67416
// Code by Nguyen Huu Lam
#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL MaxN = 1 + 1e5;

LL n, a[MaxN], kq = 1e18;

void InOut(){
    #define TASK "ABC"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
}

int main(){
    // InOut();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(LL i = 1 ; i * i <= n ; ++i)
    if(n % i == 0) kq = min(kq, i + n / i);
    cout << kq - 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int A[3][3];
    int N;
    rep(i,3) rep(j,3) cin >> A[i][j];
    cin >> N;
    int b[N];
    rep(i,N) cin >> b[i];

    rep(k,N) {
        rep(i,3) rep(j,3) {
            if (A[i][j] == b[k]) A[i][j] = 0;
        }
    }

    bool check = false;
    rep(i,3) if (A[i][0] == 0 && A[i][1] == 0 && A[i][2] == 0) check = true;
    rep(i,3) if (A[0][i] == 0 && A[1][i] == 0 && A[2][i] == 0) check = true;
    if (A[0][0] == 0 && A[1][1] == 0 && A[2][2] == 0) check = true;
    if (A[2][0] == 0 && A[1][1] == 0 && A[0][2] == 0) check = true;

    cout << (check ? "Yes" : "No") << endl;

    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
if (a>=b && a>=c) {
printf("%d", (a*10 + b + c));
} else if (b >= c && b >= a) {
printf("%d", (b*10 + a + c));
} else if (c >= a, c >= b) {
printf("%d", (c*10 + a + b));
}
return 0;
}

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

int main() {
  	char S;
  	cin >> S;
  	if(S=='a'||S=='e'||S=='i'||S=='o'||S=='u'){
			cout<<"vowel"<<endl;
		}else{
			cout<<"consonant"<<endl;
		}
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(10);
	ll a,b,n;
	cin>>a>>b>>n;
	ll m=(n/b)*b-1;
	ll ans1=((a*m)/b)-a*(m/b);
	ll ans=((a*n)/b)-a*(n/b);
	cout<<max(ans,ans1);
	return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
 
#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define PER(i, N) for(int (i) = (N)-1; (i) >= 0; (i)--)
#define REP(i, N) for(int (i) = 0; (i) < (int)(N); (i)++)
 #include <iomanip>
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

int w,s;

void solve(istream& cin, ostream& cout) {
	int k,a,b;
	cin >>k>>a>>b;
	for(int i =a; i<=b;i++)
		if(i%k == 0)
		{
			cout << "OK"<<endl;
			return;
		}
	cout <<"NG"<<endl;
}


int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	solve(cin, cout);
	/*
	{
		istringstream instr("2\n2\n14");
		solve(instr, cout);
	}
 */
	return 0;
}


Measured memory_bytes: 3168
#include<string>
#include<iostream>
using namespace std;
int b[26];
int main(){
    string a,b,c;
    cin>>a>>b;
    c = a + a;
    for(int i=0;i<a.size();i++){
        if(b==c.substr(i,b.size())){
            cout<<"Yes"<<endl;
            goto Exit;
        }
    }
    cout<<"No"<<endl;
    Exit:;
    return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  int n;
  cin >> n;
  vector<int> human(100000,0);
  rep(i,n){
    int l,r;
    cin >> l >> r;
    --l;--r;
    human.at(l) ++;
    if(r+1==100000);
    else human.at(r+1) --;    
  }
  vector<int> imos(100000,0);
  imos.at(0) = human.at(0);
  for(int i=1;i<100000;i++) imos.at(i) = imos.at(i-1) + human.at(i);
  int cnt = 0;
  rep(i,100000){
    if(imos.at(i) > 0) cnt ++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1024
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String result;
		int total;
		while(true){
			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			if((m == -1) && (f == -1) && (r == -1)){
				break;
			}
			total = m + f;
			if ((m * f < 0)){
				result = "F";
			} else if (total >= 80){
				result = "A";
			} else if (total >= 65){
				result = "B";
			} else if (total >= 50){
				result = "C";
			} else if (total >= 30){
				if (r >= 50){
					result = "C";
				}
				else {
					result = "D";
				}
			} else {
				result = "F";
			}
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 19260
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  while(n>0){
    if(n%10==7){
      cout << "Yes";
      return 0;
    }
    n=n/10;
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
    int n, y;
    cin >> n >> y;
    int a, b, c;
    bool isFind = false;
    for (int i=0; i<=n; ++i){
        if(isFind){break;}
        for (int j=0; j<=n; ++j){
            a = i;
            b = j;
            c = n - a - b;
            if(0 <= c && c <= n && 10000 * a + 5000 * b + 1000 * c == y){
                cout << a << " " << b << " " << c << endl;
                isFind = true;
                break;
            }
        }
    }
    if(!isFind){
        cout << "-1 -1 -1" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int n;
	cin >> n;
	ll m = 0, a = 0, r = 0, c = 0, h = 0;
	rep(i, n) {
		string s;
		cin >> s;
		if (s[0] == 'M') m++;
		else if (s[0] == 'A') a++;
		else if (s[0] == 'R') r++;
		else if (s[0] == 'C') c++;
		else if (s[0] == 'H') h++;
	}
	ll ans = 0;
	ans += m * a * r;
	ans += m * a * c;
	ans += m * a * h;
	ans += m * r * c;
	ans += m * r * h;
	ans += m * c * h;
	ans += a * r * c;
	ans += a * r * h;
	ans += a * c * h;
	ans += r * c * h;
	cout << ans << endl;
}

Measured memory_bytes: 384