akhauriyash/Code-Regression huggingface dataset:
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if(s=="SAT")
            {
                Console.WriteLine(1);
            }
            else if (s == "FRI")
            {
                Console.WriteLine(2);
            }
            else if (s == "THU")
            {
                Console.WriteLine(3);
            }
            else if (s == "WED")
            {
                Console.WriteLine(4);
            }
            else if (s == "TUE")
            {
                Console.WriteLine(5);
            }
            else if (s == "MON")
            {
                Console.WriteLine(6);
            }
            else
            {
                Console.WriteLine(7);
            }
        }
    }
}


Measured memory_bytes: 25840
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
#include<numeric>
#include<chrono>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define M 998244353
#define all(x) x.begin(),x.end()
#define mkp(a,b) make_pair(a,b)
using namespace std;
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
inline int mex(unordered_set<int> st)
{
	int m = 0;
	while (st.find(m) != st.end())
	{
		m += 1;
	}
	return m;
}
inline int calculateGrundy(int n)
{
	if (n == 1)
		return 0;
	unordered_set<int> mexi;
	for (int i = 1; i <= sqrt(n); i += 1)
	{
		if (n % i == 0)
		{
			if (n / i != n)
				mexi.insert(calculateGrundy(n / i));
			mexi.insert(calculateGrundy(i));
		}
	}
	return mex(mexi);
}
inline ll gcd(ll a, ll b)
{
	// This is code taken from geeksforgeek
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
/*ll power(ll x, ll y)
{
	// This is code taken from geeksforgeek
	ll res = 1;

	x = x % N;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % N;
		y = y >> 1;
		x = (x * x) % N;
	}
	return res;
}*/
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;

	while (y > 0)
	{

		if (y & 1)
			res = (res * x);

		y = y >> 1;
		x = (x * x);
	}
	return res;
}


/*ll modInverse(ll n, ll p)
{
	return power(n, p - 2, p);
}*/

ll sum(ll n)
{
	return (n * (n + 1)) / 2;
}
ll sum_digit(ll n)
{
	ll ans = 0;
	while (n)
	{
		ans += n % 10;
		n /= 10;
	}
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s;
	cin>>s;
	ll fir=(s[3]-'0')+(10*(s[2]-'0'));
	ll sec=(s[1]-'0')+(10*(s[0]-'0'));
	
	if((fir>12&&sec>12))
	{
		cout<<"NA";
	}
	else if(fir==0&&sec==0)
	{
		cout<<"NA";
	}
	else if((fir==0&&sec>12)||(sec==0&&fir>12))
	{
		cout<<"NA";
	}
	else if(fir==0&&sec<=12)
	{
		cout<<"MMYY";
	}
	else if(fir<=12&&sec==0)
	{
		cout<<"YYMM";
	}
	
	else if(sec<=12&&fir<=12)
	{
		cout<<"AMBIGUOUS";
	}
	else if(sec<=12)
	{
		cout<<"MMYY";
	}
	else
	{
		cout<<"YYMM";
	}
	
	return 0;
}


Measured memory_bytes: 3544
import math 
N,K=map(int,input().split())
A=[int(x) for x in input().split()]
A=sorted(A)
left=0
right=max(A)
mid=max((left+right)//2,1)

while(right-left>=1):
    numofcut=0
    
    for i in range(N):
        if A[i]%mid==0:
            numofcut+=(A[i]//mid) -1
        else:
            numofcut+=A[i]//mid
    #print(numofcut)
    if numofcut>K:
        left=mid+1
    else:
        right=mid
    mid=max((left+right)//2,1)
    if mid==1:
        break
print(mid)

Measured memory_bytes: 31052
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	string head = "", tail = "";
	bool rev = false;
	int q;
	cin >> q;
	rep(qi,q){
		int t;
		cin >> t;
		if(t == 1) rev = !rev;
		else{
			int f;
			char c;
			cin >> f >> c;
			if(f == 1){
				if(!rev) head += c;
				else tail += c;
			}
			else{
				if(!rev) tail += c;
				else head += c;
			}
		}
	}
	if(!rev){
		for(int i = head.size()-1; i >= 0; --i) cout << head[i];
		cout << s << tail << endl;
	}
	else{
		for(int i = tail.size()-1; i >= 0; --i) cout << tail[i];
		for(int i = s.size()-1; i >= 0; --i) cout << s[i];
		cout << head << endl;
	}
	return 0;
}

Measured memory_bytes: 3840
#include <stdio.h>
const int inf = 1000000000; // 10^9
int main(void){
    int n;
    int x[100+5];
    scanf("%d", &n);
    for(int i=0; i<n; i++)scanf("%d", &x[i]);
    
    // 最小値から最大値の範囲の総当り
    int min=x[0], max=x[0];
    for(int i=1; i<n; i++){
        if(min>x[i])min=x[i];
        if(max<x[i])max=x[i];
    }
    
    int ans=inf;
    for(int i=min; i<=max; i++){
        int cost=0;
        for(int j=0; j<n; j++){
            cost+=(x[j]-i)*(x[j]-i);
        }
        if(ans>cost)ans=cost;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1728
from collections import Counter
import sys
def solve():
    readline = sys.stdin.buffer.readline
    write = sys.stdout.buffer.write
    M, N = map(int, readline().split())
    if M == N == 0:
        return False
    B = [int(readline(), 2) for i in range(N)]
    memo = {}
    def dfs(s, t):
        key = (s, t)
        if key in memo:
            return memo[key]
        c = 0
        for b in B:
            if (b & s) == t:
                c += 1
        if c <= 1:
            memo[key] = 0
            return 0
        res = M
        for i in range(M):
            b = (1 << i)
            if s & b == 0:
                res = min(res, max(dfs(s|b, t), dfs(s|b, t|b))+1)
        memo[key] = res
        return res
    write(b"%d\n" % dfs(0, 0))
    return True
while solve():
    ...


Measured memory_bytes: 170992
#include <stdio.h>

void swap(int *x, int *y)
{
  int temp;
  temp = *x;
  *x = *y;
  *y = temp;
  
}

int main(void)
{

  int W, H, x, y, r;
  int ans = 0;
  
  scanf("%d%d%d%d%d", &W,&H,&x,&y,&r);
  
  if( x-r >= 0 && y-r >= 0 ){
    if( x+r <= W && y+r <= H ){
      ans = 1;
    }
  }
  
  if( ans ){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  
  return 0;

}

Measured memory_bytes: 584
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N; cin >> N;
    vi X(N); REP(i, N) cin >> X[i];

    vi a(N); REP(i, N) a[i] = X[i];
    sort(a.begin(), a.end());

    REP(i, N) {
        int ans = (X[i] < a[N / 2]) ? a[N / 2] : a[N / 2 - 1];
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3840
#include <iostream>
using namespace std;
int main(void){
    int n,a;
    while( cin >> n,n ){
        int f = 0,count = 0;
        for(int i = 0 ; i < n ; i++){
        cin >> a;
        if(a > 1)f = 1;
        if(a > 0)count++;
    }
    if(f)cout << count + 1 << endl;
    else cout << "NA" << endl;
  }
}


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

using namespace std;


set<long long> cand;

long long x, y;

set<long long> vis;

long long f(long long r) {
    if( vis.count(r) ) return 1e18;

    if( y == r ) return 0;

    vis.insert(r);


    long long ans = 1e18;
    for (auto c : cand) {
        if (r < c) {
            ans = min(ans, f(c) + c - r);
        }
        if (c == -r) {
            ans = min(ans, f(c) + 1);
        }
    }
    vis.erase(r);
    return ans;
}

int main() {
    cin >> x >> y;
    cand.insert(-x);
    cand.insert(+x);
    cand.insert(-y);
    cand.insert(+y);
    cout << f(x) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<string>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
using namespace std;

int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
signed main(){
	int n, k; cin >> n >> k;
	int a; cin >> a;
	int MAX = a;
	for (int i = 1; i < n; i++) {
		int b; cin >> b;
		MAX = max(MAX, b);
		a = gcd(a, b);
	}
	if (k%a == 0&&MAX>=k)puts("POSSIBLE");
	else puts("IMPOSSIBLE");
}

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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >>k;
  int anumb = a;
  int bnumb = b;
  int cnumb =c;
  int total = 0;
  int count = 0;
  while(true){
    if(anumb>0) {
      ++total;
      --anumb;
      ++count;
    }
   else if(bnumb>0){
      --bnumb;
        ++count;
    }
   else if(cnumb>0) {
      --total;
      --cnumb;
      ++count;
    }
    if(count == k) break;
  }
    cout << total << endl;

}


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

int main() {
  int N;
  cin >> N;
  vector<ll> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  ll ans = 0;
  for (int i = N - 1; i >= 0; i--) {
    if (i == N - 1 && (A[i] == 0 || A[i] % B[i] == 0)) continue;
    A[i] += ans;
    if (A[i] != 0 && A[i] % B[i] != 0) {
      ans += B[i] - (A[i] % B[i]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

const int TL = 1900;
const double T0=2e3;
const double T1=6e2;

int d;
vector<int> c(26);
vector<vector<int>> s;
vector<int> t, now;
vector<int> last(26, -1);
ll best = 0;

ll score(){
    ll res = 0;
    rep(i,26)last[i] = -1;
    rep(i,d){
        res += s[i][t[i]];
        last[t[i]] = i;
        rep(j,26) res -= c[j] * (i - last[j]);
    }
    return res;
}

double prob(double delta, double temp){
    if(delta >= 0) return 1;
    return exp(delta/temp);
}

int main(){
    auto start = std::chrono::system_clock::now();      // 計測スタート時刻を保存
    random_device seed;
    mt19937_64 mt(seed());
    uniform_int_distribution<int> rnd1(0,25);
    uniform_int_distribution<int> rnd3(1,16);
    uniform_int_distribution<int> rnd4(0,1);
    uniform_real_distribution<double> rnd5(0,1);

    cin >> d;
    uniform_int_distribution<int> rnd2(0,d-1);

    rep(i,26) cin >> c[i];
    s.resize(d);
    rep(i,d)s[i].resize(26);
    rep(i,d)rep(j,26) cin >> s[i][j];
    t.resize(d);
    rep(i,d)t[i] = rnd1(mt);
    best = score();
    // vecprint(t);
    double T = T0;
    while(true){
        auto end = std::chrono::system_clock::now();       // 計測終了時刻を保存
        auto dur = end - start;        // 要した時間を計算
        auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
        if(msec>=TL) break;
        T = pow(T0, 1-(double)msec/TL) * pow(T1, (double)msec/TL);

        if(rnd4(mt) == 0){
            int day = rnd2(mt);
            int con = rnd1(mt);
            int old = t[day];
            t[day] = con;
            ll now_s = score();
            if(rnd5(mt) < prob(now_s - best, T)) best = now_s;
            else t[day] = old;
        }else{
            int day1 = rnd2(mt);
            int day2 = day1 + rnd3(mt);
            if(day2 >= d)continue;
            swap(t[day1], t[day2]);

            ll now_s = score();
            if(rnd5(mt) < prob(now_s - best, T)) best = now_s;
            else swap(t[day1], t[day2]);
        }
    }

    // cout << score() << endl;
    rep(i,d)cout << t[i]+1 << endl;

    return 0;
}

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(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 (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}


signed main() {
    //my-code
    ll N, K; cin >> N >> K;
    ll ans = LINF;
    chmin(ans, N);
    chmin(ans, abs(N-K));
    chmin(ans, N%K);
    chmin(ans, abs(N%K-K));
    cout << ans << endl;

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let a = read_vec::<i64>();
    for i in 0..n - k {
        if a[i] < a[i + k] {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 6524
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var result = 1;
        var isIncrease = true;
        var i = 0;
        Get(ref i, ref isIncrease, ar);
        for(var j = i + 1; j < num-1; j++)
            if (isIncrease)
            {
                if (ar[j] <= ar[j + 1]) continue;
                else { result++;Get(ref j, ref isIncrease, ar); }
            }
            else
            {
                if (ar[j] >= ar[j + 1]) continue;
                else { result++;Get(ref j, ref isIncrease, ar); }
            }
        WriteLine(result);
    }

    private static void Get(ref int j,ref bool isIncrease,int[] ar)
    {
        for (var i = j==0?0:j+1; i < ar.Length-1; i++)
            if (ar[i] == ar[i + 1]) continue;
        else if (ar[i] < ar[i + 1]) { isIncrease = true;break; }
        else { isIncrease = false;break; }
    }
}


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


typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
/*--------------------------------------------*/


struct Edge{
    int to,index;
};

vector<bool> seen;
vector<int> parent;
vector<int> vert;


vector<vector<Edge>> G;

void dfs(int v,int p,int num,int index){
  vert[index] = num;

  int tmp = 1;
  for(auto next_e:G[v]){
    if(tmp == num) tmp++;
    dfs(next_e.to,v,tmp,next_e.index);
    tmp++;
  }
}

  
int main(){
  //cout.precision(10);
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;

  seen.assign(N,false);
  parent.resize(N);
  vert.assign(N-1,0);

  G.resize(N);

  vector<int> dim(N);

  rep(i,N-1){
      int a,b;
      cin >> a >> b;
      --a;--b;
      parent[b] = a;
      G[a].PB((Edge){b,i});
      dim[a]++;
      dim[b]++;
  }

  auto itr = max_element(ALL(dim));
  int M = *itr;
  cout << M << endl;        //最大次数

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


  rep(i,N-1)cout << vert[i] << endl;



}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

string print(int ans){
   if(ans == 0){
      cout<<"Sunny";
      exit(0);
   }
   else if (ans == 1){
      cout<<"Cloudy";
      exit(0);      
   }
   cout<<"Rainy";
   exit(0);
}

int Mapping(string s){
   if(s == "Sunny")
      return 0;
   else if(s == "Cloudy")
      return 1;
   else
      return 2;
}

int32_t main(){_

   string s;
   cin >> s;
   int ans = Mapping(s);
   ans++;
   ans %= 3;
   print(ans);

   return 0;
}

Measured memory_bytes: 256
# solution
import io
import math
import heapq
import bisect

def f(n):
    res = set()
    for i in range(2, int(n ** 0.5)):
        if n % i: continue
        while not n % i: n //= i
        res.add(i)
    return res | {n}

nim, mike = map(int,input().split())
print(len(f(nim) & f(mike) | {1}))

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

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

    cout << (b / k * k >= a ? "OK" : "NG") << endl;

    return 0;
}

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

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

  vector<ll> c(n);
  REP(i,n) cin >> c[i];

  REP(i,n-k) {
    if (c[i] < c[i+k]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  int N;
  cin>>N;
  map<string,int> m;
  string in;
  FOR(i,0,N){
    cin>>in;
    auto itr = m.find(in);
    if(itr != m.end()){
      m[in]++;
    }
    else{
      m[in]=1;
    }
  }
  int M;
  cin>>M;
  FOR(i,0,M){
    cin>>in;
    auto itr = m.find(in);
    if(itr != m.end()){
      m[in]--;
    }

  }
  int res =0;
  for(auto i=m.begin();i!=m.end();i++){
    res=std::max(res,i->second);
  }
  cout<<res<<endl;
}


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

typedef long long ll;
const ll MOD = 1000000007;

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

    ll ans = 0;
    int n = s.size();
    int cnt = 0;
    int d;
    for (int i = 0; i < n; i++) {
        int c = s[i]-'0'; 
        d = n-2;
        for (int j = 0; i+j < n; j++) {
            if (d < cnt) {
                d = cnt;
            }
            ans += c * pow(10, j) * pow(2, d);
            d--;
        }
        cnt++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
int main(int argc, char const* argv[]) {
    int a, b, c, x, y;
    std::cin >> a >> b >> c >> x >> y;
    int nz = 0;
    if (c * 2 < a + b) {
        nz += std::min(x, y);
    }

    if (c * 2 < a) {
        nz += std::max(x - nz, 0);
    }

    if (c * 2 < b) {
        nz += std::max(y - nz, 0);
    }
    std::cout << a * std::min(std::max(0, x - nz), x) + b * std::min(std::max(0, y - nz), y) + c * nz * 2 << std::endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i;
p_array = gets.split.map{|n| n.to_i };
q_array = gets.split.map{|n| n.to_i };

junretu_before = []
a = 0
b = 0
ans = 0
count = 0

(1..n).each do |x|
   junretu_before.push(x.to_i)
end

junretu_before.permutation do |x|
   count+=1
   if p_array == x
      a = count
   end

   if q_array == x
      b = count
   end

end

ans = (a -b).abs

puts ans


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

ll choose2(ll n) {
    return n*(n-1)/2;
}

int main() {
    int N;
    cin >> N; 
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    rep(i, N) A[i]--;
    vector<int> cnt(N);
    rep(i, N) cnt[A[i]]++;
    ll total = 0;
    rep(i, N) {
        total += choose2(cnt[i]);
    }
    rep(i, N) {
        ll ans = total;
        ans -= choose2(cnt[A[i]]);
        cnt[A[i]]--;
        ans += choose2(cnt[A[i]]);
        cout << ans << endl;
        cnt[A[i]]++;
    }
    return 0;
}

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

S = int(input())

# YYMM: XX01~XX12
# MMYY: 01YY~12YY
yymm = 0
mmyy = 0

if S % 100 <= 12 and S % 100 != 0:
    yymm = 1
if S // 100 <= 12 and S // 100 != 0:
    mmyy = 1

if yymm == 1 and mmyy == 1:
    print('AMBIGUOUS')
elif yymm == 1 and mmyy != 1:
    print('YYMM')
elif yymm != 1 and mmyy == 1:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
 
typedef long long int ll;
typedef pair<int, int> P;
 
const long long INF = 3e18 + 12;
const int inf = 1e9;
 
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) { cin >> v[i]; }
 
  sort(all(v));
 
  v.erase(unique(all(v)), v.end());
  cout << v.size() << endl;
 
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

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

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

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

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

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: usize,
    k: usize,
    sushi: [(usize1, i64); n],
  }
  let mut sushi = sushi;
  sushi.sort_by(|&(_, d1), &(_, d2)| d2.cmp(&d1));
  let mut kind_used = vec![false; n];
  let mut point_base = 0;
  let mut remove_candidate = vec![];
  let mut kind: i64 = 0;
  for &(t, d) in sushi.iter().take(k) {
    if kind_used[t] {
      remove_candidate.push(d);
    } else {
      kind_used[t] = true;
      kind += 1;
    }
    point_base += d;
  }
  remove_candidate.sort();
  let mut max_point = point_base + kind * kind;
  let mut add_candidate = vec![];
  for &(t, d) in sushi.iter().skip(k) {
    if ! kind_used[t] {
      add_candidate.push(d);
      kind_used[t] = true;
    }
  }
  for (i, &d) in add_candidate.iter().enumerate() {
    if i >= remove_candidate.len() {
      break;
    }
    point_base += d - remove_candidate[i];
    kind += 1;
    max_point = cmp::max(max_point, point_base + kind * kind);
  }

  println!("{}", max_point);
}


Measured memory_bytes: 8572
# https://atcoder.jp/contests/joisc2010/tasks/joisc2010_finals
import sys
input = sys.stdin.readline


class UnionFind:
    # この時点でそれぞれのノードは自分を親としている
    # 初期化時に問題が0の頂点を認めるかに注意すること
    def __init__(self, n):
        self.N = n
        self.parent = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    # xの根を返す関数
    def root(self, x):
        visited_nodes = []
        while True:
            p = self.parent[x]
            if p == x:
                # 縮約
                for node in visited_nodes:
                    self.parent[node] = x
                return x
            else:
                visited_nodes.append(x)
                x = p

    # 木の結合を行う。親の配下に入る
    def unite(self, x, y):
        if not self.root(x) == self.root(y):
            if self.rank[x] > self.rank[y]:
                self.parent[self.root(y)] = self.root(x)
            else:
                self.parent[self.root(x)] = self.root(y)
                if self.rank[x] == self.rank[y]:
                    self.rank[self.root(y)] += 1

    def ifSame(self, x, y):
        return self.root(x) == self.root(y)

    # 木の根に到達すまでにたどるノードの配列を返す
    def printDebugInfo(self):
        print([self.root(i) for i in range(self.N)])

# edge=[cost, place, place] sorted by cost.
# place are expected to be 0 to N-1
# N : vertical count


N = int(input())
X = []
Y = []
for i in range(N):
    x, y = map(int, input().split())
    X.append([x, i])
    Y.append([y, i])
X.sort()
Y.sort()

omega = []
for i in range(N-1):
    omega.append((X[i+1][0] - X[i][0], X[i][1], X[i+1][1], 0))
    omega.append((Y[i+1][0] - Y[i][0], Y[i][1], Y[i+1][1], 1))
omega.sort()
tree = UnionFind(N)
weight = 0
counter = N
i = 0
while True:
    # omega = [cost, place, place, type(0:x. 1:y)]
    minimum_edge = omega[i]
    a = minimum_edge[1]
    b = minimum_edge[2]
    kind = minimum_edge[3]
    cost = minimum_edge[0]
    if counter == 1:
        break
    i += 1
    if tree.ifSame(a, b):
        continue
    else:
        tree.unite(a, b)
        weight += cost
        counter -= 1
print(weight)


Measured memory_bytes: 61716
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;
typedef pair<ll, ll> pint;

const int MOD = 1000000007;
void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }
}

bool check(vector<pint> s) {
    int h = 0;
    for (pint p:s) {
        int b = h + p.first;
        if (b < 0) return false;
        h += p.second;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    vector<pint> ls, rs;
    int total = 0;
    rep(i, n) {
        string s;
        cin >> s;
        int h = 0, b = 0;
        for (char c : s) {
            if (c == '(') ++h; else --h;
            b = min(b, h);
        }
        if (h > 0) ls.emplace_back(b, h);
        else rs.emplace_back(b-h, -h);
        total += h;
    }

    sort(ls.rbegin(), ls.rend());
    sort(rs.rbegin(), rs.rend());
    if (check(ls) && check(rs) && total == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 34572
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
#include<tuple>
#include<iomanip>
#include<stack>
#include<cmath>
#define ll long long
using namespace std;
int main() {
	int data[3] = {};
	int x;
	cin >> x;
	data[x - 1] = 1;
	cin >> x;
	data[x - 1] = 1;
	for (int i = 0; i < 3; ++i)
		if (!data[i]) cout << i + 1 << endl;
	return 0;
}

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

int r[101010];

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

	int n;
	cin >> n;

	vector<int> v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];

	r[0] = 0;
	r[1] = abs(v[0] - v[1]);
	for (int i = 2; i < n; ++i) {
		r[i] = min(r[i-2] + abs(v[i-2] - v[i]), r[i-1] + abs(v[i-1] - v[i]));
	}
	cout << r[n-1] << '\n';
}


Measured memory_bytes: 1024
//
// Created on 2020/07/24.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    string s;
    cin>>s;
    vector<int>ans(s.size(),0);
    int odd_sum = 0;
    int even_sum = 0;
    char now = 'R';
    int last_index = 0;
    for (int i = 0; i < s.size(); ++i) {
        if(s[i] == now){
            if(i % 2 == 0) even_sum ++;else odd_sum ++;
        }else{
            if(now == 'R'){
                if(i % 2 == 0) swap(odd_sum,even_sum);
                ans[i - 1] += even_sum;
                ans[i] += odd_sum;
                last_index = i;
            }else{
                if(last_index % 2 != 0) swap(odd_sum,even_sum);
                ans[last_index - 1] += odd_sum;
                ans[last_index] += even_sum;
            }
            if(now == 'R')now = 'L';else now = 'R';
            odd_sum = 0;
            even_sum = 0;
            if(i % 2 == 0) even_sum ++;else odd_sum ++;
        }
    }
    if(last_index % 2 != 0) swap(odd_sum,even_sum);
    ans[last_index - 1] += odd_sum;
    ans[last_index] += even_sum;

    for (int j = 0; j < s.size() - 1; ++j) {
        cout<<ans[j]<<" ";
    }
    cout<<ans[s.size() - 1]<<endl;

    return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

int main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;

  cout << (H - h) * (W - w) << endl;

  return 0;
}

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

void swap(int& x, int& y){ 
    int tmp = x;
    x=y;
    y=tmp;
}

int main(){
    int i=1,x,y;
    cin >> x >> y;
    while (x!=0 || y!=0) {
        if(x>y) swap(x,y);
        cout << x << " " << y << endl;
        i++;
        cin >> x >> y;
    }   
    return 0;
}



Measured memory_bytes: 3080
#17:43
n,k = map(int,input().split())
a = list(map(lambda x: int(x)-1, input().split()))
mx = max(a) + 1
num = [[] for _ in range(mx)]
leg = [0 for _ in range(mx)]
for i in range(n):
  num[a[i]].append(i)
  leg[a[i]] += 1
#print(num)
nex = [0 for _ in range(n)]
for j in range(mx):
  nu = num[j]
  le = leg[j]
  for li in range(le-1):
    nex[nu[li]] = nu[li+1]+1
  if nu:
    nex[nu[-1]] = nu[0]+n+1
#print(nex)
unit = 0
now = 0
while True:
  tmp = nex[now]
  unit += tmp // n
  now = tmp % n
  #print(tmp,now)
  if now == 0:
    break
#print(unit)
k %= unit
k *= n
#print(k)
if k == 0:
  exit()
while True:
  tmp = nex[now]
  if k - (tmp-now) > 0:
    k -= tmp - now
    now = tmp % n
  else:
    ans = a[-k:]
    break
  #print(k)
l = len(ans)
seen = [0 for _ in range(mx)]
ans2 = []
for li in range(l):
  if seen[ans[li]] == 1:
    while True:
      p = ans2.pop()
      seen[p] = 0
      if p == ans[li]:
        break
  else:
    ans2.append(ans[li])
    seen[ans[li]] = 1
print(' '.join(map(lambda x:str(x+1),ans2)))

Measured memory_bytes: 128720
#include <iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

struct point{
  int x,y,b=0;
};

bool cmp2(point p,point q){
  return p.x<q.x ;
}

bool cmp3(point p,point q){
  return p.y<q.y ;
}

point red[200],blue[200];
int chk[200],n,tmp;

int solve(){
  int ans=0;
  for(int i=0;i<n;i++){
    chk[i] = 0;
  }

  for(int i=n-1;i>=0;i--){
    tmp=-1;
    for(int j=0;j<n;j++){
      if(blue[j].x>red[i].x&&blue[j].y>red[i].y&&!chk[j]){
        ans++;
        chk[j]=1;
        break;
      }
    }
  }
  return ans;
}

int main() {
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d%d",&red[i].x,&red[i].y);
  }
  for(int i=0;i<n;i++){
    scanf("%d%d",&blue[i].x,&blue[i].y);
  }
  int ans=0;
  sort(red,red+n,cmp3);
  sort(blue,blue+n,cmp2);
  ans = max(ans,solve());
  printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <utility>
using namespace std;

int main() {
  string s; cin >> s;
  set<char> se;
  for (int i = 0; i < s.length(); i++)
    se.insert(s[i]);
  if (s.length() == se.size())
    cout << "yes" << endl;
  else
    cout << "no" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>

using namespace std;

int main() {
	int N;
	string s;
	cin >> N;
	cin >> s;

	if (N % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}
	else {
		for (int i = 0; i < N / 2; ++i) {
			if (s[i] != s[i + N / 2]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;


	return 0;
}

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

int main() {
	int n, max, min, x;
	long  long sum;

	cin >> n;

	cin >> x;
	max = min = sum = x;

	for (int i = 0; i < n-1; i++) {
		cin >> x;
			if (x > max)	max = x;
			if (x < min)	min = x;
			sum += x;
	}
	cout << min << " " << max << " " << sum << endl;

	return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const ll MOD = 1000000007;
// const int INF = 2000000000;

ll N, C;
vector<ll> x, v;
vector<ll> x_rev;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> C;
  x.resize(N + 1, 0);
  v.resize(N + 1, 0);
  x_rev.resize(N + 2, 0);
  for (int i = 1; i <= N; i++) {
    cin >> x[i] >> v[i];
    x_rev[i] = C - x[i];
  }

  vector<ll> cum_calory(N + 1, 0);
  ll calory = 0;
  for (int i = 1; i <= N; i++) {
    cum_calory[i] = max(cum_calory[i - 1], calory + v[i] - x[i] + x[i - 1]);
    calory += (v[i] - x[i] + x[i - 1]);
  }

  // for (auto e : cum_calory) {
  //   cout << e << " ";
  // }
  // cout << endl;

  vector<ll> rev_cum_calory(N + 1, 0);
  calory = 0;
  for (int i = 1; i <= N; i++) {
    int rev_i = N - i + 1;
    rev_cum_calory[i] =
        max(rev_cum_calory[i - 1],
            calory + v[rev_i] - x_rev[rev_i] + x_rev[rev_i + 1]);
    calory += (v[rev_i] - x_rev[rev_i] + x_rev[rev_i + 1]);
  }

  // for (auto e : rev_cum_calory) {
  //   cout << e << " ";
  // }
  // cout << endl;

  ll ans = max(0LL, rev_cum_calory[N]);
  for (int i = 1; i <= N; i++) {
    ans = max(ans, cum_calory[i]);
    ans = max(ans, rev_cum_calory[i]);
    ans = max(ans, cum_calory[i] - x[i] + rev_cum_calory[N - i]);
    ans = max(ans, cum_calory[N - i] - x_rev[N - i + 1] + rev_cum_calory[i]);
  }

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

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

int keta(int N){
  int k = 1;
  while(N/10 > 0){
    N /= 10;
    k++;
  }
  return k;
}

int ketanum(int N, int num){
  for(int i = 0; i < num - 1; i++){
    N /= 10;
  }
  return N % 10;
}


int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M);
  vector<int> c(M);
  for(int i = 0; i < M; i++){
    cin >> s.at(i) >> c.at(i);
  }
  
  int result = 1;
  for(int i = 0; i < N - 1; i++){
    result *= 10;
  }
  int max = result * 10;

  while(result < max){
    bool judge = true;
    for(int i = 0; i < M; i++){
      if(ketanum(result,N - s.at(i) + 1) != c.at(i)) judge = false;
    }
    if(judge) break;
    result++;
  }

  //0の場合
  bool flag = true;
  for(int i = 0; i < M; i++){
    if(s.at(i) != 1 || c.at(i) != 0) flag = false;
  }

  if(N == 1 && flag) cout << 0 << endl;
  else if(result == max){

    cout << "-1" << endl;
  }
  else cout << result << endl;

}


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

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;

//少数点表示
//cout <<std::fixed << std::setprecision(14)

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    string s;
    cin >> s;
    int ss=s.size();
    int count=0;
    if(ss%2==0){
        rep(i,ss/2){
            if(s[i]!=s[ss-i-1]) count++;
            //cout << s[ss-i]<<endl;
        }
    }else{
        rep(i,ss/2){
            if(i==ss/2+1) break;
            if(s[i]!=s[ss-i-1]) count++;
        }
    }
    cout << count;


}

Measured memory_bytes: 256
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
A, B, C, D = [ri() for _ in range(4)]
print(min(A, B) + min(C, D))

Measured memory_bytes: 63232
N = int(input())
D, X = map(int, input().split())
A = []
day = 1

for i in range(N):
    a = int(input())
    X += 1
    while True:
        day += a
        if day > D:
            break
        else:
            X += 1
    
    day = 1

print(X)

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

int N;
int A[2020];
bitset<4040404> dp;

int main() {
    int N; cin >> N;
    REP(i, N) cin >> A[i];
    dp[0] = true;

    REP(i, N) {
        dp |= (dp << A[i]);
    }

    int ans = 0;
    REP(i, N) ans += A[i];
    ans = ans/2 + ans%2;

    while (!dp[ans]) ++ans;
    cout << ans << endl;
}


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

int main(){
  int h,w; cin>>h >>w;
  vector<string>a(h);
  for(int i=0;i<h;i++){
    cin>>a[i];
  }
  vector<bool>row(h,false);
  vector<bool>col(w,false);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(a[i][j]=='#'){
        row[i]=true;
        col[j]=true;
      }
    }
  }
  for(int i=0;i<h;i++){
    if(row[i]){
      for(int j=0;j<w;j++){
        if(col[j]){
          cout<<a[i][j];
        }
      }
      cout<<endl;
    }
  }
}

Measured memory_bytes: 256
n , k = map(int,input().split())

if(n%k == 0):
        
    g = n//k
        
    print(n - (g*k))
else:
    g = n//k
    ans = n - (g*k)
    if(abs(ans - k) < ans):
        print(abs(ans - k))
    else:
        print(ans)
        

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
typedef long long unsigned int ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

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

  int X;
  cin >> X;
  int ans = 1;
  rep(i, 1, X + 1) {
    rep(j, 2, X + 1) {
      int n = pow(i, j);
      if (X >= n) {
        ans = max(ans, n);
      } else {
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // setprecision
#include <cmath>

using namespace std;
typedef long long ll;
const double long PI = acos(-1);

void solve() {
  ll a, b;
  cin >> a >> b;
  cout << (a - 2 * b > 0 ? a - 2 * b : 0) << endl;
}

int main(void) {
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    string s,t;
    cin >> s >> t;
    int s_len = s.length();
    int t_len = t.length();
    vector<string> ans_cand;
    for (int i = 0; i+t_len<=s_len; i++)
    {
        int remain = s_len-t_len-i;
        string cand  = "";
        cand.append(i,'?');
        cand.append(t);
        cand.append(remain, '?');
        int flag = 0;
        for (int i = 0; i < s_len; i++)
        {
            if (cand[i]!='?' && s[i]!='?' && cand[i]!=s[i])
            {
                flag = 1;
                break;
            }
        }
        if(flag == 0)
        {
            for (int i = 0; i < s_len; i++)
            {
                if (cand[i]=='?')
                {
                    if(s[i]!='?')cand[i]=s[i];
                    else cand[i] = 'a';
                }
            }
            ans_cand.push_back(cand);
        }
    }
    if (sz(ans_cand)==0)
    {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    sort(ans_cand.begin(),ans_cand.end());
    cout << ans_cand[0] << endl;

    
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

ll sq(ll x){
	return x*x;
}

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

bool isvowel(char c){
	int i;
	string v="aeiou";
	for(i = (v.size()-1); i>=0; --i){
		if(c == v[i]){
			return true;
		}
	}
	return false;
}

int main(void){
	int x=0,n,ans=0,i;
	string s;
	cin >> n;
	cin >> s;
	for(i = 0; i < n; ++i){
		(s[i]=='I')?(++x):(--x);
		ans = max(ans,x);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int solve(int ,int);

int n,A[2000];

int main(){


  int i,q,mi;


  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&mi);

    if(solve(0,mi)) printf("yes\n");

    else printf("no\n");
  }
  return 0;

}


int solve(int i , int m){
  int res;

 if(m == 0) return 1; 
  
if( i >= n) return 0;
  

 res = solve(i+1,m) || solve(i+1,m - A[i]); return res;


}

Measured memory_bytes: 580
//gcc -std=gnu11 -O2 -o a.out Main.c -lm

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int sortFunc(const void *str1, const void *str2){
	return strcmp((const char*)str1, (const char*)str2);
}

int main(void)
{
	
	int n, l, i;
	char str[100][101];
	int ret;
	
	ret = scanf("%d %d", &n, &l);
	for(i = 0 ; i < n ; i++){
		ret = scanf("%s", str[i]);
	}
	
	qsort(str, n, sizeof(str[0]), sortFunc);
	
	for(i = 0 ; i < n ; i++){
		printf("%s", str[i]);
	}
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 128