akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    string s;
    set<char> letras;
    cin >> s;

    for ( auto l : s ) letras.insert(l);

    for (char i = 'a'; i <= 'z'; i++ ) {
        if ( letras.find(i) == letras.end() ) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "None\n";

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<int> s(3);
    for(int i = 0; i < 3; i++) cin >> s.at(i);
    sort(s.begin(),s.end());
    cout << s.at(2)*10+s.at(1)+s.at(0) << endl;
    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

# Factoring by trial split
def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1
  
  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)
  
  if n!=1:
    l.append(n)
  
  return l

def main():
  n=I()

  l=[0]*1001

  for i in range(2,n+1):
    y=getPrimeList(i)
    for x in y:
      l[x]+=1

  sm=1
  for x in l:
    if x!=0:
      sm*=x+1

  return sm%mod

print(main())


Measured memory_bytes: 5840
#include<stdio.h>
int main(void){
  int n;
  int i;
  long long ans=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    if(i%3!=0 && i%5!=0)
      ans+=i;
  }
  printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int main()
{
	IO_OP;
	
	char c;
	cin >> c;
	if(c == 'A')
		cout << 'T' << endl;
	if(c == 'T')
		cout << 'A' << endl;
	if(c == 'C')
		cout << 'G' << endl;
	if(c == 'G')
		cout << 'C' << endl;
	
}



Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var x = long.Parse(Console.ReadLine());
        decimal money = 100;
        for (var i = 1; true; i++)
        {
            money = Math.Floor(money * 1.01m);
            if(money >= x)
            {
                Console.WriteLine(i);
                break;
            }
        }
    }
}

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

typedef long long ll;
typedef pair<int,int> pii;
const int N = 200010; 
const int LOGN = 20;
const ll oo = 1e18;

int n,a[N],ans = 0;
bool tk[N];
vector<int> cmp,mp[N];

int idx(int i){
  if(!binary_search(cmp.begin(),cmp.end(),i))return -1;
  return lower_bound(cmp.begin(),cmp.end(),i)-cmp.begin();
}
int main(){
  cin >> n;
  for (int i = 0; i < n; ++i)scanf("%d",a+i);
  for (int i = 0; i < n; ++i)cmp.push_back(a[i]);
  sort(cmp.begin(),cmp.end());
  cmp.resize(unique(cmp.begin(),cmp.end())-cmp.begin());

  for(int i = 30 ; i >= 0 ; --i){
    int cur = (1<<i);
    for(int j = 0 ; j < n ; ++j)mp[j].clear();
    for(int j = 0 ; j < n; ++j){
      if(tk[j])continue;
      int go = idx(cur-a[j]);
      int my = idx(a[j]);
      if(go == -1 || mp[go].size()==0){
        mp[my].push_back(j);
      }else{
        ans++;
        int f = mp[go].back();
        mp[go].pop_back();
        tk[f] = tk[j] = 1;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

const int N = 2e5 + 10;


void smain() {

    int n;
    string s,t;
    cin>>n>>s>>t;
    int ans=2*n;
    for(int i=0;i<n;i++){
        int k=i;
        bool fl=true;
        for(int j=0;k<n;k++,j++){
            if(t[j]!=s[k]){
                fl=false;
                break;
            }
        }
        if(fl){
            cout<<i+n;
            return;
        }
    }

    cout<<2*n;



}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>

const int MAXN = 510;

int K;
int a[MAXN][MAXN];

int main() {
	scanf("%d", &K);
	int n = std::min(500, K);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j) a[i][j] = (i + j - 2) % n + 1;
	for (int i = n + 1; i <= K; ++i)
		for (int j = 1, k = i - n; j <= n; j += 2, k = (k - 3 + n) % n + 1) a[j][k] = i;
	printf("%d\n", n);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j) printf("%d%c", a[i][j], " \n"[j == n]);
	return 0;
}

Measured memory_bytes: 2048
S = ['S {}'.format(i) for i in range(1, 14)]
H = ['H {}'.format(i) for i in range(1, 14)]
C = ['C {}'.format(i) for i in range(1, 14)]
D = ['D {}'.format(i) for i in range(1, 14)]
cards = S + H + C + D
n = int(input())
for _ in range(n):
    card = input()
    cards.remove(card)
for i in cards:
    print(i)


Measured memory_bytes: 5596
#include <iostream>

using namespace std;

int main() {
    char s[4];
    cin >> s;
    int sum = 0;
    for (int i = 0; i < 4; i++) {
        if (s[i] == '+') {
            sum += 1;
        } else {
            sum -= 1;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @author yamato
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);
		int L = scanner.nextInt();
		double x = L;
		BigDecimal div = new BigDecimal(String.valueOf(27.0));
		BigDecimal x2 = new BigDecimal(String.valueOf(x));
		BigDecimal ans = (x2.multiply((x2.multiply(x2))))
				.divide(div,7,RoundingMode.HALF_UP);
		System.out.println(ans.toPlainString());
		
	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <map>
using namespace std;
int main(int argc, char* argv[])
{
	int N,K;
	cin>>N>>K;
	map<int,int> aMap;
	map<int,int>::iterator mit;
	int A;
	for (int i=0;i<N;i++){
		cin>>A;
		mit=aMap.find(A);
		if (mit==aMap.end()){
			aMap[A]=1;
		}else{
			(*mit).second++;
		}
	}
	multimap<int,int> bMap;
	for (mit=aMap.begin();mit!=aMap.end();mit++){
		int num=(*mit).second;
		bMap.insert(multimap<int,int>::value_type(num,(*mit).first));
	}
	int k=bMap.size();
	int aw=0;
	int k1=k-K;
	if (k1>0){
		multimap<int,int>::iterator bmit;
		for (bmit=bMap.begin();bmit!=bMap.end();bmit++){
			aw+=(*bmit).first;
			k1--;
			if (k1==0){
				break;
			}
		}
	}
	cout<<aw<<endl;
	return 0;
}

Measured memory_bytes: 18944
table = [[0, 3, 5 ,2, 4, 0],
         [4, 0, 1, 6, 0, 3],
         [2, 6, 0, 0, 1, 5],
         [5, 1, 0, 0, 6, 2],
         [3, 0, 6, 1, 0, 4],
         [0, 4, 2, 5, 3, 0]]

l = list(map(int, input().split()))
for i in range(int(input())):
    u, f = map(int, input().split())
    print(l[table[l.index(u)][l.index(f)] - 1])




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


void solve(long long A, long long B, long long M, std::vector<long long> a, std::vector<long long> b, std::vector<long long> x, std::vector<long long> y, std::vector<long long> c){
    ll ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());

    for(int i = 0;i < M;i++){
        x[i]--,y[i]--;
        ans = min(ans, a[x[i]] + b[y[i]] - c[i]);
    }
    cout<<ans<<endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(A);
    for(int i = 0 ; i < A ; i++){
        scanf("%lld",&a[i]);
    }
    std::vector<long long> b(B);
    for(int i = 0 ; i < B ; i++){
        scanf("%lld",&b[i]);
    }
    std::vector<long long> x(M);
    std::vector<long long> y(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        scanf("%lld",&c[i]);
    }
    solve(A, B, M, std::move(a), std::move(b), std::move(x), std::move(y), std::move(c));
    return 0;
}


Measured memory_bytes: 4224
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a,b,c,f[3],g[3];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&a,&b,&c);
		f[0]=max(g[1],g[2])+a;
		f[1]=max(g[0],g[2])+b;
		f[2]=max(g[0],g[1])+c;
		g[0]=f[0],g[1]=f[1],g[2]=f[2];
	}
	printf("%d\n",max(max(f[0],f[1]),f[2]));
	return 0;
}

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

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

    int n;
    cin >> n;
    vector<int> P(n), Q(n);
    for(int i = 0; i < n; i++){
        cin >> P[i];
    }
    for(int i = 0; i < n; i++){
        cin >> Q[i];
    }

    
    vector<int> A(n);
    for(int i = 0; i < n; i++){
        A[i] = i + 1;
    }

    int ai = -1, bi = -1, cnt = 0;
    do{
        if(ai == -1){
            bool f = true;
            for(int i = 0; i < n; i++){
                if(A[i] == P[i]);
                else{
                    f = false;
                    break;
                }
            }
            if(f) ai = cnt;
        }
        if(bi == -1){
            bool f = true;
            for(int i = 0; i < n; i++){
                if(A[i] == Q[i]);
                else{
                    f = false;
                    break;
                }
            }
            if(f) bi = cnt;
        }
        if(ai != -1 and bi != -1){
            break;
        }
        cnt++;
    }while(next_permutation(A.begin(), A.end()));

    cout << abs(ai - bi) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define INT_MAX 1000000
#include <cstring>
#include <unordered_map>
#include <vector>
using namespace std;

long helper(vector<int>&val,  vector<int>&weights, int i, int n, int w, vector<vector<long>>& map)
{
  if (i>=n || w == 0)
    return 0;
  if (map[i][w] != 0)
  {
    return map[i][w];
  }
    
  if (weights[i] > w)
    return helper(val, weights, i+1, n, w, map);
  long ans = max(val[i] + helper(val, weights, i+1, n, w-weights[i], map), helper(val, weights, i+1, n, w, map));
  map[i][w] = ans;
  return ans;
}

int main()
{
  int n, w;
  cin >> n >> w;
  vector<int> val(n, 0);
  vector<int> weights(n, 0);
  vector<vector<long>> map(n, vector<long>(w+1, 0L));
  for(int i=0; i<n; i++)
    cin >> weights[i] >> val[i];
  cout<<helper(val, weights, 0, n, w, map);
  return 0;
}

Measured memory_bytes: 82340
#include<iostream>
#include<cstring>
//#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#define  si(a)       scanf("%d",&a)
#define  sl(a)       scanf("%lld",&a)
#define  sii(a,b)    scanf("%d%d",&a,&b)
#define  sll(a,b)    scanf("%lld%lld",&a,&b)
#define  queues      priority_queue
#define mod  10000007
#define mem(a)  memset(a,0,sizeof(a));
#define def(a) ((a)&(-a))
#define fi  first
#define se  second
#define mp  make_pair
#define  pb push_back
#define mem(a,b) memset(a,b,sizeof(a));
typedef long long ll;
const ll maxn=5000006;
//priority_queue<ll,vector<ll >,greater<ll > >q;
const ll INF=0x3f3f3f3f;
//const double E=exp(1);
//const double PI=acos(-1);
using namespace std;
//__builtin_popcount
//priority_queue

int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
ll kc(ll a,ll b){ll c=1;while(b){if(b&1)c=(c*a)%mod;a=(a*a)%mod;b>>=1;}return c;}
bool cmp(double x,double y){return x>y;}
int read(){int x=0,f=1;char s=getchar();for(; s>'9'||s<'0'; s=getchar()) if(s=='-') f=-1;for(; s>='0'&&s<='9'; s=getchar()) x=x*10+s-'0';return x*f;}
int a[maxn];
int b[maxn];
int c[maxn];
int main()
{
     ios::sync_with_stdio(false);
  /*int t;
  cin>>t;
  for(int i=1;i<=t;i++)
    cin>>a[i];
    int q=0,qq=0;;
  for(int i=1;i<t;i++)
    if(a[i]>a[i+1])
  {
      if(a[i]-a[i+1]==1&&!qq){qq=1;continue;}
      else q=1;

  }
  if(!q)cout<<"Yes\n";
  else cout<<"No\n";*/
  int a,b,c;
  cin>>a>>b>>c;
  if((a-b)>=c)cout<<0<<endl;
  else cout<<c-a+b<<endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		// 標準入力で情報を取ってくる
		Scanner sc = new Scanner(System.in);

		int nowBlock = 0;
		int gap = 0;
		int mostUpGap = 0;
		int mostDownGap = 0;
		StringBuffer strb = new StringBuffer();

		// 全体試行回数
		int AllattemptCount = sc.nextInt();

		// 試行回数分プレイ
		for (int i = 0; i < AllattemptCount; i++) {

			// リスト
			ArrayList<Integer> gapList = new ArrayList<Integer>();

			// 各セッションの試行回数
			int sessionAttemptCount = sc.nextInt();

			// 最初のブロックを格納
			int pastBlock = sc.nextInt();

			// 各セッションの試行回数
			for (int t = 0; t < (sessionAttemptCount - 1); t++) {

				// 入力された値を現在のブロックとする
				nowBlock = sc.nextInt();

				// 差分を計算
				gap = (nowBlock - pastBlock);

				// リストに追加
				gapList.add(gap);

				// リストに追加し終わったので、現在のブロックを一つ前のブロックとして登録し、次回に備える
				pastBlock = nowBlock;
			}

			// 並び替え
			Collections.sort(gapList);

			// 段差がない場合を考慮し、一番登りが高い段差と、下りが高い段差を決定
			if (gapList.get(0) > 0) {
				mostDownGap = 0;
			} else {
				mostDownGap = (gapList.get(0) * -1);
			}

			if (gapList.get(gapList.size()-1) < 0) {
				mostUpGap = 0;
			} else {
				mostUpGap = gapList.get(gapList.size()-1);
			}

			String row = mostUpGap + " " + mostDownGap + "\n";
			strb.append(row);
		}

		System.out.print(strb);
	}
}

Measured memory_bytes: 33836
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n, m;
	cin >> n >> m;
	vector<vector<bool>> graph(n, vector<bool>(n));
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		graph[a][b] = true;
		graph[b][a] = true;
	}
	vector<int> v(n - 1);
	rep(i, n - 1) v[i] = i + 1;
	int ans = 0;
	do {
		bool flag = true;
		if (!graph[0][v[0]]) flag = false;
		rep(i, n - 2) if (!graph[v[i]][v[i + 1]]) flag = false;
		if (flag) ans++;
	} while (next_permutation(all(v)));
	cout << ans << '\n';
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
R, G, B, N = map(int, input().split(' '))
ans = 0

import math
r_lim = int(math.ceil(N / R))
for r in range(0, r_lim + 1):
    n = N - R * r

    g_lim = int(math.ceil(n / G))
    for g in range(0, g_lim + 1):
        m = n - g * G
        if m >= 0 and m % B == 0:
            ans += 1

print(ans)



Measured memory_bytes: 40668
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <string>
#include <iomanip>
#include <queue>
using namespace std;

int que[100003];

int main(void)
{
    //float f;
    string s;
    //vector <float> f(10);
    //char a,b,c;
    long long int i=0,j,sum=0,amount=0,zero=0;
    long long int m,n,o,gen=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>m;
        sum+=m-1;
    }
    cout<<sum;
    return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>
#include <vector>
#include <complex>
#include <cstdio>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef complex<double> vec;

int main(){
    int n; cin >> n;
    rep(i,n){
        double xa,ya,ra,xb,yb,rb;
        cin>> xa>>ya>>ra>>xb>>yb>>rb;
        double dx=xa-xb, dy=ya-yb;
        double d=sqrt(dx*dx+dy*dy);
        int ans;
        if(d>ra+rb){
            ans=0;
        }else if(d+ra<rb){
            ans=-2;
        }else if(d+rb<ra){
            ans=2;
        }else{
            ans=1;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1232
def distance(Y,Z):
    sum = 0
    for y,z in zip(Y,Z):
        tmp = y-z
        tmp = tmp*tmp
        sum += tmp
    return sum**0.5

cnt = 0
N,D = map(int,input().split())
i = 0
X = []
while(i < N):
    X.append(list(map(int,input().split())))
    i += 1
i = 0
while(i < N-1):
    j = i+1
    while(j < N):
        if distance(X[i],X[j]).is_integer():
            cnt += 1
        j += 1
    i += 1
print(cnt)

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
    char S[4], T[4];
    scanf("%s%s", S, T);
    int res = 0;
    for(int i=0; i<3; i++){
        if(S[i] == T[i]){
            res++;
        }
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 128
/**
*    created: 01.07.2020 23:37:20
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const int MOD = 1000000007;
// const int MOD = 998244353;
const long double pi = acos(-1.0);
const int INF = 1LL << 60;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string a, b;
    cin >> a >> b;
    string s = a + b;
    int n = stoll(s);
    for (int i = 2; i * i <= n; i++) {
        if (i * i == n) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
char c[100][100];
int a[100][100];
int ans=0;
int vis[100][100],dis[100][100];
queue<pair<int,int> > q;
inline void bfs(int x,int y){
	while(!q.empty())q.pop();
	memset(vis,0,sizeof(vis));
	q.push(make_pair(x,y));vis[x][y]=1;dis[x][y]=0;
	while(!q.empty()){
		int x=q.front().first,y=q.front().second;q.pop();
		ans=max(ans,dis[x][y]);
		if(a[x+1][y] && !vis[x+1][y] && x+1<=n){
			dis[x+1][y]=dis[x][y]+1;
			vis[x+1][y]=1;
			q.push(make_pair(x+1,y));
		}
		if(a[x-1][y] && !vis[x-1][y] && x-1>=1){
			dis[x-1][y]=dis[x][y]+1;
			vis[x-1][y]=1;
			q.push(make_pair(x-1,y));
		}
		if(a[x][y+1] && !vis[x][y+1] && y+1<=m){
			dis[x][y+1]=dis[x][y]+1;
			vis[x][y+1]=1;
			q.push(make_pair(x,y+1));
		}
		if(a[x][y-1] && !vis[x][y-1] && y-1>=1){
			dis[x][y-1]=dis[x][y]+1;
			vis[x][y-1]=1;
			q.push(make_pair(x,y-1));
		}
	}
	return;
}


int main(){
	n=read();m=read();
	for(register int i=1;i<=n;i++){
		scanf("%s",c[i]+1);
		for(register int j=1;j<=m;j++){
			if(c[i][j]=='.')a[i][j]=1;
		}
	}
	for(register int i=1;i<=n;i++){
		for(register int j=1;j<=m;j++){
			if(a[i][j])bfs(i,j);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<string>
#include<queue>
#include<set>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
double na,nb;
string s;
int x[10];
int vis[10];
int n,m;
int main()
{
    cin>>n>>m;
    int flag=1;
    for(int i=0;i<m;i++)
    {
        int s,c;cin>>s>>c;
        if((n>1&&s==1&&c==0)||(vis[s]&&x[s]!=c))flag=0;
        else {x[s]=c;vis[s]=1;}
    }
    if(flag==0)cout<<-1<<endl;
    else
    {
        if(n==1&&m==0)cout<<0;
        else
        {
            for(int i=1;i<=n;i++)
            {
                if(i==1&&n>1&&x[i]==0)cout<<1;
                else cout<<x[i];
            }
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

unordered_map<ll, int> value5;
void init()
{
    ll num = 0;
    for(;;)
    {
        ll now = num*num*num*num*num;
        if (now>100000000000) break;
        value5[now] = num++;
    }
    unordered_map<ll, int>  new_value5(value5);
    for (auto v: value5)
        new_value5[-v.first] = -v.second;
    swap(value5, new_value5);
}

int main()
{
    init();
    ll x;
    cin >> x;
    ll num = 0;
    for (;;)
    {
        ll now = num*num*num*num*num;
        ll tgt = now - x;
        if (value5.count(tgt)>0)
        {
            cout << num << ' ' << value5[tgt] << endl;
            return 0;
        }
        // cout << num << endl;
        ++num;
    }
    return 0;
}


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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if (A == B && B == C ){
    cout << "No" << endl;
  }
  else if ( A != B && B != C && C != A ) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
 
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)      //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++) //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)    //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))        //array size
#define SORTD(a) sort(a,a+ASIZE(a),greater<int>()) //sort in descending order for array
#define SORTA(a) sort(a,a+ASIZE(a))                //sort in ascending order for array
#define SORTS(a) sort(a.begin(),a.end())           //sort in ascending order for string type
typedef long long LL;
typedef unsigned int UINT;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector< Vi > VVi;
 
void SCAN(int *a){scanf("%d",a);}                             //scan for type int
void SCAN(int *a,int n){int i;REP(i,n){scanf("%d",&a[i]);}}   //scan for type int array
void SCAN(UINT *a){scanf("%u",a);}                            //scan for type unsigned int
void SCAN(UINT *a,int n){int i;REP(i,n){scanf("%u",&a[i]);}}  //scan for type unsigned int array
void SCAN(LL *a){scanf("%lld",a);}                            //scan for type long long int
void SCAN(LL *a,int n){int i;REP(i,n){scanf("%lld",&a[i]);}}  //scan for type long long int array
void SCAN(char *c){scanf(" %c",c);}                           //scan for type char
void SCAN(char *c,int n){int i;REP(i,n){scanf(" %c",&c[i]);}} //scan for type char array
 
const int MOD = 1000000007;
const int INF = 1999999999;
const LL INFLL = 999999999999999;
 
const int DX4[4]= {-1,0,1,0};
const int DY4[4]= {0,-1,0,1};
 
//fill an N-dimensional array with val
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
	fill((T*)array,(T*)(array+N),val);
}
 
long double pascalTri(int n,int r){
	long double tri[n+1][n+1];
	int i,j;
	REP(i,n+1){REP(j,n+1){tri[i][j]=0;}}
	REP(i,n+1){
		REP(j,n+1){
			if(j>i){break;}
			if(j==0||j==i){tri[i][j]=1;}else{tri[i][j]=(tri[i-1][j-1]+tri[i-1][j]);}
		}
	}
	return tri[n][r];
}
 
 
int main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	LL n,a,b,c,ans;
	LL l[90];
	FILL(l,0);
	int i,j,k;
 
	SCAN(&n);

	l[0]=2;
	l[1]=1;

	REP2(i,2,n+1){
		l[i]=l[i-1]+l[i-2];
	}


	printf("%lld\n",l[n]);

	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S="CODEFESTIVAL2016";
string T;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>T;
	int ret=0;
	FOR(i,S.size()) ret+=S[i]!=T[i];
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;


const int SIZE = 1e5+100;

ll n;
int main(){
    cin >> n;
    cout << n*800 - (n/15)*200 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main()
{
  string s, p;

  cin >> s;
  s += s;
  
  cin >> p;

  if ( s.find(p) == string::npos )
    {
      cout << "No" << endl;
    }
  else
    {
      cout << "Yes" << endl;
    }
  
  return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define el "\n"
#define sp " "
typedef long long ll;

main()
{
	ios_base::sync_with_stdio(false);
		cin.tie(NULL);
  ll n,x,y;
  cin>>n;
  cin>>x;
  ll ans=1;
  for(int i=1;i<n;i++)
  {
  	cin>>y;
  	if(y<=x)
  	ans++,x=y;
  }
  cout<<ans;
  
}
  
  

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

const int MOD=1e9+7;
int A[2001], B[2001], D[2001][2001];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, M;
	cin>>N>>M; D[0][0]=1;
	for(int i=1;i<=N;i++) cin>>A[i], D[i][0]=1;
	for(int i=1;i<=M;i++) cin>>B[i], D[0][i]=1;
	for(int i=1;i<=N;i++) for(int j=1;j<=M;j++) {
		D[i][j]=(D[i-1][j]+D[i][j-1])%MOD;
		D[i][j]=(D[i][j]-D[i-1][j-1]+MOD)%MOD;
		if(A[i]==B[j]) D[i][j]=(D[i][j]+D[i-1][j-1])%MOD;
	}
	cout<<D[N][M]<<'\n';
	return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#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(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)
#define BIT(x, i) (((x) >> (i)) & 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<vll> vvll;

int main() {
  int n, k, m;
  while(cin >> n >> k >> m, n | k | m) {
    m--;
    vi list(n);
    REP(i, n) list[i] = i + 1;
    while(list.size() > 1) {
      list.erase(list.begin() + m);
      m = (m + k - 1) % list.size();
    }
    cout << list[0] << endl;
  }
}

Measured memory_bytes: 3124
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    println!("{}", max_acgt_len(s.as_str()))
}

fn max_acgt_len(s: &str) -> i32 {
    fn inner(rest: &mut std::str::Chars, current: i32, max: i32) -> i32 {
        if let Some(first_char) = rest.next() {
            if let Some(_) = "ACGT".find(first_char) {
                let next_indice = current + 1;
                inner(rest, next_indice, if max > next_indice { max } else { next_indice })
            } else {
                inner(rest, 0, max)
            }
        } else {
            max
        }
    }

    inner(&mut s.chars(), 0, 0)
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10;

#define int ll
ll grid[302][302], mnx[302][302], mny[302][302];

ll svkek[200][200];

signed main()
{
	fastInp;

	ll a, b;
	cin >> a >> b;


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

	

	for (int i = 0; i < a; i++) {
		for (int j = 0; j < b; j++) {
			ll vl = 0, vl2 = 0;
			if (i > 0) vl = grid[i - 1][j];
			if (j > 0) vl2 = grid[i][j - 1];

			if (i > 0) {
				mnx[i - 1][j] = abs(grid[i - 1][j] - grid[i][j]);
			}
			if (j > 0) {
				mny[i][j - 1] = abs(grid[i][j - 1] - grid[i][j]);
			}
		}
	}

	for (int i = a - 1; i >= 0; i--) {
		for (int j = b - 1; j >= 0; j--) {
			if (i > 0) {
				mnx[i - 1][j] = max(mnx[i - 1][j], mnx[i][j]);
				//mny[i - 1][j] = max(mny[i - 1][j], mny[i][j]);
			}
			if (j > 0) {
				mny[i][j - 1] = max(mny[i][j - 1], mny[i][j]);
				//mnx[i][j - 1] = max(mnx[i][j - 1], mnx[i][j]);
			}
		}
	}
	
	ll f = 100;
	ll m = 0, unus = 2, prv = 1;
	vector<tuple<ll, ll, string>> edges;
	for (int i = 0; i < f; i++) {
		edges.push_back({ prv, unus, "X" });
		prv = unus;
		unus++;
	}

	prv = unus;
	unus++;
	for (int i = 0; i < f; i++) {
		edges.push_back({ prv, unus, "Y" });
		prv = unus;
		unus++;
	}

	edges.push_back({ prv, 300, "0" });

	for (int i = 0; i <= f; i++) {
		for (int j = 0; j <= f; j++) {
			ll c = 0;
			for (int t = 0; t < a; t++) {
				for (int k = 0; k < b; k++) {
					c = max(c, grid[t][k] - ((t + 1) * (i) + (k + 1) * (j)));
				}
			}
			svkek[i][j] = c;
			edges.push_back({ i + 1, unus - (j + 1), to_string(c) });
		}
	}

	for (int x = 1; x <= a; x++) {
		for (int y = 1; y <= b; y++) {
			ll z = 10000;
			for (int i = 0; i <= f; i++) {
				for (int t = 0; t <= f; t++) {
					z = min(z, svkek[i][t] + (i * x) + (t * y));
				}
			}
			if (z != grid[x - 1][y - 1]) {
				cout << "Impossible";
				return 0;
			}
		}
	}

	cout << "Possible\n";
	cout << 300 << " " << edges.size() << "\n";

	for (auto cur : edges) {
		cout << get<0>(cur) << " " << get<1>(cur) << " " << get<2>(cur) << "\n";
	}

	cout << 1 << " " << 300 << "\n";

	return 0;
}

Measured memory_bytes: 4396
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	
	int m=0;
	
	while(1){
		m++;
		int n;
		double x[51],y[51];
		cin>>n;
		if(n==0)return 0;
		for(int i=0;i<n;i++){
			cin>>x[i]>>y[i];
		}
		double s=x[0]*y[n-1]-x[n-1]*y[0];
		for(int i=0;i<n-1;i++){
			s+=x[i+1]*y[i]-x[i]*y[i+1];
		}
		printf("%d %.1f\n",m,s/2);
	}
	
}

Measured memory_bytes: 0
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
    "math"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func main() {
    sc.Split(bufio.ScanWords)
    sc.Scan()
    a, _ := strconv.Atoi(sc.Text())
    sc.Scan()
  
    var b float64
    b, _ = strconv.ParseFloat(sc.Text(), 64) 
    fmt.Print(int(math.Round(b*100))*a/100)
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
set<string> set_substring;
set<string>::iterator it;
string str,minstr;
char sz[5001];
void ProcessSubString(string s,int n)
{
	int i,j;
	for(i=1;i<=n;i++)
	{
		for(j=0;j<n-i+1;j++)
		{
			set_substring.insert(s.substr(j,i));
		}
	}
}
int main()
{
	scanf("%s",sz);
	str=sz;
	int k,i,n;
	scanf("%d",&k);
	minstr=str;
	n=str.length();
	if(n<=k)
	{
		ProcessSubString(str,n);
	}
	else
	{
		for(i=0;i<n-k;i++)
		{
			if(str.substr(i,k)<minstr)
			{
				minstr=str.substr(i,k);
				ProcessSubString(minstr,k);
			}
		}
		ProcessSubString(str.substr(n-k),k);
	}
	it=set_substring.begin();
	for(i=0;i<k-1;i++)
		it++;
	printf("%s",(*it).c_str());
	return 0;
}

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

using namespace std;

int main(){
	int n,s,e,w;
	n=0;
	s=0;
	e=0;
	w=0;
	string S;
	cin >> S;
	for(int i=0;i<S.size();i++){
		if(S[i]=='N'){
			n+=1;
		}else if(S[i]=='W'){
			w+=1;
		}else if(S[i]=='E'){
			e+=1;
		}else{
			s+=1;
		}
	}
	if(n*s>0&&e*w>0){
		cout <<"Yes"<<endl;
	}else if(n==0&&s==0&&e*w>0){
		cout <<"Yes"<<endl;
	}else if(e==0&&w==0&&n*s>0){
		cout <<"Yes"<<endl;
	}else{
		cout <<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int mod){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%mod;Rac[n-1]=modInv(Fac[n-1],mod);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 18;
int n, a[N][2], DP[1<<N][N*2+1], ma;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(j, 0, 2) FOR(i, 0, n) cin >> a[i][j];
  {
    V<int> z;
    FOR(i, 0, n) FOR(j, 0, 2) z.pb(a[i][j]);
    z.pb(0);
    uniq(z);
    FOR(i, 0, n)FOR(j, 0, 2) a[i][j] = lower_bound(all(z), a[i][j])-z.begin();
    ma = sz(z);
  }
  Fill(DP, IINF);
  FOR(i, 0, ma) DP[0][i] = 0;
  FOR(i, 1, 1<<n){
    int d=pcnt(i), p=d;
    FOR(k, 0, n) if(i&(1<<k)){
      d--;
      int v = a[k][(p+k+1)%2];
      mins(DP[i][v], DP[i^(1<<k)][v]+d);
    }
    FOR(j, 1, ma) mins(DP[i][j], DP[i][j-1]);
  }
  if(DP[(1<<n)-1][ma-1]==IINF){
    cout << -1 << endl;
    return 0;
  }
  cout << DP[(1<<n)-1][ma-1] << endl;
}

Measured memory_bytes: 38144
#include <iostream>
#include <climits>

using namespace std;


#define MAX 200000


unsigned long cnt_inv = 0;
unsigned long L[MAX / 2 + 1], R[MAX / 2 + 1];
void merge(unsigned long A[], int l, int m, int r)
{
    for (int i = l; i < m; i++)
        L[i - l] = A[i];
    for (int i = m; i < r; i++)
        R[i - m] = A[i];
    L[m - l] = ULONG_MAX;
    R[r - m] = ULONG_MAX;

    int i, j;
    for (i = j = 0; i + j < r - l; ) {
        if (L[i] <= R[j]) {
            A[l + i + j] = L[i++];
        } else {
            A[l + i + j] = R[j++];
            cnt_inv += (m - l - i);
        }
    }
}


void merge_sort(unsigned long A[], int l, int r)
{
    if (r - l > 1) {
        int m = (l + r) / 2;
        merge_sort(A, l, m);
        merge_sort(A, m, r);
        merge(A, l, m, r);
    }
}


unsigned long A[MAX];
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> A[i];
    merge_sort(A, 0, n);
    cout << cnt_inv << endl;

    return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  int sum = 0;
  
  for (int i = A; i <= B; i++) {
    int x = i;
    int n1 = x % 10;
    x = x / 10;
    int n2 = x % 10;
    x = x / 10;
    //int n3 = x % 10;
    x = x / 10;
    int n4 = x % 10;
    x = x / 10;
    int n5 = x;
    
    if (n1 == n5 && n2 == n4) {
      sum++;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

using namespace std;
int N, K;

int main() {
  string s;
  for (int i=0; i<3; i++) {
    cin >> s;
    cout << s.at(i);
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
const int n=20;
struct edge{
    ll from,to,len;
};
int main(){
    ll l;cin>>l;
    l--;
    vector<edge> ans;
    int cur=1;
    while(l>0){
        if(l%2==0){
            ans.push_back({cur,n,l});
            l--;
        }
        ans.push_back({cur,cur+1,0});
        ans.push_back({cur,cur+1,(l+1)/2});
        l/=2;
        cur++;
    }
    while(cur!=n){
        ans.push_back({cur,cur+1,0});
        cur++;
    }
    cout<<n<<" "<<ans.size()<<endl;
    for(auto pp:ans){
        cout<<pp.from<<" "<<pp.to<<" "<<pp.len<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>>
#define CO cout<<
#define EN <<endl
typedef long long ll;
using namespace std;

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

int main() {
	string a; cin >> a;
	string b; cin >> b;
	int c = stoi(a + b);
	for (int i = 0; i*i <= 100100;i++) {
		if (c == i * i) { CO "Yes" EN; return 0; }
	}
	CO "No" EN;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  REP(i, N){
    cin >> A[i];
    B[i]=A[i];
  }
  
  sort(ALL(B));
  REP(i,N){
    if(A[i]>=B[N/2]){
      cout << B[N/2-1] << endl;
    }else{
      cout << B[N/2] << endl;
    }
  }
}

Measured memory_bytes: 3840
n, y = map(int, input().split())
f = False
import math

m1 = math.ceil(y / 10000)
for i in range(m1 + 1):
    if y % 1000 != 0:
        break

    s = y - 10000 * i
    m2 = math.ceil( s / 5000)

    for j in range(m2 + 1):
        s = y - 10000*i - 5000*j
        k = s // 1000
        if k < 0:
            continue
        if i + j + k == n and 10000*i + 5000*j + 1000*k == y:
            f = True
            break
    if f:
        break

if f is False:
    print("-1 -1 -1")
else:
    print("{0} {1} {2}".format(i, j, k))

Measured memory_bytes: 40924
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>
 
 
int main()
{
    long int n, k; std::cin >> n >> k;
    std::vector<long int> h(n);
    for(int i=0; i<n; i++) std::cin >> h[i];
    std::sort(h.begin(), h.end());
    
    long int ans = 10000000000;
    for(int i=0; i+k-1<n; i++)
    {
        ans = std::min(ans, h[i+k-1]-h[i]);
    }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N; cin >> N;
    int tmp = N % 10;
    string ans = "hon";
    if(tmp == 0) ans = "pon";
    if(tmp == 1) ans = "pon";
    if(tmp == 6) ans = "pon";
    if(tmp == 8) ans = "pon";
    if(tmp == 3) ans = "bon";
    cout << ans << endl;
}

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

using namespace std;
using i64 = long long;

i64 table[100001];

int main(){
    i64 n,q,sum{};
    cin>>n;
    for(i64 i=0;i<n;i++){
        i64 a;
        cin>>a;
        sum+=a;
        table[a]++;
    }
    cin>>q;
    i64 ans[q];
    for(i64 i=0;i<q;i++){
        i64 b,c;
        cin>>b>>c;
        sum+=(c-b)*table[b];
        table[c]+=table[b];
        table[b]=0;
        ans[i]=sum;
    }
    for(i64 i=0;i<q;i++){cout<<ans[i]<<endl;}

    return 0;
}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin >> n;
    bool t = true;
    bool t2 = true;
    vector<long long> v(n);
    for(int i=0;i<n;i++){
        cin >> v[i];
        if(v[i] == 0){
            cout << 0 << endl;
            t = false;
            break;
        }
    }
    if(t){
        long long a = v[0];
        for(int i=1;i<n;i++){
            if(a>1000000000000000000/v[i]){
                cout << -1 << endl;
                t2 = false;
                break;
            }else{
                a *= v[i];
            }
        }
        if(t2)cout << a << endl;
    }
}


Measured memory_bytes: 4020
#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>;

int main() {
  ll n,Max=0,a,ans=0;
  cin >> n;
  rep(i,n){
    cin >> a;
    Max = max(Max,a);
    if(Max>a){
      ans += (Max - a);
    }
  }
  cout << ans << endl;
  return 0;
}





Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

ll dp[62][2];

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

    rep(i,62) rep(j,2) dp[i][j] = -1;

    ll res = 0;
    dp[0][0] = 0;
    rep(i,60) rep(j,2){
        ll mask = 1LL <<(60-i-1);

        int num = 0;
        rep(h,n) if (v[h] & mask) num++;

        ll cost0 = mask * num;
        ll cost1 = mask * (n-num);

        if (dp[i][1] != -1){
            dp[i+1][1] = max(dp[i+1][1],dp[i][1]+max(cost0,cost1));
        }
        if (dp[i][0] != -1){
            if (K & mask){
                dp[i+1][1] = max(dp[i+1][1],dp[i][0]+cost0);
            }
        }
        if (dp[i][0] != -1){
            if (K & mask){
                dp[i+1][0] = max(dp[i+1][0],dp[i][0] + cost1);
            }
            else dp[i+1][0] = max(dp[i+1][0],dp[i][0] + cost0);
        }
    }
    cout << max(dp[60][0],dp[60][1]) << endl;

    
    
    
    return 0;

}


Measured memory_bytes: 4036
while line = gets do
  count = Array.new(14){0}
  (hand=line.split(",").map(&:to_i)).each{|x|
    count[x]+=1
  }
  if count.include?(4)  || count.include?(5)
    puts "four card"
  elsif count.include?(2)
    if count.include?(3)
      puts "full house"
    elsif count.index(2)!=count.rindex(2)
      puts "two pair"
    else puts "one pair"
    end
  elsif count.include?(3)
    puts "three card"
  elsif count.join=~/11111/ || count[1]==1&&count[10..13]==[1,1,1,1]
    puts "straight"
  else
    puts "null"
  end
end

Measured memory_bytes: 6040