akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;
int main() {
    string a;
    int y=0,m=0,d=0;
    
    cin >> a;
    y=stoi(a.substr(0,4));
    m=stoi(a.substr(5,2));
    d=stoi(a.substr(8,2));
    
    if (y<=2018) cout <<"Heisei";
    else if (m>4) cout <<"TBD";
    else cout << "Heisei";
    cout << endl;
    
}



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

int main(){
  ll n,x=0;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(i>1)x^=a[i];
  }
  ll s=a[0]+a[1];
  if(s<x || (s-x)%2!=0){cout<<-1<<endl;return 0;}
  ll d=(s-x)/2;
  if(d>a[0]){cout<<-1<<endl;return 0;}
  for(ll i=0;i<42;i++){
    if(((d>>i)&1)==1 && ((x>>i)&1)==1){cout<<-1<<endl;return 0;}
  }
  ll ans=d;
  for(ll i=41;i>=0;i--){
    if(((x>>i)&1)==1)if(ans+((ll)1<<i)<=a[0])ans+=((ll)1<<i);
  }
  cout<<(ans==0?-1:a[0]-ans)<<endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
using namespace std;
long long i[10000][10000];
long long u[1111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e=1,f=0;
  cin >>a>>b>>c;
  d=a+b;
  if(c<=b) cout <<"delicious\n";
  else{
    if(d>=c) cout <<"safe\n";
    else cout <<"dangerous\n";
  }
  return (0);
}


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

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

int main() {
  int N, X; cin >> N >> X;
  int result = 1, sum = 0;
  rep(i, N) {
    int L; cin >> L;
    sum += L;
    if (sum>X) break;
    result++;
  }
  cout << result << endl;
  return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()

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

string s;

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

	cin>>s;
	REP(i,s.size()-8) cout<<s[i]<<flush;
	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())
X_list = list(map(int, input().split()))

res = 0
tmp_i = X_list[0]
for x in X_list:
    a_fatigue = A * (x - tmp_i)
    b_fatigue = B
    tmp_fatigue = min(a_fatigue, b_fatigue)
    res += tmp_fatigue
    tmp_i = x
print(res)
    

Measured memory_bytes: 20068
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#define _USE_MATH_DEFINENS
#include <cmath>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int n, k, x, y;
    cin >> n >> k >> x >> y;

    int ans = 0;
    for(int i = 0; i < n; i++){
        if(i >= k) ans += y;
        else ans += x;
    }   
    p(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;

int main(){
  int n;
  cin >> n;
  string a = "APPROVED";
  for(int i=0; i<n; i++){
    int in;
    cin >> in;
    if(in%2 == 0){
      if(in%3!=0 && in%5!=0){
        a = "DENIED";
      }
    }
  }
  
      cout << a;
}

Measured memory_bytes: 256
pub fn read_parameters<T>() -> Result<Vec<T>, String>
where
    T: std::str::FromStr,
{
    let mut line = String::new();

    std::io::stdin()
        .read_line(&mut line)
        .map_err(|err| format!("{:?}", err))?;

    line.trim()
        .split_whitespace()
        .map(|x| x.parse::<T>())
        .collect::<Result<Vec<T>, _>>()
        .map_err(|_| format!("{}", "parse error"))
}

fn is_prime(n: usize) -> bool {
    if n == 1 {
        return false;
    }
    if n == 2 {
        return true;
    }
    if n % 2 == 0 {
        return false;
    }
    let mut d = 3;
    while d * d <= n {
        if n % d == 0 {
            return false;
        }
        d += 2;
    }
    return true;
}
fn main() {
    let n = read_parameters::<usize>().unwrap();

    let mut x = Vec::new();
    for _ in 0..n[0] {
        let a = read_parameters::<usize>().unwrap();
        x.push(a[0]);
    }
    let count = x
        .into_iter()
        .filter(|&n| is_prime(n))
        .collect::<Vec<_>>()
        .len();
    println!("{}", count);
}



Measured memory_bytes: 5056
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		int count1 = 0,count2 = 0;
		for( int i=0; i<S.length(); i++ ){
			char ch = S.charAt(i);
			if( i%2==0 ){
				if( ch=='0' ){
					count1++;
				}else{
					count2++;
				}
			}else{
				if( ch=='1' ){
					count1++;
				}else{
					count2++;
				}
			}
		}
		System.out.println(Math.min(count1,count2));
	}
}


Measured memory_bytes: 26068
//In the Name of God
//Ya Ali

#include <bits/stdc++.h>

#define int long long

#define err(A) cout << #A << " = " << (A) << endl

using namespace std;

int bmm(int x, int y)
{
  if (y)
    return bmm(y, x % y);
  return x;
}

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

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

  cout << a / bmm(a, b) * b << endl;
  
  return 0;
}


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

int main()
{
    string s;
    cin >> s;
    bool flag = true;
    for(char a = 'a';a <= 'z';a++){
        int cnt = 0;
        for(int i = 0;i < s.size();i++){
            if(s[i] == a) cnt++;
        }
        if(cnt%2 == 1) flag = false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = readInts >>= putStrLn . which "bust" "win" . ( 22 <= ) . sum

Measured memory_bytes: 380
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let n: u32 = s.trim().parse().ok().unwrap();

    for i in 1..n + 1 {
        if i * 108 / 100 == n {
            println!("{}", i);
            return;
        }
    }
    println!(":(")
}

Measured memory_bytes: 4352
#include<iostream>
#include<cctype>

using namespace std;

int main(){
	char ch[1201];
	int i=0;	
	cin.getline(ch,1201,'\n');
	

	while(1){
		if(ch[i]=='\0')
			break;
		if(islower(ch[i]))
			cout<<static_cast<char>(toupper(ch[i]));
		else if(isupper(ch[i]))
			cout<<static_cast<char>(tolower(ch[i]));
		else 
			cout<<ch[i];
		i++;
	}		
	cout<<endl;
}

Measured memory_bytes: 1124
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<math.h>
#include<map>
#include<unordered_map> 
#include<vector>
#include<queue>
#include<set>
#include<bits/stdc++.h>
#include<deque> 
#include<bitset>
#include<string>
#define N 40
#define K 300005
#define MOD 1e9+7
#define int long long 
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
 
int max(int a, int b){
    if(a>b)
        return a;
    return b;
}
int min(int a, int b){
    if(a<b)
        return a;
    return b;
}
 
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
 
bool isPrime(int n) 
{ 
    // Corner case 
    if (n <= 1) 
        return false; 
  
    // Check from 2 to n-1 
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return false; 
  
    return true; 
} 
int mod = 1e9 + 7;

int mark[100005]; 
int32_t main(){
	fastio
	int n, k;
	cin>>n>>k;
	int a[n + 1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int dp[k+1];
	for(int i=0;i<=n;i++){//if 0 stones are there them irrepective of hw many option are there pl 1 will win
		dp[0] = 2;
	}
	for(int st = 1; st<=k; st++){
		int fl = 0;
		for(int last = 1; last<= n; last++){
			if(st - a[last] >= 0){
                
				int left = st - a[last];
				if(dp[left] == 2)
                    fl = 1;
			}
		}
		if(fl == 1)
			dp[st] = 1;
		else
			dp[st] = 2;
        //cout<<st<<" "<<dp[st]<<endl;
	}	
	if(dp[k] == 1)
		cout<<"First";
	else
		cout<<"Second";


 
 
	
 
	 
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

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

    int cnt = 1;
    for(int i = 0; i < S.size()-1; i++){
        if(S[i] != S[i+1]){
            cnt++;
        }
    }

    cout << cnt-1 << endl;


    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }
ll mod = 1e9+7;
int F[100][14];
int P[100][15];
signed main() {
    ll n; cin>>n;
    rep(i,n)rep(j,10)cin>>F[i][j];
    rep(i,n)rep(j,11)cin>>P[i][j];
    int res=-1145141919;
    for(int b=1;b<(1<<10);b++){
        int cc=0;
        rep(i,n){
            int c=0;
            rep(j,10)if((b>>j&1)&&F[i][j])c++;
            cc+=P[i][c];
        }
        res=max(res,cc);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
import math
N,D=map(int,input().split())
List=[list(map(int,input().split())) for i in range(N)]

count=0
for i in range(N-1):
  for j in range(i+1,N):
    dist=0
    for d in range(D):
      dist+=(List[i][d]-List[j][d])**2
    dist=math.sqrt(dist)
    if int(dist)==dist:
      count+=1
print(count)

Measured memory_bytes: 3064
"use strict";

const main = arg => {
    // 標準入力の不要な空白と改行を削除し、配列に格納する
    const input = arg.trim().split(" ");
    const str = input[0];
    const three = str.charAt(2);
    const four = str.charAt(3);
    const five = str.charAt(4);
    const six = str.charAt(5);

    three === four && five === six
        ? console.log('Yes')
        : console.log('No');

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

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

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    int x; cin >> x;
    if (x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

char field[324][324];
Int lsum[323][324];
Int rsum[324][324];
Int res = 0;
Int h, w;
Int cntl(Int x, Int y){
  if(x-y < 1-w || x-y > h-1)return 0;
  if(x < 0){
    Int k = -x;
    x += k;
    y += k;
  }
  if(y < 0){
    Int k = -y;
    x += k;
    y += k;
  }
  if(x > h){
    Int k = x-h;
    x -= k;
    y -= k;
  }
  if(y > w+1){
    Int k = y-w-1;
    x -= k;
    y -= k;
  }
  return lsum[x][y];
}

Int cntr(Int x, Int y){
  if(x+y < 2 || x+y > h+w)return 0;
  if(x < 0){
    Int k = -x;
    x += k;
    y -= k;
  }
  if(y < 0){
    Int k = -y;
    x -= k;
    y += k;
  }
  if(x > h){
    Int k = x-h;
    x -= k;
    y += k;
  }
  if(y > w+1){
    Int k = y-w-1;
    x += k;
    y -= k;
  }
  return rsum[x][y];
}

int main(){
  cin >> h >> w;
  for(Int i = 1;i <= h;i++){
    for(Int j = 1;j <= w;j++){
	cin >> field[i][j];
    } 
  }
  for(Int i = 0;i <= h;i++){
    for(Int j = 0;j <= w+1;j++){
      if(i == 0 || j == 0)lsum[i][j] = 0;
      else lsum[i][j] = lsum[i-1][j-1] + (field[i][j] == '#');
      if(i == 0 || j == w+1)rsum[i][j] = 0;
      else rsum[i][j] = rsum[i-1][j+1] + (field[i][j] == '#');
    }
  }

  for(Int i = 1;i <= h;i++){
    for(Int j = 1;j <= w;j++){
      if(field[i][j] == '.')continue;
      Int xi = i+1, xj = j+1;
      for(;xi <= h && xj <= w;xi++,xj++){
	if(field[xi][xj] == '.')continue;
	res += cntl(xi+xi-i,j)-cntl(xi-1,j+j-xj-1);
	res += cntl(i,xj+xj-j) - cntl(i+i-xi-1, xj-1);
      }
      xi = i+1, xj = j-1;
      for(;xi <= h && xj >= 1;xi++,xj--){
	if(field[xi][xj] == '.')continue;
	res += cntr(xi+xi-i-1,j+1) - cntr(xi,j+j-xj);
	//	cout << i << " " << j << " " << xi << " " << xj << endl;
	//cout << xi+xi-i-1 << " " << j+1 << " " << xi << " " << j+j-xj << endl;
	//cout << cntr(xi+xi-i-1,j+1) << " "  <<  cntr(xi,j+j-xj) << endl;
	res += cntr(i-1,xj+xj-j+1) - cntr(i+i-xi,xj);
      }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1920
#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <string>
#include <string.h>
#include <limits>
#include <utility>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <chrono>

using namespace std;

namespace
{

}

#if 1
int main()
{
	int n, t;

	cin >> n >> t;

	int minCost = std::numeric_limits<int>::max();

	for (int i = 0; i < n; i++)
	{
		int cost, time;
		cin >> cost >> time;

		if (time <= t)
		{
			if (cost < minCost)
			{
				minCost = cost;
			}
		}
	}

	if (minCost == std::numeric_limits<int>::max())
	{
		printf("TLE\n");
	}
	else
	{
		printf("%d", minCost);
	}

	return 0;
}
#endif


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


int main(){
  int n,i;
  cin >> n;
  vector<int> a(n);
  int on,fo,tw;
  on=0;
  fo=0;
  tw=0;
  for(i=0;i<n;++i){
    cin >> a[i];
    if(a[i]%4==0){
      fo++;
    }else if(a[i]%2==0 && a[i]%4!=0){
      tw++;
    }else{
      on++;
    }
  }
  if(tw==0){
    if(fo>=on-1){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    if(fo>=on){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;

}


Measured memory_bytes: 640
def is_prime(x):
    if x == 1:
        return False
    elif x == 2:
        return True
    elif x % 2 == 0:
        return False
    l = x ** 0.5
    n = 3
    while n <= l:
        if x % n == 0:
            return False
        n += 2
    return True
 
def solve():
    n = int(input())
    print("{}: ".format(n), end='')
    ans = []
     
    while n % 2 == 0:
        n //= 2
        ans.append(2)
 
    d = 3
    while n >= d:
        if is_prime(d):
            while n % d == 0:
                n //= d
                ans.append(d)
        if is_prime(n):
            ans.append(n)
            break
        d += 2
 
    print(*ans)
 
solve()

Measured memory_bytes: 7764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;


#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> // find_by_order(); order_of_key();
#define mod 1000000007
#define ll long long int
#define mk make_pair
#define pb push_back
#define xx first
#define yy second



double pi=3.141592653589793238;
const int M = 1e9+7;
const int Nmax=5005;
const int MM = 1e7+1;
const int N=100005;



int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T=1;
//cin>>T;
while(T--){

int n;
cin>>n;
map<int,int> m;
for(int i=1;i<=100;i++){
    for(int j=1;j<=100;j++){
        for(int k=1;k<=100;k++){
            m[i*i+j*j+k*k+i*j+j*k+k*i]++;
        }
    }
}
for(int i=1;i<=n;i++){
    cout<<m[i]<<"\n";
}
}
return 0;
}


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


using namespace std;


const int MOD = 1e9 + 7;
const int N = 1e5;
const long long INF = 1e9;


int main() {
    int n;
    cin >> n;
    vector<int> a (n);
    for (int& x : a)
        cin >> x;
    sort(a.begin(), a.end());
    long long ans = 1ll * n * (n - 1) * (n - 2) / 6;
    long long cnt = 0;
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            cnt += n - (lower_bound(a.begin(), a.end(), a[i] + a[j]) - a.begin());
    cout << ans - cnt;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;
const int i_INF = 2147483647;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	int n;
	cin >> n;
	bool ju = false;
	rep(i, 1, 10)rep(j, 1, 10) {
		if (n == j * i)ju = true;
	}
	if (ju)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
X=int(input())
N=10**3
i=-1000
res=[]

while(i<N):
  j=-1000
  while(j<N):
    if(i**5 - j**5==X):
      res.append(i)
      res.append(j)
      break
    j+=1
  if(1<len(res)):
    break
  i+=1

print(str(res[0])+" " +str(res[1]))

Measured memory_bytes: 9016
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;
ll gcd(ll a, ll b) {
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}
ll extgcd(ll a, ll b, ll &x, ll &y) {
	int d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else {
		x = 1;
		y = 0;
	}
	return d;
}
ll factorial(ll x) {
	int ret = 1;
	for (int i = 1; i <= x; i++) {
		ret *= i;
		ret %= MOD;
	}
	return ret;
}
ll pow(ll x, int n) {
	if (n == 0)
		return 1;
	ll ret = (n & 1) ? x : 1;
	ll a = pow(x, n / 2);
	return ret * a * a;
}
int mInverse(int a, int m) {
	int x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}
int comb(int n, int k) {
	return (((factorial(n) * mInverse(factorial(k), MOD)) % MOD) * mInverse(factorial(n - k), MOD)) % MOD;
}
int N, M, K, T, Q;
signed main() {
	int X, Y;
	cin >> X >> Y;
	int s = (2 * Y - X) / 3;
	int t = (2 * X - Y) / 3;
	int ans;
	//cout << s << " " << mInverse(s, MOD) << endl;
	if (s >= 0 && t >= 0 && s * 3 == 2 * Y - X && t * 3 == 2 * X - Y) {
		ans = comb(s + t, s);
	} else {
		ans = 0;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){

int n;
cin>>n;

for(int i=1;i<=n;i++){
    int x=i;
    if(x%3==0){
        cout<<" "<<i;
    }else{
        while(x){
            if(x%10==3){
                cout<<" "<<i;
                break;
            }
            x /= 10;
        }
    }
}
cout<<endl;
    return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int main(){
	string S,T;
	cin >> S >> T;
	if(S.size() > T.size()) cout << "GREATER" << endl;
	else if(S.size() < T.size()) cout << "LESS" << endl;
	else{
		for(int i=0; i<S.size(); i++){
			if(S[i] - T[i] > 0){
				cout << "GREATER" << endl;
				return 0;
			}
			else if(S[i] - T[i] < 0){
				cout << "LESS" << endl;
				return 0;
			}
		}
		cout << "EQUAL" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

char s[200010];
int n;

int dp[1<<26];

const int inf = 1e9;

int main()
{
	scanf("%s", s+1); n=strlen(s+1);
	fill(dp, dp+(1<<26), inf);
	dp[0]=0;
	
	int key=0;
	int ans=inf;
	for(int i=1; i<=n; ++i){
		int p=(s[i]-'a');
		key ^= (1<<p);
		for(int j=0; j<26; ++j){
			if(dp[key ^ (1<<j)] != inf){
				dp[key] = min(dp[key], dp[key ^ (1<<j)] + 1);
			}
		}
		ans = dp[key];
	}
	if(key == 0){
		puts("1");
		return 0;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 262656
#include <bits/stdc++.h>
using namespace std;
 int main(){
 int N;
   string S;
   cin >> N;
   cin >> S;
   bool a = true;
   for(int i =0;i < N/2;++i){
   if(S.at(i) != S.at(N/2+i))
     a = false;
   }
   if(N % 2 != 0)
     a = false;
   if(a == false)
     cout<< "No" << endl;
   else
     cout << "Yes" << endl;
 }

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

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

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

int ketawa(LL a){
    LL ret = 0;
    while(a > 0) ret += a % 10, a /= 10;
    return ret;
}

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

    int k;
    cin >> k;
    LL a = 1, b = 1;
    cout << 1 << endl;
    REP(i, k-1){
        if(ketawa(a + b) * (a + b*10) < ketawa(a + b*10) * (a + b)) b *= 10;
        a += b;
        cout << a << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b);
#define chmin(a, b) (a)=min(a, b);
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll N, K;
ll a[MAX*2];

ll ok(ll m) {
  ll i;
  ll cnt=0;
  
  for(i=0; i<N; i++) {
    if(a[i]>0) {
      ll b=m/a[i];
      if(m<0&&m%a[i]) b--;
      cnt+=min(i, (ll)(upper_bound(a, a+N, b)-a));
    }else if(a[i]<0) {
      ll b=m/a[i];
      if(m<0&&m%a[i]) b++;
      cnt+=max(0LL, i-(ll)(lower_bound(a, a+N, b)-a));
    }else {
      if(m>=0) cnt+=i;
    }
  }
  
  return cnt>=K;
}


int main(void) {
  ll i, j, k;
  
  cin >> N >> K;
  
  for(i=0; i<N; i++) cin >> a[i];
  sort(a, a+N);
  
  ll l=-INF-7, r=INF+7;
  while(l+1<r) {
    ll m=(l+r)/2;
    if(ok(m)) r=m;
    else l=m;
  }
  
  pt(r);
  
}





Measured memory_bytes: 1792
import sys
import math
n = int(input())
A = list(map(int, input().split()))
NODE_RANGE = [0 for i in range(n+1)]
NODE_RANGE[n] = [A[n], A[n]]
NODE_MAX = [0 for i in range(n+1)]
NODE_MAX[0]=1
# d=nから見ていって、各dに対するノードの最小値、最大値を求める
for i in range(n-1, -1, -1):
    node_min = math.ceil( NODE_RANGE[i+1][0]/2 ) + A[i]
    node_max = NODE_RANGE[i+1][1] + A[i]
    NODE_RANGE[i]=[node_min, node_max]

if NODE_RANGE[0][0] > 1 or 1 > NODE_RANGE[0][1]: # d=0の時のノード数は1
    print(-1)
    sys.exit()

# print(NODE_RANGE)
# d=0から最大ノード数を確定させていく
for i in range(1, n+1):
    NODE_MAX[i] = min((NODE_MAX[i-1]-A[i-1])*2, NODE_RANGE[i][1])
    # print(NODE_MAX[i-1] + A[i], NODE_RANGE[i][1])
# print(NODE_MAX)
print(sum(NODE_MAX))

Measured memory_bytes: 33520
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int arr[n][3];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
  }
int dp[n][3]={0};
dp[0][0]=arr[0][0];
dp[0][1]=arr[0][1];
dp[0][2]=arr[0][2];
for(int i=1;i<n;i++)
{
  dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
  dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
  dp[i][2]=arr[i][2]+max(dp[i-1][1],dp[i-1][0]);
}
cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));

}


Measured memory_bytes: 2560
#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
	string str; cin >> str;
	while(true){
		str.erase(str.end()-1);
		int size_ = str.size()/2;
		string s1 = str.substr(0,size_);
		string s2 = str.substr(size_,str.size()-size_);
// 		cout << s1 << " " << s2 << endl;
		if(s1==s2) break;

	}
	cout << str.size() << endl;
	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    if (n % 10 == 7 || n / 10 % 10 == 7 || n / 100 % 10 == 7) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}


Measured memory_bytes: 3636
import java.io.*;
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args)throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		System.out.println((1000-(n%1000))%1000);
		out.close();
	}
	static class FastIO {
		InputStream dis;
		byte[] buffer = new byte[1 << 17];
		int pointer = 0;
		public FastIO(String fileName) throws IOException {
			dis = new FileInputStream(fileName);
		}
		public FastIO(InputStream is) throws IOException {
			dis = is;
		}
		int nextInt() throws IOException {
			int ret = 0;
 
			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}
 
			return (negative) ? -ret : ret;
		}
		long nextLong() throws IOException {
			long ret = 0;
 
			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}
			return (negative) ? -ret : ret;
		}
		byte nextByte() throws IOException {
			if (pointer == buffer.length) {
				dis.read(buffer, 0, buffer.length);
				pointer = 0;
			}
			return buffer[pointer++];
		}
		String next() throws IOException {
			StringBuffer ret = new StringBuffer();
 
			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			while (b > ' ') {
				ret.appendCodePoint(b);
				b = nextByte();
			}
 
			return ret.toString();
		}
	}
}


Measured memory_bytes: 35772
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, a;
	vector<int>v(1, 0);
	cin >> n;
	while (n--)
	{
		cin >> a;
		v.push_back(a);
	}
	for (int j = 1; j < v.size(); j++)
	{
		int key = v[j];
		int  i = j - 1;
		while (i > 0 && key < v[i])
		{
			v[i + 1] = v[i];
			i--;
		}
		v[i + 1] = key;
		for (int j = 1; j<v.size(); j++) {
			cout << (j == 1 ? "" : " ") << v[j];
		}
		cout << endl;
		
	}
	//return 0;
}


Measured memory_bytes: 3152
import sys
readline = sys.stdin.readline
N, Q = map(int, readline().split())
S = readline()
D = [0]*(N+1)
for i in range(N-1):
    D[i+1] = D[i] + (S[i] == 'A' and S[i+1] == 'C')
D[N] = D[N-1]
ans = []
for i in range(Q):
    l, r = map(int, readline().split())
    if S[r-1] == 'A':
        r -= 1
    ans.append("%d\n" % (D[r] - D[l-1]))
sys.stdout.writelines(ans)

Measured memory_bytes: 14244
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	int N,sw = 0,a = 0,check = 0;
  char c = 'z';
  string s,s2,s3;
  cin >> s;
  if(s.length() < 26){
    s2 = s;
    sort(s2.begin(),s2.end());
  for(char i = 'a';i <= 'z';i++){
    if(s2[a] != i){
      s += i;
      cout << s << endl;
      return 0;
    }
    a++;
  }
  }else{
    s2 = s;
  sort(s2.begin(),s2.end());
    for(int i = 26;i >= 1;i--){
        for(int j = i;j <= 26;j++){
          if(s[i - 1] < s[j - 1] && c >= s[j - 1]){
            c = s[j - 1];
            sw = 1;
          }
        }
        if(sw == 1){
          s[i - 1] = c;
            for(int k = 0;k < 26;k++){
              if(k != i){
              cout << s[k];
              }else{
                cout << endl;
                return 0;
              }
          }
        }
        }
 cout << -1 << endl;
  }
  return 0;
}

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

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

	int ans = 0;
	rep(i,S.size()) ans += int(S[i]-'0');
	rep(i,S.size()) {
		int tmp = int(S[i]-'0') - 1 + 9*(S.size()-i-1);
		rep(j,i) tmp += int(S[j]-'0');
		ans = max(ans,tmp);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin >> N;
    vector<pair<int, int>> x(N);
    for(int i = 0; i < N; i++) {
        int d;
        cin >> d;
        x[i] = make_pair(d, i);
    }
    sort(x.begin(), x.end());
    int l = x[(N-1)/2].first, r = x[(N+1)/2].first;
    int ans[N];
    for (int i = 0; i < N; i++)
    {
        if(x[i].first <= (l + r) / 2) {
            ans[x[i].second] = r;
        }
        else {
            ans[x[i].second] = l;
        }
    }
    for (int i = 0; i < N; i++)
    {
        cout << ans[i] << endl;
    }

    return 0;
}

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

int main() {
	int A, B, ans;
	string x;
	cin >> A >> x >> B;

	if (x == "+") {
		ans = A + B;
	}
	else if (x == "-") {
		ans = A - B;
	}
	cout << ans;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
int main()
{
  lli n,W;
  cin>>n>>W;
  lli v[n];
  lli w[n];
  lli sum=0;
  for(int i=0;i<n;i++)
  {
     cin>>w[i]>>v[i];
     sum+=v[i];
  }
  lli dp[sum+1];
  fill(dp,dp+sum+1,INT_MAX);
  dp[0]=0;
  for(int i=0;i<n;i++)
  {
      for(int j=sum;j>=v[i];j--)
      {
          dp[j]=min(dp[j],w[i]+dp[j-v[i]]);
      }
  }
  lli mx=INT_MIN;
  for(int i=0;i<=sum;i++)
  {   
       if(dp[i]<=W  && dp[i]!=LONG_MAX) mx=max(mx,(lli)i);
  }
    cout<<mx<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    vi v(100,0);
    string hoge; cin>>hoge; bool mybool=true;
    rep(i,hoge.size())v[(int)hoge[i]-'a']++;
    rep(i,(int)'z'-(int)'a')if(v[i]%2)return puts("No")*0;
    puts("Yes");
}

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

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

fn main() {
    let n: usize = input();
    let ta: Vec<(i64, i64)> = (0..n)
        .map(|_| {
            let t = input();
            let a = input();
            (t, a)
        })
        .collect();

    let mut ans = (1, 1);
    for (t, a) in ta {
        let m = std::cmp::max((ans.0 + t - 1) / t, (ans.1 + a - 1) / a);
        ans = (t * m, a * m);
    }

    println!("{}", ans.0 + ans.1);
}


Measured memory_bytes: 4352
def check(s):
    if not s: return False
    res = True
    for i in range(len(s)//2):
        if s[i] != s[-1-i]: res = False

    return res

S = input()
N = len(S)

if check(S) and check(S[:(N-1)//2]) and check(S[(N+3)//2-1:]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    int ans=0;
    int mx=2;
    ans+=a[1]-1;
    for(int i=2;i<=n;i++)
    {
        if(a[i]==mx)
        {
            mx=a[i]+1;
        }
        else
        {
            ans+=(a[i]-1)/mx;
        }        
    }
    cout<<ans;

} 



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin>>n;
    ll a[n][3];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    ll dp[n+1][3];
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(ll i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
        dp[i][1]=max(dp[i-1][2],dp[i-1][0])+a[i][1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Measured memory_bytes: 4992
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=[0 for i in range(1, N+2)]
i=1
while i<=N:
    D[0]=0
    D[i]=D[i-1]+L[i-1]
    if D[i]>X:
        print(i)
        break
    i+=1
else:
    print(i)

Measured memory_bytes: 3060
/***  بسم الله الرحمن ا لرحيم   ***/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
//#include<unordered_map>
#define endl                         '\n'	
#define Ceil(x,y)             ((x+y-1)/y)
#define sz(s)               (int)s.size()
#define RT(x)           return cout<<x,0;
#define mem(x,y)    memset(x,y,sizeof(x))
#define all(v) ((v).begin()), ((v).end())
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define test int t;cin>>t;while(t--)
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
const double PI = acos(-1), EPS = 1e-7;
const int OO = 0x3f3f3f3f, N = 2e5 + 5, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ull gcd(ull x, ull y) { return (!y) ? x : gcd(y, x % y); }
ull lcm(ull x, ull y) { return ((x / gcd(x, y)) * y); }
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif  !ONLINEJUDGE
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main() {
	//file();
	int n;
	cin >> n;
	ull x,g; g = 1;
	while (n--){
		cin >> x;
		g = lcm(x, g);
	}
	RT(g);

}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val N = readInt()
  val map = mutableMapOf<String, Int>()
  repeat(N) {
    val S = readString()
    val v = map[S]
    if (v == null) {
      map[S] = 1
    } else {
      map[S] = v + 1
    }
  }
  val max = map.values.max()

  println(map.entries.filter { it.value == max }.map { it.key }.sorted().joinToString("\n"))
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  string s ;
  cin >> s ;
  
  rep(i,s.size())
    cout << "x";


}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {



    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int turn=0;
    while(a>0&&c>0){
        if(!turn){
            c-=b;
        } else {
            a-=d;
        }
        turn = 1-turn;
        // cout<<a<<" "<<c<<endl;
    }
    if(a<=0)fin("No");
    else fin("Yes");
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
LL K;
LL gcd (int a,int b){
	if(a<b)return gcd(b,a);
	if(b==0){
		return a;
	}
	return gcd(b,a%b);
}

int main(){
	cin>>K;
	LL ans=0;
	REP(i,K){
		REP(j,K){
			REP(k,K){
				LL a=gcd(i+1,j+1);
				ans+=gcd(a,k+1);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

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

  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if (a + b >= k) {
    cout << min(a, k) << "\n";
  } else {
    int left = k - (a + b);
    cout << a - left << "\n";
  }
}

Measured memory_bytes: 3636
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from random import *

def readln():
    _res = list(map(int,str(input()).split(' ')))
    return _res

p = 1000000000 + 7

n = readln()[0]
f = [0 for i in range(0,n+10)]
f[1] = n
f[2] = n * n
s = f[:]
s[2] = f[1] + f[2]
for i in range(3,n+1):
    f[i] = f[i-1] + (n - 1) * (n - 1)
    f[i] = f[i] + s[i - 3] + (n - i + 2)
    f[i] = f[i] % p
    s[i] = s[i - 1] + f[i]
    s[i] = s[i] % p
print(f[n])


Measured memory_bytes: 82616
#include "bits/stdc++.h"
using namespace std;

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

	int cnt = 0;
	int cnt_max = 0;
	int64_t h_before = 0;
	for (int i = 0; i < n; i++) {
		int64_t h;
		cin >> h;
		if (h <= h_before) {
			cnt++;
			if (cnt > cnt_max) {
				cnt_max = cnt;
			}
		} else {
			cnt = 0;
		}
		h_before = h;
	}

	cout << cnt_max << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
	static char[] list = new char[]{'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = Integer.parseInt(stdIn.nextLine());
		for(int i = 0; i < n; i++) {
			String tmp = stdIn.nextLine();
			solv(tmp);
		}
	}
	public static void solv(String tmp) {
		for(int a = 1; a < 10000; a++) {
			for(int b = 0; b < 26; b++) {
				if(a % 2 == 0 || a % 13 == 0 || a % 26 == 0) continue;
				if(check(p(tmp,a,b))) {
					return;
				}
			}
		}
	}
	
	public static String p(String a, int b, int c) {
		StringBuffer ret = new StringBuffer();
		for(int i = 0; i < a.length(); i++) {
			if(a.charAt(i) == ' ') { 
				ret.append(" ");
				continue;
			}
			int y = Arrays.binarySearch(list, a.charAt(i));
			int ans = (b * y + c) % 26;
			ret.append(list[ans]);
		}
		return ret.toString();
	}
	
	public static boolean check(String a) {
		for(int i = 0; i < a.length()-3; i++) {
			String tmp = a.substring(i, i+4);
			if(tmp.equals("that") || tmp.equals("this")) {
				System.out.println(a);
				return true;
			}
		}
		return false;
	}
}

Measured memory_bytes: 25996
#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,j,k,n1,n2,temp;
    char str[1000], work[10], rstr[1000];
    scanf("%s",&str);
    scanf("%d",&n);
    while(n--)
    {
        scanf("%s",&work);
        if(strcmp(work,"replace")==0)
        {
            scanf("%d %d %s",&n1,&n2,&rstr);
            for(i=n1,j=0;i<=n2;i++,j++)
            {
                str[i]=rstr[j];
            }
        }
        if(strcmp(work,"reverse")==0)
        {
            scanf("%d %d",&n1,&n2);
            for(i=n1,j=0;i<=n2;i++,j++)
            {
                rstr[j]=str[i];
            }
            j--;
            for(i=n1;i<=n2,j>=0;i++,j--)
                str[i]=rstr[j];
        }
        if(strcmp(work,"print")==0)
        {
            scanf("%d %d",&n1,&n2);
            for(i=n1;i<=n2;i++)
            {
                printf("%c",str[i]);
            }
            printf("\n");
        }
    }
    return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int64_t i = 0; i < (n); i++)
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    string s;cin>>s;
    const int n=s.size();
    vector<vector<int64_t>>dp(n+1,vector<int64_t>(13,0));dp[0][0]=1;
    REP(i,n)
    {
        int x;
        if(s[i]=='?')x=-1;
        else x=s[i]-'0';
        REP(j,10)
            if(x==-1||x==j)
                REP(k,13)
                    dp[i+1][(k*10+j)%13]+=dp[i][k];
    	REP(j,13)dp[i+1][j]%=1000000007;
    }
    cout<<dp[n][5]<<endl;
    return 0;
}


Measured memory_bytes: 13648
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define myPair pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define qmax priority_queue<int>
#define qmin priority_queue<int,vector<int>,greater<int>>
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define FORR(i,a,b) for(int i = a; i >= b; i--)

const int mxn = (1 << 22), MOD = 1e9 + 7;
int dp[mxn], a[22][22], n;

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n;
	FOR(m, 1, n) {
		FOR(w, 0, n - 1) {
			cin >> a[m][w];
		}
	}

	// dp[mask] = number of ways to pair first 'i' men
	//			  with remaining subset 'mask' of women

	dp[0] = 1;

	FOR(mask, 1, (1 << n) - 1) {
		int cur = __builtin_popcount(mask);
		dp[mask] = 0;
		FOR(w, 0, n - 1) {
			if(a[cur][w] && (mask & (1 << w)))
				dp[mask] = (dp[mask] + dp[mask ^ (1 << w)]) % MOD;
		}
	}

	cout << dp[(1 << n) - 1];

	return 0;
}

Measured memory_bytes: 20000
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <climits>
#include <cmath>
#include <utility>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <queue>

#define pb push_back
#define mp make_pair
#define ii pair<int, int>
#define ll long long
#define forn(i, a, b) for(int i = (int)a; i <(int)b;i++)
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w;
    cin >> h >> w;
    vector<vector<int> > score(h, vector<int>(w));
    queue<ii> q;
    forn(i,0,h){
        forn(j,0,w){
            char x;
            cin >> x;
            if(x == '#'){
                q.push(mp(i,j));
                score[i][j] = 0;
            } else {
            score[i][j] = -1;
            }
        }
    }
    
    int depth = 0;
    int dir[4][2] = {{-1,0}, {1,0}, {0,-1}, {0,1}};
    
    while(!q.empty()){
        ii top = q.front();
        int s = score[top.first][top.second];
        q.pop();
        forn(i,0,4){
            int nx = top.first + dir[i][0];
            int ny = top.second + dir[i][1];
            ii ntop = mp(nx,ny);
            if(nx >= 0 && ny >= 0 && nx < h && ny < w && score[nx][ny] < 0){
                q.push(ntop);
                score[nx][ny] = s+1;
                depth = max(depth,s+1);
            }
        }
    }
    cout << depth << endl;
}


Measured memory_bytes: 12432