akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

string S, T;
vector<string> words;

string solve(){
    size_t ss = S.size();
    size_t st = T.size();
    
    if(ss<st) return "UNRESTORABLE";
    
    for(int i=0; i<ss-st+1; i++){
        for(int j=i; j<i+st; j++){
            if(S[j]!='?' && S[j]!=T[j-i]) break;
            if(j==i+st-1){
                string s = S;
                for(int k=i; k<i+st; k++) s[k] = T[k-i];
                replace(s.begin(), s.end(), '?', 'a');
                words.push_back(s);
            }
        }
    }
    
    if(!words.size()) return "UNRESTORABLE";
    sort(words.begin(), words.end());
    return words[0];
}

int main() {
    cin >> S >> T;
    
    string ans = solve();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def readinput():
    n=int(input())
    x=input()
    return n,x

poptbl=[0]*(2*10**5+1)
def popcount(x):
    global poptbl
    if poptbl[x]!=0:
        return poptbl[x]
    
    poptbl[x]=bin(x).count('1')
    return poptbl[x]

ftbl=[0]*(2*10**5+1)
def f(x):
    global ftbl

    if ftbl[x]!=0:
        return ftbl[x]
    
    #print('f(x), x: {}'.format(x))
    if x==0:
        return 0
    else:
        ans=f(x%popcount(x))+1
        #print(ans)
        ftbl[x]=ans
        return ans    

def main():
    n=int(input())
    x=input()
    m=x.count('1')
    #print('m: {}'.format(m))
    xint=int(x,2)
    #print('xint: {}'.format(xint))
    if m!=1:
        xmodm1=xint%(m-1)
    else:
        xmodm1=1
    xmodp1=xint%(m+1)
    pow2mod1=[0]*n
    pow2mod2=[0]*n
    pow2mod1[0]=1
    pow2mod2[0]=1
    for i in range(1,n):
        if m!=1:
            pow2mod1[i]=pow2mod1[i-1]*2 % (m-1)
        pow2mod2[i]=pow2mod2[i-1]*2 % (m+1)

    ans=[]
    #b=2**(n-1)
    for i in range(n):
        if x[i]=='1':
            if m==1:
                a=0
                ans.append(a)
            else:
                xx=( xmodm1 + (m-1) -pow2mod1[n-i-1] )%(m-1)
                #ans.append(f(xx)+1)
                a=f(xx)+1
                ans.append(a)
        else:
            xx=( xmodp1 + pow2mod2[n-i-1] )%(m+1)
            #ans.append(f(xx)+1)
            a=f(xx)+1
            ans.append(a)
        #b=b//2
        print(a)
    return ans

if __name__=='__main__':
    #n,x=readinput()
    ans=main()
    #for a in ans:
    #    print(a)



Measured memory_bytes: 96460
import math
a=list(map(int,input().split()))
total=0
K=a[1]
if a[0]>=a[1]:
    tmp=a[1]
    total+=a[0]-a[1]+1
else:
    tmp=a[0]+1
    
for i in range(1,tmp):
    hoge=K/i
    total+=1/pow(2,math.ceil(math.log(hoge,2)))
print(total/a[0])

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

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

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  string S;
  cin>>S;
  int ans = 0;
  for(auto x:S){
    if(x=='+') ans++;
    else ans--;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.nextLine().toCharArray();
        char[] t = sc.nextLine().toCharArray();

        Arrays.sort(s);
        String ss = new String(s);

        Arrays.sort(t);
        String tt = new String(t);
        String td = new StringBuilder(tt).reverse().toString();

        String ans;

        if (ss.compareTo(td) < 0) {
            ans = "Yes";
        } else {
            ans = "No";
        }


        System.out.println(ans);
    }

    public static int solve(int[] A) {
        int ans = 0;
        boolean tf = true;

        for (int a: A) {
            if (a % 2 != 0) {
                tf = false;
            }
        }

        while (tf) {
            for (int i = 0; i < A.length; i++) {
                A[i] = A[i] / 2;
            }
            ans++;

            for (int a: A) {
                if (a % 2 != 0) {
                    tf = false;
                }
            }
        }

        return ans;
    }



}


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

scores = list(int(input()) for i in range(n))

temp = 101

if sum(scores) % 10 != 0:
    print(sum(scores))

if sum(scores) % 10 == 0:
    for i in scores:
        if i < temp and i % 10 != 0:
            temp = i
            
        
    if temp == 101:
            print(0)
        
    else:
        print(sum(scores)-temp)

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	if N%2 != 0 {
		fmt.Fprintln(wtr, 0)
		wtr.Flush()
		return
	}
	N /= 2
	ans := 0
	for N != 0 {
		ans += N / 5
		N /= 5
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


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

int main()
{
  string str;
  int i;
  while(true){
    getline(cin, str);
    if(str[0] == '.') break;
    
    int len = 0;
    while(str[len] != '\0'){
      len++;
    }
        
    int d[101] = {0}, j;
    for(i = 0, j = 0 ; i < len ; i++){
      if(str[i] == '('){
	d[++j] = 1;
      }
      if(str[i] == '['){
	d[++j] = 2;
      }
      if(str[i] == ')'){
	if(d[j--]-1){
	  break;
	}
      }
      if(str[i] == ']'){
	if(d[j--]-2){
	  break;
	}
      }
    }
    if(str[i] || j){
      cout << "no" << '\n';
    }else{
      cout << "yes" << '\n';
    }
  }
}

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

int N, M;
vector<vector<int> > G;

vector<bool> seen;
bool rec(int v, int p, int s, int t) {
    if (v == s && p != -1) return true; // 一周回ってきて s に戻って来たら OK
    if (v != s) seen[v] = true;
    for (auto nv :  G[v]) {
        if (nv == p || nv == t || seen[nv]) continue;
        if (rec(nv, v, s, t)) return true;
    }
    return false;
}
        
bool solve() {
    cin >> N >> M;
    G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    map<int,int> degs;
    for (int v = 0; v < N; ++v) degs[(int)G[v].size()]++;

    for (auto it : degs) if (it.first % 2 != 0) return false;
    if (degs[6] > 0) return true;
    if (degs[4] > 2) return true;
    if (degs[4] <= 1) return false;

    vector<int> four;
    for (int v = 0; v < N; ++v) if (G[v].size() == 4) four.push_back(v);
    int s = four[0], t = four[1];
    seen.assign(N, 0);
    return rec(s, -1, s, t);
}

int main() {
    if (solve()) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 7680
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int get(int A, int B, int K) {
  if (A == B) {
    return K % 2;
  }
  if (A < B) {
    return 1 - get(B, A, (A + B) - K - 1);
  }

  int ca = (A + B) / (B + 1);
  Int k1max = A / ca;

  Int lo = 0, hi = k1max + 1;
  while (hi - lo > 1) {
    Int mid = (hi + lo) / 2;
    Int ra = A - mid * ca;
    Int rb = B - mid;
    Int k2 = rb / ca;
    if (ra < k2) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  Int ra = A - lo * ca;
  Int rb = B - lo;
  Int k2 = rb / ca;
  ra -= k2;
  rb -= k2 * ca;

  if (K < (ca + 1) * lo) {
    return K % (ca + 1) == ca ? 1 : 0;
  }
  K -= (ca + 1) * lo;

  if (K < ra) return 0; K -= ra;
  if (K < rb) return 1; K -= rb;

  return K % (ca + 1) == 0 ? 0 : 1;
}


int main() {
  int Q = in();
  for (int i = 0; i < Q; ++i) {
    int A = in();
    int B = in();
    int C = in() - 1;
    int D = in();
    for (int j = C; j < D; ++j) {
      putchar("AB"[get(A, B, j)]);
    }
    puts("");
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdlib.h>
using namespace std;

#define INF 1e9
#define PI 3.141592653589793238
#define N 1000000010
#define mod 1000000007
#define REP(inc, bgn, end) for(int inc=bgn; inc<end; inc++)
typedef long long ll;

int main() {
    string s,t;cin>>s>>t;
    cout<<t<<s<<endl;

    return 0;
}

Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {

	static int[] a;
	static int n;
	
	static void riffle(){
		int[] b = new int[2*n];
		for(int i=0;i<2*n;i++){
			b[i]=a[i];
		}
		int k=0;
		for(int i=0;i<2*n;i+=2){
			a[i]=b[k];
			a[i+1]=b[n+k];
			k++;
		}
	}
	
	static void cut(int j){
		int[] b = new int[2*n];
		for(int i=0;i<2*n;i++){
			b[i]=a[i];
		}
		int k=0;
		int i;
		for(i=2*n-1;k<j;i--){
			a[i]=b[j-1-k];
			k++;
		}
		k=2*n-1;
		for(;i>=0;i--){
			a[i]=b[k--];
		}
	}
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		n = stdIn.nextInt();
		a = new int[2*n];
		for(int i=0;i<2*n;i++){
			a[i]=i+1;
		}
		int m = stdIn.nextInt();
		for(int i=0;i<m;i++){
			int k = stdIn.nextInt();
			if(k==0){
				riffle();
			}
			else{
				cut(k);
			}
		}
		for(int i=0;i<2*n;i++){
			System.out.println(a[i]);
		}
	}
}

Measured memory_bytes: 0
let split str =
  let rec split_inner ct b=
    if String.length str = ct then [(int_of_string b)]
    else
      match str.[ct] with
        ' ' -> (int_of_string b)::split_inner (ct+1) ""
      | c -> split_inner (ct+1) (b^(Char.escaped c))
  in split_inner 0 "";;

let () =
  let (n,k) = match split (read_line ()) with
        [n;k] -> (n,k)
      | _ -> raise Not_found
  in
  let ws = Array.init n (fun _ -> read_int ()) and
       l = 0 and
       r = 100000*100000
  in
  let rec search ((i,j,s,p):int*int*int*int) =
    if i=n || j=k then i
    else
      if s+ws.(i) <= p then
        search ((i+1), j, (s+ws.(i)), p)
      else
        search (i,(j+1),0,p)
  in
  let rec loop (left:int) (right:int) =
    if left < right then
      let mid = (left+right)/2 in
      if search (0,0,0,mid) >= n then loop left mid
      else loop (mid+1) right
    else right
  in
  Printf.printf "%d\n" (loop l r)
;;

Measured memory_bytes: 5644
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    int N = 0;
    cin >> N;
    ll p[N];
    ll a[N];
    ll b[N];
    for (int i = 0; i < N; ++i) {
        cin >> p[i];
        a[i] = (i + 1) * (N + 1);
        b[i] = (N - i) * (N + 1);
    }
    for (int i = 0; i < N; ++i) {
        b[p[i] - 1] += i;
    }
    for (int i = 0; i < N; ++i) {
        cout << a[i] << " ";
    }
    cout << endl;
    for (int i = 0; i < N; ++i) {
        cout << b[i] << " ";
    }
    cout << endl;

}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                                   \
  ifstream in("atcoder-problems/diverta2019_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int r = 0;
  ll ans = 0;
  while (R * r <= N) {
    int g = 0;
    while (R * r + G * g <= N) {
      int rest = N - (R * r + G * g);
      int b = rest / B;
      if (rest == 0 || (b != 0 && rest - (B * b) == 0)) {
        // printf("%d %d %d\n", r, g, b);
        ans++;
      }
      g++;
    }
    r++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int INF = 2147483647;
template <typename T>
struct segment_tree{
  int N;
  vector<T> ST;
  function<T(T, T)> f;
  T E;
  segment_tree(int n, function<T(T, T)> F, T e){
    N = 1;
    while (N < n){
      N *= 2;
    }
    ST = vector<T>(N * 2 - 1, e);
    f = F;
    E = e;
  }
  segment_tree(vector<T> A, function<T(T, T)> F, T e){
    int n = A.size();
    N = 1;
    while (N < n){
      N *= 2;
    }
    ST = vector<T>(N * 2 - 1, e);
    for (int i = 0; i < n; i++){
      ST[N - 1 + i] = A[i];
    }
    for (int i = N - 2; i >= 0; i--){
      ST[i] = F(ST[i * 2 + 1], ST[i * 2 + 2]);
    }
    f = F;
    E = e;
  }
  T operator [](int k){
    return ST[N - 1 + k];
  }
  void update(int k, T x){
    k += N - 1;
    ST[k] = x;
    while (k > 0){
      k = (k - 1) / 2;
      ST[k] = f(ST[k * 2 + 1], ST[k * 2 + 2]);
    }
  }
  T val(int L, int R, int i, int l, int r){
    if (R <= l || r <= L){
      return E;
    } else if (L <= l && r <= R){
      return ST[i];
    } else {
      int m = (l + r) / 2;
      return f(val(L, R, i * 2 + 1, l, m), val(L, R, i * 2 + 2, m, r));
    }
  }
  T query(int L, int R){
    return val(L, R, 0, 0, N);
  }
};
int f(int a, int b){
  return min(a, b);
}
int main(){
  int n, q;
  cin >> n >> q;
  segment_tree<int> A(n, f, INF);
  for (int i = 0; i < q; i++){
    int t;
    cin >> t;
    if (t == 0){
      int x, y;
      cin >> x >> y;
      A.update(x, y);
    }
    if (t == 1){
      int x, y;
      cin >> x >> y;
      cout << A.query(x, y + 1) << endl;
    }
  }
}


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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main() {
	ll X, Y, Z;
	cin >> X >> Y >> Z;
	cout << Z << " " << X << " " <<  Y << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 100

void push(int);
int pop(void);

int c[MAX],top;

int main(){
	int x,x1,x2;
	char s[MAX];

	while(scanf("%s",s) != EOF){
		if(s[0] == '+'){
			x1 = pop();
			x2 = pop();
			x = x2 + x1;
			push(x);
		}
		else if(s[0] == '-'){
			x1 = pop();
			x2 = pop();
			x = x2 - x1;
			push(x);
		}
		else if(s[0] == '*'){
			x1 = pop();
			x2 = pop();
			x = x2 * x1;
			push(x);
		}
		else{
			x = atoi(s);
			push(x);
		}
	}
	printf("%d\n",c[top]);

	return 0;
}

void push(int x){
	top++;
	c[top] = x;
}

int pop(void){
	top--;
	return c[top+1];
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  double ans = 0;
  for (int i = 0; i < N; i++) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY") {
      ans += x;
    }
    else {
      ans += x * 380000.0;
    }
  }
  cout << fixed << setprecision(16);
  cout << ans << endl;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}

struct unionfind{
    vector<int> par;
    vector<int> high;
    vector<int> size;
    int num;
    unionfind(int n):num(n), par(n,-1), high(n,1), size(n,1){}
    int find(const int x){
        if(par[x]==-1)return x;
        return par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y)return;
        if(high[x]>high[y])swap(x,y);
        if(high[x]==high[y])high[y]++;
        par[x]=y;
        size[y]+=size[x];
        num--;
        return;
    }
    int getsize(const int i){
        return size[find(i)];
    }
    void get(const int m){
        rep(i,m){
            int a,b;cin >> a >> b;
            unite(a-1,b-1);
        }
        return;
    }
};

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n,q;cin >> n >> q;
    unionfind uf(n);
    rep(i,q){
        int t,u,v;cin >> t >> u >> v;
        if(t==0)uf.unite(u,v);
        else cout << (uf.find(u)==uf.find(v)) << endl;
    }
}

Measured memory_bytes: 5420
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int sum = 0;
		int max = 0;

		for (int i = 0; i < n; i++) {
			int p = sc.nextInt();

			if (max < p) {
				max = p;
			}
			sum += p;
		}

		System.out.println(sum - max / 2);

		sc.close();
	}

}


Measured memory_bytes: 20948
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            for (var i = 0; i < S.Length; i++)
            {
                if (S[i] + N > 90)
                    Console.Write((char)(S[i] + N - 26));
                else
                    Console.Write((char)(S[i] + N));
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int n, ma, mb;
int a[50], b[50], c[50], dp[50][500][500];
const int inf = 10000;
int main() {
	cin >> n >> ma >> mb;
	for (int i = 0; i < n; i++)cin >> a[i] >> b[i] >> c[i];
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= 480; j++) {
			for (int k = 0; k <= 480; k++) {
				dp[i][j][k] = inf;
			}
		}
	}
	dp[0][0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= 480; j++) {
			for (int k = 0; k <= 480; k++) {
				if (dp[i][j][k] != inf) {
					dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
					dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
				}
			}
		}
	}
	int ans = inf;
	for (int i = 1; i*max(ma, mb) < 480; i++) {
		ans = min(ans, dp[n][ma*i][mb*i]);
	}
	if (ans == inf)cout << -1 << endl;
	else cout << ans << endl;
}

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

int const N = 1 << 18, md = 1e9 + 7;
int p[N], fr[N], H, L, an;

void ad(int &x, int y) { if ((x += y) >= md)x -= md; }

vector<pair<int, int> > go(int v = 1, int h = 1){
	if (h == H)return vector<pair<int, int> > { { v, v } };
	auto a = go(v << 1, h + 1), b = go(v << 1 | 1, h + 1);
	
	f(i, 0, a.size()){
		int u = p[a[i].first - L + 1] + L - 1, c = a[i].second;
		while (u > 1){
			c = (ll)c * u % md;
			ad(fr[u], c);
			u >>= 1;
		}
	}
	
	f(i, 0, b.size()){
		int u = p[b[i].first - L + 1] + L - 1, c = b[i].second;
		while (u > 1){
			c = (ll)c * u % md;
			ad(an, (ll)fr[u ^ 1] * c % md * (u >> 1) % md * v % md);
			u >>= 1;
		}
	}
	
	f(i, 0, a.size()){
		int u = p[a[i].first - L + 1] + L - 1;
		while (u > 1){
			fr[u] = 0;
			u >>= 1;
		}
	}
	a.insert(a.end(), b.begin(), b.end());
	b.clear();
	for (auto &t: a)t.second = (ll)t.second * v % md;
	return a;
}

int main(){
	scanf("%d", &H);
	L = 1 << H - 1;
	f(i, 1, L + 1)scanf("%d", p + i);
	go();
	printf("%d\n", an);
}

Measured memory_bytes: 6904
#include<bits/stdc++.h>
using namespace std;
#define LOL ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<ll ,ll>
const int sz=1e4+100;
ll dp[sz][12];
string sol[sz][12];
ll n;
pii ara[12];
ll tk[]={0,2,5,5,4,5,6,3,7,6};
bool cmp(pii a,pii b)
{
    return a.s>b.s;
}
//string Max(string a, string b) {
//	if(a.size() == b.size()) {
//		return (a > b) ? a : b;
//	}
//	return (a.size() > b.size()) ? a : b;
//}
ll cholo(ll in,ll w)
{
       if(in>=n){
        if(w==0)  return 1ll;
        else return 0ll;
       }
       if(w==0)  return 1ll;
       ll p=0ll,q=0ll;
       string str1="",str2="";
       ll &ret=dp[w][in];
       if(~ret) return ret;
       if(w-ara[in].f>=0) p=cholo(in,w-ara[in].f);
       q=cholo(in+1,w);
       if(p==1) str1=string(1,'0'+ara[in].s)+sol[w-ara[in].f][in];
       if(q==1) str2=sol[w][in+1];
       if(str1.size() != str2.size())  sol[w][in]=(str1.size()>str2.size()) ? str1: str2;
       else  sol[w][in]=(str1[0]>str2[0]) ? str1 :str2;
       if(p==1 || q==1) ret=1ll;
       else ret=0ll;
       return ret;
}
int main()
{
    LOL
    ll a,b,c,i,j,k,q,p,x,y,sum,ct,ct1,m,l,r,x1,y1,mn,ans,h,sum1,in,z,mid,tot;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    cin>>tot>>n;
    memset(dp,-1ll,sizeof dp);
    for(i=0;i<n;i++){
        cin>>x;
        ara[i]=mk(tk[x],x);
    }
    sort(ara,ara+n,cmp);

    for(i=0;i<sz;i++)  for(j=0;j<12;j++) sol[i][j]="";
    ll last=cholo(0,tot);
    cout<<sol[tot][0]<<endl;

}


Measured memory_bytes: 75392
s1,s2,s3=input().split()
abc=list('abcdefghijklmnopqrstuvwxyz')
ABC='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
print(str(ABC[abc.index(s1[0])]+ABC[abc.index(s2[0])]+ABC[abc.index(s3[0])]))


Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>

int isPrime(int x)
{
	if(x==2) return 1;
	
	if(x<2||x%2==0) return 0;
	
	for(int i=3;i*i<=x;i+=2){
		if(x%i==0)
		return 0;
	}
	return 1;
		
}

int main()
{
	int n, i, x, counter;
	counter=0;
	scanf("%d", &n);
	
	for(i=0;i<n;i++){
		scanf("%d", &x);
		
		if(isPrime(x)==1)counter++;
	}
	
	printf("%d\n", counter);
    
    return 0;
}


Measured memory_bytes: 2056
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

H, W = nl()

min_diff = H * W
for h1 in range(1, H):
    sa = h1*W

    h2 = (H-h1) // 2
    sb = h2*W
    sc = (H - h1 - h2)*W

    diff = max(sa, sb, sc) - min(sa, sb, sc)
    min_diff = min(diff, min_diff)

    w2 = W // 2
    sb = (H - h1)*w2
    sc = (H - h1)*(W - w2)
    diff = max(sa, sb, sc) - min(sa, sb, sc)
    min_diff = min(diff, min_diff)

for w1 in range(1, W):
    sa = H*w1

    w2 = (W-w1) // 2
    sb = H*w2
    sc = H*(W - w1 - w2)

    diff = max(sa, sb, sc) - min(sa, sb, sc)
    min_diff = min(diff, min_diff)

    h2 = H // 2
    sb = (W - w1)*h2
    sc = (W - w1)*(H - h2)
    diff = max(sa, sb, sc) - min(sa, sb, sc)
    min_diff = min(diff, min_diff)

print(min_diff)


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

using namespace std;
typedef long long ll;

int main(int, char**)
{
	int n, a, b, c, ans = 0;
	cin >> a >> b >> c;

	n = (b/a > c) ? c : (b/a);
	cout <<  n << endl;
	return 0;
}


Measured memory_bytes: 256
import math
A, B = map(int, input().split())
ans = -1

flg = True

if math.ceil(12.5*A) >= B*10:
    N = B*10
    while int(N*0.08) < A:
        N += 1
        if int(N*0.1) > B:
            flg = False
            break
    if flg: ans = N

else:
    N = math.ceil(12.5*A)
    while int(N*0.1) < B:
        N += 1
        if int(N*0.08) > A:
            flg = False
            break
    if flg: ans = N

print(ans)




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	ll n;
	rl(n);
	string a,b,ans="";
	cin>>a>>b;
	ll i=0;
	while(i<n)
	{
		ans+=a[i];
		ans+=b[i];
		i++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int h,m,s,h1,m1,s1,total,total1;
    for(int n=0;n<3;n++){
        cin >> h >> m >> s;
        cin >> h1 >> m1 >> s1;
        total = h * 3600;
        total += m * 60;
        total += s;
        
        total1 = h1 * 3600;
        total1 += m1 * 60;
        total1 += s1;
        
        total = total1 - total;
        h=0;
        m=0;
        s=0;
        if(total >= 3600){
            h = total / 3600;
            total = total % 3600;
        }
        if(total >= 60){
            m = total / 60;
            total = total % 60;
        }
        s = total;
        cout << h << " " << m << " " << s << endl;
    }
}

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

int main(void) {
    int times[26] = {0};
    string w;
    cin >> w;
    for (int i = 0; i < w.length(); ++i) {
        times[w[i] - 'a']++;
    }
    bool result = true;
    for (int i = 0; i < 26; ++i) {
        if (times[i] % 2 == 1) {
            result = false;
        }
    }
    if (result == true) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
  int N,M,X,Y;
  cin >> N >> M >> X >> Y;

  int x_max = -100;
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    if(x_max < x){
      x_max = x;
    }
  }
  if(x_max < X){
    x_max = X;
  }

  int y_min = 100;
  for(int i=0;i<M;i++){
    int y;
    cin >> y;
    if(y < y_min){
      y_min = y;
    }
  }
  if(Y < y_min){
    y_min = Y;
  }

  if(x_max < y_min){
    cout << "No War" << "\n";
  }else{
    cout << "War" << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 2e5+10;

int L;
ll dp[MAX][5];
ll A[MAX];

int main() {
    cin >> L;
    REP (i, L) cin >> A[i];

    REP (i, L) {
        dp[i+1][0] = dp[i][0] + A[i];
        dp[i+1][1] = min(dp[i+1][0], (A[i]==0)*2+(A[i]&1) + min(dp[i][0], dp[i][1]));
        dp[i+1][2] = min(dp[i+1][1], (1-(A[i]&1)) + min(dp[i][1], dp[i][2]));
        dp[i+1][3] = min(dp[i+1][2], (A[i]==0)*2+(A[i]&1) + min(dp[i][2], dp[i][3]));
        dp[i+1][4] = min(dp[i+1][3], A[i] + min(dp[i][3], dp[i][4]));
    }

    cout << dp[L][4] << endl;
}


Measured memory_bytes: 9600
#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>
int main()
{
	int n;
	cin>>n;
	vector<int>res;
	int num;
	for(int i=0;i<n;i++)
	{
		cin>>num;
		res.push_back(num);
	}
	sort(res.begin(),res.end());
	cout<<res[n-1]-res[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *    author:  yoseph
 *    created: 18.07.2020 22:31:47      
**/
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> v(n,0);
	for (int i = 0; i < n; ++i)
		cin >> v[i];
	int ans = accumulate(v.begin(),v.end(),0) - *max_element(v.begin(),v.end())/2;
	cout << ans << "\n";
	return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<ll>());

    ll ans = A[0];
    map<ll, ll> mp;
    mp[A[1]] = 2;
    for (ll i = 2; i < N; i++) {
        auto itr = mp.rbegin();
        auto [kn, val] = *itr;
        ans += kn;
        --val;
        if (val == 0) {
            mp.erase(kn);
        }
        else {
            mp[kn] = val;
        }
        mp[A[i]] += 2;
    }

    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 11128
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define tam 2302000
#define offset 8010
using namespace std;
typedef long long  ll;
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
typedef pair<map<ll,ll> ,ll> mi;
typedef pair<ii,ii> iiii;
typedef vector<ll> vi;
const ll MOD=1e9+7;
ll val[tam];
int  main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n,x;
    cin>>n>>x;
    forr(i,0,n)
    {
        cin>>val[i];
    }
    ll resta,tot=0,resta2;
    forr(i,0,n-1)
    {
            resta=max(0LL,val[i]+val[i+1]-x);
            tot+=resta;
            resta2=max(0LL,val[i+1]-resta);
            val[i+1]=resta2;
    }
    cout<<tot<<endl;
}

Measured memory_bytes: 1024
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int a;
    ld b;
    cin >> a >> b;
    ld ans = a * b;
    cout << (ll)floor(ans) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3748
#include <stdio.h>

int main(void)
{
	int i;
	char name[9][20];
	int x, y;
	int a_sum[9];
	int m_sum[9];
	
	for (i = 0; i < 9; i++){
		scanf("%s %d %d", name[i], &x, &y);
		a_sum[i] = x + y;
		m_sum[i] = x * 200 + y * 300;
	}
	
	for (i = 0; i < 9; i++){
		printf("%s %d %d\n", name[i], a_sum[i], m_sum[i]);
	}
	
	
	return (0);
}

Measured memory_bytes: 596
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define lld long long int

int cmpAscStrings(const void* a, const void* b){
    return strcmp(*(char**)a, *(char**)b);
}

void initStrArray(char** p, int n, int len){
    for(int i=0; i<n; i++){
        *(p + i) = (char*)malloc(sizeof(char) * (len + 1));
    }
}

int main(){
    char s[5001];
    int k, len;
    scanf("%s", s);
    scanf("%d", &k);
    len = strlen(s);
    char* w[30000];
    initStrArray(w, 30000, 11);
    int x=0;
    rep(i, 0, len){
        char buf[10];
        rep(j, 0, 6){
            buf[j] = s[i+j];
            buf[j+1]  = '\0';
            strcpy(w[x], buf);
            x++;
            if(s[i+j] == '\0'){
                break;
            }
        }
    }
    qsort(w, x, sizeof(char*), cmpAscStrings);
    int q=1, id=0;
    while(q<k){
        id++;
        if(strcmp(w[id-1], w[id]) != 0){
            q++;
        }
    }
    printf("%s", w[id]);

    return 0;
}

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

int main() {

int a,b,c,d;
cin >> a >>b >>c >>d;

int s1 = a*b, s2 = c*d;
if (s1 > s2 ) cout << s1 << endl;
else cout << s2 << endl;

return 0;
}

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

const int N = (12) + 1;
const int M = (1e3) + 3;
const ll OO = 1e8 + 1;
int memo[M][1 << N];
int a[M], b[M];
int c[M];
int n, m;

int dp(int m, int mask) {
  if (__builtin_popcountll(mask) == n) return 0;
  if (m == 0) return OO;
  int& ret = memo[m][mask];
  if (ret != -1) return ret;
  ret = min(a[m - 1] + dp(m - 1, mask | c[m - 1]), dp(m - 1, mask));
  return ret;
}

int main() { // claudio van
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> a[i] >> b[i];
    for (int j = 0; j < b[i]; ++j) {
      int x; cin >> x;
      c[i] |= (1 << x);
    }
  }
  memset(memo, -1, sizeof memo);
  int mn = dp(m, 0);
  if (mn >= OO) {
    mn = -1;
  }
  cout << mn << endl;
  return 0;
}

Measured memory_bytes: 32384
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int charPlus(char a[],int num){
	int length,i;
	length=strlen(a);
	for(i=0;i<length;i++){
		if(islower(a[i])){
			if(a[i]+num>'z'){
				num-=26;
			}else if(a[i]+num<'a'){
				num+=26;
			}
			a[i]+=num;
		}
	}
	
	return 0;
}

int mystrstr(char a[],char b[],int length){
	int i,sum=0,difference;
	char temp[81];
	difference=b[0]-a[0];
	strcpy(temp,a);
/*	printf("1:%s(<-%s)%d\n",temp,a,difference);
*/	charPlus(temp,difference);
/*	printf("2:%d %d %d %d(<-%d %d %d %d)\n",temp[0],temp[1],temp[2],temp[3],a[0],a[1],a[2],a[3]);
	printf("2:(%s==%s)=%d\n",temp,b,strcmp(temp,b));
*/	if(strcmp(temp,b)==0){
		return difference;
	}else{
		return 100;
	}
}

int scan(char code[],int *flag){
	char last,temp[81];
	int inputedCnt=0,tempLength;
	int difference=100,status;
	
	while(1){
		if(scanf("%80s",temp)==EOF){
			return 100;
		}
		status=scanf("%c",&last);
		tempLength=strlen(temp);
		strcpy(&code[inputedCnt],temp);
	/*		printf("t:%s\n",temp);
			printf("tl:%d:%d\n",tempLength,inputedCnt);
			printf("c:%s\n",code);
			printf("\tlast:%d\n",last);
	*/	inputedCnt+=tempLength;
	/*	printf("ww:%d==%d\n",code[inputedCnt],'\0');
	*/	if(inputedCnt>80){
			return 100;
		}
		
		if(difference==100){
			if(tempLength==3){
				difference=mystrstr(temp,"the",3);
					
			}else if(tempLength==4){
				difference=mystrstr(temp,"this",4);
				if(difference==100)difference=mystrstr(temp,"that",4);
			}
		}
		if(last=='\n' || status==EOF){
			*flag=(status==EOF);
			return difference;
		}else{
			code[inputedCnt]=' ';
			inputedCnt++;
		}
/*		printf("\t%d\n",difference);
*/	}
	
	return 0;
}

int main(){
	char code[81];
	int difference,eofFlag=0;
	
	while(eofFlag==0){
		difference=scan(code,&eofFlag);
		if(difference==100){
			break;
		}
		charPlus(code,difference);
		printf("%s\n",code);
	}
/*	printf("%d//%d\n",eofFlag,difference);
*/	return 0;
}

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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  string S;
  cin >> S;
  bool flag = false, ans = false;
  for(int i = 0; i < S.size(); i++){
    if(S[i] == 'C')flag = true;
    if(flag && S[i] == 'F')ans = true;
  }
  if(ans)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
A, B = map(int, input().split())
cnt = 0
for num in range(A, B + 1):
    flg = True
    for i in range(len(str(num)) // 2):
        if str(num)[i] != str(num)[-(i + 1)]:
            flg = False
            break

    if flg:
        cnt += 1

print(cnt)


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

int main() {
	string str;
	long long K;
	cin >> str >> K;
	for (int i = 0; i < str.length(); i++) {
		int c = 26-(str[i]-'a');
		if (K-c >= 0 && str[i] > 'a') {
			K  = K - c;
			str[i] = 'a';
		}
	}
	if (K != 0) {
		K %= 26;
		int l = str.length()-1;
		str[l] = (str[l]-'a'+K)%26 + 'a';
	}
	cout << str << endl;
	return 0;
}



Measured memory_bytes: 640
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int X = int.Parse(str[1]);
		int[] M = new int[N];
		int min = 999999;
		int sum = 0;
		int count = 0;
		for(var i=0;i<N;i++){
			string str2 = Console.ReadLine();
			M[i] = int.Parse(str2);
			min = Math.Min(min,M[i]);
			sum += M[i];
			count += 1;
		}
		count += (X-sum)/min;
		Console.WriteLine(count);
	}
}

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

int n, m;
int dp[100005];
vector<int> g[100005];

void dfs(int pos) {
	if(dp[pos]) return;
	for(auto i:g[pos]) {
		dfs(i);
		dp[pos] = max(dp[pos], dp[i] + 1);
	}
}

int main() {
	memset(dp, 0, sizeof(dp));
	scanf("%d %d", &n, &m);
	int u, v;
	for(int i = 1;i <= m; i++) {
		scanf("%d %d", &u, &v);
		g[u].push_back(v);
	}
	
	for(int i = 1;i <= n; i++) {
		dfs(i);
	} 
//	for(int i = 1;i <= n; i++) printf("dp[%d] = %d\n", i, dp[i]);
	
	int ans = 0;
	for(int i = 1;i <= n; i++) {
		ans = max(ans, dp[i]);
	}
	
	printf("%d\n", ans);
}

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

#define M 1046527
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch)
{
    if (ch == 'A')
        return 1;
    else if (ch == 'C')
        return 2;
    else if (ch == 'G')
        return 3;
    else if (ch == 'T')
        return 4;
}

/* convert a string into an integer value */
long long getKey(char str[])
{
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++)
    {
        sum += p * (getChar(str[i]));
        p *= 5;
    }
    return sum;
}

// オープンアドレス法
int h1(int key) { return key%M; }
int h2(int key) { return 1+(key%(M-1)); }
int h(int key, int i){
    return (h1(key) + i*h2(key))%M;
}

int find(char str[])
{
    long long i,j;
    i = 0;
    while (true)
    {
        j = h(getKey(str), i);
        if(strcmp(H[j], str) == 0) return j;
        else if (strlen(H[j]) == 0 || i >= M) return 0;
        else
        {
            i++;
        }
        
        
    }
    
}

int insert(char str[])
{
    long long i,j;
    i = 0;
    while(true){
        // 文字列を数値へ
        j = h(getKey(str),i);
        if(strlen(H[j]) == 0){
            strcpy(H[j], str);
            return j;
        }
        else
        {
            i++;
        }        
    }

    return 0;
}

int main()
{
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++)
        H[i][0] = '\0';

    scanf("%d", &n);

    for (i = 0; i < n; i++)
    {
        scanf("%s %s", com, str);

        if (com[0] == 'i')
        {
            //cout << "Insert: " << insert(str) << endl;
            insert(str);
        }
        else
        {
            if (find(str))
            {
                printf("yes\n");
            }
            else
            {
                printf("no\n");
            }
        }
    }

    return 0;
}


Measured memory_bytes: 17476
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
int main()
{
    int a, b;
    char op;
    vector<int> ans;
    while (1)
    {
        cin >> a >> op >> b;
        if(op=='+')
        {
            ans.push_back(a + b);
        }
        else if(op=='-'){
            ans.push_back(a - b);
        }
        else if(op=='*'){
            ans.push_back(a * b);
        }
        else if(op=='/'){
            ans.push_back(a / b);
        }
        else if(op=='?'){
            break;
        }
    }
    for (int i = 0; i < ans.size(); i++)
    {
        cout << ans[i] << endl;
    }
  //  system("pause");
    return 0;
}


Measured memory_bytes: 3144
N, *A = [int(_) for _ in open(0).read().split()]
sumB = max(0, sum(A) - N * (N - 1))
while True:
    B = [0 - (-(a + sumB + 1 - N)) // (N + 1) for a in A]
    if sumB == sum(B):
        break
    sumB += 1
print(sumB)


Measured memory_bytes: 9088
from itertools import permutations
from math import factorial

n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]

ave = 0
jun = permutations(range(n))
for j in jun:
    #print(j)
    sm = 0
    for i in range(n-1):
        x, y = xy[j[i]]
        nx, ny = xy[j[i+1]]
        #print(x, y, nx, ny)
        sm += ((x-nx)**2 + (y-ny)**2)**0.5
    ave += sm
print(ave/factorial(n))

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
const int N=10005;
const int mod=1e9+7;
const int maxn=1e7;
int main()
{
    int a,b,c,d;
    while(cin>>a>>b>>c>>d){
        if(c>b||a>d) cout<<0<<endl;
        else if(a<=c&&d<=b){
            cout<<d-c<<endl;
        }
        else if(c<=a&&b<=d){
            cout<<b-a<<endl;
        }
        else if(a<=c&&c<=b&&b<=d){
            cout<<b-c<<endl;
        }
        else if(c<=a&&a<=d&&d<=b){
            cout<<d-a<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<stack>
#include<queue>
using namespace std;

int max(int x, int y);
int min(int x, int y);
int gcd(int x, int y);	/*最大公約数*/
int lcm(int x, int y);	/*最小公倍数*/
void swap(int* x, int* y);	/*値の交換*/
void downsort(int* a, int n);	/*降順ソート*/
void upsort(int* a, int n);	/*昇順ソート*/

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*/


/*ここからmain関数*/

int main()
{
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << (H - h)*(W - w);
	
	return 0;
}

/*2数の大きい方を返す*/
int max(int x, int y)
{
	int max;

	if (x < y)
		max = y;
	else
		max = x;

	return max;
}

/*2数の小さい方を返す*/
int min(int x, int y)
{
	int min;

	if (x < y)
		min = x;
	else
		min = y;

	return min;
}

/*2数の最大公約数を返す*/
int gcd(int x, int y)
{
	int m;
	int gcd = 1;

	m = min(x, y);

	for (int i = 1;i <= m; i++)
	{
		if (x%i == 0 && y%i == 0)
			gcd = i;
	}

	return gcd;
}

/*2数の最小公倍数を返す*/
int lcm(int x, int y)
{
	int m;

	for (int i = 1;i <= y;i++)
	{
		if ((x*i) % y == 0) {
			m = x * i;
			break;
		}
	}

	return m;
}

/*2数の値を交換する*/
void swap(int* px, int* py)
{
	int temp;

	temp = *px;
	*px = *py;
	*py = temp;
}

/*クイックソートによる降順並べ替え*/
void downsort(int* a, int n)
{
	//初期設定
	int l = 0, r = n - 1;

	// ピボットの決定
	int piv = *a;

	//ピボットより大を左に、ピボット以下を右に
	while (l < r)
	{
		if (*(a + l) > piv)
			l++;
		else if (*(a + r) <= piv)
			r--;
		else
			swap(a + l, a + r);
	}

	//再帰処理
	if (n == 2)
		return;
	else if (l == 1 || l == 0)
		downsort(a + 1, n - 1);
	else if (r == n - 1)
		downsort(a, n - 1);
	else
	{
		downsort(a, l);
		downsort(a + l, n - l);
	}
}

/*クイックソートによる昇順ソート*/
void upsort(int* a, int n)
{
	downsort(a, n);

	for (int i = 0;i < n / 2;i++)
		swap(a[i], a[n - 1 - i]);
}

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

int main() {
    int N, now;
    int odd = 0, even = 0;
    cin >> N;
    for(int i = 0; i < N; ++i) {
        cin >> now;
        if(now % 2 == 1) ++odd;
        else ++even;
    }
    if(odd % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256