akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = n-1; i >= 0; --i)
#define REP(i, s, n) for (int i = s; i< (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;

template<class Len = int>
class Dijkstra {
 private:
  int n;
  std::vector<std::vector<std::pair<int, Len> > > edges;
 public:
  explicit Dijkstra(int n) : n(n), edges(n) {}

  void add_edge(int from, int to, Len cost) {
    edges[from].push_back(std::pair<int, Len>(to, cost));
  }

  std::vector<Len> solve(int source) {
    const Len inf = 1e16;
    typedef std::pair<Len, int> pi;
    std::vector<Len> d(n, inf);
    std::priority_queue<pi, std::vector<pi>, std::greater<pi> > que;
    que.push(pi(0, source));
    while (!que.empty()) {
      pi p = que.top();
      que.pop();
      int idx = p.second;
      if (d[idx] <= p.first) {
        continue;
      }
      d[idx] = p.first;
      for (int j = 0; j < edges[idx].size(); ++j) {
        que.push(pi(p.first + edges[idx][j].second, edges[idx][j].first));
      }
    }
    return d;
  }
};

int main(){
  ll n, m, s, t;
  cin >> n >> m >> s >> t;
  --s; --t;
  Dijkstra<ll> dij_a(n), dij_b(n);
  rep(i, m){
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    --u; --v;

    dij_a.add_edge(u, v, a);
    dij_a.add_edge(v, u, a);
    dij_b.add_edge(u, v, b);
    dij_b.add_edge(v, u, b);

  }

  vector<ll> sol_a = dij_a.solve(s);
  vector<ll> sol_b = dij_b.solve(t);

  vector<ll> ans(n);
  rep(i, n){
    ans.at(i) = (ll)1e15 - sol_a.at(i) - sol_b.at(i);
  }

  rrep(i, n-1){
    ans.at(i) = max(ans.at(i+1), ans.at(i));
  }

  rep(i, n){
    cout << ans.at(i) << endl;
  }

  return 0;

}


Measured memory_bytes: 18972
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}


ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  ll h,w;
  cin>>h>>w;
  if(h==1 ||w==1) cout <<1<<endl;
  else {
    ll ans =(h*w +1)/2;
    cout<<ans<<endl;
  }
  
}
  


Measured memory_bytes: 256
/*
        FFFFFFFFFFFFFFFFFFFFFF
        F::::::::::::::::::::F
        F::::::::::::::::::::F
        FF::::::FFFFFFFFF::::F
          F:::::F       FFFFFF
          F:::::F
          F::::::FFFFFFFFFF
          F:::::::::::::::F
          F:::::::::::::::F
          F::::::FFFFFFFFFF
          F:::::F
          F:::::F
        FF:::::::FF
        F::::::::FF
        F::::::::FF
        FFFFFFFFFFF
*/
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define int long long
#define mod 1000000007
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define nl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<nl
#define cout2(a,b) cout<<a<<" "<<b<<nl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<nl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<nl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<nl
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define ms(v,n) memset((v),n,sizeof(v));
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define maxi(a,b,c) max(a,max(b,c))
#define maxii(a,b,c,d) max(max(a,b),max(c,d))
#define mini(a,b,c) min(a,min(b,c))
#define md(a,b)  ((a%mod)*(b%mod)+mod)%mod 
#define ad(a,b)  (a%mod+b%mod+mod)%mod
#define inf 1e18
#define cases ll T;cin>>T;while(T--)
#define BLOCK 500
//const double PI = 3.141592653589793238460;
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
 
using namespace std;

int main()
{
    
    fast

    ll n,p;
    string s;
    cin>>n>>p>>s;
    ll ans=0;
    if(p==2)
    {
        f(i,n)
        {
            if((s[i]-'0')%2==0)
            ans+=i+1;
        }

    }
    else if(p==5)
    {
        f(i,n)
        {
            if((s[i]-'0')%5==0)
            ans+=i+1;
        }
    }
    else{

        map<ll,ll> m;
        m[0]++;
        ll t=0,mp=1;
        for(ll i=n-1;i>=0;i--)
        {
            t=(((s[i]-'0')*mp)+t)%p;
            ans+=m[t];
            m[t]++;
            mp=mp*10%p;

        }

    }
    

    cout<<ans;
    
    





    

    return 0;
    
}

Measured memory_bytes: 1044
def main():
    str = input()
    for i in range(len(str)):
        str = str[:-1]
        lengh = len(str)
        lengh_half = int(lengh/2)
        if(lengh%2==0):
            if(str[lengh_half:]==str[:lengh_half]):
                print(len(str))
                break

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <vector>
#include <iostream>
using namespace std;
int main(void)
{
    long N;
    cin >> N;
    vector<long> data (N, 0);
    vector<long> c (N, 0);
    for (auto& e: data)
      cin >> e;

    long count = 0;
    
    for (long j = 0; j < N; j++)
      	c[data[j]-1]++;

    for (auto &ci : c)
       count += ci * (ci - 1) / 2;

    for (long k = 0; k < N; k++)
		cout << (count - c[data[k]-1] +1) << endl;
}

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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 200005;
int fact[MAXN], tcaf[MAXN];

inline int sum(const int& a, const int& b) {
    int c = a + b;
    if (c >= MOD) {
        c -= MOD;
    }

    return c;
}

inline int prod(const int& a, const int& b) {
    return (1LL * a * b) % MOD;
}

int modpow(int base, int exp) {
    int res = 1;
    int cur = base;
    for (int p = 1; p <= exp; p <<= 1) {
        if (p & exp) {
            res = prod(res, cur);
        }

        cur = prod(cur, cur);
    }

    return res;
}

inline int inv(int x) {
    return modpow(x, MOD - 2);
}

void gen_fact() {
    fact[0] = tcaf[0] = 1;
    for (int i = 1; i < MAXN; ++i) {
        fact[i] = prod(fact[i - 1], i);
    }
    tcaf[MAXN - 1] = inv(fact[MAXN - 1]);
    for (int i = MAXN - 2; i >= 0; --i) {
        tcaf[i] = prod(tcaf[i + 1], i + 1);
    }
}

int choose(int n, int k) {
    if (k < 0 or k > n) return 0;
    return prod(fact[n], prod(tcaf[k], tcaf[n - k]));
}

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

    gen_fact();

    int n, a, b, c;
    cin >> n >> a >> b >> c;
    a = prod(a, inv(100));
    b = prod(b, inv(100));
    c = prod(c, inv(100));

    int pa = prod(a, inv(sum(1, MOD - c)));
    int pb = prod(b, inv(sum(1, MOD - c)));
    int cc = inv(sum(1, MOD - c));

    // for each bitstring of A/B, what's the EV of that appearing?
    // E[i] = EV of i remaining terms. Terms are already fixed
    // E[i] = c (1 + E[i]) + (1 - c) E[i - 1]
    // E[i] = c + c E[i] + E[i - 1] - c E[i - 1]
    // E[i] = (c + E[i - 1] - c E[i - 1]) / (1 - c)
    // E[i] = c / (1 - c) + E[i - 1]
    // E[n] = n * c / (1 - c)
    int ans = 0;
    for (int loser = 0; loser < n; ++loser) {
        int exp_len = prod(n + loser, cc);
        int spots = choose(loser + n - 1, loser);
        int prob = prod(spots, sum(
            prod(modpow(pa, n), modpow(pb, loser)),
            prod(modpow(pb, n), modpow(pa, loser))
        ));
        ans = sum(ans, prod(exp_len, prob));
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1792
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    lint n;
    cin >> n;

    lint ans = LLINF;

    for(lint i = 1 ; i * i <= n ; ++i){
        if(n % i == 0LL){
            chmin(ans, i + n / i - 2LL);
        }
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N, X;
    cin >> N >> X;
    int L[N];
    for (auto& l: L) {
	cin >> l;
    }
    int D = 0;
    int count = 1;
    for (int i = 0; i < N; i++) {
	D += L[i];
	if (D > X) {
	    break;
	}
	count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int MAX = 10010017;  // (1 ≦ k ≦ n ≦ 10^7 程度)
    static int MOD = 1000000007;
    static long[] fac;  // 階乗
    static long[] finv;
    static long[] inv;  // 逆元
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        int r = n - k;
        int b = k;
        
        COMinit();
        
        long ans = 0;
        for (int i = 0; i < k; i++) {
            long tmp1 = nCkMOD(b-1, i);
            // System.out.println(tmp1);
            
            long tmp2 = nCkMOD((i+1)+(r-i), (r-i));
            
            long tmp = (tmp1 * tmp2)%MOD;
            System.out.println(tmp);
        }
    }
    
    // テーブルを作る前処理
    public static void COMinit() {        
        fac = new long[MAX];
        finv = new long[MAX];
        inv = new long[MAX];
        
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    
    // 二項係数計算(1 ≦ k ≦ n ≦ 10^7 程度)
    public static long nCkMOD(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
    
    public static long modpow(long a, long n) {
        long res = 1;
        while (n > 0) {
            long tmp = n & 1;
            if (tmp > 0) res = res * a % MOD;
            a = a * a % MOD;
            n >>= 1;
        }
        return res;
    }
}


Measured memory_bytes: 258132
#include<stdio.h>
typedef struct {
	char direction[100];
	int num1,num2,num3,num4,num5,num6;
}DICE_t;
int main(){
	DICE_t a;
	scanf("%d %d %d %d %d %d",&a.num1,&a.num2,&a.num3,&a.num4,&a.num5,&a.num6);
	int e,dummy;
	if((e=getchar())=='\n'){
		scanf("%s",a.direction);
	    for(int i=0;a.direction[i]!=0;i++){
	        if(a.direction[i]=='N'){
		        dummy=a.num5;
	        	a.num5=a.num1;
	        	a.num1=a.num2;
	        	a.num2=a.num6;
	        	a.num6=dummy;
	        }
	        else if(a.direction[i]=='S'){
		         dummy=a.num6;
	        	a.num6=a.num2;
	        	a.num2=a.num1;
	        	a.num1=a.num5;
	        	a.num5=dummy;
	        }
	        else if(a.direction[i]=='E'){
		        dummy=a.num4;
	        	a.num4=a.num6;
	        	a.num6=a.num3;
	        	a.num3=a.num1;
	        	a.num1=dummy;
	        }
	        else if(a.direction[i]=='W'){
	            dummy=a.num1;
	        	a.num1=a.num3;
	        	a.num3=a.num6;
	        	a.num6=a.num4;
	        	a.num4=dummy;
	        }
	    	
        }
	    printf("%d\n",a.num1);
	}
	return 0;
}

Measured memory_bytes: 2684
using System;

namespace ABC119_D___Lazy_Faith
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABQ = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            var shrines = new long[ABQ[0]];
            for (int i = 0; i < ABQ[0]; i++) shrines[i] = long.Parse(Console.ReadLine());

            var temples = new long[ABQ[1]];
            for (int i = 0; i < ABQ[1]; i++) temples[i] = long.Parse(Console.ReadLine());

            var questions = new long[ABQ[2]];
            for (int i = 0; i < ABQ[2]; i++) questions[i] = long.Parse(Console.ReadLine());

            foreach (long q in questions)
            {
                var FS = lowerBound(shrines, q);
                var BS = FS != 0 ? FS - 1 : 0;
                if (FS == ABQ[0]) FS = FS - 1;

                var FT = lowerBound(temples, q);
                var BT = FT != 0 ? FT - 1 : 0;
                if (FT == ABQ[1]) FT = FT - 1;

                long result = long.MaxValue;
                Func<long, long, long> f = (a, b) => Math.Min(result, Math.Abs(q - a) + Math.Abs(a - b));
                result = f(shrines[FS], temples[FT]);
                result = f(shrines[FS], temples[BT]);
                result = f(shrines[BS], temples[FT]);
                result = f(shrines[BS], temples[BT]);
                result = f(temples[FT], shrines[FS]);
                result = f(temples[FT], shrines[BS]);
                result = f(temples[BT], shrines[FS]);
                result = f(temples[BT], shrines[BS]);
                Console.WriteLine(result);
            }
        }
        static int lowerBound(long[] array, long start)
        {
            int left = -1;
            int right = array.Length;

            while (right - left > 1)
            {
                int mid = (left) + (right - left) / 2;
                if (array[mid] >= start) right = mid; else left = mid;
            }
            return right;
        }
    }
}


Measured memory_bytes: 18496
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int a[4][4];

int main(){
	REP(i, 3) REP(j, 3) scanf("%d", a[i]+j);
	int n; scanf("%d", &n);
	REP(i, n){
		int b; scanf("%d", &b);
		REP(j, 3) REP(k, 3) if(a[j][k] == b) a[j][k] = 0;
	}
	bool ok = false;
	REP(i, 3){
		bool x = true;
		REP(j, 3){
			if(a[i][j]) x = false;
		}
		if(x) ok = true;
	}
	REP(i, 3){
		bool x = true;
		REP(j, 3){
			if(a[j][i]) x = false;
		}
		if(x) ok = true;
	}
	{
		bool x = true;
		REP(j, 3){
			if(a[j][j]) x = false;
		}
		if(x) ok = true;
	}
	{
		bool x = true;
		REP(j, 3){
			if(a[j][2-j]) x = false;
		}
		if(x) ok = true;
	}
	if(ok) printf("Yes\n");
	else printf("No\n");
}


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

int main(void){
  int n,m,Ci,Co,max,Ct,flag=0;

  cin >> n;
  cin >> m;

  Ct = m;
  max = m;
  for( int i = 0 ; i < n ; i++ ){
 
    cin >> Ci >> Co;

    Ct += Ci - Co;

    if( Ct < 0 ) flag = 1;

    if( max < Ct ) max = Ct;

  }

  if( flag == 1 ) cout << "0" << endl;
  else cout << max << endl;

  return 0;

}

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

using namespace std;
typedef long long LL;
int arr[100],ans[100];
int main(){
    LL a,b;
    LL ans = 0;
    cin >> a >> b;
    for(LL i= a+4-a%4 -1;i>=a ;i--) 
        ans = ans^i;
    for(LL j=b-b%4 ;j<=b;j++) 
        ans = ans^j;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
def main():
    n=int(input())
    H=list(map(int,input().split()))
    now=H[0]-1
    if n==0:
        print('Yes')
        return
    for h in H[1:]:
        if now > h:
            print('No')
            return
        elif now == h:
            now = h
        else:
            now = h -1
    print('Yes')
main()

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#include <stack>
using namespace std;
int main() {
    int h,w,m; cin >> h >> w >> m;

    vector<int> hcnt(h,0);
    vector<int> wcnt(w,0);
    int hm = 0;
    int wm = 0;
    set<pair<int,int>> bomb;
    int cnt = -1;
    for(int i=0; i<m; i++){
        int y; int x;
        cin >> y >> x;
        y--; x--;

        bomb.insert(make_pair(y,x));
        hcnt[y]++;
        wcnt[x]++;
        if(hcnt[y] > hm) hm = hcnt[y];
        if(wcnt[x] > wm) wm = wcnt[x];
    }

    vector<int> hn;
    vector<int> wn;
    for(int i=0; i<h; i++){
        if(hcnt[i] == hm) hn.push_back(i);
    }
    for(int i=0; i<w; i++){
        if(wcnt[i] == wm) wn.push_back(i);
    }

    for(int i=0; i<hn.size(); i++){
        for(int j=0; j<wn.size(); j++){
            if(bomb.count(pair<int,int>(hn[i],wn[j]))) continue;
            cout << hm + wm << endl;
            return 0;
        }
    }
    cout << hm + wm -1 << endl;
}

Measured memory_bytes: 23784
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;



class Myon
{
	public Myon() { }
	public static int Main()
	{
		cin = new Scanner();
		new Myon().calc();
		return 0;
	}

	static Scanner cin;

	const int MIN = -1000000;
	const int MAX = 1000000;

	void calc()
	{
		int K = cin.nextInt();
		int X = cin.nextInt();

		int min = Math.Max(MIN, X - K + 1);
		int max = Math.Min(MAX, X + K - 1);

		for (int i = min; i <= max; i++)
		{
			Console.WriteLine(i);
		}
	}


	//swap
	void swap<T>(ref T a, ref T b)
	{
		T c = a;
		a = b;
		b = c;
	}


}



class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		if (s.Length == 0) return next();
		i = 0;
		return s[i++];
	}

	public int nextInt()
	{
		return int.Parse(next());
	}
	public int[] ArrayInt(int N, int add = 0)
	{
		int[] Array = new int[N];
		for (int i = 0; i < N; i++)
		{
			Array[i] = nextInt() + add;
		}
		return Array;
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public long[] ArrayLong(int N, long add = 0)
	{
		long[] Array = new long[N];
		for (int i = 0; i < N; i++)
		{
			Array[i] = nextLong() + add;
		}
		return Array;
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}


	public double[] ArrayDouble(int N, double add = 0)
	{
		double[] Array = new double[N];
		for (int i = 0; i < N; i++)
		{
			Array[i] = nextDouble() + add;
		}
		return Array;
	}
}


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

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

int main(){
    int N,X,Y;
    cin>>N>>X>>Y;
    vl ans(N,0);
    FOR(i,1,N+1){
        //int d=0;
        FOR(j,i+1,N+1){
            int d=j-i;
            d=min(d,abs(j-Y)+abs(X-i)+1);
            ans[d]++;
        }
    }
    FOR(i,1,N){
        cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(int argc, char const *argv[])
 {
   
   while(true){
      int n, m, t, p; cin >> n >> m >> t >> p;
      if (n == 0) break;
      int d[t], c[t]; for (int i = 0; i < t; i++) cin >> d[i] >> c[i];
      int x[p], y[p]; for (int i = 0; i < p; i++) cin >> x[i] >> y[i];

      int cell[20*n][20*m] = {}; 
      for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cell[i][j] = 1;
      int xoffset = 0, yoffset = 0;
      int count1=0, count2=0;
      for (int k = 0; k < t; k++) {
        if (d[k] == 1) {
          int count = 0;
          while((c[k]-count)!=0){
            for (int j = 0; j < 20*m; j++){
              cell[c[k]+count+count1][j] += cell[c[k]-count-1+count1][j];
              cell[c[k]-count-1+count1][j] = 0;
            }
            count++;
          }
          count1 += c[k];
        } 
        else {
          int count = 0;
          while((c[k]-count)!=0){
            for (int i = 0; i < 20*n; i++){
              cell[i][c[k]+count+count2] += cell[i][c[k]-count-1+count2];
              cell[i][c[k]-count-1+count2] = 0;
            }
            count++;
          }
          count2+=c[k];
        }

      }
      
      for (int i = 0; i < p; i++) {
        cout << cell[x[i]+count1][y[i]+count2] << endl;
      }
    }
   return 0;
 }


Measured memory_bytes: 4704
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  vector<vector<int>> a(n, vector<int>(m));
  rep(i,m) cin >> b.at(i);
  rep(i,n) {
    rep(j,m) cin >> a.at(i).at(j);
  }
  int sum, ans=0;
   rep(i,n) {
     sum = 0;
     rep(j,m) {
       sum += b.at(j) * a.at(i).at(j);
     }
     if(sum + c > 0)
       ans++;
   }
  cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _LIBCPP_DEBUG 0
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main() {
    string n;
    cin >> n;
 
    if(n[0] == '7' || n[1] == '7' || n[2] == '7'){
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}

using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  int n,m;
  cin>>n>>m;
  int a[m],b[m];
  REP(i,m){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
  }
  
  int ans=0;
  REP(i,m){
    UnionFind uni(n);
    REP(j,m){
      if(j==i)continue;
      uni.connect(a[j], b[j]);
    }
    if(uni.root(a[i])==uni.root(b[i])){
      continue;
    }else{
      ans++;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

  int n;
  string s;
  cin >> n >> s;

  for (int i = 0; i < s.size(); i++) {
    int x = s[i] - 'A';
    x += n;
    x %= 26;
    cout << (char)('A' + x);
  }
  cout << endl;

  return 0;
}

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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main() {
    //ios::sync_with_stdio(0);
    //cin.tie(0);
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> res(n-1, 0);
    for(int i = 1; i <= n-1; ++i){
        for(int j = i+1; j <= n; ++j){
            if(i <= x){
                if(j <= x){
                    ++res[j-i-1];
                } else if(j >= y){
                    ++res[x-i + 1 + j - y-1];
                } else {
                    if(j-i < x-i+1+y-j){
                        ++res[j-i-1];
                    }else{
                        ++res[x-i + 1 + y - j - 1];
                    }
                }
            }else if(i >= y){
                ++res[j-i-1];
            }else if(j <= y){
                if(j-i < i-x+1+y-j){
                    ++res[j-i-1];
                }else{
                    ++res[i-x+1+y-j-1];
                }
            }else{
                if(j-i < i-x+1+j-y){
                    ++res[j-i-1];
                }else{
                    ++res[i-x+1+j-y-1];
                }
            }
        }
    }
    for(auto el : res){
        cout << el << endl;
    }
}

Measured memory_bytes: 256
line1 = input()
line2 = input()
line3 = input()

str_s, str_t = line1.split(" ")
num_a, num_b = line2.split(" ")

if line3 == str_s:
    print(str(int(num_a)-1), num_b)
else:
    print(num_a,str(int(num_b)-1))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// String型をchar型へ変換
		char[] c = sc.nextLine().toCharArray();

		for (int i = 0; i < c.length; i++) {
			// 1文字ずつ大文字変換された文字と比較
			if (c[i] == Character.toUpperCase(c[i])) {
				c[i] = Character.toLowerCase(c[i]);
			} else {
				c[i] = Character.toUpperCase(c[i]);
			}
		}
		// 出力
		System.out.println(c);
	}
}



Measured memory_bytes: 26160
#include<bits/stdc++.h>
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
const int inf=0x3f3f3f3f;
const long long inf2=(1<<62)-1;
const double eps=1e-6;
int dist(int x,int y,int x2,int y2){
	return (abs)(x-x2)*(y-y2);
}
int main(){
	int n,k;
	cin>>n>>k;
	if(k%2!=0){
		cout<<(long long)(n/k)*(n/k)*(n/k);
	}
	if(k%2==0){
		cout<<(long long)((long long)(n/k)*(n/k)*(n/k)+(long long)((n+k/2)/k)*((n+k/2)/k)*((n+k/2)/k));
	}
	return 0;
}


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

using namespace std;

bool ok(int n, int a, int b){
    if(a<b) swap(a,b);
    for(int i=0; i<=n; i+=a){
        if((n-i)%b==0) return true;
    }
    return false;
}

int main(){
    int n,a,b;

    while(cin>>n>>a>>b, n|a|b){
        int ans=0;
        for(int i=1; i<=n; i++){
            if(ok(i,a,b)) continue;
            ans++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int a,b,c;

int main(){
  cin>>a>>b>>c;

  for(int i=a;i<=b;i++){
    if(i<a+c)
      cout<<i<<endl;
    else if(b-c<i)
      cout<<i<<endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

const int DEBUG = 0;

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

bool check(const vector<string> &s, const VI &p) {
  int h = s.size();
  int w = p.size();
  vector<string> t(h, string(w, '+'));
  vector<string> tr(h, string(w, '+'));
  REP(i, 0, h) {
    REP(j, 0, w) {
      t[i][j] = s[i][p[j]];
    }
    tr[i] = t[i];
    reverse(tr[i].begin(), tr[i].end());
  }
  if (DEBUG) {
    cerr << "t:";
    REP(i, 0, h) cerr << t[i] << endl;
  }
  vector<bool> used(h, false);
  REP(i, 0, h) {
    if (used[i]) continue;
    bool found = false;
    REP(j, i + 1, h) {
      if (used[i]) continue;
      string r = tr[j];
      if (t[i] == r) {
	used[j] = true;
	used[i] = true;
	found = true;
        break;
      }
    }
  }
  int rem = 0;
  int idx = -1;
  REP(i, 0, h) {
    if (not used[i]) {
      rem++;
      idx = i;
    }
  }
  if (rem != h % 2) return false;
  if (rem == 0) return true;
  string r = tr[idx];
  return t[idx] == r;
}

bool dfs(int v, const vector<string> &s, VI &p, bool centre, int used, vector<bool> &vis) {
  int w = s[0].length();
  if (vis[v]) {
    return dfs(v + 1, s, p, centre, used, vis);
  }
  if (v >= w) {
    if (DEBUG){
      REP(i, 0, w) {
	cerr << " " << p[i];
      }
      cerr << endl;
    }
    return check(s, p);
  }
  if (w % 2 == 1 && not centre) {
    p[w / 2] = v;
    vis[v] = 1;
    if (dfs(v + 1, s, p, true, used, vis)) return true;
    p[w / 2] = -1;
    vis[v] = 0;
  }
  if (used < w / 2) {
    REP(i, v + 1, w) {
      if (vis[i]) continue;
      p[used] = v;
      p[w - 1 - used] = i;
      vis[v] = 1;
      vis[i] = 1;
      if (dfs(v + 1, s, p, centre, used + 1, vis)) return true;
      p[used] = -1;
      p[w - 1 - used] = -1;
      vis[v] = 0;
      vis[i] = 0;
    }
  }
  return false;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  REP(i, 0, h) cin >> s[i];
  VI p(w);
  REP(i, 0, w) p[i] = -1;
  vector<bool> vis(w);
  bool ok = dfs(0, s, p, false, 0, vis);
  cout << (ok ? "YES" : "NO") << endl;
}


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

int main() {
    string s; cin >> s;
    string ans;
    rep(i, s.size()) {
        if (s.at(i) == 'B') {
            if (ans.empty())
                continue;
            
            ans.pop_back();
            continue;
        }
        ans.push_back(s.at(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
while True:
    a,op,b = raw_input().split()
    a = int(a)
    b = int(b)
    if op == "+":
        print a + b
    elif op == "-":
        print a - b
    elif op == "*":
        print a * b
    elif op == "/":
        print a / b
    elif op == "?":
        break

Measured memory_bytes: 6288
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
int main()
{
    int n,nw=0,f=1;cin>>n;
    pair<int,int>p[n];
    for(int i = 0 ;i<n;i++)cin>>p[i].s>>p[i].f;
    sort(p,p+n);
    for(int i = 0 ;i<n;i++){
            nw+=p[i].s;
        if(nw>p[i].f)f=0;
    }
    if(f)cout<<"Yes";
    else cout<<"No";
}


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

int n;
vector<int> adj[200000];

array<int, 2> dfs(int u, int p=-1, int d=1) {
	array<int, 2> r={d, u};
	for(int v : adj[u])
		if(v^p)
			r=max(dfs(v, u, d+1), r);
	return r;
}

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

	cin >> n;
	for(int i=1, a, b; i<n; ++i) {
		cin >> a >> b, --a, --b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	cout << (dfs(dfs(0)[1])[0]%3==2?"Second":"First");
}

Measured memory_bytes: 26880
#include<stdio.h>
int main(void){
int pas[3],lpas,ju[2],lju,i,j;
for(i=0;i<3;i++){
    scanf("%d",&pas[i]);
    if(i==0)lpas=pas[0];
    if(lpas>pas[i])lpas=pas[i];
}
for(j=0;j<2;j++){
    scanf("%d",&ju[j]);
    if(j==0)lju=ju[0];
    if(lju>ju[j])lju=ju[j];
}
printf("%d\n",lpas+lju-50);

return 0;
}

Measured memory_bytes: 592
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7

N,K = I()
A = l()
i = A.index(1)
ans = 10**9
for j in range(K):
    ans = min(ans,math.ceil(max(i-j,0)/(K-1))+math.ceil(min((N-i-1+j),N-1)/(K-1)))
print(ans)

Measured memory_bytes: 91396
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define lli long long int
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}
vector<int>ar[200001];
int vis[200001];
set<int>vi;
void dfs(int v)
{
	vis[v]=1;
	vi.insert(v);
	for(int child:ar[v])
	{
		if(vis[child]==0)
		{
			dfs(child);
		}
	}
}
int main()
{
   ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
int n;
cin>>n;
int m;
cin>>m;
int l,r;
while(m--)
{
cin>>l>>r;
l--;
r--;
ar[l].pb(r);
ar[r].pb(l);	
}
int ans=0;
for(int i=0;i<n;i++)
{
	if(vis[i]==0)
	{
		vi.clear();
		dfs(i);
		int p=vi.size();
	ans=max(ans,p);	
	}
}
cout<<ans<<endl;
}
 
 

Measured memory_bytes: 34080
H, W = map(int, input().split())
N = int(input())

i = 0
buf = [0] * W
k = 1
for x, ai in zip(range(1, N+1), map(int, input().split())):
  for _ in range(ai):
    buf[i] = x
    i += 1
    if i >= W:
      print(" ".join(map(str, buf[::k])))
      i = 0
      k = -k



Measured memory_bytes: 3188
n=int(input())
if n<10:
  print(n)
if 10<=n<100:
  print(9)
elif 100 <= n < 1000:
  print(n-90)
elif 1000 <= n < 10000:
  print(909)
elif 10000 <= n < 100000:
  print(n-9090)
elif n==100000:
  print(90909)

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

#define DIVIDE (1000000007)

int main (void) {
    int n, m, i;
    scanf("%d%d", &n, &m);
    int broken_idx;
    long long step[n+3]; /* init: 0, broken: -1 */
    memset(step, 0, (n+1)*sizeof(long long));
    for ( i=0; i<m; i++ ) {
        scanf("%d", &broken_idx);
        step[broken_idx] = -1;
    }

    step[n+2]=1;
    step[n+1]=0;
    for ( i=n; i>=0; i-- ) {
        if ( step[i] == -1 ) {
            step[i] = 0;
            continue;
        }
        step[i] = (step[i+1]+step[i+2]) % DIVIDE;
    }

    printf("%lld\n", step[0]);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 896
use std::io;


fn main() {
    let k = read_one::<usize>();
    if k % 2 == 0 { println!("{}", (k / 2) * (k / 2)); }
    else { println!("{}", (k / 2) * (k + 1) / 2); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main() {
	int A, B, C, b, c, d;
	cin >> A >> B >> C;
	b = A + B + C, c = A*B + B*C + C*A, d = A*B*C;
	if (b == 17 && c == 95 && d == 175) {
		cout << "YES";
	}
	else { cout << "NO"; }
	return 0;
}

Measured memory_bytes: 256
function Main(s){
  s = s.split("\n");
  var d = s[0].split(" ").map(a=>+a);
  var g = d[1] / 100;
  d = d[0];
  var p = [];
  for(var i = 0; i < d; i++){
    p[i] = s[i+1].split(" ").map(a=>+a);
    p[i][1] /= 100;
    p[i][1] = p[i][0] * (i+1) + p[i][1];
  }
  var ans = 9e9;
  for(i = 0; i < 1<<d; i++){
    var u = 0, v = 0, w = -1;
    for(var j = 0; j < d; j++){
      if(i & (1<<j)){u += p[j][0]; v += p[j][1]}
      else w = j;
    }
    var t = 0;
    if(w >= 0)while(v < g && t++ < p[w][0]){
      u++;
      v += w + 1;
    }
    if(v >= g && ans > u)ans = u;
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 11468
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
 
int main() {
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v.at(i);
 
    vector<int> ecnt(100005, 0);
    vector<int> ocnt(100005, 0);
    rep(i, n){
       if((i+1)%2==0) ecnt.at(v.at(i))++;
       else ocnt.at(v.at(i))++;
    }
    
    int modd=0, meven=0;
    int oi, ei;
    rep(i, 100001){
        if(modd<ocnt.at(i+1)){
            modd = ocnt.at(i+1);
            oi = i+1;
        }
    }
 
    rep(i, 100001){
        if(meven<ecnt.at(i+1)){
            meven = ecnt.at(i+1);
            ei = i+1;
        }
    }
 
    int modds=0, mevens=0;
    ocnt.at(oi) = 0;
    ecnt.at(ei) = 0; 
 
    rep(i, 100001){
        modds = max(modds, ocnt.at(i+1));
        mevens = max(mevens, ecnt.at(i+1));
    }
 
    if(oi==ei){
        int res = 0;
        res = min(n-modds-meven, n-modd-mevens);
        cout << res << endl;
        return 0;
    }
 
 
    cout << n - modd - meven << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#define INF 100000000
using namespace std;

int main(){
  while(1){
    int n,t[17][17];
    cin >> n;
    if(n == 0) break;
    for(int i=0;i<n;i++)
      for(int j=0;j<n+1;j++) cin >> t[i][j];

    int dp[1<<16]={};
    for(int i=1;i<(1<<n);i++) dp[i] = INF;

    for(int i=0;i<(1<<n);i++)
      for(int j=0;j<n;j++)
	if((i&(1<<j)) == 0) {
	  dp[i+(1<<j)] = min(dp[i+(1<<j)],dp[i]+t[j][0]);
	  for(int k=0;k<n;k++)
	    if((i & (1<<k)) != 0)dp[i+(1<<j)] = min(dp[i+(1<<j)],dp[i]+t[j][k+1]);
	}    
    cout << dp[(1<<n)-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1424
//#define local
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
#ifdef local
#include "debug.cpp"
#else
#define debug(...)
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    ll n; cin >> n;
    vec<ll> l(n); rep(i,n)cin >> l[i];
    sort(l.begin(),l.end());
    ll res = 0;
    rep(i,n){
        for(ll j = i+1;j<n;j++){
            for(ll k = j+1;k<n;k++){
                if(l[j] - l[i] < l[k] && l[k] < l[j] + l[i] && l[i] != l[j] && l[j] != l[k] )res++;
                
            }
        }
    }
    cout << res << endl;
}

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

using namespace std;

int a[10][10];
int m[10][10];
int ok;

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

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int b;
        cin >> b;
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (a[j][k] == b) m[j][k] = 1;
            }
        }
    }

    for (int i = 0; i < 3; i++) {
        ok = 1;
        for (int j = 0; j < 3; j++) {
            if (m[i][j] != 1) ok = 0;
        }
        if (ok) {
            cout << "Yes\n";
            return 0;
        }
    }
    for (int i = 0; i < 3; i++) {
        ok = 1;
        for (int j = 0; j < 3; j++) {
            if (m[j][i] != 1) ok = 0;
        }
        if (ok) {
            cout << "Yes\n";
            return 0;
        }
    }
    ok = 1;
    for (int i = 0; i < 3; i++) {
        if (m[i][i] != 1) ok = 0;
    }
    if (ok) {
        cout << "Yes\n";
        return 0;
    }
    ok = 1;
    for (int i = 0; i < 3; i++) {
        if (m[i][2 - i] != 1) ok = 0;
    }
    if (ok) {
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";
}


Measured memory_bytes: 256
import sys
from collections import Counter
import numpy as np

read = sys.stdin.read
readline = sys.stdin.readline

N, *A = map(int, read().split())
a = Counter(A)
s = sum(i * (i - 1) // 2 for i in a.values())
val = np.array([a[i] for i in A], np.int64)
answer = s - (val - 1)
print('\n'.join(map(str, answer.tolist())))


Measured memory_bytes: 49972
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int ll
#define For(a, b, c) for(int a = b; a <= c; ++a)
#define Ford(a, b, c) for(int a = b; a >= c; --a)
#define All(a, b) for(auto &a : b)
#define Rep(a, b, c) for(int a = b; a < c; ++a)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define all(a) a.begin(),a.end()
#define reset(a, b) memset(a, b, sizeof(a))
#define bit(x, i) (x >> (i - 1) & 1ll)
#define onbit(x, i) (x | (1ll << (i - 1)))
#define offbit(x, i) (x & ~(1ll << (i - 1)))
#define bitone(i) __builtin_popcountll(i)
#define bitl(i) __builtin_clz(i)
#define bitr(i) __builtin_ctz(i)
#define vll vector<ll>
/********************************************************

Digvijay Bahadur Singh
MNNIT

*********************************************************/
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}


const int MOD=1e9+7;
const int N = 1e6+100;
/********************************************************************/
                 /* GRAPH*/
//vector<vector<ll>> g;
//vector<bool> vis1,vis2;
/*******************************************************************/
ll power(ll a,ll b)
{
   ll ans =1;
   while(b>0){
   if(b&1) ans = (ans%MOD * a%MOD)%MOD;
   a = (a%MOD * a%MOD)%MOD;
   b=b>>1;
   }
   return ans%MOD;
}


signed main(){
  ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
  ll n;

  
  ll T=1;
 //cin>>T;
  
   // T=1;
    
    while(T--)
  {
    
        
     int n;
     cin>>n;
     vector<string> v1,v2;
     map<string,int> mp;
     for(int i=0;i<n;i++)
     {
       string s;
       cin>>s;
       mp[s]++;
       v1.pb(s);
     }
     int maxi=INT_MIN;
     for(int i=0;i<n;i++)
     {
       maxi=max(maxi,mp[v1[i]]);

     }
     for(int i=0;i<n;i++)
     {
       if(mp[v1[i]]==maxi)
       {
         v2.pb(v1[i]);
         mp[v1[i]]=0;
       }
     }
     sort(all(v2));
     for(int i=0;i<v2.size();i++)
     {
       cout<<v2[i]<<"\n";
     }

     
	
  }

       
   
  

   
 


      

  }

  



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

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

using namespace std;

int main() {
  int s,d,m;
  while(cin>>s>>d>>m) {
    vector<vector<int>> dp(s);
    REP(i,s) {
      int k;
      cin>>k;
      vector<vector<int>> dpi(k+1, vector<int>(m+1));
      REP(j,k) {
        int w, p;
        cin>>w>>p;
        for (int l=0; l<min(p,m+1); ++l) {
          dpi[j+1][l] = dpi[j][l];
        }
        for (int l=p; l<=m; ++l) {
          dpi[j+1][l] = max(dpi[j][l-p] + w, dpi[j][l]);
        }
      }
      dp[i] = dpi[k];
    }
    vector<vector<int>> dp2(d+1, vector<int>(m+1));
    REP(i,d) {
      int f;
      cin>>f;
      REP(j,m+1) {
        dp2[i+1][j] = dp2[i][j];
        REP(k,j+1) {
          dp2[i+1][j] = max(dp2[i][k] + dp[f][j-k], dp2[i+1][j]);
        }
      }
    }
    int maxef = 0;
    int ati = 0;
    REP(i,m+1) {
      if (maxef < dp2[d][i]) {
        maxef = dp2[d][i];
        ati = i;
      }
    }
    cout << maxef << ' ' << ati << endl;
  }
  return 0;
}

Measured memory_bytes: 1392