akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n;
  cin >> n;

  vector<ll> d;
  ll e = 1;
  ll counter = 0;
  while (e <= n) {
    e *= 26;
    e += 1;
    counter++;
  }
  ll syusei = 1;
  rep(i, counter - 1) {
    syusei *= 26;
    syusei += 1;
  }

  debug(counter);
  // debug("syusei", syusei);
  ll now = n - syusei;
  // debug("now", now);
  while (now >= 26) {
    // debug("now", now);
    d.push_back(now % 26);
    now /= 26;
  }
  if (now >= 0) d.push_back(now);
  repz(i, SIZE(d), counter) d.push_back(0);
  reverse(ALL(d));
  for (ll i : d) {
    cout << char(i + 'a');
  }
  cout << endl;
  ret;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    string s, t;
    cin >> s >> t;
    REP(i, 0, s.size()) {
        if (s == t) {
            cout << "Yes" << endl;
            return 0;
        }
        rotate(begin(s), begin(s) + 1, end(s));
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int a, b, c;
	cin >> a >> b >> c;
	set<int> s;
	s.emplace(a);
	s.emplace(b);
	s.emplace(c);
	if(s.size() == 2) {
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]
def NSTR(n): return [input() for _ in range(n)]


INF = float("inf")
MOD = 10**9 + 7


def main():
    A, B, C = MAP()
    K = INT()
    while A >= B:
        B *= 2
        K -= 1
    if K < 0:
        print("No")
        return
    while B >= C:
        C *= 2
        K -= 1
    if K < 0:
        print("No")
        return

    print("Yes")

    return


if __name__ == '__main__':
    main()


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


const ll MOD = 1000000007;

ll mypow(ll x, ll n){
  if(n == 0)
    return 1;
 
  if(n % 2 == 0)
    return mypow(x * x, n / 2);
  else
    return x * mypow(x, n - 1);
}

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

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> dp(k + 7, 0);
  ll ans = 0;
  for (ll i = k; i > 0; i--){
    ll num = k / i;
    ll tmp = modpow(num, n, MOD);
    dp[i] = tmp;
    ll i_i = i * 2;
    while(i_i <= k){
      dp[i] -= dp[i_i];
      i_i += i;
    }
  }
  for (ll i = 1; i <= k; i++){
    ans += dp[i] * i % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}

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

int main() {
	int n; cin >> n;
	string s; cin >> s;
	vector<bool>flag(100, false);
	int left = 0, right = 0;
	for (int i = 0; i < n; i++) {
		if (flag[i])continue;
		bool ok = false;
		if (s[i] == '(') {
			for (int j = i + 1; j < n; j++) {
				if (!flag[j] && s[j] == ')') {
					ok = flag[i] = flag[j] = true;
					break;
				}
			}
			if (!ok)right++;
		}
		else {
			for (int j = i - 1; j >= 0; j--) {
				if (!flag[j] && s[j] == '(') {
					ok = flag[i] = flag[j] = true;
					break;
				}
			}
			if (!ok)left++;
		}
	}
	for (int i = 0; i < left; i++)cout << '('; cout << s; for (int i = 0; i < right; i++)cout << ')';
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
s = input()
  
for i in range(int(input())):
    cmd = input().split()
    a,b = [int(x) for x in cmd[1:3]]
  
    if cmd[0] == 'print':
        print(s[a:b+1])
    elif cmd[0] == 'reverse':
        s = s[:a] + s[a:b+1][::-1] + s[b+1:]
    elif cmd[0] == 'replace':
        s = s[:a] + cmd[3] + s[b+1:]

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F first
#define S second

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;

signed main() {
  IOS;
  int N,M, ans=0;
  cin >> N >> M;
  int k[M],p[M]; // mask[M],
  size_t s;
  bitset<11> mask[11];
  FOR(i,0,M) {
    cin >> k[i];
    FOR(j,0,k[i]) {
      cin >> s;
      mask[i].set(s-1);
//      mask[i] |= (1 << (s-1));
    }
  }
  FOR(i,0,M) {
    cin >> p[i];
  }

  FOR(i,0,1 << N) {
    bitset<11> t(i);
    bool on = true;
    FOR(j,0,M) {
//      cout << t << " " << mask[j] << " " << (t & mask[j]).count() << " " << p[j] << endl;
      if ((t & mask[j]).count() % 2 != p[j]) {
        on = false;
        break;
      }
    }
    if (on) ans++;
  }

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

Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
temp = [abs(T-h*0.006 - A) for h in H]
ans = 0
mint = 10**20
for i, t in enumerate(temp):
  if mint > t:
    mint = t
    ans = i+1
print(ans)
    

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

int main()
{
    int N, sn = 0;
    cin >> N;

    int tmp = N;
    while (tmp > 0)
    {
        sn += tmp % 10;
        tmp /= 10;
    }

    if (N % sn == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
    int N;
    cin>>N;
    vector<int> P={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
    vector<int> C(25,0);
    for(int i=1;i<=N;i++){
        for(int j=0;j<25;j++){
            int k=i;
            while(k>0){
            if(k%P[j]==0) C[j]++;
            else break;
                k/=P[j];
            }
        }
    }
    int cnt=0,cnt3=0,cnt5=0,cnt15=0,cnt25=0;
    if(C[0]>=74) cnt++;
    for(int i=0;i<25;i++){
        if(C[i]>=2) cnt3++;
        if(C[i]>=4) cnt5++;
        if(C[i]>=14) cnt15++;
        if(C[i]>=24) cnt25++;
    }
    if(cnt25>=1){
        cnt+=(cnt25*(cnt3-cnt25)+cnt25*(cnt25-1));
    }
    if(cnt5>=2){
        cnt+=(cnt5*(cnt5-1)*(cnt3-cnt5)/2+cnt5*(cnt5-1)*(cnt5-2)/2);
    }
    if(cnt15>=1){
        cnt+=(cnt15*(cnt5-cnt15)+cnt15*(cnt15-1));
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, q, ans[200000];
vector<int> g[200000];

void dfs(int v, int p, int x) {
	ans[v] += x;
	RF(e, g[v]) {
		if(e == p) { continue; }
		dfs(e, v, ans[v]);
	}
}

int main() {
	cin >> n >> q;
	inc(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].PB(b);
		g[b].PB(a);
	}
	inc(i, q) {
		int p, x;
		cin >> p >> x;
		p--;
		ans[p] += x;
	}
	
	dfs(0, -1, 0);
	
	inc(i, n) { cout << ans[i] << (i == n - 1 ? "\n" : " "); }
	
	return 0;
}


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	string s;
	cin >> s;
	int count = 0;
	REP(i,4){
		if(s[i]=='+') count++;
		else count--;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main (){
	
	char s[11], t[11], u[11];
	int a,b;
	scanf ("%s %s", &s, &t);
	scanf ("%d %d", &a,&b);
	getchar ();
	scanf ("%s", &u );
	
	if (strcmp(	u , s ) == 0){
		printf ("%d %d\n", a-1, b);
	}
	else if (strcmp( u , t) == 0){
		printf ("%d %d\n", a, b-1);
	}
	
	return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
#define N 300010
#define int long long
using namespace std;

int cnt[N],Ans;
char sd[N];
signed main()
{
	scanf("%s",sd); for(int i=0;sd[i]!='\0';i++)
		cnt[sd[i]-'a']++;
	int x=strlen(sd); Ans=(x+1)*x/2;
	for(int i=0;i<26;i++)
		Ans-=(cnt[i]+1)*cnt[i]/2;
	cout << Ans+1 << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
ll N;
cin >> N;
vector<ll> array(N);
  ll i;
  for(i=0;i<N;i++) cin >> array[i];
  // 配列のインデックス indiecs = {0, 1, 2, 3, 4} を作成する。
  vector<size_t> indices(array.size());
  iota(indices.begin(), indices.end(), 0);
  // ソートする。
  sort(indices.begin(), indices.end(), [&array](size_t i1, size_t i2) {
    return array[i1] < array[i2];
  });
  for (auto v : indices)
    cout << v+1 << " ";
  cout << endl;
}


Measured memory_bytes: 2432
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

#人数
n = int(arr_data[0][0])

#日数
d = int(arr_data[1][0])

#残ったチョコ
x = int(arr_data[1][1])

mysum=0
for i in range(2, 2 + n):
    
    
    a = int(arr_data[i][0])
 
#    print(a,mysum)
    
    mysum+=1
    
    cnt=1
    
#    print(mysum)
    
    while(cnt+a<=d):
        
        mysum+=1
        
        cnt+=a
 
        
mysum += x
print(mysum)
        
        

Measured memory_bytes: 3188
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {return (a%b) ? gcd(b, a%b) : b;}
ll modPow(ll x, ll n) {
    if(n==0) return 1;
    ll res = modPow(x*x%MOD, n/2);
    if(n&1) res=res*x%MOD;
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin>>s;
    if (s=="ABC") {
        ct("ARC");
    } else {
        ct("ABC");
    }
}


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

int main() {
  ll a, b, v, w, t, temp1, temp2, dist, speed;
  string ans;
  cin >> a >> v >> b >> w >> t;
  
  
  
  
  dist = abs(b - a);
  speed = v - w;
  
  if(speed * t >= dist){
    ans = "YES";
  }
  else{
    ans = "NO";
  }
  
  
  
  //cout << "dist:" << dist << "speed:" << speed << "time:" << t << endl;
  cout << ans << endl;
}


Measured memory_bytes: 3624
"use strict";
const input = require("fs").readFileSync("/dev/stdin", "utf8");
const inputs = input.trim().split(" ");

const get = (inputs) => {
  const N = +inputs[0];
  const D = +inputs[1];
  
  return Math.ceil(N / (D*2+1));
}

console.log( get(inputs) );

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

int main(void) {
    string a, b;
    int n;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b;
    n = stoi(a + b);
    cout << (n == (int)sqrt((double)n) * (int)sqrt((double)n)? "Yes" : "No") << "\n";
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  int ans = 0;
  rep(i,n){
      if((i+1)%2==1){
          if (a[i]%2==1) ans++;
      }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
n=int(input())
li=[tuple(map(int,input().split())) for i in range(n)]

from operator import itemgetter
li=sorted(li, key=itemgetter(1), reverse=True)
li.append([None,0])
over=0
#print(li)
for i in range(n):
  #aがbの差を超過する場合は既存の超過分にプラス
  if li[i][1]-li[i+1][1]<=over+li[i][0]:
    over=abs((li[i][1]-li[i+1][1])-(over+li[i][0]))
  #超過しない場合は超過分を0にリセット
  else:
    over=0
  #print(li[i+1][1],li[i][1],li[i][0],over)

if over==0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 33620
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#define rep(i,n) for(int i = 0;i<(n);i++);
using namespace std;
using ll = long long;
const ll INF = 100100100100100;

int main() {
	ll a, b;
	cin >> a >> b;
	if (a > 0) cout << "Positive" << endl;
	else if (a <= 0 && b >= 0) cout << "Zero" << endl;
	else {
		if ((b - a) % 2 == 0)cout << "Negative" << endl;
		else cout << "Positive" << endl;
	}
}

Measured memory_bytes: 256
n, m = map(int, input().split())

num = []
for i in range(n):
    num.append(False)

ans = False
if m == 0:
    if n == 1:
        ans = '0'
    else:
        ans = 10 ** (n-1)
for i in range(m):
    s, c = map(int, input().split())
    if num[s-1]:
        if num[s-1] != str(c):
            ans = -1
            break
    else:
        num[s-1] = str(c)
if ans:
    print(ans)
else:
    if num[0] == '0':
        if n == 1:
            print(0)
        else:
            print(-1)
    else:
        for i in range(n):
            if i == 0:
                if not num[0]:
                    num[0] = 1
            else:
                if not num[i]:
                    num[i] = 0

        ans = "".join(map(str, num))
        print(ans)




Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    int r, c, i, j;

    scanf("%d %d", &r, &c); //列・行を読み込む

    int row[101][101] = {0}; //最大値の配列を全て0で初期化

    for (i = 0; i < r; i++)
    {
        for (j = 0; j < c; j++)
        {
            scanf("%d", &row[i][j]); //r * cの配列の要素を読み込む
        }
    }

    for (i = 0; i <= r; i++)
    {
        for (j = 0; j < c; j++)
        {
            row[i][c] += row[i][j];
        }
    }

    for (j = 0; j <= c; j++)
    {
        for (i = 0; i < r; i++)
        {
            row[r][j] += row[i][j];
        }
    }

    for (i = 0; i <= r; i++)
    {
        for (j = 0; j <= c; j++)
        {
            if (j == c)
            {
                printf("%d", row[i][j]);
            }
            else
            {
                printf("%d ", row[i][j]);
            }
        }
            putchar('\n');
    }

    return 0;
}


Measured memory_bytes: 2760
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(),(x).end()
#define lowbit(x) x&-x
#define pb push_back
#define ls (id<<1)
#define rs (id<<1|1)
#define Rint register int
#define UNI(x) sort(ALL(x)),x.resize(unique(ALL(x))-x.begin())
#define GETPOS(c,x) (lower_bound(ALL(c),x)-c.begin())
#define LEN(x) strlen(x)
#define MS0(x) memset((x),0,sizeof((x)))
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<pii> Vpii;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(ll &x) { scanf("%lld", &x); }
void _R(ull &x) { scanf("%llu", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const ll &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
const int MAXN=2e6+10,MAXM=4e6+10;
const int INF=INT_MAX,SINF=0x3f3f3f3f;
const ll llINF=LLONG_MAX;
const int MOD=1e9+7,mod=998244353;
const int inv2=5e8+4;
const int Lim=1<<20;

int z[15];
ll cnt=0;
int n,m,q,ans;
int a[MAXN],b[MAXN],c[MAXN],d[MAXN];

void dfs(int u)
{
    if(u==n+1)
    {
        int res=0;
        for(int i=1;i<=q;i++)
        {
            if(z[a[i]]+c[i]==z[b[i]])res+=d[i];
        }
        ans=max(ans,res);
        return;
    }
    for(int i=z[u-1];i<=m;i++)
    {
        z[u]=i;
        dfs(u+1);
    }
}

void solve()
{
    z[0]=1;
    R(n,m,q);
    for(int i=1;i<=q;i++)R(a[i],b[i],c[i],d[i]);
    dfs(1);
    W(ans);
}

int main()
{
    //freopen("in.txt","r",stdin);
    int t=1;
    //R(t);
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll n;
  cin >> n;

  ll ans = (n / 2) * ((n + 1) / 2);
  cout << ans << endl;
  return 0;
}


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

int main()
{
	string c[3];
	for (int i = 0; i < 3; i++) {
		cin >> c[i];
	}
	for (int i = 0; i < 3; i++) {
		cout << c[i][i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int d, n;
	cin >> d >> n;
	vector<int> t(d);
	for (int i = 0; i < d; i++) {
		cin >> t[i];
	}
	vector<int>mi(n);
	vector<int>ma(n);
	vector<int>hi(n);
	for (int i = 0; i < n; i++) {
		cin >> mi[i] >> ma[i] >> hi[i];
	}
	vector<int> ha(n, -1);
	int te = t[0];
	for (int i = 0; i < n; i++) {
		if (mi[i] <= te and te <= ma[i]) {
			ha[i] = 0;
		}
		
	}
	for (int i = 1; i < d; i++) {
		int te = t[i];
		vector<int> yob(n);
		yob = ha;
		for (int j = 0; j < n; j++) {
			int a = mi[j];
			int b = ma[j];
			if (a <= te and te <= b) {
				ha[j] = 0;
				for (int k = 0; k < n; k++) {
					if (yob[k]!=-1) {
						ha[j] = max(ha[j], yob[k] + abs(hi[k] - hi[j]));
					}
				}
			}
			else {
				ha[j] = -1;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans = max(ans, ha[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3140
import sys
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

for _ in range(INT()):
    N = INT()
    ans = 0
    adjli1 = [[] for i in range(N)]
    adjli2 = [[] for i in range(N+1)]
    for _ in range(N):
        k, l, r = MAP()
        k -= 1
        if l > r:
            adjli1[k].append(l - r)
        elif l < r:
            adjli2[k+1].append(r - l)
        ans += min(l, r)

    que = []
    for i in range(N):
        for a in adjli1[i]:
            heappush(que, a)
        while len(que) > i+1:
            heappop(que)
    ans += sum(que)
    que = []
    for i in range(N-1, -1, -1):
        for a in adjli2[i]:
            heappush(que, a)
        while len(que) > N-i:
            heappop(que)
    ans += sum(que)
    print(ans)


Measured memory_bytes: 47584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h,w;
  string str;
  cin >> h >> w;
  for (int i = 0; i<w+2; ++i){
   cout << "#"; 
  }
  cout << endl;
  for (int j = 0 ;j<h; ++j){
   cin >> str;
   cout << "#" << str <<"#" << endl;
  }
    for (int i = 0; i<w+2; ++i){
   cout << "#"; 
  }
}

Measured memory_bytes: 256
N, C, K = list(map(int,input().split()))
listT = [int(input()) for _ in range(N)]

listT.sort()

count=0
while listT != []:
    bus = []
    time = listT[0]
    count += 1
    while len(bus) != C and time+K>=listT[0]:
        bus.append(listT.pop(0))
        if listT==[]:
            break

print(count)            


Measured memory_bytes: 7384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll INF = 9223372036854775807;
const ll MOD = 1000000007;
const long double PI = acos(-1);
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define o0(a) cout<<a<<" "
#define o1(a) cout<<a<<"\n"
#define o2(a, b) cout<<a<<" "<<b<<"\n"
#define o3(a, b, c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define o4(a, b, c, d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"
#define i1(a) cin>>a
#define i2(a, b) cin>>a>>b
#define i3(a, b, c) cin>>a>>b>>c
#define i4(a, b, c, d) cin>>a>>b>>c>>d
#define fi first
#define se second

ll power(ll a, ll b, ll z = MOD)
{
	ll res = 1;
	a = (a%z);
	while(b)
	{
		if(b&1)
			res = (res*a)%z;
		a = (a*a)%z;
		b = b>>1;
	}
	return res;
}

ll inverse(ll a, ll z = MOD)
{
	return power(a, z-2, z);
}

ll extend(ll a, ll b, ll &x, ll &y)
{
	if(b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll x1, y1;
	ll g = extend(b, a%b, x1, y1);
	x = y1;
	y = x1- (a/b)*y1;
	return g;
}

ll mat_power(ll a, ll b, ll c, ll d, ll n, ll z = MOD)
{
	ll a0 = 1, b0 = 0, c0 = 0, d0 = 1;
	while(n)
	{
		if(n&1)
		{
			ll a1 = a0, b1 = b0, c1 = c0, d1 = d0;
			a0 = (a1*a + b1*c)%z;
			b0 = (a1*b + b1*d)%z;
			c0 = (c1*a + d1*c)%z;
			d0 = (c1*b + d1*d)%z;
		}
		ll a1 = a, b1 = b, c1 = c, d1 = d;
		a = (a1*a1 + b1*c1)%z;
		b = (a1*b1 + b1*d1)%z;
		c = (c1*a1 + d1*c1)%z;
		d = (c1*b1 + d1*d1)%z;
		n = n>>1;
	}
	return c0;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, d;
	i2(n, d);
	int aray[n];
	for(int i=0;i<n;i++)
		i1(aray[i]);
	int len = sqrt(n);
	int box = n/len+1;
	pair<int, int> query[d];
	vector<pair<int, int> >q[box];
	int ans[d];
	for(int i=0;i<d;i++)
	{
		int x, y;
		i2(x, y);
		x--;
		y--;
		query[i] = mp(x, y);
		q[x/len].pb(mp(y, i));
	}
	for(int i=0;i<box;i++)
	{
		if(q[i].size() == 0)
			continue;
		sort(all(q[i]));
		int c[n+1] = {0};
		int left = 0, right = -1;
		int val = 0;
		for(auto x : q[i])
		{
			int l = query[x.se].fi, r = x.fi;
			for(int j=right+1;j<=r;j++)
			{
				if(!c[aray[j]])
					val++;
				c[aray[j]]++;
			}
			right = r;
			if(l > left)
			{
				for(int j=left;j<l;j++)
				{
					c[aray[j]]--;
					if(!c[aray[j]])
						val--;
				}
			}
			else
			{
				for(int j=l;j<left;j++)
				{
					if(!c[aray[j]])
						val++;
					c[aray[j]]++;
				}
			}
			left = l;
			ans[x.se] = val;
		}
	}
	for(int i=0;i<d;i++)
		o1(ans[i]);
	return 0;
}

Measured memory_bytes: 20212
#include <stdio.h>
#include <stdlib.h>

int compar(const void *p1, const void *p2);

int main()
{
	int i,n;
	
	scanf("%d",&n);
	
	int a[n];
	
	for(i = 0;i < n;i++)
	{
		scanf("%d",&a[i]);
	}
	
	qsort(a,n,sizeof(int),compar);
	
	for(i = 0;i < n-1;i++)
	{
		if(a[i] == a[i+1])
			break;
	}
	
	printf("%s\n",i == n - 1?"YES":"NO");
	
	return 0;
}

int compar(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}

Measured memory_bytes: 1788
n,k,q=map(int,input().split())
a=[(input()) for l in range(q)]
#if q-k<0:
 #   for i in range(n):
  #      print('Yes')
#else:
import collections
c = collections.Counter(a)
for i in range(n):
    #print(k-c[str(i+1)])
    if q-c[str(i+1)]<k:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 14244
#include <iostream>
#include <cstring>

using namespace std;

int main() {

	int l;
	char t, str[64];

	cin >> str;
	l=strlen(str);

	for(int i=0; i<l/2; i++) {
		t=str[i];
		str[i]=str[l-i-1];
		str[l-i-1]=t;
	}

	cout << str << endl;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
using namespace std;
using ll = long long int;
using vi = vector<pair<int, int> >;
using graph = vector<vi>;
const int MAXN = 212345;
int main() {
    int a, b, h;
    scanf("%d %d %d", &a, &b, &h);
    printf("%d\n", (a+b)*h >> 1);
}


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

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const ll mod = 998244353;
int n;

int main() {
	cin >> n;
	int ans = n;
	for (int i = 1; i < n / 2; i++) {
		int t = i;
		int j = n - i;
		int temp=0;
		while (t > 0) {
			temp += t % 10;
			t /= 10;
		}
		while (j) {
			temp += j % 10;
			j /= 10;
		}
		ans = min(ans, temp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int A,B,C,D;
  int X,Y,Z;

  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &C);
  scanf("%d", &D);
  
  if (A < B)
    X = A;
  else
    X = B;

  if (C < D)
    Y = C;
  else
    Y = D;

  Z = X + Y;

  printf("%d", Z);

  return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> b(n + 1);
  for (int i = 1; i < n; i++) {
    cin >> b[i];
  }
  b[n] = 1e9;
  int res = b[1];
  for (int i = 1; i < n; i++) {
    res += min(b[i], b[i+1]);
  }
  cout << res;
}

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

using namespace std;

int main() {
 	int N;
  	cin >> N;
  	int a = sqrt(N);

  	while (N % a != 0) a--;
  	if (a <= 9 && N/a <= 9) cout << "Yes";
  	else cout << "No";
}


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

signed main(){
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	
	bool flg=false;

	for(int m=0;m<n;m++){
	if(m*c-(n-1-m)*d<=b-a && b-a<=d*m-(n-1-m)*c)flg=true;
    } 

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

}
//  c  d
// -d  -c
// b-a

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

i32 x[10][10];

int main() {
  i32 n, d;
  cin >> n >> d;

  rep(i, n) rep(j, d) cin >> x[i][j];

  u32 ans = 0;
  rep(j, n) {
    rep(i, j) {
      u32 sumsq = 0;
      rep(k, d) { sumsq += (x[j][k] - x[i][k]) * (x[j][k] - x[i][k]); }
      u32 sq = sqrt(sumsq) + 0.5;
      if (sumsq == sq * sq)
        ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define pb push_back
#define A first
#define B second
using namespace std;

typedef long long ll;
typedef pair <int, int> pi;
constexpr double PI = atan(1) * 4;
constexpr int inf = 0x3f3f3f3f;
inline int LSB(int i) {return (i & -i);}

int n, c, w[105], v[105], sum, ans, dp[100005];

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

    cin >> n >> c;
    for(int i = 0; i < n; i++){
    	cin >> w[i] >> v[i];
        sum += v[i];
    }
    fill(dp, dp + sum + 1, c + 1);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
    	for(int j = sum - v[i]; j >= 0; j--){
            if(dp[j] < c){
                dp[j+v[i]] = min(dp[j+v[i]], dp[j] + w[i]);
                if(dp[j+v[i]] <= c) ans = max(ans, j + v[i]);
            }
    	}
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

struct data{
	int t;
	ll p,f;
	data(){}
	data(int tt,ll pp,ll ff){
		t=tt;
		p=pp;
		f=ff;
	}

	bool operator<(const data &d)const{
		if(f==d.f)return p<d.p;
		return f<d.f;
	}
};

struct CHTrick{
	deque<P> lines;
	bool isMonoticX=false;
	CHTrick(bool flag=false){
		isMonoticX=flag;
	}

	bool check(P l1,P l2,P l3){
		return (l3.second-l2.second)*(l2.first-l1.first)>=(l2.second-l1.second)*(l3.first-l2.first);
	}

	void add(ll a,ll b){
		if(lines.size()>0 && lines.back().first==a){
			b=max(b,lines.back().second);
			lines.pop_back();
		}
		P line(a,b);
		while(lines.size()>=2 && check(*(lines.end()-2),lines.back(),line)){
			lines.pop_back();
		}
		lines.push_back(line);
	}

	ll f(int i,ll x){
		return lines[i].first*x+lines[i].second;
	}
	ll f(P line,ll x){
		return line.first*x+line.second;
	}

	bool comp(ll lv,ll rv){
		return lv<=rv;
	}

	ll get(ll x){
		if(isMonoticX){
			while(lines.size()>=2 && comp(f(0,x),f(1,x))){
				lines.pop_front();
			}
			return f(0,x);
		}else{
			int low=-1,high=lines.size()-1;
			while(high-low>1){
				int mid=(high+low)/2;
				assert(mid>=0 && mid+1<lines.size());
				if(comp(f(mid,x),f(mid+1,x)))low=mid;
				else high=mid;
			//	printf("%d %lld %lld %lld\n",mid,x,f(mid,x),f(mid+1,x));
			}
			return f(high,x);
		}
	}
};

int n,T;
data d[4005];

CHTrick dp[4005];

int main(void){
	scanf("%d%d",&n,&T);
	for(int i=0;i<n;i++){
		scanf("%d%lld%lld",&d[i].t,&d[i].p,&d[i].f);
	}
	sort(d,d+n);
	dp[0].add(0,0);
	ll ans=0;
	for(int i=0;i<n;i++){
		for(int j=T-d[i].t;j>=0;j--){
			if(dp[j].lines.size()==0)continue;
			ll v=dp[j].get(d[i].f)+d[i].p-d[i].f*d[i].f;
			if(j==0){
				v+=d[i].f*d[i].f;
			}
			ans=max(v,ans);
			dp[j+d[i].t].add(2LL*d[i].f,v-d[i].f*d[i].f);
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main() {
  int N;
  int Alice_score=0, Bob_score=0;
  cin >> N;
  vector<int> num(N);
  
  for (int i = 0; i < N; i++) {
    cin >> num.at(i);
  }
  
  sort(num.begin(), num.end());
  reverse(num.begin(), num.end());
  
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      Alice_score += num.at(i);
    } else {
      Bob_score += num.at(i);
    }
  }
  
  cout << Alice_score - Bob_score << endl;
}
  


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		String B = sc.next();
		String C = sc.next();
		
		String A2[] = A.split("");
		String B2[] = B.split("");
		String C2[] = C.split("");
		
		if(A2[A2.length-1].equals(B2[0]) && B2[B2.length-1].equals(C2[0])){
			System.out.print("YES");
		}else{
			System.out.print("NO");
		}

	}

}


Measured memory_bytes: 23764
N, M = map(int, input().split())
mod = 10**9+7


def for_factorial(n):
    mod = 10**9+7
    val = 1
    for i in range(2, n + 1):
        val = (val*i) % mod
    return val


f = for_factorial(N)*for_factorial(M) % mod
if N == M:
    ans = f*2 % mod
elif abs(N - M) == 1:
    ans = f % mod
else:
    ans = 0

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,a,b;
  cin>>n>>a>>b;
  cout<<max((int)0,(n-2)*(b-a)+1)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct BIT{
private:
   int sz;
   vector<ll> node;
public:
   BIT(int n):sz(n),node(n+1){};
   void add(int k,ll x){
       k++;
       while(k<=sz){
           node[k]+=x;
           k+=k&-k;
       }
   }
   ll sum(int k){
       k++;
       ll ret=0;
       while(k>0){
           ret+=node[k];
           k-=k&-k;
       }
       return ret;
   }
   ll sum(int l,int r){
       return sum(r-1)-sum(l-1);
   }
   ll get(int k){
       return sum(k,k+1);
   }
};

int main(){
    ll n;cin>>n;
    ll a[n],b[n];
    rep(i,n){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    int l=0,r=n,m=1;
    while(r-l>1){
        m=(l+r)/2;
        BIT bit(3*n+1);
        int pos=n;
        ll sum=0;
        bit.add(pos,1);
        rep(i,n){
            if(a[i]>=b[m])++pos;
            else --pos;
            sum+=bit.sum(pos);
            bit.add(pos,1);
        }
        if(2*sum<n*(n+1)/2)r=m;
        else l=m;
    }
    cout<<b[l]<<endl;
    return 0;
}


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

int main() {
  int N, K, a = 1;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    if (a < K)
      a *= 2;
    else
      a += K;
  }
  
  cout << a;
}

Measured memory_bytes: 256
n, m, x, y = gets.split.map(&:to_i)
xs, ys = readlines.map(&:chomp).map(&:split).map {|arr| arr.map(&:to_i)}

if (xs.max < ys.min) && (x < ys.min && xs.max < y)
  puts "No War"
else
  puts "War"
end


Measured memory_bytes: 1788
from functools import lru_cache
n, x = map(int, input().split())

@lru_cache(None)
def d(k):
    if k == 0:
        return 1
    return 2 * d(k-1) + 3

@lru_cache(None)
def f(i, h):
    if h == 0:
        return i
    rv = 0
    if i >= 1:
        rv += f(min(i-1, d(h-1)), h-1)
    if i >= d(h-1) + 2:
        rv += 1 + f(min(i - d(h-1) - 2, d(h-1)), h-1)
    return rv

print(f(x, n))


Measured memory_bytes: 3684
// 連鎖行列積 問題
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_N 100
#define ELE_NUM 2
// 無効な値の定義
const int INV = -1;

const int colNo = 0;
const int rowNo = 1;
const int IntMAX = 	2147483647;

int ChainedMatrixtMultiplication(int n, int m, int matrixData[][ELE_NUM]);

int main(void)
{

    int n, count;
    int matrix_data[MAX_N + 1][ELE_NUM];

    cin >> n;

    for(int i = 1; i <= n; i++)
    {
        // 行
        cin >> matrix_data[i][colNo];
        // 列
        cin >> matrix_data[i][rowNo];
    }

    count = ChainedMatrixtMultiplication(n, ELE_NUM, matrix_data);
    printf("%d\n", count);

    return 0;
}

// 連鎖行列積の最小の乗算回数を演算する関数
// n : 積を求める行列の数
// m : 行列の情報 : 0 - 行の情報, 1 - 列の情報
// matrixData[][] : 各行列の行、列情報を保持する配列
int ChainedMatrixtMultiplication(int n, int m, int matrixData[][ELE_NUM])
{

    // 第1要素 : 演算開始のNo., 第2要素 : 演算終了のNo.
    int dp[MAX_N + 1][MAX_N + 1];
    int calcResult = 0;

    // 配列の初期化
    for(int i = 0; i <= n; i++)
    {
        for(int j = 0; j <= n; j++)
        {
            dp[i][j] = INV;

            if( i == j )
            {
                // 同じ要素同士の積は演算することが不可能
                dp[i][j] = 0;
            }
        }
    }

    // 行列の演算回数の計算
    // i : 行列の演算をする先頭の要素No.
    // j : 行列の演算をする最後の要素No.
    // k : i 〜 jまでの範囲を移動する変数
    for(int l = 2; l <= n; l++)
    {
        for(int i = 1; i <= n - l + 1; i++)
        {
            int j = i + l - 1;

            dp[i][j] = IntMAX;

            for(int k = i; k <= j - 1; k++)
            {
                calcResult = dp[i][k] + dp[k + 1][j]
                            + ( matrixData[i][colNo] * matrixData[k][rowNo] * matrixData[j][rowNo]);

                dp[i][j] = min( dp[i][j], calcResult );
            }
        }
    }

    return dp[1][n];
}



Measured memory_bytes: 3244
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

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

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl
int gcd(int x, int y){
    if ((x==1)||(y==1)) {
        return 1;
    }
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}

int main() {
    IN(int, n);
    vector<pii> a(n);
    REP(i, n){
        IN(int, x);
        IN(int, l);
        a[i].first = x+l;
        a[i].second = x-l;
    }
    sort(ALL(a));
    int last = a[0].first;
    int ans = 1;
    REPS(i, n-1){
        if (a[i].second>=last) {
            last =  a[i].first;
            ans++;
        }
    }
    COUT(ans);
}


Measured memory_bytes: 1024
import std.stdio;
import std.string, std.conv, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons;
import core.bitop, std.datetime, std.range;

void main(){
    auto rd = readln.split.to!(int[]);
    auto n = rd[0], q = rd[1];
    auto ds = new int[][](n, 1);
    auto n2s = iota(n).array;

    foreach(i ; 0 .. n){
        ds[i][0] = i;
    }

    foreach(lp ; 0 .. q){
        rd = readln.split.to!(int[]);
        auto c = rd[0], x = rd[1], y = rd[2];

        if(c == 0){
            merge(ds, n2s, x, y);
        } else{
            writeln(n2s[x] == n2s[y] ? 1 : 0);
        }
    }

}

void merge(int[][] ds, int[] n2s, int x, int y){
    auto u = n2s[x];
    auto v = n2s[y];

    if(u == v) return;

    if(u > v) swap(u, v);

    ds[v] ~= ds[u];
    foreach(z ; ds[u]){
        n2s[z] = v;
    }
    delete ds[u];
}

Measured memory_bytes: 11080
n = int(input())
a = [0] * 4
for loop in range(n):
    s = input()
    if s == 'AC':
        a[0] += 1
    if s == 'WA':
        a[1] += 1
    if s == 'TLE':
        a[2] += 1
    if s == 'RE':
        a[3] += 1
s = ['AC', 'WA', 'TLE', 'RE']
for i in range(4):
    print(s[i], 'x', a[i])


Measured memory_bytes: 69916
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b;
	cin>>a>>b;
	if(a-b>=0)cout<<a-b<<endl;
	else cout<<0<<endl;
	
	return 0;
}

Measured memory_bytes: 256
/*#include<iostream>
using namespace std;
int main() {
int a, sum = 0;
for (int i = 0; i < 4; i++) {
cin >> a;
sum += a;
}
cout << sum / 60 << endl << sum % 60 << endl;
}*/
/*#include<iostream>
using namespace std;
int main() {
int min1 = 2000, min2 = 2000, a;
for (int i = 0; i < 3; i++) {
cin >> a;
if (min1 > a)min1 = a;
}
for (int i = 0; i < 2; i++) {
cin >> a;
if (min2 > a)min2 = a;
}
cout << min1 + min2-50 << endl;
}*/
/*#include<iostream>
using namespace std;
int main() {
int a[5], b[2] = {1}, sum = 0;
for (int i = 0; i < 5; i++) {
cin >> a[i];
}
while (a[1] > a[3]*b[0]) {
b[0]++;
//cout << "bakatoy" << endl;
}
while (a[2] > a[4]*b[1]) {
b[1]++;
//cout << "bakatoy" << endl;
}
if (b[0] > b[1]) {
cout << a[0]-b[0] << endl;
}
else {
cout << a[0]-b[1] << endl;
}
}*/
#include<iostream>
using namespace std;
int main() {
	int a, sum=0;
	for (int i = 0; i<5; i++) {
		cin >> a;
		if (a < 40)a = 40;
		sum += a;
	}
	cout << sum / 5 << endl;
}

Measured memory_bytes: 3080
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define _max(_x, _y) ((_x)>(_y)?(_x):(_y))
#define _min(_x, _y) ((_x)>(_y)?(_y):(_x))
#define _abs(_x) ((_x)>0?(_x):(-(_x)))

// 比較関数
int asc(const void *a, const void *b) {
  long *A = (long *)a;
  long *B = (long *)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}
void qsort(
  void *base, size_t num, size_t size,
  int (*compare)(const void *a, const void *b)
);

int main(void)
{
char Nc[10];
long N, K, H[200000], index, ans;

  scanf("%ld %ld", &N, &K);
  for (index = 0; index < N; ++index) {
    scanf("%ld", &H[index]);
  }
  qsort(&H, N, sizeof(long), asc);
  for (index = 0, ans = 0; index < N - K; ++index) {
    ans += H[index];
  }
  printf("%ld\n", ans);
  
  return 0;
}

Measured memory_bytes: 3324
#include<iostream>
#include<list>
#include<algorithm>
#include<string>
using namespace std;

int main(){
    int q,x;
    char com[20];
    list<int> v;
    scanf("%d",&q);
    for (int i=0;i<q;i++){
        scanf("%s",com);
        if(com[0] == 'i'){
            scanf("%d",&x);
            v.push_front(x);
        }else if(com[6] == 'L'){
            v.pop_back();
        }else if(com[6] == 'F'){
            v.pop_front();
        }else if(com[0] == 'd'){
            scanf("%d",&x);
            for (list<int>::iterator it=v.begin();it!=v.end();it++){
                if(*it == x){
                    v.erase(it);
                    break;
                }
            }
        }
    }
    int i=0;
    for(list<int>::iterator it=v.begin();it!=v.end();it++){
        if(i++) printf(" ");
        printf("%d",*it);
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 34432
#include <stdio.h>

int main()
{
	int a,b,c;
	int f;

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

	if(a < b)
	{
		if(b < c)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	else
	{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
#include<stdio.h>
int r,d,x,i,ans[10];
int main(void){
    scanf("%d%d%d",&r,&d,&x);
    ans[0] = r*x-d;
for(i=1;i<10;i++){
    ans[i] = r*ans[i-1]-d;
}
for(i=0;i<10;i++){
    printf("%d\n",ans[i]);
}
return 0;
}

Measured memory_bytes: 128
require 'prime'
S=gets.to_i

n = 10**9
if S == 10**18
    ret = [
        n,0,
        0,n,
        n,n,    
    ]
else
    q,r=S.divmod(10**9)
    ret = [
        0,0,
        1,q+1,
        n,n-r,    
    ]
end

puts ret.join(' ')

Measured memory_bytes: 2044
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;



int main()
{
    int x;
    scanf("%d",&x);

    x=x-400;
    x=x/200;
    x=8-x;
    
    printf("%d\n",x);
    return 0;
}

Measured memory_bytes: 1736