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

using namespace std;
typedef long long ll;
/*

*/
const int N = 2e5 + 10;
int n,k;
int a[N], b[N], c[N];
vector<int> adj[N];

void visit(int u, int pa, int cpa) {
	int kk = 0;
	for (int i : adj[u]) {
		int v = (i > 0 ? b[i] : a[-i]);
		if (v == pa) continue;
		kk++; if (kk == cpa) kk++;
		c[abs(i)] = kk;
		visit(v, u, kk);
	}
	k = max(k, kk);
}

int main() {
	cin >> n;
	for (int i = 1; i < n; ++i) {
		cin >> a[i] >> b[i];
		adj[a[i]].push_back(i);
		adj[b[i]].push_back(-i);
	}
	visit(1, 1, 0);
	cout << k << endl;
	for (int i = 1; i < n; ++i) cout << c[i] << endl;
}

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

int main(){
	int n; cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin >> a[i];
	long long ans=0;
	int  l=0,r=0;
	long long t=a[0];
	while(l<n){
		while(!(t&a[r+1])&&r<n-1) t+=a[++r];
		ans+=r-l+1;
		t-=a[l++];
	}
	cout << ans << endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#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 forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(arr,n)       for(int i=0;i<n;i++)cin>>arr[i]
#define output(arr,n)      for(int i=0;i<n;i++)cout<<arr[i]<<" "
#define for_each(arr)      for(auto& it:arr)cout<<it<<" "
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx[]= {0,0,1,-1,-1,1,-1,1};
int fy[]= {1,-1,0,0,-1,1,1,-1};
int fx1[]={0,1,1,1,0,-1,-1,-1};
int fy1[]={1,1,0,-1,-1,-1,0,1};*/

ll n,k,r,p,s,ans,a;
string s1,s2;


int main()
{
    FIO;
   /* #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    cin>>n>>k>>r>>s>>p>>s1;
    ans=0;
    for(int i=k;i<n;i++){
    	if(s1[i]==s1[i-k])
    		s1[i]='g';
    }

    for(int i=0;i<n;i++){
    	if(s1[i]=='s')
    		ans+=r;
    	else if(s1[i]=='p')
    		ans+=s;
    	else if(s1[i]=='r')
    		ans+=p;
    }
    
    cout<<ans<<endl;
    

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
#define int long long
 
int cnt[26];
signed main() {
	string s; cin >> s;
	int ans = 0;
	for (int i = s.size() - 1; i >= 0; i--) {
		ans += cnt[s[i] - 'a'];
		cnt[s[i] - 'a']++;
	}
	cout << s.size()*(s.size() - 1) / 2 - ans+1 << endl;
}

Measured memory_bytes: 640
import java.io.BufferedInputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedInputStream(System.in));
        int N = scan.nextInt();
        int[] arr = new int[N];
        for (int i=0;i<N;i++) arr[i] = scan.nextInt();
        Task tsk = new Task();
        System.out.println(tsk.solve(arr));
    }

    static class Task{
        public int solve(int[] arr){
            int n = arr.length;
            int[] sorted = Arrays.copyOf(arr, n);
            Arrays.sort(sorted);

            long total = (long)n * (n+1) / 2;
            int l = 0, r = n-1;
            while (l < r) {
                int mid = l + (r-l)/2;
                int target = sorted[mid];

                int cur = 0;
                long cnt = 0;
                long[] bit = new long[2*n+2];
                for (int x=n+1;x<bit.length;x+=x&-x) bit[x]++;
                for (int i=0;i<n;i++) {
                    cur += arr[i] <= target? 1: -1;
                    for (int x=cur+n+1;x<bit.length;x+=x&-x) bit[x]++;
                    for (int x=cur+n;x>0;x-=x&-x) cnt += bit[x];
                }
                if (cnt >= total/2 + 1) r = mid;
                else l = mid+1;
            }
            return sorted[l];
        }
    }
}


Measured memory_bytes: 64828
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solve(new Scanner(System.in));
	}
	
	public void solve(Scanner sc) {
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		
		if(a > 8 || b > 8) {
			System.out.println(":(");
		} else if(a + b >16) {
			System.out.println(":(");
		} else {
			System.out.println("Yay!");
		}
	}
}


Measured memory_bytes: 22100
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int x, y;
	cin >> x >> y;
	vector <vector <char>> boxs(60,vector <char>(60,0));
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			cin >> boxs[i][j];
		}
	}
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			if (boxs[i][j] == '#') {
				cout << '#';
			}
			else if(boxs[i][j] =='.'){
				int add=0;
				if (i != 0 && j != 0) {
					if (boxs[i - 1][j - 1] == '#') {
						add++;
					}
				}
				if (i != 0) {
					if (boxs[i - 1][j + 1] == '#') {
						add++;
					}
					if (boxs[i - 1][j] == '#') {
						add++;
					}
				}
				if (j !=0) {
					if (boxs[i][j - 1]=='#') {
						add++;
					}
					if (boxs[i + 1][j - 1] == '#') {
						add++;
					}
				}
				if (boxs[i][j + 1] == '#') {
					add++;
				}
				if (boxs[i + 1][j] == '#') {
					add++;
				}
				if (boxs[i + 1][j+1] == '#') {
					add++;
				}
				cout << add;

			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 3604
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main()
{
	int K,N;
	cin>>K>>N;
	int *A = new int[N];
	int maxLength = 0;
	for(int i = 0; i < N; i++){
		cin>>A[i];
	}
	for(int i = 0; i < N-1; i++){
		maxLength = max(maxLength,A[i+1]-A[i]);
	}
	maxLength = max(maxLength, A[0] + (K - A[N-1]));
	cout<<K-maxLength<<endl;
	return 0;
}



Measured memory_bytes: 1024
/*0429??????????????§??£?§£???boolean??§???byte??§?????§???????????? : Accepted        01.11 sec        116760 KB
 * 12??????????????????????¢???? ????????°?????????????????????????????????????????????
 * ?????????????´???°????????????int ????????§????????????.?????????maxvalue???memory limit ?¶??????????????????????
 * 
 * Created by SharpDevelop.
 * User: yog-sothoth
 * Date: 2017/04/23
 * Time: 17:25
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System.Collections.Generic;
using System;
using System.IO;

namespace Dictionary
{
	
	public class DictionaryList
	{
		
		
		public static void Main(string[] args)
		{		
			int num = int.Parse(Console.ReadLine());// the number of instructions
			
			
			byte[] table = new byte[67200000];
			string iands;
			string[] instAndStr;
			int index=0;
			var sw = new StreamWriter(Console.OpenStandardOutput())
	    	{ AutoFlush = false };
			
			Console.SetOut(sw);
			
			for (int i = 0; i < num; i++) {
				iands = Console.ReadLine();//instruction and s tring
				 instAndStr = iands.Split();
			
				
				//Add list instAndStr[1]		
				if (instAndStr[0] == "insert") {//??????????????\???
					//??????????????°????????????????????????table[index]???????????°??????????????????????????¨????????????????????§????????????
					//????????°???????????????
					 index = 0;
					for (int j = 0; j < instAndStr[1].Length; j++) {
			
						index *= 4;
				
						switch (instAndStr[1][j]) {
							case 'A':
								index += 1;
								break;
							case 'C':
						
								index += 2;
						
								break;
							case 'G':
						
								index += 3;
								break;
							case 'T':
						
								index += 4;
								break;			
						}
						
		
					}
					table[index]=1;
		
					
				} else { //?????????find
					
					
					 index = 0;
					for (int k = 0; k < instAndStr[1].Length; k++) {
			
						index *= 4;
				
						switch (instAndStr[1][k]) {
							case 'A':
								index += 1;
								break;
							case 'C':
						
								index += 2;
						
								break;
							case 'G':
						
								index += 3;
								break;
							case 'T':
						
								index += 4;
								break;			
						}
						
		
					}
					if(table[index]!=1)
					{
						Console.WriteLine("no");
					}else
						Console.WriteLine("yes");
				}
				
			}
			Console.Out.Flush();
		}
		
	}
}

Measured memory_bytes: 116784
N = int(input())
inf = input().split()
A = {i+1:int(inf[i]) for i in range(N)}
ans = [0 for i in range(N+1)]
keys = list(A.keys())
keys.sort(reverse=True)
for k in keys:
  count = 0
  for j in range(2*k, N+1, k)[::-1]:
    count += ans[j]
  ans[k] = (A[k]-(count%2))%2
value = sum(ans)
print(value)
if value>0:
  tag = []
  for i in range(N+1):
    if ans[i]:
      tag += [str(i)]
  print(' '.join(tag))


Measured memory_bytes: 36908
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

int main()
{
    std::string S;
    long N;
    std::cin >> N;
    std::cin >> S;
    long count=0;
    for(long i=0; i<N-2;i++){
        if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C'){
            count++;
        }
    }
    std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define H 250
int main(){
  int A[H];
  int i,n;


scanf("%d",&n);

for(i=1;i<=n;i++){
  scanf("%d",&A[i]);
  }

for(i=1;i<=n;i++){
printf("node %d: key = %d, ",i,A[i]);
if(i != 1) printf("parent key = %d, ",A[i/2]);
if(2*i <= n) printf("left key = %d, ",A[2*i]);
if(2*i+1 <= n) printf("right key = %d, ",A[2*i+1]);
printf("\n");
}
return 0;
}

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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 
#define INF INT_MAX/2 //(1<<(4*4-1))
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

   int sx,sy,gx,gy;
   cin>>sx>>sy>>gx>>gy;

   for(int i=sy;i<gy;i++)cout<<"U";
   for(int i=sx;i<gx;i++)cout<<"R";
   for(int i=gy;i>sy;i--)cout<<"D";
   for(int i=gx;i>=sx;i--)cout<<"L";
   for(int i=sy;i<=gy;i++)cout<<"U";
   for(int i=sx;i<=gx;i++)cout<<"R";
   cout<<"DR";
   for(int i=gy;i>=sy;i--)cout<<"D";
   for(int i=gx;i>=sx;i--)cout<<"L";
   cout<<"U";
   return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int n;
    cin >> n;

    map<int, int> m;
    int a;
    rep (i, n)
    {
        cin >> a;
        ++m[a];
    }

    int neven = 0;
    for (auto item : m)
    {
        if ((item.second & 1) == 0)
        {
            ++neven;
        }
    }

    cout << m.size() - (neven & 1 ? 1 : 0) << "\n";
    return 0;
}



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

int main() {
  int h,w,n,a,b,r1=0,r2=0,c1=0,c2=0,ans=0;
  cin >> h >> w >> n >> a >> b;
  string s1,s2;
  cin >> s1 >> s2;
  for (int i=n-1;i>-1;i--){
    if (i!=n-1){
      if (s2.at(i)=='L' && r1!=0) r1--;
      if (s2.at(i)=='R' && r2!=0) r2--;
      if (s2.at(i)=='U' && c1!=0) c1--;
      if (s2.at(i)=='D' && c2!=0) c2--;
    }

    if (s1.at(i)=='R') r1++;
    if (s1.at(i)=='L') r2++;
    if (s1.at(i)=='D') c1++;
    if (s1.at(i)=='U') c2++;
    if (r1+r2>=w) {ans=1;break;}
    if (c1+c2>=h) {ans=1;break;}
  }
  if (ans==1) {cout << "NO" << endl;return 0;}
  if (b>r2 && b<w+1-r1 && a>c2 && a<h+1-c1) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf INT_MAX
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define eps 0.00001

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int c1=0,c2=0;
    rep(i,1,3)
    {
        int x;cin>>x;
        if(x==5)
        {
            c1++;
        }
        if(x==7)
        {
            c2++;
        }
    }
    if(c1==2 && c2==1)
    {
        cout<<"YES"<<"\n";
    }
    else
    {
        cout<<"NO"<<"\n";
    }


    return 0;
    // check for long long or int
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int peizi,amari;
	
	scanf("%d",&peizi);
	
	if (1==peizi%2){
		peizi=peizi/2;
		printf("%d\n",peizi+1);
	}else printf("%d\n",peizi/2);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
ll modpow(ll a, ll n) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }

    return res;
}

ll comb(ll a, ll b) {
    ll ans = 1;

    for(ll i = a; i > a - b; i--) {
        ans = ans * i % mod;
    }
    for(ll i = 1; i <= b; i++) {
        ans = (ans * modpow(i, mod - 2)) % mod;
    }
    return ans;
}

ll func(ll n) {
    if(n == 1) return 1;
    else {
        return func(n / 2) * 2  + 1; 
    }
}
int main() {
  ll H;
  cin >> H;
  ll monster = H;
  cout << func(monster) << endl;
     return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dis[100005];
int n;
vector<int>vec[100005];
void dfs(int i)
{
	dis[i]=1;
	for(int j=0;j<vec[i].size();j++)
		if(dis[vec[i][j]]==0)
		{
			dfs(vec[i][j]);
			dis[i]+=dis[vec[i][j]];
		}
}
vector<int>ans;
bool vis[100005],ok;
void dfs2(int x)
{
	vis[x]=1;
	if(!ok)ans.push_back(x);
	if(x==n)
	{
		ok=1;
		return;
	}
	for(int i=0;i<vec[x].size();i++)
		if(!vis[vec[x][i]])
			dfs2(vec[x][i]);
	if(!ok)ans.pop_back();
}
int main()
{
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		vec[x].push_back(y);
		vec[y].push_back(x);
	}
	dfs(1);
//	for(int i=1;i<=n;i++)
//		cout<<dis[i]<<' ';
//	cout<<endl;
	dfs2(1);
	int x=ans[(ans.size()+1)/2];
//	for(int i=0;i<ans.size();i++)
//		cout<<ans[i]<<' ';
//	cout<<endl;
	x=dis[x];
	if(x>=n-x)cout<<"Snuke";
	else cout<<"Fennec";
	return 0;
}


Measured memory_bytes: 11644
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 1e6+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int prime[maxn],vis[maxn],cnt;
ll s[100];
void getPrime()
{
    int n = 1e6;
    rep(i,2,n){
        if(!vis[i]) prime[++cnt] = i;
        for(int j=1;j<=cnt&&(ll)prime[j]*i<=n;j++){
            vis[prime[j]*i] = 1;
            if(i%prime[j]==0) break;
        }
    }
}
int main()
{
    fastio();
    getPrime();
    rep(i,1,60){
        s[i] = s[i-1]+i;
    }
    ll n;cin>>n;
    ll ans = 0;
    rep(i,1,cnt){
        if(n%prime[i]==0){
            int t = 0;
            while(n%prime[i]==0) t++,n/=prime[i];
            rep(k,1,60){
                if(s[k]>t) {ans+=k-1;break;}
            }
        }
    }
    if(n>1) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7864
n = int(input())
d = {}
c = 1
for i in range(n):
    i = input().split(" ")
    city = i[0]
    point = int(i[1])
    if city not in d:
        d[city] = [(point,c)]
    else:
        d[city].append([point,c])
    c += 1

sorted_d = sorted(d.items(), key=lambda x:x[0])
for i in sorted_d:
    s_score = sorted(i[1],key=lambda x:x[0],reverse=True)
    for j in s_score:
        print(j[1])


Measured memory_bytes: 3064
var
 st:string;
begin
  readln(st);
  if st[1]=st[length(st)] then
    begin
      if odd(length(st)) then writeln('Second')
        else writeln('First');
    end
    else 
    begin
      if not(odd(length(st))) then writeln('Second')
        else writeln('First');
    end
end.

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < N; ++i) {
            long A = sc.nextLong();
            list.add(A);
        }
        Collections.sort(list, Comparator.reverseOrder());
        long a = -1;
        long b = -1;
        for (int i = 0; i < N - 1; ++i) {
            if (list.get(i).equals(list.get(i + 1))) {
                if (a == -1) {
                    a = list.get(i);
                    ++i;
                } else if (b == -1) {
                    b = list.get(i);
                    break;
                }
            }
        }
        if (a > 0 && b > 0) {
            _out.println(a * b);
        } else {
            _out.println(0);
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 58764
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    
    c = ""
    for i in range(H):
        if i % 2 == 0:
            for j in range(W):
                if j % 2 == 0:
                    c += "#"
                else:
                    c += "."
            c += "\n"
        else:
            for k in range(W):
                if k % 2 == 0:
                    c += "."
                else:
                    c += "#"
            c += "\n"
    print(c)


Measured memory_bytes: 5628
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <tuple>
#include <stdbool.h>
#include <bitset>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;
using namespace std;


int main(void) {
    int n,k;
    string s;
    cin >> n >> s >> k;

    auto target = s[k - 1];
    for(const auto& c : s) {
        cout << (c == target ? c : '*');
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(raw_input())
x = y = 1
for _ in xrange(n):
    t, a = map(int, raw_input().split())
    xi = x / t + (x % t != 0)
    yi = y / a + (y % a != 0)
    k = max(xi, yi)
    x = k * t
    y = k * a
print x + y


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()


const int N = 1e6 + 5;
int tw[N];

int calc(vector<int> v) {
    int n = v.size() - 1;

    int c = 0, ans = 0;
    for (int i = 0; i <= n; i++) {
        if (c == 0)
            ans += v[i];
        c += tw[n - i] - tw[i + 1];
    }

    ans %= 2;

    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    for (int i = 2; i < N; i++) {
        int x = i;
        while (x % 2 == 0) {
            x /= 2;
            tw[i]++;
        }
    }

    int n;
    string s;
    cin >> n >> s;

    bool used[3] = {0, 0, 0};

    for (int i = 0; i < s.size(); i++) {
        used[s[i] - '1'] = true;
    }

    int us_ct = (used[0] + used[1] + used[2]);

    vector<int> v;
    for (char c : s) {
        v.push_back((c - '1') % 2);
    }

    int par = calc(v);

    if (us_ct == 3) {
       cout << par;
    }
    else if (us_ct == 2) {
        if (used[0] && used[2]) {
            vector<int> v;
            for (char c : s) {
                v.push_back(c == '3');
            }
            cout << (calc(v) ? 2 : 0);
        }
        else {
            cout << par;
        }
    }
    else {
        cout << 0;
    }

    return 0;   
}   

Measured memory_bytes: 17360
# -*- coding: utf-8 -*-

N = int(input())
A = [int(i) for i in input().split()]

Alice = 0
Bob = 0

Turn = 0
for a in sorted(A, reverse=True):
    if Turn == 0:
        Alice += a
        Turn =1
    else:
        Bob += a
        Turn = 0
print(Alice-Bob)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    int ans = n*(n-1)/2 + m*(m-1)/2;

    cout << ans << endl;
}



Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            
            int N = Integer.parseInt(br.readLine());
            String strSplit[] = br.readLine().split(" ");
            int Li[] = new int[N];
            
            for(int i=0; i<N; i++){
                Li[i] = Integer.parseInt(strSplit[i]);
            }
            
            int count = 0;
            for(int i=0; i<N-2; i++){
                for(int j=i+1; j<N-1; j++){
                    for(int k=j+1; k<N; k++){
                        if(Li[i]!=Li[j] && Li[j]!=Li[k] && Li[i]!=Li[k] && Li[i]+Li[j] > Li[k] && Li[i]+Li[k] > Li[j] && Li[j]+Li[k] > Li[i]){
                            count++;
                        }
                    }
                }
            }
            
            System.out.println(count);
            
        }catch(Exception e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 33360
N, M = map(int, input().split())
tenbo_height = list(map(int, input().split()))
adj_height = [0]*N

for i in range(M):
  #road[0] = start, road[1] = goal
  road = list(map(int, input().split()))
  adj_height[road[0]-1] = max(adj_height[road[0]-1], tenbo_height[road[1]-1])
  adj_height[road[1]-1] = max(adj_height[road[1]-1], tenbo_height[road[0]-1])
  
good_tenbo = 0
for tenbo in range(N):
  if ((tenbo_height[tenbo] > adj_height[tenbo])) or (adj_height[tenbo] == 0):
    good_tenbo += 1
print(good_tenbo)
   

Measured memory_bytes: 20024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

// -------------------------------------------------------
int a;

int main() {
  cin >> a;
  cout << a + a * a + a * a * a;
}


Measured memory_bytes: 3604
using System;
using System.Linq;

class prog{
  static void Main(){
    
    int N = int.Parse(Console.ReadLine());
    int K = int.Parse(Console.ReadLine());
    
    int number = 1;
    for(int count = N; count > 0; count--) {
      if(number <= K) number *= 2;
      else number += K;
    }
    
    Console.WriteLine(number);
    
  }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <algorithm>

using namespace std;

long long H;

long long f(long long H) {
	return H == 1 ? 1 : 2 * f(H / 2) + 1;
}

int main() {
	scanf("%lld", &H);
	printf("%lld\n", f(H));
	return 0;
}

Measured memory_bytes: 128
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[57];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>a[i];
    }
    int sum=0;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            if(i==j)
                continue;
            sum+=a[i]*a[j];
        }
    }
    cout<<sum/2;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = n-1; i >= 0; --i)
#define REP(i, s, n) for (int i = s; i< (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
ll inf = ll(1e18);
ll mod = ll(1e9) + 7;

void solve(istream &ccin = cin, ostream &ccout = cout) {
  ll n;
  ccin >> n;
  string s;
  ccin >> s;

  vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, 0));
  dp.at(0).at(0) = 1;
  REP(i, 1, n + 1) {
    rep(j, n + 1) {
      if (j == 0) {
        dp.at(i).at(j) = 2 * dp.at(i - 1).at(j + 1) % mod + dp.at(i - 1).at(0);
      } else if (j == n) {
        dp.at(i).at(j) = dp.at(i - 1).at(j - 1) % mod;
      } else {
        dp.at(i).at(j) = (dp.at(i - 1).at(j - 1) + 2 * dp.at(i - 1).at(j + 1)) % mod;
      }
    }
  }
  ccout << dp.at(n).at(s.size()) % mod << endl;

}

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

Measured memory_bytes: 195840
#include <bits/stdc++.h>
using namespace std;
int f(char str[],int len)
{
    int i=0,x=0;
    for(i;i<len;i++)
    {
        if(str[i]=='-')
            x++;
    }
    return x;
}
int main(){
    int a,b,i=0;
    char str[255];
    cin>>a>>b;
    cin>>str;
    int len=strlen(str);
    if(len!=a+b+1)
        cout<<"No";
    else if(str[a]!='-')
        cout<<"No";
    else if(f(str,len)!=1)
        cout<<"No";
    else
        cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
x = int(input())
n = [i**5 for i in range(119+1)]

a = 0
b = 0
res = False
i = 0
while not res:
    sign = 1 - 2*(n[i] < x)
    for j in range(i+1):
        if (n[i] - n[j] * sign) == x:
            print(i,j*sign)
            res = True
    i += 1

Measured memory_bytes: 9176
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    auto s = readln.chomp;
    
    auto arr = ["Sunny", "Cloudy", "Rainy"];
    
    int i = 0;
    while (arr[i] != s) { ++i; }
    
    auto ans = arr[(i+1) % 3];
    
    ans.writeln;
}

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

int main() {
  int N,M;
  int pointOld = 0;
  cin >> N;
  vector<string> blue( N );
  for( int i = 0; i < N; i++ )
    cin >> blue.at( i );
  cin >> M;
  vector<string> red( M );
  for( int i = 0; i < M; i++ )
    cin >> red.at( i );
  for( int i = 0; i < N; i++ )
  {
    int point = 0;
    for( int j = 0; j < M; j++ )
    {
      if( blue.at( i ) == red.at( j ) )
      {
	point--;
      }
    }
    for( int j = 0; j < N; j++ )
    {
      if( blue.at( i ) == blue.at( j ) )
      {
	point++;
      }
    }
    if( pointOld < point )
      pointOld = point;
  }
  cout << pointOld << endl;
}

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

#define ll long long
#define ii pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi acos(-1.0)
#define oo 1000000007
#define loo 0x7fffffffffffffff

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    ll n, ans = 0; cin >> n;
    vl a(n);
    for (int i = 0; i < n; ++i){
        cin >> a[i];
        if(i){
            if(a[i] < a[i-1]) ans+=a[i-1]-a[i], a[i] = a[i-1];
        }
    }
    cout << ans << "\n";
    
    return 0;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	vector<char> input(n);
	vector<int> red;
	vector<int> white;

	rep(i, n){
		char c;
		cin >> c;
		input[i] = c;

		if(c == 'R') red.push_back(i);
		else white.push_back(i);
	}

	sort(all(red), greater<int>());
	sort(all(white), greater<int>());

	int ans = 0;
	rep(i, n){
		if(red.size() == 0 || white.size() == 0) break;

		if(input[i] == 'R'){
			red.erase(red.begin());
		}
		else{
			red.pop_back();
			ans++;
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 4720
#include <stdio.h>
int main(void){
	int n,i;
	long long ans = 0;
	long long a[5]={0};
	char s[11];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",s);
		if(s[0]=='M'){
			a[0]++;
		}else if(s[0]=='A'){
			a[1]++;
		}else if(s[0]=='R'){
			a[2]++;
		}else if(s[0]=='C'){
			a[3]++;
		}else if(s[0]=='H'){
			a[4]++;
		}
	}
	long long func(int x,int b,int c){
		return a[x]*a[b]*a[c];
	}
	ans = func(0,1,2) + func(0,1,3) + func(0,1,4)
	+ func(0,2,3) + func(0,2,4)+func(0,3,4)+func(1,2,3)+func(1,2,4)
	+ func(1,3,4)+func(2,3,4);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

int s[100010],t[100010],c[100010];
int v[40][200010];
int main(){
    int N,C;
    cin>>N>>C;
    for (int i = 0; i < N; i++)
    {
        cin>>s[i]>>t[i]>>c[i];
        
    }
    for (int i = 0; i < N; i++)
    {
        
        v[c[i]][2*s[i]-1]++;
        v[c[i]][2*t[i]]--;
    }
    for (int i = 1; i <=C; i++)
    {
        for (int j = 1; j <=200001; j++)
        {
            v[i][j]+=v[i][j-1];
        }
        
    }
  /*for (int i = 0; i < 30; i++)
   {
       cerr<<v[1][i];
   }*/
   ll min_c=0;
   ll cnt=0;
   for (int j = 0; j <= 200001; j++)
   {    cnt=0;
       for (int i = 1; i <= C; i++)
       {
           if(v[i][j]>0)
            cnt+=1;
       }
       if(cnt>=min_c){
           min_c=cnt;
       }
       
   }
   cout<<min_c<<endl;
    return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
//const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    ll k; cin >> k;
    ll n = 7;
    if(n % k == 0) {cout << 1 << endl; return 0;}
    rep(i, k+1) {
        if(n == 0) {
            cout << i + 1 << endl;
            return 0;
        }
        else n = (n * 10 + 7) % k;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
int main(void) {
    int x, a, b; cin >> x >> a >> b;
    int c = b - a;
    if(c <= 0) cout << "delicious";
    else if(c > x) cout << "dangerous";
    else cout << "safe";
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

for line in sys.stdin:
    a, b = map(int, line.split())
    t1, t2 = a, b
    while True:
        if a%b:
            a, b = b, a%b
        else:
            break
    gcd = b
    lcm = t1/gcd*t2
    print "%d %d" %(gcd, lcm)

Measured memory_bytes: 6224
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define ll 				long long
#define int             long long int
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define modp            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define FIO           	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl 			'\n'
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
// void aks()
// {
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
// }


void solve()
{
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
}
 
int32_t main()
{
	FIO
    //aks();
    // w(t)
    {
    	solve();
    }
    return 0;
}
	

	

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 205
#define maxr 1005
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
int fl[maxn][maxn],fs[maxn][maxn],dp[maxr][maxn],n,m,r,a[maxr];
int main(){
	while(~scanf("%d%d",&n,&m) && (n+m)>0){
		memset(fl,0x3f,sizeof(fl));
		memset(fs,0x3f,sizeof(fs));
		for(int i=1;i<=n;i++) fs[i][i] = fl[i][i] = 0;
		for(int i=1;i<=m;i++){
			int u,v,w;
			scanf("%d%d%d",&u,&v,&w);
			char c;
			while(scanf("%c",&c) && (c!='S'&&c!='L'));
			if(c == 'S') fs[u][v] = fs[v][u] = min(fs[u][v],w);
			else fl[u][v] = fl[v][u] = min(fl[u][v],w);
		}
		scanf("%d",&r);
		for(int i=1;i<=r;i++) scanf("%d",&a[i]);
		for(int k=1;k<=n;k++){
			for(int i=1;i<=n;i++){
				for(int j=1;j<=n;j++){
					fl[i][j] = min(fl[i][j],fl[i][k] + fl[k][j]);
					fs[i][j] = min(fs[i][j],fs[i][k] + fs[k][j]);
				}
			}
		}
		memset(dp,0x3f,sizeof(dp));
//		a[0] = 1;
		for(int i=1;i<=n;i++) dp[1][i] = fs[a[1]][i] + fl[i][a[1]];
		for(int i=2;i<=r;i++){
			for(int j=1;j<=n;j++){
				for(int k=1;k<=n;k++){
					ll res;
					if(j==k) res = (ll)dp[i-1][k] + (ll)fl[a[i-1]][a[i]];
					else res = (ll)dp[i-1][k] + (ll)fl[a[i-1]][k] + (ll)fs[k][j] + (ll)fl[j][a[i]];
					dp[i][j] = min((ll)dp[i][j],res);
				}
			}
		}
		int ans = inf;
		for(int i=1;i<=n;i++){
			ans = min(ans,dp[r][i]);
		}
		printf("%d\n",ans);
	}
	return 0;
}



Measured memory_bytes: 4268
a, b = map(int, input().split())
st_l = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]

if st_l.index(a) > st_l.index(b):
    print('Alice')
elif st_l.index(a) < st_l.index(b):
    print('Bob')
else:
    print('Draw')

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int a[110];
int b[110];
int q=1000000;
int main()
{
 int m,n,res;
 cin>>m>>n;
 for(int i=0;i<n;i++)
 {
 	cin>>a[n];
 	b[a[n]]=1;
 }
 for(int j=0;j<202;j++)
 {
 	if(b[j]!=1&&abs(m-j)<q)
 	{
 	res=j;
 	q=m-j;
    }
 }
 cout<<res;
   return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int b,r,g,c,s,t;
	while(cin>>b>>r>>g>>c>>s>>t,b+r+g+c+s+t){
		cout<<b*95+r*63+g*7+c*2+s*3-t*3+100<<endl;
	}
	return 0;
}

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

#define ll long long
#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
inline void Fail(){
	printf("0");
	exit(0);
}

ll x;
int main(){
	scanf("%lld",&x);
	ll res=x/11LL;
	res*=2LL;
	x%=11LL;
	if(x!=0&&x<=6LL)res++;
	else if(x!=0)res+=2LL;
	printf("%lld",res);
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 256
n = int(input())
ss = input()
sl = list(ss)

right = 0
p = 0
left = 0
for s in sl:
    if s == "(":
        p -= 1
    else:
        p += 1
        left += 1
        right = max(p, right)

x = right + n - 2*left
print("("*right + ss + ")"*x)



Measured memory_bytes: 3060
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	int ans = 0;
	if (b == 1) {
		cout << 0 << endl;
		return 0;
	}
	ans++;
	b = b - a;
	ans += b / (a - 1);
	if (b % (a - 1) > 0) {
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
# D
if __name__=='__main__':
    N = int(input())
    AB = []
    worktime = 0
    answer = 'Yes'
    for i in range(N):
        a,b= map(int,input().split())
        AB.append((a,b))
    AB.sort(key=lambda x:x[1])
    for i in range(N):
        worktime +=AB[i][0]
        if worktime > AB[i][1]:
            answer = 'No'
            break
    print(answer)

Measured memory_bytes: 31864
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

#define ll long long int
#define rep(i, n) for(ll (i) = 0; (i) < (n); i++)

int main()
{
    ll n; cin >> n;
    vector<ll> ai(n);
    rep(i, n) cin >> ai[i];
    sort(ai.begin(), ai.end(), greater<ll>());

    ll ans = ai[0];
    if(n % 2){
        ll m = (n-1)/2;
        rep(k, m-1) ans += ai[k+1]*2;
        ans += ai[m];
    }else{
        ll m = n/2;
        rep(k, m-1) ans += ai[k+1]*2;
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4844
n = int(input())

B =        list( map(int, input().split()) )	# 1 2 3 4 5 ...

A=[0]*n

A[0]=B[0]
A[1]=B[0]

for i in range(n-1):
	A[i  ] = min(B[i], A[i])
	A[i+1] = B[i]

print( sum(A) )



Measured memory_bytes: 3060
from fractions import gcd


def main():
        
    N = int(input())
    A = list(map(int, input().split())) 
    MOD = 10**9 + 7


    l = 1

    for a in A:
        l = l * a // gcd(l, a)


    ans = 0
    for a in A:
        ans += (l // a)
    ans %= MOD

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 6200
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<numeric>
#include<algorithm>
#include<string>
#include<map>
#include<bitset>
#include<set>
#include<cmath>
#define int long long
#define inf 8938103643641919514ll
#define oku 1000000007ll
using namespace std;
int a,b,c,d,e,f,g,n;
int dx[]={0,-1,0,1,0};
int i,j,k;
int p[100001],q[100001],r[100001],ans;
signed main(){
	cin>>a;
	ans+=(a/11)*2;
	a%=11;
	if(a==0);
	else if(a<=6)
		ans+=1;
	else
		ans+=2;
	cout<<ans<<endl;
}

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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s; cin >> s;
	if(s == "ABC") cout << "ARC";
	else cout << "ABC";
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#define rep(i, s, n) for(int i = s; i < n; i++)
using namespace std;

int h, w;
int plus_x[4] = {1, 0, -1, 0};
int plus_y[4] = {0, -1, 0, 1};
queue<pair<int, int>> que;
char s[20][20];
int ans[20][20];

void bfs(int x, int y) {
    int ans_field[h][w];
    rep(i, 0, h) {
        rep(j, 0, w) {
            ans_field[i][j] = -1;
        }
    }

    que.push(make_pair(x, y));
    ans_field[x][y] = 0;
    while(que.size()) {
        pair<int, int> p;
        p = que.front();
        que.pop();
        rep(i, 0, 4) {
            x = p.first + plus_x[i];
            y = p.second + plus_y[i];
            if(x >= 0 && x < h && y >= 0 && y < w) {
                if(ans_field[x][y] == -1 && s[x][y] == '.') {
                    que.push(make_pair(x, y));
                    ans[x][y] = max(ans[x][y], ans_field[p.first][p.second]+1);
                    ans_field[x][y] = ans_field[p.first][p.second]+1;
                }
            }
        }
    }
}

int main() {
    cin >> h >> w;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> s[i][j];
            ans[i][j] = 0;
        }
    }

    rep(i, 0, h) {
        rep(j, 0, w) {
            if(s[i][j] == '.') {
                bfs(i, j);
            }
        }
    }

    int answer = 0;
    rep(i, 0, h) {
        rep(j, 0, w) {
            answer = max(answer, ans[i][j]);
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) cout<<"Case #"<<i<<": "
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


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

Measured memory_bytes: 256