akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define rvc(i,S) for(int i=0;i<(int)S.size();++i)
#define fore(i,x) for(int i = head[x] ; i ; i = e[i].next)
#define mp make_pair
#define pb push_back
#define maxn 1000005
#define ll long long 
#define fi first
#define int ll
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
int L,n;
int a[maxn];
int cmax;
vector<int> sl,sr;
int suml[maxn],sumr[maxn];
signed main()
{cin>>L>>n;
 rep(i,1,n) {scanf("%lld",&a[i]);sr.pb(a[i]);sumr[i]=sumr[i-1]+a[i];}
 cmax=max(a[n],L-a[1]);
 int t=0;
 repd(i,n,2)
   { sl.pb(L-a[i]); sr.pop_back() ;
     t++;int l=sr.size();
	 suml[t]+=suml[t-1]+L-a[i];
	 if(sl.size()>sr.size())
	    {int tmp=suml[t]*2+sumr[l]*2;
		 int cha=sl.size()-sr.size();
//	     cmax=max(cmax,sumr[l]*2+suml[sr.size()-1]*2+sl[sl.size()-1]);
	     cmax=max(cmax,tmp-suml[sl.size()-sr.size()]*2-sr[sr.size()-1]);
	     cmax=max(cmax,tmp-suml[sl.size()-sr.size()-1]*2-sl[sl.size()-1]);
		}
	if(sl.size()==sr.size())
	   {int tmp=suml[t]*2+sumr[l]*2;
	    cmax=max(cmax,tmp-sl[sl.size()-1]);
	    cmax=max(cmax,tmp-sr[sr.size()-1]);
	   }
	  if(sl.size()<sr.size())
	    {int tmp=suml[t]*2+sumr[l]*2;
		 int cha=sr.size()-sl.size();
//	     cmax=max(cmax,suml[t]*2+sumr[sl.size()-1]*2+sr[sr.size()-1]);
	     cmax=max(cmax,tmp-sumr[sr.size()-sl.size()]*2-sl[sl.size()-1]);
	     cmax=max(cmax,tmp-sumr[sr.size()-sl.size()-1]*2-sr[sr.size()-1]);
		}  	
   }
	cout<<cmax;
}

Measured memory_bytes: 14704
#include <iostream>

using namespace std;

int main() {
  int H, W;
  while (true)
    {
      cin >> H >> W;
      if (H == 0 && W == 0) break;
      for ( int i = 0; i < H; i++ ){
        for ( int j = 0; j < W; j++ ){
          cout << "#";
        }
        cout << endl;
      }
      cout << endl;
    }
  return 0;
}

Measured memory_bytes: 1152
use proconio::*;

fn run() {
    input! {
        mut n: usize,
        x: usize,
        m: usize,
    }
    let mut dp = vec![(0, 0); m];
    for (i, dp) in dp.iter_mut().enumerate() {
        *dp = (i * i % m, i as u64);
    }
    type T = (usize, u64);
    let mul = |a: &[T], b: &[T]| -> Vec<T> {
        let mut c = vec![(0, 0); m];
        for (c, a) in c.iter_mut().zip(a.iter()) {
            let b = b[a.0];
            *c = (b.0, b.1 + a.1);
        }
        c
    };
    let mut t = (0..m).map(|p| (p, 0)).collect::<Vec<_>>();
    let mut s = dp;
    while n > 0 {
        if n & 1 == 1 {
            t = mul(&t, &s);
        }
        s = mul(&s, &s);
        n >>= 1;
    }
    let ans = t[x].1;
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 6772
#include <stdio.h>

int main(){

	int A,B,C;

	scanf("%d %d %d",&A,&B,&C);

	if(A==B){printf("%d\n",C);}
	else if(B==C){printf("%d\n",A);}
	else if(C==A){printf("%d\n",B);}

return 0;
}

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000000000;
int PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll,ll,ll>>>;



int main(){
    int N;
    string S;
    cin >> N >> S;
    bool L[11][11][11];
    for(int i = 0;i < 11;i++){
        for(int j = 0;j < 11;j++){
            for(int k = 0;k < 11;k++){
                L[i][j][k] = false;
            }
        }
    }
    for(int i = 0;i < N;i++){
        for(int j = 0;j < 10;j++){
            char a = '0' + j;
            if(S[i] == a){
                bool frag = 0;
                if(!L[j][10][10]){
                    L[j][10][10] = true;
                    frag = 1;
                    //continue;
                }
                for(int k = 0;k < 10;k++){
                    bool frag2 = 0;
                    if(L[k][10][10] && !(k == j && frag) && !L[k][j][10]){
                        L[k][j][10] = true;
                        frag2 = 1;
                        //continue;
                    }
                    for(int l = 0;l < 10;l++){
                        if(L[k][l][10] && !(l == j && frag2)){
                            L[k][l][j] = true;
                        }
                    }
                }
                break;
            }
        }
        //cout << L[0][2][10] << ' ' << L[0][2][4] << ' ' << L[2][2][4] << endl;
    }
    int ans = 0;
    for(int i = 0;i < 10;i++){
        for(int j = 0;j < 10;j++){
            for(int k = 0;k < 10;k++){
                if(L[i][j][k]){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[200001],f[200001],d[200001],u;
int k;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]==1)<%d[++u]=i;f[i]++;k=max(k,f[i]);%>
		else
		{
			for(int j=1;j<=u;j++)
		    {
			    if(a[i]==f[d[j]]+1)
			    {
				    f[d[j]]++;
			    }
			    k=max(k,f[d[j]]);
		    }
		    
		}
	}
	if(k==0)cout<<"-1";
	else cout<<n-k;
	return 0;
}

Measured memory_bytes: 2560
from collections import Counter

n = int(input())
v = list(map(int, input().split(' ')))

v1 = v[::2]
v2 = v[1::2]

counter1 = dict(Counter(v1))
counter2 = dict(Counter(v2))
x1 = max(counter1, key=counter1.get)
x2 = max(counter2, key=counter2.get)
x1_c = counter1[x1]
x2_c = counter2[x2]
del counter1[x1]
del counter2[x2]
y1_c = 0
y2_c = 0
if len(counter1) != 0:
    y1_c = max(counter1.values())
if len(counter2) != 0:
    y2_c = max(counter2.values())

n = n//2
ans = 0
if x1 == x2:
    ans = min((n - x1_c) + (n - y2_c), (n - y1_c) + (n - x2_c))
    """
    if x1_c > x2_c:
        ans = (n - x1_c) + (n - y2_c)
    else:
        ans =  (n - y1_c) + (n - x2_c)
    """
else:
    ans = (n - x1_c) + (n - x2_c)

print(ans)

Measured memory_bytes: 22108
S = int(input())

ans = 0

a = [S]

while True:
    ans += 1
    if a[ans - 1] % 2 == 0:
        an = a[ans - 1] / 2
    else:
        an = a[ans - 1] * 3 + 1
    if an in a:
        break
    a.append(an)

print(ans + 1)

Measured memory_bytes: 3060
def main():
    n, a, b, c, d = list(map(lambda x: int(x) - 1, input().split()))
    n += 1
    s = list(input())
    s = s[a:max(c, d) + 1]
    for i in range(len(s) - 1):
        if s[i] == '#' and s[i + 1] == '#':
            print('No')
            exit()
    if c < d:
        print('Yes')
    else:
        ch = False
        for i in range(b, d + 1):
            if s[i - 1] == s[i] == s[i + 1] == '.':
                ch = True
        if ch:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 62704
/**
 *    author:  tourist
 *    created: 12.12.2019 13:30:40       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, p;
  cin >> n >> p;
  vector<int> w(n);
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> b[i];
  }
  vector<long long> value(n);
  long long s = 0;
  for (int i = 0; i < n; i++) {
    s -= p * 1LL * b[i];
    value[i] = (100LL - p) * w[i] + p * 1LL * b[i];
  }
  sort(value.rbegin(), value.rend());
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (s < 0) {
      s += value[i];
      ++ans;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1792
s = gets.chomp
c = s.index("C")
if s.count("A") == 1 && s.count("C") == 1 && s[0] == "A" && 
   s.count("A-Z", "^AC") == 0 && c >= 2 && c <= s.size - 2
    puts "AC"
else
    puts "WA"
end

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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

int INF = (1 << 14);
typedef vector<int> VI;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

void print(int* A, int n) {
    REP(i, n) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

int partition(VI &A, int p, int r) {
    int pivot = A[r];
    int i = p - 1;

    FOR(j, p, r) {
        if(A[j] <= pivot) {
            ++i;
            swap(A[i], A[j]);
        }
    }
    swap(A[++i], A[r]);

    return i;
}

void quickSort(VI &A, int p, int r) {
    if (p < r) {
        int q = partition(A, p, r);
        quickSort(A, p, q-1);
        quickSort(A, q + 1, r);
    }
}

bool check_index_in_groups(vector<VI> A, int index) {
    bool ret = false;
    REP(i, A.size()) {
        if (find(A[i].begin(), A[i].end(), index) != A[i].end()) {
            ret = true;
            break;
        }
    }

    return ret;
}

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

    int n;
    cin >> n;

    VI A(n);
    REP(i, n) cin >> A[i];

    VI S(A);
    quickSort(S, 0, n - 1);
//    cout << A << endl << S << endl;

    // extract groups
    int i = 0;
    vector<VI> groups;
    REP(i, A.size()) {
        if (A[i] == S[i]) continue;

        // continue if current index is already added to a group.
        if (check_index_in_groups(groups, i)) continue;

        VI group = {i};

        int index = i;
        while (true) {
            REP(j, A.size()) {
                if (A[index] == S[j]) {
                    index = j;
                    break;
                }
            }
            if (index == i) break;
            group.push_back(index);
        }

        groups.push_back(group);
    }

    // get min values for all groups
    vector<pair<int, int>> mins(groups.size());
    VI sums(groups.size());
    REP(i, groups.size()) {
        int m1 = INF, m2 = INF;
        int s = 0;
        VI g = groups[i];
        REP(j, A.size()) {
            if (find(g.begin(), g.end(), j) != g.end()) {
                m1 = min(m1, A[j]);
                s += A[j];
            } else {
                m2 = min(m2, A[j]);
            }
        }

        mins[i] = make_pair(m1, m2);
        sums[i] = s;
    }

//    REP(i, groups.size()) {
//        cout << groups[i] << endl << sums[i] << " " << mins[i].first << " " << mins[i].second << endl;
//    }

    // cost
    int cost = 0;
    REP(i, groups.size()) {
        pair<int, int> m = mins[i];
        int n = groups[i].size();
        int s = sums[i];

        cost += min(m.first * (n - 2) + s, m.second * (n + 1) + s + m.first);
    }

    cout << cost << endl;

}



Measured memory_bytes: 3296
let () =
  let n = read_int () in
  let tbl = Hashtbl.create 1000000 in
  let rec loop = function
      0 -> ()
    | i ->
      begin match Scanf.scanf "%s %s\n" (fun a b -> a,b) with
          "insert",word -> Hashtbl.add tbl word 0
        | _,word ->
          print_endline
            (if Hashtbl.mem tbl word then "yes" else "no")
      end;
      loop (i-1)
  in
  loop n

Measured memory_bytes: 43832
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
for i in range(11):
    if i*1000 >= n:
        break
print(i*1000-n)


Measured memory_bytes: 10392
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<utility>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,a[105],mn,ans;
int main(){
	cin>>n;
	mn=99999;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		int s1,s2;
		s1=s2=0;
		for(int j=1;j<=i;j++)
			s1+=a[j];
		for(int j=i+1;j<=n;j++)
			s2+=a[j];
		if(abs(s1-s2)<mn)
			mn=abs(s1-s2),ans=i;
	}
	cout<<mn;
	return 0;
}


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

int n, ans;

int main()
{
    cin >> n;
    vector<int> v(n), c(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
    }
    for (int i = 0; i < n; i++)
    {
        ans += max(v[i] - c[i], 0);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
s = int(input())
l = [s]
x = 1
y = 0

while y == 0:
  if s%2 == 0:
    s = int(s//2)
  else:
    s = 3*s+1

  if s in l:
    print(x+1)
    y = 1
  else:
    l.append(s)
    x += 1

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

int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	X = X/50;
	int counter = 0;
	for (int k = 0; k <= A; k++) {
		for (int j = 0; j <= B; j++) {
			for (int i = 0; i <= C; i++) {
				if (1*i + 2*j + 10*k == X) {
					counter++;
				}
			}
		}
	}
	cout << counter << endl;
}

Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())

ans = a * x + b * y
if a + b > 2 * c:
    if x > y:
        if a > 2 * c:
            ans = 2 * c * x
        else:
            ans = 2 * c * y + a * (x - y)
    else:
        if b > 2 * c:
            ans = 2 * c * y
        else:
            ans = 2 * c * x + b * (y - x)
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 80, inf = 1e7; int n, m;
int a[2][maxN][maxN];

int memo[maxN][maxN][2*maxN*maxN + 1];
int solve(int i = 0, int j = 0, int d = 0)
{
  if (i == n - 1 && j == m - 1) return min(abs(d + a[0][i][j] - a[1][i][j]), abs(d + a[1][i][j] - a[0][i][j]));
  if (memo[i][j][d] != -1) return memo[i][j][d];
  int ans = inf;
  if (i + 1 < n)
  {
    ans = min(ans, solve(i + 1, j, abs(d + a[0][i][j] - a[1][i][j])));
    ans = min(ans, solve(i + 1, j, abs(d + a[1][i][j] - a[0][i][j])));
  }
  if (j + 1 < m)
  {
    ans = min(ans, solve(i, j + 1, abs(d + a[0][i][j] - a[1][i][j])));
    ans = min(ans, solve(i, j + 1, abs(d + a[1][i][j] - a[0][i][j])));
  }
  return memo[i][j][d] = ans;
}

int main()
{
  while (scanf("%d %d", &n, &m) != EOF)
  {
    for (int i = 0; i < 2; i ++)
      for (int j = 0; j < n; j ++)
        for (int k = 0; k < m; k ++)
          scanf("%d", &a[i][j][k]);
    memset(memo, -1, sizeof(memo));
    int ans = solve();
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 320384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

const int N=201000;
int n,q,a[N];
ll L,R,f[N][4];
int main() {
	scanf("%d%d%lld%lld",&n,&q,&L,&R);
	rep(i,0,n) scanf("%d",a+i);
	rep(i,0,q) scanf("%lld%lld%lld%lld",f[i],f[i]+1,f[i]+2,f[i]+3);
	sort(a,a+n);
	int l=-1,r=n;
	while (l+1<r) {
		int md=(l+r)>>1;
		__int128_t p=a[md];
		rep(i,0,q) {
			if (f[i][0]==1) {
				if (p>=f[i][1]) p=(p+f[i][2])*f[i][3];
			} else {
				if (p<=f[i][1]) p=(p-f[i][2])/f[i][3];
			}
		}
		//printf("%d %lld\n",md,(ll)p);
		if (p>=L) r=md; else l=md;
	}
	int x=r;
	l=-1,r=n;
	while (l+1<r) {
		int md=(l+r)>>1;
		__int128_t p=a[md];
		rep(i,0,q) {
			if (f[i][0]==1) {
				if (p>=f[i][1]) p=(p+f[i][2])*f[i][3];
			} else {
				if (p<=f[i][1]) p=(p-f[i][2])/f[i][3];
			}
		}
		//printf("%d %lld\n",md,(ll)p);
		if (p<=R) l=md; else r=md;
	}
	//printf("%d %d\n",l,x);
	printf("%d\n",l-x+1);
}



Measured memory_bytes: 10132
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type IntDescSort []int

func (s IntDescSort) Len() int {
	return len(s)
}

func (s IntDescSort) Less(i, j int) bool {
	return s[i] > s[j]
}

func (s IntDescSort) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	// ここからロジック
	n, _ := strconv.Atoi(s)
	arr := make([]int, 0, n)
	arrSorted := make([]int, 0, n)

	for i := 0; i < n; i++ {
		if sc.Scan() {
			s = sc.Text()
		}
		_n, _ := strconv.Atoi(s)
		arr = append(arr, _n)
		arrSorted = append(arrSorted, _n)
	}
	// 大きい順にしてソートする
	sort.Sort(IntDescSort(arrSorted))
	for _, n := range arr{
		skipped := false
		for _, max := range arrSorted{
			if max != n || skipped{
				fmt.Println(max)
				break
			}else{
				skipped = true
				continue
			}
		}
	}
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
const int N = 102;

int n;
char a[N];

int main()
{
    scanf(" %s", a);
    n = strlen(a);
    int ans = 0;
    for (int i = 0; i < n / 2; ++i)
    {
        if (a[i] != a[n - i - 1])
        {
            ++ans;
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i ,a, b) for (int i = a ; i <= b ; i++)
#define sz(a) int(a.size())
#define cuti(a) cout << a << endl;
#define cutii(a,b) cout << a << " " << b << endl;
#define cutiii(a,b,c) cout << a << " " << b << " " << c << endl;
#define vec(a) vector<int > a;

template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }

typedef pair<int ,int > pii;
typedef long long LL;
const long long oo = 1e9 + 7;

string s;

int main(){
  //  freopen("test.txt","r",stdin);
    cin >> s;
    string t = "FESTIVAL";
    int tmp = s.size() - 8;
    s.erase(s.begin()+ tmp, s.end());
    cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn= 5e5+5;
#define mod 1000000007
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
vector<array<ll,2>> adj[mxn];
bool vis[mxn];
ll ans=0,w,check;
ll dfs(int i, ll temp, int j){
    vis[i]=true;
    ll sum=0;
    for(auto x : adj[i]){
        if(!vis[x[0]]){
            if(temp+x[0]>=check*j){
                while(x[1]>=check){
                    ans++;
                    x[1]=x[1]/2;
                }
            }
            ll k=dfs(x[0],temp+x[1],j+1);
            sum=sum+k-x[1];
            if(k>=check*j){
               while(x[1]>=check){
                    ans++;
                    x[1]=x[1]/2;
                }
            }
            sum=sum+x[1];
        }
    }
    return sum;
}
int main(){
    int n,m,q,u,v;
    cin>>n>>m>>q;
    map<int,int> a,b;
    u=v=INT_MAX;
    for(int i=1;i<=n;i++){
        int c;
        cin>>c;
        u=min(u,c);
        a[i]=c;
    }
    for(int i=1;i<=m;i++){
        int c;
        cin>>c;
        b[i]=c;
        v=min(c,v);
    }
    int  ans=INT_MAX;
    while(q--){
        int x,y,z;
        cin>>x>>y>>z;
        int  temp=a[x]+b[y]-z;
        ans=min(ans,temp);
    }
    cout<<min(v+u,ans);
}



Measured memory_bytes: 24636
#include <stdio.h>
//#include <stdlib.h>
#include <string.h>

int main(){
    int n,i,j;
    char taro[101],hanako[101];
    int tpoint=0,hpoint=0;
    scanf(" %d",&n);
        for(i = 0;i < n;i++){
            scanf("%s %s",taro,hanako);
            for(j = 0;;j++){
                if(taro[j] > hanako[j]){
                    tpoint += 3;
                    break;
                }else if(taro[j] < hanako[j]){
                    hpoint += 3;
                    break;
                }else if(taro[j]+hanako[j]==0) {
                    tpoint++;
                    hpoint++;
                    break;
                }
            }
        }
    printf("%d %d\n",tpoint,hpoint);
    return 0;
}




Measured memory_bytes: 2076
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,command,x;
    string key;
    map<string,int> myMap;
    cin >> n;

    for(int i = 0;i < n;++i){
        cin >> command >> key;
        // insert
        if(command == 0){
            cin >> x;
            myMap[key] = x;
        }else if(command == 1){
            // find
            cout << myMap[key] << endl;
        }
    }
}



Measured memory_bytes: 25848
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
using namespace std;
const int MAXN=200000+5;

namespace Seg
{
    pair<int,int>Min[MAXN<<2];
    #define ls (x<<1)
    #define rs (x<<1|1)
    void init(int x,int l,int r)
    {
        Min[x]=make_pair(1<<30,0);
        if(l==r) return;
        int mid=l+r>>1;
        init(ls,l,mid);
        init(rs,mid+1,r);
    }
    void ins(int x,int l,int r,int v,int pos)
    {
        Min[x]=min(Min[x],make_pair(v,pos));
        if(l==r) return;
        int mid=l+r>>1;
        if(pos<=mid) ins(ls,l,mid,v,pos);
        else ins(rs,mid+1,r,v,pos);
    }
    pair<int,int>query(int x,int l,int r,int ql,int qr)
    {
        if(ql<=l&&r<=qr) return Min[x];
        int mid=l+r>>1;
        if(ql>mid) return query(rs,mid+1,r,ql,qr);
        if(qr<=mid) return query(ls,l,mid,ql,qr);
        return min(query(ls,l,mid,ql,qr),query(rs,mid+1,r,ql,qr));
    }
}
int n,m;
int nxt[MAXN];
char s[MAXN];
int main()
{
    scanf("%d%d",&n,&m);
    scanf("%s",s);
    Seg::init(1,1,n);
    Seg::ins(1,1,n,0,n);
    for(int i=n-1;i>0;i--)
    if(s[i]=='0')
    {
        pair<int,int>val=Seg::query(1,1,n,i+1,min(n,i+m));
        nxt[i]=val.second;
        if(val.first!=(1<<30))
        {
            val.first++;
           // printf("%d %d %d\n",i,nxt[i],val.first);
            Seg::ins(1,1,n,val.first,i);
        }
        //printf("%d %d %d %d\n",i,nxt[i],i+1,min(n,i+m));
    }
    pair<int,int>val=Seg::query(1,1,n,1,min(m,n));
    if(val.first==(1<<30))
    {
        puts("-1");
        return 0;
    }
    for(int i=val.second,last=0;;)
    {
        printf("%d ",i-last);
        if(i==n) break;
        last=i;
        i=nxt[i];
    }

    return 0;
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
long long n,sum;
int flag=0;
int main(){
    cin>>n; 
    for(int i=sqrt(n);i>0;i--) 
        if(n%i==0){
            sum=n/i;
            break;
        }
    while(sum>0){ 
        flag++;
        sum/=10;
    }
    cout<<flag<<endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>){
  var s = readLine()!!.toCharArray()
  var size = s.size
  var count = 0
  if(s[0]=='0'){
    for(i in 1..size-1){
      var o = i%2
      if(s[i] != '1' && o == 1){
        s[i] = '1'
        count++
      }else if(s[i] != '0' && o == 0){
        s[i] = '0'
        count++
      }
    }
  }
  else if(s[0]=='1'){
    for(i in 1..size-1){
      var o = i%2
      if(s[i] != '0' && o == 1){
        s[i] = '0'
        count++
      }else if(s[i] != '1' && o == 0){
        s[i] = '1'
        count++
      }
    }
  }
  println(count)
}

Measured memory_bytes: 33808
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;

void solve() {
	int n, x;
	cin >> n >> x;
	vector<ll> v(n);
	for(int i = 0; i < n; ++i) cin >> v[i];
	ll ans = 0;
	for(int i = 0; i < n - 1; ++i) {
		if(v[i] + v[i + 1] > x) {
			ans += v[i] + v[i + 1] - x;
			if(v[i + 1] >= (v[i] + v[i + 1] - x)) v[i + 1] -= (v[i] + v[i + 1] - x);
			else v[i + 1] = 0;
			}
		}
		cout << ans << endl;
}

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve();
	return 0;
	}


Measured memory_bytes: 3964
S = input()
N = len(S)


class RLBox:
    def __init__(self, i):
        self.RStart = i
        self.REnd = 0
        self.LStart = 0
        self.LEnd = 0


state = 0

boxlist = []

for i, c in enumerate(S):
    if state == 0 and c == "R":
        box = RLBox(i)
        state = 1
    elif state == 1 and c == "R":
        pass
    elif state == 1 and c == "L":
        box.REnd = i - 1
        box.LStart = i
        state = 2
    elif state == 2 and c == "L":
        pass
    elif state == 2 and c == "R":
        box.LEnd = i - 1
        boxlist.append(box)
        box = RLBox(i)
        state = 1

box.LEnd = N - 1
boxlist.append(box)

ans = ""

for b in boxlist:
    Left = (b.REnd - b.RStart) // 2 + (b.LEnd - b.LStart + 1) // 2 + 1
    Right = (b.REnd - b.RStart + 1) // 2 + (b.LEnd - b.LStart) // 2 + 1
    ans += " 0" * (b.REnd - b.RStart)
    ans += " {}".format(Left)
    ans += " {}".format(Right)
    ans += " 0" * (b.LEnd - b.LStart)

print(ans[1:])


Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
typedef vector<int> vi;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];
int gcd(int a,int b)
{
    if(b==0){
      return a;
     }
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    int res=(a*b)/gcd(a,b);
    return res;
}
int po(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b%2!=0)
        {
            res*=a;
            b--;
        }
        else
        {
            a*=a;
            b/=2;
        }
    }
    return res;
}



int main()
{
    int n,m;
    sc(n)sc(m)
    for(int i=0;i<m;i++)
    {
        int a,b;
        sc(a) sc(b)
        arr[a]++;
        arr[b]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<arr[i]<<endl;
    }

}







Measured memory_bytes: 256
X,Y,A,B,C = map(int,input().split())

p = sorted(list(map(int,input().split()))) #A
q = sorted(list(map(int,input().split()))) #B
r = sorted(list(map(int,input().split()))) #C

xlist = p[-X:] #X
ylist = q[-Y:] #Y

"""
def main(X,Y,xlist,ylist,r):
    for i in range(min(X,Y)):
        if xlist[i] < ylist[i] and min(xlist) < max(r):
            xlist.remove(min(xlist))
            xlist.append(r.pop())
            
        elif ylist[i] < xlist[i] and min(ylist) < max(r):
            ylist.remove(min(ylist))
            ylist.append(r.pop())
            
        elif min(xlist) >= max(r) and min(ylist) >= max(r):
            break
        else:
            continue
    
    print(sum(xlist + ylist))

main(X,Y,xlist,ylist,r)
"""
all_apples = sorted(xlist + ylist + r)
print(sum(all_apples[-(X+Y):]))







Measured memory_bytes: 23456
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
    
      	Scanner sc = new Scanner(System.in);
      	int N = Integer.parseInt(sc.nextLine());
      	String[] strB = sc.nextLine().split("\\s");
      	
      	int[] A = new int[N];
       	
      	for(int i = 0; i < N - 1; i++){
      	    int B = Integer.parseInt(strB[i]);
      	    
      	    A[i+1] = B;
      	    if( (i == 0) || (A[i] > B) ) A[i] = B;
      	}
      	
      	int sum = Arrays.stream(A).sum();
      	
      	System.out.println(sum);
      	
    }
}

Measured memory_bytes: 26964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

long unsigned euclidean_gcd(long unsigned a, long unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  long unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

  ll a, b;
  cin >> a >> b;
  //ll g =  euclidean_gcd(a, b);
  ll g = __gcd(a, b);
  cerr << g << endl;

  ll ans = 1;
  for (ll i = 2; i*i < g; i++) {
    if (g%i == 0) {
      ans++;
      while (g%i == 0) {
        g /= i;
      }
    }
  }
  if (g != 1) ans++;

  cout << ans << endl;
}


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

int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  for (int i = 0; i < h; i++) cin >> a.at(i);
  vector<vector<int>> a_ul(h, vector<int>(w, 5000)), a_ur(h, vector<int>(w, 5000)),
    a_dl(h, vector<int>(w, 5000)), a_dr(h, vector<int>(w, 5000));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a.at(i).at(j) == '#') {
        a_ul.at(i).at(j) = 0;
      } else if (i > 0 && j > 0) {
        a_ul.at(i).at(j) = min(a_ul.at(i-1).at(j), a_ul.at(i).at(j-1)) + 1;
      } else if (i > 0) {
        a_ul.at(i).at(j) = a_ul.at(i-1).at(j) + 1;
      } else if (j > 0) {
        a_ul.at(i).at(j) = a_ul.at(i).at(j-1) + 1;
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = w-1; j >= 0; j--) {
      if (a.at(i).at(j) == '#') {
        a_ur.at(i).at(j) = 0;
      } else if (i > 0 && j < w-1) {
        a_ur.at(i).at(j) = min(a_ur.at(i-1).at(j), a_ur.at(i).at(j+1)) + 1;
      } else if (i > 0) {
        a_ur.at(i).at(j) = a_ur.at(i-1).at(j) + 1;
      } else if (j < w-1) {
        a_ur.at(i).at(j) = a_ur.at(i).at(j+1) + 1;
      }
    }
  }
  for (int i = h-1; i >= 0; i--) {
    for (int j = 0; j < w; j++) {
      if (a.at(i).at(j) == '#') {
        a_dl.at(i).at(j) = 0;
      } else if (i < h-1 && j > 0) {
        a_dl.at(i).at(j) = min(a_dl.at(i+1).at(j), a_dl.at(i).at(j-1)) + 1;
      } else if (i < h-1) {
        a_dl.at(i).at(j) = a_dl.at(i+1).at(j) + 1;
      } else if (j > 0) {
        a_dl.at(i).at(j) = a_dl.at(i).at(j-1) + 1;
      }
    }
  }
  for (int i = h-1; i >= 0; i--) {
    for (int j = w-1; j >= 0; j--) {
      if (a.at(i).at(j) == '#') {
        a_dr.at(i).at(j) = 0;
      } else if (i < h-1 && j < w-1) {
        a_dr.at(i).at(j) = min(a_dr.at(i+1).at(j), a_dr.at(i).at(j+1)) + 1;
      } else if (i < h-1) {
        a_dr.at(i).at(j) = a_dr.at(i+1).at(j) + 1;
      } else if (j < w-1) {
        a_dr.at(i).at(j) = a_dr.at(i).at(j+1) + 1;
      }
    }
  }
  vector<vector<int>> operation(h, vector<int>(w, 5000));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      operation.at(i).at(j) = min(operation.at(i).at(j), a_ul.at(i).at(j));
      operation.at(i).at(j) = min(operation.at(i).at(j), a_ur.at(i).at(j));
      operation.at(i).at(j) = min(operation.at(i).at(j), a_dl.at(i).at(j));
      operation.at(i).at(j) = min(operation.at(i).at(j), a_dr.at(i).at(j));
    }
  }
  int operations = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cerr << operation.at(i).at(j);
      operations = max(operations, operation.at(i).at(j));
    }
    cerr << endl;
  }
  cout << operations << endl;
}


Measured memory_bytes: 20992
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define all(a) a.begin(),a.end()
typedef pair<int,int> P;
const long long mod=1000000007;
const long long inf=1ll<<61;

vi G[200006];

signed main(){
    int n;cin>>n;
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=(n-i)*(i+1);
    }
    
    rep(i,n-1){
        int u,v;cin>>u>>v;
        if(u>v)swap(u,v);
        ans-=u*(n-v+1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8304
#include <stdio.h>

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

Measured memory_bytes: 596
while True:
    a,b = map(int,input().split())
    if a == 0 and b == 0 :
        break
    if a > b :
        c = b
        d = a
    elif a < b :
        c = a
        d = b
    else :
        c = a
        d = b
    print('{0} {1}'.format(c,d))
    
    
    


Measured memory_bytes: 5616
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <utility>
#include <map>
#include <queue>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;


int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    for(int i=0;i<n;i++)
        cin>>h[i];
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        if(h[i]>=k)
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}






Measured memory_bytes: 640
#include <stdio.h>

int main(void){
	int N[3];
	int work = 0;
	scanf("%d%d%d", &N[0], &N[1], &N[2]);
	for (int i = 0; i < 2; i++){
		if (N[0] > N[1]){
			work = N[0];
			N[0] = N[1];
			N[1] = work;
		}
		if (i == 0){
			if (N[1] > N[2]){
				work = N[1];
				N[1] = N[2];
				N[2] = work;
			}
		}
	}
	printf("%d %d %d\n", N[0], N[1], N[2]);

}

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;

int arr[maxn];

int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int sx, sy,tx,ty,dx=0,dy=0;
    cin >> sx >> sy >> tx >> ty;

    dx=tx-sx;
    dy=ty-sy;

    //Path 1
    for(int i=1 ; i<=dy ; i++) cout << "U";
    for(int i=1 ; i<=dx ; i++) cout << "R";

    //Path 2
    for(int i=1 ; i<=dy ; i++) cout << "D";
    for(int i=1 ; i<=dx ; i++) cout << "L";

    //Path 3
    cout << "L";
    for(int i=1 ; i<=dy+1 ; i++) cout <<"U";
    for(int i=1 ; i<=dx+1 ; i++) cout <<"R";
    cout << "D";

    //Path 4

    cout << "R";
    for(int i=1 ; i<=dy+1 ; i++) cout << "D";
    for(int i=1 ; i<=dx+1 ; i++) cout << "L";
    cout << "U";

    cout << endl;

    return 0;
}



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

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int n, m;
	vector<string> d;
	int ans = 0, minimum = INF;
	int we = 0, ee = 0;
	cin>>n>>m;
	
	d.resize(m);
	
	for(int i = 0; i < m; i++){
		cin>>d[i];
		for(int j = 0; j < n; j++){
			if(d[i][j] == 'W') ee++;
		}
	}
	
	for(int i = 0; i <= n; i++){
		
		if(minimum > we + ee){
			minimum = we + ee;
			ans = i;
		}
		
		if(i == n) continue;
		
		for(int j = 0; j < m; j++){
			if(d[j][i] == 'W') ee--;
			else we++;
		}
	}
	
	cout<<ans<<" "<<ans+1<<endl;
	return 0;
}


Measured memory_bytes: 4160
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string a;
	cin>>a;
	int se[n],sw[n];
	for(int i=0;i<n;i++){
		se[i]=0;
		sw[i]=0; 
	}
	if(a[0]=='E')
		se[0]=1;
	else
		sw[0]=1;
	for(int i=1;i<n;i++)
		if(a[i]=='E'){
			se[i]=se[i-1]+1;
			sw[i]=sw[i-1];
		}
		else{
			sw[i]=sw[i-1]+1;
			se[i]=se[i-1];
		}
	int minv=3000005;
	for(int i=0;i<n;i++){
		int sum=0;
		if(i==0)
			sum=se[n-1]-se[i];
		else if(i==n-1)
			sum=sw[n-2];
		else
			sum=sw[i-1]+(se[n-1]-se[i]);
		minv=min(minv,sum);
	}
	cout<<minv<<endl;
	return 0;
}

Measured memory_bytes: 3076
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////
#define R(i,n) for(int i=0;i<(n);++i)
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int A, B, C;
	cin >> A >> B >> C;
	cout << min(B / A, C) << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

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

using namespace std;

using ll = long long;

int INF = 1e9 + 5;

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

    int N, W;
    cin >> N >> W;
    
    vector<int> w(N), v(N);
    for(int i=0; i<N; ++i)
    {
        cin >> w[i] >> v[i];
    }
    
    vector<ll> dp(W+1,0);
    
    for(int i=0; i<N; ++i)
    {
        for(int j=W; j>=w[i]; --j)
        {
            dp[j] = max( dp[j] , v[i] + dp[j - w[i]]);
        }
        
        //for_each(begin(dp),end(dp),[](auto x){ cout << x << " ";}); cout << endl;
    }
    
    cout << dp[W];
    
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n;
ll x[2][100010];
ll vx[2][100010];

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

  cin>>n;
  rep(i,n){
    char c;
    cin>>x[0][i]>>x[1][i]>>c;
    if(c=='R')vx[0][i]=+1;
    if(c=='L')vx[0][i]=-1;
    if(c=='U')vx[1][i]=+1;
    if(c=='D')vx[1][i]=-1;
  }

  vector<double> cands;
  rep(k,2){
    {
      double lb=0,ub=1e9;
      rep(_,60){
        double T=(lb+ub)/2.0;
        ll idx=-1;
        double mn=1e18;
        rep(i,n){
          if((double)x[k][i]+(double)vx[k][i]*T<mn){
            mn=(double)x[k][i]+(double)vx[k][i]*T;
            idx=i;
          }
        }
        if(vx[k][idx]>0)lb=T;
        else ub=T;
      }
      cands.push_back((lb+ub)/2.0);
    }
    {
      double lb=0,ub=1e9;
      rep(_,60){
        double T=(lb+ub)/2.0;
        ll idx=-1;
        double mn=1e18;
        rep(i,n){
          if((double)x[k][i]+(double)vx[k][i]*T<mn){
            mn=(double)x[k][i]+(double)vx[k][i]*T;
            idx=i;
          }
        }
        if(vx[k][idx]>=0)lb=T;
        else ub=T;
      }
      cands.push_back((lb+ub)/2.0);
    }
    {
      double lb=0,ub=1e9;
      rep(_,60){
        double T=(lb+ub)/2.0;
        ll idx=-1;
        double mx=-1e18;
        rep(i,n){
          if((double)x[k][i]+(double)vx[k][i]*T>mx){
            mx=(double)x[k][i]+(double)vx[k][i]*T;
            idx=i;
          }
        }
        if(vx[k][idx]<0)lb=T;
        else ub=T;
      }
      cands.push_back((lb+ub)/2.0);
    }
    {
      double lb=0,ub=1e9;
      rep(_,60){
        double T=(lb+ub)/2.0;
        ll idx=-1;
        double mx=-1e18;
        rep(i,n){
          if((double)x[k][i]+(double)vx[k][i]*T>mx){
            mx=(double)x[k][i]+(double)vx[k][i]*T;
            idx=i;
          }
        }
        if(vx[k][idx]<=0)lb=T;
        else ub=T;
      }
      cands.push_back((lb+ub)/2.0);
    }
  }

  double res=1e18;
  rep(j,cands.size()){
    double xmn[2],xmx[2];
    rep(i,2)xmn[i]=1e18;
    rep(i,2)xmx[i]=-1e18;
    double T=cands[j];
    rep(i,n){
      rep(k,2){
        minch(xmn[k],(double)x[k][i]+(double)vx[k][i]*T);
        maxch(xmx[k],(double)x[k][i]+(double)vx[k][i]*T);
      }
    }
    minch(res,(xmx[0]-xmn[0])*(xmx[1]-xmn[1]));
  }
  printf("%.10f\n", res);

  return 0;
}


Measured memory_bytes: 3456
#include <climits>
#include <iostream>
#include <vector>


int main(void){
	int N, M, X, ans = INT_MAX;
	std::cin >> N >> M >> X;
	std::vector<int> c(N, 0);
	std::vector<std::vector<int>> A(N, std::vector<int>(M));

	for(int i = 0; i < N; i++){
		std::cin >> c[i];
		for(int j = 0; j < M; j++) std::cin >> A[i][j];
	}

	for(int i = 0; i < (1 << N); i++){
		std::vector<int> prof(M, 0);
		int c_cost = 0;
		for(int j = 0; j < N; j++){
			if(i & (1 << j)){
				c_cost += c[j];
				for(int k = 0; k < M; k++)
					prof[k] += A[j][k];
			}
		}	
		
		for(int j = 0; j < M; j++){
			if(prof[j] < X){
				c_cost = -1;
				break;
			}
		}
		if(c_cost > -1) ans = std::min(ans, c_cost);
	}
	if(ans == INT_MAX) ans = -1;

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


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
  long long a,b;
  cin >> a >> b;
  if ((a+b)%2==0) {
    cout << ((a+b)/2) << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}


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

stock = 0
rest  = 0
value = 1000

for i in range(1, n + 1):
    value = max(value, stock * a[i - 1] + rest)
    stock = value // a[i - 1]
    rest = value % a[i - 1]
print(value)

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

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


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
  int h,w;
  cin>>h>>w;
  char c[50][50];
  int mp[50][50]={0};
  int ans=0,cnt=0;
  rep(i,h){
    rep(j,w){
      cin>>c[i][j];
      if(c[i][j]=='.') cnt++;
    }
  }
  queue<pair<int,int> > q;
  mp[0][0]=1;
  q.push(make_pair(0,0));
  while(!q.empty()){
    pair<int,int> p;
    p=q.front();
    q.pop();
    rep(i,4){
      if(p.fst+dx[i]>=0 && p.fst+dx[i]<h  && p.scd+dy[i]>=0 && p.scd+dy[i]<w){
	if(c[p.fst+dx[i]][p.scd+dy[i]]=='.' && mp[p.fst+dx[i]][p.scd+dy[i]]==0){
	  mp[p.fst+dx[i]][p.scd+dy[i]]=mp[p.fst][p.scd]+1;
	  q.push(make_pair(p.fst+dx[i],p.scd+dy[i]));
	}
      }
    }
  }
  if(mp[h-1][w-1]!=0){
    cout<<cnt-mp[h-1][w-1]<<endl;
  }
  else cout<<-1<<endl;
    
  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long t=0;
    long n,d;
    cin>>n>>d;
    while(n--){
        long x=0,y=0;
        cin>>x>>y;
        if((x*x+y*y)<=d*d)
        t++;
    }
    cout<<t;
} 

Measured memory_bytes: 3636
import std;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
  int n = scan!int;
  long[] as = scan!long(n);
  as[] ^= as.fold!"a^b";
  as.unsplit.print;
}

Measured memory_bytes: 21256
(defn abs [x]
  (if (neg? x)
    (- x)
    x))

(-> (loop [lines (map #(clojure.string/split % #"\s")
                      (rest (line-seq (clojure.java.io/reader *in*))))
           [curr-t curr-x curr-y] [0 0 0]]
      (if-let [line (first lines)]
        (let [[t x y :as next-dest] (map #(Integer/parseInt %) line)
              d-t (- t curr-t)
              d-x (abs (- x curr-x))
              d-y (abs (- y curr-y))
              d-x+y (+ d-x d-y)]
          (if (zero? (mod d-t d-x+y))
            (recur (rest lines) next-dest)
            false))
        true))
    (if "Yes" "No")
    println)


Measured memory_bytes: 118252
import math
from decimal import *
import random

def pf(n):
    ans = [1]
    if(n%2==0):
        if(n!= 2):
            ans.append(2)
        while(n%2==0):
            n//=2
    p = 3
    while(n>1):
        if(n%p==0):
            ans.append(p)
            while(n%p==0):
                n//=p
        p+=1
    return ans

n = str(input())
tmp = 0
for i in range(len(n)):
    tmp+=int(n[i])
if(tmp%9==0):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 78452
#include<iostream>
#include<cstdio>
using namespace std;
const int N = 105;
struct info{
    int x, y, h;
}a[N];
template<class T>T Abs(T x){
    return x < 0 ? -x : x;
}
int main(){
    int n,t; cin >> n;
    for (int i = 1; i <= n; ++i){
        cin >> a[i].x >> a[i].y >> a[i].h;
        if(a[i].h) t = i;
    }
    for (int i = 0; i <= 100; ++i)
        for (int j = 0; j <= 100; ++j){
            int h = a[t].h + Abs(a[t].x - i) + Abs(a[t].y - j);
            bool flag = 1;
            for (int k = 1; k <= n; ++k)
                flag &= max(0, h - Abs(a[k].x - i) - Abs(a[k].y - j)) == a[k].h;
            if(flag)return cout << i << " " << j << " " << h << endl, 0;
        }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n,m,k;
  string str;
  cin>>n;m=n;
  int ans=0;
  while(n!=0){
    ans+=n%10;n/=10;
  }
  if(m%ans==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256