akhauriyash/Code-Regression huggingface dataset:
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back+

#define eb emplace_back
#define mod   1000000007
#define PI 2*acos(0.0)
#define all(r)(r).begin(),(r).end()
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define inf 1000000000000000000
#define N 3007
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};


//=============================================ASIFAZAD==============================================//

int32_t main()
{
    ll n;
    cin>>n;
    int p = floor(log2(n)) + 1;
    ll ans = 1;
    while(p--)
        ans *= 2;
    ans--;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vector<llong> a(n);
	llong sum=0;
	REP(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	
	vector<llong> v=a;
	llong ans=100*(llong)INF;
	REP(i,n-1){
		v[i+1]+=v[i];
		llong tmp=sum-2*v[i];
		ans=min(ans,abs(tmp));
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include <stdint.h>
#include <stdio.h>
using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using s8 = int8_t;
using s16 = int16_t;
using s32 = int32_t;
using s64 = int64_t;
// using float
// using double

int main() {
  s32 N;
  s32 K;
  s32 h;
  s32 sum = 0;
  scanf("%d%d", &N, &K);
  for(s32 i=0; i < N; i++){
    scanf("%d", &h);
		if(h >= K) sum++;
	}
  printf("%d\n", sum);
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

typedef long long ll;

const int MAXN = 100005;

int N;
ll a[MAXN];
vector <int> E[MAXN];
vector <int> nodes[MAXN];
int dad[MAXN];

void load() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++)
    scanf("%lld", a + i);
  for (int i = 1; i < N; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    E[x].push_back(y);
    E[y].push_back(x);    
  }
}

void dfs(int x, int p, int d) {
  nodes[d].push_back(x);
  dad[x] = p;
  for (int i = 0; i < E[x].size(); i++)
    if (E[x][i] != p)
      dfs(E[x][i], x, d + 1);
}

bool work(int depth) {
  vector <int> curr = nodes[depth];
  while (!curr.empty()) {
    int node = curr.back();
    int parent = dad[node];
    vector <ll> tmp;
    for (; !curr.empty() && dad[curr.back()] == parent; curr.pop_back()) 
      tmp.push_back(a[curr.back()]);
    ll sum = 0;
    for (int i = 0; i < tmp.size(); i++)
      sum += tmp[i];
    if (tmp.size() > 1)  {
      if (sum < a[parent] || sum > 2 * a[parent])
        return false;
      ll val = sum - a[parent];
      ll mx = *max_element(tmp.begin(), tmp.end());
      if (val > min(sum / 2, sum - mx))
        return false;
      a[parent] *= 2;
      a[parent] -= sum;
    }
    else if (a[node] != a[parent])
      return false;
  }
  
  return true;
}

bool solve() {
  if (N == 2)
    return a[1] == a[2];
  
  int root = 0;
  for (int i = 1; i <= N; i++)
    if (E[i].size() > 1) {
      root = i;
      break;
    }
  
  dfs(root, 0, 0);
  
  for (int i = N - 1; i >= 0; i--)
    if (!work(i))
      return false;
  
  return true;
}

int main() {
  load();
  puts(solve() ? "YES" : "NO");
  return 0;
}

Measured memory_bytes: 15872
N = int(input())
As = []
for i in range(N):
    As.append(int(input()))
As.sort()
if N%2 == 0:
    s = 0
    for i in range(N):
        if i < N/2:
            s -= 2*As[i]
        else:
            s += 2*As[i]
    s = s + As[int(N/2)-1] -As[int(N/2)]
    print(s)
else:
    s1, s2 = 0, 0
    for i in range(N):
        if i < N//2 -1:
            s1 -= 2*As[i]
        elif N//2-1 <= i <=N//2 :
            s1 -= As[i]
        else:
            s1 +=  2*As[i]
        if i < N//2:
            s2 -= 2*As[i]
        elif N//2 <= i <= N//2 +1:
            s2 += As[i]
        else:
            s2 += 2*As[i]
    print(max(s1, s2))


Measured memory_bytes: 7444
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = s, i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = s; i < (n); ++i)
#define VFORS(i, s, n) for(int i = s; i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = s, i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = s, i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
const int MOD = 1000000007;
const int INF = 1000000000;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n; cin >> n;
    double ans = 0;
    REP(i, n){
        int a; cin >> a;
        ans += 1.0 / a;
    }
    cout << fixed << setprecision(10) << 1 / ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  map<int, int> count;
  int A;
  long int ans = 0;
  for(int i = 0; i < N; i++){
    cin >> A;
    count[A] += 1;
    ans += A;
  }
  int Q; cin >> Q;
  int B, C;
  for(int j = 0; j < Q; j++){
    cin >> B >> C;
    ans = ans + (C - B) * count[B];
    cout << ans << endl;
    count[C] += count[B];
    count[B] = 0;
  }
  return 0;
}

Measured memory_bytes: 7964
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    そう甘くはないんだな〜w
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::mem::swap;
use std::ops::*;
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, One, Pow, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::rngs::SmallRng;
use rand::{random, Rng, SeedableRng};

pub const MOD: usize = 1000000007;
pub const MAX: usize = 1usize << 63usize;
pub const MIN: i64 = i64::MIN;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 'A' as u8;

use std::time::{Duration, Instant};

// code...
// #[fastout]
fn main() {
    input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d]
    }

    let start = Instant::now();

    let mut rng = SmallRng::from_entropy();

    let mut ans = Vec::new();
    for day in 0..d {
        let w = s[day].iter().enumerate().max_by_key(|x| x.1).unwrap().0 + 1;
        ans.push(w);
    }
    let mut scr = score(d, &c, &s, &ans);

    dbg!(scr);

    let mut count = 0usize;

    while start.elapsed().as_millis() < 1980 {
        let prev = ans.clone();
        ch(&mut ans, &c, &s, &mut rng);
        let new = score(d, &c, &s, &ans);
        if new <= scr {
            ans = prev;
        } else {
            scr = new;
        }
        count += 1;
    }

    dbg!(score(d, &c, &s, &ans));
    dbg!(count);

    for i in ans {
        println!("{}", i);
    }
}

fn score(d: usize, c: &Vec<i64>, s: &Vec<Vec<i64>>, ans: &Vec<usize>) -> i64 {
    let mut last = vec![0usize; 26];
    let mut a = 0i64;

    for day in 0..d {
        a += s[day][ans[day] - 1];
        last.iter_mut().for_each(|x| *x += 1);
        last[ans[day] - 1] = 0;
        a -= last
            .iter()
            .enumerate()
            .map(|(i, l)| c[i] * *l as i64)
            .sum::<i64>();
    }
    a
}

fn ch(ans: &mut Vec<usize>, c: &Vec<i64>, s: &Vec<Vec<i64>>, rng: &mut SmallRng) {
    for (d, i) in ans.iter_mut().enumerate() {
        if rng.gen_bool(0.01) {
            let g = s[d]
                .iter()
                .enumerate()
                .map(|x| (x, c[x.0]))
                .sorted_by(|a, b| ((b.0).1, a.1).cmp(&((a.0).1, b.1)))
                .skip(1)
                .take(5)
                .collect_vec();
            *i = (g[rng.gen_range(0, g.len())].0).0 + 1;
        }
    }
}


Measured memory_bytes: 2328
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = 998244353;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n;
string s;

int32_t main(){_
      
   cin >> n >> s;

   vector<int> a(8);
   a[0] = n;

   int ans = 1;
   for (int i = 0; i < 3 * n; ++i)
   {
      if (s[i] == 'R'){
         if (a[6]){
            ans *= a[6];
            --a[6];
         }
         else if (a[3]){
            ans *= a[3];
            --a[3];
            a[5]++;
         }
         else if (a[2]){
            ans *= a[2];
            --a[2];
            a[4]++;            
         }
         else{
            ans *= a[0];
            --a[0];
            a[1]++;
         }
      }
      else if (s[i] == 'G'){
         if (a[5]){
            ans *= a[5];
            --a[5];
         }
         else if (a[3]){
            ans *= a[3];
            --a[3];
            a[6]++;
         }
         else if (a[1]){
            ans *= a[1];
            --a[1];
            a[4]++;            
         }
         else{
            ans *= a[0];
            --a[0];
            a[2]++;
         }         
      }
      else{
         if (a[4]){
            ans *= a[4];
            --a[4];
         }
         else if (a[1]){
            ans *= a[1];
            --a[1];
            a[5]++;
         }
         else if (a[2]){
            ans *= a[2];
            --a[2];
            a[6]++;            
         }
         else{
            ans *= a[0];
            --a[0];
            a[3]++;
         }
      }
      ans %= mod;
   }
      
   cout<<ans;

   return 0;
}

Measured memory_bytes: 720
import java.util.*;

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

		int sum = 0;
		
		for(int i = 0; i < 4; i++) {
			sum+=sc.nextInt();
		}
		
		int x = 0, y = 0;
		
		while(sum > 0) {
			if(sum >= 60) {
				sum-=60;
				x++;
			} else {
				sum--;
				y++;
			}
		}
		
		System.out.println(x);
		System.out.println(y);
	}
}

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

int main(){
	int n;
	cin >> n;
	vector<pair<pair<string,int>,int>> p(n);
	
	rep(i,n){
		string s;
		int x;
		cin >> s >> x;
		p[i] = make_pair(make_pair(s,-x),i);
	}
	
	sort(p.begin(),p.end());
	
	rep(i,n){
		cout << p[i].second+1 << endl;
 	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(long long i=0;i<n;++i)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
using namespace std;
const int INF=INT_MAX;

vector< int > G[100000];
list< int > out;
bool V[100000];
int N;
int indeg[100000];

void bfs(int s){
    queue< int > q;
    q.push(s);
    V[s]=true;
    while(!q.empty()){
        int u=q.front();q.pop();
        out.push_back(u);
        REP(i,G[u].size()){
            int v=G[u][i];
            indeg[v]--;
            if(indeg[v]==0&&!V[v]){
                V[v]=true;
                q.push(v);
            }
        }
    }
}

void tsort(){
    REP(i,N){
        indeg[i]=0;
    }

    REP(u,N){
        REP(i,G[u].size()){
            int v=G[u][i];
            indeg[v]++;
        }
    }

    REP(u,N) if(indeg[u]==0&&!V[u]) bfs(u);

    for(auto it=out.begin();it!=out.end();++it) printf("%d\n",*it);
}

int main(){
    int s,t,M;

    scanf("%d%d",&N,&M);

    REP(i,N) V[i]=false;

    REP(i,M){
        scanf("%d%d",&s,&t);
        G[s].push_back(t);
    }

    tsort();

    return 0;
}




Measured memory_bytes: 6132
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;



int main(){

	int n,r,k,to,table[101][101],num_of_packet,start,goal,t_limit,P[101],D[101],num,min,min_index,current,Distance[101][101];

	for(int i=1; i < 101; i++){
		for(int k=1; k < 101; k++){
			table[i][k] = 0;
			Distance[i][k] = 1000000000;
		}
	}

	scanf("%d",&n);

	for(int i = 0; i < n; i++){
		scanf("%d %d",&r,&k);
		for(int p=0;p < k; p++){
			scanf("%d",&to);
			table[r][to] = 1;
		}
	}

	for(int i = 1; i<= n; i++){
		for(int k=1; k <= n; k++){
			if(i != k){
				start = i, goal = k;

				for(int index=1; index <= n; index++){
					P[index] = 0;
					D[index] = 1000000000;
				}

				P[start] = 1;
				num = 1;

				for(int index = 1; index <= n; index++){
					if(index != start && table[start][index] == 1){
						D[index] = 1;
					}
				}

				while(num < n){
					min = 1000000000;
					for(int index=1;index <= n; index++){
						if(P[index] == 0 && D[index] < min){
							min = D[index];
							min_index =index;
						}
					}

					if(min == 1000000000)break;

					P[min_index] = 1;
					current = min_index;
					num++;
					for(int index=1; index <= n; index++){
						if(table[current][index] == 1){
							D[index] = (D[index] <= (D[current]+1))?D[index]:(D[current]+1);
						}
					}
				}

				Distance[start][goal] = D[goal];
			}
		}
	}

	scanf("%d",&num_of_packet);

	for(int i=0; i < num_of_packet; i++){
		scanf("%d %d %d",&start,&goal,&t_limit);

		if(Distance[start][goal] >= t_limit){
			printf("NA\n");
		}else{
			printf("%d\n",Distance[start][goal]+1);
		}

	}

    return 0;
}

Measured memory_bytes: 2780
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int m, k;
	cin >> m >> k;

	if (k >= (1 << m))cout << -1 << endl;
	else if (m <= 1) {
		if (k)cout << -1 << endl;
		else if (m)cout << "0 1 1 0" << endl;
		else cout << "0 0" << endl;
	}
	else {
		rep(i, 1 << m)if (i != k)cout << i << " ";
		cout << k << " ";
		rep(i, 1 << m)if ((1 << m) - i - 1 != k)cout << (1 << m) - i - 1 << " ";
		cout << k << endl;
	}
}

Measured memory_bytes: 3644
#include <string>
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	int a,e,f;
	cin >> a;
	int b[a];
	int c = 0;
	double d=0,g=a;
	while (a > c) {
		cin >> b[c];
		c = c + 1;
	}
	c = 0;
	while (a > c) {
		d = d + b[c];
		c = c + 1;
	}
	d = d / g;
	f = round(d);
	c = 0;
	while (a > c) {
		e = e + (b[c] - f)*(b[c] - f);
		c = c + 1;
	}
	cout << e << endl;
}

Measured memory_bytes: 888
from collections import deque
 
N,M=map(int,input().split())
 
graph=[[]for _ in range(N+1)]
 
for _ in range(M):
    A,B=map(int,input().split())
    graph[A].append(B)
    graph[B].append(A)
 
dist=[-1]*(N+1)
dist[0]=0
dist[1]=0
 
D=deque()
D.append(1)
 
while D:
    V=D.popleft()
    for i in graph[V]:
        if dist[i]!=-1:
            continue
        dist[i]=V
        D.append(i)
 
print('Yes')
for j in dist[2:]:
    print(j)

Measured memory_bytes: 35084
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

A, B = map(int, input().split())
list_n = list(map(str, input().rstrip('\n').split("-")))
# print(list_n[0])
# print(list_n[1])
if len(list_n[0]) == A and len(list_n[1]) == B:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	getline(cin,s);
	for (int i=0;i<=s.size()-1;i+=2)
	{
		if (s[i]!='R'&&s[i]!='U'&&s[i]!='D')
		{
			cout<<"No";
			return 0;
		}
	}
	for (int i=1;i<=s.size()-1;i+=2)
	{
		if (s[i]!='L'&&s[i]!='U'&&s[i]!='D')
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=2e5+100;
int A[maxn];
int n,m;
LL k;
map<int,int> mp;
vector<int> ans;
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>A[i];
    int st=1;
    int cnt=1;
    while(1)
    {
        ans.push_back(st);
        if(mp[st])
            break;
        mp[st]=cnt;
        st=A[st];
        cnt++;
    }
    int d=cnt-mp[st];
    int val=(k-1LL*(mp[st]-1))%d;
    k++;
    if(k<mp[st])
        cout<<ans[k-1]<<endl;
    else
    {
        while(val)
        {
            val--;
            st=A[st];
        }
        cout<<st<<endl;
    }
}

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

long long dp[101][100001];

int main(void){
  int N,W ; cin >> N >> W;
  vector<int> w;
  vector<int> v;
  for(int i=0 ; i<N ; ++i){
    int a,b;
    cin >> a >> b;
    w.push_back(a);
    v.push_back(b);
  }

  for(int i=0 ; i<N ; ++i){
    for(int j=0 ; j<W+1 ; ++j){
      if(w[i]<=j){
        dp[i+1][j] = max(dp[i][j-w[i]]+v[i], dp[i][j]);
      }else{
        dp[i+1][j] = dp[i][j];
      }   
    }   
  }

  cout << dp[N][W] << endl;

  return 0;
}


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

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()


#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>

void print(T x)
{
	std::cout << x << '\n';
}


int main() {
	int N;
	cin >> N;
	int count = 0;
	vector<int> a(N);
	rep(i, N) {
		cin >> a[i];
	}
	rep(i, N - 2) {
		if ((a[i + 2] > a[i + 1] and a[i + 1] > a[i]) or (a[i] > a[i + 1] and a[i + 1] > a[i + 2]))count++;
	}
	printf("%d", count);
}

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

#include <iostream>
#include <vector>
// #include <map>
#include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

struct Wareki {
	string g;
	int y;
	int m;
	int d;

	explicit Wareki() {};
	explicit Wareki(string g, int y, int m, int d) : g(g), y(y), m(m), d(d) {};
	void print() {
		cout << g << " " << y << " " << m << " " << d << endl;
	}
	Wareki convert() {
		Wareki converted;
		converted.g = g;
		converted.y = y;
		converted.m = m;
		converted.d = d;
		if ((y == 31 and m >= 5) or y > 31) {
			converted.g = "?";
			converted.y = y - 30;
		}
		return converted;
	}
};

int main() {
	string g;
	int y, m, d;

	while (1) {
		cin >> g >> y >> m >> d;
		if (g == "#") {
			break;
		}
		Wareki before(g, y, m, d);
		Wareki after = before.convert();
		after.print();
	}

	// std::cout << "\e[38;5;0m\e[48;5;40m --- end ---  \e[m" << std::endl; // debug
	return 0;
}



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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const long long MOD = 1000000007;
const int MAX_N = 21;
int n;
bool a[MAX_N][MAX_N];
ll memo[1<<MAX_N][MAX_N];
bool vis[1<<MAX_N][MAX_N];

// 選ばれた女性がstの時,男性i以降でペアを作る
ll rec(int st, int i) {
  if (i >= n) return 1;
  if (vis[st][i]) return memo[st][i];

  vis[st][i] = true;

  for (int j = 0; j < n; j++) {
    if (st & (1<<j) || !a[i][j]) continue;
    memo[st][i] = (memo[st][i] + rec(st|(1<<j),i+1)) % MOD;
  }

  return memo[st][i];
}

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n;
  forn(i,n) forn(j,n) cin >> a[i][j];

  cout << rec(0,0) << endl;

  return 0;
}


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

int main(){
    char c;
    cin >> c;
    if (islower(c)){
        cout << 'a' << endl;
    } else {
        cout << 'A' << endl;
    }
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int x;
    for (int i = 0; i < 5; ++i) {
        cin >> x;
        if (x == 0) {
            cout << i+1 << endl;
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
int main(void) {
	int a, c, x;
	char b;
	while(1){
        scanf("%d %c %d", &a, &b, &c);
     	if(b=='+'){
     		x=a+c;
     	}else if(b=='-'){
     		x=a-c;
     	}else if(b=='*'){
     		x=a*c;
     	}else if(b=='/'){
     		x=a/c;
     	}else{
     		break;
     	}
     	printf("%d\n", x);
     	
	}
	return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <limits>

using namespace std;

vector<unsigned> v;
vector<vector<size_t>> dp;

size_t solution(const int L, const int R)
{
  if (L+1 >= R) return 0;
  size_t s = 0;
  for (int i = L; i < R; ++i) s += v[i];
  size_t res = numeric_limits<size_t>::max();
  for (int i = L+1; i < R; ++i)
  {
    if (dp[L][i] == 0) dp[L][i] = solution(L, i); 
    if (dp[i][R] == 0) dp[i][R] = solution(i, R); 
    res = min(res, dp[L][i] + dp[i][R]);
  }
  return res + s;
}

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

  int N;  
  cin >> N;
  dp = vector<vector<size_t>>(N+1, vector<size_t>(N+1, 0));

  v.resize(N);
  for (int i = 0; i < N; ++i)
  {
    cin >> v[i];
  }

  cout << solution(0, v.size());

  return 0;
}

Measured memory_bytes: 1536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");
		int a = Integer.parseInt(strlist[0]);
		int b = Integer.parseInt(strlist[1]);
		int c = Integer.parseInt(strlist[2]);
 
		String answer = "NO";
 
		for(int i=0; i<b; i++){
			if((i*b+c) % a == 0){
				answer = "YES";
				break;
			}
		}
		System.out.println(answer);
	}
 
 
}

Measured memory_bytes: 22996
#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 <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846
#ifdef LOCAL
#include <sys/types.h>
#include <sys/timeb.h>
#include <intrin.h> 
#include <thread>
#else
#include <sys/time.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

char ans[] = "keyence";

int main(){
	string str;
	cin >> str;
	int n = str.length();
	REP(i, 8) {
		if (str.substr(0, i) + str.substr(n - (7-i), 7 - i) == "keyence") {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;	
	return 0;
}

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

int main() {
  vector<int> ryori(5);
  for (int i = 0; i < 5; i++) {
    cin >> ryori.at(i);
  }
  
  vector<int> mod(5);
  bool bo = true;
  int sum = 0;
  int last = 9;
  
  for (int i = 0; i < 5; i++) {
    mod.at(i) = ryori.at(i) % 10;
    if (mod.at(i) != 0) {
      bo = false;
      sum += ((ryori.at(i) / 10) + 1) * 10;
      last = min(last, mod.at(i));
    }
    else {
      sum += ryori.at(i);
    }
  }
  if (bo) {
    cout << sum << endl;
  }
  else {
    cout << sum - (10 - last) << endl;
  }
}


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

int main()
{
 int A[1100],B[1100];
 int N,H,W;
 cin >> N >> H >> W;
 for(int i = 0; i < N; i++) cin >> A[i] >> B[i];
 int count = 0;
    
 for(int i = 0; i < N; i++){
     if(A[i] >= H && B[i] >= W) count++;
 }
    
 cout << count;

 return 0;
}

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

#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORTASC(c) sort((c).begin(), (c).end())
#define SORTDESC(c, t) sort((c).begin(), (c).end(), std::greater<t>());
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

const double PI = acos(-1.0);

using ll = long long;
using namespace std;

int main()
{
    string s;

    cin >> s;

    REP(i, s.length()){
        cout << "x";
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
	"strings"
)

type node struct {
	num    int
	parent *node
	left   *node
	right  *node
}

func printPreOrder(sep *string, n *node) {
	if n == nil {
		return
	}
	fmt.Printf("%s%d", *sep, n.num)
	*sep = " "
	printPreOrder(sep, n.left)
	printPreOrder(sep, n.right)
}
func printInOrder(sep *string, n *node) {
	if n == nil {
		return
	}
	printInOrder(sep, n.left)
	fmt.Printf("%s%d", *sep, n.num)
	*sep = " "
	printInOrder(sep, n.right)
}
func printPostOrder(sep *string, n *node) {
	if n == nil {
		return
	}
	printPostOrder(sep, n.left)
	printPostOrder(sep, n.right)
	fmt.Printf("%s%d", *sep, n.num)
	*sep = " "
}

func partition(delim int, order []int) ([]int, []int) {
	for i, e := range order {
		if e == delim {
			return order[0:i], order[i+1 : len(order)]
		}
	}
	return nil, nil
}

func recoverTree(parent *node, preIdx *int, preorder, inorder []int, tree []node) *node {
	// fmt.Printf("parent[%v] preIdx[%v] inorder[%v] tree[%v]\n", parent, *preIdx, inorder, tree)
	// 今訪れている先行巡回のnode
	me := &tree[*preIdx]
	// 親を設定
	me.parent = parent

	// 中間巡回から自分をみつけて左右のnodeにわける.
	left, right := partition(me.num, inorder)

	// 左を復元
	if left != nil && len(left) > 0 {
		*preIdx++
		me.left = recoverTree(me, preIdx, preorder, left, tree)
	} else {
		me.left = nil
	}

	// 右を復元
	if right != nil && len(right) > 0 {
		*preIdx++
		me.right = recoverTree(me, preIdx, preorder, right, tree)
	} else {
		me.right = nil
	}
	return me
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	nodeCount := eGetInt(reader)
	nodes := make([]node, nodeCount)
	preorder := eAtoisMany(strings.Fields(eGetline(reader)))
	inorder := eAtoisMany(strings.Fields(eGetline(reader)))
	for i := 0; i < nodeCount; i++ {
		nodes[i].num = preorder[i]
	}

	preIdx := 0
	recoverTree(nil, &preIdx, preorder, inorder, nodes)

	for i := range nodes {
		sep := ""
		if nodes[i].num == preorder[0] {
			// sep = ""
			// printPreOrder(&sep, &nodes[i])
			// fmt.Println()
			//
			// sep = ""
			// printInOrder(&sep, &nodes[i])
			// fmt.Println()

			sep = ""
			printPostOrder(&sep, &nodes[i])
			fmt.Println()
			break
		}
	}
}
func eGetInt(reader *bufio.Reader) int {
	return eAtoi(eGetline(reader))
}

func eGetline(o *bufio.Reader) string {
	s, err := o.ReadString(byte('\n'))
	if err != nil {
		if err == io.EOF {
			return s
		}
		log.Fatal(err.Error())
	}
	return s[:len(s)-1]
}

func eAtoisMany(s []string) []int {
	result := make([]int, len(s))
	for i := 0; i < len(s); i++ {
		result[i] = eAtoi(s[i])
	}
	return result
}

func eAtoi(s string) int {
	v, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err.Error())
	}
	return v
}



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

int main() {
  long long n, k;
  cin>>n>>k;
  long long cnt[k+1];
  for (int i=0; i<k+1; i++) cnt[i] = 0;
  long long pw[k+1];
  for (int i=0; i<k+1; i++) pw[i] = 0;
  long long mod = 1e9 + 7;
  long long sum = 0;
  for (int x=k; x>=1; x--) {
    long long y = k / x;
    if (pw[y] == 0) {
      pw[y] = 1;
      for (int i=0; i<n; i++) {
        pw[y] *= y;
        pw[y] %= mod;
      }
    }
    cnt[x] = pw[y];
    for (int i=2*x; i<k+1; i+=x) {
      cnt[x] -= cnt[i];
      if (cnt[x] < 0) {
        cnt[x] += mod;
      }
    }
    sum += cnt[x] * x;
    sum %= mod;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 5108
package main

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

func main() {
	r, txt := readLineInt()[0], readLine()
	if r%2 != 0 {
		goto Fail
	}

	if txt[r/2:] != txt[:r/2] {
		goto Fail
	}
	fmt.Println("Yes")
	return

Fail:
	fmt.Println("No")
}

/////////////////////////////////////////

func readLineInt() []int {
	result := make([]int, 0)
	for _, v := range strings.Split(readLine(), " ") {
		i, _ := strconv.Atoi(v)
		result = append(result, i)
	}
	return result
}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}


Measured memory_bytes: 2816
#include<stdio.h>
#include<string.h>
int main (void){
        int f=0,i,n;
        char s[100000];
        scanf("%s",&s);
        n=strlen(s);
        for(i=1;i<n;i++){
                if(s[i]==s[i-1]){
                        if(s[i]==0x30) {s[i]=0x31; f++;}
                        else {s[i]=0x30;f++;}
        }}
        printf("%d",f);
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i)
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
#define dis distance
#define so sort
#define rev reverse
#define pub push_back
#define sec second
#define fir first

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9+7;

int main (){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(SZ(s) < 4){
        cout << "No" << endl;
        return 0;
    }
    string cs = "YAKI";
    REP(i,4){
        if(s[i] != cs[i]){
            cout << "No" << endl; 
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

typedef struct edge{
    int v;              // エッジの　終点　だと思われる
    LL w;               // エッジの　重み　だと思われる
    edge() {}                                              // 構造体のコンストラクタ 
    edge(int v, LL w) : v(v), w(w) {};                     // これはv,wを同時にpush_back(emplace_back)するために必要
} Edge;

vector<LL> dijkstra(int n, vector<vector<Edge> >& G, int s) {   // N , G , start (ノードは0-index)
    vector<LL> d(n, LLONG_MAX/10); d[s] = 0;                    // LLONG_MAX はlong　long　の最大値を呼び出す 
    priority_queue<pair<LL, int> > que;                         // p_queue の作成　s　はやっぱりstart地点の番号
    que.push(make_pair(0LL, s));                                // queue に　（0、辺の始点）をpushしてる。                 
    while (!que.empty()) {                                      // queue が空っぽになるまでループ
        auto p = que.top(); que.pop();                          // queue から一個もってくる
        int u = p.second;                                       // もってきたpairから　二番目の情報、つまり対象となるノード番号を獲得
        LL  dist = -p.first;                                    // dist は最短距離の一時変数で、 -p.first と負の数にしているのは、p_queue の greater を省略するため。逆順ソートしたいから。
        if (dist > d[u]) continue;                              // dはそのノードまでの最短距離を表現していると考えられる。
        for (Edge e : G[u]) {                                   // 作ったグラフの　u番目　のもつpairを呼び出してる
            if (d[e.v] > d[u]+e.w) {                            // d[e.v]はEdgeの接続先のこれまでの最短距離。　右辺は接続元までの距離＋辺の重み
                d[e.v] = d[u] + e.w;                            // 最短距離の更新 
                que.push(make_pair(-d[e.v], e.v));              // 更新したノードの（最短距離と番号）をpush
            }                                                   // つまり、拡張for文でpushされた要素たちは、最短距離を更新できなくなると廃棄されて行ってemptyになるということ。
        }
    }
    return d;                                                   // 各ノードまでのstart地点からの最短距離が出る。
}

int main() {
    int N;cin >> N;
    vector<vector<Edge>> G(N);

    rep(i,N-1){
        int from,to; LL cost; 
        cin >> from >> to >> cost;
        from--;
        to--;
        G[from].emplace_back(to,cost);
        G[to].emplace_back(from,cost);
    }

    int Q,K;cin >> Q >> K;
    K--;

    vector<pair<int,int>> que(Q);
    rep(i,Q){
        int a,b;cin >> a >> b;
        a--;
        b--;
        que[i].F = a;
        que[i].S = b;
    }


    auto d = dijkstra(N,G,K);

    rep(i,Q){
        cout << d[que[i].F] + d[que[i].S] << endl;
    }

}

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

std::string s;
std::map<char, int> m;
int main() {
    std::cin >> s;
    for (int i = 0; i < s.size(); i++) {
        m[s[i]]++;
    }
    for (auto e: m) {
        if (e.second != 1) {
            std::cout << "no" << std::endl;
            return 0;
        }
    }
    std::cout << "yes" << std::endl;
}


Measured memory_bytes: 768
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int gcd(int a,int b){
	if(a/b)return b;
	return gcd(b,a%b);
}

int exdgcd(int a,int b,int c){

}

int main(){
	int n;
	long long y;
	cin>>n>>y;
	bool check=true;
	rep(i,y/10000+1){
		rep(j,y/5000+1){
			int res=(y-i*10000-j*5000)/1000;
			if(res>=0 && i+j+res==n){
				cout<<i<<" "<<j<<" "<<res<<endl;
				check=false;
				break;
			}
		}
		if(!check)break;
	}
	if(check)cout<<"-1 -1 -1"<<endl;
	return 0;
}

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

using ll = long long;

int main() {
    int n, k;
    vector<int> h;
    cin >> n >> k;
    rep(i, n) {
        int tmp;
        cin >> tmp;
        h.push_back(tmp);
    }
    sort(h.begin(), h.end());
    vector<int> diffs;
    rep(i, h.size() - (k - 1)) { diffs.push_back(h[i + k - 1] - h[i]); }
    cout << *min_element(diffs.begin(), diffs.end()) << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 110;
short h, w, a[N][N];
char s[N][N];
short dp[N][N][N];
short C(int x1, int y1, int x2, int y2) {
	if (x1>x2||y1>y2) return 0;
	--y1,--x1;
	return a[x2][y2]-a[x1][y2]-a[x2][y1]+a[x1][y1];
}
void chkmax(short &a, short b) {a<b?a=b:0;}
int main() {
	scanf("%hd%hd", &h, &w);
	int x, y;
	REP(i,1,h) { 
		scanf("%s",s[i]+1);
		REP(j,1,w) a[i][j]=a[i-1][j]+a[i][j-1]-a[i-1][j-1]+(s[i][j]=='o');
		REP(j,1,w) if (s[i][j]=='E') x = i, y = j;
	}
	short ans = 0;
	PER(a,1,x) REP(c,x,h) PER(b,1,y) REP(d,y,w) {
		int x1=1-x+c,x2=h-x+a;
		int y1=1-y+d,y2=w-y+b;
		short &r = dp[b][c][d];
		chkmax(ans,r);
		if (c<h) {
			chkmax(dp[b][c+1][d],r+C(max(x1,c+1),max(y1,b),min(x2,c+1),min(y2,d)));
		}
		if (b>1) {
			chkmax(dp[b-1][c][d],r+C(max(x1,a),max(y1,b-1),min(x2,c),min(y2,b-1)));
		}
		if (d<w) {
			chkmax(dp[b][c][d+1],r+C(max(x1,a),max(y1,d+1),min(x2,c),min(y2,d+1)));
		}
		r += C(max(x1,a-1),max(y1,b),min(x2,a-1),min(y2,d));
	}
	printf("%hd\n", ans);
}


Measured memory_bytes: 2688
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>

namespace TokorotenLab
{
    /*
    Arguments:
        Search range: [begin, end)
        Target function: f(x)
    Requirement:
        f(x) => { false, ..., false, true, ..., true }
    Judge:
        true_bound == begin => All f(x) are true
        true_bound == end => All f(x) are false
    */
    std::pair<long long, long long> binary_search(long long begin, long long end, std::function<bool(long long)> f)
    {
        long long false_bound = begin - 1LL; // ( ..., false_bound] => false
        long long true_bound = end; // [true_bound, ... ) => true
        long long x;

        while(true_bound - false_bound > 1LL)
        {
            x = false_bound + (true_bound - false_bound) / 2LL;
            if(f(x))
            {
                true_bound = x;
            }
            else
            {
                false_bound = x;
            }
        }

        return std::make_pair(false_bound, true_bound);
    }
}

using namespace std;

#define int long long

signed main()
{
    string s;
    vector<vector<int> > dp;
    const int MOD = 1e9 + 7;

    cin >> s;

    dp.resize(s.size() + 1, vector<int>(13));

    dp[0][0] = 1;
    for(int i = 0; i < s.size(); ++i)
    {
        if(s[i] == '?')
        {
            for(int k = 0; k <= 9; ++k)
            {
                for(int j = 0; j < 13; ++j)
                {
                    dp[i + 1][(10 * j + k) % 13] += dp[i][j];
                }
            }
        }
        else
        {
            int k = s[i] - '0';
            for(int j = 0; j < 13; ++j)
            {
                dp[i + 1][(10 * j + k) % 13] += dp[i][j];
            }
        }

        for(int j = 0; j < 13; ++j)
        {
            dp[i + 1][j] %= MOD;
        }
    }

    cout << dp[s.size()][5] << endl;

    return 0;
}

Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#include "string"
#define int long long

int32_t main(){
   boost;
   int n,m;
   cin>>n>>m;
   string ans  = "No";
   for(int i=0;i<101;i++){
      for(int j=0;j<101;j++){
         if(i+j == n && i*4+2*j == m)
            ans = "Yes";
      }
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3648
s = list(input())

# Note: init
# cnt = 0
# i = 1
#
# while i < len(s):
#     while len(s) != 0 and s[i - 1] != s[i]:
#         s.pop(i)
#         s.pop(i - 1)
#         i -= 1
#         cnt += 2
#     i += 1
#
# print(cnt)


cnt = min(s.count("0"), s.count("1"))
print(cnt*2)


Measured memory_bytes: 3956
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <limits.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;



int main()
{
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;

	vi p(A);
	for (int& i : p)
		cin >> i;
	vi q(B);
	for (int& i : q)
		cin >> i;
	vi r(C);
	for (int& i : r)
		cin >> i;

	sort(begin(p), end(p), greater<int>());
	sort(begin(q), end(q), greater<int>());
	sort(begin(r), end(r), greater<int>());

	int pi = X - 1, qi = Y - 1, ri = 0;
	while (true)
	{
		if (ri >= C) break;

		int pp = (pi < 0) ? INT_MAX : p[pi];
		int qq = (qi < 0) ? INT_MAX : q[qi];
		int rr = r[ri];
		if (pp >= rr && qq >= rr) break;

		if (pp < qq)
		{
			p[pi] = r[ri];
			--pi;
			++ri;
		}
		else
		{
			q[qi] = r[ri];
			--qi;
			++ri;
		}
	}

	ll ans = 0;
	for (int i = 0; i < X; i++)
	{
		ans += p[i];
	}
	for (int i = 0; i < Y; i++)
	{
		ans += q[i];
	}

	cout << ans << endl;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
#define REP(i, m, n) for(long long i = m; i < n; ++i)
#define CO(n) cout << n << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N;
int A[110];

int main()
{
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i,0,N) cin >> A[i];
    bool flag = true;
    REP(i,0,N){
        if (A[i]%2 == 0){
            if (A[i]%3 != 0 && A[i]%5 != 0) flag = false;
        }
    }
    if (flag) CO("APPROVED");
    else CO("DENIED");
    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
a = []
b = []
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

ans = 0
N.times do |i|
  if b[i] >= a[i]
    b[i] -= a[i]
    ans += a[i]
    a[i] = 0
    if b[i] >= a[i+1]
      b[i] -= a[i+1]
      ans += a[i+1]
      a[i+1] = 0
    else
      a[i+1] -= b[i]
      ans += b[i]
      b[i] = 0
    end
  else
    a[i] -= b[i]
    ans += b[i]
    b[i] = 0
  end
end

puts ans

Measured memory_bytes: 15388
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		if (N ==1) {
			System.out.println(M);
			return ;
		}
		for (int i=M/N;i>=0;i--) {
			if (M%i==0) {
				System.out.println(i);
				return ;
			}
		}
	}
}


Measured memory_bytes: 23252
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;

template<typename T>
using v = vector<T>;

int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	if (H%h == 0 && W%w == 0) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	int sum = 0;
	int n = ((H + h - 1) / h) * ((W + w - 1) / w);
	int b = (int)((double)n / (n*h*w - H*W)) + 1;
	int a = (h*w - 1)*b - 1;
	rep(i, H) {
		rep(j, W) {
			if (i%h == 0 && j%w == 0) {
				cout << a;
				sum += a;
			}
			else {
				cout << -b;
				sum -= b;
			}
			if (j == W - 1) {
				cout << endl;
			}
			else {
				cout << ' ';
			}
		}
	}
	//cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
int main()
{
  int a,b,c,d;
  while (scanf("%d%d",&a,&b) != EOF)
    {
      if(a+b==0) d=1;
      else
	{
	  c=1;
	  d=0;
	  while((a+b)/c != 0)
	    {
	      c*=10;
	      d++;
	    }
	}
      printf("%d\n",d);
    }
  return 0;
}

Measured memory_bytes: 600