akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N;
  cin >> N;
  vector<int> a(3 * N);
  rep(i, 3 * N) {
    cin >> a[i];
  }

  sort(all(a), greater<int>());
  int ans = 0;
  rep(i, N) {
    ans += a[i * 2 + 1];
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int solve_testcase() {
  int N, M, K; cin >> N >> M >> K;
  if(N == 0 and M == 0 and K == 0) return 1;

  vector< vector<double> > dp(N+1, vector<double>(N*M + 1));
  dp[0][0] = 1.0;
  for(int i=0; i<N; i++) {
    for(int j=0; j<=i*M; j++) {
      for(int k=1; k<=M; k++) {
        dp[i+1][j+k] += dp[i][j] / M;
      }
    }
  }

  double ans = 0.0;
  for(int i=0; i<=N*M; i++) {
    int val = max(1, i - K);
    ans += val * dp[N][i];
  }
  printf("%.12f\n", ans);
  return 0;
}

int main() {
  while(!solve_testcase());
  return 0;
}



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

namespace AtCoder
{
    class Abc164D
    {
        public static void Main()
        {
            var s = Console.ReadLine().Select(i => i - '0').ToArray();
            var n = s.Length;

            var r = new long[n + 1];

            long d = 1;
            var count = new long[2019];

            for (int i = 1; i <= n; i++)
            {
                r[i] = (d * s[n - i] + r[i - 1]) % 2019;
                count[r[i]]++;
                d = d * 10 % 2019;
            }

            var ans = count[0];
            for (int i = 0; i < 2019; i++)
                ans += count[i] * (count[i] - 1) / 2;

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 21928
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

int main() {
	IOS();
	ll a, b;
	cin >> a >> b;
	if (a < 6)
		dump(0);
	else if (a < 13)
		dump(b / 2);
	else
		dump(b);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

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

ll comb(ll n, ll k) {
    if(k==0) return 1;
    else if(n==k) return 1;
    else return comb(n-1, k)+comb(n-1, k-1);
}

ll f(ll n) {
    if(n==0) return 1;
    else return f(n-1)*n%MOD;
}

int main(void) {
    ll N , M;
    cin >> N >> M;
    ll n=max(N, M), m=min(N, M);
    if(n-m>=2) {
        cout << 0 << endl;
    }else if(n-m==1)
        cout << f(n)*f(m)%MOD;
    else
        cout << f(n)*f(m)*2%MOD;
}


Measured memory_bytes: 1792
n = int(input())
t_list = input().split()
t_list = [int(t) for t in t_list]
v_list = input().split()
v_list = [int(v) for v in v_list]


down_list = []
v_list.append(0)
for i in range(n):
    down = []
    down.append(sum(t_list[:i+1]))
    down.append(min(v_list[i],v_list[i+1]))
    down_list.append(down)
    
now_v = 0
distance = 0
kukan = 0
down_check = 0
now_s = 0
last_time = down_list[-1][0]
while now_s < last_time:
    for down in down_list[kukan:]:
        if down[1]+(down[0]-now_s)*1==now_v:
            next_s = down_list[kukan][0]
            next_v = now_v +(-1*(next_s-now_s))
#             print("4",next_s,next_v,now_s,now_v)
            distance += (next_v +now_v) * (next_s-now_s) /2
#             print("1",now_s,now_v,distance)
            now_v = next_v
            now_s = next_s
            kukan += 1
            down_check = 1
            break
    if down_check == 1:
        down_check = 0
        continue
    else:
        if now_v == v_list[kukan]:
            distance += now_v * 0.5
#             print("2",now_s,now_v,distance)
        else:
            next_v = now_v + 0.5
            distance += (next_v + now_v) * 0.5 /2
#             print("3",now_s,now_v,distance)
            now_v = next_v

        now_s += 0.5
        if kukan < len(down_list):
            if now_s == down_list[kukan][0]:
                kukan += 1
#                 print("kukan",kukan)

print(distance)

Measured memory_bytes: 3188
################ B
s = input()
t = input()

co = 0
num = 0
N = 0
N_max = 0
for i in range(len(s)-len(t)+1):
    for k in range(len(t)):
        if s[i+k] == t[k]:
            N += 1
    N_max = max(N,N_max)
    N = 0
print(len(t)-N_max)

Measured memory_bytes: 9004
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, K;
	cin >> N >> K;

	vector<vector<Int>> G(4*K, vector<Int>(4*K));//0～2K-1までのグリッド
	Int x, y;
	char c;
	for (Int i = 0; i < N; i++) {
		cin >> x >> y >> c;
		if (c=='W') {
			y += K;
		}
		x %= 2 * K;
		y %= 2 * K;
		G[x][y]++;

		//チェッカーにおける五カ所の累積和を求める代わりに以下の点もインクリメント
		//左上、左下、右下の点を全て右上に移動

		//http://tsutaj.hatenablog.com/entry/2018/03/09/225829   ←←五カ所の累積和を求めてもいいけど、場合分けがしんどそう
		G[x + 2 * K][y]++;
		G[x][y + 2 * K]++;
		G[x+2*K][y + 2 * K]++;
	}

	//二次元累積和
	vector<vector<Int>> S(4*K+1, vector<Int>(4*K+1));
	for (Int i = 0; i < 4*K; i++) {
		for (Int j = 0; j < 4*K; j++) {
			S[i + 1][j + 1] = S[i][j + 1] + S[i + 1][j] - S[i][j] + G[i][j];
		}
	}

	Int ans = -INF;
	Int temp;
	for (Int i = 0; i <= 2*K; i++) {//正方形の左下の座標
		for (Int j = 0; j <= 2*K; j++) {
			temp = S[i + K][j + K] - S[i][j + K] - S[i + K][j] + S[i][j];
			temp += S[i + 2 * K][j + 2 * K] - S[i + K][j + 2 * K] - S[i + 2 * K][j + K] + S[i + K][j + K];
			ans = max(ans, temp);
		}
	}

	cout << ans << "\n";

}


Measured memory_bytes: 250624
#include <iostream>
#include <complex>

using namespace std;

bool isPrimeNumber(int n)
{
  if (n == 2)
    return true;

  if (n < 2 || n % 2 == 0)
    return false;

  int i = 3;
  while (i <= sqrt(n))
    if (n % i == 0)
      return false;
    else
      i += 2;

  return true;
}

int main()
{
  int n, count = 0, tmp;
  cin >> n;

  for (int i = 0; i < n; i++)
  {
    cin >> tmp;
    if (isPrimeNumber(tmp))
      count++;
  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3080
N, K, S = gets.split.map(&:to_i)
MAX_S = 10 ** 9

ans = []

K.times do
  ans << S
end

if S < MAX_S
  (N - K).times do
    ans << S + 1
  end
else
  (N - K).times do
    ans << 1
  end
end

puts ans.join(' ')


Measured memory_bytes: 4732
#include <iostream>
#include <stdio.h>
#include <stack>
#include <vector>

using namespace std;
const int nil = -1;

int total, n, m, q;

vector<int>* vecs;
typedef int Comm;
Comm* comms;

void find_connection(int from){
	stack<int> stk;
	stk.push(from);

	while(stk.size()){
		int top = stk.top();
		comms[top] = from;
		for(int i=0, sz=vecs[top].size(); i<=sz; ++i){
			if(i==sz){
				stk.pop();
				break;
			}
			if(comms[vecs[top][i]] == nil){
				stk.push(vecs[top][i]);
				break;
			}
		}
	}
}

int main()
{
	scanf("%d %d",&n,&m);
	vecs = new vector<int> [n];
	comms = new Comm [n];

	for(int i=0; i<n; ++i){
		comms[i] = nil;
	}

	for(int i=0; i<m; ++i){
		int id, f;
		scanf("%d %d",&id,&f);
		vecs[id].push_back(f);
		vecs[f].push_back(id);
	}

	scanf("%d",&q);
	for(int i=0; i<q;++i){
		int from, to;
		scanf("%d %d",&from,&to);
		if(comms[from]==nil && comms[to]==nil){
			find_connection(from);
			if(comms[from] == comms[to]){
				cout << "yes" << endl;
			}
			else{
				cout << "no" << endl;
			}
		}
		else if(comms[from] == comms[to]){
			cout << "yes" << endl;
		}
		else{
			cout << "no" << endl;
		}
	}

	delete[] comms;
	delete[] vecs;

	return 0;
}


Measured memory_bytes: 8980
//Resting_Prince
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define mod 1000000009
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define all(v) v.begin(),v.end()
#define rep(i,a,b)    for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

int main()
{
    char a;
    cin>>a;
    switch(a)
    {
        case 'A':cout<<'T';
        break;
        case 'T':cout<<'A';
        break;
        case 'G':cout<<"C";
        break;
        case 'C':cout<<"G";
    }
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int N, M, Q; cin >> N >> M >> Q;
  int A[Q], B[Q], C[Q], D[Q];
  for (int i = 0; i < Q; i++){
    cin >> A[i] >> B[i] >> C[i] >> D[i];
    A[i]--; B[i]--;
  }
  
  int now[M + N] = {};
  for (int i = 0; i < N; i++) now[M + N - 1 - i] = 1;

  int ans = 0;
  do{
    int Now[N] = {};
    int Index = 0;
    for (int i = 0; i < M + N - 1; i++){
      if (now[i] == 1){
        Now[Index] = i - Index; Index++;
      }
    }


    int sum = 0;
    for (int i = 0; i < Q; i++){
      if (Now[B[i]] - Now[A[i]] == C[i]){
        sum += D[i];
      }
    }
    ans = max(ans, sum);


  }while (next_permutation(now, now + M + N));
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var S = ReadLine();
        var u = new bool[26];
        for (int i = 0; i < 26; i++)
        {
            u[i] = S.Contains((char)('a' + i));
        }

        if (S.Length != 26)
        {
            for (int i = 0; i < 26; i++)
            {
                if (!u[i])
                {
                    WriteLine(S + (char)('a' + i));
                    return;
                }
            }
        }
        else
        {
            var a = new List<char>();
            
            for (int i = 25; i >= 0; i--)
            {
                a.Add(S[i]);
                var s = S.Substring(0, i);
                for (int j = 0; j < a.Count; j++)
                {
                    if (S.CompareTo(s + a[j]) <0)
                    {
                        WriteLine(s + a[j]);
                        return;
                    }
                }
            }
            WriteLine(-1);
        }

    }
}

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

int main() {
  int n;
  cin >> n;
  vector<double> v(n);
  rep(i,n) cin >> v[i];
  sort(v.begin(), v.end());
  double ans = 0;
  rep(i,n) {
    if(i==0 || i==1) {
      ans += v[i] / pow(2.0, n-1);
    }
    else
      ans += v[i] / pow(2.0, n-i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(void)
{
	int n;
	cin>>n;

	int money=100000;
	for(int i=0; i<n; i++){
		
		money = money*1.05;

		int amari;

		amari = money%1000;

		if(amari>0){
			money += amari = 1000-amari;
		}
	}
	cout<<money<<endl;
}

Measured memory_bytes: 1160
n, *a = map(int, open(0).read().split())
ans = 1
for i in range(n):
    if ans == -1:
        if a[i] == 0:
            ans = 0
            break
    else:
        ans *= a[i]
        if ans > 10**18:
            ans = -1
print(ans)


Measured memory_bytes: 21760
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, l, t, mini = INT_MAX;
	cin>>n>>l;
	long long int sum = 0;
	for(int i = 1; i<=n; i++){
		t = l-1 + i;
		sum += t;
		mini = min(mini, abs(t));
	}
	if(sum>0)
	cout<<(sum-mini);
	else cout<<(sum+mini);
	return 0;
}

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

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    int a, b;
    string op;
    cin >> a >> op >> b;
    if (op == "+")
        cout << a + b << endl;
    else
        cout << a - b << endl;
}

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    char t[q],d[q];
    for (int i = 0;i < q;++i) cin >> t[i] >> d[i];
    int min = -1,max = n;
    while (max-min > 1) {
        int mid = (max+min)/2;
        int i = mid;
        bool ok = false;
        for (int j = 0;j < q;++j) if (t[j] == s[i]) {
            i += (d[j] == 'R' ? 1 : -1);
            if (i == n) break;
            if (i == -1) {
                ok = true;
                break;
            }
        }
        (ok ? min : max) = mid;
    }
    int l = min;
    min = -1;
    max = n;
    while (max-min > 1) {
        int mid = (max+min)/2;
        int i = n-1-mid;
        bool ok = false;
        for (int j = 0;j < q;++j) if (t[j] == s[i]) {
            i += (d[j] == 'R' ? 1 : -1);
            if (i == -1) break;
            if (i == n) {
                ok = true;
                break;
            }
        }
        (ok ? min : max) = mid;
    }
    cout << n-l-2-min;
    return 0;
}

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

int main(){
    int n;
    int h[100010] = {};
    cin >> n;

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

    for(int i = 1;i <= n;i++){
        if(h[i-1] > h[i]){
            cout << "No" << endl;
            return 0;
        }else if(h[i-1] < h[i]){
            h[i]--;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353

#define K 110000

ll powe(ll a, ll b){ //aのb乗のmod
	ll ret = 1;
	while(0 < b){
		if((b%2) == 0){
			a = (a*a)%MOD;
			b >>= 1;
		}
		else{
			ret = (ret*a)%MOD;
			b--;
		}
	}
	return ret;
}

ll n, k, x, i, j;
vector<ll> ansl(K,0);

int main(){
	cin >> n >> k;
	FORD(i,k,1){
		x = powe(k/i,n);
		for(j=2*i; j<=k; j=j+i){
			x -= ansl.at(j);
			x %= MOD;
		}
		ansl.at(i) = x;
	}
	ll ans = 0;
	FOR(i,1,k) ans = (ans+(ansl.at(i))*i)%MOD;
	cout << ans << endl;
}

Measured memory_bytes: 3908
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
#include <tuple>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

void exec() {
	int n,k;
	cin >> n >> k;
	if(n==0&&k==0)exit(0);
	vector<int> vs;
	bool zero=false;
	for(int i=0;i<k;i++){
		int a;
		cin >> a;
		if(a==0){
			zero=true;
		}
		else
		{
			vs.push_back(a);
		}
	}
	sort(vs.begin(),vs.end());
	int ret0=0;
	int ret1=0;
	int last=-2;
	int len=0;
	int len1=0;
	for(int v:vs){
		if(v==last+1)
		{
			len++;
			len1++;
		}
		else
		{
			if(v==last+2)
			{
				len1=len+2;
			}
			else
			{
				len1=2;
			}
			len=1;
		}
		//cout << v << ", " << len << ", " << lastLen << ", " << ret1 << endl;
		last=v;
		ret0=max(ret0,len);
		ret1=max(ret1,len1);
	}
	if(zero){
		cout << max(ret1,ret0+1) << endl;
	}
	else
	{
		cout << ret0 << endl;
	}
}
int main()
{
	while(1)exec();
}

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

const int N = 202020;

// bpm forked from 'https://atcoder.jp/contests/agc029/submissions/3802895'
struct bpm{
	vector<int> gph[N];
	int dis[N], l[N], r[N], vis[N];
	void clear(){ for(int i=0; i<N; i++) gph[i].clear();	}
	void add_edge(int l, int r){ gph[l].push_back(r); }
	bool bfs(int n){
		queue<int> que;
		bool ok = 0;
		memset(dis, 0, sizeof(dis));
		for(int i=0; i<n; i++){
			if(l[i] == -1 && !dis[i]){
				que.push(i);
				dis[i] = 1;
			}
		}
		while(!que.empty()){
			int x = que.front();
			que.pop();
			for(auto &i : gph[x]){
				if(r[i] == -1) ok = 1;
				else if(!dis[r[i]]){
					dis[r[i]] = dis[x] + 1;
					que.push(r[i]);
				}
			}
		}
		return ok;
	}
	bool dfs(int x){
		if(vis[x]) return 0;
		vis[x] = 1;
		for(auto &i : gph[x]){
			if(r[i] == -1 || (!vis[r[i]] && dis[r[i]] == dis[x] + 1 && dfs(r[i]))){
				l[x] = i; r[i] = x;
				return 1;
			}
		}
		return 0;
	}
	int match(int n){
		memset(l, -1, sizeof(l));
		memset(r, -1, sizeof(r));
		int ret = 0;
		while(bfs(n)){
			memset(vis, 0, sizeof(vis));
			for(int i=0; i<n; i++) if(l[i] == -1 && dfs(i)) ret++;
		}
		return ret;
	}
	bool chk[N + N];
	void rdfs(int x, int n){
		if(chk[x]) return;
		chk[x] = 1;
		for(auto &i : gph[x]){
			chk[i + n] = 1;
			rdfs(r[i], n);
		}
	}
	vector<int> getcover(int n, int m){ // solve min. vertex cover
		match(n);
		memset(chk, 0, sizeof(chk));
		for(int i=0; i<n; i++) if(l[i] == -1) rdfs(i, n);
		vector<int> v;
		for(int i=0; i<n; i++) if(!chk[i]) v.push_back(i);
		for(int i=n; i<n+m; i++) if(chk[i]) v.push_back(i);
		return v;
	}
 
}bpm;

int main() {
        int n;
        scanf("%d", &n);
        vector<vector<int>> es(n - 1), unko(n);
        rep(i, n - 1) {
                int c;
                scanf("%d", &c);
                rep(j, c) {
                        int u;
                        scanf("%d", &u);
                        u --;
                        es[i].push_back(u);
                        unko[u].push_back(i);
                        if (u) bpm.add_edge(i, u);
                }
        }
        int cnt = bpm.match(n);
        if (cnt != n - 1) {
                printf("-1\n");
                return 0;
        }
        queue<int> que;
        que.push(0);
        vector<pair<int, int>> ans(n - 1);
        vector<bool> used2(n - 1);
        while (!que.empty()) {
                int u = que.front();
                que.pop();
                for (auto en : unko[u]) if (!used2[en]) {
                        used2[en] = true;
                        ans[en] = make_pair(bpm.l[en], u);
                        que.push(bpm.l[en]);
                }
        }
        rep(i, n - 1) {
                printf("%d %d\n", ans[i].first + 1, ans[i].second + 1);
        }
        return 0;
}

Measured memory_bytes: 25176
#include<iostream>
#include<algorithm>
#include <functional>

using namespace std;
            
int main(){

    int m[10];
    
    for(int i = 0; i < 10; ++i){
        cin >> m[i];
	}
    
    sort(m , m + 10, greater<int>()); 
    
    
    for(int i = 0; i <  3; ++i){
		cout << m[i] << endl;
	}
    
    
	return 0;
}

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

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#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 pb push_back
#define mp make_pair

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

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; }

typedef pair<ll, int> P;

int main(){
    int n, m;
    cin >> n >> m;
    vll a(n), c(m);
    vi b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i] >> c[i];
    priority_queue<pair<ll, int>> q;
    rep(i, n) q.push({a[i], 1});
    rep(i, m) q.push({c[i], b[i]});
    ll ans = 0;
    rep(i, n) {
        P p = q.top(); q.pop();
        ans += p.first;
        if (p.second > 1) q.push({p.first, p.second-1});
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8048
import java.util.*;
import java.io.*;
public class Main{
/// functions
static long gcd(long a,long b){ if(b==0){return a;}return gcd(b,a%b);}
static long Modpow(long a,long p,long m){if(p==1){return a;}long x=Modpow(a,p/2,m);x=(x*x)%m;return (p&1l)!=0? (x*a)%m:x;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
static long ModInv(long a,long m){return Modpow(a,m-2,m);}
static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}
// end
static long[] f;
public static void main(String[] args) throws FileNotFoundException, IOException{
       Scanner s=new Scanner(System.in);
       BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
       int n=s.nextInt(),k=s.nextInt();
       s.nextLine();
       int[] arr=new int[n];
       for(int i=0;i<n;i++){arr[i]=s.nextInt();}
       	Arrays.sort(arr);
       long mod=(long)1e9+7;
       f=new long[n+1];f[0]=1;
       for(int i=1;i<=n;i++){f[i]=(f[i-1]*i)%mod;}
       	long min=0,max=0;
       	for(int i=0;i<n;i++){
       		min=(min+arr[i]*nck(n-i-1,k-1,mod))%mod;
       		max=(max+arr[i]*nck(i,k-1,mod))%mod;
       	}
          out.write((max-min+mod)%mod+" ");
        out.flush();
  }
}


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

int main(){
    int n,k;
    cin>>n>>k;
    int cnt=0;
    for(int i=0;i<n;i++){
        int h;
        cin>>h;
        if(h>=k)cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main(void) {
  int i,j,k;
  int n,ma,mb;
  cin>>n>>ma>>mb;
  int dp[45][405][405]; 
  rep(i,45)rep(j,405)rep(k,405)
    dp[i][j][k]=INF;
  dp[0][0][0]=0;
 
  rep(i,n){
    int a,b,c;
    cin>>a>>b>>c;
    rep(j,405)rep(k,405)
      if(dp[i][j][k]<INF){
        dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
        if(j+a<405 && k+b<405)
          dp[i+1][j+a][k+b]=min(dp[i+1][j+a][k+b],dp[i][j][k]+c);
     }
  }
 
  int ans=INF;
  for(i=1;i*max(ma,mb)<405;i++)
    ans=min(ans,dp[n][i*ma][i*mb]);
  if(ans<INF)
    cout<<ans<<endl;
  else
    cout<<-1<<endl;
}


Measured memory_bytes: 29056
#if 0
date +%Y.%m.%d

这。。。O(k) 能过？我本来只是想验证个猜想来着，一不小心就 AC 了。。。

不难归纳出串 S 经过一次碰撞后有两种情况：
1) S 的开头就是 A ，球直接弹飞，S 的开头变为 B
2) S 的开头不是 A ，球一定可以经过所有点，此后 S 取反后循环左移一位即为新的 S

关于 2) 的证明：
首先球如果刚跨过第 i 个点时第 i 个点一定是 A ，
因为能跨过它说明之前该点为 B ，那么跨过后就变成了 A 。
那么分两种情况：
i) A -> B ，直接变为 A A ->
ii) A -> A ，来回碰撞后变为 B A ->
不难发现每次第 i 个点就变成了第 i + 1 个点的相反。
对于边界，由于碰撞之前开头一定是 B ，碰撞之后结尾一定是 A ，所以也是成立的。

那么把 S 看作一个环，记一个反转标记和起点位置即可 O(k) 模拟，常数极小。

正解的话也很简单，事实上 S 的转移是 pho 形的，且链的长度是 2n 的因子，环的长度是 2 的因子．
令 k = 2n + (k - 2n) % 2 即可（仅适用于 k > 2n ）．
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 200005;
char s[maxn];

int main() {
	int n = read, k = read;
	scanf("%s", s + 1);

	if(k > (n << 1)) {
		k -= n << 1;
		k &= 1;
		k += n << 1;
	}

	int p = 1, A = 'A';
	while(k --) {
		if(s[p] == A)
			s[p] = 'A' + 'B' - s[p];
		else {
			A = 'A' + 'B' - A;
			++ p;
			if(p > n) p = 1;
		}
	}

	for(int i = p; i <= n; i ++)
		printf("%c", "BA"[s[i] == A]);
	for(int i = 1; i < p; i ++)
		printf("%c", "BA"[s[i] == A]);
	puts("");
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{int n,s=0;
 int a[1000][2];
 cin>>n;
 for(int i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1];
 for(int i=0;i<n;i++)
    s+=a[i][1]-a[i][0]+1;
 cout<<s<<endl;
} 

Measured memory_bytes: 256
//        VIVEK UPADHYAY
//        MANIT, BHOPAL(M.P)

#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
typedef long long ll;
const int MAXN = 1e6+10; ;
const int MAX = 1e7;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e10 ;
bool v[MAXN] ;
vector<int> adj[MAXN] ;
int s[MAXN] ;
int tot=0 ;
int main(){
    int D,N ;
    cin >>D>>N ;
    ll p = pow(100,D) ;
    
    if(N==100){
        cout<<101*p<<endl;
        return 0;
    }

    cout<<N*p<<endl;
    return 0;
}


Measured memory_bytes: 25600
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        int a = Read.Int();
        int b = Read.Int();
        int n = a - b;
        int c = Read.Int();
        Console.WriteLine(n%c);
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 11092
import numpy as np
from copy import deepcopy

N = int(input())
H = list(map(int,input().split()))

H = np.array(H)

## 高い花のところから水やりをしていく
## 水やりする場所のindexを取得して、連続範囲数だけ水やりをする
## 水やりした場所は"要水やり数"を1減らして、再度同様に続ける

## arrを受け取り最大の"要水やり数"を持つindexを取得
## そのindexの連続範囲数とidxを返す
def water_area(arr):
  max_idx = np.where(arr == max(arr))
  shift_idx = np.roll(max_idx, 1)
  n_area = len(np.where(max_idx-shift_idx != 1)[0])
  return n_area, max_idx


cnt = 0
arr = deepcopy(H)
while True:
  if np.all(arr == 0):
    break
  n_area, max_idx = water_area(arr)
  cnt += n_area
  arr[max_idx] -= 1
  
print(cnt)
  
  
## max(arr)は一度だけ計算すれば十分（毎度1を引くだけなので）

Measured memory_bytes: 12504
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <bits/stdc++.h>
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int main()
{
    int N;
    char w[110][20];
    map<string,int> mark;
    scanf("%d",&N);
    int flag=0;
    for(int i=0;i<N;i++){
        scanf("%s",w[i]);
        string str=w[i];
        //cout<<str<<endl;
        mark[str]++;
        if(i!=0){
        //int len1=strlen(w[i]);
        int len2=strlen(w[i-1]);
        if(w[i][0]!=w[i-1][len2-1]){
            flag=1;
        }
        if(mark[str]>1){
            flag=1;
        }
        }
    }
    if(flag==1){
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
    int N;
    
    scanf("%d",&N);
    
    if(N%2 == 0){
        N/=2;
        N--;
    } else {
        N/=2;
    }
    
    printf("%d\n",N);
    
    return 0;
}

Measured memory_bytes: 128
from collections import defaultdict

S=list(input())
T=list(input())

Sm=defaultdict(str)
Tm=defaultdict(str)

for s,t in zip(S,T):
    if (Sm[s] and Sm[s]!=t) or (Tm[t] and Tm[t]!=s): print('No'); exit()
    else: Sm[s]=t; Tm[t]=s
print('Yes')

Measured memory_bytes: 6832
#include<iostream>
using namespace std;
int main(){
  int a,b,c;cin>>a>>b>>c;
  if(a==5&&b==5&&c==7)cout<<"YES";
    else if(a==5&&b==7&&c==5)cout<<"YES";
      else if(a==7&&b==5&&c==5)cout<<"YES";
  else cout<<"NO";
}

Measured memory_bytes: 384
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s:Vec<char> = read::<String>().chars().collect();
    let ln = s.len();
    let mut ans = 753i64;
    for i in 0..ln-2 {
        let tmp =
                (s[i].to_digit(10).unwrap() * 100
            + s[i+1].to_digit(10).unwrap() * 10
            + s[i+2].to_digit(10).unwrap()) as i64;
        ans = min(ans, (753-tmp).abs());
    }
    println!("{}", ans);
}


Measured memory_bytes: 2108
#include <iostream>
#include <cstring>
using namespace std;
char s[1000101];
int n,x,y,ans;
int main(){
    cin>>s;
    n=strlen(s);
    for(int i=0;i<n;i++){
        if(s[i]=='p'){
            if(x>y){
                y++;
            }else{
                x++;
                ans--;
            }
        }else{
            if(x>y){
                y++;
                ans++;
            }else{
                x++;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie();
    ll n, a, b;
    cin>>n>>a>>b;
    ll ans = 0;
    ll g = a+b;
    ll d = n/g;
    ans += a*d;
    n -= d*g;
    ans += min(n, a);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(){
int x,y;

while(1){
scanf("%d %d",&x,&y);
if(x==0 && y==0){
break;
}else if(x<y){
printf("%d %d\n",x,y);
}else{
printf("%d %d\n",y,x);
}


}
return 0;
}

Measured memory_bytes: 600
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


s = int(input())
mod = 10**9+7
s3 = s//3
smod = s%3
ans = 0

for i in range(s3):
    ans+=cmb(s-(i+1)*3+i,i,mod)

print(ans%mod)

Measured memory_bytes: 67228
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
int main(){
    ll n;
    cin >> n;
    ll a[n];
    for (ll i=0;i<n;i++)cin >> a[i];
    ll x=0;
    for (ll i=1;i<n;i++){
        x=x^a[i];
    }
    cout << x << " ";
    for (ll i=1;i<n;i++){
        x^=a[i-1];
        x^=a[i];
        cout << x << " ";
    }
    cout << endl;
    return 0;
}


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

template<class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  
  return 0;
}

template<class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  
  return 0;
}

const long long INF = 1LL << 60;

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

  long long h[110000];
  for (int i = 0; i < N; ++i) {
    cin >> h[i];
  }
  
  long long dp[110000];
  for (int i = 0; i < 100010; ++i) {
    dp[i] = INF;
  }
  
  dp[0] = 0;
  
  for (int i = 0; i < N; ++i) {
    for (int j = 1; j <= K; ++j) {
      chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
  }
  
  cout << dp[N - 1] << endl;
}

Measured memory_bytes: 5164
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define w(e) int e ; cin >> e ; while (e--)  
#define ll long long 
#define endl "\n"
#define mod  10000000007
#define pi 3.1415926535897932384626433
#define setbit(x) __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)  
/*
*/
int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, k;
	cin >> k >> n;
	vector<ll> a(n, 0);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	ll max_dis = -1;
	for (int i = 0; i < n - 1; i++)
	{
		if (abs(a[i + 1] - a[i]) > max_dis)
			max_dis = abs(a[i + 1] - a[i]);
		//cout << max_dis << " okk\n";
	}
	ll dis = abs(k - a[n - 1] + a[0]);
	if (dis > max_dis)
		max_dis = dis;
	cout << k - max_dis << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n),b(n);
  rep(i,n) cin >> a[i] >> b[i];
  vector<int> c(m),d(m);
  rep(i,m) cin >> c[i] >> d[i];
  rep(i,n){
    vector<pair<int,int>> p(m);
    rep(j,m){
      int dis = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      p[j] = make_pair(dis,j+1);
    }
    sort(p);
    cout << p[0].second << endl;
  }
}

Measured memory_bytes: 256
# time complexity: O((lgN)^4)
# space complexity: O((lgN)^2)

def digit_sum(num):
    ds = 0
    while num > 0:
        ds += num % 10
        num //= 10
    return ds


K = int(input())
candidates = []
digit_sums = []
for i in range(15):
    base = 10**i
    for j in range(1, 150):
        candidate = j * base + (base - 1)
        candidates.append(candidate)

candidates = sorted(list(set(candidates)))
digit_sums = [digit_sum(candidate) for candidate in candidates]

snuke_nums = []
smaller_as_snuke = lambda n, m, ds_n, ds_m: True if n * ds_m <= m * ds_n else False
for i, candidate in enumerate(candidates):
    ds_cand = digit_sums[i]
    for j in range(i + 1, len(candidates)):
        other_num = candidates[j]
        ds_other = digit_sums[j]
        if not smaller_as_snuke(candidate, other_num, ds_cand, ds_other):
            break
    else:
        snuke_nums.append(candidate)

for snuke_num in snuke_nums[:K]:
    print(snuke_num)



Measured memory_bytes: 3312
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] Array = new int[101];
        int n;
        int max =0;
        while (sc.hasNext()){
            n =sc.nextInt();
            Array[n]++;
            if (max < Array[n])max = Array[n];
            }
                for (int i =0;i<Array.length;i++){
                    if (Array[i]==max){
                        System.out.println(i);
                    }
                }
            }
}

Measured memory_bytes: 18096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
void PrimeFactorization(ll a, map<ll,int>&P){
    ll n= a;
    for(ll i=2; i*i<=n; i++){
        
        if(a%i==0){
            // cout << i << " " << a << endl;
            P[i]++;
            a/=i;
            i--;
        }
    }
    if(a>1) P[a]++;
}

ll gcd(ll a, ll b){
    if(a%b==0) return b;
    else return gcd(b, a%b);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false); 
    ll x,y;
    cin >> x >> y;
    //x,yの公約数＝＝x,yの最大公約数の約数
    ll p= gcd(x,y);
    // cout << p << endl;
    map<ll,int> P;
    PrimeFactorization(p,P);
    ll num= 1;
    for(auto x:P){
        num++;
    }
    cout << num << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int maxn=1e6+55,k,num;
string s1;
void dfs(string s2)
{
	string s3; char i;
	for(i='a';i<='z';i++)
	{
		s3=s2+i;
		if(num==k) return;
		if(s1.find(s3)!=s1.npos)
		{
			num++;
			if(num==k){cout<<s3<<endl; return;}
			dfs(s3);
		}
	}
}
 
int main()
{
	cin>>s1>>k;
	string s2=""; dfs(s2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define sz size()
#define pb push_back
#define bg begin()
#define ed end()
#define fi first()
#define se second()
using namespace std;
using ll = long long;
using vint = vector<int>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template <typename T>
T sq(T x) {
  return x * x;
}
ll mod = 1e9 + 7;

signed main() {
  int n, x, t;
  cin >> n >> x >> t;
  int tako = 0;
  for (int i = 0; i < 1010; i++) {
    tako += x;
    if (tako >= n) {
      cout << (i + 1) * t << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3616
from collections import defaultdict
from heapq import heappush, heappop, heapify, heapreplace

class Solution:
    def main(self):
        N = int(input())
        sp = []
        for i in range(N):
            s, p = input().split()
            p = int(p)
            sp.append((s, p, i+1))

        sp = sorted(sp, key=lambda x: (x[0], -x[1]))

        for i in range(len(sp)):
            s, p, idx = sp[i]
            print(idx)


if __name__ == '__main__':
    Solution().main()

Measured memory_bytes: 3436
from collections import defaultdict


N = int(input())
A = list(map(int, input().split()))





ls = defaultdict(int)
rs = defaultdict(int)
for i, a in enumerate(A):
    ls[a+i+1] += 1
    rs[i+1-a] += 1


ans = 0

for i in range(2, N):
    ans += ls[i] * rs[i] 

print(ans)

Measured memory_bytes: 172244
import sys
from fractions import gcd

N, K = map(int, input().split())
A = list(map(int, input().split()))

A.sort()
if A[-1] < K:
    print("IMPOSSIBLE")
    sys.exit()
    
s = A[0]
for i in A:
    s = gcd(s, i)

if K % s != 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")
    

Measured memory_bytes: 16240
# -*- coding: utf-8 -*-
# IMPORT ###############################################################################################################
import sys                                                      # システム
sys.setrecursionlimit(10**6)                                    # 再帰処理の上限変更
from collections import deque, Counter                          # キュー・個数カウント
from itertools   import accumulate, permutations, combinations  # 累積和・順列・組み合わせ
from operator    import itemgetter                              # ソート補助
from bisect      import bisect_left, bisect_right, bisect       # 二分探索
from heapq       import heappop, heappush                       # プライオリティキュー
from fractions   import gcd                                     # 最大公約数
from math        import ceil, floor, sqrt, cos, sin, tan, pi    # 数学処理
from copy        import deepcopy                                # オブジェクトコピー
import numpy         as np                                      # 数値計算

# MAIN #################################################################################################################
def main():
    # Init #############################################################################################################
    im = InputManager()
    # Input ############################################################################################################
    n = im.inputSingle()
    a = im.inputMultiple(aslist=True)
    # Logic ############################################################################################################
    count = 0
    for ai in a:
        while ai % 2 == 0:
            count += 1
            ai = ai // 2
    # Output ###########################################################################################################
    print(count)
    # Return ###########################################################################################################
    return

# INPUT MANAGER ########################################################################################################
class InputManager(object):
    def __init__(self):
        pass

    @staticmethod
    def inputSingle(dtype=int):
        return dtype(input())
    
    @staticmethod
    def inputMultiple(dtype=int, aslist=False):
        if aslist:
            return list(map(dtype, input().split()))
        else:
            return map(dtype, input().split())

    @staticmethod
    def input2D(h, dtype=int):
        return [list(map(dtype, input().split())) for i in range(h)]

# CALL MAIN ############################################################################################################
main()

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

int main(){
    int n;
    int m[3];
    m[0]=m[1]=m[2]=0;
    for(int i=0;i<10;i++)
    {
        cin >> n;
        if(n>m[0]) { m[2]=m[1]; m[1]=m[0]; m[0] = n;}
        else if(n>m[1]){ m[2]=m[1]; m[1] = n; }
        else if(n>m[2]) m[2] = n;
    }
    for(int i=0;i<3;i++) cout << m[i] << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define M 10000000000
using namespace std;
lo int n;
lo int A[li],B[li],ans;
bool h[li+1005];
vector<lo int> pr,cb;
map<lo int , lo int> mpx;
vector< pair<lo int, lo int> > v;
void sieve(){
	for(int i=2;i<li;i++){
		if(h[i]==0){
			pr.pb(i);
			for(int j=i;j<li;j+=i){
				h[j]=1;
			}
		}
	}	
}
int main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&A[i]);
	sieve();
	for(int i=0;i<(int)pr.size();i++){
		if(pr[i]*pr[i]*pr[i]<=M) cb.pb(pr[i]);
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<(int)cb.size();j++){
			while(A[i]%(cb[j]*cb[j]*cb[j])==0){
				A[i]/=(cb[j]*cb[j]*cb[j]);
			}
		}
	}
	for(int i=1;i<=n;i++){
		lo int x=A[i];
		B[i]=1;
		for(int j=0;j<(int)cb.size();j++){
			lo int go=cb[j];
			if(x%go==0){
				lo int cnt=0;
				while(x%go==0){
					cnt++;
					x/=go;
				}
				if(cnt==1){
					B[i]*=go*go;
				}
				else B[i]*=go;
			}
		}
		if(x!=1){
			lo int sq=sqrt(x);
			if(sq*sq==x){
				B[i]*=sq;
			}
			else{
				B[i]*=x*x;
			}
		}
		mpx[A[i]]++;
		v.pb(mp(A[i],B[i]));
	}
	for(int i=0;i<(int)v.size();i++){
		if(v[i].fi==1){
			if(mpx[1]) ans++;
		}
		else{
			ans+=max(mpx[v[i].fi],mpx[v[i].se]);
		}
		mpx[v[i].fi]=0,mpx[v[i].se]=0;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 16112
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define foreach(c,itr) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define INF 1e9;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
int main(){
	int n;
	cin>>n;
	long long num[n+1];
	num[0]=2;
	num[1]=1;
	for(int i=2;i<=n;i++){
		num[i]=num[i-1]+num[i-2];
	}
	cout<<num[n];
	return 0;
}

Measured memory_bytes: 256