akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define cst() int __t;scanf("%d",&__t);while(__t--)
#define rep(i,s,t) for(int i=s;i<t;++i)
#define repb(i,s,t) for(int i=s;i<=t;++i)
#define lepb(i,s,t) for(int i=s;i>=t;--i)
#define mst(a,b) memset(a,b,sizeof(a))
#define mcpy(des,sor) memcpy(des,sor,sizeof(sor))
#define pt(x) cout<<#x<<"="<<x<<" "
#define ptl(x) cout<<#x<<"="<<x<<endl
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
template<class T> void Max(T &a,T b){a<b?a=b:0;}
template<class T> void Min(T &a,T b){a>b?a=b:0;}
typedef long long ll;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
const ll mod = 998244353;
#define maxn 20006

int main()
{
//	freopen("1.txt","r",stdin);
    int h,w,n,a[maxn],p[200][200];
    int d[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
    cin>>h>>w>>n;
    repb(i,1,n)cin>>a[i];
    int i,j,k,o;
    mst(p,inf);
    repb(i,1,h)repb(j,1,w)p[i][j]=0;
    for(i=j=k=1,o=0;k<=n;++k)
    {
        while(a[k]--)
        {
            p[i][j]=k;
            if(p[i+d[o][0]][j+d[o][1]]!=0)o=(o+1)%4;
            i+=d[o][0];j+=d[o][1];
        }
    }
    repb(i,1,h)
    {
        repb(j,1,w)cout<<p[i][j]<<" ";
        cout<<"\n";
    }
    cout<<endl;
}

Measured memory_bytes: 512
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

ll a,k,mod = 1e9+7,x,y,hz=0;
vec<ll> neg, pos, m;

ll binpow(ll X, ll K){
    X%=mod;
    if(K<2) return K ? X : 1;
    return (binpow(X*X, K/2)*(K&1 ? X : 1))%mod;
}

ll modInv(ll c){
    return binpow(c, mod-2);
}

int main() {
    fast;
    cin>>a>>k;
    m = vec<ll>(a);
    for(int q=0; q<a; q++){
        cin>>m[q];
        hz |= m[q]==0;
        if(m[q]>0) pos.pb(m[q]);
        if(m[q]<0) neg.pb(m[q]);
    }
    if(pos.size()+neg.size()<k){cout<<0; return 0;}
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());
    x = pos.size(), y = neg.size();
    ll i = 0, j = x-1, p = 1, sig = 1;
    for(int q=0; q<k; q++){
        if(i<y && (j==-1 || -neg[i]>pos[j])){
            p = (p*-neg[i])%mod;
            sig*=-1;
            i++;
        }
        else{
            p = (p*pos[j])%mod;
            j--;
        }
    }
    if(sig==-1){
        if(i<y){
            if(j>-1){
                ld delta1 = ((ld)(1.0)*pos[j])/(ld)(-neg[i-1]);
                ld delta2 = j==x-1 ? -1 : ((ld)(1.0)*-neg[i])/(ld)(pos[j+1]);
                if(delta1>delta2){
                    p = (p*pos[j])%mod;
                    p = (p*modInv(-neg[i-1]))%mod;
                }
                else{
                    p = (p*-neg[i])%mod;
                    p = (p*modInv(pos[j+1]))%mod;
                }
                sig = 1;
            }
            else if(x){
                p = (p*-neg[i])%mod;
                p = (p*modInv(pos[0]))%mod;
                sig = 1;
            }
        }
        else{
            if(j>-1 && y>0){
                p = (p*pos[j])%mod;
                p = (p*modInv(-neg[y-1]))%mod;
                sig = 1;
            }
        }
    }
    if(sig==-1){
        if(hz) p = 0;
        else{
            p = 1, sig = 1;
            sort(m.begin(), m.end(), [](ll i, ll j){return abs(i)<abs(j);});
            for(int q=0; q<k; q++){
                p = (p*abs(m[q]))%mod;
                sig *= m[q]<0 ? -1 : 1;
            }
            assert(sig==-1);
            p = (-p+mod)%mod;
        }
    }
    cout<<p;
}

Measured memory_bytes: 6964
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	vector<ll> a(n);
	for( auto &k : a ) cin >> k;
	sort( a.begin(), a.end(), greater<ll>() );
	ll ans = a.front();
	int cnt = 0;
	for( int i = 2; i < n; ++i ){
		if( i%2 == 0 ){
			++cnt;
		}
		ans += a[cnt];
	}
	cout << ans << endl;
}

Measured memory_bytes: 4840
#include<stdio.h>
#include<string.h>
const int MAXN=510;
int uN,vN;
int g[MAXN][MAXN];
int linker[MAXN];
bool used[MAXN];
int x1[MAXN],x2[MAXN],y1[MAXN],y2[MAXN];
bool dfs(int u)
{
    int v;
    for(v=1;v<=vN;v++)
        if(g[u][v]&&!used[v])
        {
            used[v]=true;
            if(linker[v]==-1||dfs(linker[v]))
            {
                linker[v]=u;
                return true;
            }
        }
    return false;
}
int hungary()
{
    int res=0;
    int u;
    memset(linker,-1,sizeof(linker));
    for(u=1;u<=uN;u++)
    {
        memset(used,0,sizeof(used));
        if(dfs(u))  res++;
    }
    return res;
}
int main()
{
    int k,n,i,j;
    int u,v;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d%d",&x1[i],&y1[i]);
    for(i=1;i<=n;i++)
        scanf("%d%d",&x2[i],&y2[i]);
    memset(g,0,sizeof(g));
    uN=n,vN=n;
    for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
    if(x1[i]<x2[j]&&y1[i]<y2[j])
        g[i][j]=1;
    printf("%d\n",hungary());
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <map>
#include <limits>
#include <utility>
#include <queue>

template<class T>
using Edge = std::map<std::string, T>;
template<class T>
using Graph = std::map<T, std::vector<Edge<T> > >;

//The id of a vertex in the graph must be in [0,V).
template<class T>
std::pair<T, std::vector<T> > Dijkstra(Graph<T> &graph, const T &V, const T &start, const T &end){
    const T distanceSup = std::numeric_limits<T>::max();
    std::vector<T> distance(V, distanceSup);
    std::vector<T> predecessor(V, distanceSup);
    std::vector<bool> isVisited(V, false);
    distance[start] = 0;
    predecessor[start] = start;

    auto compare = [](const std::pair<T,T> &a, const std::pair<T,T> &b){
        return a.second > b.second;
    };
    std::priority_queue<std::pair<T,T>, std::vector<std::pair<T,T> >, decltype(compare)> queue(compare);
    queue.emplace(start,distance[start]);
    T pred, suc;
    T distTmp;
    while(!queue.empty()){
        pred = queue.top().first;
        if(isVisited[pred]){
            continue;
        }
        isVisited[pred] = true;
        queue.pop();

        if(pred == end || distance[pred] == distanceSup){
            break;
        }

        for(auto &edge: graph[pred]){
            suc = edge["vertex"];
            if(isVisited[suc]){
                continue;
            }
            distTmp = distance[pred] + edge["length"];
            if(distance[suc] > distTmp){
                distance[suc] = distTmp;
                predecessor[suc] = pred;
                queue.emplace(suc,distance[suc]);
            }
        }        
    }

    return std::pair<T, std::vector<T> >(distance[end],predecessor);
}

int main(int argc, char *argv[]){
    long int N,M;
    std::cin >> N >> M;
    if(M<1){
        std::cout << -1 << std::endl;
        return 0;
    }
    long int u,v;
    Graph<long int> graph;
    Edge<long int> edge;
    for(long int i=0; i<M; ++i){
        std::cin >> u >> v;
        --u; --v;
        edge["vertex"] = v+N;
        edge["length"] = 1;
        graph[u].emplace_back(edge);
        edge["vertex"] = v+2*N;
        edge["length"] = 1;
        graph[u+N].emplace_back(edge);
        edge["vertex"] = v;
        edge["length"] = 1;
        graph[u+2*N].emplace_back(edge);
    }
    long int S,T;
    std::cin >> S >> T;
    --S; --T;

    auto dijkstra = Dijkstra(graph, 3*N, S, T);
    if(dijkstra.first < std::numeric_limits<long int>::max()){
        std::cout << dijkstra.first/3 << std::endl;
    }else{
        std::cout << -1 << std::endl;
    }
    return 0;
}


Measured memory_bytes: 87040
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	VII arr(n);
	VII cnt(200005,0);
	for(int i=0;i<n;++i)
	{
		cin>>arr[i];
		cnt[arr[i]]++;
	}
	ll ans=0;
	for(int i=1;i<=200005;++i)
	{
		ll g=(cnt[i]);
		ll t=g*(g-1)/2;
		ans=ans+t;
	}

	for(auto x:arr)
	{
		ll temp=ans;
		ll gg=(ll)(cnt[x])*(cnt[x]-1)/2;
		temp=temp-gg;
		if(cnt[x]-1)
		{
			ll kk=(ll)(cnt[x]-1)*(cnt[x]-2)/2;
			temp+=kk;
		}
		cout<<temp<<endl;
	}
	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0;
  int cnt2 = 0;

  for (int i = 0; i < n; i++) {
    if (s[i] == '(')
      cnt++;
    else {
      if (cnt == 0)
        cnt2++;
      else
        cnt--;
    }
  }
  string res = "";
  for (int i = 0; i < cnt2; i++) res.push_back('(');
  res += s;
  for (int i = 0; i < cnt; i++) res.push_back(')');
  cout << res << endl;
}

Measured memory_bytes: 256
import Data.Attoparsec.ByteString.Char8
import qualified Data.ByteString.Char8 as BS
import Data.Char (isLower)

main :: IO ()
main = do
  s <- BS.getLine
  putStrLn $ solve s

solve :: BS.ByteString -> String
solve s = case parseOnly acParser s of
  Left _ -> "WA"
  Right () -> "AC"

acParser :: Parser ()
acParser = do
  let lower = satisfy isLower
  char 'A'
  many1 lower
  char 'C'
  many1 lower
  endOfInput
  return ()

Measured memory_bytes: 508
using System;

namespace AtCoder
{
    class MainClass
    {
        public static void Main()
        {
           

            string[] input1 = Console.ReadLine().Split(' ');
            int K = int.Parse(input1[0]);
            int N = int.Parse(input1[1]);

            string[] input2 = Console.ReadLine().Split(' ');


            int[] points = new int[N] ;


            for (int i = 1; i <= N; i++)
            {


                points[i - 1] = int.Parse(input2[i - 1]);
            }


            int longest = points[0];

            for (int j = 0; j <= N - 2; j++)
            {
                int distance = points[j + 1] - points[j];

                if (distance > longest)
                {
                    longest = distance;
                }
            }


            int last = K - points[N - 1]+points[0];


            if (last > longest)
            {

                longest = last;
            }


            Console.WriteLine(K - longest);
        }
    }
}


Measured memory_bytes: 34140
#include<bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define P pair<ll,ll>
#define F first
#define S second
#define vll vector<ll>
#define pb push_back
#define M 1000000007
#define for1(i,n) for(ll i=1;i<=n;i++)
#define for0(i,n) for(ll i=0;i<n;i++)
#define forab(i,a,b,c) for(ll i=a;i<=b;i+=c)
using namespace std;
int main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll x, y;
	cin >> x >> y;
	if (4 * x - y >= 0 && (4 * x - y) % 2 == 0 && (4 * x - y) / 2 <= x)
	{
		cout << "Yes" << "\n";
	}
	else
	{
		cout << "No" << "\n";
	}
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int mx[4]={0,1,0,-1},my[4]={1,0,-1,0};
int h,w,ans=-1;string s[30];bool vis[30][30];
void bfs(int x,int y)
{
	queue<pair<pair<int,int>,int> >q;
	q.push(make_pair(make_pair(x,y),0));
	vis[x][y]=1;
	while(!q.empty())
	{
		pair<int,int> p=q.front().first;
		int d=q.front().second;q.pop();
		for(int i=0;i<4;++i)
		{
			int xx=p.first+mx[i];
			int yy=p.second+my[i];
			if(xx<0||yy<0||xx>=h||yy>=w||vis[xx][yy]||s[xx][yy]=='#') continue;
			vis[xx][yy]=1;ans=max(ans,d+1);
			q.push(make_pair(make_pair(xx,yy),d+1));
		}
	}
}
int main()
{
	cin>>h>>w;
	for(int i=0;i<h;++i)
	 cin>>s[i];
	for(int i=0;i<h;++i)
	 for(int j=0;j<w;++j)
	  if(s[i][j]=='.')
	  {
	  	memset(vis,0,sizeof(vis));
		bfs(i,j);
	  }
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3596
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    s = gete()
    t = gete()
    ans = ""

    dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]

    for i, si in enumerate(s):
        for j, tj in enumerate(t):
            if si == tj:
                dp[i + 1][j + 1] = dp[i][j] + 1
            else:
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j])

    i, j = len(s), len(t)

    ans_r = ""
    while i > 0 and j > 0:
        if s[i - 1] == t[j - 1]:
            ans_r += s[i - 1]
            i -= 1
            j -= 1
        elif dp[i - 1][j] == dp[i][j]:
            i -= 1
        else:
            j -= 1

    print(ans_r[::-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 112604
#pragma comment(linker, "/stack:200000000")
       #pragma GCC optimize ("Ofast")
        #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
         
         
        #include <iostream>
        #include <iomanip>
        #include <sstream>
        #include <cstring>
        #include <vector>
        #include <deque>
        #include <queue>
        #include <set>
        #include <map>
        #include <valarray>
        #include <iterator>
        #include <functional>
        #include <limits>
        #include <algorithm>
        #include <numeric>
        #include <cmath>
        #include <cassert>
        #include <unordered_map>
        #include <stack>
        using namespace std;
        #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
         #define trace(x) cerr << #x << ": " << x << " " << endl;
     
        typedef int64_t ll;
     
        #define endl '\n'
        #define int ll
        ll mod=1e9+7;
        ll mod1=1e9+5;
        ll power(ll a,ll b)
        {
            if(b==0) return 1;
            else if(b%2==0)
                return power((((a%mod)*(a%mod))%mod),b/2)%mod;
            else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
        }
        
        
        int n,m;
        vector<int> v[1001];
        int cost[1001];
        int temp[1001];
        int dp[5001][1001];

        int solve(int mask,int i)
        {
            if(i==m)
                {
                    if(mask==power(2,n)-1)
                        return 0;
                    return 1e15;
                }

            int &res=dp[mask][i];
            if(res!=-1)
                return res;
            
            res=1e16;
            return res=min(solve(mask,i+1),cost[i]+solve(mask|temp[i],i+1));

        }
        
        int32_t main()
        {
            IOS
           
            
            
            
            cin>>n>>m;
            memset(temp,0,sizeof(temp));
            map<int,int> m1;
            for(int i=0;i<m;++i)
            {
                cin>>cost[i];
                int b;
                cin>>b;
                for(int j=0;j<b;++j)
                {
                    int k;
                    cin>>k;
                    k--;
                    temp[i]|=1ll<<k;
                    m1[k]++;
                    v[i].push_back(k);
                }
            }
            
            for(int i=0;i<n;++i)
            {
                if(m1[i]==0)
                {
                    cout<<-1;
                    return 0;
                }
            }
            memset(dp,-1,sizeof(dp));
            cout<<solve(0,0);

        }

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

int main() {
  int X, Y;                                                               
  cin >> X >> Y;
  if(2*X <= Y && Y <= 4*X) {
    if(Y%2 == 1) {
      cout << "No" << endl;
    }else {
      cout << "Yes" << endl;
    }
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3616
import java.util.Scanner;

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

        int r = stdIn.nextInt();
        int D = stdIn.nextInt();
        int x2000 = stdIn.nextInt();

        int i=1;
        for(; i<=10; i++){
            System.out.println(x2000 = r * x2000 - D);
        }
    }
}

Measured memory_bytes: 23124
// ITP1_6_D:   Matrix Vector Multiplication
// 2017.7.27

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int a[101][101], b[101], c[101];
	int i, j;
	int n, m;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
	}
	for (j = 0; j < m; j++) scanf("%d", &b[j]);

	for (i = 0; i < n; i++) {
		c[i] = 0;
		for (j = 0; j < m; j++) c[i] += a[i][j] * b[j];
	}

	for (i = 0; i < n; i++) {
		printf("%d\n", c[i]);
	}
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<functional>

using namespace std;

#define FOR(it,o) for(__typeof((o).begin()) it=(o).begin();it!=(o).end();++it)

struct Node
{
  map<int,int> con;
  void refresh(int n, int newV){if(con.find(n)!=con.end()){con[n]=min(con[n],newV);}else con[n]=newV;}
};
struct State{
  int pos,cost;
  State():pos(0),cost(0){}
  State(int pos,int cost):pos(pos),cost(cost){}
  bool operator>(const State &t)const{return cost>t.cost;}
};

typedef vector<Node> Graph;

int dijkstra(int st, int ed, const Graph &G)
{
  priority_queue<State,vector<State>,greater<State> > pq;
  bool vis[G.size()];fill(vis,vis+G.size(),false);
  pq.push(State(st,0));
  while(!pq.empty()){
    State now=pq.top();pq.pop();
    vis[now.pos]=true;if(now.pos==ed)return now.cost;
    FOR(itm,G[now.pos].con){
      if(!vis[itm->first]){
	State next(itm->first,now.cost+itm->second);
	pq.push(next);
      }
    }
  }
  return -1;
}

int main()
{
  while(true){
    int n,k;cin>>n>>k;if(n==0&&k==0)break;
    Graph G;G.resize(1+n);
    for(int i=0;i<k;++i){int type;cin>>type;
      if(type==0){
	int st,ed;cin>>st>>ed;
	cout<<dijkstra(st,ed,G)<<endl;
      }else{
	int src,dst,e;cin>>src>>dst>>e;
	G[src].refresh(dst,e);G[dst].refresh(src,e);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1008
#include <iostream>

using namespace std;

bool BSearch(int A[] ,unsigned int sp ,unsigned int ep ,int n){ //あり、なしのみboolで返す
  int mid = (ep+sp) / 2;
  int l = sp;
  int r = ep;
  while(l <= r){
    mid = (l + r) / 2;
    if(A[mid] == n){
      return 1;
    }
    else if(A[mid] < n){
      l = mid + 1;
    }
    else{
      r = mid - 1;
    }
  }
  return 0;
}

int main(void){
  int n,q;
  int counter = 0;
  int S[100000];
  int T[50000];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> S[i];
  }
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> T[i];
  }


  for(int i=0;i<q;i++){
    if(BSearch(S,0,n,T[i])){
      counter++;
      //cout << T[i] << "is found!" << endl;
    } else {
      //cout << T[i] << "is not found" << endl;
    }
  }
  cout << counter << endl;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define int long long
using namespace std;

int32_t main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int takahashi = 1;
  while (true) {
      if (takahashi) {
        c -= b;
        if (c <= 0) {
            cout << "Yes";
            break;
        }
      }
      else {
          a -= d;
          if (a <= 0) {
              cout << "No";
              break;
          }
      }
      takahashi ^= 1;
  }
  return 0;
}


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

int N,M;
vector<vector<int>> p;

void dfs(vector<int> v) {
	if(v.size() == N)
		p.push_back(v);
	else
		for(int i=v.at(v.size()-1); i<=M; ++i) {
			vector<int> t = v;
			t.push_back(i);
			dfs(t);
		}
}

int main() {
	int Q,r=0;
	cin >> N >> M >> Q;
	vector<int> a(Q),b(Q),c(Q),d(Q),t;

	rep(i,Q)
		cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
	
	rep(i,10) {
		vector<int> x;
		x.push_back(i+1);
		dfs(x);
	}

	rep(i,p.size()) {
		// rep(j,N)
		// 	cout << p.at(i).at(j) << " ";
		// cout << endl;

		int t=0;
		rep(j,Q)
			if(p.at(i).at(b.at(j)-1)-p.at(i).at(a.at(j)-1) == c.at(j))
				t += d.at(j);
		r = max(r, t);
	}

	cout << r << endl;
}

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

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


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[100000];
  int mn=BIG,p;
  int cnt=0,sum=0;
  rep(i,n){
    cin>>a[i];
    if(mn > abs(a[i]) ){
      mn=abs(a[i]);
      p=i;
    }
    if(a[i]<0) cnt++;
    sum+=abs(a[i]);
  }
  if(cnt%2) cout<<sum-(abs(a[p])*2)<<endl;
  else cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007
//#define DEBUG

long long int combination(long long int n, long long int r)
{
	//printf("n:%lld, r:%lld\n", n, r);
    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(array, 10, sizeof(int), compare_int)



int main(){
	int n, hantei[120];
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		int small, large;
		scanf("%d%d", &small, &large);
		if(small == large) hantei[i] = 1;
		else hantei[i] = 0;
	}

	int p = 0, f=0;
	for(int i=0; i<n; i++){
		if(hantei[i] == 1) p++;
		else p = 0;
		if(p >= 3){
			f = 1;
			break;
		}
	}
	
	if(f == 1) printf("Yes\n");
	else printf("No\n");
	
	return 0;
}



Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int> > to(n);
    rep(i, m){
        int s, t;
        cin >> s >> t;
        s--; t--;
        to[s].push_back(t);
    }
    vector<double> dp(n);

    for (int v = n-2; v >= 0; v--){
        double now = 0;
        for (int u : to[v]){
            now += dp[u];
        }
        now /= to[v].size();
        now++;
        dp[v] = now;
    }
    double ans = dp[0];
    for (int nv; nv < n - 1; nv++){
        if(to[nv].size() == 1) continue;
        int nu = to[nv][0];
        for (int u : to[nv]){
            if (dp[nu] < dp[u]) nu = u;
        }

        double now = [&]{
            for (int v = n-2; v >= 0; v--){
                double now = 0;
                for (int u : to[v]){
                    if(v == nv && u == nu) continue;
                    now += dp[u];
                }
                int deg = to[v].size();
                if(v == nv) deg--;
                now /= deg;
                now++;
                dp[v] = now;
            }
            return dp[0];
        }();
        ans = min(ans, now);
    }
    printf("%.10lf\n", ans);
    
}

Measured memory_bytes: 5016
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N = in.nextInt();
			out.println(N / 3);
		}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}


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

const int N = 2e5 + 5;
vector<int> adj[N];
int vals[N]; 
int pref[N];

void dfs(int v, int x){
	x += pref[v];
	vals[v] += x;
	for(int u:adj[v]){
		dfs(u, x);
	}
}

int main(){
	int n, m;
	cin>>n>>m;
	memset(vals, 0, sizeof(vals));
	memset(pref, 0, sizeof(pref));
	for(int i = 1;i<n;i++){
		int t1, t2;
		cin>>t1>>t2;
		adj[t1].push_back(t2);
	}
	for(int i = 0;i<m;i++){
		int a, b;
		cin>>a>>b;
		pref[a] += b;
	}
	dfs(1, 0);
	for(int i = 1;i<=n;i++){
		cout<<vals[i]<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 21120
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

s = ns()

dp = [0] * 13
dp[0] = 1
mod = 1000000007
for v in s:
    ndp = [0] * 13
    if v == "?":
        for j in range(13):
            for k in range(10):
                nj = (j*10+k)%13
                ndp[nj] += dp[j]
                ndp[nj] %= mod
    else:
        k = ord(v)-ord("0")
        for j in range(13):
            nj = (j*10+k)%13
            ndp[nj] += dp[j]
            ndp[nj] %= mod
    dp = ndp
print(dp[5])


Measured memory_bytes: 44380
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
long long int gcd(long long int a,long long int b);

int main (void){
int a[100001],b[100001],n,tmp;
int g_first=0,g_second=0,g_first_n=0,g_second_n=0;
int k_first=0,k_second=0,k_first_n=0,k_second_n=0;
for (int i = 0; i <= 100000; i++) {
  a[i]=0;
  b[i]=0;
}
scanf("%d\n",&n);
if (n==2) {
  int A,B;
  scanf("%d\n",&A );
  scanf("%d\n",&B );
  if (A==B) {
    printf("1\n" );
  }else{
    printf("0\n" );
  }
  return 0;
}
for (int i = 1; i <= n; i++) {
  scanf("%d\n", &tmp);
  if (i%2==1) {
      a[tmp]++;
  }else{
    b[tmp]++;
  }

}

for (int i = 1; i <= 100000; i++) {
  if (a[i]>=k_first_n) {
    k_second_n=k_first_n;
    k_second=k_first;
    k_first_n=a[i];
    k_first=i;
  }else{
    if (a[i]>=k_second_n) {
      k_second_n=a[i];
      k_second=i;
    }
  }
}
for (int i = 1; i <= 100000; i++) {
  if (b[i]>=g_first_n) {
    g_second_n=g_first_n;
    g_second=g_first;
    g_first_n=b[i];
    g_first=i;
  }else{
    if (b[i]>=g_second_n) {
      g_second_n=b[i];
      g_second=i;
    }
  }
}
//printf("%d\n",g_first );
//printf("%d\n",k_first );
if (g_first!=k_first) {
  printf("%d\n", n-g_first_n-k_first_n);
}else{
  if (g_second_n>=k_second_n) {
    printf("%d\n", n-g_second_n-k_first_n);
  }else{
    printf("%d\n", n-g_first_n-k_second_n);
  }
}
  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	if(n<=9) cout<<"Yes\n";
	else if(n<=81){
		int f=0;
		for(int i=2;i<=9;++i){
			if(n%i==0 and (n/i<=9 and n/i>=1)) {
				cout<<"Yes\n";f=1;break;
			}
		}
		if(f==0) cout<<"No\n";
	}
	else{
		cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 256
r,c = map(int, input().split())
s=[]
T=[]
t=0
for k in range(r):
   x = list(map(int, input().split()))
   x.append(sum(x))
   s.append(x)
for i in range(c+1):
   t=0
   for j in range(r):
      t += s[j][i]
   T.append(t)
s.append(T)
for p in range(r+1):
   print(*s[p])


Measured memory_bytes: 6232
#include <bits/stdc++.h>
#define nmax 100010 
#define eps 1e-9
#define f(c,a,b) for (int c=a; c<=b; c++)

using namespace std;
typedef double db;
struct P{
    db x, y;
    P(){};
    db times(P a) { return x*a.y-y*a.x; }
    P (db _x, db _y):x(_x),y(_y){}
    bool operator < (const P a) const { return (a.y==y)?a.x>x:a.y>y; }
    P operator - (const P a) const { return P(a.x-x,a.y-y); }
    db len(){ return sqrt(x*x + y*y); }
};
typedef P V;
P ps[nmax],po[nmax];
int is=0, n;

int sign(db x) { return x<-eps?-1:x>eps; }

void andrew(){
    ps[++is]=po[1];
    f(i,2,n){
        while( is>=2 && (ps[is]-ps[is-1]).times(po[i]-ps[is])<0 ) is--;
        ps[++is]=po[i];
    }
    for(int i=n-1; i>=1; i--){
        while( is>=2 && (ps[is]-ps[is-1]).times(po[i]-ps[is])<0 ) is--;
        ps[++is]=po[i];
    }
}

int main(){
    //freopen("owo.in","r",stdin);
    cin >> n;
    f(i,1,n) scanf("%lf%lf", &po[i].x, &po[i].y);
    sort(po+1,po+1+n);
    andrew();
    cout << (is-1) << endl;
    f(i,1,is-1) printf("%d %d\n", (int)ps[i].x, (int)ps[i].y);
    return 0;
}


Measured memory_bytes: 5704
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cstdint>
#include <cmath>
using namespace std;

void solve() {
	int n;
	string s;
	cin >> n >> s;
	std::transform(s.begin(), s.end(), s.begin(), [n](char c) {
		return char(c - 'A' + n) % 26 + 'A';
	});
	cout << s << endl;
}

int main() {
	solve();
	return 0;
}


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

using namespace std;

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

typedef long long int ll;


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

	int n;
	
	cin >> n;
	double ans1 = 0;
	double ans2 = 0;
	rep(i , n)
	{
		double temp;
		string str;
		cin >> temp >> str;
		if(str == "JPY")
		{
			ans1 += temp;
		}
		else
		{
			ans2 += temp;
		}
	}

 	cout << ans1+(ans2*380000.0);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define deb(x) cout<<#x<<" : "<<x<<"\n";
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define deb_arr(a,n) {cout<<#a<<":";for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';}
#define deb_mat(dist,n,m) {cout<<#dist<<"\n";for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}}
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define all(a) (a).begin(),(a).end()
#define bs binary_search
#define sz size()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define clr fflush(stdout);
//#define clr cout.flush();
#define N 200001
#define fpr(i,a,b) for(int i=a;i<b;i++)
#define fdr(i,a,b) for(int i=a;i>b;i--)
#define repp(i,a,b,d) for(int i=a;i<b;i+=d)
#define repd(i,a,b,d) for(int i=a;i>b;i-=d)
#define LLMIN LLONG_MIN
#define LLMAX LLONG_MAX
#define AKASH_PATEL ios_base::sync_with_stdio(false);
#define SVNIT_SURAT cin.tie(NULL);cout.tie(NULL);
#define mset(x,a) memset(x,a,sizeof(x));
#define nl cout<<'\n';
#define print(c) cout<<c<<'\n';
#define setp(n) cout << fixed << setprecision(n)
#define take_arr(a,n) fpr(i,0,n) cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';
#define take_mat(mat,n,m) fpr(i,0,n) fpr(j,0,m) cin>>mat[i][j];
#define set_mat(mat,n,m,k) fpr(i,0,n) fpr(j,0,m) mat[i][j]=k;
#define print_mat(dist,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
template< class T > bool odd(T a) { return a&1; }
template< class T > bool even(T a) { return !(a&1); }
int main()
{
//#ifndef ONLINE_JUDGE
//    freopen("../ip.txt", "r", stdin);
//    freopen("../op.txt", "w", stdout);
//#endif
    AKASH_PATEL;
    SVNIT_SURAT;
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        ll sum=0;
        fpr(i,1,n+1)
        {
            if(i%3==0 || i%5==0)
            {

            }
            else
            {
                sum+=i;
            }
        }
        print(sum)
    }
    return 0;
}





Measured memory_bytes: 3640
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		ABC50A p = new ABC50A();
		p.solve();
	}
}

class ABC50A {
	public void solve() throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		long a = Long.parseLong(input[0]);
		long b = Long.parseLong(input[2]);
		if (input[1].equals("+"))
			System.out.println((a + b));
		else
			System.out.println((a - b));
	}
}

Measured memory_bytes: 8148
#include<iostream>
#include<stdio.h>
#include<string>
#include<string.h>
using namespace std;
int sum[111111];
int main()
{
    int n,m;
    string s;
    cin >> n >> m;
    cin >> s;
    for(int i = 1 ; i < n ; i ++)
    {
        if(s[i]=='C'&&s[i-1]=='A')
        {
            sum[i+1] = sum[i] + 1;
        }
        else
        {
            sum[i+1] = sum[i];
        }
    }
    
    while(m--)
    {
        int l,r;
        cin >> l >> r;
        cout << sum[r] - sum[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    public static void Main( )
    {
        long N = long.Parse( Console.ReadLine( ) );
        var divisors = PrimeFactorization_Easy( N ).GroupBy( x => x );
        long ans = 0;
        long remainningN = N;
        foreach ( var divInfo in divisors )
        {
            long aPrime = divInfo.Key;
            for ( long ex = 1; ex <= divInfo.Count( ); ex++ ) // ex=指数
            {
                long z = 1; for ( int i = 1; i <= ex; i++ ) z *= aPrime;
                if ( remainningN % z == 0 )
                {
                    remainningN /= z;
                    ans++;
                }
            }
            if ( remainningN == 1 ) break;
        }
        Console.WriteLine( ans );
    }

    public static List<long> PrimeFactorization_Easy( long target )
    {
        var result = new List<long>( );
        long remainning = target;

        for ( long i = 2; i * i <= target; i++ )
        {
            if ( target % i != 0 ) continue;
            while ( remainning % i == 0 )
            {
                result.Add( i );
                remainning /= i;
            }
        }
        if ( remainning != 1 ) result.Add( remainning );
        return result;
    }
}

Measured memory_bytes: 28292
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let n=read::<i32>();
    println!("{}",(0..n).map(|_|{
        let mut a=read::<i32>();
        let mut c=0;
        while a%2==0{a/=2;c+=1}
        c
    }).min().unwrap())
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
inline int lcm(int a,int b){ return a / gcd(a,b) * b;}
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }
 
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};

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

    string s;
    cin >> s;

    if(s == "ABC"){
        cout << "ARC\n";
    } else{
        cout << "ABC\n";
    }

    return 0;
}

Measured memory_bytes: 3492
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static Reader;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var n = NextLong;
        var k = NextLong;
        var a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = NextLong;
        Array.Sort(a);
        var Valid = -(long)1e18 + 1;
        var Invalid = (long)1e18 + 1;
        //小さい数の個数
        while (Invalid - Valid > 1)
        {
            var target = (Valid + Invalid) / 2;
            var res = 0L;
            //res = Enumerable.Range(0, a.Length).Sum(ind => Count(ind, mid));
            for (int ind = 0; ind < a.Length; ind++)
            {
                int valid, invalid;
                //負
                if (a[ind] < 0) { valid = a.Length; invalid = ind; }
                //正
                else { invalid = a.Length; valid = ind; }

                while (Abs(valid - invalid) > 1)
                {
                    var mid = (valid + invalid) / 2;
                    if (a[ind] * a[mid] <= target) valid = mid;
                    else invalid = mid;
                }
                if (a[ind] < 0) res += a.Length - valid;
                else res += valid - ind;
            }
            if (res < k) Valid = target;
            else Invalid = target;
        }
        Console.WriteLine(Invalid);
    }
}


static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = BUF_SIZE - 1;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }


    public static long NextLong
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            long res = 0; int sign = 1; while (Buffer[ptr] < 45) Move();
            if (Buffer[ptr] == 45) { Move(); sign = -1; }
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res * sign;
        }
    }
}


Measured memory_bytes: 14688
#include <stdio.h>
#define N 100

int main(){
  int flag=1,n,j,tmp,A[N],cnt=0;

  scanf("%d",&n);
  for(j=0;j<n;j++)  
    scanf("%d",&A[j]);

  while(flag){
    flag=0;
    for(j=n-1;j>0;j--)
      if(A[j]<A[j-1]){
	tmp=A[j];
	A[j]=A[j-1];
	A[j-1]=tmp;
	flag=1;
	cnt++;
      }
  }

  printf("%d",A[0]);
  for(j=1;j<n;j++)  
    printf(" %d",A[j]);
  printf("\n%d\n",cnt);

  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	long long N, K;
	cin >> N >> K;

	if (K > N) {
		if (K  >= 2*N) {
			cout << N << endl;
		} else {
			cout << K - N << endl;
		}
	} else {
		long long n = N / K;
		while (n*K < N)
		{
			n++;
		}
		cout << n * K - N << endl;
	}
}


Measured memory_bytes: 256
s = input()

ok = True
index = len(s)
while True:
    if index == 0:
        break

    if s[index - 1] == 'r':
        if index - 6 >= 0 and s[index - 6:index] == 'eraser':
            index -= 6
        elif index - 7 >= 0 and s[index - 7:index] == 'dreamer':
            index -= 7
        else:
            ok = False
            break
    elif s[index - 1] == 'e':
        if index - 5 < 0 or s[index - 5:index] != 'erase':
            ok = False
            break
        else:
            index -= 5
    elif s[index - 1] == 'm':
        if index - 5 < 0 or s[index - 5:index] != 'dream':
            ok = False
            break
        else:
            index -= 5
    else:
        ok = False
        break
if ok:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 40048
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define TF(flag) (flag)?1:0
#define fi first
#define se second
#define debug if(DEBUG)
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
 
template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}
 
template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  return os;
}
 
template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}
 
bool DEBUG=true;

int main(void){
  int N; cin>>N;
  mat<char> S(N,vec<char>(N));
  rep(i,N){
    rep(j,N){
      cin>>S[i][j];
    }
  }
  
  int ans=0;
  rep(A,N){
    bool able=true;
    rep(i,N){
      rep(j,N){
        able=able&&(S[i][j]==S[j][i]);
      }
    }
    ans+=TF(able);
    S.insert(S.begin(),S[N-1]);
    S.pop_back();
  }
  cout<<ans*N<<endl;
}

Measured memory_bytes: 384
/*
    @uthor: Varun Mishra
    "varun21999" ->  Codechef, Codeforce, Hackerrank, Hackerearth;
*/
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int            long long int
#define ull            unsigned int
#define ld             long double
#define pb             push_back
#define pa             pair<int,int>
#define ppa            pair<pair<int,int>,int>
#define pap            pair<int,pair<int,int>>
#define v1d            vector<int>
#define v2d            vector<vector<int> >
#define vpa            vector<pair<int,int>>
#define M              1000000007
#define MN             LLONG_MIN
#define MX             LLONG_MAX
#define ff             first
#define ss             second
#define endl           "\n"
#define v1s            vector<string>
#define all(v)         v.begin(),v.end()
#define S(v)           sort(v.begin(),v.end())
#define RS(v)          sort(v.rbegin(),v.rend())
#define R(v)           reverse(v.begin(),v.end())
#define mxpq(T)        priority_queue <T>
#define mnpq(T)        priority_queue<T,vector<T>,greater<T>>
#define T              int tc;cin>>tc;while(tc--)
#define p2d(v)         for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)         for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)         for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define forIloop(i,n)  for(auto i=0;i<n;i++);
#define forDloop(i,n)  for(auto i=n-1;i>=0;i--);
#define qqq 400005
#define isEven(n)  (!n & 1);
const int MOD = 1e9 + 7;
// bool isEven(int n){
//     return (!(n & 1));
// }
// int popcount(int num){
//     num = num - ((num >> 1) & 0x55555555);
//     num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
//     return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
// }
// int powerOfTwo(int n){
//     return 1 << n;
// }

// int arr[1000001];
// bool temet = false;


void codeforce2(){
    string a,b,c;
    cin>>a>>b>>c;
    cout << a[0] << b[1] << c[2] << endl;
    
}




int32_t main(){

    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    /*#ifndef _DEBUG
     freopen("input.txt",  "r",  stdin);
     freopen("output.txt", "w", stdout);
    #endif*/
    //auto start = high_resolution_clock::now();

    // Lucario();
    //codeforceContest();
    //hackerEarth();
    //codeChef();
    codeforce2();

   /* auto stop = high_resolution_clock::now();
    auto duration = duration_cast<seconds>(stop - start);
    cout << "Time: "<<duration.count()<<endl;*/
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
    string S, T;
    cin >> S >> T;
 
    //Initialize ans with a temporal value.
    //This value should be large enough; otherwise you will get wrong answer
    //Make sure that the value will lead to the correct answer.
    int ans = T.size();
 
    //Brute force through all initial position in S
    for (int start = 0; start <= S.size() - T.size(); start++)
    {
        int diff = 0;
        for (int i = 0; i < T.size(); i++)
        {
            if (T[i] != S[start + i]) {
                diff++;
            }
        }
        ans = min(ans, diff);
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 3628