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

int main()
{
	
	
	
	int n,a,b;
	cin>>n>>a>>b;
	if(a*n <= b) cout << a*n << endl;
	else cout << b << endl;
	
	
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <math.h>  
using namespace std; 
void findNumberOfDigits(long N, int K) 
{  
    int dig = (int)(floor( log(N) /  
                         log(K)) + 1);  
      
    cout <<dig;
} 
  
// Driver method  
int main() 
{ 
    long N; 
    int K; 
    cin>>N>>K;
    findNumberOfDigits(N, K); 
    return 0; 
} 

Measured memory_bytes: 888
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#define REG register
#define LLI long long
#define DBL double
#define CHR char 
#define BOL bool
const int MOD = 1000000007;
const int MXN = 100010;


int main() {
	//freopen("template.in", "r", stdin);
	//freopen("template.out", "w", stdout);
	REG int i; REG LLI a, b, n, x, ans=0;
	
	scanf("%lld%lld", &n, &x);
	//if(x > n - x) x = n - x;
	if(n % x == 0) {
		ans += 3 * (n - x);
		printf("%lld\n", ans);
		return 0;
	}
	ans = n;
	a = n - x, b = x;
	
	while(a != 0 && b != 0 && a != b) { 
		//printf("%lld %lld\n", a, b);
		if(a < b) std::swap(a, b);
		if(a / b > 1)
			ans += 2 * (a / b - 1) * b, a = a % b + b;
		else
			ans += 2 * b, a -= b;
	}
	if(a == b) ans += a;
	printf("%lld\n", ans);
	
	
	
	return 0;
}


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

/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)

/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair 

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */

/*struct*/
struct aaa {
	aaa() {
		cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//Counterclockwise from the 9o'clock direction
//Take the x-axis downward and the y-axis right

//#define int ll
//#define int long long

signed main()
{
//input
	int n; cin >> n;
	map<string, int,less<>> ms;

    REP(i, n){
      string s;cin >> s;
      ms[s]++;
    }
  
    int m;cin >> m;
    REP(i, m) {
      string s;cin >> s;
      ms[s]--;
    }

//process



//output
    int ans = 0;
    for(auto& p : ms){
      ans = max(ans, p.second);
    }
    cout << ans << endl;

	return 0;
}

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

int main() {

long  K,A,B;
cin>>K>>A>>B;

if(B-A<=2){
  cout<<1+K<<endl;
  return 0;
}

long ans=1+(A-1);
K-=(A-1);

if(K%2==1) K--,ans+=1;
ans-= A*K/2;
ans += B*K/2;

cout<<ans<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int getD(int N){
	return to_string(N).length();
}
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	int s[M], c[M];
	int ans = -1;
	for (int i = 0; i < M; i++)
	{
		cin >> s[i] >> c[i];
	}
	for (int i = 0; i < 1000; i++)
	{
      	bool F = true;
		if(getD(i)!=N) continue;
		for (int j = 0; j < M; j++)
		{
			if(c[j] != (i/int(pow(10, N-s[j])))%10){
				F=false;
				break;
			}
		}
		if(F){
        	ans = i;
			break;
        }
	}
	cout << ans << endl;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int, int> PII;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
int mod = 1000000007;

/*FUNCs=================================================*/

//abc124 - d "handstand"

/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n,k; cin >> n >> k;
    string s; cin >> s;
    //圧縮
    vi seg_sum(n);
    vi cond(n);
    int idx = 0;
    cond[0] = s[0]-'0';
    for(int i = 0; i < n-1; ++i) {
        ++seg_sum[idx];
        if(s[i]!=s[i+1]) {
            ++idx;
            cond[idx] = s[i+1]-'0';
        }
    }
    ++seg_sum[idx];
    // siz : seg_sum,condのsize
    int siz = idx+1;

    //for(auto i : seg_sum) debug(i);
    //for(auto ch : cond) debug(ch);
    
    //累積和
    vi cum_sum(siz+1, 0);
    for(int i = 0; i < siz; ++i) {
        cum_sum[i+1] = cum_sum[i] + seg_sum[i];
    }

    //for(auto i : cum_sum) debug(i);

    int ans = 0;
    for(int i = 0; i < siz; i++) {
        int l, r;
        if(cond[i]==1) {
            l = i;
            r = i + k*2;
        }
        else {
            l = i-1;
            r = i - 1 + k*2;
        }
        l = max(l, 0);
        r = min(r, siz-1);
        int cnt = cum_sum[r+1] - cum_sum[l];
        chmax(ans, cnt);
    }

    cout << ans << '\n';
}


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

int main(){
	int N;
	cin >> N;
	vector<long long> A(N);
	for(auto &i:A)cin >> i;

	long long ans=0;
	int l=0,r=0;
	long long s=A[0],x=A[0];
	while(l<N){
		
		if(s==x){
			if(r<N-1){
				r++;
				s+=A[r];
				x^=A[r];
			}
			else{
				ans+=r-l+1;
				s-=A[l];
				x^=A[l];
				l++;
			}
		}
		else{
			ans+=r-l;
			s-=A[l];
			x^=A[l];
			l++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
n = int(input())
V = list(map(int,input().split()))

A = [[0] * (10**5+1) for i in range(2)]

for i in range(n):
    A[i%2][V[i]] += 1

C = [[0] * (10**5+1) for i in range(2)]  # A[0][:i], A[1][:i]の最大値
for i in range(1, len(C[0])):
    C[0][i] = max(C[0][i-1], A[0][i])
    C[1][i] = max(C[1][i-1], A[1][i])

# print(A[0][:150])
# print(A[1][:150])
# print(C[:150])

ans = 0
for i in range(1, len(C[0])):
    ans = max(ans, C[1][i-1] + A[0][i])
    ans = max(ans, C[0][i-1] + A[1][i])

print(n - ans)

Measured memory_bytes: 55148
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let s=sin()
  out(sw(s,[
    'SUN',7,
    'MON',6,
    'TUE',5,
    'WED',4,
    'THU',3,
    'FRI',2,
    'SAT',1,
  ]))
}
main()


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n, m;
    cin >> n >> m;

    int L = 0, R = n - 1;
    rep(i, 0, m) {
        int l, r;
        cin >> l >> r;
        L = max(L, l - 1);
        R = min(R, r - 1);
    }

    cout << max(R - L + 1, 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int s32_a,s32_b,s32_c;
    
    scanf("%d",&s32_a);
    scanf("%d",&s32_b);
    scanf("%d",&s32_c);
    
    if(s32_a - s32_b == 0)
    {
        printf("%d",s32_c);
    }
    else if(s32_a - s32_c == 0)
    {
        printf("%d",s32_b);
    }else
    {
        printf("%d",s32_a);
    }
    
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[100005],b[100005];
signed main(){
	int n;scanf("%d",&n);
	for(register int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
	}
	long long ans=0;
	for(register int i=n;i>=1;i--){
		ans+=(b[i]-(a[i]+ans%b[i]+b[i]-1)%b[i]-1);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4568
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define vec vector<int>
using namespace std;
int main()
{
    int count = 0;
    string S;
    cin >> S;
    rep(i, S.size())
    {
        if (S[i] == 'o')
        {
            count++;
        }
    }
    if (15 - S.size() + count >= 8)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
namespace eight_puzzle{
	typedef unsigned int uint;
	const int N = 3;
	const int ansval = 123456780;
	const int ansarray[N*N] = {1,2,3,4,5,6,7,8,0};
	uint arraytovalue(int *table){
		uint t=0;
		for(int i=0;i<N*N;++i){
			t*=10;
			t=t+table[i];
		}
		return t;
	}
	void valuetoarray(uint t,int *table){
		for(int i=N-1;i>=0;--i){
			for(int j=N-1;j>=0;--j){
				int panel = t-t/10*10;
				table[i*N+j] = panel;
				t/=10;
			}
		}		
	}
	uint getscore(uint t){
		int table[N*N];
		uint score = 0;
		valuetoarray(t,table);
		for(int i=0;i<N*N;++i){
			for(int j=0;j<N*N;++j){
				if(ansarray[i]==table[j]){
					score += (i/N-j/N)*(i/N-j/N)+(i%N-j%N)*(i%N-j%N);
					break;
				}
			}
		}
		return score;
	}
	struct State{
		State(const State &s){
			table = s.table;
			n = s.n;
			score = s.score;
		}
		State(const uint tt,const uint tn){
			table = tt;
			n = tn;
			score = getscore(table);
		}

		State& operator=(const State &s){
			table = s.table;
			n = s.n;
			score = s.score;
			return (*this);
		}
		bool operator<(const State& s) const{
			return score < s.score;
		}
		bool operator>(const State& s) const{
			return score > s.score;
		}
		bool isfinished() const{
				return table == 123456780;
		}
		
		uint table;
		uint n;
		uint score;
	};

	void getnextstate(const State &s,std::vector<State> &states){
		int table[N*N];
		int t = s.table;
		int zi,zj;
		valuetoarray(t,table);
		for(int i=0;i<N*N;++i){
			if(table[i]==0){
				zi = i/N;
				zj = i%N;
			}
		}
		for(int i=-1;i<=1;++i){
			for(int j=-1;j<=1;++j){
				if((i+j)%2==0)continue;
				int ti = zi+i,tj=zj+j;
				if(0<=ti&&ti<N&&0<=tj&&tj<N){
					std::swap(table[ti*N+tj],table[zi*N+zj]);
					states.push_back(State(arraytovalue(table),s.n+1));
					std::swap(table[ti*N+tj],table[zi*N+zj]);
				}
			}
		}
		
	}
	
	std::map<uint, bool> visited;
};

int main(){
	using namespace eight_puzzle;
	int array[N*N];
	for(int i=0;i<N*N;++i){
		std::cin>>array[i];
	}
	State init(arraytovalue(array),0);
	if(init.isfinished()){
		std::cout<<0<<std::endl;
		return 0;
	}
//	std::priority_queue<State,std::vector<State>,std::greater<State> > Q;
	std::queue<State> Q;
	Q.push(init);
	while(!Q.empty()){
		State s = Q.front();
		Q.pop();
		std::vector<State> states;
		getnextstate(s,states);
		for(uint i=0;i<states.size();++i){
			if(states[i].isfinished()){
				std::cout<<states[i].n<<std::endl;
				return 0;
			}
			if(visited.find(states[i].table)==visited.end()){
				Q.push(states[i]);
				visited[states[i].table]=true;
			}
		}
	}
	return 0;

}

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

void solve() 
{
    ll n;cin>>n;ll a[n];
    REP(i,n)cin>>a[i];
    sort(a,a+n);
    ll ans=0;
    vector<bool>flag(1000010,0);
    vector<int>flag2(1000010,0);
    REP(i,n){
        if(flag2[a[i]]==1){
            ans--;
            flag2[a[i]]=-1;
        }
        else if(!flag[a[i]]&&flag2[a[i]]==0){
            ans++;
            flag2[a[i]]=1;
            for(ll j=a[i];j<=1000000;j+=a[i]) flag[j]=1;
        }
    }
    cout<<ans<<endl;;
}

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

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

#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define for1(i, n) for (int i = 1; i <= (int)n; ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long i64;
typedef vector<int> vi;
typedef vector<i64> vi64;
typedef vector<vi> vvi;
typedef vector<vi64> vvi64;
typedef double ld;

i64 C[51][51];

void comb_table(int N) {
    forn (i, N + 1) forn(j, i + 1) {
        if (j == 0 or j == i) {
            C[i][j] = 1LL;
        } else {
            C[i][j] = (C[i - 1][j - 1] + C[i-1][j]);
        }
    }
}

int main() {

    
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int N, A, B;
    cin >> N >> A >> B;
    vector<double> v(N);
    forn(i, N) cin >> v[i];
    sort(all(v));
    reverse(all(v));

    double ans_ave = 0;
    forn(i, A) {
        ans_ave += v[i];
    }
    ans_ave /= (double)A;

    comb_table(50);

    int aval = 0;
    int apos = 0;

    forn(i, N){
        if (v[i] == v[A-1]) {
            aval++;
            if (i < A) apos++;
        }
    }

    i64 cnt = 0LL;
    if (apos == A) {
        fore(i, A, B) {
            cnt += C[aval][i];
        }
    } else {
        cnt += C[aval][apos];
    }

    cout << ans_ave << endl;
    cout << cnt << endl;
    return 0;
}



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

using namespace std;

const int maxn=2e5+5;

typedef long long ll;

int n;

char s[210][210];

int color[maxn];

bool dfs(int now,int col){
	color[now]=col;
	for(int i=1;i<=n;i++){
		if(s[now][i]=='1'){
			if(color[now]==color[i]) return false;
			if(!color[i]){
				if(!dfs(i,3-col)) return false;
			}	
		}
	}
	return true;
}

const int inf=0x3f3f3f3f;

int dis[210][210];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	memset(color,0,sizeof(color));
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%s",s[i]+1);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(s[i][j]=='0') dis[i][j]=inf;
			else dis[i][j]=1;
		}
	}
	
	int flag=1;
	if(!dfs(1,1)){
		flag=false;
	}
	for(int i=1;i<=n;i++){
		if(color[i]==0){
			flag=0;
			break;
		}
	}
	if(!flag){
		printf("-1");return 0;
	}
	
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if(dis[i][j]>dis[i][k]+dis[k][j]){
					dis[i][j]=dis[i][k]+dis[k][j];
				}
			}
		}
	}
//	for(int i=1;i<=n;i++){
//		for(int j=1;j<=n;j++){
//			printf("%d ",dis[i][j]);
//		}
//		printf("\n");
//	}
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(dis[i][j]<=inf&&i!=j){
				ans=max(ans,dis[i][j]);
			}
		}
	}
	printf("%d\n",ans+1);
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, int> pl;
typedef pair<ll, pl> pll;
 
#define fir first
#define sec second.first;
#define thr second.second;
#define INF (1ll << 60)
 
int n,m;
ll h[100800],dist[100800],ah[100800];
vector<pl> g[100800];
 
void dijkstra(ll height){
    int i,from,to;
    ll hi,d,l,nw;
    pll tmp;
    priority_queue<pll, vector<pll>, greater<pll> > pq;
    fill(dist,dist+n,INF);
    fill(ah,ah+n,0ll);
    dist[0] = 0ll;
    ah[i] = height;
    pq.push(pll(dist[0],pl(height,0)));
    while(!pq.empty()){
        tmp = pq.top();
        pq.pop();
        from = tmp.thr;
        hi = tmp.sec;
        d = tmp.fir;
        for(i=(g[from].size()-1); i>=0; i--){
            to = g[from][i].second;
            l = g[from][i].first;
            if(l<=hi){
                nw = d+l;
                if(dist[to]>=nw && h[to] >= hi-l){
                    if(dist[to]!=nw){
                        ah[to] = hi-l;
                    	dist[to] = nw;
                    	pq.push(pll(dist[to],pl(ah[to],to)));
                    }else if(ah[to] < hi-l){
						ah[to] = hi-l;
                    	dist[to] = nw;
                    	pq.push(pll(dist[to],pl(ah[to],to)));
                    }
                }else if(dist[to]>=nw){
                    nw += hi-l-h[to];
                    if(dist[to]>nw){
                        dist[to] = nw;
                        ah[to] = h[to];
                        pq.push(pll(dist[to],pl(ah[to],to)));
                    }else if(dist[to]==nw && ah[to]<h[to]){
                        dist[to] = nw;
                        ah[to] = h[to];
                        pq.push(pll(dist[to],pl(ah[to],to)));
                    }
                }
            }else if(l<=h[from]){
                nw = d+l-hi+l;
                if(dist[to]>nw){
                    ah[to] = 0ll;
                   	dist[to] = nw;
                    pq.push(pll(dist[to],pl(ah[to],to)));
                }
            }
        }
    }
}
 
int main(void){
    int i,a,b;
    ll x,t;
    cin >> n >> m >> x;
    for(i=0; i<n; i++){
        cin >> h[i];
    }
    for(i=0; i<m; i++){
        cin >> a >> b >> t;
        a--;
        b--;
        g[a].push_back(pl(t,b));
        g[b].push_back(pl(t,a));
    }
    dijkstra(x);
    if(dist[n-1]==INF){
        dist[n-1] = -1;
    }else{
        dist[n-1] += h[n-1] - ah[n-1];
    }
    cout << dist[n-1] << endl;
    return 0;
}

Measured memory_bytes: 23308
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <iomanip>
#include <tuple>
#include <queue>

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,k,q;
	cin >> n >> k >> q;
	int a[100005] = {};
	rep(i,0,q){
		int tmp;
		cin >> tmp;
		a[tmp-1]++;
	}

	rep(i,0,n){
		if(k-q+a[i]>0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;


}


Measured memory_bytes: 1024
def main():
    n, m = map(int, input().split(' '))
    dp = [10**9 for _ in range(2**n)]
    dp[0] = 0
    for i in range(m):
        a, b = map(int, input().split(' '))
        c = list(map(int, input().split(' ')))
        num = 0
        for j in range(b):
            num += 1 << (c[j]-1)
        for s in range(2**n):
            if dp[s|num] >= dp[s] + a:
                dp[s|num] = dp[s] + a
    if dp[-1] == 10**9:
        print(-1)
    else:
        print(dp[-1])
if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <bitset>
#include <utility>
#include <ctime>
#include <cassert>
#include <climits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii > vii;
typedef vector<pair<int, pair<int, int> > > viii;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<vii> vvii;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define MEM(a,b) memset(a,(b),sizeof(a))
#define tr(c,it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(a) a.begin(),a.end()
#define loop(x,a,b) for(int (x) = (a);(x)<(b);(x)++)
#define rep(x,n)   for(int (x)=0;(x)<(n);(x)++)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ain(a,n) int ((a)[(n)]); for(int i=0; i<(n); i++) cin>>((a)[i])  
#define md 1000000007
#define MAXN 200005

int main()
{   
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    ain(a,n);
    ll sm = 0;
    rep(i,n)
    	sm += max(0,a[i]);

    ll high = 0, low = 0, mn = 1e18;

    rep(i,k-1)
    {
    	if(a[i] > 0)
    		high += a[i];
    	else
    		low -= a[i];
    }

    loop(i,k-1,n)
    {
    	if(a[i] > 0)
    		high += a[i];
    	else
    		low -= a[i];
    	mn = min(mn,low);
    	mn = min(mn,high);

    	if(a[i-k+1] > 0)
    		high -= a[i-k+1];
    	else
    		low += a[i-k+1];
    }
    if(k == 1)
    	mn = 0;

    cout<<sm-mn<<"\n";

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
#include<complex>
using namespace std;

typedef complex<double> P;

#define X real()
#define Y imag()
typedef int kz;

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

bool pr(int n) {
    int i=2;
    while (i*i<=n) {
        if (n%i==0) return false;
            i++;
    }
    return true;
}


int main(){
    int mod=1000000007;
    int n;
    while (scanf("%d",&n)!=EOF) {
        int ans[2]={0,0};
        for (int i=n-1;n>0;--i) {
            if (pr(i)) {
                ans[0]=i;
                break;
            }
        }
        for (int i=n+1;i<100000;++i) {
            if (pr(i)) {
                ans[1]=i;
                break;
            }
        }
        printf("%d %d\n",ans[0],ans[1]);
    }
    return 0;
}

Measured memory_bytes: 3128
#include<stdio.h>

int main(void){

   int N,i,red_people = 0,blue_people = 0;
   char s[100];

   scanf("%d",&N);
   scanf("%s",s);

   for(i = 0;i < N;i++){
      if(s[i] == 'R'){
         red_people++;
      }else{
         blue_people++;
      }
   }

  if(red_people > blue_people){
      printf("Yes");
   }else{
      printf("No");
   }

  return 0;
}

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

typedef long long ll;
const int maxn = 320, maxm = 1e5;
const ll lim = 1e15, inf = 1e18;
int n, x[maxn + 3], y[maxn + 3], m, a[maxn + 3], b[maxn + 3];
int l[maxn + 3], r[maxn + 3], u[maxn + 3], d[maxn + 3];
int tot, wei[maxm + 3], ter[maxm + 3], nxt[maxm + 3], lnk[maxn + 3];
int src, snk, pre[maxn + 3];
bool in[maxn + 3];
ll v[maxn + 3], len[maxm + 3], dist[maxm + 3];
char s[maxn + 3];

int func(int x) {
	return x & 1 ? x + 1 : x - 1;
}

void add(int u, int v, int w, ll l) {
	ter[++tot] = v, wei[tot] = w, len[tot] = l;
	nxt[tot] = lnk[u], lnk[u] = tot;
}

void add_f(int u, int v, int w, ll l) {
	add(u, v, w, l);
	add(v, u, 0, -l);
}

bool spfa() {
	queue<int> Q;
	Q.push(src), in[src] = true;
	fill(dist + 1, dist + snk + 1, inf);
	dist[src] = 0;
	while (!Q.empty()) {
		int u = Q.front();
		Q.pop();
		in[u] = false;
		ll l = 0;
		for (int i = lnk[u], v; i; i = nxt[i]) {
			v = ter[i], l = len[i];
			if (wei[i] && dist[u] + l < dist[v]) {
				dist[v] = dist[u] + l;
				pre[v] = i;
				if (!in[v]) {
					in[v] = true;
					Q.push(v);
				}
			}
		}
	}
	return dist[snk] != inf;
}

void flow(int &res, ll &ans) {
	while (spfa()) {
		int x = snk;
		while (x != src) {
			wei[pre[x]]--, wei[func(pre[x])]++;
			x = ter[func(pre[x])];
		}
		res++;
		ans += dist[snk];
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d %d %lld", &x[i], &y[i], &v[i]);
	}
	scanf("%d", &m);
	for (int i = 1; i <= m; i++) {
		char t[5];
		scanf("%s %d %d", t + 1, &a[i], &b[i]);
		s[i] = t[1];
		if (s[i] == 'U') {
			s[i] = 'D';
		} else if (s[i] == 'D') {
			s[i] = 'U';
		}
	}
	ll ans = 0;
	for (int T = 1; T <= n; T++) {
		fill(l + 1, l + T + 1, 1);
		fill(r + 1, r + T + 1, 100);
		fill(u + 1, u + T + 1, 1);
		fill(d + 1, d + T + 1, 100);
		for (int i = 1; i <= m; i++) {
			if (b[i] + 1 > T) {
				continue;
			}
			if (s[i] == 'L') {
				l[b[i] + 1] = max(l[b[i] + 1], a[i] + 1);
			} else if (s[i] == 'R') {
				r[T - b[i]] = min(r[T - b[i]], a[i] - 1);
			} else if (s[i] == 'U') {
				u[b[i] + 1] = max(u[b[i] + 1], a[i] + 1);
			} else if (s[i] == 'D') {
				d[T - b[i]] = min(d[T - b[i]], a[i] - 1);
			}
		}
		for (int i = 2; i <= T; i++) {
			l[i] = max(l[i], l[i - 1]);
			u[i] = max(u[i], u[i - 1]);
		}
		for (int i = T - 1; i; i--) {
			r[i] = min(r[i], r[i + 1]);
			d[i] = min(d[i], d[i + 1]);
		}
		src = n * 4 + 1, snk = src + 1;
		tot = 0;
		fill(lnk + 1, lnk + snk + 1, 0);
		for (int i = 1; i <= T; i++) {
			add_f(src, i, 1, 0);
			for (int j = 1; j <= n; j++) {
				if (x[j] >= l[i] && x[j] <= r[i]) {
					add_f(i, j + n, 1, 0);
				}
			}
		}
		for (int i = 1; i <= n; i++) {
			add_f(i + n, i + n * 2, 1, lim - v[i]);
		}
		for (int i = 1; i <= T; i++) {
			add_f(i + n * 3, snk, 1, 0);
			for (int j = 1; j <= n; j++) {
				if (y[j] >= u[i] && y[j] <= d[i]) {
					add_f(j + n * 2, i + n * 3, 1, 0);
				}
			}
		}
		int fl = 0;
		ll mx = 0;
		flow(fl, mx);
		if (fl == T && T * lim - mx > ans) {
			ans = T * lim - mx;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

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

    if (K >= (1 << M)) {
        cout << -1 << endl;
        return 0;
    }

    if (M == 1) {
        if (K == 0)
            cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;

        if (K == 1)
            cout << -1 << endl;

        return 0;
    }

    vector<int> X;
    for (int i = 0; i < (1 << M); i++) {
        if (i != K) X.push_back(i);
    }

    for (int i = 0; i < X.size(); i++) cout << X[i] << " ";
    cout << K << " ";
    for (int i = X.size() - 1; i >= 0; i--) cout << X[i] << " ";
    cout << K << endl;
}


Measured memory_bytes: 2424
S = input()
flag = True
if S[0] != 'A':
    flag = False
if S[2:len(S)-1].count('C') != 1:
    flag = False
S = S[1:].replace('C', 'c')
if S.islower() and flag is True:
    print('AC')
else:
    print('WA')


Measured memory_bytes: 2940
[N, K] = list(map(int, input().split()))
[R, S, P] = list(map(int, input().split()))
T = str(input())
t = []
for i in range(K):
  t.append(T[i])
for i in range(K, N):
  if t[-K] != T[i]:
    t.append(T[i])
  else:
    t.append('Z')
R_s = R * len([r for r in t if r == 's'])
S_s = S * len([s for s in t if s == 'p'])
P_s = P * len([p for p in t if p == 'r'])
ans = int(R_s + S_s + P_s)
print(ans)

Measured memory_bytes: 4596
function Main(input) {
    var input_arr = input.split("\n");
    var input_arr_line0 = input_arr[0].split(" ");
    var a = input_arr_line0[0];
    var b = input_arr_line0[1];
    var c = input_arr_line0[2];

    var x = Math.floor(b / a);
    console.log(Math.min(c, x));
}

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

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct S
{
    ll g;
    ll s;
    ll b;
};

ll dp[5][5000 * 5000 + 5];

int main()
{
    ll N;
    cin >> N;

    S sa, sb;
    cin >> sa.g >> sa.s >> sa.b;
    cin >> sb.g >> sb.s >> sb.b;

    ll g = 0, s = 0, b = 0;

    //! 初回A
    {
        memset(dp, 0, sizeof(dp));
        //! ナップザックの価値と重さとみなす
        vector<pll> v; //! (w,v);
        v.push_back(pll(sa.g, sb.g - sa.g));
        v.push_back(pll(sa.s, sb.s - sa.s));
        v.push_back(pll(sa.b, sb.b - sa.b));

        REP(i, 3)
        {
            REP(j, N + 1)
            {
                if (j < v[i].first)
                {
                    dp[i + 1][j] = dp[i][j];
                }
                else
                {
                    dp[i + 1][j] = std::max(dp[i][j], dp[i + 1][j - v[i].first] + v[i].second);
                }
            }
        }
        N += dp[3][N];
    }

    //! 初回B
    {
        memset(dp, 0, sizeof(dp));
        //! ナップザックの価値と重さとみなす
        vector<pll> v; //! (w,v);
        v.push_back(pll(sb.g, sa.g - sb.g));
        v.push_back(pll(sb.s, sa.s - sb.s));
        v.push_back(pll(sb.b, sa.b - sb.b));

        REP(i, 3)
        {
            REP(j, N + 1)
            {
                if (j < v[i].first)
                {
                    dp[i + 1][j] = dp[i][j];
                }
                else
                {
                    dp[i + 1][j] = std::max(dp[i][j], dp[i + 1][j - v[i].first] + v[i].second);
                }
            }
        }
        N += dp[3][N];
    }

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

Measured memory_bytes: 976896
import numpy as P
M=10**9+7
m=lambda:map(int,input().split())
n,k=m()
a=P.matrix([list(m())for i in[0]*n],'O')
b=P.eye(n,n,0,'O')
while k:b=[b,b*a%M][k&1];a=a*a%M;k>>=1
print(b.sum()%M)

Measured memory_bytes: 14548
N = [int(e) for e in input().split()]
height = [int(t) for t in input().split()]
root = []
a = []
ans = 0
for i in range(N[0]):
    a.append([])
for  i in range(N[1]):
    root.append([int(t) for t in input().split()])
for roots in root:
    t = a[roots[0] - 1]
    t.append(roots[1])
    a[roots[0] - 1] = t
    t = a[roots[1] -1]
    t.append(roots[0])
    a[roots[1] - 1] = t
for j in range(N[0]):
    if(a[j] == []):
        ans += 1
        continue
    for k in range(len(a[j])):
        if(height[j] <= height[a[j][k] -1]):
            break
    else:
        ans += 1
print(ans)

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

int main() {

    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);


    int stime;
    int etime;
    if (a <= c) {
        stime = c;
    } else {
        stime = a;
    }
    if (b <= d) {
        etime = b;
    } else {
        etime = d;
    }
    printf("%d", (etime - stime>=0 ? etime-stime :0));



    return 0;

}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
int a,b,c,k,i;
k = 0;
scanf("%d %d %d",&a,&b,&c);
for(i=a; i<=b; ++i){
if(c%i == 0){
k++;
}
}
printf("%d\n",k);
return 0;
}

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

typedef long long ll;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007

int main() {
    int n;cin>>n;
    vector<int>a(n);
    double avr=0;
    rep(i,n){
        cin>>a[i];
        avr+=a[i];
    }
    avr /=n;

    double min=100;
    int ans=0;
    rep(i,n){
        if(abs(a[i]-avr)<min){
            min=abs(a[i]-avr);
            ans=i;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <cstdio>
#include <bitset>
#include <map>


using namespace std;

int main()
{
    int m, f, r;
    while (cin >> m >> f >> r)
    {
        //method 1
        // if (m==-1 && f==-1 && r==-1)
        //     break;
        
        // if (m==-1 || f==-1)
        // {
        //     cout << 'F' << endl; 
        //     continue;           
        // }


        // if (m+f >= 80)
        //     cout << 'A';
        // else if (m+f >= 65)
        //     cout << 'B';
        // else if (m+f>=50)
        //     cout << 'C';
        // else if (m+f >= 30)
        //     if (r >= 50)
        //         cout << 'C';
        //     else
        //         cout << 'D';
        // else
        //     cout << 'F';

        // cout << endl;

        //method 2
        if (m==-1 && f==-1 && r==-1)
            break;
        
        if (m==-1 || f==-1 || m+f<30)
            cout << 'F'; 
        else if (m+f >= 80)
            cout << 'A';
        else if (m+f >= 65)
            cout << 'B';
        else if (m+f>=30 && r>=50 || m+f>=50)
            cout << 'C';
        else
            cout << 'D';

        cout << endl;
    }
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef
tree<
  pair<int,int>,
  null_type,
  less<pair<int,int>>,
  rb_tree_tag,
  tree_order_statistics_node_update>
map_t;
int main() {
  int N;
  cin >> N;
  int X[N];
  map_t a;
  map<int,int> b;
  for (int i = 0; i < N; i++) {
    cin >> X[i];
    a.insert(make_pair(X[i],++b[X[i]]));
  }
  for (int i = 0; i < N; i++) {
    a.erase(make_pair(X[i],b[X[i]]));
    cout << a.find_by_order(N/2-1)->first << endl;
    a.insert(make_pair(X[i],b[X[i]]));
  }
}

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

int h, w;
int grid[400][400];
int arrived[400][400];

pair<int, int>  dfs(int x, int y, pair<int, int>  cnt) {
  if (arrived[y][x]) {
    return cnt;
  }
  arrived[y][x] = 1;
  if (grid[y][x]) {
    ++cnt.first;
  } else {
    ++cnt.second;
  }
  if (x > 0 && grid[y][x-1] ^ grid[y][x]) cnt = dfs(x-1, y, cnt);
  if (x < w-1 && grid[y][x+1] ^ grid[y][x]) cnt = dfs(x+1, y, cnt);
  if (y > 0 && grid[y-1][x] ^ grid[y][x]) cnt = dfs(x, y-1, cnt);
  if (y < h-1 && grid[y+1][x] ^ grid[y][x]) cnt = dfs(x, y+1, cnt);

  return cnt;
}
int main() {
  cin>>h>>w;
  for (int i=0; i<h; i++) {
    string s;
    cin>>s;
    for (int j=0; j<w; j++) {
      grid[i][j] = s[j] == '#';
    }

  }
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      arrived[i][j] = 0;
    }
  }
  long long ans = 0;
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (!arrived[i][j]) {
        auto cnt = dfs(j, i, make_pair(0, 0));
        ans += (long long)cnt.first * cnt.second;
      }
    }
  }
  cout<<ans<<endl;
}

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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
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;
}

int main(){
  COMinit();
  int n;
  cin >> n;
  vector<int> a(n+1), id(n, -1);
  int left, right;
  REP(i, n+1){
    cin >> a[i];
    a[i]--;
    if(id[a[i]] == -1){
      id[a[i]]=i;
    }
    else{
      left = id[a[i]], right = i;
    }
  }
  int b = left + (n+1-right-1);
  FOR(i, 1, n+2){
    ll ans = 0;
    ans += COM(n+1, i);
    ans %= mod;
    ans -= COM(b, i-1);
    ans %= mod;
    if(ans < 0){
      ans += mod;
    }
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 13952
import java.util.HashMap;
import java.util.Scanner;


public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long [] arr = new long[n];
    HashMap<Long,Integer> hm = new HashMap();
    long sum = 0;
    for(int i = 0; i < n; i++) {
      long now = sc.nextLong();
      sum += now;
      if(!hm.containsKey(now))
        hm.put(now,0);
      hm.put(now,hm.get(now)+1);
    }
    int q = sc.nextInt();
    while(q--!=0) {
      long now = sc.nextLong();
      long to = sc.nextLong();
      if(hm.containsKey(now)) {
        sum -= hm.get(now)*now;
        sum += hm.get(now)*to;
      if(!hm.containsKey(to)) {
        hm.put(to,hm.get(now));
      } else {
        hm.put(to,hm.get(to)+hm.get(now));
      }
      hm.remove(now);
      }
      System.out.println(sum);
    }
  }

}


Measured memory_bytes: 70376
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N, M;
  cin >> N >> M;
  int ans = 0;
  if(N > 1) ans += N * (N-1) / 2;
  if(M > 1) ans += M * (M-1) / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    cin.ignore();
    string hit = "HIT";
    string home = "HOMERUN";
    string out = "OUT";
    string in;
    bool* runer = new bool[3];
    int point = 0;
    int outcount;
    for(int i = 0; i < n; ++i) {
        outcount = 0;
        point = 0;
        for(int j = 0; j < 3; ++j) {
            runer[j] = false;
        }
        while(1) {
            cin >> in;
            if (in.compare(hit) == 0) {
                if (runer[0] == false) {
                    runer[0] = true;
                }
		else {
                    if (runer[1] == false) {
                        runer[1] = true;
                    }
                    else {
                        if (runer[2] == false) {
                            runer[2] = true;
                        }
                        else {
                            ++point;
                        }
                    }

                }

            }
 else if (in.compare(home) == 0) {
                ++point;
                if (runer[0] == true) {
                    ++point;
                    if (runer[1] == true) {
                        ++point;
                        if (runer[2] == true) {
                            ++point;
                        }
                    }

                }

                for(int j = 0; j < 3; ++j) {
                    runer[j] = false;
                }


            }
            else if (in.compare(out) == 0) {
                ++outcount;
                if (outcount >= 3) {
                    cout << point << endl;
                    break;
        	}
            }

        }

    }
    delete [] runer;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

string s;
int n;

ll f(int ind, ll sum) {
    if (ind == n) return sum;
    ll num = 0, r = 0;
    fore(i,ind,n) {
        num = num*10 + s[i]-'0';
        r += f(i+1, sum+num);
    }
    return r;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    cin >> s;
    n = s.size();
    cout << f(0, 0) << endl;
}


Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cassert>
#include <unordered_set>
#include <set>

#define prev asasddlsa
#define rank aljds

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll sum = 0, val = 0;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        sum += x;
        val += x * x;
    }
    cout << (sum * sum - val) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
//ワーシャルフロイド（全点対最短路問題）
//スタート地点１つに対してゴールが２つ。流れるものは水
//故に、単純に $cost[$s][$g1] + $cost[$s][$g2] とするとWA
//スタート〜ある点までは合流道。ある点〜それぞれのゴールまでは二股に分かれて進むイメージ
//また、有向グラフ（一方通行）なので注意。
//と言ってもむしろ$cost[$b][$a] = $cost[$a][$b]というコピーが不要になるので楽。


$file_handle = fopen('php://stdin', "r");
//$file_handle = fopen('aoj2005_in.txt', "r");


function warshall_floyd($cost) {
	global $n;

	for ($i = 1; $i <= $n; ++$i) {
	    for ($j = 1; $j <= $n; ++$j) {
	        for ($k = 1; $k <= $n; ++$k) {
	            // j -> kへ行くのにiを経由した方が良いかどうか(cost)
	            $via = $cost[$j][$i] + $cost[$i][$k];
	            if ($via < $cost[$j][$k]) {
	                $cost[$j][$k] = $via;
	            }
	        }
	    }
	}
	return $cost;
}


while(1){
	//ファイル読み込み
	$info = trim(fgets($file_handle));
	$explode = explode(' ', $info);
	$n = $explode[0]; $m = $explode[1]; $s = $explode[2]; $g1 = $explode[3]; $g2 = $explode[4];
	//終了条件
	if ($n==0 && $m==0 && $s==0 && $g1==0 && $g2==0) break;
	
	//初期化
	$cost = array();

	//ワーシャルフロイド準備。
	for ($i=1; $i<=$n; ++$i){
		for ($j=1; $j<=$n; ++$j){
			if ($i === $j){
				$cost[$i][$i] = 0;
			} else {
				$cost[$i][$j] = INF;
			}
		}
	}

	//辺の情報を格納
	for ($i=1; $i<=$m; ++$i){
		$info2 = trim(fgets($file_handle));
		$explode = explode(' ', $info2);
		$a = $explode[0]; $b = $explode[1]; $c = $explode[2];
		$cost[$a][$b] = $c;
	}

	//探索。先に全点対最短路を求めておく必要がある
	$cost = warshall_floyd($cost);
	
	//最小値計算
	$min = INF;
	for($i=1; $i<=$n; ++$i){
		//どこで分岐するのが最も総コストが低いか比較
		$via = $cost[$s][$i] + $cost[$i][$g1] + $cost[$i][$g2];
		$min = min($min, $via);
	}
	
	//出力
	echo $min;
	echo PHP_EOL;
}

fclose($file_handle);

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

using namespace std;

int main() {
    long long n, a, b;
    cin >> n >> a >> b;

    long long blue = n / ( a + b ) * a;
    long long remain = n % ( a + b);
    blue +=  min(remain,a);
    cout << blue << endl;
      
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);ios::sync_with_stdio(false);



signed main(){
    string s;
    cin>>s;
    rep(i,siz(s)){
        if(i%2==0 && s[i]=='L'){
            cout<<"No"<<endl;
            return 0;
        }else if(i%2==1 && s[i]=='R'){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
def solve(k,as)
  n = as.length
  n.times do |i|
    next if k[i] == 0
    as[i].each do |x,y|
      return 0 if k[x] != y
    end
  end
  ans = 0
  n.times do |i|
    ans += 1 if k[i] == 1
  end
  return ans
end

n = gets.to_i
as = []
n.times do |i|
  a = gets.to_i
  tmp = []
  a.times do |j|
    x,y = gets.split.map(&:to_i)
    x -= 1
    tmp << [x,y]
  end
  as << tmp
end

ans = 0
(2**n).times do |i|
  tmp = solve(i,as)
  ans = tmp if tmp > ans
end
p ans

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

int main() {
	int n,d,x; cin>>n>>d>>x;
	for(int i=0;i<n;i++){
		int a; cin>>a;
		x+=(d-1)/a+1;
	}
	cout<<x<<endl;
	return 0;
}

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

int main() {
  int na, nb, m;
  cin >> na >> nb >> m;
  vector<int> a(na), b(nb);

  rep(i,na) cin >> a[i];
  rep(i,nb) cin >> b[i];

  

  int ans = 1001001001;
  for(int i=0; i<m; i++){
    int x,y,z;
    int sum=0;
    cin >> x >> y >> z;
    sum = a[x-1]+b[y-1]-z;
    ans = min(ans,sum);
  }

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  ans = min(ans,a[0]+b[0]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
while 1:
    n, m = map(int, raw_input().split())
    if n == m == 0:
        break
    p = [0]*m
    for i in xrange(n):
        d, v = map(int, raw_input().split())
        p[d-1] = max(p[d-1], v)
    print sum(p)

Measured memory_bytes: 6420
using System;
using System.Collections.Generic;

namespace cswork {
    class Program {
        static void Main (string[] args) {
            string s = ReadStr();
            if(s.Equals("a") || s.Equals("i") || s.Equals("u") || s.Equals("e") || s.Equals("o")){
                Write("vowel");
            }else{
                Write("consonant");
            }
            Exit ();
        }

        public static void Write (string str) {
            Console.WriteLine (str);
        }

        public static void Write (int i) {
            Console.WriteLine (i);
        }

        public static void Write (double d) {
            Console.WriteLine (d);
        }

        public static string ReadStr () {
            return Console.ReadLine ();
        }

        public static int ReadInt () {
            return int.Parse (Console.ReadLine ());
        }

        public static long Read () {
            return long.Parse (Console.ReadLine ());
        }

        public static double ReadDouble () {
            return double.Parse (Console.ReadLine ());
        }

        public static void Exit () { }

        public static List<string> ReadListStr () {
            return new List<string> (ReadStr ().Split (" "));
        }

        public static List<long> ReadList () {
            return ReadListStr ().ConvertAll (x => long.Parse (x));
        }

        public static List<int> ReadListInt () {
            return ReadListStr ().ConvertAll (x => int.Parse (x));
        }
    }
}

Measured memory_bytes: 25760
N,M,Q=map(int,input().split())
que=[tuple(map(int,input().split())) for _ in range(Q)]
task=[]
sta=[[i] for i in range(1,M+1)]
while sta:
    s=sta.pop()
    if len(s)==N: task.append(s)
    else:
        for d in range(int(s[-1]),M+1):
            sta.append(s+[d])
ans=0
for s in task:
    tmp=0
    for a,b,c,d in que:
        if s[b-1]-s[a-1]==c: tmp+=d
    ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 23020
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>
#define MAXN 100

using namespace std;
int t[MAXN+8],p[MAXN+8],x[MAXN+8];
int main()
{
	int n,m,i,S=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",t+i),S+=t[i];
	scanf("%d",&m);
	for(i=1;i<=m;i++)
		scanf("%d%d",p+i,x+i);
	for(i=1;i<=m;i++)
		printf("%d\n",S-t[p[i]]+x[i]);
    return 0;
}

Measured memory_bytes: 256