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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

const long double eps = 1.0e-6; // 許容される誤差

long double mysqrtl(long double x) {
    long double a = sqrt((double) x); // 近似値
    do {
        a = (a + x / a) / 2.0L;
    } while (fabsl(x - a * a) > eps);
    return a;
}

void solve() {
    long double a, b, c;
    cin >> a >> b >> c;
    if (a / 2 + b / 2 + mysqrtl(a) * mysqrtl(b) < c / 2) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


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

string t;

int main() {
    cin >> t;

    for (int i = 0; i < t.size(); i++) {
        if (t[i] == '?') {
            t[i] = 'D';
        }
    }

    cout << t << endl;
    
    return 0;
}


Measured memory_bytes: 3748
def main():
  N, M = map(int, input().split())
  
  correct = [0] * N
  penalty = [0] * N
  pena = 0
  
  for _ in range(M):
    pi, si = input().split()
    pi = int(pi)
    
    if si == 'WA' and correct[pi-1] == 0:
      penalty[pi-1] += 1
    elif si =='AC' and correct[pi-1] == 0:
      correct[pi-1] = True
      pena += penalty[pi-1]

  print(sum(correct), pena)       

main()


Measured memory_bytes: 4596
N, M = map(int, input().split())
mod = 10 ** 9 + 7


def prime_factorization(n):  # 素因数分解
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            cnt = 0
            while n % i == 0:
                cnt += 1
                n //= i
            res.append((i, cnt))
    if n > 1:
        res.append((n, 1))
    return res


def binomial_coefficient(n, r, mod=10**9+7):
    """
    二項係数nCr, (n,r)をmodで除したあまりを返す
    """
    res = 1
    div = 1
    r = min(r, n - r)
    for i in range(r):
        res *= (n - i) % mod
        div *= (i + 1) % mod
    res *= pow(div, mod - 2, mod)
    return res % mod


pf = prime_factorization(M)
ans = 1
for _, x in pf:
    ans = (ans * binomial_coefficient(N+x-1, x, mod)) % mod
print(ans)


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

int main(){
      int n;cin >> n;
      int t;cin >> t;
      int arr[n + 10];
      for(int i = 0;i < n;i++)cin >> arr[i];
      int curr = 0;
      int ans = 0;
      while(curr <= t){
            ans++;
            curr += arr[ans - 1];
      }
      cout << ans;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
import math
ng=0
ok=max(a)
center=(ok+ng)//2
while ng+1!=ok:
  counter=0
  for i in range(len(a)):
    counter+=math.ceil(a[i]/center)-1
  if counter>k:
    ng=center
    center=(ok+ng)//2
  else:
    ok=center
    center=(ok+ng)//2
print(ok)    
    
  



Measured memory_bytes: 30776
#include <iostream>
#include <string>
#include <limits>

using namespace std;

int main()
{
	string input;
	cin >> input;

	auto position = input.find("YAKI");
	if(numeric_limits<size_t>::max() == position || position != 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


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

int N;
LL A[81];

int main() {
 cin>>N;
 rep(i,N) cin>>A[i];
 LL P=1000;
 rep(i,N-1){
  if(A[i+1]<=A[i]) continue;
  P = P + P/A[i]*(A[i+1]-A[i]);
 }
 cout<<P<<endl;
}



Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
typedef pair<long long, long long> P;
int main() {
	string S, T; cin >> S >> T;
	long long ans = 0;
	for (long long i = 0; i < S.size(); i++) {
		if (S.at(i) == T.at(i)) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++) cin >> s.at(i);
	int m;
	cin >> m;
	vector<string> t(m);
	for (int i = 0; i < m; i++) cin >> t.at(i);

	map<string, int> num;
	for (int i = 0; i < n; i++) num[s.at(i)]++;
	for (int i = 0; i < m; i++) num[t.at(i)]--;

	int ans = 0;
	for (auto i = num.begin(); i != num.end(); i++) {
		ans = max(i->second, ans);
	}

	if (ans >= 0) cout << ans << endl;
	else cout << 0 << endl;

 	return 0;
 }

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T="keyence"; cin >> S;
    int N=S.size();
    for (int i=0;i+6<N;++i){
        if (S.substr(i,7)==T){
            cout << "YES" << '\n';
            return 0;
        }
    }
    for (int i=1;i<7;++i){
        int ok=1;
        for (int j=0;j<7;++j){
            if (j<i&&S[j]!=T[j]) ok=0;
            if (i<=j&&S[N-7+j]!=T[j]) ok=0;
        }
        if (ok){cout << "YES" << '\n'; return 0;}
    }
    cout << "NO" << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,cnt=0,aa[220000],ans=0,ab[220];
pair<int,int> pp[220000];
string s,ss[220000];
char c;
queue<int> que;
signed main(){
    cin>>s>>ss[0];
    if(s==ss[0]){
        cout<<"EQUAL"<<endl;
    }elif(s.size()>ss[0].size()){
        cout<<"GREATER"<<endl;
    }elif(s.size()<ss[0].size()){
        cout<<"LESS"<<endl;
    }else{
        rep(i,s.size()){
            if(s[i]>ss[0][i]){
                cout<<"GREATER"<<endl;
                return 0;
            }elif(s[i]<ss[0][i]){
                cout<<"LESS"<<endl;
                return 0;
            }
        }
        cout<<"EQUAL"<<endl;
    }
}

Measured memory_bytes: 10424
package main

import (
	"fmt"
	"math"
)

var A, B, C, D uint64

func main() {
	fmt.Scan(&A, &B, &C, &D)
	x1 := (A - 1) / C
	y1 := B / C
	a := y1 - x1

	x2 := (A - 1) / D
	y2 := B / D
	b := y2 - x2

	x3 := (A - 1) / (C * D / gcd(C, D))
	y3 := B / (C * D / gcd(C, D))
	c := y3 - x3

	fmt.Println(B - A - (a + b - c) + 1)
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy []XY

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i].x == a[j].x {
		return a[i].y > a[j].y
	}
	return a[i].x > a[j].x
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n))
typedef bitset<16> MASK;

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}
vector<vector<int>>submasks(1<<16);
ll gVal[1<<16];
ll arr[17][17],dp[1<<16];
ll ans(MASK m){
    if(!m.count())return 0;
    ll &ret=dp[m.to_ulong()];
    if(~ret)return ret;
    ret=-1e15;
    for (int i = 0; i < submasks[m.to_ulong()].size(); ++i) {
        MASK t=submasks[m.to_ulong()][i];
        ll val=gVal[t.to_ulong()];
        t.flip();
        t&=m;
        ret=max(ret,val+ans(t));
    }
    return ret;
}
int main() {
    fast();
    for (int i = 0; i <(1<<16) ; ++i)for(int s=i;s;s=(s-1)&i)submasks[i].push_back(s);
    int n;cin>>n;
    for (int j = 0; j <n ; ++j) {
        for (int i = 0; i <n ; ++i) {
            cin>>arr[j][i];
        }
    }
    for (int k = 0; k <submasks[(1<<16)-1].size() ; ++k) {
        MASK m=submasks[(1<<16)-1][k];
        for (int i = 0; i <16 ; ++i) {
                for (int j = i+1; j <16; ++j)
                    if(m[i]&&m[j])
                    gVal[m.to_ulong()]+=arr[i][j];
        }
    }
    clr(dp,-1);
    MASK m;m.flip();
    cout<<ans(m);



}


Measured memory_bytes: 174076
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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;}

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    ll n,k;
    cin>>n>>k;
    ll count=1;
    while(llpow(k,count)<=n){
        count++;
    }
    cout<<count<<endl;
    return 0;
}




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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = a; i < (b); ++i)
#define REV(i, a, b) for (int i = a; i > (b); --i)
#define debug(a) cerr << #a << " " << a << endl
#define debug2(a, b) cerr << #a << " " << a << ", " << #b << " " << b << endl

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

void Main() {
  double pi = 6.28318530;
  int r; cin >> r;
  cout << double(r)*pi << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 3804
object Main{
  def main(args: Array[String]){
    val in = new java.util.Scanner(System.in)

    var list = List[Int]()
    for(i <- 0 to 9){
      list = in.nextInt :: list
    }

    list = list.sorted.reverse
    println(list(0)+"\n"+list(1)+"\n"+list(2))

  }
}

Measured memory_bytes: 42044
# -*- coding: utf-8 -*-
# Small, Large, or Equal
#	Write a program which prints small/large/equal relation of given two integers a and b.
#
# Input
#	Two integers a and b separated by a single space are given in a line.
#
# Output
#	For given two integers a and b, print
#
#	a < b
#	if a is less than b,
#
#	a > b
#	if a is greater than b, and
#
#	a == b
#	if a equals to b.
#
# Constraints
#	-1000 ≤ a, b ≤ 1000
# Sample Input 1
#	1 2
# Sample Output 1
#	a < b
# Sample Input 2
#	4 3
# Sample Output 2
#	a > b
# Sample Input 3
#	5 5
# Sample Output 3
#	a == b

a, b = (int(x) for x in input().split())

if a == b:
    print('a == b')
else:
    if a < b:
        print('a < b')
    else:
        print('a > b')



Measured memory_bytes: 5604
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); ++i)
  {
    if (i % 2 == 0 && s[i] != 'R' && s[i] != 'U' && s[i] != 'D')
    {
      cout << "No";
      return 0;
    }
    else if (i % 2 != 0 && s[i] != 'L' && s[i] != 'U' && s[i] != 'D')
    {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  string s; cin >> s;
  string out;
if (s=="ARC") out = "ABC";
else out="ARC";
 cout << out << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
#define Mod 1000000007
   ll gcdExtended(ll a, ll b, ll *x, ll *y) 
     { 
         // Base Case 
         if (a == 0) 
         { 
             *x = 0, *y = 1; 
             return b; 
         } 
   
         ll x1, y1; // To store results of recursive call 
         ll gcd = gcdExtended(b%a, a, &x1, &y1); 
   
   
         *x = y1 - (b/a) * x1; 
         *y = x1; 
   
         return gcd; 
     } 
 ll modInverse(ll a, ll m) 
     { 
         ll x, y; 
         ll g = gcdExtended(a, m, &x, &y); 
   
        ll res = (x%m + m) % m; 
         return res; 
     } 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll sum = 0;
    ll i, j, k, l, n, m;
    string s;
    cin >> n;
    cin >> s;
    ll sz = s.size();
    ll gun1 =1 ;
    for (i = 1; i <= n;i++){
        gun1 = (gun1 * 26) % Mod;
    }
    ll gun2 = 1;
    ll temp1 = 1;
    ll temp2 = 1;
    ll ini = sz;
    ll fina = 1;
    for (i = 0; i <= n;i++){
        ll kola = (temp1 * modInverse(temp2, Mod))%Mod;
        kola = (kola * gun1) % Mod;
        kola = (kola * gun2) % Mod;
        sum = (sum + kola) % Mod;
        gun2 = (gun2 * 25) % Mod;
        gun1 = (gun1 * modInverse(26, Mod))%Mod;
        temp1 = (temp1 * ini) % Mod;
        temp2 = (temp2 * fina) % Mod;
        ini++;
        fina++;
    }
    cout << sum << "\n";
    return 0;
}

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

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int c, t;
    int ans = 0;
    
    for (int i = 1; i <= n; i++) {
        c = i;
        t = 0;
        
        while(c) {
            t += c % 10;
            c /= 10;
        }
        
        if ((t >= a) && (t <= b)) {
            ans += i;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys
import math

#n = map(int,input().split())

k = int(input())


def gcd(a,b):
    if a > b:
        a , b = b , a

    # q = b / a
    r = b % a

    if r == 0:
        return a
    else:
        return gcd(a,r)
    

sum = 0



for i in range(1,k+1):
    for j in range(1,k+1):
        x = math.gcd(i,j)
        for l in range(1,k+1):
            sum += math.gcd( x, l)

print(sum)

Measured memory_bytes: 27156
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

template <typename T>
struct SegmentTree {
private:
	size_t n;
	vector<T> node;
	T M0;

public:
	SegmentTree(const vector<T>& v, T m0) {
		M0 = m0;
		n = 1;
		while (n < v.size()) { n *= 2; }
		node.assign(2*n - 1, M0);

		for (int i = 0; i < v.size(); ++i) {
			node[n - 1 + i] = v[i];
		}
		for (int i = n - 2; i >= 0; --i) {
			node[i] = merge(node[2*i + 1], node[2*i + 2]);
		}
	}

	T merge(T a, T b) { return max(a, b); }

	void update(int x, T val) {
		x += (n - 1);
		node[x] = val;
		while (x > 0) {
			x = (x - 1) / 2;
			node[x] = merge(node[2*x + 1], node[2*x + 2]);
		}
	}

	T query(int a, int b, int k=0, int l=0, int r=-1) {
		if (r < 0) { r = n; }
		if ((r <= a) || (b <= l)) { return M0; }
		if ((a <= l) && (r <= b)) { return node[k]; }

		T vl = query(a, b, 2*k + 1, l, (l + r) / 2);
		T vr = query(a, b, 2*k + 2, (l + r) / 2, r);
		return merge(vl, vr);
	}
};

int main() {
	int N, Q;
	cin >> N >> Q;
	vector<int> A(N), T(Q), x(Q), y(Q);
	for (int i = 0; i < N; ++i) { cin >> A[i]; }
	for (int i = 0; i < Q; ++i) {
		cin >> T[i] >> x[i] >> y[i];
	}

	SegmentTree<int> seg(A, 0);
	vector<int> ans;
	for (int i = 0; i < Q; ++i) {
		if (T[i] == 1) {
			seg.update(x[i] - 1, y[i]);
		}
		if (T[i] == 2) {
			ans.push_back(seg.query(x[i] - 1, y[i]));
		}
		if (T[i] == 3) {
			int l = x[i] - 1, r = N;
			if (seg.query(l, N) < y[i]) {
				ans.push_back(N + 1);
				continue;
			}

			while (r - l > 1) {
				int m = (r + l) / 2;
				(seg.query(l, m) < y[i] ? l : r) = m;
			}
			ans.push_back(l + 1);
		}
	}
	for (auto v : ans) { cout << v << "\n"; }

	return 0;
}


Measured memory_bytes: 9504
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

char s[110];
int main() {
	scanf("%s", s);
	bool r = true;
	for (int i = 0; s[i] != 0; i++)
		if ((i % 2 == 0 && s[i] == 'L') || (i % 2 == 1 && s[i] == 'R'))
			r = false;
	printf(r ? "Yes\n" : "No\n");
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	string ans;
	cout << "? 1" << string(9, '0') << endl;
	cin >> ans;
	if (ans == "Y") {
		for (int i = 9; i > 0; i--) {
			cout << "? " << string(i, '9') << endl;
			cin >> ans;
			if (ans == "N") {
				cout << "! 1" << string(i, '0') << endl;
				return 0;
			}
		}
		cout << "! 1" << endl;
	}
	else {
		int d;
		for (d = 8; d > 0; d--) {
			cout << "? 1" << string(d, '0') << endl;
			cin >> ans;
			if (ans == "Y") break;
		}
		string now = "";
		for (int i = d; i >= 0; i--) {
			int l = 0, r = 10;
			while (r - l > 1) {
				int m = (l + r) / 2;
				cout << "? " << now << string(1, '0' + m) << string(9, '0') << endl;
				cin >> ans;
				if (ans == "Y") {
					cout << "? " << now << string(1, '0' + (m - 1)) << string(9, '9') << endl;
					cin >> ans;
					if (ans == "N") {
						cout << "! " << now << string(1, '0' + m) + string(i, '0') << endl;
						return 0;
					}
					r = m;
				}
				else l = m;
			}
			now += string(1, '0' + l);
		}
		cout << "! " << now << endl;
	}
}

Measured memory_bytes: 596
#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 MP make_pair
#define PB push_back

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

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

int main(){
	int n=read(),last=0;
	ll ans=0;
	REP(i,n){
		int k=read();
		if(last&&k){
			last--;
			k--;
			ans++;
		}
		ans+=k/2;
		last=k%2;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cassert>

template <class Monoid, template <class> class Container> class segment_tree {
public:
	using value_structure = Monoid;
	using value_type = typename value_structure::value_type;
	using container_type = Container<value_type>;
	using const_reference = typename container_type::const_reference;
	using size_type = typename container_type::size_type;

private:
	size_type sequence_size, base_size;
	container_type c;
	static size_type getsize(const size_type size) {
		size_type ret = 1;
		while (ret < size)
			ret <<= 1;
		return ret;
	}
	void recalc(const size_type index) {
		c[index] = value_structure::operation(c[index << 1], c[index << 1 | 1]);
	}

public:
	segment_tree() : base_size(0), c() {}
	explicit segment_tree(const size_type size)
		: sequence_size(size), base_size(getsize(size)),
		c(base_size + size + (size & 1), value_structure::identity()) {}

	bool empty() const { return !sequence_size; }
	size_type size() const { return sequence_size; }

	const_reference operator[](const size_type index) const {
		assert(index < size());
		return c[index + base_size];
	}
	value_type fold(size_type first, size_type last) const {
		assert(first <= last);
		assert(first <= size());
		assert(last <= size());
		value_type ret_l = value_structure::identity(),
			ret_r = value_structure::identity();
		for (first += base_size, last += base_size; first < last;
			first >>= 1, last >>= 1) {
			if (first & 1)
				ret_l = value_structure::operation(ret_l, c[first++]);
			if (last & 1)
				ret_r = value_structure::operation(c[last - 1], ret_r);
		}
		return value_structure::operation(ret_l, ret_r);
	}
	template <class F> size_type search(const F &f) const {
		if (f(value_structure::identity()))
			return 0;
		if (!f(c[1]))
			return size() + 1;
		value_type acc = value_structure::identity();
		size_type i = 1;
		while (i < base_size)
			if (!f(value_structure::operation(acc, c[i <<= 1])))
				acc = value_structure::operation(acc, c[i++]);
		return i - base_size + 1;
	}

	template <class F> void update(size_type index, const F &f) {
		assert(index < size());
		index += base_size;
		c[index] = f(c[index]);
		while (index >>= 1)
			recalc(index);
	}
};

#include <algorithm>
#include <limits>
template <class T> class min_monoid {
public:
	using value_type = T;
	static value_type operation(const value_type &x, const value_type &y) {
		return ::std::min(x, y);
	}
	static value_type identity() {
		return 2147483647;
	}
	static value_type reverse(const value_type &x) { return x; }
};

#include <iostream>
#include <vector>

template<class T> using vec_alias = ::std::vector<T>;

int main() {
	int n, q;
	::std::cin >> n >> q;

	segment_tree<min_monoid<int>, vec_alias> seg(n);

	while (q--) {
		int c, x, y;
		::std::cin >> c >> x >> y;

		if (c)
			::std::cout << seg.fold(x, y + 1) << ::std::endl;
		else
			seg.update(x, [y](int) {return y;});
	}

	return 0;
}



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

int main(void){
	string numl;
	cin>>numl;
	if(numl[0]==numl[1]&&numl[1]==numl[2])
		cout<<"Yes"<<endl;
	else if(numl[1]==numl[2]&&numl[2]==numl[3])
		cout<<"Yes"<<endl;
	else if(numl[2]==numl[3]&&numl[3]==numl[4])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let s = input::<String>();

    let mut ans = 0;
    for c in s.chars() {
        if c == '+' {
            ans += 1;
        } else {
            ans -= 1
        }
    }
    println!("{}", ans);
}


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

using namespace std ; 

const int N = 2e5 + 7 ; 

long long n ,m , k ;
long long mod = 998244353; 
long long fac[N] ; 

long long mul(long long a , long long b){
    return 1ll * (a% mod  * b %mod )  % mod; 
}

long long faspow(long long a , long long b) {
    if(!b) return 1 ; 
    long long ret = faspow(a , b/2) ; 
    ret = mul(ret , ret) ;  
    if(b%2) ret = mul(ret , a) ; 
    return ret ; 
}

long long ncr(long long nn , long long rr){
    return mul( fac[nn] , faspow( mul(fac[rr] , fac[nn - rr]) , mod-2) ) ; 
}

long long add (long long a , long long b){
    return (a% mod + b %mod) %mod ; 
}

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

    fac[0] =1 ; 
    for(int i = 1 ;i < N ;i++){
        fac[i] = mul(i , fac[i-1]) ; 
    }
    cin>>n>>m>>k ; 
    long long ans = mul( m , faspow(m-1 , n-1)  ) ; 
    long long vl = ans ; 
    for(int i = 1 ;i <= k ; i++){
        vl = mul(vl, faspow(m-1 , mod-2)) ; 
        ans = add(ans , mul( mul(m , faspow(m-1 , n - 1 - i)) , ncr(n-1 , i) )  ) ; 
    }
    cout<< ans % mod ; 
    return 0 ; 
}


Measured memory_bytes: 5208
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
  ll n,m,k,i,j,result=0;
  int ac=0,tle=0,wa=0,re=0;
  string s;
  cin >> n;
  rep(i,n){
    cin >> s;
    if(s=="AC") ac++;
    else if(s=="TLE") tle++;
    else if(s=="WA") wa++;
    else re++;
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) {
        string s;
        cin >> s;
        int m=s.size();
        rep(j,m) {
            if (s[j]=='.') {
                rep(k,9) {
                    if (j+1+k<m) {
                        a[i]+=ll(s[j+1+k]-'0')*pow(10,8-k);
                    }
                }
                rep(k,j) a[i]+=ll(s[j-1-k]-'0')*pow(10,9+k);
                break;
            } else if (j==m-1) {
                rep(k,j+1) a[i]+=ll(s[j-k]-'0')*pow(10,9+k); 
            }
        }
    }
    ll md=1e9;
    vector<pair<int,int>> p(n);
    vector<vector<ll>> q(50,vector<ll>(50));
    rep(i,n) {
        ll b=a[i];
        int x=0,y=0;
        ll u=md;
        while (b%2==0) {
            b/=2;
            ++x;
        }
        while (b%5==0) {
            b/=5;
            ++y;
        }
        p[i]={x,y};
        ++q[x][y];
    }
    ll ans=0;
    rep(i,50) {
        invrep(j,49) q[i][j]+=q[i][j+1];
    }
    rep(j,50) {
        invrep(i,49) q[i][j]+=q[i+1][j];
    }

    rep(i,n) {
        int x=max(0,18-p[i].first);
        int y=max(0,18-p[i].second);
        ans+=q[x][y];
        if (9<=p[i].first && 9<=p[i].second) --ans;
    }
    ans/=2;
    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 6840
l = list(map(int, input().split()))

flag_5 = flag_7 = 0

for i in l:
    if i == 5:
        flag_5 += 1
    if i == 7:
        flag_7 += 1

if flag_5 == 2 and flag_7 == 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 8964
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;

int main(){
	int N;
	cin>>N;
	
	map<int,int> ma;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		if(ma[a]==1){
			ma.erase(a);
		}
		else{
			ma[a]=1;
		}
	}
	cout<<ma.size()<<endl;
		
	
	return 0;
}

Measured memory_bytes: 4864
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
	int N,C; cin >> N >> C;
	vector<vector<int>> D(C,vector<int>(C)),c(N,vector<int>(N));
	int sum[3][C]; //余りごとにどれかの色に変わるときの違和感を足しておく
	memset(sum,0,sizeof(sum));
	rep(i,C)rep(j,C){
		cin >> D[i][j];
	}

	rep(i,N)rep(j,N){
		cin >> c[i][j];
		c[i][j]--;
		rep(k,C){
			sum[(i+j)%3][k] += D[c[i][j]][k];
			
		}
	}
	int ans = INF;
	rep(i,C)rep(j,C){
		if(i != j){
			rep(k,C){
				if(i != k && j != k){
					int now = sum[0][i] + sum[1][j] + sum[2][k];
					ans = min(ans,now);
				}
			}
		}
	}
	cout << ans << endl;
	
}
   


Measured memory_bytes: 1280
package main

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

var sc = bufio.NewScanner(os.Stdin)

// NextLine reads a line text from stdin, and then returns its string.
func NextLine() string {
	sc.Scan()
	return sc.Text()
}

// NextIntsLine reads a line text, that consists of **ONLY INTEGERS DELIMITED BY SPACES**, from stdin.
// And then returns intergers slice.
func NextIntsLine() []int {
	ints := []int{}
	intsStr := NextLine()
	tmp := strings.Split(intsStr, " ")
	for _, s := range tmp {
		integer, _ := strconv.Atoi(s)
		ints = append(ints, integer)
	}
	return ints
}

// NextRunesLine reads a line text, that consists of **ONLY CHARACTERS ARRANGED CONTINUOUSLY**, from stdin.
// Ant then returns runes slice.
func NextRunesLine() []rune {
	return []rune(NextLine())
}

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// PowInt is integer version of math.Pow
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}
	fa := float64(a)
	fe := float64(e)
	fanswer := math.Pow(fa, fe)
	return int(fanswer)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	fa := float64(a)
	fanswer := math.Abs(fa)
	return int(fanswer)
}

// sort package (snippets)
//sort.Sort(sort.IntSlice(s))
//sort.Sort(sort.Reverse(sort.IntSlice(s)))
//sort.Sort(sort.Float64Slice(s))
//sort.Sort(sort.StringSlice(s))

/*******************************************************************/

var s, t []rune

func main() {
	s = NextRunesLine()
	t = NextRunesLine()
	for i := 0; i < len(s); i++ {
		before := s[len(s)-1-i : len(s)]
		after := s[0 : len(s)-1-i]
		rots := []rune{}
		rots = append(rots, before...)
		rots = append(rots, after...)
		if string(t) == string(rots) {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 768
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

# dp[i][j][k] iまで見た, j個保留, 奇妙さk
dp = [[[0]*(K+N*2+1) for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1

for i in range(N) :
    for j in range(i+1) :
        for k in range(K+1) :
            dp[i+1][j][k+j*2] += dp[i][j][k]
            dp[i+1][j][k+j*2] %= MOD
            dp[i+1][j+1][k+(j+1)*2] += dp[i][j][k]
            dp[i+1][j+1][k+(j+1)*2] %= MOD
            dp[i+1][j][k+j*2] += dp[i][j][k] * j * 2
            dp[i+1][j][k+j*2] %= MOD
            if j >= 1 :
                dp[i+1][j-1][k+(j-1)*2] += dp[i][j][k] * j * j
                dp[i+1][j-1][k+(j-1)*2] %= MOD
                
print(dp[N][0][K])

Measured memory_bytes: 96220
#include<stdio.h>

int main() {
  int i,n;
  long long FBsum = 0,sum = 0;
  scanf("%d",&n);
  for(i = 1;i <= n;i++) {
    sum += i;
    if(i % 3 == 0 || i % 5 == 0) {
      FBsum+=i;
    }
  }

  printf("%lld\n",sum-FBsum);
}


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

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


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

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

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

int main() {
	int n,m;
	cin >> n >> m;
	int cnt=1;
	bool vis[n];
	int a[n];
	for(int i=0;i<n;i++) vis[i]=false;
	for(int i=0;i<n;i++) a[i]=1;
	vis[0]=true;
	int fr,to;
	for(int i=0;i<m;i++)
	{
		cin >> fr>> to;
		fr-=1;to-=1;
		a[fr]-=1;a[to]+=1;
		if(vis[fr]) 
		{
			if(a[fr]==0)
			 {
			   cnt--;
			   vis[fr]=false;
			 }
			if(!vis[to])
			  vis[to]=true, cnt++;
			 
		}
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 768
a,b,c,x = 4.times.map {gets.to_i}
count = 0
(0..a).each do |a|
    (0..b).each do |b|
        (0..c).each do |c|
             count += 1 if a*500 + b*100 + c*50 == x
        end
    end
end

puts count

Measured memory_bytes: 1788
#include <iostream>

using namespace std;

int main() {
    int x, y;
    cin >> x >> y;

    for (int i = 0; i <= x; i++) {
        int tsuru = i * 2;
        int kame = (x - i) * 4;
        if (tsuru + kame == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

bool ok(char c) {
	c = toupper(c);
	if ((c == 'A') || (c == 'C') || (c == 'G') || (c == 'T')) return true;
	return false;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	string s;
	cin >> s;
	int ans = 0;
	int k = 0;
	for (int i = 0; i < s.size(); i++) {
		if (ok(s[i])) k++;
		else {
			ans = max(ans, k);
			k = 0;
		}
	}
	cout << max(ans, k) << ende;
  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

using llong = long long;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) { a += b, a &= MOD; }

int main() {
  // Input
  int a, b, c, d, e;
  int k;
  std::cin >> a >> b >> c >> d >> e >> k;

  // Main
  bool ok = true;
  // if (b - a > k or c - b > k or d - c > k or e - d > k)
  if (e - a > k)
    ok = false;

  // Output
  if (ok)
    std::cout << "Yay!" << std::endl;
  else
    std::cout << ":(" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
#define rank __RAnK
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
#define rd read
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
int cnt1[100005],cnt2[100005],b[100005],c[100005],a[100005];
int n;
bool cmp1(int a,int b){
	return cnt1[a] > cnt1[b];
}
bool cmp2(int a,int b){
	return cnt2[a] > cnt2[b];
}
int check(int a,int b){
	if(a==b) return n+1;
	return n - cnt1[a] - cnt2[b];
}
int main(){
	n = rd();
	Rep(i,1,n) a[i] = rd();
	for(int i=1;i<=n;i+=2){
		cnt1[a[i]]++;
	}
	for(int i=2;i<=n;i+=2){
		cnt2[a[i]]++;
	}
	Rep(i,1,100000){
		b[i] = i;
		c[i] = i;
	}
	sort(b+1,b+1+100000,cmp1);
	sort(c+1,c+1+100000,cmp2);
	int ans = 0x3f3f3f3f;
	ans = min(ans,check(b[1],c[1]));
	ans = min(ans,check(b[2],c[1]));
	ans = min(ans,check(b[1],c[2]));
	ans = min(ans,check(b[2],c[2]));
	writeln(ans);
	return 0;
}


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

int main() {
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	sort(arr,arr+n);
	float avg=(arr[0]+arr[1])/2.0;
	for(int i=2;i<n;i++)
	{
		avg=(avg+arr[i])/2.0;
	}
	cout<<avg;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define tzcnt __builtin_ctzl
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))

using namespace std;
typedef long long ll;
typedef __int128_t lll;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template<typename T>string join(V<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isprime(ll n){if(n<2||n%2==0)return n==2;lll m=n-1,d=m/(m&-m),t,k[]={2,325,9375,28178,450775,9780504,1795265022};for(lll a:k)if(a%n){for(t=d,a=modpow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}
mt19937 rnd; void set_rnd(){random_device r;rnd=mt19937(r());}
V<ll> fact, rfact; void set_fact(int n, ll m){fact.pb(1);rfact.pb(1);FOR(i,1,n+1)fact.pb(fact[i-1]*i%m),rfact.pb(modpow(fact[i],m,m-2));}
const int iinf = 1e9+6;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 1e5;
int a, b;
lll x, y, g, aa, bb;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b;
  g = gcd(a, b, x, y);
  a /= g, b/=g;
  g = y/a;
  x += g*b, y -= g*a;
  if(y<=0) x -= b, y += a;
  lll _x = x+b, _y = y-a;
  if(y-x > _x-_y) x = _x, y = _y;
  cout << ll(x) << " " << ll(y) << endl;
  return 0;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 1010

int mat[maxn][maxn];

void solve() {
    int n, m;
    while (cin >> n >> m and n and m) {

        int mx = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                cin >> mat[i][j];
                if (i != 0)
                    mat[i][j] += mat[i - 1][j];
                if (i == m - 1)
                    mx = max(mx, mat[i][j]);
            }
        }
        cout << mx << endl;
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


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

#define PB push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

const int inf = 1e9;
int D;
vl c, ans;
vvl s;

void init() {
    cin >> D;
    ans.assign(D, 0);
    c.resize(26);
    s.assign(D, vl(26));
    rep(t, 26) cin >> c[t];
    rep(d, D) rep(t, 26) {
        cin >> s[d][t];
    }
}

ll evaluate(vl typeOfDays, int numDays = D) {
    ll score = 0;
    vl lasts(26, 0);
    rep(d, numDays) {
        score += s[d][typeOfDays[d]];
        lasts[typeOfDays[d]] = d + 1;
        rep(t, 26) {
            score -= c[t] * (d - lasts[t] + 1);
        }
    }
    return score;
}

void solve() {
    rep(d,D) {
        ll mx = -inf;
        vl cand = ans;
        rep(t,26) {
            cand[d] = t;
            ll sc = evaluate(cand);
            if (sc > mx) {
                mx = sc;
                ans = cand;
            }
        }
    }
    cerr << evaluate(ans) << endl;
}

void output() {
    rep(d,D) cout << ans[d]+1 << endl;
}

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


Measured memory_bytes: 3728
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

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

    int l = 4*a*b;
    int r = c-(a+b);
    if (r<=0){
        cout << "No" << endl;
        return 0;
    }

    r = r*r;
    cout << (l<r ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

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

ll n;
ll h[MAX_N];
ll dp[MAX_N]; //足場iまでのコストの総和の最小値

int main() {

  cin >> n;
  rep(i, n) cin >> h[i];

  dp[0] = 0;
  dp[1] = abs(h[1]-h[0]);

  rrep(i, 2, n) {
    dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
  }

  cout << dp[n-1] << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	/*
	string r,L;
	cin>>r;
	int Y;
	cin>>Y;
	if(Y>10){L=(Y/10)+'0';}
	Y%=10;
	L+=Y+'0';
	cout<<L;
	*/
	
	
	int n;
	while(1){
	cin>>n;if(n==0)break;
	
	string str,ans="";
	cin>>str;bool f=true,F=false;
	
	int p=1;
	while(n--){char ch=str[0];p=1;
		//cout<<n<<"#";
	for(int i=1;i<str.size();i++){
		
		if(str[i]==ch)p++;
		else{
			if(p>99){ans+=(p/100)+'0';
			p%=100;}
			if(p>9){ans+=(p/10)+'0';
			p%=10;}
			ans+=(p)+'0';
			
			ans=ans+ch;
			p=1;
		}
		ch=str[i];

		}
	//if(p>1)
	{
		if(p>99){ans+=(p/100)+'0';
		p%=100;}
			if(p>9){ans+=(p/10)+'0';
			p%=10;}
			ans+=(p)+'0';

		ans=ans+str[str.size()-1];
		p=1;
	}
	
	str=ans;
	ans="";
	

	}
	cout<<str<<endl;
	}
	return 0;
}
	

Measured memory_bytes: 1380