akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "No" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    vector<ll> B(N);
    ll suma=0,sumb=0;

    rep(i,N) cin>>A[i],suma+=A[i];
    rep(i,N) cin>>B[i],sumb+=B[i];

    ll kai=sumb-suma;
    if(kai<0) dame;

    ll ct=0;

    rep(i,N){
        if(B[i]<A[i]) ct+=A[i]-B[i];
        else ct+=(B[i]-A[i])%2;
    }
    if(ct<=kai) cout<< "Yes" <<"\n";
    else dame;

}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 384
using System;
using System.Linq;

class Problem {
    public static void Main() {
        var str = Console.ReadLine();
        var n = int.Parse(Console.ReadLine());
        for (var i = 0; i < n; i++) {
            var dat = Console.ReadLine().Split();
            var a = int.Parse(dat[1]); var b = int.Parse(dat[2]);
            switch (dat[0]) {
                case "print": Console.WriteLine(str.Substring(a, b - a + 1)); break;
                case "reverse": str = str.Substring(0, a) + new string(str.ToCharArray(a, b - a + 1).Reverse().ToArray()) + str.Substring(b + 1); break;
                case "replace": str = str.Substring(0, a) + dat[3] + str.Substring(b + 1); break;
            }
        }
    }
}


Measured memory_bytes: 9592
/*
  AOJ #2799
  title:Yamanote-line Game
  @kankichi573
 */
#include <stdio.h>
int N,p[1000],d;

int main()
{
  int i,ret;

  scanf("%d %d",&N,&d);
  for(i=0;i<N;i++)
    scanf("%d",&p[i]);
  for(i=0,ret=0;i<N;i++)
    if(p[i]>d)
      ret += (p[i]-d);
  if(ret==0)
    printf("kusoge\n");
  else
    printf("%d\n",ret);
  return(0);
}

Measured memory_bytes: 600
//region #include <cp_helper>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector< pair<ll, ll> >
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define fori(i, n) for (ll i=0; i<n; ++i)
#define foris(i, a, b) for (ll i=a; i<b; ++i)
#define ford(i, n) for (ll i=n; i>=0; --i)
#define fords(i, a, b) for (ll i=a; i>=b; --i)
#define forr(i, a) for (auto &i : a)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;
//endregion

const double pi = 3.14159265;

int main() {
    io();
    double a, b, x, h, m;
    cin >> a >> b >> x;
    h = x / (a*a);
    m = b-h;
    cout << setprecision(10);
    if (x/(a*a*b) <= 0.5) cout << (atan((b*b)/(2*a*h)) * (180/pi));
    else cout << atan(m/(a/2)) * (180/pi);
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int> > s(m);
    for (int i = 0; i < m; i++) {
        int k;
        cin >> k;
        s[i].resize(k);
        for (int j = 0; j < k; j++) {
            cin >> s[i][j];
            s[i][j]--;
        }
    }

    vector<int> p(m);
    for (int i = 0; i < m; i++) {
        cin >> p[i];
    }

    int ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        bool ok = true;
        for (int j = 0; j < m; j++) {
            int c = 0;
			for (int id : s[j]) {
				if ((i >> id) & 1) {
					c++;
				}
			}
			c %= 2;
			if (c != p[j]) {
				ok = false;
			}
        }
        if (ok) {
			++ans;
		}
    }
    
    cout << ans << endl;
	return 0;   
}

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

int main() {
  string s, t;
  cin >> s >> t;
  map<char, int> index, next[s.size()];
  for (int i = s.size() - 1; i >= 0; --i) {
    index[s[i]] = s.size() + i;
  }
  for (int i = s.size() - 1; i >= 0; --i) {
    index[s[i]] = i;
    next[i] = index;
  }
  int64_t result = 0;
  for (int64_t i = 0; i < t.size(); ++i) {
    auto it = next[result % s.size()].find(t[i]);
    if (it == next[result % s.size()].end()) {
      result = -1;
      break;
    }
    result += it->second - result % s.size() + 1;
  }
  cout << result;
  return 0;
}

Measured memory_bytes: 127376
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

template<typename ...Ts>
void show(Ts... ts){
  cout<<"#:";
  auto print=[](auto v){cout<<v<<" ";};
  initializer_list<int>{(void(print(ts)),0)...};
  cout<<endl;
}



int main(void){
    ll a;
    ll ans=0;
    string s;
    cin>>s;
    int n=s.size();
    vll N(n+1,0);
    vll A(n+1,0);
    vll AB(n+1,0);
    vll ABC(n+1,0);
    N[0]=1;

    REP(i,1,n+1){
        N[i]=N[i-1];
        switch(s[i-1]){
            case '?':
                N[i]+=2*N[i-1];
                A[i]=3*A[i-1]+N[i-1];
                AB[i]=3*AB[i-1]+A[i-1];
                ABC[i]=3*ABC[i-1]+AB[i-1];
                break;

            case 'A':
                A[i]=A[i-1]+N[i-1];
                AB[i]=AB[i-1];
                ABC[i]=ABC[i-1];
                break;            

            case 'B':
                A[i]=A[i-1];
                AB[i]=AB[i-1]+A[i-1];
                ABC[i]=ABC[i-1];
                break;            
                
            case 'C':
                A[i]=A[i-1];
                AB[i]=AB[i-1];
                ABC[i]=ABC[i-1]+AB[i-1];
                break;            
        }
        N[i]%=mod;
        A[i]%=mod;
        AB[i]%=mod;
        ABC[i]%=mod;
    }
    ans=ABC[n];
    cout<<ans<<endl;
    //solve(t);
}


Measured memory_bytes: 3664
s=list(map(int,input().split()))
a=s[0]
b=s[1]
c=s[2]
k=s[3]
m=0

if k>a:
    m+=a
    k-=a
    if k>b:
        k-=b
        if k>c:
            m-=c
        else:
            m-=k
else:
    m=k


print(m)

Measured memory_bytes: 8696
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String line = scanner.next();
			if (line.equals("0"))
				break;
			Pattern pattern = Pattern.compile("^r+$|^g+$|^b+$");
			Deque<String> deque = new ArrayDeque<String>();
			Set<String> set = new HashSet<String>();
			deque.offer(line);
			boolean flag = false;
			int step = 0;
			loop: while (!deque.isEmpty()) {
				int size = deque.size();
				for (int i = 0; i < size; i++) {
					String tmp = deque.pop();
					if (pattern.matcher(tmp).find()) {
						flag = true;
						break loop;
					}
					if (!set.contains(tmp)) {
						set.add(tmp);
						char[] chs = tmp.toCharArray();
						for (int j = 0; j < chs.length - 1; j++) {
							char l = chs[j];
							char r = chs[j + 1];
							if (l != r) {
								if (l != 'r' && r != 'r')
									chs[j] = chs[j + 1] = 'r';
								else if (l != 'g' && r != 'g')
									chs[j] = chs[j + 1] = 'g';
								else {
									chs[j] = chs[j + 1] = 'b';
								}
								deque.offer(String.valueOf(chs));
								chs[j] = l;
								chs[j + 1] = r;
							}

						}
					}

				}
				step++;
			}
			System.out.println(flag ? step : "NA");
		}
	}
}

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

void all_subset_check(vector<vector<int>>& book, vector<int>& cost, int& min_cost, int x)
{
    int n = cost.size();
    int m = book[0].size();
    int count = 1 << n;
    for (int i = 1; i <= count; i++)
    {
        int cur_cost = 0;
        vector<int> M(m, 0);
        for (int j = 0; j < n; j++)
        {
            if (i & (1 << j))
            {
                cur_cost += cost[j];
                for (int k = 0; k < m; k++)
                    M[k] += book[j][k];
            }
        }
        bool flag = true;
        for (int k = 0; k < m; k++)
            if (M[k] < x)
            {
                flag = false;
                break;
            }
        if (flag)
            min_cost = min(min_cost, cur_cost);
    }
}

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> cost(n);
    vector<vector<int>> book(n, vector<int>(m));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= m; j++)
        {
            int t;
            cin >> t;
            if (!j)
                cost[i] =t;
            else
            {
                book[i][j-1] = t;
            }
        }
    }
    int min_cost = INT_MAX;
    all_subset_check(book, cost, min_cost, x);
    if (min_cost != INT_MAX)
        cout << min_cost << endl;
    else
    {
        cout << -1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3632
from collections import Counter

N = int(input())
*A, = map(int, input().split())
cnt = Counter(A)
A = sorted(A, reverse=True)
ans = 0
for a in A:
    if a & (a - 1) != 0:
        cand = (1 << ((a - 1).bit_length())) - a
        if cnt[a] == 0 or cnt[cand] == 0: continue
    else:
        cand = a
        if cnt[a] < 2: continue
    ans += 1
    cnt[a] -= 1; cnt[cand] -= 1
print(ans)

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

int main(){
    ll n;
    ll k;
    cin >> n >> k;
    vector<pair<ll,ll>> pairs(n);
    rep(i,n){
        ll a, b;
        cin >> a >> b;
        pairs.at(i) = make_pair(a,b);
    }
    sort(pairs.begin(),pairs.end());
    ll tmp = 0;
    rep(i,n){
        tmp += pairs.at(i).second;
        if(k > tmp) continue;
        else{
            cout << pairs.at(i).first << endl;
            break;
        }
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define F first
#define S second
const int INF=1000000000;
typedef long long int lli;
typedef pair<int,int> P;

int main(){
	int w,h,n;
	cin >> w >> h >> n;
	vector<P> s;
	for(int i=0;i <n; ++i){
		int x,y;
		cin >> x >> y;
		s.push_back(P(x,y));
	}
	int ans=0;
	for(int i=1; i<n; ++i){
		if((s[i-1].F>=s[i].F&&s[i-1].S<=s[i].S)||(s[i-1].F<=s[i].F&&s[i-1].S>=s[i].S)) ans+=abs(s[i].F-s[i-1].F)+abs(s[i].S-s[i-1].S); 
		else ans+=max(abs(s[i].F-s[i-1].F),abs(s[i].S-s[i-1].S));
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1216
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<queue>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;

int main()
{
	int n, d, flag = 0, t[100005], x[100005], y[100005];
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%d%d%d", &t[i], &x[i], &y[i]);
		if(x[i] + y[i] > t[i])
			flag = 1;
		else
		{
			d = t[i] - (x[i] + y[i]);
			if(d % 2 == 0)
				continue;
			else
				flag = 1;
		}
	}
	if(flag == 1)
		printf("No\n");
	else
		printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long long LL;
typedef pair<int,int> pii;
typedef priority_queue<pii> priii;
const int INF = 0x3f3f3f3f;
namespace {
  template <typename T> inline void read(T &x) {
    x = 0; T f = 1;char s = getchar();
    for(; !isdigit(s); s = getchar()) if(s == '-') f = -1;
    for(;  isdigit(s); s = getchar()) x = (x << 3) + (x << 1) + (s ^ 48);
    x *= f;
  }
}
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define _for(n,m,i) for (int i = (n); i < (m); i++)
#define _rep(n,m,i) for (int i = (n); i <= (m); i++)
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define lowbit(x) x & (-x)
#define fi first
#define se second
int main() {
  int n, num = 0, x;
  read(n);
  while(n--) {
    read(x);
    num ^= x;
  }
  if(num ) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

/////////////         modの計算

#define MOD_IS_PRIME
const ll mod = 1000000007LL;

class modlong {
public:
	modlong() { x = 0; }
	modlong(ll num) { x = adjust(num); }
	inline operator ll() const { return x; }
	inline bool operator ==(ll num) { return this->x == num; }
	inline bool operator !=(ll num) { return !(*this == num); }
	inline void operator = (ll num) { x = adjust(num); }
	inline void operator += (ll num) { x = adjust(x + num); }
	inline void operator ++() { this->operator+=(1); }
	inline modlong operator + (ll num) const { modlong m(this->x); m += num; return m; }
	inline void operator -= (ll num) { x = adjust(x - num); }
	inline void operator --() { this->operator-=(1); }
	inline modlong operator - (ll num) { modlong m(this->x); m -= num; return m; }
	inline void operator *= (ll num) { x = adjust(x * num); }
	inline modlong operator * (ll num) { modlong m(this->x); m *= num; return m; }
private:
	inline ll adjust(ll a) {
		if (a >= mod) { return a % mod; }
		if (a < 0) { return mod - 1 + ((a + 1) % mod); }
		return a;
	}
	ll x;
};

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

	constexpr int K = 16;

	vector<modlong> v_e = { 0, 765144583, 346175634, 347662323, 5655049, 184117322, 927321758, 444014759, 542573865, 237315285, 417297686, 471090892, 183023413, 660103155, 727008098, 869418286 };
	vector<modlong> v_o = { 539588932, 729548371, 700407153, 404391958, 962779130, 184117322, 927321758, 444014759, 542573865, 237315285, 417297686, 471090892, 183023413, 660103155, 727008098, 869418286 };

	int T; cin >> T;
	for (int _t = 0; _t < T; _t++) {
		ll N; cin >> N;
		if (N % 2 == 0) {// even
			modlong ans = 0;
			modlong x = 1;
			for (int i = 0; i < K; i++) {
				ans += x * v_e[i];
				x *= N;
			}
			cout << (ll)ans << endl;
		}
		else {// odd
			modlong ans = 0;
			modlong x = 1;
			for (int i = 0; i < K; i++) {
				ans += x * v_o[i];
				x *= N;
			}
			cout << (ll)ans << endl;
		}
	}

	return 0;
}

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

int main(){
    string s,t,ans;
    cin >> s >> t;
    int dp[3001][3001];
    for(int i = 0;i < s.size();i ++){
        for(int j = 0;j < t.size();j ++){
            if(s[i]==t[j]) dp[i+1][j+1] = dp[i][j]+1;
            else dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
        }
    }
    for(int i=s.size(),j=t.size(),k=0;k<dp[s.size()][t.size()];k++){
        while(dp[i][j]==dp[i-1][j]) i--;
        while(dp[i][j]==dp[i][j-1]) j--;
        ans = s[i-1]+ans;
        i --;
        j --;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define endl "\n"
inline bool EQ(double a, double b)
{
    return fabs(a - b) < 1e-9;
}
const int INF = 1 << 29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }

inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int &n, int b) { n |= two(b); }
inline void unset_bit(int &n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n)
{
    int res = 0;
    while (n && ++res)
        n -= n & (-n);
    return res;
}
template <class T>
void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
void chmin(T &a, const T &b) { a = min(a, b); }

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

    ll n, x = 0;
    cin >> n;
    ll a[n];
    REP(i, n)
    {
        cin >> a[i];
        x = x ^ a[i];
    }
    REP(i, n)
    cout << (x^a[i]) << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 5152
import math
def ncr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
n,p=map(int,input().split())
a=list(map(int,input().split()))
odd=0
even=0

for i in a:
    if i%2==0:
        even+=1
    else:
        odd+=1

if p==1:
    ans=2**even
    odd_choice=0
    for i in range(1,odd+1,2):
        odd_choice+=ncr(odd,i)
    print(ans*odd_choice if even!=0 else odd_choice)

else:
    ans=2**even
    if even==0:
        ans=0
    odd_choice=0
    for i in range(0,odd+1,2):
        odd_choice+=ncr(odd,i)
    print(ans*odd_choice if even!=0 else odd_choice)

Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
  int h = 0;
  int n = 0;
  int sum = 0;


  scanf("%d %d",&h,&n);
    int dat[n];
    for(int i = 0;i < n;i++)
  {
    scanf("%d",&dat[i]);
    sum += dat[i];
  }
  
  if(sum >= h)
  {
  printf("Yes");
  }
  else
  {
    printf("No");
  }

    return 0;
}

Measured memory_bytes: 512
using System;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        // なんか入力用の関数作ったけどまだテストしてないので使う前に確かめて
        static void Main(){
            string[] abcd = Console.ReadLine().Split();
            long a = long.Parse(abcd[0]);
            long b = long.Parse(abcd[1]);
            long c = long.Parse(abcd[2]);
            long d = long.Parse(abcd[3]);
            long mx = Math.Max(c,d);
            long mn = Math.Min(c,d);

            long kouyakusuu;

            mx = mx%mn;

            while(mx!=0 && mn!=0){
                mn = mn%mx;
                if(mn==0)break;
                mx = mx%mn;
            }

            kouyakusuu = Math.Max(mx,mn);

            long koubaisuu = c * d / kouyakusuu;


            long cmin = (a-1)/c; //1
            long dmin = (a-1)/d; //1
            long cmax = b/c; //4
            long dmax = b/d; //3
            long csa = cmax - cmin; //3
            long dsa = dmax - dmin; //2
            long cdmin = (a-1)/koubaisuu; //0
            long cdmax = b/koubaisuu; //1
            long cdsa = cdmax - cdmin; //1

            Console.WriteLine(b-a+1-csa-dsa+cdsa); //9-4-3-2+1
        }

        static readonly long MOD = 1000000007;


    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;
// get<K>(tuple型の変数)

const ll inf=1LL<<60;
int n;
vector<ll> a(500, 0), cum(500, 0);
vector<vector<ll>> memo(500, vector<ll>(500, -1));

ll rec(int l, int r){
    if(memo[l][r]!=-1) return memo[l][r];
    if(l==r) return memo[l][r]=0;

    ll res=inf;
    repr(i, l, r){
        chmin(res, cum[r]-cum[l-1]+rec(l, i)+rec(i+1, r));
    }
    return memo[l][r]=res;
}

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

    cin >> n;
    repr(i, 1, n+1) cin >> a[i];
    repr(i, 1, n+1) cum[i]=a[i]+cum[i-1]; 
    
    cout << rec(1, n) << endl;

    return 0;
}



Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    if (n > 0) {
        return  n * fac(n - 1);
    }else{
        return 1;
    }
}

int main()
{
    ll n,ans = 0,a;
    cin >> n;
    rep(i, n){
        cin >> a;
        ans += a - 1;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int a[100]={0};int n=0;
	while(cin>>a[n++]);n--;
	int b[10]={0};
	for(int i=0;i<n;i++)
	{
		if(a[i]==0)
		{
			cout<<b[0]<<endl;
			for(int j=0;j<9;j++)
			{
				b[j]=b[j+1];
			}
		}else
		{
			for(int j=9;j>0;j--)
			{
				b[j]=b[j-1];
			}
			b[0]=a[i];
		}
	}
	return 0;
}

Measured memory_bytes: 3076
#include <stdio.h>

int main(void){
  int n=5;
  int x[n];
  int i;
  
  for(i=0; i<5; i++){
    scanf("%d", &x[i]);
    if(x[i]==0){
      printf("%d\n", i+1);
      break;
    }
  }
  
  return 0;
}

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

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

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

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

// borrowed from neal's code
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    double r; cin >> r;
    printf("%.6f", 2 * 3.14159 * r);
}

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

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

void Main() {
  Cin(int, n);
  double ans = 0;
  for (int i = 0; i < n; ++i) {
    Cin(string, x, u);
    if (u == "JPY") ans += stoi(x);
    if (u == "BTC") ans += stod(x) * 380000;
  }
  cout << ans << endl;
  return;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
books = []
for _ in range(N):
    books.append(list(map(int, input().split())))

min_price = float('inf')
for combo in range(0, 2**N):
    combo = list(map(int, bin(combo)[2:]))
    combo = [0] * (N - len(combo)) + combo
    curr_sums = [0] * M
    curr_price = 0
    for i, val in enumerate(combo):
        if val == 1:
            curr_price += books[i][0]
            for j in range(M):
                curr_sums[j] += books[i][j + 1]
    
    good = True
    for val in curr_sums:
        if val < X:
            good = False
    
    if good:
        min_price = min(min_price, curr_price)

print("{}".format('-1' if min_price >= float('inf') else min_price))


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

using namespace std;
using ll = long long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI = 4.0 * atan(1.0);

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

int main() {
    double A, B, H, M; cin >> A >> B >> H >> M;
    
    double thetaB = 2.0 * PI * M / 60.0;
    double thetaA = 2.0 * PI * (H / 12.0 + M / (60.0 * 12.0));
    double theta = abs(thetaB - thetaA);
    if (theta > PI) theta = 2.0 * PI - theta;
    
    double c = sqrt(A * A + B * B - 2.0 * A * B * cos(theta));

    cout << setprecision(18) << c << endl;
    return 0;
}


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

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

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

    int cnt = 0;
    for(int i = 1; i < n-1; i++) {
        if((arrP[i] >= arrP[i-1]) && (arrP[i]) <= arrP[i+1]) cnt++;
        else if((arrP[i] <= arrP[i-1]) && (arrP[i]) >= arrP[i+1]) cnt++;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
int main(){
string a,b,c;
int vis=0;
cin>>a>>b;
int len=a.length(),len1=b.length();
int maxx=0,cnt=0;
int start=-1,end=-1;
for(int i=0;i<=len;i++){
	if(a[i]=='?')cnt++;
	else {
		if(cnt>=len){
		   start=i-len1;
		   end=i-1;
		   vis=1;
	    }
		cnt=0;
	}
}
if(cnt>=len){
	end=len-1;start=len-len1-2;
}
if(start==-1){
	for(int i=0;i<len;i++){
		vis=0;
		if(len1+i>len)break;
		for(int j=i;j<len1+i;j++){
			if(a[j]!='?'&&a[j]!=b[j-i]){
				vis=1;break;
			}
		}
		if(vis==0){
			start=i,end=len1+i-1;
		}
	}
	if(start==-1)cout<<"UNRESTORABLE";
	else {
		for(int i=0;i<start;i++){
			if(a[i]=='?')c[i]='a';
			else c[i]=a[i];
		}
		for(int i=start;i<=end;i++){
			 c[i]=b[i-start];
		}
		for(int i=end+1;i<len;i++){
			if(a[i]=='?')c[i]='a';
			else c[i]=a[i];
		}
		for(int i=0;i<len;i++){
			cout<<c[i];
		}
	}
}
else {
	for(int i=0;i<start;i++){
		if(a[i]=='?')c[i]='a';
		else c[i]=a[i];
	}
	for(int i=start;i<=end;i++){
		c[i]=b[i-start];
	}
	for(int i=end+1;i<len;i++){
		if(a[i]=='?')c[i]='a';
		else c[i]=a[i];
	}
	c[len]='\0';
	for(int i=0;i<len;i++)cout<<c[i];
}
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int g,q;
    bool k;
    scanf("%d",&q);
    for(g=k=1;g<10;g++)
        if(q%g==0&&q/g<10)k=false;
    if(k)printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
fn main() {
    proconio::input!(k: usize);
    let mut ans = 0;
    for i in 1..(k + 1) {
        for j in 1..(k + 1) {
            for x in 1..(k + 1) {
                ans += num::integer::gcd(i, num::integer::gcd(j, x));
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2156
import java.util.Scanner;

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

    int n;
    n = sc.nextInt();

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

    for (int i = 1; i < n; i++) {
      System.out.printf("%d ", a[n - i]);
    }

    System.out.printf("%d\n", a[0]);

    sc.close();
  }
}



Measured memory_bytes: 26488
#include <iostream>

using namespace std;
using ll = long long;

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

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

  bool ans = true;

  rep(i, n) {
    int a;
    cin >> a;
    if (a % 2 == 0) {
      if (a % 3 != 0 && a % 5 != 0) ans = false;
    }
  }

  cout << (ans ? "APPROVED" : "DENIED") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n,i,a[100010],t;
  long s=0,amin=1e10;
  cin >> n;
  for (i=0;i<n;i++) cin >> a[i];
  for (i=0;i<n;i++){
    if (a[i]<0) t++;
    s+=abs(a[i]);
    if (amin > abs(a[i])) amin=abs(a[i]);
  }
  if (t%2) cout << s-amin*2 << endl;
  else cout << s << endl;
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(){
	int N,M,i;
	scanf("%d%d",&N,&M);
	char A[N][N+1];
	char B[M][M+1];
	for(i=0;i<N;i++)scanf("%s",A[i]);
	for(i=0;i<M;i++)scanf("%s",B[i]);
	
	for(i=0;i<=N-M;i++){
		for(int j=0;j<=N-M;j++){
			int flag=1;
			for(int k=0;k<M;k++){
				for(int l=0;l<M;l++){
					if(A[k+i][l+j]!=B[k][l])flag=0;
				}
			}
			if(flag==1){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
const int Max = 1E5 + 10;
const int MOD = 1E9 + 7;
typedef long long LL; 
using namespace std;
LL A[Max];
LL mod_pow(LL x,LL n,LL mod)
{
	LL res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int main()
{
    LL N,t=0,s=0;
    cin>>N;
    for(int i=0;i<N;i++)
    	cin>>A[i];
    sort(A,A+N);
    if(N&1)
    {
    	if(A[0]!=0) t=1;
		for(int i=1;i<N;i+=2)
		{
			if(A[i]!=i+1 || A[i+1]!=i+1) 
			{
				t=1;
				break;
			}
		}
		if(t==1) cout<<s<<endl;
		else if(t==0) cout<<mod_pow(2,N/2,MOD)<<endl;
	}
	else 
	{
		for(int i=0;i<N;i+=2)
		{
			if(A[i]!=i+1 || A[i+1]!=i+1) 
			{
				t=1;
				break;
			}
		}
		if(t==1) cout<<s<<endl;
		else if(t==0) cout<<mod_pow(2,N/2,MOD)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
import sys
while True:
	y,x=map(int, input().split())
	if x==y==0: break
	for i in range(1,y+1):
		for j in range(1,x+1):
			if(i%2==1):
				if(j%2==1):
					sys.stdout.write('#')
				elif(j%2==0):
					sys.stdout.write('.')
			if(i%2==0):
				if(j%2==0):
					sys.stdout.write('#')
				elif(j%2==1):
					sys.stdout.write('.')
		print('')
	print('')

Measured memory_bytes: 6740
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
//const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){cout << a << " " << b << " " << c << endl;}
#define INT_MAX 1<<30;
const int MAX = 1020000;
const double EPS = 1e-6;
const int mod = 1e9+7;

int main(){
    ll n,u,v; cin >> n >> u >> v; u--; v--;
    vvl G(n);
    rep(i,n-1){
        ll a,b; cin >> a >> b; a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    queue<ll> q;
    vl d(n,inf);
    d[u] = 0;
    q.push(u);
    vl pre(n,-1);
    while(!q.empty()){
        ll s = q.front(); q.pop();
        for(auto t : G[s]){
            if(d[t]==inf){
                d[t] = d[s] + 1;
                q.push(t);
            }
        }
    }
    q.push(v);
    vl e(n,inf);
    e[v] = 0;
    while(!q.empty()){
        ll s = q.front(); q.pop();
        for(auto t : G[s]){
            if(e[t]==inf){
                e[t] = e[s] + 1;
                q.push(t);
            }
        }
    }
    ll mx = 0;
    rep(i,n){
        //cout << e[i] << " " << d[i] << endl;
        if(d[i]<e[i]){
            //cout << i << " " << e[i] << " " << d[i] << endl;
            chmax(mx,e[i]-1);
        }else if(d[i]==e[i]){
            chmax(mx,1LL);
        }
    }
    cout << mx << endl;
}


Measured memory_bytes: 8832
#include <iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int n,d,x,a,ans=0;
    scanf("%d%d%d",&n,&d,&x);
    ans+=x;
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        ans+=((d-1)/a+1);
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long int j,a,b,c,d,cnt,A,AA,AAA,B,BB,BBB;
    cin>>a>>b>>c>>d;
    j=(c*d)/(__gcd(c,d));
    if(a%c!=0){A=((a/c)+1)*c;}
    else{A=a;}
    if(a%d!=0){AA=((a/d)+1)*d;}
    else{AA=a;}
    if(a%j!=0){AAA=((a/j)+1)*j;}
    else{AAA=a;}

    if(b%c!=0){B=(b/c)*c;}
    else{B=b;}
    if(b%d!=0){BB=(b/d)*d;}
    else{BB=b;}
    if(b%j!=0){BBB=(b/j)*j;}
    else{BBB=b;}

    cnt=(b-a)+1-(((B-A)/c)+1+((BB-AA)/d)+1-((BBB-AAA)/j)-1);
    cout<<cnt;
    return 0;
}


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

int main()
{
    long long int n,c=0,i;
    double z,x,y,d;
    cin>>n>>d;
    for(i=0;i<n;i++){
        cin>>x>>y;
        z=sqrt(1.0*(x*x+y*y));
        if(z<=d)
        c++;
    }
    cout<<c;
}

Measured memory_bytes: 3856
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <memory.h>

#define UNKNOWN -2000000

using namespace std;

//FILE *in = freopen("input.txt", "r", stdin);
//FILE *out = freopen("output.txt", "w", stdout);

int n, m, M;

vector<vector<pair<int,int>>> data;
bool chk[100001];

int res[100001];
int query[100001][2];
int dist[100001];

struct UnionFind {
	vector<int> par; vector<int> rank;
	UnionFind(int n){
		par = vector<int>(n);
		rank = vector<int>(n);
		for(int i = 0; i < n; i++) {
			par[i] = i;
		}
	}
	int find(int x) {
		if(par[x]==x) return x;
		else return find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rank[x]<rank[y])
			par[x] = y;
		else {
			par[y] = x;
			if(rank[x]==rank[y])rank[x]++;
		}
	}
	inline bool same(int x, int y) {
		return find(x) == find(y);
	}
};

void bfs(int a) {
	queue<pair<int,int>> que;
	que.push(make_pair(a, 0));
	chk[a] = true;
	while(!que.empty()){
		int cur = que.front().first;
		int val = que.front().second;
		que.pop();
		dist[cur] = val;

		for(int i = 0; i < data[cur].size(); i++) {
			if(chk[data[cur][i].first]) continue;
			chk[data[cur][i].first] = true;
			que.push(make_pair(data[cur][i].first, val + data[cur][i].second));
		}
	}
}

void process() {
	UnionFind uf(n+1);
	data.clear();
	data.resize(n+1);
	memset(chk, 0, sizeof(chk));
	memset(res, 0, sizeof(res));
	memset(dist, 0, sizeof(dist));
	M = 0;
	char tt[10];
	int a, b, c;
	for(int k = 0; k < m; k++) {
		scanf("%s%d%d", tt, &a, &b);
		if(tt[0] == '!') {
			scanf("%d", &c);
			if(uf.same(a,b)) continue;
			data[a].push_back(make_pair(b, c));
			data[b].push_back(make_pair(a, -c));
			uf.unite(a,b);
		}
		else {
			query[M][0] = a;
			query[M][1] = b;
			if(!uf.same(a, b)) {
				res[M] = UNKNOWN;
			}
			M++;
		}
	}

	for(int i = 1; i <= n; i++) {
		if(!chk[i]) {
			bfs(i);
		}
	}

	for(int i = 0; i < M; i++) {
		if(res[i] == UNKNOWN) {
			printf("UNKNOWN\n");
		} else {
			printf("%d\n", dist[query[i][1]]-dist[query[i][0]]);
		}
	}
}

int main() {
	while(true){
		scanf("%d%d", &n, &m);
		if(n == 0)break;
		process();
	}
	return 0;
}

Measured memory_bytes: 7608
#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    int i=1;
    while(1)
    {
        c=c-b;
         a=a-d;
        if(c<=0){printf("Yes");
            break;}
 
  else if(a<=0){printf("No");
            break;}
    
        i++;
      
    }
    
 
    return 0;
}

Measured memory_bytes: 1736
import heapq
N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N-1):
  a, b, c = map(int, input().split())
  a -= 1
  b -= 1
  graph[a] += [[b, c]]
  graph[b] += [[a, c]]

Q, K = map(int, input().split())

def dijkstra(s):
  dist = [float('inf')]*N
  dist[s] = 0
  num = [0]*N
  num[s] = 1
  q = [[0, s]]
  heapq.heapify(q)
  while q:
    c, u = heapq.heappop(q)
    if dist[u] < c:
      continue
    for v, weight in graph[u]:
      if dist[v] > dist[u] + weight:
        dist[v] = dist[u] + weight
        num[v] = num[u]
        heapq.heappush(q, [dist[v], v])
      elif dist[v] == dist[u] + weight:
        num[v] += num[u]
  return dist, num

dist, _ = dijkstra(K-1)

for _ in range(Q):
  x, y = map(lambda x:int(x)-1, input().split())
  print(dist[x]+dist[y])

Measured memory_bytes: 120268
#include<stdio.h>
int main()
{
    int n, i, x, ans = 0, j;
    int a[2][100];
    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", &a[0][i]);
    for (i = 0; i < n; i++)
        scanf("%d", &a[1][i]);
    for (i = 0; i < n; i++)
    {
        x = 0;
        for (j = 0; j <= i; j++)
            x += a[0][j];
        for (j = i; j < n; j++)
            x += a[1][j];
        if (ans < x)
            ans = x;
    }
    printf("%d\n", ans);
    return 0;

}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

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

    double ans = 0;
    for(int i = 1; i <= n; i++){
        int x = i;
        double tmp = 1.0/n;
        while(x < k){
            x *= 2;
            tmp /= 2;
        }
        ans += tmp;
    }

    printf("%.12f\n", ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
const int maxn =5e5+10;
#define pb push_back

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    string s;
    vector<int>ans;
    cin>>s;
    reverse(s.begin(),s.end());
    int r=0;
    while(r<=n-1)
    {
        int f=0;
        int step=0;
        for(int i=1;i<=m;i++)
        {
            if(r+step==n)
                break;
            if(s[r+i]=='1')
                continue;
            step=i;
            f=1;
        }
        if(f==0)
        {
            cout<<-1<<'\n';
            return 0;
        }
        ans.pb(step);
        r+=step;
    }
    reverse(ans.begin(),ans.end());
    for(auto &v:ans)
        cout<<v<<" ";









}


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	int h, w, k; cin >> h >> w >> k;
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	vector<string> c(h); cin >> c;

	x1--; y1--; x2--; y2--;

	using piii = pair<int, pair<int, int>>;
	//priority_queue<piii, vector<piii>, greater<piii>> que;
	//que.push({0, {x1, y1}});
	vector<pair<int, int>> que;
	que.push_back({x1, y1});
	vector<vector<int>> dist(h, vector<int>(w, 1e9));
	dist[x1][y1] = 0;

	for(int d=0;; d++){
		set<pair<int, int>> next;
		for(auto p: que){
			int x = p.first;
			int y = p.second;
			dbg(x, y, d);

			int dx[] = {0, 1, 0, -1};
			int dy[] = {1, 0, -1, 0};
			for(int j=0; j<4; j++){
				for(int l=1; l<=k; l++){
					int nx = x+dx[j]*l;
					int ny = y+dy[j]*l;
					if(nx<0||h<=nx||ny<0||w<=ny||dist[nx][ny]<=d+1||c[nx][ny]=='@') break;
					next.insert({nx, ny});
				}
			}
		}

		que.clear();
		for(auto p: next){
			dist[p.first][p.second] = d+1;
			que.push_back(p);
		}

		if(que.size()==0) break;
	}

	if(dist[x2][y2]==1e9){
		cout << -1 << endl;
	} else{
		cout << dist[x2][y2] << endl;
	}

	return 0;
}


Measured memory_bytes: 14628
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	vector<pair<ll, ll>> v;
	bool finished=true;
	for(int i=0; i<n; i++){
		ll a, b;
		cin >> a >> b;
		if(a>b) finished=false;
		v.push_back(make_pair(b, a));
	}
	sort(v.begin(), v.end());

	ll t=0;
	for(int i=0; i<n; i++){
		t+=v[i].second;
		if(t>v[i].first) finished=false;
	}
	if(finished) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int n;
string s;

int main() {
//	cout << int('Z');//65-90
	cin >> n >> s;
	int len = s.length();
	for (int i = 0; i < len; i++) {
		int now = int(s[i]) + n;
		if (now > 90) now -= 26;
		cout << char(now); 
	}
	return 0;
} 

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

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

    if (N < 2)
        cout << 1 << endl;
    else if (N < 4)
        cout << 2 << endl;
    else if (N < 8)
        cout << 4 << endl;
    else if (N < 16)
        cout << 8 << endl;
    else if (N < 32)
        cout << 16 << endl;
    else if (N < 64)
        cout << 32 << endl;
    else if (N < 128)
        cout << 64 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int x,y,n,r;
  scanf("%d %d",&x,&y);
  if(x < y){
    n = x;
    x = y;
    y = n;
  }

  while(y>0){
    r = x % y;
    x = y;
    y = r;
  }
  printf("%d\n",x);

  return 0;
}


Measured memory_bytes: 2104
n=int(input())
a=list(map(int,input().split()))
M=max(a)
m=min(a)
if M>m+1:
  print("No")
elif M==m+1:
  cntm=a.count(m)
  cntM=n-cntm
  if cntm>m:
    print("No")
  elif cntm+cntM//2<M:
    print("No")
  else:
    print("Yes")
elif M==m:
  if m<=n//2:
    print("Yes")
  elif m==n-1:
    print("Yes")
  else:
    print("No")

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

int main(){
    int dish[5];
    int min = 10;
    int minmo = 4;
    int m[5];
    for(int i = 0; i< 5; i++){
        cin >> dish[i];
        m[i] = dish[i]%10;
        if(m[i] == 0){
            m[i] = 10;
        }
    }

    //最小とは隣同士ではなく現在の最小値と比較するものである。
    for(int i = 0; i<5; i++){
        if(m[i] < min){
            minmo = i;
            min = m[i];
        }
    }
        
           
    swap(dish[minmo],dish[4]);
    swap(m[minmo],m[4]);

    int t = 0;
    for(int i = 0;i < 4;i++){
        t += dish[i] + (10-m[i]);
    }
    t += dish[4];

    cout << t << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int A; cin >> A;
		while (A % 2 == 0) {
			ans++;
			A /= 2;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

const string YES = "Yes";
const string NO = "No";

void solve(ll A, ll B, ll C) {
  bool pred = A == B && B == C;
  cout << (pred ? YES : NO) << endl;
}

int main() {
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  ll C;
  cin >> C;
  solve(A, B, C);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<int V>
struct MaxFlow {
  using T = int;
  const T INF = 1<<28;

  struct Edge {
    int to,rev;
    T cap;
  };

  vector<Edge> g[V];
  int level[V];
  int iter[V];

  void add(int from, int to, T cap) {
    g[from].push_back(Edge{to, (int)g[to].size(), cap});
    g[to].push_back(Edge{from, (int)g[from].size()-1, 0});
  }
  void add_multi(int from, int to, T cap) {
    g[from].push_back(Edge{to, (int)g[to].size(), cap});
    g[to].push_back(Edge{from, (int)g[from].size()-1, cap});
  }

  void bfs(int s) {
    fill_n(level,V,-1);
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while(!que.empty()) {
      int v = que.front();
      que.pop();
      for(Edge e: g[v]) {
        if(e.cap <= 0)continue;
        if(level[e.to] < 0) {
          level[e.to] = level[v] + 1;
          que.push(e.to);
        }
      }
    }
  }

  T dfs(int v,int t,T f) {
    if(v == t)return f;
    for(int &i = iter[v]; i < g[v].size(); i++) {
      Edge &e = g[v][i];
      if(e.cap <= 0)continue;
      if(level[v] < level[e.to]) {
        T d = dfs(e.to,t,min(f,e.cap));
        if(d <= 0)continue;
        e.cap -= d;
        g[e.to][e.rev].cap += d;
        return d;
      }
    }
    return 0;
  }
  T exec(int s,int t) {
    T flow = 0;
    while(true) {
      bfs(s);
      if(level[t] < 0)return flow;
      fill_n(iter,V,0);
      T f;
      while((f = dfs(s,t,INF)) > 0) {
        flow += f;
      }
    }
  }
};
int main(void) {
  int N;
  cin >> N;
  vector<int> x(N), y(N), a(N), b(N);
  MaxFlow<300> mf;
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
    mf.add(0, i + 1, 1);
  }
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
    mf.add(i + N + 1, 2 * N + 2, 1);
  }

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (x[i] < a[j] && y[i] < b[j]) {
        mf.add(i + 1, j + N + 1, 1);
        cerr << i << "->" << j << endl;
      }
    }
  }
  cout << mf.exec(0, 2 * N + 2) << endl;


  return 0;
}

Measured memory_bytes: 384