akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
  int n,a[10001];
  int min=1000000,max=-1000000;
  long long int sum=0;
  int i;
  
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a[i];
    sum+=a[i];
    if(a[i]>max) max=a[i];
    if(a[i]<min) min=a[i];
  }
  cout << min <<" "<< max <<" "<<sum<<endl;
  return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
template <class T>
using VVV = V<V<V<T>>>;

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

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);

    string s, t;
    V<string> a;
    cin >> s >> t;
    rep(i, s.size() - t.size() + 1) {
        bool f = true;
        rep(j, t.size()) {
            if (s[i + j] != '?' && t[j] != '?' && s[i + j] != t[j]) {
                f = false;
                break;
            }
        }
        string S = s;
        if (f) {
            rep(j, t.size()) { S[i + j] = t[j]; }
            rep(j, S.size()) {
                if (S[j] == '?') S[j] = 'a';
            }
            a.push_back(S);
        }
    }
    if (a.size() == 0)
        cout << "UNRESTORABLE" << endl;
    else {
        sort(all(a));
        cout << a[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

long long MOD = 1000000007;

long long mod_pow(long long n, long long r, long long mod){
  long long ret = 1;
  while(r>0){
    if(r&1)
      ret = ret * n % mod;
    r = r>>1;
    n = n*n%mod;
  }
  return ret;
}


int main(){
  long long N;
  cin >> N;
  //

  long long ans = 0;

  ans += mod_pow(10, N, MOD);
  ans += mod_pow(8, N, MOD);

  ans %= MOD;
  
  ans -= 2*mod_pow(9, N, MOD);

  ans %= MOD;

  cout << (ans+MOD)%MOD << endl;
  
  
  return 0;
}


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


int main(){
  vector<int> a(3);
  rep(i,3) cin >> a.at(i);
  sort(a.begin(),a.end());
  cout << a.at(2)*10+a.at(1)+a.at(0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<ctime>
using namespace std;
const int N=505;
int a[N][N];
int n;
int range[N],missing[N],lost;
void make()
{
	srand(time(NULL));
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			a[i][j]=rand()%2;
		}
	}
}
int main()
{
	char c;
	int minimum;
	cin>>n;
	minimum=0;
	/*make();
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			if(a[i][j]==1){
				range[j]=1;	
			}
			else{
				missing[i]++;
			}
		}
	}*/
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			cin>>c;
			if(c=='#'){
				a[i][j]=1;
				range[j]=1;	
				minimum++;
			} 
			else{
				a[i][j]=0;
				missing[i]++;	
			} 
		}
	}
	if(minimum==0){
		cout<<-1<<endl;
		return 0;
	}
	minimum=n+1;
	for(int i=1;i<=n;++i){
		int temp=0;
		for(int j=1;j<=n;++j){
			if(a[j][i]==1) temp++;
		}
		if(temp<n) lost++;
	}
	for(int i=1;i<=n;++i){
		if(range[i]&&missing[i]<minimum){
			minimum=missing[i];
		}
		else if(range[i]==0&&missing[i]+1<minimum){
			minimum=missing[i]+1;
		}
	}
	cout<<lost+minimum<<endl;
	return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String strIn = scan.next();
		int intLoop = scan.nextInt();
		int intStart = 0;
		int intEnd = 0;
		String strReplace = "";
		String strTemp = "";
		for(int i = 0; i < intLoop; i++){
			String strOrder = scan.next();
			if("print".equals(strOrder)){
				intStart = scan.nextInt();
				intEnd = scan.nextInt();
				strTemp = "";
				for(int j = intStart; j <= intEnd; j++){
					strTemp += strIn.charAt(j);
				}
				System.out.println(strTemp);
			}else if("reverse".equals(strOrder)){
				intStart = scan.nextInt();
				intEnd = scan.nextInt();
				strTemp = "";
				String strReverse ="";
				for(int j = intStart; j <= intEnd; j++){
					strTemp += strIn.charAt(j);
				}
				StringBuffer sb = new StringBuffer(strTemp);
		        strTemp = sb.reverse().toString();
		        int k = 0;
				for(int j = 0; j < strIn.length(); j++){
					if(intStart <= j && j <= intEnd){
						strReverse += strTemp.charAt(k);
						k++;
					}else{
						strReverse += strIn.charAt(j);
					}
				}
				strIn = strReverse;
			}else if("replace".equals(strOrder)){
				intStart = scan.nextInt();
				intEnd = scan.nextInt();
				strReplace = scan.next();
				strTemp = "";
				boolean isInsert = true;
				for(int j = 0; j < strIn.length(); j++){
					if(intStart <= j && j <= intEnd){
						if(isInsert){
							strTemp += strReplace;
							isInsert = false;
						}
					}else{
						strTemp += strIn.charAt(j);
					}
				}
				strIn = strTemp;
			}
		}
		scan.close();
	}
}

Measured memory_bytes: 100628
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define MOD 1000000007
typedef long long ll;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define RER(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef pair<ll, ll> P;
ll dp[13][MAX_N], n, a[MAX_N], b[MAX_N];
string s;

signed main(){
	cin >> s;
	n = s.size();
	// cout << (char)s[0] << " " << n << endl;
	b[0] = 1;
	REP(i, MAX_N) b[i+1] = b[i] * 10 % 13;

	REP(i, n) a[i] = s[n-i-1] - '0';
	REP(i, 13) REP(j, n+1) dp[i][j] = 0;

	if(s[n-1] != '?') dp[a[0]][1] = 1;
	else REP(i, 10) dp[i][1] = 1;

	FOR(i, 1, n){
		if(s[n-i-1] != '?') REP(k, 13){			
			dp[(a[i] * b[i] + k) % 13][i+1] += dp[k][i];
			dp[(a[i] * b[i] + k) % 13][i+1] %= MOD;
		}
		else{
			REP(j, 10) REP(k, 13){
				dp[(j * b[i] + k) % 13][i+1] += dp[k][i];
				dp[(j * b[i] + k) % 13][i+1] %= MOD;
			}
		}
	}
	cout << dp[5][n] << endl;
    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
   ll n;cin >>n;
   ll even=0;
   ll four=0;
    for (int i = 0; i < n; ++i) {
        ll a;cin >>a;
        if(a%4==0)four++;
        else if(a%2==0)even++;
    }
    bool flg=false;
    if(four>=n/2)flg=true;
    if(four*2+even>=n){
        flg=true;
    }
    if(flg)puts("Yes");
    else puts("No");
    return 0;
}



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

int main(void){
    int n;
    vector<int> ps;
    cin >> n;
    int input;
    for(int i = 0; i < n; i++){
        cin >> input;
        ps.push_back(input);
    }

    int first, second, third;
    int ans = 0;
    for(int i = 0; i < n - 2; i++){
        first = i;
        second = i + 1;
        third = i + 2;

        if(ps[second] > ps[first] && ps[second] < ps[third]){
            ans++;
        }
        else if(ps[second] < ps[first] && ps[second] > ps[third]){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
a,b,c,d = map(int,input().split())
while(a > 0 and c > 0):
    c -= b
    if(c <= 0):
        flag = 1
        break
    a -= d
    if(a <= 0):
        flag = 2
        break

if(flag==1):
    print("Yes")
else:
    print("No")


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

int main() {
  int H,W;
  cin>>H>>W;
  vector<string> a(H);
  for(int i=0;i<H;i++){
    cin>>a.at(i);
  }
  for(int i=0;i<W+2;i++){
    cout<<"#";
  }
  cout<<endl;
  for(int i=0;i<H;i++){
    cout<<"#"<<a.at(i)<<"#"<<endl;
  }
    for(int i=0;i<W+2;i++){
    cout<<"#";
  }
  cout<<endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)
const int V_MAX = 20005;
typedef vector<int> Edges;
typedef vector<Edges> Graph;

int order[V_MAX];
bool visit[V_MAX];
int comp[V_MAX];
int order_tmp;

void dfs(Graph &G, int now){
    if(visit[now]) return;
    visit[now] = true;
    REP(i, G[now].size()){
        if(!visit[G[now][i]]) dfs(G, G[now][i]);
    }
    order[order_tmp] = now;
    order_tmp++;
}

void rdfs(Graph &G, int now, int k){
    if(comp[now]!=-1) return;
    comp[now] = k;
    REP(i, G[now].size()){
        if(comp[G[now][i]]==-1) rdfs(G, G[now][i], k);
    }
}

void SCC(Graph &G){
    int V = G.size();
    Graph G_inv(V);
    REP(i, V){
        REP(j, G[i].size()){
            G_inv[G[i][j]].push_back(i);
        }
    }
    order_tmp = 0;
    REP(i, V) visit[i] = false;
    REP(i, V) dfs(G, i);
    REP(i, V) comp[i] = -1;
    REP(i, V) rdfs(G_inv, order[V-1-i], order[V-1-i]);

}

int main(){
    int V, E;
    cin >> V >> E;
    Graph G(V);
    REP(i, E){
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
    }
    SCC(G);
    int Q;
    cin >> Q;
    REP(i, Q){
        int a, b;
        cin >> a >> b;
        cout << (comp[a]==comp[b]) << endl;
    }
    return 0;
}

Measured memory_bytes: 4460
import java.util.*;

import static java.lang.System.*;

// 2次元累積和
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int Q = sc.nextInt();

        int[][] sum = new int[N+1][N+1];
        for(int i = 0; i < M; i++){
            sum[sc.nextInt()][sc.nextInt()]++;
        }

        int[] p = new int[Q];
        int[] q = new int[Q];
        for(int i = 0; i < Q; i++){
            p[i] = sc.nextInt();
            q[i] = sc.nextInt();
        }

        for(int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++){
                sum[i][j] += sum[i-1][j];
                sum[i][j] += sum[i][j-1];
                sum[i][j] -= sum[i-1][j-1];
            }
        }

        for(int i = 0; i < Q; i++){
            out.println(sum[q[i]][q[i]] - sum[p[i]-1][q[i]] - sum[q[i]][p[i]-1] + sum[p[i]-1][p[i]-1]);
        }

    }
}


Measured memory_bytes: 163472
#include<bits/stdc++.h>
using namespace std;
int main(void){
    long long  A, B, K;
    cin >> A >> B >> K;
    if (A>=K){
        cout << A-K <<" "<< B  << endl;
    }
    else if (A+B > K){
        cout << 0 <<" "<< B-(K-A) << endl;
    }
    else{
        cout << 0 <<" "<< 0 << endl;
    }
}

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

int main() {

	int H, W;
	cin >> H >> W;
	vector<vector<char>> C(H, vector<char>(W));

	for (int i = 0; i < H; i++) {
		string tmp;
		cin >> tmp;
		for (int j = 0; j < W; j++) {
			C[i][j] = tmp[j];
		}
	}

	vector<vector<char>> res(2 * H, vector<char>(W));
	for (int i = 0; i < 2 * H; i++) {
		for (int j = 0; j < W; j++) {
			int tmp = i / 2;
			res[i][j] = C[tmp][j];
		}
	}

	for (int i = 0; i < 2 * H; i++) {
		for (int j = 0; j < W; j++) {
			cout << res[i][j] << flush;;
		}
		cout << endl;
	}

	return 0;
}

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

using ll = long long;
static const ll MOD = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int h, w;
  cin >> h >> w;
  
  vector<vector<char>> a(h, vector<char>(w));
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> a.at(i).at(j);
    }
  }
  
  vector<vector<ll>> x(h + 2, vector<ll>(w + 2, 0));
  x.at(1).at(1) = 1;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(i == 0 && j == 0) continue;
      if(a.at(i).at(j) == '.') x.at(i + 1).at(j + 1) = x.at(i).at(j + 1) + x.at(i + 1).at(j);
      x.at(i + 1).at(j + 1) %= MOD;
    }
  }
  
  cout << x.at(h).at(w) << '\n';
}

Measured memory_bytes: 9216
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) (a>0?a:(-(a)))
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	printf("%lld",1ll*n*n*n);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n,m,edge[20][20];
long long ans=0,sum[1<<16],dp[1<<16][20];
int main(){
	scanf("%d %d",&n,&m);
	for(int i=1,u,v,w;i<=m;i++){
		scanf("%d %d %d",&u,&v,&w);
		edge[u][v]=edge[v][u]=w;
		ans+=w;
	}
	int tmp=(1<<n);
	for(int S=0;S<tmp;S++){
		for(int i=1;i<=n;i++){
			dp[S][i]=-1;
			if(!(S&(1<<(i-1)))&&!sum[S|(1<<(i-1))]){
				sum[S|(1<<(i-1))]=sum[S];
				for(int j=1;j<=n;j++){
					if(S&(1<<(j-1))) sum[S|(1<<(i-1))]+=edge[i][j];
				}
			}
		}
	}
	dp[1][1]=0;
	for(int S=0;S<tmp;S++){
		for(int i=1;i<=n;i++){
			if(dp[S][i]<0) continue;
			if(S&(1<<(i-1))){
				for(int j=1;j<=n;j++){
					if(!(S&(1<<(j-1)))&&edge[i][j]){
						dp[S|(1<<(j-1))][j]=max(dp[S][i]+edge[i][j],dp[S|(1<<(j-1))][j]);
					}
				}
				int now=((tmp-1)^S)|(1<<(i-1));
				for(int M=now;M;M=(M-1)&now){
					if(M&(1<<(i-1))) dp[S|M][i]=max(dp[S][i]+sum[M],dp[S|M][i]);
				}
			}
		}
	}
	printf("%lld\n",ans-dp[tmp-1][n]);
}

Measured memory_bytes: 6656
#include "bits/stdc++.h"
using namespace std;
const int maxN=1e5+10;
const long long MOD=1e9+7;
int n;
long long k;
long long ans[maxN];
long long res=0LL;
long long fast_mi(long long a,int p)
{
	if(p==0)
	{
		return 1LL;
	}
	long long tmp=fast_mi(a,p>>1);
	tmp=tmp*tmp%MOD;
	if(p&1)
	{
		tmp=tmp*a%MOD;
	}
	return tmp;
}
int main()
{
	cin>>n>>k;
	for(long long x=k;x>=1LL;x--)
	{
		long long multi_num=k/x;
		long long num=fast_mi(multi_num,n);
		for(int i=x+x;i<=k;i+=x)
		{
			num=(num-ans[i]+MOD)%MOD;
		}
		ans[x]=num;
		res=(res+num*x)%MOD;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 4344
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var d = new Dictionary<long, long>();
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, long.Parse);
        var w = 0L; d[w] = 1;
        for (int i = 0; i < n; i++)
        {
            w = a[i] + w;
            if (d.ContainsKey(w)) d[w]++;
            else d[w] = 1;
        }
        Console.WriteLine(getAns(d));
    }
    public static long getAns(Dictionary<long, long> d)
    {
        var ret = 0L;
        foreach (var x in d)
            if (x.Value >= 2 && x.Value % 2 == 0) ret += (x.Value / 2) * (x.Value - 1);
            else if (x.Value >= 2 && x.Value % 2 != 0) ret += ((x.Value - 1) / 2) * x.Value;
        return ret;
    }
}

Measured memory_bytes: 42596
//============================================================================
// Name        : ATcoder.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>
using namespace std;

int main() {

	int n,a,b;
	int e,f;


	cin>>n>>a>>b;

	e=n*a;
	f=b;

	if(e<f){
		cout<<e<<endl;
	}else{
		cout<<f<<endl;
	}




}




Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

#define mod 1000000007

class RMQ
{
    private:
        long long int elemnum;
        vector<long long int> result;

    public:
        RMQ(long long int n){
            elemnum = n;
            vector<long long int> tmp(2 * n, (long long int)pow(2, 31) - 1);
            result = tmp;
        }

        void addelem(long long int x, long long int value)
        {
            result[x + elemnum] = value;
            int tmp = (x + elemnum) / 2;
            while(tmp > 0){
                result[tmp] = min(result[tmp * 2], result[tmp * 2 + 1]);
                tmp = tmp / 2;
            }
        }

        long long int getminval(long long int targetl, long long int targetr, long long int nownum, long long int nowl, long long int nowr)
        {
            // cout << nowl << " " << nowr << endl;
            if(min(targetr, nowr) < max(targetl, nowl)) return (long long int)pow(2, 31) - 1;
            else if(targetl <= nowl && targetr >= nowr) return result[nownum];
            else {
                long long int tmp1 = getminval(targetl, targetr, 2 * nownum, nowl, (nowl + nowr) / 2);
                long long int tmp2 = getminval(targetl, targetr, 2 * nownum + 1, (nowl + nowr) / 2 + 1, nowr);
                return min(tmp1, tmp2);
            }
        }

        void printresult()
        {
            for(int i = 1; i < 2 * elemnum; i++){
                cout << result[i] << " ";
            }
            cout << endl;
        }

        int getelemnum()
        {
            return elemnum;
        }
};

int main()
{
    int n, q;
    cin >> n >> q;
    int tmp = 1;
    while(tmp < n) tmp = tmp * 2;
    RMQ ans = RMQ(tmp);
    for(int i = 0; i < q; i++){
        long long int com, x, y;
        cin >> com >> x >> y;
        if(com == 0){
            ans.addelem(x, y);
        } else {
            cout << ans.getminval(x, y, 1, 0, ans.getelemnum() - 1) << endl;
        }
        // ans.printresult();
    }
}

Measured memory_bytes: 7040
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

typedef double P_type; //座標(integer or real)
typedef double G_real; //実数の戻り値(float or double or long double)
typedef complex<P_type> P;
const G_real P_eps = 1e-8; //整数の時はゼロ

namespace std{
  template<class T> bool operator<(const complex<T> &a, const complex<T> &b){
    return abs(a.real() - b.real()) < P_eps ? a.imag() + P_eps < b.imag() : a.real() + P_eps < b.real();
  }
};

int main(){
  int n, k;
  vector<P> vec;
  
  scanf("%d%d", &n, &k);

  for(int i=0;i<n;i++){
    int x, y;
    scanf("%d%d", &x, &y);
    vec.push_back(P(x, y));
  }

  int ans = 0;
  
  for(int i=0;i<n;i++){
    map<P, int> dic;
    for(int j=0;j<n;j++){
      if(i == j) continue;

      P r = (vec[i] - vec[j]) / abs(vec[i] - vec[j]);

      if(r.real() < 0) r *= -1;
      if(abs(r.real()) < P_eps && r.imag() < 0) r *= -1;
      dic[r]++;
    }

    for(auto it : dic){
      ans = max(ans, it.second);
    }
  }

  printf("%d\n", ans >= k-1);
  
  return 0;
}



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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s, t; cin >> s >> t;
    int id_s[26], id_t[26];
    for(int i=0;i<26;i++){
        id_s[i] = -1;
        id_t[i] = -1;
    }
    bool ans = true;
    for(int i=0;i<s.size();i++){
        if(id_s[s[i] - 'a'] != -1){
            if(id_s[s[i] - 'a'] != id_t[t[i] - 'a']){
                ans = false;
                break;
            }
        }
        id_s[s[i] - 'a'] = i;
        id_t[t[i] - 'a'] = i;
    }
    for(int i=0;i<26;i++){
        id_s[i] = -1;
        id_t[i] = -1;
    }
    for(int i=0;i<s.size();i++){
        if(id_t[t[i] - 'a'] != -1){
            if(id_s[s[i] - 'a'] != id_t[t[i] - 'a']){
                ans = false;
                break;
            }
        }
        id_s[s[i] - 'a'] = i;
        id_t[t[i] - 'a'] = i;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 916
K = int(input())
s = [
    1,
    1,
    1,
    2,
    1,
    2,
    1,
    5,
    2,
    2,
    1,
    5,
    1,
    2,
    1,
    14,
    1,
    5,
    1,
    5,
    2,
    2,
    1,
    15,
    2,
    2,
    5,
    4,
    1,
    4,
    1,
    51,
]

print(s[K - 1])



Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==1){
		if(b==1){
			printf("Open\n");
		}
		else{
			printf("Close\n");
		}
	}
	else{
		if(b==0){
			if(c==0){
				printf("Close\n");
			}
			else{
				printf("Open\n");
			}
		}
		else{
			printf("Close\n");
		}
	}
	return 0;
}
	
		


Measured memory_bytes: 2700
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{
	string str;
	cin >> str;
	vector<int> v;
	for(int i = 0; i < str.size(); i++){
		if(str[i]=='0')v.push_back(0);
		else if(str[i]=='1')v.push_back(1);
		else if(v.size() > 0)v.pop_back();
	}
	
	for(int i = 0; i < v.size(); i++){
		cout << v[i];
	}
	cout << endl;
	return 0;
}


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

using namespace std;

int main(){
    int n, k;
    cin >> n;
    string s;
    for(int i=0; i<n; ++i){
        static char a;
        cin >> a;
        s.push_back(a);
    }
    cin >> k;
    char sp = s.at(k-1);
    string output;
    for(int i=0; i<n; ++i){
        if(s.at(i)==sp) output.push_back(sp);
        else output.push_back('*');
    }
    cout << output << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int kam1 = a / d;
    if(a % d) kam1++;
    int kam2 = c / b;
    if(c % b) kam2++;
    if(kam2 <= kam1) cout << "Yes";
    else cout << "No";


    return 0;
}


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

int main() {
    int n=0, k=0;
    scanf("%d %d\n", &n, &k);
    char s = 0;
    for (int i=0; i<n; i++) {
        s = getchar();
        if (i != k-1) {
            putchar(s);
        }
        else {
            s = s - 'A' + 'a';
            putchar(s);
        }
    }
    putchar('\n'); 
    return 0;
}


Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
b=0
for _ in a:
    for i in range(n-1,0,-1):
        if a[i]<a[i-1]:
            a[i],a[i-1]=a[i-1],a[i]
            b+=1
print(*a)
print(b)


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

  
// Driver code 
int main() 
{ 
    int n;
    cin>>n;
    vector<int> arr(n), sum(n), diff(n);
    map<int, int> ct;
    for(int i = 0; i < n; i++)
        {cin>>arr[i];}
    for(int i = 0; i < n; i++)
    {
        sum[i]=i+arr[i];
    }
    for(int j = 0; j < n; j++)
    {
        diff[j] = j - arr[j];
        ct[diff[j]]++;
    }
    sort(diff.begin(), diff.end());
    sort(sum.begin(), sum.end());
    long long ans = 0;
    for(int i = 0; i < n; i++)
    {
        if(binary_search(diff.begin(), diff.end(), sum[i]))
        {
            ans+=ct[sum[i]];
        }
    }
    cout<<ans<<endl;
    // int arr[] = { 1, 5, 6, 7, 9 }; 
    // int n = sizeof(arr) / sizeof(arr[0]); 
  
    // cout << countPairs(arr, n); 
  
    return 0; 
} 

Measured memory_bytes: 14276
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

ll gcd(ll x, ll y)
{
    while (y > 0)
    {
        ll tmp = y;
        y = x % y;
        x = tmp;
    }
    return x;
}

ll lcm(ll x, ll y)
{
    return x / gcd(x, y) * y;
}

// 素因数分解O(sqrt(n))
map<ll, ll> prime_factor(ll n) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

int main(int argc, char const *argv[])
{
    ll i;
    cin >> i;
    cout << (i ? 0 : 1) << endl;
}

Measured memory_bytes: 3624
s = input()
ans = 0
for i in range(len(s)):
    s = s[0:len(s) - 1]
    if(len(s) % 2 != 0):
        continue
    if(s[0:len(s)//2] == s[len(s)//2:]):
        ans = len(s)
        break
print(ans)

Measured memory_bytes: 3060
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N;
int main() {
	cin>>N;


	int ans=0;
	for(int i=1;i<N+1;i++){
		ans+=i;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
def main():
    n,m=map(int,input().split())
    a=set(int(input()) for _ in range(m))
    pattern = [0] * (n+1)
    pattern[0] = 1
    for i in range(n-1):
        if i in a:
            continue
        if i+1 not in a:
            pattern[i+1] += pattern[i]
            pattern[i+1] %= 1000000007
        if i+2 not in a:
            pattern[i+2] += pattern[i]
            pattern[i+2] %= 1000000007
    pattern[n] += pattern[n-1]
    pattern[n] %= 1000000007
    print(pattern[n])
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 17228
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	int X; cin >> X;
	int a = X / 500;
	X %= 500;
	int b = X / 5;
	cout << 1000 * a + 5 * b << "\n";
	
	return 0;
}

Measured memory_bytes: 256
/*
        Author: Prokash
                CSE,JU
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,d,i,j,k;
    cin>>n>>d;
    int ara[n][d];
    for(i=0;i<n;i++)
    {
        for(j=0;j<d;j++)
        {
            cin>>ara[i][j];
        }
    }
    double sum=0.0;
    int cnt=0;
    for(i=0;i+1<n;i++)
    {
        k=i+1;
        while(k<n){
        for(j=0;j<d;j++)
        {
            sum+=((ara[i][j]-ara[k][j])*(ara[i][j]-ara[k][j]));
        }
        sum=sqrt(sum*1.0);
        int x=sum;
        if(sum==x)
        {
            cnt++;
        }
        sum=0.0;
        k++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            // 整数配列の入力
            var inputArray = Console.ReadLine();
            int cnt = 0;
            for(int i=0; i< 3; ++i) {
                if(int.Parse(inputArray.Substring(i,1)) == 1) {
                    ++cnt;
                }
            }

            Console.WriteLine(cnt);
            return;
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define int long long
const double PI=3.141592653589793238;
double calc(int res,int ans){
  return abs(((double)res/ans)-PI);
}
signed main(){
  double d;
  while(cin>>d,d!=0){
    //cout<<d<<endl;
    int ans=1,res=0;
    while(1){
      res=floor(ans*(PI-d))-1;
      //cout<<res<<" " <<ans<<":"<<calc(res,ans)<<endl;
      while(calc(res,ans)>calc(res+1,ans)) res++;
      if(calc(res,ans)<d) break;
      ans++;
    }
    cout<<res<<"/"<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3228
h,w,k=map(int,input().split());p=[sum(('11'in str(bin(j)))^1for j in range(1<<i))for i in range(8)];d=[w*[0]for _ in[0]*-~h];d[0][0]=1
for i in range(h):
 b=d[i]
 for j in range(w):
  t=u=D=0
  if j:t=p[max(0,j-2)]*p[max(0,w-j-2)];D=b[j-1]*t
  if j<w-1:u=p[max(0,j-1)]*p[max(0,w-j-3)];D+=b[j+1]*u
  d[i+1][j]=(b[j]*(p[w-1]-t-u)+D)%(10**9+7)
print(d[-1][k-1])

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] array=new int[n];
		int min=99999,sum=0;

		for(int i=0;i<n;i++) {
			array[i]=sc.nextInt();
		}
		for(int i=1;i<n-1;i++) {
			if(array[i]>array[i-1]&&array[i]<array[i+1])sum++;
			else if(array[i]<array[i-1]&&array[i]>array[i+1])sum++;
		}

		System.out.println(sum);


	}
}
/*
 6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40
 */

//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));




Measured memory_bytes: 21844
import sys
import fractions
input = sys.stdin.readline

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
    A, B = map(int, input().split())

    ap = prime_factorize(A)
    bp = prime_factorize(B)

    primes = [1] + list(set(ap) & set(bp))

    print(len(primes))


if __name__ == "__main__":
    main()


Measured memory_bytes: 5052
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String S = scan.nextLine();
      
      	int v = 700;
      	for(int i = 0; i < S.length(); i++){
        if(S.charAt(i) == 'o'){
        	v += 100;
        }
      }
      
      System.out.println(v);
    }
}


Measured memory_bytes: 35816
#include <iostream>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    string s, t;
    getline(cin, s);
    getline(cin, t);
    map<char, char> s2t, t2s;
    for(int i = 0; i < s.size(); ++i){
        char cs = s.at(i);
        char ct = t.at(i);
        if((s2t.count(cs) && s2t.at(cs) != ct) ||
           (t2s.count(ct) && t2s.at(ct) != cs)){
            cout << "No" << endl;
            return 0;
        }
        s2t[cs] = ct;
        t2s[ct] = cs;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1020
def gcd(a,b):
    while b != 0:
        a, b = b, a % b
    return a

N, K = map(int, input().split())
A =sorted(list(map(int, input().split())))
ans = ''
a = A[0]
for b in range(1, N):
    a = gcd(a, A[b])
if A[N-1] < K:
    ans = 'IMPOSSIBLE'
elif a == 1:
    ans = 'POSSIBLE'
else:
    for n in reversed(A):
        if (n - K) % a == 0:
            ans = 'POSSIBLE'
            break
        else:
            if n < K:
                break
if  ans == '':
    ans = 'IMPOSSIBLE'
print(ans)


Measured memory_bytes: 14108
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = long.Parse(ReadLine());
			var sqrtN = Sqrt(n);
			var factors = new Dictionary<long, long>();

			if (n == 1)
			{
				WriteLine(0);
				return;
			}

			for (long i = 2; i <= sqrtN + 2; i += 2)
			{
				while (n % i == 0)
				{
					if (!factors.ContainsKey(i))
					{
						factors.Add(i, 0);
					}
					factors[i]++;
					n /= i;

					if (n == 1)
					{
						break;
					}
				}
				if (n == 1)
				{
					break;
				}
				if (i == 2)
				{
					i--;
				}
			}

			if(n != 1)
			{
				factors.Add(n, 1);
			}

			if (!factors.Any())
			{
				WriteLine(1);
				return;
			}

			long count = 0;
			foreach (var value in factors.Values)
			{
				var tmp = value;
				long i = 1;
				while (tmp > 0)
				{
					if (tmp - i > i || tmp - i == 0)
					{
						tmp -= i;
						count++;
					}
					i++;
				}
			}

			WriteLine(count);
		}
	}
}


Measured memory_bytes: 18788
#include <cstdio>
#include <map>
#include <algorithm>
 
using namespace std;
 
long long a, b, c, d;
map<long long, long long> mp;
 
long long calc(long long n) {
    int i;
    long long ans = 1e18;
    
    if (mp.count(n)) return mp[n];
    if (n == 0) return mp[n] = 0;
    
    for (i = -1; i <= 1; i++) {
        if (n + i > 0 && (n + i) % 2 == 0 && (n + i) / 2 < n) ans = min(ans, calc((n + i) / 2) + a + abs(i) * d);
    }
    
    for (i = -2; i <= 2; i++) {
        if (n + i > 0 && (n + i) % 3 == 0 && (n + i) / 3 < n) ans = min(ans, calc((n + i) / 3) + b + abs(i) * d);
    }
    
    for (i = -4; i <= 4; i++) {
        if (n + i > 0 && (n + i) % 5 == 0 && (n + i) / 5 < n) ans = min(ans, calc((n + i) / 5) + c + abs(i) * d);
    }
    
    if (n <= ans / d) ans = min(ans, n * d);
    
    return mp[n] = ans;
}
 
int main() {
    int t, i;
    
    scanf("%d", &t);
    
    for (i = 0; i < t; i++) {
        long long n;
        
        scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &c, &d);
        
        mp.clear();
        
        printf("%lld\n", calc(n));
    }
    
    return 0;
}

Measured memory_bytes: 4120
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

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

#include <functional>
template<typename T>
class SegmentTreeAllOne {
    using Func = function<T(T, T)>;

public:
    vector<T> data;
    int n;
    T init;
    Func update_func;
    SegmentTreeAllOne(int _n, T _init, Func up) {
        init = _init;
        update_func = up;
        for (n = 1; n < _n; n *= 2)
            ;
        data.resize(2 * n - 1, init);
    }
    void update(int l, int r, T val) {
        for (l += n - 1, r += n - 1; l < r; l = l / 2, r = (r - 1) / 2) {
            if (!(l & 1)) {
                data[l] = update_func(data[l], val);
            }
            if (!(r & 1)) {
                data[r - 1] = update_func(data[r - 1], val);
            }
        }
    }
    T query(int pos) {
        pos += n - 1;
        T res = data[pos];
        while (pos > 0) {
            pos = (pos - 1) / 2;
            res = update_func(res, data[pos]);
        }
        return res;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    auto SUM = [](ll a, ll b) { return a + b; };
    int n, q;
    cin >> n >> q;
    SegmentTreeAllOne<ll> segtree(n, 0, SUM);
    REP(i, 0, q) {
        int com;
        cin >> com;
        if (com) {
            int x;
            cin >> x;
            cout << segtree.query(x - 1) << endl;
        } else {
            int s, t, x;
            cin >> s >> t >> x;
            segtree.update(s - 1, t, x);
        }
    }

    return 0;
}



Measured memory_bytes: 4876
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M, 0);
    for(int i=0; i<M; i++) cin >> B[i];

    int cnt=0;
    for(int i=0; i<N; i++){
        int ans=C;
        vector<int> A(M, 0);
        for(int j=0; j<M; j++){
            cin >> A[j];
            ans += A[j]*B[j];
        } 
        if(ans > 0) cnt++;
    }

    cout << cnt << endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	long long a,b,x;
	long long cnt=0;
	scanf("%lld %lld %lld",&a,&b,&x);
	if(a==0)
	{
		cnt=(b/x)+1;
		printf("%lld",cnt);
	}
else
{

	cnt=(b/x)-((a-1)/x);
	
	printf("%lld",cnt);}
	
	
}

Measured memory_bytes: 256
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

dp = [0]*(w+1)

for i in range(n):
    for j in range(w, wv[i][0]-1, -1):
        dp[j] = max(dp[j], dp[j-wv[i][0]]+wv[i][1])

print(max(dp))

Measured memory_bytes: 41708
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll              long long
#define l1(i, n)        for (ll i = 1; i <= n; i++)
#define l0(i, n)        for (ll i = 0; i < n; i++)
#define lo(i, s, n)     for (ll i = s; i <= n; i++)
#define sca(n)          scanf("%lld", &n)
#define pri(n)          printf("%lld", n)
#define pb              push_back
#define mp              make_pair
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define all(x)          x.begin(), x.end()
#define ms(a, b)        memset(a, b, sizeof(a));
#define cases(tc)       cout<<"Case "<<tc<<": "
#define nl              cout<<"\n";
#define pnl             printf("\n");
#define pi              acos(-1)
#define mod             1000000007
#define inf             999999999999999999
			
 


 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    */

    ll t;
    t=1;
    while(t--){
        ll n, k;
        cin>>n>>k;
        ll p[n+1];
        ll c[n+1];
        l1(i, n) cin>>p[i];
        l1(i, n) cin>>c[i];
        ll ans=-inf;
        l1(i, n){
            ll mov=0;
            ll pos=i;
            ll score=0;
            ll sum=-inf;
            ll mx=-inf;
            while(1){
                pos=p[pos];
                score+=c[pos];
                mov++;
                if(pos==i)
                break;
            }
            ll sum2=0;
            if(score>0 && mov<k){
                if(k%mov==0){
                sum=score*(k/mov-1);
                ll rem=mov;
                pos=i; 
                for(ll j=1; j<=rem; j++){
                    pos=p[pos];
                    sum2+=c[pos];
                    mx=max(mx, sum2);
                }
                sum+=mx;
                }
                else{
                sum=score*(k/mov);
                ll rem=k%mov;
                pos=i; 
                for(ll j=1; j<=rem; j++){
                    pos=p[pos];
                    sum2+=c[pos];
                    mx=max(mx, sum2);
                }
                sum+=mx;
                }
            }
            else{
                pos=i;
                for(ll j=1; j<=min(mov, k); j++){
                    pos=p[pos];
                    sum2+=c[pos];
                    sum=max(sum, sum2);
                }
            }
            ans=max(ans, sum);
        }
        cout<<ans;
        nl
    }
    return 0;
}


Measured memory_bytes: 3688
#include <stdio.h>
int main(void){
	long a,b,ans;
	scanf("%ld%ld",&a,&b);
	if((a==1)||(b==1)) ans=1;
	else if((a%2==1)&&(b%2==1)) ans=a*b/2+1;
	else ans=a*b/2;
	printf("%ld",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tuple<ll,ll,ll> tll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n),b(n);
  rep(i,n) cin>>a[i]>>b[i];
  sort(all(a));
  sort(all(b));
  if(n%2){
    COUT(b[n/2]-a[n/2]+1);
  }
  else{
    double ans=0;
    ans+=(b[n/2]+b[n/2-1])/2.0-(a[n/2]+a[n/2-1])/2.0;
    ans*=2;
    COUT((ll)(ans)+1);
  }
}

Measured memory_bytes: 6324
h,w = map(int,input().split())
a = [""]*h
for i in range(h):
    a[i] = input()
row = [0]*h
col = [0]*w
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            row[i] = 1
            col[j] = 1
for i in range(h):
    if row[i] == 1:
        for j in range(w):
            if col[j] == 1:
                print(a[i][j], end="")
        print()

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

int h[N];
pair<int, int> a[N];

void solve() {
  int n, m; scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &a[i].second, &a[i].first);
    ++h[a[i].second];
  }
  for (int i = 1; i <= n; ++i) {
    h[i] += h[i-1];
  }
  sort(a, a+m);
  int prev = 0, ans = 0;
  for (int i = 0; i < m; ++i) {
    if (h[a[i].first-1] == h[prev]) continue;
    if (a[i].second <= prev) continue;
    ++ans;
    prev = a[i].first-1;
  }
  printf("%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4996
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N;
  cin>>N;
  VEC<LL>D(N);
  LL sum = 0;
  REP(i,0,N)cin>>D[i];
  REP(i,0,N){
    REP(j,i+1,N){
      sum+=D[i]*D[j];
    }
  }
  cout<<sum<<endl;

  return 0;
}


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

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final int k = scanner.nextInt();

        final int[] array = new int[n + 1];
        for (int i = 0; i < k; i++) {
            final int d = scanner.nextInt();
            for (int j = 0; j < d; j++) {
                array[scanner.nextInt()]++;
            }
        }

        final long answer = Arrays.stream(array, 1, n + 1)
                .filter(i -> i == 0)
                .count();
        System.out.println(answer);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

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

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

Measured memory_bytes: 34856
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
#define PI 3.1415926
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

signed main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, k, h[100000];
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	sort(h, h+n);
	int min = 2000000000;
	for (int i = 0; i < n-k+1; i++) {
		if(min > abs(h[i]-h[i+k-1])){
			min = abs(h[i]-h[i+k-1]);
		}
	}
	cout << min << endl;

	return 0;
}

Measured memory_bytes: 640