akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc147/tasks/abc147_a
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        a:i32, b:i32, c:i32
    };
    println!("{}", ifv!(a+b+c>=22, "bust", "win"));
}


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

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

    int N, C, K;
    cin >> N >> C >> K;
    vector<int> T(N);
    for (auto &x : T) cin >> x;
    sort(T.begin(), T.end());

    int lim = T.at(0) + K;
    int c = 0;
    int ans = 1;
    for (int i = 0; i < N; ++i) {
        if (T.at(i) <= lim && c < C) {
            c++;
        } else {
            ans++;
            c = 1;
            lim = T.at(i) + K;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
from collections import deque
s1 = str(input())
s2 = str(input())
s3 = str(input())
a = []
b = []
c = []
for i in range(len(s1)):
    a.append(s1[i])
for i in range(len(s2)):
    b.append(s2[i])
for i in range(len(s3)):
    c.append(s3[i])
a = deque(a)
b = deque(b)
c = deque(c)

x = a.popleft()
while True:
    if x == 'a':
        if len(a) == 0:
            print('A')
            break
        x = a.popleft()
    elif x == 'b':
        if len(b) == 0:
            print('B')
            break
        x = b.popleft()
    else:
        if len(c) == 0:
            print('C')
            break
        x = c.popleft()




Measured memory_bytes: 9412
#include <stdio.h>
#define N 200005
int n, i, j, k, f, a, c, t[N], v[N];
long long m;
int main(){
	scanf("%d%lld", &n, &m);
	for(i=1; i<=n; i++){
		scanf("%d", &t[i]);
	}
	for(a=1; m; m--){
		a = t[a], c++;
		if(v[a]) break;
		v[a] = c;
	}
	if(m == 0) printf("%d\n", a);
	else{
		c = c - v[a];
		m = --m % c;
		for(; m; m--) a = t[a];
		printf("%d\n", a);
	}
	return 0;
}

Measured memory_bytes: 3292
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_4_A
TLE
"""
import sys
from sys import stdin
from bisect import bisect_right, bisect_left
input = stdin.readline
 
 
def main(args):
    N, V = map(int, input().split())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]
    C = [int(x) for x in input().split()]
    D = [int(x) for x in input().split()]
 
    AB = []
    for i in A:
        for j in B:
           AB.append(i+j)
    AB.sort()
 
    CD = [float('-inf'), float('inf')]
    for i in C:
        for j in D:
           CD.append(i+j)
    CD.sort()
 
    count = 0
    for ab in AB:
        i = bisect_left(CD, V - ab)
        j = bisect_right(CD, V - ab)
        count += max((j-i), 0)
 
    print(count)
 
 
if __name__ == '__main__':
    main(sys.argv[1:])

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

int main(){
	int n,a,b,c,x[1000],y[1000];
	cin>>n;
	cin>>a;
	for(int i=0;i<a;i++){
		cin>>x[i]>>y[i];
		b=min(x[i],n+1-x[i]);
		b=min(b,y[i]);
		b=min(b,n+1-y[i]);
		if(b%3==0){
			c=3;
		}
		else{
			c=b%3;
		}
		cout<<c<<endl;
	}

	return 0;
}

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

using namespace std;
//DP用
template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;

int main() {
    int a,p;
    cin >> a >> p;
    cout << (a*3+p)/2 << " ";
    return 0;
}





Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=n-1;i>=0;i--){
            a[i] = sc.nextInt();
        }
        for(int i=0;i<n;i++){
            if(i == n-1){
                System.out.print(a[i]);
            }else{
                System.out.print(a[i]+" ");
            }
        }
        System.out.println("");
    }
}


Measured memory_bytes: 26276
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    int a,b;
    int keta = 1;
    scanf("%d%d",&a,&b);
    keta += floor(log10(b));
    int x = a*(int)pow(10,keta) + b;
    bool po = x == (int)pow((int)sqrt(x),2);
    if(po) {
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}

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

int main()
{
    ll a, i, l = 1, x;
    map <string, int> m;;
    cin>>a;
    cin.ignore();
    string s[a+2];
    for(i=0;i<a;i++)
    {
        cin>>s[i];
        m[s[i]]++;
        if(i)
        {
            if(m[s[i]] > 1)
                l = 0;
            x = s[i-1].size();
            if(s[i][0] != s[i-1][x-1])
                l = 0;
        }
    }
    if(l) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main(){

  int n,a=100000;

  cin >> n;

  for(int i=0;i<n;i++){
    a=a*1.05;

    if(a%1000!=0){
      a=a/1000;
      a++;
      a=a*1000;
    }

  }

  cout << a << endl;

}  

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
#define max(a,b) a < b ? b:a

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

    ll m = pos[0] + (k-pos[n-1]);

    rep(i,n-1){
        m = max(m, pos[i+1]-pos[i]);
    }

cout << k-m << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int x = in.nextInt();

        int[] a = new int[n];
        for(int i=0; i<n; i++)
            a[i] = in.nextInt();

        Arrays.sort(a);

        int cnt = 0;
        for(int i=0; i<n-1; i++) {
            if(x >= a[i]) {
                x -= a[i];
                cnt++;
            } else {
                break;
            }
        }

        if(x == a[n-1]) cnt++;

        System.out.println(cnt);
    }
}

Measured memory_bytes: 23764
from collections import deque
X,Y,A,B,C = (int(i) for i in input().split())

P = [int(i) for i in input().split()]
Q = [int(i) for i in input().split()]
R = [int(i) for i in input().split()]
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)
P_deque = deque(P)
Q_deque = deque(Q)
R_deque = deque(R)

red_counter = 0
green_counter = 0

ans = 0

for i in range(X+Y):
  if red_counter == X:
    P_deque = [-1]
  elif green_counter == Y:
    Q_deque = [-1]

  if len(R_deque) != 0:
    if P_deque[0] >= Q_deque[0] and P_deque[0] >= R_deque[0]:
      ans += P_deque.popleft()
      red_counter += 1
    elif Q_deque[0] >= P_deque[0] and Q_deque[0] >= R_deque[0]:
      ans += Q_deque.popleft()
      green_counter +=1
    else:
      ans += R_deque.popleft()
  else:
    if P_deque[0] >= Q_deque[0]:
      ans += P_deque.popleft()
      red_counter += 1
    elif Q_deque[0] >= P_deque[0]:
      ans += Q_deque.popleft()
      green_counter +=1

print(ans)


Measured memory_bytes: 23488
#include <iostream>
using namespace std;
int main ()
{
    int a,b;
    while (cin >> a >> b)
    {
        int sum = a+b,count = 0;
        while (sum != 0)
        {
            count ++;
            sum /= 10;
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

int main(void) {
  long X, K, D;
  cin >> X >> K >> D;
  X = abs(X);
  long k = X / D;
  if (K <= k) {
    cout << X - K * D << endl;
  } else {
    X = X - k * D;
    K -= k;
    if (K % 2) {
      cout << abs(X - D) << endl;
    } else {
      cout << X << endl;
    }
  }
}

Measured memory_bytes: 3588
#include<stdio.h>
#include<string.h>
int main()
{
    char a[100],b[100];
    scanf("%s %s",a,b);
    int lb,la;
    la=strlen(a);
    lb=strlen(b);
    int k=0,i,j,x,y;
    for(i=0;i<la;i++)
    {
        k=0;
        if(a[i]==b[0])
        {
            for(j=0,x=i;j<lb;j++,x++)
            {
                if(x==la) x=0;
                if(b[j]==a[x]) k++;
                //printf("%d\n",k);
            }
        }
        if(k==lb) break;
    }
    if(k==lb) printf("Yes\n");
    else  printf("No\n");
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

#include<queue>

using namespace std;

int main(void)
{
    int a, b, diff, westHeight = 0, snowDepth = 0;

    cin >> a >> b;

    // diffを求めることで最後に足された値が分かる
    diff = b - a;

    // 西側の塔の高さを求める
    for(int i = 1; i < diff; i++)
    {
        westHeight += i;
    }

    // 積雪の深さを求める
    snowDepth = westHeight - a;

    cout << snowDepth;

    return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

let inputData = '';

process.stdin.on('data', inputStdin => {
  inputData += inputStdin;
});

process.stdin.on('end', _ => {
  inputData = inputData.replace(/\s*$/g, '')
    .split(' ');
  main();
});

function main() {
  let result = inputData.reduce((a, b) => a * b);

  process.stdout.write(result.toString())
}


Measured memory_bytes: 29664
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    vector<P> X(n);
    rep(i, n) {
        cin >> X[i].first;
        X[i].second = i;
    }
    sort(ALL(X));
    int x = X[n / 2 - 1].first;
    int y = X[n / 2].first;
    rep(i, n) {
        if(i < n / 2) X[i].first = y;
        else X[i].first = x;
    }
    vector<P> ans(n);
    rep(i, n) {
        ans[i].first = X[i].second;
        ans[i].second = X[i].first; 
    }
    sort(ALL(ans));
    rep(i, n) {
        cout << ans[i].second << endl;
    }

    return 0;
}

Measured memory_bytes: 5376
N, L = map(int, raw_input().split())
A = map(int, raw_input().split())

k = None
for i in range(N-1):
    if A[i] + A[i+1] >= L:
        k = i
        break
    
if k is None:
    print "Impossible"
else:
    print "Possible"
    for j in range(1,k+1):
        print j
    for j in range(N-1, k, -1):
        print j

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

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


void solve(){
  string S;
  cin >> S;

  int N = S.size();
  bool res = true;
  rep(i, (N - 1) / 2){
    if(S[i] != S[N - 1 - i]){
      res = false;
      break;
    }
  }

  rep(i, N / 4){
    if(S[i] != S[(N - 1) / 2 - i - 1]){
      res = false;
      break;
    }
  }

  cout << (res ? "Yes" : "No") << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 55;
const int MAXV = 1 << 18;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
ll coef[MAXN], binom[MAXN][MAXN];
int cnt[MAXV], bits[MAXV];
int m, goal, n, k, s, t, bit[MAXN], a[MAXN];
bool inc(int x, int y) {
	return (x | y) == x;
}
void FWTOR(int *a, int N) {
	for (int len = 2; len <= N; len <<= 1)
	for (int s = 0; s < N; s += len)
	for (int i = s, j = s + len / 2; j < s + len; i++, j++)
		a[i] = a[i] + a[j];
}
int main() {
	read(m), read(k), read(s), read(t);
	if (!inc(t, s)) {
		puts("0");
		return 0;
	}
	for (int i = 1; i <= m; i++) {
		int x; read(x);
		if (inc(x, s) && inc(t, x)) a[++n] = x;
	}
	m = 0, goal = 0;
	for (int i = 1; i <= 18; i++) {
		bit[i] = 1 << (i - 1);
		if ((t & bit[i]) && (s & bit[i]) == 0) m++, goal = goal * 2 + 1;
	}
	for (int i = 1; i <= n; i++) {
		int res = 0;
		for (int j = 1; j <= 18; j++)
			if ((t & bit[j]) && (s & bit[j]) == 0) {
				if (a[i] & bit[j]) res = res * 2 + 1;
				else res = res * 2;
			}
		a[i] = res;
	}
	for (int i = 0; i <= n; i++) {
		binom[i][0] = 1;
		for (int j = 1; j <= i; j++)
			binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];
		for (int j = 0; j <= k - 1; j++)
			coef[i] += binom[i][j];
	}
	for (int i = 1; i <= goal; i++)
		bits[i] = bits[i / 2] + i % 2;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		memset(cnt, 0, sizeof(cnt));
		for (int j = i + 1; j <= n; j++)
			cnt[a[i] ^ a[j] ^ goal]++;
		FWTOR(cnt, goal + 1);
		for (int j = 0; j <= goal; j++)
			if (bits[j] & 1) ans -= coef[cnt[j]];
			else ans += coef[cnt[j]];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5708
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

LL gcd(LL x, LL y) {
    while (1) {
	if (x) y %= x; else return y;
	if (y) x %= y; else return x;
    }
}
LL lcm(LL x, LL y) {
    return x / gcd(x, y) * y;
}

int N, M;
char buf[100011];
string S, T;

void MAIN() {
    scanf("%d%d", &N, &M);
    scanf("%s", buf);
    S = buf;
    scanf("%s", buf);
    T = buf;

    LL l = lcm(N, M);
    
    bool yes = true;
    int j = 0;
    REP (i, N) {
	while (j < M && l / M * j < l / N * i) j++;
	if (l / M * j == l / N * i) {
//	    eprintf("%c %c\n", S[i], T[j]);
	    if (S[i] != T[j]) {
		yes = false;
		break;
	    }
	}
    }

    if (yes) {
	printf("%lld\n", l);
    } else {
	puts("-1");
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

using namespace std;

const int lim = 4e4, Nmax = 505;
typedef long long ll;

int i, j;
ll a[Nmax][Nmax];
vector<int> primes;
bool used[lim+2];

void run_primes()
{
    int i;
    for(i=2; i<=lim; ++i)
        if(!used[i])
        {
            primes.push_back(i);
            for(j=i*i; j<=lim; j+=i) used[j] = 1;
        }
}

int main()
{
   // freopen("input", "r", stdin);

    run_primes();

    int n, N;
    cin >> N;
    n = N + ((N&1)^1);

    for(i=0; i<n; ++i)
        for(j=0; j<n; ++j)
            if(!((i+j)&1)) a[i][j] = (ll) primes[(i+j)/2] * primes[(i-j)/2 + n + 1];

    for(i=0; i<n; ++i)
        for(j=0; j<n; ++j)
            if((i+j)&1)
            {
                if(j && j<n-1) a[i][j] = a[i][j-1] * a[i][j+1] + 1;
                    else a[i][j] = a[i-1][j] * a[i+1][j] + 1;
            }

    for(i=0; i<N; ++i)
        for(j=0; j<N; ++j)
            cout << a[i][j] << " \n"[j==N-1];

    return 0;
}


Measured memory_bytes: 5120
n = int(input())
a = list(map(int, input().split()))

time = [0 for _ in range(n+1)]
time_s = [0 for _ in range(n)]
time[0] = abs(a[0])
time[-1] = abs(a[-1])
time_s[0] = abs(a[1])
time_s[-1] = abs(a[-2])
for i in range(1, n):
    time[i] = abs(a[i]-a[i-1])
for i in range(1, n-1):
    time_s[i] = abs(a[i+1]-a[i-1])
t = sum(time)
for i in range(n):
    print(t-time[i]-time[i+1]+time_s[i])


Measured memory_bytes: 16164
import java.util.Scanner;

public class Main{
    public static void main(String[]argc){
        Scanner sc = new Scanner(System.in);
        for(int a=0;;a++){
            int n = sc.nextInt();
            int x = sc.nextInt();
            int count = 0;
            if(n==0&&x==0){
                break;
            }
            for(int i=1;i<=n-2;i++){
                for(int j=i+1;j<=n-1;j++){
                    for(int k=j+1;k<=n;k++){
                        int sum = 0;
                        sum = i + j + k;
                        if(sum==x){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
}




Measured memory_bytes: 26636
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] A = new int[9];
		for(int i = 0;i < 9;i++) {
			A[i] = scan.nextInt();
		}
		int N = scan.nextInt();
		int[] b = new int [N];
		for(int i = 0;i < N;i++) {
			b[i] = scan.nextInt();
		}
		scan.close();
		boolean[] Ab = new boolean[9];
		for(int i = 0;i < 9;i++) {
			for(int ii = 0;ii < N;ii++) {
				if(A[i] == b[ii]) Ab[i] = true;
			}
		}
		boolean flg = false;
		for(int i = 0;i < 3;i++) {
			if(Ab[3*i])if(Ab[3*i+1])if(Ab[3*i+2])flg = true;
			if(Ab[i])if(Ab[i+3])if(Ab[i+6])flg = true;
		}
		if(Ab[0])if(Ab[4])if(Ab[8])flg = true;
		if(Ab[2])if(Ab[4])if(Ab[6])flg = true;
		if(flg) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21840
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

import heapq
import collections

N, M = rl()
daytasks = collections.defaultdict(list)
for i in range(N):
	a, b = rl()
	daytasks[a].append(b)

heap = []
ans = 0
for i in range(1, M+1):
	for t in daytasks[i]:
		heapq.heappush(heap, (-t, i))
	if len(heap) > 0:
		b, a = heapq.heappop(heap)
		b = -b
		ans += b
print(ans)



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

int main(){
    int N, M;
    cin >> N >> M;
    int l = 1;
    int r = N;
    for(int i =0; i < M; i++){
        int ll, rr;
        cin >> ll >> rr;
        l = max(l, ll);
        r = min(r, rr);
        if(l > r){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << r - l + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int x,y;
    cin >> x >> y;
    if(x == 2 || y == 2) cout << "No" << endl;
    else if((x == 4 && (y == 6 || y == 9 || y == 11)) || (x == 6 && (y == 9 || y == 11)) || (x == 9 && y == 11)){
        cout << "Yes" << endl;
    }
    else if((x == 1 && (y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)) || (x == 3  && (y == 5 || y == 7 || y == 8 || y == 10 || y == 12)) || (x == 5 && (y == 7 || y == 8 || y == 10 || y == 12)) || (x == 7 && (y == 8 || y == 10 || y == 12)) || (x == 8 && (y == 10 || y == 12)) || (x == 10 && y == 12)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cmath>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int main(){
	int n;
	double d;
	cin>>n>>d;
	int ans=0;
	for(int i=1;i<=n;i++){
		double x,y;
		cin>>x>>y;
		if(sqrt(x*x+y*y)<=d)ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, no_sat = 0;
    cin >> n;
    int array[3];
    cin >> array[0] >> array[1] >> array[2];
    for (int i = 0; i <= n - 3; i++) {
        if (min(min(array[0], array[1]), array[2]) != array[1] && max(max(array[0], array[1]), array[2]) != array[1]) {
            no_sat++;
        }
        array[0] = array[1];
        array[1] = array[2];
        cin >> array[2];
    }
    cout << no_sat;
}



Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
int main(){
  int N;
  cin >> N;
  long long ans = 0;
  for(int i = 1; i <= N; i++){
    long long be = i;
    long long en = i * (N / i);
    ans += (be + en) * (long long) (N / i) / 2; 
    //cout << be << " " << en << " " << i << " " << (N / i) << endl;
    //cout << (be + en) / 2 * (N / i) << endl;
    //cout << ans << endl;
  }
  //int sqrt_N = 1;
  //while(sqrt_N * sqrt_N <= N){
  //  sqrt_N ++;
  //}
  //cout << sqrt_N << endl;
  //ans += (N + sqrt_N) * (long long) (N - sqrt_N + 1) / 2;
  cout << ans << endl;
  return 0;
}


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

struct UnionFind{
  vector<int> p;
  UnionFind(int n){
    p.resize(n+1);
    for(int i=1; i<=n; i++)
      p[i] = i;
  }
  int find(int x){
    if(p[x] == x)  return x;
    return p[x] = find(p[x]);
  }
  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y)  return;
    p[x] = y;
  }
};

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

  UnionFind uf(n);
  while(m--){
    int x, y;  cin >> x >> y;
    uf.unite(x, y);
  }
  
  int ans = 0;
  for(int i=1; i<=n; i++)
    if(uf.find(i) == uf.find(p[i]))
      ans++;

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


Measured memory_bytes: 4020
#include <iostream>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  rep(i, 10)
  {
    x = r * x - D;
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import operator
import sys
def solve():
    readline = sys.stdin.readline
    write = sys.stdout.write
    N = int(readline())
    if N == 0:
        return False
    P = [list(map(int, readline().split())) for i in range(N)]
    P.sort(key = operator.itemgetter(0))
    RS = sum(r for r, w in P)
    WS = sum(w for r, w in P)
    if all(2*r <= RS for r, w in P):
        write("%d\n" % (RS + WS))
        return True
    rl, sl = P[-1]

    W = 2*rl - RS
    dp = [0]*(W+1)
    dp[0] = 1
    for r, w in P[:-1]:
        for j in range(W, w-1, -1):
            dp[j] |= dp[j-w]
    ma = max(j for j in range(W+1) if dp[j])
    write("%d\n" % (RS + WS + (W - ma)))
    return True
while solve():
    ...


Measured memory_bytes: 5844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k;
	cin>>k;
	vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cout<<a[k-1]<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String[] words = reader.readLine().split(" ");
        Map<String, Integer> countMap = new HashMap<String, Integer>();
        int maxCount = 0;
        String maxCountWord = null;
        int maxLength = 0;
        String maxLengthWord = null;
        for (String word : words) {
            Integer count = countMap.get(word);
            if (count == null) {
                count = new Integer(1);
            } else {
                count += 1;
            }
            countMap.put(word, count);

            if (count > maxCount) {
                maxCount = count;
                maxCountWord = word;
            }

            int length = word.length();
            if (length > maxLength) {
                maxLength = length;
                maxLengthWord = word;
            }
        }
        out.println(maxCountWord + " " + maxLengthWord);
    }
}

Measured memory_bytes: 9348
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
    int N;
    cin >> N;
    P seito[N];
    int a;
    for(int i=0;i<N;i++){
        cin >> a;
        seito[i] = make_pair(a, i+1);
    }
    sort(seito, seito+N);

    for(int i=0;i<N-1;i++){
        cout << seito[i].second << " ";
    }
    cout << seito[N-1].second <<endl;
    
  	return 0;
}



Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s,t;
    cin>>s>>t;
    int kari=0;
    int ans=1000000;
    for(int i=0; i<s.size()-t.size()+1; i++){
        for(int k=0; k<t.size(); k++){
            if(s.at(k+i)!=t.at(k)){
                kari++;
            }
        }
        if(kari<ans){
            ans=kari;
            kari=0;
        }else{
            kari=0;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  bool flag = true;
  int ans = 0;
  while (flag)
  {
    for (int i = 0; i < n; i++)
    {
      if (a[i] % 2 == 1)
      {
        flag = false;
        break;
      }
      a[i] /= 2;
    }
    ans++;
  }
  cout << --ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
ll ret;
ll num[26];
int main() {
	cin >> s;
    for(int i=0;i<s.size();i++)
        num[s[i]-'a']++;
	for(int i=0;i<26;i++)
        ret += num[i] * (s.size() - num[i]);
	cout << ret / 2 + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
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");
        }
    } 
}


Measured memory_bytes: 26356
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();

        List<String> list = new ArrayList<>();

        for (int i=0; i<num; i++) {
            char[] str = sc.next().toCharArray();
            Arrays.sort(str);
            list.add(String.valueOf(str));
        }

        long count = 0;
        Map<String, Long> map = new HashMap<>();

        for (int i=0; i<num; i++) {
            String input = list.get(i);

            if (map.containsKey(input)) {
                count += map.get(input);
                map.put(input, map.get(input) + 1L);
            } else {
                map.put(input, 1L);
            }
        }

        System.out.println(count);
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<long long int> A(N + 1);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  A.at(N) == 0;
  long long int M = 1000;
  for (int i = 0; i < N; i++) {
    long long int K = 0;
    if (A.at(i) < A.at(i + 1)) K = M / A.at(i);
    M += K * (A.at(i + 1) - A.at(i));
  }
  cout << M << endl;
}

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

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

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,d;
  cin>>n>>d;
  int ans=0;
  rep(i,n){
    int x,y;
    cin>>x>>y;
    double nn=sqrt((x*x)+(y*y));
    //cout<<nn<<endl;
    if(nn<=d) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3720
#include <stdio.h>
int main(void)
{
    unsigned long long int a[4],b[3],i,n,k=0,sum=0,min;
   for(i=0;i<4;i++)
   scanf("%llu",&a[i]);
    scanf("%llu",&n);
    
   b[0] = a[0]*4;
   b[1] = a[1]*2;
   b[2] = a[2];
    if(n>=2)
    {
        if(n%2!=0)
        {
        n = n-1;
        }
        else { k=1; }
        a[0] = a[0]*4*n;
        a[1] = a[1]*2*n;
        a[2] = a[2]*n;
        a[3] = a[3]*n/2;
        
    //qsort(a,4,sizeof(unsigned long long int),cmpfunc);    
      min = a[0];
        for(i=0;i<4;i++)
        {
           // printf("hello");
            if(a[i]<min)
            min = a[i];
        }
      sum = sum + min;     
     // printf("--%d==",sum);
    }
    if(k==0)
    {
        
        min = b[0];
        for(i=0;i<3;i++)
        {
           // printf("hello");
            if(b[i]<min)
            min = b[i];
        }
    //    printf("min : %d ",min);
        sum = sum + min;
        
    }
        printf("%llu\n",sum);
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//inline int in() { int x; scanf("%d",&x); return x;}
inline ll in() { ll x; cin >> x; return x; }
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const ll mod = 1000000007ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  string s; cin >> s;
  ll n = s.length();
  vector<vector<int>> dp(n+1, vector<int>(13));
  dp[0][0] = 1;
  rep(i,n) {
    rep(j,13) {
      if (s[i] == '?') {
        rep(d, 10) {
          int jd = (j * 10 + d) % 13;
          dp[i+1][jd] += dp[i][j];
          dp[i+1][jd] %= mod;
          //(dp[i+1][(j*10+d)%13] += dp[i][j]) %= mod;
        }
      } else {
        int js = (j * 10 + s[i] - '0') % 13;
        dp[i+1][js] += dp[i][j];
        dp[i+1][js] %= mod;
        //(dp[i+1][(j*10+s[i]-'0') % 13] += dp[i][j]) %= mod;
      }
    }
  }
  cout << dp[n][5] << endl;
  return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M =1000000007;
//MOD??
long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}
ll mpow(ll x, ll n){ //x^n(mod M) ????pow(x,n)?????????????mod??
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
int main (){
  int i;
  int s,w;
  cin>>s>>w;
  if(w>=s){
    cout<<"unsafe"<<endl;
  }
  else{
    cout<<"safe"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
# abc127/abc127_d
import sys
from operator import itemgetter

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))


def main():
    N, M = i2nn()
    A = [(1, x) for x in i2nn()]
    BC = [0] * M
    for j in range(M):
        BC[j] = tuple(i2nn())
    BC.extend(A)
    ABC = sorted(BC, key=itemgetter(1))
    sum = 0
    poped = ABC.pop()
    while N > poped[0]:
        sum += poped[0] * poped[1]
        N -= poped[0]
        poped = ABC.pop()
    sum += poped[1] * N
    print(sum)
    return

main()


Measured memory_bytes: 34348
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main() {
    int h,w;
    cin >> h >> w;
    int c[10][10];
    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j <= 9; j++) {
            cin >> c[i][j];
        }
    }
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {
                c[j][k] = min(c[j][k],c[j][i]+c[i][k]);
            }
        }
    }
    int ret = 0;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++) {
            int x;
            cin >> x;
            if (x != -1){
                ret += c[x][1];
            }
        }
    }
    cout << ret;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_set>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1ll << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	ll a, b;
	cin >> a >> b;
	REP(i, 10000) {
		if (i * 108 / 100 - i == a and i * 110 / 100 - i == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int n,T;
    scanf("%d%d", &n, &T);
    map<int,int> z;
    int i;
    int maxval=0;
    ll  maxcnt=0;
    for(i=0; i<n; i++) {
        int tmp;
        scanf("%d", &tmp);
        if(!z.empty()) {
            auto it=z.begin();
            int tmp0=it->first;
            int val=tmp-tmp0;
            if(val>maxval) {
                maxval=val;
                maxcnt=it->second;
            }
            else if(val==maxval) {
                maxcnt+=it->second;
            }
        }
        z[tmp]++;
    }
    printf("%lld\n", maxcnt);

    return 0;
}


Measured memory_bytes: 4864
import sys

S = input()

cnt = 0
for i in range(len(S)):
	if i == 0 and S[i] != 'A':
		print('WA')
		sys.exit()
	elif i == 0:
		continue
	if i >= 2 and i <= len(S)-2 and S[i] == 'C':
		cnt += 1
	elif S[i].isupper():
		print('WA')
		sys.exit()

if cnt != 1:
	print('WA')
	sys.exit()
	
print('AC')

Measured memory_bytes: 3060
// template version 1.2
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0LL)
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

template<typename A, size_t N, typename T> // n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
//}}}


int solve(){
  int N,M,X,Y;cin>>N>>M>>X>>Y;

  int x[N]; rep(i, N) {cin>>x[i];}
  int y[M]; rep(i, M) {cin>>y[i];}

  sort(x, x+N);
  sort(y, y+M);
  dump_1d(x, N);
  dump_1d(y, M);

  if (max(x[N-1], X)>=min(y[0], Y)){
    cout << "War" << endl;
  }
  else{
    cout << "No War" << endl;
  }

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

class coordinate {
public:
    int x;
    int y;
    int times;

    coordinate(int a, int b, int c) {
        x = a;
        y = b;
        times = c;
    }
};

signed main() {
    int H, W;
    cin >> H >> W;
    vector<vector<bool>> field(H, vector<bool>(W, true));
    char input;
    queue<coordinate> black;
    for (int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> input;
            if (input == '#') {
                black.push(coordinate(i, j, 0));
                field[i][j] = false;
            }
        }
    }
    int ans = 0;
    while (!black.empty()) {
        coordinate take = black.front();
        // printf("%d %d %d\n", black.front().x, black.front().y, black.front().times);
        ans = take.times;
        black.pop();
        if (take.x - 1 >= 0 && field[take.x - 1][take.y]) {
            black.push(coordinate(take.x - 1, take.y, take.times + 1));
            field[take.x - 1][take.y] = false; 
        }
        if (take.x + 1 < H && field[take.x + 1][take.y]) {
            black.push(coordinate(take.x + 1, take.y, take.times + 1));
            field[take.x + 1][take.y] = false;
        }
        if (take.y - 1 >= 0 && field[take.x][take.y - 1]) {
            black.push(coordinate(take.x, take.y - 1, take.times + 1));
            field[take.x][take.y - 1] = false;
        }
        if (take.y + 1 < W && field[take.x][take.y + 1]) {
            black.push(coordinate(take.x, take.y + 1, take.times + 1));
            field[take.x][take.y + 1] = false;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 24628
#!/usr/bin/env python
# coding: utf-8

# In[1]:


H,W,K = map(int, input().split())
s = []
for _ in range(H):
    s.append(input())


# In[29]:


ans = [[0]*W for _ in range(H)]
num = 1
for h in range(H):
    if "#" not in s[h]:
        if h != 0:
            ans[h] = ans[h-1]
            continue
        else:
            continue
    is_first = True
    for w in range(W):
        if s[h][w] == "#":
            if is_first:
                is_first = False
            else:
                num += 1
        ans[h][w] = num
    num += 1
for h in range(H-2,-1,-1):
    if 0 in ans[h]:
        ans[h] = ans[h+1]
for h in range(H):
    print(*ans[h])


# In[ ]:






Measured memory_bytes: 12828
cnt = 0
l = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
for i in range(l[0]):
    s = 0
    a = [int(j) for j in input().split()]
    for k in range(l[1]):
        s += a[k]*b[k]
    if s+l[2]>0:
        cnt += 1
print(cnt)


Measured memory_bytes: 3060