akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < (n); i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, k, n) for (int i = (k); i < (n); i++)
#define REPEACH(itr, k) for (auto &&itr : k)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;


const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<pair<ll,ll>> v(n);
    REP(i,n){
        cin >> v[i].second >> v[i].first;
    }
    ll now=0;
    sort(all(v));
    REP(i,n){
        now+=v[i].second;
        if(now>v[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define MAX 105
#define INF (1<<30)
//#define EZPZ_LEMON_SQUEENZ
using namespace std;

vector<int> M[MAX];
stack<int> s;
int states[MAX][2];
bool vis[MAX];
int n, t;

void dfs(int index)
{
	if (index == n + 1) return;
	vis[index] = true;
	for (int i = 0; i < M[index].size(); i++)
	{
		if (!vis[M[index][i]]) {
			states[M[index][i]][0] = t++;
			dfs(M[index][i]);
			states[M[index][i]][1] = t++;
		}
	}
}

int main()
{
#ifdef EZPZ_LEMON_SQUEENZ
	freopen("D:\\in.txt", "r", stdin);
	freopen("D:\\out.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int b, nn, e;
		cin >> b >> nn;
		for (int j = 1; j <= nn; j++) {
			cin >> e;
			M[b].push_back(e);
		}
	}
	t = 1;
	for (int i = 1; i <= n; i++)
	{
		if (!vis[i]) {
			states[i][0] = t++;
			dfs(i);
			states[i][1] = t++;
		}
	}
	for (int i = 1; i <= n; i++) cout << i << " " << states[i][0] << " " << states[i][1] << endl;
	return 0;
}


Measured memory_bytes: 3152
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

using namespace std;

int main(){
    int n;
    bool b[110];
    while(cin >> n, n){
        fill(b, b+110, false);
        vi v;
        for(int i=0; i < n; i++){
            int p;
            cin >> p;
            v.pb(p);
        }
        int p;
        cin >> p;

        int count = 0;
        int lb = 0, ub = n-1;
        while(true){
            count++;
            int mid = (lb + ub) / 2;

            if(v[mid] == p) break;
            else if(v[mid] > p){
                ub = mid-1;
            }
            else {
                lb = mid+1;
            }
            if(ub < lb) break;
        }
        cout << count << endl;
    }
}

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

using namespace std;

int main() {
    int y, m, d;
    scanf("%d/%d/%d", &y, &m, &d);
    if (y * 366 + m * 31 + d > 2019 * 366 + 4 * 31 + 30) cout << "TBD" << endl;
    else cout << "Heisei" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

struct Mod{
  unsigned n;
  Mod() : n(0){}
  Mod( ll x ){
    if( x < 0 ) n = x%MOD+MOD;
    else n = x%MOD;
  }
};
Mod operator + ( Mod a  , Mod b ){ return Mod( a.n + b.n ); }
Mod operator +=( Mod &a , Mod b ){ return a = a + b; }
Mod operator - ( Mod a ){ return Mod( MOD - a.n ); }
Mod operator - ( Mod a  , Mod b ){ return Mod( a.n + MOD - b.n ); }
Mod operator -=( Mod &a , Mod b ){ return a = a - b; }
Mod operator * ( Mod a  , Mod b ){ return Mod( (ll)a.n * b.n ); }
Mod operator *=( Mod &a , Mod b ){ return a = a * b; }
Mod modpow( Mod x , ll k ){
  Mod res = 1;
  while( k ){
    if( k & 1 ) res *= x;
    k /= 2;
    x *= x;
  }
  return res;
}
ll extgcd( ll a , ll b , ll &x , ll &y ){
  ll d = a;
  if( b != 0 ){
    d = extgcd( b , a % b , y , x );
    y -= a / b * x;
  } else {
    x = 1, y = 0;
  }
  return d;
}
Mod inv( Mod a ){ ll x, y; assert( extgcd( a.n , MOD , x , y ) == 1 ); return Mod( x ); }
Mod operator / ( Mod a  , Mod b ){ return Mod( (ll)a.n * inv(b).n ); }
Mod operator /=( Mod &a , Mod b ){ return a = a / b; }

int main(){

  int n = in();
  int k = in();
  vector<int> a(n);
  REP(i, n){
    a[i] = in();
  }
  vector<vector<Mod>> dp(n + 1, vector<Mod>(k + 1, 0));
  dp[0][0] = 1;
  REP(i, n){
    vector<Mod> s(k + 2, 0);
    REP(j, k + 1){
      s[j + 1] = s[j] + dp[i][j];
    }
    REP(j, k + 1){
      dp[i + 1][j] = s[j + 1];
      if(j > a[i]){
        dp[i + 1][j] -= s[j - a[i]];
      }
    }
  }

  cout << dp[n][k].n << endl;
  
  return 0;
}


Measured memory_bytes: 40192
n=int(input())-2
a=list(map(int,input().split()))
a.sort(reverse=True)
ind=1
ans=a[0]
co=0
while n>0:
  co+=1
  ans+=a[ind]
  if co==2:
    co=0
    ind+=1
  n-=1
print(ans)

Measured memory_bytes: 31748
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    int a = 1;
    int b = 1;
    
    
        while(true){
            StringTokenizer st = new StringTokenizer(br.readLine(), " ");
            b = Integer.parseInt(st.nextToken());
            a = Integer.parseInt(st.nextToken());

            if(a==0&&b==0)break;
            for(int x = 0; x<b; x++){
                
                
                for(int y = 0; y<a; y++){
                    System.out.print("#");
                }
                
                System.out.print("\n");
            }
            
            System.out.print("\n");
            
        }
        
    }
}

Measured memory_bytes: 35372
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 100010;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> a_sum(n + 1);
    a_sum[0] = 0;
    _rep(i, 1, n + 1) a_sum[i] = a_sum[i - 1] ^ a[i - 1];

    rep(i, n){
        ll ans = a_sum[n] ^ a[i];
        cout << ans << endl; 
    }
}

Measured memory_bytes: 6352
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int N = sc.nextInt();
		int r = W, t = H, l = 0, d = 0;
		for(int i = 0 ; i<N; i++){
			int x = sc.nextInt();
			int y = sc.nextInt();
			int a = sc.nextInt();
			if(a == 1){ // want > x
				l = Math.max(x, l);
			}
			else if( a == 2){ // want < x
				r = Math.min(x, r);
			}
			else if( a == 4){ // want < y
				t = Math.min(t, y);
			}
			else if( a == 3){ // want > y 
				d = Math.max(d, y);
			}
		}
	//	System.out.println( t+" "+d+" "+l+" "+r);
		if(t-d>0 && r-l >0)
		System.out.println((t-d)*(r-l));
		else System.out.println(0);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

int M;
int memo[512][16][512][4][2];
string limit;

int f(int pos , int digit , int mod , int up , int free){
	if(pos == -1) return (mod == 0);
	if(memo[pos][digit][mod][up][free] != -1) return memo[pos][digit][mod][up][free];
	int ans = 0;
	if(up != 2){
		if(up){
			for(int i = digit+1 ; i <= (free?9:limit[pos]) ; i++){
				ans += f(pos-1,i,(mod*10+i)%M,up^1,free||(i < limit[pos]));
			}
		}else{
			for(int i = (free?digit-1:min((int)limit[pos],digit-1)) ; i >= 0 ; i--){
				ans += f(pos-1,i,(mod*10+i)%M,up^1,free||(i < limit[pos]));
			}
		}
	}else{
		ans += f(pos-1,0,(mod*10+0)%M,2,free||(0 < limit[pos]));
		for(int i = 1 ; i <= (free?9:limit[pos]) ; i++){
			ans += f(pos-1,i,(mod*10+i)%M,0,free||(i < limit[pos]));
			if(pos != 0) ans += f(pos-1,i,(mod*10+i)%M,1,free||(i < limit[pos]));
		}
	}
	ans %= 10000;
	return memo[pos][digit][mod][up][free] = ans;
}

int solve(string n){
	memset(memo,-1,sizeof(memo));
	limit = "0" + n;
	reverse(limit.begin(),limit.end());
	for(int i = 0 ; i < limit.size() ; i++) limit[i] -= '0';
	return f(limit.size()-1,0,0,2,0) - 1;
}

int zig(string s){
	if(s.size() == 1) return true;
	if(s[0] == s[1]) return false;
	if(s.size() == 2) return s[0] != s[1];
	int up = s[0] > s[1];
	for(int i = 2 ; i < s.size() ; i ++){
		if( s[i-1] == s[i] || (up && s[i-1] >= s[i]) || (!up && s[i-1] <= s[i]) ) return false;
		up^=1;
	}
	return true;
}

int main(){
	string A,B;
	cin >> A >> B >> M;
	
	cout << ( solve(B) - solve(A) + zig(A) + 100000) % 10000 << endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define pb push_back
#define int long long
#define pii pair<int, int>
#define tupint tuple<int, int, int>
#define tupint2 tuple<int, int, int, int>
#define str string
using namespace std;
const int M = 1e9 + 7;
int dp[100001][3];

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> A(n), B(n), C(n);
    for (int i = 0; i < n; i++) cin >> A[i] >> B[i] >> C[i];
    dp[0][0] = A[0];
    dp[0][1] = B[0];
    dp[0][2] = C[0];
    for (int i = 1; i < n; i++) {
        dp[i][0] = A[i] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = B[i] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = C[i] + max(dp[i - 1][0], dp[i - 1][1]);
    }
    cout << max(dp[n - 1][2], max(dp[n - 1][0], dp[n - 1][1]));
}

Measured memory_bytes: 4992
import sys
h, n = map(int, input().split())
# A = [0] * n
# B = [0] * n
# for i in range(n):
#     A[i], B[i] = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n)]
min_hp = h
max_hp = h + max(a for a, b in (AB))

dp = [sys.maxsize] * (max_hp + 1)
dp[0] = 0

for i in range(1, max_hp + 1):
    # dp[i] = min(dp[i - A[j]] + B[j] for j in range(n))
    dp[i] = min(dp[i - a] + b for a, b in AB)
print(min(dp[h:]))


Measured memory_bytes: 3832
import scala.io.StdIn.{readLine,readInt}

object Main extends App {

  var index = 1
  Iterator.continually(readInt).takeWhile ( w => w != 0).foreach { w =>
    val n = readInt
    val wv = Array.ofDim[Int](n+1,2)
    val m = Array.ofDim[Int](n+1,w+1)

    for(i<-1 to n) wv(i) = readLine.split(",").map(_.toInt)
    for(i<-1 to n;j<-0 to w) {
      if(j >= wv(i)(1) && m(i-1)(j) <= wv(i)(0) + m(i-1)(j-wv(i)(1)))
        m(i)(j) = wv(i)(0) + m(i-1)(j-wv(i)(1))
      else
        m(i)(j) = m(i-1)(j)
    }
    println("Case "+index+":")
    println(m(n)(w))
    println((0 to w).find(m(n)(_) == m(n)(w)).get)
    index += 1
  }
}

Measured memory_bytes: 49444
import math

def keta(s):
    if len(s) < 2:
        return int(s)
    n = sum(map(int, s))
    return keta(str(n))

def main():
    N = input()
    # N, X, T = list(map(int, input().split()))
    
    if keta(N) % 9 == 0:
        print("Yes")
    else:
        print("No")



if __name__ == "__main__":
    main()

Measured memory_bytes: 9280
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ctime>
#include<deque>
using namespace std;

#define fr                first
#define se                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define pii               pair<int,int>
#define vi                vector<int>
#define mi                map<int,int>
#define pq                priority_queue<int>
#define set_bits(x)       __builtin_popcountll(x)
#define mod               1000000007
#define inf               1e18                        //Defining infinity the overflow of int
#define ps(x,y)           fixed<<setprecision(y)<<x   //for defining the precision of the decimal upto y places.
#define zrosetbits(x)     __builtin_ctzll(x)         //it will give no of 0's before the first 1 from the right.
#define mk(a,n,type)      type *a=new type[n];
#define test(t)           int t; cin>>t; while(t--)
#define no                cout<<"No\n";
#define yes               cout<<"Yes\n";
#define NO                cout<<"NO\n";
#define YES               cout<<"YES\n";
// #define for(i,n)          for(int i=0;i<n;i++)
// #define for(j,n)          for(int j=0;j<n;j++)
// #define forn(i,n)               for(int i=0;i<n;i--)



//**********************************************************************************************************
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }

  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

#define safemap               unordered_map<int,int,custom_hash>

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

void io()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin.tie(0);

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




int32_t main()
{

  io();
  clock_t begin = clock();

  int te = 1;

  // test(t)
  // {

  int n, x, t;
  cin >> n >> x >> t;

  int val = n / x;
  int r = n % x;

  if (r > 0)
    val += 1;


  cout << val*t << "\n";

// cout << "Case #" << te << ": " << res << "\n";
//te++;
// double c_time = (double) (clock() - begin) / CLOCKS_PER_SEC;
// cout << ps(c_time, 4) << " seconds\n";
  //}

  return 0;
}








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

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    string a,b;
    cin >> a>>b;
    string strab = a+b;
    int ab = stoi(strab);
    // 最大ケース：a=100,b=100
    // 100100
    for(int i = 1; i<317; i++){
        if(i*i==ab){
            cout << "Yes" <<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3628
N,M = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i).sort!.reverse!
sum = 0

(0..N-1).each do |i|
  sum += A[i]
end

if A[M-1] >= sum.to_f / (4 * M)
  puts "Yes"
else
  puts "No"
end

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

#define ll long long
#define fr first
#define se second
#define pb push_back

using namespace std;

const long long N = 1e5 + 7;

long long res, n, m, cnt, ans , a , b , sum , mx , mn, c , d;
string s;
set<string>st;
int main()
{
    cin >> a >> b;
    if( a > b )
        cout << "safe";
    else
        cout << "unsafe";
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll a, b;

	cin >> a >> b;

	ll ans = 0;
	ll now = 1;

	while (now < b) {
		now += a - 1;
		ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(10) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<lli,lli>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> M;
  DV(dp,lli,2000,(1<<12)+10,INF);
  dp[0][0]=0;
  Vec(Q,lli,M,0);
  Vec(P,lli,M,0);
  rep(i,0,M){
    cin >> Q[i] >> A;
    rep(j,0,A){
      cin >> B;B--;
      P[i]+=(1<<B);
    }
  }
  rep(i,0,M)rep(j,0,1<<N){
    chmin(dp[i+1][j],dp[i][j]);
    chmin(dp[i+1][j|P[i]],dp[i+1][j]+Q[i]);
  }
  if(dp[M][(1<<N)-1]==INF)Out(-1);
  else Out(dp[M][(1<<N)-1]);
}

Measured memory_bytes: 64640
#include <bits/stdc++.h>
using namespace std;
int main (){
  long long int a,b,k;
  cin>>a>>b>>k;
  long long int i;
  a-=k;
  if(a<0)
    b+=a;

  if(a<0)
    cout<<0<<endl;
  else
    cout<<a<<endl;
  if(b<0)
    cout<<0<<endl;
  else
    cout<<b<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
ll int n,k,q;
  cin>>n>>k>>q;
 ll int s[n]; 
  for(ll int j=0;j<n;j++)
  {
    s[j]=k-q;}
  ll int a[q];
  for(ll int i=0;i<q;i++)
  {
   cin>>a[i];
   s[a[i]-1]++;
  }
  for(ll int j=0;j<n;j++)
  {
  if(s[j]>0)
    cout<<"Yes"<<endl;
    else 
      cout<<"No"<<endl;
  }
}

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

 using namespace std;

 int main() {
   int i;
   string S;

   cin >> S;

   for (i = 1; i < S.length() / 2; i++) {
     if (S.substr(0, S.length() / 2 - i) == S.substr(S.length() / 2 - i, S.length() / 2 - i)) {
       cout << S.length() - 2 * i << endl;
       break;
     }
   }
 }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] p = new int[n];
		int cnt = 0;
		for (int i = 0; i < p.length; i++) {
			p[i] = sc.nextInt();
		}

		for (int i = 1; i < p.length - 1; i++) {
			if (p[i - 1] < p[i] && p[i] < p[i + 1]
					|| p[i - 1] > p[i] && p[i] > p[i + 1]) {
				cnt++;
			}
		}

		System.out.println(cnt);

	}
}

Measured memory_bytes: 21844
#include <stdio.h>
int main(void){
    int a,b,c,d,e,f,g;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);
    scanf("%d", &e);
    if((a<=b)&&(a<=c))
        f=a;
    else if(b<=c)
        f=b;
    else
        f=c;
    if(d<=e)
        g=d;
    else
        g=e;
    int h=f+g-50;
    printf("%d\n", h);
}


Measured memory_bytes: 2736
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, K; 
    cin >> N >> K; 
    int ans = 1; 
    for(char i = 0; i < N; ++i){
     ans = min(ans * 2, ans + K); 
    } 
    cout << ans << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n,t,x,y,m,q;

int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      cin>>x>>n>>y;
      ll d=abs(x)/y;
      if(d>n) cout<<abs(abs(x)-n*y);
      else if((n-d)%2==0)cout<<abs(x)-d*y;
      else cout<<abs(abs(x)-(d+1)*y);
}

Measured memory_bytes: 3632
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

#include <bits/stdc++.h>
 
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

const int maxN = 1e7 + 5;

int prime[maxN];
map<int, int> m;

void sieve(){ 
    prime[1] = 1; 
    for(int i = 2; i < maxN; i++){
        prime[i] = i; 
    }
    for(int i = 4; i < maxN; i += 2){
        prime[i] = 2; 
    }
    for(int i = 3; i * i < maxN; i++){ 
        if(prime[i] == i){ 
            for(int j = i * i; j < maxN; j += i){
                if(prime[j] == j) 
                    prime[j] = i;
            } 
        } 
    }
    return; 
} 

void prime_factorize(int x){ 
    m.clear();
    while (x != 1){ 
        m[prime[x]]++; 
        x = x / prime[x]; 
    } 
    return; 
} 

void solve(){
    int n;
    cin >> n;
    ll suma = 0;
    for(ll i = 1; i <= n; i++){
        prime_factorize(i);
        ll temp = 1LL;
        for(auto x : m){
            temp *= (x.second + 1);
        }
        suma += (i * temp);
    }
    cout << suma << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    sieve();
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 42716
#include<iostream>
using namespace std;
int main() {
	int h,m,s; h = m = s = 0;
	int total; cin>>total;
	h = total/3600;
	m = (total%3600)/60;
	s = total%60;
	cout<<h;
	cout<<":";
	cout<<m;
	cout<<":";
	cout<<s<<endl;
	return 0;
}


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

int n;
vector<ll> a(300000);
vector<ll> p_max(100001);
vector<ll> q_min(100001);
priority_queue<ll,vector<ll>,greater<ll> > que_p;
priority_queue<ll> que_q;

void change_que_p(int k);
void change_que_q(int k);
int main(){
  cin >> n;
  for(int i=0;i<3*n;i++){
    cin >> a.at(i);
  }
  for(int i=0;i<n;i++){
    que_p.push(a.at(i));
  }
  for(int i=0;i<n;i++){
    que_q.push(a.at(2*n+i));
  }
  ll tmp_max=0;
  for(int i=0;i<n;i++){
    tmp_max+=a.at(i);
  }
  p_max.at(0)=tmp_max;
  for(int k=1;k<n+1;k++){
    change_que_p(k);
  }
  ll tmp_min=0;
  for(int i=0;i<n;i++){
    tmp_min+=a.at(2*n+i);
  }
  q_min.at(0)=tmp_min;
  for(int k=1;k<n+1;k++){
    change_que_q(k);
  }
  ll ans=p_max.at(0) - q_min.at(n);
  for(int k=1;k<n+1;k++){
    ll tmp_ans = p_max.at(k) - q_min.at(n-k);
    if(tmp_ans>ans) ans=tmp_ans;
  }
  cout << ans << endl;
}

void change_que_p(int k){
  ll t_max = p_max.at(k-1);
  t_max += a.at(n-1+k);
  que_p.push(a.at(n-1+k));
  t_max -= que_p.top();
  que_p.pop();
  p_max.at(k)=t_max;
}

void change_que_q(int k){
  ll t_min = q_min.at(k-1);
  t_min += a.at(2*n-k);
  que_q.push(a.at(2*n-k));
  t_min -= que_q.top();
  que_q.pop();
  q_min.at(k)=t_min;
}

Measured memory_bytes: 6516
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

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

  if (S == "AAA" || S == "BBB")
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }

  return 0;
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
	int n,m;cin>>n>>m;
	vector<int> a(m);
	int i,j;
	rep(i,m)cin>>a[i];
	sort(all(a));
	reverse(all(a));
	vector<int> cost={100,2,5,5,4,5,6,3,7,6};
	vector<int> dp(n+1,-100);
	dp[0]=0;
	for(i=1;i<=n;i++)
	{
		rep(j,m)
		{
			if(i-cost[a[j]]>=0)
			{
				if(dp[i-cost[a[j]]]<0)continue;
				dp[i]=max(dp[i],dp[i-cost[a[j]]]+1);
			}
		}
	}
	int now=n;
	while(now>0)
	{
		rep(i,m)
		{
			if(now-cost[a[i]]<0)continue;
			if(dp[now]==1)
			{
				if(now==cost[a[i]])
				{
					cout<<a[i];
					now-=cost[a[i]];
					break;
				}
			}
			else if(dp[now-cost[a[i]]]==dp[now]-1)
			{
				cout<<a[i];
				now-=cost[a[i]];
				break;
			}
		}
	}
	cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int f[100][10], p[100][11];

int main() {
    int n;
    cin >> n;
    REP(i,n) REP(j,10) cin >> f[i][j];
    REP(i,n) REP(j,11) cin >> p[i][j];

    int ans = -1e9 - 10;
    REP(mask,1<<10){
        if (mask == 0) continue;
        VI a(10);
        REP(i,10) a[i] = (mask >> i) & 1;
        int tmp = 0;
        REP(i,n){
            int c = 0;
            REP(j,10) c += a[j] & f[i][j];
            tmp += p[i][c];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int n = 1; n <= N; n += 2) {
    int cnt = 0;
    for (int a = 1; a <= n; a++) {
      if (n % a == 0) ++cnt;
    }
    if (cnt == 8)
      ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
let n=Int(readLine()!)!
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
let pp=readInts()
var count=0
for i in 1...(n-2){
  if (pp[i-1]<pp[i])&&(pp[i]<pp[i+1]){
    count+=1
  }else if (pp[i-1]>pp[i])&&(pp[i]>pp[i+1]){
    count+=1
  }
}

print(count)




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

int main(){
	int n;
	cin >> n;
	map<int,int> mp;
	rep(i,n){
		int d;
		cin >> d;
		mp[d] = 1;
	}
	int cnt = 0;
	for(auto p:mp){
		if(p.second = 1) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

typedef vector<int> vec;
typedef pair<vec, const char*> parsed;

map<vector<int>, string> nameMap;
map<string, vector<int> > mp;
string name[10];

parsed expr(const char *p);
parsed term(const char *p);
parsed fact(const char *p);

bool error;
parsed expr(const char *p)
{
  parsed r=term(p);
  while(*r.second=='+'||*r.second=='-'){
    char op=*r.second;
    vec tmp=r.first;
    r=term(r.second+1);
    // cout << "+" << endl;
    // FOR(it, tmp) cout << *it << " ";cout << endl;
    // FOR(it, r.first) cout << *it << " "; cout << endl;
    if (tmp != r.first) {
      error = 1;
    }
  }
  return r;
}

parsed term(const char *p)
{
  parsed r=fact(p);
  while(*r.second=='*'||*r.second=='/'){
    char op=*r.second;
    vec tmp=r.first;
    r=fact(r.second+1);
    if (op=='*') {
      REP(i, tmp.size()) {
        r.first[i] += tmp[i];
      }
    } else {
      REP(i, tmp.size()) {
        r.first[i] = tmp[i]-r.first[i];
      }
    }
    //cout << "*/" << endl;
    //FOR(it, r.first) cout << *it << " "; cout << endl;
    
  }
  return r;
}

parsed fact(const char *p)
{
  if (isalpha(*p)){
    string t=string(1,*(p++));
    while(isalpha(*p)) t += string(1, *(p++));
    return parsed(mp[t],p);
  }
  else if (*p=='('){
    parsed r=expr(p+1);
    if (*r.second!=')') exit(0); // invalid input
    return parsed(r.first,r.second+1);
  }
  else
    exit(0); // invalid input
}

int main() {
  int n, m, p;
  while(cin>>n>>m>>p,n||m||p) {
    nameMap.clear();
    mp.clear();
    REP(i, m) {
      cin >> name[i];
      vector<int> v(n);
      REP(j, n) cin >> v[j];
      nameMap[v] = name[i];
      mp[name[i]] = v;
    }
    string formula;
    cin >> formula;
    REP(i, p) {
      string v, D;
      cin >> v >> D;
      mp[v] = mp[D];
    }
    error = 0;
    vector<int> v = expr(formula.c_str()).first;
    if (error) {
      cout << "error" << endl;
    } else {
      if (nameMap.count(v) == 0) {
        cout << "undefined" << endl;
      } else {
        cout << nameMap[v] << endl;
      }
    }
  }
}

Measured memory_bytes: 956
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main(){
  long long int N, K;
  cin >> N >> K;
  long long int a, b;
  vector< pair<long long int, long long int> > M;
  for(long long int i = 0LL; i < N; ++i){
    cin >> a >> b;
    M.push_back(make_pair(a,b));
  }
  sort(M.begin(), M.end());
  long long int t = 0LL;
  for(int i = 0LL; i < N; ++i){
    t += M[i].second;
    if(t >= K){
      cout << M[i].first << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto e : a) cout << e << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);
using namespace std;
int INF = 1e9 + 7;

int main()
{
    set<char> a = {'1', '2', '3'};
    FOR(i, 2, 0)
    {
        char x; cin >> x;
        a.erase(x);
    }
    for(auto e : a)cout << e;
    return 0;
}


Measured memory_bytes: 256
s = input()
l = len(s)

ans = 0

for i in range(2**(l-1)):
    a = s[0]
    for j in range(l-1):
        if i >> j & 1 == 1:
            a += '+'
        a += s[j+1]
    ans += eval(a)
print(ans)

Measured memory_bytes: 9068
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] abc = new int[10];
    for (int i = 0; i < 3; i++) {
      int tmp = sc.nextInt();
      abc[tmp]++;
    }
    if (abc[5] == 2 && abc[7] == 1) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

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

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

    vector<ll> h(n);
    vector<vector<int>> l(n, vector<int>());

    rep(i, n)
    {
        cin >> h.at(i);
    }

    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        l.at(a-1).push_back(b-1);
        l.at(b-1).push_back(a-1);
    }

    int ans = 0;

    rep(i, n)
    {
        bool flg = true;
        rep(j, l.at(i).size())
        {
            if (h.at(i) <= h.at(l.at(i).at(j)))
                flg = false;
        }
        if (flg)
            ans++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	char S[200001]; 
	int N = fread(S, 1, 200001, stdin);
	if (S[N - 1] < 'a' || S[N - 1] > 'z') N--;

	vector<int> V;
	V.pb(N);
	int kazu = 0;
	int A = 0;
	for (int i = N - 1; i >= 0; i--) {
		A |= 1 << S[i] - 'a';
		if (A == 67108863) {
			kazu++;
			V.pb(i);
			A = 0;
		}
	}

	A = 0;
	vector<char> kotae;
	int flag = 0;
	int nai = 0;
	rep(i, N) {
		if (i == V[kazu]) {
			rep(j, 26) if (!(A >> j & 1)) {
				nai = j;
				break;
			}
			kotae.pb('a' + nai);
			kazu--;
			flag = 1;
		}
		if (flag) {
			if (S[i] == 'a' + nai) {
				A = 0;
				flag = 0;
			}
		}
		else if (flag == 0) {
			A |= 1 << S[i] - 'a';
		}
	}
	rep(j, 26) if (!(A >> j & 1)) {
		nai = j;
		break;
	}
	kotae.pb('a' + nai);

	rep(i, kotae.size()) putchar(kotae[i]);
	putchar('\n');

	Would you please return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

int main() {
    return []() {
        std::function<void()> input;
        std::vector <int> list;
        (input = [&input, &list]() {
            int data;
            if ( std::cin >> data ) {
                list.push_back( data );
                input();
            }
        })();
        sort( list.rbegin(), list.rend() );
        for_each(
            list.begin(),
            list.begin() + 3,
            [](int x){ std::cout << x << std::endl; }
        );
        return 0;
    }();
}

Measured memory_bytes: 1216
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const ll MAX = 1e15 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


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


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, r, mx;
vector <int> g[N];
void dfs(int v, int pr, int dist) {
    if (mx < dist) {
        mx = dist;
        r = v;
    }
    for (int to : g[v]) {
        if (to != pr) dfs(to, v, dist + 1);
    }
}
main() {
    file("rmq");
    ios;
    cin >> n;
    fo(i, 1, n - 1, 1) {
        int u, v;
        cin >> u >> v;
        g[u].eb(v);
        g[v].eb(u);
    }
    dfs(1, 1, 2);
    mx = 0;
    dfs(r, r, 2);
    if (mx % 3) cout << "First";
    else cout << "Second";
    return 0;
}
/**

*/


Measured memory_bytes: 20608
n = int(input())
a = []
d = []
for _ in range(n):
    a.append(list(map(int,input().split())))
    d.append([0,0,0])
d[0]=a[0]
for i in range(1,n):
    for j in range(3):
        d[i][j]=max(d[i-1][(j+1)%3],d[i-1][(j+2)%3])+a[i][j]
print(max(d[-1]))

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

int main(){
  int N,K,cnt=0;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    cnt += min(a,K-a);
  }
  cout << cnt*2 << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
# int(input()) # 入力が1つ
n, m = map(int, input().split()) # 入力が複数
A = [int(i) for i in input().split()]
total = sum(A)

cond = total / (4 * m)
ans = 0
for a in A:
    if a >= cond:
        ans += 1
if ans >= m:
    print('Yes')
else:
    print('No')

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

int main(){
    long long int h,r,ans=0;
    cin >> h;
    r=0;
    while(h>1){
        h/=2;
        r++;
    }

    for(long long int i=0;i<=r;i++){
        ans+=pow(2,i);
    }
    

   cout << ans << endl;


}

Measured memory_bytes: 256
N = int(input())
n3=N//3
n5=N//5
n15=N//15
S3 = 0.5*n3*(2*3+(n3-1)*3)
S5 = 0.5*n5*(2*5+(n5-1)*5)
S15 = 0.5*n15*(2*15+(n15-1)*15)
S=(N+1)*N/2
print(int(S-S3-S5+S15))

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> x >> y;
    if (x == 2) {
        Yn(y == 2)
        exit(0);
    }

    set<ll> g1;
    set<ll> g2;

    g1.insert(1);
    g1.insert(3);
    g1.insert(5);
    g1.insert(7);
    g1.insert(8);
    g1.insert(10);
    g1.insert(12);

    g2.insert(4);
    g2.insert(6);
    g2.insert(9);
    g2.insert(11);

    if (g1.count(x) != 0) {
        Yn(g1.count(y) != 0)
    } else {
        Yn(g2.count(y) != 0)
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int ,int> P;
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

int main(){
	 ll n;
	 string s;
	 cin>>n>>s;
	 for(int i=0;i<2;i++){ //0が羊、1が狼
	 	int a[n+1];
	 	a[1]=i;
	 	for(int j=0;j<2;j++){//両隣の種を仮定
	 		a[0]=j;
	 		if(!i){
	 			if(s[1]=='o') a[2]=j;
	 			else a[2]=!j;
			}	 	
	 		else {
	 			if(s[1]=='o') a[2]=!j;
	 			else a[2]=j;
	 		}
	 		for(int k=2;k<n-1;k++){
	 			if(!a[k]){
	 				if(s[k]=='o') a[k+1]=a[k-1];
	 				else a[k+1]=!a[k-1];
	 			}
	 			else{
	 				if(s[k]=='o') a[k+1]=!a[k-1];
	 				else a[k+1]=a[k-1];
	 			}
	 		}
	 		char ans[2]={'S','W'};
	 		if(((s[0]=='o'&&((a[0]==0&&a[n-1]==a[1])||(a[0]==1&&a[n-1]!=a[1])))||
	 		   (s[0]=='x'&&((a[0]==0&&a[n-1]!=a[1])||(a[0]==1&&a[n-1]==a[1]))))&&((s[n-1]=='o'&&((a[n-1]==0&&a[n-2]==a[0])||(a[n-1]==1&&a[n-2]!=a[0])))||
	 		   (s[n-1]=='x'&&((a[n-1]==0&&a[n-2]!=a[0])||(a[n-1]==1&&a[n-2]==a[0]))))){ 
	 			for(int l=0;l<n;l++) cout<<ans[a[l]];
	 			cout<<endl;
	 		    return 0;
	 		}
	 	}
	 }
	 cout<<-1<<endl;
	 return 0;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int gcd(int m,int n);
int main(){
  int a,b,k,i=1;
  vector<int> ans;
  cin >> a >> b >> k;
  while(i<=100){
    if(a%i == 0 && b%i == 0){
      ans.push_back(i);
    }
    i++;
  }
  cout << ans[ans.size() - k];
}


Measured memory_bytes: 256
//2017-10-10
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)

LL Solve(LL a, LL b){
	if(!b) return 0;
	return Solve(b, a%b) + 3 * (a - a%b);
}

int main(){
	LL n, x;
	
	scanf("%lld%lld", &n, &x);
	printf("%lld\n", Solve(n-x, x));

	return 0;
}

Measured memory_bytes: 256
#define inf 9223372036854775807
#define ll long long
#define pii pair<ll,ll>
#define m_p  make_pair
#define ull unsigned long long
#define spd  ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ll n,x,t,ans;

    cin>>n>>x>>t;

    ans = n/x;

    if(n%x)ans++;

    cout<<ans*t<<endl;

}


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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)
#define REP(i, n, m) for (long long i = (long long)(n); i < (long long)(m); i++)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll N, H[100010], dp[100010];

  void init() {
    scanf("%lld", &N);
    rep(i, N) scanf("%lld", H+i);
  }

  void solve() {
    dp[0] = 0;
    dp[1] = abs(H[1] - H[0]);
    rep2(i, N) dp[i] = min(dp[i-2] + abs(H[i] - H[i-2]), dp[i-1] + abs(H[i] - H[i-1]));
    cout << dp[N-1] << endl;
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int x, y;
    cin >> x >> y;
    cout << min(k, n) * x + max(n - k, 0) * y;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
struct goods {
  int profit;
  int weight;
};
int **C;
struct goods *item;
int uknapsack(int size, int limit);
int main(void)
{
  int i, n, w;
  scanf("%d%d", &n, &w);
  C = (int**)malloc(sizeof(int*) * (n + 1));
  item = (struct goods*)malloc(sizeof(struct goods) * (n + 1));
  for (i = 0; i <= n; i++) {
    C[i] = (int*)malloc(sizeof(int) * (w + 1));
    C[i][0] = 0;
    if (i) scanf("%d%d", &item[i].profit, &item[i].weight);
  }
  for (i = 0; i <= w; i++) C[0][i] = 0;
  printf("%d\n", uknapsack(n, w));
  for (i = 0; i <= n; i++) free(C[i]);
  free(C);
  free(item);
}
int uknapsack(int size, int limit)
{
  int i, j;
  for (i = 1; i <= size; i++) {
    for (j = 1; j <= limit; j++) {
      C[i][j] = C[i-1][j];
      if (item[i].weight > j) continue;
      if (item[i].profit + C[i][j-item[i].weight] > C[i-1][j]) {
        C[i][j] = item[i].profit + C[i][j-item[i].weight];
      }
    }
  }
  return C[size][limit];
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int a,b;cin>>a>>b;
  if(b<a)swap(a,b);
  for(int i=0;i<b;i++){
    cout<<a;
  }
  cout<<endl;

  
  return 0;
}


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

int main() {
  for(int n, m, a; cin >> n >> m >> a && (n|m|a);) {
    --a;
    vector<pair<int,int> > v;
    for(int i = 0; i < m; ++i) {
      int h, p, q;
      cin >> h >> p >> q;
      --p; --q;
      v.push_back(make_pair(h, min(p, q)));
    }
    sort(v.begin(), v.end());
    vector<int> b(n);
    for(int i = 0; i < n; ++i) b[i] = i+1;
    for(int i = 0; i < v.size(); ++i) {
      swap(b[v[i].second], b[v[i].second+1]);
    }
    cout << b[a] << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
// #include<vor>
using namespace std;
typedef long long int ll;
#define pb push_back
ll mod = 1e9+7;

ll powm(ll a , ll b , ll mod)
{
  ll res = 1;
  while(b)
  {
    if(b & 1)
    res = (res *a)%mod;
    a = (a*a)%mod;
    b>>1;
  }
  return res;
}
ll gcd(ll a , ll b);
ll power(ll x , ll y , ll m);

ll modInverse(ll a , ll m)
{
  ll g = gcd(a,m);
  if(g != 1)
  return 1;
  else
  return power(a,m-2,m);

}

ll power(ll x , ll y , ll m)
{
  if(y == 0)
  return 1;
  ll p = power(x , y/2 , m)%m;
  p = (p*p)%m;

  return (y%2 == 0) ? p : (x *p) % m;
}

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

void solve()
{
  ll n;
  cin>>n;
  // cout<<"hi\n";
   ll sum = 0;
  for(ll i = 1;i<=n;i++)
  {
    if(i%3 != 0 and i%5 != 0)
    {
      sum+=i;
      // cout<<i<<" ";
    }
  }
  cout<<sum<<"\n";
}

int main()
{
  // int tc;
  // cin>>tc;
  // while(tc--)
  // {
    solve();
  // }
}


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

int a=scan.nextInt();
int b=scan.nextInt();
int c,d;
double e;
c=a/b;
d=a%b;
e=(double)a/(double)b;
System.out.print(c+" "+d+" ");
String after = String.format("%.16f", e);
 System.out.println(after);
}
}

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

int main() {
  int A, B, count = 0;
  cin >> A >> B;
  int N = B - A + 1;
  rep(i, N){
    int K = (A + i) / 1000;
    int L = (A + i) % 100;
    if(K / 10 == L % 10 && K % 10 == L / 10){
     count++;
     }
   }
   cout << count <<endl;
   return 0;   
}

Measured memory_bytes: 3628