akhauriyash/Code-Regression huggingface dataset:
n,m = map(int, input().split(' '))
A = []
for i in range(m):
    p,s = input().split(' ')
    A.append((int(p),s))

A = sorted(A, key=lambda a: a[0])
ac = set()
wa = {}

total_ac_cnt = 0
total_wa_cnt = 0

for a in A:
    if a[1] == 'AC':
        if not a[0] in ac:
            ac.add(a[0])
            if a[0] in wa:
                total_wa_cnt += wa[a[0]]
            total_ac_cnt += 1
    else:
        if not a[0] in ac:
            if a[0] in wa:
                wa[a[0]] += 1
            else:
                wa[a[0]] = 1

print(total_ac_cnt, total_wa_cnt)


Measured memory_bytes: 25720
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> query;
typedef vector<vector<ll>> matrix;

pii a[100005]; // <a.first - a.second, a.second>
ll xS[100005];
ll yS[100005];
void solve() {
  int x, y, z;
  cin >> x >> y >> z;
  int n = x+y+z;
  ll base = 0;
  for(int i = 0; i < n; i++) {
    ll c;
    cin >> a[i].first >> a[i].second >> c;
    a[i].first -= c;
    a[i].second -= c;
    a[i].first -= a[i].second;
    base += c;
  }
  sort(a, a+n);
  reverse(a, a+n);
  {
    map<int, int> dp;
    ll curr = 0;
    for(int i = 0; i < n; i++) {
      curr += a[i].first + a[i].second;
      dp[a[i].first + a[i].second]++;
      if(i >= x) {
        ll lowest = dp.begin()->first;
        curr -= lowest;
        if(--dp[lowest] == 0) dp.erase(lowest);
      }
      xS[i+1] = curr;
    }
  }
  {
    map<int, int> dp;
    ll curr = 0;
    for(int i = 0; i < n; i++) {
      curr += a[n-1-i].second;
      dp[a[n-1-i].second]++;
      if(i >= y) {
        ll lowest = dp.begin()->first;
        curr -= lowest;
        if(--dp[lowest] == 0) dp.erase(lowest);
      }
      yS[i+1] = curr;
    }
  }
  ll ret = 0;
  for(int i = x; i <= n-y; i++) {
    ret = max(ret, base + xS[i] + yS[n-i]);
  }
  cout << ret << "\n";
}

void casesolve() {
  int t;
  cin >> t; cin.ignore();
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 7040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		    Scanner sc = new Scanner(System.in);

		   int n = sc.nextInt();
		   int order = 0;
		   int m = n;
		   int ans = 0;

		   while(m>=1) {
			   m = m/10;
			   order += 1;
		   }
		   if(order%2==0) {
			   for(int i=1;i<=order-1;i=i+2) {
				   ans = ans + (int)Math.pow(10, i)-(int)Math.pow(10, i-1);
			   }
		   }else {
			   for(int i=1;i<=order-2;i=i+2) {
				   ans = ans + (int)Math.pow(10, i)-(int)Math.pow(10, i-1);
			   }
			   ans = ans + (n-(int)Math.pow(10, order-1)+1);
		   }
		   System.out.println(ans);

		    sc.close();
	}
}

Measured memory_bytes: 23764
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,M = LI()
    node = [-1] * N
    edge = [[] for _ in range(N)]
    for _ in range(M):
        a,b = _LI()
        edge[a].append(b)
        edge[b].append(a)

    node[0] = 0
    q = collections.deque()
    q.append((0,0))
    d = [0] * 2
    while q:
        u,c = q.popleft()
        for v in edge[u]:
            if c == node[v]:
                break
            if node[v] < 0:
                node[v] = 1-c
                q.append((v,node[v]))
        else:
            continue
        d[1] = N-1
        node = [0] * N
        break
    else:
        d[0] = node.count(0)
        d[1] = node.count(1)

    ans = 0
    for i in range(N):
        ans += d[1-node[i]] - len(edge[i])
    print(ans//2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 90060
#!/usr/bin/env python3


def count_pins(n, s):
    k = 3
    if n < k or n < 1 or k < 1:
        return 0
    elif n == k:
        return 1
    v1 = [0 for _ in range(n)]
    v2 = [0 for _ in range(n)]
    v3 = [0 for _ in range(10)]
    v2[n - 1] = 1
    v3[s[n - 1] - 1] = 1
    for i in range(n - 1)[::-1]:
        v2[i] = v2[i + 1]
        if v3[s[i] - 1] == 0:
            v2[i] += 1
            v3[s[i] - 1] = 1
    for j in range(1, k):
        v3 = [0 for _ in range(10)]
        v1[n - 1] = 0
        for i in range(n - 1)[::-1]:
            v1[i] = v1[i + 1]
            v1[i] += v2[i + 1]
            v1[i] -= v3[s[i] - 1]
            v3[s[i] - 1] = v2[i + 1]
        v2 = v1[:]
    return v1[0]


def main():
    n = int(input())
    s = [int(c) for c in input()]
    res = count_pins(n, s)
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 42608
#include<stdio.h>
#include<string.h>
#define MAX 10000
#define MAX2 1000000
int  sieve[MAX2+1];
int primes[MAX];
void create_primes() {
	memset(sieve, 0, sizeof(sieve));
	memset(primes, 0, sizeof(primes));
	int i,j,p;
	p = 0;
	for (i=2; i<MAX2; i++) {
		if (!sieve[i]) {
			primes[p++]=i;
			if (p>=MAX) break;
			for (j=i; j<MAX2+1; j+=i) sieve[j]=1;
		}
	}
}
int main()
{
	int n,i,res;
	create_primes();
	while (1) {
		scanf("%d", &n);
		if (n==0)break;
		res = 0;
		for (i=0;i<n;i++)res+=primes[i];
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 4552
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main(){

  int x, t;
  cin >> x >> t;

  if(x-t>=0){
    cout << x-t << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
goalA = 0
goalB = 0
for i in range(1, X):
    goalA += A.count(i)
for j in range(X + 1, N):
    goalB += A.count(j)
print(min(goalA, goalB))


Measured memory_bytes: 3060
using System;
using System.Linq;

namespace AtCoder.DP
{
    class EDPC_M
    {
        public static void Main()
        {
            var nk = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var n = nk[0];
            var k = nk[1];

            const long mod = 1000000007;
             
            var dp = new long[k + 1];

            var acc = 0;
            for (int i = 1; i <= n; i++)
            {
                var next = new long[k + 1];
                acc += a[i - 1];
                next[0] = 1;
                for (int j = 1; j <= Math.Min(acc, k); j++)
                {
                    next[j] = dp[j] + next[j - 1];
                    if (j > a[i - 1])
                        next[j] -= dp[j - 1 - a[i - 1]];
                    next[j] %= mod;
                }
                dp = next;
            }
            Console.WriteLine(dp[k] < 0 ? dp[k] + mod : dp[k]);
        }
    }
}


Measured memory_bytes: 32344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;
const int N = 200;

int n,m;
char s[N][N];
int f[N][N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>s[i]+1;
	memset(f,INF,sizeof(f));
    f[1][1]=(s[1][1]=='#');
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(i>1) f[i][j]=min(f[i][j],f[i-1][j]+(s[i-1][j]!=s[i][j]));
			if(j>1) f[i][j]=min(f[i][j],f[i][j-1]+(s[i][j-1]!=s[i][j]));
		}
	}
	cout<<(f[n][m]+1)/2<<'\n';
	return 0;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	s = "R" + s + "L";
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (s[i] == 'L') {
			if (s[i-1] == 'L') ans++;
		}
		else {
			if (s[i+1] == 'R') ans++;
		}
	}
	cout << min(ans+k*2, n-1) << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

int main() {
	std::string s;

	std::cin >> s;

	int g = 0, p = 0;
	int count = 0;

	for (int  i = 0; i < s.length(); i++) {
		if (g > p) {
			// グーもパーも出せる
			if (s[i] == 'p') {
				p++;
			} else {
				p++;
				count++;
			}
		} else {
			// グーしか出せない
			if (s[i] == 'p') {
				count--;
			}
			g++;
		}
	}

	std::cout << count << std::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;

int main() {
  int n;
  cin >> n;
  int a[2][n];
  rep(i, 2)rep(j, n) cin >> a[i][j];
  int l[n], r[n];
  l[0] = a[0][0]; r[n-1] = a[1][n-1];
  rep(i, n-1) l[i+1] = l[i] + a[0][i+1];
  rep(i, n-1) r[n-2-i] = r[n-1-i] + a[1][n-2-i];
  int ans = 0;
  rep(i, n) ans = max(ans, l[i]+r[i]);
  cout << ans << endl;
  return 0;
}

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

const int INF = 1 << 30;

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(auto &e : A) cin >> e;
    vector<vector<int>> G(N);
    for(int i = 0; i < N - 1; ++i) {
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    vector<int> dp(N + 1, INF);
    dp[0] = 0;
    stack<pair<int, int>> st;
    vector<int> ans(N);
    auto dfs = [&](auto &&dfs, int cur, int pre) -> void {
        auto it = lower_bound(dp.begin(), dp.end(), A[cur]);
        st.emplace(it - dp.begin(), *it);
        *it = A[cur];
        ans[cur] = prev(lower_bound(dp.begin(), dp.end(), INF)) - dp.begin();
        for(auto &to : G[cur]) {
            if(to == pre) continue;
            dfs(dfs, to, cur);
        }
        auto[i, n] = st.top(); st.pop();
        dp[i] = n;
    };
    dfs(dfs, 0, 0);
    for(auto &e : ans) cout << e << '\n';
    return 0;
}


Measured memory_bytes: 35128
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll n=in(),C=in();
    auto d=vec2<ll>(C,C);for(int i=0;i<C;++i)for(int j=0;j<C;++j)d[i][j]=in();
    auto c=vec2<ll>(n,n);for(int i=0;i<n;++i)for(int j=0;j<n;++j)c[i][j]=in()-1;

    auto colors=vec2<ll>(3,C);
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            ++colors[(i+1+j+1)%3][c[i][j]];
        }
    }

    ll ans=1000*500*500;
    for(int i=0;i<C;++i){
        for(int j=0;j<C;++j){
            for(int k=0;k<C;++k){
                if(i==j||j==k||k==i)continue;
                ll tmp=0;
                for(int l=0;l<C;++l)tmp+=d[l][i]*colors[0][l];
                for(int l=0;l<C;++l)tmp+=d[l][j]*colors[1][l];
                for(int l=0;l<C;++l)tmp+=d[l][k]*colors[2][l];
                ans=min(ans,tmp);
            }
        }
    }
    cout<<ans<<endl;
}


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

int main() {
  int n;
  cin >> n;
  int count = 0;
  vector<int> v(n);
  for(int i=0; i<n; i++) {
    cin >> v.at(i);
    if(v.at(i) != i+1)
      count++;
  }
  
  if(count == 0 || count == 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

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

#define N 200010
int h, w, n;
vector <int> v[N];

int main()
{
	while (scanf("%d%d", &h, &w) != EOF)
	{
		scanf("%d", &n); 
		int res = h; 
	    for (int i = 1; i <= h; ++i) v[i].clear(); 	
		for (int i = 1, x, y; i <= n; ++i)
		{
			scanf("%d%d", &x, &y);
			v[x].push_back(y);
		}
		int far = 1; 
		for (int i = 2; i <= h; ++i) 
		{
			if (v[i].empty()) 
			{
				++far;
				continue;
			}
			sort(v[i].begin(), v[i].end());
			if (v[i][0] <= far) 
			{
				res = i - 1;
				break;
			}
			bool flag = true; 
			for (auto it : v[i]) if (it == far + 1)
				flag = false;
			far += flag; 
		}
		printf("%d\n", res); 
	}
	return 0;
}


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

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

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

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


    ll tmp = 100;
    double r = 0.01;
    ll y = 0;
    while (true) {

        if (x <= tmp) {
            break;
        }

        tmp = tmp * (1 + r);
        y++;
    }

    cout << y << endl;
    return 0;
}

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

int main() {
  string s, answer = "None";
  cin >> s;
  vector<char> c(26, 0);
  for (int i = 0; i < s.size(); i++) c[(int)s.at(i) - (int)'a']++;//s[i]がaなら0,zなら25を増やす
  for (int i = 0; i < 26; i++) {
    if (c[i] == 0) {
      answer = (char)((int)'a' + i);
      break;
    }
  }
  cout << answer;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1000005,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int T,n,m,l,r,K;
struct node{int x,y,t;}a[10];
int calc(int n,int m){return (max(n,m)-1)/(min(n,m)+1)+1;}
int calc(int n,int m,int fl){
	if (fl) return min(n,m) ? ((max(n,m)-1)/min(n,m)+1) : inf;
	if (!n) return inf;
	if (!m) return n;
	return max((n-1)/(m+1)+1,(m-1)/n+1);
}
int work(int n,int m,int fl){
	int l=0,r=min(n/K,m),mid;
	while (l<r){
		mid=(l+r+1)>>1;
		if (calc(n-mid*K,m-mid,fl)<=K) l=mid;
		else r=mid-1;
	}
	return l;
}
int main(){
	T=read();
	while (T--){
		n=read();m=read();l=read();r=read();
		K=calc(n,m);
		int t=work(n,m,0);
		a[1]=(node){K,1,t};
		n-=K*t;m-=t;
		t=work(m,n,a[1].t>0);
		a[3]=(node){1,K,t};
		n-=t;m-=K*t;
		a[2]=(node){n,m,1};
		int now=0;
		for (int i=1;i<=3;i++)
		if (a[i].x+a[i].y){
			if (now<l){
				int t=min((l-now-1)/(a[i].x+a[i].y),a[i].t);
				a[i].t-=t;now+=(a[i].x+a[i].y)*t;
			}
			while ((a[i].t)&&(now<r)){
				int t=max(l-now,1);now=max(now,l-1);
				for (int j=t;(now<r)&&(j<=a[i].x+a[i].y);j++,now++) putchar((j<=a[i].x) ? 'A' : 'B');
				a[i].t--;
			}
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    
 
 
  int main(){
     lint h,w,k;
     cin>>h>>w>>k;
    lint ans=0;
    char x[h][w];
    rep(i,h){
        rep(j,w){
            cin>>x[i][j];
        }
    }
    bool h1[h];
    bool w1[w];
    rep(i,1<<h){

        fill(h1,h1+h,false);
        rep(j,h){
            if(i&(1<<j))h1[j]=true;
        }
        rep(a,1<<w){
            lint count=0;
             fill(w1,w1+w,false);
        rep(j,w){
            if(a&(1<<j))w1[j]=true;
        }
        rep(b,h){
            if(h1[b])continue;
            rep(c,w){
                if(w1[c])continue;
                if(x[b][c]=='#')count++;
            }
        }
        if(count==k)ans++;
        }
    }
    cout<<ans<<endl;
      
     }
     
 

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string s;
ll pa=1;
ll a=0;
ll b=0;
ll c=0;
int main(){
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='?'){
			c=c*3+b;
			b=b*3+a;
			a=a*3+pa;
			c%=MOD;
			b%=MOD;
			a%=MOD;
			pa*=3;
			pa%=MOD;
		}
		if(s[i]=='C'){
			c+=b;
			c%=MOD;
		}
		if(s[i]=='B'){
			b+=a;
			b%=MOD;
		}
		if(s[i]=='A'){
			a+=pa;
			a%=MOD;
		}
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 512
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    s = input()
    s = s[::-1]
    flag = True

    i = 0
    while i < len(s):
        if s[i:i + 5] == 'maerd' or s[i:i + 5] == 'esare':
            i += 5
        elif s[i:i + 6] == 'resare':
            i += 6
        elif s[i:i + 7] == 'remaerd':
            i += 7
        else:
            flag = False
            break
    print('YES' if flag else 'NO')

if __name__ == '__main__':
    main()


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    int k; cin>>k;
    int p = 1;
    int cnt = 0;
    while(1){
        if(n/p>=1){
            p*=k;
            cnt++;
        }
        else break;
    }
    print(cnt);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef SIR
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define err(...) 42
#endif

typedef long long ll;

using namespace std;

void solve() {
    int n; cin >> n;
    string a, b, c; cin >> a >> b >> c;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        set<char> s;
        s.insert(a[i]), s.insert(b[i]), s.insert(c[i]);
        if (s.size() == 2) ans += 1;
        else if (s.size() == 3) ans += 2;
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef SIR
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();
}

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

using namespace std;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)


int main() {
	ll N, M, C;
	cin >> N >> M >> C;
	ll cnt = 0;
	vector<ll> B(M);
	REP(i, M){cin>>B[i];}
	REP(i, N){
		vector<ll> A(M);
		REP(i, M){cin>>A[i];}
		ll sum = 0;
		REP(i, M){sum += A[i]*B[i];}
		if (sum > -C){cnt += 1;}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<map>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////
int main(){
    int ar[4];
    for(int i = 1;i<=3;i++){
        cin>>ar[i];
    }
    if(!(ar[1] == ar[2] && ar[2] == ar[3]) && (ar[1] == ar[2] || ar[1] == ar[3] || ar[2] == ar[3]))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.regex;

void main() {
	string l;
	string[] i;
	while ((l = stdin.readln.chomp) != "") i ~= l;
	auto d = i.join.toLower.replace(regex(`/[^a-z]/g`), "").dup.representation;
	foreach (cp; 97..123) "%c : %d".writefln(cp.to!char, d.count(cp));
}

Measured memory_bytes: 3196
#include <iostream>
#include <algorithm>
#include <list>

using namespace std;

void PrintAll(list<int> li, bool isReversed)
{
    auto it_begein = li.cbegin();
    auto it_end = li.cend();
    
    while(it_begein != it_end)
    {
        if(isReversed)
        {
            cout << *(--it_end);
        }
        else
        {
            cout << *(it_begein++);
        }

        if(it_begein != it_end) cout << ' ';
    }

    cout << endl;
}

int main() {
    list<int> li;

    int n;
    cin >> n;

    for(int i = 0; i < n; ++i)
    {
        int input;
        cin >> input;

        if(i % 2 == 0)
        {
            li.push_front(input);
        }
        else
        {
            li.push_back(input);
        }
    }

    PrintAll(li, n % 2 == 0);

    return 0;
}

Measured memory_bytes: 14720
/*
大毒瘤！
vector比邻接表快十倍！
vector比邻接表快十倍！
vector比邻接表快十倍！
vector比邻接表快十倍！
vector比邻接表快十倍！
*/
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <vector>
#include <set>
using namespace std;

void read(int &x)
{
	char ch=getchar();bool f=0;x=0;
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	if(f)x=-x;
} 

void read(long long &x)
{
	char ch=getchar();bool f=0;x=0;
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	if(f)x=-x;
}


vector <int> graph[1001];

void addedge(int u,int v)
{
	graph[u].push_back(v);
}

int vis[1001][1001];
struct
{
	int first,second;
}edge[200001];
int mark[1001];
int times=1;
int tmp;

void dfs(int from,int now)
{
	vis[from][now]++;
	mark[now]=times;
	for(auto to:graph[now])
	{
		if(to==from)continue;
		if(vis[from][to]<2&&mark[to]!=times)
		{
			dfs(from,to);
		}
	}
}

int main()
{
//	freopen("sep2_0.in","r",stdin);
//	freopen("sep.out","w",stdout);
	int n,m;
	read(n);read(m);
	for(int i=0;i<m;i++)
	{
		int from,to;
		read(from);read(to);
		addedge(from,to);
		edge[i].first=from;
		edge[i].second=to;
	}
	for(int i=1;i<=n;i++)
	{
		for(auto to:graph[i])
		{
			if(vis[i][to]<2)
			{
				times++;
				dfs(i,to);
			}
		}
	}
	//return 0;
/*	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cout<<"("<<vis[i][j]<<","<<vis2[i][j]<<")";
		}
		cout<<endl;
	}*/
	for(int i=0;i<m;i++)
	{
		int from=edge[i].first,to=edge[i].second;
		if(vis[to][from])
		{
			if(vis[from][to]>1)
			{
				puts("same");
			}
			else
			{
				puts("diff");
			}
		}
		else
		{
			if(vis[from][to]>1)
			{
				puts("diff");
			}
			else
			{
				puts("same");
			}
		}
	}
	return 0;
}
/*
3 3
1 2
1 3
2 3

2 2
1 2
2 1
*/


Measured memory_bytes: 8192
# -*- coding: utf-8 -*-
from sys import stdin

def insertionSort(A, N):  #N個の要素を含む0−オリジンの配列
  print(' '.join(map(str, A)))
  for i in range(1, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
      A[j + 1] = A[j]
      j -= 1
    A[j + 1] = v
    print(' '.join(map(str,A)))

N = int(stdin.readline().rstrip())
A = list(map(int, stdin.readline().split()))

insertionSort(A, N)



Measured memory_bytes: 5612
import heapq
from itertools import repeat, starmap
from operator import mul

R = lambda: map(int, input().split())
n, m = R()
a = list(zip(R(), repeat(1)))
heapq.heapify(a)
for _ in range(m):
    b, c = R()
    i = b
    while i:
        x, y = a[0]
        if x >= c:
            break
        d = min(i, y)
        i -= d
        y -= d
        if y:
            heapq.heapreplace(a, (x, y))
        else:
            heapq.heappop(a)
    heapq.heappush(a, (c, b - i))
print(sum(starmap(mul, a)))


Measured memory_bytes: 21548
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 300005
using namespace std;
char s[maxn];
int cnt[maxn];
int main()
{
	int n;
	scanf("%d", &n);
	scanf("%s", s + 1);
	for(int i = 1; i <= n; i++)
	{
		cnt[i] = cnt[i - 1];
		if(s[i] == 'W') cnt[i]++;
	}
	int ans = n;
	for(int i = 1; i <= n; i++)
	{
		int nans = cnt[i - 1];
		if(i != n) nans += (n - i - (cnt[n] - cnt[i]));
		ans = min(ans, nans);
	}
	printf("%d\n", ans);
	return 0;
 } 

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

from collections import deque
import heapq
import math
import bisect

H, W = map(int, input().split())
grid = [input() for i in range(H)]
dist = [[-1]*W for i in range(H)]
q = deque()
dx, dy = [1, 0, -1, 0], [0, 1, 0, -1]


def bfs():
    res = 0
    while(len(q)):
        ci, cj = q.popleft()
        for i in range(4):
            ni, nj = ci + dx[i], cj + dy[i]
            if 0<=ni<H and 0<=nj<W and dist[ni][nj]==-1:
                dist[ni][nj] = dist[ci][cj] + 1
                res = max(res, dist[ni][nj])
                q.append((ni, nj))

    return res


def main():
    for i in range(H):
        for j in range(W):
            if grid[i][j] == "#":
                dist[i][j] = 0
                q.append((i, j))

    print(bfs())


if __name__ == '__main__':
    main()


Measured memory_bytes: 88156
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	string s;
	cin >> s;
	bool ok = true;
	for (int i = 0; i < s.size(); i += 2) {
		//cout << s[i] << endl;
		if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
			ok = false;
			//cout << 99 << endl;
		}
	}
	for (int i = 1; i < s.size(); i += 2) {
		//cout << s[i] << endl;

		if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
			ok = false;
			//cout << -22 << endl;
		}
	}
	if (ok) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
ll A[20];
vector<l_l> dp[20][20];

void f(int start, int end) {
    vector<l_l> tmp;
    for(int eat = start; eat < end; eat++) {
        for(int i = 0; i < dp[start][eat].size(); i++) {
            for(int j = 0; j < dp[eat + 1][end].size(); j++) {
                ll val1 = dp[start][eat][i].first;
                val1 += dp[start][eat][i].second;
                val1 += dp[eat+1][end][j].first;
                val1 += A[eat];
                ll val2 = dp[start][eat][i].second;
                val2 += dp[eat+1][end][j].first;
                val2 += dp[eat+1][end][j].second;
                val2 += A[eat];
                tmp.emplace_back(val1, val2);
            }
        }
    }
    sort(tmp.begin(), tmp.end());
    dp[start][end].push_back(tmp[0]);
    ll  minimum = tmp[0].second;
    for(int i = 1; i < tmp.size(); i++) {
        if(chmin(minimum, tmp[i].second)) {
            dp[start][end].push_back(tmp[i]);
        }
    }
    /*
    cerr << "----" << start << "----" << end << "----" << endl;
    for(int i = 0; i < dp[start][end].size(); i++) {
        cerr << dp[start][end][i].first << " " << dp[start][end][i].second << endl;
    }
    */
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> A[i];
    for(int i = 1; i <= N; i++) dp[i][i].push_back({0,0});
    for(int delta = 1; delta <= N - 2; delta++) {
        for(int start = 2; start + delta <= N; start++) {
            f(start, start + delta);
        }
    }
    ll ans = LONG_MAX;
    for(int i = 0; i < dp[2][N].size(); i++) {
        chmin(ans, A[1] + A[N] + dp[2][N][i].first + dp[2][N][i].second);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int a,b;
		String op = "+";
		while (!op.equals("?")) {
		a = scan.nextInt();
		op = scan.next();
		b = scan.nextInt();

		if (0 <= a && a <= 20000 && 0 <= b && b <= 20000) {

				if (op.equals("/") && b == 0) {
					break;
				}
				switch (op) {
				case "+":
					System.out.println(a + b);
					break;

				case "-":
					System.out.println(a - b);
					break;
				case "*":
					System.out.println(a * b);
					break;

				case "/":
					System.out.println(a / b);
					break;
				}
			}
		}

	}

}

Measured memory_bytes: 26172
#include<cstdio>
int n,a,b,h[100000],i,l,r;
long x,m;
main(){
  for(scanf("%d%d%d",&n,&a,&b),a-=b;i<n;l=1,r=1e9)scanf("%d",h+i++);
  while(l<r){
    m=(l+r)/2;
    for(x=i=0;i<n;++i)h[i]>m*b?x+=(h[i]-m*b+a-1)/a:0;
    x<=m?r=m:l=m+1;
  }
  printf("%d\n",l);
}


Measured memory_bytes: 512
package main

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

var (
	dp []int
	g  [][]int
)

func rec(now int) int {
	if dp[now] != -1 {
		return dp[now]
	}

	ret := 0
	for _, next := range g[now] {
		ret = max(ret, rec(next)+1)
	}

	dp[now] = ret
	return ret
}

func solve() {
	n, m := getInt(), getInt()

	dp = make([]int, n+1)
	for i := range dp {
		dp[i] = -1
	}

	g = make([][]int, n)
	for i := range g {
		g[i] = make([]int, 0)
	}
	for i := 0; i < m; i++ {
		x, y := getInt()-1, getInt()-1
		g[x] = append(g[x], y)
	}

	ans := -1
	for now := 0; now < n; now++ {
		ans = max(ans, rec(now))
	}

	fmt.Fprintln(wr, ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


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

using namespace std;

typedef long long ll;
typedef pair <int, int> P;
int main(){

  ll h,n;
  cin >>h>>n;
  ll a[n], b[n];
  ll max_a=0;
  for (ll i=0; i<n; i++){
  cin>>a[i]>>b[i];
  if (max_a<a[i])max_a=a[i];
  }
  ll inf=100000000;
  ll d[h+max_a];
  for (ll i=0; i<h+max_a; i++){
    d[i]=inf;
  }

  d[0]=0;
  for (ll i=0; i<n; i++){
    for (ll j=0; j<h; j++){
      d[j+a[i]]=min(d[j+a[i]],d[j]+b[i]);
  }
  }
  ll ans;
  ans=d[h];
  for (ll i=h; i<h+max_a; i++){
 ans=min(d[i],ans);
 

  }

cout<<ans<<endl;
}


Measured memory_bytes: 384
def main():
    N = int(input())
    T = list(map(int, input().split()))
    A = list(map(int, input().split()))
    MOD = 10 ** 9 + 7

    ans = [0] * N
    H = [0] * N
    tmp = 0
    for i in range(N):
        if tmp < T[i]:
            tmp = T[i]
            ans[i] = 1
            H[i] = T[i]
        else:
            ans[i] = T[i]
            H[i] = T[i]

    tmp = 0
    for i in range(N-1,-1,-1):
        if tmp < A[i]:
            tmp = A[i]
            ans[i] = min(ans[i],1)
            H[i] = min(H[i],A[i])
        else:
            ans[i] = min(A[i],ans[i])
            H[i] = min(H[i],A[i])

    tmp = 0
    for i in range(N):
        tmp = max(tmp, H[i])
        if tmp != T[i]:
            print(0)
            exit()

    tmp = 0
    for i in range(N-1,-1,-1):
        tmp = max(tmp, H[i])
        if tmp != A[i]:
            print(0)
            exit()
    

    cnt = 1
    for i in ans:
        cnt *= i
        cnt %= MOD
    
    print(cnt)

if __name__ == "__main__":
    main()

Measured memory_bytes: 82916
#pragma once

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, char, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

int main(void)
{
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	map<string, int> m;
	m[s] = a;
	m[t] = b;
	string u;
	cin >> u;
	m[u]--;
	cout << m[s] << " " << m[t] << endl;
	return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

class Node{
	Node[] adjnodes;
	Node[] kids;
	Node parent;
	int id;
	this(int id){
		this.id = id;
		}
	void add(Node nd){
		this.adjnodes ~= nd;
		nd.adjnodes ~= this;
		}
	void setKids(){
		foreach(nd; this.adjnodes){
			if(!this.parent || nd.id != this.parent.id){
				this.kids ~= nd;
				nd.parent = this;
				nd.setKids;
				}
			}
		}
	int getStatus(){ // 0: I am single; 1: I am paired; 2: Cannot pair
		if(this.kids.length == 0){
			return 0 /* single */;
			}
		else if(this.kids.length == 1){
			int s = this.kids[0].getStatus;
			if(s == 0 /* single */) return 1 /* paired */;
			else if(s == 1) return 0 /* single */;
			else return 2 /* error */;
			}
		else{
			int s = 0 /* single */;
			foreach(nd; this.kids){
				int s1 = nd.getStatus;
				if(s1 == 2 /* error */) return 2 /* error */;
				if(s1 == 0 /* single */){
					if(s == 0 /* single */) s = 1 /* paired */;
					else return 2 /* error */;
					}
				}
			return s;
			}
		}
	}

void main(){
	int n = read.to!int;
	
	Node[int] nodes;
	foreach(i; 1 .. n + 1){
		nodes[i] = new Node(i);
		}
	
	foreach(i; 1 .. n){
		int a = read.to!int;
		int b = read.to!int;
		nodes[a].add(nodes[b]);
		}
	
	nodes[1].setKids;
	
	string ans;
	if(nodes[1].getStatus == 1 /* paired */) ans = "Second";
	else ans = "First";
	
	ans.writeln;
	}

Measured memory_bytes: 23292
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,m;
    cin>>n>>m;
    int a[n];
    rep(i,n)cin>>a[i];
    int b[n];
    rep(i,n)b[i]=i;
    vector<int> ord(2*n);
    iota(ord.begin(),ord.end(),0);
    sort(ord.begin(),ord.end(),[&](int x,int y){
        int xx=(x<n?a[x] : b[x-n]);
        int yy=(y<n?a[y] : b[y-n]);
        return xx>yy;
    });
    vector<int> usea(n), useb(n);
    rep(i,n){
        if(ord[i]<n)usea[ord[i]]=1;
        else useb[ord[i]-n]=1;
    }
    priority_queue<int> ma,mi;
    ll ans=0;
    rep(i,n){
        if(usea[i]&&useb[i])ma.push(min(a[i],b[i]));
        if(!usea[i]&&!useb[i])mi.push(min(-a[i],-b[i]));
        ans+=abs(a[i]-b[i]);
    }
    m=min(m, (int)ma.size());
    rep(i,m){
        int x=ma.top(), y=mi.top();
        ma.pop();mi.pop();
        ans+=2*(x+y);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 5580
#include <bits/stdc++.h>
#define MAX 500111
#define mod 1000000007
const long long  inf = 200000000000000000;
using namespace std;

long long a[MAX],mn = inf;
int n;
long long get(long long x){
    long long ans = 0 ;
    for(int i = 0; i < n; i++) ans += abs(x - a[i]);
    return ans;
}
int main(){ 
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
    cin>>n;
    for(int i = 0; i  < n ; i++){cin>>a[i];a[i] -= (i+1);}
    sort(a,a+n);
    for(int i = max(n/2 - 1,0)  ; i <= min(n/2 + 1,n-1) ; i++)mn = min(get(a[i]),mn);
    cout<<mn;
    return 0;
}

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

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

 if(a % 2 != b % 2) {
cout << "IMPOSSIBLE" << endl;
 }
  else {
cout << (a + b) / 2 << endl; 
} 
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define pb push_back
#define mk make_pair
#define ull unsigned long long
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
    fastIO;
    ll x,y;
    cin>>x>>y;
    ll ans=0;
    map<ll,ll>m;
    m.insert({1,300000});
    m.insert({2,200000});
    m.insert({3,100000});
    if(x>=1 && x<=3)
    {
        ans+=m[x];
    }
    if(y>=1 && y<=3)
    {
        ans+=m[y];
    }
    if(x==y && x==1)
    {
        ans+=400000;
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        long a = scanner.nextLong();
        long b = scanner.nextLong();

        if((a*b)%2 == 0){
            System.out.println("Even");
        }else{
            System.out.println("Odd");
        }
    }
}


Measured memory_bytes: 21716
a,b=gets.split.map &:to_i
a-=1;b-=1
ds=".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#"
d="...................................................................................................."
s="####################################################################################################"
print("100 100\n")
for k in 1..50
  if a>51 && k%2==1
    print("#{ds}\n")
    a-=50
  elsif a>0  && k%2==1
    for k in 1..100
      if a>0 && k%2==1
        print(".")
        a-=1
      else
        print("#")
      end
     end
      print("\n")
  else
    print("#{s}\n")
  end
end
#にゃ
print("#{d}\n")
for k in 1..49
  if b>51 && k%2==0
    print("#{ds}\n")
    b-=50
  elsif b>0  && k%2==0
    for k in 1..100
      if b>0 && k%2==1
        print("#")
        b-=1
      else
        print(".")
      end
     end
      print("\n")
  else
    print("#{d}\n")
  end
end


Measured memory_bytes: 1916
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <iomanip>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    int N; cin >> N;
    vector<double> x(N), y(N); rep (i, N) cin >> x[i] >> y[i];

    vi ord; rep(i, N) ord.push_back(i);
    double sum = 0, cnt = 0;

    do {

        rep (i, N-1) {

            sum += sqrt(pow(x[ord[i+1]] - x[ord[i]], 2.0) + pow(y[ord[i+1]] - y[ord[i]], 2.0));

        }
        cnt++;
    } while (next_permutation(ord.begin(), ord.end()));

    double ans = sum / cnt;
    cout<<fixed<<setprecision(8)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;
typedef long long LL;

int main(int argc, char* argv[]) {

#ifdef _MSC_VER
	while (true)
#endif
	{
		LL n = -1, k = -1, ans = 0;
		cin >> n >> k;
		if (n < 0) return 0;
		vector<LL> a(n), sum(n + 1);
		map<LL, LL> m;
		for (int i = 0; i < n; ++i) {
			cin >> a[i];
		}
		if (k > 1) {
			m[0] = 1;
			for (int i = 0; i < n; ++i) {
				sum[i + 1] = (sum[i] + a[i] + k - 1) % k;
				ans += m[sum[i + 1]];
				m[sum[i + 1]] += 1;
				if (i >= k - 2) {
					m[sum[i + 2 - k]] -= 1;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 15872
n = int(input())
s = []
for _ in range(n):
    tmp = list(input())
    tmp.sort()
    s.append(str(tmp))
cnt = 0
dict = {}
for x in s:
    if x in dict:
        cnt += dict[x]
        dict[x] += 1
    else:
        dict[x] = 1
print(cnt)

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    int sum=0;
    if(a==1)sum += 300000;
    if(a==2) sum += 200000;
    if(a==3) sum += 100000;
    if(b==1)sum += 300000;
    if(b==2) sum += 200000;
    if(b==3) sum += 100000;
    if(a==1 && b==1) sum += 400000;
    cout << sum << endl;

}

Measured memory_bytes: 892
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;

const int mod = 1000000007;

long long qpow(long long base,int tms)
{
	if(tms < 0) return 1;
	long long tmp = 1;
	while(tms)
	{
		if(tms & 1) tmp = tmp * base % mod;
		base = base * base % mod;
		tms >>= 1;
	}
	return tmp;
}

int f[2][2050];

int main()
{
	int n,k; scanf("%d%d",&n,&k);
	int cur = 0,lst = 1;
	f[0][0] = 1;
	for(int i = 1;i <= k - 1; ++ i)
	{
		cur ^= 1,lst ^= 1;
		memset(f[cur],0,sizeof(f[cur]));
		int sum = f[lst][0];
		for(int j = 1;j <= n; ++ j)
			f[cur][j] = (sum + f[lst][j]) % mod,sum = (sum + f[lst][j]) % mod;
		for(int j = 0;j < n; ++ j)
			f[cur][j] = f[cur][j + 1];
	}
	int ans = 0;
	for(int i = 0;i < n - k + 1; ++ i) ans = (ans + f[cur][i]) % mod;
	printf("%d\n",ans * 1ll * qpow(2,n - k - 1) % mod);
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn solve() -> usize {
    let a: usize = read();
    let b: usize = read();
    let c: usize = read();
    let x: usize = read();

    let mut cnt = 0;
    for i in 0..a + 1 {
        for j in 0..b + 1 {
            for k in 0..c + 1 {
                let sum = 500 * i + 100 * j + 50 * k;
                if sum == x {
                    cnt += 1;
                }
            }
        }
    }

    cnt
}

fn main() {
    println!("{}", solve());
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  for(int i=1;i<=9;i++)
    for(int j=1;j<=9;j++)
      if(i*j==n) drop("Yes");
  drop("No");
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
arr=[0]+list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(m):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
ans=0
for v in range(1,n+1):
  for u in g[v]:
    if arr[u]>=arr[v]:
      break
  else:
    ans+=1
print(ans)

Measured memory_bytes: 29428
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int main(){
	ll n,k;
	scanf("%lld%lld",&n,&k);
	if(k>(n-1)*(n-2)/2){
		puts("-1");
		return 0;
	}
	
	printf("%lld\n",n*(n-1)/2-k);
	rep(i,1,n)printf("1 %lld\n",i+1);
	rep(i,1,n)rep(j,i+1,n){
		if(k==0){
			printf("%lld %lld\n",i+1,j+1);
		}else{
			k--;
		}
	}
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  for(int i=1; i <= n; ++i){
    int x = i;
    if(x%3 == 0){
      cout << " " << i;
      continue;
    }
    do{
      if(x%10 == 3){
        cout << " " << i;
        break;
      }
    }while (x /= 10);
  }
  cout << endl;
  return 0;
}


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

int num[10][10][10];
 
int main(void)
{
    int n, i, j, ans = 0;
    cin >> n;
    
    for(i = 1; i <= n; i += 2) {
        int num = 0;
        for(j = 1; j <= i; j++) {
            if(i % j == 0)
                num++;
        }
        if(num == 8)
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
a = []
N.times { a << Array.new(gets.split.map(&:to_i)) }
a.sort! { |a, b| a[0] <=> b[0] }
remain = M
i = 0
total_pay = 0
while remain > 0 do
  if remain > a[i][1]
    total_pay += a[i][1] * a[i][0]
    remain -= a[i][1]
    i += 1
  else
    total_pay += remain * a[i][0]
    remain = 0
  end
end
puts total_pay

Measured memory_bytes: 10600