akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S, ans="NO";
  cin >>S;
  vector<string> Z={"dream","dreamer","erase","eraser"};   
  if(S.size()<=7){
    if(S.size()>4){
      for(int i=0; i<4; i++){
        if(S==Z[i]) ans="YES";
      }
    }
  cout << ans << endl;
  return 0;
  }

  for(int k=3; k>=0; k--){
    for(int i=0; i<S.size()-Z[k].size()+1; i++){
      if(S[i]==Z[k][0]){
        for(int j=1; j<Z[k].size(); j++){
          if(S[i+j]!=Z[k][j]) break;
          if(j==Z[k].size()-1){
            for(j=0; j<Z[k].size(); j++){
            S[i+j]='x';
            }
          }
        }      
      }
    }
  }
  for(int i=0; i<S.size(); i++){
    if(S[i]!='x') break;
    if(i==S.size()-1) ans="YES";
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
var
  i,j,k,n,m,t,x,y:longint;
  s:string;
begin
  readln(s);
  x:=0;
  for i:= 1 to length(s) do
    begin
      if s[i]='C' then x:=1;
      if (x=1) and (s[i]='F') then begin write('Yes');
                                         halt;
                                   end;
    end;
write('No');
end.
  

Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::max;
fn main() {
    input!{
        a: u64,
        b: u64,
        c: u64,
        d: u64,
    }
    println!("{}", max(a * b, c * d));
}


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


#define rep(i, s, c) for (int i = s; i < c; i++)
#define rep_neg(i, c) for (int i = c - 1; i > -1; i--)
#define MOD 1000000000 + 7

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

	vector<int> x(N + 1);
	int num; // 素因数分解する変数num 

    rep(n, 2, N + 1){
        num = n;
        rep(i, 2, n + 1){
            while (num%i == 0) { // 素数で割り切れなくなるまで割っていく
                x.at(i)++;//割った個数を配列に足す
                num /= i;
            }
        }
    }
	rep(i, 2, N+1) if (x.at(i) > 0) x.at(i) += 1;//それぞれを+1して掛けていく
	//rep(i, 2, N+1) if (x.at(i) > 0) cout << i << "\t" << x.at(i) << endl;//それぞれを+1して掛けていく

    int ans = 0;
    int above_25 = 0;
    int above_15 = 0;
    int above_5 = 0;
    int above_3 = 0;

    rep(i, 2, N+1){
        int value = x.at(i);
        if (value >= 75) ans += 1;
        if (value >= 25) above_25 += 1;
        if (value >= 15) above_15 += 1;
        if (value >= 5) above_5 += 1;
        if (value >= 3) above_3 += 1;
    }
    //cout << above_3 << endl;
    //cout << above_5 << endl;

    ans += above_25 * (above_3 - 1);
    ans += above_15 * (above_5 - 1);
    ans += (above_3 - 2) * (above_5) * (above_5 - 1) / 2;
    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5,low=9;
typedef long long ll;
int n,vis[31][31];
char s[1005];
ll ans=0;
int main()
{
    scanf("%d",&n);
    for(int h=1;h<=n;h++)
    {
        scanf("%s",s+1);
        int m=strlen(s+1);
        long long u=0;
        int i=1,c=0,a=0,b=0;
        for(;i<=m;i++)
            if(s[i]=='.') break;
        else u=u*10+s[i]-'0';
        for(i++;i<=m;i++)
            u=u*10+s[i]-'0',c++;
        while(u%2==0) u/=2,a++;
        while(u%5==0) u/=5,b++;
        a=min(a,18);b=min(b,18);
        for(int i=max(-9,c-a);i<=18;i++)
            for(int j=max(-9,c-b);j<=18;j++)
            ans+=vis[i+low][j+low];
        vis[a-c+low][b-c+low]++;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
#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++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcm(int a, int b)
{
    if (b == 0)
        return a;
    gcm(b, a % b);
}

int main()
{
    string s;
    cin >> s;
    if (s <= "2019/04/30")
        cout << "Heisei" << endl;
    else
        cout << "TBD" << endl;
}


Measured memory_bytes: 256
n,m = map(int,raw_input().split())
q = map(int,raw_input().split())

bit = [0]*40

for a in q:
  buf = a
  for b in range(40):
    bit[b] += buf & 1
    buf >>= 1

ans = 0
now = 0

for b in range(39,-1,-1):
  qq = 1<<b
  if (now+qq) > m:
    ans += (1<<b)*bit[b]
    continue
  if bit[b] > (n/2):
    ans += (1<<b)*bit[b]
  else:
    ans += (1<<b)*(n-bit[b])
    now += qq

print ans
 



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

int main()
{
  string a, b, c;
  cin >> a >> b >> c;
  cout << a.at(0) << b.at(0) << c.at(0) << endl;
}


Measured memory_bytes: 256
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    string S;
    cin >> S;
    int ans = INF;
    for (int i = 0; i + 2 < S.size(); i++)
    {

        string stmp = "";
        stmp.push_back(S[i]);
        stmp.push_back(S[i + 1]);
        stmp.push_back(S[i + 2]);
        int tmp = atoi(stmp.c_str());
        if (abs(tmp - 753) < ans)
        {
            ans = abs(tmp - 753);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int l,a,b,c,d;
  cin >> l >> a >> b >> c >> d;
  int o=1;
  int x,y;
  x=a/c;
  if(a%c!=0) x++;
  y=b/d;
  if(b%d!=0) y++;
  cout << max(o,min(l-x,l-y)) << endl;
  
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << 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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  string s;
  cin >> s;
  if(sz(s)==2){
    print(s);
  }
  else{
    reverse(all(s));
    print(s);
  }
}

Measured memory_bytes: 256
macro_rules! scan {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| scan!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let n = scan!(usize);
    if n % 2 == 0 {
        println!("0.5");
    } else {
        println!("{}", (n as f64 / 2.0).ceil() / n as f64);
    }
}

Measured memory_bytes: 4352
use std::io;

fn main() {
    loop {
        let mut line = String::new();
        io::stdin().read_line(&mut line).ok();

        let mut iter = line.split_whitespace().map(|w| w.parse::<i32>().unwrap());
        let h = iter.next().unwrap();
        let w = iter.next().unwrap();

        if h == 0 && w == 0 { break; }

        for i in 0..h {
            for j in 0..w {
                if (i + j) % 2 == 0 {
                    print!("#");
                } else {
                    print!(".");
                }
            }
            println!("");
        }
        println!("");
    }
}



Measured memory_bytes: 5024
// https://beta.atcoder.jp/contests/abc110/tasks/abc110_b
#include<iostream>
#include<climits>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
int main(){

	int n,m,X,Y;
	cin >> n >> m >> X >> Y;
	vector< int > x(n);
	vector< int > y(m);

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

	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	
	for(int i = X+1; i <= Y; i++){
		if (x.back()<i && y.front() >= i){
			cout << "No War" << endl;
			return 0;
		}
	}
	
	cout << "War" << endl;
	
	return 0;
}

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

using namespace std;

int main(){
  int d, n, m;
  while(1){
    cin >> d;
    if(!d) break;
    cin >> n >> m;

    vector<int> shop(n+1, 0), deli(m, 0);
    for(int i=0; i<n-1; ++i) cin >> shop[i];
    shop[n-1]=0;
    shop[n]=d;
    for(int i=0; i<m; ++i) cin >> deli[i];
    sort(shop.begin(), shop.end());
    sort(deli.begin(), deli.end());

    int sum=0;
    for(int i=1, j=0; j<deli.size(); ){
      if(shop[i] >= deli[j]){
	sum += min(deli[j]-shop[i-1], shop[i]-deli[j]);
	++j;
      }else{
	++i;
      }
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1532
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()

    val B = readLine()!!.split(" ").map(String::toInt)

    val A = IntArray(N){Integer.MAX_VALUE}

    for ((i, v) in B.withIndex()) {
        A[i] = Math.min(v, A[i])
        A[i + 1] = Math.min(v, A[i + 1])
    }

    println(A.sum())


}

Measured memory_bytes: 36080
k, n = map(int, input().split())
alist = list(map(int, input().split()))

doublelist = alist.copy()

for a in alist:
    doublelist.append(k + a)

# print(doublelist)

res = float('inf')
prev = float('inf')

for i in range(n + 1):
    prev = doublelist[i + n - 1] - doublelist[i]
    # print(prev)
    res = min(res, prev)

print(res)

Measured memory_bytes: 26060
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,m;
    cin>>n>>m;
    string s[n];
    for(int i=0;i<n;i++)
    {
      cin>>s[i];
    }
    for(int i=0;i<n;i++)
    {
      cout<<s[i]<<endl;
      cout<<s[i]<<endl;
    }
}
return 0;
}

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

int main() {
  int N;
  cin >> N;
  int ac = 0, wa = 0, tle = 0, re = 0;
  for (int i = 0; i < N; i++) {
    string tmp;
    cin >> tmp;
    if (tmp == "AC") ac++;
    else if (tmp == "WA") wa++;
    else if (tmp == "TLE") tle++;
    else re++;
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}


Measured memory_bytes: 3628
import java.text.ParseException;
import java.util.Scanner;

public class Main {

	public static void main(String[] arges) throws ParseException {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		int v = Integer.parseInt(line);

		int[][] daice = new int[v][6];
		for (int i = 0; i < v; i++) {
			String line2 = sc.nextLine();
			String[] ks = line2.split(" ");
			for (int j = 0; j < 6; j++) {
				daice[i][j] = Integer.parseInt(ks[j]);
			}
		}
		int count = 0;
		for (int i = v - 1; i > 0; i--) {
			for (int j = i -1; j > -1; j--) {
				for (int j2 = 0; j2 < 4; j2++) {
					if (daice[i][0] == daice[j][0]) {
						break;
					}
					Daice.south(daice, i);

					if (j2 == 3 && daice[i][0] != daice[j][0]) {
						Daice.west(daice, i);
					}

				}
				for (int j2 = 0; j2 < 4; j2++) {
					if (daice[i][0] == daice[j][0]) {
						break;
					}
					Daice.south(daice, i);
				}
				if (daice[i][0] != daice[j][0]) {
					break;
				} else {
					for (int j2 = 0; j2 < 4; j2++) {
						Daice.kaiten(daice, i);
						if (daice[i][1] == daice[j][1]) {
							break;
						}

					}
					if (daice[i][0] == daice[j][0]
							&& daice[i][1] == daice[j][1]
							&& daice[i][2] == daice[j][2]
							&& daice[i][3] == daice[j][3]
							&& daice[i][4] == daice[j][4]
							&& daice[i][5] == daice[j][5]) {
						count++;
					} else {
						

					}
				}

			}
		}
		if (count == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	public static class Daice {

		public static void south(int[][] daice, int i) {
			int[] fs = new int[] { daice[i][0], daice[i][1], daice[i][2],
					daice[i][3], daice[i][4], daice[i][5] };
			daice[i][5] = fs[1];
			daice[i][1] = fs[0];
			daice[i][0] = fs[4];
			daice[i][4] = fs[5];

		}

		public static void west(int[][] daice, int i) {
			int[] fs = new int[] { daice[i][0], daice[i][1], daice[i][2],
					daice[i][3], daice[i][4], daice[i][5] };
			daice[i][5] = fs[3];
			daice[i][2] = fs[5];
			daice[i][0] = fs[2];
			daice[i][3] = fs[0];
		}

		public static void kaiten(int[][] daice, int i) {
			int[] fs = new int[] { daice[i][0], daice[i][1], daice[i][2],
					daice[i][3], daice[i][4], daice[i][5] };
			daice[i][1] = fs[3];
			daice[i][2] = fs[1];
			daice[i][3] = fs[4];
			daice[i][4] = fs[2];
		}
	}
}

Measured memory_bytes: 27108
# ABC060D - Simple Knapsack (ARC073D)
from itertools import accumulate as acc


def main():
    N, W, *A = map(int, open(0).read().split())
    V, x = [[] for _ in range(4)], A[0]  # x: w1 (W1 ≤ wi ≤ w1 + 3)
    for w, v in zip(*[iter(A)] * 2):  # group by weight
        V[w - x].append(v)
    for i in range(4):  # V[i][j] := max value of picking up j items from group i
        V[i] = tuple(acc([0] + sorted(V[i], reverse=1)))
    L = [len(v) for v in V]
    ans = 0
    for i in range(L[0]):
        for j in range(L[1]):
            for k in range(L[2]):
                w = i * x + j * (x + 1) + k * (x + 2)
                if w > W:
                    break
                l = min(L[3] - 1, (W - w) // (x + 3))
                v = V[0][i] + V[1][j] + V[2][k] + V[3][l]
                ans = max(ans, v)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

A = []
for i in range(N):
    A.append(list(map(int, input().split())))
    
l_ans = []
for a in A:
#     print(a)
    l_ans.append(sum([a[j] * B[j] for j in range(M)]) + C > 0)
print(sum(l_ans))

Measured memory_bytes: 3064
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from collections import defaultdict
from collections import deque
import bisect
from decimal import *
from functools import reduce
def main():
    def comb(n, r):
        if r == 0:
            return 1
        else:
            numerator = reduce(lambda x, y: x * y % mod, [n - r + k + 1 for k in range(r)])
            denominator = reduce(lambda x, y: x * y % mod, [k + 1 for k in range(r)])
            return numerator * pow(denominator, mod - 2, mod) % mod
    S = I()
    mod = 10 ** 9 + 7
    N = S // 3
    ans = 0
    for i in range(1, N + 1):
        x = S - 3 * i
        ans += comb(x + i - 1, i - 1)
        ans %= mod
    print(ans)
if __name__ == "__main__":
    main()



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

using namespace std;

#define M (ll)(1e9+7)
#define EPS (double)(1e-12)
#define ll long long
#define N (ll)(2*1e5)

class Graph {
    
    public:
        int V;
        vector<int> *adj;
        bool *visited;

        Graph(int V) {
            this->V = V;
            adj = new vector<int>[V];
            visited = new bool(V);
            memset(visited, 0, V*sizeof(bool));
        }
        void addEdge(int u, int v) {
            adj[u].push_back(v);
            adj[v].push_back(u);
        }
        void dfs(int u);
        void bfs(int u);
};

void Graph::dfs(int u) {
    if(visited[u])
        return;
    visited[u] = true;
    cout << u << " ";

    for(auto a : adj[u]) {
        dfs(a);
    }
}

void Graph::bfs(int u) {
    queue<int> fila;

    fila.push(u);
    visited[u] = true;
    while(!fila.empty()) {
        int s = fila.front();
        cout << s << " ";
        fila.pop();

        for(auto a : adj[s]) {
            if(!visited[a]) {
                visited[a] = true;
                fila.push(a);
            }
        }
    }
}

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

    int n, m, sum = 0;

    cin >> n >> m;

    int val;
    for(int i = 0; i < m; i++) {
        cin >> val;
        sum += val;
    }
    if(n - sum < 0)
        cout << -1 << endl;
    else   
        cout << n-sum << endl;

    return 0;
}

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

using namespace std;

using int64 = long long;

int main() {
  int N, A[10000];
  cin >> N;
  int ret = 0;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    while(A[i] % 2 == 0) {
      A[i] /= 2;
      ++ret;
    }
  }
  cout << ret << endl;
}


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

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

enum {migi, hidari, mae, ushiro, ccw, cw};
int dx[] = {0,0,1,-1,0,0};
int dy[] = {1,-1,0,0,0,0};
int op[6][6] = {
	{4,1,0,3,5,2},
	{2,1,5,3,0,4},
	{3,0,2,5,4,1},
	{1,5,2,0,4,3},
	{0,4,1,2,3,5},
	{0,2,3,4,1,5},
};

void roll(vector<int> &v, int dir){
	vector<int> temp = v;
	for(int i = 0; i < 6; i++){
		temp[i] = v[op[dir][i]];
	}
	v = temp;
}

vector<int> dice[24];

void init_dice(){
	for(int i=1; i < 24; i++){
		dice[i] = dice[i-1];
		roll(dice[i], ccw);
		if( i % 8 == 0 ) roll(dice[i], hidari);
		else if(i % 4 == 0) roll(dice[i], mae);
	}
}

int R,C;
string table[32];
string order;

bool valid(int x, int y) {
	return 0 <= x && x < R && 0 <= y && y < C;
}

string color = "rgbmyc";
int memo[30][30][7][6][6];
struct State {
	int x, y, m;
	vector<int> v;
	int &ref() {
		return memo[x][y][m][color.find(v[0])][color.find(v[1])];
	}
};

int bfs(int x, int y, vector<int> v) {
	queue<State> up;
	State s = (State){ x, y, 0, v};
	up.push( s );
	s.ref() = 0;
	while( !up.empty() ) {
		s = up.front();
		up.pop();
		if( s.m == 6 ) return s.ref();
		REP(k, 4) {
			int nx = s.x + dx[k];
			int ny = s.y + dy[k];
			if( !valid(nx, ny) || table[nx][ny] == 'k' ) continue;
			if( table[nx][ny] != 'w' ) {
				if( order[s.m] != table[nx][ny] ) continue;
				vector<int> next_v = s.v;
				roll(next_v, k);
				if( next_v[0] != table[nx][ny] ) continue;
				
				State next = s;
				next.x = nx;
				next.y = ny;
				next.m = next.m + 1;
				next.v = next_v;
				if( next.ref() == -1 ) {
					next.ref() = s.ref() + 1;
					up.push(next);
				}
			} else {
				vector<int> next_v = s.v;
				roll(next_v, k);
				State next = s;
				next.x = nx;
				next.y = ny;
				next.v = next_v;
				if( next.ref() == -1 ) {
					next.ref() = s.ref() + 1;
					up.push(next);
				}
			}
		}
	}
	return -1;
}

int main() {
	for(;;) {
		cin >> C >> R; if( R == 0 && C == 0 ) break;
		REP(r, R) {
			cin >> table[r];
		}
		cin >> order;
		
		int sx, sy;
		REP(r, R) REP(c, C) {
			if( table[r][c] == '#' ) {
				sx = r; sy = c;
				table[r][c] = 'w';
			}
		}
		
		dice[0].push_back('r');
		dice[0].push_back('m');
		dice[0].push_back('b');
		dice[0].push_back('g');
		dice[0].push_back('y');
		dice[0].push_back('c');
		memset(memo, -1, sizeof(memo));
		int res = bfs(sx, sy, dice[0]);
		if( res == -1 )
			cout << "unreachable" << endl;
		else
			cout << res << endl;
	}
}

Measured memory_bytes: 2404
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  string s;
  cin >> s;
  i64 k = s.size();
  i64 cnt = 0;
  for (char c : s) if (c == 'o') ++cnt;
  if (15 - k + cnt >= 8) cout << "YES";
  else cout << "NO";
  cout << '\n';
  return 0;
}


Measured memory_bytes: 256
c = []
for _ in range(3):
    c.append([int(x) for x in input().split()])
ans = 'Yes'
for i in range(3):
    minv = min(c[i])
    for j in range(3):
        c[i][j] = c[i][j] - minv

for k in range(3):
    if c[0][k] == c[1][k] and c[0][k] == c[2][k]:
        pass
    else:
        ans = 'No'
print(ans)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define nl '\n'
#define precision(n) setprecision(n)
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

int MAX_LEN = 26;

int main() { _
    string s; cin >> s;
    int n = (int)s.length();
    char ch = 'a';
    set<char> seen;
    
    forn(i, 0, n) {
        seen.insert(s[i]);
        while(seen.count(ch)) {
            ch++;
        }
    }
    
    if (n < 26) {
        cout << s << ch <<nl;
    } else {
//        int index = -1;
        seen.erase(s[n - 1]);
        for (int i = n - 2; i > -1; i--) {
            char cur = s[i];
            while (seen.count(cur)) {
                cur++;
            }
            if (cur <= 'z') {
                s[i] = cur;
                cout << s.substr(0, i + 1) << nl;
                return 0;
            } else {
                seen.erase(s[i]);
            }
        }
        cout << -1 << nl;
//        if (index == -1 && s[0] == 'z') {
//            cout << "-1" << nl;
//            return 0;
//        } else {
//            if (index == -1) index = 0;
//            char last = s[index];
//            while(seen.count(last)) {
//                last++;
//                if (last > 'z') {
//                    seen.insert(s[index]);
//                    index++;
//                    last = s[index];
//                }
//            }
//            s[index] = last;
//            s = s.substr(0, index + 1);
//            cout << s << nl;
//        }
    }
    return 0;
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    long double l;  cin >> l;
    long double a = l/(long double)3.0;
    cout << a*a*a << endl;

}

Measured memory_bytes: 256
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        int INF = 1<<27;

        while(true){
            int n = sc.nextInt(), m = sc.nextInt();
            if(n==0 && m==0) break;

            int[][] riku = new int[n][n];
            int[][] umi = new int[n][n];
            for(int i=0; i<n; i++){
                Arrays.fill(riku[i], INF);
                Arrays.fill(umi[i], INF);
            }


            for(int i=0; i<m; i++){
                int x = sc.nextInt()-1, y = sc.nextInt()-1;
                int t = sc.nextInt(); String s = sc.next();
                if(s.equals("L")){
                    riku[x][y] = Math.min(riku[x][y], t);
                    riku[y][x] = Math.min(riku[y][x], t);
                }else{
                    umi[x][y] = Math.min(umi[x][y], t);
                    umi[y][x] = Math.min(umi[y][x], t);
                }
            }

            for(int i=0; i<n; i++){
                riku[i][i] = 0;
                umi[i][i] = 0;
            }

            int r = sc.nextInt();
            int[] z = new int[r];
            for(int i=0; i<r; i++) z[i] = sc.nextInt()-1;

            for(int k=0; k<n; k++){
                for(int i=0; i<n; i++){
                    for(int j=0; j<n; j++){
                        riku[i][j] = Math.min(riku[i][j], riku[i][k] + riku[k][j]);
                        umi[i][j] = Math.min(umi[i][j], umi[i][k] + umi[k][j]);
                    }
                }
            }

            int[][] dp = new int[r][n];
            for(int i=0; i<r; i++) Arrays.fill(dp[i], INF);
            dp[0][z[0]] = 0;

            for(int k=0; k<r-1; k++){
                for(int i=0; i<n; i++){
                    if(dp[k][i]==INF) continue;
                    for(int j=0; j<n; j++){
                        dp[k+1][j] = Math.min(dp[k+1][j], 
                                              dp[k][i] + riku[z[k]][i] + umi[i][j] + riku[j][z[k+1]]);
                    }
                    dp[k+1][i] = Math.min(dp[k+1][i], dp[k][i] + riku[z[k]][z[k+1]]);
                }
            }

            int min = INF;
            for(int i=0; i<n; i++) min = Math.min(min, dp[r-1][i]);
            System.out.println(min);
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 62004
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int mod = 998244353;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}
const int N = 1e2+5;

int32_t main(){
   
   speed_cubing
   
   int n,m,k;
   cin>>n>>m>>k;

   int a[n],b[m];

   for(int i=0;i<n;i++)
      cin>>a[i];

   for(int i=0;i<m;i++)
      cin>>b[i];

   int dp1[n],dp2[m];

   dp1[0] = a[0],dp2[0] = b[0];

   int ans = 0;

   for(int i=1;i<n;i++){
      dp1[i] = dp1[i-1]+a[i];
   }

   for(int i=1;i<m;i++){
      dp2[i] = dp2[i-1]+b[i];
   }

   for(int i=0;i<n;i++){
      int temp = k-dp1[i];
      if(temp<0)
        break;
      int ind = upper_bound(dp2,dp2+m,temp)-dp2;
      ans = max(ans,ind+i+1);   
   }

    for(int i=0;i<m;i++){
      int temp = k-dp2[i];
      if(temp<0)
        break;
      int ind = upper_bound(dp1,dp1+n,temp)-dp1;
      ans = max(ans,ind+i+1);   
   }

   cout<<ans;
    
   return 0;
}

Measured memory_bytes: 9864
import java.util.Scanner

fun main(args:Array<String>){

    val cin = Scanner(System.`in`)

    while(true){
        var str = cin.next()
	    if(str == "-") break

	    val m = cin.nextInt()
	    var temp = str

	    for(i in 1..m){
	        var index = cin.nextInt()
	        temp = str.substring(index,str.length)
	        temp += str.substring(0,index)
	        str = temp
	    }
        println(temp)
    }
}
    



Measured memory_bytes: 25440
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<int(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
constexpr int64_t INF = INT64_C(1000000000000000000);

int main() {
  int n,m,l;
  cin>>n>>m>>l;
  vector<int> vk(n);
  REP(i,n) cin>>vk[i];
  vector<int64_t> vs(m);
  REP(i,m) cin>>vs[i];
  vector<int64_t> pss(m+1);
  partial_sum(ALL(vs), begin(pss)+1);
  sort(ALL(vk));
  vector<vector<int64_t>> dp(n, vector<int64_t>(n, INF));
  dp[0][0] = 0;
  REP(i,n-1) {
    REP(j,max(1,i)) {
      dp[i+1][j] = min(dp[i+1][j], dp[i][j] + (pss[vk[i+1]] - pss[vk[i]-1])/l);
      dp[i+1][i] = min(dp[i+1][i], dp[i][j] + (pss[vk[i+1]] - pss[vk[j]-1])/l);
    }
  }
  int64_t res = INF;
  REP(i,n-1) {
    res = min(res, dp[n-1][i] + (pss[vk[n-1]] - pss[vk[i]-1])/l);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 35876
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void func(vl &v,vl f){
    rep(i,v.size()){
        v[i]=f[v[i]];
    }
}
int main(){
    ll n,k;cin >> n >>k;
    vl f(n);rep(i,n){
        cin >> f[i];f[i]--;
    }
    vl ans(n);rep(i,n)ans[i]=i;
    rep(i,63){
        if(k&(1LL<<i)){
            func(ans,f);
        }
        func(f,f);
    }
    cout << ans[0]+1 <<endl;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

template< typename T >
struct Combination {
	vector< T > fc, ifc;
	T MOD;
	int sz;

	Combination(T MOD, T sz) : fc(sz + 1), ifc(sz + 1), MOD(MOD), sz(sz) {}

	void init() {
		fc[0] = 1;
		for (int i = 1; i <= sz; i++) fc[i] = fc[i - 1] * i % MOD;
		ifc[sz] = inv(fc[sz]);
		for (int i = sz - 1; i >= 0; i--) ifc[i] = ifc[i + 1] * (i + 1) % MOD;
	}

	// 階乗
	T fact(int n) {
		return fc[n];
	}
	// 階乗の逆元
	T inv_fact(int n) {
		return ifc[n];
	}
	//逆元
	T inv(int n) {
		return pow(n, MOD - 2);
	}
	// 冪乗
	T pow(T n, int a) {
		T res = 1;
		while (a > 0) {
			if (a & 1) (res *= n) %= MOD;
			(n *= n) %= MOD;
			a >>= 1;
		}
		return res;
	}
	// 順列
	T perm(T n, T r) {
		if (r < 0 || n < r) return 0;
		return fc[n] * ifc[n - r] % MOD;
	}
	// 組み合わせ
	T comb(T n, T r) {
		if (r < 0 || n < r) return 0;
		return fc[n] * ifc[r] % MOD * ifc[n - r] % MOD;
	}
	// 重複組み合わせ
	T homo(T n, T r) {
		if (n < 0 || r < 0) return 0;
		return r == 0 ? 1 : comb(n + r - 1, r);
	}
};

int n;
ll a, b, k;
ll ans;
const int MOD = 998244353;

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

    Combination< ll > C = Combination< ll >(MOD, 300010);
    C.init();

    cin >> n >> a >> b >> k;
    REP(A, k / a + 1) {
        ll rest = k - A * a;
        if (rest < 0) continue;
        if (rest % b != 0) continue;
        int B = rest / b;
        if (A * a + B * b != k) continue;
        (ans += C.comb(n, A) * C.comb(n, B) % MOD) %= MOD;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
    int n;
    cin>>n;
    int vec[n];
    for(int i=0;i<n;i++){
        cin>>vec[i];
    }
    int cnt=0;
    while(1){
        int even=1;
        for(int i=0;i<n;i++){
            if(vec[i]%2==0){
                continue;
            }else{
                even=0;
                break;
            }
        }
        if(even==0) break;
        else if(even==1){
            cnt++;
            for(int i=0;i<n;i++){
                vec[i]/=2;
            }
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define VMAX 10001

int main(void){
    unsigned short *A, *B;
    int n, i;
    int C[VMAX];
    
    scanf("%d", &n);
    A = malloc(sizeof(int) * n + 1);
    B = malloc(sizeof(int) * n + 1);

    for (i = 0; i < VMAX; i++){
        C[i] = 0;
    }

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

    for (i = 0; i < n; i++){
        // printf("%d  ", C[i]);
        // printf("%d ", *A);
        // A++;
    }
    

    for (i = 1; i < VMAX + 1; i++){
        C[i] = C[i - 1] + C[i];
    }

    // check
    // for (i = 0; i < 10; i++){
    //     printf("%d  ", C[i]);
    // }
    // putchar('\n');

    for (i = n - 1; i >= 0; i--){
        
        B[C[A[i]] - 1] = A[i];
        C[A[i]]--;
    }

    for (i = 0; i < n - 1; i++){
        printf("%d ", B[i]);
    }
    printf("%d\n", B[n - 1]);
    
    return 0;

}

/*
7 
2 5 1 3 2 3 0
*/


Measured memory_bytes: 9608
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define vp  vector<pii>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ls l,mid,rt<<1
#define rs mid+1,r,rt<<1|1
#define de(x) cout<< #x<<" = "<<x<<endl
#define dd(x) cout<< #x<<" = "<<x<<" "
#define sf scanf
#define pf printf
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef unsigned long long ull;
//typedef __int128 INT128;
//INT128 read(){
//    INT128 x=0,f=1;
//    char ch=getchar();
//    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
//    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
//    return x*f;
//}
//void write(INT128 x){
//    if(x<0){putchar('-');x=-x;}
//    if(x<10){putchar(x+'0'); return;}
//    write(x/10);putchar(x%10+'0');
//}
typedef long double ld;
const int INF=0x3f3f3f3f;
const double eps=1e-8;
const double PI=acos(-1.0);
const int MAXN=1e5+5;
const int MAXM=2e6+5;
const int MOD=1e9+7;
int sgn(double x){if(fabs(x)<eps)return 0;if(x<0)return -1;else return 1;}
ll pw(ll a,ll n,ll mod){ll ret=1;while(n){if(n&1)ret=ret*a%mod;a=a*a%mod;n>>=1;}return ret;}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
void inc(ll &a,ll b){a+=b;if(a>=MOD)a-=MOD;}
void dec(ll &a,ll b){a-=b;if(a<0)a+=MOD;}
int mul(int x, int y){ll z=1ll*x*y;return z-z/MOD*MOD;}
//head

const int sed=13331;
int n; char s[50];
map<pii,int>hs;
void add(int x){
    int t1=0,t2=0;
    rep(i,0,n)if(x&(1<<i))t1=t1*sed+(s[n+i]-'a'+1);
    per(i,0,n)if(!(x&(1<<i)))t2=t2*sed+(s[n+i]-'a'+1);
    //pf("%d %d\n",t1,t2);
    hs[mp(t2,t1)]++;
}
int gao(int x){
    int t1=0,t2=0;
    rep(i,0,n)if(x&(1<<i))t1=t1*sed+(s[i]-'a'+1);
    per(i,0,n)if(!(x&(1<<i)))t2=t2*sed+(s[i]-'a'+1);
    //pf("x=%d %d %d\n",x,t1,t2);
    return hs[mp(t1,t2)];
}
int main(){
    sf("%d%s",&n,s);
    rep(i,0,(1<<n))add(i);
    ll ans=0;
    rep(i,0,(1<<n))ans+=gao(i);
    pf("%lld\n",ans);
}


Measured memory_bytes: 33024
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], n, m, k;

void solve()
{
     cin >> n >> k;
     for (int i = 0; i < k; i++)
     {
          int x; cin >> x;
          m += x;
     }
     if (m >= n)
          cout << "Yes";
     else
          cout << "No";

}

int32_t main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

Measured memory_bytes: 256
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    V = LI()
    C = LI()

    res = 0
    for v, c in zip(V, C):
        if v - c > 0:
            res += v - c

    return res


print(main())


Measured memory_bytes: 3064
#include <iostream>
#include <string.h>
using namespace std;

int main() {
  int a,b,c;
  cin >> a;
  cin >> b;
  int sum = 0; 
  for (int i=0; i < a; i++){
      cin >> c;
      if(c <= b - c) sum += 2*c;
      else sum += 2*(b - c);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll t;
ll va[100005];

int main(void){
	scanf("%lld",&t);
	ll val=1;
	ll ans=t;
	ll tt=t;
	va[0]=1;
	for(int i=1;i<40;i++){
		va[i]=va[i-1]*3LL;
	}
	for(int i=0;i<40;i++){
		ll rec=i*2;
		ll sum=0;
		for(int j=0;j<i;j++){
			sum+=va[j]*2LL;
			if(sum>t)break;
		}
		sum+=va[i];
		sum--;
		//printf("%lld\n",sum);
		if(sum>t)continue;
		ll rest=t-sum;
		for(int j=i;j>=0;j--){
			while(rec<1000 && rest>=va[j]){
				rest-=va[j];
				rec++;
			}
		}
		if(rest==0){
			ans=min(ans,rec);
		}
	}
	printf("%lld\n",ans);
	return 0;
}



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

//ll gcd ( ll a, ll b ) {
//    if ( b == 0 ) return 0;
//    if ( a % b == 0 ) return b;
//    return gcd( b, a % b );
//}
//
//ll lcm ( ll a, ll b ) {
//    return a / gcd(a, b) * b ;
//}

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
//    sort(a.begin(), a.end());
//    ll lcm_num;
//    rep(i, n-1) {
//        if ( i == 0 ) lcm_num = lcm(a[i], a[i+1]);
//        else          lcm_num = lcm(lcm_num, a[i+1]);
//    }
    ll ans = 0;
//    rep(i, n) {
//        ans += ( lcm_num - 1LL ) % a[i];
//    }
    rep(i, n) {
        ans += a[i] - 1LL;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef pair<int,int> pii;

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

const int N = 1e5 + 9, M = 1e5, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

ll n, k;

ll power(ll b, ll p){
    if(p == 0)return 1;
    ll res = power(b,p/2);
    res *= res;
    res %= modulo;
    if(p & 1)res *= b;
    return res % modulo;
}

inline void fixMod(ll &x){
    x = ((x % modulo) + modulo) % modulo;
}

ll cnt[N] = {};

int main(){
    init();

    n = 3;

    cin >> k;

    ll ans = 0;
    for(int i = k;i >= 1;i--){
        ll mults = (k / i);
        ll localAns = power(mults, n);
        ll exclude = 0;
        for(int j = 2;j * i <= k;j++){
            exclude += cnt[i * j];  exclude %= modulo;
        }

        localAns -= exclude;    fixMod(localAns);
        cnt[i] = localAns;
        ans += localAns * i;    fixMod(ans);
    }

    cout << ans;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
	}

	void solve() {
		int N;
		cin >> N;

		int a = 0;
		for( int i = 1; i <= N; ++i ) {
			int x = i * (i+1) / 2;
			if( x >= N ) {
				a = i;
				break;
			}
		}

		for( int i = 1; i <= a; ++i ) {
			int x = a * (a+1) / 2;
			if( i != x-N ) {
				cout << i << '\n';
			}
		}
	}
};

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


Measured memory_bytes: 256
import numpy as np
N=int(input())
h=list(map(int,input().split()))
dp=[0]*N
for i in range(1,N):
    dp[i]=dp[i-1]+np.abs(h[i]-h[i-1])
    if (i>=2):
        dp[i]=min(dp[i],dp[i-2]+np.abs(h[i]-h[i-2]))
print(dp[i])

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

using namespace std;

int main(void)
{
	int a, b, c, d;

	while(scanf("%d%d%d%d", &a, &b, &c, &d)==4)
	{
		a=max(a, c);
		b=min(b, d);
		printf("%d\n", max(b-a, 0));
	}

	return 0;
}


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

class Program
{
    static void Main()
    {
        string[] arr = Console.ReadLine().Split();
        int A, B;
        A = int.Parse(arr[0]);
        B = int.Parse(arr[1]);
        Console.WriteLine(Math.Max(A + B, Math.Max(A - B, A * B)));
        return;
    }
}

Measured memory_bytes: 27408
n=int(input())
a=list(map(int, input().split()))

def insertion(a:list, n:int) -> None:
    if not isinstance(a, list):
        return None

    for i in range(n):
        v=a[i]
        j=i-1
        while j >= 0 and a[j] > v:
            a[j+1]=a[j]
            j-=1
        a[j+1]=v

        print(" ".join(map(str, a)))

insertion(a, n)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

pair<ll, ll> arr[N];

bool comp(pair<ll, ll> &a, pair<ll, ll> &b) { return a.second < b.second; }
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;

  for (ll i = 1; i <= n; i++)
    cin >> arr[i].first >> arr[i].second;

  sort(arr + 1, arr + n + 1, comp);

  ll flag = 0;
  ll curr = 0;
  for (ll i = 1; i <= n; i++) {
    curr += arr[i].first;
    if (curr > arr[i].second)
      flag = 1;
  }

  cout << ((flag == 1) ? "No" : "Yes") << en;
  return 0;
}

Measured memory_bytes: 3456
package main

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

func main() {
	var s string
	ans := 700
	fmt.Scan(&s)
	cols := strings.Split(s, "")
	for _, c := range cols {
		if c == "o" {
			ans += 100
		}
	}
	fmt.Printf(strconv.Itoa(ans))
}


Measured memory_bytes: 640