akhauriyash/Code-Regression huggingface dataset:
// ALDS1_8_B.cpp
// Binary search trees - Binary Search Tree II

#include <iostream>
#include <vector>
using namespace std;

struct TreeNode {
    int val;
    TreeNode* lchild;
    TreeNode* rchild;
    //TreeNode* parent;
    TreeNode(int x): val(x), lchild(NULL), rchild(NULL) {}
};

void insert(TreeNode *&tree, TreeNode *node)
{
    if (tree) {
        TreeNode *tmp = tree;
        TreeNode *tmp2 = tmp;
        while (tmp != NULL) {
            tmp2 = tmp;
            if (node->val < tmp->val) {
                tmp = tmp->lchild;
            }
            else {
                tmp = tmp->rchild;
            }
        }
        if (node->val < tmp2->val) {
            tmp2->lchild = node;
        }
        else {
            tmp2->rchild = node;
        }
    }
    else {
        tree = node;
    }
}

void inorder(TreeNode *tree) {
    if (!tree) return;
    inorder(tree->lchild);
    cout << " " << tree->val;
    inorder(tree->rchild);
}

void preorder(TreeNode *tree) {
    if (!tree) return;
    cout << " " << tree->val;
    preorder(tree->lchild);
    preorder(tree->rchild);
}

void print(TreeNode *tree) {
    inorder(tree);
    cout << endl;
    preorder(tree);
    cout << endl;
}

void find(TreeNode *tree, int num) {
    while (tree) {
        if (tree->val == num) {
            cout << "yes" << endl;
            return;
        }
        else if (tree->val < num) {
            tree = tree->rchild;
        }
        else {
            tree = tree->lchild;
        }
    }
    cout << "no" << endl;
}

int main()
{
    int n;
    cin >> n;
    string cmd;
    int num;
    TreeNode *tree = NULL;
    while(n--) {
        cin >> cmd;
        if (cmd == "insert") {
            cin >> num;
            TreeNode *node = new TreeNode(num);
            insert(tree, node);
        }
        if (cmd == "find") {
            cin >> num;
            find(tree, num);
        }
        if (cmd == "print")
            print(tree);
    }
    return 0;
}

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

#define int long long

int n;
int a[200010];
int b[200010];

signed main(){
    cin >> n;

    int sum = 0;
    bool tmp = true;
    for(int i = 0;i < n;i++){
        cin >> a[i] >> b[i];
        sum += a[i];
        tmp = tmp && a[i] == b[i];

    }

    if(tmp){
        cout << 0 << endl;
        return 0;
    }

    int ans = 0;
    for(int i = 0;i < n;i++){
        if(a[i] > b[i]){
            int tt = sum-a[i];
            ans = max(ans, tt+(a[i]-b[i]));
        }
    }

    cout << ans << endl;

    return 0;
}







Measured memory_bytes: 512
#include <iostream>

int i_height(int i) {
    if (i==1)
        return 1;
    return i + i_height(i-1);
}

int main() {
    int a, b;
    std::cin >> a >> b;
    
    int height = i_height(b - a);
    std::cout << height - b << std::endl;
}

Measured memory_bytes: 256
from itertools import groupby

s = input()
k = int(input())
a, b = [], []
count1, count2 = 0, 0

for key, group in groupby(s):
  a.append(list(group))

if len(a) == 1:
  if len(s)%2==1 and k%2==1:
    print(len(s)//2 + len(s)*(k-1)//2 )
  else:
    print(len(s)*k//2)
else:
  for key, group in groupby(s*2):
    b.append(list(group))  

  for i in a:
    count1 += len(i) // 2

  for i in b:
    count2 += len(i) // 2

  c = count2 - count1

  print(count1 + c*(k-1))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, w, p[105], v[105], tab[105][100005];
ll knap(int obj, int peso){
    if(tab[obj][peso]!=-1){
        return tab[obj][peso];
    }
    if(obj>n || peso<0){
        return tab[obj][peso]=0;
    }
    ll nao=knap(obj+1, peso);
    if(p[obj]<=peso){
        ll pega=v[obj]+knap(obj+1, peso-p[obj]);
        return tab[obj][peso]=max(pega, nao);
    }
    return tab[obj][peso]=nao;
}
int main()
{
    memset(tab, -1, sizeof(tab));
    cin >> n >> w;
    for(int i=1; i<=n; i++){
        cin >> p[i] >> v[i];
    }
    cout << knap(1, w) << endl;
    return 0;
}

Measured memory_bytes: 82304
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  int n;cin>>n;
  ll ans=1LL;
  bool inf=false;
  rep(i, n){
    ll a;cin>>a;
    if(a==0LL){cout<<0<<endl;return 0;}
    ll d=ll(1e18)/ans;
    if(d<a){inf=true;ans=1LL;}
    ans*=a;
  }
  cout<<(inf?-1:ans)<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


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

bool is_prime[1000001];

void sieve() {
  for(int i=0;i<1000001;i++) {
    is_prime[i] = true;
  }

  is_prime[0]=is_prime[1]=false;

  for(int i=2;i<1000001;i++) {
    if(is_prime[i]) {
      for(int j=2*i;j<1000001;j+=i) {
        is_prime[j]=false;
      }
    }
  }
}

int solve(int n) {
  int times=0;
  int sum=0;
  for(int i=2;times<n;i++) {
    if(is_prime[i]) {
      times++;
      sum += i;
    }
  }
  return sum;
}

  int main() {
    int n;
    sieve();
    while(cin >> n) {
      if(n==0) break;
      cout << solve(n) << endl;
    }
  }

Measured memory_bytes: 0
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int A,B;cin>>A>>B;
    vector<bool> b(4,true);
    b[A]=b[B]=false;
    for(int i=1;i<=3;i++){
        if(b[i]==true){
            cout<<i<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <cassert>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

#define P 998244353
struct segtree{
  ll M=1, INIT;
  vector<ll> dat;
  segtree(ll N, ll num):INIT(num){
    while(M<N) M*=2;
    dat.resize(M*2-1, INIT);
  }
  void update(ll x, ll k){
    k+=M-1;
    dat[k] = (dat[k] + x)%P;
    while(k>0) k = (k-1)/2, dat[k] = (dat[k*2+1] + dat[k*2+2])%P;
  }
  ll query(ll a, ll b=-1, ll k=0, ll l=0, ll r=-1){
    if(r==-1) r = M;
    if(b==-1) b = M;
    if(r<=a || b<=l) return INIT;
    if(a<=l && r<=b) return dat[k];
    ll A = query(a, b, k*2+1, l, (l+r)/2);
    ll B = query(a, b, k*2+2, (l+r)/2, r);
    return (A + B)%P;
  }
};

int main(){
  ll n, k;std::cin >> n >> k;
  vvl d = VV(k, 2, 0, ll);
  for(int i=0;i<k;i++) std::cin >> d[i][0] >> d[i][1];
  segtree seg(n+1, 0);
  seg.update(1, 0);

  for(int i=1;i<=n;i++){
    for(int j=0;j<k;j++){
      ll l = max(0LL, i - d[j][1]), r = max(-1LL, i - d[j][0]);
      ll q = seg.query(l, r+1);
      seg.update(q, i);
    }
  }
  std::cout << seg.query(n-1, n) << '\n';
}


Measured memory_bytes: 7456
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
	
  	int S;
	cin >> S;
	
  	int h, m, s;
  	
  	h = S/3600;
  	m = S%3600/60;
  	s = S%3600%60;
  
  	cout << h << ":" << m << ":" << s << endl;
  
  	return 0;
}


Measured memory_bytes: 3084
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut ans = 0;
    for _ in 0..n {
        let mut a: i32 = read();
        let k: i32 = read();
        while a % k != 0 && a > k {
            let w = a / k + 1;
            let diff = (a - (w - 1) * k) / w * w;
            a = a - diff;
            assert!(a / k + 1 == w);
            if a % k != 0 {
                a -= w;
            }
        }
        // println!("{}", a / k);
        ans ^= a / k;
    }
    println!("{}", if ans != 0 { "Takahashi" } else { "Aoki" });
}

Measured memory_bytes: 4352
#define _USE_MATH_DEFINES

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

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

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

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N,K;
	cin >> N >> K;
	vector<int> H(N);
	IN(H);
	SO(H);
	int ans = INF;
	for (int i = 0; i + K - 1< N; ++i) {
		chmin(ans, H[i + K - 1] - H[i]);
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 640
def examA():
    N = I()
    S = SI(); T = SI()
    ans = 2*N
    for l in range(N-1,-1,-1):
        flag = True
        for i in range(l+1):
            if S[N-1-i] != T[l-i]:
                flag = False
                break
        if flag:
            ans -=(l+1)
            break
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examA()


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

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

const int N = 2e5+10 , mod = 1e9+7;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n , m , k;
   cin >> n >> m >> k;
   string s[n];
   for(int i = 0 ; i < n ; i++)
      cin >> s[i];
   int ans = 0;
   for(int i = 0 ; i < (1 << (n + m)) ; i++){
      int num = 0;
      for(int j = 0 ; j < n ; j++)
         for(int k = 0 ; k < m ; k++)
            if(s[j][k] == '#' && ((1 << j) & i) == 0 && ((1 << (n + k)) & i) == 0)
               num++;
      if(num == k)
         ans++;
   }
   cout << ans;
   return 0;
}


Measured memory_bytes: 3648
import sys
from math import factorial as fc

if sys.platform =='ios':
	sys.stdin=open('inputFile.txt')
		
#+++++
bpn=(10**9)+7

def pat(num, bunkatsu):
	if num==0 and bunkatsu == 0:
		return 1
	
	if bunkatsu==0:
		return 0
		
	if num < bunkatsu:
		return 0
	
	if bunkatsu==1:
		return 1
	
	#numのものをbunkatsuに分ける場合の数を求める。
	c=num-1
	l=bunkatsu-1
	
	#print(c,l)
	cpl=fc(c)//(fc(c-l)*fc(l)) %bpn
	return cpl % bpn

def kk(nb,nr,i):
	ret=0
	a=pat(nb, i)%bpn
	#print(a)
	
	b=pat(nr, i+1)%bpn
	#print(b,nr)
	ret+=(a*b) % bpn
	ret = ret % bpn
	
	c=pat(nr, i)%bpn
	ret += (a*c*2 )% bpn
	ret = ret % bpn
	
	d = pat(nr, i-1)%bpn
	ret += (a*d)% bpn
	ret = ret % bpn
	
	#print(a,b,c,d)
	
	return (ret % bpn)
	
def main():
	n, k = map(int, input().split())
	
	for i in range(1,k+1):
		print(kk(k,n-k,i))
	return

if __name__ == "__main__":
	main()
	#print(pat(10,4))
	

Measured memory_bytes: 3444
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

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

	vi cards(2*n);
	vi temps(2*n);

	REP(i, cards.size()) {
		cards[i] = i+1;
		temps[i] = i+1;
	}

	REP(hoge, m) {
		int command;
		cin >> command;

		if(command) {
			REP(i, command) {
				temps[2*n-command+i] = cards[i];
			}

			REP(i, 2*n-command) {
				temps[i] = cards[command+i];
			}
		} else {
			REP(i, n) {
				temps[2*i] = cards[i];
				temps[2*i+1] = cards[n+i];
			}
		}

		REP(i, 2*n) {
			cards[i] = temps[i];
		}
	}

	REP(i, 2*n) {
		cout << cards[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define pii pair<int,int>
#define mo 1000000007
#define ll long long
#define pll pair<ll,ll>
#define db double
#define fi first
#define se second
#define For(i,j,k) for (int i=j;i<=k;i++)
using namespace std;
ll a,b,c,times;
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&times);
	if (times&1) printf("%lld",b-a);
	else printf("%lld",a-b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  vector<int>A(N+1),B(N);
  for(int i=0;i<N+1;i++){
    cin>>A[i];
  }
  for(int i=0;i<N;i++){
    cin>>B[i];
  }
  int64_t cnt=0;
  for(int i=0;i<N;i++){
    cnt+=min(A[i],B[i]);
    int a=max(0,B[i]-A[i]);
    cnt+=min(A[i+1],a);
    A[i+1]=max(0,A[i+1]-a);
   // cout<<cnt<<endl;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3988
fun main(args: Array<String>) {
        val nk = readLine()!!.split(" ").map { it.toInt() }
        val plist = readLine()!!.split(" ").map { it.toInt() }

        val queue = mutableListOf<Double>()
        var sum = 0.0
        var max = 0.0
        var index = 0
        plist.forEach {
            val temp = (0..it).sum().toDouble() / it
            queue.add(temp)
            sum += temp
            if (queue.count() >= nk[1]) {
                if (sum > max) {
                    max = sum
                }
                sum -= queue[index - nk[1] + 1]
            }
            index += 1
        }
        print(max.toString())
    }

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

const int N = 100;

int main(){
  int n;
  cin >> n;
  int p[N+1], m[N+1][N+1];
  for(int i=1;i<=n;i++) cin >> p[i-1] >> p[i];

  for(int i=1;i<=n;i++) m[i][i] = 0;
  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      int j = i + l - 1;
      // m[i][j] = numeric_limits<int>::infinity();
      m[i][j] = (1 << 21);
      for(int k=i;k<=j-1;k++){
        m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
      }
    }
  }
  cout << m[1][n] << endl;
  return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;
const int MOD = 1000000007;

template< int mod >
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
};
using mint = ModInt< 1000000007 >;

int mod_pow(int n, int p, int MOD){
  int r = 1;
  for(; p > 0; p >>= 1){
    if(p & 1LL) r = (r * n) % MOD;
    n = (n * n) % MOD;
  }
  return r; // r = n^p % MOD
}

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v) {
    for (auto &e : t) fill(e, v);
}
// auto v = make_vec<int>(h, w);
// fill(v, 0);

signed main(){

  int n; cin >> n;
  if(n == 1){
    cout << 0 << endl;
  }else{ 
    auto dp = make_vec<mint>(n+1, 3);
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
      dp[i+1][0] = dp[i][0] * 8;
      dp[i+1][1] = dp[i][0] * 2 + dp[i][1] * 9;
      dp[i+1][2] = dp[i][1] + dp[i][2] * 10;
    }
    cout << dp[n][2] << endl;
  }

  return 0;
}

Measured memory_bytes: 57812
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))

def main():
    n = II()
    aa = MII()
    aa = [0] + aa + [0]
    g = [0]
    for i in range(1, n+2):
        g.append(abs(aa[i]-aa[i-1]))
    ng = [0, 0]
    for i in range(2, n+2):
        ng.append(abs(aa[i]-aa[i-2]))
    sumv = sum(g)
    for i in range(1, n+1):
        print(sumv - (g[i] + g[i+1]) + ng[i+1])

if __name__ == '__main__':
    main()
#0, 3, 5, -1, 0
#0, 3, 2,  6, 1
#0, 0, 5,  4, 5

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    if (a==b)cout<<"Draw"<<endl;
    else if (a>b&&b!=1||a==1)cout<<"Alice"<<endl;
    else if (b>a||b==1)cout<<"Bob"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int T = sc.nextInt();

		PriorityQueue<Point> queue = new PriorityQueue<>((e1,e2) -> e1.x - e2.x);
		for (int i = 0; i < n; i++) {
			int c = sc.nextInt();
			int t = sc.nextInt();
			if (t <= T) {
				queue.add(new Point(c, t));
			}
		}

		if (queue.isEmpty()) {
			out.println("TLE");
		} else {
			out.println(queue.poll().x);
		}

		out.flush();

	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


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

#pragma warning(disable : 4996)

using namespace std;

int N, A[100], B[100]; string S;

int main()
{
	while (true)
	{
		scanf("%d", &N);

		if (N == 0) break;

		cin >> S;

		for (int i = 0; i < N; i++)
		{
			scanf("%d", &A[i]);
			scanf("%d", &B[i]);
		}

		for (int i = N - 1; i >= 0; i--)
		{
			swap(S[A[i] - 1], S[B[i] - 1]);

			int sa = B[i] - A[i];

			S[A[i] - 1] = ((int)(S[A[i] - 1] - 'a') + sa) % 26 + 'a';
			S[B[i] - 1] = ((int)(S[B[i] - 1] - 'a') + sa) % 26 + 'a';
		}

		cout << S << endl;
	}

	return 0;
}

Measured memory_bytes: 3128
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

int arr[31][31];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);

    int N, M;
    cin >> N >> M;

    for (int i = 0; i < N; ++i)
    {
        int K;
        cin >> K;
        for (int j = 0; j < K; ++j)
        {
            int a;
            cin >> a;
            a--;
            arr[i][a]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < M; ++i)
    {
        bool ok = true;
        for (int j = 0; j < N; ++j)
        {
            if (!arr[j][i])
                ok = false;
        }
        if (ok)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>
#include <map>
#include <utility>
#include <numeric>

#define _USE_MATH_DEFINES
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define atcoder 1000000007
#define MAX_N 100

using namespace std;


int main() {

	int a, b, x;

	cin >> x >> a >> b;

	a = abs(x - a);
	b = abs(x - b);
	if (a < b)cout << 'A' << endl;
	else cout << 'B' << endl;

	return 0;
}


Measured memory_bytes: 256
/*
 * FileName:     D
 * CreatedDate:  2020-04-19 20:58:20 +0900
 * LastModified: 2020-04-19 22:15:22 +0900
 */

#include <stdio.h>

int main(void){
    long int n,k;
    scanf("%ld %ld",&n,&k);
    long int count=0;
    long int down=0,up=0;
    for(long int i=k;i<n+2;i++){
        down=(i-1)*i/2;
        up=n*i-down;

        count+=up-down+1;
        count=count%1000000007;
    }
    printf("%ld\n",count%(1000000007));
    return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
 
// macro
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define MOD 1000000007
#define ll unsigned long long
#define FOR(i, m, n) for(ll i = m;i < n;i++)
 
using namespace std;
 
// Factorial
// need init
ll factorial_memo[5001];
ll factorial(ll n) {
  factorial_memo[0] = 1;
  if(factorial_memo[n] != -1) return factorial_memo[n];
  factorial_memo[n] = (factorial(n-1) * n) % MOD;
  return factorial_memo[n];
}
 
// Combination(nCr)
// need init
ll nCr_memo[5001][5001];
ll nCr(ll n, ll r) {
  if(r*2 > n) r = n-r;
  if(r == 1) return n;
  if(r == 0) return 1;
  if(nCr_memo[n][r] != -1) return nCr_memo[n][r];
  nCr_memo[n][r] = (nCr(n-1, r) + nCr(n-1, r-1)) % MOD;
  return nCr_memo[n][r];
}

// list of prime numbers
vector<int> primes;
void find_primes(int n) {
  if(n < 2) return;
  primes.push_back(2);
  FOR(i, 3, n+1) {
    bool isPrime = true;
    for(int x : primes) {
      if(i % x == 0) {
        isPrime = false;
        break;
      }
      if(x*x > i) break;
    }
    if(isPrime) primes.push_back(i);
  }
}

void solve() {
  int N;
  cin >> N;
  find_primes(N);
  map<int, int> mp;
  for(int x : primes) {
    mp[x] = 0;
  }
  FOR(i, 1, N+1) {
    int n = i;
    for(int x : primes) {
      if(n < 2) break;
      while(true) {
        if(n % x == 0) {
          mp[x]++;
          n /= x;
        } else {
          break;
        }
      }
    }
  }
  ll ans = 1;
  for(pair<int, int> p : mp) {
    ll tmp = p.second + 1;
    ans = (ans * tmp) % MOD;
  }
  cout << ans << "\n";
}
 
int main() {
  // init
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using ll = long long;
using namespace std;
int main() {
  	ll n, tmp, ans = 0;
  	vector<ll> v;
  	cin >> n;
  	if (n % 2 != 0){
      	cout << ans << endl;
      	return 0;
    }
  
  	REP(i, n){
      	cin >> tmp;
      	v.push_back(tmp);
    }
  	sort(v.begin(), v.end());
  
  	ans = v[n/2] - v[n/2 - 1];
  	cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
long long a,b,x,y;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin>>a>>b;
x=min(a,b);
y=max(a,b);
for(int i=0;i<y;i++){
	 cout<<x;
}
return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define rep(i,r) for (int i = 0; i < r; i++)

long repunit(long unit, long digits) {
  return digits == 1 ? unit : repunit(unit, digits - 1) * 10 + unit;
}

int main() {
  long a, b;
  scanf("%ld%ld", &a, &b);
  printf("%ld", repunit(a < b ? a : b, a < b ? b : a));
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int a,b;
int main(){
	a=read(),b=read();
	if(b==1)puts("0");
	else if(a>=b)puts("1");
	else printf("%d",(b-a)/(a-1)+((b-a)%(a-1)!=0)+1);
	return 0;
}

Measured memory_bytes: 256
import numpy as np
from numba import njit, i8, jitclass
import sys

spec = [
    ("size", i8),
    ("tree", i8[:])
]


@jitclass(spec)
class Bit:
    def __init__(self, n, arr):
        self.size = n
        self.tree = np.array([0] + arr, np.int64)
        for i in range(1, n+1):
            x = i + (i & -i)
            if x < n + 1:
                self.tree[x] += self.tree[i]

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def range_sum(self, l, r):
        return self.sum(r) - self.sum(l)


def main():
    n, q = map(int, sys.stdin.buffer.readline().split())
    bit = Bit(n, list(map(int, sys.stdin.buffer.readline().split())))
    for x in sys.stdin.buffer.readlines():
        q, p, x = map(int, x.split())
        if q:
            print(bit.range_sum(p, x))
        else:
            bit.add(p+1, x)


if __name__ == "__main__":
    main()


Measured memory_bytes: 160764
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n,i;
    long ans=0;
    cin >> n;
    vector <int>a(n+1);
    vector <int>b(n);
    for(i=0;i<n+1;i++) cin >> a[i];
    for(i=0;i<n;i++) cin >> b[i];
    for(i=0;i<n;i++){
        if(a[i]>b[i]) ans+=b[i];
        else if(a[i]+a[i+1]>b[i]){
            ans+=b[i];
            a[i+1] = a[i+1]-(b[i]-a[i]);
        }
        else{
            ans+=a[i]+a[i+1];
            a[i+1] = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1152
#include <stdio.h>

int n;
int A[1000];
void print(){
  int i;
  for(i=0;i<n;i++){
    if(i!=n-1)printf("%d ",A[i]);
    else printf("%d",A[i]);
  }
  printf("\n");
}

void insertion(){
  int i;
  int v,j;
  for(i=1;i<n;i++){
  	print();
    v = A[i];
    j = i-1;
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
  }
}

int main(){
  scanf("%d",&n);
  int i;
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  insertion();
  print();
  return 0;
}

Measured memory_bytes: 2736
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int int_vector_find(std::vector<int> vec, int num) {
	auto itr = std::find(vec.begin(), vec.end(), num);
	int index = std::distance(vec.begin(), itr);

	if (index != vec.size()) {
		return 1;
	}
	else {
		return 0;
	}
}

int main() {
	std::string str;
	std::cin >> str;
	int hoge = 100000000;

	for (int i = 2; i < str.size(); ++i) {
		if (hoge > std::abs(753 - ((str[i - 2] - '0') * 100) - ((str[i - 1] - '0') * 10) - (str[i] - '0'))) {
			hoge = std::abs(753 - ((str[i - 2] - '0') * 100) - ((str[i - 1] - '0') * 10) - (str[i] - '0'));
		}
	}

	std::cout << hoge << std::endl;

}

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

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

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

	cout << endl;
	return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,i,ans,cnt[200010];
char s[200010];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(i=1;i<=n;i++){
		cnt[s[i]-'a']++;
	}
	for(i=0;i<26;i++)ans+=cnt[i]*(cnt[i]-1)/2;
	ans=n*(n-1)/2+1-ans;
	printf("%lld",ans);
}

Measured memory_bytes: 384
function Main(arg) {
    arg = arg.trim().split('\n');
    X = Number(arg[0].split(' ')[2]);
    Y = Number(arg[0].split(' ')[3]);
    
    x = arg[1].split(' ');
    y = arg[2].split(' ');
    
    x.sort(function(a,b){
        if(Number(a)<Number(b))return -1;
        if(Number(a)>Number(b))return 1;
        return 0;
    });
    y.sort(function(a,b){
        if(Number(a)<Number(b))return -1;
        if(Number(a)>Number(b))return 1;
        return 0;
    });
    if(Number(x[x.length - 1]) < Number(y[0])){
        if(X < Number(y[0]) && Number(x[x.length - 1]) < Y){
            console.log('No War');
            return;
        }
    }
    console.log('War');
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
N,M,C = map(int,input().split())
B = list(map(int,input().split()))

count = 0
for i in range(N):
  A = list(map(int,input().split()))
  p=C
  for j in range(M):p+=A[j]*B[j]
  if p>0:count+=1
print(count)

Measured memory_bytes: 3060
# include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
# define forn(i, n) for (ll i = 0; i < int(n); i++)
# define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
# define all(V) V.begin(), V.end()
# define rall(V) V.rbegin(), V.rend()
# define len(V) (int)V.size()
# define ll long long
# define ld long double
# define ff first
# define ss second
# define pb push_back
# define mp make_pair
# define endl '\n'
# define M_PI 3.14159265358979323846
 
void solve()
{
        int n; cin >> n;
        vector<bool> primes(100000 + 10);
        primes.assign(n + 1, true);
        primes[2] = true;
        for(int i = 2; i * 1LL * i <= 100000 + 10; ++i)
        {
                for(ll j = i * i; j <= 100000 + 10; j += i)
                {
                        primes[j] = false;
                }
        }
        int i = n;
        while(true)
        {
                if(primes[i])
                {
                        cout << i << endl;
                        break;
                }
                i++;
        }
}
 
int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        solve();
}

Measured memory_bytes: 256
v = Array.new(9)
v[0],v[1],v[2] = gets.strip.split.map!(&:to_i)
v[3],v[4],v[5] = gets.strip.split.map!(&:to_i)
v[6],v[7],v[8] = gets.strip.split.map!(&:to_i)
N = gets.to_i
yomiage = Array.new(N)

for k in 0..N-1
  yomiage[k]=gets.to_i
  for i in 0..8
    if yomiage[k] == v[i]
      v[i] = "0"
    end
  end
end

if (v[0]=="0" && v[0]==v[1] && v[1]==v[2])
  puts "Yes"
elsif (v[3]=="0" && v[3]==v[4] && v[4]==v[5])
  puts "Yes"
elsif (v[6]=="0" && v[6]==v[7] && v[7]==v[8])
  puts "Yes"
elsif (v[0]=="0" && v[0]==v[3] && v[3]==v[6])
  puts "Yes"
elsif (v[1]=="0" && v[1]==v[4] && v[4]==v[7])
  puts "Yes"
elsif (v[2]=="0" && v[2]==v[5] && v[5]==v[8])
  puts "Yes"
elsif (v[0]=="0" && v[0]==v[4] && v[4]==v[8])
  puts "Yes"
elsif (v[2]=="0" && v[2]==v[4] && v[4]==v[6])
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14304
import math

n = int(input())
h = int(math.sqrt(n))

answer = len(str(n))
for a in range(1, n + 1):
  if a * a > n:
    break
  if n % a != 0:
    continue
  b = int(n / a)
  a_len = len(str(a))
  b_len = len(str(b))
  current = max(a_len, b_len)
  if answer > current:
    answer = current

print(answer)

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

class lazy_segtree {
    public:
        int size;
        vector<int> node,lazy;
        lazy_segtree(int n_) {
            size=1;
            while (size<n_) size*=2;
            node.resize(2 * size, INT_MAX);
            lazy.resize(2 * size, -1);
        }

        void setlazy(int k, int v) {
            if (k>=2*size-1) return ;
            lazy[k] = v;
            node[k] = v;
        }

        void push(int k) {
            if (k>=2*size-1) return ;
            if (lazy[k] == -1) return ;
            setlazy(k * 2 + 1, lazy[k]);
            setlazy(k * 2 + 2, lazy[k]);
            lazy[k] = -1;
        }

        void range_update(int queryL,int queryR,int val,int k=0,int nodeL=0,int nodeR=-1) {
            if (nodeR==-1) nodeR=size;
            if (nodeR<=queryL || queryR<=nodeL) return ;
            if (queryL<=nodeL && nodeR<=queryR) {
                setlazy(k,val);
                return ;
            }
            else {
                push(k);
                int nodeM=(nodeL+nodeR)/2;
                range_update(queryL,queryR,val,k*2+1,nodeL,nodeM);
                range_update(queryL,queryR,val,k*2+2,nodeM,nodeR);
                return ;
            }
        }

        int get_node(int queryL,int queryR,int k=0,int nodeL=0,int nodeR=-1) {
            if (nodeR==-1) nodeR=size;
            if (nodeR<=queryL || queryR<=nodeL) return -1;
            if (queryL<=nodeL && nodeR<=queryR) return node[k];
            else {
                push(k);
                int nodeM=(nodeL+nodeR)/2;
                int tmp1=get_node(queryL,queryR,k*2+1,nodeL,nodeM);
                int tmp2=get_node(queryL,queryR,k*2+2,nodeM,nodeR);
                if (tmp1!=-1) return tmp1;
                else if(tmp2!=-1) return tmp2;
            }
        }
};

int n,q;

int main(){
    cin >> n >> q;
    lazy_segtree ls(n);
    for (int i=0; i<q; i++) {
        int que,s,t,x,idx;
        cin >> que;
        if (que==0) {
            cin >> s >> t >> x;
            ls.range_update(s,t+1,x);
        }
        else {
            cin >> idx;
            cout << ls.get_node(idx,idx+1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4944
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;


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

	cin >> N;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	M = accumulate(v.begin(), v.end(), 0LL) % MOD;
	long long int ans = M * M%MOD;
	for (auto i : v) {
		ans += MOD - i * i%MOD;
	}
	ans %= MOD;
	ans *= (MOD + 1) / 2;
	cout << ans % MOD << endl;
}

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

int main() {
  ll N,K,Q; cin>>N>>K>>Q;
  
  vector<int> score(N);
  
  for(ll i=0; i<N; i++){
    score.at(i)=K-Q;
  }
  
  for(ll i=0; i<Q; i++){
    int a; cin>>a;
    score.at(a-1)++;
  }
  
  for(ll i=0; i<N; i++){
    if(score.at(i)>0){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
  
  return 0;
}

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

int main(){
    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << v[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

H, W = reads()
A = []
for _ in range(H):
  A.append(reads())

def key(p):
  i, j = p
  return i * W + (j if i % 2 == 0 else W - 1 - j)

acts = []

ls = sorted(product(range(H), range(W)), key=key)
for u in range(len(ls)-1):
  i, j = ls[u]
  if A[i][j] % 2 != 0:
    (ii, jj) = ls[u+1]
    A[ii][jj] += 1
    A[i][j] -= 1
    acts.append((i, j, ii, jj))

N = len(acts)
print(N)
for a in acts:
  i, j, ii, jj = a
  print(i+1, j+1, ii+1, jj+1)



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

int main()
{
    long long a,b,w;
    cin >> w >> a >> b;

    if(a+w < b) cout << b-(a+w);
    else if(b+w < a) cout << a-(b+w);
    else cout << 0;

    cout << endl;
    return 0;
}

Measured memory_bytes: 3572
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long LL;

int main(int argc, char* argv[]) {
	LL n, k;
	cin >> n >> k;
	vector<int> a(n), p(n, -1);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		--a[i];
	}
	int c = 0;
	for (LL t = 0; t < k; ++t) {
		c = a[c];
		if (p[c] >= 0) {
			LL f = t - p[c];
			t += max(0LL, (k - t - f) / f) * f;
		}
		p[c] = t;
	}
	cout << (c + 1) << endl;
	return 0;
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, a, p);

  cout << (3 * a + p) / 2 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define mod 998244353
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
int n,k;
int main()
{
	n=read(); k=read();
	if(k==1)writeln(0);
	else writeln(n-k);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define N_MAX 200000
#define INF 1145141919
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;

int i, j;

int n, m;
int k, s;

int h, w;

char str[N_MAX];

void solve(){
	return;
}

int main (void) {
	int sx, sy, tx, ty;
	scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
	for (i = 0; i < (ty - sy); i++) putchar('U');
	for (i = 0; i < (tx - sx); i++) putchar('R');
	for (i = 0; i < (ty - sy); i++) putchar('D');
	for (i = 0; i < (tx - sx); i++) putchar('L');
		putchar('L');
	for (i = 0; i < (ty - sy); i++) putchar('U');
		putchar('U');
		putchar('R');
	for (i = 0; i < (tx - sx); i++) putchar('R');
		putchar('D');
		putchar('R');
	for (i = 0; i < (ty - sy); i++) putchar('D');
		putchar('D');
		putchar('L');
	for (i = 0; i < (tx - sx); i++) putchar('L');
		putchar('U');

	putchar('\n');
	return 0;
}




Measured memory_bytes: 128
#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(void) {
    int N, ans=0;
    string S;
    cin >> S;

    int max_pos=0;
    int tmp = 0;
    bool flag = true;
    rep(i,S.size()){
      if(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T')
        tmp++;
      else
        tmp =0;

      max_pos = max(max_pos,tmp);
    }

    cout << max_pos << endl;

    return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct Dinic {
  struct edge {
    int to, capacity, rev, id, isrev;
    edge(){}
    edge(int to, int capacity, int rev):to(to), capacity(capacity), rev(rev){}
  };

  vector< vector<edge> > graph;
  vector<int> level, iter;
  Dinic(int sz):graph(sz), level(sz), iter(sz){};
  void add_edge(int from, int to, int capacity) {
    graph[from].push_back(edge(to, capacity, (int)graph[to].size()));
    graph[to].push_back(edge(from, 0, (int)graph[from].size()-1));
  }
  void bfs(int source) {
    fill(level.begin(), level.end(), -1);
    queue<int> que;
    level[source] = 0;
    que.push(source);
    while(!que.empty()) {
      int v = que.front(); que.pop();
      for(int i = 0; i < (int)graph[v].size(); i++) {
	edge& e = graph[v][i];
	if(e.capacity > 0 && level[e.to] < 0) {
	  level[e.to] = level[v] + 1;
	  que.push(e.to);
	}
      }
    }
  }
  int dfs(int v, int sink, int f) {
    if(v == sink) return f;
    for(int &i = iter[v]; i < (int)graph[v].size(); i++) {
      edge& e = graph[v][i];
      if(e.capacity > 0 && level[v] < level[e.to]) {
	int d = dfs(e.to, sink, min(f, e.capacity));
	if(d > 0) {
	  e.capacity -= d;
	  graph[e.to][e.rev].capacity += d;
	  return d;
	}
      }
    }
    return 0;
  }
  int max_flow(int source, int sink) {
    int flow = 0;
    while(1) {
      bfs(source);
      if(level[sink] < 0) return flow;
      fill(iter.begin(), iter.end(), 0);
      int f; while((f = dfs(source, sink, inf)) > 0) flow += f;
    }
  }
};

int solve(vint& x) {
  int n = x.size();
  int s = n*2, t = s+1, V = t+1;
  Dinic graph(V);
  rep(i, n) {
    graph.add_edge(s, i, 1);
    graph.add_edge(n+i, t, 1);
  }
  rep(i, n) rep(j, n) if(i != j) {
    if(x[j]%x[i] == 0) graph.add_edge(i, n+j, 1);//, cout << x[i] << " " << x[j] << endl;
  }
  int flow = graph.max_flow(s, t);
  //cout << flow << endl;
  return n-flow;
}

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

  int n;
  cin >> n;
  vint x(n);
  rep(i, n) cin >> x[i];

  int mx = solve(x);
  //cout << mx << endl;
  vint ans;
  vint used(n, 0);
  rep(i, n) if(!used[i]) {
    //cout<< x[i]<<":"<<endl;
    vint y;
    reps(j, i+1, n) if(!used[j]) {
      if(x[j]%x[i] == 0 || x[i]%x[j] == 0) continue;
      //cout <<x[j]<< endl;
      y.push_back(x[j]);
    }
    int f = solve(y);
    //cout<<mx<<" "<<f<<endl;
    if(mx == f+1) {
      mx--;
      ans.push_back(i+1);
      reps(j, i+1, n) {
	if(x[j]%x[i] == 0 || x[i]%x[j] == 0) used[j] = 1;
      }
    }
  }
  rep(i, ans.size()) {
    if(i) cout << " ";
    cout << ans[i];
  }
  cout << endl;

  return 0;
}

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

using namespace std;


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

template <typename T>
T my_abs(T x) {
    return x < 0 ? -x : x;
}

template <typename T>
map<T, T> prime_factor(T n) {
    map<T, T> ret;
    for(T i = 2; i * i <= n; i++) {
        T tmp = 0;
        while(n % i == 0) {
            tmp++;
            n /= i;
        }
        ret[i] = tmp;
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

template <typename T>
T divisor_num(T n) {
    map<T, T> pf = prime_factor(n);
    T ret = 1;
    for(auto p : pf) {
        ret *= (p.second + 1);
    }
    return ret;
}

int main() {

    int n;
    string s;

    cin >> n >> s;

    unsigned long long result = 0;
    set<string> id_list;
    for(int id = 0; id <1000; id++) {
        char str_id[12];
        sprintf(str_id, "%03d", id);
//        cout << id << endl;
        for(int i=0; i<s.length()-2; i++) {
            if(str_id[0] == s[i]) {
                for(int j=i+1; j<s.length()-1; j++) {
                    if(str_id[1] == s[j]) {
                        for(int k=j+1; k<s.length(); k++) {
                            if(str_id[2] == s[k]) {
                                string temp = s.substr(i,1) + s.substr(j,1) + s.substr(k,1);
                                if(temp == str_id) {
                                    result++;
                                    goto ENDLOOP;
                                }
                            }
                        }
                        goto ENDLOOP;
                    }
                }
                goto ENDLOOP;
            }
        }
        ENDLOOP:;
    }
     cout << result << endl;

    return 0;
}


Measured memory_bytes: 256