akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var dic = new Dictionary<string, int>();
            for (var i = 0; i < n; i++)
            {
                var str = Console.ReadLine();
                if (dic.TryGetValue(str, out var num))
                {
                    dic[str] = num + 1;
                }
                else
                {
                    dic[str] = 1;
                }
            }

            var max = dic.Values.Max();
            foreach (var str in dic.Where(kvp => kvp.Value == max).OrderBy(kvp => kvp.Key))
            {
                Console.WriteLine(str.Key);
            }

        }
    }
}

Measured memory_bytes: 53388
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
from collections import deque


# from decorator import stop_watch
#
#
# @stop_watch
def solve(H, W, Ss):
    Ss = ['#' + S + '#' for S in Ss]
    Ss = ['#' * (W + 2)] + Ss + ['#' * (W + 2)]
    # for S in Ss:
    #     print(S)
    ans = 0
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if Ss[i][j] == '#':
                continue
            visited = [[-1] * (W + 2) for _ in range(H + 2)]
            now = 0
            visited[i][j] = now
            q = deque([(i, j, now)])
            while q:
                x, y, n = q.popleft()
                # for v in visited:
                #     print(v)
                # input()
                for x1, y1 in [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]:
                    if Ss[x1][y1] == '.' \
                            and visited[x1][y1] < 0:
                        q.append((x1, y1, n + 1))
                        visited[x1][y1] = n + 1
            ans = max(ans, max([max(v) for v in visited]))

    print(ans)


if __name__ == '__main__':
    H, W = map(int, input().split())
    Ss = [input() for _ in range(H)]
    solve(H, W, Ss)


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

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

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

  s += s;
  while (p.length() >  s.length()) s += s;

  cout << ((s.find(p) != string::npos) ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 3200
#include <iostream>

using namespace std;

int main(void) {
  int x1, x2, x3, x4, x;
  int y1, y2, y3, y4, y;
  cin >> x1 >> y1 >> x2 >> y2;
  x = x2 - x1;
  y = y2 - y1;
  x3 = x2 - y;
  y3 = y2 + x;
  x4 = x3 - x;
  y4 = y3 - y;
  printf("%d %d %d %d\n", x3, y3, x4, y4);
  return 0;
}

Measured memory_bytes: 3212
#include<iostream>

using namespace std;

int main(){
	int n,a[10],f,s;
	bool flg=true;
	
	cin>>n;
	
	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++){
			cin>>a[j];
		}
		f=0;s=0;flg=true;
		for(int j=0;j<10;j++){
			if(a[j]<f){
				if(a[j]<s)flg=false;
				else s=a[j];
			}else f=a[j];
		}
		if(flg)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}

}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "NO" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    string N;
    //Nは最大で100桁あるので、longlongではオーバーフローしてしまう
    //そこでstringで入力する
    int K;
    cin >> N >> K;
    
    //桁DPの典型的な問題
    //まず、Nの具体的な値は無視して、以下のDPをする
    //dp[i][j][k]=[j*10^i,(j+1)*10^i)までに0でない桁がk桁あるような数の個数
    //このDPは、以下の遷移で求まる
    //dp[i][j][k]=(i=0 j=0 k=0)1
    //            (i=0 j=0 k!=0)0
    //            (i=0 j!=0 k=1)1
    //            (i=0 j!=0 k!=1)0
    //            (i!=0 j=0)Σ[j,0~9] dp[i-1][j][k]
    //            (i!=0 j!=0)Σ[j,0~9] dp[i-1][j][k-1]
    
    int dp[104][11][5]={};
    REP(j,10){
        if(j==0){
            dp[0][j][0]=1;
        }else{
            dp[0][j][1]=1;
        }
    }
    
    REP(k,K+1){
        REP(i,N.size()){
            if(i==0)continue;
            REP(j,10){
                if(j==0){
                    REP(l,10){
                        dp[i][j][k]+=dp[i-1][l][k];
                    }
                }else if(k!=0){
                    REP(l,10){
                        dp[i][j][k]+=dp[i-1][l][k-1];
                    }
                }
            }
        }
    }
    
    //そうしてDPのボードが完成したら答えを求める
    //Nの上からi桁目をDとおき、[0,D)だけdp[i][j][k]を足す
    //なお、最後の桁だけは[0,D]
    //Dが0のときは以降の桁に0が残り続けるので、kをデクリメントする
    //全ての桁を調べるかkが負になったら終了
    
    int Ans=0;
    int k=K;
    RREP(i,N.size()){
        int D=N[N.size()-1-i]-'0';
        if(i==0)D++;
        REP(j,D){
            Ans+=dp[i][j][k];
        }
        if(D!=0)k--;
        if(k<0)break;
    }
    cout << Ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.StringTokenizer;

import static java.lang.Math.max;
import static java.lang.Math.min;

/**
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) throws IOException {
        OutputStream outputStream = System.out;
        FastReader in = new FastReader();
//        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(1, in, out);
        out.close();
    }


    static class Solver {


        public void solve(int testNumber, FastReader in, PrintWriter out) throws IOException {
            Set<Pair> set = new HashSet<>();
            int ans = 0;
            int n = in.nextInt();
            for (int i = 0; i < n; i++) {
                int x = in.nextInt();
                Pair p = new Pair(min(i + 1, x), max(i + 1, x));
                if (!set.add(p)) ans++;
            }
            out.println(ans);
        }

        static class Pair {
            int x;
            int y;

            public Pair(int x, int y) {
                this.x = x;
                this.y = y;
            }

            @Override
            public boolean equals(Object o) {
                if (this == o) return true;
                if (o == null || getClass() != o.getClass()) return false;
                Pair pair = (Pair) o;
                return x == pair.x &&
                        y == pair.y;
            }

            @Override
            public int hashCode() {
                return Objects.hash(x, y);
            }
        }
    }


    static class FastReader implements AutoCloseable {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() throws FileNotFoundException {
            br = new BufferedReader(new InputStreamReader(System.in));
//            br = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        @Override
        public void close() throws Exception {

        }
    }
}

Measured memory_bytes: 45888
#include <bits/stdc++.h>
using namespace std;
string rotate(string s){
  return s.substr(1)+s[0];
}
int main(){
  string s,t;
  cin>>s>>t;
  int cnt=0;
  int n=s.length();
  for(int i=0;i<n;i++){
    if(s==t){
      cnt++;
    }
    else{
      s=rotate(s);
    }
  }
  if(cnt>0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
struct dot{
    int x,y;
}a[58],b[58];
int n,m;
int main(){
    cin>>n>>m;
    int i,j;
    for(i=1;i<=n;i++)
    cin>>a[i].x>>a[i].y;
    for(i=1;i<=m;i++)
    cin>>b[i].x>>b[i].y;
    for(i=1;i<=n;i++)
    {
        int minn=1000000000,k;
        for(j=1;j<=m;j++)
        {
            int dis=abs(a[i].x-b[j].x)+abs(a[i].y-b[j].y);
            if(dis<minn)minn=dis,k=j;
        }
        cout<<k<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(a * b);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

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

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

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32568
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
ln = len(bin(max(a))) -2
cnt = [0] * ln
for x in a:
    for shift in range(ln):
        cnt[shift] += (x>>shift)%2
# print(cnt)
res = 0
for i in range(ln):
    now = cnt[i] * (n-cnt[i])
    res += now*pow(2,i)
    res %= mod
print(res)  



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

using namespace std;
typedef long long ll;
int main(){
    ll n,m;
    cin >> n >> m;
    ll i,j,k;
    vector<vector<ll>> v(100010);
    priority_queue<ll> pq;
    for(i=0;i<n;i++){
        pair<ll,ll>p;
        cin >> p.first >> p.second;
        v[p.first].push_back(p.second);
    }
    ll ret = 0;
    for(i=1;i<=m;i++){
        for(j=0;j<v[i].size();j++){
            pq.push(v[i][j]);
        }
        if(!pq.empty()){
            ret+=pq.top();
            pq.pop();
        }
    }
    cout << ret << endl;
    return 0;
}

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

int main(){

for(;;){
int x,y;
cin>>x>>y;
if(x==0 && y==0)break;
	for(int i=0;i<x;i++){
		for(int g=0;g<y;g++){
		cout<<"#";
		}
		cout<<endl;
		}
cout<<endl;
}
return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<ctime>
#define R(i, n) for(int i = 0;i < n;i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", a + i)
#define P(a) printf("%d", a)
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;

int N;

int main() {
	S(N);
	ll ans = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			ans += i;
		}
	}
	printf("%lld", ans);
}

Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
#define INF 2e9+5
#define ll long long

vector<ll >coins;
vector<ll >weight;
ll dp[102][100001];
ll solve(int x,int w)
{
    if(w<0)
        return INT_MIN;
    if(x==coins.size())
        return 0;
    if(dp[x][w]!=-1)
        return dp[x][w];
    return dp[x][w]=max(solve(x+1,w-weight[x])+coins[x],solve(x+1,w));
}
int main()
{
    int n,w;
    cin>>n>>w;
    for(int i=0;i<n;i++)
    {
        int Coins;
        int Weight;
        cin>>Weight>>Coins;
        weight.push_back(Weight);
        coins.push_back(Coins);
    }
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,w)<<endl;
    return 0;
}


Measured memory_bytes: 80000
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll N,minimum=1000000000;
  cin>>N;
  vector<ll> A(N);
  for(ll i=0;i<N;i++){
    cin>>A.at(i);
    minimum=min(minimum,A.at(i));
  }
  while(true){
    ll x=minimum,check=0,count=0;
    for(ll i=0;i<N;i++){
      if(A.at(i)!=x || check>0){A.at(i)=A.at(i)%x;}
      if(A.at(i)==x){check++;}
      if(A.at(i)==0){count++;}
      else{minimum=min(minimum,A.at(i));}
    }
    if(count==N-1){break;}
  }
  cout<<minimum<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define es cout<<" "
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;
template<class T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<class T, class... Ts> 
auto make_vec(size_t a, Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}

int main(void) {
    int n; cin >> n;
    vector<lint> v(n);
    repeat (i, n) cin >> v[i];
    
    lint ans = 0;
    repeat_from_to (i, 1, (n-1)/2) {
        lint tmp = 0;
        lint l = 0;
        lint r = n-1;
        do {
            tmp += v[l];
            tmp += v[r];
            ans = max(ans, tmp);
            l += i;
            r -= i;
            
            if ((n-1) % i == 0) {
                if (l >= r) break;
            }
            else {
                if (l >= (n-1)-i or r <= i) break;
            }
        } while (true);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
inline int read()
{
	int x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}
const int N=1e5+9;
int n,a[N],ha[N];
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read(),ha[i]=a[i];
	sort(ha+1,ha+n+1);
	for(int i=1;i<=n;i++)
		a[i]=lower_bound(ha+1,ha+n+1,a[i])-ha;
	int ans=0;
	for(int i=2;i<=n;i+=2)if(a[i]&1)ans++;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mod 1000000007
#define F first
#define S second
#define eb emplace_back
int main()
{
    //freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    lli n,m,i,j,k;
    cin>>n>>k;
    lli dp[k+1]={},ar[k+1]={};
    for(i=0;i<n;i++)
    {
        cin>>ar[i];
        dp[ar[i]]=1;
    }
    //m=ar[n-1];
    for(i=0;i<=k;i++)
    {
        if(dp[i]==1)
        continue;
        for(j=0;j<n;j++)
        if(i-ar[j]>=0)
            if(dp[i-ar[j]]==0)
            {
                dp[i]=1;
                break;
            }
    }
    //for(i=0;i<=k;i++)
    //    cout<<dp[i]<<" ";cout<<"\n";
    if(dp[k]==1)
        cout<<"First";
    else
        cout<<"Second";
    return 0;
}


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

signed main(){
    string s,t,u; cin>>s>>t>>u;
    char a='A'+(s.at(0)-'a'),b='A'+(t.at(0)-'a'),c='A'+(u.at(0)-'a');
    cout<<a<<b<<c;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(void) {
	int i=2, A,B,ans=1,count=0;
	scanf("%d %d", &A, &B);
	while (ans < B) {
		ans = ans + A - 1;
		count++;
	}
	printf("%d", count);
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void)
{
	int e1, e2, e3, e4;
	scanf("%d %d %d %d", &e1, &e2, &e3, &e4);
	if ((e1 == e2 && e3 == e4) || (e1 == e3 && e2 == e4) || (e1 == e4 && e2 == e3))
		printf("yes\n");
	else
		printf("no\n");
	return 0;
}



Measured memory_bytes: 2144
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String S = in.readLine();
		ArrayList<String> list = new ArrayList<String>();
		String tmp = S.substring(0,1);
		int indx=1;

		list.add(tmp);
		for(int i=2;i<S.length();i++){
			if(!tmp.equals(S.substring(indx,i))){
				tmp = S.substring(indx,i);
				list.add(tmp);
				indx=i;

			}
		}
		if(!"".equals(S.substring(indx,S.length())) && !tmp.equals(S.substring(indx,S.length()))){
			tmp = S.substring(indx,S.length());
			list.add(tmp);
		}


		System.out.println(list.size());

	}




}


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

int main()
{
    int h, w;
    cin >> h >> w;

    vector<vector<char>> vvc(h, vector<char> (w));
    vector<bool> row(h, false), col(w, false);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> vvc[i][j];
            if (vvc[i][j] == '#') row[i] = col[j] = true;
        }
    }

    for (int i = 0; i < h; i++) {
        if (!row[i]) continue;
        for (int j = 0; j < w; j++) {
            if (!col[j]) continue;
            cout << vvc[i][j];
        }
        cout << endl;
    }

    return 0;
}


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

int main() {
	int X, A, B, C;
	int count = 0;
	cin >> A >> B >> C >> X;

	for (int i=A; i>=0; --i) {
		if (X >= i * 500) {
			for (int j=B; j>=0; --j) {
				if ((X - i * 500) >= j * 100) {
					for (int k=C; k>=0; --k) {
						if (((X - i * 500 - j * 100) - (k * 50)) == 0) ++count;
					}
				}
			}
		}
	}
	cout << count << endl;

	return 0;
}

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

#define REP(i, n) for (int i=0;i<(n);i++)
#define FOR(i, a, b) for (int i=(a);i<(b);i++)

using namespace std;

int N;
int a[101];
int b[101];
int c[101];
int d[101];

int main()
{
    scanf("%d", &N);
    REP(i, N)
        scanf(" %d %d", &a[i], &b[i]);
    REP(i, N)
        scanf(" %d %d", &c[i], &d[i]);

    bool used_cd[101];
    bool used_ab[101];
    REP(i, N) {
        used_ab[i] = false;
        used_cd[i] = false;
    }
    int ans = 0;
    REP(j, N) {
        int c_min = 2*N+1;
        int d_min;
        int tmp_cd;
        REP(i, N) {
            if(c[i]<c_min && !used_cd[i]) {
                c_min = c[i];
                d_min = d[i];
                tmp_cd = i;
            }
        }
        used_cd[tmp_cd] = true;
        int b_max = -1;
        bool exist = false;
        int tmp_ab;
        REP(i, N) {
            if(a[i]<c_min && b[i]<d_min && b[i]>b_max && !used_ab[i]) {
                b_max = b[i];
                tmp_ab = i;
                exist = true;
            }
        }
        if(exist) {
            ans++;
            used_ab[tmp_ab] = true;
        }
    }
    printf("%d\n", ans);


    return 0;
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve())
}

func resolve() int {
	n, m := scanInt(sc), scanInt(sc)
	nums := make([]int, m)
	for _ = range loop0(n) {
		k := scanInt(sc)
		for _ = range loop0(k) {
			nums[scanInt(sc)-1]++
		}
	}
	v := 0
	for i := range loop0(m) {
		if nums[i] == n {
			v++
		}
	}
	return v
}

func loop0(n int) chan int {
	return loop(0, n-1, 1)
}

func loop1(n int) chan int {
	return loop(1, n, 1)
}

func loop(s, e, d int) chan int {
	ch := make(chan int)
	go func() {
		for i := s; i <= e; i += d {
			ch <- i
		}
		close(ch)
	}()
	return ch
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}

Measured memory_bytes: 1804
def insertionSort(A,g):
    global cnt
    
    for i in range(g,len(A)):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
            
def shellSort(A):
    global cnt
    cnt = 0
    h = 1
    g = []
    while h <= len(A):
        g.append(h)
        h = 3*h+1
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str,g)))
    for i in range(m):
        insertionSort(A,g[i])

    

n = int(input())
A = [int(input()) for i in range(n)] 


shellSort(A)
print(cnt)
for i in A:
    print(i)
            


Measured memory_bytes: 45524
// https://atcoder.jp/contests/abc177/tasks/abc177_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const int SZ = 1e6;

// エラトステネスの篩
template <int N> struct Prime {
    bitset<N + 1> b;
    Prime() : b() {
        // trueで初期化
        b.flip();
        b[0] = b[1] = false;
        for (int i = 2; i <= N; ++i) {
            if (b[i]) {
                for (int j = i * i; j <= N; j += i) {
                    b[j] = false;
                }
            }
        }
    }
};
Prime<SZ> prime;

void solve() {
    int N;
    cin >> N;
    vector<int> A(N), D(SZ + 1);
    for (auto &x : A) {
        cin >> x;
        // 同じ数が重複するケースを考慮
        D[x]++;
    }
    // trueなら "pairwise coprime"
    bool pc = true;

    REP(i, SZ) {
        // 素数の場合
        if (prime.b[i]) {
            int cnt = 0;
            for (int now = i; now <= SZ; now += i) {
                cnt += D[now];
            }
            // 共通の素数を含むのでgcd(ALL) >= i
            if (cnt >= 2) {
                pc = false;
                break;
            }
        }
    }
    if (pc) {
        cout << "pairwise coprime" << endl;
    } else {
        int g = A[0];
        for (auto &x : A) {
            g = gcd(g, x);
        }
        if (g == 1)
            cout << "setwise coprime" << endl;
        else
            cout << "not coprime" << endl;
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 18972
#include <stdio.h>
#include <stdlib.h>
int desc(const void *a, const void *b){
    return *(int*)b-*(int*)a;
}
int main(void){
    int n,k,i;
    scanf("%d%d",&n,&k);
    int h[n];
    long long ans=0;
    for(i=0;i<n;i++) scanf("%d",&h[i]);
    qsort(h,n,sizeof(int),desc);
    for(i=0;i<n;i++){
        if(k>0) k--;
        else ans+=h[i];
    }
    printf("%lld",ans);
    return 0;
}

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

using ll = long long;

using namespace std;

using P = pair<ll, int>;
#define fi first
#define se second

int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<P> apple;
    for (int i=0; i<a; i++) {
        ll pi;
        cin >> pi;
        apple.push_back({pi, 0});
    }
    for (int i=0; i<b; i++) {
        ll qi;
        cin >> qi;
        apple.push_back({qi, 1});
    }
    for (int i=0; i<c; i++) {
        ll ri;
        cin >> ri;
        apple.push_back({ri, 2});
    }
    sort(apple.begin(), apple.end(), greater<P>());
    int pi = 0, qi = 0, idx = 0;
    ll ans = 0;
    for (int i=0; i<x+y; i++) {
        while (pi == x && apple[idx].second == 0) idx++;
        while (qi == y && apple[idx].second == 1) idx++;
        ans += apple[idx].first;
        if (apple[idx].second == 0) pi++;
        if (apple[idx].second == 1) qi++;
        idx++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 10604
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  vll a(n); REP(i, n) cin >> a.at(i);
  ll ans = 0;
  REP(i, n) ans += a.at(i)-1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
ans = 100000
for i in range(len(A)):
    cnt = 0
    while A[i] % 2 == 0:
        A[i] /= 2
        cnt += 1
    # print(cnt)
    ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 1e9
#define EPS 1e-9
#define MOD (998244353)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}

const int z=700001;

using vl=vector<ll>;

vl fact_mod(z,1), fact_invmod(z);

ll modpow(ll a, ll n){
	if(n==1)return a;
	ll half=modpow(a,n/2);
	return (n%2?modpow(a,n-1)*a:half*half)%MOD;
}

void calc(){
	range(i,1,z) fact_mod[i]=fact_mod[i-1]*i%MOD;
	fact_invmod[z-1]=modpow(fact_mod[z-1],MOD-2);
	for(int i=z-2;i>=0;i--) fact_invmod[i]=fact_invmod[i+1]*(i+1)%MOD;
}

ll nCr_mod(int n,int r){
	return fact_mod[n] * fact_invmod[r]%MOD * fact_invmod[n-r]%MOD;
}

int main(){
    calc();
    ll n,a,b,k;
    cin>>n>>a>>b>>k;
    if(b<a)swap(a,b);
    
    ll ans=0;
    for(ll c=0;a*c<=k and c<=n ;c++){
        if((k-a*c)%b!=0) continue;
        ll d=(k-a*c)/b;
        if(c>n or d>n) continue;
        ll ca=nCr_mod(n,c);
        ll cb=nCr_mod(n,d);
        ans=(ans+ca*cb)%MOD;
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 11136
#include<cstdio>
using namespace std;
int a,b,c;
int ans;
int main()
{
 scanf("%d%d%d",&a,&b,&c);
 for(int i=a;i<=b;i++)if(c%i==0)ans++;
 printf("%d\n",ans);
 return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
  char x[3];
  for(int i=0;i<3;i++){
     cin>>x[i];
     if(x[i]=='9'){
       x[i]='1';
  }else{
       x[i]='9';
  }}
 for(int i=0;i<3;i++){
   cout<<x[i];
}
cout<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << p.first << " " << p.second; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  int n; cin >> n;
  V q(n);
  rep(i, n) {
    int p; cin >> p;
    --p;
    q[p] = i;
  }

  int ans = 0;
  int now = 1;
  rep2(i, 1, n) {
    if (q[i] > q[i-1]) ++now;
    else {
      chmax(ans, now);
      now = 1;
    }
  }
  chmax(ans, now);

  ans = n - ans;
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 4000
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Collections;
import java.util.Arrays;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int N = reader.nextInt();
		String S = reader.next();
		int K = reader.nextInt();
		char base = S.charAt(K-1);
		for(int i=0; i<N; i++) {
		    if (S.charAt(i) == base) System.out.print(S.charAt(i));
		    else System.out.print("*");
		}
		System.out.println();
	}
	
	public static void solver(int H, int W, boolean[][] matrix) {
		// write logic
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 21204
n,k = map(int,input().split())
s = input()
now = 1
cnt = 0
Nums = []
for i in range(n):
    if s[i] == str(now): cnt += 1
    else:
        Nums.append(cnt)
        now = 1-now
        cnt = 1
if cnt != 0: Nums.append(cnt)

if len(Nums)%2 == 0: Nums.append(0)
ad = 2*k+1
# print(Nums)
ans = 0
left = right = 0
tmp = 0
for i in range(0,len(Nums),2):
    nextleft = i
    nextright = min(i+ad, len(Nums))
    while nextleft > left:
        tmp -= Nums[left]
        left += 1
    while nextright > right:
        tmp += Nums[right]
        right += 1
    ans = max(tmp,ans)
print(ans)

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

map<int,int> flg;

void solve(int p,int q,int now){
  int r = p % q;
  int w = p / q;
  if(flg[r] != 0){
    cout << w << endl;
    for(int i=0;i<flg[r]-1;i++) cout << " ";
    for(int i=flg[r]-1;i<now+1;i++) cout << "^";
    cout << endl;
  } else {
    flg[r] = now + 2;
    cout << w;
    if(r != 0) solve(r*10,q,now+1);
    else cout << endl;
  }
  return;
}

int main(){
  int p,q;
  while(cin >> p >> q){
    flg[p%q] = 1;
    solve(p*10,q,0);
    flg.clear();
  }
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i < (n);++i)
typedef long long ll;
using namespace std;
 
int main(){
  int k;
  cin >> k;
  
  int ans;
  
  if(k%2 ==0) ans = k*k/4;
  else ans = k/2*(k+1)/2;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys


def input():
    return sys.stdin.readline()[:-1]


H, W = map(int, input().split())

sy = 0
sx = 0
gy = H-1
gx = W-1

board = [list(input().strip()) for _ in range(H)]
visited = [[0 for i in range(W)] for j in range(H)]

q = deque([])
q.append([sy, sx, 0])
is_reach = False

while q:
    y, x, z = q.popleft()
    if y == gy and x == gx:
        is_reach = True
        break
    if (not 0 <= y < H) or (not 0 <= x < W):
        continue
    if board[y][x] == "." and visited[y][x] == 0:
        q.append([y+1, x, z+1])
        q.append([y, x+1, z+1])
        q.append([y-1, x, z+1])
        q.append([y, x-1, z+1])
        visited[y][x] = 1

if is_reach:
    num_white = 0
    for i in range(H):
        for j in range(W):
            if board[i][j] == ".":
                num_white += 1
    print(num_white-z-1)
else:
    print(-1)


Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
using namespace std::chrono;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=a;i<b;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define sum(...) accumulate(range(__VA_ARGS__),0)
#define _range(i) (i).begin(),(i).end()
#define rangek(i,k) (i).begin(),(i).begin()+k
#define range(...) _overload3(__VA_ARGS__,a,_rangek,_range)(__VA_ARGS__)
const ll LINF=1000000000000000000;
const int INF=100000007;
const ll MOD=100000007;
#define Yes(i) out((i)?"Yes":"No")
#define vec(type,name,size) vector<type> name(size);
#define VEC(type,name,size) vector<type> name(size);in(name)
#define INT(i) int i;in(i)
#define LL(i) ll i;in(i)
#define STR(i) string i;in(i)
#define CHR(i) char i;in(i)
#define DBL(i) double i;in(i)
struct aaa{aaa(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}aaaaaaa;
template<typename T>
istream& operator >> (istream& is, vector<T>& vec);
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p);
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec);
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p);
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p){is >> p.first;is >> p.second;return is;}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){rep(i,vec.size()){os << vec[i] << ( i+1 == vec.size() ? "" : " " );}return os;}
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}
inline void in() {}
inline void in(int&& a){scanf("%d",&a);}
inline void in(ll&& a){scanf("%lld",&a);}
inline void in(double&& a){scanf("%lf",&a);}
inline void in(char&& a){scanf("%c",&a);}
template<class T>
inline void in(T&& a){cin>>a;}
template<class Head,class... Tail>
inline void in(Head&& head,Tail&&... tail){in(head);in(move(tail)...);}
inline void out(){cout<<'\n';}
inline void out(const char a[]){if(strcmp(a,"No_Break"))cout<<a<<'\n';}
template<class T>
inline void out(T a){cout<<a<<'\n';}
template<class Head,class... Tail>
inline void out(Head head,Tail... tail){cout<<head<<' ';out(move(tail)...);}




int main(){
    INT(n);
    INT(m);
    out(((n-m)*100+m*1900)*1<<m);
}









Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

int main(){
    int n;cin >> n;
    vector<int> p(n+1);
    bool sw  =true;
    for(int i=0;i<=n;i++){
        p[i] = 0;
    }
    for(int j=2;j<=n;j++){
        int tmp = j;    
        for(int i=2;i<=n;i++){
            while(tmp%i == 0){
                tmp = tmp/i;
                p[i] ++;
            }
        }
    }
    for(int i=2;i<=n;i++){
      //  cout <<i << " " <<  p[i] << endl;
    }
    int ans = 0;
    for(int i=2;i<=n;i++){
        if(p[i] >= 74){
                ans ++;
            }
        for(int j=2;j<=n;j++){
            if(i != j){
                if(p[i] >= 14 && p[j] >= 4){
                    ans ++;
                }
            }
            if(i != j){
                if(p[i] >= 24 && p[j] >= 2){
                    ans ++;
                }
            }
            
            for(int k=2;k<=n;k++){
                if(i < j && j != k && k != i){
                    if(p[i] >= 4 && p[j] >= 4 && p[k] >= 2){
                        ans ++;
                    }
                }

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

Measured memory_bytes: 256
// Aaradhya Beri
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    string s;
    cin>>s;
    if(s == "ABC")
    	cout<<"ARC";
    else
    	cout<<"ABC";
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const double PI = acos(-1);
const double EPS = 1e-9;

const int MX = 100005;
const int MM = 1000000007;

int N, M;
vector<int> G[MX];
vector<int> L;

int vst[MX], chk[MX];
void dfs(int x, int t){
	if( vst[x] ) return;
	vst[x] = 1;
	for(int c : G[x]){
		if( vst[c] ) continue;
		if( t == 0 ) L.push_back(c), chk[c] = 1;
		dfs(c, t++);
	}
}

int main()
{
	scanf("%d%d", &N, &M);
	for(int i = 1; i <= M; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int t = 0;
	vst[1] = 1;
	L.push_back(1), chk[1] = 1;
	for(int c : G[1]){
		if( vst[c] ) continue;
		L.push_back(c), chk[c] = 1;
		dfs(c, 0);
		if( ++t == 2 ) break;
		reverse(L.begin(), L.end());
		for(int i = 1; i <= N; i++) vst[i] = chk[i];
	}
	printf("%d\n", L.size());
	for(int c : L) printf("%d ", c);
	printf("\n");
}


Measured memory_bytes: 13304
#include<bits/stdc++.h>
using namespace std;
int n,a,hsh1[100005],hsh2[100005],sum=0;
vector<pair<int,int> > v1,v2;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if(i%2==1)
		{
			++hsh1[a];
		}else
		{
			++hsh2[a];
		}
	}
	for(int i=1;i<=100000;i++)
	{
		v1.push_back(make_pair(hsh1[i],i));
		v2.push_back(make_pair(hsh2[i],i));
	}
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	if(v1[99999].second!=v2[99999].second)
	{
		printf("%d\n",n-v1[99999].first-v2[99999].first);
	}else
	{
		printf("%d\n",min(n-v1[99999].first-v2[99998].first,n-v1[99998].first-v2[99999].first));
	}
}

Measured memory_bytes: 5892
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
//I referred to other's code.
const int MAX_L = 10000001;
string s;
int needidx;
string expr(int& p);
int num(int& p){
  int res = 0;
  while(isdigit(s[p])){
    res = res * 10 + (s[p++] - '0');
  }
  return res;
}
string chara(int& p){
  string res = "";
  while(isalpha(s[p])){
    res += s[p++];
  }
  return res;
}
string term(int& p){
  string res;
  if(isalpha(s[p])){
    res =  chara(p);
  }else{
    int n = num(p);
    string t;
    if(s[p]=='('){
      p++;
      t = expr(p);
      p++;
    }else{
      t = chara(p);
    }
    REP(i,n){
      if(res.size() > needidx) break;
      res += t;
    }
  }
  return res;
}
string expr(int& p){
  string res = term(p);
  while(p < s.size() && s[p] != ')'){
    if(res.size() > needidx) break;
    res += term(p);
  }
  return res;
}

int main(){
  while(cin>>s>>needidx, s!="0"){
    int p = 0;
    string ans = expr(p);
    if(ans.size() > needidx){
      cout<<ans[needidx]<<endl;
    }else{
      cout<<0<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
import sys
n=int(input())
a=list(map(int,input().split()));b=list(map(int,input().split()))
if sum(a)<sum(b): print(-1),sys.exit()
x=sorted([a[i]-b[i] for i in range(n)],reverse=True)
s=-sum(d for d in x if d<0)
ans=sum(1 for d in x if d<0)
i=0
while s>0:
    s-=x[i]
    ans+=1
    i+=1
print(ans)

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);

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

    if((n%2)==1) {
        frep(i, 1, m) {
            cout << i << ' ' << n-i << endl;
        }
    }
    else {
        set<ll> s;
        ll a = 1, b = n, count = 0;
        while(count < m) {
            ll d1 = my_abs(a-b), d2 = my_abs(n+a-b);
            if(s.count(d1) || s.count(d2) || d1 == d2) {
                b--;
                d1 = my_abs(a-b);
                d2 = my_abs(n+a-b);
            }
            s.insert(d1);
            s.insert(d2);
            cout << a << ' ' << b << endl;
            a++; b--;
            count++;
        }
    }
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count))%MOD;
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}



Measured memory_bytes: 10028
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n, ans = 0;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0)ans += a[i];
		else ans -= a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
bool is_integer( double x ){
  return std::floor(x)==x;
}
int main(){
    int n,d;
    cin>>n>>d;
    int x[n][d];
    int ans=0;

    rep(i,n){
        rep(j,d)cin>>x[i][j];
    }
    rep(i,n){
        rep(j,n){
          double tmp=0;
            rep(k,d){
              //cout<<(x[i][k]-x[j][k])<<endl;
            tmp+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
          tmp = sqrt(tmp);
        //cout<<tmp<<endl;
        if(is_integer(tmp))ans++;
        }
      //cout<<tmp<<endl;
        

    }
    cout<<(ans-n)/2<<endl;
    

}

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

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


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    
    char palavra[7];
    scanf("%s", palavra);
    if(palavra[2] == palavra[3]){
        if(palavra[4] == palavra[5]){
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    } else {
        printf("No\n");
    }

    return 0;
}

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

int main()
{
   
  	ll n,k;
  	cin>>n>>k;
   	ll w[n+1],v[n+1];
   	w[0]=0;
   	v[0]=0;
   	for (int i = 1; i <=n; ++i)
   	{
   		cin>>w[i]>>v[i];
   	}

   	ll dp[n+1][k+1];

   	for (int i = 0; i <=n ; ++i)
   	{
   		for (int j = 0; j <=k ; ++j)
   		{
   			if(j==0||i==0)
   				dp[i][j]=0;
   			else if(j>=w[i])
   			{
   				dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
   			}
   			else
   			{
   				dp[i][j]=dp[i-1][j];
   			}
   		}
   	}
   	
   
   	cout<<dp[n][k];
}



Measured memory_bytes: 79104