akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <float.h>
#include <cfloat>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <errno.h>
#include <cerrno>
#include <assert.h>
#include <cassert> 
#include <map>
#include <memory.h>
#include <cctype>
#include <ctype.h>
#include <math.h>
#include <vector> 
#include <cstdio> 
#include <set>
#include <string.h>
#include <stdio.h>
#include <new>
#include <memory>
#include <cmath>
#include <queue>
#include <cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define fol(i,m,n) for(ll i=(ll)m;i<(ll)n;i++) 
#define br break
#define ct continue
#define all(s) s.first(),s.end() 
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define pii pair<int,int>  
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
#define mem(a,b) memset(a,b,sizeof(a))
#define lb lower_bound
#define ub upper_bound
#define li long int 
using namespace std;
int easy(){
    puts("Hello World");
    exit(0);
}
int main(){
    int a;
    cin>>a;
    if(a==1){
        easy();
    }
    else{
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;;return ss.str();}
#define P pair<unsigned int,unsigned int>


int main(){
	int n;
	vector<P>ta;
	cin>>n;
	ta.push_back(P(1,3));
	for(int i=1;i<20;i++){
	P tmp(ta[i-1].second+1,ta[i-1].second*3);
	ta.push_back(tmp);
	}
	//for(int i=0;i<20;i++)cout<<i+1<<" "<<ta[i].first<<" "<<ta[i].second<<endl;
	for(int i=0;i<20;i++){
	if(ta[i].first<=n&&ta[i].second>=n){
	cout<<i+1<<endl;
	break;
	}
	}
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <math.h>
#include <queue>
using namespace std;

typedef long long ll;
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define memset(v, h) memset((v), h, sizeof(v))
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll m[20][20];

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

struct node
{
    public: ll x;
    public: ll y;

    node(ll xx, ll yy)
    {
        x = xx;
        y = yy;
    }
};

int main(){
    ll h, w;
    ll d, s;
    cin >> h >> w;
    if(h >= w)
    {
        d = h;
        s = w;
    }   
    else
    {
        d = w;
        s = h;
    }

    string k = "";

    rep(i, d)k += std::to_string(s);
    
    cout << k << endl;
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    if(N <= 111){
        cout << 111 << endl;
    }else if(N <= 222){
        cout << 222 << endl;
    }else if(N <= 333){
        cout << 333 << endl;
    }else if(N <= 444){
        cout << 444 << endl;
    }else if(N <= 555){
        cout << 555 << endl;
    }else if(N <= 666){
        cout << 666 << endl;
    }else if(N <= 777){
        cout << 777 << endl;
    }else if(N <= 888){
        cout << 888 << endl;
    }else if(N <= 999){
        cout << 999 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {
    ll n;
    cin >> n;

    vl d(3);
    rep(i, 3) {
        cin >> d[i];
    }

    vector<P> p(n+1);
    rep(i, n) {
        string s;
        cin >> s;
        if(s == "AB") {
            p[i] = make_pair(0, 1);
        }
        else if(s == "AC") {
            p[i] = make_pair(0, 2);
        } 
        else if(s == "BC") {
            p[i] = make_pair(1, 2);
        } 
    }
    p[n] = make_pair(0, 1);

    vector<char> ans;
    auto add = [&](ll a, ll b) {
        d[a]++;
        d[b]--;
        char c = 'A' + a;
        ans.pb(c);
    };

    rep(i, n) {
        ll a = p[i].first;
        ll b = p[i].second;
        if(d[a] == 0 && d[b] == 0) {
            out("No");
            re0;
        }
        else if(d[a] == 0) {
            add(a, b);
        }
        else if(d[b] == 0) {
            add(b, a);
        }
        else {
            ll na = p[i+1].first;
            ll nb = p[i+1].second;
            if(a == na || a == nb) {
                add(a, b);
            }
            else {
                add(b, a);
            }
        }
    }

    out("Yes");
    for(auto c : ans) {
        out(c);
    }

    re0;
}

Measured memory_bytes: 5140
#include<iostream> 
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
int a[200];

int main()
{
	int n,x;
	cin>>x>>n;map<int,int> mp;
	for(int i=0;i<n;i++){
		cin>>a[i];mp[a[i]]=1;
	} 
	if(n==0){
		cout<<x;exit(0);
	}
	sort(a,a+n);
	int cha=1e9,ans=0;
	for(int i=0;i<=200;i++){
		if(!mp[i]){
			if(cha>abs(i-x)){
				cha=abs(i-x);ans=i;
			}
		} 
	}
	cout<<ans;
	return 0;	
} 

Measured memory_bytes: 3196
N, M = map(int, input().split())
SC = [list(map(int, input().split())) for _ in range(M)]
 
for X in range(10**N):
  X = str(X)
  
  #all　すべてがtrueならという意味
  if len(X) == N and all(X[s-1] == str(c) for s, c in SC):
    print(X)
    break
else:
  print(-1)

Measured memory_bytes: 9188
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;

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


int main(void) {
	ll n;
	cin >> n;
	for (ll h = 1;h <= 3500;h++) {
		for (ll w = 1;w <= 3500;w++) {
			if ((4 * h*w - n * w - n * h > 0) && (n*h*w % (4 * h*w - n * w - n * h) == 0)) {
				cout << h << " " << n * h*w / (4 * h*w - n * w - n * h) << " " << w << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
//  RAKSHIT KADAM

 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!
 
// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000004
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long
 
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
 
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500003;
// ll fact[1000005];
//void facto()
//{
//    ll lim =1000005;fact[0]=1;
//    for(ll i=1;i<lim;i++)
//    {
//        fact[i]=(fact[i-1]*i)%MOD;
//    }
//}
//ll ncr(ll a,ll b)
//{
//    ll ret = 0;
//    ret = fact[a]*(modInverse(fact[b],MOD));
//    ret%=MOD;
//    ret*=modInverse(fact[a-b],MOD);
//    ret%=MOD;
//    return ret;
//}
void solve(ll tt)
{
    
    cout<<"Case #"<<tt<<":"<<endl;
    
}

void s()
{
    ll a,b,c,k;cin>>a>>b>>c>>k;
    ll ans =0;
    while(b<=a)
    {
        b*=2;ans++;
    }
    while(c<=b)
    {
        c*=2;ans++;
    }
    if(ans>k)cout<<"No"<<endl;else cout<<"Yes"<<endl;
}

signed main()
{
   Need_for_speed(activated);
//    input;
//    ll ttt;cin>>ttt;
//    for(ll tt=1;tt<=ttt;tt++)
//    {
//  solve(tt);
//   }
    
//    solve();
    s();
//    satisfy{s();}
    return 0;
}
//Concentrate while implementing,,,!!!
 


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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll a, b, c, d; cin >> a >> b >> c >> d;

  ll x = a * c;
  x = max(x, b * c);
  x = max(x, a * d);
  x = max(x, b * d);
  cout << x << endl;

  return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

ll a[1000010];

void solve(){

    long double r;
    long double PI=3.14159265358979323846;
    cin >> r;
    cout << 2*r*PI << endl;

}

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


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

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;
const int MOD = 1000000007;

typedef long long ll;

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll LCM(ll x, ll y)
{
    return x * y / GCD(x, y);
}

typedef pair<int, int> P;

// dp[i+1][j]は，i枚目までを投げた時，j枚が表の確率
double dp[3010][3010];
int main()
{
    int N;
    cin >> N;
    vector<double> p(N);
    rep(i, N)
    {
        cin >> p.at(i);
    }

    dp[0][0] = 1.0;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= i; j++) {
            dp[i + 1][j + 1] += dp[i][j] * p.at(i);
            dp[i + 1][j] += dp[i][j] * (1.0 - p.at(i));
        }
    }

    int half = N / 2 + 1; // N=5なら3とか
    double sum = 0.0;
    for (int j = half; j <= N; j++) {
        sum += dp[N][j];
    }

    cout << fixed << setprecision(10) << sum << endl;
}


Measured memory_bytes: 69120
from collections import deque

H, W = map(int, input().split())
maze = [input() for i in range(H)]
reached = [[-1] * W for i in range(H)]

que = deque([])

for i in range(H):
    for j in range(W):
        if maze[i][j] == '.':
            continue
        reached[i][j] = 0
        que.append([i, j])

while que:
    py, px = que.popleft()
    dy = (0, 1, 0, -1)
    dx = (1, 0, -1, 0)
    for y, x in zip(dy, dx):
        ny = py + y
        nx = px + x
        if ny < 0 or ny >= H or nx < 0 or nx >= W:
            continue
        if reached[ny][nx] == -1:        
            que.append([ny, nx])
            reached[ny][nx] = reached[py][px] + 1

MAX = 0
for i in range(H):
    MAX = max(max(reached[i]), MAX)

print(MAX)


Measured memory_bytes: 141148
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  string s;
  cin >> s;
  int n = s.size();
  int h = s[0] - '0';
  int ans = h + 9 * (n-1);
  FOR(i,1,n){
    if(s[i]!='9'){
      ans--;
      break;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

;; Hauptteil

(defun main ()
  (let* ((n (read))
         (h (read))
         (w (read)))
    (println (* (+ n (- h) 1) (+ n (- w) 1)))))

#-swank(main)


Measured memory_bytes: 15592
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;

int main() {
	int N, X, Y;
	cin >> N >> X >> Y;
	//バイパス適用対象:i<X&&Y<j
	vector<int>dist(N);
	int bipass, forward;
	for (int i = 1; i <= N; i++)
	{
		for (int j = i+1; j <= N; j++)
		{
			forward = j - i;
			bipass = abs((X - i)) + abs((Y - j))+1;
			dist.at(min(forward, bipass))++;
		}
	}
	for (size_t i = 1; i < N; i++)
	{
		cout << dist.at(i)<<endl;
	}
}

Measured memory_bytes: 256
#ifdef __GNUC__
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#endif

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>

#include <string>
#include <cstring>
#include <vector>
#include <valarray>
//#include <array>//x C++ (G++ 4.6.4)

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <cassert>//assert();
#include <fstream>
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)

/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#define PII pair<int,int>
/////////
using namespace::std;

// 最大公約数
template<class T>
inline T gcd(T a, T b){return b == 0 ? a : gcd(b, a % b);}
// 最小公倍数
template<class T>
inline T lcm(T a, T b){return a * b / gcd(a, b);}
////////////////////////////////
vector< vector<bool> > G;
vector<bool> used;
int N;

int dfs(int pos){
	int RET = 0;//返す値。
	int TEMP = 0;
	int res;
	bool flag = true;
	for(int i=0;i<N;++i){
		if( used[i] == false ){
			flag = false;
			break;
		}
	}
	if( flag == true ){
		return 1;
	}
	for(int i=0;i<N;++i){
		if( used[i] ) continue;
		if( pos == i ) continue;
		if( G[pos][i] == false)continue;
		used[i] = true;
		res = dfs(i);
		if( res != -1 ){
			RET += res;
		}
		used[i] = false;
	}
	return RET;
}

inline void solve(){
	int M;
	cin >> N >> M;
	G = vector< vector<bool> >(N,vector<bool>(N,false) );
	used = vector<bool>(N,false);
	int a,b;
	for(int i=0;i<M;++i){
		cin >> a >> b;
		--a;--b;
		G[a][b] = true;
		G[b][a] = true;
	}
	
	used[0] = true;
	int ret = dfs(0);
	cout << ret << endl;
}

signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	//std::cout << std::fixed;//小数を10進数表示
	//cout << setprecision(16);//小数をいっぱい表示する。16?

	solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<ll> monsters(N+1);
    rep(i, N+1){
        cin >> monsters[i];
    }
    ll helpFromPrev, ans;
    helpFromPrev = 0;
    ans = 0;
    rep(i, N){
        ll b;
        cin >> b;
        if(helpFromPrev + b > monsters[i]){
            ans += monsters[i];
            helpFromPrev = min(b, helpFromPrev + b - monsters[i]);
        } else {
            ans += helpFromPrev + b;
            helpFromPrev = 0;
        }
    }
    ans += min(helpFromPrev, monsters[N]);

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


Measured memory_bytes: 1024
#include "bits/stdc++.h"

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;


ll N, W;
ll w[110], v[110];
ll dp[100010];
int main(){
	cin >> N >> W;
	REP(i,0,N){
		cin >> w[i] >> v[i];
	}
	dp[0]=0;
	REP(i,0,N){
		RREP(nw,0,W){
			if(nw + w[i] > W) continue;
			dp[nw + w[i]] = max(dp[nw + w[i]], dp[nw] + v[i]);

		}
	}
	ll ans = 0;
	REP(i,0,W+1){
		ans = max(ans, dp[i]);
	}
	p(ans);
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
  int a,b,k;
  scanf("%d%d%d",&a,&b,&k);

  int i,ans=0;
  for(i=a;i<b+1;i++)
    if((i<a+k)||(i>b-k))
      printf("%d\n",i);

  return 0;
}


Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int a;
    int b;
    a = (int)(s[0]-'0')*10 + (int)(s[1]-'0');
    b = (int)(s[2]-'0')*10 + (int)(s[3]-'0');
    bool aa = false;
    bool bb = false;
    if(a > 0 && a <= 12)aa = true;
    if(b > 0 && b <= 12)bb = true;
    
    if(aa && bb)cout << "AMBIGUOUS";
    else if(aa)cout << "MMYY";
    else if(bb)cout <<"YYMM";
    else cout<<"NA";
    cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define debug(output) cout<<#output<<"= "<<output<<endl
using lint=long long;
int MOD=1000000007;
vector<lint> zeta_trans(vector<lint> const& array){
    int n=array.size();
    vector<lint> res(array);
    vector<bool> memo(n,true);
    for(int i=2;i<n;++i){
        if(!memo[i])continue;
        for(int j=(n-1)/i;j>0;--j){
            memo[i*j]=false;
            res[j]+=res[i*j];
        }
    }
    return res;
}
lint gcd(lint a,lint b){
    if(b==0)return a;
    return gcd(b,a%b);
}
signed main(){
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    vector<lint> array(1000001,0);
    rep(i,n)array[a[i]]++;
    vector<lint> fac=zeta_trans(array);
    bool flag=true;
    for(int i=2;i<=1000000;++i){
        if(fac[i]>1)flag=false;
    }
    lint c=0;
    rep(i,n){
        c=gcd(c,a[i]);
    }
    if(flag){
        cout<<"pairwise coprime"<<"\n";
    }
    else{
        if(c==1)cout<<"setwise coprime"<<"\n";
        else cout<<"not coprime"<<"\n";
    }
    return 0;
}

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

int main(){
    int h, w;
    cin >> h >> w;
    string s[h];
    rep(i, h) cin >> s[i];
    bool ans = true;
    rep(y, h){
        rep(x, w){
            bool u = true, d = true, l = true, r = true;
            if (s[y][x] == '#'){
                if (x > 0 && s[y][x - 1] == '.') l = false;
                if (x < w - 1 && s[y][x + 1] == '.') r = false;
                if (y > 0 && s[y - 1][x] == '.') u = false;
                if (y < h - 1 && s[y + 1][x] == '.') d = false;
            }
            ans = ans & (u || d || l || r);
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int h,w,n;
  cin>>h>>w>>n;
  int si,sj;
  cin>>si>>sj;
  si--;sj--;
  string t,u;
  cin>>t>>u;

  bool ans = true;
  rep(_,2){
    int lb = -1, ub = w;
    bool cans = true;
    for(int i=n-1; i>=0; i--) {
      if(u[i] == 'L') {
        ub = min(ub+1, w);
      }
      if(u[i] == 'R') {
        lb = max(lb-1, -1);
      }
      if(t[i] == 'R') {
        ub--;
      }
      if(t[i] == 'L') {
        lb++;
      }
      if(lb+1 >= ub) {
        cans = false;
        break;
      }
      dbg(lb,ub,t,u);
    }

    ans = ans & cans & (lb < sj && sj < ub);
    dbg(cans, ans);

    swap(h,w);
    swap(si,sj);
    map<char,char> conv = {{'U','L'},{'D','R'},{'R','D'},{'L','U'}};
    rep(i,n) t[i] = conv[t[i]];
    rep(i,n) u[i] = conv[u[i]];
  }

  cout << (ans ? "YES" : "NO") << endl; 

  return 0;
}


Measured memory_bytes: 776
num_input=list(map(int,input().split()))

while num_input[0]!=0 or num_input[1]!=0:
    if num_input[0]<num_input[1]:
        print(str(num_input[0])+" "+str(num_input[1]))
    else:
        print(str(num_input[1])+" "+str(num_input[0]))
    num_input=list(map(int,input().split()))



Measured memory_bytes: 5612
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i, n) for (int i = (int)(n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to, cost; };
using P = pair<int, int>;
using D = pair<double, double>;
//const long long mod = 998244353;
const long long mod = 1e9 + 7;
const long long inf = 3e18;
const string sp = " ";

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

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n == r) return 1;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int nck[1010][1010];
void comb(int n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

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

int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int> factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

double dis(D a, D b) { return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second)); }

int n, m, ans;
int a[100010];
bool r[100010];
signed main() {
	cin >> n >> m;
	r[0] = true;
	rep(i, n) a[i] = 1;
	rep(i, m) {
		int x, y;
		cin >> x >> y;
		--x; --y;
		if (r[x]) r[y] = true;
		a[x] = a[x] - 1;
		a[y] = a[y] + 1;
		if (a[x] == 0) r[x] = false;
	}
	rep(i, n) {
		if (r[i]) ++ans;
	}
	cout << ans << endl;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string S;
	cin >> S;
	int tmp = S.size();
	int cnt = 0;
	for (int i = 0; i < S.size() / 2; i++){
		if (S[i] != S[S.size() - i - 1]) {
			cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
def prime(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for j in range(4, n+1, 2):
        is_prime[j] = False
    for i in range(3, int(n**0.5) + 1, 2):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

n = int(input())
prime_list = prime(110000)
i = 0
while True:
    if prime_list[i] >= n:
        print(prime_list[i])
        break
    else:
        i += 1

Measured memory_bytes: 4276
import itertools
N=int(input())
words=['3','5','7']
mojiretu=[]
for a in range(1,10):
    answers = list(itertools.product(words, repeat=a))
    for a in answers:
        moji = ''
        for b in a:
            moji += b
        mojiretu.append(moji)
S=[]
for a in mojiretu:
    number=0
    suuji=0
    kazu=0
    for b in a:
        if b=='3':
            number+=1
        elif b=='5':
            suuji+=1
        elif b=='7':
            kazu+=1
    if number>=1 and suuji>=1 and kazu>=1:
        S.append(int(a))
T=[i for i in S if i<=N]
print(len(T))


Measured memory_bytes: 48092
#include<stdio.h>
int main()
{
    char a[4];
    int x,i,b=0,c=0,d=0,e=0;
    scanf("%d",&x);
    for(i=0;i<x;i++)
    {
        scanf("%s",a);
        if(a[0]=='A')
        {
            b++;
        }
        else if(a[0]=='T')
        {
            c++;
        }
        else if(a[0]=='W')
        {
            d++;
        }
        else if(a[0]=='R')
        {
            e++;
        }
    }
    printf("AC x %d\n",b);
    printf("WA x %d\n",d);
    printf("TLE x %d\n",c);
    printf("RE x %d\n",e);
    return 0;
}

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    vector<int> x(3);
    for(auto &i:s)
        ++x[i-'a'];
    int m=0;
    for(int i=0;i<3;++i)
        for(int j=i+1;j<3;++j)
            m=max(m,abs(x[i]-x[j]));
    if(m>1)
        printf("NO\n");
    else
        printf("YES\n");
}


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

using namespace std;

void bubbleSort(vector<int> &vec)
{
	int cmp_num = 0;
	int vec_size;
	int tmp;

	vec_size = vec.size();

	for(int i = 1; i <= vec_size-1; i++)
	{
		for(int j = vec_size-1; j >= i; j--)
		{
			if( vec[j] < vec[j-1])
			{
				tmp = vec[j];
				vec[j] = vec[j-1];
				vec[j-1] = tmp;
				cmp_num++;
			}
		}
	}

	for(int i = 0; i < vec_size-1; i++)
	{
		cout << vec[i] << " ";
	}
	cout << vec[vec_size-1] << endl;
	cout << cmp_num << endl;

	return;
}

int main(void)
{
	int n;
	
	cin >> n;
	vector<int> A(n);

	//データ入力
	for(int i = 0; i < n; i++)
	{
		cin >> A[i];
	}

	bubbleSort(A);

	return 0;
}



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

int qmax(int a, int b){
	return (a > b) ? a : b;
}

int n;
int l[100100], r[100100];
vector<int> robot[200200];
int dp[200200];
map<int, int> mp;
set<int> s;

int main(){
	scanf("%d", &n);
	rep(i, n){
		int x, L;
		scanf("%d %d", &x, &L);
		l[i] = x - L, r[i] = x + L;
		s.insert(l[i]), s.insert(r[i]);
	}
	int cnt = 0;
	for(set<int>::iterator it = s.begin(); it != s.end(); it++, cnt++){
		mp[*it] = cnt;
	}
	rep(i, n){
		l[i] = mp[l[i]];
		r[i] = mp[r[i]];
		robot[r[i]].push_back(i);
	}
	memset(dp, 0, sizeof(dp));
	for(int i = 1; i < cnt; i++){
		dp[i] = dp[i-1];
		rep(j, robot[i].size()){
			dp[i] = qmax(dp[i], dp[l[robot[i][j]]] + 1);
		}
	}
	cout << dp[cnt-1] << endl;
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int count = 0;
    for(int i = 0; i < s.size()-1; i++){
        if(s.at(i) == s.at(i+1)){
            count++;
        }
    }
    if(count == 0){
        cout << "Good" << endl;
    } else {
        cout << "Bad" << endl;
    }
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll n,m,a[2005],b[2005],dp[2005][2005],prfx[2005];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>m;
    for(ll i=0;i<n;i++)cin>>a[i];
    for(ll i=0;i<m;i++)cin>>b[i],prfx[i]=1;
    dp[0][0]=1;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++)if(a[i]==b[j])dp[i+1][j+1]=prfx[j];
        ll prv=0;
        for(ll j=0;j<m;j++){
            prv+=dp[i+1][j];
            prv%=mod;
            prfx[j]+=prv;
            prfx[j]%=mod;
        }
    }
    ll ans=0;for(ll i=0;i<=n;i++)for(ll j=0;j<=m;j++)ans+=dp[i][j],ans%=mod;
    cout<<ans;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n;
string now;
string digit[10] = {
  "0111111",
  "0000110",
  "1011011",
  "1001111",
  "1100110",
  "1101101",
  "1111101",
  "0100111",
  "1111111",
  "1101111"
};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> n, n >= 0) {
    now = "0000000";
    for (int i = 0; i < n; i++) {
      string ans(7, '0');
      int d;
      cin >> d;
      for (int j = 0; j < 7; j++) {
        if (now[j] == digit[d][j]) continue;
        ans[j] = '1';
      }
      cout << ans << endl;
      now = digit[d];
    }
  }  

  return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  string s; cin >> s;
  map<char, int> cnt;
  for (int i = 0; i < s.size(); ++i) {
    cnt[s[i]]++;
  }

  int ans = 1<<30;
  for (auto v : cnt) {
    char c = v.first;
    int cnt = 0, maxc = 0;
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] == c) {
        cnt = 0;
      } else {
        cnt++;
        maxc = max(maxc, cnt);
      }
    }
    ans = min(ans, maxc);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}

import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Data.Char
import Control.Monad
import Control.Monad.Primitive 

type Parent = VUM.IOVector Int
type Size = VUM.IOVector Int
 
makeUF :: Int -> IO (Parent, Size)
makeUF n = do
    par <- VU.unsafeThaw $ VU.generate n id
    siz <- VUM.replicate n 1
    return (par, siz)
 
root :: Int -> Parent -> IO Int
root x par = do
    r <- VUM.read par x
    if x == r
        then return x
        else do
            newr <- root r par
            VUM.write par x newr
            return newr
 
same :: Int -> Int -> Parent -> IO Bool
same x y par = do
    rx <- root x par
    ry <- root y par
    return $ rx == ry
 
unite :: Int -> Int -> Parent -> Size -> IO ()
unite x y par siz = do
    x' <- root x par
    y' <- root y par
    sx <- VUM.read siz x'
    sy <- VUM.read siz y'
    unless (x' == y') $ 
        if sx < sy
            then do
                VUM.modify siz (+sx) y'
                VUM.write par x' y'
            else do
                VUM.modify siz (+sy) x'
                VUM.write par y' x'
 
size :: Int -> Parent -> Size -> IO Int
size x par siz = root x par >>= VUM.read siz

toTuple :: B.ByteString -> (Int, Int)
toTuple bs =
    let
        Just (a, bs') = B.readInt bs
        Just (b, _) = B.readInt $ B.dropWhile isSpace bs'
    in
        (a, b)
    
main = do
    [n,m,k] <- map read . words <$> getLine :: IO [Int]
    (par, siz) <- makeUF (n+1)
    (cnt :: VUM.IOVector Int) <- VUM.replicate (n+1) 0
    replicateM_ m $ do
        (a,b) <- toTuple <$> B.getLine 
        unite a b par siz
        VUM.modify cnt (+1) a
        VUM.modify cnt (+1) b

    replicateM_ k $ do
        (c,d) <- toTuple <$> B.getLine 
        branch <- same c d par
        when branch $ do
            VUM.modify cnt (+1) c
            VUM.modify cnt (+1) d
        
    forM_ [1..n] $ \i -> do
        s <- size i par siz
        c <- VUM.read cnt i
        putStr $ show (s - c - 1)
        putStr " "
    putStrLn ""

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

#define ll long long

using namespace std;


int main(){
 int a,b;
 cin>>a>>b;
 if(((a==1)&&(b==2))||((a==2)&&(b==1))){
     cout<<"3"<<endl;
 }
 if(((a==1)&&(b==3))||((a==3)&&(b==1))){
     cout<<"2"<<endl;
 }
if(((a==3)&&(b==2))||((a==2)&&(b==3))){
    cout<<"1"<<endl;
}


}

Measured memory_bytes: 256
LARGE = 998244353


def solve(n, d_list):
    cnt = [0] * (max(d_list) + 1)
    for i in range(n):
        cnt[d_list[i]] += 1
    if cnt[0] != 1 or d_list[0] != 0:
        return 0
    res = 1
    for i in range(max(d_list)):
        res *= pow(cnt[i], cnt[i + 1], LARGE)
        res %= LARGE
    return res


def main():
    n = int(input())
    d_list = list(map(int, input().split()))
    res = solve(n, d_list)
    print(res)


def test():
    assert solve(4, [0, 1, 1, 2]) == 2
    assert solve(4, [1, 1, 1, 1]) == 0
    assert solve(7, [0, 3, 2, 1, 2, 2, 1]) == 24


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 53164
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#define inf 2147483647
#define N 1000010
#define p(a) putchar(a)
#define For(i,a,b) for(int i=a;i<=b;++i)

using namespace std;
int n;

void in(int &x){
    int y=1;char c=getchar();x=0;
    while(c<'0'||c>'9'){if(c=='-')y=-1;c=getchar();}
    while(c<='9'&&c>='0'){ x=(x<<1)+(x<<3)+c-'0';c=getchar();}
    x*=y;
}
void o(int x){
    if(x<0){p('-');x=-x;}
    if(x>9)o(x/10);
    p(x%10+'0');
}

struct node{
	string s;
	int w;
	int id;
	bool operator < (const node & a)const{
		if(s==a.s)
			return w>a.w;
		return s<a.s;
	}
}a[N];

signed main(){
    in(n);
    For(i,1,n){
    	cin>>a[i].s;
    	in(a[i].w);
    	a[i].id=i;
    }
    sort(a+1,a+n+1);
    For(i,1,n) o(a[i].id),p('\n');
    return 0;
}

Measured memory_bytes: 31488
import sys

nums = []
count = 0

for num in sys.stdin:
	nums.append(int(num))

for num in nums:
	for a in range(0, 10):
		for b in range(0, 10):
			for c in range(0, 10):
				for d in range(0, 10):
					if a+b+c+d == num:
						count += 1
	print count
	count = 0

Measured memory_bytes: 4216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const int INF=(int)2e9;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
const ll MOD=(ll)1e9+7;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=max(l,r),_m=min(l,r);i>=_m;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
#define MAX 100005
#define wa cout<<"wa"<<endl;
int irand(int lo, int hi){
	return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}

string toString(ll x) {
	stringstream ss;
	ss << x;
	return ss.str();
}

ll toNumber(string S) {
	ll ret;
	sscanf(S.c_str(),"%lld",&ret);
	return ret;
}

void base(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main(){
	string str;
	cin>>str;
	cout<<"ABC"<<str<<endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s[3];
	for (auto& ss: s) {
		cin >> ss;
	}
	bool can[3][3][2001] = {};
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int shift = 0; shift <= 2000; ++shift) {
				can[i][j][shift] = true;
				for (int k = 0; k < s[j].size() && k + shift < s[i].size(); ++k) {
					if (s[i][k + shift] != '?' && s[j][k] != '?' && s[i][k + shift] != s[j][k]) {
						can[i][j][shift] = false;
						break;
					}
				}
			}
		}
	}
	int p[] = {0, 1, 2};
	auto ans = s[0].size() + s[1].size() + s[2].size();
	do {
		for (int sh1 = 0; sh1 <= 2000; ++sh1) {
			for (int sh2 = 0; sh2 <= 2000; ++sh2) {
				int sh3 = sh1 + sh2;
				if (can[p[0]][p[1]][sh1] && can[p[1]][p[2]][sh2] && (sh3 > 2000 || can[p[0]][p[2]][sh3])) {
					ans = min(ans, max(s[p[0]].size(), max(sh1 + s[p[1]].size(), sh3 + s[p[2]].size())));
				}
			}
		}
	} while (next_permutation(p, p + 3));
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  map<int,int> a;
  rep(i,n){
    int t;
    cin >> t;
    if(a.count(t)){
      cout << "NO" << endl;
      return 0;
    }
    a[t]++;
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll k; cin >> k;
    ll a = 0;
    vector<bool> chkd(k,0);
    ll ans = 0;
    for(int i=1;i<=k;i++){
        a = a*10 + 7;
        a = a%k;
        if(a == 0){
            ans = i;
            break;
        }
        if(chkd.at(a)) break;
        chkd.at(a) = 1;
    }
    if(ans){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

long long modp(long long a, long long p) {
    long long res = a % p;
    if (res < 0) res += p;
    return res;
}

bool comp(pair<ll,ll> a, pair<ll,ll> b){
    return a.second < b.second;
}

int main(void){
    ll N,L,T; cin >> N >> L >> T;
    vector<ll> X(N), W(N); REP(i,N) cin >> X[i] >> W[i];

    ll n_swap = 0;
    REP(i,N-1){
        if(W[0] == W[i+1]) continue;
        if(W[0] == 1) n_swap += (2*T + (L-X[i+1]+X[0])) / L;
        else n_swap += (2*T + (X[i+1]-X[0])) / L;
    }

    ll init;
    if(W[0] == 1) init=-1;
    else init=LL_INF;
    vector<pair<ll,ll>> after(N, pair<ll,ll>(0,init));
    if(W[0] == 1) after[0].second = modp(n_swap, N);
    else after[0].second = modp(-n_swap, N);

    ll key = after[0].second;

    REP(i,N){
        if(W[i] == 1) after[i].first = modp(X[i]+T, L);
        else after[i].first = modp(X[i]-T, L);
    }

    SORT(after);

    int pos = 0; while(after[pos].second != key) pos++;
    REP(i,N){
        after[pos].second = key;
        pos = (pos+1)%N;
        key = (key+1)%N;
    }

    sort(after.begin(), after.end(), comp);

    REP(i,N) cout << after[i].first << endl;
    return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    long long n,k,tmp; cin >> n >> k;
    vector<long long> minus, plusorzero;
    for(long long i = 0; i< n;i++){
        cin >> tmp;
        if(tmp < 0){
            minus.push_back(abs(tmp));
        } else {
            plusorzero.push_back(tmp);
        }
    }
    sort(minus.begin(), minus.end());
    long long minnum = 1 << 30;
    for(long long i = 0; i <= minus.size(); i++){
        if(k-i > plusorzero.size()){
            // cout << "continue " << i<<endl;
            // if(minus.size() == 0){
            //     cout << plusorzero[k-i-1] << endl;
            //     return 0;
            // }
            continue;
        }
        if(i == 0)
            tmp = plusorzero[k-i-1];
        else {
            if(plusorzero.size() == 0){
                tmp = minus[i-1];
            }
            else{
                tmp = min(minus[i-1]*2 + plusorzero[k-i-1], minus[i-1] + plusorzero[k-i-1]*2);
            }
        }
            // tmp = minus[i-1] + plusorzero[k-i-1];
        // cout << tmp << endl;
        if(tmp < minnum){
            minnum = tmp;
        }
    }
    cout << minnum << endl;
}


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

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node*)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, i, x;
    string com;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        cin >> com;
        if (com == "insert") {
            scanf("%d", &x);
            insert(x);
        } else if( com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 26744
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll k,x;
int main(){FAST;
cin>>k>>x;
for(ll i=x-k+1;i<=x+k-1;i++){
	if(i>=-1000000 and i<=1000000){
		cout<<i<<" ";
	}
}
return 0;
}

Measured memory_bytes: 256
/**************** Geometrical Library ****************/

#include<cmath>
#include<vector>
#include<algorithm>

#define	EPS	1e-9

#define	pb	push_back

using namespace std;

class Point{
public:
	double x,y;
	Point(){}
	Point(double xx,double yy):x(xx),y(yy){}
};

class Polygon:public vector<Point>{};

double cross(const Point &a,const Point &b){
	return a.x*b.y-a.y*b.x;
}

double area(const Polygon &pl){
	int n=pl.size();
	double a=0;
	for(int i=0;i<n;i++)	a+=cross(pl[i],pl[(i+1)%n]);
	return abs(a)/2;
}

/**************** Library END ****************/

#include<cstdio>

int main(){
	for(int n,t=1;scanf("%d",&n),n;t++){
		Polygon pl;
		for(int i=0;i<n;i++){
			int x,y;	scanf("%d%d",&x,&y);
			pl.pb(Point(x,y));
		}
		printf("%d %.1f\n",t,area(pl));
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int A[30],n;

int solve(int i, int m){
  int res;
  if (m == 0)
    return 1;
  if (i >= n)
    return 0;
  res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  
  return res;
}

int main(){
  int i,q,key;
  
  scanf("%d", &n);

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

  scanf("%d", &q);

  for ( i = 0; i < q; i++ ) {
    scanf("%d", &key);
    if (solve(0,key)) printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}



Measured memory_bytes: 2048
function main(input) {
    const args = input.split(' ');
    const N = parseInt(args[0],10),
	  Y = parseInt(args[1],10);

    var result = '-1 -1 -1';

    for(var a = 0; a <= N; a++){
	for(var b = 0; b <= N;b++){
	    if((a + b) > N ){
		continue;
	    }

	    var sum = (a * 10000)  + (b * 5000) + ((N - a -b) * 1000);
	    if(sum === Y){
		result = `${a} ${b} ${N - a - b}`;
		break;
	    }
	}
    }
    console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int n,c=0,k;
  cin>>n>>k;
  if(k==1){cout<<0;return 0;}
  for(int i=0;i<10000;i++){
    if(i==0)c+=n;
    else c+=n-1;
    if(c>=k){cout<<i+1;return 0;}
  }
}


Measured memory_bytes: 256