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

using namespace std;

#define f first
#define s second
#define pb push_back
#define FILL(a, b) memset(a, b, sizeof(a))

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
const int INF = 0x3F3F3F3F;
const ll INFL = 0x3F3F3F3F3F3F3F3FLL;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;

int N;
int arr[MAX], sorted[MAX], pref[MAX], bit[2 * MAX];

inline void update(int pos, int x) {
    pos += N + 1;
    for (int i = pos; i <= 2 * N + 1; i += i & -i) {
        bit[i] += x;
    }
}

inline int query(int pos) {
    pos += N + 1;
    int ans = 0;
    for (int i = pos; i > 0; i -= i & -i) {
        ans += bit[i];
    }
    return ans;
}

inline bool check(int x) {
    
    FILL(pref, 0), FILL(bit, 0);
    for (int i = 1; i <= N; i++) {
        pref[i] = arr[i] >= x ? 1 : -1;
        pref[i] += pref[i - 1];
    }
    
    ll ans = 0;
    update(0, 1);
    for (int i = 1; i <= N; i++) {
        ans += query(pref[i]);
        update(pref[i], 1);
    }
    return ans >= ((ll) N * (N - 1) / 2 + N + 1) / 2;
}

int main() {
    
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) {
        scanf("%d", &arr[i]);
        sorted[i] = arr[i];
    }
    sort(sorted + 1, sorted + N + 1);
    
    int lo = 2, hi = N + 1, mid;
    while (lo < hi) {
        mid = (lo + hi) / 2;
        if (!check(sorted[mid])) {
            hi = mid;
        } else {
            lo = mid + 1;
        }
    }
    printf("%d\n", sorted[lo - 1]);
    
    return 0;
}

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

constexpr int D = 365;
constexpr int T = 26;
int c[D];
int s[D][T];
vector<int> ans;

void Input() {
    int tmp; cin >> tmp;
    REP(i, T) cin >> c[i];
    REP(i, D) REP(j, T) cin >> s[i][j];
    return;
}

void Commit(int day, int contest, int& score, vector<int>& last) {
    last[contest] = day;
    score += s[day - 1][contest];
    REP(type, T) score -= c[type] * (day - last[type]);
    return;
}

void Output() {
    for(auto contest: ans) cout << contest + 1 << endl;
    return;
}

double lambda = 5.5; // 5.0 is better
int FindMaxProfitContest(int day, vector<int>& last) {
    double max_profit = -1e18;
    int argmax = -1;
    REP(type, T) {
        double profit = 0;
        profit += s[day - 1][type];
        profit += lambda * c[type] * (day - last[type]);
        if(profit > max_profit) {
            max_profit = profit;
            argmax = type;
        }
    }
    return argmax;
}

int Greedy(int start_day, vector<int>& last) {
    int score = 0;
    vector<int> last_copy = last;
    for(int day = start_day; day <= D; day++) {
        int contest = FindMaxProfitContest(day, last_copy);
        Commit(day, contest, score, last_copy);
    }
    return score;
}

int FindMaxProfitContestWithPredict(int day, vector<int>& last) {
    double max_profit = -1e18;
    int argmax = -1;
    REP(type, T) {
        double profit = 0;

        profit += s[day - 1][type];
        profit += lambda * c[type] * (day - last[type]);

        int tmp = last[type];
        last[type] = day;
        profit += Greedy(day + 1, last);
        last[type] = tmp;

        if(profit > max_profit) {
            max_profit = profit;
            argmax = type;
        }
    }
    return argmax;
}

int main() {
    Input();
    int score = 0;
    vector<int> last(T, 0);
    for(int day = 1; day <= D; day++) {
        int contest = FindMaxProfitContestWithPredict(day, last);
        ans.push_back(contest);
        Commit(day, contest, score, last);
    }
    Output();
    // cerr << score << endl;
    return 0;
}


Measured memory_bytes: 3648
S = input()
l = len(S)
flag = 0
half = l // 2

for i in range(l):
  if S[i] != S[l - 1 - i]:
    flag = 1
    
for i in range(half // 2):
  if S[i] != S[half - 1 - i]:
    flag = 1
    
for i in range(half // 2):
  if S[half + 1 + i] != S[l - 1 - i]:
    flag = 1
    
if flag == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <utility>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
const int MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<ll> r(n + 1, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        r.at(i + 1) = r[i] + a[i];
    }
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        ll sum = (r[n] - r[i + 1]) % MOD;
        ans += sum * a[i];
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
    int n;
    cin >> n;
    ll a[n + 1], s[n + 1] = {0};
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        s[i] = s[i - 1] + a[i];
    }

    ll ans = 0;
    for(int i = 1; i < n; i++){
        ll c = s[n] - s[i];
        c %= 1000000007;
        c *= a[i];
        c %= 1000000007;
        ans += c;
        ans %= 1000000007;
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 6780
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		int a = 0;
		for(int i=1; i<=N; i++) {
			int valLen = String.valueOf(i).length();
			if(valLen%2==1) {
				a++;
			}
		}
		System.out.println(a);
	}

}

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

//#define int long long
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a[100];

signed main() {
	cin >> n;
	rep(i,n) cin >> a[i];
	rep(i,n) cout << a[i] << (i==n-1 ? '\n' : ' ');
	reps(i,1,n) {
		int v = a[i];
		int j = i-1;
		while (j>=0 && a[j]>v) {
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
		rep(i,n) cout << a[i] << (i==n-1 ? '\n' : ' ');
	}
}


Measured memory_bytes: 3132
#include <iostream>
#include <string>    
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll h, w, a;
ll c[10][10];
ll d[10];
bool use[10];

int main() {
	cin >> h >> w;
	for(ll i = 0; i <= 9; i++){
		for(ll j = 0; j <= 9; j++){
			cin >> c[j][i];	
		}
		d[i] = 10000;
		use[i] = false;
	}
	for(ll i = 0; i <= 9; i++){
		d[i] = c[1][i];
	}
	use[1] = true;
	//for(ll i = 0; i <= 9; i++){for(ll j = 0; j <= 9; j++){cout << c[j][i];}cout << endl;}
	
	for(ll i = 1; i <= 9; i++){
		ll min = 10000;
		ll argmin = -1;
		for(ll j = 0; j <= 9; j++){
			if(!use[j] && d[j] < min){
				min = d[j];
				argmin = j;
			}
		}
		use[argmin] = true;
		//kousin
		for(ll j = 0; j <= 9; j++){
			if(d[argmin]+c[argmin][j] < d[j]){d[j] = d[argmin]+c[argmin][j];}
		}
	}
	
	ll r = 0;
	for(ll i = 1; i <= h; i++){
		for(ll j = 1; j <= w; j++){
			cin >> a;
			if(0 <= a && a <= 9){
				r += d[a];
			}
		}
	}
	cout << r;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=1005;
int n,m,lim,a[MN],b[MN],f[MN*20];
int main(){
	scanf("%d%d",&m,&n);
	for(reg int i=1;i<=n;i++)scanf("%d%d",a+i,b+i),lim=max(lim,a[i]);
	memset(f,0x3f,sizeof(f));
	lim+=m;f[0]=0;
	for(reg int i=1;i<=n;i++)
		for(reg int j=a[i];j<=lim;j++)
			f[j]=min(f[j],f[j-a[i]]+b[i]);
	reg int Ans=0x3f3f3f3f;
	for(reg int i=m;i<=lim;i++)Ans=min(Ans,f[i]);
	printf("%d\n",Ans);
	return 0;
}

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

using namespace std;

int pot(int x, int p)
{
    int b = x;
    for (int i = 1; i< p; i++)
    {
        b*=x;  
    }
        

    return b;
}
int main()
{
    int x;

    cin >> x;
    for (int i = -118; i <= 119; i++)
    {
        for (int j = -119; j <= 118; j++)
        {
            if (pot(i,5) - pot(j,5) == x)
            {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3632
h, w = map(int, input().split())
s = [['.' for i in range(w + 2)] for j in range(h + 2)]
for i in range(h):
    t = str(input())
    for j in range(w):
        s[i+1][j+1] = t[j]
# 判定
ans = "Yes"
for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] == '.': continue
        if s[i-1][j] == '.' and s[i+1][j] == '.' and s[i][j-1] == '.' and s[i][j+1] == '.': ans = "No"
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
  int n,a[200000],i;
  long s=0,sn=0,ar,sa,min=2000000000;
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%d",&a[i]);
    s+=a[i];
  }
  for (i=0;i<n-1;i++){
    sn+=a[i];
    ar=s-sn;
    sa=(ar>sn)? ar-sn:sn-ar;
    if (min>sa) min=sa;
  }
  printf("%ld\n",min);
  return 0;
}

Measured memory_bytes: 896
n = int(input())
s = [chr(i) for i in range(97, 97+26)]

out = ''
tmp = n
r = 1
c = 0
count = 1
while True:
    r *= 26
    # c += r
    # print(c)
    if tmp > c+r:
        c += r
        count += 1
    else:
        break

tmp = n - c - 1
# print(tmp)
# out = s[tmp%27-1]
# tmp = int(tmp/27)
while tmp>0:
    out = s[tmp%26]+out
    tmp = int(tmp/26)
# out = s[tmp%26-1]+out
for _ in range(count-len(out)):
    out = 'a'+out

print(out)

Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int gcd(int x, int y)
{
	if (x < y)
	{
		swap(x, y);
	}
	int z = x%y;
	if (z == 0)return y;
	return gcd(y, z);
}

int main()
{
	int x, y;
	cin >> x >> y;
	cout << gcd(x, y) << endl;
	return 0;
}


Measured memory_bytes: 3108
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;


int N;
char S[10000000];
int Q;
int K[100];

signed main()
{
	cin >> N;
	cin >> S;
	cin >> Q;
	REP(i, Q) cin >> K[i];

	for (int q = 0; q < Q; q++)
	{
		int k = K[q];

		int d = 0;
		int m = 0;
		int dm = 0;
		int ans = 0;

		for (int i = 0; i < k; i++)
		{
			if (S[i] == 'D')
			{
				d++;
			}
			else if (S[i] == 'M')
			{
				m++;
				dm += d;
			}
			else if (S[i] == 'C')
			{
				ans += dm;
			}
		}

		for (int i = k; i < N; i++)
		{
			if (S[i - k] == 'D')
			{
				d--;
				dm -= m;
			}
			else if (S[i - k] == 'M')
			{
				m--;
			}
			else if (S[i - k] == 'C')
			{
			}

			if (S[i] == 'D')
			{
				d++;
			}
			else if (S[i] == 'M')
			{
				m++;
				dm += d;
			}
			else if (S[i] == 'C')
			{
				ans += dm;
			}
		}

		cout << ans << endl;
	}

}








Measured memory_bytes: 1280
use std::io::{self, Write};

fn main() {
    let mut stdout = io::stdout();
    let stdin = io::stdin();

    let mut input = String::new();
    stdin.read_line(&mut input).expect("failed to read line");

    let k: i32 = match input.trim().parse() {
        Ok(num) => num,
        Err(e) => {
            eprintln!("{:?}", e);
            std::process::exit(1);
        }
    };
    input.clear();
    stdin.read_line(&mut input).expect("failed to read line");

    let (a, b): (i32, i32) = {
        let v: Vec<i32> = input
            .trim()
            .split_whitespace()
            .map(|n| n.parse::<i32>().expect("failed to parse string"))
            .collect();
        (v[0], v[1])
    };

    let mut achieve = false;
    for i in a..=b {
        if i % k == 0 {
            achieve = true;
            break;
        }
    }

    if achieve {
        println!("OK");
    } else {
        println!("NG");
    }
    stdout.flush().unwrap();
}


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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define inf 1000000100

int main()
{
    int n;
    cin >> n;
    map<int, int> diff;
    bool solve = 1;
    int parity;
    for(int i = 0; i < n; i++)
    {
        int d;
        cin >> d;
        if(i == 0)
        {
            parity = d%2;
        }
        else
        {
            if(d%2 != parity)
            {
                solve = 0;
            }
        }

        diff[d]++;
    }

    if(!solve)
    {
        cout << 0 << endl;
        return 0;
    }

    if(n%2 == 0)
    {
        for(auto x: diff)
        {
            if(x.second != 2)
            {
                solve = 0;
                break;
            }
        }
        if(!solve)
        {
            cout << 0 << endl;
            return 0;
        }
        else
        {
            ll ans = 1;
            ll co = n/2;
            while(co--)
            {
                ans *= 2;
                if(ans > 1000000007)
                {
                    ans %= 1000000007;
                }
            }

            cout << ans << endl;
        }
    }
    else if(n%2 == 1)
    {
        for(auto x: diff)
        {
            if((x.first != 0 && x.second != 2) || (x.first == 0 && x.second != 1))
            {
                solve = 0;
                break;
            }
        }
        if(!solve)
        {
            cout << 0 << endl;
            return 0;
        }
        else
        {
            ll ans = 1;
            ll co = n/2;
            while(co--)
            {
                ans *= 2;
                if(ans > 1000000007)
                {
                    ans %= 1000000007;
                }
            }

            cout << ans << endl;
        }

    }


}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define int long long int
#define double long double
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
vi a, mini;
int n, cnt = 0;
signed main()
{
    cin >> n;
    a.resize(n);
    mini.resize(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (i != 0)
            mini[i] = min(mini[i - 1], a[i]);
        else
            mini[i] = a[i];
    }
    for (int i = 0; i < n; i++)
    {
        if (a[i] <= mini[i])
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

int main(void){
	int n,sum;
	while(true){
		cin >> n >> sum;
		if(n == 0 && sum == 0){
			break;
		}
		int count = 0;
		for(int i = 1;i < n-1;i++){
			for(int j = i + 1;j < n;j++){
				for(int k = j + 1;k <= n;k++){
					if(i+j+k == sum){
						count += 1;
					}
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    int n;
    cin >> n;

    for(int i = 0; i < n; i++){
        int a, b;
        string command;
        cin >> command >> a >> b;
        if(command == "print"){
            string s = str.substr(a, b - a + 1);
            cout << s << endl;
        }else if(command == "reverse"){
            reverse(str.begin() + a, str.begin() + b + 1);
        }else{
            string p;
            cin >> p;
            str.replace(a, b - a + 1, p);
        }
    }

    return 0;
}


Measured memory_bytes: 3216
n = int(input())
c= []
ans = 0
for i in range(1, n+1):
  if i % 2 == 1:
    c.append(i)


for i in c:
  if i == 1:
    continue
  else:
    t = 2
    for k in range(1, c.index(i) - 1):
      if i % c[k] == 0:
        t += 1

    if t == 8:
      ans += 1

print(ans)


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

string to_string(string s){
    string t = "";
    for(auto c: s)
        t += tolower(c);
    return t;
}
int main(){
    string w; cin >> w;
    string t;
    
    w = to_string(w);
    
    int ans = 0;
    while(cin >> t, t != "END_OF_TEXT"){
        t = to_string(t);
        ans += t == w;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
int n,m,x,y;
map <string , int > v;
string s[102],t[102];
int main()
{
    cin>>n;
    for (int i=0;i<n;i++)
        cin>>s[i];
    cin>>m;
    for (int i=0;i<m;i++)
        cin>>t[i];
    for (int i=0;i<n;i++)
    {
        for (int j=0;j<n;j++)
        {
            if (i!=j)
            {
                if (s[i]==s[j])
                    x++;
            }
        }
        for (int j=0;j<m;j++)
        {
            if (s[i]==t[j])
                x--;
        }
        x++;
        v [s[i]]=x;
        x=0;
    }
    x=-1000000;
    for (int i=0;i<n;i++)
    {
        x=max (x,v[s[i]]);
    }
    if (x<=0)
        cout<<0;
    else
        cout<<x;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int k;
  scanf("%d",&k);

  int i;
  int x[n];
  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
  }

  int ans =0;

  for(i=0;i<n;i++){
    if(k-x[i]>x[i]){
      ans += 2*x[i];
    }else{
      ans += 2*(k-x[i]);
    }
  }
  printf("%d\n",ans);

  return 0;

}


Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
k1, k2, k4 = 0, 0, 0
for a_i in a:
    if a_i % 4 == 0:
        k4 += 1
    elif a_i % 2 == 0:
        k2 += 1
    else:
        k1 += 1
t = min(k1, k4)
k1 -= t
k4 -= t
result = k1 == 0 or (k1 == 1 and not k2)
print([ 'No', 'Yes' ][result])

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

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()
#define INF (int)1e9
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
int a[mxN];

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

    char t;
    cin >> t;

    if (t == tolower(t))
        cout << "a";
    else
        cout << "A";

    return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
int p[1001];
int ans;
vector<int> vec;
int n,m;
int main()
{
	while(1)
	{
		memset(p,0,sizeof(p));
		vec.clear();
		cin >> n >> m;
		ans=0;
		if(n==0&&m==0)break;
		for(int i=0;i<n;i++)
		{
			cin >> p[i];
		}
		for(int i=0;i<n;i++)
		{
			vec.pb(p[i]);
			for(int j=0;j<n;j++)
			{
				vec.pb(p[i]+p[j]);
			}
		}
		sort(vec.begin(),vec.end());
		for(int i=0;i<sz(vec);i++)
		{
			vector<int>::iterator it=upper_bound(vec.begin(),vec.end(),m-vec[i]);
			if(it==vec.begin())continue;
			it--;
			ans=max(*it+vec[i],ans);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 6788
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
//typedef pair<int, int> P;

/** Problem0109 : Smart Calculator **/
string s; int pos;
int factor();

int number()
{
	int ret=0;
	while (isdigit(s[pos])) {
		ret *= 10;
		ret += s[pos++]-'0';
	}
	return ret;
}

int term()
{
	int ret = factor();
	
	for(;;) {
		if (s[pos] == '*') {
			pos++;
			ret *= factor();
		} else if (s[pos] == '/') {
			pos++;
			ret /= factor();
		} else {
			break;
		}
	}
	
	return ret;
}

int expression()
{
	int ret=term();
	
	for (;;) {
		if (s[pos] == '+') {
			pos++;
			ret += term();
		} else if (s[pos] == '-') {
			pos++;
			ret -= term();
		} else {
			break;
		}
	}
	
	return ret;
}

int factor()
{
	int ret;
	
	if (s[pos]=='(') {
		pos++;
		ret = expression();
		pos++;
	} else {
		ret = number();
	}
	return ret;
}

int main()
{
	int N; cin>>N;
		
	rep(i, N) {
		cin>>s;
		pos=0;
		cout << expression() << endl;
	}
}

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

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

using namespace std;

int main(){
	int n,m; cin>>n>>m;

	int cnt[30]={};
	rep(i,n){
		int k; cin>>k;
		rep(j,k){ int a; cin>>a; a--; cnt[a]++; }
	}

	cout<<count(cnt,cnt+m,n)<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

char s[101][101];
char d[202][101];

int main(){
	int h,w;
	cin >> h >> w;
	rep(i,h)rep(j,w)cin >> s[i][j];
	rep(i,h){
		rep(j,w){
			d[2*i][j]=s[i][j];
			d[2*i+1][j]=s[i][j];
		}
	}
	rep(i,2*h){
		rep(j,w){
			cout << d[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3536
n, m = map(int, input().split())
x = list(map(int, input().split()))

x.sort()

num = []
for i in range(m-1):
  num.append(x[i+1]-x[i])

num.sort()
if n > m:
  print(0)
else:
  print(sum(num[:m-n]))

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

using namespace std;

using ll = long long;

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

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

    int max_c = min(c, a + b + 1);

    cout << max_c + b << '\n';

    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define itn int
typedef long long ll;
typedef pair<int,int> p;


int main()
{
 int a,b;
 cin >> a >> b;
 if (a <= 8 && b <= 8)
 {
   cout << "Yay!" << endl;
 }else{
   cout << ":(" << endl;
 }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int N,L;
    int ans=0;
    cin >>N>>L;
    if(L+N-1<=0){
        REP(i,N-1){
            ans+=L+i;
        }
    }
    else{
        if(L<=0){
            REP(i,N){
                ans+=L+i;
            }
        }
        else{
            REP(i,N-1){
                ans+=L+i+1;
            }
        }
    }
    cout << ans<<endl;
}

Measured memory_bytes: 256
import Control.Monad
import Text.Printf
import Control.Applicative

main :: IO()
main = do
  [n, m, x] <- map read . words <$> getLine
  a <- map read . words <$> getLine
  printf "%s" $ slv n m x a

slv :: Int -> Int -> Int -> [Int] -> String
slv n m x a | slen > tlen = show tlen
            | otherwise = show slen
  where (s, t) = span (< x) a
        slen = length s
        tlen = length t


Measured memory_bytes: 892
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int q;
    cin >> q;
    vector<int> ans(n, INT_MAX);
    priority_queue<pair<int, int>> pq;
    while(q--){
        int a, b;
        cin >> a >> b;
        a--;
        ans[a] = b;
        pq.emplace(ans[a], a);
    }
    while(pq.size()){
        auto x = pq.top();
        pq.pop();
        for(int v: g[x.second]){
            if(ans[v] == INT_MAX){
                ans[v] = x.first - 1;
                pq.emplace(ans[v], v);
            }else if(abs(ans[v] - x.first) != 1){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    rep(i,n)cout << ans[i] << "\n";
}


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

comp1 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
comp2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
comp3 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
comp4 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
    
for i in range(n):
    b, f, r, v = map(int, input().split())
    if b == 1:
        comp1[f - 1][r - 1] += v
    elif b == 2:
        comp2[f - 1][r - 1] += v
    elif b == 3:
        comp3[f - 1][r - 1] += v
    else:
        comp4[f - 1][r - 1] += v

for s in comp1:
    s = [str(n) for n in s]
    print(' ', end="")
    print(' '.join(s))
print('#' * 20)
for s in comp2:
    s = [str(n) for n in s]
    print(' ', end="")
    print(' '.join(s))
print('#' * 20)
for s in comp3:
    s = [str(n) for n in s]
    print(' ', end="")
    print(' '.join(s))
print('#' * 20)
for s in comp4:
    s = [str(n) for n in s]
    print(' ', end="")
    print(' '.join(s))


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

int main()
{
	ios_base::sync_with_stdio(false),cin.tie(NULL);
	int n=0;
	cin>>n;
	vector<vector<int>> dp(n+1,vector<int>(4,0));
	cin>>dp[1][1]>>dp[1][2]>>dp[1][3];
	for(int i=2;i<=n;i++)
	{
		int x,y,z;
		cin>>x>>y>>z;
		dp[i][1]=max(dp[i-1][2]+x,dp[i-1][3]+x);
		dp[i][2]=max(dp[i-1][1]+y,dp[i-1][3]+y);
		dp[i][3]=max(dp[i-1][1]+z,dp[i-1][2]+z);
	}

	cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
	return 0;
}

Measured memory_bytes: 5760
N = int(input())
AB = [list(map(int, input().split(" "))) for _ in range(N)]

AB.sort(key=lambda x: x[1])
# print(AB)

time = 0
for a, b in AB:
    time += a
    # print(time, b, b<time)
    if b < time:
        print("No")
        exit()
print("Yes")

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

using namespace std;
bool is_Palindrome(string x){
	string y=string(x.rbegin(),x.rend());
	if(x==y)return true;
	else return false;
}
int main(){
	string s;
	cin>>s;
	int n=s.size();
	bool is_Palindrome(string x);
	string a=s.substr(0,(n-1)/2),b=s.substr((n+1)/2,(n-1)/2);
	if(is_Palindrome(a)&&is_Palindrome(b)&&is_Palindrome(s)){
		cout<<"Yes";return 0;
	}
	cout<<"No";
	return 0;
} 

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! debug {
  ($($e:expr), *) => {println!(concat!($(stringify!($e), " = {:?}\n"), *), $($e), *)}
}

fn main() {
  let n = get::val::<usize>();
  let sn = format!("{}", n).chars().collect::<Vec<_>>();

  let sum = sn.iter().map(|&c|c as usize - '0' as usize).sum::<usize>();
  let ans = if n % sum == 0 {"Yes"} else {"No"};
  println!("{}", ans)
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn list<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(list());
    }
    mat
  }

  pub fn chars() -> Vec<char> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().chars().collect()
  }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = 2e9;
const int MAX_N = 1;

int main() {
  int a, b; cin >> a >> b;
  if (a+b == 15) {
    cout << "+" << endl;
  } else if (a*b == 15) {
    cout << "*" << endl;
  } else {
    cout << "x" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
const ll INF = ll(1e18);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

//modの値の確認をすること
int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<bool> u(1e6 + 1,true);
    rep0(i, n)cin >> a[i];
    sort(all(a));
    ll ans = 0;
    rep0(i, n){
        if(u[a[i]]){
            for (ll j = 1; j * a[i] <= ll(1e6); ++j)u[a[i] * j] = false;
            if(a[i] != a[i + 1])++ans;
        }
    }
    pf(ans);
    return 0;
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, P;
  int c = 0;
  cin >> N ;
  int min = N;
  for(int i = 0; i < N; i++){
    cin >> P;
  	if (min >= P){
      min = P;
      c++;
  	}
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

    int h,w; cin>>h>>w;
    vector<string> a(h);
    rep(i,h) cin>>a[i];
    
    vector<bool> row(h, false);
    vector<bool> col(w, false);
    rep(i,h){
        rep(j,w){
            if(a[i][j] == '#'){
                row[i] = true;
                col[j] = true;
            }
        }
    }
    
    rep(i,h){
        if(row[i]){
            rep(j,w){
                if(col[j]){
                    cout << a[i][j];
                }
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAXN 1005

int N;
int T, A;
double h[MAXN];
int main()
{
	scanf("%d", &N);
	scanf("%d%d", &T, &A);
	for (int i = 0; i < N; i++)
	{
		int hh;
		scanf("%d", &hh);
		h[i] = (double)A - ((double)T - (double)hh*0.006);
		if (h[i] < 0) h[i] = -h[i];
	}
	double x = 1e6;
	int ans = 0;
	for (int i = 0; i < N; i++) if (x > h[i]) x = h[i], ans = i+1;
	
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define itn int
//#define int long long
#define mod 1000000007
#define fi first
#define se second
#define be begin()
#define en end()
#define re reverse
#define Set setprecision
#define NO cout<<"NO\n"
#define YES cout<<"YES\n"
#define No cout<<"No\n"
#define Yes cout<<"Yes\n"
const int INFi=2147483647;
const long long INFl=9223372036854775807LL;
template<typename T> T abs(T a,T b){
    return max(a,b)-min(a,b);
}
template<typename T> T lcm(T a,T b){//最小公倍数
    return (a*b)/gcd(a,b);
}
int gcd(int a,int b){//最大公約数
    int c=a%b;
    while(true){
	if(c==0) break;
	a=b;
	b=c;
	c=a%b;
    }
    return b;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    itn a,b,q;
    int c[1000000];
    int d[1000000];
    int x,y,e;
    itn m=10000000,f=10000000;
    int sum=0;
    cin>>a>>b>>q;
    for(int i=0;i<a;i++){
	cin>>c[i];
	m=min(c[i],m);
    }
    for(int i=0;i<b;i++){
	cin>>d[i];
	f=min(f,d[i]);
    }
    sum=m+f;
    for(int i=0;i<q;i++){
	cin>>x>>y>>e;
	sum=min(sum,(c[x-1]+d[y-1])-e);
    }
    cout<<sum<<"\n";
}
    


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
int n,k,x,y;
void solve()
{
    if (n>k) cout<<k*x+(n-k)*y;
    else cout<<n*x;
    cout<<endl;
}
int main()
{
    while(cin>>n>>k>>x>>y)
        solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
using namespace std;

int main()
{
    int D, N;
    cin >> D >> N;
    int ans = 0;
    if (N == 100)
    {
        ans = floor(pow(100, D)) * (N + 1);
    }
    else
    {
        ans = floor(pow(100, D)) * N;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
using namespace std;
#define MOD 1000000007
class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};





int main() {
	string s;
	cin >> s;
	if (s[5] == '1') {
		cout << "TBD";
	}
	else if(s[6]>'4') {
		cout << "TBD";
	}
	else {
		cout << "Heisei";
	}


	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
N=int(input())
soinsu=defaultdict(int)
x=2
while x<=10**6:
  while N%x==0:
    soinsu[x]+=1
    N//=x
  x+=1
  
if N>1:
  soinsu[N]+=1
  
ans=0
for key in soinsu.keys():
  x=1
  while soinsu[key]>=x:
    ans+=1
    soinsu[key]-=x
    x+=1
    
print(ans)

Measured memory_bytes: 9412
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

A = int(input())
B = int(input())

if A > B:
    print("GREATER")
elif A < B:
    print("LESS")
else:
    print("EQUAL")


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

char encode(char y, int a, int b) {
    if (islower(y)) {
        int n = y - 'a';
        return (a * n + b) % 26 + 'a';
    } else {
        return y;
    }
}

string encode(string s, int a, int b) {
    string t;
    for (int i = 0; i < s.size(); i++) {
        t.push_back(encode(s[i], a, b));
    }
    return t;
}

string s;

bool check(string t) {
    return s.find(t) != string::npos;
}

map<char, char> decode_table;
void create_decode_table(int a, int b) {
    for (int i = 'a'; i < 'a'+26; i++) {
        decode_table[encode(i, a, b)] = i;
    }
}

string decode(string t) {
    string u;
    for (int i = 0; i < t.size(); i++) {
        if (islower(t[i])) {
            u.push_back(decode_table[t[i]]);
        } else {
            u.push_back(' ');
        }
    }
    return u;
}

int main() {
    int n; cin >> n;
    cin.ignore(1);
    while (n--) {
        getline(cin, s);
        for (int a = 0; a < 26; a++) {
            for (int b = 0; b < 26; b++) {
                //cout << encode("that", a, b) << endl;
                if (check(encode("that", a, b)) || check(encode("this", a, b))) {
                    create_decode_table(a, b);
                    cout << decode(s) << endl;
                    break;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1220
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
#include<stdio.h>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    int N,R;
    cin >> N >> R;
    int num=0;
    if(N>=10){
        num=R;
    }
    else{
        num=R+100*(10-N);
    }
    cout << num;
    }

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

int main() {
  int n, k;
  cin >> n >> k;
  int i = 0;
  while ((k-1)*i+1 < n) ++i;
  cout << i << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	w := scanString()

	m := map[string]int{}
	for _, c := range w {
		m[string(c)]++
	}

	for _, v := range m {
		if v%2 != 0 {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N, X;
    cin >> N >> X;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<ll> v(N);
    for (ll i = 0; i < N; i++) {
        v[i] = A[i];
    }
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        ans += v[i];
    }
    ll tmp;
    for (ll k = 1; k < N; k++) {
        for (ll i = 0; i < N; i++) {
            v[i] = min(v[i], A[(i-k+N) % N]);
        }
        tmp = 0;
        for (ll i = 0; i < N; i++) {
            tmp += v[i];
        }
        ans = min(ans, tmp + k * X);
    }
    printf("%lld\n", ans);

}

Measured memory_bytes: 3736
package main

import "fmt"

func main() {
	var n int

	fmt.Scan(&n)
	c := make([]int, n-1)
	s := make([]int, n-1)
	f := make([]int, n-1)

	for i := 0; i < n-1; i++ {
		fmt.Scan(&c[i], &s[i], &f[i])
	}

	for i := 0; i < n-1; i++ {
		fmt.Println(solve(n-i, c[i:], s[i:], f[i:]))
	}
	fmt.Println(0)
}

func solve(n int, c []int, s []int, f []int) int {
	t := 0

	for i := 0; i < n-1; i++ {
		r := t % f[i]
		if r != 0 {
			t += f[i] - r
		}
		if t < s[i] {
			t = s[i]
		}

		t += c[i]
	}

	return t
}


Measured memory_bytes: 512
#include<cstdio>
int max(int x,int y) {return x>y?x:y;}
char s[300005];
int a[300005],b[300005];
int main()
{
	int n;scanf("%d",&n);
	scanf("%s",s);
	for(int i=0;i<n;i++) a[i+1]=a[i]+(s[i]=='E');
	for(int i=n-1;i>=0;i--) b[i+1]=b[i+2]+(s[i]=='W');
	int ans=0;
	for(int i=1;i<=n;i++) ans=max(ans,a[i-1]+b[i+1]);
	printf("%d\n",n-ans-1);
	return 0;
}

Measured memory_bytes: 2816
(n, m) = [int(i) for i in input().split()]
A = []
b = []
for i in range(n):
    A.append([int(j) for j in input().split()])
 
for i in range(m):
    b.append(int(input()))
 
for i in range(n):
    s = 0
    for j in range(m):
        s += A[i][j] * b[j]
    print(s)

Measured memory_bytes: 8056