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

int main(void)
{
    long long w, h;
    long long x, y;
    cin >> w >> h >> x >> y;
    double a = w * h / 2.;
    cout << a << ' ';
    if (2*x == w && 2*y == h) cout << '1' << endl;
    else cout << '0' << endl;

    return 0;
}



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


bool is_bingo(bool* B)
{
/*
0 1 2
3 4 5
6 7 8
*/
	if (B[0] && B[1] && B[2]) return true;
	if (B[3] && B[4] && B[5]) return true;
	if (B[6] && B[7] && B[8]) return true;
	if (B[0] && B[3] && B[6]) return true;
	if (B[1] && B[4] && B[7]) return true;
	if (B[2] && B[5] && B[8]) return true;
	if (B[0] && B[4] && B[8]) return true;
	if (B[2] && B[4] && B[6]) return true;
	
	return false;
}

int main()
{
	int A[9];
	for (int i = 0; i < 9; i++)
	{
		std::cin >> A[i];
	}

	int N;
	std::cin >> N;

	std::vector<int> b(N);
	for (int i = 0; i < N; i++)
	{
		std::cin >> b[i];
	}

	bool B[9];
	for (int i = 0; i < 9; i++)
	{
		B[i] = false;
	}

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < 9; j++)
		{
			if (b[i] == A[j])
			{
				B[j] = true;
			}
		}
	}

	const char* ans = is_bingo(B) ? "Yes" : "No";
	std::cout << ans;
}



Measured memory_bytes: 256
//09, 02, 2019, 10:42:14 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int N = int(2e5 + 10);
ll a[N];
ll pref[N], suf[N];
ll dp_left[N][2], dp_right[N][2];

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

    int l;

    cin >> l;

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

        pref[i] = a[i] + pref[i - 1];
    }

    for(int i = l ; i >= 1 ; i--){
        suf[i] = suf[i + 1] + a[i];
    }

    //compute dp_left
    for(int i = 1 ; i <= l ; i++){
        ll cost_go_and_back = 0LL, cost_just_go = 0LL;

        if(a[i] == 0LL){
            cost_go_and_back = 2LL;
            cost_just_go = 1LL;
        }else if(a[i] & 1LL){
            cost_go_and_back = 1LL;
        }else{
            cost_just_go = 1LL;
        }

        dp_left[i][0] = min({dp_left[i - 1][0] + cost_just_go, dp_left[i - 1][1] + cost_just_go,pref[i]});
        dp_left[i][1] = min(dp_left[i - 1][1] + cost_go_and_back, pref[i]);
    }
    
    //compute dp_right
    for(int i = l ; i >= 1 ; i--){
        ll cost_go_and_back = 0LL, cost_just_go = 0LL;

        if(a[i] == 0LL){
            cost_just_go = 1LL;
            cost_go_and_back = 2LL;
        }else if(a[i] & 1LL){
            cost_go_and_back = 1LL;
        }else{
            cost_just_go = 1LL;
        }

        dp_right[i][0] = min({dp_right[i + 1][0] + cost_just_go, dp_right[i + 1][1] + cost_just_go,suf[i]});
        dp_right[i][1] = min(dp_right[i + 1][1] + cost_go_and_back, suf[i]);
    }

    ll best = ll(1e18);

    for(int i = 0 ; i <= l ; i++){
        best = min(best, dp_left[i][0] + dp_right[i + 1][1]);
        best = min(best, dp_left[i][1] + dp_right[i + 1][0]);
        best = min(best, dp_left[i][1] + dp_right[i + 1][1]);
    }

    cout << best << endl;

    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define se second
#define fi first
const int N=102;
int g[N][N],v[N * N];

int main(){

//	freopen("in.txt","r",stdin);

	int r,c,n;
	cin >> r >> c >> n;
	for(int i=0;i < n;i++)
		scanf("%d",&v[i]);

	int st=0;
	for(int i=0;i < r;i++){
		if(i & 1) for(int j=c - 1;j >= 0;j--){
			g[i][j]=st + 1;
			if(!--v[st]) st++;
		}
		else for(int j=0;j < c;j++){
			g[i][j]=st + 1;
			if(!--v[st]) st++;
		}
	}
	for(int i=0;i < r;i++){
		for(int j=0;j < c;j++){
			printf("%d ",g[i][j]);
		}
		puts("");
	}

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
int main(void){
  int n, m, max = 0, tate[2000] = {0};
  char map[2000][2010] = {0};
  scanf("%d %d", &n, &m);getchar();
  for(int i = 0; i < n; i++){
    fgets(map[i], 2010, stdin);
  }
  int flag = 1, sell = 0;
  for(int i = 0; i < n; i++){
    flag = 1;
    for(int j = 0; j < m; j++){
      if(map[i][j] == '#'){flag = 1; tate[j] = 0; continue;}
      int light = 0;
      if(flag){
        for(int k = j - 1; k >= 0; k--){
          if(map[i][k] == '.'){
            light++;
          }else{
            break;
          }
        }
        for(int k = j + 1; k < m; k++){
          if(map[i][k] == '.'){
            light++;
          }else{
            break;
          }
        }
        sell = light;
        light = 0;
        flag = 0;
      }
      if(tate[j] == 0){
        for(int k = i - 1; k >= 0; k--){
          if(map[k][j] == '.'){
            light++;
          }else{
            break;
          }
        }
        for(int k = i + 1; k < n; k++){
          if(map[k][j] == '.'){
            light++;
          }else{
            break;
          }
        }
        tate[j] = light;
      }
      if(tate[j] + sell + 1 > max){
        max = tate[j] + sell + 1;
      }
    }
  }
  printf("%d\n", max);
  return 0;
}


Measured memory_bytes: 4096
from math import ceil

N, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
F = sorted(list(map(int, input().split())))

def is_valid(A, F, K, T):
    for a, f in zip(A, F):
        if a*f > T:

            k = ceil(a - T/f)
            if k <= K:
                K -= k
            else:
                return False
    return True

def solve(N, K, A, F):
    i = 0
    left, right = 0, 10**12

    while left < right:
        mid = (left + right) // 2

        if is_valid(A, F, K, mid):
            right = mid
        else:
            left = mid + 1
    
    if is_valid(A, F, K, mid-1) and (not is_valid(A, F, K, mid)):
        return mid-1
    elif is_valid(A, F, K, mid):
        return mid
    else:
        return mid+1

print(solve(N, K, A, F))



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

#define all(a) a.begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999


int main(){
	int n,w,d;
	while(cin >> n >> w >> d, n+w+d){
		vector<pair<int, int>> v;
		v.push_back(make_pair(w, d));
		rep(i, n){
			int p, s;
			cin >> p >> s;
			p--;
			pair<int, int> rec = v[p];
			
			pair<int, int> a = rec, b = rec;
			
			int count = 0;
			while(true){
				int diff;
				if(count%2 == 0) diff = rec.first;
				else diff = rec.second;
				
				if(s-diff > 0) s -= diff;
				else break;
				count++;
			}
			
			if(count%2 == 1){ a.second = s; b.second = rec.second-s;}
			else {a.first = s; b.first = rec.first-s;}
			
			v.erase(v.begin()+p);
			if(a.first*a.second > b.second*b.first) swap(a, b);
			v.push_back(a); v.push_back(b);
		}
		
		vector<int> ans;
		for(int i=0; i< v.size(); i++) ans.push_back(v[i].first*v[i].second);
		sort(ans.begin(),ans.end());
		
		rep(i, ans.size()){
			cout << (i == 0 ? "" : " ") << ans[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3124
N , M = map(int,input().split())
L = []
transit = set()
for _ in range(M):
    t = tuple(map(int,input().split()))
    L.append(t)
for x in L :
    if x[1] == N:
        transit.add(x[0])
for x in L:
    if x[0] == 1:
        if x[1] in transit:
            print("POSSIBLE")
            quit()
print("IMPOSSIBLE")


Measured memory_bytes: 32988
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)10e9+7;
const int INF = 0x3f3f3f3f;

int a[100001];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string str;
    cin >> str;
    int n = str.length();
    if(n&1)
    {
        if(str[0]==str[n-1])
        {
            cout << "Second";
        }
        else cout << "First";
        return 0;
    }
    else
    {
        if(str[0]==str[n-1])
        {
            cout << "First";
        }
        else cout << "Second";
        return 0;
    }
}

//TODO: 48


Measured memory_bytes: 512
A,B = [int(x) for x in input().split(' ')]

def calc_xor0(num):
    if num % 2 ==  0:
        if num % 4 == 2:
            ans =  num + 1
        else:
            ans =  num
    else:
        if num % 4 == 1:
            ans =  1
        else:
            ans =  0 #3:0 5:1 
    return ans

def main():
    print(calc_xor0(A-1) ^ calc_xor0(B))    

if __name__ == "__main__":
    main()




Measured memory_bytes: 2940
import sys

N = int(input())
worktime, deadline = [], []

for _ in range(N):
    a, b = map(int, input().split())
    worktime.append(a)
    deadline.append(b)

union = sorted(zip(worktime, deadline), key=lambda x: x[1])
worktime, deadline = zip(*union)

current = 0
for i in range(N):
    if current + worktime[i] > deadline[i]:
        print("No")
        sys.exit()
    else:
        current += worktime[i]
        pass
print("Yes")
    
    

Measured memory_bytes: 49100
#include <stdio.h>

int main(void)
{
	int num[100] = {0};
	int n;
	int i;
	int max = 0;
	
	
	while (scanf("%d", &n) != EOF){
		num[n - 1]++;
	}
	
	for (i = 0; i < 100; i++){
		if (max < num[i]){
			max = num[i];
		}
	}
	
	for (i = 0; i < 100; i++){
		if (max == num[i]){
			printf("%d\n", i + 1);
		}
	}
	
	return (0);
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int n;
    cin >> n;

    vector<ll> count(100001);

    ll ans = 0;

    rep(i, n){
        int tmp;
        cin >> tmp;
        count[tmp]++;

        ans += tmp;
    }

    int q;
    cin >> q;

    rep(i, q){
        int b,c;
        cin >> b >> c;

        int tmpcount = count[b];
        count[c] += tmpcount;
        count[b] = 0;

        ans += (c - b) * tmpcount;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4044
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		String line;
		int count = 0;
		while ((line = reader.readLine()) != null) {
			Pattern pattern = Pattern.compile("([0-9]+)");
			Matcher matcher = pattern.matcher(line);
			while (matcher.find()) {
				count += Integer.parseInt(matcher.group());
			}
		}
		System.out.println(count);
	}

}

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

int desc(const void *a, const void *b) {
	long long int *A = (long long int *)a;
	long long int *B = (long long int *)b;
	if (*A > *B) return -1;
	if (*A < *B) return 1;
	return 0;

}


int main() {
	int X, Y, Z, K, i, j, k, l;
	long long int A[1000], B[1000], C[1000], AB[1000000], ABC[3000000];

	scanf("%d %d %d %d", &X, &Y, &Z, &K);
	for (i = 0; i < X; i++) {
		scanf("%lld", &A[i]);
	}
	for (i = 0; i < Y; i++) {
		scanf("%lld", &B[i]);
	}
	for (i = 0; i < Z; i++) {
		scanf("%lld", &C[i]);
	}

	k = 0;
	for (i = 0; i < X; i++) {
		for (j = 0; j < Y; j++) {
			AB[k] = A[i] + B[j];
			k++;
		}
	}

	qsort(AB, k, sizeof(long long int), desc);

	l = 0;
	for (i = 0; i < Z; i++) {
		for (j = 0; j < k && j < K; j++) {
			ABC[l] = C[i] + AB[j];
			l++;
		}
	}

	qsort(ABC, l, sizeof(long long int), desc);

	for (i = 0; i < K; i++) {
		printf("%lld\n", ABC[i]);
	}

	return 0;
}

Measured memory_bytes: 54920
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int F(long long A, long long B) {
	int a = 0, b = 0;
	while (A != 0) {
		++a;
		A /= 10;
	}
	while (B != 0) {
		++b;
		B /= 10;
	}
	
	return max(a, b);
}

int main() {
	long long n;
	cin >> n;

	long long A = 1, B = 1;

	int minF = 100000000;
	for (long long i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			A = i;
			B = n / i;

			minF = min(minF, F(A, B));
			//cout << A * B << " " << minF << endl;
		}
	}

	cout << minF << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<bits/stdc++.h>
using std::string;
int main()
{
    int N;
    std::cin >> N;
    int arr[2 * N];
    for(int i = 0; i < 2 * N; i++)
    {
        std::cin >> arr[i];
    } 
    int n = sizeof(arr)/sizeof(arr[0]);
    std::sort(arr, arr + n);
    int ans = 0;
    for(int i = 0; i < 2 * N; i++)
    {
        if(i % 2 == 0)
        {
            ans += arr[i];
        }
    }
    std::cout << ans << '\n';
}

Measured memory_bytes: 3616
import sys
input = sys.stdin.readline
 
def main():
    K,S = [int(x) for x in input().split()]
 
    count = 0
 
    for x in range(K+1):
        for y in range(K+1):
            z = S - (x + y)
            if z >= 0 and z <= K:
                count += 1
 
    print(count)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main() {
	int W, H, x, y, r = 0;
	cin >> W >> H >> x >> y >> r;
	if (x-r<0||x+r>W)
	{
		cout << "No\n";
	}
	else if (y-r<0||y+r>H)
	{
		cout << "No\n";
	}
	else
	{
		cout << "Yes\n";
	}
	return 0;
}


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

int main()
{
	int a,b;
	cin >>a >>b;
if(a>9||b>9)
{
	cout<<-1<<endl;
	return 0;
}

cout<<a*b<<endl;
	return 0;
}	

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
#include <queue>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int a, b ,c;
    cin >> a >> b >> c;
    if (a+b < c) {
        cout << a+b+b+1 << std::endl;
        return 0;
    }
    else {
        cout << b+c << std::endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n, k = MAP()
ans = 1
for i in range(n):
    if i == 0:
        ans *= k
    else:
        ans *= k - 1
print(ans)

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

void solve_sub(ll N){
    cout << (N / 2) * 4 << endl;

    const ll M = N - N % 2;
    vector<vector<ll>> vs;
    REP(i, M / 2){
        vs.push_back({i + 1, M - i});
    }
    if(N % 2){
        vs.push_back({N});
    }

    REP(i, vs.size()){
        for(ll x : vs.at(i)){
            for(ll y : vs.at((i + 1) % vs.size())){
                cout << x << ' ' << y << endl;
            }
        }
    }
}

void solve(long long N){
    if(N == 3){
        cout << 2 << endl;
        cout << 1 << ' ' << 3 << endl;
        cout << 2 << ' ' << 3 << endl;
    }else if(N == 4){
        cout << 4 << endl;
        cout << 1 << ' ' << 2 << endl;
        cout << 1 << ' ' << 3 << endl;
        cout << 4 << ' ' << 2 << endl;
        cout << 4 << ' ' << 3 << endl;
    }else{
        solve_sub(N);
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pii pair<int,int>

int n,a[105],pd=1;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]%2==0&&(a[i]%3&&a[i]%5))pd=0;
	}
	if(pd)puts("APPROVED");
	else puts("DENIED");
    return 0;
}

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

int main() {
	long int s, c, a;
	cin >> s >> c;
	if (s >= c / 2){
		cout << c / 2 << endl;
	}else{
		a = (c / 2) - s;
		a = a / 2;
		cout << s + a << endl;
	}
	return 0;
	
}

Measured memory_bytes: 256
import math

a, b = map(int, input().split())
cnt = 1
i = 2
c, d = a, b

while d > 0:
    c, d = d, c % d

k = int(math.sqrt(c))

while c > 1:
    if c % i == 0:
        cnt += 1
        
        while c % i == 0:
            c //= i

    i += 1

    if k < i:
        cnt += 1
        break

print(cnt)

Measured memory_bytes: 3064
def main():
    N = int(input())
    L = [tuple(map(int, input().split())) for _ in range(N)]
    xx, yy, hh = next(l for l in L if l[2] >= 1)
    for Cx in range(101):
        for Cy in range(101):
            H = hh + abs(xx - Cx) + abs(yy - Cy)
            for x, y, h in L:
                if h != max(H - abs(x - Cx) - abs(y - Cy), 0):
                    break
            else:
                print(Cx, Cy, H)
                quit()

main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007 
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int n;
ll M[50][50],a[50][50],c[50][50];
void multiply(ll a[50][50],ll b[50][50]){ 
    ll mul[50][50]; 
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){ 
            mul[i][j] = 0ll; 
            for (int k = 0; k < n; k++) 
                mul[i][j] += (a[i][k]*b[k][j])%MOD; 
        } 
    } 
    for(int i=0; i<n; i++) 
        for(int j=0; j<n; j++) 
            a[i][j]=mul[i][j]%MOD;  // Updating our matrix 
} 
void power1(ll F[50][50],ll m){  
    if (m==1) 
        return; 
    power1(F, m/2); 
    multiply(F, F); 
    if (m%2 != 0) 
        multiply(F, M);  
} 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        ll k;
        cin>>n>>k;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                cin>>a[i][j];
                M[i][j]=a[i][j];
                c[i][j]=1ll;
            }
        }
        power1(a,k);
        multiply(a,c);
        ll ans=0;
        for(int i=0;i<n;i++){
            ans+=a[i][i];
        }
        ans%=MOD;
        cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 384
<?php

list($x) = explode(' ', trim(fgets(STDIN)));

$five_handred_yen = (int)floor($x / 500);
$five_yen = (int)floor(($x - (500 * $five_handred_yen)) / 5);

echo $five_handred_yen * 1000 + $five_yen * 5;


Measured memory_bytes: 4856
from collections import Counter

n = int(input())
A = [int(i) for i in input().split()]
C = Counter(A)
a, b, c = [C[i] for i in range(3, 0, -1)]

DP = [[[-1] * (a + b + c + 1) for i in range(a + b + 1)] for j in range(a + 1)]
DP[0][0][0] = 0

for i in range(a + 1):
    for j in range(a + b - i + 1):
        for k in range(a + b + c - i - j + 1):
            if i == j == k == 0:
                continue
            DP[i][j][k] = 1
            if i > 0: DP[i][j][k] += i / n * DP[i - 1][j + 1][k]
            if j > 0: DP[i][j][k] += j / n * DP[i][j - 1][k + 1]
            if k > 0: DP[i][j][k] += k / n * DP[i][j][k - 1]
            DP[i][j][k] *= n / (i + j + k)

print(DP[a][b][c])

Measured memory_bytes: 502308
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <queue>
#include <iostream>
#include <sstream>
 
using namespace std;
 
 
string sanitize(string s) {
    for(int i = 0 ; i < s.size() ; i++){
        char &c = s[i];
        if (c >= '0' && c <= '9') continue;
        c = ' ';
    }
    return s;
}
 
struct Edge {
    int cap;
    int flow;
    Edge(){
        cap = 0;
        flow = 0;
    }
 
    int residue() {
        return cap - flow;
    }
};
 
typedef map<int, Edge> Edges;
 
vector<Edges> g;
 
 
int S(){ return g.size()-1; }
int T(){ return g.size()-2; }
 
void process_np(string s) {
    stringstream ss(sanitize(s));
    int a, b;
    ss >> a >> b;
    g[S()][a].cap += b;
}
 
void process_nc(string s) {
    stringstream ss(sanitize(s));
    int a, b;
    ss >> a >> b;
    g[a][T()].cap += b;
}
 
void process_edge(string s) {
    stringstream ss(sanitize(s));
    int a, b, c;
    ss >> a >> b >> c;
    g[a][b].cap += c;
}
 
vector<int> dist;
vector<bool> visit;
 
#define INF 1e9
 
 
int dfs(int s, const int &t, int flow) {
    if (flow <= 0 || visit[s]) return 0;
    if (s == t) return flow;
    visit[s] = true;
    int ans = 0;
    for(Edges::iterator e = g[s].begin(); e != g[s].end(); ++e ){
        if (dist[e->first] != dist[s] + 1) continue;
 
        const int used = dfs(e->first, t, min(flow, e->second.residue()));
        if (used > 0) {
            g[s][e->first].flow += used;
            g[e->first][s].flow -= used;
            ans = used;    
	    visit[s] = false;
            break;
        }
    }
    return ans;
 
}
 
int max_flow(int s, int t) {
    int ans = 0;
    visit.resize(g.size());
    dist.resize(g.size());
    while (true) {
        bool update = false;
        fill(dist.begin(), dist.end(), INF);
        fill(visit.begin(), visit.end(), false);
        queue<int> Q;
        Q.push(s);
        dist[s] = 0;
        while (!Q.empty()) {
            int q = Q.front();
            Q.pop();
            for(map<int, Edge>::iterator e = g[q].begin(); e != g[q].end(); ++e ){
                if (e->second.residue() > 0 && dist[e->first] == INF) {
                    dist[e->first] = dist[q] + 1;
                    Q.push(e->first);
                }
            }
        }
        while (true) {
            int flow = dfs(s, t, INF);
            if (flow == 0) break;
            ans += flow;
            update = true;
        }
        if (!update) break;
    }
    return ans;
}
 
int main() {
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    g = vector<map<int, Edge> >(n);
 
    for (int i = 0; i < m; i++) {
        int a,b, c;
        cin >> a >> b >> c;
        g[a][b].cap += c;
    }
    cout << max_flow(0, n-1) << endl;
 
}


Measured memory_bytes: 3272
opr_list = ["+", "*"]


def solve():
    N = int(input())
    while(N != 0):
        if(N == 1):
            print(int(input()))
        else:
            ans = [0 for i in range(20)]
            s = []
            opr = [0 for i in range(20)]
            for i in range(N):
                s.append(list(input()))
            layer = 0
            for i in range(N):
                nowlayer = s[i].count(".")
                if(nowlayer < layer):
                    while(nowlayer < layer):
                        if(opr[layer-2] == "+"):
                            ans[layer-1] += ans[layer]
                        else:
                            ans[layer-1] *= ans[layer]
                        layer -= 1
                if(s[i][-1] in opr_list):
                    opr[nowlayer] = s[i][-1]
                    ans[nowlayer + 1] = 0 if opr[nowlayer] == "+" else 1
                    layer += 1
                else:
                    if(opr[nowlayer-1] == "+"):
                        ans[nowlayer] += int(s[i][-1])
                    else:
                        ans[nowlayer] *= int(s[i][-1])
                layer = nowlayer
            if(layer > 1):
                while(layer > 1):
                    if(opr[layer-2] == "+"):
                        ans[layer-1] += ans[layer]
                    else:
                        ans[layer-1] *= ans[layer]
                    layer -= 1
            print(ans[1])
        N = int(input())


solve()

Measured memory_bytes: 7800
#include<stdio.h>
int main()
{
    int n,x,i,a[550],d[550],e;
    while(~scanf("%d%d",&n,&x))
    {
        d[1]=0;
        e=1;
        for(i=1;i<=n;i++)
            scanf("%d",&a[i]);
        for(i=2;i<=n+1;i++)
        {
            d[i]=d[i-1]+a[i-1];
            if(d[i]<=x)
                e++;
        }
        printf("%d\n",e);
    }
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define int long long
#define all(c) (c).begin(), (c).end()
#define cpresent(c,x) ((c).find(x) != (c).end()) 
#define vpresent(c,x) (find(all(c),x) != (c).end())
#define endl '\n'
#ifdef LOCAL
#include "/home/iggaboi/Desktop/CP/debug.h"
#else
#define debug(x...)
#endif
using namespace std;

int sx, sy, tx, ty;

void solve(){
    cin >> sx >> sy >> tx >> ty;
    for(int i = 0; i < ty - sy; ++i) cout << 'U';
    for(int i = 0; i < tx - sx; ++i) cout << 'R';
    for(int i = 0; i < ty - sy; ++i) cout << 'D';
    for(int i = 0; i < tx - sx; ++i) cout << 'L';
    cout << 'L';
    for(int i = 0; i <= ty - sy; ++i) cout << 'U';
    for(int i = 0; i <= tx - sx; ++i) cout << 'R';
    cout << 'D';
    cout << 'R';
    for(int i = 0; i <= ty - sy; ++i) cout << 'D';
    for(int i = 0; i <= tx - sx; ++i) cout << 'L';
    cout << 'U';
}

int32_t main(){
	ios_base::sync_with_stdio(false),cin.tie(nullptr);
	// int t; cin >> t;
	// while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 3652
import sys
readline = sys.stdin.readline

K = int(readline())
S = readline().rstrip()
S = len(S)
N = K + S

DIV = 10 ** 9 + 7
n = (10 ** 6) * 5
g1 = [1] * 2 + [0] * (n - 2) # 元テーブル
g2 = [1] * 2 + [0] * (n - 2) #逆元テーブル
inverse = [0, 1] + [0] * (n - 2) #逆元テーブル計算用テーブル

for i in range(2, n):
  g1[i] = (g1[i - 1] * i ) % DIV
  inverse[i] = (-inverse[DIV % i] * (DIV // i)) % DIV
  g2[i] = (g2[i - 1] * inverse[i]) % DIV

def nCr(n, r, DIV):
  if ( r<0 or r>n ):
      return 0
  r = min(r, n-r)
  return g1[n] * g2[r] * g2[n-r] % DIV

# K = 3, S = 5のとき
# ..X.X.X.
# Xが取る3か所を選んだ上で、
# 最も右のXよりも右のマス：各26通り
# 最も右のXを含む、それより左のマス：Xのマスは1通り、それ以外は各25通り
# 最も右のXが
# ..X.....　の状態から、
# .......X  
# の状態について、場合の数を求める

ans = 0
for xpos in range(S, N + 1):
  # xpos箇所からK箇所を選ぶ場合の数
  # 一番右に1個固定した状態で、残りのxpos - 1か所からS - 1個を選ぶ
  pat = nCr(xpos - 1, S - 1, DIV)
  # その場合の数に対して、X以外の文字の選び方は25 ** (X - S)通りある
  pat *= pow(25, xpos - S, DIV)
  pat %= DIV
  
  # 残りのマスに対しては26通りずつ選べる
  pat *= pow(26, N - xpos, DIV)
  pat %= DIV
  
  ans += pat
  ans %= DIV

print(ans)


Measured memory_bytes: 238076
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.immutable._
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}

object Main {
  def solve(sc: => Scanner): Unit = {
    val N, M = sc.nextInt
    if (N != 0 || M != 0) {
      val A = Array.fill(N)().zipWithIndex.map(x => Set[Int](x._2))
      for (_ <- Range(0, M)) {
        val a, b = sc.nextInt - 1
        A(a) += b
        A(b) += a
      }
      println(A(0).map(x => A(x)).fold(Set[Int]())((x: Set[Int], y: Set[Int]) => x ++ y).size - 1)

      solve(sc)
    }
  }

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define cout(d) cout<<d<<endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

int main(){
  int n,k,q;cin>>n>>k>>q;
  vi a(q);
  rep(i,q) cin>>a[i];
  
  vi v(n,0);
  rep(i,q){
    v[a[i]-1]++;
  }
  rep(i,n){
    string ans="Yes";
    if(q-v[i]>=k) ans="No";
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

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

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int main() {
	int n;
	string S[51];
	int count[26];
	for (int i = 0; i < 26; ++i)count[i] = INF;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> S[i];
		int C[26];
		for (int j = 0; j < 26; ++j)C[j] = 0;
		for (int j = 0; j < S[i].size(); ++j) {
			C[int(S[i][j] - 'a')]++;
		}
		for (int j = 0; j < 26; ++j) {
			count[j] = min(count[j], C[j]);
		}
	}
	vector<char>V;
	for (int i = 0; i < 26; ++i) {
		while (count[i] != 0) {
			V.push_back(char('a' + i));
			count[i]--;
		}
	}
	for (int i = 0; i < V.size(); ++i) {
		cout << V[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void coins( int n,double a[]){
   double dp[n+1][n+1];
   for(int i=0;i<=n;i++){
       for(int j=0;j<=n;j++){
           dp[i][j]=0;
       }
   }
   dp[1][0]=1.0-a[1];
   //cout<<dp[1][0];
   for(int i=2;i<=n;i++){
       dp[i][0]=dp[i-1][0]*(1.0-a[i]);
   }
   dp[1][1]=a[1];
   for(int i=2;i<=n;i++){
       dp[i][i]=dp[i-1][i-1]*a[i];
   }
   for(int i=1;i<=n;i++){
       for(int j=1;j<i;j++){
           dp[i][j]=dp[i-1][j]*(1.0-a[i])+dp[i-1][j-1]*a[i];
       }
   }
   double ans=0;
   for(int i=n/2+1;i<=n;i++){
       ans+=dp[n][i];

   }
   //cout<<ans;
    cout << fixed << setprecision(10) << ans;
    //return 0;


}
int main() {
   int n;
   cin>>n;
  double a[n+1];
  // int k=1;
   for(int i=1;i<=n;i++){
       cin>>a[i];
     // k=k*a[i];
   }
  coins(n,a);
}


Measured memory_bytes: 74008
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

int main() {
	vector<bool> s(14), h(14), c(14), d(14);
	int n; cin >> n;
	while (n--) {
		string t; int i; cin >> t >> i;
		if (t == "S") s[i] = true;
		if (t == "H") h[i] = true;
		if (t == "C") c[i] = true;
		if (t == "D") d[i] = true;
	}
	for (int i = 1; i <= 13; i++)
		if (!s[i]) cout << "S " << i << endl;
	for (int i = 1; i <= 13; i++)
		if (!h[i]) cout << "H " << i << endl;
	for (int i = 1; i <= 13; i++)
		if (!c[i]) cout << "C " << i << endl;
	for (int i = 1; i <= 13; i++)
		if (!d[i]) cout << "D " << i << endl;
}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

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

  sort(a);
  a.erase(unique(a.begin(), a.end()), a.end());
  p(a.size());
}

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

using namespace std;

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

#define int ll

int n;
int num[100001];

main(){
	ll a,b,v,w,t;

	cin >> a >> v >> b >> w >> t;

	if(v>w){
		ll u = v-w;
		ll l = abs(b-a);
		if((double)l/u<=t) cout << "YES" << endl;
		else cout << "NO" << endl;
	}else{
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

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

  string s;
  cin >> s;

  int unhappy = 0;
  int bithappy = 0;
  for (int i = 0; i < n-1; i++)
  {
    if(s[i]=='R'&&s[i+1]=='L'){
      unhappy++;
    }
  }
  if(s[0] == s[n-1]){
    bithappy = 0;
  }else if(s[0] == 'R'){
    unhappy--;
    bithappy++;
  }else {
    bithappy++;
  }

  while(1){
    if(k == 0)break;
    if(unhappy==0&&bithappy==0)break;
    else if(unhappy==0)bithappy--;
    else if(unhappy > 0)unhappy--;
    k--;
  }
  cout << n - unhappy * 2 - bithappy - 1 << endl;

}

Measured memory_bytes: 512
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int ans = c - (a - b);
        if (ans <= 0) {
            System.out.println(0);
            return;
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


Measured memory_bytes: 21204
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n, d;
	cin >> n >> d;
	ll ans = (n - 1) / (2 * d + 1) + 1;
	dump(ans);
	return 0;
}


Measured memory_bytes: 256
from collections import deque
N, M = 4,4
inf = float("inf")
dp = []
dc=[0,0,0,0]
for _ in range(3):
    a, b = map(int, input().split())
    dc[a-1]+=1
    dc[b-1]+=1
    if a > b:
        a,b=b,a
    dp.append((a-1,b-1))
dp.sort()
for i in range(2):
    if dp[i] == dp[i+1] or max(dc)==3:
        print("NO")
        exit()
print("YES")


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  set<int>s,t;
  rep(i,m)
  {
    int a,b;
    cin>>a>>b;
    if(a==1)s.insert(b);
    if(b==n)t.insert(a);
  }
  set<int>l;
  set_intersection(all(s),all(t),inserter(l,l.begin()));
  if(l.size()>0)cout<<"POSSIBLE"<<endl;
  else  cout<<"IMPOSSIBLE"<<endl;

  return 0;

}


Measured memory_bytes: 9600
#0:pushBack
def pushBack(t,x):
  A[t].append(x)
  
#1:dump
def dump(t):
  if len(A[t]) > 0:
    print(A[t][0],end="")
    for i in A[t][1:]:
      print(" {}".format(i), end="")
  print()

#2:clear
def clear(t):
  A[t].clear()
  

cmdList = [ pushBack, dump, clear ]
n,q = map(int,input().split())
A = list()
for i in range(n):
  A.append([])

for i in range(q):
  cmd = input()
  if cmd.startswith("0"):
    c,t,x = map(int,cmd.split(" "))
    cmdList[0](t,x)
  if cmd.startswith("1"):
    c,t = map(int,cmd.split(" "))
    cmdList[1](t)
  if cmd.startswith("2"):
    c,t = map(int,cmd.split(" "))
    cmdList[2](t)



Measured memory_bytes: 29764
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  long a, b, c, k;
  readf("%s %s %s %s\n", &a, &b, &c, &k);
  
  if (k % 2) {
    writeln (b - a);
  } else {
    writeln(a - b);
  }
}


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

using namespace std;

int main() {

	int a, b, c, d;
	int cnt = 0;
	cin >> a >> b >> c >> d;

	for (int i = a; i < b; i++) {
		for (int j = c; j < d; j++) {
			if (i == j) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
 
int main(){
    int x;cin>>x;
    if(x==1){
        cout<<x-1<<endl;
    }
    else{
        cout<<x+1<<endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P  = pair <int, int>;

#define rep(i, n)     for (int i = 0; i < (int) (n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp)   for (auto &i : mp)

const int INF = 1001001001;

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

  ll ans = 0;
  if (x == 0) { ans = 1; }
  cout << ans << endl;


  return 0;
}


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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') cnt++;
    }
    string goal;
    for (int i = 0; i < cnt; i++) {
        goal += "R";
    }
    for (int i = 0; i < n - cnt; i++) {
        goal += "W";
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (not(s[i] == goal[i])) ans++;
    }
    cout << ans / 2 << endl;
    return 0;
}

Measured memory_bytes: 3848
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stdlib.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n],min = 1;
    bool flag = false;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(min == a[i]) {
            min++;
            flag = true;
        }
    }
    min--;
    if(flag == false) {
        cout << -1;
        return 0;
    }else {
        cout << n - min;
        return 0;
    }
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll n;
	cin>>n;
	ll arr[n]={10000000000000},b[n-1],i=0,j=0,ans=0;
	for(i=0;i<n-1;i++){
		cin>>b[i];
	}
	arr[0]=b[0];
	arr[n-1]=b[n-2];
	for(i=0;i<n-1;i++){
		arr[i+1]=b[i];
		arr[i]=min(arr[i],b[i]);
	}
	for(i=0;i<n;i++){
//		cout<<arr[i]<<" ";
		ans=ans+arr[i];
	}
	cout<<ans;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288

int main(){
    int n;
    cin>>n;
    ll ans=0;
    rep(i,n+1){
        if(i%3==0)continue;
        if(i%5==0)continue;
        ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};

#define lim 200005

struct info{
    ll x,y,d;
};

info arr[lim];

bool comp(info u,info v){
    return u.d < v.d;
}

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n,ans;
    sfl(n);
    FOR(i,n){
        sfl(arr[i].x),sfl(arr[i].y);
        arr[i].d = arr[i].x+arr[i].y;
    }
    sort(arr+1,arr+n+1,comp);
    ans = arr[n].d-arr[1].d;
    FOR(i,n){
        arr[i].d = arr[i].x-arr[i].y;
    }
    sort(arr+1,arr+n+1,comp);
    ans = max(ans,arr[n].d-arr[1].d);
    pfl(ans);
    return 0;
}

Measured memory_bytes: 8448