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

int main(){
  int n;
  cin >> n;
  bool exist = false;
  for(int i = 0; i <= n / 4; i++){
    for(int j = 0; j <= n / 7; j++){
      if(4 * i + 7 * j == n) exist = true;
    }
  }
  if(exist) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
def my_gcd(x, y):
    if x >= y:
        m = x
        n = y
    else:
        m = y
        n = x
    r = m % n
    while r:
        m = n
        n = r
        r = m % n
    return n

def cm_between(a, b, p):
    a_mod = a % p
    b_mod = b % p
    if b - a < p and 0 < a_mod <= b_mod:
        return 0
    elif a_mod == 0:
        return ((b - b_mod - a) // p + 1)
    else:
        return (((b - b_mod) - (a + p - a_mod)) // p + 1)

a, b, c, d = map(int, input().split())
l = (c * d) // my_gcd(c, d)
print((b - a + 1) - cm_between(a, b, c) - cm_between(a, b, d) + cm_between(a, b, l))

Measured memory_bytes: 3064
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

A.sort()

ans = 0
tmp = [True for i in range(A[-1] + 1)]

for i in range(N - 1):
    if tmp[A[i]]:
        if A[i + 1] != A[i]:
            ans += 1
        for j in range(A[i], A[-1] + 1, A[i]):
            tmp[j] = False
if tmp[A[-1]]:
    ans += 1
print(ans) 


Measured memory_bytes: 160184
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def isMM(s2):
    d = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]
    return s2 in d

def main():
    s = input()
    if isMM(s[0:2]):
        if isMM(s[2:]):
            print("AMBIGUOUS")
        else:
            print("MMYY")
    else:
        if isMM(s[2:]):
            print("YYMM")
        else:
            print("NA")


if __name__ == '__main__':
    main()


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

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vvint(v, w, n) vector<int> v(n); vector<int> w(n); REP(i,n) cin >> v[i] >> w[i];
#define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v, n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v, n1, n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v, n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()
#define len(v) (v).length()
#define FIND(s, n) (s.find(n) != s.end())
#define SORT(a) sort(all(a))

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long int MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};


int Knapsack_01(int N,int W,vector<int> v,vector<int> w) {

  int dp[N+1][W+1];
//std::vector<std::vector<int> > dp(N + 1, std::vector<int>(W + 1, 0));
  for (int i = 0; i <= N; i++) dp[i][0] = 0;
  for (int j = 0; j <= W; j++) dp[0][j] = 0;

  REP(i, N) REPS(j, 1, W+1){
      if (j < w[i]) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = max(dp[i][j], dp[i+1][j - w[i]] + v[i]);
  }
  return dp[N][W];
}

int Knapsack_eco(int N,int W, vector<int> v,vector<int> w) {

    vector<int> dp(W+1, 0);

    REP(i, N) REPS(j, w[i], W+1) dp[j] = max(dp[j], dp[j-w[i]]+v[i]);

    return dp[W];
}

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

  int N, W;
  cin >> N >> W;

  vvint(v, w, N);

  cout << Knapsack_eco(N, W, v, w) << endl;

}

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

typedef long long ll;
int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;

	priority_queue<ll> lower;
	priority_queue<ll, vector<ll>, greater<ll>> upper;

	ll ans=0;
	ll l[n],r[n],temp;
	for(temp=0;temp<n;temp++)	cin>>l[temp]>>r[temp];

	lower.push(l[0]);
	upper.push(l[0]);
	ll lazylow=0,lazyhigh=0;
	for(temp=1;temp<n;temp++) {

		ll len0=r[temp-1]-l[temp-1]+1;
		ll len1=r[temp]-l[temp]+1;
		lazylow-=len1-1;
		lazyhigh+=len0-1;

		if(l[temp]<lower.top()+lazylow) {
			ll shifted=lower.top()+lazylow;
			ans+=shifted-l[temp];
			lower.push(l[temp]-lazylow);
			lower.push(l[temp]-lazylow);
			upper.push(shifted-lazyhigh);
			lower.pop();
		}
		else if(l[temp]>upper.top()+lazyhigh) {
			ll shifted= upper.top()+lazyhigh;
			ans+=l[temp]-shifted;
			upper.push(l[temp]-lazyhigh);
			upper.push(l[temp]-lazyhigh);
			lower.push(shifted-lazylow);
			upper.pop();
		}
		else {
			lower.push(l[temp]-lazylow);
			upper.push(l[temp]-lazyhigh);
		}
	}
	cout<<ans<<"\n";

}

Measured memory_bytes: 3692
import java.util.*;
 
public class Main{
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		Set<String> set=new HashSet<>();
		int ans=0;
		for(int i=0;i<n;i++) {
			String s=sc.next();
			if(!set.contains(s)) {
				set.add(s);
				ans++;
			}
		}
		System.out.print(ans);
	}
}

Measured memory_bytes: 77100
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn solve() {
    let n = get();
    let a: Vec<i64> = (0 .. n).map(|_| get()).collect();
    println!("{}", a.into_iter().sum::<i64>() - n as i64);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
A, B, C = map(int, input().split())
n = 0  # ログイン回数
temp = 0  # n回ログインした後の合計枚数
while temp < C:
	n = n + 1
	if n % 7 == 0:
		temp = temp + A + B
	else:
		temp = temp + A

print(n)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
char g[111][111];
int main(){
	int n, m; cin >> n >> m;
	for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) cin >> g[i][j];
	for(int i = 1; i <= 2 * n; i++, cout << endl) for(int j = 1; j <= m; j++) cout << g[(i+1)/2][j];
	return 0;
}


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

// macros
#define overload_rep(_1, _2 ,_3 ,name, ...) name
#define re_p(i, n) for(int i = 0; i < (n); ++i)
#define r_ep(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, r_ep, re_p)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
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; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// AtCoder Beginner Contest 144
typedef long long ll;

int main(){

    ll N;
    cin >> N;

    ll ans = 1ll << 60;
    for(ll i = 1; i * i <= N; i++){
        if(N % i == 0){
            chmin(ans, i + N / i - 2);
        }
    }
    cout << ans << '\n';

}

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

using namespace std;

#define _int64 long long

char s[200000];
char ans[200000];

int main()
{
  int i,j,n,b1;
  char tmp;
  scanf("%d",&n);
  scanf("%s",s);
  b1=0;
  ans[n]='\0';
  for (i=0;i<4;i++)
  {
    if (i/2==0) ans[0]='S';
    else ans[0]='W';
    if (i%2==0) ans[1]='S';
    else ans[1]='W';
    for (j=2;j<n;j++)
    {
      tmp=s[j-1];
      if (ans[j-1]=='W') tmp='o'+'x'-tmp;
      if (tmp=='o') ans[j]=ans[j-2];
      else ans[j]='S'+'W'-ans[j-2];
    }

    if (ans[n-2]==ans[0]) tmp='o';
    else tmp='x';
    if (ans[n-1]=='W') tmp='o'+'x'-tmp;
    if (tmp!=s[n-1]) continue;
    
    if (ans[n-1]==ans[1]) tmp='o';
    else tmp='x';
    if (ans[0]=='W') tmp='o'+'x'-tmp;
    if (tmp!=s[0]) continue;

    b1=1;break;
  }
  if (b1==0) printf("-1\n");
  else printf("%s\n",ans);
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>


int k, x;

void input() {

    scanf("%d %d", &k, &x);
}

void process() {

    for(int i=x-k+1;i<x+k;i++) {
        printf("%d ", i);
    }


}

int main() {

    input();
    process();

    return 0;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

bool win(int a,int b,int c,int d,vector<vector<vvi>>& memo)
{
	if(a>=5 && b>=5) return memo[a][b][c][d]=false;
	if(c>=5 && d>=5) return memo[a][b][c][d]=true;
	bool res=false;
	if(a<5){
		if(c<5) res|=!win(min(c+a,5),d,a,b,memo);
		if(d<5) res|=!win(c,min(d+a,5),a,b,memo);
	}
	if(b<5){
		if(c<5) res|=!win(min(c+b,5),d,a,b,memo);
		if(d<5) res|=!win(c,min(d+b,5),a,b,memo);
	}
	return res;
}

int main()
{
	for(vi l(2),r(2);cin>>l[0]>>r[0]>>l[1]>>r[1] && l[0]!=-1;){
		vector<vector<vvi>> memo(6,vector<vvi>(6,vvi(6,vi(6,-1))));
		cout<<(win(l[0],r[0],l[1],r[1],memo)?"ISONO":"NAKAJIMA")<<endl;
	}
}

Measured memory_bytes: 1220
N,A,B,C = map(int, input().split())
l = [int(input()) for _ in range(N)]

INF = 1<<20
score = INF

import itertools
for ms in itertools.product(range(-1,3), repeat=N):
    lens = [0]*3
    tmp_score = -30
    for i, group in enumerate(ms):
        if group>=0:
            lens[group] += l[i]
            tmp_score += 10
    if all(lens):
        score = min(score, tmp_score + abs(lens[0]-A)+abs(lens[1]-B)+abs(lens[2]-C))

print(score)


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

int main()
{
	int n;
	cin >> n;
	string t = to_string(n);
	auto a = string(t.size(), '0');
	auto d = vector<int>(10);
	auto countUp = [&d](auto countUp, string& a, int x) -> bool {
		if(x == a.size()) return false;
		char& p = a[a.size() - x - 1];
		char q = (p == '0' ? '3' : p + 2);
		if(q == '9'){
			q = '3';
			if(!countUp(countUp, a, x + 1)){
				return false;
			}
		}
		--d[p - '0'];
		++d[q - '0'];
		p = q;
		return true;
	};
	int ans = 0;
	while(countUp(countUp, a, 0) && a <= t){
		if(d[3] * d[5] * d[7] > 0) ++ans;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n; cin >> n;
    map<int, int> d;
    for (int i=0; i<n; ++i) {
        int num; cin >> num;
        d[num]++;
    }
    bool can = true;
    int m; cin >> m;
    for (int i=0; i<m; ++i) {
        int num; cin >> num;
        d[num]--;
        if (d[num] < 0) can = false;
    }
    cout << (can ? "YES" : "NO") << endl;
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <string>
#include <stdlib.h>
#include <vector>
#include <climits>
#include <math.h>
#include <map>
#include <set>

using namespace std; 
#define Endl '\n'
int main()
{
    long long int n,m;
    cin>>n>>m;
    long long int a[n];
    long long int sum=0;
    for (int i = 0; i < m; ++i)
    {
        cin>>a[i];
        sum=sum+a[i];
    }
    if (n-sum>=0)
    {
        cout<<n-sum;
    }
    else
        cout<<-1;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll M;
ll d[200010],c[200010];

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

  cin>>M;
  rep(i,M)cin>>d[i]>>c[i];

  ll res=0,crt=0,sum=0;
  rep(i,M){
    ll tmp=(d[i]*c[i]);
    while(tmp>=10){
      res+=tmp/10LL;
      tmp=(tmp/10LL)+(tmp%10LL);
    }
    crt+=tmp;
    sum+=c[i];
  }
  while(crt>=10){
    res+=crt/10LL;
    crt=(crt/10LL)+(crt%10LL);
  }
  cout<<res+sum-1<<endl;

  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int b[5];
char buff[300010];
int f(char c)
{
	if(c == 'R') return 0;
	if(c == 'G') return 1;
	return 2;
} 
int main()
{
	//freopen("1.txt","r",stdin);
	int n;
	scanf("%d%s",&n,buff+1);
	int ans = 1;
	for(int i = 1;i <= 3*n;i ++)
	{
		char c = buff[i];
		int t0 = f(c);int t1 = (f(c)+1)%3;int t2 = (t1+1)%3;
		if(b[t0] >= b[t1] && b[t0] >= b[t2]) {}
		else if(b[t0] < b[t1] && b[t0] >= b[t2])
			ans = 1ll*ans*(b[t1]-b[t0])%mod;
		else if(b[t0] < b[t2] && b[t0] >= b[t1])
			ans = 1ll*ans*(b[t2]-b[t0])%mod;
		else if(b[t1] < b[t2])
			ans = 1ll*ans*(b[t1]-b[t0])%mod;
		else
			ans = 1ll*ans*(b[t2]-b[t0])%mod;
		b[t0] ++;
	}
	for(int i = 1;i <= n;i ++)
		ans = 1ll*i*ans%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
//2019.2.22 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-10
inline int read() {
    res s=0;
    bool w=0;
    char ch=getchar();
    while(ch<'0'||ch>'9') {
        if(ch=='-')w=1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void _swap(res &x,res &y) {
    x^=y^=x^=y;
}
inline int _abs(const res &x) {
    return x>0?x:-x;
}
inline int _max(const res &x,const res &y) {
    return x>y?x:y;
}
inline int _min(const res &x,const res &y) {
    return x<y?x:y;
}
const int N=2e5+10;
const int kcz=1e9+7;
const int M=4e3+20;
namespace MAIN {
    inline int qpow(res x,res y){
        res ret=1;
        while(y){
            if(y&1)ret=1LL*ret*x%kcz;
            y>>=1,x=1LL*x*x%kcz;
        }
        return ret;
    }
    int n;
    inline void add(res &x,const res &y){
        x+=y,x>=kcz?x-=kcz:1,x<0?x+=kcz:1;
    }
    int fac[M<<1],inv[M<<1];
    inline void pre(){
        fac[0]=fac[1]=inv[0]=inv[1]=1;
        for(res i=2;i<=M*2-10;i++)fac[i]=1LL*fac[i-1]*i%kcz,inv[i]=1LL*inv[kcz%i]*(kcz-kcz/i)%kcz;
        for(res i=2;i<=M*2-10;i++)inv[i]=1LL*inv[i]*inv[i-1]%kcz;
    }
    inline int mul(const res &x,const res &y){
        return 1LL*x*y%kcz;
    }
    inline int C(const res &x,const res &y){
        if(x<y)return 0;
        return mul(fac[x],mul(inv[y],inv[x-y]));
    }
    int dp[M][M];
    int a[N],b[N];
    inline int Add(const res &x,const res &y){
        return x+y>=kcz?x+y-kcz:(x+y<0?x+y+kcz:x+y);
    }
    int ans;
    inline void MAIN(){
        n=read(),pre();
        for(res i=1;i<=n;i++)a[i]=read(),b[i]=read(),dp[2001-a[i]][2001-b[i]]++;
        for(res i=1;i<=4002;i++)
            for(res j=1;j<=4002;j++)add(dp[i][j],Add(dp[i-1][j],dp[i][j-1]));
        for(res i=1;i<=n;i++)add(ans,Add(dp[2001+a[i]][2001+b[i]],-C((a[i]+b[i])*2,a[i]*2)));
        printf("%d\n",mul(ans,qpow(2,kcz-2)));
    }
}
int main() {
//    freopen("number.in","r",stdin);
//    freopen("number.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

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

int HOST[20];

int DP(vector <int> V, int n){
  if (n < 0)
    return 0;
  if (!HOST[n])
    HOST[n] = max(V[n] + DP(V,n-1), DP(V,n-1));
  return HOST[n];
}

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

  int n, x, y, i;
  cin >> n;
  vector <int> V (n);
  for (i = 0; i < n; i++)
    cin >> V[i];
  for (i = 0; i < n; i++){
    cin >> x;
    V[i] -= x;
  }
  
  cout << DP(V, n-1) << endl;
}

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

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


Measured memory_bytes: 256
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/PCK/Prelim/0337?year=2016

#include <bits/stdc++.h>

using namespace std;

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

    if (e == 0) {
        if (y <= 1911) {
            cout << "M" << y - 1868 + 1 << endl;
        } else if (y <= 1925) {
            cout << "T" << y - 1912 + 1 << endl;
        } else if (y <= 1988) {
            cout << "S" << y - 1926 + 1 << endl;
        } else {
            cout << "H" << y - 1989 + 1 << endl;
        }
    } else if (e == 1) {
        cout << 1868 + (y - 1) << endl;
    } else if (e == 2) {
        cout << 1912 + (y - 1) << endl;
    } else if (e == 3) {
        cout << 1926 + (y - 1) << endl;
    } else {
        cout << 1989 + (y - 1) << endl;
    }
    
    return 0;
}

/*
 *
 */


Measured memory_bytes: 3108
import sys
import math

N = int(input())
AList = [int(n) for n in input().split()]
BList = [int(n) for n in input().split()]

result = 0

for i in range(N):
    i = int(i)

    m = min(AList[i], BList[i])
    AList[i] -= m
    BList[i] -= m
    result += m
    
    m = min(AList[i+1], BList[i])
    AList[i+1] -= m
    BList[i] -= m
    result += m

print(result)

Measured memory_bytes: 18468
#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 = 410, inf = 2e18;
int a[mxn];
int dp[mxn][mxn], n;
bool c[mxn][mxn];

int f(int l, int r)
{
	if(c[l][r])
		return dp[l][r];
	if(l == r)
		dp[l][r] = 0;
	else
	{
		dp[l][r] = inf;
		FOR(k, l, r - 1)
			dp[l][r] = min(dp[l][r], f(l, k) + f(k + 1, r) + a[r] - a[l - 1]);
	}
	c[l][r] = 1;
	return dp[l][r];
}

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;
	a[0] = 0;
	FOR(i, 1, n)
	{
		cin >> a[i];
		a[i] += a[i - 1];
	}
	memset(c, 0, sizeof(c));
	cout << f(1, n);

	return 0;
}

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

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

    // 入力値を配列に代入
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }

    // 配列の値を逆順に出力
    for (int i = n; i > 0; i--) {
    cout << arr[i-1];
    if(i-1!=0)cout<<" ";
    }
    cout << endl;
    return 0;
}


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

const LL MOD = 1000000007;
LL powmod(LL a, LL n){
    if(n == 0) return 1;
    if(n % 2) return (a*powmod(a,n-1)) % MOD;
    LL c = powmod(a, n/2);
    return (c*c) % MOD;
}
LL inv(LL a){
    return powmod(a, MOD-2);
}
LL fact[110000];
LL invfact[110000];

LL ncr(LL n, LL r){
    if(r < 0 || n < 0) return 0;
    if(n < r) return 0;
    LL a = fact[n];
    a = (a * invfact[r]) % MOD;
    a = (a * invfact[n-r]) % MOD;
    return a;
}
void init(){
    fact[0] = 1;
    invfact[0] = 1;
    LL inv2 = inv(2);
    for(LL i = 1; i < 110000; i++){
        fact[i] = (i*fact[i-1]) % MOD;
        invfact[i] = inv(fact[i]);
    }
}

pair<LL,LL> solve(vector<LL> a){
	LL r = a[0];
	for(int j = 0; j < a.size(); j++){
		r = min(r, a[j]);
	}
	LL num0 = 0;
	for(int j = 0; j < a.size(); j++){
		a[j] -= r;
		if(a[j] == 0) num0++;
	}
	vector<LL> cur;
	LL total = powmod(2, num0);
	LL alternating = 2;
	a.push_back(0);

	for(int j = 0; j < a.size(); j++){
		if(a[j] == 0 && cur.size() > 0){
			pair<LL,LL> d = solve(cur);
			cur.clear();
			total = (total * (d.first + d.second) ) % MOD;
			alternating = (alternating * d.second) % MOD;
		}
		if(a[j] != 0){
			cur.push_back(a[j]);
		}
		if(a[j] == 0){
			num0 ++;
		}
	}
	total -= alternating;
	alternating = (alternating * powmod(2, r-1)) % MOD;
	total += alternating;
	total %= MOD;
	if(total < 0) total += MOD;
	if(alternating < 0) alternating += MOD;
	return {total, alternating};
}
int main(){
	LL N;
	cin >> N;
	vector<LL> h;
	for(int i = 0; i < N; i++){
		LL a;
		cin >> a;
		h.push_back(a);
	}
	pair<LL,LL> ans = solve(h);
	cout << ans.first << endl;
}


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

char alpha[26] = {'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'};

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

int main(){
    string s, t; cin >> s >> t;
    int ans = 0;
    REP(i, 0, s.size()){
        if(s[i] != t[i]){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3920
import java.io.*;

class Main {
	public static void main(String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		try {
			String buf = br.readLine();
			int x = Integer.parseInt(buf);
			System.out.println((int)Math.pow(x,3));
		} catch (IOException e) {
			System.out.println("IOException!");
		}
	}
}

Measured memory_bytes: 16876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define TEST int t;cin>>t;for(int i=1;i<=t;i++)
#define F first
#define S second
int main()
{
	long double a,b;
	cin>>a>>b;
	long double c=a*b;
	cout<<fixed<<setprecision(0)<<c<<endl;
	//main();
}


Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>


// #define INT_MAX 2147483647
// #define LL_MAX 9223372036854775807

using namespace std;
#define i64  long long

void solve(void)
{
  int x;
  int h,m,s;

  cin>>x;
  h = x/3600;
  m = (x - h*3600)/60;
  s = (x - h*3600 -m*60);
  cout<<h<<":"<<m<<":"<<s<<endl;
}
int main(int argc, const char *argv[])
{

  solve();

  return 0;
}



Measured memory_bytes: 3084
def g(n, a):
    for i in range(1, 100):
        if a**i > n:
            return a**(i-1)
    return -1

dp = {}
def solve(n):
    if n < 6:
        return n
    if not n in dp:
        a = g(n, 6)
        b = g(n, 9)
        dp[n] = min(solve(n-a)+1, solve(n-b)+1)
    return dp[n]

# assert solve(127) == 4
# assert solve(3) == 3
# assert solve(44852) == 16

print solve(input())

Measured memory_bytes: 2568
#include<iostream>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define yn(i) ((i)?"Yes":"No")
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define abs(n) max((n),-(n))
#define dist(a,b) max((a)-(b),(b)-(a))
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}




string key="keyence";

void add(char m,string s,set<string> st){
  int n=s.size();
  rep(i,n){
    if(s[i]!=m) continue;
    string t;
    repa(j,i,n){
      t.push_back(s[j]);
      st.insert(t);
    }
  }
}

int main(){
  li a,b,c; cin >>a >>b >>c;
  if((a&b&c&1)==0){
    print(0);
    return 0;
  } 
  li m0=max({a,b,c}),m2=min({a,b,c}),m1=a+b+c-m0-m2;
  print(m1*m2);
}





Measured memory_bytes: 3604
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
a = Counter(v[::2])
b = Counter(v[1::2])
count = a.most_common()
count1 = b.most_common()
if len(set(v)) == 1:
    print(n//2)
    exit()
if count[0][0] == count1[0][0]:
    print(n- count[0][1] - (max(count[1][1], count1[1][1])))

else:
    print(n - count[0][1] - count1[0][1])

Measured memory_bytes: 70764
n, m = map(int, input().split())
c = [[] for _ in range(n+1)]
for i in range(m):
  a, b = map(int, input().split())
  c[a].append(b)
  c[b].append(a)

for i in c[1]:
  if n in c[i]:
    print('POSSIBLE')
    exit()

print('IMPOSSIBLE')

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

int main(){
    string S;
    cin >> S;
    vector<int> val(4);
    for(int i=0; i<4; i++){
        val[i] = S[i] - '0';
    }

    int target = 7;
    int ans = val[0];

    for(int i=0; i < 1<<3; i++){
        ans = val[0];
        int x0 = (i >> 0) & 1;
        int x1 = (i >> 1) & 1;
        int x2 = (i >> 2) & 1;

        ans = (x0 == 0)? ans - val[1] : ans + val[1];
        ans = (x1 == 0)? ans - val[2] : ans + val[2];
        ans = (x2 == 0)? ans - val[3] : ans + val[3];

        if(ans == target){
            char c0 = (x0 == 0)? '-' : '+';
            char c1 = (x1 == 0)? '-' : '+';
            char c2 = (x2 == 0)? '-' : '+';
            cout << val[0] << c0 << val[1] << c1 << val[2] << c2 << val[3] << "=7" << endl;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll x, ans = 0;
    cin >> x;
    ans += x / 11 * 2;
    x %= 11;
    if(x <= 6 && x != 0)ans++;
    else if (x != 0)ans += 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
//#ifdef DEBUG
//#define _GLIBCXX_DEBUG
//#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 2e5 + 10;
string s[maxN];
typedef unsigned long long ull;
const ull pt = 239;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
//    n = 2;
    vector < ull > all;
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
        reverse(s[i].begin(), s[i].end());
        ull cur = 0;
        for (int j = 0; j < s[i].size(); j++) {
            cur = cur * pt + (s[i][j] - 'a' + 1);
        }
        all.emplace_back(cur);
    }
    sort(all.begin(), all.end());
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        int cnt[26] = {};
        for (char& c : s[i]) cnt[c - 'a']++;
        ull cur_hsh = 0;
        for (int len = 0; len < s[i].size(); len++) {
            if (len > 0) {
                cur_hsh = cur_hsh * pt + (s[i][len - 1] - 'a' + 1);
                cnt[s[i][len - 1] - 'a']--;
            }
            for (int d = 0; d < 26; d++) {
                if (cnt[d]) {
                    ull nn = cur_hsh * pt + (ull)d + 1;
                    int r = lower_bound(all.begin(), all.end(), nn) - all.begin();
                    if (r != all.size() && all[r] == nn) ans++;
                }
            }
        }
    }
    cout << ans - n;
    return 0;
}

Measured memory_bytes: 11540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const ll mil = 5000000000000000;

int solve(string &s, ll k) {
    int tmp = -1;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] != '1') {
            tmp = i;
            break;
        }
    }

    if (tmp == -1 || k < tmp + 1) {
        return 1;
    }
    return s[tmp] - '0';
}

int main() {
    string s; cin >> s;
    ll k; cin >> k;
    int ans = solve(s, k);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 40;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
const ll MOD = 1e9 + 7;

int main(){
    int N, M; cin >> N >> M;
    vector<string> A,B;
    string s;

    FOR(i,0,N){
        cin >> s;
        A.push_back(s);
    }
    FOR(i,0,M){
        cin >> s;
        B.push_back(s);
    }
    bool flg1=false;
    FOR(i,0,N-M+1){
        FOR(j,0,N-M+1){
            bool flg2=true;
            FOR(k,0,M){
                if(A[i+k].substr(j,M)!=B[k])flg2=false;
            }
            if (flg2) flg1=true;
        }
    }
    if(flg1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mod = 1e9 + 7;

ll modpower(ll a, ll m) {
    ll res = 1;
    ll n = m;
    ll b = a;
    while (n > 0) {
        if (n % 2 == 1) {
            res *= b;
            res %= mod;
        }
        n /= 2;
        b = (b * b) % mod;
    }
    return res;    
}

ll modinv(ll a){
    return modpower(a, mod-2);
}

int main(){
    int x;
    int y;
    cin >> x >> y;
    int xjiku = 0;
    int yjiku = 0;
    while(x > 0 && y > 0){
        if(x>=y){
            x-=2;
            y-=1;
            xjiku++;            
        }else{
            x-=1;
            y-=2;
            yjiku++;
        }
    }
    if(x != 0 || y != 0){
        cout << "0" << endl;
        return 0;
    }

    ll ans = 1;
    for (int i = xjiku+yjiku; i >= xjiku+1; i--) {
        ans *= i;
        ans %= mod;
    }
    for (int i = 1; i <= yjiku; i++) {
        ans *= modinv(i);
        ans %= mod;
    }
    cout << ans << endl;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ops = 0;
    while (b <= a)
    {
        b = b << 1;
        ops++;
    }
    while (c <= b)
    {
        c = c << 1;
        ops++;
    }
    if (ops <= k)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 3648
var l,r,u,d:array[1..2000] of array[1..2000] of integer;
    i,j,h,w,ans:integer;
    s:array[1..2000] of array[1..2000] of char;

begin
  ans:=0;
  readln(h,w);
  for i:=1 to h do begin
    for j:=1 to w do read(s[i][j]);
    readln
  end;
  for i:=1 to h do begin
    for j:=1 to w do begin
      if s[i][j] = '#' then begin
        u[i][j] := -1;
        l[i][j] := -1
      end else begin
        if i=1 then u[i][j] := 0 else u[i][j] := u[i-1][j] + 1;
        if j=1 then l[i][j] := 0 else l[i][j] := l[i][j-1] + 1
      end
    end
  end;
  for i:=h downto 1 do begin
    for j:=w downto 1 do begin
      if s[i][j] = '#' then begin
        d[i][j] := -1;
        r[i][j] := -1
      end else begin
        if i=h then d[i][j] := 0 else d[i][j] := d[i+1][j] + 1;
        if j=w then r[i][j] := 0 else r[i][j] := r[i][j+1] + 1
      end;
      if ans < l[i][j] + r[i][j] + u[i][j] + d[i][j] + 1 then ans := l[i][j] + r[i][j] + u[i][j] + d[i][j] + 1
    end
  end;
  writeln(ans)
end.

Measured memory_bytes: 66560
import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        for(int i = 0;i<s.length();i++){
            if(i%2==0){
                System.out.print(s.charAt(i));
            }
        }
    }
}



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


int main(){
	
	int p,q;
	while(cin>>p>>q){
		map <int,int>mp;
		int i=1,n=1;
		for(;n;i++){
			p*=10;
			if(mp[p]){
				n=mp[p];
				break;
			}
			mp[p]=i;
			int j=p/q;
			cout<<j;
			p-=j*q;
			if(p==0)n=0;
		}
		cout<<endl;
		if(n){
			for(int j=1;j<i;j++){
				if(j>=n)cout<<'^';
				else cout<<' ';
			}
			cout<<endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 1196
#define _USE_MATH_DEFINES
#include <iostream>//C++全般
#include <cmath>//
#include <cstdio>//printf
#include<algorithm>//max,min
#include <string>//string

using namespace std;

int main()
{
	int w, h;
	bool flg = false;
	cin >> h >> w;
	while (h||w) {
		for (int n = 0; n < h; n++) {
			for (int i = 0; i < w; i++) {
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
		cin >> h >> w;
	}
	return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;

const int N = 2e5+5;
int cnt[N];

int main()
{
   IOS;
   int n;
   cin >> n;
   vector<int>a;
   vector<int>b;
   rep(i,1,n)
   {
       int x;
       cin >> x;
       ++cnt[x];
       a.pb(x);
   }
   rep(i,1,n)
   {
       int x;
       cin >> x;
       ++cnt[x];
       b.pb(x);
   }
   rep(i,0,n)
   {
       if(cnt[i] > n)
       {
           cout << "No";
           return 0;
       }
   }
   cout << "Yes\n";
   sort(b.rbegin(),b.rend());
   n = b.size();
//    cout << n <<endl;
   rep(i,0,n-1)
   {
       if(a[i] == b[i])
       {
           rep(j,0,n-1)
           {
               if(b[i] != b[j] && a[j] != b[i])
               {
                   swap(b[i],b[j]);
                   break;
               }
           }
       }
   }
   for(auto i:b)
   {
       cout << i << ' ';
   }
}


Measured memory_bytes: 6320
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	long double ans_temp = 0;
	for(int i = 0; i < n; i++){
		double temp;
		cin >> temp;
		ans_temp += (1/temp);
	}
	long double ans = (1/ans_temp);
	cout <<setprecision(16)<<ans<< endl;
}

Measured memory_bytes: 256
x = int(input())
thresh=130
for i in range(thresh):
	for j in range(thresh):
		if i**5 - j**5 == x:
			print(i,j)
			exit(0)
		if j**5 - i**5 == x:
			print(j,i)
			exit(0)
for i in range(thresh):
	for j in range(0,-thresh,-1):
		if i**5 - j**5 == x:
			print(i,j)
			exit(0)
		if j**5 - i**5 == x:
			print(j,i)
			exit(0)
for i in range(0,-thresh,-1):
	for j in range(thresh):
		if i**5 - j**5 == x:
			print(i,j)
			exit(0)
		if j**5 - i**5 == x:
			print(j,i)
			exit(0)
for i in range(0,-thresh,-1):
	for j in range(0,-thresh,-1):
		if i**5 - j**5 == x:
			print(i,j)
			exit(0)
		if j**5 - i**5 == x:
			print(j,i)
			exit(0)

Measured memory_bytes: 67712
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

const int MOD = 1000000007;

int main(){
  int n; cin >> n;
  
  rep(i,50001){
    int x = i*1.08;
    if(x == n){
      cout << i << endl;
      return 0;
    }
  }
  
  cout << ":(" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(void) {
	string a, b;

	cin >> a >> b;

	if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

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

using namespace std;

map<pair<int, int>, int> mapper;
int maxi = -1;

void dfs(vector<int> edges[], int c, int node, int par){

    int temp_c = 1;

    for(auto adj: edges[node]){
        if(par - adj){
            if(temp_c == c) temp_c++;
            mapper[{node, adj}] = temp_c;
            mapper[{adj, node}] = temp_c;

            maxi = max(maxi, temp_c);

            dfs(edges, temp_c, adj, node);
            temp_c++;
        }
    }
}

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

    vector<int> edges[n];

    pair<int, int> edgeList[n-1];

    for(int i=0; i<n-1; i++){
        int u, v;
        cin >> u >> v;
        u--, v--;

        edgeList[i] = {u, v};

        edges[u].push_back(v);
        edges[v].push_back(u);
    }

    dfs(edges, 0, 0, -1);

    cout << maxi << endl;

    for(int i=0; i<n-1; i++){
        pair<int, int> cur = edgeList[i];
        cout << mapper[cur] << endl;
    }
}


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

int main() {
  int X,A,B;
  cin >> X >> A >> B;
  if(A>=B){
    cout << "delicious" << endl;
    return 0;
  }
  else if(A+X<B){
    cout << "dangerous" << endl;
    return 0;
  }
  cout << "safe" << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n,k;
    cin >> n >> k;
    vector<int>v(n);
    for(auto & e: v) cin >> e;
    int res = 0;
    int sum = 0;
    for(int bit = 40; bit >= 0;bit--){
        int cnt = 0;
        for(auto num : v){
            // increment when 'bit' is settted.
            if(1LL << bit & num) cnt++;
        }
        if(cnt*2 < n and sum + (1LL << bit) <= k ){
            sum += 1LL << bit;
            res += (1LL << bit) * (n-cnt);
            continue;
        }
        //Optimal bit is zero.... addition is unnecessary
        // sum += 0;
        res += (1LL << bit) * (cnt);
        
    }
    cout << res << endl;
}



Measured memory_bytes: 1024
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	String[] TABLE = {"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","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) {
		new Main().run();
	}
	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int a,b,c; String target;
			Queue <Integer> q = new LinkedList<Integer>();

			a = sc.nextInt();

			if(a == 0){
				break;
			}

			for(int i=0; i < a ; i++){
				q.add(sc.nextInt());
			}

			target = sc.next();
			String[] tgtchr = new String[target.length()];
			for(int i=0; i < target.length(); i++){
				tgtchr[i] = String.valueOf(target.charAt(i));
			}

			for(int i=0; i < target.length(); i++){
				for(int j=0; j < TABLE.length; j++){
					//System.out.println("out");
					if(TABLE[j].equals(tgtchr[i])){
						//System.out.println("in");
						c = q.poll();
						b = j - c;
						if(b < 0){
							b = 52 + b;
						}
						q.add(c);
						System.out.print(TABLE[b]);
					}
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 25548
import math
a = list(map(int,input().split()))
xy = [map(int, input().split()) for _ in range(a[0])]
x, y = [list(i) for i in zip(*xy)]


def caldis(x, y):
    l = math.sqrt(x ** 2 + y ** 2)
    return l

ans = 0

i = 0
for i in range(a[0]):

    if caldis(x[i], y[i]) <= a[1]:
        ans += 1
    i += 1

print(ans)

Measured memory_bytes: 116708
#pragma GCC optimize "trapv" 
#include<bits/stdc++.h>
#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define inarr(arr,n)   rep(i,a,n)cin>>arr[i]
#define ll             long long int
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define IOS            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ret            return 0
#define pi             3.1415926536
#define hell           1000000007
#define narak          998244353
const int inf1=1e9;
const ll inf2=1e18;
const int N=100000;
using namespace std;
int dirs[4][2] ={{1,0},{-1,0},{0,1},{0,-1}};
bool ispalindrome(string s){
    string t=s;
    reverse(all(s));
    return t==s;
}
int solve(){
 string s;cin>>s;
 int n=s.length();
 int f1=ispalindrome(s);
 int f2=ispalindrome(s.substr(0,(n-1)/2));    
 int f3=ispalindrome(s.substr((n+3)/2-1,n-(n+3)/2+1));    
 if(f1&f2&f3){
     cout<<"Yes\n";
 }
 else{
     cout<<"No\n";
 }
 ret;
}
int main(){
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef cat
    cat();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    ret;
}
 

Measured memory_bytes: 256
#include<stdio.h>
int main (void)
{
   int a,b;
   scanf("%d %d", &a, &b);
   if (a < b) {
     printf("a < b\n");
   }
   else if (a > b) {
     printf("a > b\n");
   }
   else {
     printf("a == b\n");
   }
   return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>


int main(){
  int N;
  scanf("%d", &N);
  std::vector<int> a(N);
  int min=1001001001, max=-1001001001;  
  int minindex = -1;
  int maxindex = -1;
  for (int i=0; i<N; i++){
    scanf("%d", &a[i]);
    if (a[i]<min){
      min = a[i];
      minindex = i;
    }
    if (a[i]>max){
      max = a[i];
      maxindex = i;
    }
  }
  if (min>=0){
    printf("%d\n", N-1);
    for (int i=1; i<N; i++){
      printf("%d %d\n", i, i+1);
    }
  } else if (max<=0){
    printf("%d\n", N-1);
    for (int i=N; i>1; i--){
      printf("%d %d\n", i, i-1);
    }  
  } else {
    if (abs(max)>=abs(min)){
      printf("%d\n", 2*N-1);
      for (int i=1; i<=N; i++){
        printf("%d %d\n",maxindex+1,i);
      }
      for (int i=1; i<N; i++){
        printf("%d %d\n", i, i+1);
      }
    } else {
      printf("%d\n", 2*N-1);
      for (int i=1; i<=N; i++){
        printf("%d %d\n",minindex+1,i);
      }
      for (int i=N; i>1; i--){
        printf("%d %d\n", i, i-1);
      }      
    }
  }
  return 0;
}

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

int main() {
    std::string s; std::cin >> s;
    std::string t; std::cin >> t;
    std::size_t slength = s.size();
    
    for (int i = 0; i < slength; i++) {
        char first = s[0];
        s.erase(s.begin(), s.begin() + 1);
        s += first;
        
        if (s == t) {
            std::cout << "Yes" << std::endl;
            return 0;
            break;
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[309][309];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	long long ret = 0; bool flag = true;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int res = 2012345678;
			for (int k = 0; k < n; k++) {
				if (k != i && k != j) {
					res = min(res, a[i][k] + a[k][j]);
				}
			}
			if (res < a[i][j]) flag = false;
			if (res > a[i][j]) ret += a[i][j];
		}
	}
	cout << (flag ? ret : -1) << endl;
	return 0;
}

Measured memory_bytes: 640