akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int) int {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int) int {
	return a * b / GCD(a, b)
}

type P struct {
	l, r int
}

func main() {
	var N int
	fmt.Scanf("%d\n", &N)
	A := make([]int, N)
	addMap := map[int]int{}
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		A[i] = a
		addMap[i+1-a]++
	}
	cnt := 0
	for idx, a := range A {
		diff := idx + 1 + a
		cnt = cnt + addMap[diff]
	}
	fmt.Println(cnt)
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


Measured memory_bytes: 18224
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

signed main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    ll a;
    map<ll, ll> mp;
    rep(n){
        cin >> a;
        mp[a] = 1 - mp[a];
    }
    ll ans = 0;
    for(auto itr=mp.begin(); itr!=mp.end(); ++itr){
        if(itr->second == 1) ans++;
    }
    cout << ans;
}


Measured memory_bytes: 6528
n = int(input())
s = list(input())
tmp = [0 for x in range(n+1)]
current=0
for idx, ss in enumerate(s):
    if ss=='I':
        tmp[idx+1]=tmp[current]+1
    else:
        tmp[idx+1]=tmp[current]-1
    current+=1
print(max(tmp))


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

int main() {
    long a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0) {
        c -=b;
        a -=d;
    }
    // cout<<a<<" "<<c;
	if(c > 0) {
	    cout<<"No";
	}
	else {
	    cout<<"Yes"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
long long int  mod=1000000007;
 
int main()
{
 
 int n;
 cin>>n;
 
 
 long long int a=0;
 long long int s=0;
 long long int answer=0;
 for(int i=0;i<n;i++)
 {
     cin>>a;
     a=a%mod;
     long long b=((s%mod)*(a%mod))%mod;
     answer=(answer+(b))%mod;
     
     s+=a;
 }
 cout<<(answer)<<endl;
return 0;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N, X = map(int, input().split())
Ms = list()
for n in range(N):
    Ms.append(int(input()))
ans = N
X -= sum(Ms)
ans += X // min(Ms)
print(ans)


Measured memory_bytes: 6480
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  bool f=false;
  for(int j=0;j<s.size();j++){
 
    char w=s[s.size()-1];
    s.pop_back();
    s=w+s;

    if(s==t){
      f=true;
      break;
    }
  }
  if(f)
  cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
# coding: utf-8
from math import gcd

K=int(input())
ans=0
memo=[[[-1 for i in range(K+1)] for j in range(K+1)] for k in range(K+1)]

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            if memo[i][j][k]==-1:
                v=gcd(i,gcd(j,k))
                memo[i][j][k]=v
                memo[i][k][j]=v
                memo[j][k][i]=v
                memo[j][i][k]=v
                memo[k][i][j]=v
                memo[k][j][i]=v
            else:
                v=memo[i][j][k]
            ans+=v

print(ans)

Measured memory_bytes: 135256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;

    string ans;
    for (int i = 0; i < N; i++) {
        ans += S[i];
        ans += T[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# 入力を取得
input = gets
tmp = input.split(" ")

# 文字列
N = tmp[0]
K = tmp[1]
Q = tmp[2]

point = []

# デフォルトのポイントをセット
for i in 0..N.to_i-1
    point.push(K.to_i-Q.to_i)
end

# ポイントの計算
for i in 0..Q.to_i-1
    a = gets
    point[a.to_i-1]+=1
end

# # Yes,Noに変換
result = point.map{|p|
    if p <= 0
        "No"
    else
        "Yes"
    end
}

# 結果を出力
puts result

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

int main() {
    int H, W, M;
    cin >> H >> W >> M;
    int h[M], w[M];
    for (int i = 0; i < M; i++) cin >> h[i] >> w[i];

    map<pair<int, int>, bool> mp;
    for (int i = 0; i < M; i++) mp[{h[i], w[i]}] = true;

    vector<int> h_cnt(300005, 0), w_cnt(300005, 0);
    for (int i = 0; i < M; i++) h_cnt[h[i]]++, w_cnt[w[i]]++;

    int mx_h = *max_element(h_cnt.begin(), h_cnt.end());
    int mx_w = *max_element(w_cnt.begin(), w_cnt.end());

    vector<int> h_koho, w_koho;
    for (int i = 0; i < 300005; i++) {
        if (h_cnt[i] == mx_h) h_koho.push_back(i);
        if (w_cnt[i] == mx_w) w_koho.push_back(i);
    }

    bool ext = true;
    for (int nh: h_koho) for (int nw: w_koho) {
        if (!mp[{nh, nw}]) {
            ext = false;
            break;
        }
    }

    cout << mx_w + mx_h - ext << endl;
    return 0;
}

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

using namespace std;
const int N = 1000005;

string s;
int c, f;

void init(){
	cin >> s;
	for(int i = 1; i <= s.length(); i++){
		if(s[i - 1] == 'C' and !c) c = i;
		if(s[i - 1] == 'F') f = i; 
	}
	if(!c or ! f) puts("No");
	else if(f > c) puts("Yes");
	else puts("No");
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
using namespace std;
const int N = 1e5+50;

int32_t main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("atcoder.txt", "r", stdin);
	int tc = 1;
	for(int T=1; T<=tc; T++){
		int n, a, b; cin>>n>>a>>b;
		int rem,tmp=0;
		if((a+b)>0){
			rem = n%(a+b);
			tmp = n/(a+b);
		}
		rem = min(rem,a);
		cout<<rem+a*tmp<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  char s[101], t[101];
  scanf("%s", s);
  scanf("%s", t);
  int n = strlen(s);
  int ok = 0;
  rep(first, 0, n) {
    if ( s[first] != t[0] ) continue;
    int ti = 1;
    int si = first + 1;
    int judge = 1;
    while (si % n != first) {
      if ( s[si % n] != t[ti % n] ) {
        judge = 0;
        break;
      }
      si++; ti++;
    }
    if ( judge ) {
      ok = 1;
      break;
    }
  }
  printf( ok ? "Yes\n" : "No\n" );
  return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp13
{
	class Program
	{
		static void Main(string[] args)
		{
			string input= Console.ReadLine();
			char mid = input[1];
			if (mid == 'B')
			{
				Console.WriteLine("ARC");

			}
			else
			{ Console.WriteLine("ABC");
				}
			
		}

	}
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,r;
    cin>>n>>r;
    ll ans=0;
    if(n<10){
        ans=r+100*(10-n);
    }else{
        ans=r;
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func emp(nums [3]int) (age string) {
	switch {
	case nums[0] <= 2018:
		age = "Heisei"
	case nums[0] <= 2019 && nums[1] <= 4:
		age = "Heisei"
	case nums[0] >= 2019 && nums[1] >= 5:
		age = "TBD"
	}
	return
}

func main() {
	var s string
	fmt.Scan(&s)
	var nums [3]int
	for i, x := range strings.Split(s, "/") {
		nums[i], _ = strconv.Atoi(x)
	}
	fmt.Println(emp(nums))
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void){
  int a,b,c;
  long int k;
  scanf("%d%d%d%ld",&a,&b,&c,&k);
  if(k%2==1){
    printf("%d",b-a);
  }else{
    printf("%d",a-b);
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int n , a , b;
    cin >> n >> a >> b;
    if(n < a + b){
        cout << min(a , b) << ' ' << a + b - n << endl;
    }
    else{
        cout << min(a , b) << ' ' << 0 << endl;
    }
}


Measured memory_bytes: 3636
object Main extends App {
  val n = scala.io.StdIn.readInt()
  var spArray = Vector.empty[(String, Int, Int)]
  for(i<-1 to n) {
    val readSP = scala.io.StdIn.readLine()
    val arraySP =  readSP.split(" ")
    spArray :+= (arraySP(0), arraySP(1).toInt, i)
  }
  val spArraySorted = spArray.sortWith { (sp1, sp2) =>
    if(sp1._1 == sp2._1) {
      sp1._2 > sp2._2
    } else {
      sp1._1.compareToIgnoreCase(sp2._1) < 0
    }
  }
  spArraySorted.foreach(sp =>
    println(sp._3)
  )
}

Measured memory_bytes: 25416
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  rep(i,N) cin >> p[i];
  int no=0;
  rep(i,N) if(p[i]!=(i+1)) no++;
  if(no<=2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

#define LENGTH 3

int main () {

    char S[LENGTH + 1];

    scanf("%s", S);
    //printf("%s\n", S);

    if(!strcmp(S, "ABC")) printf("ARC\n");
    if(!strcmp(S, "ARC")) printf("ABC\n");

    return 0;
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1000000000;
const ll INF= 1e18;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    vector<bool> cnt(N);
    if(vec.at(0) >= 0){
        for(int i = 1;i < N;i++) {
            cnt.at(i) = true;
        }
    }
    else if(vec.at(N - 1) <= 0) {
        cnt.at(N - 1) = true;
    }
    else {
        for(int i = 1;i < N;i++) {
            if(vec.at(i) >= 0) {
                cnt.at(i) = true;
            }
        }
    }
    int ret = 0;
    for(int i = 0;i < N;i++) {
        if(cnt.at(i) == true) {
            ret += vec.at(i);
        }
        else {
            ret -= vec.at(i);
        }        
    }
    cout << ret << endl;
    ret = vec.at(0);
    for(int i = N - 1;i >= 0;i--) {
        if(cnt.at(i - 1) == false) {
            cout << vec.at(i) << " " << ret << endl;
            ret = vec.at(i) - ret;
            break;
        }
        else {
            cout << ret << " " << vec.at(i) << endl;
            ret -= vec.at(i);
        }
    }
    for(int i = 1;i < N;i++) {
        if(cnt.at(i) == true) {
            break;
        }
        else {
            cout << ret << " " << vec.at(i) << endl;
            ret -= vec.at(i);
        }
    }
}

Measured memory_bytes: 2304
from heapq import heappush, heappop

N, M = map(int, input().split())
AB = [[] for _ in range(M+1)]

for _ in range(N) :
    a, b = map(int, input().split())
    if a <= M :
        AB[M-a].append(b)
    
q = []
for a in range(M+1) :
    for b in AB[a] :
        heappush(q, b)
        if len(q) > a + 1 :
            heappop(q)
            
print(sum(q))

Measured memory_bytes: 66208
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
 
#define int long long
 
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
 
struct person {
    int A, B, C;
};
 
int X, Y, Z;
person p[110000];
int ans_XY[110000], ans_XZ[110000] = {};
 
signed main() {
    cin >> X >> Y >> Z;
    for (int i = 0; i < X + Y + Z; i++) {
        cin >> p[i].A >> p[i].B >> p[i].C;
    }
    sort(p, p + X + Y + Z, [](person l, person r) {
        return l.B - l.C > r.B - r.C;
    });
    auto c_XY = [](int l, int r) {
            return p[l].B - p[l].A > p[r].B - p[r].A;
        };
    auto c_XZ = [](int l, int r) {
            return p[l].C - p[l].A > p[r].C - p[r].A;
        };
    priority_queue<int, vector<int>, decltype(c_XY)> pq_XY(c_XY);
    priority_queue<int, vector<int>, decltype(c_XZ)> pq_XZ(c_XZ);
    for (int i = 0; i < Y; i++) {
        pq_XY.push(i);
        ans_XY[Y - 1] += p[i].B;
    }
    for (int i = X + Y + Z - 1; i >= X + Y; i--) {
        pq_XZ.push(i);
        ans_XZ[X + Y] += p[i].C;
    }
    for (int i = Y; i < X + Y; i++) {
        pq_XY.push(i);
        ans_XY[i] = ans_XY[i - 1] + p[i].B - p[pq_XY.top()].B + p[pq_XY.top()].A;
        pq_XY.pop();
    }
    for (int i = X + Y - 1; i >= Y; i--) {
        pq_XZ.push(i);
        ans_XZ[i] = ans_XZ[i + 1] + p[i].C - p[pq_XZ.top()].C + p[pq_XZ.top()].A;
        pq_XZ.pop();
    }
    int ans = 0;
    for (int i = Y - 1; i < X + Y; i++) {
        ans = max(ans, ans_XY[i] + ans_XZ[i + 1]);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
  string S;
  int val=700;
  
  cin >> S;
  
  for(int i=0;i<S.size();i++){
    if(S[i]=='o'){
      val+=100;
    }
  }
  cout << val << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
        using namespace std;
         
        #define int long long
        #define f(i,l,n) for(int i=l;i<n;i++)
        #define E "\n"
          #define M 998244353
  
        int32_t main()
        {
          
               int n,a,b;
               cin>> n >> a >> b;
               
               
               
               if(a>b) swap(a,b);
               
               int ans=0;
               if((b-a)%2==0)
               {
                 ans=(b-a)/2;
               }
               else
               {
                    ans=min(b-1,n-a);
                    
                    
                         int aa=a+n-b+1,bb=n;
                        
                         int aan=(n-aa)/2;
                         aan+=1+n-b;
                         ans=min(ans,aan);
                    
                    
                         bb=b-(a-1);
                         aan=(bb-1)/2;
                         aan+=1+a-1;
                         
                         
                         ans=min(ans,aan);
                    
               }
               
             cout<<ans;
         return 0;
        }
       

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

int main(){
  string str;
  int val,i;
  cin >> str;
  for (i=0;i<str.size()-1;i++){
    if(str.at(i)==str.at(i+1)){
      val++;
      if(str.at(i+1) == '0'){
      	str.at(i+1) = '1';
      }else{
        str.at(i+1) ='0';
      }
    }
  }
  cout << val <<endl;
}

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

int main() {
  int n;
  cin >> n;
  double x = 1;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    x *= a.at(i);
  }
  vector<double> b(n);
  double s = 0;
  for(int i=0;i<n;i++){
    b.at(i) = x / a.at(i);
    s += b.at(i);
  }
  
  cout << x / s << endl;
}

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

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] a_asArgs)
		{
			long l_iN = Console.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray()[0];
			char[] l_acHead = new char[] { 'M', 'A', 'R', 'C', 'H' };
			long[] l_aiCount = new long[5];
			for (long l_iIndex = 0; l_iIndex < l_iN; l_iIndex++)
			{
				string l_sName = Console.ReadLine();
				long l_iPos = Array.IndexOf<char>(l_acHead, l_sName[0]);
				if (l_iPos > -1)
				{
					l_aiCount[l_iPos]++;
				}
			}
			long[][] l_aaiCombination = new long[][] {
				new long[] {0,1,2},
				new long[] {0,1,3},
				new long[] {0,1,4},
				new long[] {0,2,3},
				new long[] {0,2,4},
				new long[] {0,3,4},
				new long[] {1,2,3},
				new long[] {1,2,4},
				new long[] {1,3,4},
				new long[] {2,3,4},
			};
			long l_iResult = 0;
			for (long l_iBuf = 0; l_iBuf < l_aaiCombination.Length; l_iBuf++)
			{
				l_iResult += l_aiCount[l_aaiCombination[l_iBuf][0]] * l_aiCount[l_aaiCombination[l_iBuf][1]] * l_aiCount[l_aaiCombination[l_iBuf][2]];
			}
			Console.WriteLine(l_iResult);
		}
	}
}


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

#define EQ(a,b) (abs((a)-(b)) < EPS)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define all(a) (a).begin(),(a).end()

using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;

const D EPS = 1e-8;
const D PI = acos(-1);

namespace std{
  bool operator<(const P &a,const P &b){
    return EQ(real(a),real(b))?imag(a)<imag(b):real(a)<real(b);
  }
  bool operator==(const P &a, const P &b){return EQ(a,b);}
}

//for vector

inline D dot(P x, P y){return real(conj(x)*y);}

inline D cross(P x, P y){return imag(conj(x)*y);}

//rotate a point counter-clockwise on the origin
inline P rotate(P v, D s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

inline int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;   //counter clockwise
  if (cross(b,c)<-EPS) return -1; //clockwise
  if (dot(b, c)<-EPS) return 2;   //c--a--b on line
  if (abs(b)+EPS<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

inline bool is_cp(L a,L b){
  if(ccw(a.fs,a.sc,b.fs)*ccw(a.fs,a.sc,b.sc)<=0)
    if(ccw(b.fs,b.sc,a.fs)*ccw(b.fs,b.sc,a.sc)<=0)return true;
  return false;
}

inline D seg_p_dis(L a,P x){
  if(dot(a.sc-a.fs,x-a.fs)<EPS)return abs(x-a.fs);
  if(dot(a.fs-a.sc,x-a.sc)<EPS)return abs(x-a.sc);
  return abs(cross(a.sc-a.fs,x-a.fs))/abs(a.sc-a.fs);
}

inline D seg_seg_dis(L a,L b){
  D res = 1e10;
  res = min(res,seg_p_dis(a,b.fs));
  res = min(res,seg_p_dis(a,b.sc));
  res = min(res,seg_p_dis(b,a.fs));
  res = min(res,seg_p_dis(b,a.sc));
  return res;
}

int main(){
  int n,m,l;
  while(scanf("%d%d%d",&n,&m,&l), n){
    vector< vector<L> > stars(n);
    for(int i=0;i<n;i++){
      int x,y,a,r;
      scanf("%d%d%d%d",&x,&y,&a,&r);
      P c = P(x,y);

      vector<P> v;
      P p = P(0,r);
      for(int j=0;j<5;j++){
	v.push_back(c+rotate(p,PI*(a+j*72)/180));
      }
      
      vector<L> l;
      for(int j=0;j<5;j++){
	l.push_back(L(v[j],v[(j+2)%5]));
      }
      stars[i] = l;
    }

    vector< vector<D> > g(n, vector<D>(n,0));
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	D dis = 1e9;
	for(L a : stars[i]){
	  for(L b : stars[j]){
	    if(is_cp(a,b))dis = 0;
	    else dis = min(dis, seg_seg_dis(a,b));
	  }
	}
	g[i][j] = g[j][i] = dis;
      }
    }

    for(int k=0;k<n;k++){
      for(int i=0;i<n;i++){
	for(int j=0;j<n;j++){
	  g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
	}
      }
    }

    printf("%.9lf\n",g[m-1][l-1]);
  }
}	

Measured memory_bytes: 1356
#include<stdio.h>
int main(){
int A[3],K,i,max;
scanf("%d%d%d%d",&A[0],&A[1],&A[2],&K);
max=0;
if(A[max]<A[1]){max=1;}
if(A[max]<A[2]){max=2;}
for(i=0;i<K;i++){
A[max]=A[max]*2;
}
printf("%d",A[0]+A[1]+A[2]);
return 0;
}


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

using namespace std;

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

  int N, L;
  cin >> N >> L;
  vector<std::string> str_arr(N);
  for (int i = 0; i < N; i++) {
    cin >> str_arr[i];
  }

  sort(str_arr.begin(), str_arr.end());
  string ans;

  for (int i = 0; i < N; i++) {
    ans += str_arr[i];
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;
int dp[100];

int main(){
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 4;
	for (int i = 4; i <= 30; i++){
		dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
	}
	while (cin >> n&&n){
		cout << dp[n] / 3650 + 1 << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
class UnionFindTree
{
    vector<int> parent;
    vector<int> depth;
    vector<int> cnt;

public:
    UnionFindTree(int n) : parent(n), depth(n), cnt(n)
    {
        for (int i = 0; i < n; i++)
        {
            parent[i] = i;
            depth[i] = 0;
            cnt[i] = 1;
        }
    }

    //木の根を求める
    int find(int x)
    {
        if (parent[x] == x)
        {
            return x;
        }
        else
        {
            return parent[x] = find(parent[x]);
        }
    }

    //xとyの属する集合を併合
    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (depth[x] < depth[y])
        {
            parent[x] = y;
            cnt[y] += cnt[x];
        }
        else
        {
            parent[y] = x;
            cnt[x] += cnt[y];
            if (depth[x] == depth[y])
                depth[x]++;
        }
    }
    // 同じ集合に属しているか判定
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
    // 集合のサイズを取得
    int size(int x)
    {
        return cnt[find(x)];
    }
};

int main(){
    UnionFindTree utree(100100);
    int n;
    cin >> n;
    vector<int> v(n,1);
    int m,k;
    cin >> m >> k;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        v[a-1]++;
        v[b-1]++;
        utree.unite(a-1,b-1);
    }
    rep(i,k){
        int a,b;
        cin >> a >> b;
        if(utree.same(a-1,b-1)){
            v[a-1]++;
            v[b-1]++;
        }
    }
    rep(i,n){
        cout << utree.size(i)-v[i] << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2432
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  while(1){
    int d, n, m, res = 0;
    scanf("%d%d%d", &d, &n, &m);
    if(d == 0)return 0;
    int shop[n + 1];
    for(int i = 1;i < n;i++){
      scanf("%d", shop + i);
    }
    shop[n] = d;
    sort(shop, shop + n + 1);
    for(int i = 0;i < m;i++){
      int k;
      scanf("%d", &k);
      if(k == 0)continue;
      int * x = lower_bound(shop, shop + n, k);
      int * y = x - 1;
      res += min(*x - k,k - *y);
    }
    printf("%d\n", res);

  }
}

Measured memory_bytes: 1432
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n;
	int x[1001];
	cin >> n;
	for (int i = 1;i <= n;i++)cin >> x[i];
	int ans, Ma, Mi;
	ans = Ma = 0;
	Mi = 10000;
	for (int i = 1;i <= n;i++) {
		Ma = max(Ma, x[i]);
		Mi = min(Mi, x[i]);
	}
	ans = abs(Ma - Mi+1)/2;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3104
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;



int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	if (k % 2 == 0) {
		if(a - b <= 1e19)cout<<(a - b)<< endl;
		else cout << "Unfair" << endl;
	}
	else {
		if (b-a <= 1e19)cout << (b-a) << endl;
		else cout << "Unfair" << endl;
	}

	return 0;
}

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

#define int long long

char graph[310][310];
int dist[310][310];
int n;

int solve(int idx){

    int ans = -1;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            if(graph[i][j] == 1){
                if(!(dist[idx][i] == dist[idx][j]-1 || dist[idx][i] == dist[idx][j]+1)){
                    return -1;
                }
            }
        }

        ans = max(ans, dist[idx][i] + 1);
    }
    return ans;
}

signed main(){
    cin >> n;

    for(int i = 0;i < n;i++){
        cin >> graph[i];
        for(int j = 0;j < n;j++){
            graph[i][j] -= '0';
            dist[i][j] = INT_MAX;
            if(graph[i][j] == 1){
                dist[i][j] = 1;
            }
            if(i == j) dist[i][j] = 0;
        }
    }

    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            for(int k = 0;k < n;k++){
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }

    int ans = -1;

    for(int i = 0;i < n;i++){
        ans = max(ans, solve(i));
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
import collections
from sys import stdin


def main():
    N, K, Q = [int(x) for x in stdin.readline().rstrip().split()]
    A = [int(input()) for _ in range(Q)]

    a = collections.Counter(A)

    for n in range(1, N+1):
        if K-(Q-a[n]) <= 0:
            print("No")
        else:
            print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 11892
#include<iostream>
#include<string>
using namespace std;
int main(){
	string w,t;
	int a=0;
	cin>>w;
	for(;;){
		cin>>t;
		int b=t.size();
		if(t=="END_OF_TEXT"){
			cout<<a<<endl;
			return 0;
			}
			for(int i=0;i<b;i++){
				if(t[i]>='A' && t[i]<='Z'){
					t[i]=t[i]+32;
					}
				}
			if(w==t){
				a++;
				}
		}
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100010];
int main(){
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int now=0;
    for(int i=1;i<=n;i++){
        if(a[i]>now) a[i]--;
        else if(a[i]<now) return 0*puts("No");
        now=max(now,a[i]);
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    int n;

    cin >> n;

    int max_num = 0;
    int h = 0;
    int cnt = 0;
    for ( int i = 0; i < n; i++ ) {
        cin >> h;
        if ( max_num <= h ) {
            cnt++;
        }
        max_num = max(h, max_num);
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>

#define ll long long int
#define loop(a, n) for(int a = 0; a < n; ++a)
#define INF 114514//1919810
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std

#define MAX_D 1234
#define MAX_N 1234

int N, A, B;


int main()
{
	IN >> N >> A >> B;


	printf("%d\n", std::min(B, N * A));

	return 0;
}

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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000000000000000 // If you use it, make sure not to put in "int" type variable ;(, use long long int
const ll mod=2;

int main()
{
    int nT; nT=1;
    while(nT--)
    {
        ll n; cin>>n;
        ll a[n+2]; a[0]=a[n+1]=0;
        for(int i=1; i<=n; i++) cin>>a[i];
        ll gpr[n+2], gpo[n+2]; gpr[0]=0; gpo[n+1]=0;
        for(int i=1; i<=n; i++) gpr[i]=__gcd(gpr[i-1],a[i]);
        for(int i=n; i>=0; i--) gpo[i]=__gcd(gpo[i+1],a[i]);
        ll ans=1;
        for(int i=1; i<=n; i++) ans=max(ans,__gcd(gpr[i-1],gpo[i+1]));
        cout<<ans;
    }
    return 0;
}


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

#define   ipr         	pair<int, int>
#define   pb            push_back
#define   ff            first
#define   ss            second
#define   fr(i, j, k)   for (int i = j; i < k; i++)
#define   rf(i, j, k)   for (int i = j; i >= k;i--)
#define   int           long long
#define   ll 			unsigned long long
#define   ld            long double
#define   all(x)        x.begin(), x.end()
#define   rall(x)       x.rbegin(),x.rend()
#define   mp            make_pair
#define   inf           INT_MAX
#define   read_file();	freopen("input.txt", "r", stdin);	freopen("output.txt", "w", stdout);
#define   IOS           std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int Maxn  =  2019;
const ld  pi   =  acos(-1);
const int mod =  1000000007;

template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
template<class T> ostream& operator <<(ostream &out,set<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}


int32_t main(){
   int n,temp,x=0,sum=0;
cin>>n;
temp=n;
while(n!=0)
{
  n=n/10;
  x++;
}
if(x==1) cout<<temp;
else {
  for(int i=1;i<x;i+=2){
  sum=sum+9*powr(10,i-1);
  //cout << sum << endl;
  }
  if(x%2!=0) sum=sum+temp-pow(10,x-1)+1;
  cout<<sum;
}


 return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 20;
long long p[maxn], w[maxn * maxn];
unordered_map<int, int> W, W2;
int stk = 0;
long long dfs(int p, long long d){
	long long mx = 0;
	for(int i = p; i < stk; i++) mx += w[i] * 9;
	if(d < -mx || mx < d) return 0;
	if(p == stk){
		return d == 0;
	}
	long long ans = 0;
	for(int i = -9; i <= 9; i++) ans += (p == 0 ? W2 : W)[i] * dfs(p + 1, d - i * w[p]);
	return ans;
}
long long calc(int len, long long d){
	stk = 0;
	int i = 0, j = len - 1;
	while(j > i){
		w[stk++] = p[j] - p[i];
		j--;
		i++;
	}
	return dfs(0, d) * ((len&1)?10:1);
}
int main(){
	for(int i = 0; i <= 9; i++) for(int j = 0; j <= 9; j++) W[i - j]++;
	for(int i = 0; i <= 9; i++) for(int j = 1; j <= 9; j++) W2[i - j]++;
	p[0] = 1;
	for(int i = 1; i < maxn; i++) p[i] = 10ll * p[i - 1];
	int d; cin >> d;
	long long ans = 0;
	for(int i = 2; i <= 18; i++) ans += calc(i, d);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int c[3][3];
  REP(i,3)REP(j,3)cin>>c[i][j];

  for(int b1=0;b1<101;b1++){
    int a1=c[0][0]-b1;
    int a2=c[1][0]-b1;
    int a3=c[2][0]-b1;
    if(a1<0||a2<0||a3<0)continue;
    bool f=true;
    if((c[0][1]-a1==c[1][1]-a2)&&(c[1][1]-a2==c[2][1]-a3)&&(c[2][1]-a3==c[0][1]-a1)&&(c[0][2]-a1==c[1][2]-a2)&&(c[1][2]-a2==c[2][2]-a3)&&(c[2][2]-a3==c[0][2]-a1)){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[100005], b[100005];
int n;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		if (i % 2 == 1)b[1] += a[i];
		else b[1] -= a[i];
	}
	cout << b[1];
	for (int i = 2; i <= n; i++)
	{
		b[i] = 2 * a[i - 1] - b[i - 1];
		cout << " " << b[i];
	}
	return 0;
} 

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

int main(){
  double a;
  double b;
  double x;
  cin >> a;
  cin >> b;
  cin >> x;

  double h = (x)/(a*a);

  double res = 0;
  if(h > (b/2)){
    res = atan(2*(b - h)/a);
  }else{
    res = atan(b*b/(2*a*h));
  }
  res = res*180/M_PI;

  std::cout << std::fixed << std::setprecision(10) << res << std::endl;
}


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

using namespace std;

int main(){
  int a[3];
  scanf("%d %d %d", &a[0], &a[1], &a[2]);
  sort(a, a+3);
  printf("%d %d %d\n", a[0], a[1], a[2]);
  return 0;
}



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

int main(){
  int N;
  long a_min,a_max;
  a_max = 0;
  a_min = 1000;
  cin >> N;
  long a[N];
  for(int i=0;i<N;i++){
    cin >> a[i];
    a_min = min(a[i],a_min);
    a_max = max(a[i],a_max);
  }
  cout << a_max-a_min << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int k, s; scanf("%d%d", &k, &s);
	
	int ans = 0;
	for(int i = 0; i <= k; i++) {
		for(int j = 0; j <= k; j++) {
			ans += (i + j <= s and s - (i + j) <= k);
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

typedef long long ll;
ll H, W, A, B;
map<ll, pair<ll, ll>> M;
ll K = -1, L = -1;
const ll MAX_W = 1000;
pair<ll, ll> VNorm[MAX_W];
ll Row[MAX_W];

void solve() {
  for (ll k = 0; k <= H; ++k) {
    M[H * A + k * (W - 2 * A)].first = k + 1;
  }
  for (ll l = 0; l <= W; ++l) {
    M[W * B + l * (H - 2 * B)].second = l + 1;
  }
  for (auto keyval : M) {
    pair<ll, ll> val = keyval.second;
    ll k = val.first - 1, l = val.second - 1;
    if (k >= 0 && l >= 0) {
      K = k;
      L = l;
    }
  }
  if (K == -1) {
    cout << "No" << endl;
    return;
  }
  assert(0 <= K && K <= H);
  assert(0 <= L && L <= W);
  assert(H * A + K * (W - 2 * A) == W * B + L * (H - 2 * B));
  for (ll j = 0; j < W; ++j) {
    VNorm[j].first = j < L ? H - B : B;
    VNorm[j].second = j;
  }
  for (ll i = 0; i < H; ++i) {
    ll hnorm = i < K ? W - A : A;
    sort(VNorm, VNorm + W, greater<pair<ll, ll>>());
    for (ll q = 0; q < W; ++q) {
      ll &vnorm = VNorm[q].first;
      ll j = VNorm[q].second;
      if (hnorm > 0 && vnorm > 0) {
        Row[j] = 1;
        --hnorm;
        --vnorm;
      } else {
        Row[j] = 0;
      }
    }
    assert(hnorm == 0);
    for (ll j = 0; j < W; ++j) {
      cout << Row[j];
    }
    cout << endl;
  }
  for (ll j = 0; j < W; ++j) {
    assert(VNorm[j].first == 0);
  }
}
int main() {
  cin >> H >> W >> A >> B;
  solve();
  return 0;
}


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

#define vi vector<int>
#define pb push_back

typedef long long ll;


int main(){
//    ifstream in("bin.txt");
//    cin.rdbuf(in.rdbuf());
    string s;
    while(getline(cin,s),s[0]!='.'){
        bool flag = true;
        stack<char> st;
        rep(i,s.size()){
            switch(s[i]){
                case '(':
                    st.push('(');
                    break;
                case ')':
                    if(st.empty() || st.top()!='('){
                        flag = false;
                        i = s.size();
                    }else{
                        st.pop();
                    }
                    break;
                case '[':
                    st.push('[');
                    break;
                case ']':
                    if(st.empty() || st.top()!='['){
                        flag = false;
                        i = s.size();
                    }else{
                        st.pop();
                    }
                    break;
            }
        }
        if(st.empty() && flag) cout << "yes" << endl;
        else cout << "no" << endl;
    }

    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;

int main()
{
    long double a, b, c;
    cin >> a >> b >> c;
    cout << (a + b + 2 * sqrt(a) * sqrt(b) < c ? "Yes" : "No");
    // system("pause");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
#define keta fixed<<setprecision
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	int n;
	std::cin >> n;
	for (int i = 1; i < n+1; i++) {
		/* code */
		int x=i;
		if(i%3==0){std::cout <<  " "<<i;
					continue;
		}
		for (; x>=1; ) {
			/* code */
			if(x%10==3){
				std::cout <<  " "<<i;
				break;
			}
			x/=10;
		}
	}
	std::cout  << std::endl;
}


Measured memory_bytes: 3096
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

using ll = long long;
using P = pair<int, int>;

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 T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

const ll INF = 1e18;
vector<ll> a;
vector<ll> sum;
vector<vector<ll>> memo(401, vector<ll>(401, -1));

//[l, r)を1つにするときのコストの最小値
ll rec(int l, int r) {
    if (r - l == 1) return 0;
    
    if (memo[l][r] != -1) return memo[l][r];
    ll res = INF;
    repr(i, l + 1, r) chmin(res, (sum[i] - sum[l] + rec(l, i)) + (sum[r] - sum[i] + rec(i, r)));
    return memo[l][r] = res;
}

int main() {
    int n;
    cin >> n;
    a.resize(n);
    cin >> a;
    sum.resize(n + 1);
    rep(i, n) sum[i + 1] = sum[i] + a[i];
    cout << rec(0, n) << endl;
}

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

using namespace std;

const long long INF = 1e18L + 18;

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int N, G;
  cin >> N >> G;
  vector < int > w(N), v(N);
  for (int i = 0; i < N; ++i)
    cin >> w[i] >> v[i];
  int sum = 0;
  for (int x : v)
    sum += x;
  vector < long long > dp(sum + 1, INF);
  dp[0] = 0;
  for (int i = 0; i < N; ++i)
    for (int val = sum - v[i]; val >= 0; --val)
      dp[val + v[i]] = min (dp[val + v[i]], dp[val] + w[i]);
  long long ans = 0;
  for (int i = 0; i <= sum; ++i)
    if (dp[i] <= G)
      ans = max (ans, (long long)i);
  cout << ans;
}


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

int main(){
 	int a,b;
	cin >>a >> b;
  	int count = 0;
 	for(int i = a; i<=b;i++) {	
      	if(i/10000 == i%10 && (i%10000)/1000 == (i%100)/10)
  			count++;
    }
  	cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>

using namespace std;

const int MAXN=100005;
const long long MOD=1000000007;

struct Node{
	int l;
	int r;
};

int N;
vector<Node>T(MAXN);
vector<Node>A(MAXN);
vector<int>varT(MAXN);
vector<int>varA(MAXN);

int main(){	
	scanf("%d",&N);
	for(int i=1;i<=N;++i){
		scanf("%d",&varT[i]);
	}
	for(int i=1;i<=N;++i){
		scanf("%d",&varA[i]);
	}
	T[1].l=T[1].r=varT[1];
	for(int i=2;i<=N;++i){
		if(varT[i]!=varT[i-1]){
			T[i].l=T[i].r=varT[i];
		}
		else{
			T[i].l=1;
			T[i].r=varT[i];
		}
	}

	A[N].l=A[N].r=varA[N];
	int maxH=varT[0];
	for(int i=N-1;i>0;--i){
		if(varA[i]!=varA[i+1]){
			A[i].l=A[i].r=varA[i];
		}
		else{
			A[i].l=1;
			A[i].r=varA[i];
		}
	}

	bool flag=true;
	long long ans=1;
	for(int i=1;i<=N&&flag;++i){
		long long l=max(T[i].l,A[i].l);
		long long r=min(T[i].r,A[i].r);
		if(l>r){
			flag=false;
		}
		ans=ans*(r-l+1);
		ans%=MOD;
	}
	if(flag){
		cout<<ans<<endl;
	}
	else{
		cout<<0<<endl;
	}
	return 0;
}

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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int ll
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 1e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 

ll n, m, k;
vector < int > g[N];
int p[N];
int sz[N];

int get (int x) {
	if (p[x] != x) return p[x] = get(p[x]);
	return x;
}

int u[N];
set < int > all;
set < int > now;

void dfs (int v) {
	now.insert(get(v));

	u[v] = 1;
	for (auto to : g[v]) if (!u[to]) {
		dfs(to);
		u[v] += u[to];
	}
}

array<int,3> iput[N];

 main () {
	scanf("%lld%lld%lld", &n, &m, &k);

	for (int i = 1; i <= n; i ++) p[i] = i, sz[i] = 1;

	ll mx = 0;
	int mn = 0;
	bool end = (n > 9);
	for (int i = 1; i <= k; i ++) {
		int a, b, c;
		scanf("%lld%lld%lld", &a, &b, &c);
		iput[i][0] = c;
		iput[i][1] = a;
		iput[i][2] = b;
	}
	//if (end) exit(0);
	sort(iput + 1, iput + k + 1);
	int cnt = n;

	for (int i = 1; i <= k; i ++) {
		if (i > 1 && iput[i] == iput[i - 1]) continue;
		int a, b, c;
		c = iput[i][0];
		a = iput[i][1];
		b = iput[i][2];
		a ++, b ++;
		if (c) {
			if (m < n || get(a) == get(b) || cnt == 2) {
				cout << "No";
				exit(0);
			}
		} else {
			a = get(a);
			b = get(b);
			if (a == b) continue;
			cnt --;
			if (sz[a] > sz[b]) swap(a, b);

			p[a] = b;
			sz[b] += sz[a];

			mn ++;
			mx += sz[b] - 1; 
		}
	}

	if (m - n + cnt <= (cnt * (cnt - 1)) / 2ll)
		cout << "Yes";
	else
		cout << "No";

   return Accepted;
}

// B...a

Measured memory_bytes: 7296
S = input()
T = input()

len_t = len(T)
for i in reversed(range(len(S)-len_t + 1)):
    for j, s in enumerate(S[i:i+len_t]):
        if s != T[j] and s != "?":
            break
        if j == len_t - 1:
            res = S[:i] + T + S[i + len_t:]
            res = res.replace("?", "a")
            print(res)
            exit()

print("UNRESTORABLE")

Measured memory_bytes: 61888