akhauriyash/Code-Regression huggingface dataset:
//
//  ARC085C.cpp
//  
//
//  Created by Yoshida Satoshi on 2017/11/11.
//
//

#include <iostream>
using namespace std;

int main(){
    int N,M;
    cin>>N>>M;
    long X;
    int t=100*N+1800*M;
    int p=1;
    for(int i=0;i<M;i++)    p*=2;
    X=p*t;
    
    cout<<X<<endl;
    
    return 0;
}


Measured memory_bytes: 256
// C - Sugar Water

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

const int MAX = 4000;
bool dp[MAX][MAX]; // dp[a][b]: 水i(g), 砂糖j(g)の組み合わせがあれば1

int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;

	set<int> water;
	set<int> sugar;

	for (int i=0; i*100*A<=F; i++) {
		for (int j=0; j*100*B<=F; j++) {
			if ((i*100*A + j*100*B != 0) && (i*100*A + j*100*B <= F)) {
				water.insert(i*100*A + j*100*B);
			}
		}
	}

	for (int i=0; i*C<=F; i++) {
		for (int j=0; j*D<=F; j++) {
			if (i*C + j*D <= F) {
				sugar.insert(i*C + j*D);
			}
		}
	}

	int ans_w = 100*A;
	int ans_s = 0;
	for (int w : water) {
		for (int s : sugar) {
			if (s * (100 + E) > E * (w + s)) continue;
			if (w + s > F) continue;

			if (s * (ans_w + ans_s) > ans_s * (w + s)) {
				ans_w = w;
				ans_s = s;
			}
		}
	}

	cout << ans_w + ans_s << " " << ans_s << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll n,k;cin>>n>>k;
	vl vec(n);
	rep(i,0,n) cin>>vec[i];
	sort(all(vec));
	ll ans=MOD;
	rep(i,0,n){
		if(i+k-1>=n) break;
		chmin(ans,vec[i+k-1]-vec[i]);
	}
	cout<<ans;
	
	return 0;
}

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

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	vector<ll> f(n);
	for (ll i = 0; i < n; ++i)cin >> a[i];
	for (ll i = 0; i < n; ++i)cin >> f[i];
	sort(a.begin(), a.end());
	sort(f.rbegin(), f.rend());
	ll Min = -1;
	ll Max = 1e15;
	while (Max - Min > 1) {
		ll Mid = (Min + Max) / 2;
		ll cnt = 0;
		for (ll i = 0; i < n; ++i) {
			cnt += max(0ll, a[i] - Mid / f[i]);
		}
		if (cnt > k)Min = Mid;
		else Max = Mid;
	}
	cout << Max << endl;
}


Measured memory_bytes: 6356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353 
#define INF 1e9
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,i,j,k,t,l;
    cin>>n;
    int a[n+5];
    multiset <ll> m;
    multiset <ll> :: iterator it;
    for(i=0;i<n;i++){
    	cin>>a[i];
    	it  = m.lower_bound(a[i]);
    	if( it == m.begin()){
    		m.insert(a[i]);
		}else{
			it--;
			m.erase(it);
			m.insert(a[i]);
	   }
	}
    cout<<m.size()<<endl;
 }

Measured memory_bytes: 5376
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,len,j;
	char s[20];
	scanf("%s",s);
    len=strlen(s);
	for(i=len-1;i>=0;i--){
	    printf("%c",s[i]);
	}
	    printf("\n");
}


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

typedef long long ll; 

int main(){
    int n; cin>>n; int a[n]; for(int i=0;i<n;i++) cin>>a[i]; sort(a,a+n); 
    int x=a[n-1]; 
    int l=x/2,r=x/2+x%2; 
    int y; 
    ll d=100000000000000; 
    for(int i=0;i<n-1;i++) { 
        ll dd=min(abs(a[i]-l),abs(a[i]-r)); 
        if(dd<d){ d=dd; y=a[i]; }
    }
    cout<<x<<" " <<y; 

	return 0; 
}



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


int main()
{
    int w,h,x,y,r;
    bool a,b;
    cin >> w >> h >> x >> y >> r;
    //縦
    if(((x - r) >= 0) && (w >= (x + r))){
        a = true;
    }else if(((x - r) < 0) || (w < (x + r))){
        a = false;
    }else{
        a = false;
    }
    //横
    if(((y - r) >= 0) && (h >= (y + r))){
        b = true;
    }else if(((y - r) < 0) || (h < (y + r))){
        b = false;
    }else{
        b = false;
    }
    if((a == true) && (b == true)){
        cout << "Yes" << endl;
    }else{
        cout <<"No" << endl;
    }
    
}



Measured memory_bytes: 3096
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  vvi v(n, vi(3)), dp(n + 1, vi(3, 0));
  rep(i, n) cin >> v[i][0] >> v[i][1] >> v[i][2];
  rep(i, n){
    rep(j, 3){
      rep(k, 3){
        if(j != k) dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + v[i][j]);
      }
    }
  }
  int ans = 0;
  rep(i, 3) ans = max(ans, dp[n][i]);
  cout << ans << endl;
}

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

int main() {
  ll count = 0;
  string s,t;
  cin >> s >> t;
  ll n;
  n = s.size();
  rep(i,n){
    if(s[i] != t[i]){
      count++;
    }
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 3916
from collections import deque
n,q = map(int,input().split())
l =  [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    l[a].append(b)
    l[b].append(a)

value = [0 for _ in range(n)]
for _ in range(q):
    p,q = map(int,input().split())
    value[p-1] += q

bit = [0 for _ in range(n)]
"""
def dfs(k):
    bit[k] = 1
    for i in l[k]:
        if bit[i]==0:
            value[i] += value[k]
            dfs(i)
"""
d = deque([0])
while d:
    a = d.popleft()
    bit[a] = 1
    for i in l[a]:
        if bit[i]==0:
            d.append(i)
            value[i] += value[a]
        

print(*value)


Measured memory_bytes: 129496
using System;
using System.Linq;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] tmpLine = Console.ReadLine()
                                    .Split(' ')
                                    .Select(s => int.Parse(s))
                                    .ToArray();
            int N = tmpLine[0];
            int K = tmpLine[1];
            int Q = tmpLine[2];
            int[] countAns = new int[N];
            for (int i = 0; i < Q; i++)
            {
                countAns[int.Parse(Console.ReadLine()) - 1]++;
            }
            for (int i = 0; i < N; i++)
            {
                // Q - ans < K
                Console.WriteLine(countAns[i] > Q - K? "Yes" : "No");
            }

        }
    }
}


Measured memory_bytes: 17884
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
typedef pii point;
using namespace std;
const ll INF = (1ll<<32);
const ll MOD = 1000000007;

int main() {
  ll n; cin>>n;
  vi a(n); REP(i,n) cin>>a[i];
  vi b(n); REP(i,n) cin>>b[i];
  ll ans=0;
  REP(i,30) {
    vi ac=a,bc=b;
    REP(j,n) ac[j]%=(1ll<<(i+1));
    REP(j,n) bc[j]%=(1ll<<(i+1));
    sort(bc.begin(),bc.end());
    ll cnt=0;
    REP(j,n) {
      ll s1=(1ll<<i)-ac[j]%(1ll<<(i+1));
      ll t1=(1ll<<(i+1))-ac[j]%(1ll<<(i+1));
      ll s2=(1ll<<(i+1))+(1ll<<i)-ac[j]%(1ll<<(i+1));
      ll t2=(1ll<<(i+2))-ac[j]%(1ll<<(i+1));
      cnt+=lower_bound(bc.begin(),bc.end(),t1)-lower_bound(bc.begin(),bc.end(),s1);
      cnt+=lower_bound(bc.begin(),bc.end(),t2)-lower_bound(bc.begin(),bc.end(),s2);
    }
    if(cnt%2) ans+=(1ll<<i);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6552
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll v,e,s,t,d,g[105][105]={},f=0;
  cin >> v >> e;
  for(int i=0; i<v; i++) {
    for(int j=0; j<v; j++) {
      if(i!=j) {
        g[i][j]=INF;
      }
    }
  }
  for(int i=0; i<e; i++) {
    cin >> s >> t >> d;
    g[s][t]=d;
  }
  for(int i=0; i<v; i++) {
    for(int j=0; j<v; j++) {
      for(int k=0; k<v; k++) {
        g[j][k]=min(g[j][k],g[j][i]+g[i][k]);
      }
    }
  }
  for(int i=0; i<v; i++) {
    if(g[i][i]<0) {
      f=1;
    }
  }
  if(f) {
    cout << "NEGATIVE CYCLE" << endl;
    return 0;
  }
  for(int i=0; i<v; i++) {
    for(int j=0; j<v; j++) {
      if(g[i][j]>INF/2) {
        cout << "INF";
      }
      else {
        cout << g[i][j];
      }
      if(j!=v-1) {
        cout << " ";
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 3304
#include<bits/stdc++.h>
using namespace std;
int n,k;
int d[100100];
int a[100100];
int qjh[100100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		scanf("%1d",&d[i]);
	}
	for(int i=1;i<=n;i++)
		a[i]=(d[i]^d[i-1]);
	for(int i=1;i<=n;i++)
		qjh[i]=a[i]+qjh[i-1];
	int res=0;
	int b=0;
	for(int i=1;i<=n;i++){
		b^=a[i];
		int val=upper_bound(qjh+1,qjh+n+1,k*2-(!b)+qjh[i])-qjh;
		res=max(res,val-i);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int par[100000+10],n,m,x,y,p,q,sz[100000+10];
long long res[100000+100];
pair<int,int> a[100000+100];
int parent(int x)
{
if(par[x]==x)return x;
return parent(par[x]);

}
void add(int x,int y)
{
        if(sz[x]>sz[y])
        {
           add(y,x); return ;
        }
        par[x]=y;
        sz[y]+=sz[x];
}
int main()
{

  cin>>n>>m;
  for(int i=1;i<=m;i++){
   cin>>x>>y;
   a[i].first=x;
   a[i].second=y;
  }


  for(int i=1;i<=n;i++){par[i]=i; sz[i]=1;}

  for(int i=m;i>0;i--)
  {
    x=a[i].first;y=a[i].second;

     p= parent(x); q=parent(y);

     if(p==q) {res[i]=0; continue;}
     res[i]= 1LL*sz[p]*sz[q];
     add(p,q);


  }
   res[0]=0LL;
  for(int i=1;i<=m;i++){
     res[i]+=res[i-1];
  cout<<res[i]<<endl;}
}


Measured memory_bytes: 3712
#include <cstdio>
#include <iostream>
#include <cstring>
#include <map>
#include <vector>
#include <vector>
#include <unordered_map>

#define X first
#define Y second

using namespace std;

typedef pair < int, int> pii;
typedef pair < pii, int> pi;
typedef map < pii, int > mpi;

const int N = 1e5 + 500;
const int INF = 0x3f3f3f3f;

int a[N],n;

mpi solve(int l,int r){
    if(l  == r){
        mpi ret;
        int cnt = 0;
        while(a[l] >= (1 << cnt)) cnt++;
        cnt--;
        if(a[l] == (1 << cnt)){
            ret[{cnt, cnt}] = cnt;
        }
        else{
            ret[{cnt, cnt + 1}] = cnt + 1;
            ret[{cnt + 1, cnt}] = cnt + 1;
        }
        return ret;
    }
    int mid = (l + r) / 2;
    mpi p1 = solve(l, mid), p2 = solve(mid + 1, r), ret;
    for(pi x : p1){
        for(pi y : p2){
            int sol = x.Y + y.Y - min(x.X.Y, y.X.X);
            if(ret.count({x.X.X, y.X.Y})){
                ret[{x.X.X, y.X.Y}] = min(ret[{x.X.X, y.X.Y}], sol);
            }
            else{
                ret[{x.X.X, y.X.Y}] = sol;
            }
        }
    }
    return ret;
}

int main(){
    scanf("%d", &n);
    for(int i = 0;i<n;i++){
        scanf("%d", a + i);
    }
    mpi sol = solve(0, n - 1);
    int fin = INF;
    for(pi x : sol)
        fin = min(fin, x.Y);
    printf("%d\n", fin);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/rope>
using namespace std;
using namespace __gnu_cxx;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ii, ii> iii;
int MOD = 1e9 + 9;
const ld E = 1e-7;
#define null NULL
#define ms(x) memset(x, 0, sizeof(x))
#ifndef LOCAL
#define endl "\n"
#endif
#ifndef LONG_LONG_MAX
#define LONG_LONG_MAX LLONG_MAX
#endif
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define _read(x) freopen(x, "r", stdin)
#define _write(x) freopen(x, "w", stdout)
#define files(x) _read(x ".in"); _write(x ".out")
#define filesdatsol(x) _read(x ".DAT"); _write(x ".SOL")
#define output _write("output.txt")
#define input _read("input.txt")
#define prev time_prev
#ifndef M_PI
#define M_PI acos(-1)
#endif
#define remove tipa_remove
#define next tipa_next
#define left tipa_left
#define right tipa_right
#define mod % MOD
#define y1 hello_world
unsigned char ccc;
bool _minus = false;
template<typename T>
inline T sqr(T t) {
	return (t * t);
}
inline void read(ll &n) {
	n = 0;
	_minus = false;
	while (true) {
		ccc = getchar();
		if (ccc == ' ' || ccc == '\n')
			break;
		if (ccc == '-') {
			_minus = true;
			continue;
		}
		n = n * 10 + ccc - '0';
	}
	if (_minus)
		n *= -1;
}
inline bool read(int &n) {
	n = 0;
	_minus = false;
	while (true) {
		ccc = getchar();
		if (ccc == ' ' || ccc == '\n') {
			if (ccc == '\n')
				return true;
			break;
		}
		if (ccc == '-') {
			_minus = true;
			continue;
		}
		n = n * 10 + ccc - '0';
	}
	if (_minus)
		n *= -1;
	return false;
}
char wwww[19];
int kkkk;
inline void write(ll y) {
	long long x = y;
	kkkk = 0;
	if (x < 0) {
		putchar('-');
		x *= -1;
	}
	if (!x)
		++kkkk, wwww[kkkk] = '0';
	else
		while (x) {
			++kkkk;
			wwww[kkkk] = char(x % 10 + '0');
			x /= 10;
		}
	for (int i = kkkk; i >= 1; --i)
		putchar(wwww[i]);
}
#ifdef LOCAL
//#define DEBUG
#endif
#ifdef DEBUG
#define dbg if(1)
#else
#define dbg if(0)
#endif

int main() {
	sync;
	srand(time(NULL));
	cout.precision(10);
	cout << fixed;
#ifdef LOCAL
	input;
#else

#endif

	int n;
	cin >> n;

	ll sum = 0;
	ll ans = 1e18;

	vector<int> v(n);
	for(int &a : v){
		cin >> a;
		sum += a;
	}
	ll s = 0;
	for(int i = 0; i + 1 < n; i++){
		s += v[i];
		sum -= v[i];
		ans = min(ans, abs(s - sum));
	}

	cout << ans << endl;

}


Measured memory_bytes: 1024
// A.

#include <iostream>
#include <sstream>

using namespace std;

int main(int argc, char *argv[])
{
	int a, b;
	string op;
	cin >> a >> op >> b;
	int ans = op == "+" ? (a + b) : (a - b);
	cout << ans << endl;
	return 0;
}


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

int main(){
  int N, X;
  cin >> N >> X;
  
  int m_tmp, m_min=1000;
  int retval = 0;
  for (int i=0;i<N;i++){
    cin >> m_tmp;
    if (m_tmp<m_min) m_min = m_tmp;
    X -= m_tmp;
    retval++;
  }
  
  retval += X/m_min;
  cout << retval << endl;

}

  
  

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define rep(i, s, t) for(i = s; i <= t; ++i)
#define dep(i, s, t) for(i = s; i >= t; --i)

using namespace std;

typedef long long LL;
int n, k;
LL ans;

int main() {
	int i, j, l, r;
	scanf("%d%d", &n, &k);
	rep(i, k+1, n)
		for(l = k, r = i-1; l <= n; l += i, r += i) ans += (LL)min(r, n) - max(l, 1) + 1;
	printf("%lld\n", ans);
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

vector<vector<int>> edges;
vector<int> prv;
vector<bool> vis;
vector<int> t0, t1;

void print(int u, int v){
    vector<int> a;
    a.push_back(v);
    u = v;
    do{
        int vv = -1;
        int tt = 0;
        for(int v2 : edges[u]){
            if (vv == -1 || t0[v2] > tt){
                tt = t0[v2];
                vv = v2;
            }
        }
        if (vv == v)
            break;
        a.push_back(vv);
        u = vv;
    }while(1);
    cout << a.size() << endl;
    for(int ai : a)
        cout << ai << endl;
    exit(0);
}

bool dfs(int u, int& t){
    vis[u] = 1;
    t0[u] = ++t;
    int vv = -1, t0v = 0;
    for(int v : edges[u]) {
        if (t1[v])
            return false;
        if (t0[v] && !t1[v])
            if (vv == -1 || t0[v] > t0v) {
                t0v = t0[v];
                vv = v;
            }
    }
    if (vv!=-1)
        print(u, vv);
    for(int v : edges[u]){
        if (!vis[v]){
            prv[v] = u;
            if (!dfs(v, t))
                return false;
        }
    }
    t1[u] = ++t;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int N, M;
    cin >> N >> M;
    edges.resize(N+1);
    vis.resize(N+1); prv.resize(N+1);
    t0.resize(N+1); t1.resize(N+1);

    FOR(i, M){
        int u, v;
        cin >> u >> v;
        edges[u].push_back(v);
    }

    FOR1(u, N){
        vis.clear(); prv.clear();
        vis.resize(N+1); prv.resize(N+1);
        t0.clear(); t1.clear();
        t0.resize(N+1); t1.resize(N+1);
        int t = 0;
        dfs(u, t);
    }
    cout << -1 << endl;


    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

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

using namespace std;


int main(){
    int len_set1,len_set2;
    int temp;
    set<int> set_array1;
    set<int> set_array2;
    set<int> union_set;

    scanf("%d",&len_set1);
    for(int i = 0; i < len_set1;i++){
        scanf("%d",&temp);
        set_array1.insert(temp);
    }
    scanf("%d",&len_set2);
    for(int i = 0; i < len_set2;i++){
        scanf("%d",&temp);
        set_array2.insert(temp);
    }

    set_union(set_array1.begin(),set_array1.end(),
              set_array2.begin(),set_array2.end(),
              inserter(union_set,union_set.end()));

    for(auto itr = union_set.begin();itr!=union_set.end();itr++){
        printf("%d\n",*itr);
    }
    return 0;   
}



Measured memory_bytes: 40656
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h> 
#define pb emplace_back
#define mp make_pair 
#define st first 
#define nd second 
#define all(v) v.begin(),v.end()
#define umap unordered_map
#define L nd<<1
#define R (L)|1
#define mid ((s + e)>>1)
#define ln '\n'
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
string s;
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);cout.tie(nullptr);cerr.tie(nullptr);
  cin >> s;
  for(char  c : s){
  	if(c == '7'){
  		cout << "Yes";
  		return 0;
  	}
	}
  cout << "No";
}

Measured memory_bytes: 3640
#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt
#include <sstream>	//stringstream,getline
#include <cmath>	//ceil

using namespace std;

int main() {

	int N;
	cin >> N;

	N = N % 10;
	string ans;

	switch (N) {
	case 0: ans = "pon"; break;
	case 1: ans = "pon"; break;
	case 2: ans = "hon"; break;
	case 3: ans = "bon"; break;
	case 4: ans = "hon"; break;
	case 5: ans = "hon"; break;
	case 6: ans = "pon"; break;
	case 7: ans = "hon"; break;
	case 8: ans = "pon"; break;
	case 9: ans = "hon"; break;
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 3572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace CODEFEST2016C {
    class Program {
        struct Cake {
            public string name;
            public int num;
            public Cake(int i, string str) {
                this.num = i;
                this.name = str;
            }
            public void setNum(int i) {
                num = i;
            }
        }
        static void Main(string[] args) {
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            int K = int.Parse(input[0]);
            int T = int.Parse(input[1]);
            // スペース区切りの整数の入力
            input = Console.ReadLine().Split(' ');
            var cakes = new List<Cake>();
            int Num = 0;
            for(var i = 0; i < input.Length; i++) {
                cakes.Add(new Cake(int.Parse(input[i]), i.ToString()));
                if(cakes[i].num > 100)
                    return;
                Num += cakes[i].num;
            }

            if(Num != K || K < 1 || K > 10000 || T < 1 || T > 100) {
                return;
            }

            int Multiple = 0;
            string preEat = "-1";

            while(Num > 0) {
                cakes.Sort((b, a) => a.num.CompareTo(b.num));
                for(int i = 0; i < T; i++) {
                    if(eat(ref Num, ref cakes, ref preEat, ref i)) {
                        break;
                    }
                    if(i == T - 1) {
                        Cake tmp = cakes[0];
                        tmp.num--;
                        cakes[0] = tmp;
                        Num--;
                        Multiple++;
                        preEat = cakes[0].name;
                        break;
                    }
                }

            }
            Console.Write(Multiple);
        }
        static bool eat(ref int pNum, ref List<Cake> pCakes, ref string pPreeat, ref int t) {
            if(pPreeat != pCakes[t].name && pCakes[t].num > 0) {
                Cake tmp = pCakes[t];
                tmp.num--;
                pCakes[t] = tmp;
                pNum--;
                pPreeat = pCakes[t].name;
                return true;
            } else {
                return false;
            }
        }
    }
}


Measured memory_bytes: 7252
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
using namespace std;
const int INF = 2e9;
const ll INFLL = 4e18;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int main() {
	int n,ans=0;
	ll d,x,y;
	sd(n);slld(d);
	d*=d;
	for(int i = 1; i <= n; i++){
		slld(x);slld(y);
		x*=x;
		y*=y;
		ans+=((x+y)<=d);
	}
	pd(ans);
	return 0;
}

Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
using namespace std;

int main(){
  int n,ans=100000;
  cin>>n;
  for(int i=0;i<n;i++){
    ans*=1.05;
    ans=(ans+999)/1000*1000;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2984
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main(void) {
	int a, b;
	cin >> a >> b;
	if ((a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 || a == 12) && (b == 1 || b == 3 || b == 5 || b == 7 || b == 8 || b == 10 || b == 12)) {
		cout << "Yes";
		return 0;
	}
	else if ((a == 4 || a == 6 || a == 9 || a == 11) && (b == 4 || b == 6 || b == 9 || b == 11)) {
		cout << "Yes";
		return 0;
	}
	else if (a == 2 && b == 2) {
		cout << "Yes";
		return 0;
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cassert>
#include <tuple>
using namespace std;

// 中国剰余定理
// x = b_1 (mod_1), ..., x = b_k (mod_k), ... を満たす x を
// 0 <= x < lcm(mod_1, mod_2, ..., mod_k, ...) の範囲で求める

template <typename NumType, NumType LIMIT = NumType(1e10)>
struct CRT {
    pair<NumType, NumType> NIL;
    CRT() : NIL(-1, -1) {}
    
    NumType extgcd(NumType a, NumType b, NumType &p, NumType &q) {
        if(b == 0) {
            p = 1, q = 0;
            return a;
        }
        NumType d = extgcd(b, a%b, q, p);
        q -= a / b * p;
        return d;
    }

    pair<NumType, NumType> solve(NumType b1, NumType mod1, NumType b2, NumType mod2) {
        NumType p, q;
        NumType d = extgcd(mod1, mod2, p, q);
        
        if((b2 - b1) % d != 0) return NIL;
        NumType s = (b2 - b1) / d;
        NumType t = (s * p % (mod2 / d));

        // get lcm
        NumType lc = mod1 / d * mod2;
        NumType so = (b1 + mod1 * t) % lc;
        (so += lc) %= lc;
        return make_pair(so, lc);
    }

    // m, mod の vector をもらって、
    // CRT の解を (x, lcm(mod_1, mod_2, ..., mod_k, ...)) の形で返す
    pair<NumType, NumType> solve(vector<NumType> m, vector<NumType> mod) {
        assert(m.size() == mod.size());
        NumType so = 0, lc = 1;
        for(size_t i=0; i<m.size(); i++) {
            tie(so, lc) = solve(so, lc, m[i], mod[i]);
            if(so > LIMIT or so < 0) {
                return NIL;
            }
        }
        return make_pair(so, lc);
    }
};


void yuki_186() {
    using ll = long long int;
    vector<ll> b(3), mod(3);
    for(int i=0; i<3; i++) {
        cin >> b[i] >> mod[i];
    }

    CRT<ll, (ll)2e18> crt;
    auto ans = crt.solve(b, mod);
    cout << ans.first + (ans.first == 0 ? ans.second : 0) << endl;
}

void AOJ2659() {
    using ll = long long int;
    ll N, M, D; cin >> N >> M >> D;
    vector<int> A(M);
    for(int i=0; i<M; i++) {
        cin >> A[i];
    }

    CRT<ll, (ll)1e10> crt;
    for(int i=0; i<D; i++) {
        vector<ll> b, mod;
        for(int j=0; j<M; j++) {
            int val; cin >> val;
            if(val < 0) continue;
            b.push_back(val);
            mod.push_back(A[j]);
        }
        ll so, lc; tie(so, lc) = crt.solve(b, mod);
        if(so < 0 or so > N) {
            cout << -1 << endl;
            return;
        }
        N = (N - so) / lc * lc + so;
    }
    cout << N << endl;
}

int main() {
    // yuki_186();
    AOJ2659();
    return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
int n, a[223123];
map<int, int> mp;

bool chk(int x) {
	mp.clear();
	for (int i = 1; i <= n; ++i)
		if (a[i] <= a[i - 1]) {
			int p = a[i];
			while (!mp.empty()) {
				map<int, int>::iterator it = --mp.end();
				if (it -> first > p) mp.erase(it);
				else break;
			}
			while (mp[p] == x - 1) {
				mp[p] = 0; --p;
				if (!p) return 0;
			}
			++mp[p];
		}
	return 1;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	bool fd = 1;
	for (int i = 1; i < n; ++i)
		if (a[i] >= a[i + 1]) {
			fd = 0; break;
		}
	if (fd) {
		printf("1"); return 0;
	}
	int l = 2, r = n;
	while (l != r) {
		int mid = (l + r) >> 1;
		if (chk(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%d", l);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define L long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define aa first
#define bb second
#define mp make_pair
#define mpp(a,b,c) mp(mp(a,b),c)
using namespace std;
const int q=1000000007;
int n,m,f[2010][2010];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
	  f[1][i]=1;
	for(i=2;i<=m;i++)
	  {
	   for(j=1;j<=n-i+1;j++)
	     f[i][j]=f[i-1][j];
	   for(j=n,k=0;j>0;j--)
	     {
		  f[i][j]=(f[i][j]+k)%q;
		  k=(k+f[i-1][j])%q;
		 }
	  }
	for(i=m+1,k=(f[m][1]-f[m-1][1]+q)%q;i<n;i++)
	  k=(k<<1)%q;
	printf("%d\n",k);
	return 0;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll X; cin >> X;
	int ans = 0;
	vector<ll> s(TE + 1);
	for (int i = 1; i <= TE; i++) {
		s[i] = s[i - 1] + i;
		if (s[i] == X) {
			ans = i;
			break;
		}
		else if (s[i] > X) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
}


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

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

    double ans = 0;
    double x;
    string u;
    for(int i = 0; i < N; ++i){
        cin >> x >> u;

        if(u == "JPY"){
            ans += x;
        }else if(u == "BTC"){
            ans += x*380000.0;
        }
    }

    printf("%.5lf\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a,b,x;
  cin >> a >> b >> x;
  long long C=a/x;
  long long c=a%x;
  long long D=b/x;
  long long d=b%x;
  if(c==0){
    C=C-1;}
  cout << D-C << endl;
}

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

using namespace std;
#define ll long long

int main(){
    ll N;
    string S; 
    cin >> N;
    vector <int> V(N+2), C(N+2),D(N+2);
    for(int i=0; i<N; i++){
        cin >> V[i];
    }
    for(int i=0; i<N; i++){
        cin >> C[i];
        D[i] = V[i] - C[i];
    }
    sort(D.begin(),D.end(),greater<int>());
    int k = 0,ans=0;
    while( D[k] >= 0 && k != N){
        ans += D[k];
        k++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Open(s) freopen(s".in","r",stdin);freopen(s".out","w",stdout);
#define inl inline
#define reg register
#define i64 long long 
using namespace std;
inl int read(){int x=0,f=0;char ch=0;while(!isdigit(ch))f|=(ch=='-'),ch=getchar();while(isdigit(ch))(x*=10)+=(ch^48),ch=getchar();return f?-x:x;}
inl void Ot(reg int x){if(x<0)x=-x,putchar('-');if(x>=10)Ot(x/10);putchar(x%10+'0');}
inl void Print(reg int x,char til='\n'){Ot(x);putchar(til);}
inl int Max(reg int x,reg int y){return x>y?x:y;}
inl int Min(reg int x,reg int y){return x<y?x:y;}
inl int Abs(reg int x){return x<0?-x:x;}
const int MAXN=22;
int n,m;
char mp[MAXN][MAXN];
bool mark[MAXN][MAXN];
int mv[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
struct Node{
	int x,y;
	int step;
};
bool check(int x,int y){
	if(mark[x][y]||mp[x][y]=='#')return 0;
	if(x<1||x>n||y<1||y>m)return 0;
	return 1;
}
int bfs(int x,int y){
	queue<Node>que;
	que.push((Node){x,y,0});
	mark[x][y]=1;
	int ans=0;
	while(!que.empty()){
		Node h=que.front();
		que.pop();
		// printf("(%d %d) %d\n",h.x,h.y,h.step);
		ans=Max(ans,h.step);
		for(reg int i=0;i<4;i++){
			int nx=h.x+mv[i][0];
			int ny=h.y+mv[i][1];
			if(check(nx,ny)){
				mark[nx][ny]=1;
				que.push((Node){nx,ny,h.step+1});
			}
		}
	}
	return ans;
}
signed main(){
	n=read(),m=read();
	for(reg int i=1;i<=n;i++)
		for(reg int j=1;j<=m;j++)
			cin>>mp[i][j];
	int ret=0;
	// printf("%d\n",bfs(3,1));
	for(reg int i=1;i<=n;i++)
		for(reg int j=1;j<=m;j++){
			memset(mark,0,sizeof(mark));
			if(mp[i][j]=='.')
			ret=Max(ret,bfs(i,j));
		}
	Print(ret);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5;
const ll mod=1e9+7;
ll fct[N],inv[N],invfct[N];
void init(){
    fct[0]=fct[1]=1;
	inv[1]=1;
	invfct[0]=invfct[1]=1;
	for(ll i=2;i<N;i++){
		fct[i]=i*fct[i-1]%mod;
		inv[i]=ll(mod-inv[mod%i])*(mod/i)%mod;
		invfct[i]=ll(inv[i])*invfct[i-1]%mod;
	}
}
inline ll nck(ll n,ll k){
    if(k>n)return 0;
    ll val = fct[n]*invfct[k];
    val%=mod;
    val = val*invfct[n-k];
    val%=mod;
    return val;
}

int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,k;cin>>n>>k;
    init();
    map<ll,ll> mp;
    for(ll i=0,x;i<n;i++)cin>>x,mp[x]++;
    vector<ll> a;
    vector<ll> org;
    ll tot=0;
    for(auto &ele:mp)a.push_back(ele.second),tot+=ele.second,org.push_back(ele.first);
    ll mx=0,mn=0;
    ll prv=0;
    for(ll i=0;i<a.size();i++){
        ll cnt=a[i];
        ll big_equal = tot-prv;

        if(big_equal>=k){
            ll big=tot-prv-a[i];
            for(ll j=1;j<=cnt;j++){
                ll frombig = k - j;
                ll val = org[i];
                ll tot = nck(cnt,j)*nck(big,frombig);
                tot%=mod;
                mn = mn + (val*tot)%mod;
                mn%=mod;
            }
        }

        ll small_equal = prv+cnt;
        if(small_equal>=k){
            ll small = prv;
            for(ll j=1;j<=cnt;j++){
                ll fromsmall = k-j;
                ll val=org[i];
                ll tot= nck(cnt,j)*nck(small,fromsmall);
                tot%=mod;
                mx = mx + (val*tot)%mod;
                mx%=mod;
            }
        }

        prv+=a[i];
    }
    cout<<( mx - mn  + mod )%mod;
}


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

int main(){
	int N;
	int A[100];
	int count = 0;
	
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%d", &A[i]);
	}
	
	int minj, tmp;
	for(int i = 0; i < N; i++){
		minj = i;
		for(int j = i; j < N; j++){
			if(A[j] < A[minj]){
				minj = j;
				
			}
		}
		if(i != minj){
			tmp = A[i];
			A[i] = A[minj];
			A[minj] = tmp;
			count++;
		}
		
	}
	
	for(int i = 0; i < N; i++){
		printf("%d", A[i]);
		if(i != N-1) putchar(' ');
	}
	putchar('\n');
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    string s;
    int cnt = 0;
    cin >> s;
    int n = s.size();
    s += "#";
    string c = "#";
    rep(i,n){
        if(i == n-1 && c == s.substr(n-1, 1)) continue;
        if(c.size() == 2) c = s.substr(i,1);
        else{
            if(c == s.substr(i,1)){
                c = s.substr(i,2);
                i++;
            }
            else c = s.substr(i,1);
        }
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
using namespace std;
int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    char b4;
    int ans=0;

    for(int i=0;i<n;i++) {
        if(b4!=s[i]) ans+=1;
        b4 = s[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
int main()
{
    int a,count=0;
    scanf("%d",&a);
    int arr[a];
    for (int i=0; i<=a-1; i++) {
        scanf("%d",&arr[i]);
    }

    for(int i=1;i<a-1;i++)
    {
        if( (( arr[i] > arr[i-1] ) && ( arr[i] < arr[i+1])) || ((arr[i] < arr[i-1]) && (arr[i]>arr[i+1])))
        {
                count++;
        }
        
    }
    printf("%d \n",count);
    return 0;
    
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int main(){
	ll N,K;
	cin>>N>>K;
	if(N<100){
		int ans=0;
		rep(i,N-2) rep(j,5){
			int s=0;
			rep(x,3) rep(y,3) s+=(1+(i+x)*7+j+y);
			if(s%11==K) ans++;
		}
		cout<<ans<<endl;
		return 0;
	}
	int q=N/11-2,c=0;
	ll ans=0;
	N-=q*11;
	rep(i,N-2) rep(j,5){
		int s=0;
		rep(x,3) rep(y,3) s+=(1+(i+x)*7+j+y);
		if(s%11==K) ans++;
	}
	rep(i,11) rep(j,5){
		int s=0;
		rep(x,3) rep(y,3) s+=(1+(i+x)*7+j+y);
		if(s%11==K) c++;
	}
	ans+=q*c;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>

using namespace std;

int main()
{
	int a;
	cin >> a;
	cout << a * a <<endl;
	
	
	
	
	
	
	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    int N;
    cin >> N;
    vector<double> v;
    REP(i, N)
    {
    	double tempV;
    	cin >> tempV;
    	v.push_back(tempV);
    }

    sort(v.begin(), v.end());
   	double material = v[0];
   	for (int i = 1; i <= N - 1; ++i)
   	{
   		material = (material + v[i]) / 2.0;
   	}

    printf("%.6f\n", material);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll x; cin >> x;

  rep2(i, -1000, 1000) {
    rep2(j, -1000, 1000) {
      if (pow(i, 5) - pow(j, 5) == x) {
        cout << i << " " << j << endl;
        return (0);
      }
    }
  }
  
  return (0);
}

Measured memory_bytes: 4124
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main()
{
  int N, M, K;
  cin >> N >> M >> K;

  if (K == 0 or N * M == K) {
    cout << "Yes" << endl;
    return 0;
  }

  // row first
  for (int i = 0, m = 0; i <= N/2; m += M, ++i) {
    int d = N - 2 * i;
    for (int j = 0; j < M; ++j) {
      // cout << m << " + " << d << "*" << j << endl;
      if (m + d * j == K) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  // column first
  for (int i = 0, n = 0; i <= M/2; n += N, ++i) {
    int d = M - 2 * i;
    for (int j = 0; j < N; ++j) {
      // cout << n << " + " << d << "*" << j << endl;
      if (n + d * j == K) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   string s;
   cin >> s;
   for (int i = 0; i < s.size(); i++) {
      if (s[i] == '?') cout << 'D';
      else cout << s[i];
   }
   cout << endl;
   return 0;
}


Measured memory_bytes: 3756
#include<iostream>
#include<vector>
#include<iomanip>
#include<cstring>
#define prDouble(x) cout << fixed << setprecision(10) << x
#define ll long long int 
#define ii pair<int,int>
#define fast_io ios_base::sync_with_stdio(false);
#define MOD 1000000007
using namespace std;
ll dp[22][1<<22];
ll f(vector<vector<int>>&comp,int currentIndex,int set)
{
	if(currentIndex == 0)
		return set==0?1:0;
	if(dp[currentIndex-1][set]!=-1)
		return dp[currentIndex-1][set];
	ll count = 0;
	for(int i = 0;i < comp.size();++i)
	{
		int mask = (1<<i);
		if(comp[currentIndex-1][i] == 1 && (mask&set)!=0)
			count = (count + f(comp,currentIndex-1,set&(~mask)))%MOD;
	}
	return dp[currentIndex-1][set]=count;
}
int main()
{
	fast_io;
	int n;
	cin >> n;
	vector<vector<int>>comp(n,vector<int>(n,0));
	for(int i = 0;i < n;++i)
	{
		for(int j = 0;j < n;++j)
			cin >> comp[i][j];
	}
	memset(dp,-1,sizeof(dp));
	int  set = ((1<<n)-1);
	cout << f(comp,n,set) << "\n";
	return 0;
}

Measured memory_bytes: 724824
s = input()
l = len(s)
X, Y = (int(x) for x in input().split())
F = s.split("T")
x_move = [f.count("F") for f in F[2::2]]
y_move = [f.count("F") for f in F[1::2]]
x_set = set()
x_set.add(F[0].count("F"))
y_set = set()
y_set.add(0)
for move in x_move:
    x_set = set(x + move for x in x_set) | set(x - move for x in x_set)
for move in y_move:
    y_set = set(y + move for y in y_set) | set(y - move for y in y_set)

if X in x_set and Y in y_set:
    print("Yes")
else:
    print("No")


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


void solve(long long N, long long R){
    long long ans = 0;
    if(N >= 10) ans = R;
    else ans = R + 100 * (10-N);
    cout << ans << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long R;
    scanf("%lld",&R);
    solve(N, R);
    return 0;
}


Measured memory_bytes: 3644
from collections import deque
N = int(input())
A = [0] + list(map(int, input().split())) + [0]

total = 0
for i in range(1, N + 2):
    total += abs(A[i - 1] - A[i])

visited = []
for i in range(1, N + 1):
    a = abs(A[i - 1] - A[i + 1])
    b = abs(A[i] - A[i - 1]) + abs(A[i] - A[i + 1])
    visited.append(total + (a - b))

for v in visited:
    print(v)

Measured memory_bytes: 14532
w = input()
W = []
for i in range(len(w)):
    x = ord(w[i]) - 97
    W.append(x)
ans = 'Yes'
if len(w) % 2 == 1:
    ans = 'No'
else:
    for i in range(26):
        if W.count(i) % 2 == 1:
            ans = 'No'
            break
print(ans)
    

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

int main(){
  int n;
  while(cin >> n, n){
    vector<pll> a(n);
    rep(i,n)cin >> a[i].second >> a[i].first;
    sort(all(a));

    bool ans = true;
    ll sum = 0;
    rep(i,n){
      sum += a[i].second;
      if(sum > a[i].first) ans = false;
    }
    cout << (ans?"Yes":"No") << endl;
  }
}

Measured memory_bytes: 1200
D=int(input())
c=input().split()
c=[int(a) for a in c]
S=[]
for _ in range(D):
    s=input().split()
    s=[int(a) for a in s]
    S.append(s)
T=[]
for _ in range(D):
    t=int(input())-1
    T.append(t)
held=[0 for _ in range(26)]
ans=0
for d in range(D):
    s=S[d]
    place=T[d]
    held[place]=d+1
    ans+=s[place]
    for n in range(26):
        ans-=c[n]*(d+1-held[n])
    print(ans)
    

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

using namespace std;

const int MAXN = 100010;

int n;
int f[MAXN];
int child[MAXN];
int visit[MAXN];
vector<pair<int, int>> g[MAXN];

vector<long long> weights;

void dfs_model(int v, int p) {
  for(auto e : g[v]) {
    int s = e.first, w = e.second;
    if(s == p || visit[s]) continue;
  }
}

void dfs_prepare(int v, int p) {
  child[v] = 1;
  for(auto e : g[v]) {
    int s = e.first, w = e.second;
    if(s == p || visit[s]) continue;
    dfs_prepare(s, v);
    child[v] += child[s];
  }
}

int dfs_centroid(int v, int p, int root) {
  for(auto e : g[v]) {
    int s = e.first, w = e.second;
    if(s == p || visit[s]) continue;
    if(child[s] * 2 >= child[root]) return dfs_centroid(s, v, root);
  }
  return v;
}

/// sum of edges smaller than x, count of edges greater than x
long long fwt[MAXN], fwt2[MAXN], answer[MAXN];

void add(int y, int sign) {
  for(int x = y; x < MAXN; x += x & -x) fwt[x] += sign * weights[y];
  for(int x = y - 1; x > 0; x -= x & -x) fwt2[x] += sign;
}

long long calc(int y) {
  long long ret = 0;
  for(int x = y; x < MAXN; x += x & -x) ret += fwt2[x] * weights[y];
  for(int x = y; x > 0; x -= x & -x) ret += fwt[x];
  return ret;
}

void dfs_calc(int v, int p, int W) {
  answer[v] += calc(W);
  for(auto e : g[v]) {
    int s = e.first, w = e.second;
    if(s == p || visit[s]) continue;
    dfs_calc(s, v, min(W, w));
  }
}

void dfs_add(int v, int p, int W, int sign) {
  add(W, sign);
  for(auto e : g[v]) {
    int s = e.first, w = e.second;
    if(s == p || visit[s]) continue;
    dfs_add(s, v, min(W, w), sign);
  }
}

void go(int v) {
  dfs_prepare(v, -1);
  v = dfs_centroid(v, -1, v);
  visit[v] = 1;

  add(weights.size() - 1, 1);
  for(auto e : g[v]) {
    int s = e.first, w = e.second;
    if(visit[s]) continue;
    dfs_calc(s, v, w);
    dfs_add(s, v, w, 1);
  }

  add(weights.size() - 1, -1);
  answer[v] += calc(weights.size() - 1);

  for(auto e : g[v]) {
    int s = e.first, w = e.second;
    if(visit[s]) continue;
    dfs_add(s, v, w, -1);
    dfs_calc(s, v, w);
  }

  for(auto e : g[v]) {
    int s = e.first, w = e.second;
    if(visit[s]) continue;
    go(s);
  }
}

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

  weights = {-1, 0, (int)1e9 + 7};

  cin >> n;
  for(int i = 0; i < n - 1; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    g[--u].emplace_back(--v, w);
    g[v].emplace_back(u, w);
    weights.push_back(w);
  }

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

  for(int u = 0; u < n; ++u) {
    for(auto &e : g[u]) {
      e.second = lower_bound(weights.begin(), weights.end(), e.second) - weights.begin();
    }
  }
  go(0);

  for(int i = 0; i < n; ++i) cout << answer[i] << "\n";

  return 0;
}


Measured memory_bytes: 17076