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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  int n,a,b;
  cin>>n>>a>>b;
  if(n==1)
    cout<<"Hello World\n";
  else
    cout<<a+b<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<deque>
#include<stdio.h>
using namespace std;

int res(char ch,int R,int S,int P){
	switch(ch){
		case 'r':
			return P;
		case 's':
			return R;
		case 'p':
			return S;
	}
	return 0;
}

int main(){
	
	int N, K, R, S, P;

	cin >> N >> K >> R >> S >> P;

	deque<char> record;
	char ch;
	int long point = 0;
	getchar();

	for(int i=0; i<K; ++i){
		ch = getchar();
		record.push_back(ch);
		point += res(ch,R,S,P);
		//cout << i << ' ' << ch << ' ' << point << endl;
	}

	for(int i=K; i<N; ++i){
		ch = getchar();
		if(ch == record[0]){ch='n';}
		else if (ch != record[0]){
			point += res(ch,R,S,P);
		}
		record.pop_front();
		//cout << i << ' ' << ch << ' ' << point << endl;
		record.push_back(ch);
	}

	cout << point << endl;

	return 0;
}


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

int main() {
  int N, M, L, R, l, r;
  cin >> N >> M >> L >> R;
  for (int i=0; i<M-1; i++) {
    cin >> l >> r;
    if (l > L)
      L = l;
    if (r < R)
      R = r; 
  }
  if (R-L+1>0)
    cout << R-L+1 << endl;
  else
    cout << 0 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define int long long

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

const ll MOD = 998244353LL;

long long mod_inverse(long long x) {
	long  long ret = 1; long long n = MOD - 2;
	while (n) {
		if (n & 1)ret = ret * x%MOD;
		x = x * x%MOD; n >>= 1;
	}
	return ret;
}

ll fact[300300], fact_inv[300300];

ll comb(ll n, ll r) {
	ll ret = ((fact[n] * fact_inv[n - r]) % MOD )* fact_inv[r] % MOD;
	return ret;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    ll N, A, B, K; cin >> N >> A >> B >> K;
	fact[0] = 1LL; fact_inv[0] = mod_inverse(1LL);
	rep(i, N) {
		fact[i + 1] = fact[i] * (i + 1) % MOD;
		fact_inv[i + 1] = mod_inverse(fact[i + 1]);
	}
	ll ans = 0;
	rep(a, N + 1) {
		ll K_ = K - a * A;

		if(K_ % B != 0) continue;
		ll b = K_ / B;
		if(b < 0 || N < b) continue;
		ans += comb(N, a) * comb(N, b) % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
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;
}

int main(){
  cout << fixed << setprecision(15);
  int ans;
  //string ans;
  
  map<string, int> days;
  days["SUN"] = 0;
  days["MON"] = 1;
  days["TUE"] = 2;
  days["WED"] = 3;
  days["THU"] = 4;
  days["FRI"] = 5;
  days["SAT"] = 6;

  string s; cin >> s;

  ans = 7 - days[s];

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

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

using ll = long long;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	string s;
	cin >> s;
	vector<char> c;
	for(int i = 0; i < s.size(); i++){
		pb(c,s[i]);
	}
	sort(ben(c));
	int ok = 0;
	int check = 0;
	for(int i = 0; i < s.size() - 1; i++){
		if(c[i] == c[i + 1]){
			ok++;
		}
		else{
			ok++;
			if(ok % 2)check = 1;
			ok = 0;
		}

		if(i == s.size() - 2){
			ok++;
			if(ok % 2)check = 1;
		}
	}
	if(!(s.size() - 1))check = 1;
	
	if(check)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0; 
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Stack<Integer> stack = new Stack<Integer>();
        while(sc.hasNextInt()){
            int a=sc.nextInt();
            if(a==0){
                System.out.println(stack.pop());
            }else{
                stack.push(a);
            }
        }
    }
}

Measured memory_bytes: 17208
#include <iostream>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
    {
        puts("Possible");
    }
    else
    {
        puts("Impossible");
    }
}

Measured memory_bytes: 256
n,w=map(int,input().split())
wv=[list(map(int,input().split())) for i in range(n)]
wv.sort(key=lambda x:-x[1])#reverse
wv.sort(key=lambda x:x[0])
#print(wv)
w0=wv[0][0]
x=[[0],[0],[0],[0]]
for i in range(n):
    z=wv[i][0]-w0
    k=wv[i][1]+x[z][-1]
    l=len(x[z])
    if l*wv[i][0]<=w:
        x[z].append(k)
ma=0
l3=len(x[3])
l2=len(x[2])
l1=len(x[1])
for i in range(l3):
    for j in range(l2):
        for k in range(l1):
            d=w-(i*(w0+3)+j*(w0+2)+k*(w0+1))
            if d>=0:
                ma_sub=x[3][i]+x[2][j]+x[1][k]+x[0][min(d//w0,len(x[0])-1)]
            ma=max(ma,ma_sub)
print(ma)


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n;cin>>n;
    VL a(n);
    LL result = 0;
    REP(i,n){
        cin>>a[i];
        result ^= a[i];
    }

    REP(i,n){
        if(i!=0){
            cout<<" ";
        }
        cout<<(result^a[i]);
    }
    cout<<endl;

	return;
}

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

Measured memory_bytes: 4744
import Control.Monad
import Text.Printf
import Control.Applicative
import Data.List as L

main :: IO()
main = do
  _ <- getLine
  a <- map read . words <$> getLine
  printf "%d" $ sum.map (\x -> x * (x-1) `div` 2) $ map length $ group.sort $ scanl (+) 0 a

Measured memory_bytes: 114044
loop do
    n,m = gets.split(" ").map(&:to_i)
    break if n == 0 && m == 0
    place = Array.new(m).fill {|i| [i+1,0]} #[0] ??´??? [1] ????\¨??°
    n.times do
        a = gets.split(" ").map(&:to_i)
        0.upto(m-1) do |i|
            place[i][1] += a[i]
        end
    end
    new_place = place.sort {|i,j| if i[1] == j[1] then i[0] <=> j[0] else j[1] <=> i[1] end}
    puts new_place.map{|pl| pl[0]}.join(" ")
end

Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;

int n;
vector<pair<int,ll>> e[maxn];
int q,rt;
ll ans[maxn]={0};

bool u[maxn];
void dfs(int i){
	u[i]=1;
	for(pair<int,ll> t:e[i]){
		if(u[t.F]) continue;
		ans[t.F]=ans[i]+t.S;
		dfs(t.F);
	}
}

int main()
{
	scanf("%d",&n);
	REP(i,n-1){
		int x,y;
		ll z;
		scanf("%d%d%lld",&x,&y,&z);
		e[x].pb({y,z});e[y].pb({x,z});
	}
	scanf("%d%d",&q,&rt);
	dfs(rt);
	REP(i,q){
		int x,y;
		scanf("%d%d",&x,&y);
		printf("%lld\n",ans[x]+ans[y]);
	}
	return 0;
}


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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long ll;
typedef pair<int, int> pii;



int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n , val = 0;
    cin >> n;
    vi v(n);
    for(int &x : v)cin >> x , val ^= x;
    for(int x : v)cout << (val ^ x) << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 3988
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}

#ifndef ONLINE_JUDGE
#define dbg(x...)                 \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define dbg(x...)
#endif
#define endl "\n"
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define ROF(i, a, n) for (ll i = a; i >= n; i--)
#define all(x) (x).begin(), (x).end()
#define dline cout << "///REACHED///\n";

typedef long long ll;

const ll MOD = 1e+9 + 7;
const ll INF = 0x7f7f7f7f7f7f7f7f;
const int INFi = 0x7f7f7f7f;
const ll MAXN = 4e+5 + 7;


ll n;
vector<ll> h;
void solve(){
	cin>>n;
	h.resize(n);
	for(ll&x:h)cin>>x;
	vector<ll> dp(n,0);
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	FOR(i,2,n){
		dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
	}
	// dbg(dp);
	cout<<dp[n-1]<<endl;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T = 1;
    // cin >> T;
    while (T--)
    {
        solve();
    }
    return 0;
}


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

using namespace std;
int a,b,q,ans;
bool arr[105];
int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(0);cout.tie(0);
	cin>>a>>b;
	memset(arr,0,sizeof arr);
	for(int i=1;i<=b;i++){
		cin>>q;
		arr[q]=1;
	}
	for(int i=0;i<=1000;i++){
		if(!arr[a-i]){
			ans = a-i;
			break;
		}
		if(!arr[a+i]){
			ans = a+i;
			break;
		}
		
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n;
string s;

int main(){
	cin>>n;
	while(cin>>s){
		if(s.size()<6||s[0]!='>'){cout<<"NA"<<endl;continue;}
		int cur=2,l=0,l2=0,f=0,f2=0;
		if(s[1]=='\''){
			while(cur<s.size()){
				if(f2){f2=0;break;}
				else if(s[cur]=='='){
					if(!f)l++;
					else l2++;
				}
				else if(s[cur]=='#'){
					if(!l||f)break;
					else f=1;
				}
				else if(s[cur]=='~'){
					if(l&&l==l2){f2=1;}
					else break;
				}
				else break;
				cur++;
			}
		}
		else if(s[1]=='^'){
			while(cur<s.size()){
				if(f2){f2=0;break;}
				if(s[cur]=='Q'){
					if(!f)f=1;
					else break;
				}
				else if(s[cur]=='='){
					if(f==1)f=0;
					else break;
				}
				else if(s[cur]=='~'){
					if(!f)f=2;
					else if(f==2)f2=2;
					else break;
				}
				else break;
				cur++;
			}
		}
		if(f2==1)cout<<"A"<<endl;
		else if(f2==2)cout<<"B"<<endl;
		else cout<<"NA"<<endl;
	}
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int MaxN = 1e4 + 5;
char a[MaxN], b[MaxN];
int main(){
	scanf("%s", a + 1);
	scanf("%s", b + 1);
	int len1 = strlen(a + 1);
	int len2 = strlen(b + 1);
	int cnt1, cnt2;
	cnt1 = cnt2 = 0;
	for(int i = 1; i <= len1 + len2; i++){
		if(i & 1) printf("%c", a[++cnt1]);
		else printf("%c", b[++cnt2]);
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;

int main(){
	int n;
	vector<int> v;
	cin >> n;
	for(int i = 0; i < n; i++){
		char p;
		int x;
		cin >> p >> x;
		v.push_back((p == '(')? x : -x);
	}
	int k = 0;
	stack<int> st;
	for(int i = 0; i < v.size(); i++){
		k += v[i];
		if( k < 0 ){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << ((k == 0)? "YES" : "NO") << endl;
}

Measured memory_bytes: 1224
// OURL: https://atcoder.jp/contests/agc035/tasks/agc035_c
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

inline void set_edge(stringstream &ss, int i, int j) {
  ss << i << " " << j << "\n";
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  if (!(N & (N-1))) { // N=2^n
    cout << "No" << endl;
    return 0;
  }
  stringstream ss;
  set_edge(ss, 1,2);
  set_edge(ss, 2,3);
  set_edge(ss, 3,1+N);
  set_edge(ss, 1+N,2+N);
  set_edge(ss, 2+N,3+N);
  int c = (N-3);
  if (N % 2 == 0) {
    c--;
  }
  for (int i = 0; i < c; i+=2) {
    set_edge(ss, i+4+N, 1+N);
    set_edge(ss, i+5+N, i+4+N);
    set_edge(ss, i+5, 1+N);
    set_edge(ss, i+4, i+5);
  }
  if (N%2==0) {
    // N, 2Nを入れる必要がある.
    int p = N ^ (N-1) ^ 1; // p1 < N-1
    set_edge(ss, N, N-1);
    if (p & 1) { // odd
      set_edge(ss, N*2, p);
    } else {
      set_edge(ss, N*2, p+N);
    }
  }
  cout << "Yes" << endl;
  cout << ss.str() << endl;
  return 0;
}


Measured memory_bytes: 9220
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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 ll INF=1e18;

int main(){
    ll n;
    cin >> n;
    ll ans=0;
    rep(i,n){
        ll l,r;
        cin >> l >> r;
        ans+=r-l+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> ans(10001,0);
    for(int x = 1; x <= 100; x++){
        for(int y = 1; y <= 100; y++){
            for(int z = 1; z <= 100; z++){
                int now = x*x + y*y + z*z + x*y + y*z + z*x;
                if(now <= 10000) ans[now]++;
            }
        }
    }
    rep(i,n){
        cout << ans[i+1] << endl;
    }
    return 0;
}

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

int main() {
    int x,y;
    cin >> x >> y;
    if (x == 1 && y == 1) {
        cout << 1000000 << endl;
    } else {
        cout << (max(0,4-x)+max(0,4-y))*100000 << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	int n,m,x;
	cin >> n >> m >> x;
	int left = 0;
	rep(i,m){
		int xx;
		cin >> xx;
		if(xx<x) left++;
	}
	//cout << left << endl;
	cout << min(left,m-left) << endl;
	return 0;
}

Measured memory_bytes: 256
"""
her basamağaa bak, if 7 varsa print yes else print no :)

1. 526 572 777 : "526" "572" "777" 
"""
flag = False

N = input()
N = int(N)

for i in range(3) :
    if N%10==7:
        flag = True
    N = N//10
 
    
if flag :
    print("Yes")
else :
    print("No")

Measured memory_bytes: 8940
#include<iostream>

int main(){
	//入力機構
	int a,b,c,d;
	std::cin>>a>>b>>c>>d;
	//解答
	bool judge=(std::abs(a-c)<=d ||//直接連絡が取れる
		(std::abs(a-b)<=d && std::abs(b-c)<=d)//間接的に連絡できる
		);	
	//結果出力
	if(judge){
		std::cout<<"Yes"<<std::endl;
	} else{
		std::cout<<"No"<<std::endl;
	}
	return 0;
}


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

int main(void)
{
  int n;
  int a[2][100];
  int dp[2][100];
  cin>>n;
  for(int i=0;i<2;i++)
    for(int j=0;j<n;j++)
      cin>>a[i][j];
  
  dp[0][0]=a[0][0];
  dp[1][0]=a[1][0]+a[0][0];
  
  for(int i=1;i<n;i++)
    dp[0][i]=dp[0][i-1]+a[0][i];
  
  for(int i=1;i<n;i++)
  {
    dp[1][i]=max(dp[0][i],dp[1][i-1])+a[1][i];
  }
  
  if(n==1)
    cout<<a[0][0]+a[1][0]<<endl;
  else
  cout<<dp[1][n-1]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int X;
    cin >> X;
    rep(i, 50000) {
        if(i*(i-1)/2 < X && X <= i*(i+1)/2) {
            cout << i << endl;
            return 0;
        }
    }
}

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

int main(){

  while(1){
    int n;
    int x[50],y[50];
    
    scanf("%d",&n);
    if(n==0) break;
    
    for(int i=0;i<n;i++){
      scanf("%d %d",&x[i],&y[i]);
    }
    
    for(int i=0;i<n-1;i++){
      for(int j=n-1;j>i;j--){
	if(y[j-1]>y[j]){
	  swap(y[j-1],y[j]);
	  swap(x[j-1],x[j]);
	}
      }
    }
    
    //for(int i=0;i<n;i++) printf("%d %d\n",x[i],y[i]);
    
    int sum=0;
    for(int i=0;i<n;i++){
      sum+=x[i];
      if(sum>y[i]){
	printf("No\n");
	break;
      }
      else if(i==n-1){
	printf("Yes\n");
      }
    } 
  }

  return 0;
}

Measured memory_bytes: 1168
# from line_profiler import LineProfiler
from collections import deque
from sys import stdin

def main():
    while(True):
        W, H = map(int, stdin.readline().split())
        if not W: break
        tx,ty = map(int, stdin.readline().split())
        kx,ky = map(int, stdin.readline().split())
        ma = [[False]+[bool(1-int(a)) for a in stdin.readline().split()]+[False] for i in range(H)]
        ma = [[False]*(W+2)] + ma + [[False]*(W+2)]
        que = deque([[tx,ty,kx,ky,0]])
        pas = set()
        ans = "NA"
        while(que):
            tx,ty,kx,ky,c = que.popleft()
            if tx == kx and ty == ky:
                ans = c
                break
            if c+1 > 100: continue
            for dx,dy in [[-1,0],[0,-1],[1,0],[0,1]]:
                tdx, tdy = ( dx, dy) if ma[ty+dy][tx+dx] else (0,0)
                kdx, kdy = (-dx,-dy) if ma[ky-dy][kx-dx] else (0,0)
                ttx,tty,kkx,kky = tx+tdx,ty+tdy,kx+kdx,ky+kdy
                if (ttx,tty,kkx,kky) in pas: continue
                que.append([ttx,tty,kkx,kky,c+1])
                pas.add((ttx,tty,kkx,kky))
        print(ans)

if __name__ == "__main__":
    # prf = LineProfiler()
    # prf.add_function(main)
    # prf.runcall(main)
    # prf.print_stats()
    main()


Measured memory_bytes: 35188
N = int(input())
A = list(map(int, input().split()))

Dict={}
for i in A:
    if(Dict.get(i,None)==None):
        Dict[i]=1
    else:
        Dict[i]+=1

T=1
C=0
Dict = sorted(Dict.items(), key=lambda x:-x[0])
for i in Dict:
    if((i[1]>=2)&(C>=1)):
        T*=i[0]
        C+=1
        break
    if(i[1]>=4):
        T*=i[0]*i[0]
        C=2
        break
    if(i[1]>=2):
        T*=i[0]
        C+=1

if(C==2):
    print(T)
else:
    print("0")
    

Measured memory_bytes: 25100
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

ll d[110][110];
signed main(void)
{
	while(true) {
		int n, m, s, g1, g2;
		cin >> n >> m >> s >> g1 >> g2;
		if(!n &&!m && !s && !g1 && !g2) break;
		s--, g1--, g2--;
		REP(i, n) REP(j, n) d[i][j] = INF;
		REP(i, n) d[i][i] = 0;
		REP(i, m) {
			int a, b, c;
			cin >> a >> b >> c;
			d[a-1][b-1] = c;
		}

		REP(k, n) REP(i, n) REP(j, n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
		ll ret = INF;
		REP(i, n) {
			//cout << "i:" << i << " " << ret << " " << d[s][i] << " " << d[i][g1] << " " << " " << d[i][g2] << endl;
			ret = min(ret, d[s][i] + d[i][g1] + d[i][g2]);
		}
		cout << ret << endl;
	}

	return 0;
}

Measured memory_bytes: 3140
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>

inline void read(int &T) {
	int x=0;bool f=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=!f;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	T=f?-x:x;
}

int n,a,b,c;
char ans[100001];
std::string cmd[100001];

void dfs(int step,int a,int b,int c) {
	if(step>n) {
		puts("Yes");
		for(int i=1;i<=n;++i) {
			printf("%c\n",ans[i]);
		}
		exit(0);
	}
	if(cmd[step]=="AB") {
		if(a) {
			ans[step]='B';
			dfs(step+1,a-1,b+1,c);
		}
		if(b) {
			ans[step]='A';
			dfs(step+1,a+1,b-1,c);
		}
	}
	if(cmd[step]=="AC") {
		if(a) {
			ans[step]='C';
			dfs(step+1,a-1,b,c+1);
		}
		if(c) {
			ans[step]='A';
			dfs(step+1,a+1,b,c-1);
		}
	}
	if(cmd[step]=="BC") {
		if(b) {
			ans[step]='C';
			dfs(step+1,a,b-1,c+1);
		}
		if(c) {
			ans[step]='B';
			dfs(step+1,a,b+1,c-1);
		}
	}
}

int main() {
	read(n),read(a),read(b),read(c);
	for(int i=1;i<=n;++i) std::cin>>cmd[i];
	dfs(1,a,b,c);puts("No");
	return 0;
}

Measured memory_bytes: 14692
#include <iostream>
#include <vector>
#include <random>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;

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

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

using namespace std;

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

const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, a[100001] = {};
    cin >> n;
    rep(i, n) {
        cin >> a[i];
    }

    int ans = 0;
    int check[100001] = {};
    rep(i, n) {
        if (check[i]) continue;
        if (a[a[i] - 1] ==  i + 1) {
            ++ans; 
            check[a[i] - 1 ] = 1;
        }
    }

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int MAX = 2e5 ;
const int INF = 1e9 + 1e5 + 2;
const int mod= 1e9+7;
using namespace std;
bool cmp(const pair<int,int> &a,
               const pair<int,int> &b)
{
       if (a.first==b.first)
           return (a.second >b.second);
       return (a.first<b.first);
}
int main()
{
    int n,m;

    cin>>n>>m;

    int p=1;
    for (int i=n; i>n-2; --i)
        p*=i;

    p/=2;

    int pp=1;

    for (int i=m; i>m-2; --i)
        pp*=i;

    pp/=2;

    cout<<p+pp;






}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int P = sc.nextInt();
		int Q = sc.nextInt();
		int R = sc.nextInt();
		ArrayList<Integer> ary = new ArrayList<Integer>();

		int sum1 = P + Q;
		int sum2 = R + Q;
		int sum3 = P + R;
		int sum4 = Q + R;
		int sum5 = R + P;
		int sum6 = Q + P;

		ary.add(sum1);
		ary.add(sum2);
		ary.add(sum3);
		ary.add(sum4);
		ary.add(sum5);
		ary.add(sum6);

		Collections.sort(ary);

		System.out.println(ary.get(0));

		sc.close();
	}
}

Measured memory_bytes: 23124
#include <iostream>
using namespace std;
int house[4][3][10];
int main(){
  int n; cin>>n;
  for(int i = 0; n > i; i++){
    int a,b,c,d;cin>>a>>b>>c>>d;a--;b--;c--;
    house[a][b][c] += d;
  }
  for(int i = 0; 4 > i; i++){
    for(int j = 0; 3 > j; j++){
      for(int k = 0; 10 > k; k++){
        cout << " " << house[i][j][k];
      }
      cout << endl;
    }
    if(i+1 != 4)cout << "####################" << endl;
  }
}


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

int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int l = s.length();
  set<string> a;
  for (char c = 'a'; c <= 'z'; c++) {
    for (int i = 0; i < l; i++) {
      if (s[i] == c) {
        string t;
        for (int j = i; j < l; j++) {
          t += s[j];
          a.insert(t);
          if (j - i + 1 >= k) break; 
        }
      }
    }
    if (a.size() >= k) break;
  }
  auto itr = a.begin();
  /*for (int i = 0; i < a.size(); i++) {
    cout << *itr << endl;
    itr++;
  } */ 
  for (int i = 0; i < k - 1; i++) itr++;
  cout << *itr << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<62)           //1LL<<63でオーバーフロー

int main(int argc,char* argv[]){
    int a,b,c;
    cin >> a >> b >> c;
    int n;
    cin >> n;

    for(int i=0;i<n;i++){
        if(a>=b) b*=2;
        else if(a<b && b>=c) c*=2;
        else if(a<b && b<c) break;
    }

    if(a<b && b<c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

string day[7] =  {"Sunny", "Cloudy", "Rainy"};

int main(){
    int D;
    cin >> D;
    cout << "Christmas";
    for(int i = 0; i < 25 - D; i++){
        cout << " Eve";
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

int main() {
  int n, a, b, c, x;
  while (true) {
    cin >> n >> a >> b >> c >> x;
    if (n == 0 && a == 0 && b == 0 && c == 0 && x == 0) break;
    int res = 0;
    rep (iii, n) {
      int y;
      cin >> y;
      int x0 = x;
      while (x != y) {
	++res;
	x = (a * x + b) % c;
	if (x == x0 || res > 10000) {
	  for (++iii; iii < n; ++iii) cin >> y;
	  goto end;
	}
      }
      x = (a * x + b) % c;
      ++res;
    }
    cout << res - 1 << endl;
    continue;
  end:;;
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<ll> diff(N), A(N), B(N);
    ll ans = 0, sumA = 0, sumB = 0, minus = 0;
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];

    rep(i, N) {
        sumA += A[i];
        sumB += B[i];
        if (A[i] < B[i]) {
            ans++;
            minus += A[i] - B[i];
        }
        diff[i] = A[i] - B[i];
    }

    if (sumA < sumB) {
        cout << -1 << endl;
        return 0;
    }
    sort(all(diff));
    reverse(all(diff));

    rep(i, N) {
        if (minus >= 0) {
            break;
        }
        minus += diff[i];
        ans++;
    }

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

Measured memory_bytes: 2688
from collections import deque


def main():
    N, u, v = map(int, input().split())
    adj = [set() for _ in range(N)]
    for _ in range(N-1):
        A, B = map(int, input().split())
        adj[A-1].add(B-1)
        adj[B-1].add(A-1)
    move = [-1] * N
    q = deque([(v-1, 0)])
    while len(q):
        cur, c = q.popleft()
        move[cur] = c
        for nxt in adj[cur]:
            if move[nxt] == -1:
                q.append((nxt, c+1))
    reachable = [False] * N
    q = deque([(u-1, 0)])
    while len(q):
        cur, c = q.popleft()
        reachable[cur] = True
        for nxt in adj[cur]:
            if c+1 <= move[nxt] and not reachable[nxt]:
                q.append((nxt, c+1))
    ans = 0
    for i in range(N):
        if reachable[i] and len(adj[i]) >= 2:
            ans = max(ans, move[i])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 78112
process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

const l = [];

reader.on("line", (line) => {
  l.push(line);
});

reader.on("close", () => {
  let f = () => Array(13).fill(1);
  let o = {
    S: f(),
    H: f(),
    C: f(),
    D: f(),
  };

  let n = Number(l[0]);
  for (let i = 1; i <= n; i++) {
    let [M, N] = l[i].split(" ");
    o[M][Number(N) - 1] = 0;
  }
  let p = (m) => o[m].forEach((e, i) => e && console.log(`${m} ${i + 1}`));
  p("S");
  p("H");
  p("C");
  p("D");
});



Measured memory_bytes: 16532
#include <stdio.h>

int main()
{
	int i,j,H,W;
	while(1){
		scanf("%d %d", &H, &W);
		if(H == 0 && W == 0) break;

		for(i=0; i<H; i++){
			for(j=0; j<W; j++){
				if((i+j)%2 == 0){		//the even place will be printed #
					printf("#");
				}else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
class Solver(object):
    def __init__(self):
        self.n = int(input())

    def solve(self):
        prev = input()
        self.words = set([prev])
        valid = True
        for _ in range(self.n-1):
            word = input()
            if valid:
                if word in self.words:
                    valid = False
                if word[0] != prev[-1]:
                    valid = False
                self.words.add(word)
                prev = word
        if valid:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    s = Solver()
    s.solve()

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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   vector<vector<int>> c(3, vector<int>(3));
   rep(i, 3) {
     rep(j, 3) {
       cin >> c.at(i).at(j);
     }
   }

   string ans = "Yes";
   rep(i, 2) {
     if (c.at(i).at(0) - c.at(i).at(1) != c.at(i + 1).at(0) - c.at(i + 1).at(1) || c.at(i).at(2) - c.at(i).at(1) != c.at(i + 1).at(2) - c.at(i + 1).at(1)) {
       ans = "No";
       break;
     }
   }
   cout << ans << endl;
 }


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


void solve(long long N, long long K, std::vector<long long> p){
    double init = 0;
    for (ll i=0;i<K;i++){
        init += (1+p[i])/2.0;
    }
    double maximum = init;
    for (ll j=0;j<N-K;j++){
        init -= (1+p[j])/2.0;
        init+= (1 + p[j+K])/2.0;
        if ( maximum<init) maximum = init;
    }
    printf("%f\n",maximum);

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, K, std::move(p));
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
int main(void) {

	int N;
	scanf("%d", &N);
	if (N < 10) {
		printf("%d", N);
	}
	else if (N >= 10 && N < 100) {
		printf("%d", 9);
	}
	else  if (N >= 100 && N < 1000) {
		printf("%d",N-100 +1+ 9);
	}
	else if (N >= 1000 && N < 10000) {
		printf("%d",909);
	}
	else if (N >= 10000 && N < 100000) {
		printf("%d", N -10000 +1+ 9 + 900);
	}
	else if (N == 100000) {
		printf("%d",9+900+90000 );
	}


	return 0;

}

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

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

  if(N==1){
    cout << "Hello World" << endl;
  }
  else{
    int A, B;
    cin >> A >> B;
    cout << A+B << endl;
  }

return 0;  
}

Measured memory_bytes: 256
// DPL_1_G Knapsack Problem with Limitations

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

#define MAXN 110
#define MAXW 10010

using namespace std;

int dp[2][MAXW + 1][15]; // 14=ceil(log2(10000))

struct item {
  int v, w, m;
};

int main() {
  int N, W;
  cin >> N >> W;
  vector<item> A;
  for (int i = 0; i < N; ++i) {
    int v, w, m;
    cin >> v >> w >> m;
    A.push_back({v, w, m});
  }

  // 1 => 1
  // 2 => 1, 1
  // 3 => 1, 2
  // 4 => 1, 2, 1
  // 5 => 1, 2, 2
  // 6 => 1, 2, 3
  // 7 => 1, 2, 4
  // 8 => 1, 2, 4, 1
  // 9 => 1, 2, 4, 2
  // 10 => 1, 2, 4, 3
  // x => stop at last power of 2 at most x/2
  //      then, the last choice is x minus
  //      (the last power of 2, times 2, minus 1)
  vector<int> maxj(N);
  for (int i = 0; i < N; ++i) {
    maxj[i] = log2(A[i].m) - 1;
    int lastchoice = (maxj[i] < 0) ? 1 : (A[i].m - (1 << ((maxj[i]) + 1)) + 1);
  }

  // Handle the first item separately: no wraparound on the last choice
  for (int w = 1; w <= W; ++w) {
    int lastchoice = (A[0].m == 1) ? 1 : (A[0].m - (1 << ((maxj[0]) + 1)) + 1);
    if (A[0].w * lastchoice <= w)
      dp[0][w][maxj[0] + 1] = lastchoice * A[0].v;
    for (int j = maxj[0]; j >= 0; --j) {
      int choice = 1 << j;
      dp[0][w][j] = dp[0][w][j + 1];
      if (A[0].w * choice <= w)
        dp[0][w][j] = max(dp[0][w][j], (A[0].v * choice) +
                                           dp[0][w - A[0].w * choice][j + 1]);
    }
  }

  // for each item
  for (int i = 1; i < N; ++i) {
    // each weight
    for (int w = 1; w <= W; ++w) {
      // and each (logM, many non-mutually-exclusive) choice of quantity
      for (int j = 0; j <= maxj[0] + 1; ++j)
        dp[i % 2][w][j] = 0; // clear before filling in

      // handle the last (potentially not power of 2) quantity separately:
      // the alternative is comparing to the prior item, rather than the
      // next quantity of the same item
      int lastchoice =
          (A[i].m == 1) ? 1 : (A[i].m - (1 << ((maxj[i]) + 1)) + 1);
      dp[i % 2][w][maxj[i] + 1] = dp[!(i % 2)][w][0];
      if (A[i].w * lastchoice <= w)
        dp[i % 2][w][maxj[i] + 1] = max(
            dp[i % 2][w][maxj[i] + 1],
            dp[!(i % 2)][w - (A[i].w * lastchoice)][0] + (lastchoice * A[i].v));

      for (int j = maxj[i]; j >= 0; --j) {
        int choice = 1 << j;
        dp[i % 2][w][j] = dp[i % 2][w][j + 1];
        if (A[i].w * choice <= w)
          dp[i % 2][w][j] =
              max(dp[i % 2][w][j],
                  (A[i].v * choice) + dp[i % 2][w - A[i].w * choice][j + 1]);
      }
    }
  }

  cout << dp[(N - 1) % 2][W][0] << endl;
}



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

int s[30],t[30];
string S,T;

int main(){
  cin >> S;
  cin >> T;
  for(int i=0;i<S.size();i++){
    s[S[i]-'a']++;
    t[T[i]-'a']++;
  }

  bool ans=true;
  for(int i=0;i<S.size();i++){
    if(S[i] != T[i]){
      if(s[S[i]-'a'] != t[T[i]-'a']) ans = false;
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main() {
  string N;
  cin >> N;
  long long sum = 0;
  int n = N.size();
  for(int i = 0; i < (1 << n-1); i++){
    long long dig = N.at(0) - '0';
    for(int t = 0; t < n-1; t++){
      if(i & (1 << t)){
        sum += dig;
        dig = N.at(t+1) - '0';
      }
      else{
        dig *= 10;
        dig += N.at(t+1) - '0';
      }
    }
     sum += dig;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int si=-1,ei=-1;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='A'&&si==-1)
		{
			si=i;
		}
		else if(s[i]=='Z'&&si!=-1)
		{
			ei=i;
		}

	}
	cout<<(ei-si+1);
}

Measured memory_bytes: 640