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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    char s[4] = {};

    Scs(s);

    if(strlen(s) == 2 ) printf ("%s\n", s);
    else {
        printf ("%c", s[2]);
        printf ("%c", s[1]);
        printf ("%c\n", s[0]);
    }

    return 0;
}



Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

long pow(long n, long k) {
    if(k == 0) {
        return 1;
    }
    long tmp = pow(n, k/2) % p;
    if(k%2 == 0) { 
        return (tmp * tmp) % p;
    } else {
        return (((tmp * tmp) % p) * n) % p;
    }
}

void main(){

    auto n = readLong();

    auto P = new long[](n+2);
    P[0] = 1;
    foreach(i; iota(1, n+2)) {
        P[i] = (P[i-1] * i) % p;
    }

    long c(long n, long k) {
        if(n < k) {
            return 0;
        }
        if(k == 0) {
            return 1;
        }
        if(n == k) {
            return 1;
        }
        return (((P[n] * pow(P[k], p-2)) % p) * pow(P[n-k], p-2)) % p;
    }

    auto a = readLongs();
    long[long] l;
    long s, t;
    foreach(i; iota(n+1)) {
        if(a[i] in l) {
            s = l[a[i]];
            t = i;
            break;
        }
        l[a[i]] = i;
    }
    foreach(i; iota(n+1)) {
        auto k = i+1;
        writeln((c(n+1, k) + p - c(n+1 - (t-s+1), k-1)) % p);
    }
}



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

int main()
{
    int n;
    cin >> n;
    int w[n];
    int a=0;
    int b=0;
    for(int i=0;i<n;i++){
        cin >> w[i];
        b = b + w[i];
    }
    int c = b-a;
    for(int j=0;j<n;j++){
        a = a + w[j];
        b = b - w[j];
        c = min(c,abs(b-a));
    }

    cout << c << endl;

    
    return 0;
}

Measured memory_bytes: 256
'''
hardest 2.
Aizu Online Judge 1165: Pablo Squarson's Headache
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1165

## ?§£??¬

??£?????¢?????????????????£?????§???????????¢?????\????????????????????¢???????°????????????¨???????????????????????????????????§???
??£?????¢???????????¢???????????????????????????????????¨???????????¶???????????????

?´°????????¬?????????????????????????????§?????????????????\???????????????????????§?§£?????????

1. ?°´????????????x???,?????´?????????y?????¨?????????
2. ???????????£?????¢??????????????§?¨????(0, 0)??¨????????????????????£?????¢?????§?¨?????±???????
3. ????????¢????????????  (?????£?????¢???x??§?¨?????????§???) - (?????£?????¢???x??§?¨????????°????) + 1
4. ????????¢???????????????(?????£?????¢???y??§?¨?????????§???) - (?????£?????¢???y??§?¨????????°????) + 1

?????±???????????????????????°?????????????????????(AOJ?????????????????????????????????????????????????????¨????????????????????????)

'''

adjacent_vectors = [
    (-1, 0), # left
    (0, -1), # down
    (1, 0),  # right
    (0, 1)   # up
]

while True:
    num_squares = int(input())

    if num_squares == 0:
        break

    x_coordinates = [0] # x??§?¨?????????????
    y_coordinates = [0] # y??§?¨?????????????

    for _ in range(num_squares-1):
        # adjacent_square: ??£??\????????£?????¢?????????
        adjacent_square, direction = map(int, input().split())

        x = x_coordinates[adjacent_square] # ??£??\????????£?????¢???x??§?¨?
        y = y_coordinates[adjacent_square] # ??£??\????????£?????¢???y??§?¨?

        (dx, dy) = adjacent_vectors[direction]

        x_coordinates.append(x + dx)
        y_coordinates.append(y + dy)

    max_x = max(x_coordinates)
    min_x = min(x_coordinates)
    max_y = max(y_coordinates)
    min_y = min(y_coordinates)

    print(max_x - min_x + 1, max_y - min_y + 1)

Measured memory_bytes: 7696
#include <stdio.h>

int main(){
	int m,day,date;
	int a[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	int i,j,k;
	int b;
	while(1){
		date=2;
		b=1;
		scanf("%d %d",&m,&day);
		if(m==0)break;
		for(i=1; i<=12; i++){
			for(j=1; j<=a[i]; j++){
				date=(date+1)%7;
				//printf(" month:%2d day:%2d date:%2d\n",i,j,date);
				if(j==day&&i==m){
					b=0;
					break;
				}
			}
			if(!b)break;
		}
		if(date==0)printf("Monday\n");
		else if(date==1)printf("Tuesday\n");
		else if(date==2)printf("Wednesday\n");
		else if(date==3)printf("Thursday\n");
		else if(date==4)printf("Friday\n");
		else if(date==5)printf("Saturday\n");
		else if(date==6)printf("Sunday\n");
	}

	return 0;
}

Measured memory_bytes: 584
use proconio::input;
use std::cmp::{max, min};

const MAX_L: usize = 100_000;
const BASE_SIZE: usize = (1 << 10) + (1 << 9);

fn main() {
    input! {
        n: usize,
        vw: [(u32, u32); n],
        q: usize,
        vl: [(usize, usize); q],
    }
    let dp = make_dp(&vw);
    for vlq in vl {
        println!("{}", calc(&vw, vlq.0 - 1, vlq.1, &dp));
    }
}

fn make_dp(vw: &Vec<(u32, u32)>) -> Vec<Vec<u32>> {
    let mut dp = Vec::<Vec<u32>>::new();

    dp.push(
        (0..=MAX_L)
        .map(|i| if i < (vw[0].1 as usize) { 0 } else { vw[0].0 })
        .collect()
    );

    let n = min(vw.len(), BASE_SIZE - 1);
    for c in 1..n {
        let p = (c - 1) / 2;
        dp.push(
            (0..=MAX_L)
            .map(|i| {
                let w = vw[c].1 as usize;
                let v = if i < w { 0 } else { dp[p][i - w] + vw[c].0 };
                max(dp[p][i], v)
            })
            .collect()
        );
    }

    dp
}

fn calc(
    vw: &Vec<(u32, u32)>,
    u: usize, 
    l: usize,
    dp: &Vec<Vec<u32>>
) -> u32 {
    if u < dp.len() {
        dp[u][l]
    } else {
        let p = (u - 1) / 2;
        let w = vw[u].1 as usize;
        let pv1 = calc(vw, p, l, dp);
        let pv2 = if l < w { 0 } else { calc(vw, p, l - w, dp) + vw[u].0 };
        max(pv1, pv2)
    }
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll n,ans=0,tmp=0;
    cin>>n;
    vector<ll> h(n+1);
    for (int i = 0; i < n; i++)
    {
        cin>>h[i];
    }
    h[n]=1e10;

    for (int i = 0; i <= n; i++)
    {
        if(h[i]>=h[i+1])
        {
            tmp++;
        }
        else
        {
            ans=max(ans,tmp);
            tmp=0;
        }
        
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a < b){
            System.out.println("a < b");
        }else if(a == b){
            System.out.println("a == b");
        }else{
            System.out.println("a > b");
        }
        sc.close();
    }
}



Measured memory_bytes: 26124
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int N=110;
int main()
{
    char s[N];
    while(~scanf("%s",s))
        printf("%c%d%c\n",s[0],strlen(s)-2,s[strlen(s)-1]);


    return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left
N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for i in range(N):  # １番短い棒
    for j in range(i + 1, N):  # 真ん中の長さの棒
        ans += bisect_left(L, L[i] + L[j]) - (j + 1)

print(ans)


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

int main() {
  int N, K;
  cin >> N >> K;

  int sum = 0;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;

    int a = x * 2;
    int b = (K - x) * 2;

    if (a < b) {
      sum += a;
    } else {
      sum += b;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
/*
[abc134] E - Sequence Decomposing
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;

int N;
int A[MAX_N];

ll solve() {
    multiset<int> s;

    for (int i = N - 1; i >= 0; i--) {
        auto iter = s.upper_bound(A[i]);
        if (iter != s.end()) {
            s.erase(iter);
        }
        s.insert(A[i]);
    }

    return s.size();
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define out(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    string s; cin >> s;
    bool ans = false;
    REP(i,2) {
        if (s[i] == s[i+1] && s[i] == s[i+2]) ans = true;
    }

    ATYN(ans)

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
using namespace std;

signed main(){
	fast;
	int n; cin>>n;
	
	int ans=0, tot=0;
	
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			for(int k=1; k<=n; k++){
				ans=__gcd(i, j);
				ans=__gcd(ans, k);
				//cout<<ans<<" ";
				tot+=ans;
			}
		}
	}
	
	cout<<tot;
    return 0; 
}

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

signed main(){

  int n; cin >> n;
  multimap<int,int> mp;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    mp.insert({a,1});
  }

  int ans = 0;
  for(; !mp.empty();){
    auto p = mp.end();
    p--;
    int t = 1;
    while(p->first >= t) t *= 2;
    mp.erase(p);
    if(mp.find(t-p->first) != mp.end()){
      mp.erase(mp.find(t-p->first));
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


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

const int MAXN = 100003;
int A[MAXN], B[MAXN];

int main() {
	int n;
	scanf("%d", &n);
	long long s = 0;
	for(int i = 1; i <= n; i++) {
		scanf("%d", A + i);
		s += A[i];
		B[i] = A[i] - A[i - 1];
	}
	B[1] = A[1] - A[n];
	bool fg = 1;
	long long t = (long long)(n + 1) * n / 2;
	if(s % t) fg = 0;
	s /= t;
	for(int i = 1; i <= n; i++) {
		B[i] -= s;
		if(B[i] % n || A[i] < s) {
			fg = 0;
			break;
		}
	}
	if(fg) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
  int a,b;
  scanf("%d %d",&a,&b);
  if(-1000<=a&&b<=1000)
  {
    if(a<b)
    {
      printf("a < b\n" );
    }
    if(a>b)
    {
      printf("a > b\n" );
    }
    if(a==b){
      printf("a == b\n" );
    }
  }
  else
  {
    printf("条件を満たす入力をしてください。\n");
  }
	return 0;
}



Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

/* gcd */
template<typename T>
T gcd(T a,T b)
{
	if(a==0 || b==0)return 0;
	T r;
	while(1)
	{
		r=a%b;
		if(r==0)break;
		a=b;
		b=r;
	}
	return b;
}

/* lcm */
template<typename T>
T lcm(T a,T b)
{
	if(a==0 || b==0)return 0;
	return a*(b/gcd(a,b));
}

int main()
{
	int N;
	lint ans;
	
	cin >> N;
	cin >> ans;
	for(int i=0;i<N-1;i++)
	{
		lint t;
		cin >> t;
		ans=lcm(ans,t);
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int input(int*[]);
int isMatch(int*[], int*[], int, int);

main(){
  int n, q;
  int *S[10000], *T[500];

  n = input(S);
  q = input(T);
 
  printf("%d\n", isMatch(S, T, n, q));
  return 0;
}

int input(int* array[]){
  int i, e;
  scanf("%d", &e);
  for(i = 0; i < e; i++){
    scanf("%d", &array[i]);
  } 
  return e;
}

int isMatch(int* S[], int* T[], int n, int q){
  int i, j, count = 0;
  for(i = 0; i < q; i++){
    for(j = 0; j < n; j++){
      if(T[i] == S[j]){
	count++;
	break;
      }
    }
  }

  return count;
}

Measured memory_bytes: 680
n = gets.chomp.to_i 

nums = gets.chomp.split(" ")

nums = nums.map(&:to_i)

sum = nil 

i = 0
(nums.max - nums.min + 1).times{
    
    x = nums.min + i 
    y = (nums.map {|item| (item - x)*(item - x) }).inject(0){|result, i| result + i }
    
    if sum == nil
        sum = y 
    elsif sum > y 
        sum = y 
    else 
    end 
    
    i += 1 
    }
    
p sum 

Measured memory_bytes: 1916
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] S = Console.ReadLine().Split(' ');
            long A, B, C, K;
            A = long.Parse(S[0]);
            B = long.Parse(S[1]);
            C = long.Parse(S[2]);
            K = long.Parse(S[3]);
            long max = 0;
            if (A > K) max = K;
            else if (A + B >= K && K >= A) max = A;
            else max = A - (K - B - A);
            Console.WriteLine(max);
        }
    }
}

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

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr int MAXN = 3005;
constexpr int MAXD = 200005;

int h, w, n;
vector<pair<int, int>> points;
array<ll, MAXD> facts;
array<ll, MAXD> invs;
array<ll, MAXN> dp;

ll modpow(ll base, ll exp) {
  ll res = 1;
  ll basePower = base;
  for (ll k = 1; k <= exp; k <<= 1) {
    if ((k & exp) > 0) {
      res = (res * basePower) % MOD;
    }
    basePower = (basePower * basePower) % MOD;
  }
  return res;
}

ll inv(ll x) {
  return modpow(x, MOD - 2);
}

ll nCr(int n, int k) {
  assert(n >= k && k >= 0);
  ll res = facts[n];
  res = (res * invs[k]) % MOD;
  res = (res * invs[n - k]) % MOD;
  return res;
}

// number of ways to get from (0, 0) to point p
ll solve(int p) {
  ll& res = dp[p];
  if (res != -1LL) { return res; }
  int px = points[p].first, py = points[p].second;
  res = nCr(px + py, px);
  for (int i = 0; i < p; i++) {
    int ix = points[i].first, iy = points[i].second;
    if (ix > px || iy > py) { continue; }
    ll ways = (nCr(px - ix + py - iy, px - ix) * solve(i)) % MOD;
    res = (res + MOD - ways) % MOD;
  }
  return res;
}

int main() {
  fill(dp.begin(), dp.end(), -1LL);
  facts[0] = 1;
  invs[0] = 1;
  for (int i = 1; i < MAXD; i++) {
    facts[i] = (i * facts[i - 1]) % MOD;
    invs[i] = inv(facts[i]);
  }
  cin >> h >> w >> n;
  for (int i = 0; i < n; i++) {
    int a, b; cin >> a >> b;
    points.emplace_back(a - 1, b - 1);
  }
  points.emplace_back(h - 1, w - 1);
  sort(points.begin(), points.end());
  cout << solve(n) << "\n";
  return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

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

int main() {
	int n;
	cin >> n;
	rep(_,n) {
		int m, n;
		cin >> m >> n;
		int k = m*m + n*n;
		int cnt = 0;
		for(int y=0; y*y<=k; y++) {
			for(int x=0; y*y+x*x<=k; x++) {
				if(x+y==0) continue;
				int p = m*x - n*y;
				int q = m*y + n*x;
				int xy = x*x + y*y;
				if(p%xy==0 && q%xy==0) {
					cnt++;
				}
			}
		}
		cout << (cnt*2<=8 ? "P" : "C") << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define test(t) int t; cin>>t; while(t--)
#define p1(x) { cout << " [" << #x << ": " << x << "]\n"; }
#define p2(x) { cout << " [" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]\n"; }
#define pb(x) { push_back(x); }
 
 
void solve()
{
	int n, k, ans=0;
	vector<int> p;
	cin>>n>>k;
	for(int i=0; i<n; i++) {
		int x;
		cin>>x;
		p.push_back(x);
	}
	sort(p.begin(), p.end());
	for(int i=0; i<k; i++) {
		ans+=p[i];
	}
	cout<<ans<<endl;
}
 
int main() {
	// your code goes here
	// test(t)
		solve();
	return 0;
}
 

Measured memory_bytes: 3636
import itertools
from collections import defaultdict

N, K = map(int, input().split())

A = list(map(int, input().split()))

A = [0] + [x-1 for x in A]

Acum = list(itertools.accumulate(A))
Acum = [x % K for x in Acum]

counter = defaultdict(int)
answer = 0
for i, x in enumerate(Acum):
    answer += counter[x]
    counter[x] += 1
    if i >= K - 1:
        counter[Acum[i - K + 1]] -= 1

print(answer)

Measured memory_bytes: 117656
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; ++i)

using namespace std;
using LL = long long;

int main(){
	int n; cin >> n;
	
	LL Ln = 2; LL Ln1 = 1;
	
	forn(i, n - 1){
		Ln1 += Ln; Ln = Ln1 - Ln;
	}
	cout << Ln1 << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
ls = len(s)
o0 = s[::2].count('0')
e0 = s[1::2].count('0')
if e0>=o0:
    print(ls//2-e0 + o0)
elif ls%2!=0:
    print(ls//2+1-o0 + e0)
else:
    print(ls//2-o0 + e0)
    

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
vector<int> to[maxn];
int n;
int sg (int u, int fa) {
    int sz = to[u].size();
    int ret = 0;
    for (int i = 0; i < sz; i++) if (to[u][i] != fa){
        ret ^= sg (to[u][i], u) + 1;
    }
    return ret;
}
int main () {
    scanf ("%d", &n);
    for (int i = 1; i < n; i++) {
        int a, b;
        scanf ("%d%d", &a, &b);
        to[a].push_back (b);
        to[b].push_back (a);
    }
    if (sg(1, 0) == 0) printf ("Bob\n");
    else printf ("Alice\n");
}


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

bool is_prime(int x){
	if(x <= 1) return false;
	for(int i = 2; i*i <= x; i++){
		if(x%i == 0) return false;
	}
	return true;
}

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

	int p = x;
	while(!is_prime(p)) p++;

	cout << p << endl;

	return 0;
}

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

int n,k,len,vis[10],tot;
char ch[10];

inline bool check(int n)
{
	sprintf(ch+1,"%d",n);
	len=strlen(ch+1);
	for(int i=1;i<=len;i++) if(vis[ch[i]-'0']) return 0;
	return 1;
}

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++)
	{
	  int x;
	  scanf("%d",&x);
	  vis[x]=1;
	}
	while(1)
	{
	  if(check(n)) break;
	  n++;
	}
	cout<<n<<"\n";
	return 0;
}

Measured memory_bytes: 256
A = [[0 for _ in range(4)] for _ in range(4)]


for _ in range(3):
    a, b = map(int, input().split())
    A[a-1][b-1] = 1
    A[b-1][a-1] = 1

B = [sum(A[i]) for i in range(4)]

for i in range(4):
    if B[i] == 3 or B[i] == 0:
        flag = False
        break
    else:
        flag = True

if flag:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const int mod = 1e9+9;
const int INF = 1e9;

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

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

    int ans = INF;
    int index;
    rep(i,n-k+1){
        index = array[i+k-1] - array[i];
        index += min(abs(array[i+k-1]), abs(array[i]));
        ans = min(ans, index);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3976
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353
N = 2*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n,m,k = map(int,input().split())

if k==n-1:
  print(pow(m,n,mod))
  exit()

ans = 0
a= m*pow(m-1,n-1-k-1,mod)

for i in range(k,-1,-1):
  a =a*(m-1)%mod
  
  ans += a*cmb(n-1,i,mod)
  ans %= mod
  
print(ans)

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  string s; cin >> s;
  for(auto&e:s)e = 'x';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3624
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAXN = 55;
vector<pair<int,int>> graph[MAXN];
int n,m;
int edges[MAXN];

int dfs(int u,int p,int target,int mask){
    if(u == target) return 1;

    int ret = 0;
    for(auto v:graph[u]){
        if(v.f == p) continue;
        int check = dfs(v.f,u,target,mask);
        if(check) edges[v.s] |= mask,ret = 1;
    }
    return ret;
}

int dp[MAXN][(1<<20)];

int rec(int idx,int mask){
    if(idx == n){
        if(mask == (1<<m)-1) return 1;
        else return 0;
    }

    int &ans = dp[idx][mask];
    if(ans != -1) return ans;

    ans = 0;
    ans = ans + rec(idx+1,mask);
    ans = ans + rec(idx+1,mask|edges[idx]);

    return ans;
}

void solve(){
    cin>>n;

    FOR(i,1,n-1){
        int u,v; cin>>u>>v;
        graph[u].push_back({v,i});
        graph[v].push_back({u,i});
    }

    cin>>m;

    FOR(i,0,m-1){
        int u,v; cin>>u>>v;
        dfs(u,0,v,(1<<i));
    }

    MINUS(dp);
    cout<<rec(1,0)<<endl;
}

signed main(){

   FastRead;    


    int t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

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

using namespace std;

#define int long long

const int N = 1e5 + 100, INF = 3e18;

int a[N], b[N], c[N], arr[N], l[N], r[N];
int x, y, z, n, sum, ans;
multiset<int> s;

int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> x >> y >> z;
    n = x + y + z;
    for (int i = 0; i < n; i++) {
	cin >> a[i] >> b[i] >> c[i];
	sum += c[i];
	a[i] -= c[i]; b[i] -= c[i];
	arr[i] = i;
    }
    sort(arr, arr + n, [&] (int i, int j) {return a[i] - b[i] < a[j] - b[j];});
    int tmp = 0;
    for (int o = 0; o < n; o++) {
	int i = arr[o];
	if (o < y) {
	    tmp += b[i];
	    s.insert(b[i]);
	}
	else {
	    tmp += max(0LL, b[i] - *s.begin());
	    s.insert(b[i]);
	    s.erase(s.begin());
	}
	l[o] = (o < y - 1 ? -INF : tmp);
    }
    s.clear();
    tmp = 0;
    for (int o = n - 1; o >= 0; o--) {
	int i = arr[o];
	if (o >= n - x) {
	    s.insert(a[i]);
	    tmp += a[i];
	}
	else {
	    tmp += max(0LL, a[i] - *s.begin());
	    s.insert(a[i]);
	    s.erase(s.begin());
	}
	r[o] = (o > n - x ? -INF : tmp);
    }
    ans = -INF;
    for (int i = 0; i < n - 1; i++)
	ans = max(ans, l[i] + r[i + 1]);
    return cout << ans + sum, 0;
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string kkk;
int main(){
	ll n;
	double a,tot=0;
	scanf("%lld",&n);
	for(int i=1;i<=n;++i){
		cin>>a>>kkk;
		if(kkk=="BTC")tot+=a*380000;
		else tot+=a;
	}
	cout<<tot<<endl;
	return 0;
}

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

int main(){
  long a,b,k;
  cin >> a >> b >> k;
  if(a >= k){
    cout << a-k << " " << b << endl;
  }
  else if(a+b >= k){
    cout << 0 << " " << a+b-k << endl;
  }
  else{
    cout << "0 0" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int a[] = new int[N];
		int total = 0;
		for (int i = 0; i < a.length; i++) {
			a[i] = scanner.nextInt();
			total += a[i];
		}
		;
		int ave = Math.round((float) total / (float) N);
		long ans = 0;
		for (int i = 0; i < a.length; i++) {
			ans += (a[i] - ave) * (a[i] - ave);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 9680
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int a, b, n;
    while(cin >> a >> b, a|b){
        cin >> n;
        vector<vector<int>> dp(b, vector<int>(a, 0));
        map<pair<int, int>, int> m;
        dp[0][0] = 1;
        for (int i = 0; i < n; ++i) {
            int x, y;
            cin >> x >> y;
            m[make_pair(x-1, y-1)]++;
        }
        for (int i = 0; i < b; ++i) {
            for (int j = 0; j < a; ++j) {
                if(m[make_pair(j, i)]) continue;
                if(i > 0) dp[i][j] += dp[i-1][j];
                if(j > 0) dp[i][j] += dp[i][j-1];
            }
        }
        cout << dp[b-1][a-1] << "\n";   
    }
    
    return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define INF 1e18
#define M 1000000009
#define pi 3.14159265358979323846264338327950
typedef pair<int,int> pr;
#define N 1000002
signed main()
{
    SPEED;
  	int n;
  	cin>>n;
    map<int,int>m;
  	while(n%2==0)
    {
      	m[2]++;
     	n/=2;
    }
  	for(int i=3;i<=sqrt(n);i+=2)
    {
      	if(n%i==0)
        {
          while(n%i==0)
          {
            m[i]++;
            n/=i;
          }
        }
    }
  	if(n>1)
      m[n]++;
  	int f=0,ans=0;
  	for(auto &x:m)
    {
      int p=x.second;
      for(int i=1;i<=p;++i)
      {
        ans++;
        p-=i;
      }
    }
  	cout<<ans;
}

Measured memory_bytes: 3664
#include <cstdio>
#include <cstring>
using namespace std;
int a[4],n;
char s[5];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%s",s);
		if(strcmp(s,"AC")==0)a[0]++;
		if(strcmp(s,"WA")==0)a[1]++;
		if(strcmp(s,"TLE")==0)a[2]++;
		if(strcmp(s,"RE")==0)a[3]++;
	}
	printf("AC x %d\n",a[0]);
	printf("WA x %d\n",a[1]);
	printf("TLE x %d\n",a[2]);
	printf("RE x %d\n",a[3]);
	return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b<c+d)
    cout<<"Right";
  else if(a+b>c+d)
    cout<<"Left";
  else
    cout<<"Balanced";
}

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

char buf[110];
const char * keyence = "keyence";

int main(void) {
  scanf("%s", buf);
  int n = strlen(buf);
  bool ok = false;
  REP(ed, n) {
    REP(bg, ed+1) {
      if(n - (ed-bg) != 7) {
        continue;
      }
      int i1 = 0;
      REP(i, n) {
        if(!(bg <= i && i < ed)) {
          if(buf[i] == keyence[i1]) {
            ++i1;
          } else {
            goto NEXT;
          }
        }
      }
      if(i1 == 7) {
        ok = true;
        goto OUT;
      }
    NEXT:
      ;
    }
  }
 OUT:
  puts(ok ? "YES" : "NO");

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    int res=1;
    int t=a;
    if(b==1){
        cout<<0<<endl;
        return 0;
    }
    while(1){
        if(a >= b)break;
        res++;
        a+=t-1;
    }
    cout<<res<<endl;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

void test(int n, int k)
{
  for (int a = 1; a <= n; ++a) {
    for (int b = 1; b <= n; ++b) {
      if ((a + b) % k) continue;
      for (int c = 1; c <= n; ++c) {
        if ((a + c) % k) continue;
        if ((b + c) % k) continue;
        cout << a << ' ' << b << ' ' << c << endl;
        assert((a + b) % k == 0);
        assert((a + c) % k == 0);
        assert((c + b) % k == 0);
        cout << "% " << a%k << ' ' << b % k << ' ' << c % k << endl;
      }
    }
  }
  return ;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  // test(31415, 9265);

  lli n, k;
  while (cin >> n >> k) {
    const int N = 2 * 1e5 + 10;
    static lli cnt[N];
    fill(cnt, cnt + N, 0);

    for (int i = 1; i <= n; ++i) {
      ++cnt[i % k];
    }

    lli sum = 0;
    sum += cnt[0] * cnt[0] * cnt[0];
    if (k % 2 == 0) {
      sum += cnt[k / 2] * cnt[k / 2] * cnt[k / 2];
    }
    cout << sum << endl;
  }
  
  return 0;
}


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



int main(){
    cout<<fixed<<setprecision(10);

    
    const double PI = acos(-1);
    
    int n; cin>>n;
    long int minval, maxval, sumval;
    minval = 1000001;
    maxval = -1000001;
    sumval = 0;
    
    while( n > 0){
        int a; cin>>a;
        sumval += a;
        if(a < minval) minval = a;
        if(a > maxval) maxval = a;
        --n;
    }
    
    cout<<minval<<" "<<maxval<<" "<<sumval<<endl;

    return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define nt _int128
#define mod 1000000007
ll n ,arr[200005],brr[200005];
ll dp[2000005];
void update(ll strt,ll end,ll i,ll id,ll val)
{
    if(strt==end and strt==i)
    {
        dp[id]=val;
        return ;
    }
    ll mid=(strt+end)/2;
    if(i<=mid)
        update(strt,mid,i,2*id,val);
    else
        update(mid+1,end,i,2*id+1,val);
    dp[id]=max(dp[2*id],dp[2*id+1]);
}
ll query(ll strt,ll end,ll i,ll j,ll id)
{
    if(j<strt||i>end)
        return 0;
    if(strt>=i and end<=j)
        return dp[id];
    ll mid=(strt+end)/2;
    return max(query(strt,mid,i,j,2*id),query(mid+1,end,i,j,2*id+1));

}
ll func(ll i)
{
    ll max1 =0LL;
    for(ll i=n;i>0;i--)
    {
        ll x=query(1,n,arr[i]+1,n,1);
        update(1,n,arr[i],1,x+brr[i]);
        max1=max(max1,x+brr[i]);
    }
    return max1;
}
int main()
{
// #ifndef ONLINE_JUDGE
//        freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
// #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    // cin >> t;
    t  = 1;
    while(t--)
    {
        cin>>n;
        for(ll i=1;i<=n;i++)
            cin>>arr[i];
        for(ll i=1;i<=n;i++)
            cin>>brr[i];
        memset(dp,-1,sizeof(dp));
        ll x=func(1);
        cout<<x;
    }
    return 0;
}

Measured memory_bytes: 19072
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll N, H;
	cin >> N >> H;
	vector<pll> at;
	at.reserve(2 * N);
	for (ll n = 0; n < N; n++) {
		ll a, b;
		cin >> a >> b;
		at.push_back(pll(a, 0));
		at.push_back(pll(b, 1));
	}
	sort(at.begin(), at.end(), [](pll a,pll b) {
		if (a.first != b.first)return a.first > b.first;
		else return a.second > b.second;
	});
	ll ans = 0;
	for (ll n = 0; n < 2 * N; n++) {
		if (at[n].second == 1) {
			H -= at[n].first;
			ans++;
		}
		else {
			ll time = ceil((ld)H / at[n].first);
			H -= time * at[n].first;
			ans += time;
		}
		if (H <= 0)break;
	}
	cout << ans << "\n";
	return 0;
}

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

int main()
{
    int a, b, c,count = 0;
    cin >> a >> b >> c;
    for (int i = a; i <= b; i++)
    {
        if(c % i == 0)
        {
            count++;
        }
    }

    cout << count << endl;
    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
constexpr ll INF = 1e18;
constexpr double PI = 3.14159265358979;

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

  ll n;
  string ans = "Yes";
  cin >> n;
  vector<ll> a(n), kind;
  map<ll, int> mp;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(mp[a[i]] == 0) kind.push_back(a[i]);
    mp[a[i]]++;
  }
  if(kind.size() > 3) ans = "No";
  sort(kind.begin(), kind.end());
  if(kind.size() == 1){
    if(kind[0] != 0) ans = "No";
  }else{
    if(n%3 != 0) ans = "No";
    if(kind.size() == 2){
      if(kind[0] != 0 or mp[kind[0]] != n/3){
        ans = "No";
      }
    }else{
      if((kind[0] xor kind[1] xor kind[2]) == 0){
        if(!(mp[kind[0]] == mp[kind[1]] and mp[kind[1]] == mp[kind[2]])){
          ans = "No";
        }
      }else ans = "No";
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
int gcd(int a,int b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    ll C[5] = {};
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        if(s[i][0] == 'M') C[0]++;
        if(s[i][0] == 'A') C[1]++;
        if(s[i][0] == 'R') C[2]++;
        if(s[i][0] == 'C') C[3]++;
        if(s[i][0] == 'H') C[4]++;
    }
    ans += C[0]*C[1]*C[2];
    ans += C[0]*C[1]*C[3];
    ans += C[0]*C[1]*C[4];
    ans += C[0]*C[2]*C[3];
    ans += C[0]*C[2]*C[4];
    ans += C[0]*C[3]*C[4];
    ans += C[1]*C[2]*C[3];
    ans += C[1]*C[2]*C[4];
    ans += C[1]*C[3]*C[4];
    ans += C[2]*C[3]*C[4];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6144
/*
１つの配列で実装してみる。
ACしたかどうかは数の正負で判定する。ACするまでのWAの回数は、負の数で数える。
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long int ll;
typedef pair<int, int> P;

int n, m;
vector<int> Q(101010, -1);

int main(){
  cin >> n >> m;
  rep(i, m){
    int p; string s;
    cin >> p >> s;
    if(s == "WA" && Q[p] < 0){
      Q[p]--;
    }else{
      Q[p] = abs(Q[p]);
    }
  }
  int ac = 0, wa = 0;
  rep(i, n + 1){
    if(Q[i] > 0){
      ac++;
      wa += Q[i] - 1;
    }
  }
  cout << ac << " " << wa << endl;
  return 0;
}

Measured memory_bytes: 640
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n: usize
   }
   if n%1000 == 0 {
      println!("0");
   }else{
   println!("{}", 1000-n % 1000);
   }
}


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

typedef long long int lli;

int main(void)
{
	//freopen("A.in","r",stdin);
	//freopen("A.out","w",stdout);
	lli n;
	cin >> n;
	set<lli> s;
	while(n--)
	{
		lli x;
		cin >> x;
		set<lli>::iterator it = s.find(x);
		if(it == s.end())
			s.insert(x);
		else
			s.erase(it);
	}
	cout << s.size();
	return 0;
}

Measured memory_bytes: 4864
#include<cstdio>
using ull = unsigned long long;
const static int MOD = 1000000007;

int main(){
	int K;
	scanf("%d", &K);
	ull A[K];
	for (int i = 0; i < K; ++i) scanf("%llu", A + i);
	if(A[K - 1] != 2){
		printf("-1\n");
		return 0;
	}
	ull min = 2, max = 2;
	for (int i = K - 2; i >= 0; --i){
		if(((min - 1)/A[i] + 1)*A[i] >= max + A[i + 1]){
			printf("-1\n");
			return 0;
		}
		min = ((min - 1)/A[i] + 1)*A[i];
		max = (max + A[i + 1] - 1)/A[i]*A[i];
	}
	printf("%llu %llu\n", min, max + A[0] - 1);
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(ll a=b;a<=c;a++)
#define PER(a,b,c) for(ll a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<ll,ll>
#define pii pair<pair<ll,ll>,ll>
using namespace std;
const ll MAXN=1e6+5;
ll n,m,t;
ll v[MAXN];
char s[MAXN];
int main(){
    cin>>n>>m;
    int l=1,r=m;
    REP(i,1,m/2){
        cout<<l<<' '<<r<<endl;
        l++,r--;
    }
    l=m+1,r=m*2+1;
    REP(i,1,m-m/2){
        cout<<l<<' '<<r<<endl;
        l++,r--;
    }
}

Measured memory_bytes: 3192
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <stack>

using namespace std;
////////////////*My library*////////////////////////
#define rep_to(a,i,n) for(int i=a;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_r(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) cout<<x<<endl
#define s_1(x) cin>>x
#define s_2(x,y) cin>>x>>y
////////////////////////////////////////////////////

////////////////////////
/*prime()*/
/*primecount()*/
/*sort()*/
/*imos???*/
/*????????¢?´¢*/
/*??±???????????¢?´¢*/
/*???????¨???????*/
///////////////////////

int main()
{
	int N;
	int a,b;
	while(1)
	{
		s_1(N);
		if(N==0)break;

		int sumA=0,sumB=0;
		rep(i,N)
		{
			s_2(a,b);
			if(a>b)sumA+=(a+b);
			else if(a<b) sumB+=(a+b);
			else 
			{
				sumA+=a;
				sumB+=b;
			}
		}
		cout<<sumA<<" "<<sumB<<endl;
	}

	return 0;
}

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

// Utility
#define ALL(X) (X).begin(), (X).end()
#define RANGE(I, X, Y) for (int I = (X); I < (Y); I++)
using ll = int64_t;
using ull = uint64_t;
namespace std {
template<class ...Ts>        istream& operator>>(istream& i, tuple<Ts...>& x) { apply([&](auto&&... ys){ ((i >> ys), ...); }, x); return i; }
template<class T1, class T2> istream& operator>>(istream& i, pair<T1, T2>& x) { i >> x.first >> x.second; return i; }
template<class T>            istream& operator>>(istream& i, vector<T>& x)    { for (auto& y : x) { i >> y; } return i; }
}

// Debugging
#define DD(X) std::cout << #X ": " << (X) << std::endl << std::flush
namespace std {
template<class ...Ts>        ostream& operator<<(ostream& o, const tuple<Ts...>& x) { o << "("; apply([&](auto&& y, auto&&... ys){ o << y; ((o << ", " << ys), ...); }, x); o << ")"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const pair<T1, T2>& x) { o << tie(x.first, x.second); return o; }
template<class T>            ostream& operator<<(ostream& o, const vector<T>& x)    { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const set<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
}

// Main
void mainCase() {
  int n;
  cin >> n;
  vector<ull> ls(n, 0);
  cin >> ls;
  sort(ALL(ls));

  // Check zero
  if (ls[0] == 0) {
    cout << 0 << endl;
    return;
  }

  ull lim = 1000'000'000'000'000'000ULL;
  ull res = 1;
  RANGE(i, 0, n) {
    // Check mul overflow by division
    // x.y > z  <=> x > z/y  <=> x > ⌊z/y⌋
    if (res > lim / ls[i]) {
      cout << -1 << endl;
      return;
    }
    res *= ls[i];
  }
  cout << res << endl;
}

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

Measured memory_bytes: 4032
n = int(input())
a = list(map(int,input().split()))
check = 10**18

a = sorted(a)
ans = a[0]
tmp = 0


for i in range(n-1,0,-1):
    ans = ans * a[i]
    if ans > check:
        tmp  = 1
        break
    elif a[0] == 0:
        tmp = 2
        break

if tmp == 1:
    print('-1')
elif tmp == 0:
    print(ans)
elif tmp == 2:
    print('0')


Measured memory_bytes: 84684
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define loop(i,n) for(int i=0;i<(n);i++)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define pub push_back
#define pob pop_back
#define mak make_pair

typedef long long ll;
typedef long double lf;
const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

int main(){
	puts("32957");
	puts("< 2 0 3");
	puts("+ 0 3 0");
	range(j,30,0,-1){
		puts("< 2 0 5");
		loop(k,j)puts("+ 5 5 5");
		puts("+ 4 5 10");
		puts("< 10 0 6");
		printf("< 10 0 %d\n",j+100);
		loop(k,j)puts("+ 6 6 6");
		puts("+ 4 6 4");
	}
	puts("< 0 2 4");
	puts("+ 1 3 1");
	range(j,30,0,-1){
		puts("< 2 0 5");
		loop(k,j)puts("+ 5 5 5");
		puts("+ 4 5 10");
		puts("< 10 1 6");
		printf("< 10 1 %d\n",j+200);
		printf("< %d 3 %d\n",j+200,j+200);
		loop(k,j)puts("+ 6 6 6");
		puts("+ 4 6 4");
	}
	loop(i,31)loop(j,31){
		printf("< %d %d 1000\n",i+200,j+100);
		loop(k,i+j)puts("+ 1000 1000 1000");
		puts("+ 2 1000 2");
	}
	return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <string>
using namespace std;
int main(){
  int i,j,n,k[100],l,len,h;
  string s,out;
  char data[52]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
  while(1){
    out="";
    cin >> n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> k[i];
    }
    cin >> s;
    len=s.size();
    for(i=0,l=0;i<len;i++,l++){
      if(l==n) l=0;
      for(j=0;j<52;j++){
    if(s[i]==data[j]){
      if(j-k[l]<0){
        h=k[l]-j;
        out+=data[52-h];
      }
      else out+=data[j-k[l]];
    }
      }
    }
    cout << out << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ZYCSwing
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt();
            int last = b - a;
            int tot = (last + 1) * last / 2;
            out.print(tot - b);
        }

    }
}



Measured memory_bytes: 21844
// AOJ 0648 Art Exhibition
// 2018.3.30 bal4u

#include <stdio.h>
#include <stdlib.h>

//#define getchar_unlocked()  getchar()
int in()	/* 整数値の入力 */
{
	int n = 0, c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

long long big()		/* long long 整数値の入力 */
{
	long long n = 0, c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define INF 0x1010101010101010LL
typedef struct { long long a; int b; } T;
T tbl[500002];

int cmp(T *a, T *b) {
	if (a->a == b->a) return a->b - b->b;
	if (a->a < b->a) return -1;
	return 1;
}

int main()
{
	int N, i;
	long long s, t, min, max;

	N = in();
	for (i = 0; i < N; i++) tbl[i].a = big(), tbl[i].b = in();
	qsort(tbl, N, sizeof(T), cmp);

	min = INF, max = -INF, s = 0;
	for (i = 0; i < N; i++) {
		t = s - tbl[i].a; if (t < min) min = t;
		t += tbl[i].b - min; if (t > max) max = t;
		s += tbl[i].b;
	}
	printf("%lld\n", max);
	return 0;
}



Measured memory_bytes: 17200