akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>

#pragma comment(linker, "/STACK:336777216")  

using namespace std;

const int MAXN = 200000 + 10;

int N;
bool ok[1 << 26];
int B[MAXN];
char S[MAXN];
int DP[MAXN];
int there[1 << 26];

void Work()
{
	ok[0] = true;
	for (int i = 0; i < 26; i ++)
		ok[1 << i] = true;

	scanf("%s", S);
	N = strlen(S);
	B[0] = 0;
	for (int i = 1; i <= N; i ++)
		B[i] = B[i - 1] ^ (1 << (S[i - 1] - 'a'));

	memset(there, 10, sizeof(there));
	DP[0] = 0;
	there[0] = 0;
	for (int i = 1; i <= N; i ++)
	{
		DP[i] = there[B[i]] + 1;
		for (int j = 0; j < 26; j ++)
			DP[i] = min(DP[i], there[B[i] ^ (1 << j)] + 1);
		there[B[i]] = min(there[B[i]], DP[i]);
	}
	printf("%d\n", DP[N]);
}

int main()
{
	Work();
	return 0;
}

Measured memory_bytes: 274816
#include <iostream>

int main(){
    int S;
    std::cin >> S;
    int h = S / 3600;
    int m =  S % 3600 / 60;
    int s = S % 3600 % 60;

    std::cout << h << ":" << m << ":" << s << std::endl;
    return 0;
}



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

using namespace std;

int cnt[1005][1005];
const int MOD = 1e9+7;

int main(){

	int h,w;
	cin >> h >> w;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			char a;
			cin >> a;
			if(i==1 and j==1)
				cnt[i][j]=1;
			else if(a=='#')
				cnt[i][j]=0;
			else
				cnt[i][j] = cnt[i-1][j] + cnt[i][j-1];
			cnt[i][j] %= MOD;
		}
	}
	cout << cnt[h][w];
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
 
    ll a,b;
    cin>>a>>b;
    ll x=a*b;
    
    
    if(a==1||b==1){cout<<1<<endl;}
    else if(x%2==0)
    {
        cout<<x/2<<endl;
    }
    else {cout<<(x/2)+1<<endl;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    return 0;
}

Measured memory_bytes: 256
n, t = map(int, input().split())
a = list(map(int, input().split()))

time = 0
for i in range(n-1):
    if a[i + 1] - a[i] < t:
        time += a[i + 1] - a[i]
    elif a[i + 1] - a[i] >= t:
        time += t
print(time + t)


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


int main() {
  int n;
  cin >> n;
 string s; 
  cin >> s;
  int count = 0;
  
  for(int i=0; i < n-2; i++){
    if(s.at(i) == 'A'){
      if(s.at(i+1) == 'B'){
        if(s.at(i+2) == 'C'){
          count++;
        }
      }
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n, u, V;
vector<int> et[100000];
int dist1[100000];
int dist2[100000];
int parent[100000];	//Vを根とする

void dfs(int p, int v, int dep, int dist[]) {
	parent[v] = p;
	dist[v] = dep;
	
	int i;
	rep(i, et[v].size()) {
		int nv = et[v][i];
		if (nv == p) continue;
		dfs(v, nv, dep + 1, dist);
	}
}

int dfs2(int p, int v) {
	int i;
	
	int ret = dist2[v] - 1;
	
	rep(i, et[v].size()) {
		int nv = et[v][i];
		if (nv == p) continue;
		int res = dfs2(v, nv);
		ret = max(ret, res);
	}
	return ret;
}

signed main() {
	int i;
	
	cin >> n >> u >> V;
	u--; V--;
	
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		et[a].push_back(b);
		et[b].push_back(a);
	}
	
	dfs(-1, u, 0, dist1);
	dfs(-1, V, 0, dist2);
	
	int bu = -1;
	while (u != -1 && dist2[u] - dist1[u] > 0) {
		bu = u;
		u = parent[u];
	}
	if (bu == -1) { cout << 0 << endl; return 0; }
	u = bu;
	
	//cout << "u = " << u + 1 << endl;
	//rep(i, n) cout << i + 1 << " : " << dist1[i] << ", " << dist2[i] << endl;
	
	int res = dfs2(parent[u], u);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 14592
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
int n;
int col[200005], sub[200005], tmp[200005];
vector<int> edges[200005];
ll ans[200005];
void dfs (int u, int par) {
  //cout << "u: " << u << ' ' << par << endl;
  int p = tmp[col[u]];
  int ini = p;
  ll s = 0;
  sub[u] = 1;
  for (int v : edges[u]) {
    if (v == par) continue;
    dfs(v, u);
    int q = tmp[col[u]];
    ans[col[u]] += s * (sub[v] + (q - p)); 
    //cout << sub[v] << ' ' << q - p << endl;
    s += sub[v] + (q - p); p = q;
    sub[u] += sub[v];
  }
  ans[col[u]] += (s + 1) * (n + ini - sub[u] + 1);
  tmp[col[u]] = ini - sub[u];
  //cout << endl;
}
int main () {
  scanf("%d", &n);
  FOR(i, 1, n) {
    scanf("%d", &col[i]);
  }
  FOR(i, 1, n - 1) {
    int u, v;
    scanf("%d %d", &u, &v);
    edges[u].pb(v); edges[v].pb(u);
  }
  SET(ans, 0);
  dfs(1, -1);
  FOR(i, 1, n) printf("%lld\n", ans[i]);
  return 0;
}

Measured memory_bytes: 40436
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
using namespace std;

int n;
vector<int> s;

int main(){
    while(1){
        cin>>n;
        if(n==0)break;
        int sum=0;
        for(int i=0;i<n;++i){
            int num;
            cin>>num;
            s.push_back(num);
            sum+=num;
        }
        double ave = (double)sum/n;
        double sum2=0;
        for(int i=0;i<s.size();++i){
            sum2 += (s[i]-ave)*(s[i]-ave);
        }
        double variance=sum2/n;
        double SD=sqrt(variance);
        printf("%.5lf\n",SD);
        s.clear();
    }
    
    return 0;
}



Measured memory_bytes: 3228
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
	if(!b)return 1;	if(b&1)return modpow(a,b-1,m)*a%m;
	int memo = modpow(a,b>>1,m);
	return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a;
  cin>>a;
  vector<int> b(a);
  rep(i,a)
    cin>>b[i];
  int c=0,d=0;
  rep(i,a){
  if(c<=b[i]){
  c=b[i];
    d++;
    }
    }
  
    out(d);
}

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

int N, A[10000];

bool isPrimeNumber(int x) {
  if (x == 2) return true;
  if (x % 2 == 0) return false;
  for (int i = 3; i <= sqrt(x); i += 2) {
    if (x % i == 0) return false;
  }
  return true;
}

int main(void){
  cin >> N;
  
  int cnt = 0, x;
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (isPrimeNumber(x)) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(b<a) { a=b; return 1; } return 0; }

int main(){
  int x,y; cin >> x >> y;

  int ans1 = INF, ans2 = INF, ans3 = INF;
  if(x < y){
    ans1 = y - x;
  }else{
    if(0 <= x && 0 <= y && -x < y){
      if(y) ans2 = x + y;
      else ans2 = x + y + 1;
    }
  }

  if(x < 0 && y < 0){
    ans3 = 2;
    x *= -1;
    y *= -1;
  }else if(x < 0){
    ans3 = 1;
    x *= -1;
  }else if(y < 0){
    ans3 = 1;
    y *= -1;
  }
  ans3 += abs(x-y);

  cout << min({ans1,ans2,ans3});
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3432
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
mt19937 R(chrono::system_clock().now().time_since_epoch().count());

const int N = 1e6+11;
ll n,a[N],hz[N],cur=1,res=1;
int main() {
	read(n);rep(i,0,n)read(a[i]);
	per(i,n,0)hz[i]=hz[i+1]+a[i];
	if(a[0]){
		if(!n&&a[0]==1)puts("1");else puts("-1");
		return 0;
	}
	rep(i,1,n){
		cur=min(2*cur,hz[i]);
		res+=cur;cur-=a[i];if(cur<0){puts("-1");return 0;}
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 5204
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    ll ans = 0;
    int tmp;
    int n;
	cin >> n;
	vector<int> a(n);
	REP(i, n) cin >> a[i];
	vector<int> b(n);
	REP(i, n) cin >> b[i];
	vector<int> c(n);
	REP(i, n) cin >> c[i];
	a.push_back(INF);
	b.push_back(INF);
	c.push_back(INF);
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	ll summi[n+1] = {};
	int z = 0;
	REP(y, n){
		while (c[z] <= b[y] && z < n)
		{
			z++;
		}
		summi[y] = n - z;
	}
	summi[n] = 0;
	for(int y = n-1; y >= 0; y--){
		summi[y] += summi[y+1];
	}
	//REP(i, n+1) cout << summi[i] << " " ;
	//cout << endl;
	z = 0;
	REP(x, n){
		while (b[z] <= a[x] && z < n)
		{
			z++;
		}
		ans += summi[z];
	}

    cout << ans << endl;
}

Measured memory_bytes: 2280
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	int t[55];
	while(cin>>n>>m){
		if(!n)break;
		memset(t,0,sizeof(t));
		a=m;
		for(i=0;;i++){
			if(i==n)i=0;
			if(a>0)t[i]++,a--;
			else a=t[i],t[i]=0;
			if(t[i]==m)break;
		}
		cout<<i<<endl;
	}
}



Measured memory_bytes: 3076
using System;

namespace Atcoder
{
    class ABC123_A
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int d = int.Parse(Console.ReadLine());
            int e = int.Parse(Console.ReadLine());
            int k = int.Parse(Console.ReadLine());

            if(e - a <= k)
            {
                Console.Write("Yay!");
            }
            else
            {
                Console.Write(":(");
            }
        }
    }
}


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

int main()
{
    int bit,i,j,M,N;
    int number[10],switches[10][10],onoff[10];int ultimatesum=0;
    cin>>N>>M;
    for(i=0;i<M;i++)
    {
        cin>>number[i];
        for(j=0;j<number[i];j++)
            scanf("%d",&switches[i][j]);
    }
    for(i=0;i<M;i++)cin>>onoff[i];
    for(bit=0;bit<pow(2.0,(double)N);bit++)
    {
        for(i=0;i<M;i++)
        {
            int somesum1=0;
            for(j=0;j<number[i];j++)
                {int somesum2=(bit>>(switches[i][j]-1))%2;
                somesum1+=somesum2;
                }
            if(somesum1%2!=onoff[i])break;
        }
        if(i==M) ultimatesum++;
    }
    cout<<ultimatesum<<endl;


    return 0;
}


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

// MOD p でいくつクラス
#define MOD 998244353
class mll {
	unsigned long long val = 0;
public:
	mll(long long y = 0) : val(((y % MOD) + MOD) % MOD) {}
	mll operator + (const mll& y) { return mll(*this) += y; }
	mll& operator += (const mll& y) {
		val = (val + y.val) % MOD;
		return *this;
	}
	mll operator - (const mll& y) { return mll(*this) -= y; }
	mll& operator -= (const mll& y) {
		val = (val - y.val + MOD) % MOD;
		return *this;
	}
	mll operator * (const mll& y) { return mll(*this) *= y; }
	mll& operator *= (const mll& y) {
		val = (val * y.val) % MOD;
		return *this;
	}
	mll operator / (const mll& y) { return mll(*this) /= y; }
	mll& operator /= (const mll& y) {
		long long a = y.val, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		mll c = val * u; // この計算でoverflowしないか？
		val = c.val;
		return *this;
	}
	bool operator >= (const mll& y) {
		return this->val >= y.val;
	}
	mll pow(long long t) const {
		if (!t) return 1;
		mll a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	unsigned long long getVal() {
		return val;
	}
	friend ostream& operator <<(ostream& os, mll& y) {
		os << y.val;
		return os;
	}
};
#undef MOD


int A, B, C, D;
vector<vector<mll> > X;

mll f(int a, int b) {
	if (a < A || b < B) return mll(1);
	if (a == A && b == B) return mll(1);
	if (a == A) return mll(a) * f(a, b - 1);
	if (b == B) return mll(b) * f(a - 1, b);
	if (X[a][b].getVal() > 0) return X[a][b];
	mll x = mll(a) * f(a, b - 1) + mll(b) * f(a - 1, b) - mll(a - 1)*mll(b - 1)*f(a - 1, b - 1);
//	cout << A << ", " << B << ", " << a << ", " << b << ", " << "," << x.getVal() << endl;
	X[a][b] = x;
	return x;
}

int main() {

	cin >> A >> B >> C >> D;
	X = vector<vector<mll> >(C+1,vector<mll>(D+1,0));
	mll ans = f(C, D);
	cout << ans.getVal() << endl;
	return(0);
}


Measured memory_bytes: 74032
#include <stdio.h>
 
int main ()
 
{
    double r, area, circumference;
     scanf("%lf", &r);
     area=3.141592653589*r*r;
     circumference=2*3.141592653589*r;
     printf("%lf %lf\n", area, circumference);
     return 0;
}


Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<ll> sum(n + 1,0),a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum[i + 1] = sum[i] + a[i];
    }
    ll ans = 1145141919810364;
    for(int i = 0; i < n; i++){
        ans = min(ans, abs(sum[i + 1] - (sum[n] - sum[i + 1])));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
import java.util.*;

public class Main {
  static int head = 0;
  static int tail = 0;
  static int max = 100000;
  static int[] queue = new int[max];
  static String[] str = new String[max];

  public static void initialize() {
    head = tail = 0;
  }
  public static boolean isEmpty() {
    return head == tail;
  }
  public static boolean isFull() {
    return head == (tail + 1) % max;
  }
  public static void enqueue(int x, String s) {
    if(isFull()) {
      throw new IllegalArgumentException("オーバーフロー");
    } else {
      queue[tail] = x;
      str[tail] = s;
      if(tail + 1 == max) {
        tail = 0;
      } else {
        tail++;
      }
    }
  }
  public static int dequeue() {
    if(isEmpty()) {
      throw new IllegalArgumentException("アンダーフロー");
    } else {
      int x = queue[head];
      if(head + 1 == max) {
        head = 0;
      } else {
        head++;
      }
      return x;
    }
  }
  public static String destr() {
    if(head == 0) {
      return str[max - 1];
    } else {
      return str[head - 1];
    }
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int q = sc.nextInt();
    String s = "";
    int a = 0;
    int time = 0;
    for(int i = 0; i < n; i++) {
      s = sc.next();
      a = sc.nextInt();
      if(a <= q) {
        time += a;
        System.out.println(s + " " + time);
      } else {
        time += q;
        enqueue(a - q, s);
      }
    }
    while(!isEmpty()) {
      a = dequeue();
      s = destr();
      if(a <= q) {
        time += a;
        System.out.println(s + " " + time);
      } else {
        time += q;
        enqueue(a - q, s);
      }
    }
  }
}



Measured memory_bytes: 68656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
double ans=0.0;
double kouho=0;
void Main(){
    ll n;cin>>n;
    ll k;cin>>k;
    vector<ll> p(n);
    For(i,0,n) cin>>p[i];
    vector<double> d(n);
    For(i,0,n) d[i]=(p[i]+1.0)/2.0;
    For(i,0,k) kouho+=d[i];
    ans=kouho;
    For(i,k,n){
        kouho-=d[i-k];
        kouho+=d[i];
        ans=max(ans,kouho);
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int count = 0;
        for (int i=0; i<=N-3; i++) {
            String temp = S.substring(i,i+3);
            if (temp.equals("ABC")) {
                count++;
            }
        }
        System.out.println(count);
    }
}

// cool function

//     public static boolean isPrime(int n) {
//        return !new String(new char[n]).matches(".?|(..+?)\\1+");
//    }


Measured memory_bytes: 22484
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	int A,B;
	vector<int> M(3);
	cin >> A >> B;
	M[0]=A+(A-1);
	M[1]=A+B;
	M[2]=B+(B-1);
	int m;
	m=max(M[0],M[1]);
	m=max(m,M[2]);
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


int main(){
  int N, K; cin >> N >> K;
  vector < pair<ll, ll> > XY(N);
  for (int i = 0; i < N; i++){
    ll X, Y; cin >> X >> Y;
    XY[i] = make_pair(X, Y);
  }

  ll ans = -1;
    for (int i1 = 0; i1 < N; i1++){
      ll X1 = XY[i1].first, Y1 = XY[i1].second;
      for (int i2 = 0; i2 < N; i2++){
        ll X2 = XY[i2].first, Y2 = XY[i2].second;
        for (int i3 = 0; i3 < N; i3++){
          ll X3 = XY[i3].first, Y3 = XY[i3].second;
          for (int i4 = 0; i4 < N; i4++){
            ll X4 = XY[i4].first, Y4 = XY[i4].second;

            ll X = max(max(X1, X2), max(X3, X4));
            ll x = min(min(X1, X2), min(X3, X4));
            ll Y = max(max(Y1, Y2), max(Y3, Y4));
            ll y = min(min(Y1, Y2), min(Y3, Y4));

            int cnt = 0;
            for (int i = 0; i < N; i++){
              if (x <= XY[i].first && XY[i].first <= X){
                if (y <= XY[i].second && XY[i].second <= Y){
                  cnt++;
                }
              }
            }
            
            if (cnt >= K){
              if (ans == -1) ans = (X - x) * (Y - y);
              else ans = min(ans, (X - x) * (Y - y));
            }
          }
        }
      }
    }
  
  
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

template<int Mod> struct ModInt {
    ll x;
    ModInt() : x(0) {}
    ModInt(ll sig) { int sigt = sig % Mod; if(sigt < 0) sigt += Mod; x = sigt; }
    int get() const { return (int)x; }

    ModInt &operator+=(ModInt that) { if((x += that.x) >= Mod) x -= Mod; return *this; }
    ModInt &operator-=(ModInt that) { if((x += Mod - that.x) >= Mod) x -= Mod; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % Mod; return *this; }

    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    friend ostream& operator<<(ostream& stream, const ModInt& that) { return (stream << that.x); }
};
typedef ModInt<MOD> mint;

int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    mint m(1);
    vector<int> c(3);
    REP(i, N){
        ll cnt = 0;
        if(c[0] == A[i]) cnt++; 
        if(c[1] == A[i]) cnt++; 
        if(c[2] == A[i]) cnt++;

        m *= cnt;
        REP(j, 3){
            if(c[j]==A[i]){
                c[j]++;
                break;
            }
        }
    }
    pr(m);
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int main() {
  ll A,B,C; cin >> A >> B >> C;
  if ( A+B >= C ) cout << B+C << endl;
  else cout << A+B+B+1 << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
// スペース区切りの整数の入力
fscanf(STDIN, "%d %d", $N, $M);
// 文字列の入力
fscanf(STDIN, "%s", $s);
fscanf(STDIN, "%s", $t);

$n = $N;
$m = $M;

//とりあえずnとmの最大公約数を求める
//ユークリッドの互除法
if($n < $m) {
  while($n !== 0){
      $tmp_n = $n;
      $n = $m % $n;
      $m = $tmp_n;
  }
  $gcd = $m;
} else {
  while($m !== 0){
      $tmp_m = $m;
      $m = $n % $m;
      $n = $tmp_m;
  }
  $gcd = $n;
}
//最小公倍数
$lcm = $M * $N / $gcd;

$bool = true;
for ($i = 0; $i < $gcd; $i++) {
  //文字列のa番目の文字をとる
  $s_str = $s[$i * $N/$gcd];
  $t_str = $t[$i * $M/$gcd];

  if ($s_str !== $t_str) {
    $bool = false;
    break;
  }
}

if ($bool) {
  echo $lcm;
} else {
  echo -1;
}
?>


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

int m;
int a[10], c[10];

bool ok(string s) {
  rep(i,m) {
    if( s[a[i]-1]-'0' != c[i] ) {
      return false;
    }
  }
  return true;
}

void solve() {

}

int main() {
  int n;
  cin >> n >> m;
  vector<string> vec;
  rep(i,10000) {
    string s = to_string(i);
    if( (int)s.size() == n ) {
      vec.pb(s);
    }
  }

  rep(i,m) {
    cin >> a[i] >> c[i];
  }
  sort(ALL(vec));
  rep(i,(int)vec.size()) {
    if( ok(vec[i]) ) {
      cout << vec[i] << endl;
      return 0;
    }
  }
  puts("-1");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int ai, n, a[10000];

  int min = 1000000 + 1;
  int max = -1000000 - 1;
  long long int sum = 0;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> ai;
    if (ai > max) {
      max = ai;
    }
    if (ai < min) {
      min = ai;
    }

    sum += ai;
  }

  cout << min << " " << max << " " << sum << endl;

  return 0;
}



Measured memory_bytes: 3096
import java.util.Scanner;

class Main{

    public static void main(String[] args){
        
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int r = scanner.nextInt();
        scanner.close();
        if(n>9){
            System.out.println(r);
            return;
        }else{
            System.out.println(r+100*(10-n));
            return;
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x;
  cin >> n >> x;
  int l[n];
  for ( int i=0; i<n; i++){
    cin >> l[i];
  }
  int b=1;
  int bx=0;
  for (int i=0; i<n; i++){
    bx += l[i];
    if (bx>x){
      break;
    }
    b++;
  }
  cout << b << endl;
}

Measured memory_bytes: 256
using System;

namespace debug
{
    class Program
    {
        static void Main(string[] args)
        {
            ProgramF a = new ProgramF();
            a.main();

        }
    }

    //ABC162
    class ProgramE
    {
        public void main()
        {
            string[] s = Console.ReadLine().Split(' ');
            long n = long.Parse(s[0]);
            long k = long.Parse(s[1]);
            long MOD = 1000000000 + 7;
            long[] ans = new long[k];
            //最大公約数が大きいほうから数えていく
            for(long i = k;i > 0;i--)
            {
                //答えを格納
                ans[i - 1] = modpow(k / i, n, MOD);

                long x = 2 * i;
                //これより大きい公約数をもつ場合は除く(logNの計算時間のはず...）
                while(x <= k)
                {
                    ans[i - 1] = (ans[i - 1] - ans[x - 1]) % MOD;
                    x += i;
                }
            }

            //答え算出
            long count = 0;
            for(int i = 0;i < k;i++)
            {
                count += ans[i] *(i + 1) % MOD;
                count %= MOD;
            }

            Console.WriteLine(count);
        }

        public long modpow(long a, long n, long mod)
        {
            if (n == 0)
                return 1;

            if (n % 2 == 0)
            {
                long temp = modpow(a, n / 2, mod);
                return temp * temp % mod;
            }

            return modpow(a, n - 1, mod) * a % mod;
        }
    }

    //ABC162
    class ProgramF
    {
        public void main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] a = Console.ReadLine().Split(' ');
            long INF = -10000000000 + 7;

            long[,] dp = new long[n + 1, 2];//i番目までに何個選ぶかを決めて状態遷移, t = i/2, i/2 + 1
            dp[0, 0] = 0;
            dp[0, 1] = INF;
            dp[1, 0] = 0;
            dp[1, 1] = long.Parse(a[0]);
            dp[2, 0] = long.Parse(a[1]);
            dp[2, 1] = INF;
            for (int i = 3; i <= n; i++)
            {

                if (i % 2 == 0)
                {
                    dp[i, 1] = dp[i - 2, 1];
                    dp[i, 0] = Math.Max(dp[i - 3, 1] + long.Parse(a[i - 1]), dp[i - 2, 0] + long.Parse(a[i - 1]));

                }
                else
                {
                    dp[i, 1] = dp[i - 2, 1] + long.Parse(a[i - 1]);
                    dp[i, 0] = Math.Max(dp[i - 2, 1], dp[i - 2, 0] + long.Parse(a[i - 1]));
                    dp[i, 0] = Math.Max(dp[i, 0], dp[i - 3, 0] + long.Parse(a[i - 1]));
                    if(i > 3)
                        dp[i, 0] = Math.Max(dp[i, 0], dp[i - 4, 1] + long.Parse(a[i - 1]));
                }

            }

            if(n % 2 == 0)
                Console.WriteLine(Math.Max(dp[n -1, 1], dp[n, 0]));
            else
                Console.WriteLine(Math.Max(Math.Max(dp[n, 0], dp[n - 1, 0]), dp[n - 2,1]));
        }
    }
}


Measured memory_bytes: 48584
/*
 * ARC99_D.cpp
 *
 *  Created on: Jun 25, 2018
 *      Author: 13743
 */
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

int wa(lng x) {
	int y = 0;
	while(x > 0) {
		y += x % 10;
		x /= 10;
	}
	return y;
}

bool comp(lng x, lng y) {
	if(x == 0) return true;
	return (x*1.0/wa(x) <= y*1.0/wa(y));

}

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

	int K;
	cin >> K;

	lng y = 1, d = 1;
	REP(i, K) {
		cout << y << endl;
		if(!comp(y+d, y+d+d)) {
			d *= 10;
		}
		y += d;
	}
}






Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> inline void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> inline void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }
TPL<TNM T> inline void UNIQUE(vector<T>& vec) { sort(ALL(vec)); vec.erase(unique(ALL(vec)), vec.end()); }

int main(void) {
	int N;
	cin >> N;
	vec<int> A(N);
	REP(i, N) {
		cin >> A[i];
	}
	int x = 0;
	REP(i, N) {
		if (A[i] % 2 == 1) {
			cout << "first" << endl;
			return 0;
		}
	}
	cout << "second" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>

using namespace std;

int main(){
int h,w;
while(1){
cin>>h>>w;
if(h==0&&w==0)break;
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        if(j==0||i==0||i==h-1||j==w-1)cout<<"#";
        else cout<<".";
    }
    cout<<endl;
}
cout<<endl;

}
}




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (auto& x : A) cin >> x;
	for (int tt = 0; tt < K; ++ tt) {
		vector<int> a(N+1);
		for (int i = 0; i < N; ++ i) {
			++ a[max(0, i - A[i])];
			-- a[min(N, i + A[i] + 1)];
		}
		bool ok = true;
		int x = 0;
		for (int i = 0; i < N; ++ i) {
			x += a[i];
			A[i] = x;
			if (x != N) ok = false;
		}
		if (ok) break;
	}
	for (auto x : A) cout << x << " ";
	cout << endl;
}


Measured memory_bytes: 4844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        final String[] in = br.readLine().split(" ");
        final int[] s = new int[n];
        for(int i = 0; i<n; i++){
            s[i] = Integer.parseInt(in[i]);
        }
        int c = 0;
        br.readLine();
        final String[] t = br.readLine().split(" ");
        for(final String ti:t){
            final int q = Integer.parseInt(ti);
            for(int i = 0; i<n; i++){
                if(s[i]==q){
                    c++;
                    break;
                }
            }
        }
        System.out.println(c);
    }
}

Measured memory_bytes: 27656
#include<bits/stdc++.h>
using namespace std;
int read(){
	char c;int x;while(c=getchar(),c<'0'||c>'9');x=c-'0';
	while(c=getchar(),c>='0'&&c<='9') x=x*10+c-'0';return x;
}
int d,g,ans=2e9,vis[15];
struct node{
	int num,bonus,all;
}p[15];
void dfs(int x,int tot,int res){
	if(x==d+1){
		for(int i=d;i>=1;i--){
			if(vis[i]) continue;
			if(tot>=g) break;
			int k=0;
			while(tot<g){
				tot+=i*100;k++;res++;
				if(tot>=g) break;
				if(k==p[i].num) break;
			}
		}
		ans=min(ans,res);return;
	}
	vis[x]=1;dfs(x+1,tot+p[x].all,res+p[x].num);
	vis[x]=0;dfs(x+1,tot,res);
}
int main()
{
	d=read();g=read();
	for(int i=1;i<=d;i++){
		p[i].num=read();p[i].bonus=read();
		p[i].all=p[i].num*i*100+p[i].bonus;
	}
	dfs(1,0,0);
	printf("%d",ans);
	return 0;
}

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

int main() {
    int a, b;
    char op;
    cin >> a >> op >> b;
    int ans = a + b;
    if (op == '-') ans = a - b;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<random>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 21000000145141919
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
struct edge { int to, cost; };

int d[501][501], c[501][501];
int cv[3][35];
signed main() {
	int n, C; cin >> n >> C;
	rep(i, C)
		rep(j, C)cin >> d[i][j];
	rep(i, n)rep(j, n)cin >> c[i][j];

	rep(i, n) {
		rep(j, n)
		{
			if ((i + j) % 3 == 0)cv[0][c[i][j]-1]++;
			else if ((i + j) % 3 == 1)cv[1][c[i][j]-1]++;
			else cv[2][c[i][j]-1]++;
		}
	}
	int ans = inf;
	rep(i, C) {
		rep(j, C) {
			rep(k, C) {//color
				if (i == j || j == k || k == i)continue;
				int r1 = 0, r2 = 0, r3 = 0;
				rep(x, 3) {
					rep(l, C) {
						if (x == 0)r1 += cv[x][l] * d[l][i];
						if (x == 1)r2 += cv[x][l] * d[l][j];
						if (x == 2)r3 += cv[x][l] * d[l][k];
					}
				}
				ans = min(ans, r1 + r2 + r3);
			}
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 2304
int main(int argc,const char*argv[])
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    
    if(x>=r && x+r<=W && y>=r && y+r<=H){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
const int inf = 1e9;

struct station{
	int st;
	int c,h,r;
	station(int st, int c, int h, int r):st(st),c(c),h(h),r(r){}
	station(){}
};
struct info{
	int pos, cost, time;
	info(int p, int c, int t):pos(p),cost(c),time(t){}
	info();
	bool operator < (const info &a) const{
		return (cost!=a.cost)? cost > a.cost : time < a.time;
	}
};

int solve(int s, int g, int time, int pass, vector<vector<station> > &adj){
	vector<vector<int> > mincost(adj.size(), vector<int>(time+1, inf));
	for(int i=0; i<=time; i++){
		mincost[s][i] = 0;
	}
	priority_queue<info> wait;
	wait.push(info(s, 0, time));
	while(!wait.empty()){
		int p = wait.top().pos;
		int c = wait.top().cost;
		int t = wait.top().time;
		wait.pop();
		if(c > mincost[p][t]) continue;
		if(p == g) return c;
		
		for(int i=0; i<(int)adj[p].size(); i++){
			station next = adj[p][i];
			int npos = next.st;
			int ncost = ((pass & 1<<next.r) != 0 )? c: c +next.c;
			int ntime = t -next.h;
			if(ntime < 0 || ncost >= mincost[npos][ntime]) continue;
			for(int j=0; j<=ntime; j++){
				mincost[npos][j] = min(mincost[npos][j], ncost);
			}
			wait.push(info(npos, ncost, ntime));
		}
	}
	return inf;
}

int main(){
	while(1){
		int n,m,h,k;
		cin >> n >> m >> h >> k;
		if(n==0) break;
		
		vector<vector<station> > adj(n);
		for(int i=0; i<m; i++){
			int a,b,c,h,r;
			cin >> a >> b >> c >> h >> r;
			a--; b--; r--;
			adj[a].push_back(station(b, c, h, r));
			adj[b].push_back(station(a, c, h, r));
		}
		
		int s,t,p;
		cin >> s >> t >> p;
		s--; t--;
		vector<int> dp(1<<k, inf);
		dp[0] = 0;
		for(int i=0; i<p; i++){
			int num, d, pass=0;
			cin >> num >> d;
			for(int j=0; j<num; j++){
				int k;
				cin >> k;
				k--;
				pass |= 1<<k;
			}
			for(int j=0; j<(1<<k); j++){
				if(dp[j] != inf){
					dp[j|pass] = min(dp[j|pass], dp[j]+d);
				}
			}
		}
		
		int ans = inf;
		for(int i=0; i<(1<<k); i++){
			if(dp[i] >= ans) continue;
			ans = min(ans, dp[i] + solve(s, t, h, i, adj));
		}
		
		if(ans == inf){
			cout << -1 << endl;
		}else{
			cout << ans << endl;
		}
	}
	return 0;
}



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

using namespace std;

int mark[2000001], f[2000001];
int a[200001];

int cnt, n;

const int N = (int )1e6;
int main( ) {
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++) {
		scanf("%d", &a[i]);
		mark[a[i]] ++;
	}
	for (int i = 1; i <= N; i ++)
		for (int j = i; j <= N; j += i)
			f[j] += mark[i];
	
	for (int i = 1; i <= n; i ++)
		if (f[a[i]] == 1) ++ cnt;
	printf("%d\n", cnt);
	return 0;
}


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

ll mod_pow(ll x, ll n, ll mod)
{
    if (n == 0) return 1;
    ll res = mod_pow(x * x % mod, n / 2, mod);
    if (n & 1) res = res * x % mod;
    return res;
}

int main(){
  ll m,n;cin>>m>>n;
  cout << mod_pow(m,n,1000000007) << endl;
  return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int n; cin >> n;
		if(n==0)break;
		vector<pair<pair<int,int>,string>> v(n);
		for(int i=0;i<n;i++){
			string l; cin >> l;
			int p,a,b,c,d,e,f,s,m; cin >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			int sum=a+b+c+(d+e)*m;
			v[i]=make_pair(make_pair(f*s*m-p,sum),l);
		}
		sort(v.begin(),v.end(),[](auto i,auto j){
			if(i.first.first*j.first.second==i.first.second*j.first.first){
				return i.second<j.second;
			}
			else{
				return i.first.first*j.first.second>j.first.first*i.first.second;
			}
		});
		for(int i=0;i<n;i++){
			cout << v[i].second << endl;
		}
		cout << "#" << endl;
	}
}


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

int main(){
    int h, w;
    for(;;){
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if((i+j) % 2){
                    cout << '.';
                }else{
                    cout << '#';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<double> v(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());

    double ans = -1;
    for(double num : v)
    {
        if(ans < 0)
        {
            ans = num;
            continue;
        }
        ans = (ans+num)/2;
    }
    cout << fixed << setprecision(6) << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    bool a[50002]={0};
    
    for(int i=2;i<25002;i++)
        for(int j=i;j*i<50002;j++)
            a[i*j]=true;
    int n;
    while(cin>>n,n){
        int co=0;
        for(int i=2;i<=n/2;i++){
            if((!a[i])&&(!a[n-i]))co++;
        }
        cout<<co<<endl;
    }
}

Measured memory_bytes: 1216
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p = sorted(p,reverse = True)
q = sorted(q,reverse = True)
r = sorted(r,reverse = True)
p = p[0:x]
q = q[0:y]
h = p+q+r
h = sorted(h,reverse = True)
print(sum(h[:x+y]))

Measured memory_bytes: 22720
N=int(input())
S=input()

# 全ての組み合わせ数
allcnt = S.count("R") * S.count("G") * S.count("B")

# 除外するものチェック
rem = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    k = j + (j - i)
    if k >= N:
      break
    if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
      rem += 1
print(allcnt - rem)


Measured memory_bytes: 9100
K = int(input())
if K%7 == 0:
  L = 9*K//7
else:
  L = 9*K

if K%2 == 0 or K%5 == 0:
  print(-1)
else:
  X = 10%L
  if X == 1:
    print(1)
  else:
    for i in range(K):
      X = X*10 % L
      if X == 1:
        print(i+2)
        break

Measured memory_bytes: 9096
#include<iostream>
#include<vector>

int main() {
  using namespace std;
  int n; cin >> n;
  vector<int> x(n);
  for(int i = 0; i < n; ++i) cin >> x[i];
  long long ans = (1LL<<62)-1, cnt;
  for(int p = 1; p <= 100; ++p) {
    cnt = 0;
    for(int i = 0; i < n; ++i) {
      cnt += (x[i]-p)*(x[i]-p);
    }
    ans = min(ans, cnt);
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

#define pb push_back
#define fi first
#define se second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int inf = 1e9;

template <class T>
istream& operator>>(istream& ss, vector<T>& v) {
    for (int i = 0; i < v.size(); i++) ss >> v[i];
    return ss;
}

template <class T>
ostream& operator<<(ostream& ss, const vector<T>& v) {
    for (int i = 0; i < v.size(); i++) ss << v[i] << ' ';
    return ss;
}

void solve() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";
}

int main() {
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int main()

{
    int a, b;

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

    if(a>=1 && a<=9 && b>=1 && b<=9)
    {
        printf("%d\n", a*b) ;
    }
    else
    {
        printf("-1\n") ;
    }

    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <cstring>
#define ll long long int
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define PI 3.141592653589793
using namespace std;

int main() {
    int N,ans=0;

    cin >> N;
    int d[10][10];
    REP(i,10) {
        REP(j,10) d[i][j] = 0;
    }
    for(int i=1; i<=N; i++){
        int x = i;
        while(x >= 10) x = x / 10;
        d[x][i%10]++;
    }
    for(int i=1; i<=N; i++){
        int x = i;
        while(x >= 10) x = x / 10;
        ans += d[i%10][x];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
const int maxn=100005;
int n,q;
int a[maxn];
int cnt=0;
void finds (int x)
{
    int left=0,right=n-1;
    while (left<=right)
    {
        int mid=(left+right)>>1;
        if(a[mid]==x)
        {
            cnt++;
            return ;
        }
        else if(a[mid]>x)
                right=mid-1;
        else
            left=mid+1;

    }
}
int main()
{
    scanf("%d",&n);
    for (int i=0;i<n;i++)
        scanf("%d",&a[i]);
    scanf("%d",&q);
    for (int i=0;i<q;i++)
    {
        int temp;
        scanf("%d",&temp);
        finds (temp);
    }
    printf("%d\n",cnt);
    return 0;
}



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

using namespace std;

int main()
{
   string s1,s2,s3;
   cin>>s1>>s2>>s3;
   s1=toupper(s1[0]);
   s2=toupper(s2[0]);
   s3=toupper(s3[0]);
   cout<<s1<<s2<<s3<<endl;
   return 0;
}

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

using namespace std;
static const int N = 1000;

int lenCommon(string s1, string s2)
{
	int m = s1.size();
	int n = s2.size();
	int len = max(m, n);
	vector<vector<int> > dp(N+1, vector<int>(N+1, 0));

	//s1 = " " + s1;
	//s2 = " " + s2;

	//for (int i = 0; i <= len; ++i) dp[i][0] = 0;
	//for (int i = 0; i <= len; ++i) dp[0][i] = 0;

	int ret = 0;
	for (int i = 1; i <= m; ++i)
	{
		for (int j = 1; j <= n; ++j)
		{
			if (s1[i - 1] == s2[j - 1])
				dp[i][j] = dp[i - 1][j - 1] + 1;
			else
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);

			ret = max(ret, dp[i][j]);
		}
	}
	return ret;
}

int main()
{
	string s1, s2;
	int num; cin >> num;
	for (int i = 0; i < num; ++i)
	{
		cin >> s1 >> s2;
 		int res = lenCommon(s1, s2);
		cout << res << endl;
	}
}

Measured memory_bytes: 6772