akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)

int main() {
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	int i, w = 0;
	int f = 0;
	for (i = 0; i<n; i++) {
		if (s[i] == 'c')
			cout << "No" << endl;
		else if (s[i] == 'a') {
			if (w<a + b) {
				cout << "Yes" << endl;
				w++;
			}
			else {
				cout << "No" << endl;
			}
		}
		else {
			f++;
			if (w<a + b && f <= b) {
				cout << "Yes" << endl;
				w++;
			}
			else {
				cout << "No" << endl;
			}
		}
	}
}

Measured memory_bytes: 896
#include <stdio.h>

int main(void) {
  int a;
  int b;
  scanf("%d %d", &a, &b);
  if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) printf("Possible");
  else printf("Impossible");
  return 0;
}


Measured memory_bytes: 128
def calc(nums):
    for n in nums:
        if n % 2 == 0:
            if not (n % 3 == 0 or n % 5 == 0):
                return False
    return True

if __name__ == '__main__':
    N = int(input())
    nums = list(map(int, input().split()))
    if calc(nums):
        print('APPROVED')
    else:
        print('DENIED')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;

int main() {
  ll n;
  cin >> n;
  if (n%1000==0)
    cout << 0 << endl;
  else
    cout << 1000 - n%1000 << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
 
int main()
{
    int n,x;
    std::cin >> n >> x;
    std::vector<int>  l(n+1);
    for(int i  = 1 ; i <= n;i++){
        std::cin >> l[i];
    }
    int cur = 0,cnt = 0;
    for(int i = 0;i <= n; i++){
        cur += l[i];
        if(cur <= x)cnt++;
    }
    std::cout << cnt << std::endl;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    set<char> a;
    rep(i, n) {
        char tmp;
        cin >> tmp;
        a.insert(tmp);
    }
    if (a.size() == 4)
        cout << "Four" << endl;
    else
        cout << "Three" << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn=1e5+5;
const LL mod=1e9+7;
int read() {
	char ch=getchar();int x=0,f=1;
	while(ch<'0' || ch>'9')	{if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int gcd_(int a,int b) {return b==0?a:gcd_(b,a%b);}
LL fpow(LL a,LL b) {
	LL res=1;
	while(b) {
		if(b&1) res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main() {
//	cout<<"Accepted!\n";
	int n,r;
	cin>>n>>r;
	if(n>=10) cout<<r;
	else cout<<r+100*(10-n);
	return 0;
}


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


int main(){
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    int math[h][w];//行列
    for(int i=0; i<b; i++){
        for(int j=0; j<a; j++){
            math[i][j]=0;
        }
        for(int j=a; j<w; j++){
            math[i][j]=1;
        }
    }
    for(int i=b; i<h; i++){
        for(int j=0; j<a; j++){
            math[i][j]=1;
        }
        for(int j=a; j<w; j++){
            math[i][j]=0;
        }
    }

    //cout << "OK!";
    //cout << math[0][0] << math[0][1]<< math[0][2];

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cout << math[i][j];
        }
        cout << endl;
    }

    
}




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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int a[4];
	rep(i,4)cin >> a[i];
	
	bitset<12> B;
	rep(i,4)B[a[i]] = true;
	
	if(B == bitset<12>("001010010010"))puts("YES");
	else puts("NO");
}



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

num_lists.sort()
num_lists.reverse()
alice_num_lists = []
bob_num_lists = []

for i in range(n):
  if i%2 == 0:
    alice_num_lists.append(num_lists[i])
  else:
    bob_num_lists.append(num_lists[i])

alice_score = 0
bob_score = 0
for i in alice_num_lists:
  alice_score += i
for i in bob_num_lists:
  bob_score += i

print(alice_score - bob_score)

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i = 0; i < n; i++)
    cin >> d.at(i);
  sort(d.begin(), d.end());
  cout << d.at(n / 2) - d.at(n / 2 - 1) << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main(){
    int a, b, c;
    int f = 0;
    cin >> a >> b >> c;
    VE v;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.rbegin(), v.rend());
    int ans = 0;
    ans += (v[0] - v[1]) / 2;
    if((v[0] - v[1]) % 2)f++;
    ans += (v[0] - v[2]) / 2;
    if((v[0] - v[2]) % 2)f++;
    if(f == 1){
        ans += 2;
    }else if(f == 2){
        ans += 1;
    }
    print(ans);
}

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

typedef long long ll;

int main(){

    string s;
    cin >> s;

    int sum_b = 0;
    ll ans = 0;
    
    for(int i=0; i<s.size(); i++){
	if( s[i] == 'B' ) {
	    sum_b++;
	}
	else{
	    ans += sum_b;
	}
    }
    cout << ans << endl;
    
    
    
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

typedef long long ll;
#define MOD 998244353ll

ll ten[1000000],one[1000000];

struct S{
	int len;
	ll val;
};

using F = int;

S op(S l, S r){
    // ,
	return S{l.len + r.len, (l.val * ten[r.len] + r.val) % MOD};
}

S e(){
	return S{0, 0};
}

S mapping(F f, S s){
	if(f == 0) return s;
	return S{s.len, one[s.len] * f % MOD};
}

F composition(F l, F r){
	return ((l == 0) ? r : l);
}

F id(){
	return 0;
}

int main(void){
	int N,Q,i;

    // ten[i] = 1 * (i * 10)
	ten[0] = 1;
	for(i=1;i<1000000;i++) ten[i] = ten[i-1] * 10 % MOD;
    // one([i]) = 111...
	one[0] = 0;
	for(i=1;i<1000000;i++) one[i] = (one[i-1] * 10 + 1) % MOD;

	cin >> N >> Q;
	S unit = {1, 1};
	vector <S> v(N, unit);
	lazy_segtree <S, op, e, F, mapping, composition, id> seg(v);

	REP(i,Q){
		int L,R,D;
		scanf("%d%d%d", &L, &R, &D);
		seg.apply(L-1, R, D);
		ll ans = seg.prod(0, N).val;
		printf("%d\n", (int)ans);
	}

	return 0;
}


Measured memory_bytes: 31264
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

const ll n_div = 1e9+7;
const ll MAX_N = 2*1e5;
ll N;
ll C[MAX_N];
ll dp[MAX_N+1]; // 0-iまでの部分列でありうる組み合わせ
ll dp_same[MAX_N+1]; //右端がj色部分列の組み合わせのここまでの最大のもの

void rec(ll i){
	if (i==0){
		dp[i] = 1;
	}
	else if (C[i-1]==C[i]){
			dp[i] = dp[i-1];
	} 
	else{
		dp[i] = dp[i-1] + dp_same[C[i]];
		dp[i] %= n_div;
	}
	dp_same[C[i]] = dp[i];
	// printf("dp[%lld] = %lld, dp_same[%lld] = %lld\n",
	// 	i, dp[i], C[i], dp_same[C[i]]);
	return;
}
 
 
int main() {
	// 入力
	cin >> N;
	for (ll i = 0; i < N; ++i) cin >> C[i];
 
	// 解法
	// DP
	memset(dp, -1, sizeof(dp));
	// memset(dp_same, 1, sizeof(dp_same));
	REP(i,MAX_N+1)dp_same[i] = 0;
	REP(i,N) rec(i);
	//出力
	cout << dp[N-1] << endl;
}


Measured memory_bytes: 4992
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
bool ch(string s){
	int n=s.size();
	rep(i,n){
		if(s[i]!=s[n-i-1]) return false;
	}
	return true;
}
int main()
{
	string s;cin>>s;int n=s.size();
	if(ch(s) && ch(s.substr(0,n/2)) && ch(s.substr(n-n/2))) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    def ok():
        for a in aa:
            if a%2==0:
                if a%3 and a%5:return False
        return True

    n=II()
    aa=LI()
    if ok():print("APPROVED")
    else:print("DENIED")

main()

Measured memory_bytes: 3064
def merge(a, left, mid, right):
    global cnt
    l = a[left:mid] + [10**9 + 1]
    r = a[mid:right] + [10**9 + 1]

    i = 0
    j = 0
    for k in range(left, right):
        if l[i] <= r[j]:
            a[k] = l[i]
            i += 1
        else:
            cnt += len(l) - 1 - i  # rest of left-[10**9+1]
            a[k] = r[j]
            j += 1


def mergesort(a, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergesort(a, left, mid)
        mergesort(a, mid, right)
        merge(a, left, mid, right)


n = int(input())
a = list(map(int, input().split()))
cnt = 0
mergesort(a, 0, n)
print(cnt)

Measured memory_bytes: 30464
d=int(input())
C=sorted((c,e) for e,c in enumerate(map(int,input().split())))[::-1]
l,m,r=C[:9],C[9:18],C[18:]
p=l+m+l+r+l+m
for i in range(d): print(p[i%len(p)][1]+1)

Measured memory_bytes: 9224
def sum(p):
    q=0
    while p>0:
        q+=p%10
        p=p//10
    return(q)

n,a,b=map(int,input().split())
ans=0
for i in range(1,n+1):
    if sum(i)>=a and sum(i)<=b:
        ans+=i

print(ans)

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

M = 1000
X = 0
i = 0

while i<N-1:
  if A[i]<A[i+1]:
    M = M + X * A[i]
    X = M // A[i]
    M = M - X * A[i]
    i += 1
  elif A[i]>A[i+1]:
    M = M + X * A[i]
    X = 0
    i += 1
  else:
    i += 1

print(A[N-1] * X + M)


Measured memory_bytes: 61904
"""
https://abc067.contest.atcoder.jp/tasks/abc067_b
"""
[n,k]=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]
l.sort()
a=0
for i in range(k):
    a=a+l[n-i-1]
print(a)


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

ans = 0
for i in range(N):
    ans += B[i]
    if i != N-1 and A[i+1]-A[i]==1:
        ans += C[A[i]-1]

print(ans)

Measured memory_bytes: 38384
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main() {
	int s[10];
	int ss = 0;
	while(true) {
		int x;
		if(scanf("%d", &x)<1)break;
		if(x==0) {
			printf("%d\n",s[--ss]);
		} else {
			s[ss++]=x;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define st string
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define each(i, n) for(auto&& i: n)

int main() {
  int A, B;
  cin >> A >> B;
  if(A <= 9 && B <= 9) {
    cout << A * B << endl;
  }
  else {
    cout << -1 << endl;
  }
}  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PAIR pair<double, double>
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
#define PI acos(-1)
const LL MOD = (LL)1e9+7;
const LL INF = (LL)1e9+7;
const LL INFLL = (LL)1e18;
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int main(){
	string s;
	cin >> s;
	if(s[0]=='S'){
		cout << "Cloudy" << endl;
	}else if(s[0]=='C'){
		cout << "Rainy" << endl;
	}else{
		cout << "Sunny" << endl;
	}

	return 0;

}


Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


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

    int a, b;
    cin >> a >> b;
    cout << (a * b) << '\n';
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N, K;
	int D[9];
	scanf("%d %d", &N, &K);
	for(int i = 0; i < K; i++) scanf("%d", &D[i]);
	for(int i = N; i < 100000; i++){
		int p = i;
		bool flag = true;
		while(p > 0){
			for(int j = 0; j < K; j++){
				if(D[j] == p % 10){
					flag = false;
					break;
				}
			}
			p /= 10;
		}
		if(flag){
			printf("%d\n", i);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
def check(s):
    try:
        if s.count(s[0]) == 4:
            return False

        s1 = s[0]
        s.remove(s1)
        s.remove(s1)

        s1 = s[0]
        s.remove(s1)
        s.remove(s1)
    except ValueError:
        return False
    else:
        return True

s = list(input())
if check(s):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A), b(B);
    rep(i, A) cin >> a[i];
    rep(i, B) cin >> b[i];
    
    int ans = 100000000;
    rep(i, M) {
        int x, y, c;
        cin >> x >> y >> c;
        ans = min(ans, a[x - 1] + b[y - 1] - c);
    }
    
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    ans = min(ans, a[0] + b[0]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int solve(int a, int year, int t, double r, int q)
{
	int b, x;
	int y = 0;
	if(t == 1){
		while(year--){
			b = a * r;
			x = a + b - q;
			a = x;
		}
	}
	
	if(t == 0){
		while(year--){
			b = a * r;
			x = a - q;
			y += b;
			a = x;
		}
	}
	return x + y;
}
	
void max(int n, int d[110])
{
	int z = 0;
	for(int i = 0; i < n; i++){
		if(z < d[i]) z = d[i];
	}
	cout << z << endl;
}

int main()
{
	int m;
	int a, year, n, t, q;
	double r;
	int d[110];
	
	cin >> m;
	while(m--){
		cin >> a;
		cin >> year;
		cin >> n;
		for(int i = 0; i < n; i++){
			cin >> t >> r >> q;
			d[i] = solve(a, year, t, r, q);
		}
		max(n, d);
	}
	return 0;
}

Measured memory_bytes: 1232
<?php
/**
 * ABC128
 * C - Switches
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d %d", $n, $m);
for ($i = 0; $i < $m; $i++) {
    $line = array_map('intval', explode(' ', trim(fgets(STDIN))));
    $k[$i] = array_shift($line);
    $s[$i] = $line;
}
$p = array_map('intval', explode(' ', trim(fgets(STDIN))));
$count = 0;
for ($i = 0; $i < 2 ** $n; $i++) {
    $bit = decbin($i);
    $bit = str_pad($bit, $n, '0', STR_PAD_LEFT);
    for ($j = 0; $j < $m; $j++) {
        $total = 0;
        for ($l = 0; $l < $k[$j]; $l++) {
            $total += (int) $bit[$s[$j][$l] - 1];
        }
        if ($total % 2 != $p[$j]) {
            continue 2;
        }
    }
    $count++;
}

echo $count, PHP_EOL;


Measured memory_bytes: 4604
#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vvi = vector<vector<int>> ;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI 3.141592653
#define rep(i, n) for(ll i = 0; i < n; i++)



int main(){
  vll v(5);
  rep(i, 5){
    cin >> v[i];
    if(v[i] != i+1){cout << i+1 << endl;}
    }
  
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int A, B, C; cin >> A >> B >> C;
  int result = max(0, B+C-A);
  cout << result << endl;
  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++)
using ll = long long;

int main() {
int n;
cin >> n;
vector<int> a(n);

rep(i,n) cin >> a.at(i);

int cnt = 0;
for(int i = 1; i < n-1; i++){
  vector<int> b = {a.at(i-1),a.at(i),a.at(i+1)};
  sort(b.begin(),b.end());
  if(b.at(1) == a.at(i)) cnt++;
}

cout << cnt << endl;
}
  


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <algorithm>

using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
	int K, A, B;
	cin >> K >> A >> B;

	for (int i = A; i <= B; ++i) {
		if (i % K == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;
	return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int r, D, x;

int main() {
    cin >> r >> D >> x;

    for (int i = 2001; i <= 2010; i++) {
        x = r * x - D;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  int n,q,i,j,l,r;
  scanf("%d%d",&n,&q);
  int t[n];
  char s[n];
  scanf("%s",s);
  t[0]=0;
  for(i=1;i<n;i++){
    if(s[i]=='C'&&s[i-1]=='A')t[i]=t[i-1]+1;
    else t[i]=t[i-1];
  }
  for(i=0;i<q;i++){
    scanf("%d%d",&l,&r);
    printf("%d\n",t[r-1]-t[l-1]);
  }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

char b;
void solve(){
  cin >> b;
  switch(b){
  case 'A':
    cout << 'T' fin;
    break;
  case 'T':
    cout << 'A' fin;
    break;
  case 'C':
    cout << 'G' fin;
    break;
  case 'G':
    cout << 'C' fin;
  }
  
  


}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define modulo 1000000007
typedef long long int ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int main() {
	int n;
	cin >> n;
	vector<int> a(n+1);
	for(int i=1; i<n+1; i++) cin >> a[i];

	vector<int> b(n+1,0);
	int ans(0);

	for(int i=n; i>=1; i--){
		int sum(0);
		for(int j=i*2; j<=n; j+=i){
			if(b[j]==1) sum ++;
		}
		if(sum % 2 != a[i] % 2){
			b[i] = 1;
			ans ++;
		}
	}

	cout << ans << endl;
	for(int i=1; i<n+1; i++){
		if(b[i]>0)
			cout << i << endl;
	}

	return 0;
}

Measured memory_bytes: 2432
#include <iostream>

using namespace std;

void solve()
{
	int time = 7200;
	int h, m, s;
	while(cin >> h >> m >> s)
	{
		if(h == -1 && m == -1 && s == -1)
		{
			break;
		}
		int sum = time - (3600 * h + 60 * m + s);
		int sum3 = sum * 3;
		h = sum / 3600;
		sum %= 3600;
		m = sum / 60;
		sum %= 60;
		s = sum;
		cout << "0" << h << ":";
		if(m < 10)
		{
			cout << "0" << m << ":";
		}
		else
		{
			cout << m << ":";
		}
		if(s < 10)
		{
			cout << "0" << s << endl;
		}
		else
		{
			cout << s << endl;
		}
		int h3, m3, s3;
		h3 = sum3 / 3600;
		sum3 %= 3600;
		m3 = sum3 / 60;
		sum3 %= 60;
		s3 = sum3;
		cout << "0" << h3 << ":";
		if(m3 < 10)
		{
			cout << "0" << m3 << ":";
		}
		else
		{
			cout << m3 << ":";
		}
		if(s3 < 10)
		{
			cout << "0" << s3 << endl;
		}
		else
		{
			cout << s3 << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1160
import math

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]

count = N * (N - 1) // 2
t = 0.0

for i in range(N):
    for j in range(i + 1, N):
        x1 = XY[i][0]
        y1 = XY[i][1]
        x2 = XY[j][0]
        y2 = XY[j][1]

        t += math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)

print(t / count * (N - 1))

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll MOD = 1e9 + 7;
ll A,B,H, N, M, L, K, W, X, Y, Z;
ll ans = 0;
int main() {
	cin >> N >> K;
	if (K & 1) {
		ans = pow(N / K, 3);
	}
	else {
		ans = pow((N + K / 2) / K, 3) + pow(N / K, 3);
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
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; }
using namespace std;


int main(){
  ll N,K,S,ans=0;
  cin>>N>>K>>S;
  
  if(S<1000000000){
    for(int i=1; i<=N; ++i){
      if(i<=K) cout<<S<<" ";
      else cout<<S+1<<" ";
    }
    cout<<endl;
    return 0;
  }
  
  else{
    for(int i=1; i<=N; ++i){
      if(i<=K) cout<<S<<" ";
      else cout<<S-1<<" ";
    }
    cout<<endl;
    return 0;
  }
  
}

Measured memory_bytes: 1280
/* 
 * Project: AtCoder Beginners Contest 154 C - Distinct or Not
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/04
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <algorithm>
using namespace std;

int n;
int a[200000];

void solve() {

    sort(a, a+n);
    for (int i=0;i<n-1;i++) {
        if (a[i+1] - a[i] == 0) {
            printf("NO\n");
            return;
        }
    }
    printf("YES\n");
    return;

}

int main() {

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

    solve();

}

Measured memory_bytes: 3844
#include<stdio.h>

int main(void)
 {
	int a, b, c;
	scanf("%d %d %d",&a ,&b ,&c);
	if(a<b){
		if(b<c){
			printf("%d %d %d\n",a, b, c);
			return 0;
		}
		if(c<b){
			printf("%d %d %d\n",a, c, b);
			return 0;
		}
	}
	if(b<c){
		if(c<a){
			printf("%d %d %d\n",b, c, a);
			return 0;
		}
		if(a<c){
			printf("%d %d %d\n",b, a, c);
			return 0;
		}
	}
	if(c<a){
		if(a<b){
			printf("%d %d %d\n",c, a ,b);
			return 0;
		}
		if(b<a){
			printf("%d %d %d\n",c, b, a);
			return 0;
		}
	}
 }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

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

int main() {
    int n;
    cin >> n;
    int a[n];
    map<int, int> mp;
    rep(i, 0, n) {
        cin >> a[i];
        mp[a[i]]++;
    }
    int ans = n;
    rep(i, 0, n) {
        vector<int> d = divisor(a[i]);
        bool flag = false;
        for (auto j : d) {
            if (j == a[i]) {
                if (mp[j] >= 2) {
                    ans--;
                    flag = true;
                }
            } else {
                if (mp[j] >= 1) {
                    ans--;
                    flag = true;
                }
            }
            if (flag) break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		int d=scan.nextInt();
		int e=scan.nextInt();
		int f=scan.nextInt();
		if((e-a)<=f) {
			System.out.println("Yay!");
		}
		else {
			System.out.println(":(");
		}
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef string str;
const long long INF = INT64_MAX;

#define REP(i, n) for(ll i=0;i<n;i++)
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define UNIQ(v) ASC(v);erase(unique(v.begin(), v.end()), v.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

ll F[101][10];
ll P[101][11];

void solve() {
    ll N;cin >> N;
    for (int y = 0; y < N; y++)
    {
        for (int j = 0; j < 10; j++)
        {
            cin >> F[y][j];
        }
        
    }
    for (int y = 0; y < N; y++)
    {
        for (int j = 0; j < 11; j++)
        {
            cin >> P[y][j];
        }
        
    }
    ll ans = -INF;
    for (int i = 1; i < 1024; i++)
    {
        ll profit = 0;
        for (int j = 0; j < N; j++)
        {
            ll ctr = 0;
            for (int k = 0; k < 10; k++)
            {
                ll b = (i >> k) & 1;
                if(F[j][k] == 1 && b == 1) {
                    ctr++;
                }
            }
            profit += P[j][ctr];
        }
        ans = max(ans, profit);
    }
    cout << ans << endl;
}

int main() {
    FIO;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pb push_back
#define ll long long
using namespace std;
const int inf=1e9;
const int mod=998244353;
const int maxn=1e5+10;
int n;
ll d[maxn];
ll ksm(ll a,ll b){
	ll ret=1;
	while(b){
		if(b&1) ret=ret*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return ret;
}
int main(){
	ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n;
	int x;
	cin>>x;
	d[x]++;
	if(x!=0){
		cout<<0<<endl;
		return 0;
	}
	for(int i=2;i<=n;i++){
		cin>>x;
		d[x]++;
	}
	ll ret=0;
	ll ans=1;
	ll pr=1;
	if(d[0]>1){
		cout<<0<<endl;
		return 0;
	}
	for(int i=0;i<n;i++){
		if(d[i]==0){
			if(ret!=n) ans=0;
			break;
		}
		ans=ans*ksm(pr,d[i])%mod;
		ret+=d[i];
		pr=d[i];
	}
	cout<<ans<<endl;
	return 0;
}
//1 2 3 1

Measured memory_bytes: 1024
var input = '';
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout

});
reader.on('line',function(line){
    input += line + ' '
});
reader .on('close',function(){
    main(input)
});
function main(input){
    var args = input.split(' ')
    const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);

    if ((a * b) % 2 === 0) {
        console.log('Even');
    } else {
        console.log('Odd');
    }
}

Measured memory_bytes: 7500
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(void){
    ll l,r;
    ll ans = 200000;
    cin >> l >> r;
    if(r-l>=2019)ans = 0;
    else{
        for(ll i=l;i<=r;i++){
            for(ll j=i+1;j<=r;j++){
                ans = min(ans,(i*j)%2019);
            }
        }
    }
    cout << ans << endl;
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
ll n,ans;
vector<char> arr={'7','5','3'};
void check(string now)
{
    ll tmp=0;
    ll sev=-1,five=-1,three=-1;
    fr(i,0,SZ(now))
    {
        if(now[i]=='7')
        {
            sev=1;
        }
        if(now[i]=='5')
        {
            five=1;
        }
        if(now[i]=='3')
        {
            three=1;
        }
        tmp*=10;
        tmp+=(now[i]-'0');
    }
    if(sev==1&&five==1&&three==1)
    {
        if(tmp<=n)
        {
            ans++;
        }
    }
    return;
}
void fuckoff(ll digit,string now)
{
    if(SZ(now)==digit)
    {
        check(now);
        return;
    }
    check(now);
    fr(i,0,3)
    {
        now.pb(arr[i]);
        fuckoff(digit,now);
        now.pop_back();
    }
    return;
}
void solve()
{   
    cin>>n;
    ll digit=0;
    ll tmp=n;
    while(tmp>0)
    {
        digit++;
        tmp/=10;
    }
    fuckoff(digit,"");
    cout<<ans<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main() {
    int k,s; cin >> k >> s;
    ll ans = 0;
    rep(i,k+1){
        rep(j,k+1){
            if(s-i-j >= 0 && s-i-j <= k) ans ++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3632
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
//#include <unordered_set>
//#include <unordered_map>
#include <iomanip>
#include <sstream>

using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;

class SplitStream {
	typedef basic_ostream<char, char_traits<char> > BaseOst;
	std::ostream& ost_m;
	bool line_is_empty_m;
public:
	SplitStream(std::ostream& ost);
	template <typename T>
	SplitStream& operator<<(T right);
	SplitStream& operator<<(BaseOst& (*right)(BaseOst&));
};
SplitStream::SplitStream(std::ostream& ost) : ost_m(ost), line_is_empty_m(true) {}
template <typename T>
SplitStream& SplitStream::operator<<(T right) {
	if (!line_is_empty_m) ost_m << ' ';
	line_is_empty_m = false;
	ost_m << right;
	return *this;
}
/* std::endl のみ */
SplitStream& SplitStream::operator<<(BaseOst& (*right)(BaseOst&)) {
	ost_m << '\n';
	ost_m.flush();
	line_is_empty_m = true;
	return *this;
}
SplitStream Scout(cout);

template <typename T, int Begin, int End>
class OffsetArray {
	T arr_m[End - Begin];
public:
	OffsetArray();

	T& operator[](int index);
	T operator[](int index) const;
};
template<typename T, int Begin, int End>
OffsetArray<T, Begin, End>::OffsetArray() : arr_m() {}
template<typename T, int Begin, int End>
T& OffsetArray<T, Begin, End>::operator[](int index) {
	return arr_m[index - Begin];
}
template<typename T, int Begin, int End>
T OffsetArray<T, Begin, End>::operator[](int index) const {
	return arr_m[index - Begin];
}


int X, Y;
int main() {
	cin >> X >> Y;
	int ret;
	if ((LL)X * Y >= 0) {
		if (Y >= X) {
			ret = Y - X;
		} else {
			if (Y == 0) {
				ret = X + 1;
			} else if (X == 0) {
				ret = 1 - Y;
			} else {
				ret = X - Y + 2;
			}
		}
	} else {
		ret = abs(X + Y) + 1;
	}

	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct peo
{
    int o;
    int x;
}p[100050];
bool cmp(peo a,peo b)
{
    return a.x<b.x;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        p[i].o=i+1;
        scanf("%d",&p[i].x);
    }
    sort(p,p+n,cmp);
    printf("%d",p[0].o);
    for(int i=1;i<n;i++)
        printf(" %d",p[i].o);
    printf("\n");
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define sz(s) (ll)s.size()
#define print(d) cout << fixed << setprecision(15) << d
#define pii pair<ll,ll>
#define ppii pair<ll,pii>
#define ff first
#define ss second
const ll MOD = 1000000007;
const ll MAXN = 1e6 + 5;
const ll inf = 2e18;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
tree_order_statistics_node_update> ord_set;
#define debug(x) cerr << #x << " = " << x << endl


ll power(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x%m * p%m) % m; 
} 


int main()
{
   fast
   ll h,w;
   cin >> h >> w;
   if(h==1||w==1)
   {
    cout << 1 << "\n";
   }
   else
   cout << (h*w+1)/2 << "\n";

   
   return 0;
}










Measured memory_bytes: 256
mycode = r'''
# distutils: language=c++
# cython: language_level=3
# cython: boundscheck=False
# cython: wraparound=False
# cython: infer_types=True
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。

# cythonライブラリよみこみ

from libc.stdlib cimport abs as iabs

# define 
ctypedef long long LL
ctypedef LL[:] Arr

import numpy as np
from functools import partial
zeros=partial(np.zeros, dtype=np.int64)


# 読み込みはpython側で行う
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.readline #文字列読み込む時はこっち

def exit(*argv,**kwarg):
    print(*argv,**kwarg)
    sys.exit()


cdef LL a_int(): return int(readline())

cdef read_matrix(LL H,LL W):
    #return np.ndarray shape=(H,W) matrix
    lines=[]
    cdef LL _
    for _ in range(H): 
        lines.append(read())
    lines=' '.join(lines) #byte同士の結合ができないのでreadlineでなくreadで
    return np.fromstring(lines, sep=' ',dtype=np.int64).reshape(H,W)

cdef LL i,j,k,_


# tの偶奇は市松模様の分布になる
# つまり0,0からのマンハッタン距離が偶数のとき偶数時刻を許容でき、距離が奇数のとき奇数時刻を許容できる
# またt[n]-t[n-1]がマンハッタン距離を上回る場合は到達不可能なことに気をつけよう

N=a_int()
data=zeros((N+1,3))
data[1:] = read_matrix(N,3)

cdef Arr T =data[:,0]
cdef Arr X =data[:,1]
cdef Arr Y =data[:,2]

cdef LL manhattan(LL x, LL y):
    return iabs(x)+iabs(y)

cdef LL dt, dd,
for i in range(N):
    dt=T[i+1]-T[i]
    dd=manhattan(X[i+1]-X[i], Y[i+1]-Y[i])
    if (manhattan(X[i+1],Y[i+1])&1 != T[i+1]&1) or (dd>dt):
        exit('No')
print('Yes')



'''

import sys
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    import os
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode


Measured memory_bytes: 35968
import sys

def main():
    n = int(input())
    s = [x.rstrip() for x in sys.stdin.readlines()]
    alphabet = "abcdefghijklmnopqrstuvwxyz"

    for c in alphabet:
        minc = 10**10
        for x in s:
            cnt = x.count(c)
            minc = min(cnt, minc)
        print(c*minc, end="")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
# @author 

import sys

class BGoodDistance:
    def dist(self, u, v):
        return (sum((u[i] - v[i]) ** 2 for i in range(len(u)))) ** .5
    def solve(self):
        n, d = [int(_) for _ in input().split()]
        p = []
        for _ in range(n):
            p.append([int(_) for _ in input().split()])
        
        ans = 0
        for i in range(n):
            for j in range(i + 1, n):
                d = self.dist(p[i], p[j])
                if abs(d - int(d)) < 1e-9:
                    ans += 1
        
        print(ans)

solver = BGoodDistance()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 38512
import math

n, m = map(int, input().split())
s = []
for i in range(m):
    li = input().split()
    s.append(list(map(int, li[1::])))
p = list(map(int, input().split()))

cnt = 0
for i in range(int(math.pow(2,n))):
    isall_lighted = True
    bin = i
    onoff = [0]*n
    for i in range(n):
        digit = int(math.pow(2, i+1))
        if bin % digit != 0:
            onoff[i] = 1
            bin = bin - digit//2

    for i, light in enumerate(s):
        sw_cnt = 0
        for sw in light:
            sw_cnt += onoff[sw-1]
        if sw_cnt % 2 != p[i]:
            isall_lighted = False
    if isall_lighted:
        cnt += 1

print(cnt)


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        sc.nextInt();
        long K = sc.nextLong();

        int ret = 0;

        if (K % 2 == 0) {
            ret = A - B;
        } else {
            ret = B - A;
        }

        System.out.println(ret);
    }
}

Measured memory_bytes: 21332
import sys
input = sys.stdin.readline
N = int(input())
S = input().rstrip()
Q = int(input())
qs = [input().split() for i in range(Q)]

def ctoi(c):
    return ord(c) - ord('a')

class BinaryIndexedTree:
    def __init__(self,size):
        self.N = size
        self.bit = [0]*(size+1)
    def add(self,x,w):
        while x <= self.N:
            self.bit[x] += w
            x += (x & -x)
    def sum(self,x):
        ret = 0
        while x > 0:
            ret += self.bit[x]
            x -= (x & -x)
        return ret
bits = [BinaryIndexedTree(N) for _ in range(26)]

for i,c in enumerate(S):
    bits[ctoi(c)].add(i+1,1)

s = list(S)
ans = []
for a,b,c in qs:
    if a=='1':
        x = int(b)
        bits[ctoi(c)].add(x,1)
        bits[ctoi(s[x-1])].add(x,-1)
        s[x-1] = c
    else:
        tmp = 0
        for i in range(26):
            if bits[i].sum(int(c)) - bits[i].sum(int(b)-1) > 0:
                tmp += 1
        ans.append(tmp)
print(*ans, sep='\n')

Measured memory_bytes: 172020
import java.util.*;
public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
  	int cnt = 0;
 	String S = sc.next();
  	String T = sc.next();
  	char[] s_arr = S.toCharArray();
	char[] t_arr = T.toCharArray();
  
  	for (int i=0;i<3;i++){
      	if (s_arr[i] == t_arr[i]){
          	cnt++;
        }
    }
  	System.out.println(cnt);                           
}
}

Measured memory_bytes: 22612
import java.util.Scanner;

public class Main {
		static int CARD_MAX=1000;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.next();
		int n = scan.nextInt();

		for(int i=0;i<n;i++){
			String order = scan.next();
			if(order.equals("replace")){
				str = replaceString(str,scan.nextInt(),scan.nextInt(),scan.next());
			}else if(order.equals("reverse")){
				str = reverseString(str,scan.nextInt(),scan.nextInt());
			}else if(order.equals("print")){
				printString(str,scan.nextInt(),scan.nextInt());
			}

		}
	}



public static void printString(String str,int a,int b){
	for(int i=a;i<=b;i++){
		System.out.print(str.charAt(i));
	}
	System.out.println();
}


public static String replaceString(String str,int a,int b,String p){
	String target="";
	String before="";
	String after="";
	
	for(int i=0;i<a;i++){
		before = before + str.charAt(i);
	}
	
	for(int i=a;i<=b;i++){
		target = target + str.charAt(i);
	}
	
	for(int i=b+1;i<str.length();i++){
		after = after + str.charAt(i);
	}

	str = before+ p + after;
	return str;
}

public static String reverseString(String str,int a,int b){
	String target="";
	String before="";
	String after="";
for(int i=0;i<a;i++){
		before = before + str.charAt(i);
	}
	
	for(int i=a;i<=b;i++){
		target = str.charAt(i) + target;
	}
	
	for(int i=b+1;i<str.length();i++){
		after = after + str.charAt(i);
	}

	str = before+ target + after;
	return str;
}


}

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

using namespace std;

int main() {
	int n; cin >> n;
	vector<long long> a(n + 1, 0);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	long long res = 0;
	long long curr = 0;

	for (int i = 1; i <= n; i++) {
		long long ds = a[i];
		long long prs = (ds + curr) / 2;
		res += prs;
		if (ds == 0) {
			curr =  0;
		} else {
			curr = (ds + curr) % 2;
		}
		// cout << prs << " pairs\n";
	}
	cout << res << "\n";
}

Measured memory_bytes: 4072