akhauriyash/Code-Regression huggingface dataset:
mod reader {
    use std::fmt::Debug;
    use std::str::FromStr;
    use std::collections::VecDeque;
    use std::io::{self, Read};

    fn _read_line() -> String {
        let mut buf = String::new();
        io::stdin().read_to_string(&mut buf);
        buf
    }

    fn _read_vec_deque_string() -> VecDeque<String> {
        _read_line().split_whitespace().map(|s| s.to_string()).collect()
    }

    pub struct Reader {
        buf: VecDeque<String>
    }

    impl Reader {
        pub fn new() -> Reader {
            Reader {buf: VecDeque::new()}
        }

        fn update_buf(&mut self) {
            if self.buf.is_empty() {
                self.buf = _read_vec_deque_string();
            }
        }

        pub fn next<T>(&mut self) -> T where T: FromStr, T::Err: Debug {
            self.update_buf();
            self.buf.pop_front().unwrap().parse::<T>().unwrap()
        }

        pub fn nextN<T>(&mut self, n: usize) -> Vec<T> where T: FromStr, T::Err: Debug {
            let mut vec: Vec<T> = Vec::with_capacity(n);
            for i in 0..n {
                vec.push(self.next());
            }
            vec
        }
    }
}

mod data {
    pub struct UnionFind {
        root : Vec<usize>
    }

    impl UnionFind {
        pub fn new(size : usize) -> UnionFind {
            UnionFind {root : (0..size).collect()}
        }

        pub fn find(&mut self, x : usize) -> usize {
            let xroot = self.root[x];
            if x != xroot {
                self.root[x] = self.find(xroot);
            }
            self.root[x]
        }

        pub fn unite(&mut self, x : usize, y : usize) {
            let xroot = self.find(x);
            self.root[xroot] = self.find(y);
        }

        pub fn same(&mut self, x : usize, y : usize) -> bool {
            self.find(x) == self.find(y)
        }
    }
}

fn with_large_stack(func : fn() -> ()) {
    use std::thread::Builder;
    let builder = Builder::new();
    let th = builder.stack_size(10000000);

    th.spawn(move || {
        func();
    }).unwrap().join();
}

fn main() {
    with_large_stack(_main);
}

fn _main() {
    let mut reader = reader::Reader::new();

    let n = reader.next();
    let a: Vec<i32> = reader.nextN(n);

    let mut b = vec![0; 9];
    for r in a {
        b[(std::cmp::min(r, 3200) / 400) as usize] += 1;
    }

    let mut cnt = 0;
    for i in 0..8 {
        cnt += std::cmp::min(b[i], 1);
    }

    println!("{} {}", std::cmp::max(cnt, 1), cnt + b[8]);
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector <vector<int>>;
using vvl = vector <vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll a = 1; a <= n; a++) {
    ll b_num = n / a;
    if (n % a == 0) b_num--;
    ans += b_num;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    int L, R, d;
    cin >> L >> R >> d;
    int cnt = 0;
    for (int x=L; x<=R; ++x) {
        if (x%d == 0) ++cnt;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int a,b,c;
int main(){
	cin>>a>>b>>c;
        cout<<a<<" "<<b<<" "<<-a-b+3*c<<endl;
        cout<<-2*a-b+4*c<<" "<<c<<" "<<2*a+b-2*c<<endl;
        cout<<a+b-c<<" "<<-b+2*c<<" "<<-a+2*c<<endl;
	return(0);
}

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

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

	bool flag = false;
	for (int i = 1; i <= 9; i ++) {
		if (a % i == 0 && a / i > 0 && a / i < 10) {
			flag = true;
			break;
		}
	}
	if (flag)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

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

// isDebug?
#ifndef ONLINE_JUDGE
#define _DEBUG
#endif

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// -* https://xn--kst.jp/blog/2019/08/29/cpp-comp/ *- Thx :)
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    cout << __FILE__ << ": " << __LINE__ << ": " << __func__ << " -> ";   \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

// namespace / type / class / struct - alias, def:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;
const int FACN = 510000;

// Global Variables:
// ll fac[FACN], finv[FACN], inv[FACN];

// Prototype Declarations:
int gcd(int, int);
int lcm(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int n, x, t;
    cin >> n >> x >> t;

    cout << n / x * t + (n % x ? t : 0) << endl;
    return 0;
}
// ===========================================

// Functions:
// 最大公約数 O(log(min(a, b)))
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
// 最小公倍数 O(log(min(a, b)))
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

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


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong(), w = sc.nextLong();

        if (h == 1 || w == 1) {
            System.out.println(1);
            return;
        }

        long base = h * w;

        if (base % 2 == 0) {
            System.out.println(base / 2);
            return;
        } else System.out.println(base / 2 + 1);
    }
}

Measured memory_bytes: 21460
n, c = map(int, input().split())
sushi = []
for i in range(n):
    x, v = map(int, input().split())
    sushi.append((x, v))
sushi.sort()
sushi_reversed = list(reversed([(c - x, v) for x, v in sushi]))


def accum_max(s):
    v = 0
    res = [(0, 0)]
    for x_i, v_i in s:
        v += v_i
        res.append(max(res[-1], (v-x_i, x_i)))
    return res[1:]


max_sushi = accum_max(sushi)
max_sushi_reversed = accum_max(sushi_reversed)


def solve(s, msr):
    v_max = 0
    v_2d_max = 0
    v = 0
    n = len(s)
    for i in range(n-1):
        x_i, v_i = s[i]
        v += v_i
        if v - x_i*2 > v_2d_max:
            v_2d_max = v - x_i*2
            v_sub = msr[n - 2 - i][0]
            v_max = max(v_max, v_2d_max + v_sub)
    return v_max


l = solve(sushi, max_sushi_reversed)
r = solve(sushi_reversed, max_sushi)
print(max(l, r, max_sushi[-1][0], max_sushi_reversed[-1][0]))


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

using namespace std;

typedef long double ld;
typedef long long ll;

const int M = 100100;

int n, m;
vector<int> a[M];

void read() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    a[x % m].push_back(x);
  }
  for (int i = 0; i < m; ++i)
    sort(a[i].begin(), a[i].end());
}

int cnt(vector<int> x) {
  map<int, int> c;
  for (int a : x)
    c[a]++;
  int ans = 0;
  for (auto p : c)
    ans += p.second / 2;
  return ans;
}

void kill() {
  int ans = 0;
  for (int i = 0; i <= m - i; ++i) {
    int j = (m - i) % m;
    if (i == j) {
      ans += a[i].size() / 2;
    } else {
      auto x = a[i];
      auto y = a[j];

      if (x.size() > y.size())
        swap(x, y);

      int xs = x.size();
      int ys = y.size();

      int t = cnt(y);

      ans += xs + min(t, (ys - xs) / 2);
    }
  }
  cout << ans << endl;
}

int main() {
#ifdef LOCAL
  assert(freopen("d.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  read();
  kill();

}



Measured memory_bytes: 5760
x, y = map(int, input().split())
 
a = [0, 300000, 200000, 100000, 0]
ans = 0
 
x = min(x, 4)
y = min(y, 4)
 
ans = a[x] + a[y]
if x == 1 and y == 1:
    ans += 400000
 
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
const int INF=0x3f3f3f3f;
int main(int argc, char *argv[]) {
	ll n,a,b,sum=0,m=INF;
	bool f=0;
	cin>>n;
	while (n--){
		cin>>a>>b;
		sum+=b;
		if (b<a && m>b)
			m=b;
		if (b!=a) f=1;
	}
	if (f) cout<<sum-m<<endl;
	else cout<<"0"<<endl;
	return 0;
}

Measured memory_bytes: 256
# input
A = int(input())
B = int(input())
C = int(input())
X = int(input())

# check
if X % 100 == 50 and C == 0:
    print(0)
else:
    all_case = len(
        [
            1
            for a in range(A + 1)
            for b in range(B + 1)
            for c in range(C + 1)
            if 500 * a + 100 * b + 50 * c == X
        ]
    )

    print(all_case)

Measured memory_bytes: 9152
#include <stdio.h>
main(){
	
	int a,b,c,x;
	
	scanf("%d%d%d",&a,&b,&c);
	
	if(a>b){
		x=a;
		a=b;
		b=x;
	}
	
	if(b>c){
		x=b;
		b=c;
		c=x;
	}
	if(a>b){
		x=a;
		a=b;
		b=x;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
#include <cstdio>
int main(){
    int in; 
    int h=0; 
    int m=0; 
    int s=0; 

    scanf("%d",&in);

    while(in>=3600){
    in -= 3600;
    h++;
    }

    while(in>=60){ 
    in -= 60;
    m++;
    }

    s = in;

    printf("%d:%d:%d\n",h,m,s);
}


Measured memory_bytes: 2740
$N=<>;
@a=glob<>;
while(grep$_>=$N,@a){
	$s=0;
	$a[$_]-=$N*($b[$_]=$==$a[$_]/$N),$s+=$=for 0..$N-1;
	$a[$_]+=$s-$b[$_]for 0..$N-1;
	$%+=$s
}
print$%


Measured memory_bytes: 768
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
const int N=1e6+10;
int n,tot;
int a[N];
int prime[N],vis[N],cnt[N];
int gcd(int a,int b)
{
    return b?gcd(b,a%b):a;
}
void Euler()
{
    vis[1]=1;
    for(int i=2;i<N;++i)
    {
        if(vis[i]==0)
            prime[++tot]=i;
        for(int j=1;j<=tot&&i*prime[j]<N;++j)
        {
            vis[i*prime[j]]=1;
            if(i%prime[j]==0)
                break;
        }
    }
}
int main(void)
{
    sync;
    cin>>n;
    Euler();
    for(int i=0;i<n;++i)
        cin>>a[i];
    bool f1=true;
    int g=a[0];
    for(int i=0;i<n;++i)
    {
        g=gcd(g,a[i]);
        int aa=a[i];
        for(int j=1;j<=tot;++j)
        {
            if(!vis[aa])
            {
                if(cnt[aa])
                    f1=false;
                ++cnt[aa];
                break;
            }
            if(aa%prime[j]==0)
            {
                if(cnt[prime[j]])
                    f1=false;
                ++cnt[prime[j]];
                while(aa%prime[j]==0)
                {
                    aa/=prime[j];
                }
            }
            if(aa==1)
                break;
        }
    }
    if(f1)
        cout<<"pairwise coprime"<<endl;
    else
    {
        if(g==1)
            cout<<"setwise coprime"<<endl;
        else
            cout<<"not coprime"<<endl;
    }
    return 0;
}

Measured memory_bytes: 15028
#include<bits/stdc++.h>
using namespace std;
#define mod 10000007
#define ff first
#define ss second
#define ll long long
#define int long long
#define pii pair<ll,ll>
#define vi vector<ll>
#define mii map<ll,ll>
#define pb push_back
#define mp make_pair
#define sp(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w(x) ll x; cin>>x; while(x--)
#define endl '\n'
#define str string
#define all(v) v.begin(),v.end()
void kehsihba() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
	//kehsihba();
	ll a,b,x;
	cin>>a>>b>>x;
	if(a==b){
		if(a%x==0){
			cout<<1;
		}
		else{
			cout<<0;
		}
	}
	else{
		ll m=a%x;
		if(m)
			a+=(x-m);
		ll n=b%x;
		if(n)
			b-=(n);
		cout<<((b-a)/x)+1;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
ll A[5000001],bin[5000001];
vector<string>v;
map<int,int>myMap;
set<int>mySet;
vector<pair<ll,ll> >v2;
/*void bti(ll n)
{
ll k=1;
  while(n!=0)
    {
    bin[k++]=n%2;
    n/=2;
    }
}*/
/*void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}*/
int main()
{
    ll index=0;
    v.push_back("Sunny");
     v.push_back("Cloudy");
      v.push_back("Rainy");
   string s;
   cin>>s;
   for(int i=0;i<v.size();i++)
   {
       if(v[i]==s)
        index=i;
   }
   index++;
   if(index==3)
    index=0;
   cout<<v[index]<<endl;
return 0;
}


Measured memory_bytes: 256
L,R = map(int, input().split())

def repeat_division(n):
    while True:
        if n < 2019:
            break
        n %= 2019
    return n

l = repeat_division(L)
r = repeat_division(R)

if R - L  >= 2019:
    print(0)
elif l > r:
    print(0)
else:
    min = 2019
    for k in range(l, r):
        for i in range(k+1,r+1):
            if min > repeat_division(k * i):
                min = repeat_division(k * i)
    print(min)


Measured memory_bytes: 3060
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    int n;cin>>n;

    LL result = 0;
    int start_b=0;
    int end_a=0;
    int both=0;
    REP(i,n){
        string s;cin>>s;
        int len = SIZE(s);
        REP(j,len-1){
            if(s[j]=='A' && s[j+1]=='B'){
                result++;
            }
        }
        if(s[0]=='B'&&s[len-1]=='A'){
            both++;
        }
        if(s[0]=='B'){
            start_b++;
        }
        if(s[len-1]=='A'){
            end_a++;
        }
    }
    result += min(start_b,end_a);
    if(both!=0 && both==start_b && start_b==end_a){
        result--;
    }

    cout<<result<<endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,m;
	cin>>n>>m;
	if(m/2<=n){
		cout<<m/2;
	}else if(n<m/2){
		m-=n*2;
		cout<<n+m/4;
	}
	return 0;
}


Measured memory_bytes: 256
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    S = input()
    K = int(input())

    S = [s for s in S]
    D = [ord('z') - ord(s) + 1 if s != 'a' else 0 for s in S]
    T = []
    for s, d in zip(S, D):
        if d <= K:
            T.append('a')
            K -= d
        else:
            T.append(s)

    c = ord(T[-1])
    for _ in range(K):
        if c == ord('z'):
            c = ord('a')
        else:
            c += 1
    T[-1] = chr(c)

    print(''.join(T))


if __name__ == '__main__':
    main()


Measured memory_bytes: 52400
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

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

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};


int main(){
    CIN(H);CIN(W);
    V<string> vec;
    REP(a,H){
       string s;
       cin >>s;
       vec.pb(s);
    }
    REP(a,W+2){
        cout<<"#";
    }
    cout<<endl;
    REP(a,H){
        cout<<"#";
        cout<<vec.at(a);
        cout<<"#";
        if(a!=H-1)cout<<endl;
    }
    cout<<endl;
    REP(a,W+2){
        cout<<"#";
    }
    return 0;
}


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

using namespace std;

#define int long long

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

  int n;
  cin >> n;

  vector<int> a(n+1);

  for (int i = 0; i <= n; i++) {
    cin >> a[i];
  }

  vector<int> maxi(n+1);
  vector<int> mini(n+1);

  maxi[n] = a[n];
  mini[n] = a[n];

  for (int i = n-1; i >= 0; i--) {
    maxi[i] = maxi[i+1] + a[i];
    mini[i] = (mini[i+1] + 1)/2 + a[i];
  }

  if (mini[0] > 1) {
    cout << "-1\n"; return 0;
  }
  if (maxi[0] < 1) {
    cout << "-1\n"; return 0;
  }

  vector<int> actual(n+1);
  actual[0] = 1;
  int tot = 1;

  for (int i = 1; i <= n; i++) {
    actual[i] = min(maxi[i], (actual[i-1] - a[i-1]) * 2);
    tot += actual[i];
  }

  cout << tot << "\n";
}


Measured memory_bytes: 6352
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

 
int vector_finder(std::vector<int> vec, int number) {
  size_t index = std::distance( vec.begin(), std::find(vec.begin(), vec.end(), number) );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}



int N;

int main()
{
	cin >> N;
	int x[N], y[N], h[N];
	REP(i,N){
		cin >> x[i] >> y[i] >> h[i];
	}
	int cx, cy,H;
	int HH;
	REP(i, 101)
	{
		REP(j,101){
			REP(k,N){
				if(h[k]>0){
					HH = h[k] + abs(x[k] - i) + abs(y[k] - j);
				}
			}
			bool flag = true;
			REP(k, N)
			{
					if(h[k]!=max(HH-abs(x[k] - i) - abs(y[k] - j),0)){
						flag = false;
					}
			}
			if(flag){
				H = HH;
				cx = i;
				cy = j;
			}
		}
	}

	cout << cx<<" " << cy <<" "<< H << endl;
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define pb push_back

using namespace std;

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

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

void solve() {

}

int main() {
  int n;
  cin >> n;
  vector<int> A(n+1), B(n);
  rep(i,n+1) cin >> A[i];
  rep(i,n) cin >> B[i];
  ll sum = 0;
  rep(i,n) {
    int mini = min(A[i],B[i]);
    A[i] -= mini;
    B[i] -= mini;
    sum += mini;
    if( B[i] >= 0 )  {
      mini = min(A[i+1],B[i]);
      A[i+1] -= mini;
      B[i]   -= mini;
      sum += mini;      
    }
  }
  cout << sum << endl;
  return 0;
}


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

using namespace std;
#define         MAX         1000000
#define         ll          long long
#define         input       freopen("input.txt","r",stdin)
#define         output      freopen("output.txt","w",stdout)

ll sum = 0;
ll arr[300] = {1,9,30,76,141,267,400,624,885,1249,1590,2208,2689,3411,4248,5248,6081,7485,8530,10248,11889,
13687,15228,17988,20053,22569,25242,28588,31053,35463,38284,42540,46581,50893,55362,61824,65857,71247,76884,
84388,89349,97881,103342,111528,120141,128047,134580,146316,154177,164817,174438,185836,194157,207927,218812,
233268,245277,257857,268182,288216,299257,313635,330204,347836,362973,383709,397042,416448,434025,456967,471948,
499740,515581,536073,559758,583960,604833,633651,652216,683712,709065,734233,754734,793188,818917,846603,874512,
909496,933081,977145,1006126,1041504,1073385,1106467,1138536,1187112,1215145,1255101,1295142,1342852,1373253,1422195,
1453816,1502376,1553361,1595437,1629570,1691292,1726717,1782111,1827492,1887772,1925853,1986837,2033674,2089776,2145333,
2197483,2246640,2332104,2379085,2434833,2490534,2554600,2609625,2693919,2742052,2813988,2875245,2952085,3003306,3096024,
3157249,3224511,3306240,3388576,3444609,3533637,3591322,3693924,3767085,3842623,3912324,4027884,4102093,4181949,4270422,4361548,
4427853,4548003,4616104,4718640,4812789,4918561,5003286,5131848,5205481,5299011,5392008,5521384,5610705,5739009,5818390,5930196,
6052893,6156139,6239472,6402720,6493681,6623853,6741078,6864016,6953457,7094451,7215016,7359936,7475145,7593865,7689630,7886244,
7984165,8130747,8253888,8403448,8523897,8684853,8802826,8949612,9105537,9267595,9376656,9574704,9686065,9827097,9997134,10174780,
10290813,10493367,10611772,10813692};
int main() {

    int n;

    cin>>n;
    cout<<arr[n-1]<<endl;

    return 0;
}


Measured memory_bytes: 3672
//in the name of allah the most gracious the most merciful
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast","unroll-loops")
#define int long long
#define pb push_back
#define fi  first
#define rep(i,n)  for(int i=0;i<n;i++)//looping 
#define rep1(i,n) for(int i=1;i<=n;i++)  
#define se  second
#define endl '\n'
#define PB pop_back
#define PF pop_front
#define pf push_front
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define ld long double 
const double PI = acos(-1);
const double e = exp(1);
const int MAXN = 2e5+100;
using namespace std;
bool check(string s ){
    int n = s.size(); 
    for(int i=0;i<n/2;i++){
        if(s[i] != s[n-1-i]) return 0 ; 
    }
    return 1 ;
}
void solve(){
    string s ; 
    cin>>s;
    if(!check(s)){
        cout << "No";
        return ; 
    }
    int n = s.size();
    string fs ,ss ; 
    for(int i=0;i<(n-1)/2;i++){
        fs+=s[i]; 
    }
    for(int i=(n+3)/2-1;i<n;i++) ss += s[i]; 
    if(check(fs) && check(ss)){
        cout << "Yes"; 
    }
    else cout << " No";
    return ;
}
signed main ()
{
    int t=1; 
    
    while(t--){
        solve(); 
        cout << endl;
    }
    return 0 ; 
}   

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}
int n,d;
double p[15][15];
double dist(int i,int j){
	double s=0.0;
	rep(k,d)s+=(p[i][k]-p[j][k])*(p[i][k]-p[j][k]);
	return sqrt(s);
}
void solve(){
	cin>>n>>d;
	rep(i,n)rep(j ,d)cin>>p[i][j];
	int res=0;
	rep(i,n){
		for(int j=0;j<i;j++){
			double s=dist(i,j);
			if(s-(ll)s<1e-18)res++;
		}
	}
	cout<<res;
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    ll n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll ret = 0;
    for (int i = 0; i < n; i++)
    {
        ll left = 0, cnt = 0;
        for (int j = 0; j < i; j++)
        {
            if (a[j] > a[i])
                left++;
        }
        for (int j = 0; j < n; j++)
        {
            if (a[j] > a[i])
                cnt++;
        }
        ll sum = k * (k - 1) / 2 % MOD;
        sum = sum * cnt % MOD;
        ret += sum + k * left % MOD;
        ret %= MOD;
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

int main()
{
	ll X;
	scanf("%lld", &X);
	
	ll happiness = 0;
	
	ll a = X / 500;
	X -= a * 500;
	happiness += a * 1000;
	
	ll b = X / 5;
	happiness += b * 5;
	
	printf("%lld\n", happiness);
	
	return 0;
}

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

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

  vector<int> p; 
  for ( int i = 0; i < n; ) {
    if ( s[i] == '0' ) {
      p.push_back(i);
      while ( i < n && s[i] == '0' ) { i++; }
    }
    if ( s[i] == '1' ) {
      p.push_back(i);
      while ( i < n && s[i] == '1' ) { i++; }
    }
  }
  
  int ans = 0;
  for ( int i = 0; i < p.size(); i++ ) {
    int cur_len = 0;;
    if ( s[p[i]] == '0' ) {
      cur_len = ( i + 2*k < p.size() ) ? p[i+2*k]-p[i] : n-p[i];
    } else {
      cur_len = ( i+1 + 2*k < p.size() ) ? p[i+1+2*k]-p[i] : n-p[i];
    }
    ans = max(ans, cur_len);
  }

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

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

ll n, ans, h[M], val[M], f[M];

ll get(ll x){
    ll res = 0;
    for (; x > 0; x -= x&(-x)) res = max(res, f[x]);
    return res;
}

void update(ll x, ll v){
    for (; x <= n; x += x&(-x)) f[x] = max(v, f[x]);
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> h[i];
    for (int i = 1; i <= n; i++) cin >> val[i];
    for (int i = 1; i <= n; i++){
        ll k = get(h[i]) + val[i];
        ans = max(ans, k);
        update(h[i], k);
    }
    cout << ans;
    return 0;
}

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

using namespace std;

int main(){
	int a, b; cin >> a >> b;
	if(b == 1){
		cout << 0 << endl;
		return 0;
	}
	int ans = 1;
	b -= a;
	while(b > 0){
		ans++;
		b -= (a-1);
	}
	cout << ans << endl;
}

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"

constexpr long long INF = (long long)1e18;
constexpr 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, K, S;
	int temp = 100'0000'000;
	
	cin>>N>>K>>S;
	if(S < temp) {
		for(int i = 0; i < N; i++){
			if(i) cout<<" ";
			if(i < K) cout<<S;
			else cout<<temp;
		}
		cout<<endl;
	} else {
		for(int i = 0; i < N; i++){
			if(i) cout<<" ";
			if(i < K) cout<<S;
			else cout<<temp-1;
		}
		cout<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 1280
#include<cstdio>
#include<vector>
using namespace std;
#define MAX 2000

int n,m,h,k;
int t[MAX][MAX];
int change[MAX];
int u[MAX];
vector<int> G[MAX],A,B;

void compute(){
  for(int i=0;i<n;i++)t[h][i]=i;
  for(int i=h-1;i>=0;i--){
    for(int j=0;j<n;j++)t[i][j]=t[i+1][j];
    for(int j=0;j<(int)G[i].size();j++){
      int w=G[i][j];
      A.push_back(t[i][w]);
      B.push_back(t[i][w+1]);
      swap(t[i][w],t[i][w+1]);
    }
  }
}

void solve(){  
  compute();
  int mini=0;
  for(int i=0;i<k;i++)mini+=u[t[0][i]];
  for(int i=0;i<(int)A.size();i++){
    swap(u[A[i]],u[B[i]]);
    int sum=0;
    for(int j=0;j<k;j++) sum+=u[t[0][j]];
    mini=min(mini,sum);
    swap(u[A[i]],u[B[i]]);
  }
  printf("%d\n",mini);
}

void init(){
  A.clear();
  B.clear();
  for(int i=0;i<MAX;i++)G[i].clear();
}

int main(){
  while(1){
    scanf("%d %d %d %d",&n,&m,&h,&k);
    if(n==0&&m==0&&h==0&&k==0)break;
    h--;
    init();
    for(int i=0;i<n;i++)scanf("%d",&u[i]);
    for(int i=0;i<m;i++){
      int a,b;
      scanf("%d %d",&a,&b);
      a--,b--;
      G[b].push_back(a);
    }
    solve();
  }
  return 0;
}

Measured memory_bytes: 10628
n = int(input())
a = [int(i) for i in input().split()]

kotae = 1
for i in range(n):
    if(kotae == -1):
        if(a[i] == 0):
            kotae = 0
    else:
        kotae *= a[i]
    if(kotae > 10 ** 18):
        kotae = -1

print(kotae)

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define fout(x) cout << fixed << setprecision(10) << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

auto print = [](auto &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
};

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  VI ans(n, -1);
  bool flag = true;
  rep(i, m) {
    int s, c;
    cin >> s >> c;
    s--;
    if(ans[s] != -1 && ans[s] != c) flag = false;
    ans[s] = c;
  }
  if (ans[0] == -1 && n != 1) ans[0] = 1;
  if(ans[0] == -1 && n == 1) ans[0] = 0;
  if(flag && (ans[0] != 0 && n != 1 || n == 1)) {
    rep(i, n) {
      if(ans[i] != -1) cout << ans[i];
      else cout << 0;
    }
    cout << endl;
  }
  else out(-1);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;
template<typename T> T factorial(T n){
    if(n==1) return 1;
    else return n*factorial(n-1)%MOD;
}
template<typename T> T Pow(T x, T n, T m){
    if(n == 0) return 1;
    if(n % 2 == 0) return Pow(x * x % m, n / 2, m);
    else return x * Pow(x, n - 1, m) % m;
}
template<typename T> T combination(T n, T k, T m){
    return factorial<T>(n) * Pow<T>(factorial(k), m-2, m) % m * Pow<T>(factorial(n-k), m-2, m) % m;
}
struct edge{
    int to; // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using graph = vector<vector<edge>>;
using Graph = vector<vector<int>>;

int main(){
    ll n, m; cin >> n >> m;
    ll ans = 0;
    if(n >= 2) ans += n*(n-1)/2;
    if(m >= 2) ans += m*(m-1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!ruby -pl
l=$_.split(?,).map &:to_i
v=l.zip(l.rotate(2)).map{|a,b|b-a}.each_slice(2).to_a
z=v.zip(v.rotate).map{|(a,b),(c,d)|a*d-b*c}
$_=z.all?{|i|i>0}||z.all?{|i|i<0}?:YES: :NO

Measured memory_bytes: 6116
def A():
    temp = input().split()
    S = temp[0]
    T = temp[1]
    temp = [int(i) for i in input().split()]
    A = temp[0]
    B = temp[1]
    U = input()
    if U == S:
        print(A-1, B)
    else:
        print(A, B-1)

A()

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

const int N = 205;
const int mod = 998244353;

struct Point {
	int x; int y;
} a[N];

long long cross(Point O, Point A, Point B) {
	A.x -= O.x; A.y -= O.y; B.x -= O.x; B.y -= O.y;
	return 1LL * A.x * B.y - 1LL * A.y * B.x;
}

void add(int &x, int y) {
	x += y; while(x >= mod) x -= mod; while(x < 0) x += mod;
}

int n;
int ans;
int pow2[N];
int cnt[10005];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d%d", &a[i].x, &a[i].y);
	}

	pow2[0] = 1; for (int i = 1; i <= n; ++i) pow2[i] = 2LL * pow2[i - 1] % mod;

	// line y = a
	for (int i = 1; i <= n; ++i) cnt[a[i].y]++;
	for (int y = 0; y < 1e4; ++y) add(ans, pow2[cnt[y]] - 1);

	// line: ax + b = y with a != 0
	for (int pivot = 1; pivot <= n; ++pivot) {
		vector<Point> v;
		for (int i = 1; i <= n; ++i) {
			if (a[i].y > a[pivot].y) v.push_back(a[i]);
		}
		sort(v.begin(), v.end(), [&](Point p, Point q) {
			return cross(a[pivot], p, q) > 0;
		});

		for (int i = 0; i < v.size(); ) {
			int j = i + 1;
			while(j < v.size() && cross(a[pivot], v[i], v[j]) == 0) ++j;

			add(ans, pow2[j - i] - 1);
			i = j;
		}
	}

	ans = pow2[n] - 1 - ans;
	while (ans < 0) ans += mod;

	printf("%d\n", ans);
}

Measured memory_bytes: 256
n, q = map(int, input().split())
node = [[] for _ in range(n)]
ans = [0] * n

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

for _ in range(q):
    p, x = map(int, input().split())
    p -= 1
    ans[p] += x

not_yet = [True] * n
not_yet[0] = False
stack = [0]
while stack:
    parent = stack.pop()
    for child in node[parent]:
        if not_yet[child]:
            ans[child] += ans[parent]
            not_yet[child] = False
            stack.append(child)

print(*ans)


Measured memory_bytes: 55856
#include <bits/stdc++.h>
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
typedef long long ll;
using namespace std;
#define pii pair<int, int>
#define fi first
#define sc second

int main(){
    int n;
    cin >> n;
    
    ll ans = 0;
    rep2(i, 1, n+1){
        rep2(j, 1, n+1){
            if(i*j<n)ans++;
            if(i*j>=n)break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <ctime>
#include <climits>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <utility>
#include <cstdlib>

using namespace std;
long int pow107 = (int)pow(10, 9) + 7;
int ilimit = INT_MAX;
long int llimit = LONG_MAX;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

int Func2(int n,int m){
    long int s2 = 1,
        r = 1;


    for(int i = 1; i <= m; ++i){
        s2 = (s2*(n - (i - 1))/i) % pow107;
    }

    return s2;
}

//long intの最大llimit
//intの最大ilimit
//10^9+7    pow107
//素数pn
//n乗jou
//階乗factorial
//コンビネーションFunc2

int main(){
    string s,si;
    cin >> s;
    int c = 1;
    for(int i = s.size() / 2 - 1; i >= 0  ; --i){
        for(int j = 0; j <= i ; ++j){
            si += s[j];
        }
        int l = s.find(si,i + 1);
        //cout << si << " " << i << " " << l << endl;
        if(l == i + 1 && l * 2 <= s.size() - c){
            cout << l * 2 << endl;
            return 0;
        }
        c++;
        si = "";
    }
}

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

using namespace std;

long long n, mx;

map<long long, long long> mp, m;

vector<long long> v;


int main() {
    cin >> n;
    v.resize(2);
    for (int i = 0; i < n; ++i) {
        long long x;
        cin >> x;
        mx = max(mx, x);
        mp[x]++;
        if (mp[x] >= 2 && !m[x]) {
            v.push_back(x);
            m[x] = 1;
        }
    }
    if (mp[mx] >= 4) {
        cout << mx * mx;
        return 0;
    }
    sort(v.rbegin(), v.rend());
    cout << v[0] * 1ll * v[1];
}


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long K = sc.nextLong();
		if (A >= K) {
			System.out.print((A - K) + " " + B);
		} else if (A + B > K) {
			System.out.print(0 + " " + (B - K + A));
		} else {
			System.out.print(0 + " " + 0);
		}
	}
}

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

int A[1000000], n;

/* 二部探索 */
int binarySearch(int key) {
    int left = 0;
    int right = n;
    int mid;
    while (left < right) {
        mid = (left + right) / 2;
        if (key == A[mid]) return 1;    /* keyを発見 */
        if (key > A[mid]) left = mid + 1;   /* 後半を探索 */
        else if (key < A[mid]) right = mid; /* 前半を探索 */
    }
    return 0;
}

int main() {
    int i, q, k, sum=0;

    cin >> n;
    for (i=0; i<n; i++) cin >> A[i];
    cin >> q;
    for (i=0; i<q; i++) {
        cin >> k;
        if (binarySearch(k)) sum++;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3476
#include <bits/stdc++.h>
#define INF 1023456789
#define sacnf scanf
#define CRLF <<'\n';
#define PRPAIR(x) x.first << x.second
#define DEBUG(x) do { std::cerr <<(x)<<'\n'; } while (0)
#define rep(i,a,b) for(int i=(a);i!=(int)b-((a)>(b));(a)>(b)?--i:++i)
#define trav(it,v) for(typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> pip;
typedef vector<int> vi;
typedef long long ll;
#define MAX_N 200005

char s[MAX_N],t[MAX_N];


int main(){
    scanf("%s%s",s,t);
    int n = strlen(s);
    int c=0;
    rep(i,0,n){
        if (s[i] != t[i])
            c++;
    }
    cout << c;

}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
int N,M;
int main(){
    cin>>N>>M;
    string a[N],b[M];

    for(int i=0;i<N;i++) cin>>a[i];
    for(int i=0;i<M;i++) cin>>b[i];

    for(int i=0;i<N-M+1;i++){
        for(int j=0;j<N-M+1;j++){
            if(a[i][j]==b[0][0]){
                for(int k=0;k<M;k++){
                    for(int l=0;l<M;l++){
                        if(a[i+k][j+l]!=b[k][l]){
                            goto A;
                        }
                    }
                }
                cout<<"Yes"<<"\n";
                return 0;
            }
            A:;
        }
    }
    cout<<"No"<<"\n";
    return 0;
}



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

using namespace std;

int main()
{
    long long int balance = 100;
    long long int x;
    int years = 0;
    double j = 0.01;
    cin >> x;

    while (balance < x)
    {
        balance += balance*j;
        years++;   
        
    }

    cout << years << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define X first
#define Y second
#define fw(i, start, end) for (ll i = start; i < end; ++i)
#define fe(i, start, end) for (ll i = start; i <= end; ++i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define endl "\n"
#define mem(a, i) memset(a, i, sizeof(a))
int main()
{
    FASTIO
 long   double n, m;
    cin >> n >> m;
    cout << (ll)((n * m)+0.001) << endl;

    return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define int ll


signed main(){
    int N;
    int A[114514];
    int B[114514]={};
    cin >> N;
    REP(i,N){
        cin >> A[i];
    }
    sort(A,A+N);
    B[0]=A[0];
    REP(i,N-1){
        B[i+1]=B[i]+A[i+1];
    }
    int Ans=1;
    RREP(i,N-1){
        if(2*A[i]>=A[i+1]){
            Ans++;continue;
        }
        if(2*B[i]<A[i+1]){
            break;
        }
      Ans++;
    }
    cout << Ans << endl;
    
    return 0;
}   


Measured memory_bytes: 1920
#include <stdio.h>
#include <string.h>
int main(){
  int i,n;
  char str[20];
  scanf("%s",str);
  n=strlen(str);
  for(i=n-1;i>=0;i--){
    printf("%c",str[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 524
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int[] p = new int[n];
    for(int i=0; i<n; i++){
      p[i] = Integer.parseInt(sc.next());
    }

    int ans = 0;
    for(int i=0; i<n-2; i++){
      if((p[i]-p[i+1])*(p[i+2]-p[i+1]) < 0){
        ans++;
      }
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Int32;
using static System.Math;
using System.Numerics;

class Program
{

    static void Main(string[] args)
    {
        label:
        var sp = ReadLine().Split();
        int n = Parse(sp[0]);
        int t = Parse(sp[1]);
        int? result = null;
        for(int i = 0; i < n; ++i)
        {
            sp = ReadLine().Split();
            if (Parse(sp[1]) <= t)
            {
                int tmp = Parse(sp[0]);
                if (!result.HasValue || tmp < result) result = tmp;
            }
        }
        WriteLine(result.HasValue ? result.Value.ToString() : "TLE");
    }
}


Measured memory_bytes: 11092
n, q = map(int, input().split())
s = list(input())

l = [0]
ll = []
count = 0

for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
        count += 1
    l.append(count)


for i in range(q):
    array = list(map(int, input().split()))
    ll.append(array)

for i in range(q):
    print(l[ll[i][1]-1] - l[ll[i][0]-1])



Measured memory_bytes: 31388
import bisect
n, d, a = map(int, input().split())
XH = sorted([list(map(int, input().split())) for _ in range(n)])
X, H = zip(*XH)
K = [-(-i//a) for i in H]
L = [0]*(n+2)
ans = 0
for i in range(n):
  L[i+1] += L[i]
  s = max(K[i]-L[i+1], 0)
  ans += s
  L[i+1] += s
  L[bisect.bisect_right(X, X[i]+2*d)+1] -= s
print(ans)

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

using namespace std;

#define ll long long

int main() {
    cin.tie();
    ios_base::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    
    if (a >= 10) cout << b; else cout << b + 100 * (10 - a);
    return 0;
}

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

int main() {
	int n;
  	cin >> n;
  	vector <pair <int, int> > v;
  	for ( int i = 0; i < n; ++i ) {
      	int x;
      	cin >> x;
      	v.push_back({x, i+1});
    }
  	sort(v.begin(), v.end());
  	for ( int i = 0; i < v.size(); ++i ) {
      	cout << v[i].second;
      	if ( i != v.size() - 1 ) cout << ' ';
    }
  	cout << endl;
	return 0;
}

Measured memory_bytes: 1780
program ubiquity
  implicit none
  integer(8), parameter :: modu = 1000000007
  integer :: n
  read(*,*) n
  write(*,'(i0)') modulo(pow(10_8, n) - pow(9_8, n) * 2 + pow(8_8, n), modu)
contains
  integer(8) function pow(a, n) result(res)
    integer(8), intent(in) :: a
    integer, intent(in) :: n
    integer(8) :: b
    integer :: m
    res = 1
    b = a
    m = n
    do while (m > 0)
      if (btest(m, 0)) res = mod(res * b, modu)
      b = mod(b * b, modu)
      m = rshift(m, 1)
    end do
  end
end program ubiquity

Measured memory_bytes: 2908
#include <bits/stdc++.h>
using namespace std;
long long dp[500005],fish,Ans[500005];
int nex[500005],las[500005],Arrive[500005],Con,N;
vector <long long> Son[100005],Sum[100005],Suf[100005];
void jt(int x,int y)
{
	Con++;
	nex[Con]=las[x];
	las[x]=Con;
	Arrive[Con]=y;
}
void dfs(int Now,int fa)
{
	dp[Now]=1;int cnt=0;
	for (int i=las[Now];i;i=nex[i])
	  {
	  	if (Arrive[i]!=fa)
	  	{
	  	  dfs(Arrive[i],Now);
	  	  cnt++;
		  dp[Now]=dp[Now]*(dp[Arrive[i]]+1)*1ll%fish;
		  Son[Now].push_back(Arrive[i]);
		  Suf[Now].push_back(0);
		  Sum[Now].push_back(0);
	    }
    }
    for (int i=0;i<cnt;i++)
     {
     	if (i==0) Sum[Now][i]=1;else Sum[Now][i]=Sum[Now][i-1];
     	Sum[Now][i]=Sum[Now][i]*1ll*(dp[Son[Now][i]]+1)%fish;
	 }
	for (int i=cnt-1;i>=0;i--)
	  {
	  	if (i==cnt-1)
	  	Suf[Now][i]=1;
	  	else Suf[Now][i]=Suf[Now][i+1];
	  	Suf[Now][i]=Suf[Now][i]*1ll*(dp[Son[Now][i]]+1)%fish;
	  }
}
void Change(int u,long long v)
{
	Ans[u]=dp[u]*1ll*(v+1)%fish;
	for (int i=Son[u].size()-1;i>=0;i--)
	{
		int Arr=Son[u][i];
		Change(Arr,((i==0)?1:Sum[u][i-1])*1ll*((i==(Son[u].size()-1))?1:Suf[u][i+1])%fish*(v+1)%fish);
	}
}
int main()
{
	scanf("%d%lld",&N,&fish);
	for (int i=1;i<N;i++)
	 {
	 	int x,y;
	 	scanf("%d%d",&x,&y);
	 	jt(x,y);
	 	jt(y,x);
	 }
	dfs(1,0);
	Change(1,0);
	for (int i=1;i<=N;i++)
	  printf("%lld\n",Ans[i]%fish);
	return 0;
}

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

#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1

using namespace std;

inline int mod(int n){ return (n%1000000007); }

int gcd(int a, int b){
  if(a == 0 || b == 0) return 0;
  if(b == 1) return b;
  else return gcd(b, a%b);
}

int32_t main(){
	DESYNC;
	int n;
	int ans = 0;
	cin >> n;
	int v[n];
	for(int i=0; i<n; i++){
	  cin >> v[i];
	}
	int color = -1;
	int qtd = 0;
	for(int i=0; i<n; i++){
	  if(color == -1){
	    color = v[i];
	    qtd = 1;
	    continue;
	  }
	  else if(color != v[i]){
	    ans += qtd/2;
	    qtd = 0;
	    color = -1;
	    i--;
	    continue;
	  }
	  else qtd++;
	}
	ans += qtd/2;
	cout << ans << endl;
}



Measured memory_bytes: 892