akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

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

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF = 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();
LL ave(LL, LL);

int main() {
	string n; cin >> n;
	if (n[0] == n[1]&&n[1] == n[2])coutY();
	else if (n[1] == n[2]&&n[2] == n[3])coutY();
	else coutN();
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}
LL ave(LL a, LL b) {
	return (a + b) / 2;
}

Measured memory_bytes: 256
// Jump, and you will find out how to unfold your wings as you fall.

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn=25010,maxk=410,mod=1e9+7;

int dp[maxn][maxk],smd[maxn][maxk],sm[maxk],a[maxn],lst[maxk],pw[maxn],fac[maxk];

int solve1(int n,int m,int k){
    int ans=0;
    for(int A=0,B=n-m;B>=0;A++,B--){
	int spe=0;
	while(B>=0 && n-A-B<k){
	    int num=dp[A][n-A-B];
	    if(B>0) num=1ll*num*smd[B-1][n-A-B] %mod;
	    spe=(1ll*spe+1ll*fac[n-A-B-1]*num)%mod;
	    B--;
	}
	ans=(ans+pw[n-m]-spe)%mod;
	B=n-m-A;	 
    }
    return ans;
}
int solve2(int n,int m,int k,int l1,int l2){
    int ans=0;
    for(int A=0,B=n-m;B>=0;A++,B--){
	ans=(1ll*ans+1ll*pw[n-m]-1ll*dp[A][l1]*dp[B][l2])%mod;
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n,k,m;cin>>n>>k>>m;
    for(int i=1;i<=m;i++){
	cin>>a[i];
    }
    for(int i=1;i<k;i++){
	dp[0][i]=1;
	smd[0][i]=i;
    }
    for(int i=1;i<maxn;i++){
	for(int j=1;j<k;j++)
	    sm[j]=(sm[j-1]+dp[i-1][j])%mod;
	for(int j=1;j<k;j++)
	    dp[i][j]=( 1ll*(k-j)*dp[i-1][j+1] + 1ll*sm[j] )%mod;
	for(int j=1;j<k;j++)
	    smd[i][j]=(smd[i][j-1]+dp[i][j])%mod;
    }
    pw[0]=1;
    for(int i=1;i<maxn;i++){
	pw[i]=1ll*pw[i-1]*k %mod;
    }
    fac[m-1]=1;
    for(int i=m;i<k;i++){
	fac[i]=1ll*fac[i-1]*(k-i) %mod;
    }
    
    int L1=m,L2=1;
    bool is=0;
    memset(lst,-1,sizeof lst);
    for(int i=1;i<=m;i++){
	if(lst[a[i]]!=-1)
	    L2=max(L2,lst[a[i]]+1);
	is|= i-L2+1==k;
	lst[a[i]]=i;
    }
    memset(lst,-1,sizeof lst);
    for(int i=m;i>=1;i--){
	if(lst[a[i]]!=-1)
	    L1=min(L1,lst[a[i]]-1);
	lst[a[i]]=i;
    }
    int ANS=0;
    if(is) ANS=1ll*pw[n-m]*(n-m+1) %mod;
    else if(L2==1) ANS=solve1(n,m,k);
    else ANS=solve2(n,m,k,L1,m-L2+1);
    if(ANS<0) ANS+=mod;
    return cout<<ANS<<endl,0;
}
// Deathly mistakes:
//  * Read the problem curfully.
//  * Check maxn.
//  * Overflows.


Measured memory_bytes: 80640
#include <bits/stdc++.h>
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef long long int64;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
template<class T,class U>bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>void vcin(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cill(n);
    LL i = 1;
    LL ans = LLINF;
    while(i * i <= n){
        if (n % i == 0){
            ans = min(ans, i + n / i - 2);
        }
        i++;
    }
    co(ans);
    return 0;
}

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

using namespace std;

int main()
{
  int X, K, Q;
  int R[100001];


  scanf("%d %d", &X, &K);
  for(int i = 1; i <= K; i++) scanf("%d", &R[i]);
  scanf("%d", &Q);

  R[0] = 0;
  R[K + 1] = 1 << 30;

  int tail = 1;
  int low = 0, high = X;
  int latte = 0, malta = X;

  while(Q--) {
    int T, A;
    scanf("%d %d", &T, &A);
    while(R[tail] <= T) {
      auto beet = R[tail] - R[tail - 1];
      auto delta = beet * (tail % 2 == 0 ? 1 : -1);
      if(tail % 2 == 0) high -= max(0, malta + delta - X);
      else low += max(0, -(latte + delta));
      latte = min(X, max(0, latte + delta));
      malta = min(X, max(0, malta + delta));
      ++tail;
    }
    auto beet = T - R[tail - 1];
    auto delta = beet * (tail % 2 == 0 ? 1 : -1);
    if(low <= A && A <= high) printf("%d\n", min(X, max(0, latte + delta + (A - low))));
    else if(A < low) printf("%d\n", min(X, max(0, latte + delta)));
    else printf("%d\n", min(X, max(0, malta + delta)));
  }

}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //ATTENTION: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/
int n,m;
/**********************************/

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

    cout << (n-1)*(m-1) << endl;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//なにもわからない

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 19;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[4];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint(), M = getint(), L = getint();
	int C[300][300];
	rep(j, N) rep(i, j) C[i][j] = 1e9 + 1;
	rep(i, M) {
		int a = getint(), b = getint(), c = getint();
		C[--a][--b] = c;
		C[b][a] = c;
	}

	rep(k, N) {
		rep(j, k) {
			rep(i, j) {
				chmin(C[i][j], C[i][k] + C[j][k]);
			}
		}
		for (int j = k + 1; j < N; j++) {
			rep(i, k) {
				chmin(C[i][j], C[i][k] + C[k][j]);
			}
			for (int i = k + 1; i < j; i++) {
				chmin(C[i][j], C[k][i] + C[k][j]);
			}
		}
	}

	rep(j, N) rep(i, j) {
		C[i][j] = (C[i][j] <= L) ? 1 : 1e9;
	}

	rep(k, N) {
		rep(j, k) {
			rep(i, j) {
				chmin(C[i][j], C[i][k] + C[j][k]);
			}
		}
		for (int j = k + 1; j < N; j++) {
			rep(i, k) {
				chmin(C[i][j], C[i][k] + C[k][j]);
			}
			for (int i = k + 1; i < j; i++) {
				chmin(C[i][j], C[k][i] + C[k][j]);
			}
		}
	}

	int Q = getint();
	rep(i, Q) {
		int s = getint(), t = getint();
		if (--s > --t) swap(s, t);
		if (C[s][t] == 1) {
			*di++ = '0';
			*di++ = '\n';
		}
		else if (C[s][t] < 1e9) putint(C[s][t] - 1);
		else {
			*di++ = '-';
			*di++ = '1';
			*di++ = '\n';
		}
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 1152
package main

import (
	"fmt"
	"os"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	mod := 2019

	if a*b < mod {
		fmt.Println(a * b)
		os.Exit(0)
	} else if a*b%mod == 0 {
		fmt.Println(0)
		os.Exit(0)
	}

	res := 2019
	for i := a; i <= b-1; i++ {
		for j := i + 1; j <= b; j++ {
			if m := i * j % mod; m < res {
				res = m
			}
			if res == 0 {
				break
			}
		}
		if res == 0 {
			break
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<(k) ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=(k) ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef jayinnn
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const ll MAXN = 100005;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();
    unsigned long long n, a, b;
    cin >> n >> b >> a;
    unsigned long long ans = 0;
    ans += (n / (a + b)) * b;
    ans += min(n % (a + b), b);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n =int(input())
limit = 10**18
re =1
 
l = list(map(int, input().split()))
 
l.sort()
#print(l)
if(l[0] == 0):
    re = 0
else:
  for i in l:
    re *= i
    #print(re)
    if(re > limit):
      re = -1
      break
print(re)

Measured memory_bytes: 21784
#include<iostream> A
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 100010;
const LL INF = 9187201950435737471;

int N; int a[MAXN+1],pos[MAXN+1];
LL f[5010][5010]; LL A,B;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(); A=read(),B=read();
	memset(f,127,sizeof(f)); 
	for(int i=1;i<=N;i++) a[i]=read(),pos[a[i]]=i;
	f[0][0]=0; LL ans=INF;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(f[i][j]==INF) continue;
			f[i][j+1]=min(f[i][j+1],(pos[j+1]<=i?0:B)+f[i][j]);
		}
		for(int j=0;j<=N;j++){
			if(f[i][j]==INF) continue;
			if(j+1==a[i+1]){
				f[i+1][j+1]=min(f[i][j],f[i+1][j+1]);
			} else if(j<a[i+1]){
				f[i+1][j]=min(f[i][j]+A,f[i+1][j]);
			} else{
				f[i+1][j]=min(f[i][j],f[i+1][j]);
			}
		} 
	} for(int i=0;i<=N;i++) ans=min(ans,f[N][i]);
	printf("%lld\n",ans);
	return 0;
}




Measured memory_bytes: 199888
import sys
input = sys.stdin.readline

n, a, b = map(int, input().split())

if (b - a) % 2 == 0:
  ans = (b - a) // 2
  
elif (b - 1) < (n - a):
  ans = a + (b - a - 1) // 2
  
else:
  ans = n - b + 1 + abs(a - b + 1) // 2

print(ans)


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

#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define int long long

using namespace std;
const int INF = 2e9;
const int MB = 30;
const int MOD = 1e9 + 7;

/*
2q 4w
q + w = x
2q + 2w = 2x
2q + 4w = y

2w = y - 2x
*/

void solve() {
	int x, y;
	cin >> x >> y;
	int one = y - 2 * x;
	int w = one / 2;
	if (one < 0 || one % 2 || x - w < 0) {
		cout << "No";
		return;
	}
	cout << "Yes";
	
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	srand(time(0));
	int t = 1;
	//int t;
	//cin >> t;
	while (t--) solve();
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int[] x = new int[N];
		for(int i = 0; i < N; i++)
			x[i] = Math.abs(X - sc.nextInt());
		
		int min = x[0];
		for(int i = 1; i < N; i++) {
			int a = x[0];
			int b = x[i];
			int r;
			while((r = a % b) != 0) {
				a = b;
				b = r;
			}
			if(min > b)
				min = b;
			
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 48432
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define mp make_pair
#define pb push_back
#define pf push_fron
#define INF 1000000000
typedef long long ll;

ll a[200010], b[200010], ad[200010], bd[200010];

int main() {
	
	int n;
	ll ans = 0;
	cin >> n;

	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++)cin >> b[i];
	
	for (int i = 0; i <= 30; i++) {
		ll T = 1;
		for (int k = 0; k < i; k++) T *= 2;
		for (int i = 0; i < n; i++) {
			ad[i] = a[i] % (2*T);
			bd[i] = b[i] % (2*T);
		}

		sort(bd, bd + n);

		ll cnt = 0;
		for (int i = 0; i < n; i++) {//a固定
			ll *pf,*ps, *pt;
			int idxf,idxs,idxt;

			ps = lower_bound(bd, bd + n, T - ad[i]);
			pt = lower_bound(bd, bd + n, 2 * T -ad[i]);
			idxs = distance(bd, ps);
			idxt = distance(bd, pt);
			cnt += idxt - idxs;

			pf = lower_bound(bd, bd + n, 3 * T - ad[i]);
			idxf = distance(bd, pf);
			cnt += n - idxf;
		}

		if (cnt % 2 == 1) ans += T;
	}

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

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;

int main() {
    int c1, c5, c10, c50, c100, c500;
    cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
    int sum = c1 + c5*5 + c10*10 + c50*50 + c100*100 + c500*500;
    cout << (1000 <= sum ? 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cmath>
#include <vector>


using namespace std;



int main()
{
	int N;
	cin >> N;
	vector<vector<pair<int,int>>> V;
	vector<int> A(N,0);
	for (int i = 0;i < N;i++) {
		cin >> A[i];
		vector<pair<int, int>> tmpV;
		for (int j = 0;j < A[i];j++) {
			int tmp1, tmp2;
			cin >> tmp1 >> tmp2;
			tmpV.push_back(make_pair(tmp1, tmp2));
		}
		V.push_back(tmpV);
	}

	int max = 0;

	//Nビットの数を設定して、1ならば対応する人間は正直者、
	//0ならば不親切な人と仮定して、矛盾するかどうかを見る。
	for (int bit = 0;bit < (1 << N);bit++) {
		//矛盾しているかどうかのフラグ
		bool flag = true;
		//矛盾していなかった場合に正直者を数えるためのカウンター
		int count = 0;
		for (int i = 0;i < N;i++) {
			//i番目の人間を正直者と仮定したか、不親切な人と仮定したかどうかを取り出す。
			bool choice1 = bit & (1 << i);
			//不親切な人と仮定していた場合は何もしない。
			if (choice1) {
				count++;
				//証言についてみていく。
				for (int j = 0;j < V[i].size();j++) {
					//証言された人間を何と設定したかを見て、矛盾しているかどうかを見る。
					//正直者と証言されていて正直者と設定している場合と、
					//不親切な人と証言されていて不親切な人と証言している場合はOK
					bool choice2 = bit & (1 << (V[i][j].first-1));
					if ((choice2 == true && V[i][j].second == 0) || (choice2==false && V[i][j].second==1)) {
						flag = false;
					}
				}
			}
		}
		if (flag) {
			max = std::fmax(max, count);
		}
	}

	cout << max << endl;

	return 0;
}



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

#define iFOR(idx, from, upto) for (int  idx = from; idx < upto; ++idx)
#define lFOR(idx, from, upto) for (long idx = from; idx < upto; ++idx)

#define ll long long
#define ull unsigned long long

using namespace std;

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

    vector<unsigned int> a(n);
    vector<unsigned long> counter(n+1);
    unsigned int tmp;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        a[i] = tmp;
        counter[tmp]++;
    }

    ull sum = 0;

    // 先に合計を求めてしまえ
    for (int i = 0; i < n+1; i++) {
        sum += counter[i] * (counter[i] - 1) / 2;
    }

    // nC2 - n-1C2 = n-1
    for (int i = 0; i < n; i++) {
        cout << sum - (counter[a[i]] - 1) << endl;
    }

    return 0;
}


Measured memory_bytes: 4992
n = int(input())
s = list(input())

A_index = [i for i, x in enumerate(s) if x == 'A']

count = 0
for j in A_index :
  if j != n-1 :
    if s[j+1] == 'B' :
      if j != n-2 :
        if s[j+2] == 'C' :
          count += 1

print(count)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

ll n, c;

vl v, x, rv, rx;
vl pv;
vl prv;

ll solve(vl v, vl x, vl rv, vl rx) {
	vl pv(n+1);
	vl prv(n+1);
	rep(i,1,n+1) {
		pv[i] = pv[i-1] + v[i];
		prv[i] = prv[i-1] + rv[i];
	}
	rep(i,1,n+1) {
		prv[i] -= rx[i];
	}
	rep(i,1,n+1) {
		prv[i] = max(prv[i],prv[i-1]);
	}
	ll ret = 0;
	for(int i=0; i<=n; ++i) {
		ll A = max(pv[i] - x[i],0LL);
		int j = n-i;
		ll B = max(prv[j] - x[i],0LL);
		ret = max(ret, A+B);
	}
	return ret;
}

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> n >> c;
	//c /= 1e8;
	v.resize(n+1);
	x.resize(n+1);
	rep(i,1,n+1) {
		cin >> x[i] >> v[i];
		//x[i] /= 1e8;
		//v[i] /= 1e8;
	}
	rv.resize(n+1);
	rx.resize(n+1);
	rep(i,1,n+1) {
		rx[i] = c - x[n+1-i];
		rv[i] = v[n+1-i];
	}
	ll ret = solve(v, x, rv, rx);
	ret = max(ret, solve(rv,rx,v,x));
	cout << ret << '\n';
	return 0;
}


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

int main(){
  int N;
	cin >> N;
	long long L[100];
	L[0] = 2;
	L[1] = 1;
	for(int i=2;i<=N;i++){
		L[i] = L[i-1] + L[i-2];
	}
  cout << L[N] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    lli cnt = 0;
    for (int i = 0; i <= N; i++)
    {
        for (int j = 0; j <= N; j++)
        {
            /*for (int k = 0; k <= N; k++)
            {
                */
            int k = (int)((N - R * i - G * j) / B);
            if (R * i + G * j + B * k == N && k >= 0)
            {
                cnt++;
            } /*
            }*/
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll Nagaemon1;
void swap(ll i,ll j){
  Nagaemon1=i;
  i=j;
  j=Nagaemon1;
}
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main(void){
  ll n;
  cin >> n;
  n--;
  ll e=26,k=0;
  while(n>=0){
    n-=e;
    e=e*26;
    k++;
  }
  n+=e/26;
  string s;
  for(ll i=k-1;i>=0;i--){
    s[i]='a'+n%26;
    n/=26;
  }
  for(ll i=0;i<k;i++)cout << s[i];
}

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

using namespace std;

int main()
{
  int a,b;

  cin >> a >> b;

  if(a>=13){
    cout << b << endl;
  }
  else if(a<=12&&6<=a){
    cout << b/2 << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

char s[300000];
stack<ll> st,st2,L2;
queue<ll> L;

int main(void){
    ll a,l,max,maxi,level;

    scanf("%s",s);

    int len = strlen(s);
    max = 0;level = 0;maxi = 0;
    REP(i,len){
        if(s[i] == '/')
            level++;
        else if(s[i] == '\\')
            level--;
        if(max < level){
            max = level;maxi = i;
        }    
    }
    a = 0;l = 0;
    REP(i,maxi + 1){
        if(s[i] == '\\')
            st.push(i);
        else if(s[i] == '/' && st.empty() == false){
            ll b = i - st.top();
            st.pop();
            a += b;l += b;
        }

        if(st.empty() == true && l > 0){
            L.push(l); l = 0;
        }
    }
    l = 0;
    RFOR(i,maxi,len){
        if(s[i] == '/')
            st2.push(i);
        else if(s[i] == '\\' && st2.empty() == false){
            ll b = st2.top() - i;
            st2.pop();
            a += b;l += b;
        }
        if(st2.empty() == true && l > 0){
            L2.push(l);l = 0;
        }
    }

    while(L2.empty() == false){
        L.push(L2.top());L2.pop();
    }


    printf("%lld\n%lld",a,L.size());
    if(L.size() > 0)
        printf(" ");
    while(L.empty() == false){
        printf("%lld",L.front());
        L.pop();
        if(L.empty() == true)
            break;
        else
            printf(" ");
    }
    printf("\n");
    return 0;
} 

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin >> n >> k;
    vector<ll> a(n),sm(n+1),ml(n+1),mr(n+1);
    REP(i,n){
        cin >> a[i];
        sm[i+1]=sm[i]+a[i];
        ml[i+1]=ml[i]+(a[i]>0?a[i]:0);
    }
    REPR(i,n){
        mr[i]=mr[i+1]+(a[i]>0?a[i]:0);
    }
    ll ans=0;
    REP(i,n-k+1){
        chmax(ans,max(0LL,sm[i+k]-sm[i])+ml[i]+mr[i+k]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6372
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    import copy
    h,w = map(int, input().split())
    s = [list(input().rstrip()) for _ in range(h)]

    #始点(i,j)から最短で行ける一番遠い距離
    def bfs(i, j):
        dxy = [[0,1],[0,-1],[1,0],[-1,0]]
        q = deque([[i,j]])
        d[i][j] = 0
        while q:
            x, y = q.popleft()
            for dx, dy in dxy:
                nx, ny = x+dx, y+dy
                if 0<=nx<=h-1 and 0<=ny<=w-1:
                    if d[nx][ny]=='.':
                        d[nx][ny] = d[x][y] + 1
                        q.append([nx,ny])
        res = 0
        for a in range(h):
            for b in range(w):
                if d[a][b] != '#':
                    res = max(res, d[a][b])
        return res

    res = 0
    for i in range(h):
        for j in range(w):
            if s[i][j] == '.':
                d = copy.deepcopy(s)
                res = max(res, bfs(i, j))
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 51676
#include <bits/stdc++.h>
 
typedef long long ll;
typedef unsigned long long ull;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;

const ull ULL_MAX = 1.8446744e+19;

using namespace std;

int n;

int main () {

	int n;
	ull s = 1;
	ull b = 1000000000000000000;

	cin >> n;

	ull a[n];
	rep (i, n) {
		cin >> a[i];
		if (a[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}

	rep (i, n) {
		
		if (s > (ULL_MAX / a[i])) {
			cout << -1 << endl;
			return 0;
		}
		s *= a[i];
		if (s > b) {
			cout << -1 << endl;
			return 0;
		}
	}

	cout << s << endl;

}

Measured memory_bytes: 4408
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int N, A, B, C;
vector<int> l;
int dfs(int a, int b, int c, int now){
    if(now==N){
        if(a==0||b==0||c==0) return 1000000000;
        return abs(A-a)+abs(B-b)+abs(C-c);
    }
    int r1=dfs(a, b, c, now+1);
    int r2=dfs(a+l[now], b, c, now+1)+10;
    int r3=dfs(a, b+l[now], c, now+1)+10;
    int r4=dfs(a, b, c+l[now], now+1)+10;
    return min({r1,r2,r3,r4});
}
int main() {
    cin >> N >> A >> B >> C;
    l.resize(N);
    for (int i = 0; i < N; i++)
    {
        cin >> l[i];
    }
    int ans = dfs(0, 0, 0, 0)-30;
    cout << ans << endl;
}

Measured memory_bytes: 256
k = input()
s = int(input())
ls = []
for i in k:
    ls.append(int(i))
    
if set(ls[0:s]) == {1}:
    print(1)
else:
    flg = 1
    for i in ls:
        flg = int(i)
        if flg !=1:
            break
    print(flg)

Measured memory_bytes: 38256
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(;n>0;n--) {
			l = sc.next() + ".."; p = 0;
			System.out.println(solve());
		}
	}
	
	String l; int p;
	char next() {
		return l.charAt(p++);
	}
	
	int solve() {
		char c = next();
		if(c != '[') return val();
		ArrayList<Integer> l = new ArrayList<Integer>();
		while(c == '[') {
			l.add(solve());
			c = next();
		}
//		if(c != ']') debug("err");
		int n = l.size();
		sort(l);
		int ret = 0;
		for(int i=0;i<n/2+1;i++) ret += l.get(i);
//		debug(ret, l);
		return ret;
	}
	
	int val() {
		p--;
		char c = next();
		String v = "";
		while( '0' <= c && c <= '9' ) {
			v += c; c = next();
		}
		return Integer.valueOf(v) / 2 + 1;
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 67524
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] S = sc.nextLine().split(" ");
    int[] num1 = new int[100000];
    int[] num2 = new int[100000];
    for(int i = 0; i < N; i++){
      if(i%2 == 0){
        num1[Integer.parseInt(S[i])-1]++;
      }else{
        num2[Integer.parseInt(S[i])-1]++;
      }
    }
    
    int n, n1, n2, m, m1, m2;
    n = n1 = n2 = m = m1 = m2 = 0;
    for(int i = 0; i < 100000; i++){
      if(num1[i] > n1){
        n2 = n1;
        n1 = num1[i];
        n = i;
      }else if(num1[i] > n2){
        n2 = num1[i];
      }
      
      if(num2[i] > m1){
        m2 = m1;
        m1 = num2[i];
        m = i;
      }else if(num2[i] > m2){
        m2 = num2[i];
      }
    }
    
    int ans = 0;
    if(n != m){
      ans += (N/2) - n1;
      ans += (N/2) - m1;
    }else{
      int a = (N/2)-n1 + (N/2)-m2;
      int b = (N/2)-m1 + (N/2)-n2;
      ans += Math.min(a, b);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 48796
N, K = map(int, input().split())
S = input()
segs = []
prev = "x"
for c in S:
    if c != prev:
        segs.append([c])
    else:
        segs[-1].append(c)
    prev = c
ans = sum(len(seg) - 1 for seg in segs)
print(min(ans + 2 * K, N - 1))


Measured memory_bytes: 17724
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>


#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

char mat[15][15]; // ¥n
char* zero = (char*)"0";
char* one = (char*)"1";

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

bool check(int x, int y){
  if(0 <= x && x <= 11 && 0 <= y && y <= 11) return true;
  else false;
}
void dfs(int x, int y){
  mat[x][y] = zero[0];  
  REP(k, 4){
    int xx = x+dx[k], yy = y+dy[k];
    if(check(xx, yy) && mat[xx][yy] == one[0]) dfs(xx, yy);          
  }
}

int
main(void){  
  ios_base::sync_with_stdio(false);

  int n = 12;
  while(scanf("%s",mat[0])!=EOF){
    for(int i=1; i <= n-1; i++){
      scanf("%s",mat[i]);
    }
    getchar();  
    ll ans = 0LL;    

    //REP(i, n) REP(j, n) cin >> mat[i][j];
    REP(i, n) REP(j, n) if(mat[i][j] == one[0]) {dfs(i,j); ans++;}
    cout << ans << endl;
  }
    
  
  return 0;
}



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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int n;
	cin >> n;
	string s ;
	cin >> s ;
	if(n%2)  coN();
	else{
		string t = s.substr(0,n/2);
		string S = s.substr(n/2,n/2);
		debug(t);
		debug(S);
		if( t == S ) coY();
		else coN();
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int k = scanner.nextInt();
		int q = scanner.nextInt();
		int[] point = new int[n];
		for (int i = 0, a; i < q; i++) {
			point[scanner.nextInt() - 1]++;
		}
		for (int i = 0; i < n; i++) {
			System.out.println(k - q + point[i] > 0 ? "Yes" : "No");
		}

	}

}


Measured memory_bytes: 59276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1e18;

int main() {
  ll n;
  cin >> n;
  for(ll i=1;i<=n;i++) {
    if(i*(i+1)/2>=n) {
      cout << i << endl;
      return 0;
    }
  }
}

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

using namespace std;

int main(){

	int n;
	while(cin>>n&&n!=0){
		vector<pair<int,int> > infos;
		for(int i = 0; i < n; i++){
			int num;
			cin>>num;
			int frame=1;
			pair<int,int> scores[11];
			int sum=0;
			while(1){
				if(frame==10){
					int sc,sc2;
					cin>>sc>>sc2;
					int sc3=0;
					if(sc==10||sc+sc2>=10){
						cin>>sc3;
					}
					scores[10].first=sc;
					scores[10].second=sc2;
					sum+=sc3+sc+sc2;
					break;
				}
				else{
					int sc;
					cin>>sc;
					if(sc==10){
						scores[frame].first=sc;
						scores[frame].second=-1;
						frame++;
					}
					else{
						int sc2;
						cin>>sc2;
						scores[frame].first=sc;
						scores[frame].second=sc2;
						frame++;
					}
				}
			}
			// {[iXðÁZ
			for(int i = 1; i <= 9; i++){
				sum+=scores[i].first;
				// XgCN
				if(scores[i].first==10){
					sum+=scores[i+1].first;
					// XgCN¾Á½ê
					if(scores[i+1].first==10&&i+1!=10){
						sum+=scores[i+2].first;
					}
					else{
						sum+=scores[i+1].second;
					}
				}
				// XyA
				else if(scores[i].second!=-1&&scores[i].first+scores[i].second==10){
					sum+=scores[i].second;
					sum+=scores[i+1].first;
				}
				else{
					sum+=scores[i].second;
				}
			}
			infos.push_back(make_pair(sum,-num));
		}
		sort(infos.begin(),infos.end(),greater<pair<int,int> >());
		for(int i = 0; i < infos.size(); i++){
			cout<<-infos[i].second<<" "<<infos[i].first<<endl;
		}
	}

	return 0;
}

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

using namespace std;

#define endl '\n'
#define cw(x) cout << (x) << endl
#define cww(x,y) cout << (x) << ' ' << y << endl
#define cwa(x) for(auto a:x) cout << a << ' ';cout << endl
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second

typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef unordered_set<int> usi;
typedef vector<pi> vpi;

int n;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    
    cin >> n;
    cw(n%1000?1000-n%1000:0);

    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
const ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  vector<vll> dp(n, vll(1e5 + 1, inf));
  dp[0][0] = 0;
  for (ll i = 1; i <= 1e5; i++) {
    if (i <= v[0]) dp[0][i] = ww[0];
    else break;
  }
  for (ll i = 1; i < n; i++) {
    dp[i] = dp[i - 1];
    for (ll j = 1; j <= 1e5; j++) {
      if (dp[i - 1][max(0ll, j - v[i])] < inf) {
        dp[i][j] = min(dp[i][j], dp[i - 1][max(0ll, j - v[i])] + ww[i]);
      }
    }
  }
  for (ll i = 0; i <= 1e5; i++) {
    if (dp[n - 1][i] > w) {
      cout << i - 1 << endl;
      return 0;
    }
  }
  cout << 1e5 << endl;
}

Measured memory_bytes: 79488
n = input()
t,a = map(float,raw_input().split())
l = map(float,raw_input().split())
ans = abs(t-0.006*l[0]-a)
index = 1
for i in xrange(1,n):
	x = abs(t-0.006*l[i]-a)
	if x < ans:
		ans = x
		index = i+1
print index



Measured memory_bytes: 29676
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
int find(int a){
     if(par[a]==a)return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);if(a==b)return ;
     parent[b]=a;
}*/
 
 
 
 
 
 
 











ll dist1[100005],distn[100005];
vector<int> adj[100005];
void dfs(int node,int par,ll dist1[]){
     for(int child:adj[node]){
          if(child==par)continue;
          dist1[child]=dist1[node]+1;
          dfs(child,node,dist1);
     }
}
int main(){
     ll n;
     cin>>n;
     for(int i=0;i<n;i++){
          int x,y;
          cin>>x>>y;
          adj[x].push_back(y);
          adj[y].push_back(x);
     }
     dfs(1,-1,dist1);
     dfs(n,-1,distn);
     int ct1=0,ctn=0;
     for(int i=1;i<=n;i++){
          if(i!=1&&i!=n){
               if(dist1[i]>distn[i])ctn++;
               else ct1++;
          }
     }
    // cout<<ct1<<" "<<ctn<<"\n";
     if(ct1>ctn)cout<<"Fennec";
     else cout<<"Snuke";
     
     
}


























Measured memory_bytes: 16852
#include<iostream>
using namespace std;
int main()
{
char s[100];
 int i;
  for(i=1;i<=3;i++)
  {
    cin>>s[i];
  }
if(s[1]==s[3] and s[2]==s[3])
  cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

if n==1:
  x=a[0]
else:
  x=gcd(a[0],a[1])
  for i in range(2,n):
    x=gcd(x,a[i])

if max(a)>=k and k%x==0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 14100
#include<iostream>
#include<vector>
#include<sstream>
#include<algorithm>
#include<cstdlib>
using namespace std;

bool cmp(const string& a,const string b)
{
  if(a.size() != b.size())
    return a.size() < b.size();
  if(a != b)
    return (atoi)(a.c_str()) < (atoi)(b.c_str());
  return false;
}

int main()
{
  int n;
  vector<string> vec;
  cin >> n; 
  vec.resize(n);

  int men = 100000000;  
  int Size[6];
  for(int i=0;i<6;i++)
    Size[i] = 0;
  for(int i=0;i<n;i++)
    cin >> vec[i],Size[vec[i].size()]++,men = min(men,(int)vec[i].size());

  sort(vec.begin(),vec.end(),cmp);
    
  if(Size[men] >= 4)
      cout << vec[0] << vec[3] << endl;
  else if(Size[men] == 3)
    cout << vec[1] << vec[0] << endl;
  else if(Size[men] == 2)
    {
      string a,b;
      a = vec[0]+vec[2];
      b = vec[2]+vec[0];
      cout << min((atoi)(b.c_str()),(atoi)(a.c_str())) << endl;
    }
  else if(Size[men] == 1)
    {
      vector<string> ans;
      for(int i=0;i<10;i++)
	for(int j=0;j<10;j++)
	  if(i != j)
	    ans.push_back(vec[i]+vec[j]);
      sort(ans.begin(),ans.end(),cmp);
      cout << ans[2] << endl;
    }


  


  return 0;
}

Measured memory_bytes: 1652
s=input()

for i in range(len(s)):
  if s[i]=="L" and (i%2==0 or i==0):
    print("No")
    exit()
    
  elif s[i]=="R" and i%2!=0:
    print("No")
    exit()
    
  else:
    pass
  
print("Yes")
    

Measured memory_bytes: 2940
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	ll ans;

	if(n==1&&m==1){
		cout<<1<<endl;
		return 0;
	}
	if(n==1){
		cout<<max(0LL,m-2)<<endl;
		return 0;
	}
	if(m==1){
		cout<<max(0LL,n-2)<<endl;
		return 0;
	}
	ans=(n-2);
	ans*=(m-2);
	cout<<ans<<endl;
} 
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
	int n,ac=0,wa=0,tle=0,re=0;
	string s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s[0]='A' && s[1]=='C'){
			ac++;
		}
		if(s[0]='W' && s[1]=='A'){
			wa++;
		}
		if(s[0]='T' && s[1]=='L' && s[2]=='E'){
			tle++;
		}
		if(s[0]='R' && s[1]=='E'){
			re++;
		}
	}
	cout<<"AC"<<" "<<"x"<<" "<<ac<<endl;
	cout<<"WA"<<" "<<"x"<<" "<<wa<<endl;
	cout<<"TLE"<<" "<<"x"<<" "<<tle<<endl;
	cout<<"RE"<<" "<<"x"<<" "<<re<<endl;
	return(0);
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;

map<ll,ll> fact(ll m){//素因数-指数のmapを返す
    map<ll,ll> X;
    bool flag;
    X[1]=0;
    while(m){
        flag=false;
        For(i,2,sqrt(m)+2){
            if(m%i==0){
                flag=true;
                m/=i;
                X[i]++;
                break;
            }
        }
        if(flag) continue;
        X[m]++;
        break;
    }
    return X;
}

void Main(){
    ll n;
    cin >> n;
    map<ll,ll> mp = fact(n);

    vector<ll> vec(1000,0);
    For(i,1,1000) vec[i]=vec[i-1]+i;
    for(auto p:mp){
        if(p.first==1) continue;
        else{
            For(i,1,1000){
                if(vec[i]>p.second){
                    ans+=i-1;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define mp make_pair;

const ll prime = 1000000000 + 7;
const ld PI = 2 * acos(0.0);

/*
cout << fixed << setprecision(10);
*/

int main() {

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

	ll i, j;
	i = -1;
	j = n;
	ll sum = 0;
	while (j - i >= 2) {
		if (sum <= 0) {
			// +
			i++;
			sum += a[i];
		}
		else {
			// -
			j--;
			sum -= a[j];
		}
	}
	ll sum2;
	if (sum < 0) {
		sum2 = sum + 2 * a[j];
	}
	else {
		sum2 = sum - 2 * a[i];
	}
	ll ans;
	ans = min(abs(sum), abs(sum2));
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main(){
	int n, m, c, ans = 0, cnt = 0;
	int a[25], b[25];
	cin >> n >> m >> c;
	for(int i = 0; i < m; i++){
		cin >> b[i];
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> a[j];
		}
		for(int j = 0; j < m; j++){
			ans += a[j] * b[j];
		}
		ans += c;
		if(ans > 0){
			cnt++;
		}
		ans = 0;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
using namespace std;

#define ll long long
//#define int long long
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

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


typedef pair<int, int> P;
struct Point{
	int x, y;
};
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = {1,0,-1,0};


ll c[200001];
ll N, K;

int main(){

	cin >> N >> K;

	for (int i = 0; i < N; i++){
		int t;
		cin >> t;
		c[t]++;
	}

	sort(c, c + 200001, greater<int>());

	int i;
	for (i = 0; i < 200001; i++){
		if (c[i] == 0) break;
	}

	int r=0;
	for (int j = i; j >= K; j--){
		r += c[j];
	}

	cout << r << endl;



	return 0;
}

Measured memory_bytes: 1792