akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
template<typename T>
void print_to(std::ostream &os,const char *,const char *tail,const T &fst){
  os<<fst<<tail;
}
template<typename Fst,typename... Rst>
void print_to(std::ostream &os,const char *del,const char *tail,const Fst &fst,const Rst &... rst){
  os<<fst<<del;
  print_to(os,del,tail,rst...);
}
template<typename Iter>
void print_to_(std::ostream &os,const char *del,const char *tail,Iter bgn,Iter end){
  for(Iter it=bgn;it!=end;){
    os<<*it;
    if(++it!=end)os<<del;
    else os<<tail;
  }
}
template<typename Fst,typename... Rst>
void println(const Fst &fst,const Rst &... rst){
  print_to(std::cout,"\n","\n",fst,rst...);
}
template<typename Fst,typename... Rst>
void print(const Fst &fst,const Rst &... rst){
  print_to(std::cout," ","\n",fst,rst...);
}
template<typename Iter>
void println_(Iter bgn,Iter end){
  print_to_(std::cout," ","\n",bgn,end);
}
using namespace std;
//const ll MOD=(ll)1e9+7;
//const ll inf=(ll)1e14;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
int n,m,h,w;
string s;
ll c[51];
map<ll,int> mp;
ll conb[51][51];
void cal(){
  for(int i=0;i<51;i++){
    conb[i][0]=1;
    conb[i][i]=1;
  }
  for(int i=0;i<51;i++){
    for(int j=0;j<=i;j++){
      if(i==j || j==0)continue;
      conb[i][j]=conb[i-1][j-1]+conb[i-1][j];
    }
  }
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  int a,b;cin>>n>>a>>b;
  for(int i=0;i<n;i++){
    cin>>c[i];
    mp[c[i]]++;
  }
  cal();
  sort(c,c+n);
  reverse(c,c+n);
  double ave=0;
  for(int i=0;i<a;i++){
    ave+=(double)c[i];
  }
  ave/=a;
  print(ave);
  if(c[0]==c[a-1]){
    ll res=0;
    int maxvx=mp[c[0]];
    int mini=min(maxvx,b);
    for(int i=a;i<=mini;i++){
      res+=conb[maxvx][i];
    }
    print(res);
    return 0;
  }
  if(a==1){
    if(c[0]!=c[1]){
      print(1);
      return 0;
    }else{
      ll res=0;
      int maxvx=mp[c[0]];
      int mini=min(maxvx,b);
      for(int i=a;i<=mini;i++){
        res+=conb[maxvx][i];
      }
      print(res);
      return 0;
    }
  }else if(a==n){
    print(1);
    return 0;
  }else{
    if(c[a-1]!=c[a] && c[a-1]!=c[a-2]){
      print(1);
      return 0;
    }else{
      int cont=0;
      for(int i=0;i<a;i++){
        if(c[a-1]==c[i])cont++;
      }
      int minvx=mp[c[a-1]];
      print(conb[minvx][cont]);
      return 0;
    }
  }
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}






Measured memory_bytes: 256
import java.util.*;

public class Main{
        public static void main(String[] args){
                try(Scanner sc = new Scanner(System.in)){
                        long N = sc.nextLong(), K = sc.nextLong();
                        long ans = 0;
                        for(long i = 0; i < N - 1; i++){
                                ans = K * ((long)(ans / (K - 1))) + ans % (K - 1) + 1;
                        }
                        System.out.println(ans);
                }
        }
}

Measured memory_bytes: 26368
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static class UnionFind {
		int[] par; //

		public UnionFind(int n) {
			par = new int[n];
			for(int i = 0; i < n; i++){
				par[i] = -1;
			}
		}

		public int find(int x) {
			if(par[x] < 0){
				return x;
			}else{
				return par[x] = find(par[x]);
			}
		}

		public boolean union(int x, int y) {
			x = find(x);
			y = find(y);

			if(x != y){
				if(par[y] < par[x]){ // 多い方が根になるようにスワップする.
					int tmp = x;
					x = y;
					y = tmp;
				}
				par[x] += par[y];
				par[y] = x;
				return true;
			}else{
				return false;
			}
		}

		public boolean same(int x, int y) {
			return find(x) == find(y);
		}

		public int size(int x) {
			return -par[find(x)];
		}
	}
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int M = sc.nextInt();
			
			UnionFind uf = new UnionFind(N);
			
			for(int i = 0; i < M; i++) {
				final int a = sc.nextInt() - 1;
				final int b = sc.nextInt() - 1;
				
				uf.union(a, b);
			}
			
			HashSet<Integer> groups = new HashSet<Integer>();
			for(int i = 0; i < N; i++) {
				groups.add(uf.find(i));
			}
			
			System.out.println(groups.size() - 1);
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 53936
/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};    // King's move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hx[]={-2,-2,-1,+1,+2,+2,-1,+1};    // Knight's move
int hy[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e5+9;


int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>n>>m;
    cout<<(n*(n-1))/2+(m*(m-1))/2<<endl;

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 256
N = input()
A = input()
A = A.split()

A = [i for i in A if int(i) % 2 == 0]
# print(A)

all_nums = len(A)
A = [i for i in A if int(i) % 3 == 0 or int(i) % 5 == 0]
# print(A)

if len(A) == all_nums:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            System.out.println(N % 2 == 0 ? 0.5 : ((N / 2 + 1) / ((double) N)));
        }
    }
}


Measured memory_bytes: 26984
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll dp[3000][3000][4];

class EPickingGoods {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int r, c, k; cin >> r >> c >> k;
      rep(i, r) rep(j, c) rep(K, 4) {
        dp[i][j][K] = 0;
      }

      ll val[r][c];
      rep(i, r) rep(j, c) {
        val[i][j] = 0;
      }

      rep(i, k) {
        int R, C, V; cin >> R >> C >> V;
        R--; C--;
        val[R][C] = V;
      }

      dp[0][0][1] = val[0][0];

      for(int i=0; i<r; i++) {
        for(int j=0; j<c; j++) {
          // move to right
          if (j+1 < c) {
            rep(K, 4) {
              chmax(dp[i][j+1][K], dp[i][j][K]);
              if (K < 3) chmax(dp[i][j+1][K+1], dp[i][j][K] + val[i][j+1]);
            }
          }
          // down
          if (i+1 < r) {
            rep(K, 4) {
              chmax(dp[i+1][j][0], dp[i][j][K]);
              chmax(dp[i+1][j][1], dp[i][j][K] + val[i+1][j]);
            }
          }
        }
      }

      ll ret = 0;
      rep(K, 4) {
        chmax(ret, dp[r-1][c-1][K]);
      }
      cout << ret << endl;



    }
};

signed main() {
  EPickingGoods solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 354988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int N=2e3+5;
pii a[N];
ll dp[N][N];

void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    int n;cin>>n;
    int x;
    for(int i=1;i<=n;i++){
        cin>>x;
        a[i]=pii(x,i);
    }
    sort(a+1,a+n+1);
    for(int r=1;r<=n;r++){
        for(int l=r;l;l--){
            if(l==r) dp[l][r]=1LL*a[1].first*abs(l-a[1].second);
            else{
                int id=r-l+1;
                dp[l][r]=max(dp[l+1][r]+1LL*a[id].first*abs(a[id].second-l),
                             dp[l][r-1]+1LL*a[id].first*abs(a[id].second-r));
            }
        }
    }
    cout<<dp[1][n];
}


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


char str[20001]={};
int height[20001]={};

//conversion character strings to integer array whitch represent each height
int charToHeight(void){
    int i=0;
    int h=0;
    while(str[i]!='\0'){
        switch(str[i]){
            case '\\':
                h--;
                break;
            case '/':
                h++;
                break;
            default:
                break;
        }
        height[i+1]=h;
        i++;
    }
    return i+1;
}

//search the position which is same height of start position 
int searchSameHeight(int startposition, int size){
    int i=1;
    while(startposition+i!=size && height[startposition+i]!=height[startposition]){
        i++;
    }
    if(startposition+i==size)return -1;//no match
    int endposition=i+startposition;
    if(height[endposition-1]>height[endposition]){//mountain
        return -1;
    }else if(height[endposition-1]==height[endposition]){//flat
        return -1;
    }else{//valley
        return endposition; 
    }
}

//calculate the area
double calcArea(int startposition, int endposition){
    double area=0.0;
    for(int m=startposition;m<endposition;m++){
        if(height[m]>height[m+1]){
            area+=(double)abs(height[startposition]-height[m+1])-0.5;
        }else if(height[m]==height[m+1]){
            area+=(double)abs(height[startposition]-height[m+1]);
        }else if(height[m]<height[m+1]){
            area+=(double)abs(height[startposition]-height[m+1])+0.5;
        }
    }
    return area;
}

int main(){
    //input
    scanf("%s",str);

    int size=charToHeight();
    double area[20000]={};
    int areanum=0;
    int i=0;
    while(i<size){
        int endposition=searchSameHeight(i,size);
        if(endposition!=-1){
            area[areanum]=calcArea(i,endposition);
            areanum++;
            i=endposition;
        }else{
            i++;
        }
    }

    ll s=0;
    rep(i,areanum){
        s+=area[i];
    }
    cout<<s<<endl;
    cout<<areanum;

    rep(i,areanum){
        cout<<" "<<(ll)area[i];
    }
    cout<<endl;
}
                


Measured memory_bytes: 3404
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n;
  int a[33];
  while(cin >> n){
    if(!n) break;
    for(int i = 0; i < n; i++){
      cin >> a[i];
    }
    int p = 32;
    for(int i = 0;p; i++){
      if(i%2){
	p -= a[i/2%n];
      }else{
	p -= (p-1)%5;
      }
      p = max(0,p);
      cout << p << endl;
    }
  }
}

Measured memory_bytes: 1160
//#define _CRT_SECURE_NO_WARNINGS
//#include <bits/stdc++.h>
#include "bits/stdc++.h"

#define rep(i,n) for(long long (i)=0;(i)<(long long)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define int long long

#define PI (3.14159265358979323)
#define MOD (1000000007LL)
#define INF (1LL<<60LL)
#define MAX_N (10000001)
#define MAX (1000000000000000000LL)
using namespace std;

signed main() {
	int n, d; cin >> n >> d;
	d = d * d;
	int ans = 0;
	rep(i, n) {
		int a, b; cin >> a >> b;
		if (d >= a * a + b * b)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

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

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

	int ans = a[0];
	for(int i = 1; i < n; i++){
		ans = gcd(ans,a[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) {

    new Main().run();
  }
  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      String line = in.readLine();
      int[] ax = new int[n];
      long sum = 0;

      int m;
      int offset=0,next=0;
      char regex = ' ';
      boolean isContinue = true;
      for(int i=0; isContinue; i++) {
        if((next = line.indexOf(regex,offset)) == -1) {
          next = line.length();
          isContinue = false;
        }
        m = Integer.parseInt(line.substring(offset,next));
        ax[i] = (m -= (i+1));
        offset = ++next;
      }

      Arrays.parallelSort(ax);
      int b = ax[n/2];

      for (int i : ax) {
        sum += Math.abs(i-b);
      }

      System.out.println(sum);

    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 48756
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
typedef pair<LL, LL> P;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  LL N, Q; cin >> N >> Q;
  vector<LL> A(N); cin >> A;
  reverse(A.begin(), A.end());

  vector<LL> S(N + 1), evenS(N + 1);
  S[0] = 0, evenS[0] = 0;
  for (int i = 0; i < N; ++i) {
    S[i + 1] = S[i] + A[i];
    evenS[i + 1] = evenS[i] + (i % 2 == 0 ? A[i] : 0);
  }

  map<LL, LL> m;
  m[0] = S[(N + 1) / 2];
  for (int i = 0; i < (N-1)/2; ++i) {
    LL threshold = (A[i + 1] + A[2 * (i + 1)]) / 2 + 1;
    LL value = (S[i + 1]) + (evenS[N] - evenS[2*(i + 1)]);
    m[threshold] = value;
  }

  for (int i = 0; i < Q; ++i) {
    int x; cin >> x;
    auto it = m.upper_bound(x);
    --it;
    cout << it->second << endl;
  }
}


Measured memory_bytes: 8768
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
    int n;
    cin >> n;
    vector<ll> p(n);
    int i,j;
    int h=0;
    for(i=0;i<n;i++){
        cin>> p.at(i);
        if(p.at(i)!=(i+1))h++;
        }
    if((h==2)||(h==0))cout << "YES" << endl;
    else cout << "NO" <<endl;

    return 0;
}

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

int main(){
	bool prime[33000];
	for(long i=0; i<33000; ++i) prime[i]=true;
	prime[0]=prime[1]=false;
	
	for(long i=2; i<33000; ++i){
		if(prime[i]) for(long j=2; i*j<33000; ++j) prime[i*j]=false;
	}
	
	while(1){
		int n;
		
		scanf(" %d", &n);
		if(n==0) break;
		
		int ans=0;
		for(int i=2; i<=n/2; ++i)
			if(prime[i] && prime[n-i]) ans++;
		
		printf("%d\n", ans);
	}
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 200010

ll N, T;
ll Ts[MAX_N] = {};

signed main()
{
    cin >> N >> T;
    REP(i, N) { cin >> Ts[i]; }

    ll ans = 0;
    REP(i, N) {
        if(i != N-1) {
            ans += min(Ts[i+1]-Ts[i], T);
        } else {
            ans += T;
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
 
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
 
struct primes_ {
	vector<int> d;
	primes_(int n): d{2, 3} {
		if (n < 3) {
			if (n == 2) d = vector<int>(1, 2);
			else d.clear();
			return;
		}
		bool f = false;
		int end = 1;
		for(int i = 5; i <= n; i += (f = !f) ? 2 : 4) {
			while(d[end] * d[end] <= i) end++;
			bool isprime = true;
			for(int k = 0; k < end; k++) {
				if (i % d[k] == 0) {
					isprime = false;
					break;
				}
			}
			if (isprime) d.push_back(i);
		}
	}
	auto begin() {return d.begin();}
	auto end() {return d.end();}
} primes(1000000);
 
int main() {
    int n;
    cin >> n;
    VI a(n), d(1e6 + 1);
    rep(i, n) {
        cin >> a[i];
        d[a[i]] += 1;
    }
    bool pc = true;
    for(int p: primes) {
        int cnt = 0;
        for(int now = p; now <= 1e6; now += p) {
            cnt += d[now];
        }
        if (cnt >= 2) {
            pc = false;
            break;
        }
    }
    if (pc) {
        cout << "pairwise coprime" << endl;
    } else {
        int g = 0;
        rep(i, n) g = gcd(g, a[i]);
        if (g == 1) cout << "setwise coprime" << endl;
        else cout << "not coprime" << endl;
    }
}

Measured memory_bytes: 11332
n = int(input())
v = input().split()

even_dict = {'dummy':0}
odd_dict = {'dummy':0}

for x in list(set(v)):
	even_dict[x] = 0
	odd_dict[x] = 0

for i in range(n):
	x = v[i]
	if(i % 2 == 0):
		odd_dict[x] += 1
	else:
		even_dict[x] += 1

even_sort = sorted(even_dict.items(), key=lambda x:x[1], reverse=True)
odd_sort = sorted(odd_dict.items(), key=lambda x:x[1], reverse=True)

if( even_sort[0][0] != odd_sort[0][0] ):
	ans =  n - even_sort[0][1] - odd_sort[0][1]
else:
	ans = min(n - even_sort[1][1] - odd_sort[0][1],
			 n - even_sort[0][1] - odd_sort[1][1])

print(ans)

Measured memory_bytes: 37292
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1000000007LL;
const int Maxn = 25e6 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

ll a[Maxn], p[Maxn];

ll dp1[Maxn], dp2[Maxn];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	ll ga, sa, ba;
	cin >> ga >> sa >> ba;
	ll gb, sb, bb;
	cin >> gb >> sb >> bb;
	for(int i = 1; i < Maxn; i++){
		dp1[i] = dp1[i - 1] + 1;
		if(i >= ga) dp1[i] = max(dp1[i], dp1[i - ga] + gb);
		if(i >= sa) dp1[i] = max(dp1[i], dp1[i - sa] + sb);
		if(i >= ba) dp1[i] = max(dp1[i], dp1[i - ba] + bb);
		
		dp2[i] = dp2[i - 1] + 1;
		if(i >= gb) dp2[i] = max(dp2[i], dp2[i - gb] + ga);
		if(i >= sb) dp2[i] = max(dp2[i], dp2[i - sb] + sa);
		if(i >= bb) dp2[i] = max(dp2[i], dp2[i - bb] + ba);
	}
	
	cout << dp2[dp1[n]];
	return 0;
}
/*
1
5 1
20 21 22 23 24

1
4 2 
1 2 3 4

2 4 1 3

*/


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

int main(){
  int t[100000];
  int n;
  cin >> n;
  
  int max,i;
  max=0;
  int a[1000000];
  for(i=0;i<n;i++){
     cin >> a[i];
    if(a[i]>max){
      max = a[i];
    }
    t[i]=a[i];
  }
  
  int h,x,p;
  double s;
  x=10000000000000;
    
  for(h=0;h<n;h++){
    if ( t[h]==max ) {
      continue;
    }
    s=abs(t[h]-max/2);
    if ( s<x ){
      x=s;
      p=t[h];
    }
  }
  
  cout << max << " " << p << endl;
  
}



Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;

int main() {
  int n, i;
  cin >> n >> i;
  cout << n - i + 1<< endl;
}


Measured memory_bytes: 256
import sys
from array import array

def main():
	while True:
		m = input()
		if m == 0: return 0
		dp = [array('I', [0] * 1001) for i in range(m + 1)]
		dp[0][0] = 1
		for i in xrange(m):
			v, c = map(int, raw_input().split())
			for j in xrange(1001):
				for k in xrange(c + 1):
					next = j + v * k
					if next > 1000: continue
					dp[i + 1][next] += dp[i][j]
		n = input()
		for i in range(n):
			x = input()
			print dp[m][x]

if __name__ == '__main__':
	sys.exit(main())

Measured memory_bytes: 4472
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t n;
    cin >> n;

    vector<pair<pair<int64_t, int64_t>, int64_t>> lr(n);
    for (auto idx : irange(0L, n)) {
        lr[idx].second = idx;
        auto& t = lr[idx].first;
        cin >> t.first >> t.second;
    }

    if (n == 2) {
        std::cout << (lr[0].first.second - lr[0].first.first + 1) +
                             (lr[1].first.second - lr[1].first.first + 1)
                  << endl;
        return 0;
    }

    int64_t ans = 0;

    auto it1 = max_element(
            lr.begin(), lr.end(), [&](const auto& lr1, const auto& lr2) {
                return make_tuple(lr1.first.first, -lr1.first.second) <
                       make_tuple(lr2.first.first, -lr2.first.second);
            });
    int64_t maxL = it1->first.first;
    int64_t maxL_idx = it1->second;

    auto it2 = min_element(
            lr.begin(), lr.end(), [&](const auto& lr1, const auto& lr2) {
                return make_tuple(lr1.first.second, -lr1.first.first) <
                       make_tuple(lr2.first.second, -lr2.first.first);
            });
    int64_t minR = it2->first.second;
    int64_t minR_idx = it2->second;

    int64_t longest = 0;
    for (const auto& t : lr) {
        if (t.second == maxL_idx || t.second == minR_idx) {
            continue;
        }

        longest = max(longest, t.first.second - t.first.first + 1);
    }

    ans = max(minR - maxL + 1, 0L) + longest;

    sort(lr.rbegin(), lr.rend());

    int64_t currentR = lr[0].first.second;
    for (auto i : irange(1L, n)) {
        ans = max(ans, std::max(currentR - maxL + 1, 0L) +
                               std::max(minR - lr[i].first.first + 1, 0L));
        if (lr[i].first.second == minR) {
            break;
        }
        currentR = min(currentR, lr[i].first.second);
    }

    std::cout << ans << endl;
}

Measured memory_bytes: 2688
N,Q = map(int,input().split())
T = [0]*(N+1)
V = [0]*(N+1)
for _ in range(N-1):
    a,b = map(int,input().split())
    T[b] = a
for _ in range(Q):
    p,x = map(int,input().split())
    V[p]+=x
for i in range(1,N+1):
    V[i]+=V[T[i]]
print(*V[1:])

Measured memory_bytes: 66008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[10010];
int main() {
	int n, mod;
	ll ans = 0;
	string s;
	cin >> n >> mod >> s;
	if(mod == 2 || mod == 5) {
		for(int i = 0; i < n; i++) {
			if((s[i] - '0') % mod == 0) ans += i + 1;
		}
	}
	else {
		int res = 0, t = 1;
		a[0] = 1ll;
		for(int i = n - 1; i >= 0; i--) {
			res = (res + (s[i] - '0') * t) % mod;
			ans += a[res]++;
			t = t * 10 % mod;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 644
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
const int N=200;
struct dat{
    int x,y;
    dat(){}
    dat(int x,int y):
        x(x),y(y){}
    bool operator < (const dat &r) const
    {
        return y>r.y;
    }
};
int n;
int a[N];
char s[N],ch[N],ans[N][N],tem[N];
priority_queue<dat> q;
int main()
{
    setbuf(stdout,NULL);
    for(int k=1;k<=26;k++)
        ch[k]='a'+k-1;
    for(int k=1;k<=26;k++)
        ch[k+26]='A'+k-1;
    for(int k=0;k<=9;k++)
        ch[k+53]='0'+k;
    for(int k=1;k<=62;k++)
    {
        for(int i=1;i<=128;i++)
            s[i]=ch[k];
        s[129]='\0';
        printf("? %s\n",s+1);
        scanf("%d",&a[k]);
        a[k]=128-a[k];
        n+=a[k];
        if(a[k]) q.push(dat(k,a[k]));
    }
    for(int k=1;k<=62;k++)
        for(int i=1;i<=a[k];i++)
            ans[k][i]=ch[k];
    while(q.empty()==0)
    {
        int x=q.top().x;
        q.pop();
        if(q.empty())
        {
            ans[x][a[x]+1]='\0';
            printf("! %s\n",ans[x]+1);
            break;
        }
        int y=q.top().x;
        q.pop();
        int u=1,v=1,cnt=0;
        while(u<=a[x]&&v<=a[y])
        {
            int cntt=0;
            for(int k=1;k<=cnt;k++)
                s[++cntt]=tem[k];
            s[++cntt]=ans[y][v];
            for(int k=u;k<=a[x];k++)
                s[++cntt]=ans[x][k];
            s[cntt+1]='\0';
            printf("? %s\n",s+1);
            int w;
            scanf("%d",&w);
            if(w>n-cntt) tem[++cnt]=ans[x][u++];
            else tem[++cnt]=ans[y][v++];
        }
        while(u<=a[x]) tem[++cnt]=ans[x][u++];
        while(v<=a[y]) tem[++cnt]=ans[y][v++];
        for(int k=1;k<=cnt;k++)
            ans[x][k]=tem[k];
        a[x]=cnt;
        q.push(dat(x,a[x]));
    }
    return 0;
}


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

int cost( string a, string b)
{
	int i;
	int cnt = 0;
	for(i=0;i<a.size();i++)
	{
		if(a[i]!=b[i])
			cnt++;
	}
	return cnt;
}
int main()
{
	int i,j,k,n;
	string S,T;
	cin >> S >> T;
	
	int ans = T.size();
	map<string, int> mp;
	for(i=0;i<=S.size(); i++)
	{
			if(T.size()+i <= S.size())
				ans = min(ans,cost(S.substr(i,T.size()),T));
	}
	
	cout<<ans<<endl;
		
	return 0;
}



Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main(){
    string str;
    while(cin >> str,str!="0"){
        int n=str.size();
        int D[n];
        for(int i=0;i<n;i++){
            D[i]=((i&1)==1?-1:1)*(str[i]-'0');
        }
        int C[n]; fill(C,C+n,0);
        for(int i=0;i<n;i++){
            int sum=0;
            if(D[i]==0&&(i>0?C[i-1]:0)==0)continue;
            for(int j=i;j<n;j++){
                sum+=D[j];
                sum%=11;
                if(!sum){
                    if(D[i]==0){
                        C[j]+=(i>0?C[i-1]:0);
                    }else{
                        C[j]+=1+(i>0?C[i-1]:0);
                    }
                    break;
                }
            }
        }
        int count=0;
        for(auto& c:C)count+=c;
        cout << count << endl;
    }
    return 0;
}

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

using namespace std;

//#define double long double

typedef pair<int,int> ii;
typedef pair<int,long long> il;
typedef pair<long long,long long> ll;
typedef pair<ll,int> lli;
typedef pair<long long,int> li;
typedef pair<double,double> dd;
typedef pair<ii,int> iii;
typedef pair<double,int> di;
typedef pair<int,ii> iii2;
typedef pair<ii,ii> iiii;
long long mod = 1000000007LL;
long long large = 2000000000000000000LL;



int main(){

	int n;
	cin>>n;
	vector<int> cnt(26,0);
	string s;
	cin>>s;
	for(int i=0;i<n;i++){
		cnt[(int)(s[i]-'a')]++;
	}

	long long ans = 1;
	for(int i=0;i<26;i++){
		ans*=1LL*(cnt[i]+1);
		ans%=mod;
	}
	cout<<ans-1<<endl;



	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#include<bits/stdc++.h>
#pragma GCC optimize(2)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define Mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define maxn 100000 * 2 + 10
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    if(m > n / 2)
        cout<<0<<endl;
    else
    {
        int mid = n - 2*m;
        cout<<mid<<endl;
    }
}


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

int main2(), main();
int getDigit(long long ll) {
	if (ll == 0) return 0;
	return getDigit(ll / 10) + 1;
}

int main() {
	int i, j, n, m, k, q;
	//cin >> n;
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c && c <= b) cout << "Yes" << endl;
	else cout << "No" << endl;

}


Measured memory_bytes: 256
#include<cstdlib>
#include<cstdio>
#include<iostream>
#include<vector>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <map>

using namespace std;


int main() {
    int a,b;
    cin >> a >> b;
    cout << max(max(a+b, a-b), a*b) << endl;
    return 0;
}


Measured memory_bytes: 256
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine
    

main = do
    (a, p) <- readTuple2
    print $ (a * 3 + p) `div` 2



Measured memory_bytes: 380
n = gets.to_i
a = gets.split.map &:to_i

last_index = [nil] * 20
count = 0
min_distance = 0
a.each_with_index do |ai, i|
    #ビットがぶつかる場所との距離を測る
    20.times do |j|
        if ai[j] == 1
            #まだ初回にうまったビット
            if last_index[j] == nil
            else #ビットがぶつかった時
                distance = i - last_index[j] - 1
                min_distance = [distance, min_distance].min
            end
            last_index[j] = i
        end
    end
    count += min_distance
    min_distance += 1
end
puts count + n

Measured memory_bytes: 20740
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string s = to_string(N);
  int S = 0;
  for (int i = 0; i < s.size(); i++) S += s[i] - '0';
  cout << (N % S == 0 ? "Yes" : "No");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int sum = 0;
		String s = scan.next();
		if(s.substring(0, 1).equals("1")) {
			sum++;
		}
		if(s.substring(1, 2).equals("1")) {
			sum++;
		}
		if(s.substring(2, 3).equals("1")) {
			sum++;
		}
		System.out.println(sum);
		scan.close();

	}

}


Measured memory_bytes: 22608
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
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};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, m, y, p, res[100100], res2[100100];
vector<pair<int,int> > v[100100];

signed main() {
	cin >> n >> m;
	rep(i,m) {
		cin >> p >> y;
		v[p].push_back({y,i});
	}
	rep(i,100100) if (!v[i].empty()) {
		sort(all(v[i]));
		int m = v[i].size();
		rep(j,m) res[v[i][j].second] = i, res2[v[i][j].second] = j+1;
	}
	rep(i,m) printf("%06d%06d\n",res[i],res2[i]);
}


Measured memory_bytes: 8576
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

from functools import lru_cache

A, B, C, X, Y = map(int, input().split())

ans = INF
for i in range((10**5)+1):
    tmp = i * 2 * C
    if X - i > 0:
        tmp += (X - i) * A
    if Y - i > 0:
        tmp += (Y - i) * B
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 9496
INF = 10 ** 10
n, m = gets.split.map(&:to_i)
bin_memo = [1]
1.upto(n - 1) do |i|
  bin_memo[i] = bin_memo[i - 1] * 2
end
costs = []
keys = []
m.times do
  costs << gets.to_i
  keys << gets.split.map(&:to_i).inject(0) { |res, num| res | bin_memo[num - 1] }
end
dp = Array.new(2 ** n, INF)
dp[0] = 0
keys.each_with_index do |key, i|
  dp.each_with_index do |cost, opened|
    next if cost == INF
    next_opened = (opened | key)
    dp[next_opened] = cost + costs[i] if dp[next_opened] > cost + costs[i]
  end
end
puts dp.last == INF ? - 1 : dp.last


Measured memory_bytes: 3836
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        while(true){
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        if(h == 0 && w == 0){
            break;
        }
        int[][] yard = new int[h][w];
        int max = 0;
        int cap = 0;
        int lakemax = 0;
        int yardmin = 10;
        int flag = 0;
        int cap1 = 0;
        for(int i = 0;i<h;i++){
            for(int j = 0;j<w;j++){
                yard[i][j] = scanner.nextInt();
            }
        }

        for(int i = 3;i <= h;i++){
            for(int j = 3;j<=w;j++){
                for(int h_start = 0;h_start<=h-i;h_start++){
                    for(int w_start = 0;w_start<=w-j;w_start++){
                        for(int h_yardsearch = h_start;h_yardsearch<h_start+i;h_yardsearch++){
                            for(int w_yardsearch = w_start;w_yardsearch<w_start+j;w_yardsearch++){
                                if(h_yardsearch != h_start && h_yardsearch != h_start+i-1){
                                    yardmin = yardmin>yard[h_yardsearch][w_yardsearch]?yard[h_yardsearch][w_yardsearch]:yardmin;
                                    yardmin = yardmin>yard[h_yardsearch][w_yardsearch+j-1]?yard[h_yardsearch][w_yardsearch+j-1]:yardmin;
                                    break;
                                }
                                yardmin = yardmin>yard[h_yardsearch][w_yardsearch]?yard[h_yardsearch][w_yardsearch]:yardmin;
                                
                            }
                        }
                        for(int h_lakesearch = h_start+1;h_lakesearch<h_start+i-1;h_lakesearch++){
                            for(int w_lakesearch = w_start+1;w_lakesearch<w_start+j-1;w_lakesearch++){
                                cap1 = yardmin-yard[h_lakesearch][w_lakesearch];
                                if(cap1<=0){
                                    flag = 1;
                                    break;
                                }else{
                                    cap += cap1;
                                }
                            }
                            if(flag == 1){
                                break;
                            }
                        }
                        if(flag ==1){
                        }else{
                            max = max<cap?cap:max;
                        }
                        cap = 0;
                        flag = 0;
                        yardmin = 10;
                    }
                }
            }
        }

        System.out.println(max);
    }
    }
}


Measured memory_bytes: 36788
a1,b1 = map(int,input().split())
a2,b2 = map(int,input().split())
a3,b3 = map(int,input().split())

li = []
li.append(a1)
li.append(a2)
li.append(a3)
li.append(b1)
li.append(b2)
li.append(b3)

if li.count(1)>=3 or li.count(2)>=3 or li.count(3)>=3 or li.count(4)>=3:
  print("NO")
else:
  print("YES")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

/**
* Binary_Indexed_Tree(BIT)
* Fenwick Tree
* 1-indexed!!!
*/
template<typename T = int>
class BIT {
private:
    std::vector<T> bit;
    const int N;
public:
    BIT() : N(-1) {}
    BIT(int n) : N(n), bit(n + 1, 0) {}
    //bit[point]にnum追加
    void add(int point, T num) {
        assert(N != -1 && 0 <= point && point <= N);
        while (point <= N) {
            bit[point] += num;
            point += point & -point;
        }
    }
    //pointまでの値の和を返す
    T sum(int point) {
        assert(N != -1 && 0 <= point && point <= N);
        T res = 0;
        while (point > 0) {
            res += bit[point];
            point -= point & -point;
        }
        return res;
    }
    //left から right の区間和
    T sum(int left, int right) {
        return this->sum(right) - this->sum(left - 1);
    }
};

const int MAX = 3 * 1e5 + 10;
int N, M;
int l[MAX], r[MAX];
BIT<int> bit(MAX);
vector<int> v[MAX];

int main(void) {
    scanf("%d%d", &N, &M);
    REP(i, N) {
        scanf("%d%d", l + i, r + i);
        v[r[i] - l[i] + 1].EB(i);
    }
    int worst = N;//取れる数の最低数
    FOR(d, 1, M + 1) {
        FORE(e, v[d - 1]) {
            bit.add(l[e], 1);
            bit.add(r[e] + 1, -1);
            worst--;
        }
        int ans = worst;
        for (int i = d; i <= M; i += d) {
            ans += bit.sum(i);
        }
        printf("%d\n", ans);
    }
}


Measured memory_bytes: 14592
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LS()
    if a == b:
        print("H")
    else:
        print("D")
    return

#B
def B():
    w, a, b = LI()
    a, b = min(a, b), max(a, b)
    if w + a >= b:
        print(0)
        return
    print(b-a-w)
    return

#C
def C():
    n = II()
    x = 0
    for i in range(1, 10 ** 5):
        x += i
        if n <= x:
            print(i)
            return
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 38640
#include<bits/stdc++.h>
using namespace std;
#define IO {ios_base::sync_with_stdio(false); cin.tie(0);}
#define ll long long
#define pi pair<ll,ll>
ll a[300008], b[400000], c[3][300];
string s, s1;
map<ll, ll>mp;

int main()
{
    IO;
    ll i, j, k=0, l, n, m, t, h, cnt=0, curr, mx=0;
    cin>>n; cout<<n+n*n+n*n*n<<endl;
    return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
#include<stdlib.h>
int main(){
	int N,d[100],a[100],temp,count=1,i,j;
	scanf("%d",&N);
	for( i = 0;i < N;i++){
		scanf("%d",&d[i]);
	}
	for (i = 0; i < (N - 1); i++) {
    for (j = (N - 1); j > i; j--) {
      if (d[j-1] < d[j]) {
        temp = d[j-1];
        d[j-1] = d[j];
        d[j] = temp;
      }
    }
  }
	for(i = 1;i < N;i++){
		if(d[i] != d[i-1]){
			count++;
		}
	}
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

unsigned gcd(unsigned a, unsigned b) {
    if (a < b) return gcd(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}


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

    ll n, x;
    cin >> n >> x;
    vector<ll> pos;
    pos.push_back(x);
    REP(i, n) {
        ll input;
        cin >> input;
        pos.push_back(input);
    }
    ll min_pos = *min_element(ALL(pos));
    REP(i, n + 1) {
        pos[i] -= min_pos;
    }
    sort(ALL(pos));

    // この段階で各位置が昇順に並んでいる
    // 最初の値は0
    ll ans = pos[1];
    FOR(i, 2, n+1) {
        ans = gcd(ans, pos[i]);
    }
    P(ans);

    return 0;
}


Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt();

        for (int i = 1; i <= N; i++) {
            if ((int) (i * 1.08) == N) {
                System.out.println(i);
                return;
            }
        }

        System.out.println(":(");
    }
}

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

c1 = [0, 0] # corner 1
c2 = [W, H] # corner 2

while(N):
    x, y, a = map(int, input().split())
    if a == 1:
        if c1[0] < x:
            c1[0] = x
    elif a == 2:
        if c2[0] > x:
            c2[0] = x
    elif a == 3:
        if c1[1] < y:
            c1[1] = y
    else:
        if c2[1] > y:
            c2[1] = y
            
    N = N - 1

if (c2[0] - c1[0]) >= 0 and (c2[1] - c1[1]) >= 0:
    S = (c2[0] - c1[0]) * (c2[1] - c1[1])
    print(S)
else:
    print(0)

Measured memory_bytes: 3064