akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
static const int INFTY = (1 << 21);

class Edge{
public:
	int from, to, cost;
	int backedge;
	Edge(int from = 0, int to = 0, int cost = 0) :
		from(from), to(to), cost(cost){
		backedge = -1;
	}

};

class Node{
public:
	vector<Edge> edges;
	int prenum;
	int parent;
	int lowest;
	Node(){
		prenum = -1;
		parent = -1;
	}
};

class Graph{
public:
	vector<Node> nodes;
	int prenum;
	Graph(int n) {
		rep(i, n) { Node n;  nodes.push_back(n); }
		prenum = 0;
	}
};

Graph *G = NULL;

void dfs(Edge &e){

	Node *n = &(G->nodes[e.to]);

	if (n->prenum != -1) {
		int parent = G->nodes[e.from].parent;
		if (e.to == parent){
			e.backedge = -1; // neither backedge nor treeedge
		}
		else{
			e.backedge = 1;
		}
		return;
	}

	// set parameter
	G->prenum++;
	e.backedge = 0; // not backage
	n->prenum = G->prenum;
	n->parent = e.from;
	n->lowest = n->prenum;

	for (auto &ee : n->edges){
		dfs(ee);
	}

	for (auto &ee : n->edges){
		if (ee.backedge != -1){
			n->lowest = min(n->lowest, G->nodes[ee.to].lowest);
		}
	}

}


int main() {

	int V, E;
	cin >> V >> E;

	Graph _G(V);
	G = &_G;

	rep(i, E){
		int from, to;
		cin >> from >> to;
		G->nodes[from].edges.push_back(Edge(from, to, 0));
		G->nodes[to].edges.push_back(Edge(to, from, 0));
	}

	Edge e(-1, 0, 0);
	dfs(e);

	rep(i, V){
		// printf("%d %d %d %d\n", i, G.nodes[i].parent, G.nodes[i].prenum, G.nodes[i].lowest);
	}

	set<int> ret;
	rep(i, V){
		if (G->nodes[i].parent == -1){
			int count = 0;
			rep(j, V){
				if (G->nodes[j].parent == i) count++;
			}
			if (count > 1) ret.insert(i);
		}
		else{
			Node n = G->nodes[i];
			Node p = G->nodes[n.parent];
			if (p.prenum <= n.lowest && p.parent != -1){
				ret.insert(n.parent);
			}
		}
	}

	for (auto &i : ret){
		cout << i << endl;
	}
}

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

int main(void){
	int n,r,number;
	int a[4][13]={};
    char symbol;
    cin >> n;
    for(int i = 0; i<n;i++){
		cin >> symbol >> number;
        if(symbol=='S'){
            r = 0;
        }else if(symbol=='H'){
            r = 1;
        }else if(symbol=='C'){
            r = 2;
        }else if(symbol=='D'){
            r = 3;
        } 
        a[r][number-1]=1;
    }
    for(int i=0; i<4; i++){
		for(int j=0; j<13; j++){
            if(a[i][j]!=1){
                if(i==0)symbol='S';
		        if(i==1)symbol='H';
                if(i==2)symbol='C';
                if(i==3)symbol='D';
                cout <<symbol <<" " <<j+1 << endl;              
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>

int garden[10][10] = {};
int min = 10;

int pond_area(int sx,int sy,int width,int height){
    int area = 0;
    for(int i=sx+1;i<width+sx-1;i++){
        for(int j=sy+1;j<height+sy-1;j++){
            int d = garden[j][i];
            area += (min - d);
        }
    }
    return area;
}
    
bool isPond(int sx,int sy,int width,int height){
    //std::cout << "start:(" << sx << ',' << sy << ") width = " << width << " height=" << height << '\n';
    int max = 0;
    min = 10;
    for(int k=sy;k<height+sy;k++){
        int d1 = garden[k][sx];
        int d2 = garden[k][sx+width-1];
        if(d1>d2) d1 = d2;
        if(min>d1) min = d1;
    }
    for(int k=sx;k<width+sx;k++){
        int d1 = garden[sy][k];
        int d2 = garden[sy+height-1][k];
        if(d1>d2) d1=d2;
        if(min>d1) min = d1;
    }
    
    for(int i=sx+1;i<width+sx-1;i++){
        for(int j=sy+1;j<height+sy-1;j++){
            int d = garden[j][i];
            if(max<d) max = d;
        }
    }
    
    //std::cout << "  min=" << min << "  max=" << max << '\n';
    
    if(min>max) return true;
    else return false;
}

    
int main(){
    int m,n;
    while(1){
        int max = 0;
        std::cin >> m >> n;
        if(m==0&&n==0) break;
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                std::cin >> garden[i][j];
            }
        }
        /*for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                std::cout << garden[i][j] << ' ';
            }
            std::cout << '\n';
        }
         */
        for(int height=m;height>2;height--){
            for(int width=n;width>2;width--){
                for(int sy=0;sy<m-height+1;sy++){
                    for(int sx=0;sx<n-width+1;sx++){
                        if(isPond(sx,sy,width,height)){
                            int area = pond_area(sx,sy,width,height);
                            if(area > max) max = area;
                            //std::cout << "area=" << area << '\n';
                        }
                    }
                }
            }
        }
        std::cout << max << '\n';
    }
    return 0;
}



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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
const ll mod = 1000000007;

vector<ll> E[100005];
ll ans[100005];
ll n,k;

void dfs(ll v, ll g, ll cnt) {
    if (g == 0) ans[g] = k;
    else if (v == 0) ans[g] = max(0ll, k-cnt-1);
    else ans[g] = max(0ll, k-cnt-2);
    int t = 0;
    for (ll x : E[g]) {
        if (x != v) {
            dfs(g, x, t);
            t++;
        }
    }
}

int main() {
    cin >> n >> k;
    ll u,v;
    rep(i,n-1) {
        cin >> u >> v;
        E[u-1].push_back(v-1);
        E[v-1].push_back(u-1);
    }
    dfs(-1,0,0);
    ll anss = 1;
    //rep(i,n) cout << ans[i] << endl;
    rep(i,n) {
        anss = anss * ans[i] % mod;
    }
    cout << anss << endl;
    return 0;
}


Measured memory_bytes: 13316
from bisect import bisect_left, bisect_right
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))

ans = 0
for i in range(n):
    x = b[i]
    l = bisect_left(a, x)
    r = bisect_right(c, x)
    ans += l * (n - r)
print(ans)


Measured memory_bytes: 29280
/**
                 MD.Faysal Hasan
                Comilla Univesity               **/

#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<string>
#include <stdlib.h>
using namespace std;

#define         rep(i,n)       for ( i=0 ; i<n ; ++i )
#define         rep1(i,n)      for ( i=1 ; i<=n ; ++i )
#define         sajo(str)      sort(str.begin(),str.end())
#define         rev(str)       reverse(str.begin(),str.end())
#define         usajo(str)     sort(str.rbegin(),str.rend())
#define         pi             2*acos(0.0)
#define         nel            printf("\n")
#define         longmx         92233720368547758
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         yes            cout<<"Yes"<<"\n"
#define         no             cout<<"No"<<"\n"
#define         vcl            vector<ll>
#define         pb             push_back
#define         prl            pair< ll , ll >
#define         mkp(x,y)       make_pair(x,y)
#define         ff             first
#define         sc             second
#define         spc            ' '
#define         nn             '\n'
#define         Faysal         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef         long long int  lli;
typedef         long long      ll;

int main(){//Faysal

    lli ans,sum,tot,cnt,mx,mn,idx,chk,rem,ret,tmp,mid,lft,rgt,pos;

    ll tc,n,m,a,b,c,d,g,h,l,r,x,y,i,j,k;

    cin>>l;
    double xx=l/3.0;
    cout<<fixed<<setprecision(12)<<xx*xx*xx<<nn;
    return 0;
}


Measured memory_bytes: 256
N, M = list(map(int, input().split()))

g = [[] for _ in range(N)]

for i in range(M):
  a, b = list(map(int, input().split()))
  g[a-1].append(b-1)
  g[b-1].append(a-1)

visited = [False for _ in range(N)]

def dfs(v, visited):
  if all(visited):
    return 1
  total = 0
  for cv in g[v]:
    if not visited[cv]:
      visited[cv] = True
      total += dfs(cv, visited)
      visited[cv] = False
  return total
    
visited[0] = True
ret = dfs(0, visited)
print(ret)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
void print() { cout << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////

const int MAX = 51;
int A[MAX],B[MAX];
bool used[MAX];
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];

    for (int i = 1; i < MAX; i++) used[i] = 1;

    auto check=[&]() {
        rep(i,N) {
            vector<bool> check(MAX);
            queue<int> que;
            check[A[i]] = 1;
            que.emplace(A[i]);
            while (!que.empty()) {
                int v = que.front(); que.pop();
                for (int j = 1; j <= v; j++) {
                    if (!used[j]) continue;
                    if (!check[v%j]) {
                        check[v%j] = 1;
                        que.emplace(v%j);
                    }
                }
            }
            if (!check[B[i]]) return false;
        }
        return true;
    };

    if (!check()) {
        cout << -1 << ln;
        return 0;
    }
    for (int i = MAX-1; i > 0; i--) {
        used[i] = 0;
        if (!check()) {
            used[i] = 1;
        }
    }
    ll ans = 0;
    rep(i,MAX) if (used[i]) ans += (1LL<<i);
    cout << ans << ln;
}


Measured memory_bytes: 256
#include <stdio.h>

int main () {
    int n, m, l;
    long long A[100][100], B[100][100],C[100][100] = {0};

    scanf("%d %d %d", &n, &m, &l);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            scanf("%lld", &A[i][j]);
        }
    }
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < l; j++)
        {
            scanf("%lld", &B[i][j]);
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
        {
            C[i][j] = 0;
            for (int k = 0; k < m; k++)
            {
                C[i][j] = C[i][j] + A[i][k]*B[k][j];
            }
        }
    }
    
    
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
        { 
            if (j == 0)
            printf("%lld", C[i][j]);
            else
            printf(" %lld", C[i][j]);
        }
        printf("\n");
    }
    
    return 0;
}


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

#define DEBUG 1
 



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

    long long counter = 0;

    for(int i = 0;i < N.length(); i++){
       counter += (int)( N.at(i) - '0');
    }

    if(counter % 9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
            }





    return 0;

}




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

using namespace std;

int main() {
    int S, h, m, s;
    cin >> S;

    h = S / 3600;
    m = (S - h * 3600) / 60;
    s = S - h * 3600 - m * 60;

    cout << h << ":" << m << ":" << s << endl;

}


Measured memory_bytes: 3132
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, n) {cin >> a[i];}
#define readmat(a, n, m) int a[(n) + 1][(m) + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

vvi adj(2e5), tns(2e5); vi topo, vis(2e5);

void dfs (int cur)
{
    vis[cur] = 1;
    for (int i : adj[cur]) if(!vis[i]) dfs(i);
    topo.pb(cur);
}
     
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    #ifndef ONLINE_JUDGE 
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        freopen ("OUTPUT_ERROR.txt" , "w" , stderr);
    #endif

    //start from here

    readb(n, m)
    int x, y;

    fori (i, 1, m)
    {
        cin >> x >> y;
        adj[x].pb(y); tns[y].pb(x);
    }

    fori (i, 1, n)
    {
        if(!vis[i]) dfs(i);
    }

    reverse(all(topo));

    vi dp(n+1); int ans = 0;

    for (int i : topo)
    {
        for (int x : tns[i]) dp[i] = max(dp[i], dp[x] + 1);
        ans = max(ans, dp[i]);
    }

    print(ans)

    return 0;
}


Measured memory_bytes: 24264
import sys
sys.setrecursionlimit(100000)

X = 10**9+7
N,M = list(map(int,input().split()))
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

def cmb(n, r):
    # faster than the following code
    # def combinations_count(n, r):
    #     return factorial(n) // (factorial(n - r) * factorial(r))
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result


ans = 1
for val,dupes in factorize(M):
    ans *= cmb(N+dupes-1,N-1)
    ans = ans % X
print(ans%X)


Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x;
	scanf("%d",&x);
	if(x>=400&&x<=599)printf("8\n");
	else if(x>=600&&x<=799)printf("7\n");
	else if(x>=800&&x<=999)printf("6\n");
	else if(x>=1000&&x<=1199)printf("5\n");
	else if(x>=1200&&x<=1399)printf("4\n");
	else if(x>=1400&&x<=1599)printf("3\n");
	else if(x>=1600&&x<=1799)printf("2\n");
	else if(x>=1800&&x<=1999)printf("1\n");
	return 0;
}


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

using namespace std;

int main()
{
    int N,a;
    long long sum[200001] = {};
    long long min_num = 2 * pow(10, 9.0);

    cin >> N;

    for (int i = 1; i <= N; i++) {
        cin >> a;
        sum[i] = sum[i - 1] + a;
    }
    
    for ( int i = 1; i < N; i++) {
        min_num = min(min_num, abs(sum[N] - (2 * sum[i])));
    }
    cout << min_num << '\n';

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
	
	int n,m; cin>>n>>m;
	vector<pair<int,int>> ab(n);
	for(int i=0; i<n; i++) {
		cin>>ab.at(i).first>>ab.at(i).second;
		ab.at(i).second*=-1;
	}
	priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>> p,q;
	for(int i=0; i<n; i++){
		p.push(ab.at(i));
	}
	int sum{};
	for(int i=m-1; i>=0; i--){
		while(!p.empty()){
			auto t = p.top();
			if(t.first==m-i){
				p.pop();
				swap(t.first,t.second);
				q.push(t);
			}
			else break;
		}
		if(!q.empty()){
			auto t = q.top();
			sum += t.first;
			q.pop();
		}
	}
	cout << -sum << endl;
	
}


Measured memory_bytes: 3316
#include <iostream>
#include <queue>
using namespace std;
int main(){
  int n,t,p,c=0;
  string s;
  cin>>n>>t;
  queue<pair<string,int> >a;
  while(n--){
    cin>>s>>p;
    a.push(make_pair(s,p));
  }
  while(!a.empty()){
    pair<string,int>b=a.front();
    a.pop();
    if(b.second<=t){
      c+=b.second;
      cout<<b.first<<' '<<c<<endl;
    }
    else{
      b.second-=t;
      c+=t;
      a.push(b);
    }
  }
}

Measured memory_bytes: 6296
n, m = map(int, input().split())
ls = [[int(_) for _ in input().split()] for _ in range(m)]

flag = [0, 0]
ls1 = []
ls2 = []

for i in range(m):
    if ls[i][0] == 1 and ls[i][1] == n:
        flag[0] = 1
        break
    elif ls[i][0] == 1:
        ls1.append(ls[i][1])
    elif ls[i][1] == n:
        ls2.append(ls[i][0])

ls1_ls2 = set(ls1) & set(ls2)

if len(ls1_ls2) != 0:
    flag[1] = 1

if sum(flag) == 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Measured memory_bytes: 48616
def div(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
def check(a,b):
    if x == a**5-b**5:
        return 0
    return a**5-b**5    

x = int(input())
s = div(x)
s.sort()
for i in s:
    for j in range(i//2+1):
        if(check(i-j,-j)==0):
            print(i-j,-j)
            exit()
    k = 1        
    while(check(i+k,k)<=x):
        if check(i+k,k)==0:
            print(i+k,k)
            exit()
        k+=1

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

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  string ans = "No";
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= M; j++) {
      if (i * (M - j) + (N - i) * j == K) {
        ans = "Yes";
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<string.h>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>


#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



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


int N;

long int dp[17][17] = { 0 };

int gx, gy, p;
int px1[101], py1[101], px2[101], py2[101];

void input(void) {
	CI N;

	return;
}


int main(void) {
	input();

	int temp = 0;
	
	
	

	for (int x = 0; x < N;x++) {
		dp[1][0] = 1;
		CI gx >> gy >> p;
		for (int i = 0; i < p; i++) {
			CI px1[i] >> py1[i] >> px2[i] >> py2[i];
			if (px1[i] + py1[i] > px2[i] + py2[i]) {
				if (px1[i] == px2[i]) {
					dp[px1[i] + 1][py1[i] + 1] -= 1;
				}
				else {
					dp[px1[i] + 1][py1[i] + 1] -= 2;
				}
			}
			else {
				if (px1[i] == px2[i]) {
					dp[px2[i] + 1][py2[i] + 1] -= 1;
				}
				else {
					dp[px2[i] + 1][py2[i] + 1] -= 2;
				}
			}
		}
		for (int j = 1; j <= gy + 1; j++) {
			for (int i = 1; i <= gx + 1; i++) {
				if (dp[i][j] != -2 && dp[i][j] != -3) {
					temp += dp[i - 1][j];
				}
				if (dp[i][j] != -1 && dp[i][j] != -3) {
					temp += dp[i][j - 1];
				}
				dp[i][j] = temp;
				temp = 0;
			}
		}


		if (dp[gx + 1][gy + 1] == 0) {
			CO "Miserable Hokusai!" E
		}
		else {
			CO dp[gx + 1][gy + 1] E
		}
		for (int i = 0; i < 17; i++) {
			for (int j = 0; j < 17; j++) {
				dp[i][j] = 0;
			}
		}
		temp = 0;
	}
	return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>

typedef long long ll;
using namespace std;

int main(){
    ll N,M;
    cin >> N >> M;
    vector<pair<ll, ll>> ab(N);
    for (ll i = 0; i < N;i++){
        ll a, b;
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }
    sort(ab.begin(), ab.end());

    ll ans = 0, ext = 0;
    priority_queue<ll> tmp;

    for (ll j = 1; j <= M;j++){
        while(ab[ext].first <= j && ext < N){
            tmp.push(ab[ext].second);
            ext++;
        }
            if(tmp.empty())
                continue;

            ans += tmp.top();
            tmp.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 2936
def _input():
    array = input().split()
    # 人数と身長
    return int(array[0]), int(array[1])

def input_heights():
    array = input().split()
    array_as_int = []

    for i in array:
        array_as_int.append(int(i))
    return array_as_int

def result(array, limit):
    counter = 0
    for i in array:
        if limit <= i:
            counter += 1
    return counter


if __name__ == "__main__":
    number, height = _input()
    heights_array = input_heights()
    print(result(heights_array, height))
    
    
    

Measured memory_bytes: 11908
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	vector<int> a;
	vector<int> sorted_a;

	cin >> n;
	a.resize(n);

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

	sorted_a = a;
	sort(sorted_a.begin(), sorted_a.end(), greater<int>());

	for(int i = 0; i < n; ++i)
	{
		cout << (a[i] == sorted_a[0] ? sorted_a[1] : sorted_a[0]) << endl;
	}
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

li n, a, b;

bool read () {
	if (scanf("%lld%lld%lld", &n, &a, &b) != 3)
		return false;
	--a, --b;
	return true;
}

void solve() {
	li res = 0;
	if ((a + b) % 2 != 0){
		li k1 = min(a, b);
		li k2 = min(n - a - 1, n - b - 1);
		res += min(k1, k2) + 1;
		if (k1 < k2){
			a -= k1;
			b -= k1;
			if (a != 0) --a;
			else --b;
		}
		else{
			a += k2;
			b += k2;
			if (a != n - 1) ++a;
			else ++b;
		}
	}
	printf("%lld\n", res + abs(b - a) / 2);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while(read()) {	
#else
	if(read()) {
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define d double
using namespace std;
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin>>s;
  if(s=="SUN"){
  	cout<<"7"<<endl;
  }
  
  else if(s=="SAT"){
  	cout<<"1"<<endl;
  	
  }
  else if(s=="FRI"){
  	cout<<"2"<<endl;
  }
  else if(s=="THU"){
  	cout<<"3"<<endl;
  }
  else if(s=="WED"){
  	cout<<"4"<<endl;
  }
  else if(s=="TUE"){
  	cout<<"5"<<endl;
  }
  else if(s=="MON"){
  	cout<<"6"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
	int x,y,z;
	cin>>x>>y>>z;
	 if(y>z)
	 {
 		cout<<z<<" ";
 	}
 	else cout<<y<<" ";
 	int p;
 	if(y+z>x)
 	cout<<y+z-x;
 	else
 	cout<<0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <tuple>
#include <time.h>
using namespace std;

int main() {
#if _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vector<int>x(n + 1), ans;
	for (int i = 1; i <= n; ++i) {
		cin >> x[i];
	}
	for (int i = 1; i <= n; ++i) {
		if (x[i] != i) ans.push_back(i);
	}
	if (ans.size() > 2) {
		puts("NO");
	}
	else {
		if (ans.size() == 0) {
			puts("YES");
		}
		else {
			swap(x[ans[0]], x[ans[1]]);
			for (int i = 1; i <= n - 1; ++i) {
				if (x[i] > x[i + 1]) {
					puts("NO");
					return 0;
				}
			}
			puts("YES");
		}
	}
	return 0;
}


Measured memory_bytes: 888
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] S = sc.nextLine().split(" ");
    int min = 100000000;
    int ans = 0;
    for(int i = 0; i < N; i++){
      int M = Integer.parseInt(S[i]);
      if(M <= min){
        min = M;
        ans++;
      }
    }
    System.out.println(ans);
  }
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);

    }
    sort(a.begin(),a.end());
    cout<<a.at(n-1)-a.at(0)<<endl;
}

Measured memory_bytes: 256
def factorization(n):
    ans = 0
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            ch_point = 1
            while temp%i==0:
                cnt+=1
                if cnt == ch_point:
                    cnt = 0
                    ans += 1
                    ch_point += 1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])
        ans += 1

    if arr==[]:
        arr.append([n, 1])
        ans += 1

    return ans

N = int(input())
if N == 1:
    print(0)
    exit();


print(factorization(N))

Measured memory_bytes: 9488
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,A;
    cin>>s;
    int N=s.size();
    
    for (int i=0;i<N;++i){
        if(i==0){
            A+=s[i];
            continue;
        }
        else if(i%2==0){
            A+=s[i];
        }
        }
        cout<<A<<endl;
    }


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double n = sc.nextDouble(), m = sc.nextDouble(), d = sc.nextDouble();
        long nn = (long) n, dd = (long) d;

        double count = 2 * (n - d);
        double temp = count / (n * n);
        if (d == 0) temp = 1 / n;
        System.out.println((m - 1.0) * temp);
    }
}


Measured memory_bytes: 23124
{-# OPTIONS_GHC -O2 #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.ST
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import           Data.Primitive.MutVar
import qualified Data.Vector                 as V
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM

main :: IO ()
main = do
    [v, e] <- map read.words <$> getLine
    edges <- U.unfoldrN e (readInt2.B.dropWhile isSpace) <$> B.getContents
    putStr . unlines . map show . solve $ directedGraph v edges

solve :: Graph -> [Vertex]
solve gr = U.toList $ topologicalSort gr

------------------------------------------------------------------------------

readInt2 :: B.ByteString -> Maybe ((Int,Int), B.ByteString)
readInt2 bs = Just ((x,y),bsy)
  where
    Just (x, bsx) = B.readInt bs
    Just (y, bsy) = B.readInt $ B.unsafeTail bsx

unlessM :: Monad m => m Bool -> m () -> m ()
unlessM mb f = mb >>= flip unless f
{-# INLINE unlessM #-}

type Vertex = Int
type Edge = (Int, Int)
type Graph = V.Vector (U.Vector Vertex)

directedGraph :: Int -> U.Vector Edge -> Graph
directedGraph numV edges = V.map U.fromList
    . V.unsafeAccumulate (flip (:)) (V.replicate numV [])
    $ U.convert edges

vertices :: Graph -> U.Vector Vertex
vertices gr = U.generate (V.length gr) id

topologicalSort :: Graph -> U.Vector Vertex
topologicalSort gr = runST $ do
    visited <- UM.replicate (V.length gr) False
    sorted <- newMutVar []
    U.forM_ (vertices gr) . fix $ \dfs v ->
        unlessM (UM.unsafeRead visited v) $ do
            UM.unsafeWrite visited v True
            U.mapM_ dfs $ V.unsafeIndex gr v
            modifyMutVar' sorted (v:)
    U.fromList <$> readMutVar sorted

Measured memory_bytes: 9388
#include<bits/stdc++.h>
#define inf INT_MAX
#define sc(a) scanf("%d",&a)
#define scc(a,b) scanf("%d %d",&a,&b)
#define sccc(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pff(a,b) printf("%d %d",a,b)
#define pfff(a,b,c) printf("%d %d %d",a,b,c)
#define pb(a) push_back(a)
#define em empty()
#define fr front()
#define cl clear()
#define sz size()
#define mp(a,b) make_pair(a,b)
#define fri(b) freopen(b,"r",stdin)
#define fro(b) freopen(b,"w",stdout)
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
/*
ID: uslusam1
TASK: test
LANG: C++
*/
using namespace std;

long long n,w;
long long arr[113][3];
long long dp[113][100013];

long long solve(long long x,long long y,long long ans){
	if(y<0){
		return 0;
	}
	if(dp[x][y]!=-1){
		return ans+dp[x][y];
	}
	if(y==0){
		dp[x][y]=0;
		return ans;
	}
	if(x>n){
		dp[x][y]=0;
		return ans;		
	}	
	long long don=max(solve(x+1,y,ans),solve(x+1,y-arr[x][1],ans+arr[x][2]));
	dp[x][y]=don-ans;
	return don;
}
 
int main(){
	//fri("a.txt");
	//fro("b.txt");
	memset(dp,-1,sizeof dp);
	scanf("%lld %lld",&n,&w);
	for(int i=1;i<=n;i++){
		scanf("%lld %lld",&arr[i][1],&arr[i][2]);
	}
	long long bas=solve(1,w,0);
	cout<<bas<<endl;
	
	return 0;
}

Measured memory_bytes: 88576
#ifdef __GNUC__
#include <bits/stdc++.h>
#endif // __GNUC_

int main() {
    
    int N;
    std::cin >> N;
    std::vector<int> V(N);
    std::vector<int> C(N);
    for (auto& i : V)std::cin >> i;
    for (auto& i : C)std::cin >> i;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int dif = V[i] - C[i];
        if (dif > 0)ans += dif;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    if (a % k == 0 || b % k == 0 || b / k != a / k) 
        cout << "OK";
    else
        cout << "NG";
    cout << endl;
}

Measured memory_bytes: 3620
#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))
//-------------------------------------------------------

int N;
vector<int> E[101];

int col=100;
ll num=0;

int V[105];

void dfs(int cur,int pre,int d) {
	int n=0;
	FORR(e,E[cur]) if(e!=pre) {
		n++;
		dfs(e,cur,d+1);
	}
	V[d]=max(V[d],n);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	if(N==2) {
		cout<<1<<" "<<2<<endl;
		return;
	}
	FOR(i,N-1) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	
	
	FOR(i,N) {
		ZERO(V);
		dfs(i,i,0);
		
		int tc=0;
		ll tot=1;
		FOR(tc,101) {
			if(V[tc]==0) break;
			tot*=V[tc];
		}
		if(tc<col) col=tc, num=1LL<<62;
		if(tc==col) num=min(num,tot);
	}
	FOR(i,N) {
		FORR(e,E[i]) if(e>i) {
			ZERO(V);
			dfs(i,e,0);
			dfs(e,i,0);
			
			int tc=0;
			ll tot=2;
			FOR(tc,102) {
				if(V[tc]==0) break;
				tot*=V[tc];
			}
			
			if(tc<col) col=tc, num=1LL<<62;
			if(tc==col) num=min(num,tot);
		}
	}
	
	
	cout<<col+1<<" "<<num<<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);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <iomanip>
#include <string>
#include <algorithm>

int main()
{
    string s;
    cin>>s;
    bool flg=0;


    if(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihi"||s=="hihihihihi"){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int result;
  if(N>1000){
    if(N%1000==0){
      cout << 0 << endl;
      return 0;
    }
    result  = 1000-(N%1000); 
  }else{
    result = 1000-N;
  }
  cout << result<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, ans = 0, i;
    vector <pair<int, int>> v;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        int x;
        
        scanf("%d", &x);
        
        v.push_back(make_pair(x, i));
    }
    
    sort(v.begin(), v.end());
    
    for (i = 0; i < n; i++) {
        if (i % 2 == 0 && v[i].second % 2 == 1) ans++;
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 1400
import  numpy   as np
import  copy   
i_N =   int(input())
i_T =   input().split()
i_T =   np.array(i_T).astype(type(i_N))
i_M =   int(input())
i_X =   []
for i in range(i_M):
    i_tmp   =   input().split()
    i_X.append(i_tmp)

for P,X in i_X:
    i_calc  =   copy.deepcopy(i_T)
    i_calc[int(P)-1]  =   int(X)
    print(np.sum(i_calc))


Measured memory_bytes: 12380
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int C=sc.nextInt();
		int K=sc.nextInt();
		int[] time=new int[N];
		for(int i=0; i<N; i++) {
			time[i]=sc.nextInt();
		}
		Arrays.sort(time);		//そーと
		int[] kannin=new int[N];
		for(int i=0; i<N; i++) {
			kannin[i]=time[i]+K;
		}
		int bus=1;
		int ninzu=1;
		int min=time[0];
		int max=kannin[0];
		for(int i=1; i<N; i++) {
			if(time[i]<=max && ninzu<C) {
				ninzu++;
			}
			else if(time[i]<=max && ninzu>=C) {		//間に合ってても乗れない時
				bus++;
				ninzu=1;
				min=time[i];
				max=kannin[i];
			}
			else if(time[i]>max) {	//間に合わない時
				bus++;
				ninzu=1;
				min=time[i];
				max=kannin[i];
			}
		}
		System.out.println(bus);
	}
}

Measured memory_bytes: 50676
n = int(input())
a = list(map(int,input().split()))
b = 0
d = sum(a)
for m in range(n-1):
    d = d -a[m]
    b = b + a[m]*d
    if b >= 10**9+7:
        b = b % (10**9+7)
print(b)

Measured memory_bytes: 94292
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
tuple<int, int, char, int, string> t[111111];
signed main() {
	int n;
	cin >> n;
	rep(i, n) {
		int a, b, d;
		char c;
		string e;
		cin >> a >> b >> c >> d >> e;
		t[i] = make_tuple(a, b, c, d, e);
	}
	sort(t, t + n);
	rep(i, n) {
		int a = get<0>(t[i]);
		int b = get<1>(t[i]);
		char c = get<2>(t[i]);
		int d = get<3>(t[i]);
		string e = get<4>(t[i]);
		cout << a << " " << b << " " << c << " " << d << " " << e << endl;
	}
	return 0;
}


Measured memory_bytes: 13684
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N = int(readline())

for i in range(1,3501):
    for j in range(1,3501):
        if 4*i*j-N*i-N*j > 0 and (N*i*j)%(4*i*j-N*i-N*j) == 0:
            print(i,j,(N*i*j)//(4*i*j-N*i-N*j))
            exit()


Measured memory_bytes: 40684
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;

struct edge {
    i64 from, to, cost;
    edge(i64 from, i64 to) : from(from), to(to), cost(1) {}
    edge(i64 from, i64 to, i64 cost) : from(from), to(to), cost(cost) {}
};
using Graph = vector<vector<edge>>;

constexpr i64 SINF = std::numeric_limits<i64>::max() / 10;
const i64 MOD = 1000003;
const i64 dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const i64 dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//const i64 dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//const i64 dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}

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

int main() {
    i64 n, ans;
    cin >> n;
    ans = SINF;
    vector<i64> w(n);
    for(int i = 0; i < n; ++i) cin >> w[i];
    for (int i = 0; i < n - 1; ++i) {
        i64 s1, s2;
        s1 = s2 = 0;
        for (int j = 0; j < n; ++j) {
            if(j <= i) s1+= w[j];
            else s2 += w[j];
        }
        ans = min(ans, abs(s1 - s2));
    }
    cout << ans << endl;
 }

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{   int N;
    while(cin>>N){
        string s;
        cin>>s;

        int middle=N/2;int max1=0;
        while(max1<middle){
                int ar1[27]={0};int ar2[27]={0};
                int count1=0;
            for(int i=0;i<middle;i++){
                ar1[s.at(i)-96]=1;
            }
            for(int i=middle;i<N;i++){
                ar2[s.at(i)-96]=1;
                }
            for(int i=1;i<=26;i++){

                if(ar1[i]==1&&ar2[i]==1){
                    count1++;
                }
            }
               middle-=1;
               if(count1>=max1){
                max1=count1;
               }

            }
          int middle1=N/2;int max2=0;
        while(max2<N-middle1){
            int ar1[27]={0};int ar2[27]={0};
                int count1=0;
            for(int i=0;i<middle1;i++){
                ar1[s.at(i)-96]=1;
            }
            for(int i=middle1;i<N;i++){
                ar2[s.at(i)-96]=1;
                }
            for(int i=1;i<=26;i++){
                if(ar1[i]==1&&ar2[i]==1){
                    count1++;
                }
            }
               middle1+=1;
               if(count1>=max2){
                max2=count1;
               }
            }
        int c=max(max1,max2);

        cout<<c<<endl;
    }
return 0;

}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int, C: int, D: int):
    while True:
        C -= B
        if C <= 0:
            print(YES)
            return
        A -= D
        if A <= 0:
            print(NO)
            return
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)


if __name__ == '__main__':
    main()


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

int main()
{
  string a, b, c, d;
  cin >> a >> b;
  c=a; d=b;
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  
  if (b==c && a==d) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;
	int red = 0, blue = 0;
	rep(i, n) {
		if (s[i] == 'R') red++;
		else blue++;
	}
	if (blue < red)  cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for i in range(N)]
B = sorted(A,reverse=True)
if B[0] == B[1]:
    for i in range(N):
        print(B[0])
else:
    for i in range(N):
        if A[i] == B[0]:
            print(B[1])
        else:
            print(B[0])

Measured memory_bytes: 14088
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>

using namespace std;

int main() {
  int n, m, k;
  cin >> n >> m >> k;

  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (i * m + j * n - 2 * i * j == k) {
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;

typedef double db;
using namespace std;

ll N, K;
ll V[52];
ll dl[52][52], dr[52][52]; //dl[x][y]左からxまで取り出し&y個まで突っ込んでいいよのスコア最大値

int main()
{
  cin>>N>>K;
  rep1(i,N){
    cin>>V[i];
    dl[i][0]=dl[i-1][0]+V[i];
  }
  rrep1(i,N){
    dr[i][0]=dr[i+1][0]+V[i];
  }


  vector<ll> v;
  rep1(i,N){
    v.push_back(V[i]);
    sort(v.begin(), v.end());
    rep1(j,N){
      dl[i][j] = dl[i][j-1];
      if(j <= v.size() && v[j-1]<0) dl[i][j]-=v[j-1];
    }
  }

  vector<ll> w;
  rrep1(i,N){
    w.push_back(V[i]);
    sort(w.begin(), w.end());
    rep1(j,N){
      dr[i][j]=dr[i][j-1];
      if(j<=w.size() && w[j-1]<0) dr[i][j]-=w[j-1];
    }
  }
  ll ans = 0;
  rep(i, N+1){
    rep(j, i+1){
      rep(k, N+1){
        if(i+k>N) continue;
        rep(l, k+1){
          if(i+j+k+l>K) continue;
          ans = max(ans, dl[i][j]+dr[N+1-k][l]);
        }
      }
    }
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 256
#include"iostream"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"iomanip"
using namespace std;
typedef long long ll;
struct ab
{
    ll a,b;
    bool operator<(const ab & ob) const
    {
        return a==ob.a?b<ob.b:a<ob.a;
    }
};
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;cin>>n>>k;
    vector<ab>rec(n);
    for(int i=0;i<n;++i)
    {
        ll a,b;cin>>a>>b;
        ab ob;ob.a=a;ob.b=b;
        rec[i]=ob;
    }
    sort(rec.begin(),rec.end());
    ll c=0;
    for(int i=0;i<n;++i)
    {
        c+=rec[i].b;
        if(c>=k)
        {
            cout<<rec[i].a<<'\n';
            return 0;
        }
    }
}

Measured memory_bytes: 1792
num = gets.to_i
ary = gets.split.map(&:to_i)

(num-1).times{ |j| print "#{ary[j]} "}
print "#{ary[-1]}\n"

for i in 1..num-1

  compared = i - 1

  while compared >= 0 && ary[compared] > ary[i]

    ary[compared], ary[i] = ary[i], ary[compared]
    i -= 1
    compared -= 1
  end

  (num-1).times{ |j| print "#{ary[j]} "}
  print "#{ary[-1]}\n"
end



Measured memory_bytes: 6876