akhauriyash/Code-Regression huggingface dataset:
a=int(input())
b=int(input())
if a==1 and b==2:
	print(3)
elif a==1 and b==3:
	print(2)
elif a==2 and b==1:
	print(3)
elif a==2 and b==3:
	print(1)
elif a==3 and b==1:
	print(2)
elif a==3 and b==2:
	print(1)

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    ll ans=0;
    for(int i=0;i<=3000;i++){
        for(int j=0;j<=3000;j++){
            int memo=n-i*r-j*g;
            if(memo<0) continue;
            if(memo%b==0){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    
}

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

int main()
{
    string str,tr;
    cin>>str>>tr;
    vector<vector<data_type> > dp(str.size()+1,vector<data_type>(tr.size()+1,0));
    for(int i=1; i<=str.size(); i++)
        {
            for(int j=1; j<=tr.size(); j++)
                {
                    if(str[i-1]==tr[j-1])
                        dp[i][j]=dp[i-1][j-1]+1;
                    else
                        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                }

        }
    string ans;
    int i=str.size(),j=tr.size();
    while(i>0&&j>0)
        {
            if(dp[i][j]==dp[i-1][j])
                i--;
            else if(dp[i][j]==dp[i][j-1])
                j--;
            else
                i--,j--,ans+=str[i];
        }

    for(int i=ans.size()-1; i>=0; i--)
        cout<<ans[i];
        cout<<endl;



    return 0;
}


Measured memory_bytes: 73748
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
int64_t f(int64_t x){
    if(x%2!=0){//xが奇数
        if((x+1)/2 % 2 == 0){
            return 0;
        }
        else{
            return 1;
        }
    }
    else{
        if(x/2 % 2 == 0){
            return 0 ^ x;
        }
        else{
            return 1 ^ x;
        }
    }
}
int main(){
    int64_t a,b;
    cin>>a>>b;
    cout<<(f(a-1)^f(b))<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
using namespace std;

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

int main() {
	int n;
	while(cin >> n, n) {
		vector<string> word(n);
		int depth[n];
		rep(i, n) {
			string in;
			cin >> in;
			int dots = 0;
			while(in[dots]=='.') dots++;
			word[i] = in.substr(dots, in.length()-dots);
			depth[i] = dots;
		}
		cout << word[0] << endl;
		bool bar[1001] = {};
		for(int i=1; i<n; i++) {
			rep(j, depth[i]-1) {
				if(bar[j+1]) cout << '|';
				else         cout << ' ';
			}
			cout << '+' << word[i] << endl;

			int nxt = i+1;
			while(nxt<n && depth[i]<depth[nxt]) nxt++;
			if(nxt<n && depth[nxt]==depth[i]) bar[depth[i]] = true;
			else bar[depth[i]] = false;
		}
	}
	return 0;
}

Measured memory_bytes: 1316
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  string s;
  cin >> s;

  bool no = false;
  bool we = false;
  bool so = false;
  bool ea = false;

  for (int i = 0; i < s.length(); i++){
    string ch = s.substr(i,1);
    if(ch == "N")
      no = true;
    if(ch == "E")
      ea = true;
    if(ch == "W")
      we = true;
    if(ch == "S")
      so = true;
  }

  if(no && so && we && ea){
    cout << "Yes" << endl;
  }else if(no && so && !we && !ea){
    cout << "Yes" << endl;
  }else if(!no && !so && we && ea){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
void main()
{
    string s = readln.chomp;

    writeln(
        s.canFind('N') == s.canFind('S')
        && s.canFind('W') == s.canFind('E')
        ? "Yes"
        : "No"
    );
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n, i, j, result=0, minp=0;
  int p[200001];
  scanf("%d", &n);
  for(i=1;i<=n;i++) scanf("%d", &p[i]);
  result = n;
  
  minp = p[1];
  for(i=1;i<=n;i++){
    if(minp > p[i]) minp = p[i];

    if(!(p[i] <= minp)){
      result--;
    }
  }
  printf("%d", result);
}

Measured memory_bytes: 1024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, usize, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};

fn main() {
    input!{
        n: usize,
        a: [i64; n],
    }
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let mut counter = HashMap::new();
    for x in &a {
        let count = counter.entry(x).or_insert(0);
        *count += 1;
    }
    let s: i64 = counter.values().map(|c| c * (c - 1) / 2).sum();
    for x in &a {
        writeln!(out, "{}", s - counter[x] + 1).unwrap();
    }
}


Measured memory_bytes: 20632
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <functional>
#include <bitset>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";}
template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";}
template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 1e9+7;

int main() {
  int h1,m1,h2,m2,k; cin>>h1>>m1>>h2>>m2>>k;
  m1+=h1*60; m2+=h2*60;
  cout<<m2-m1-k<<endl;
}
// Thank you for making problems and running the contest

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin >> s;
  cin >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  int result = s.compare(t);
  
  if(result < 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
# ターン制だから
while True:
    # 自分の体力を相手の攻撃力で引かれる
    c-=b
    if c<=0:
        print("Yes")
        exit()
    # 生きてた場合相手のターンへ
    a-=d
    if a<=0:
        print("No")
        exit()

Measured memory_bytes: 9180
H, W = map(int, input().split())

src = [input() for i in range(H)]
ans = []

for row in src:
  ans.append(list(row))

dxy = [(-1,-1),(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1)]
for y in range(H):
    for x in range(W):
        if src[y][x] == '#': continue
        c = 0
        for dx,dy in dxy:
            if x+dx < 0 or x+dx > W-1 or y+dy < 0 or y+dy > H-1: continue
            if src[y+dy][x+dx] == '#': c += 1
        ans[y][x] = c
 
for row in ans:
    print(''.join(list(map(str,row))))

Measured memory_bytes: 3188
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int h, w; cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

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

    vector<vector<int>> ans(h, vector<int>(w, -1));

    rep(i, h) {
        rep(j, w) if (s[i][j] == '.') {
            int cnt = 0;
            rep(k, 8) {
                int ny = i + dy[k];
                int nx = j + dx[k];

                if (ny >= 0 and ny < h and nx >= 0 and nx < w) {
                    if (s[ny][nx] == '#') ++cnt;
                }

            }
            ans[i][j] = cnt;
        }
    }

    rep(i, h) {
        rep(j, w) {
            if (ans[i][j] == -1) cout << '#';
            else cout << ans[i][j];
        }
        cout << "\n";
    }
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

struct UnionFind {
#define MAX 100001
    int root[MAX];
    void Init() {rep(i,MAX) root[i] = -1;}
    void unite(int a ,int b) {
        int a_root = find(a),b_root = find(b);
        if (a_root != b_root) {
            if (root[a_root] > root[b_root]) {
                root[a_root] += root[b_root];
                root[b_root] = a_root;
            } else {
                root[b_root] += root[a_root];
                root[a_root] = b_root;
            }
        }
    }
    int find(int a) {
        if (root[a] < 0) return a;
        else {
            root[a] = find(root[a]);
            return root[a];
        }
    }
    int size(int a) {
        int a_root = find(a);
        return root[a_root];
    }
    /*
     * root : rootの番号
     * unite : 併合
     * find : aのrootを返す
     * size : aのグループの要素数
     * */
};

int n,m,p[100000],x,y,ans;
UnionFind UF;

signed main() {
    UF.Init();
    cin >> n >> m;ans=n;
    rep(i,n) cin >> p[i];
    rep(i,m) cin >> x >> y, UF.unite(x,y);
    rep(i,n) if (UF.find(i+1) != UF.find(p[i])) ans--;
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int a,b,c,d,k;
    cin >> a >> b  >> c >> d >> k;
    int end = c*60+d;
    int s = a*60+b;
    cout << end-s-k << endl;
    return 0;
}

Measured memory_bytes: 3676
#include <stdio.h>

int main(){
  char a[]="0 1 2 3 4 5 6 7 8 9 5 4 3 2 1 0 1 2 3 4 5 6 7 8";
  int b[10][10]={
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{28,-1, 2, 2, 2, 2, 2, 2, 2, 2},
{26,26,-1, 4, 4, 4, 4, 4, 4, 4},
{24,24,24,-1, 6, 6, 6, 6, 6, 6},
{22,22,22,22,-1, 8, 8, 8, 8, 8},
{20,20,20,20,20,-1,10,10,10,10},
{12,12,12,12,12,12,-1,12,12,12},
{14,14,14,14,14,14,14,-1,14,14},
{16,16,16,16,16,16,16,16,-1,16},
{18,18,18,18,18,18,18,18,18,-1}};
  int c[10][10]={
{-1, 2, 4, 6, 8,10,12,14,16,18},
{30,-1, 4, 6, 8,10,12,14,16,18},
{30,28,-1, 6, 8,10,12,14,16,18},
{30,28,26,-1, 8,10,12,14,16,18},
{30,28,26,24,-1,10,12,14,16,18},
{30,28,26,24,22,-1,12,14,16,18},
{30,28,26,24,22,20,-1,14,16,18},
{30,28,26,24,22,20,42,-1,16,18},
{30,28,26,24,22,20,42,44,-1,18},
{30,28,26,24,22,20,42,44,46,-1}};
  int d,e,f,g,h;
  scanf("%d",&d);
  for(e=0;e<d;e++){
    scanf("%d %d",&f,&g);
    for(h=b[f][g];h<=c[f][g];h++) printf("%c",a[h]);printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#pragma 03
using namespace std;
using namespace __gnu_pbds;
ll mod = 1e9 + 7;
int main(){
 	ll n; string s; cin >> n >> s;
	ll cnt = 0, ans = 1;
	for (ll i = 0; i < 2 * n; i++){
		ll k = cnt % 2;
		if (s[i] == 'B') k ^= 1;
		if (k == 1) cnt++;
		else if (cnt > 0){
			(ans *= cnt) %= mod; cnt--;
		}
		else{
			cout << 0 << endl; return 0;
		}
	}
	if (cnt > 0){
		cout << 0 << endl; return 0;
	}
	for (ll i = 1; i <= n; i++) (ans *= i) %= mod;
 	cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
  
  public static void main (String[] args){
    
    Main main = new Main();
    main.solve();
  }
  
  private void solve(){
    
	Scanner scanner = new Scanner (System.in);
    
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int K = scanner.nextInt();
    
    int count = 0;
    
    int number;
    
    if (A<B){
      number=A;
    }else {
      number=B;
    }
    
    for (; number<=A&&number<=B; number--){
      
      if(A%number==0&&B%number==0){
        count++;
        if (count==K){
          System.out.println(number);
          break;
        }
      }
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    int res = 0;
    vi p(n); for(auto& e : p) cin >> e, res += e;

    sort(_all(p));
    res -= p.back() / 2;

    cout << res << endl;

    return 0;
}


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

int main(){
  int K;
  string S;
  string result;
  int size_s;
  
  cin >> K >> S;
  size_s = S.size();
  
  if(size_s > K){
    cout << S.substr(0, K) + "..." << endl;
  }
  else{
    cout << S << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3628
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<double, double>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
ll mod = 1000000007LL;

const ll inf = 1e9;


int main() {
	int n, m, r;
	cin >> n >> m >> r;
	vector<int> rs(r);
	rep(i, r) {
		cin >> rs[i];
		rs[i] --;
	}
	sort(rs.begin(),rs.end());

	ll d[n][n];
	rep(i,n) rep(j,n) {
		d[i][j] = i == j ? 0 : inf;
	}


	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		
		d[a][b] = c;
		d[b][a] = c;

	}



	rep(k, n) rep(i, n) rep(j,n) {
		d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	}

	ll ans = inf;
	do {
		ll total = 0;
		rep(i, r - 1) {
			total += d[rs[i]][rs[i+1]];
		}
		//cout << "total:" << total << endl;
		ans = min(total,ans);



  	} while ( next_permutation(rs.begin(),rs.end()));

  	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3492
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cstdlib>
#include<stack>
#define ll long long
#define maxn 1e7+5
using namespace std;
const int mod=1e9+7;
int n,m,f[2][301][301][3];
struct pp
{
	int l,v,next;
}a[301];
int cnt,h[301],ans;
void add(int x,int y,int z)
{
	cnt++;a[cnt].l=y;a[cnt].v=z;a[cnt].next=h[x];h[x]=cnt;
}
int main()
{
	scanf("%d%d",&n,&m);
	int l,r,x;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&l,&r,&x);
		add(r,l,x);
	}
	f[1][0][0][1]=1;f[1][0][0][2]=1;f[1][0][0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<i;j++)
		{
			for(int k=0;k<i;k++)
			{
				for(int t=0;t<3;t++)
				{
					int p=i&1;
					if(f[p][j][k][t]==0)continue;
					for(int z=h[i];z;z=a[z].next)
					{
						l=a[z].l,x=a[z].v;
						int tot=1;if(j>=l)tot++;if(k>=l)tot++;//cout<<tot<<x<<endl;
						if(tot!=x)
						{
							f[p][j][k][0]=0;f[p][j][k][1]=0;f[p][j][k][2]=0;
							break;
						}//cout<<"=="<<p<<endl;
					}//cout<<i<<" "<<j<<" "<<k<<" "<<t<<" "<<f[p][j][k][t]<<"+++"<<endl;
					if(f[p][j][k][t]==0)break;
					if(i==n)continue;
					f[p^1][j][k][t]=(f[p^1][j][k][t]+f[p][j][k][t])%mod;
					if(t==0)
					{
						f[p^1][i][k][1]=(f[p^1][i][k][1]+f[p][j][k][t])%mod;
						f[p^1][i][j][2]=(f[p^1][i][j][2]+f[p][j][k][t])%mod;
					}
					else if(t==1)
					{
						f[p^1][i][k][0]=(f[p^1][i][k][0]+f[p][j][k][t])%mod;
						f[p^1][j][i][2]=(f[p^1][j][i][2]+f[p][j][k][t])%mod;
					}
					else if(t==2)
					{
						f[p^1][k][i][0]=(f[p^1][k][i][0]+f[p][j][k][t])%mod;
						f[p^1][j][i][1]=(f[p^1][j][i][1]+f[p][j][k][t])%mod;
					}
					if(i!=n)f[p][j][k][t]=0;
				}
			}
		}
	}
	for(int j=0;j<n;j++)
		for(int k=0;k<n;k++)
			for(int t=0;t<3;t++)
			ans=(ans+f[n&1][j][k][t])%mod;
			cout<<ans;
			
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

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

    int N; cin >> N;
    vc<pi> v(N);
    rep(i,N) cin >> v[i].se >> v[i].fi;
    int t=0;
    sort(all(v));
    bool can=true;
    rep(i,N){
        if(v[i].se+t>v[i].fi) can=false;
        t+=v[i].se;
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3456
n=int(input())
data=list(map(lambda x:[str(x),-1],input()))
while 1:
    i=0
    while i<len(data):
        if data[i][0]==')' and data[i][1] == -1:
            break
        i+=1
    if i==len(data):
        break
    j=i-1
    while j>=0:
        if data[j][0]=='(' and data[j][1]==-1:
            data[i][1]=1
            data[j][1]=1
            break
        j-=1
    if j==-1:
        data[i][1]=1
        data.insert(0,['(',1])
while 1:
    i=len(data)-1
    while i>=0:
        if data[i][0]=='(' and data[i][1] == -1:
            break
        i-=1
    if i==-1:
        break
    data[i][1]=1
    data.append([')',1])
print(''.join(list(map(lambda x:x[0],data))))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3005;
const long long int MOD = 998244353ll;
long long int A[MAXN], poly[2][MAXN];
long long int power(long long int a, long long int b)
{
	if (b == 0)
	{
		return 1;
	}
	long long int ans = power(a, b/2);
	ans = (ans * ans)%MOD;
	if (b%2)
	{
		ans = (ans * a)%MOD;
	}
	return ans;
}
int main(int argc, char const *argv[])
{
	int n,s;
	cin>>n>>s;
	for (int i = 0; i < n; ++i)
	{
		cin>>A[i];
	}

	long long int two_inv = power(2, MOD - 2);

	poly[1][0] = 1;
	for (int idx = 0; idx < n; ++idx)
	{
		int curr = (idx%2);
		int prev = 1 - curr;

		for (int i = 0; i < MAXN; ++i)
		{
			poly[curr][i] = poly[prev][i];
			if (i >= A[idx])
			{
				poly[curr][i] = (poly[prev][i] + poly[prev][i - A[idx]]*two_inv)%MOD;
			}
		}
	}

	long long int ans = power(2, n);
	ans = (ans * poly[(n - 1)%2][s])%MOD;

	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3704
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <functional>
#include <numeric>
#include <cassert>
#include <algorithm>

#define INF 100000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int, int>;


int main() {
    ll a,b,c,d,ans,m1,m2,m3,m4;
    ans = 0;
    cin >> a >> b >> c >> d;
    m1 = max(a,b);
    m2 = max(c,d);
    m3 = min(a,b);
    m4 = min(c,d);
    ans = max({m1*m2,m1*m4,m3*m2,m3*m4});
    
    
    
    cout << (ans) << endl;
}

Measured memory_bytes: 3632
H, W = map(int, input().split())
S = [input() for _ in range(H)]
ans = 0
for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      flag = 0
      if i > 0 and S[i-1][j] == "#":
        flag = 1
      if i < H-1 and S[i+1][j] == "#":
        flag = 1
      if j > 0 and S[i][j-1] == "#":
        flag = 1
      if j < W-1 and S[i][j+1] == "#":
        flag = 1
      if flag == 0:
        ans = 1
print("Yes" if ans == 0 else "No")

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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
#define tc ll t; cin >> t; while (t--)
#define sz(c) (ll) (c).size()
#define trav(x,c) for(auto &x : c)
#define all(c) (c).begin(), (c).end()
#define rll(c) (c).rbegin(), (c).rend()
#define _for(i,a,n) for(ll i = a ; i < n; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);

int main() {
    godspeed;
    ll n, k; cin >> n >> k;

    ll ans = 0, x;
    while(n--) {
        cin >> x;
        if(x >= k) ans++;
    }

    cout << ans;

}

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

using namespace std;
#define endl '\n'



int main()
{
	ios::sync_with_stdio(false);
	cout.tie(0);
	set<string> s;
	int n;
	cin >> n;
	string item;
	while (n--)
	{
		cin >> item;
		s.insert(item);
	}
	cout << s.size()<<endl;

	//system("pause");
	return 0;
}

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

vector<int64_t> Divisor(int64_t n) {
    vector<int64_t> ret;
    for(int64_t i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}


int main() {
	int64_t n; cin >> n;
	int64_t ans = 1e18;
	for(int64_t x : Divisor(2 * n)) {
		int64_t y = 2 * n / x;
		int64_t k = crt({0, y - 1}, {x, y}).first;
		if(k != 0) {
			ans = min(ans, k);
		}
	}
	cout << ans << '\n';
	return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N;
char ans[400];
ll i, j, k;
ll a, b;
char ipt[9];
void stp1(){
    ll i=0,cc=0;
    printf("? ");
    fornum(j,1,N+1){
        printf("%lld ",j);
    }
    printf("\n");
    cout << flush;
    scanf("%s", ipt);
    if(ipt[0]=='R')
        cc = 1;
    ll l = 1, r = N;
    while(l<r){
        ll c = (l + r+1) / 2;
        printf("? ", i + 1);
        fornum(j,c,c+N){
            printf("%lld ",j);
        }
        printf("\n");
        cout << flush;
        scanf("%s", ipt);
        ans[i] = ipt[0];
        if((cc==0&&ipt[0]=='R')||(cc==1&&ipt[0]=='B')){
            r = c - 1;
        }else{
            l = c;
        }
    }
    
    a = l+1;
    b = l + N - 1;
}
void stp2(){
    
    fornum(i,0,N*2){
        if(a<=i+1&&i+1<=b)
            continue;
        printf("? %lld ", i + 1);
        fornum(j,a,b+1){
            printf("%lld ",j);
        }
        printf("\n");
        cout << flush;
        scanf("%s", ipt);
        ans[i] = ipt[0];
    }
    fornum(i,0,N*2){
        if(i+1<a||b<i+1)
            continue;
        printf("? %lld ", i + 1);
        fornum(j,0,N*2){
            if(j+1<a-1||b+1<j+1)
                printf("%lld ",j+1);
        }
        printf("\n");
        cout << flush;
        scanf("%s", ipt);
        ans[i] = ipt[0];
    }
}
void solve(){
    printf("! ");
    fornum(i,0,N*2){
        printf("%c", ans[i]);
    }
    printf("\n");
    cout << flush;
}
int main(){
    scanf("%lld", &N);
    if(N==1){
        printf("? 1\n");
        cout << flush;
        scanf("%s", ipt);
        if(ipt[0]=='R'){
            printf("! RB");
        }else{
            printf("! BR");
        }
        printf("\n");
        cout << flush;
        return 0;
    }
    stp1();
    stp2();
    solve();
    return 0;
}

Measured memory_bytes: 724
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w;
string s,s1,s2;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    vl v(2019,0);
    cin>>x>>y;
    y=min(y,x+2018);p=inf;
    for(ll i=x;i<=y;i++){
        for(ll j=i+1;j<=y;j++){
            p=min(p,i%2019*j%2019);
        }
    }
    cout<<p;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#define fast(); ios_base::sync_with_stdio(0);cin.tie(0);
#define rep(i, n) for(int i= 0; i < n; ++i)
using namespace std;

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


int main() {
	fast();

	int n; cin >> n;
	long long res = 0;
	while (n--) {
		int l, r; cin >> l >> r;
		res += abs(r - l) + 1;
	}
	cout << res << endl;
	return 0;
}


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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
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();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,i;
    cin >> n >> i;


    cout << n - i + 1 ;


    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <sstream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define EPS 1e-12
#define pri_max 60000
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

/*
bool memo[pri_max] = {};
vector<int> pri;
void calc()
{
	for (int i = 2; i < pri_max; i++)
	{
		if (memo[i] == false)
		{
			pri.push_back(i);
			for (int l = i; l < pri_max; l += i)
			{
				memo[l] = true;
			}
		}
	}
}*/

int main()
{
	int n;
	while (cin >> n&&n != -1)
	{
		double x=1.0, y=0.0;
		FOR(i, n-1)
		{
			double s = atan2(0 - y, 0 - x);
			s -= M_PI/2.0;
			x += cos(s);
			y += sin(s);
		}
		printf("%.3lf\n%.3lf\n", x, y);
	}
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

int main()
{
    string s; cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    ll a,b,c;cin>>a>>b>>c;
    ll k;cin>>k;
    ll cnt=0;
    while(b<=a){
        b*=2;
        cnt++;
    }
    while(c<=b){
        c*=2;
        cnt++;
    }
    if(cnt<=k)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define reverse(s) reverse(s.begin(),s.end())

int main(){
    char a;
    cin >> a;

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

    return 0;
}

Measured memory_bytes: 3648
/**
 *  author: mahfuzz
 *  created: 10.05.2020
**/
 
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(), (a).end()
#define trace(x) cout << #x << ':' << x << "\n"
typedef long long ll;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    string s, t; cin >> s >> t;
    
    for(int i = 0; s[i]; i++){
        if(s[i] != t[i]){
            cout << "No\n";
            return 0;
        }
    }
    
    cout << "Yes\n";
        
    return 0;
}



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

int main() {
  int N;
  cin >> N;
  string S,T,A;
  cin >> S >> T;
  A = S + T;
  rep(i,N){
    A.at(2*i) = S.at(i);
    A.at(2*i+1) = T.at(i);
  }
  cout << A << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
m = [int(i) for i in input().split()]
lst = [False]*(max(sum(a)+1,max(m)+1))

for i in range(1<<n):
    cnt = 0
    for j in range(n):
        if i >> j & 1: cnt += a[j]
        lst[cnt] = True

for i in range(q):
    print("yes" if lst[m[i]] else "no")


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

using namespace std;

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

#define int ll

const ll mod = 1e9 + 7;


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

	vector<ll> a(n);
	for(int i=0;i<n;i++) cin >> a[i];

	for(int i=k;i<n;i++){
		if(a[i-k]<a[i]){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}

	return 0;
}


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

void    Unique(vector<long> &A, vector<vector<long> > &B) {
        // A sorted
        B.push_back({A.at(0), 1});
        for (int i=1; i<A.size(); i++) {
                if (B.at(B.size()-1).at(0)==A.at(i)) {
                        B.at(B.size()-1).at(1)++;
                } else {
                        B.push_back({A.at(i), 1});
                }
        }
        return;
}

int     main() {
        int N;
        cin >>N;
        vector<long> a(N);
        long ab=0;
        for (int i=0; i<N; i++) {
                cin >> a.at(i);
                ab ^= a.at(i);
        }
        if (0!=ab) {
                cout <<"No" <<endl;
                return 0;
        }
        sort(a.begin(), a.end());
        // All 0
        if (0==a.at(N-1)){
                cout <<"Yes" <<endl;
                return 0;
        }
        vector<vector<long> > U(0);
        Unique(a, U);
        // 0 Not Included
        if (0!=U.at(0).at(0)) {
                if (3!=U.size()) {
                        cout <<"No" <<endl;
                        return 0;
                }
                if (U.at(0).at(1)!=U.at(1).at(1)) {
                        cout <<"No" <<endl;
                        return 0;
                }
                if (U.at(0).at(1)!=U.at(2).at(1)) {
                        cout <<"No" <<endl;
                        return 0;
                }
                cout <<"Yes" <<endl;
                return 0;
        }
        // 0 Included
        U.at(0).at(1) -= N/3;
        for (int i=0; i<U.size(); i++) {
                if (1==U.at(i).at(1)%2) {
                        cout <<"No" <<endl;
                        return 0;
                }
        }
        cout <<"Yes" <<endl;
        return 0;
}

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

using namespace std;
using ll = long long;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#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 mod = 1e9 + 7;

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int l, b, c, n, m;
    vector<tuple<int, int, int>> ans;
    cin >> l;
    n = 0;
    b = l;
    vector<bool> bits;

    while (b > 0)
    {
        n++;
        bits.push_back(b % 2);
        b /= 2;
    }

    rep(i, n - 1)
    {
        ans.push_back(make_tuple(i + 1, i + 2, pow(2, n - 2 - i)));
        ans.push_back(make_tuple(i + 1, i + 2, 0));
    }

    b = pow(2, n - 1);

    reverse(bits.begin(), bits.end());


    rep2(i, 1, n)
    {
        if (bits[i])
        {
            ans.push_back(make_tuple(1, i + 1, b));
            b += pow(2, n - i - 1);
        }
    }

    m = ans.size();
    cout << n << " " << m << endl;
    for (auto z : ans)
    {
        cout << get<0>(z) << " " << get<1>(z) << " " << get<2>(z) << endl;
    }

    return 0;
}


Measured memory_bytes: 512
# ABC158 D
from collections import deque
s=input()
q=int(input())
l=[]

for i in range(q):
    l.append(list(map(str,input().split())))

cnt=0
front_str=''
end_str=''

t_str=deque(s)
front_str=deque(front_str)
end_str=deque(end_str)

for ll in l:
    if ll[0]=='1':
        cnt+=1
    elif ll[0]=='2':
        if cnt%2==0:
            if ll[1]=='1':
                front_str.appendleft(ll[2])
            elif ll[1]=='2':
                end_str.append(ll[2])
        elif cnt%2==1:
            if ll[1]=='1':
                end_str.append(ll[2])
            elif ll[1]=='2':
                front_str.appendleft(ll[2])
ans=list(front_str)+list(t_str)+list(end_str)

if cnt%2==0:
    ans=''.join(ans)
else:
    ans=ans[::-1]
    ans=''.join(ans)
print(ans)



Measured memory_bytes: 46936
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const int MAX_H=101;

int main(){
  int H,W;
  cin >> H >> W ;
  string a[MAX_H];
  string edge(W+2,'#');
  cout << edge << endl;
  rep(i,H){
    cin >> a[i] ;
    cout << '#'+a[i]+'#' << endl;
  }
  cout << edge << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
ll a[200010],n;
ll ma(ll q, ll w, ll e, ll r) {
	return max(max(q, w), max(e, r));
}
ll mi(ll q, ll w, ll e, ll r) {
	return min(min(q, w), min(e, r));
}
int main()
{
	ll dap = 999999999999999;
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		a[i] += a[i - 1];
	}
	for (int i = 2; i <= n-2; i++) {
		ll ch = a[i];
		ll ch1 = a[n] - a[i];
		ll q, w, e, r,q1,w1,e1,r1;
		int t = lower_bound(a, a + n + 1, ch/2) - a;
		q = a[t];
		w = ch - q;
		t--;
		q1 = a[t];
		w1 = ch - q1;
		t = lower_bound(a, a + n + 1, ch + ch1 / 2) - a;
		e = a[t] - ch;
		r = ch1 - e;
		t--;
		e1 = a[t] - ch;
		r1 = ch1 - e1;
		dap = min(dap, ma(q, w, e, r) - mi(q, w, e, r));
		dap = min(dap, ma(q, w, e1, r1) - mi(q, w, e1, r1));
		dap = min(dap, ma(q1, w1, e, r) - mi(q1, w1, e, r));
		dap = min(dap, ma(q1, w1, e1, r1) - mi(q1, w1, e1, r1));
	}
	printf("%lld\n", dap);
}

Measured memory_bytes: 1792
def resolve():
    N, K = list(map(int, input().split()))
    D = input().split()
    i = N
    while True:
        for s in str(i):
            if s in D:
                i += 1
                break
        else:
            print(i)
            return
    raise Exception("unreachable!")

if '__main__' == __name__:
    resolve()



Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main(void)
{
  long long X;
  cin >> X;
  long ans = 0;
  long long money = 100;
  long long tmp;
  while(1)
  {
    if(money >= X)break;
    tmp = money*0.01;
    money += tmp;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

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

ll fact(ll a){
  ll ret = 1;
  while(a>=1){
    ret *= a;
    a--;
  }
  return ret;
}

long double dist(ll x1,ll y1,ll x2,ll y2){
  return pow(double((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)),0.5);
}

int main(){
  int N;cin>>N;
  vll x(N),y(N);rep(i,N)cin>>x[i]>>y[i];
  long double ans = 0;
  for(int i=0;i<N-1;++i){
    for(int j=i+1;j<N;++j){
      ans += 2 * fact(N-1) * dist(x[i],y[i],x[j],y[j]);
    }
  }
  ans /= double(fact(N));
  cout << setprecision(15)<<ans<<endl;
}

Measured memory_bytes: 4192
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define REP(i,n) for (int i=0; i<n; i++)
#define RREP(i,n) for (int i=n-1; i>=0; i--)
#define FOR(i,a,b) for (int i=a; i<b; i++)
#define MXTO(a,b) a = max(a,(__typeof__(a))(b))
#define MNTO(a,b) a = min(a,(__typeof__(a))(b))
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) x.size()
using namespace std;

#define debug(x) cerr<<#x<<" is "<<x<<endl;

const ll mod = 998244353;
const int maxn = 2e5+5;


int main(){
	ios::sync_with_stdio(0), cin.tie(0),cout.tie(0);
	int n; cin>>n;
	int m = n+ ((n%2)^1);
	cout<<n*(n-1)/2 - n/2<<'\n';
	//debug(m);
	REP(i,n){
		REP(j,i){
			if ((i+j+2)!=m){
				cout<<i+1<<' '<<j+1<<'\n';
			}
		}
	}
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if ((a && b) || c) cout << "Open" << endl;
  else cout << "Close" << endl;
  return 0;
}

Measured memory_bytes: 1156
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(a < b && b < c)
			System.out.println("Yes");
		
		else
			System.out.println("No");
		
		sc.close();

	}

}

Measured memory_bytes: 26096
#include<stdio.h>
int main(){
    int l[10],r[10]={-1};
    int i,j,k,c[10],n=0;
    for(i=0;i<10;i++){
        c[i]=11;
    }
    for(i=0;i<10;i++){
        scanf("%d",&l[i]);
    }
    for(j=0;j<10;j++){
        for(i=0;i<10;i++){
            for(k=0;k<10;k++){
                if(c[k]==i){
                    n=1;
                }
            }
            if(!(n==1)){
                if(l[i]>=r[j]){
                    r[j]=l[i];
                    c[j]=i;
                }
            }
            n=0;
        }
    }
    for(i=0;i<3;i++){
        printf("%d\n",r[i]);
    }
    return 0;
}

Measured memory_bytes: 2664
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll mod = 10e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prtd(n, var)  cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl

//----------------------------------------------------------------

int main(void) {
  int a[5];
  rep(i,5){
    cin >> a[i];
  }

  int ans=0;
  int tmp=10;
  rep(i,5){
    if(a[i]%10!=0){
      if(tmp>a[i]%10){tmp = a[i]%10;}
      a[i] = (a[i]/10)*10+10;
    }
  }


  rep(i,5){
    ans += a[i];
  }
  ans += tmp - 10;

  prt(ans);

}


Measured memory_bytes: 256