akhauriyash/Code-Regression huggingface dataset:
# 参考 https://atcoder.jp/contests/abc133/submissions/7966658

import numpy as np

def abc133_c():
    L, R = map(int, input().split())
    if R - L > 673: return 0
    x = np.arange(L, R+1, dtype=np.int64)
    #y = x[:, None] * x[None, :] % 2019
    y = x.reshape(-1, 1) * x.reshape(1, -1)  # 区間内のすべての組合せの積
    y %= 2019
    np.fill_diagonal(y, 2019)  # 対角成分は無視する (同じ数を2回選べない) のでinf値で埋める
    return y.min()

print(abc133_c())

Measured memory_bytes: 14312
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
//change null_type here for map/set
typedef tree<int,null_type,less<int>,rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;
typedef long long int  ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define F first
#define S second

template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
    x*=sgn; return ~c;
}
///START HERE
///indexed_set pbd;
//pbd.insert()
//auto x = pbd.find_by_order(2);
//int od=pbd.order_of_key(7)
///rope<int> rp;
//rp.push_back()
//RandomAccess like vector
//mutable_begin, mutable_end()
int ar[1123456];
int main(){
    ///read()+printf
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //fast;

    mem(ar,0);
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                int x;
                if(i==j&&j==k){
                    x=1;
                }
                else if(i==j||j==k||i==k){
                    x=3;
                }
                else{
                    x=6;
                }
                ar[i*i+j*j+k*k+i*j+i*k+j*k]++;
            }
        }
    }
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cout<<ar[i]<<endl;
    }



    return 0;
}


Measured memory_bytes: 7980
# BFSして終わり 必ず存在するので
from collections import deque

n, m = map(int, input().split())
t = [[] for _ in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    t[a].append(b)
    t[b].append(a)

stamp = [0] * (n + 1)
stamp[0], stamp[1] = -1, -1
queue = deque()
for tv in t[1]:
    queue.append((tv, 1))
    stamp[tv] = 1

while len(queue) > 0:
    cur_node, pre_node = queue.popleft()
    for nex_node in t[cur_node]:
        if stamp[nex_node] != 0:
            continue
        stamp[nex_node] = cur_node
        queue.append((nex_node, pre_node + 1))

print("Yes")
for i in stamp[2:]:
    print(i)

Measured memory_bytes: 38344
#define FOR(i,j,n) for (long long i=(j);i<(n);i++)
#define REP(i,n) for (long long i=0;i<(n);i++)
#define REPN(i,n) for (long long i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define INF (long long)1<<59
#include <bits/stdc++.h>
using namespace std;

long long n,a,ret;
vector<long long> jw;

struct edge {long long to, cap, rev; };
vector<vector<edge>> graph(102);

bool used[102];

void add_edge(long long from, long long to, long long cap){
    graph[from].push_back( (edge){to, cap, graph[to].size()} );
    graph[to].push_back( (edge){from, 0, graph[from].size()-1 });
}

long long dfs(long long v, long long t, long long f){
    if (v==t) return f;
    used[v] = true;
    for (long long i = 0; i < graph[v].size(); i++){
        edge &e = graph[v][i];
        if (!used[e.to] && e.cap > 0){
            long long d = dfs(e.to, t, min(f,e.cap));
            if (d>0){
                e.cap -= d;
                graph[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

long long max_flow(long long s, long long t){
    long long flow = 0;
    for(;;){
        memset(used,0,sizeof(used));
        long long f = dfs(s,t,INF);
        if (f==0) return flow;
        flow += f;
    }
}

int main(){
    jw.pb(0);
    LL(n);
    REP(i,n){
        LL(a);
        jw.pb(a);
        if (a<0){
            add_edge(0,i+1,0);
            add_edge(i+1,101,-a);
        } else {
            ret += a;
            add_edge(0,i+1,a);
            add_edge(i+1,101,0);
        }
    }

    FOR(i,1,n){
        int j = i;
        while(j<n+1){
            add_edge(j,i,INF);
            j += i;
        }
    }

    cout << ret - max_flow(0,101) << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
 
public class Main {
  private static int n;
  private static List<String> res = new LinkedList<String>();
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    n = sc.nextInt();
    dfs(new StringBuffer(), 0);
    Collections.sort(res, new Comparator<String> () {
      public int compare(String a, String b) {
        int len = Math.min(a.length(), b.length());
        for(int i = 0; i < len; ++i) {
          if(a.charAt(i) != b.charAt(i)) return a.charAt(i) - b.charAt(i);
        }
        return a.length() - b.length();
      }
    });
    for(String s : res) {
      System.out.println(s);
    }
  }
  
  private static void dfs(StringBuffer cur, int used) {
    if(cur.length() >= n) {
      res.add(cur.toString());
      return;
    }
    for(int i = 0; i <= Math.min(cur.length(), used); ++i) {
      cur.append((char)('a' + i));
      int next = used;
      if(i >= used) next = i + 1;
      dfs(cur, next);
      cur.deleteCharAt(cur.length() - 1);
    }
  }
}


Measured memory_bytes: 51568
package main

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

func Pow(n, k int) int {
  a, b := 1, n
  for ; 0 < k; k /= 2 {
    if k % 2 == 1 { a = a * b % p }
    b = b * b % p
  }
  return a
}

const p = 1000000007

func Solve() {
  var N int
  NextInt(&N)
  Write((Pow(10, N) - 2 * Pow(9, N) + Pow(8, N) + 2 * p) % p)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntSlice(A *[]int) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]int, 0)
    return
  }
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatSlice(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]float64, 0)
    return
  }
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(S ...interface{}) {
  fmt.Fprintln(writer, S...)
}
func WriteIntSlice(A []int) {
  B := make([]interface{}, len(A))
  for i, a := range A { B[i] = a }
  fmt.Fprintln(writer, B...)
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 1816
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, X, ans;

LL gcd(LL a, LL b)
{
	if (a < b) std::swap(a, b);
	LL r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

int main()
{
	in >> N >> X;
	std::vector<LL>x(N);
	rep(i, N) in >> x[i];
	ans = std::abs(x[0] - X);
	rep(i, N) ans = gcd(ans, std::abs(x[i] - X));
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
class Main{
    public static void main(String args[]) throws IOException{
	int i,a=0,b=0;
        BufferedReader d = new BufferedReader(new InputStreamReader(System.in));
        String[] s = d.readLine().split(" ");
	Stack<Integer> stk = new Stack<Integer>();
	
        for (i=0;i<s.length;i++) {
            if (s[i].equals("+")) {
                a = stk.pop();
                b = stk.pop();
                stk.push(b + a);
                continue;
            }
            if (s[i].equals("-")) {
                a = stk.pop();
                b = stk.pop();
                stk.push(b - a);
                continue;
            }
            if (s[i].equals("*")) {
                a = stk.pop();
                b = stk.pop();
                stk.push(b * a);
                continue;
            }
            if (s[i].equals("*")) {
                a = stk.pop();
                b = stk.pop();
                stk.push(b * a);
                continue;
            }
            stk.push(Integer.parseInt(s[i]));
        }
        System.out.println(stk.pop());
    }
}





Measured memory_bytes: 24240
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 
#define digits(n) (int)(log10(n) + 1)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/*********** TEMPLATE ENDS HERE *************/

const int DIM = 3e5 + 7;

int east[DIM];
int west[DIM];

main()
{
	IOS
	
	int n;
	cin >> n;
	
	string s;
	cin >> s;
	
	for(int i = 1; i <= n; i++)
		west[i] = west[i - 1] + (s[i - 1] == 'W');
	
	for(int i = n; i >= 1; i--)
		east[i] = east[i + 1] + (s[i - 1] == 'E');
	
	int turns = n;
	
	for(int i = 1; i <= n; i++)
		turns = min(turns, west[i - 1] + east[i + 1]);
	
	cout << turns;
	
}

Measured memory_bytes: 2964
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793


   
int main(){
  vector<VI> c(3,VI(3));
  rep(i,3){
    rep(j,3){
      cin >> c.at(i).at(j);
    }
  }
  vector<int> v={0,1,2};
  sort(v.begin(),v.end());
  int m=c.at(0).at(0)+c.at(1).at(1)+c.at(2).at(2);
  int n;
  bool a=true;
  do{
    n=c.at(0).at(v.at(0))+c.at(1).at(v.at(1))+c.at(2).at(v.at(2));
    if(n!=m){
		a=false;
      break;
    }
    }while (next_permutation(v.begin(), v.end()));
  if(a) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

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

int main(void){
    int n;
    cin>>n;
    vector<pair< pair<int, int>, int> > v(n);
    rep(i, n-1){
        int a, b, c;
        cin>>a>>b>>c;
        v[i]=make_pair(make_pair(a, b), c);
    } 
    v[n-1]=make_pair(make_pair(0, 0), 1);
    rep(i, n-1){
        int ans=v[i].first.second;
        for(int j=i;j<=n-2;j++){
            ans+=v[j].first.first;
            ans=max(ans, v[j+1].first.second);
            if(ans%v[j+1].second!=0) {
                ans+=v[j+1].second-ans%v[j+1].second;
            }
        }
        cout<<ans<<endl;
    }
    cout<<0<<endl;
    return 0;
}

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

public class Main {
    public static final int MOD = (int) (1e9 + 7);

    public void solve(InputReader in, PrintWriter out) {
        int h = in.nextInt(), n = in.nextInt();
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            sum += in.nextInt();
        }
        out.println((sum >= h ? "Yes" : "No"));
    }

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        new Main().solve(in, out);
        out.flush();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 33648
n=int(input())
s=input()
ans=0
r,g,b=0,0,0
for i in range(n):
    if s[i]=="R":
        r+=1
    elif s[i]=="G":
        g+=1
    else:
        b+=1
for i in range(1,n):
    for j in range(i+1,n):
        if (j-i)+j<=n:
            k=(j-i)+j-1
            if  s[i-1]!=s[j-1] and  s[j-1]!=s[k] and s[k]!=s[i-1]:
                ans-=1
ans+=r*g*b
print(ans)

Measured memory_bytes: 73564
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, T;
	cin >> N >> T;
	T++;
	vector< pair<double, pair<int, int> > > A;
	vector<int> A0;
	for(int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		a++, b++;
		if(b > T) continue;
		if(a == 1) A0.push_back(b);
		else A.push_back({1.*(a-1)/b, {a, b}});
	}
	sort(begin(A), end(A));
	sort(begin(A0), end(A0));
	vector<int> min_t(31, T+1);
	min_t[0] = 1;
	for(int i = (int)A.size()-1; i >= 0; i--)
		for(int j = 30; j >= 0; j--) {
			if(min_t[j] > (T-A[i].ss.ss)/A[i].ss.ff) continue;
			min_t[j+1] = min(min_t[j+1], min_t[j]*A[i].ss.ff+A[i].ss.ss);
		}
	int sum = 0, ans = 0;
	for(int i = 0; i <= (int)A0.size(); i++) {
		if(sum > T) break;
		for(int j = 0; j <= 30; j++) {
			if(sum+min_t[j] > T) break;
			ans = max(ans, i+j);
		}
		if(i == (int)A0.size()) break;
		sum += A0[i];
	}
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 6640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int asort(const void *A,const void *B){
    return *(long long*)A>*(long long*)B?1:0;
}

long long roundup(long long A,long long B){
    return (A+B-1)/B;
}

long long max(long long A,long long B){
    return A>B?A:B;
}

int main(void){
    int n;
    scanf("%d",&n);
    long long a[n];
    for (int i=0; i<n; i++){
        scanf("%lld",&a[i]);
    }
    qsort (a,n,sizeof(long long),asort);
    long long b[n];
    for (int i=0; i<n; i++){
        scanf("%lld",&a[i]);
        b[i]=a[i];
    }
    for (int i=1; i<n-1; i++){
        if (b[i]<0){
            b[n-1]-=b[i];
        } else {
            b[0]-=b[i];
        }
    }
    printf("%lld\n",b[n-1]-b[0]);
    long long tmp=a[n-1];
    long long tmp2=a[0];
    for (int i=1; i<n-1; i++){
        if (a[i]<0){
            printf("%lld %lld\n",tmp,a[i]);
            tmp-=a[i];
        } else {
            printf("%lld %lld\n",tmp2,a[i]);
            tmp2-=a[i];
        }
    }
    printf("%lld %lld\n",tmp,tmp2);
    return 0;
}


Measured memory_bytes: 3436
import math
n=int(input())
s=int(input())

def f(b,n):
    if n<b:
        return n
    else:
        return f(b,n//b)+(n%b)


def abc(N,S):
    if N==S:
        return N+1
    else:
        for b in range(2,int(math.sqrt(N))+2):
            if f(b,N)==S:
                return b
        tmp=-1
        for p in range(1,int(math.sqrt(N))+2):
            if (N-S)%p!=0:
                continue
            b=(N-S)//p+1
            if b<=1:
                continue
            if f(b,N)==S:
                tmp=b
        return tmp
ans=abc(n,s)
print(ans)

Measured memory_bytes: 3064
n,m = gets.split.map(&:to_i)
ab = Array.new(m,[])
m.times do |i|
  ab[i] = gets.split.map(&:to_i)
end
count = 0
(2..n).to_a.permutation.each do |arr|
  is_break = false
  arr.unshift(1)
  (n-1).times do |i|
    tmp = [arr[i],arr[i+1]].sort
    is_break = true unless ab.include?(tmp)
   	break if is_break
  end
  count += 1 unless is_break
end

puts count

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

#define rep(i,n) for(int i=0; i<n; i++)
#define reep(i,a,b) for(int i=a; i<b; i++)
#define fi first
#define se second
using pii = pair<int,int>;

int table[4][4];

bool inside(int a, int b){
	return 0<=a&&a<4&&0<=b&&b<4;
}

int calc(vector<vector<int>> vv){
	int state = 0;
	rep(i,4){
		rep(j,4){
			if(vv[i][j]){
				state += 1<<(i*4+j);
			}
		}
	}
	return state;
}

int main(){
	int n;
	cin>>n;
	vector<pii> v(n);
	rep(i,n){
		cin>>v[i].fi>>v[i].se;
	}
	vector<pair<pii,pii>> w;
	int dx[] = {1,1,-1,-1};
	int dy[] = {1,-1,1,-1};
	rep(i,4){
		rep(j,4){
			rep(k,n){
				rep(l,4){
					pii lu(i,j);
					pii rd(max(0,min(i+dx[l]*(v[k].fi-1), 3)), max(0,min(j+dy[l]*(v[k].se-1), 3)));
					w.push_back(minmax(lu,rd));
				}
			}
		}
	} 
	sort(w.begin(), w.end());
	w.erase(unique(w.begin(), w.end()), w.end());
	rep(i,4){
		rep(j,4){
			char t;
			cin>>t;
			rep(k,3){
				if(t == "RGB"[k]){
					table[i][j] = k;
				}
			}
		}
	}
	vector<int> dp(1<<16,1e9);
	dp[0] = 0;
	rep(i,1<<16){
		if(dp[i]>1e8) continue;
		vector<vector<int>> vv(4,vector<int>(4));
		rep(j,16){
			if(i&(1<<j)){
				vv[j/4][j%4] = 1;
			}
		}
		for(auto x: w){
			bool ok = true;
			int color = -1;
			reep(k,x.fi.fi, x.se.fi+1){
				reep(l,x.fi.se, x.se.se+1){
					if(vv[k][l]==0){
						if(color == -1) color = table[k][l];
						else if(color != table[k][l]) ok = false;
					}
				}
				if(!ok) break;
			}
			if(ok){
				// auto tmp = vv;
				int tmp = i;
				reep(k,x.fi.fi, x.se.fi+1){
					reep(l,x.fi.se, x.se.se+1){
						if(vv[k][l]==0){
							tmp += 1<<((k)*4+l);
						}
					}
				}
				dp[tmp] = min(dp[tmp], dp[i]+1);
			}
		}
	}
	cout<<dp[(1<<16)-1]<<endl;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = 5e5+23;
const int sqN = 800;

int n, q;
string s;
int a[710][30];


void solve() {
  cin >> n >> s >> q;
  for (int i = 0; i < n; ++i) {
    ++a[i/sqN][s[i]-'a'];
  }
  while (q--) {
    int t; cin >> t;
    if (t == 1) {
      int pos;
      char c;
      cin >> pos >> c;
      --pos;
      c -= 'a';
      --a[pos/sqN][s[pos]-'a'];
      ++a[pos/sqN][c];
      s[pos] = c+'a';
    } else {
      int l, r; cin >> l >> r;
      --l; --r;
      int ans = 0;
      int h[30] = {0};
      for (int i = l; i <= r;) {
	if (i % sqN == 0 && i+sqN-1 <= r) {
	  for (int j = 0; j < 30; ++j) {
	    h[j] += a[i/sqN][j];
	  }
	  i += sqN;
	} else {
	  ++h[s[i]-'a'];
	  ++i;
	}
      }
      for (int i = 0; i < 30; ++i) if (h[i]) ++ans;
      printf("%d\n", ans);
    }
  }
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4000
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

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

    int n;
    cin >> n;

    ll a = 2, b = 1;

    rep(i, n - 1) {
        a += b;
        swap(a, b);
    }

    cout << b << endl;
}

Measured memory_bytes: 3652
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        int [] a = new int[n];
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            set.add(a[i]);
        }
        Arrays.sort(a); boolean ok = true;
        int max = a[n - 1]; int start = (max + 1) / 2;
        if (max % 2 == 0) {
            if (a[0] != max / 2) ok = false;
            if (a[1] == max / 2) ok = false;
        } else {
            if (a[0] != start || a[1] != start) ok = false;
            if (n > 2 && a[2] == start) ok = false;
        }

        if (a[0] < start) ok = false;
        for (int i = start; i <= max; i++) {
            if (!set.contains(i)) ok = false;
        }
        out.println(ok ? "Possible" : "Impossible");
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 32700
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

class PrimeTest{
private:
	std::vector<bool> is_prime_;					//nが素数かどうかをis_prime[n]で判定
	std::vector<unsigned int> prime_numbers_;		//素数の集合

public:
	PrimeTest();

	~PrimeTest();

	const std::vector<unsigned int>& get_prime_numbers() const;

	bool is_prime(unsigned int n);

};
 
PrimeTest::PrimeTest(){
	is_prime_.push_back(false);	//0
	is_prime_.push_back(false);	//1
	is_prime_.push_back(true);	//2
	is_prime_.push_back(true);	//3

	prime_numbers_.push_back(2);
	prime_numbers_.push_back(3);
}
PrimeTest::~PrimeTest(){}

const std::vector<unsigned int>& PrimeTest::get_prime_numbers() const{
	return prime_numbers_;
}

bool PrimeTest::is_prime(unsigned int n){
	if(n >= is_prime_.size()){
		unsigned int i_s = is_prime_.size();
		is_prime_.resize(n + 1, false);

		//i_sからnまでの各数が素数かどうか判定
		for(unsigned int i = i_s; i <= n; i++){
			unsigned int max_val = int(sqrt((double)i));
			bool b = true;
			for(unsigned int j = 0; j < prime_numbers_.size(); j++){
				if(prime_numbers_[j] > max_val){ break;}
				if(i % prime_numbers_[j] == 0){
					b = false;
					break;
				}
			}
			if(b){
				prime_numbers_.push_back(i);
				is_prime_[i] = true;
			}
		}

	}
	return is_prime_[n];
}

int main(int argc, char **argv){
	int n;
	PrimeTest prime_test;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

	prime_test.is_prime(50000);

#if INPUT_FROM_FILE
	while(ifs >> n){
#else
	while(std::cin >> n){
#endif
		int sprime = 0;
		int lprime = 0;
	
		for(int i = n - 1; i >= 0; i--){
			if(prime_test.is_prime(i)){
				sprime = i;
				break;
			}
		}
		for(int i = n + 1; ; i++){
			if(prime_test.is_prime(i)){
				lprime = i;
				break;
			}
		}

		std::cout << sprime << " " << lprime << std::endl;
	}
 
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}


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

int N;
int p[200];

void swaps(int k){
    for(int i=k;i<N;i++) swap(p[i],p[i-k]);
}

bool check(){
    for(int i=1;i<N;i++) if(p[i]<p[i-1]) return false;
    return true;
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> p[i];
    vector<int> ans;
    while(!check()){
        if(p[0]!=0 && p[N-1]!=0 && p[0]<p[N-1]){
            swaps(N-1);
            ans.push_back(N-1);
        }
        swaps(1);
        ans.push_back(1);
    }
/*    for(int i=0;i<N;i++) cerr << p[i] << " ";
    cerr << endl;
*/    assert((int)ans.size()<=100000);
    cout << ans.size() << endl;
    for(auto x:ans) cout << x << endl; 
}

Measured memory_bytes: 764
#include <stdio.h>
int main(void){
	long long n,m,a;
	scanf("%lld %lld",&n,&m);
	if(m>=2*n){
		a=n;
		m-=2*n;
		a+=m/4;
	}
	else{
		a=m/2;
	}
	printf("%lld\n",a);
	return 0;
}

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

#define fir first
#define sec second

typedef std::pair<int, int> Pii;

const int DX[] = {-1, 0, 0, 1};
const int DY[] = {0, -1, 1, 0};

char S[410][410];
int H, W, vis[410][410];

long long BFS(int, int);

int main() {
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; i++) scanf("%s", S[i]);

	long long ans = 0;
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++)
			if (!vis[i][j]) ans += BFS(i, j);

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

long long BFS(int sx, int sy) {
	std::queue<Pii> que;
	long long cnt1, cnt2;
	for (cnt1 = cnt2 = 0, vis[sx][sy] = 1, que.push(Pii(sx, sy)); !que.empty(); ) {
		Pii now = que.front(); que.pop();
		S[now.fir][now.sec] == '#' ? ++cnt1 : ++cnt2;
		for (int k = 0; k < 4; k++) {
			int nx = now.fir + DX[k], ny = now.sec + DY[k];
			if (nx >= 0 && nx < H && ny >=0 && ny < W && !vis[nx][ny] && S[nx][ny] ^ S[now.fir][now.sec]) {
				vis[nx][ny] = 1;
				que.push(Pii(nx, ny));
			}
		}
	}

	return cnt1 * cnt2;
}


Measured memory_bytes: 1024
use std::io;

fn main() {
	let we = ["Sunny", "Cloudy", "Rainy"];
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s = buf.trim();
	let mut a = 0;
	for n in 0..3 {
		if s == we[n] {
			a = (n + 1) % 3;
			break;
		}
	}
	println!("{}", we[a]);
}

Measured memory_bytes: 4352
n, m = map(int, input().split())
INF = float('inf')
graph = [[INF for i in range(n)] for j in range(n)]
tmp = []

for i in range(m):
    a, b, c = map(int, input().split())
    graph[a - 1][b - 1] = c
    graph[b - 1][a - 1] = c
    tmp.append((a - 1, b - 1, c))

for k in range(n):
    for i in range(n):
        for j in range(n):
            graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])

ans = 0
for a, b, c in tmp:
    if c > graph[a][b]:
        ans += 1

print(ans)


Measured memory_bytes: 3444
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    if (Math.abs(c-a) <= d) {
      System.out.println("Yes");
    } else if (Math.abs(b-a) <= d && Math.abs(c-b) <= d ) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23636
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    
    boolean odd = false;
    int cnt = 0;
    
    while(true) {
      for(int i = 0; i < n; i++) {
        if(a[i]%2 == 0) {
          a[i] /= 2;
        } else {
          odd = true;
          break;
        }
      }
      if(odd) {
        break;
      } else {
        cnt++;
      }
    }
  
    System.out.print(cnt);
    
  }
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a <= c && c <= b){
    cout << "Yes" << endl;
  }
  else if(a > c && c > b){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

a_line = []
b_line = []
for i in range(n):
    a, b = map(int, input().split())
    a_line.append(a)
    b_line.append(b)
    
a_line.sort()
b_line.sort()


if n % 2 == 0:
    left = a_line[n // 2 - 1] + a_line[n // 2]
    right = b_line[n // 2 - 1] + b_line[n // 2]
    print(right - left + 1)
else:
    print(b_line[n // 2] - a_line[n // 2] + 1)

Measured memory_bytes: 25452
#include<bits/stdc++.h>
#define rep(i,a) for(int i=0;i<a;i++)
#define all(v) v.begin(),v.end()
#define int long long
using namespace std;
int gcd(int a, int b) {
    if(a%b==0) return b;
    else return gcd(b,a%b);
}
signed main(){
    int a,b;
    cin>>a>>b;
    cout<<a/gcd(a,b)*b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = 5000;
const int md = 998244353;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll ar[M],dp[M],tp[M];

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

	ll n,s,i,j,inv;

	cin >> n >> s;
	for(i=1;i<=n;++i)
		cin >> ar[i];

	inv = pwr(2,md-2,md);
	dp[0] = pwr(2,n,md);

	for(i=1;i<=n;++i)
	{
		for(j=0;j<=s;++j)
			tp[j] = dp[j];
		for(j=ar[i];j<=s;++j)
			dp[j] = (dp[j] + 1ll*tp[j-ar[i]]*inv%md)%md;
	}

	cout << dp[s] << "\n";
}
	

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

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    string t = s;
    sort(t.begin(),t.end());
    // cout << t << "t\n";
    int ans = 0;
    for (int i = 0 ; i < s.length() ; i++)
    {
        if (t[i] != 'R') break;
        ans += (t[i] != s[i]);
    }
    cout << min(ans,n - ans) << endl;
    return 0;
}

Measured memory_bytes: 3800
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]
dp = [[0]*3 for _ in range(n)]
for i in range(3):
    dp[0][i] = abc[0][i]
for i in range(n-1):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j]+abc[i+1][k])
print(max(dp[-1]))


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


int main(){
    /*#ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif*/
    
    int x,y,z;
    cin>>x>>y>>z;

    swap(x,y);
    swap(x,z);

    cout<<x<<" "<<y<<" "<<z<<endl;    
    
    
    return 0;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int main(){
  int N;
  cin >> N;
  cout << N*N*N << endl;
  return 0;
}


Measured memory_bytes: 256
let mcm p n =
  let m = Array.make_matrix (n + 1) (n + 1) max_int in
  for i = 1 to n do m.(i).(i) <- 0 done;
  for l = 2 to n do
    for i = 1 to n - l + 1 do
      let j = i + l - 1 in
      for k = i to j - 1 do
        m.(i).(j) <- min m.(i).(j) (m.(i).(k) + m.(k+1).(j) + p.(i-1)*p.(k)*p.(j))
      done
    done
  done;
  m.(1).(n)

let () =
  let n = read_int () in
  let p = Array.make (n + 1) 0 in
  let rec read i =
    if i < n then begin
      let (r, c) = Scanf.scanf "%d %d\n" (fun r c -> (r, c)) in
      p.(i) <- r; p.(i+1) <- c;
      read (i + 1)
    end
  in
  read 0;
  Printf.printf "%d\n" (mcm p n)

Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

ll h;

ll f (ll n)
{
    if (n == 1) {
        return 1;
    } else {
        return f(n/2) * 2 + 1;
    }

}

int main()
{
    cin>>h;
    cout<<f(h)<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by ??\??? on 2016/12/2.
 */
public class Main {
    static void print(Object[] array)
    {
        for(int i = 0;i<array.length;i++)
        {
            if(i==0)
                System.out.print(array[i].toString());
            else
                System.out.print(" "+array[i].toString());
        }
        System.out.println();
    }
    static int run(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()) {
            int T = Integer.parseInt(scan.nextLine());
            String[] array = scan.nextLine().split(" ");
            for (int i = 1; i <= T; i++) {
                if (i == 1)
                    print(array);
                else {
                    int pointer = i - 1;
                    for (int j = pointer - 1; j >= 0; j--) {
                        if (Integer.parseInt(array[pointer]) < Integer.parseInt(array[j])) {
                            String temp = array[pointer];
                            array[pointer] = array[j];
                            array[j] = temp;
                            pointer = j;
                        } else break;
                    }
                    print(array);
                }
            }
        }
        return 0;
    }
    public static void main(String[] args)
    {
        run(args);
    }

}

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

int main() {
	int N, M, a;
	cin >> N >> M;
	set<int> b;
	for (int i = 0; i < M; ++i) {
		cin >> a;
		b.insert(a);
	}
	vector<int> ans(N);
	if (!b.count(1)) ans[0] = 1;
	if (1 != N) {
		if (!b.count(2)) ans[1] = 1 + ans[0];
	}
	for (int i = 2; i < N; ++i) {
		if (!b.count(1 + i)) ans[i] = (ans[i - 2] + ans[i - 1]) % 1000000007;
	}
	cout << ans.back();
}

Measured memory_bytes: 5376
mod = 10**9+7
K = input()
D = int(input())
N = len(K)
dp = [[0] * D for i in range(N)]
for i in range(int(K[0])):
    dp[0][i%D] += 1
tight = int(K[0])%D
for i in range(1, N):
    for j in range(D):
        for k in range(10):
            dp[i][j] += dp[i-1][(j-k)%D]
            dp[i][j] %= mod
    for k in range(int(K[i])):
        dp[i][(tight+k)%D] += 1
    tight = (tight+int(K[i]))%D
print((dp[N-1][0]+(tight==0)-1)%mod)


Measured memory_bytes: 52148
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
const ll mod = 1000000007;
ll beki(ll a, ll b) {
    if(b == 0) return 1;
    ll ret = beki(a, b / 2);
    ret = ret * ret % mod;
    if(b & 1) ret = ret * a % mod;
    return ret;
}

ll num[105000];
vector<ll> Div[105000];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    for(ll i = 1; i <= K; i++) {
        num[i] = beki(K / i, N);
        for(ll j = i * 2; j <= K; j += i) {
            Div[j].push_back(i);
        }
    }
    ll ans = 0;
    for(ll i = K; i >= 1; i--) {
        ans += num[i] * i;
        ans %= mod;
        for(auto v : Div[i]) {
            num[v] -= num[i] - mod;
            num[v] %= mod;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 20440
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main(){
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << fixed << setprecision(6) << sqrt(pow((x2 - x1), 2) + pow((y2 - y1), 2)) << endl;
}

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

int main() {
	int n,m[100];
	cin >> n ;
	for (int i=0;i<n;i++) {
		cin >> m[i];
	}
	sort(m,m+n);	
		
	cout <<m[n-1]-m[0] << endl;
	}

Measured memory_bytes: 256
N,M = map(int,input().split())

L = list(map(int,input().split()))

L.sort(reverse=True)

# M 番目の数
M_num = L[M-1]

# 前得票数
A = sum(L)

if M_num < A/(4*M):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
# AtCoder Beginner Contest 153 - B
# -*- encoding: UTF-8 -*-
h, n = map(int, input().split())
aList = list(map(int, input().split()))

result = "No"
total = 0
for i in aList:
  total = total + i

if total < h :
  result = "No"
else :
  result = "Yes"

print(result)


Measured memory_bytes: 13964
import java.util.Scanner;
import java.util.ArrayList;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int p[] = new int[n];
        for(int i = 0;i < n;i++) {
            p[i] = stdIn.nextInt();
        }
        int count = 0;
        for(int i = 0;i < n;i++){
            if(p[i] != i+1) {
               count++;             
            }
        }
        if(count >= 3) {
            System.out.println("NO");
        }else {
            System.out.println("YES");
        }
    }
}

Measured memory_bytes: 22740
#include <stdio.h>

int main(){

  int H,W,i,j;
  while(1){
    scanf("%d%d",&H,&W);
    if(H==0&&W==0) break;
    
    for(i=0;i<H;i++)
      {
      for(j=0;j<W;j++)
	{
	  if((i+j)%2==0){
	    printf("#");
	      }else{
	    printf(".");
	      }
	}
      printf("\n");
      }
    printf("\n");
  }
  return 0;
}
	  

Measured memory_bytes: 1000
#include <bits/stdc++.h>
// #include <experimental/iterator>

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* debug */
// auto debug = std::experimental::make_ostream_joiner(std::cout, " ");

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val % MOD + (val > 0 ? 0 : MOD)) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = long long;
using std::cout;
using std::cin;
using std::endl;
using Mint = Modint<long long, 1000000007>;

Int a, b, c, x, y;

int main(){
	cin >> a >> b >> c >> x >> y;
	Int ab = ont(a + b, c * 2);
	onth(a, c * 2);
	onth(b, c * 2);
	Int ans;
	if(x < y){
		ans = x * ab + (y - x) * b;
	}else{
		ans = y * ab + (x - y) * a;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
namespace AtCoder_Beginner_Contest_13
{
    class Program
    {
        //配列にする
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        //Listにする
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
        }
        static void Solve()
        {
            var N = Sarray()[0];
            var Hi = Sarray(); ;
            for (var i = 1; i < N; ++i)
            {
                if (Hi[i - 1] < Hi[i])
                { --Hi[i]; }
                if (Hi[i] < Hi[i - 1])
                {
                    WriteLine("No");
                    return;
                }
            }
            WriteLine("Yes");
        }
    }
}


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

namespace ABC143A
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputArr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //var inputInt = int.Parse(Console.ReadLine());

            int ans = 0;
            //string ans = "";
            int A = inputArr[0];
            int B = inputArr[1];
            ans = A - 2 * B;
            ans = ans < 0 ? 0 : ans;

            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13268
#include<iostream> 
using namespace std; 
int main(){ 
  int t[100],h[100],n,m,mn,tsum,hsum,at,ah; 
  while(1){ 
    cin>>n>>m; 
    if(n==0&&m==0)break; 
    tsum=hsum=0; 
    mn=201; 
    for(int i=0;i<n;i++){cin>>t[i];tsum+=t[i];} 
    for(int i=0;i<m;i++){cin>>h[i];hsum+=h[i];} 
    for(int i=0;i<n;i++){ 
      for(int j=0;j<m;j++){ 
    if(hsum-h[j]+t[i]==tsum-t[i]+h[j]){ 
      if(mn>t[i]+h[j]){ 
        at=t[i];ah=h[j]; 
        mn=t[i]+h[j]; 
      } 
    } 
      } 
    } 
    if(mn==201){ 
      cout<<-1<<endl; 
    }else{ 
      cout<<at<<" "<<ah<<endl; 
    } 
      
      
  } 
  return 0; 
} 

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int a, b;
    cin >> a >> b;
    cout << (a * b % 2 == 0 ? "Even" : "Odd") << endl;
}


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

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

    for(int i = 0; i < n; i++){
        cin >> s;
        if(s == "Y"){
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<string, int>;
using ll = long long;

template<class T>
class Queue
{
private:
    static const ll LEN = 100005;
public:
    ll head;
    ll tail;
    T data[LEN];

    Queue() : head(0), tail(0){}

    bool is_empty(){
        return head == tail;
    }

    bool is_full(){
        return head == (tail + 1)%LEN;
    }

    void enqueue(T x){
        if(is_full()){
            //todo : エラー処理を書く
        }
        data[tail] = x;
        tail = (tail + 1)%LEN;
        return;
    }

    T dequeue(){
        if(is_empty()){
            //todo : エラー処理を書く
        }
        T x = data[head];
        head = (head + 1)%LEN;
        return x;
    }
};

int main(){
    int n, q; cin >> n >> q;
    Queue<P> qe;
    rep(i, n){
        string s;
        ll t;
        cin >> s >> t;
        qe.enqueue(make_pair(s, t));
    }

    ll now_t = 0;
    while(!qe.is_empty()){
        P h = qe.dequeue();
        ll t = min(q, h.second);
        h.second -= t;
        now_t += t;
        if(h.second > 0) qe.enqueue(h);
        else cout << h.first << ' ' << now_t << endl;
    }

    return 0;
}


Measured memory_bytes: 7060
S=input()

if S=='SUN':
  print(7)
elif S=='MON':
  print(6)
elif S=='TUE':
  print(5)
elif S=='WED':
  print(4)
elif S=='THU':
  print(3)
elif S=='FRI':
  print(2)
elif S=='SAT':
  print(1)

Measured memory_bytes: 2940