akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
using namespace std;
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int n;
int main(){
    while(cin >> n && n){
        int lun[2] = {0,0},din[2] = {0,0},mid[2] = {0,0};
        rep(i,n){
            int h,m,M;
            scanf("%d:%d %d",&h,&m,&M);
            int t = M-m;
            if(t < 0) t += 60;
            if(11<= h && h < 15){
                lun[0]++;
                if(t <= 8) lun[1]++;
            }else if(18 <= h && h < 21){
                din[0]++;
                if(t <= 8) din[1]++;
            }else if(21 <= h || (0 <= h && h < 2)){
                mid[0]++;
                if(t <= 8) mid[1]++;
            }
        }

        cout << "lunch ";
        if(lun[0]) cout << 100*lun[1]/lun[0] << endl;
        else cout << "no guest" << endl;
        cout << "dinner ";
        if(din[0]) cout <<  100*din[1]/din[0] << endl;
        else cout << "no guest" << endl;
        cout << "midnight ";
        if(mid[0]) cout << 100*mid[1]/mid[0] << endl;
        else cout << "no guest" << endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

int main() {
  int n, m; cin >> n >> m;
  int a[n]; rep(i,n) { cin >> a[i]; a[i]--; }

  ll d[m*2+1] = {};
  repr(i,1,n) {
    if (a[i]>a[i-1]) { 
      d[a[i-1]+2] += 1; 
      d[a[i]+1] -= a[i]-a[i-1]; 
      d[a[i]+2] += a[i]-a[i-1]-1;
    }
    else {
      d[a[i-1]+2] += 1;
      d[a[i]+m+1] -= a[i]+m-a[i-1];
      d[a[i]+m+2] += a[i]+m-a[i-1]-1;
    }
  }
  ll v[m*2+1] = {};
  repr(i,1,m*2+1) d[i] += d[i-1];
  repr(i,1,m*2+1) v[i] = v[i-1] + d[i];
  rep(i,m) v[i] += v[i+m];
  // debug(d,d+m*2+1); debug(v,v+m);
  ll ma = 0; rep(i,m) ma = max(ma,v[i]);

  ll result = 0;
  repr(i,1,n) result += (a[i]+m-a[i-1])%m;
  result -= ma;
  cout << result << endl;
  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    string s, ans;
    cin >> s;
    rep(i, s.size()) {
        if(s[i] == 'B') {
            if(!ans.empty()) ans.pop_back();
        } else {
            ans.push_back(s[i]);
        }
    }

    cout << ans << endl;

    return 0;
}


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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main(){
    input!{
        a:i64,
        b:i64,
    }
    let mut a = a;
    let mut b = b;
    let mut ans = 0;
    for _ in 0..2 {
        if a >= b {
            ans += a;
            a-=1;
        }else {
            ans += b;
            b-=1;
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
use proconio::input;

fn main() {
    input! {
        n: usize,
        q: usize,
        a: [usize; n],
    }

    let mut t = FenwickTree::from_vec(a);
    for _ in 0..q {
        input! { f: usize };
        if f == 1 {
            input! { l: usize, r: usize }
            println!("{}", t.sum(l, r));
        } else {
            input! { p: usize, x: usize }
            t.add(p, x);
        }
    }
}

struct FenwickTree<T> {
    v: Vec<T>,
}

use std::ops::AddAssign;
use num::{Integer, zero};

impl<T: Copy + AddAssign + Integer> FenwickTree<T> {
    fn new(n: usize) -> Self {
        Self {
            v: vec![zero(); n],
        }
    }

    fn from_vec(v: Vec<T>) -> Self {
        let n = v.len();
        let mut t = Self::new(n);
        for i in 0..n {
            let v = t.v[i] + v[i];
            t.v[i] = v;
            let p = i + Self::lsb(i + 1);
            if p < n {
                t.v[p] += v;
            }
        }
        t
    }

    fn add(&mut self, mut i: usize, v: T) {
        while i < self.v.len() {
            self.v[i] += v;
            i += Self::lsb(i + 1);
        }
    }

    fn sum(&self, l: usize, r: usize) -> T {
        self.get(r) - self.get(l)
    }

    fn get(&self, mut i: usize) -> T {
        let mut v = zero();
        while i > 0 {
            v += self.v[i - 1];
            i -= Self::lsb(i);
        }
        v
    }

    fn lsb(i: usize) -> usize {
        i & i.wrapping_neg()
    }
}


Measured memory_bytes: 23068
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int N;
	char S[300001];
	scanf("%d", &N);
	scanf("%s", S);
	
	int i, count = 0, max = 0;
	for (i = 0; S[i] != 0; i++) if (S[i] == 'W') count++;
	for (i = 0, count; S[i] != 0; i++) {
		if (S[i] == 'W') count--;
		if (count > max) max = count;
		if (S[i] == 'E') count++;
	}
	
	printf("%d\n", N - max - 1);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2416
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	int n;
	int p = -1;
	int c = 0;
	int ans = 0;
	cin >> n;
	rep(i,n){
		int a;
		cin >> a;

		if (p == a)c++;
		else {
			ans += c / 2;
			c = 1;
		}

		p = a;
	}
	ans += c / 2;
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  vector<ll> f(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>f[i];

  ll l=0;
  ll r=(ll)(1.0e18);

  sort(begin(a),end(a));
  sort(begin(f),end(f),greater<ll>());

  /*
  for(auto x:a) cout << x << " ";
  cout << endl;
  for(auto x:f) cout << x << " ";
  cout << endl;
  */
  ll cost;
  while(r-l>1){

    ll p=l+(r-l)/2;
    cost=0;

    rep(i,n){
      ll c;
      //if( p%f[i] ==0 ) c=a[i]-p/f[i];
      //else c=a[i]-p/f[i]+1;
      c=a[i]-p/f[i];
      cost+=max( c ,0LL);
    }
    //cout << p << "," << cost << endl;
    if(cost>k){
      l=p;
    }
    else{
      r=p;
    }

  }

  //cout << l << "," << r << endl;

  ll p=l;
  cost=0;

  rep(i,n){
    ll c;
    //if( p%f[i] ==0 ) c=a[i]-p/f[i];
    //else c=a[i]-p/f[i]+1;
    c=a[i]-p/f[i];
    cost+=max( c ,0LL);
  }
  //cout << p << "," << cost << endl;
  if(cost>k){
    cout << r << endl;
  }
  else{
    cout << l << endl;
  }
  

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}


Measured memory_bytes: 3328
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int d[] = new int[3];
        d[0]=a*b;
        d[1]=a+b;
        d[2]=a-b;
        Arrays.sort(d);
        System.out.println(d[2]);
    }
}


Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {
    public static void main(String[] args ){
        Scanner scanner = new Scanner(System.in);
        double x = scanner.nextDouble();
        System.out.printf("%.6f %.6f\n", x * x * Math.PI, x * 2 * Math.PI);
        scanner.close();
    }
}


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

const ll INF = 1LL << 60;

ll N, K;
string S;
int main() {
    cin >> N >> K;
    cin >> S;

    vector<ll> sum;
    ll ans = 0;
    rep(i, N - 1) {
        if (S[i] == S[i + 1]) ans++;
    }

    cout << min(N - 1, ans + K * 2) << endl;
}

Measured memory_bytes: 3660
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int[] X = nextIntArray(sc, N);

		sc.close();

		int[] b = new int[N];
		System.arraycopy(X, 0, b, 0, N);
		Arrays.sort(b);

		int m1 = b[N / 2 - 1];
		int m2 = b[N / 2];

		StringBuilder ans = new StringBuilder();
		for (int i = 0; i < N; i++) {

			if (X[i] <= m1) {
				ans.append(m2);
				ans.append("\r\n");
			} else {
				ans.append(m1);
				ans.append("\r\n");
			}
		}

		out.print(ans.toString());

	}

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

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 69780
n = int(input())
s= input()

next_ = [[-1]*(n+1) for i in range(10)]
for num in range(10):
    pos = -1
    for i in range(n)[::-1]:
        next_[num][i] = pos
        if num == int(s[i]):
            pos = i

start = [-1] * 10
for num in range(10):
    for i in range(n)[::-1]:
        if num == int(s[i]):
            start[num] = i
ans = 0
for i in range(1000):
    t = ("000"+str(i))[::-1][0:3][::-1]
    pos = start[int(t[0])]
    for i in t[1:]:
        pos = next_[int(i)][pos]
    if pos != -1:
        ans += 1
print(ans)

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

int cnt;

int Partition(int A[],int p,int r)
{
    int x=A[r];
    int i=p-1;
    int j,t;
    for(j=p;j<r;++j)
    {
        if(A[j]<=x)
        {
            i=i+1;
            t=A[i];A[i]=A[j];A[j]=t;
        }
    }
    t=A[i+1];A[i+1]=A[r];A[r]=t;
    return i+1;
}

int main(){
    int A[100001],n,i,p;
    cin>>n;
    for(i=0;i<n;++i)
    {
        cin>>A[i];
    }

    p=Partition(A,0,n-1);
    for(i=0;i<n;++i)
    {
        if(i)cout<<" ";
        if(i==p)
        {
            cout<<"[";
        }
        cout<<A[i];
        if(i==p)
        {
            cout<<"]";
        }
    }
    cout<<endl;

    return 0;
}



Measured memory_bytes: 3404
#include <iostream>
#include <cctype>
#include <string>
#include <algorithm>

using namespace std;

string myMax(string a, string b)
{
	if (a.length() < b.length()) return b;
	if (a.length() > b.length()) return a;

	for (int i = 0; i < a.length(); i++){
		if (a[i] < b[i]){
			return b;
		}
		if (a[i] > b[i]){
			return a;
		}
	}
	return a;
}

string retMax(string a, string b)
{
	// 先頭の0をさくじょ
	string c, d;
	bool pf = false;
	for (int i = 0; i < a.length(); i++){
		if (pf || a[i] != '0'){
			c += a[i];
			pf = true;
		}
	}
	pf = false;
	for (int i = 0; i < b.length(); i++){
		if (pf || b[i] != '0'){
			d += b[i];
			pf = true;
		}
	}
	a = c;
	b = d;
	if (a == "") a = "0";
	if (b == "") b = "0";
	// cout << a << " " << b << endl;
	// 大小ひかく
	if (a.length() < b.length()) return b;
	if (a.length() > b.length()) return a;

	for (int i = 0; i < a.length(); i++){
		if (a[i] < b[i]){
			return b;
		}
		if (a[i] > b[i]){
			return a;
		}
	}
	return a;
}

int main(void)
{
	int w, h;
	while (cin >> w >> h, w && h){
		string field[80];
		for (int i = 0; i < h; i++){
			cin >> field[i];
		}
		string dp[80][80] = {};
		string ret;
		// 右下からやる
		for (int i = h-1; 0 <= i; i--){
			for (int j = w-1; 0 <= j; j--){
				if ('0' <= field[i][j] && field[i][j] <= '9'){
					dp[i][j] = myMax(field[i][j] + dp[i][j + 1], field[i][j] + dp[i + 1][j]);
				}
				// 0 を考慮した大小
				ret = retMax(dp[i][j], ret);
				// cout << ret << endl;
			}
		}

		/*
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				if (dp[i][j] != "") cout << dp[i][j] << " ";
				else cout << "* ";
			}
			puts("");
		}*/
		

		bool pf = false;
		for (int i = 0; i < ret.length(); i++){
			if (pf || ret[i] != '0'){
				cout << ret[i];
				pf = true;
			}
		}
		if (!pf) cout << "0";
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1364
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

template<typename T>
T gcd(T a, T b) 
{
    if (b < a) { //! make sure a <= b
        T tmp = b;
        b = a;
        a = tmp;
    }

    T r = b % a;
    while (r) {
        b = a;
        a = r;
        r = b % a;
    }

    return a;
}

typedef map<LL, int> FACTORS;

void factorize(LL x, FACTORS& factors)
{
    LL org = x;
    int p = 0;
    while (x % 2 == 0) {
        ++p;
        x /= 2;
    }
    if (0 < p) {
        factors[2] = p;
    }
    for (LL f = 3; 1 < x && f * f <= org; f += 2) {
        p = 0;
        while (x % f == 0) {
            ++p;
            x /= f;
        }
        if (0 < p) {
            factors[f] = p;
        }
    }
    if (1 < x) {
        factors[x] = 1;
    }
}


int main()
{
    LL A, B;
    cin >> A >> B;

    LL G = gcd(A, B);

    FACTORS fs;

    factorize(G, fs);

    int ans = 1;
    for (auto it: fs) {
        ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
ans=0
flag=True
while flag:
    flag=False
    for i in range(n-1,0,-1):
        if a[i]<a[i-1]:
            a[i],a[i-1]=a[i-1],a[i]
            flag=True
            ans+=1
print(*a)
print(ans)



Measured memory_bytes: 5608
n, w = map(int, input().split())

weights = []
profits = []

for i in range(n):
    x, y = map(int, input().split())
    weights.append(x)
    profits.append(y)

dp = [[0 for i in range(w+1)] for j in range(n+1)]

for i in range(1, n+1):
    for j in range(1, w+1):

        if weights[i-1] <= j:
            dp[i][j] = max(dp[i-1][j], profits[i-1] + dp[i-1][j-weights[i-1]])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[n][w])


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

int main() {
  int N, K;
  double Sum=0;
  cin >> N >> K;
  rep(i, N){
    int A=i+1, cnt=0;
    while(K>A){
      A*=2;
      cnt++;
    }
    Sum+=1/(N*pow(2,cnt));
  }
  cout << setprecision(15) << Sum << endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                       \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
#define pb push_back
#define ll long long

struct Q
{
	ll x, y;
	ll operator*(Q b)
	{
		// cout << x << " "<< y<<endl;
		// cout << b.y << " "<< b.x << endl;
		return (x * b.y - y * b.x);
	}
	void read()
	{
		cin >> x >> y;
	}
	Q operator-(Q b)
	{
		return {x - b.x, y - b.y};
	}
	double operator%(Q b)
	{
		return sqrt(pow(x - b.x, 2) + pow(y - b.y, 2));
	}
};
int main()
{
	FAST_IO
	int a,ans=0;
	string s;
	cin >> a >> s;
	for (int i = 0; i < a - 2; i++)
	{
					string qw ="";

		for (int j = 0; j < 3; j++)
		{
			qw+= s[i+j];
		}
		if (qw == "ABC")ans+=1;
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t, c = 0, d = 0, e = 0, f{0};
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        if (s == "AC")
            c++;
        else if (s == "WA")
            d++;
        else if (s == "TLE")
            e++;
        else
            f++;
    }
    cout << "AC x " << c << endl;
    cout << "WA x " << d << endl;
    cout << "TLE x " << e << endl;
    cout << "RE x " << f << endl;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

int main() {
  std::string s;
  std::cin >> s;
  for (int i = 0; i < (int)s.length(); ++i) {
    for (int j = i; j < (int)s.length() + 1; ++j) {
      std::string a = s.substr(0, i);
      std::string b = s.substr(j);
      if (a + b == "keyence") {
        std::cout << "YES" << std::endl;
        return 0;
      }
    }
  }
  std::cout << "NO" << std::endl;
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  vector<int>hat(N);
  int64_t ans=1;
  hat[0]=3;
  for(int i=0;i<N;i++){
    int a;cin>>a;
    ans*=hat[a];
    ans%=mod;
    hat[a]--;
    hat[a+1]++;
  }
  cout<<ans<<endl;
  return 0;  
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 177, task a, 2020/08/29
//ms,
/*
*/
#define P 1000000007

int main(void){
  int N;
  vector<int64_t> a;
  vector<int64_t> b;
  int64_t tmp_b=0;
  int64_t ans=0;


  cin >>N;
  for(int i=0;i<N;i++){
    int64_t tmp;
    cin >>tmp;
    a.push_back(tmp);
  }


  for(int i=N-2;i>=0;i--){
    tmp_b += a[i+1];
    tmp_b %= P;
    b.push_back(tmp_b);
  }

  for(int i=0;i<N-1;i++){
    ans += a[i]*b[N-2-i];
    ans %= P;
  }

  cout <<ans;

  return 0;
}
/*
*/


Measured memory_bytes: 7964
program ABC142D
    implicit none
    integer(8) ::N,i,j
    integer(8) ::c
    integer(8) ::result
    integer(8),allocatable,dimension(:)::L

    read (5,*) N
    result=N*(N-1)*(N-2)/6
    allocate(L(N))
    read (5,*) (L(i),i=1,N)
    L=iqsort(L)

    do i=1,N-2
        do j=i+1,N-1
            c=L(N+1-i)-L(N+1-j)
            result=result-min(N-j,upper_bound(L,N,c)-1)
        end do
    end do

    print'(i0)',result

contains  
    recursive function iqsort(ix) result(ires)
      integer(8), allocatable :: ires(:)
      integer(8), intent(in)  :: ix(:)
      integer :: k
      if (size(ix) <= 1) then 
        ires = ix
      else  
        k = ix(size(ix) / 2)
        ires = [iqsort(pack(ix, ix < k)), pack(ix, ix == k), iqsort(pack(ix, ix > k))] 
      end if
    end function iqsort

    function upper_bound(A,N,s) result(place)
      integer(8),intent(in)::A(:),N,s
      integer(8)::place,t,e,c

      t=0
      e=N

      do
          if(e-t<=1) then
              exit
          end if

          c=(t+e)/2
          if(A(c)>s) then
              e=c
          else if(A(c)<=s) then
              t=c
          end if
      end do
      place=e
    end function upper_bound
end program ABC142D

Measured memory_bytes: 640
import itertools
n=int(input())
a=list(map(int,input().split()))
cumsum=[0]+list(itertools.accumulate(a))
sum_num=sum(a)
ans=10**100
for i in range(1,n):
    yen=abs(cumsum[i]-(sum_num-cumsum[i]))
    if yen<ans:
        ans=yen
print(ans)

Measured memory_bytes: 31144
MOD = 1000003
q = int(input())
cumprod = [1]
for i in range(1, MOD):
	cumprod.append((cumprod[-1] * i) % MOD)

def calc(l, r):
	return (cumprod[r] * pow(cumprod[l-1], MOD-2, MOD)) % MOD

def solve(x, d, n):
	if x == 0:
		return 0
	elif d == 0:
		return pow(x, n, MOD)
	else:
		l = (x * pow(d, MOD-2, MOD)) % MOD
		if l+n-1 >= MOD:
			return 0
		else:
			return (calc(l, l+n-1) * pow(d, n, MOD)) % MOD

for _ in range(q):
	x, d, n = map(int, input().split())
	print(solve(x, d, n))

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

int a[100009], dp[100009];

int main()
{
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        if(i > 1) dp[i] = INT_MAX;
        for(int j = 1; i - j > 0 && j <= k; j++) dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
    }
    cout << dp[n] << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long 
#define int long long 
#define vll vector<long long>
#define pii pair<long long ,long long > 
#define vvi vector< vector<long long > > 
#define vpii vector<pair<int,int>> 
#define pll  pair<long long ,long long > 
#define pb  push_back
#define ff  first 
#define sec second  
#define SORT(a) sort(a.begin(),a.end())
#define SORTR(a) sort(a.rbegin(),a.rend()) 
#define m_p make_pair
#define all(x) (x.begin(),x.end()) 
#define sz(v) ((int)(v.size()))
#define endl '\n'
#define INF 1e18+1
typedef vector< long long > vi ;
const int MOD=1e9 +7 ;
int size=10000000; 
 

int32_t main(){
  fast; 
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif */
  
  int T=1; //cin>>T; 
  while(T--){

    int n,w; cin>>n>>w; 
    vpii v(n); 
    int sum=0; 
    for(int i=0;i<n;i++){
      int x,y; cin>>x>>y; 
      v[i]={x,y};
      sum+=y;  
    }

    vi dp(sum+1,INF);
    dp[0]=0; 


    for(int i=0;i<n;i++){
      for(int j=sum-v[i].sec;j>=0;j--){
        dp[j+v[i].sec]=min(dp[j+v[i].sec],v[i].ff+dp[j]); 
      }
    } 

    int mx=0; 
    for(int i=0;i<=sum;i++){
      if(dp[i]<=w){
        mx=max(mx,i); 
      }
    }

    cout<<mx<<endl; 




  }
    


  return 0; 
} 


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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;


int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    cout<<n*800-(n/15)*200<<endl;

    return 0;
}


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    string s;
    cin >> s;

    int n = s.size();
    int ans = 0;
    //if (n % 2 == 0) {
        for (int i = 0; i < n / 2; i++) {
            if (s[i] != s[n - i - 1]) ans++;
        }
    //}
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

ll bs(vector<ll>& arr, ll x) {
    for(ll val: arr) {
        x -= x % val;
    }
    return x;
}
int main() {
    int k;
    cin >> k;
    vector<ll> arr(k, 0);
    for(auto& val: arr)
        cin >> val;
    ll l = 0, r = (ll)INT_MAX * (ll)(INT_MAX-2);

    ll upper = -1, lower;
    while(l < r) {
        ll mid = l+(r-l)/2;
        ll res = bs(arr, mid);
        // cout << "lower mid " << mid << " =>" << res << endl;
        if (res < 2) {
            l = mid+1;
        } else {
            r = mid;
        }
    }
    lower = l;
    if (bs(arr, lower) != 2) {
        cout << -1 << endl;
        return 0;
    }

    l = 0, r = (ll)INT_MAX * (ll)(INT_MAX-2);
    while(l < r) {
        ll mid = l+(r-l)/2;
        ll res = bs(arr, mid);
        //cout << "upper mid " << mid << " =>" << res << endl;
        if (res > 2) {
            r = mid-1;
        } else {
            l = mid;
            if (l+1 == r) {
                upper = (bs(arr, r) == 2) ? r : l;
                break;
            }
        }
    }
    if (upper == -1)
        upper = l;
    cout << lower << " " << upper << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

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

    pair<int, int> p[n];
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        p[i] = make_pair(b, a);
    }
    sort(p, p+n);
    
    int t = 0;
    rep(i, n) {
        t += p[i].second;
        
        if(p[i].first < t) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;   
}    

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    int H,N,A[100000],sum=0;
    cin >> H >> N;
    REP(i,N){
        cin >>A[i];
        sum = sum+A[i];
    }
    if(H>sum){
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }

    return 0;    
}

Measured memory_bytes: 640
#pragma GCC optimize("03")
#include <bits/stdc++.h>
#define ll long long 
#define fi first
#define se second

//CHECK FOR N = 1 OR OTHER DUMB TESTS 

using namespace std;

int main() {
	//ifstream cin("tst.in");
	//ofstream out("tst.out");
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int a;
	string s;
	cin >> a >> s;
	if (a < 3200)
		cout << "red";
	else cout << s;	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

bool question(int n) {
    cout << n << endl;
    fflush(stdout);
    string seat;
    cin >> seat;
    if (seat == "Vacant") {
        fflush(stdout);
        exit(0);
    }
    else {
        return (seat == "Male");
    }
}
int main()
{
    int N;
    cin >> N;

    int left = 0, right = N - 1;
    bool head = question(left);
    bool tail = question(right);

    rep(i, 18) {
        int mid = (left + right) / 2;
        bool center = question(mid);
        if ((mid - left) % 2 && center == head || (mid - left) % 2 == 0 && center != head) {
            right = mid;
            tail = center;
        }
        else {
            left = mid;
            head = center;
        }
    }
}

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

int n;

int main() {
	cin >> n;
  	int cnt = 0;
  	for (int i = 1; i <= n; i++)
      if (i & 1) cnt++;
  	cout << double (cnt) / (1.0 * n);

	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>

using namespace std;

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

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

    int types[200000];
    for (int i = 0; i < 200000; i++)
        types[i] = 0;

    for (int i = 0; i < n; i++)
        types[a[i]] += 1;

    sort(types, types+200000, greater<int>());

    int count = 0;
    for (int i = 0; i < 200000; i++) {
        if (i < k) {
            // do nothing
        } else
            count += types[i];
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <algorithm>    // std::copy
#include <iterator>     // std::back_inserter
#include <set>
using namespace std;
 
int main(){
    int  A;
    int  B;

    cin >> A >> B;

    int m = A;
    int count = 1;
    if(B == 1){
        cout << 0 << endl;
        return 0;
    }

    for(int i = 0; i < 30 ; i++){
        if(m >= B){
            break;
        }
        else {
            count++;
            m--;
            m+=A;
        }
    }
    cout << count << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << ((b - a) == (c - b) ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    n = list(input())
    if '7' in n:
        print('Yes')
    else:
        print('No')



if __name__ == '__main__':
    solve()


Measured memory_bytes: 9064
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll N;
    cin >> N;
    ll A[N];
    ll g = 0;
    rep(i,N){
        cin >> A[i];
        if(i==0) g = A[0];
        else g = __gcd(g,A[i]);
    }
    ll out = g;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  if(b==0)return a;
  return gcd(b,a%b);
}

int main(){
  int n;
  cin>>n;
  int ans;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    if(i!=0){
      if(ans<a)swap(ans,a);
      ans=gcd(ans,a);
    }
    else ans=a;
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = (a), i_len = (b); i < i_len; ++i)

int main()
{
    int N;
    cin >> N;
    REP(i, 1, N + 1) if(N%i == 0) {
        int a = i, b = N/i;
        if(a <= 9 && b <= 9) { cout << "Yes" << endl; return 0; }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b;
	double f;
	scanf("%d",&a);
	scanf("%d",&b);
	if(1<=a&&b<=1E+9){
		int d=a/b;
		int r=a%b;
		f=(double)a/b;
		
		printf("%d %d %lf\n",d,r,f);
	}
	else{
		printf("error");
	}
	return 0;
}

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

int main() {
  string s, t; cin >> s >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  if (s<t) cout << "Yes" << endl;
  else cout << "No" << endl;
}
  
  
  
  
  

Measured memory_bytes: 256
ABCD=input()
A,B,C,D=[ABCD[_] for _ in range(4)]
a,b,c,d=int(A),int(B),int(C),int(D)
if a+b+c+d==7:
    print(A+'+'+B+'+'+C+'+'+D+'=7')
elif a+b+c-d==7:
    print(A+'+'+B+'+'+C+'-'+D+'=7')
elif a+b-c+d==7:
    print(A+'+'+B+'-'+C+'+'+D+'=7')
elif a+b-c-d==7:
    print(A+'+'+B+'-'+C+'-'+D+'=7')
elif a-b+c+d==7:
    print(A+'-'+B+'+'+C+'+'+D+'=7')
elif a-b+c-d==7:
    print(A+'-'+B+'+'+C+'-'+D+'=7')
elif a-b-c+d==7:
    print(A+'-'+B+'-'+C+'+'+D+'=7')
elif a-b-c-d==7:
    print(A+'-'+B+'-'+C+'-'+D+'=7')

Measured memory_bytes: 3064
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int n;
	while(scanf("%d", &n)==1)
	{
		vi h(n);

		for(int i=0;i<n;i++) scanf("%d", &h[i]);
		int ans=0, max_h=-1;

		for(int i=0;i<n;i++)
		{
			if(max_h<=h[i])
			{
				max_h=h[i];
				ans++;
			}
		}

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


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

int main(){
    
    string S;
    cin >> S;
    
    int a = 0;
    int b = 0;
    int c = 0;
    for(int i = 0; i < S.size();i++){
        if(S[i] =='a')a++;
        else if(S[i] =='b')b++;
        else if(S[i] =='c')c++;
    }
    
    if(a==0&&b==0&&c==0)cout <<"NO"<<endl;
    else if(abs(a-b)<=1&&abs(b-c)<=1&&abs(a-c)<=1)cout <<"YES"<<endl;
    else cout <<"NO"<<endl;
    
    
    
}

    
    



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

using namespace std;

template <typename T>
vector<pair<T, Int>> factorize(T n) {
	vector<pair<T, Int>> ret;

	for (T p = 2; p * p <= n; ++p) {
		if (n % p != 0) { continue; }

		int num = 0;
		while (n % p == 0) {
			++num;
			n /= p;
		}
		ret.emplace_back(p, num);
	}
	if (n != 1) { ret.emplace_back(n, 1); }

	return ret;
}

int64_t modpow(int64_t a, int64_t b, int64_t MOD) {
	int64_t ret = 1;
	while (b > 0) {
		if (b & 1) { (ret *= a) %= MOD; }
		(a *= a) %= MOD;
		b >>= 1;
	}
	return ret % MOD;
}

int main() {
	const Int MOD = 1e9 + 7;
	Int N;
	cin >> N;
	vector<Int> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }

	// map<Int, Int> mp;
	unordered_map<Int, Int> mp;
	vector<vector<pair<Int, Int>> > va(N);
	for (int i = 0; i < N; ++i) {
		va[i] = factorize(a[i]);
		for (auto p : va[i]) {
			mp[p.first] = max(mp[p.first], p.second);
		}
	}

	Int ans = 0;
	for (int i = 0; i < N; ++i) {
		Int B = 1;
		set<Int> st;
		for (auto p : va[i]) {
			st.insert(p.first);
			(B *= modpow(p.first, mp[p.first] - p.second, MOD)) %= MOD;
		}
		for (auto it = mp.begin(); it != mp.end(); ++it) {
			if (st.count(it->first) > 0) { continue; }
			(B *= modpow(it->first, it->second, MOD)) %= MOD;
		}
		(ans += B) %= MOD;
	}
	cout << ans % MOD << endl;

	return 0;
}


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

const ll MOD = 1e9+7;
vector<ll> fac, ifac;
ll comb(int n, int k){
  return fac[n]*ifac[k]%MOD * ifac[n-k]%MOD;
}

template<class T> T powmod(T x, ll n, ll m)
{
    T r = 1;
    T a = x % m;
    while (n>0)
    {
        if (n & 1)
            r = (r*a)%m;
        a = (a*a)%m;
        n = n >> 1;
    }
    return r;
}

template<class T> T gcdi(T m, T n){
    T x1 = 0;
    T y1 = 1;
    T x2 = 1;
    T y2 = 0;
    T r, q, tmp;
    T mod = n;
    while(n)
    {
        r = m%n;
        q = m/n;
        m = n;
        n = r;

        tmp = x1;
        x1 = x2 - q*x1;
        x2 = tmp;

        tmp = y1;
        y1 = y2 - q*y1;
        y2 = tmp;
    }
    if (x2<0) x2 += mod;
    return x2;
}

int main(){
  int n, m;
  scanf("%d%d",&n,&m);
  //n = 2; m = 1000000000;
  //n = 2; m = 17*17;
  //n = 3; m = 12;
  //n = 100000; m = 1000000000;

  int n2 = max(50, n);
  fac.resize(n2+1); ifac.resize(n2+1);
  fac[0] = 1;
  for(int i=1; i<=n2; i++){
    fac[i] = fac[i-1]*i%MOD;
  }
  ifac[0] = 1;
  for(int i=1; i<=n2; i++){
    ifac[i] = ifac[i-1]*gcdi((ll)i, MOD)%MOD;
  }

  map<int, int> fact;
  int m2 = m;
  for(int d=2; (ll)d*d <= m; ){
    if (m2%d==0){
      fact[d]++;
      m2 /= d;
    }
    else
      d++;
  }
  if (m2>1){
    fact[m2]++;
  }

  ll sol = 1;
  for(auto it : fact){
    ll y = 0;
    for(int i=1; i<=min(n,it.second); i++){
      y += comb(it.second-1, i-1) * comb(n, i) % MOD;
      if (y>=MOD)
        y -= MOD;
    }
    sol = sol * y % MOD;
  }
  printf("%lld\n", sol);
  return 0;
}


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

int main() {
  long long int A, B;
  cin >> A >> B;
  if(A%2 == B%2) {
    cout << (A + B) / 2 << endl;
  }
  else
    cout << "IMPOSSIBLE" << endl;

  return 0;
  
}

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



int main(){
    char c[3];
    rep(i,0,3)cin>>c[i];
    int ok=0;
    rep(i,0,3){
        if(c[i]=='7')ok=1;
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
    









Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int N, T;
    cin >> N >> T;
    int ans = 1e9;
    for(int i = 0; i < N; i++){
        int c, t;
        cin >> c >> t;
        if(t <= T){
            ans = min(ans, c);
        }
    }
    if(ans == 1e9){
        cout << "TLE" << endl;
    }else{
        cout << ans << endl;
    }
}


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

int main(){
 int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  long long sum=0;
  for(int i=1;i<N;i++){
    if(A.at(i)<A.at(i-1)){
      sum+=A.at(i-1)-A.at(i);
      A.at(i)=A.at(i-1);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 4052
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def is_p(s):
    n = len(s)
    a, b = s, s[::-1]
    if a==b:
        return True
    return False

def main():
    s = input()
    n = len(s)


    a = s[:(n-1)//2]
    b = s[(n+3)//2 -1:]
    if is_p(s) and  is_p(a) and is_p(b):
        print('Yes')
    else:
        print('No')

    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 5332
#include <bits/stdc++.h>
using namespace std;
long long int big = 10e100;

int main() {
    long long int n, a, b;
    cin >> n >> a >> b;
    long long int x = n / (a + b);
    long long int y = n % (a + b);
    long long int ans = a*x + min(a, y);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  vector<ll> ys;
  vector<tuple<ll,ll,ll,ll>> rectangles;
  ll n;
  cin >> n;
  rep(i,n) {
    ll x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    rectangles.emplace_back(x1,y1,x2,y2);
    ys.push_back(y1);
    ys.push_back(y2);
  }
  sort(all(ys)); // increasing order
  ys.erase(unique(all(ys)), ys.end()); // uniquify

  ll ans = 0;
  rep(i, ys.size()-1) {
    ll miny = ys[i];
    ll maxy = ys[i+1];
    vector<P> xs; // <x,type>. type = 0 .. open, type = 1 .. close.
    for (auto& rec : rectangles) {
      ll x1,y1,x2,y2;
      tie(x1,y1,x2,y2) = rec;
      if (y1 <= miny && maxy <= y2) { // rec is effective.
        xs.emplace_back(x1, 0); // open
        xs.emplace_back(x2, 1); // close
      }
    }
    sort(all(xs));
    ll dx = 0;
    ll cnt = 0;
    ll pre = 0;
    for (auto& p : xs) {
      if (p.second == 0) { // open
        if (cnt == 0) {
          pre = p.first;
        }
        ++cnt;
      } else { // p.second == 1. close
        if (cnt == 1) {
          dx += p.first - pre;
        }
        --cnt;
      }
    }
    ans += dx*(maxy-miny);
  }
  cout << ans << endl;
}



Measured memory_bytes: 3288