akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long  Int;

template <typename Weight, int MAX_N, Weight INF> class MaxFlow{
private:
	struct E{
		int to, rev;
		Weight lim;
		E(int x, Weight y, int z){
			to = x;
			lim = y;
			rev = z;
		}
	};

	vector<E> edge[MAX_N];
	int lev[MAX_N];
	int iter[MAX_N];


	Weight dfs(int s, int g, Weight f){
		if(s == g)return f;
		for(int &i = iter[s];i < edge[s].size();i++){
			E &e = edge[s][i];
				if(lev[e.to] <= lev[s] || e.lim <= 0)continue;
			Weight tmp = dfs(e.to, g, min(f, e.lim));
			if(!tmp)continue;
			e.lim -= tmp;
			edge[e.to][e.rev].lim += tmp;
			return tmp;
		}
		return 0;
	}

	void bfs(int x){
		queue<int> q;
		q.push(x);
		int p = 0;
			while(!q.empty()){
			for(int i = q.size();i--;){
				int tmp = q.front();q.pop();
				if(lev[tmp] != INF)continue;
				lev[tmp] = p;
				for(int j = 0;j < edge[tmp].size();j++){
					if(edge[tmp][j].lim > 0 && lev[edge[tmp][j].to] == INF)q.push(edge[tmp][j].to);
				}
			}
			p++;
		}
	}

public:
	void make_edge(int a, int b, Weight l){
		edge[a].push_back(E(b, l, edge[b].size()));
		edge[b].push_back(E(a, 0, edge[a].size() - 1));
	}

	Weight max_flow(int s, int g){
		Weight res = 0;
		bool fin = false;
		while(!fin){
			fill(lev, lev + MAX_N, INF);
			fill(iter, iter + MAX_N, 0);
			bfs(s);
			fin = true;
			while(true){
				Weight p = dfs(s, g, INF);
				if(p == 0)break;
				fin = false;
				res += p;
			}
		}	
		return res;
	}
};


#define INF (1 << 30)

int dist[108][108];
int p[1080], t[1080];
int main(){
	int n, m, l, u, v, d;
	while(cin >> n >> m >> l, n|m|l){		
		MaxFlow<int, 2160, INF> mf;
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				if(i == j)dist[i][j] = 0;
				else dist[i][j] = INF-1;
			}
		}
		for(int i = 0;i < m;i++){
			cin >> u >> v >> d;
			dist[u][v] = d;
			dist[v][u] = d;
		}
		for(int i = 0;i < n;i++)
			for(int j = 0;j < n;j++)
				for(int k = 0;k < n;k++)
					dist[j][k] = min(dist[j][i] + dist[i][k], dist[j][k]);
		for(int i = 0;i < l ;i++){
			cin >> p[i] >> t[i];
		}
		for(int i = 0;i < l;i++){
			mf.make_edge(l * 2, i, 1);
			mf.make_edge(i + l, l * 2+1, 1);			
			for(int j = 0;j < l;j++){
				if(i == j)continue;
				if(t[i] + dist[p[i]][p[j]] <= t[j]){
					mf.make_edge(i, j + l, 1);
				}
			}
		}
		cout << l - mf.max_flow(l * 2, l * 2 + 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 18956
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
const ll linf = 0x3f3f3f3f3f3f3f3f;

inline void chk_min(ll &a,ll b){ if(a>b) a=b;}

struct Queue
{
	int q[MAXN],hd,tl;
	Queue(void){ hd=tl=0;}
	inline bool empty(void){ return hd>=tl;}
	inline int front(void){ return q[hd+1];}
	inline int back(void){ return q[tl];}
	inline void push(int x){ q[++tl]=x;}
	inline void pop(void){ ++hd;}
}q;

int a[MAXN];
ll dp[MAXN];

int main(void)
{
	int n,e,t;
	scanf("%d%d%d",&n,&e,&t);
	for(int i=1; i<=n; ++i) scanf("%d",&a[i]);
	
	memset(dp,0x3f,sizeof(dp));
	
	dp[0]=0;
	q.push(0);
	ll mn=linf;
	for(int i=1; i<=n; ++i)
	{
		while(!q.empty() && (a[i]-a[q.front()+1])*2 > t)
			chk_min(mn, dp[q.front()] - 2*a[q.front()+1]),
			q.pop();
		
		if(!q.empty()) chk_min(dp[i], dp[q.front()]+t);
		else chk_min(dp[i],t);
		
		chk_min(dp[i], mn+2*a[i]);
		q.push(i);
	}
	printf("%lld\n",dp[n]+e);
	return 0;
}

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0149
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int[,] res = new int[4, 2];
            while (true)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line)) break;

                double[] eyeLR = Array.ConvertAll(line.Trim().Split(' '), e => double.Parse(e));

                for (int i = 0 ; i < eyeLR.Length ; i++)
                {
                    if (eyeLR[i] >= 1.1) res[0, i]++;
                    else if (eyeLR[i] >= 0.6) res[1, i]++;
                    else if (eyeLR[i] >= 0.2) res[2, i]++;
                    else res[3, i]++;
                }
            }

            for (int i = 0 ; i < res.GetLength(0) ; i++)
            {
                Console.WriteLine("{0} {1}", res[i, 0], res[i, 1]);
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 18016
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
char S[20];
int main()
{
	int a;
	scanf("%d%s",&a,S);
	if(a>=3200)	printf("%s\n",S);
	else	printf("red\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                PrintWriter ou = new PrintWriter(System.out);
                int n = Integer.parseInt(sc.next());
                int k = Integer.parseInt(sc.next()) - 1;
                int[] x = new int[n];
                for(int i = 0 ; i < n ; i++){
                        x[i] = Integer.parseInt(sc.next());
                }
                sc.close();
                long[] q = new long[n - k];
                for(int i = 0 ; i < n - k ; i++){
                        if(x[i] < 0 && x[i + k] > 0) q[i] = Math.min(-x[i] , x[i + k]) - x[i] + x[i + k];
                        else q[i] = Math.max(Math.abs(x[i]) , Math.abs(x[i + k]));
                }
                Arrays.sort(q);
                ou.print(q[0] + "\n");
                ou.flush();
        }
}

Measured memory_bytes: 60324
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
using namespace std;

typedef complex<int> P;

int b[19][19];


int main(){
	
	int n;
	P p[51][11];
	int m[51];
	
	while(cin>>n,n){
		for (int i=0; i<=n; i++) {
      cin >> m[i];
			int a,b;
      for (int j=0; j<m[i]; j++) {
        cin>>a>>b;
      	p[i][j]=P(a,b);
      }
			}
		
		
		for(int i=1;i<=n;i++){
			if(m[0]!=m[i]){
				continue;
			}
			
			bool f;
			int ox1,oy1,ox2,oy2;
			
			for(int k=0;k<4;k++){
				for(int j=0;j<m[0];j++){
					p[0][j]*=P(0,1);
				}
			
			f=true;
			ox1=p[0][0].real(); oy1=p[0][0].imag();
			ox2=p[i][0].real(); oy2=p[i][0].imag();
			for(int j=0;j<m[0];j++){
				if(p[0][j].real()-ox1!=p[i][j].real()-ox2){f=false; break;}
				if(p[0][j].imag()-oy1!=p[i][j].imag()-oy2){f=false; break;}
			}
			if(f){
				cout<<i<<endl;
				break;
			}
			
			f=true;
			ox1=p[0][m[0]-1].real(); oy1=p[0][m[0]-1].imag();
			ox2=p[i][0].real(); oy2=p[i][0].imag();
			for(int j=0;j<m[0];j++){
				if(p[0][m[0]-1-j].real()-ox1!=p[i][j].real()-ox2){f=false; break;}
				if(p[0][m[0]-1-j].imag()-oy1!=p[i][j].imag()-oy2){f=false; break;}
			}
			if(f){
				cout<<i<<endl;
				break;}
			}
		}
	cout<<"+++++"<<endl;
	}
	
}

Measured memory_bytes: 2988
N = int(input())
s = input()

MOD = 10**9 + 7

dp =  [[0] * N for i in range(N)]

dp[0][0] = 1
for i in range(1,N):
    if( s[i-1] == '<'):
        tmp = 0
        for j in range(i+1):
            dp[i][j] = tmp
            tmp += dp[i-1][j]
            tmp = tmp % MOD
    else:
        tmp = 0
        for j in range(i-1,-1,-1):
            tmp += dp[i-1][j]
            tmp = tmp % MOD
            dp[i][j] = tmp

ans = sum(dp[N-1]) % MOD
print(ans)


Measured memory_bytes: 111964
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int N = scanner.nextInt();
		    int M = scanner.nextInt();
		    int X = scanner.nextInt();
		    int[] station = new int[M];
		    int costfor0 = 0;
		    int costforN = 0;
		    
		    for(int i = 0; i < M; i++) 
		    {
		    	station[i] = scanner.nextInt();
		    	if( station[i] < X ) 
		    	{
		    		costfor0++;
		    	}
		    	else 
		    	{
		    		costforN++;
		    	}
		    }
		    System.out.println( Math.min(costfor0, costforN) );
		    scanner.close(); }
		  }

Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;

int main() {
	//入力
	string S;
	cin >> S;

	//処理
	string T = "ATCG";

	int ans = 0;
	for (int i = 0; i < S.size(); i++)
	{
		//i は開始地点
		int now = 0;
		for (int j = i; j < S.size(); j++)
		{
			//j 文字目まではATCGであるかチェック
			bool ok = false;
			for (int k = 0; k < T.size(); k++)
			{
				if (S[j] == T[k]) ok = true;
			}

			if (ok) {
				//j文字目がATCG文字なら、i文字目からj文字目までがATCG文字列である。
				now++;
				ans = max(ans, now);
			}
			else {
				//j文字目がATCG文字ではないなら、
				//これ以上i文字目から始まるATCG文字列は作れない。
				break;
			}
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int n; cin>>n;
    vint d(n); rep(i,n)cin>>d[i];
    sort(d.begin(),d.end());
    if(d[n/2] == d[n/2-1]){cout<<0<<endl; return 0;}
    else{cout<<d[n/2]-d[n/2-1]<<endl; return 0;}
}


Measured memory_bytes: 640
#include<stdio.h>

int BubbleSort( int *A, int N) {
	int C = 0;
	int flag = 1;
	while ( flag ) {
		flag = 0;
		for ( int j = N-1; j > 0; j--) {
			if ( A[j - 1] > A[j]) {
				int temp = A[j - 1];
				A[j - 1] = A[j];
				A[j] = temp;
				flag = 1;
				C++;
			}
		}
	}
	return C;
}

int main() {
	int N;
	int A[100+10];
	scanf("%d", &N);
	for ( int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	int c = BubbleSort(A, N);
	for ( int i = 0; i < N; i++) {
		printf("%d",A[i]);
		if(i != N - 1) printf(" ");
		else printf("\n");
	}
	printf("%d\n",c);
}


Measured memory_bytes: 2740
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

const int MAX_N = 40000;
const int MAX_Q = 40000;
const int SQRT = 200;
const int INF = 1<<29;

struct query{
	int type, x, y;
};

int N, Q, E;
query qs[MAX_Q];

struct edge{
	int from, tar, add, rm;
};

edge es[MAX_Q];
vector<int> graph[MAX_N];
bool found;
bool visited[MAX_N];

struct UnionFind{
	static const int MAX_UF = MAX_N;

	int pars[MAX_UF];
	int ranks[MAX_UF];

	void init(int n){
		for(int i=0; i<n; i++){
			pars[i] = i;
			ranks[i] = 0;
		}
	}

	int get_root(int x){
		if(pars[x] == x){
			return x;
		}
		else{
			return pars[x] = get_root(pars[x]);
		}
	}

	void merge(int x, int y){
		x = get_root(x);
		y = get_root(y);
		if( x == y ){
			return ;
		}

		if(ranks[x] < ranks[y]){
			pars[x] = y;
		}
		else if(ranks[y] < ranks[x]){
			pars[y] = x;
		}
		else{
			pars[x] = y;
			ranks[y]++;
		}
	}

	bool is_same(int x, int y){
		return get_root(x) == get_root(y);
	}
};

UnionFind uf;

void init(){
	scanf("%d%d", &N, &Q);
	for(int i=0; i<Q; i++){
		scanf("%d%d%d", &qs[i].type, &qs[i].x, &qs[i].y);
	}
}

void prepare(){
	map<pair<int,int>, int> dict;
	for(int i=0; i<Q; i++){
		if(qs[i].type == 1){
			dict[make_pair(qs[i].x, qs[i].y)] = E;
			es[E++] = (edge){qs[i].x, qs[i].y, i, INF};
		}
		else if(qs[i].type == 2){
			es[dict[make_pair(qs[i].x, qs[i].y)]].rm = i;
		}
	}
}

void prepare2(int start){
	uf.init(N);
	for(int i=0; i<E; i++){
		if(es[i].add < start && es[i].rm >= start + SQRT){
			uf.merge(es[i].from, es[i].tar);
		}
	}

	for(int i=0; i<N; i++){
		graph[i].clear();
	}

	for(int i=0; i<E; i++){
		if(es[i].add < start && es[i].rm >= start && es[i].rm < start + SQRT){
			int x = uf.get_root(es[i].from), y = uf.get_root(es[i].tar);
			graph[x].push_back(y);
			graph[y].push_back(x);
		}
	}
}


void dfs(int v, int goal, bool color){
	if(v == goal){
		found = true;
	}
	visited[v] = color;

	for(int i=0; i<(int)graph[v].size(); i++){
		const int u = graph[v][i];
		if(visited[u]!=color){
			dfs(u, goal, color);
		}
	}
}

bool search(int start, int goal){
	found = false;
	dfs(start, goal, true);
	dfs(start, goal, false);
	return found;
}

void solve(){
	prepare();
	for(int b=0; b*SQRT < Q; b++){
		prepare2(b*SQRT);
		for(int t=b*SQRT; t<(b+1)*SQRT && t<Q; t++){
			int x = uf.get_root(qs[t].x), y = uf.get_root(qs[t].y);
			if(qs[t].type == 1){
				graph[x].push_back(y);
				graph[y].push_back(x);
			}
			else if(qs[t].type == 2){
				graph[x].erase(find(graph[x].begin(), graph[x].end(), y));
				graph[y].erase(find(graph[y].begin(), graph[y].end(), x));
			}
			else if(qs[t].type == 3){
				if(x == y || search(x, y)){
					puts("YES");
				}
				else{
					puts("NO");
				}
			}
		}
	}
}

int main(){
	init();
	solve();

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> x(N);
  for (int i = 0; i < N; ++i)
    cin >> x[i];

  sort(x.begin(), x.end());

  int ans = 1000000001;
  for (int i = 0; i <= 2000; ++i)
    if (max(abs(x[0] - i), abs(x[N - 1] - i)) < ans)
      ans = max(abs(x[0] - i), abs(x[N - 1] - i));

  cout << ans << endl;
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
#include <queue>
#include <stack>
using namespace std;
 
typedef pair<long long int,long long int>pa;
#define resize(A) A.resize(unique(A.begin(), A.end()) - A.begin())
#define pb push_back
 
# define  MAX 200005
long long int MOD=998244353;
long long int INF=1e18;
 
int main()
{
    
       ios_base::sync_with_stdio(false); 
       cin.tie(NULL);
     cout.tie(NULL);
      long long int i,j,k=0,l=0,r=0,m=0,n,p=0,cnt=0,cnt1=0,x,y,z=0,a,b,low,mid,high,ans=0,maxi=0,mini=INF,t,d;
  cin>>n;
    long long int A[n];
    long long int B[n];
    for(i=0;i<n;i++)
    {
        cin>>A[i];
        B[i]=A[i];
    }
    sort(B,B+n);
    for(i=0;i<n;i++)
    {
        if(A[i]==B[n-1])
             cout<<B[n-2]<<endl;
        else
            cout<<B[n-1]<<endl;
    }
   // cout<<cnt;
   
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,ll>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=5e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,k,Mx[MAXN<<2],a[MAXN],ans[MAXN],vis[MAXN];priority_queue<int>q;
#define ls x<<1
#define rs x<<1|1
inline int comp(int x,int y){return a[x]>a[y]?x:y;}
inline void pushup(int x){Mx[x]=comp(Mx[ls],Mx[rs]);}
void Build(int x,int l,int r){
	if(l==r){Mx[x]=l;return;}int mid=l+r>>1;
	Build(ls,l,mid),Build(rs,mid+1,r),pushup(x);
}
void Del(int x,int l,int r,int p){
	if(l==r){Mx[x]=0;return;}int mid=l+r>>1;
	p<=mid?Del(ls,l,mid,p):Del(rs,mid+1,r,p),pushup(x);
}
int Ask(int x,int l,int r,int ql,int qr){
	if(ql>qr)return 0;if(ql<=l&&r<=qr)return Mx[x];int mid=l+r>>1;
	if(qr<=mid)return Ask(ls,l,mid,ql,qr);else if(ql>mid)return Ask(rs,mid+1,r,ql,qr);
	else return comp(Ask(ls,l,mid,ql,mid),Ask(rs,mid+1,r,mid+1,qr));
}
inline bool check(int x){return x&&!vis[x]&&Ask(1,1,n,x-k+1,x+k-1)==x;}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),k=read();
	Rep(i,1,n)a[i]=read();a[0]=-1e9,Build(1,1,n);
	Rep(i,1,n)if(check(i))q.push(i),vis[i]=1;
	Red(i,n,1){
		if(q.empty())break;
		int x=q.top(),p;q.pop(),ans[x]=i,Del(1,1,n,x);
		if(x>1)if(check(p=Ask(1,1,n,x-k+1,x-1)))vis[p]=1,q.push(p);
		if(x<n)if(check(p=Ask(1,1,n,x+1,x+k-1)))vis[p]=1,q.push(p);
	}Rep(i,1,n)cout<<ans[i]<<'\n';
	return 0;
}




Measured memory_bytes: 15856
n, m, x = map(int, input().split())
book = [list(map(int, input().split())) for _ in range(n)]

A = []
C = []
for c, *a in book:
    C.append(c)
    A.append(a)

ans = float("inf")
for i in range(2 ** n):
    algo = [0] * m
    cost = 0
    for j in range(n):
        if (i >> j) & 1:
            cost += C[j]
            for idx, a in enumerate(A[j]):
                algo[idx] += a
    if all([True if a >= x else False for a in algo]):
        ans = min(ans, cost)

print(ans if ans != float("inf") else -1)


Measured memory_bytes: 68984
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define out() fflush(stdout)
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define pii pair < int, int >
typedef vector<int> vi;
typedef   long long ll;
const int mod =1e9+7;

void solve(){
	int a[6];
	int ans=0;
	for(int i=1;i<=5;i++){
		cin>>a[i];
		if(!a[i])ans=i;
	}
	cout<<ans;
}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

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

int main()
{
  int X,N;
  cin >> X >> N;
  vector<int> p(N);
  for(int i=0;i<N;i++)
    cin >> p[i];
  
  int dis = 1 ;
  int forcus = X;
  bool islittle = false;

  
  while(1)
  {
    auto result = std::find(p.begin(), p.end(), forcus);
    if (result == p.end()) 
    {
      std::cout << forcus << std::endl;
      return 0;
    }else
    {
//      cout << forcus << endl;
      if(islittle == false)
      {
        forcus = X-dis;
        islittle = true;
      }else
      {
        forcus = X + dis; 
        islittle = false;
        dis++;
      }
      continue;
    } 
  }
  return 0; 
}

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

int main ()
{
	string s;  cin>>s;
	
	if(s[0]==s[1] ||s[2]==s[3]||s[1]==s[2])
	{ 
		cout<<"Bad"<<endl;
	}
	else
	cout<<"Good"<<endl;
	


}


Measured memory_bytes: 3576
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }
template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }

char S[1020];

int main() {
    scanf("%s", S);
    string s = S;
    int u = 0, r = 0, d = 0, l = 0;
    for (auto&& c : s) {
        u += c == 'N';
        d += c == 'S';
        r += c == 'E';
        l += c == 'W';
    }

    bool ok = false;
    if (u && d && r && l) ok = 1;
    else if (u&&d && !r && !l) ok = 1;
    else if (r&&l && !u && !d) ok = 1;
    puts(ok ? "Yes" : "No");

    return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

template <class T, class Op>
class SegmentTree {
private:
    const Op op;
    const T ID;
    std::vector<T> vec;
    size_t sz;

public:
    explicit SegmentTree(size_t _n, Op _op, T _identity) noexcept
        : op(_op), ID(_identity) {
        sz = 1;
        while (sz < _n) sz <<= 1;
        vec.resize(sz * 2, ID);
    }
    explicit SegmentTree(const std::vector<T>& _vec, Op _op, T _identity) noexcept
        : op(_op), ID(_identity) {
        size_t n = _vec.size();
        sz = 1;
        while (sz < n) sz <<= 1;
        vec.resize(sz * 2, ID);
        set_array(_vec);
    }
    void set_value(size_t _idx, T _val) noexcept {
        vec[_idx + sz] = _val;
    }
    template <class RandomIt>
    void set_array(RandomIt _begin, RandomIt _end) noexcept {
        std::copy(_begin, _end, vec.begin() + sz);
    }
    void set_array(const std::vector<T>& _newvec) noexcept {
        set_array(_newvec.begin(), _newvec.end());
    }
    void build() noexcept {
        for (size_t i = sz - 1; i > 0; i--) {
            vec[i] = op(vec[i * 2], vec[i * 2 + 1]);
        }
    }
    void update(size_t _idx, T _val) noexcept {
        _idx += sz;
        vec[_idx] = _val;
        for (_idx >>= 1; _idx > 0; _idx >>= 1) {
            vec[_idx] = op(vec[_idx * 2], vec[_idx * 2 + 1]);
        }
    }
    // 区間[_i, _r)に対するクエリを実行する
    T query(size_t _l, size_t _r) const noexcept {
        T l_val = ID, r_val = ID;
        _l += sz, _r += sz - 1;
        for (; _l <= _r; _l >>= 1, _r >>= 1) {
            if (_l & 1) l_val = op(l_val, vec[_l++]);
            if (!(_r & 1)) r_val = op(r_val, vec[_r--]);
        }
        return op(l_val, r_val);
    }
    const T& operator[](size_t _idx) const noexcept {
        return vec[_idx + sz];
    }
};

using Bs = bitset<26>;

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

    int N;
    cin >> N;
    string S;
    cin >> S;
    auto op = [](const Bs& a, const Bs& b) {
        return a | b;
    };
    SegmentTree<Bs, decltype(op)> seg(N, op, Bs());
    for (int i = 0; i < N; i++) {
        seg.set_value(i, Bs().set(S[i] - 'a'));
    }
    seg.build();
    int Q;
    cin >> Q;
    while (Q--) {
        int query;
        cin >> query;
        if (query == 1) {
            int idx;
            char c;
            cin >> idx >> c;
            seg.update(idx - 1, Bs().set(c - 'a'));
        }
        else {
            int l, r;
            cin >> l >> r;
            --l, --r;
            cout << seg.query(l, r + 1).count() << '\n';
        }
    }

    return 0;
}

Measured memory_bytes: 9116
import sys
import math
import itertools

rl = sys.stdin.readline
x = int(rl())
while True:
    if x == 2:
        print(2)
        break
    if x % 2:
      for i in range(3, x//2, 2):
        if x % i == 0:
            break
      else:
        print(x)
        break
    x += 1



Measured memory_bytes: 38512
import java.io.*;
import java.util.*;

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long) (1e9+7);
	static long cf = 998244353;
    static final long MAX = (long) 1e15;
   // public static List<Integer>[] edges;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		boolean found = false;
		for(int i=1;i<=9;++i) {
			for(int j=1;j<=9;++j) {
				if(i*j == n) found = true;
			}
		}
		if(found) out.print("Yes");
		else out.print("No");
		out.close();
	}
}


Measured memory_bytes: 22612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main() {
	int argW, argH, argN;
	cin >> argW >> argH >> argN;

	vector<vector<int>> argP(argW, vector<int>(argH, 1));
	vector<int> argX(argN), argY(argN), argFlag(argN);
	for (int i = 0; i < argN; ++i) {
		cin >> argX.at(i) >> argY.at(i) >> argFlag.at(i);
	}

	for (int i = 0; i < argN; ++i) {
		if (argFlag.at(i) == 1) {
			for (int x = 0; x < argW; ++x) {
				if (x < argX.at(i)) {
					for (int y = 0; y < argH; ++y) {
						argP.at(x).at(y) = 0;
					}
				}
			}
		}
		else if (argFlag.at(i) == 2) {
			for (int x = 0; x < argW; ++x) {
				if (x >= argX.at(i)) {
					for (int y = 0; y < argH; ++y) {
						argP.at(x).at(y) = 0;
					}
				}
			}
		}
		else if (argFlag.at(i) == 3) {
			for (int y = 0; y < argH; ++y) {
				if (y < argY.at(i)) {
					for (int x = 0; x < argW; ++x) {
						argP.at(x).at(y) = 0;
					}
				}
			}
		}
		else if (argFlag.at(i) == 4) {
			for (int y = 0; y < argH; ++y) {
				if (y >= argY.at(i)) {
					for (int x = 0; x < argW; ++x) {
						argP.at(x).at(y) = 0;
					}
				}
			}
		}
	}

	int ret = 0;
	for (int x = 0; x < argW; ++x) {
		for (int y = 0; y < argH; ++y) {
			ret += argP.at(x).at(y);
		}
	}

	cout << ret << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long LL;
int n,dis[410][410],a[410][410],tot;
LL sum;
struct Edge
{
    int f,t,w;
    friend bool operator<(const Edge &p,const Edge &q)
    {
        return p.w>q.w;
    }
}e[100010];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        {
            scanf("%d",&dis[i][j]);
            a[i][j]=dis[i][j];
            if(i<j) ++tot,e[tot].f=i,e[tot].t=j,e[tot].w=dis[i][j],sum+=dis[i][j];
        }
    for(int k=1;k<=n;k++)
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            if(a[i][j]!=dis[i][j]) {puts("-1");return 0;}
    sort(e+1,e+tot+1);
    for(int i=1;i<=tot;i++)
    {
        int x=e[i].f,y=e[i].t;
        int a=0,b=0,c=0;
        for(int k=1;k<=n;k++)
            if(k!=x&&k!=y)
            {
                if(dis[x][k]+dis[k][y]<dis[x][y]) a++;
                else if(dis[x][k]+dis[k][y]==dis[x][y]) b++;
                else c++;
            }
        if(a+b>0) sum-=e[i].w;
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(i, first, last) for (int i = (first); i < (last); ++i)
#define REP(i, n) FOR(i, 0, n)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) std::cerr << #x << " = " << (x) << std::endl;

inline int to_int(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string to_string(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

typedef unsigned long long ull;
typedef unsigned long ul;

int main() {
  int n;
  stack<char> s;
  string inp;

  cin>>n;
  cin>>inp;
  for(char c : inp) {
    if(s.size()) {
      if(s.top()=='(' && c==')') s.pop();
      else s.push(c);
    } else {
      s.push(c);
    }
  }

  int l=0,r=0;
  while(s.size()) {
    if(s.top()=='(') l++;
    else r++;
    s.pop();
  }
  DUMP(l);
  DUMP(r);
  REP(_,r) cout <<'(';
  cout<<inp;
  REP(_,l) cout <<')';
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
N = gets.to_i
a = []
b = []
c = []
 
N.times do
  gets.split(' ').each_with_index do |e, i|
    a << e.to_i if i == 0
    b << e.to_i if i == 1
    c << e.to_i if i == 2
  end
end
 
d = [[a[0], b[0], c[0]]]
 
(1...N).each do |i|
  d << [[d[i-1][1], d[i-1][2]].max + a[i], [d[i-1][0], d[i-1][2]].max + b[i], [d[i-1][0], d[i-1][1]].max + c[i]]
end
 
puts d[-1].max

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

N = i()
A = l()
Q = i()
c = dict(Counter(A))
ans = sum(A)
for i in range(Q):
    B,C = I()
    if B in c:
        b = c.pop(B)
        ans += b*(C-B)
        d = 0
        if C in c:
             d = c.pop(C)
        c[C] = b+d
    print(ans)

Measured memory_bytes: 99412
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
	string S;
	cin >> S;
	int cnt = 0;
	int ans = 0;
	rep(i, S.size())
	{
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')cnt++;
		else
		{
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	ans = max(ans, cnt);
	cout << ans;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int train = sc.nextInt();
        int taxy = sc.nextInt();

        int result = taxy; 
        if (n*train < taxy) result = n*train; 
        
        System.out.println(result);
    }
}


Measured memory_bytes: 35524
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;

template <class T>
T gcd(T a, T b) {
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

bool solve(int N, vector<ll>& A) {
    if (N == 1) return false;
    ll sum = accumulate(A.begin(), A.end(), 0LL);

    // Nが偶数の場合、和の偶奇がそのまま勝敗になる
    if (N % 2 == 0) return sum % 2 != 0;

    // Nが奇数の場合も、和が偶数なら絶対勝てる
    if (sum % 2 == 0) return true;

    // 奇数を前に持っていく
    sort(A.begin(), A.end(), [](int a, int b) { return a % 2 > b % 2; });
    // 奇数が複数個ある、あるいは唯一の奇数が1(減らせない)なら負け
    if (A[0] == 1 || (A[1] & 1) != 0) return false;

    // そうでなければ、唯一の奇数を減らしてシミュレート
    --A[0];
    int g = accumulate(A.begin(), A.end(), 0LL, gcd<ll>);
    for (auto& a : A) a /= g;
    return !solve(N, A);
}

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for (auto& a : A) cin >> a;
    cout << (solve(N, A) ? "First" : "Second") << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll from;
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RES(a, n) (a).resize(n)
#define VLCIN(a, n) REP(i,n){cin >> a[i];}
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = (ll)pow(10,7);
/****** define constant end ********/
/****** define variable start ******/
ll n, m;
vl a, b, c;
map<pair<ll, ll>, bool> onroad;
Graph G;
vll dist;
vll pre;
/******* define variable end *******/
void warshall_floyd(vll &dist, vll &pre){
	for(ll k = 0; k < n; k++){
		for(ll i = 0; i < n; i++){
			for(ll j = 0; j < n; j++){
				if(dist[i][k] + dist[k][j] < dist[i][j]){
					dist[i][j] = dist[i][k] + dist[k][j];
					pre[i][j] = pre[k][j];
				}
			}
		}
	}
}

vector<ll> get_path(const vector<vector<long long>> &pre, ll s, ll t) {
    vector<ll> path;
    for (ll cur = t; cur != s; cur = pre[s][cur]) {
        path.push_back(cur);
    }
    path.push_back(s);
    reverse(path.begin(), path.end());
    return path;
}
int solve() {
	cin >> n >> m;
	RES(a, m);
	RES(b, m);
	RES(c, m);
	RES(G, n);
	pre.resize(n, vl(n));
	REP(i, n){
		REP(j, n){
			pre[i][j] = i;
		}
	}
	dist.resize(n, vl(n, INF));
	REP(i, n){
		dist[i][i] = 0;
	}
	REP(i, m){
		cin >> a[i] >> b[i] >> c[i];
		onroad[make_pair(a[i]-1, b[i]-1)] = false;
		onroad[make_pair(b[i]-1, a[i]-1)] = false;
		dist[a[i]-1][b[i]-1] = c[i];
		dist[b[i]-1][a[i]-1] = c[i];
	}
	warshall_floyd(dist, pre);
	REP(i, n){
		FOR(j, i+1, n){
			vl path = get_path(pre, i, j);
			REP(k, path.size()-1){
				onroad[make_pair(path[k], path[k+1])] = true;
				onroad[make_pair(path[k+1], path[k])] = true;
			}
		}
	}
	ll ans = 0;
	for(auto [key, value] : onroad){
		if(!value) ans++;
	}
	cout << ans/2 << endl;
	return 0;
}
int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


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

using namespace std;

const int md = (int) 1e9 + 7;

inline int add(int x, int y) {
  x += y;
  if (x >= md) x -= md;
  if (x < 0) x += md;
  return x;
}

inline int mul(int x, int y) {
  return 1ll * x * y % md;
}

inline int power(int x, int y) {
  int r = 1;
  while (y > 0) {
    if (y & 1) r = mul(r, x);
    x = mul(x, x);
    y >>= 1;
  }
  return r;
}

const int N = 105;

int dp[N][N];

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1, 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      if (a[j] > a[i]) continue;
      if (a[j] < a[i - 1]) {
        int bef = (a[i] < a[i - 1] ? i : i - 1);
        dp[i][j] = mul(add(dp[i - 1][j], dp[i - 1][bef]), power(2, a[i] - a[i - 1]));
      } else {
        dp[i][j] = mul(2 * dp[i - 1][i - 1], power(2, a[i] - a[j]));
      }
    }
  }
  cout << dp[n][0] << '\n';
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int a, b;
  cin >> a >> b;
  if (a < b) {
    for (int i = 0; i < b; i++) {
      cout << a;
    }
    cout << endl;
  } else {
    for (int i = 0; i < a; i++) {
      cout << b;
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
bool check(string s)
{
    if(s.size() >= 2 && s[0] == 'X') return true;
    return false;
}
void get_str(string &s)
{
    string tmp = "";
    for(int i = s.size(); i <= 130; i++) tmp += '0';
    s = tmp + s;
}
int to_int(char ch) { return ch - '0'; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    while(cin >> s)
    {
        int p = s.find('+'), q = s.find('=');
        string a = s.substr(0, p), b = s.substr(p + 1, q - p - 1), c = s.substr(q + 1);
        int ans = -1;
        bool flag = false;
        if(check(a) || check(b) || check(c)) flag = true;
        for(char k = (flag ? '1' : '0'); k <= '9'; k++)
        {
            string ta, tb, tc; ta = tb = tc = "";
            for(int i = 0; i < a.size(); i++) ta += (a[i] == 'X' ? k : a[i]);
            for(int i = 0; i < b.size(); i++) tb += (b[i] == 'X' ? k : b[i]);
            for(int i = 0; i < c.size(); i++) tc += (c[i] == 'X' ? k : c[i]);
            get_str(ta); get_str(tb); get_str(tc);
            int inc = 0;
            bool ok = true;
            for(int i = ta.size() - 1; i >= 0; i--)
            {
                if(ok == false) break;
                int left = to_int(ta[i]) + to_int(tb[i]) + inc;
                int right = to_int(tc[i]);
                if(left >= 10)
                {
                    left %= 10;
                    inc = 1;
                }
                else inc = 0;
                if(left != right) ok = false;
            }
            if(ok) ans = k - '0';
        }
        if(ans == -1) cout << "NA" << endl;
        else cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3116
function Main(input) {
    var x = parseInt(input);
     x = x * x * x;
    console.log(x);
   }
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug() {
    var input = document.getElementById("input").value;
    Main(input);
}

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define rep(i,n) for(int i=0;i<(int)n;++i)
#define SZ(a) (int)((a).size())
#define mp make_pair
#define pb push_back
#define F first
#define S second
typedef pair<int,int> PI;
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};


int dp[1200000];
int odp[1200000];
int n;
void solve(){
  
}

int main(){
  rep(i,1200000) dp[i]=1<<28;
  rep(i,1200000) odp[i]=1<<28;

  dp[0]=0;
  odp[0]=0;
  
  for(int i=1;;++i){
    int p = i*(i+1)*(i+2)/6;
    if(p>1100000) break;
    //cout <<  i << endl;
    for(int j=0;j+p<1200000;++j)
      dp[j+p]=min(dp[j+p],dp[j]+1);
    if(p&1)
      for(int j=0;j+p<1200000;++j)
        odp[j+p]=min(odp[j+p],odp[j]+1);
      // for(int j=110000-p;j>=0;--j)
      //   odp[j+p]=min(odp[j+p],odp[j]+1);
  }
  
  //return 0;
  
  while(cin >> n,n) cout << dp[n] << " " << odp[n] << endl;
}

Measured memory_bytes: 10536
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final int MIN_BET = 100; // 投票券1枚の値段
        final int MAX_P = 100; // 控除率の最大値
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            int n = sc.nextInt();
            int m = sc.nextInt();
            int p = sc.nextInt();
            if (n == 0) {
                break;
            }
            
            int[] x = new int[n+1];
            int sum = 0; // 掛け金の合計
            for (int i = 1; i <= n; i++) {
                x[i] = sc.nextInt();
                sum += x[i];
            }
            sum *= MIN_BET;
            
            int pay = sum * (MAX_P - p) / MAX_P; // 当選者に払う金額の合計
            int ans = x[m] == 0 ? 0 : pay / x[m];
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 27724
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
int main() {
	string s;
	int p = 0, c = 0;
	cin >> s;
	rep(i, 0, s.size()) {
			if (s[i] == 'g')p++;
	}
	printf("%d\n", p - (s.size() + 1) / 2);
	return 0;
}


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

int main(void){
    int n, k, a[2000000];
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = k; i < n; i++){
        if(a[i-k] < a[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4420
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

a, b, c = map(int, input().split())
k = int(input())

while b <= a:
    b *= 2
    k -= 1
    if k < 0:
        print('No')
        sys.exit()

while c <= b:
    c *= 2
    k -= 1
    if k < 0:
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 61732
#include <iostream>
#include <vector>
#include <queue>

int bfs(int H, int W, int si, int sj, int ti, int tj,
    const std::vector<std::string> &S)
{
    std::queue<std::pair<int, int>> q;
    q.push(std::make_pair(si, sj));

    constexpr int INF = 1<<29;
    std::vector<std::vector<int>> d(H, std::vector<int>(W, INF));
    d[si][sj] = 0;

    constexpr int di[] = {0, -1, 0, 1};
    constexpr int dj[] = {-1, 0, 1, 0};

    while (!q.empty()) {
        auto curr = q.front(); q.pop();
        int ci = curr.first;
        int cj = curr.second;

        if (cj == tj && ci == ti)
            return d[ci][cj];

        for (int i = 0; i < 4; i++) {
            int ni = ci + di[i];
            int nj = cj + dj[i];

            if (nj < 0 || nj >= W || ni < 0 || ni >= H || S[ni][nj] == '#')
                continue;

            if (d[ci][cj] + 1 < d[ni][nj]) {
                d[ni][nj] = d[ci][cj] + 1;
                q.push(std::make_pair(ni, nj));
            }
        }
    }

    return -1;
}

int main()
{
    int H, W;

    std::cin >> H >> W;
    std::vector<std::string> S(H);
    for (int i = 0; i < H; i++) {
        std::cin >> S[i];
    }

    int max = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '#')
                continue;

            for (int k = 0; k < H; k++) {
                for (int l = 0; l < W; l++) {
                    if (S[k][l] == '#')
                        continue;

                    max = std::max(max, bfs(H, W, i, j, k, l, S));
                }
            }
        }
    }
    std::cout << max << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define MAX 200005
#define INF 200005

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> ans(n);
  int inp;
  rep(i, n){
    cin >> inp;
    inp--;
    ans[inp]=i+1;
  }
  rep(i, n){
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 5100000;
const int MOD = 1e9 + 7;

const double PI=3.14159265358979323846;


long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

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

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}



int main(){
    cin >> N;
    vector<ll> v(N);
    REP(i,N) cin >> v[i];
    sort(ALL(v));
    cout << (v[N/2] - v[N/2 -1]) << "\n";
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
import java.io.*;
class Main
{
public static void main(String args[])
{
  int i,j,k;
  Scanner sc = new Scanner(System.in);
  i = sc.nextInt();
  j = sc.nextInt();
  k = sc.nextInt();
  i = i+j;
  i = i+k;
  if(i>=22)
  {
    System.out.print("bust");
  }
  else
  {
    System.out.print("win");
  }
}
}

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

int main(){
    int n, d;
    cin >> n >> d;
    n -= (2 * d + 1);
    int count = 1;
    while(n>0)
    {
        count++;
        n -= 2 * d + 1;
    }
    cout << count;
}

Measured memory_bytes: 256
#include<iostream>
#include<time.h>
#include<stdlib.h>
#include<string>
#include<cmath>
#include <iomanip>

using namespace std;

long long maxof(long long* N, int p){
    long long big = N[0];
    for(int i = 0; i < p; i++){
        if(big < N[i]){
            big = N[i];
        }
    }
    return big;
}

long long pow2(int a, int b){
    long long ans = 1;
    for(int i = 0; i <b; i++){
        ans *= a;
    }
    return ans;
}

int main(){
    int n = 0;
    cin >> n;
    if(n >= 2000){
        cout << 1;
        return 0;
    }
    else if (n < 100){
        cout << 0;
        return 0;
    }
    else{
        int k = n/100;
        if(n <= 105 * k){
            cout <<1;
        }
        else cout << 0;
    }
    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int A, B, C, R;
  
  scanf("%d %d", &A, &B);
  
  if (A > B){
		C = A - 1;
		R = A + C;
}
  if (A < B){
		C = B - 1;
		R = B + C;
}
  if (A == B){
		R = A + B;
}

  printf("%d", R);

  return 0;

}

Measured memory_bytes: 128
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import deque, defaultdict
    n, m = map(int, readline().split())
    edge_to = defaultdict(set)
    edge_from = defaultdict(set)
    from_cnt = [0] * n
    par = [-1] * n

    for _ in range(n + m - 1):
        a, b = map(int, readline().split())
        a, b = a - 1, b - 1
        edge_to[a].add(b)
        edge_from[b].add(a)
        from_cnt[b] += 1

    root = from_cnt.index(0)
    par[root] = 0

    que = deque()
    que.append(root)

    while que:
        cur = que.popleft()
        for nx in edge_to[cur]:
            if from_cnt[nx] == 1:
                par[nx] = cur + 1
                que.append(nx)
            else:
                from_cnt[nx] -= 1

    for i in range(n):
        print(par[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 146232