akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
	
	int W, H;
	cin >> W >> H;
	
	int S1 = 0, S2 = 0;
	vector<int> a, b;
	
	for(int i = 0; i < W; i++){
		int num;
		cin >> num;
		S1 += num;
		a.push_back(num);
	}
	
	for(int i = 0; i < H; i++){
		int num;
		cin >> num;
		S2 += num;
		b.push_back(num);
	}
	
	if(S1 != S2){
		cout << 0 << endl;
		return 0;
	}
	
	for(int i = 0; i < W; i++){
		sort(b.begin(), b.end());
		for(int j = 0; j < a[i]; j++){
			b[H - j - 1] -= 1;
		}
	}
	
	sort(b.begin(), b.end());
	if(b[0] == 0){
		cout << 1 << endl;
	}else{
		cout << 0 << endl;
	}
	
	return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
 
int n,m,k;
long long inv[900010],fac[900010],p[900010],ans;
const long long mod=1e9+7;
inline long long ksm(long long x,long long y)
{
	long long res=1;
	while(y)
	{
		if(y&1)
		res=res*x%mod;
		x=x*x%mod;
		y>>=1;
	} 
	return res;
}
inline long long c(int x,int y)
{
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	if(m<k)
	swap(m,k);
	p[0]=1ll;
	fac[0]=1ll;
	inv[0]=1ll;
	for(int i=1;i<=9e5;++i)
	{
		p[i]=p[i-1]*3ll%mod;
		fac[i]=fac[i-1]*i%mod;
	}
	inv[900000]=ksm(fac[900000],mod-2);
	for(int i=9e5-1;i>=1;--i)
	inv[i]=inv[i+1]*(long long)(i+1)%mod;
	long long x=1;
	--n;
	for(int i=0;i<=m+k;++i)
	{
		ans=(ans+c(n+i,n)*p[m+k-i]%mod*x)%mod;
		if(i<k)
		x=x*2ll%mod;
		else if(i<m)
		x=(x*2ll-c(i,k)+mod)%mod;
		else 
		x=(x*2ll-c(i,k)-c(i,m)+mod+mod)%mod;		
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

bool solve(int k, int a, int b) {
    for (int i = a; i <= b; i++)
        if (i % k == 0)
            return true;
    return false;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int k, a, b;
    cin >> k >> a >> b;
    if (solve(k, a, b))
        cout << "OK" << endl;
    else
        cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3640
if __name__ == "__main__":
    n = int(input())
    w = list()
    for i in range(n):
        w.append(input())

    tmp = set(w)
    if len(tmp) != n:
        print('No')
        exit()

    head = w[0][0]
    for i in range(n):
        if head == w[i][0]:
            head = w[i][-1]
        else:
            print('No')
            exit()

    print('Yes')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    ll A, B, K;
    cin >> A >> B >> K;
    if(A >= K){
        cout << A - K << " " << B << endl;
        return 0;
    }

    ll res = K - A;
    if(B >= res){
        cout << 0 << " " << B - res << endl;
    }else{
        cout << 0 << " " << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

int main() {
	ll n;
	cin>>n;
	ll t[110000], x[110000], y[110000];
	rep(i,1,n+1)cin>>t[i]>>x[i]>>y[i];
	t[0]=0,x[0]=0,y[0]=0;
	bool pfuck=true;

	rep(i,1,n+1){
		ll fuck =abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
		ll tfuck=t[i]-t[i-1];
		if(tfuck>=fuck && (tfuck-fuck)%2==0) continue;
		else pfuck=false;
	}
	if(pfuck)cout<<"Yes";
	else cout<<"No";
}


Measured memory_bytes: 2816
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use std::mem::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::usize;

#[allow(unused_macros)]
macro_rules! read_cols {
    ($($t:ty),+) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();

        let mut it = line.trim()
            .split_whitespace();

        ($(
            it.next().unwrap().parse::<$t>().ok().unwrap()
        ),+)
    }}
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.trim().to_string().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    line.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn root(g: &mut Vec<usize>, i: usize) -> usize {
    if g[i] != i {
        let parent = g[i];
        g[i] = root(g, parent);
    }
    g[i]
}

fn merge(g: &mut Vec<usize>, i: usize, j: usize) {
    let lg = root(g, i);
    let rg = root(g, j);
    
    g[rg] = lg;
}

fn main() {
    let (n, m) = read_cols!(usize, usize);
    
    let links = {
        let mut links = vec![];
        for _ in 0..m {
            let (a, b) = read_cols!(usize, usize);
            links.push((a, b));
        }
        links
    };

    let ans = links.iter().rev()
      .fold((vec![1; n+1], (0..n+1).collect::<Vec<_>>(), vec![n * (n - 1) / 2]), |(mut counts, mut groups, mut ans), link| {
        let lg = root(&mut groups, link.0);
        let rg = root(&mut groups, link.1);
        
        let mut num_unconnected = ans.last().unwrap().clone();
        
        if lg != rg {
            merge(&mut groups, link.0, link.1);
            num_unconnected -= counts[lg] * counts[rg];
            counts[lg] += counts[rg];
            counts[rg] = counts[lg];
        }
        
        ans.push(num_unconnected);
        (counts, groups, ans)
    }).2;
    
    for a in ans.iter().rev().skip(1) {
        println!("{}", a);
    }
}


Measured memory_bytes: 11132
/**
 *  author:   TakeruOkuyama
 *  created:  2020-04-15 11:17:28
**/
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    rep(i, N){
        rep(j, D){
            cin >> X[i][j];
        }
    }
    int ans = 0;
    rep(i,N)rep(j,i){
        int sq = 0;
        rep(k,D){
            int s = X[i][k] - X[j][k];
            sq += s*s;
        }
        int s = sqrt(sq);
        if(s*s == sq) ans++;
    }
    cout << ans << endl;
return 0;}

/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define l long long
long long a[200010];
long long ans[200010];
int main()
{
    l n;
    cin>>n;

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


    for(l i=2; i<=n; i++)
    {
        ans[a[i]]++;
    }
    for(l i=1; i<=n; i++)
    {
        cout<<ans[i]<<endl;
    }
   /* map<l,l>m;
    map<l,l>::iterator it;
    for(l i=2; i<=n; i++)
    {
        cin>>a[i];
        m.insert(a[i]);
        m[a[i]]++;
    }
    for(it=m.begin(); it!=m.end(); it++)
    {
        cout<<*it<<endl;
    }*/
}


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

vector<int> p[200001];

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    rep(i, N) {
        int r, c;
        cin >> r >> c;
        p[r].push_back(c);
    }
    rep(i, H) sort(p[i].begin(), p[i].end());

    int len = 1;
    for (int i=1; i<=H-1; ++i) {
        //cout << "len = " << len << endl;
        for (int j=0; j<p[i+1].size(); ++j) {
            if (len >= p[i+1][j]) {
                cout << i << endl;
                return 0;
            }
        }
        if (len < W) {
            bool ok = true;
            for (int j=0; j<p[i+1].size(); ++j) {
                if (len+1 == p[i+1][j]) {
                    ok = false;
                    break;
                }
                else if (len+1 < p[i+1][j]) break;
            }
            if (ok) len++;
        }
    }
    cout << H << endl;
    return 0;
}


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

using namespace std;

vector<int>v;

int dp[100050];

int main(){
    int n,br;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>br;
        v.push_back(br);
    }

    dp[0]=v[0];
    if(n>1)dp[1]=abs(v[0]-v[1]);
    if(n>2)dp[2]=min(abs(v[0]-v[2]),dp[1]+abs(v[1]-v[2]));
    if(n>3){
        for(int i=3;i<n;i++){
            dp[i]=min(dp[i-1]+abs(v[i-1]-v[i]),dp[i-2]+abs(v[i-2]-v[i]));
        }
    }

    cout<<dp[n-1];




    return 0;
}


Measured memory_bytes: 1144
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] arg) {
		Scanner in = new Scanner(System.in);
		int a, b;
		while ((a = in.nextInt()) + (b = in.nextInt()) > 0) {
			int[][] point = new int[a + 1][b + 1];
			int n = in.nextInt();
			Set<Integer> koji = new HashSet<Integer>();
			for (int i = 0; i < n; i++) {
				int x = in.nextInt();
				int y = in.nextInt();
				koji.add((x << 8) + y);
			}
			point[0][1] = 1;
			for (int x = 1; x <= a; x++) {
				for (int y = 1; y <= b; y++) {
					if (!koji.contains((x << 8) + y)) {
						point[x][y] = point[x][y - 1] + point[x - 1][y];
					} else {
					}
				}
			}
			System.out.println(point[a][b]);
		}
		in.close();
	}
}

Measured memory_bytes: 20372
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 100005

ll inv[N], fac[N], finv[N];

void make()
{
	fac[0] = fac[1] = 1;
	inv[1] = 1;
	finv[1] = finv[0] = 1;
	for(int i = 2; i < N; ++i)
	{
		fac[i] = i * fac[i - 1] % MOD;
		inv[i] = MOD - MOD/i * inv[MOD % i] % MOD;
		finv[i] = inv[i] * finv[i - 1] % MOD;
	}
}

ll C(ll n, ll k)
{
	if(n < k || n < 0) return 0;
	return fac[n] * finv[n - k] % MOD* finv[k] % MOD;
}

ll gcd(ll a, ll b)
{
	if(b == 0)
		return a;
	return gcd(b, a % b);
}
#define N 100005
int n, k;
int h[N];
int dp[N];
int dpf(int i)
{
	if(i >= n)
		return 1e9;
	if(i == n - 1)
		return 0;
	if(dp[i] >= 0)
		return dp[i];
	dp[i] = 1e9;
	for (int j = 1; j <= k; ++j)
	{
		dp[i] = min(dp[i], abs(h[i + j] - h[i]) + dpf(i + j));
	}
	return dp[i];
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> k;
	for (int i = 0; i < n; ++i)
	{
		cin >> h[i];
		dp[i] = -1;
	}
		dp[1] = abs(h[1] - h[0]);
		dp[0] = 0;
		for(int i = 2; i < n; ++i)
		{
			dp[i] = 1e9 + 2;
			for(int j = 1; j <= k; ++j)
			{
				if(i - j >= 0)
				dp[i] = min(dp[i], abs(h[i] - h[i - j]) + dp[i - j]);
			}
		}
	int ans = dp[n - 1];
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1024
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
using namespace std;
int n,ma,mb,a,b,c,ans=INF,f[405][405];
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n>>ma>>mb;
	memset(f,100,sizeof(f));
	f[0][0]=0;
	for(int i=1;i<=n;i++){
		cin>>a>>b>>c;
		for(int i=400;i>=a;i--)
		for(int j=400;j>=b;j--)
		f[i][j]=min(f[i-a][j-b]+c,f[i][j]);
	}
	for(int i=1;i<=400;i++){
		if(ma*i>400)
		break;
		if(mb*i>400)
		break;
		ans=min(ans,f[ma*i][mb*i]);
	}
	if(ans!=INF)
	cout<<ans<<endl;
	else
	cout<<-1<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MAX 10000001
using ll = long long;
using P = pair<ll, ll>;

const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void fail() {
    cout << -1 << endl;
    exit(0);
}

int yakusu[MAX];


int main(){
    // 約数カウント
    ll n;
    cin >> n;
    for(ll i=0; i < MAX; i++) yakusu[i] = 0;
    for(ll i=1; i < MAX; i++){
        for(ll j=i; j < MAX; j+=i){
            yakusu[j] += 1;
        }
    }
    ll ans = 0;
    for(ll i=1; i <= n; i++){
        ans += i * yakusu[i];
    }
    cout << ans << endl;
}

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

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

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K;
    string S;
    cin >> N >> S >> K;
    char check = S[K - 1];
    for (int i = 0; i < S.length(); i++) {
        if (S[i] != check) S[i] = '*';
    }
    cout << S << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

     signed main(){
    int n,a,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a;
        if(i%2==1&&a%2==1)ans++;
    }
    cout<<ans<<endl;
     }


 


 






    





      

        


Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

int main(){
	string s;
	cin >> s;
	int a=0,b=0;
	for(int i=0;i<s.length();i++){
		if(s[i]=='0')a++;
		else b++;
	}
	cout << min(a,b)*2 << endl;

	return 0;
}

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

struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int root(int x) {
    if (d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  int size(int x) { return -d[root(x)];}
};

int main() {
  int n, m, k; cin >> n >> m >> k;
  UnionFind uf(n);
  vector<vector<int>> g1(n), g2(n);
  rep(i, m) {
    int a, b; cin >> a >> b; a--; b--;
    g1[a].push_back(b);
    g1[b].push_back(a);
    uf.unite(a, b);
  }
  rep(i, k) {
    int c, d; cin >> c >> d; c--; d--;
    g2[c].push_back(d);
    g2[d].push_back(c);
  }
  rep(i, n) {
    int ans = uf.size(i) - g1[i].size() - 1;
    rep(j, (int)g2[i].size())
      if (uf.same(i, g2[i][j])) ans--;
    printf("%d%c", ans, i == n-1 ? '\n' : ' ');
  }
  return 0;
}

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

int main(){

    int N;
    int K;
    int X;
    int Y;

    cin >> N;
    cin >> K;
    cin >> X;
    cin >> Y;

    if(N <= K){
    	cout << N*X << endl;
    }else{
    	cout << K*X + (N-K)*Y << endl;
    }

    return 0;


}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
//#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
#include <string>

int main(){


    int N;
    cin >> N;
    int K;
    cin >> K;
    string S;
    cin >> S;
    string ans = "";
    for( int ni = 0 ; ni < N ; ni++ ){
        if(ni == K -1){
            string target = S.substr(ni,1);
            if(target=="A"){
                ans = ans + "a";
            }else if(target=="B"){
                ans = ans + "b";
            }else{
                ans = ans + "c";
            }
        }else{
            ans = ans + S.substr(ni,1);
        }
    }    
    cout << ans;

}

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

using namespace std;

int main(){
  int a_pos, a_move;
  int b_pos, b_move;
  int t;
  long long a;
  
  cin >> a_pos >> a_move;
  cin >> b_pos >> b_move;
  cin >> t;
  
  if(a_move <= b_move){
    cout << "NO" << endl;
    return 0;
  }
  
  a = (long)abs(a_move-b_move)*t;
  
  if(abs(b_pos-a_pos) <= a){
    cout << "YES" << endl;
  } else{
        cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> vi;

ifstream fin("parimpar2.in");
ofstream fout("parimpar2.out"); 

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
   
    int a, b, c;
    cin >> a >> b >> c;
    if(a==b && b==c)
        cout << 1;
    else if(a==b)
        cout << 2;
    else if(a==c)
        cout << 2;
    else if(b==c)
        cout << 2;
    else
        cout << 3;
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>


/*
?a,b,cを入力する
?for文用のカウンタ変数iを宣言する
?約数の個数をカウントする変数cntを宣言して０で初期化
?for文でiがaからbまで繰り返す→for(i=a; i<=b; i++)
?for文中でcがiで割り切れる場合cntをインクリメント
*/


main()
{
	int a, b, c, i, cnt=0;

	scanf("%d %d %d", &a, &b, &c);

	for(i=a; i<=b; i++)
	{
		if(c%i == 0)
		{
			cnt++;
		}
	}
	printf("%d\n", cnt);

	return 0;
}

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

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

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

const int MAX = 1e5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

string S, T;

int main(){
    cin >> S >> T;
    int ans = 0;
    rep(i, 3){
        if (S[i] == T[i]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, m, n) for(long long i = m; i < n; ++i)
#define CO(n) cout << n << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N;
string S[200010];

int main()
{
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i,0,N) cin >> S[i];
    map<string, int> dict; //stringをキーに，intをバリューに持つdict
    // 要素の追加
    REP(i,0,N) dict[S[i]] += 1;
    int ans=0;
    //要素を全てループ
    map<string, int>::iterator ite;
    for (ite = dict.begin(); ite != dict.end(); ++ite){
        if (ite->second > ans) ans = ite->second;
    }
    for (ite = dict.begin(); ite != dict.end(); ++ite){
        if (ite->second == ans) CO(ite->first);
    }
    return 0;
}

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

int calc(int x) {
  int res = 0;
  for (int i = 1; i*i <= x; i++) {
    if (x % i == 0) {
      res++;
      if (i*i != x) res++;
    }
  }
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; i += 2) {
    if (calc(i) == 8) ans++;
  }  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 5e3 + 10, LOG = log2(N) + 5;

string solve(string s, int k);

int main() {
	fast_cin();
	int n, k;
	cin >> n >> k;
	string s; cin >> s;
	char a = *min_element(s.begin(), s.end());
	if (k > LOG or (1 << (k - 1)) >= n) {
		cout << string(n, a) << endl;
		return 0;
	}
	string best = s;
	string t = s;
	reverse(t.begin(), t.end());
	s += t;
	// vector<int> pos;
	// int l = 0, cur = 0;
	// for (int i = 0; i < 2 * n; ++i) {
	// 	if (s[i] == a) {
	// 		++cur;
	// 		if (i - n + 1 >= 0) {
	// 			if (l > cur) {
	// 				l = cur;
	// 				pos = {i - n + 1};
	// 			} else if (l == cur) {
	// 				pos.pb(i - n + 1);
	// 			}
	// 		}
	// 	} else {
	// 		cur = 0;
	// 	}
	// }
	for (int p = 0; p <= n; ++p) {
		best = min(best, solve(s.substr(p, n), k - 1));
	}
	cout << best << endl;
}

string solve(string s, int k) {
	int n = s.length();
	while (k--) {
		string t = s;
		reverse(t.begin(), t.end());
		s += t;
		int p = n;
		while (p < 2 * n - 1 and s[p + 1] == s[p]) {
			++p;
		}
		s = s.substr(p - n + 1, n);
	}
	reverse(s.begin(), s.end());
	return s;
}

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

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

using namespace std;
typedef long long ll;

int main(){

    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int start = h1 * 60 + m1;
    int end = h2 * 60 + m2;

    cout << end - start - k << endl;
    return 0;
}


Measured memory_bytes: 3632
s=int(input())
a,b,c=1,1,1
modd= 1e9+7
for i in range(s):
    a= (a*10)%modd
    b=(b*8)%modd
    c=(c*9)%modd
c= a+b-2*c
c%=modd
print(int(c))

Measured memory_bytes: 9036
#include<iostream>
#include<stdio.h>
using namespace std;
int n;

int dy[]={-1,1};
int dx[]={1,-1};
int t[10][10];

bool inField(int y,int x){
  if (0<=y&&y<n&&0<=x&&x<n)return true;
  return false;
}

int main(){
  int Tc=1;
  while(cin>>n&&n){
    int y=0,x=0,cnt=1;
    
    for(int i=0;i<n*2-1;i++){  
      t[y][x]=cnt++;
      while(inField(y+dy[i%2],x+dx[i%2])){
	y+=dy[i%2];
	x+=dx[i%2];
	t[y][x]=cnt++;
      }
      if(i<n-1){
	if(i%2==0)x++;
	else y++;
      }else{
	if(i%2==1)x++;
	else y++;
      }
    }
  
    t[n-1][n-1]=n*n;
    
    cout<<"Case "<<Tc++<<":"<<endl;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	printf("%3d",t[i][j]);
      }
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int r=0;
    for(int i=1; i<=n; i++){
        int c = 0;
        int t = i;
        for(int j=0; j<5; j++){
            c+=t%10;
            t/=10;
        }
        if(a<=c&&c<=b){
            r+=i;
        }
    }
    cout << r << endl;
    return 0;
}




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

ll x = 1e9 + 7; 

int main() {
  int k, n;
  cin >> k >> n;
  int x = 0;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    if (i == 0) continue;
    x = max(x, a[i]-a[i-1]);
  }
  x = max(x, k-a[n-1]+a[0]);
  cout << k-x << endl;
  return 0;
}

Measured memory_bytes: 4028
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  vector<ll> vec(n);
  ll cnt = 0;
  ll vmin = 1e10;
  ll vsum = 0;
  for (auto &v : vec) {
    cin >> v;
    if (v < 0)
      ++cnt;
    vmin = min(vmin, abs(v));
    vsum += abs(v);
  }
  if (cnt % 2 == 0)
    cout << vsum << endl;
  else
    cout << vsum - 2 * vmin << endl;
}


Measured memory_bytes: 4048
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

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

    vector<int> v;

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

        if(c == 0){
            int x;
            cin >> x;
            v.push_back(x);
        }else if(c==1){
            int p;
            cin >> p;
            cout << v.at(p) << endl;
        }else if(c==2){
            v.pop_back();
        }
    }
}



Measured memory_bytes: 3844
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct edge { int to; int cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-12;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int dp[3010][3010];

int main(){
	string s,t;
	cin >> s >> t;
	for(int i = 0; i < s.size(); i++){
		for(int j = 0; j < t.size(); j++){
			if(s[i] == t[j]) dp[i+1][j+1] = dp[i][j]+1;
			else dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
		}
	}
	string ans;
	int i = s.size()-1,j = t.size()-1;
	while(i > -1 && j > -1){
		while(i != -1 && j != -1 && dp[i][j] == dp[i+1][j+1]) i--,j--;
		while(i != -1 && dp[i][j+1] == dp[i+1][j+1]) i--;
		while(j != -1 && dp[i+1][j] == dp[i+1][j+1]) j--;
		if(i != -1 && j != -1) ans = s[i]+ans;
		i--,j--;
	}
	/*cout << " " << t << endl;
	rep(i,s.size()){
		cout << s[i];
		rep(j,t.size()) cout << dp[i][j];
		cout << endl;
	}
	cout << dp[s.size()][t.size()] << endl;*/
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int d; cin >> d;
	cout << "Christmas";
	int i = 25-d;
	while( i-- ){
		cout << " Eve";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
n, m, x = [int(i) for i in input().split()]

l = list()

INF = float("inf")
ans = INF

for i in range(n):
	c, *a = [int(i) for i in input().split()]
	l.append((c, a))

for b in range(1, 1 << n):
	p = 0
	lm = [0] * m

	for j in range(n):
		if (b >> j) & 1:
			p += l[j][0]
			for k, v in enumerate(l[j][1]):
				lm[k] += v

	if min(lm) >= x:
		ans = min(ans, p)

if ans == INF:
	print(-1)
else:
	print(ans)

Measured memory_bytes: 9224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        long K = long.Parse(str[1]);
        int[] A = new int[N];
        int[] B = new int[N];
        for(int i = 0; i < N; i++){
            str = Console.ReadLine().Split(' ');
            A[i] = int.Parse(str[0]);
            B[i] = int.Parse(str[1]);
        }

        Array.Sort(A,B);

        for(int i = 0; i < N; i++){
            if(B[i] >= K){
                Console.WriteLine(A[i]);
                break;
            }
            K -= B[i];
        }

    }
}

Measured memory_bytes: 17312
import java.lang.Math
import kotlin.comparisons.*

val MOD: Int = 1000000000 + 7
val MODL: Long = MOD.toLong()

fun main(args: Array<String>)
{
    var (n, h) = read().split().toInt()
    // val damage = mutableListOf<Pair<Int, Int>>()
    // for (i in 0 until n) {
    //     val (a, b) = read().split().toInt()
    //     damage.add(Pair<Int, Int>(a, b))
    // }
    var a = -1
    val b = mutableListOf<Int>()
    for (i in 0 until n) {
        val (s, t) = read().split().toInt()
        a = Math.max(a, s)
        b.add(t)
    }

    b.sortWith(compareByDescending{it})
    var ans = 0L
    for (i in 0 until n) {
        if (b[i] <= a) break
        h -= b[i]
        ans++
        if (h <= 0) {
            println(ans)
            return
        }
    }

    ans += h.toLong() / a.toLong() + if (h % a == 0) 0L else 1L
    println(ans)

}

fun read(): String = readLine()!!
fun CharSequence.split(): List<String> = this.split(" ")
fun Iterable<String>.toInt(): List<Int> = this.map{it.toInt()}


Measured memory_bytes: 75836
#define dbg(...) fprintf(stderr,__VA_ARGS__)
#define dpr(x) cerr<<#x<<": "<<x<<endl;
#define dprc(c) do{cerr<<#c<<":";for(auto&_i:(c)){cerr<<" "<<_i;}cerr<<endl;}while(0)
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
int INF = 1e9+7;
#define all(c) (c).begin(), (c).end()
#define tr(i,c) for(auto i=(c).begin();i!=(c).end();i++)
#define rtr(i,c) for(auto i=(c).rbegin();i!=(c).rend();i++)
#define rep(i,b) for(auto i=0;i<(b);i++)
#define pb push_back
#define sz(c) int((c).size())

int main(int argc, char **argv)
{
  vector<function<int(int, int)>> ops = {
    [](int a, int b) { return a + b; },
    [](int a, int b) { return a - b; },
    [](int a, int b) { return a * b; },
  };
  stack<int> stk;
  string s;
  while (cin >> s) {
    auto k = string("+-*").find(s[0]);
    if (k != string::npos) {
      int b = stk.top(); stk.pop();
      int a = stk.top(); stk.pop();
      int r = ops[k](a, b);
      stk.push(r);
    } else {
      stk.push(stoi(s));
    }
  }
  cout << stk.top() << endl;
  return 0;
}

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

int main() {
  string s;
  cin >> s;

  string ans = "";
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != 'B') ans += s[i];
    else if (ans != "") ans.pop_back();
  }

  cout << ans << endl;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int n; cin >> n;
    vi a(n); REP(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 0;
    REP(i, n) FOR(j, i + 1, n) {
        ans += lower_bound(a.begin() + j + 1, a.end(), a[i] + a[j]) - (a.begin() + j + 1);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int a,b;
int main(){
 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> a >> b;
	cout << 6 - (a + b) << endl;
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

string s;
const LL mod = 1e9 + 7;
LL dp[2][101010];

int main(){
    cin >> s;
    dp[0][0] = 1;
    REP(i, (int)s.size()){
        REP(j, 2){
            int lim;
            if(j)lim = 2;
            else{
                lim = s[i] - '0' + 1;
            }
            REP(k, lim){
                (dp[j | (k < s[i] - '0')][i + 1] += dp[j][i] * (k ? 2LL : 1LL)) %= mod;
            }
        }
    }
    LL ans = 0;
    ans = ((dp[0][(int)s.size()] + dp[1][(int)s.size()])) % mod;
    cout << ans << endl;
}

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

int main(){
	int r,c;
	cin>>r>>c;

	int num[101][101]={};
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){ cin>>num[i][j];}}
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){ num[r][c] +=num[i][j];}}
	for(int i=0;i<r;i++){
	int sum=0;
	for(int j=0;j<c;j++){ sum +=num[i][j];}
	num[i][c] =sum;
	}
	for(int j=0;j<c;j++){ 
	int sum=0;
	for(int i=0;i<r;i++) {sum +=num[i][j];}
	num[r][j] =sum;
	}
	for(int i=0;i<=r;i++){
	for(int j=0;j<=c;j++){
	if(j) cout<<" ";
	cout<<num[i][j];
	}
	cout<<endl;
}
  return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define int long long

using namespace std;

const int mod = 1e9 + 7;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N;
    cin >> N;
    int ans = 1, scad = 2, adun = 1;
    for(int i = 0; i < N; ++i) {
        ans = (ans * 10) % mod;
        scad = (scad * 9) % mod;
        adun = (adun * 8) % mod;
    }
    ans = (ans + adun) % mod;
    ans = (ans - scad + mod) % mod;
    cout << ans;
}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
		cout << 0 << endl;
	else
		cout << min(min(a*b, b*c), a*c) << endl;
	//system("Pause");
}

Measured memory_bytes: 256
r, c = map(int, raw_input().split())
sum_c = [0] * (c+1)
row_list = []
for i in xrange(r):
	row = map(int, raw_input().split())
	row.append(sum(row))
	row_list.append(row)
	sum_c = map(lambda x, y: x+y, sum_c, row) 
row_list.append(sum_c)
for row in row_list:
	print ' '.join(map(str, row))

Measured memory_bytes: 4308
@_=($N=<>,map[glob],<>);
for(1..$N){
	$x=0;
	for($_..$N-1){
		$x=$x<$_[$_][1]?$_[$_][1]:(~-$x/$_[$_][2]+1|0)*$_[$_][2];
		$x+=$_[$_][0]
	}
	print$x,$/
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <list>
#include <stack>

using namespace std;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;

/* typedef */

typedef long long ll;

/* global variables */

/* function */

/* main */
int main() {

    int x, y; cin >> x >> y;
    cout << x * y << ' ' << 2 * (x + y) << '\n';

}



Measured memory_bytes: 3088
import numpy as np


def main():
    n = int(input())
    As = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    As_sum = sum(As)
    ans = 0

    for i in range(n):
        As_sum -= As[i]
        ans += As_sum * As[i]
        ans %= mod
    ans %= mod
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 49968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
int main(){
    ll n,m;
    cin>>n>>m;
    ll ans=0;
    if(n>m/2)ans=m/2;
    else ans+=n+(m-2*n)/4;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
C = [list(map(int, input().split())) for i in range(10)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][j], C[i][k] + C[k][j])

ans = 0
for h in range(H):
    A = list(map(int, input().split()))
    for a in A:
        if a >= 0:
            ans += C[a][1]

print(ans)


Measured memory_bytes: 3064
N, M = map(int, input().split())
op = []
for _ in range(M):
    x, y = map(int, input().split())
    op.append((x, y))
box = {i: 1 for i in range(1, N+1)}
possible = {i: False for i in range(1, N+1)}
possible[1] = True
for x, y in op:
    box[x] -= 1
    box[y] += 1
    if possible[x]:
        possible[y] = True
    if box[x] == 0:
        possible[x] = False
print(sum(possible.values()))

Measured memory_bytes: 40764
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <unordered_map>
#include <queue>
using namespace std;

int main(){
	string s1, s2;
	cin >> s1 >> s2;
	if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0]){cout << "YES";}
	else cout << "NO";
	return 0;
}
	

Measured memory_bytes: 256
N = int(input())

print(N*(N-1)//2-N//2)
for i in range(1, N):
    for j in range(i+1, N+1):
        if N % 2 == 0:
            if i+j != N+1:
                print(i, j)
        else:
            if i+j != N:
                print(i, j)


Measured memory_bytes: 42864
#include <iostream>
using namespace std;
int A1;
int A2;
int A3;

int main()
{
    std::cin >> A1 >> A2 >> A3;
    if (A1 > 0 && A1 < 14) {
        if (A2 > 0 && A2 < 14) {
            if (A3 > 0 && A3 < 14) {
                if (A1 + A2 + A3 >= 22)
                std::cout << "bust";
                else std::cout << "win";
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define Fast ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define deb(x) cout<<#x<<" "<<x<<endl;
#define all(v) v.begin(),v.end()
#define endl '\n'
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void judge() {
#ifndef ONLINE_JUDGE
	FILE_READ_IN
	FILE_READ_OUT
#endif
}

int main() {
	Fast;
	int t = 1;
	judge();
	// cin >> t;
	while (t--) {
		int n;
		cin >> n;
		n -= 400;
		n /= 200;
		n = 8 - n;
		cout << n << endl;
	}
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pii pair<long long,long long>
#define endl '\n'
#define N 100001
int MOD=1000000007;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};

void solve()
{
    double n; cin>>n; int x,y;
    double pi = 3.14159265358979323846;
    double t = (double)2;
    cout<<fixed<<setprecision(22)<<t*pi*n;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test;test=1;
    while(test--)
    {
        solve();
    }
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int num = 0;
  
  for (int i = a; i <= b; i++) {
    if ((i / 10000 == i % 10) && (i / 1000) % 10 == ((i % 100) - (i % 10)) / 10) {
      num++;
    }
  }
  
  cout << num << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <map>

int main() {
  size_t N;
  scanf("%zu", &N);

  char buf[64];
  scanf("%s", buf);
  std::string S = buf;

  std::string S0(S.begin(), S.begin()+N);
  std::string S1(S.begin()+N, S.end());
  std::reverse(S1.begin(), S1.end());

  std::map<std::pair<std::string, std::string>, intmax_t> T1;
  for (size_t i=0; i<(1u<<N); ++i) {
    std::string t, u;
    for (size_t j=0; j<N; ++j)
      ((i>>j & 1)? t:u) += S1[j];
    ++T1[{t, u}];
  }

  intmax_t res = 0;
  for (size_t i=0; i<(1u<<N); ++i) {
    std::string t, u;
    for (size_t j=0; j<N; ++j)
      ((i>>j & 1)? t:u) += S0[j];
    auto it = T1.find({t, u});
    if (it != T1.end()) res += it->second;
  }
  printf("%jd\n", res);
}


Measured memory_bytes: 48168
package main

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



var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func main() {
    line := nextLine()
    a, _ := strconv.Atoi(line)
    line = nextLine()
    b, _ := strconv.Atoi(line)
    line = nextLine()
    h, _ := strconv.Atoi(line)

    area := float64 ((a + b) * h) / 2
    fmt.Print(area)
}

Measured memory_bytes: 640
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
typedef pair<int, int> P;
const int INF = 100000000;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int i, j, k, l, m, sum0,sumn, N, M,X,Y,C;
	cin >> N;
	sum0 = sumn = 0;
	vector<int>A(N);
	vector<int>B(N);
	for (i = 0; i<N; i++) {
		cin >> A[i];
		B[i] = A[i];
	}
	sort(A.begin(), A.end());
	for (i = 0; i < N ; i++) {
		if (B[i] <A[N / 2 ]) {
			cout << A[N / 2 ] << endl;
		}
		else
			cout << A[N / 2-1] << endl;
	}
	
	
	
	return 0;
}



Measured memory_bytes: 3712
// tested by Hightail: https://github.com/dj3500/hightail
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define INF 1001001001
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define mp make_pair
#define pii pair<int,int>
#define ll long long
#define vi vector<int>
#define SZ(x) ((int)((x).size()))
#define fi first
#define se second
#define wez(n) int (n); scanf("%d",&(n));
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m));
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k));
inline void pisz(int n) { printf("%d\n",n); }
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream& operator<<(ostream &s,vector<T> t){FOR(i,SZ(t))s<<t[i]<<" ";return s; }
#define DBG(vari) cout<<"["<<__LINE__<<"] "<<#vari<<" = "<<(vari)<<endl;
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (__typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define TESTS wez(testow)while(testow--)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define IOS ios_base::sync_with_stdio(0);

const int mod = 1000000007;
ll dp[51][51][52*52*2];

int main () {
   wez2(n,k);
   const int OFF = 50 * 50;
   dp[0][0][OFF+0] = 1;
   REP(i,0,n-1) {
      // dodaj i+1
      REP(lp,0,i) {
         REP(l,-OFF,OFF) {
            dp[i][lp][OFF+l] %= mod;
            if (dp[i][lp][OFF+l] != 0) {
               const ll cur = dp[i][lp][OFF+l];
               // ze soba
               dp[i+1][lp][OFF+l] += cur;

               if(lp>0) dp[i+1][lp-1][OFF+l+2*(i+1)] += cur * lp * lp;
               dp[i+1][lp][OFF+l] += cur * lp;
               dp[i+1][lp][OFF+l] += cur * lp;
               dp[i+1][lp+1][OFF+l-2*(i+1)] += cur;
            }
         }
      }
   }
   ll res = dp[n][0][OFF+k] % mod;
   if (res < 0) res += mod;
   pisz(res);
}

Measured memory_bytes: 107136
#include <iostream>

using namespace std;

void insertionSort(int A[], int n)
{
    for(int i=1; i<n; i++) {
        int v = A[i];
        int j=i-1;
        while(j>=0 && A[j]>v) {
            A[j+1] = A[j];
            j--;
            A[j+1] = v;
        }
        cout<<A[0];
        for(int k=1; k<n; k++) cout<<' '<<A[k];
        cout<<'\n';
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, A[100];
    cin >> n;
    for(int i=0; i<n; i++) cin >> A[i];
    cout<<A[0];
    for(int i=1; i<n; i++) cout<<' '<<A[i];
    cout<<'\n';
    insertionSort(A, n);
    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

const int MAX = 2e5 + 5;
ll BIT[MAX];
// 1-index queries
void upd(int i, ll val)
{
	for(; i < MAX; i += i&-i)
	BIT[i] = max(BIT[i], val);
}
ll qry(int i)
{
	ll sum = 0;
	for(; i; i -= i&-i)
	sum = max(sum, BIT[i]);
	return sum;
}
int main()
{
	boost;
	int n, i;
	cin >> n;
	int h[n], a[n];
	fo(i, 0, n)
	cin >> h[i];
	fo(i, 0, n)
	cin >> a[i];
	
	ll dp[n];
	fo(i, 0, n) {
		dp[i] = a[i] + qry(h[i] - 1);
		upd(h[i], dp[i]);
	}
	cout << *max_element(dp, dp + n);	
}


Measured memory_bytes: 8340