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


int main() {

  int n;
  cin>>n;

  int64_t sum_j=0,sum_b=0;;
  for(int i=0;i<n;i++){
    double x;
    string u;

    cin>>x>>u;
    if(u=="JPY"){
      sum_j+=(int64_t)x;
    }
    else
    {
      sum_b+=(int64_t)(x*(double)100000000);
    }
    


  }

  cout << std::fixed  <<(double)sum_j+(double)(sum_b*38/(double)10000)<<endl;

  return 0;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt(); sc.nextLine();

    for(int i = 0; i < W+2; i++) {
      System.out.print("#");
    }

    System.out.println();

    for(int i = 0; i < H; i++) {
      String line = sc.nextLine();

      System.out.print("#");
      System.out.print(line);
      System.out.println("#");
    }

    for(int i = 0; i < W+2; i++) {
      System.out.print("#");
    }

    System.out.println();
  }
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> X(N, 0);
    for (int i = 0; i < N; ++i)
    {
        cin >> X[i];
    }
    int min_var = 1 << 30;
    for (int i = 0; i <= N - K; ++i)
    {
        int ans1 = abs(X[i]);
        ans1 += abs(X[i] - X[i + K-1]);
        int ans2 = abs(X[i+K-1]);
        ans2 += abs(X[i] - X[i + K - 1]);

        min_var = min({min_var, ans1,ans2});

    }

    cout << min_var << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
using Graph = vector<vector<pair<ll, ll>>>;

bool is_prime(ll num) {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    for (ll i = 3; i <= sqrt(num); i += 2) {
        if (num % i == 0) return false;
    }
    return true;
}

int main()
{
    ll N; cin >> N;
    vll v{11}; ll i = 16;
    while (v.size() < N) {
        if (is_prime(i)) v.push_back(i);
        i+=5;
    }
    rep(i, N) cout << v[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,k,p,a,pwr[200],j;
string s;
int main(){
	cin>>n;
	a=26;
	j++;
	while(a<n){
	n-=a;
	a*=26;
	j++;
	}
	pwr[0]=1;
    for(k=1;k<=11;k++)
    pwr[k]=pwr[k-1]*26;

	for(k=1;k<=j;k++){
		for(int i='a';i<='z';i++){
			if(n<=pwr[j-k]*(i-'a'+1) && n>=pwr[j-k]*(i-'a')) {
				cout<<(char)(i);
				n-=pwr[j-k]*(i-'a');break;
			}
		}
	}
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define DBL(x) ((x)*(x))
#define EPS 1e-10

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int memoY[1000][1000];
int memoT[1000][1000];
int memo[1000][1000];
char buff[1000][1010];

int main(){
  int n;
  while(scanf("%d ",&n), n){
    memset(memoY,0,sizeof(memoY));
    memset(memoT,0,sizeof(memoT));
    memset(memo, 0,sizeof(memo) );
    REP(i,n) fgets(buff[i],sizeof(buff[i]),stdin);
    REP(i,n){
      int tmp1 = 1, tmp2 = 1;
      for(int j=0; j<n; j++){
	if(buff[i][j] == '*') tmp1 = 0;
	memoY[i][j] = tmp1++;
	if(buff[j][i] == '*') tmp2 = 0;
	memoT[j][i] = tmp2++;
      }
    }
    int ans = 0;

    for(int i=0; i<n; i++){
      if(buff[i][0] == '.')
	ans = max(ans, memo[i][0] = 1);
      if(buff[0][i] == '.')
	ans = max(ans, memo[0][i] = 1);
    }

    for(int i=1; i<n; i++){
      for(int j=1; j<n; j++){
	if(buff[i][j] == '.'){
	  int tmpm = INT_MAX;
	  tmpm = min(tmpm, memoY[i][j-1]);
	  tmpm = min(tmpm, memoT[i-1][j]);
	  tmpm = min(tmpm, memo[i-1][j-1]);
	  ans = max(ans, memo[i][j] = tmpm + 1);
	}
      }
    }

    /*
    REP(i,n) {REP(j,n) printf("%c ",buff[i][j]); puts("");}
    puts("[memoY]");
    REP(i,n) {REP(j,n) printf("%d ",memoY[i][j]); puts("");}
    puts("[memoT]");
    REP(i,n) {REP(j,n) printf("%d ",memoT[i][j]); puts("");}
    puts("[memo]");
    REP(i,n) {REP(j,n) printf("%d ",memo[i][j]); puts("");}
    */

    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 13000
#include <iostream>
#include <cstring>
#define MOD 1000000007
using namespace std;

int a, n=10, arr[110];

int main(void){
	cin>>a;
	arr[0]=0;
	for(int i=1;i<n;i++)for(int j=1;j<n;j++)arr[i*j]=1;
	if(arr[a])cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
int h,w;
long long mem[10];
long long ma[100][100];
long long a[200][200];
 
void solve(int st, long long cal, int num){
    long long stg;
    if(num == 1){
        mem[st] = min(cal, mem[st]);
        return;
    }
 
    if(mem[st] > cal){
        for(int i = 0; i < 10; i++){
            if(mem[st] > cal + ma[num][i] && i != num){
                solve(st, cal+ma[num][i], i);
            }
        }
    }
}
 
int main(){
    cin >> h >> w;
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin >> ma[i][j];
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++)  cin >> a[i][j];
    }
 
    for(int i = 2; i <= 9; i++) mem[i] = 100000;
  mem[0] = 10000;
    for(int i = 0; i <= 9; i++){
        for(int j = 0; j <= 9; j++){
            if(i != j)  solve(i,ma[i][j],j);
        }
    }
    
 
    long long ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j] != -1){
                ans += mem[a[i][j]];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
  
  vector<vector<char>>date(H,vector<char>(W));
  vector<vector<int>>ans(H,vector<int>(W));
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
cin>>date.at(i).at(j);
    }
  }
  
   for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
   if(date.at(i).at(j)=='#'){
     if(i-1>=0){
       ans.at(i-1).at(j)++;
       
       if(j-1>=0&&j-1<=W-1){
ans.at(i-1).at(j-1)++;
       }
       if(j+1>=0&&j+1<=W-1){
ans.at(i-1).at(j+1)++;
     }
     }
     
     if(j+1>=0&&j+1<=W-1){
       ans.at(i).at(j+1)++;
       
       if(i+1>=0&&i+1<=H-1){
         ans.at(i+1).at(j+1)++;
       }
     }
     if(i+1>=0&&i+1<=H-1){
ans.at(i+1).at(j)++;
    if(j-1>=0&&j-1<=W-1){
      ans.at(i+1).at(j-1)++;
    }
     }
     if(j-1>=0&&j-1<=W-1){
       ans.at(i).at(j-1)++;
     }
   }
    }
   }
  
 for(int i=0;i<H;i++){
   for(int j=0;j<W;j++){
     if(date.at(i).at(j)!='#'){
cout<<ans.at(i).at(j);
       
       if(j==W-1){
cout<<endl;
       }

     }
     else if(date.at(i).at(j)=='#'){
       cout<<'#';
       
       if(j==W-1){
cout<<endl;
     }

     }
     
   }
 }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
bool ch[100010]={true};
int main() {
	ll n,k;
	cin>>n>>k;
	ll hi[100010];
	for(ll i=0;i<n;i++){
		cin>>hi[i];
		ch[i]=true;
	}
	for(ll i=0;i<k;i++){
		ll x,y;
		cin>>x>>y;
		x--;y--;
		if(hi[x]<=hi[y]){
			ch[x]=false;
		}
		if(hi[y]<=hi[x]){
			ch[y]=false;
		}
	}
	ll cnt=0;
	for(ll i=0;i<n;i++){
		if(ch[i]==true){
			cnt++;
		}
	}
	cout <<cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 4464
#include<iostream>

using namespace std;

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

    if(a==b) cout<<"Draw"<<endl;
    else if(a==1 && b!=1) cout<<"Alice"<<endl;
    else if(b==1 && a!=1) cout<<"Bob"<<endl;
    else if(a>b && b!=1) cout<<"Alice"<<endl;
    else if(a<b && a!=1) cout<<"Bob"<<endl;
    return 0;
}

Measured memory_bytes: 256
n, m = list(map(int, input().split()))
a = [input() for i in range(n)]
b = [input() for i in range(m)]

flag = False
for i in range(n-m+1):
    for k in range(n-m+1):
        part = []
        for j in range(m):
            part.append(a[k+j][i:i+m])
        if b == part:
            flag = True

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
 
using namespace std;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

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

long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
 
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;

char s[201];
char t[201];

int main(){
	scanf("%s", s);
	
	strcpy(t,s);
	
	int len = strlen(s);
	
	int f = 1;
	
	while (f){
		len--;
		if (len%2 == 0){
			f = 0;
			REP(i,len/2){
				if (s[len/2+i] != t[i]){
					f = 1;
					break;
				}
			}
		}
	}
	
	cout << len << endl;
	
	return 0;
}

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

const int MAXN = 200000+10;
int sta[MAXN],end[MAXN];

struct Arm{
	int x;
	int Num;
}arm[MAXN];

bool cmp(const Arm a1,const Arm a2){
	return a1.x<=a2.x;
}

int main(){
	int N,M;
	scanf("%d%d",&N,&M);
	int x,d;
	for(int i=1;i<=N;i++)	sta[i]=end[i]=i;
	for(int i=1;i<=M;i++){
		scanf("%d%d",&x,&d);
		arm[i].x=x;
		arm[i].Num=d;
	}
	sort(arm+1,arm+1+M,cmp);
	for(int i=1;i<=M;i++){
		d=arm[i].Num;
		sta[d+1]=sta[d]=min(sta[d+1],sta[d]);
		end[d+1]=end[d]=max(end[d+1],end[d]);
	}
	for(int i=1;i<=N;i++){
		printf("%d",end[i]-sta[i]+1);
		if(i!=N)	printf(" ");
	}
	printf("\n");
	return 0;
}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;


int main(){
    int a,b;
  cin >>a>>b;
  vector<int> h(1000);
  for(int i = 1; i < 1000; ++i){
    h[i]=i+h[i-1];
  }
  int d = b-a;
  int ans = h[d] - b;
      
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
struct circle{
  double x,y,r;
  int c;
};
int ch(circle a,circle b){
  if((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)<(a.r+b.r)*(a.r+b.r)) return 1;
  return 0;
}
int sum;
int n;
vector<circle>  v;
int on[30]={};
bool dp[1<<24];
void rec(int bit){
  if(dp[bit]) return;
  dp[bit]=true;
  int i,j,k;
  int o=0;
  for(i=0;i<n;i++) if(bit>>i&1) o++;
  sum=max(n-o,sum);
  int f=0;
  for(i=0;i<n;i++){
    if(!(bit>>i&1)||bit&on[i]) continue;
    for(j=i+1;j<n;j++){
      if(!(bit>>j&1)||bit&on[j]) continue;
      if(v[i].c==v[j].c){
	rec((bit&~(1<<i))&~(1<<j));
      }
    }
  }
}

int main(){
  cin >> n;
  while(n!=0){
    circle c;
    int i,j,k;
    v.clear();
    for(i=0;i<n;i++){
      cin >> c.x >> c.y >> c.r >> c.c;
      v.push_back(c);
    }
    sum=0;
    fill(on,on+30,0);
    for(i=0;i<n;i++){
      for(j=0;j<i;j++){
	if(ch(v[i],v[j])) on[i]|=(1<<j);
      }
    }
    fill(dp,dp+(1<<n),false);
    rec((1<<n)-1);
    cout << sum << endl;
    cin >> n;
  }
  return 0;
}

Measured memory_bytes: 17640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int d[n+1];
  long long cnt=0;

  
  for (int i = 0;i < n;i++){
      cin >> d[i];
  }

  sort(d,d+n);
 
cout << d[n/2]-d[n/2-1] << endl;
  


}

Measured memory_bytes: 768
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    mt = 0
    for i in range(len(str(n))):
        t = (n // (10 ** i)) * (10 ** i)
        t -= 1 if i != 0 else 0
        t = str(t)
        tt = 0
        for j in range(len(t)):
            tt += int(t[j])
        mt = max(mt, tt)
    print(mt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    N = int(input())
    A, B = map(int, input().split())
    P = list(map(int, input().split()))

    problem1, problem2, problem3 = [], [], []
    for p in P:
        if p <= A:
            problem1.append(p)
        elif A + 1 <= p <= B:
            problem2.append(p)
        else:
            problem3.append(p)

    res = min(len(problem1), len(problem2), len(problem3))
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
count = [[[0]*11 for j in range(4)] for i in range(5)]
n = int(input())

for i in range(n):
    b, f, r, v = map(int, input().split())
    count[b][f][r] += v

for b in range(1, 5):
    if b >= 2:
        print("####################")
    for f in range(1, 4):
        for r in range(1, 11):
            print(" ", count[b][f][r], end="", sep="")
        print()

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    vec X(N);
    REP(i,0,N) cin >> X[i];

    ll sum = 0;
    REP(i,0,N-1) sum += MIN(A*abs(X[i]-X[i+1]),B);
    PR(sum);

    return 0;
}

/*



*/

Measured memory_bytes: 3936
from collections import defaultdict

N, M = map(int, input().split())
# Aは昇順に並べる
A = list(sorted(map(int, input().split())))

# B,Cの対応辞書を作り、C順に並べる
counter = defaultdict(int)
for _ in range(M):
    B, C = map(int, input().split())
    counter[C] += B
c_list = list(sorted(counter.keys(), reverse=True))

# Cを大きい順に個数分並べたリストを作る
moves = []
n = 0
for c in c_list:
    b = counter[c]
    if n + b < N:
        p = b
    else:
        p = N - n
    for i in range(p):
        moves.append(c)
    if len(moves) >= N:
        break

# AとCを小さい順に比較
siz = min(N, len(moves))
for i in range(siz):
    # Aの小さいものを上書き
    A[i] = max(A[i], moves[i])

print(sum(A))


Measured memory_bytes: 27520
s=require('fs').readFileSync('/dev/stdin','utf8').split('\n');
[n,h,w]=s[0].split(' ').map(n=>n|0)
for(i=1,r=0;i<=n;i++){
	[a,b]=s[i].split(' ').map(n=>n|0)
	a>=h&&b>=w&&r++
}
console.log(r)


Measured memory_bytes: 7740
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        int[] n={0,0,0};
		int ex;
		Scanner sc=new Scanner(System.in);
		for(int i=0;i<3;i++){
			n[i]=sc.nextInt();
		}
		for(int i=0;i<2;i++){
			for(int j=i+1;j<3;j++){
				if(n[i]>n[j]){
					ex=n[i];
					n[i]=n[j];
					n[j]=ex;
				}
			}
		}
		System.out.println(n[0]+" "+n[1]+" "+n[2]);
    }
}


Measured memory_bytes: 26376
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A[] = new int[N];
        int count = 0;
        for(int i =0; i < N; i++){
            A[i] = sc.nextInt();
                while(A[i]%2 == 0){
                A[i] = A[i]/2;
                count += 1;
                }
        }
        System.out.println(count);
    }
}


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

int main() {
int n;
  cin>>n;
 int a=0,b=0,c=0; 
 while(n--)
 {int dp[3]={0};
   int i,j,k;
  cin>>i>>j>>k;
  dp[0]=i+max(b,c);
  dp[1]=j+max(a,c);
  dp[2]=k+max(a,b);
  a=dp[0];
  b=dp[1];
  c=dp[2];
 }
  cout<<max(max(a,b),c);
}


Measured memory_bytes: 3612
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		int voteSum = 0;

		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
			voteSum += a[i];
		}

		for(int i = 0; i < n-1; i++){
			for(int j = i + 1; j < n; j++){
				if(a[i] < a[j]){
					int box = a[i];
					a[i] = a[j];
					a[j] = box;
				}
			}
		}

		if(a[m - 1] < ((double)voteSum/(4 * (double)m))){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}
	}
}

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

int main(){
  char s[3];
  int m;
  for(int i = 0; i < 3; i++){
    cin >> s[i];
    if(s[i]=='1'){
      m++;
    }
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <deque>

using namespace std;

int cur, tot;
long long n;

deque<int> A, B;

void solve(long long n) {
	if(!n) return;
	if(n & 1) {
		solve(n >> 1);
		++cur, tot += 2;
		A.push_back(cur), B.push_back(cur);
	} else {
		solve(n - 1);
		++cur, tot += 2;
		A.push_back(cur), B.push_front(cur);
	}
	return;
}

int main() {
	scanf("%lld", &n);
	solve(n);
	printf("%d\n", tot);
	for(int i = 1; i <= tot / 2; ++i) {
		printf("%d ", A.front());
		A.pop_front();
	}
	for(int i = 1; i <= tot / 2; ++i) {
		printf("%d%c", B.front(), i == tot / 2 ? '\n' : ' ');
		B.pop_front();
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
long long MIN(long long a,long long b){return a<b?a:b;}
long long MAX(long long a,long long b){return a<b?b:a;}
int main(){
  long long n,m,a[100],b[100],u,d,r,l,i,j,k,o,p,c,min=1e18*4;
  scanf("%lld %lld",&n,&m);
  for(i=0;i<n;i++)scanf("%lld %lld",&a[i],&b[i]);
  for(i=0;i<n;i++){
    for(j=0;j<=i;j++){
      for(k=0;k<=j;k++){
	for(p=0;p<=k;p++){
	  u=MIN(MIN(b[i],b[j]),MIN(b[k],b[p]));
	  d=MAX(MAX(b[i],b[j]),MAX(b[k],b[p]));
	  l=MIN(MIN(a[i],a[j]),MIN(a[k],a[p]));
	  r=MAX(MAX(a[i],a[j]),MAX(a[k],a[p]));
	  for(o=c=0;o<n;o++){
	    if(u<=b[o]&&b[o]<=d&&l<=a[o]&&a[o]<=r)c++;
	  }
	  if(c<m)continue;
	  min=MIN(min,(d-u)*(r-l));
	}
      }
    }
  }
  printf("%lld\n",min);
  return 0;
}


Measured memory_bytes: 128
import string
  
count = {x: 0 for x in string.ascii_lowercase}
lines = ""
  
while True:
    try:
        lines += input().lower()
    except EOFError:
        break
          
for c in lines:
    if 'a' <= c <= 'z':
        count[c] += 1
          
for key in string.ascii_lowercase:
    print("{0} : {1}".format(key, count[key]))

Measured memory_bytes: 8072
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <sstream> // std::stringstream
#include <bitset>  // std::bitset<N>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

void solve(){
	ll r, g, b;
	cin >> r >> g >> b;
	ll k;
	cin >> k;

	for (ll i = 0; i < k;i++){
		if(r>=g){
			g *= 2;
			continue;
		}

		if(g>=b){
			b *= 2;
			continue;
		}

		if(r<g && g<b){
			break;
		}
	}

	if(r<g && g<b){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

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



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string s,result;
int len;
cin>>s;
len = s.length();
result = "Yes";
for(int i=0;i<len;i++){
if(i%2==0 &&s[i]=='L'){
	result = "No";
}
if(i%2==1&&s[i]=='R'){
	result = "No";
}
}
cout<<result<<endl;
}

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

typedef long long ll;
ll X,Y;
string first="Alice",second="Brown";

int main(){
  cin>>X>>Y;
  if(X==Y|| X+1==Y || Y+1==X)cout<<second<<endl;
  else cout<<first<<endl;
  return 0;
}


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

using namespace std;

int gcd(const int x, const int y)
{
    if (x < y)
        return gcd(y, x);
    else if (x % y == 0)
        return y;
    else
        return gcd(y, x - y);
}

int main()
{
    int n;
    scanf("%d", &n);
    int a0;
    scanf("%d", &a0);
    for (int i = 1; i < n; i++)
    {
        int a;
        scanf("%d", &a);
        a0 = gcd(a, a0);
    }

    printf("%d\n", a0);

    return 0;
}


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

using namespace std;

typedef long long ll;

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

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

#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;


int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  
  ans = (n/500)*1000;
  n = n%500;
  ans += (n/5)*5;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int k;
	cin>>k;
	string s;
	cin>>s;
	k+=s.length();
	ll m=1e9+7;
	ll inv[2000005],fact[2000005],ifact[2000005];
	inv[1] = 1;
    for(int i = 2; i < 2e6+5; ++i)
    inv[i] = (m - (m/i) * inv[m%i] % m) % m;
    fact[0]=1;
    ifact[0]=1;
    for(int i=1;i<2e6+5;++i)
    {
    	fact[i]=(fact[i-1]*i)%m;
    	ifact[i]=(ifact[i-1]*inv[i])%m;
	}
	ll a25[2000005],a26[2000005];
	a25[0]=1;
	a26[0]=1;
	for(int i=1;i<2e6+5;i++)
	{
		a25[i]=(a25[i-1]*25)%m;
		a26[i]=(a26[i-1]*26)%m;
	}
	ll ans=0;
	for(int i=s.length();i<=k;i++)
	{
		ll temp=1;
		temp=(temp*fact[i-1])%m;
		temp=(temp*ifact[s.length()-1])%m;
		temp=(temp*ifact[i-s.length()])%m;
		//(((fact[i-1]*ifact[s.length()-1])%m)*ifact[i-s.length()])%m;
		temp=(temp*a25[i-s.length()])%m;
		temp=(temp*a26[k-i])%m;
		ans=(ans+temp)%m;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 82432
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()

#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
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

char albt[26] = {'a','b','c','d','e','f','g','h','i','j','k','l',
                 'm','n','o','p','q','r','s','t','u','v','w','x',
                 'y','z'};

//vector<ll> g[202020];
//fill(score, score+202020, 0);
//vector<ll> v;

int main(){
  ll n;
  cin >> n;
  
  ll idx[n+1];
  for (int i=0;i<n;i++){
    ll tmp;
    cin >> tmp;
    idx[tmp] = i;
  }
  
  multiset<ll> ms;
  ll ans = 0;
  ms.insert(-1); ms.insert(-1); ms.insert(n); ms.insert(n);
  for (int i=n;i>0;i--){
    ll cur_idx = idx[i];
    // auto pos = lower_bound(ms.begin(), ms.end(), cur_idx);
    auto pos = ms.lower_bound(cur_idx);
    //cout << distance(pos - ms.begin()) << endl;
    ll l1 = *pos; pos++;
    ll l2 = *pos; pos--; pos--;
    ll s1 = *pos; pos--;
    ll s2 = *pos;
    
    //cout << s2 << " " << s1 << " " << cur_idx << " " << l1 << " " << l2 << endl;
    ms.insert(cur_idx);
    ans += i*((s1-s2)*(l1-cur_idx)+(cur_idx-s1)*(l2-l1));
    //cout << i << " " << ans << endl;
    //break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5760
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 21 13:05:54 2019

@author: Yamazaki Kenichi
"""

N = int(input())
S = input()

a,ans = [],0
for c in S:
    if c == '.':
        ans += 1
        a.append(-1)
    else:
        a.append(1)
tmp = ans
for i in range(N):
    tmp += a[i]
    ans = min(ans,tmp)
#    print(ans,a[i],tmp)
print(ans)

Measured memory_bytes: 5128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;


int main(){
    ll n, k;
    cin >> n >> k;


    vector<ll> h(n);
    rep(i, n){
        cin >> h[i];
    }

    sort(h.begin(), h.end());
    reverse(h.begin(), h.end());
    ll ans = 0;
    for(int i = 0; i < k && i < n; ++i)   h[i] = 0;
    rep(i, n)   ans += h[i];
    cout << ans << endl;

}

Measured memory_bytes: 1792
# https://atcoder.jp/contests/abc077/tasks/arc084_a
# bisectで行けるけどめぐる式の練習

# Bを固定すると、A,Cを二分探索すれば条件を満たす個数が計算できる

from bisect import bisect_left, bisect_right
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


N = read_a_int()
A = read_ints()
B = read_ints()
C = read_ints()

A.sort()
C.sort()

ans = 0
for b in B:
    ans += bisect_left(A, b) * (N - bisect_right(C, b))
    # Cに関しては真に大きい個数を知りたいことに注意
print(ans)


Measured memory_bytes: 22720
import math
while True:
    num_student = int(input())
    if num_student == 0:
        break
    score = list(map(int, input().split()))

    mean = sum(score) / num_student

    total = 0
    for i in range(len(score)):
        total += (score[i] - mean) ** 2

    print('{:.8f}'.format(math.sqrt(total / num_student)))


Measured memory_bytes: 5700
import sys
input = sys.stdin.readline
n, q = map(int,input().split())
C = [list(map(int,input().split())) for i in range(q)]

class UnionFind():  # DSU（disjoint set union, 素集合データ構造）と同じ
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def leader(self, x):  # xが属する連結成分の代表元
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.leader(self.parents[x])
            return self.parents[x]

    def size(self, x):  # xが属する連結成分のサイズ
        return -self.parents[self.leader(x)]

    def merge(self, x, y):  # xとyを辺でつなぐ
        x = self.leader(x)
        y = self.leader(y)
        if x == y:
            return x
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return x

    def same(self, x, y):  # xとyが連結かどうか
        return self.leader(x) == self.leader(y)

    def groups(self):  # 連結成分ごとの頂点リスト
        n = self.n
        leader_index = [-1] * n
        ind = 0
        for i in range(n):
            if self.parents[i] < 0:
                leader_index[i] = ind
                ind += 1
        ANS = [[] for i in range(ind)]
        for i in range(n):
            ld = self.leader(i)
            ANS[leader_index[ld]].append(i)
        return ANS

    def n_cc(self):  # グラフ全体の連結成分の数
        A = [i for i in self.parents if i < 0]
        return len(A)

U = UnionFind(n)
for i in range(q):
    if C[i][0] == 0:
        U.merge(C[i][1], C[i][2])
    else:
        print(int(U.same(C[i][1], C[i][2])))

Measured memory_bytes: 109764
N=int(input())
a=list(map(int,input().split()))
o=0
m=0
u=[0]*8
for i in a:
    if 3199<i:
        o+=1
    else:
        if u[i//400]==0:
            u[i//400]+=1
            m+=1
print(max(m,1),m+o)

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

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

template<class T> bool chmin(T& a,T b){ if(a > b){ a = b; return true; } return false; }
template<class T> bool chmax(T& a,T b){ if(a < b){ a = b; return true; } return false; }

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

    int64_t n;cin >> n;
    string ans = "";
    while(n){
        n--;
        ans += (char)('a' + (n % 26));
        n /= 26;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << '\n';
}


Measured memory_bytes: 3644
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.{NumericRange, Queue}
import scala.collection.mutable
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val X = Array.fill(101)(0)
    Array.fill(sc.nextInt)(X(sc.nextInt) += 1)
    var ans = 0
    for (j <- Range(0, 100)) {
      val i = 100 - j
      X(i - 1) += X(i)
      if (X(i) >= i) (ans = math.max(ans, i))
    }
    println(ans)

  }

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}


Measured memory_bytes: 45244
program main
implicit none
integer :: n, k, i
character :: s*50,t*50

do i = 1, 50
t(i:i) = '1'
end do

read(*,*) n, k
read(*,*) s(1:n)
do i = 1, n
   if( i/= k ) then
   t(i:i) = s(i:i)
   else
   t(i:i) = char( ichar(s(i:i))+32 )
   end if
end do
write(*,*) t(1:n)

end program main


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

namespace ConsoleApplication1
{

    class Program
    {

        static void Main(string[] args)
        {

            
            string[] input = Console.ReadLine().Split(' ');

            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            int B = 0;

            for(int i = 1; i <= b - a; i++)
            {
                B += i;
            }

            int k = B - b;

            Console.WriteLine(k);

        }
    }
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
  cout.precision(17);

  int n;cin>>n;
  if(n%2==0){
    cout<<0.5<<endl;
  }else{
    cout<<(0.5 + (0.5/n))<<endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,a,b,c;
    cin>>a>>b>>c>>x;
    int ans=0;
    for(int i=0;i<=a;++i)
    {
        for(int j=0;j<=b;++j)
        {
            for(int k=0;k<=c;++k)
            {
                if(500*i+100*j+50*k==x)
                    ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n,m;
vl a,dp;

bool Judge(ll i,ll j,ll k){
	ll a1=-2*a[i],b1=a[i]*a[i]+dp[i];
	ll a2=-2*a[j],b2=a[j]*a[j]+dp[j];
	ll a3=-2*a[k],b3=a[k]*a[k]+dp[k];
	return (a2-a1)*(b3-b2)>=(b2-b1)*(a3-a2);
}
 
ll F(ll j,ll x){
	return -2*a[j]*x+a[j]*a[j]+dp[j];
}

int main(){
	cin>>n>>m;
	a=dp=vl(n);
	deque<int> q;
	q.push_back(0);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=1;i<n;i++){
		while(q.size()>1&&F(q[0],a[i])>F(q[1],a[i])) q.pop_front();
		dp[i]=F(q[0],a[i])+a[i]*a[i]+m;
		while(q.size()>1&&Judge(q[q.size()-2],q.back(),i)) q.pop_back();
		q.push_back(i);
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 3840
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main(){
	while(true){
		int H,W;
		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 == 0 || i == H-1 || j == 0 || j == W-1){
					cout << "#";
				}
				else cout << ".";
			}
			cout << endl;
		}
		
		cout << endl;
	}
}





Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
 
 
 
int main() {
   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
   
    int x,y;
    cin>>x>>y;
    
    int i,j,flag=0;
    for(i=0;i<=x;++i)
     {
         for(j=0;j<=x;++j)
          {
              if(2*i+4*j==y && i+j==x)
                {
                    flag=1;
                    break;
                }
          }
          
          if(flag==1)
            break;
     }
     
     if(flag==1)
       cout<<"Yes";
       
     else
      cout<<"No";
    
    
   
 
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main() {
  int H;
  int N;
  cin >> H;
  cin >> N;
  int i=0, a[N];
  for(i=0;i<N;i++){
    cin >> a[i];
  }

  int tmp =0;
  for (i=0; i<N; i++) {
      tmp += a[i];
     }
  

    if(H>tmp){
      cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <cassert>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

// Reference:
// D. Gusfield,
// Algorithms on Strings, Trees, and Sequences: Computer Science and
// Computational Biology
template <class T> vector<int> z_algorithm(const vector<T>& s) {
  int n = int(s.size());
  if (n == 0) return {};
  vector<int> z(n);
  z[0] = 0;
  for (int i = 1, j = 0; i < n; i++) {
    int& k = z[i];
    k = (j + z[j] <= i) ? 0 : min(j + z[j] - i, z[i - j]);
    while (i + k < n && s[k] == s[i + k]) k++;
    if (j + z[j] < i + z[i]) j = i;
  }
  z[0] = n;
  return z;
}

vector<int> z_algorithm(const string& s) {
  int n = int(s.size());
  vector<int> s2(n);
  for (int i = 0; i < n; i++) {
    s2[i] = s[i];
  }
  return z_algorithm(s2);
}

void print(vector<int> v){
  int n = (int)v.size();
  for(int i=0;i<n;i++){
  if(i==n-1) printf("%d\n", v[i]);
  else printf("%d ", v[i]);
  }
}

int main(){
  string s;std::cin >> s;
  int n = s.size();
  vector<int> l(n, true), r(n, true);

  auto z = z_algorithm(s);
  for(int i=1;i<n;i++){
    for(int j=2;(j-1)*i<=z[i];j++){
      l[i*j-1] = false;
    }
  }
  reverse(all(s));
  z = z_algorithm(s);
  for(int i=1;i<n;i++){
    for(int j=2;(j-1)*i<=z[i];j++){
      r[i*j-1] = false;
    }
  }
  if(l[n-1]){
    std::cout << 1 << '\n';
    std::cout << 1 << '\n';
    return 0;
  }
  ll cnt = 0;
  for(int i=0;i<n;i++) cnt += s[i] == s[0];

  if(cnt==n){
    std::cout << n << '\n';
    std::cout << 1 << '\n';
    return 0;
  }
  //print(l);
  //print(r);
  cnt = 0;
  for(int i=1;i<n;i++) if(l[i-1]&&r[n-1-i]) cnt++;
  std::cout << 2 << '\n';
  std::cout << cnt << '\n';
}


Measured memory_bytes: 13560
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long I, O, T, J, L, S, Z;
  cin >> I >> O >> T >> J >> L >> S >> Z;
  long long tmp1 = I / 2 * 2 + J / 2 * 2 + L / 2 * 2;
  long long tmp2 = 0;
  if (I > 0 && J > 0 && L > 0){
    tmp2 += 3 + (I - 1) / 2 * 2 + (J - 1) / 2 * 2 + (L - 1) / 2 * 2;
  }
  cout << O + max(tmp1, tmp2) << endl;
}

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

int n, m, x;
int c[12]; int a[12][12];

signed main() {
	int i, j;
	
	cin >> n >> m >> x;
	rep(i, n) {
		cin >> c[i];
		rep(j, m) cin >> a[i][j];
	}
	
	int ans = 1e+9;
	rep(i, (1 << n)) {
		int rikai[12] = {0};
		int sumC = 0;
		rep(j, n) {
			if ((i >> j) & 1) {
				sumC += c[j];
				for (int k = 0; k < m; k++) {
					rikai[k] += a[j][k];
				}
			}
		}
		rep(j, m) {
			if (rikai[j] < x) break;
		}
		if (j == m) ans = min(ans, sumC);
	}
	if (ans >= 1000000000) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(){
	int a;
	scanf("%d",&a);
	while(a--){
		int b,c,d,e;
		scanf("%d%d%d%d",&b,&c,&d,&e);
		int ret=0;
		int n;
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			int g,h;
			scanf("%d%d",&g,&h);
			if(g>=b&&g<=b+d&&h>=c&h<=c+e)ret++;
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int n;
    cin >> n;
    vector<pii> to[n];
    for (int i = 0; i < n - 1; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        to[a].push_back(make_pair(b, c));
        to[b].push_back(make_pair(a, c));
    }

    int q, k;
    cin >> q >> k;
    k--;
    ll d[n];
    for (int i = 0; i < n; i++) d[i] = -1;
    d[k] = 0;
    queue<int> que;
    que.push(k);
    while (que.size() > 0) {
        int a = que.front();
        que.pop();
        for (pii p : to[a]) {
            int na = p.first;
            int c = p.second;
            if (d[na] >= 0) continue;
            d[na] = d[a] + c;
            que.push(na);
        }
    }

    ll ans[q];
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        ans[i] = d[x] + d[y];
    }

    for (int i = 0; i < q; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 9588
#include <stdio.h>
int main(void){
    // Your code here!
    int N,Rc=0;
    char s[101];
    scanf("%d",&N);
    scanf("%s",s);
    for(int i = 0; i < N; i++)
    {
        if(s[i] == 'R') Rc++;
    }
    //printf("%d %d\n",Rc,N-Rc);
    printf("%s\n",(Rc>N-Rc)? "Yes":"No");
}


Measured memory_bytes: 128
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,x = map(int,readline().split())
lst1 = list(map(int,readline().split()))

lst1.sort()

i = 0
ans = 0
while i < n:
    if lst1[i] > x:
        break
    x -= lst1[i]
    ans += 1
    i += 1

if i == n:
    if x == 0:
        print(ans)
    else:
        print(ans-1)
else:
    print(ans)

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

int main() {
	
	int n;
	cin >> n;
	set<string> s;
	char last;
	bool is_shiritori = true;
	rep(i, n){
		string w;
		cin >> w;
		if(s.count(w)){
			is_shiritori = false;
		}else{
			s.insert(w);
		}
		if(last != w[0] && i > 0){
			is_shiritori = false;
		}
		last = w[w.size() - 1];
	}
	if(is_shiritori){
		puts("Yes");
	}else{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pld pair<ld, ld>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto i : a) cout << i << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);



using namespace std;

const int N = 2e5 + 5;
vector<int> gr[N];
ll q[N];
int used[N];

void dfs(int v, ll nows)
{
    q[v] = nows;
    used[v] = 1;
    for(auto i : gr[v])
    {
        if(!used[i])dfs(i, nows + q[i]);
    }
}
int main()
{
    fast;
    int n, m; cin >> n >> m;
    FOR(i, n - 1, 0)
    {
        int u, v; cin >> u >> v;
        gr[u].pb(v);
        gr[v].pb(u);
    }
    while(m--)
    {
        int p, x; cin >> p >> x;
        q[p] += x;
    }
    dfs(1, q[1]);
    FOR(i, n + 1, 1)cout << q[i] << ' ';
    return 0;
}


Measured memory_bytes: 21888
N = input()
N = int(N)
K= list(map(int, input().split()))
import numpy as np
answers = []
ave = sum(K)//len(K)
sqrtMax = int(np.sqrt(max(K)))
rngMin = ave - sqrtMax#range min
for p in range(rngMin,rngMin+2*sqrtMax):
    ans = 0
    for k in K:
        ans += ((k-p)**2)
    answers.append(ans)
print(min(answers))

Measured memory_bytes: 12492
// https://atcoder.jp/contests/dp/tasks/dp_a
// https://qiita.com/drken/items/dc53c683d6de8aeacf5a

#include <stdio.h>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int N_input;
    int h[100010];
    long long int cost[100010];

    for(auto i=0; i<100010; i++){
        h[i] = 0;
        cost[i] = 0;
    }
    scanf("%d", &N_input);
    for(auto i=1; i<=N_input; i++){
        scanf("%d", &h[i]);
    }
    h[N_input+1] = 0;
    h[N_input+2] = 0;

    cost[0] = 0;
    cost[1] = h[0];
    cost[2] = abs(h[1] - h[2]);
    for(auto i=1; i<N_input; i++){
        cost[i+2] += min(
            cost[i] + abs(h[i] - h[i+2]),
            cost[i+1] + abs(h[i+1] - h[i+2])
        );
        // printf("%d\t%lld\n", i+2, cost[i+2]);
    }

    printf("%lld", cost[N_input]);
    
}

Measured memory_bytes: 1280
#include <iostream>

using namespace std;
int main(){
	int i,a,b;
	cin >> a >> b;
	for(i=0;i<=100000;i++){
		double x = (double)i;
		int y = (int)(x*0.08);
		int z = (int)(x*0.10);
		if(y==a && z==b){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

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

using namespace std;

typedef long long LL;

const int MAXN = 1e05 + 10;

int N;
pair<LL, int> d[MAXN];

int subsize[MAXN]= {0}, fa[MAXN]= {0};
void solve () {
	for (int i = N; i > 1; i --) {
		subsize[d[i].second] ++;
		int up = N - 2 * subsize[d[i].second];
		if (up < 0) { puts ("-1"); exit (0); }
		int p = lower_bound (d + 1, d + N + 1, make_pair (d[i].first - up, 0)) - d;
		if (p >= i || d[p].first != d[i].first - up) { puts ("-1"); exit (0); }
		fa[d[i].second] = d[p].second;
		subsize[d[p].second] += subsize[d[i].second];
	}
}

vector<int> G[MAXN];
LL dist[MAXN]= {0}, total = 0;
void DFS (int root) {
	total += dist[root];
	for (int i = 0; i < (int) G[root].size(); i ++) {
		int v = G[root][i];
		dist[v] = dist[root] + 1;
		DFS (v);
	}
}

inline LL getnum () {
	LL num = 0; char ch = getchar ();
	while (! isdigit (ch)) ch = getchar ();
	while (isdigit (ch)) num = (num << 3) + (num << 1) + ch - '0', ch = getchar ();
	return num;
}

int main () {
	// freopen ("33.txt", "r", stdin);

	N = getnum ();
	for (int i = 1; i <= N; i ++) d[i].first = getnum (), d[i].second = i;
	sort (d + 1, d + N + 1);
	solve ();
	for (int i = 2; i <= N; i ++) G[fa[d[i].second]].push_back(d[i].second);
	DFS (d[1].second);
	if (total != d[1].first) { puts ("-1"); return 0; }
	for (int i = 2; i <= N; i ++)
		printf ("%d %d\n", fa[d[i].second], d[i].second);

	return 0;
}

/*
7
10
15
13
18
11
14
19
*/

/*
2
1
2
*/

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  ll a = 1;
  for(int i=0;i<m;i++) {
    a *= 2;
  }
  cout << a * m * 1900 + a * (n-m) * 100 << endl;
}


Measured memory_bytes: 256