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

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;
 
/*
struct SegmentTree{
   
  vector<lol> SumV(1000005,0);
  vector<lol> MaxV(1000005,0);
  vector<lol> MinV(1000005,0);
  int N;
   
  void update(int i,int x){
    i += N - 1;
    minv[i] = x;
    maxv[i] = x;
    sumv[i] = x;
    while(i > 0){
      i = (i - 1)/2;
      maxv[i] = max(maxv[i*2+1],maxv[i*2+2]);
      minv[i] = min(minv[i*2+1],minv[i*2+2]);
      sumv[i] = sumv[i*2+1]+sumv[i*2+2];
    }
  }
   
  void add(int i,int x){
    i += N - 1;
    sumv[i] += x;
    maxv[i] += x;
    minv[i] += x;
    while(i > 0){
      i = (i - 1)/2;
      sumv[i] = sumv[i*2+1]+sumv[i*2+2];
      minv[i] = min(minv[i*2+1],minv[i*2+2]);
      maxv[i] = max(maxv[i*2+1],maxv[i*2+2]);
    }
  }
   
  int getmax(int a,int b,int k,int l,int r){
    if(r <= a || b <= l) return -INF;
    if(a <= l && r <= b) return maxv[k];
    else{
      int c1 = getmax(a,b,2*k+1,l,(l+r)/2);
      int c2 = getmax(a,b,2*k+2,(l+r)/2,r);
      return max(c1,c2);
    }
  }
   
  int getmin(int a,int b,int k,int l,int r){
    if(r <= a || b <= l) return INF;
    if(a <= l && r <= b) return minv[k];
    else{
      int c1 = getmin(a,b,2*k+1,l,(l+r)/2);
      int c2 = getmin(a,b,2*k+2,(l+r)/2,r);
      return min(c1,c2);
    }
  }
   
  int getsum(int a,int b,int k,int l,int r){
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return sumv[k];
    else{
      int c1 = getsum(a,b,2*k+1,l,(l+r)/2);
      int c2 = getsum(a,b,2*k+2,(l+r)/2,r);
      return c1+c2;
    }
  }
}
*/
 
//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}
//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int e, y;
  string s = "MTSH";
  cin >> e >> y;
  if(e == 0){
    if(y <= 1911){
      cout << s[0] << y - 1867 << '\n';
    } else if(y <= 1925){
      cout << s[1] << y - 1911 << '\n';
    } else if(y <= 1988){
      cout << s[2] << y - 1925 << '\n';
    } else {
      cout << s[3] << y - 1988 << '\n';
    }
  } else if(e == 1){
    cout << 1867 + y << '\n';
  } else if(e == 2){
    cout << 1911 + y << '\n';
  } else if(e == 3){
    cout << 1925 + y << '\n';
  } else {
    cout << 1988 + y << '\n';
  }
  return 0;
}



Measured memory_bytes: 3236
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
#include <math.h>
int ans;
int main(int argc, char* argv[]){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if ((a*100+b*10+c)%4==0) {
    printf("YES\n");
  }else{
    printf("NO\n");
  }
}


Measured memory_bytes: 128
from bisect import bisect_left, bisect_right

n, k, c = map(int, input().split())
s = input()

work = [i for i, e in enumerate(s, 1) if e == "o"]
INF = 10 ** 9

work_l = [-INF]
prev = -INF
for e in work:
    if e - prev > c:
        work_l.append(e)
        prev = e

work_r = [INF]
prev = INF
for e in work[::-1]:
    if prev - e > c:
        work_r.append(e)
        prev = e

work_r = work_r[::-1]

ans = []
mx_r = len(work_r)
for e in work:
    l = bisect_left(work_l, e)
    r = bisect_right(work_r, e)
    cnt = (l - 1) + (mx_r - r - 1)
    if work_r[r] - work_l[l-1] <= c:
        cnt -= 1
    if cnt < k:
        ans.append(e)

print(*ans, sep="\n")


Measured memory_bytes: 20528
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a1 = sc.nextInt();
		int a2 = sc.nextInt();
		int b1 = sc.nextInt();
		int b2 = sc.nextInt();
		int c1 = b1 - (b2 - a2);
		int c2 = b2 + (b1 -a1);
		int d1 = a1 - (b2 - a2);
		int d2 = a2 + (b1 - a1);

		System.out.println(c1 + " " + c2 + " " + d1 + " " + d2);

	}
}

Measured memory_bytes: 23380
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;


int main() {
        int n;
        cin >> n;
        vector<int> vec;
        int x;
        for(int i = 0; i < n; ++i) {
                cin >> x;
                vec.push_back(x); 
        }


        int y = round(accumulate(vec.begin(), vec.end(), 0.0) / n);

        //cout << y << " ";

        for(int i = 0; i < n; ++i) {
                vec[i]= pow((vec[i] - y), 2);
        } 

        cout << accumulate(vec.begin(), vec.end(), 0) << " ";





}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <tuple>
#include <unordered_set>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, M;
  int64_t P;
  cin >> N >> M >> P;
  vector<tuple<int, int, int64_t>> E(M);
  rep(i, M) {
    int A, B;
    int64_t C;
    cin >> A >> B >> C;
    A--, B--;
    E.emplace_back(B, A, P - C);
  }
  sort(E.begin(), E.end());

  // Bellman-Ford
  vector<int64_t> dist(N, INT64_MAX);
  dist[0] = 0;
  rep(i, N - 1) {
    for (auto& [to, fr, cost] : E) {
      if (dist[fr] == INT64_MAX) continue;
      dist[to] = min(dist[to], dist[fr] + cost);
    }
  }
  // one-more loop
  unordered_set<int> update;
  for (auto& [to, fr, cost] : E) {
    if (dist[fr] == INT64_MAX) continue;
    if ((dist[fr] + cost) < dist[to]) update.emplace(to);
    dist[to] = min(dist[to], dist[fr] + cost);
  }

  // search from N
  vector<int64_t> inv(N, INT64_MAX);
  inv[N - 1] = 0;
  rep(i, N - 1) {
    for (auto& [fr, to, cost] : E) {
      if (inv[fr] == INT64_MAX) continue;
      inv[to] = min(inv[to], inv[fr] + cost);
    }
  }
  // check update nodes can reach to N
  bool Nupdate = false;
  for (auto u : update) {
    if (inv[u] != INT64_MAX) Nupdate = true;
  }

  if (Nupdate)
    cout << -1 << endl;
  else if (0 <= dist[N - 1])
    cout << 0 << endl;
  else
    cout << -dist[N - 1] << endl;
  return 0;
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

int cnt_digits(ll N) {
  int digits = 0;
  while(N > 0) {
    N /= 10;
    digits++;
  }
  return digits;
}

signed main() {
  ll n;
  cin >> n;
  int ans = to_string(n).length();
  for(ll a = 1; a * a <= n; a++) {
    if(n % a != 0) continue;
    ll b = n / a;
    int cur = max(cnt_digits(a), cnt_digits(b));
    ans = min(ans, cur);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    string k;
  cin>>k;
  if(k[0]==k[2]){
	cout<<"Yes";
  }else{
    cout<<"No";
  }
    return 0;
}

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

using ll = long long;

constexpr ll INF = 1'010'000'000'000'000'017LL;
constexpr ll MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(ll i = (start); i < end; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }

template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
using pint = pair<int, int>;
using pll = pair<ll, ll>; using vp = V<pll>;

ll mod(ll val, ll m){ ll res = val % m; if(res < 0) res += m; return res;}
ll modinv(ll a, ll m) { ll b = m, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u;}
ll modpow(ll a, ll n, ll mod) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }


//---------------------------------------------------------------

void Main()
{
    int N, R;
    cin >> N >> R;
    if(N>=10){
        cout << R << endl;
    }else{
        cout << R + 100 * (10 - N) << endl;
    }
}

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

Measured memory_bytes: 256
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

A = [0]
B = [0]

for i in range(n):
    A.append(A[i]+a[i])

for i in range(m):
    B.append(B[i]+b[i])
    
ans,j = 0,m
for i in range(n+1):
    if A[i] > k:
        break
    while B[j] > k - A[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)

Measured memory_bytes: 134292
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
int main()
{
	string s;
	cin >> s;
	int n = s.size();
	int m = 2019;
	reverse(s.begin(), s.end());
	ll ans = 0;
	vector<int> cnt(m);
	int tot = 0;
	int x = 1;
	rep(i, n) {
		cnt[tot]++;
		tot += (s[i] - '0')*x;
		tot %= m;
		ans += cnt[tot];
		x = (x * 10) % m;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
const int MAX_N = 1e5;
/* Union-Find木 */
long int par[MAX_N];  // 親
long int ranks[MAX_N]; // 木の深さ
long int nords[MAX_N];

//親と木の深さの初期化
void init(long int n){
    for (long int i = 0; i < n; i++){
        par[i] = i;
        ranks[i] = 0;
        nords[i] = 1;
    }
}

//木の根を求める
int find(long int x){
    if(par[x] == x){
        return x;
    }
    else{
        return par[x] = find(par[x]);
    }
}

//xとyの属する集合を併合
void unite(long int x, long int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(ranks[x] < ranks[y]){
        par[x] = y;
        nords[y] += nords[x];
    }
    else{
        par[y] = x;
        nords[x] += nords[y];
        if (ranks[x] == ranks[y]) ranks[x]++;
    }
}

//xとyが同じ集合か判定
bool same(long int x, long int y){
    return find(x) == find(y);
}
//------------------------------------------
int main(){
    long int n, m;
    cin >> n >> m;
    init(n);
    vector<long long int> ans(m,0);
    ans.push_back(n * (n-1) / 2);
    vector<pair<long int, long int>> v;
    int a, b;
    for(long int i = 0; i < m; i++){
        cin >> a >> b;
        pair<long int, long int> p = make_pair(a-1,b-1);
        v.push_back(p);
    }
    for (long int i = m-1; i >= 0; i--){
        long int n1 = nords[find(v[i].first)], n2 = nords[find(v[i].second)];
        if(same(v[i].first, v[i].second)){
            ans[i] = ans[i+1];
        }
        else {
            unite(v[i].first, v[i].second);
            ans[i] = ans[i+1] - n1 * n2;
        }
    }
    for(long int i = 0; i < m; i++){
        cout << ans[i + 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 7020
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C_Skip
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NX = Console.ReadLine().Split(' ');
            int N = int.Parse(NX[0]);
            int X = int.Parse(NX[1]);

            List<int> num = new List<int>
            {
                X
            };
            int x;
            string[] x0 = Console.ReadLine().Split(' ');

            for (int i = 0; i < N; i++)
            {
                x = int.Parse(x0[i]);
                num.Add(x);
            }
            
            num.Sort();
            List<int> sa = new List<int>();

            for (int i = 0; i < N; i++)
            {
                sa.Add(num[i + 1] - num[i]);
            }

            int gcd = 0;
            List<int> gcdList = new List<int>();

            if (N == 1)
            {
                Console.WriteLine(sa[0]);
            }
            else
            {
                for (int i = 0; i < N - 1; i++)
                {
                    gcd = Gcd(sa[i + 1], sa[i]);
                    gcdList.Add(gcd);
                }
                Console.WriteLine(gcdList.Min());
            }
        }

        // ユークリッドの互除法 
        public static int Gcd(int a, int b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
    }
}


Measured memory_bytes: 21216
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int n;
  cin>>n;
  vector<int> d(n);
  rep(i,n) cin>>d[i];

  if(n==1){
    cout << d[0] << endl;
    return 0;
  }

  vector<pair<int,int>> x;
  rep(i,n){
    x.pb(mp(d[i], i));
    if(d[i]!=0 && d[i]!=12) x.pb(mp(24-d[i], i));
  }
  sort(all(x));
// dbg(x);
  for(int a = 12; a>=0; a--){
    auto f = [&](){
      vector<bool> used(n, false);
      int last = 0;
      int idx = 0;
      int m = x.size();
      while(idx < m){
        while(idx < m && (used[x[idx].second] || x[idx].first - last < a)) idx++;
        if(idx == m) break;
        // dbg(a,idx);
        last = x[idx].first;
        used[x[idx].second] = true;
        idx++;
      }
      if(24-last < a) return false;
      rep(i,n) if(!used[i]) return false;
      return true;
    };

    if(f()){
      cout << a << endl;
      return 0;
    }
  }
  assert(false);

  return 0;
}


Measured memory_bytes: 256
#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 D, T, S;
    cin >> D >> T >> S;
    if (D <= T * S) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
    uint_fast64_t N, M, Q;
    scanf("%llu%llu%llu", &N, &M, &Q);
    vector<vector<long long>> pt(N + 2, vector<long long>(N + 2));
    for(uint_fast64_t i = 0, L, R; i < M; ++i){
        scanf("%llu%llu", &L, &R);
        ++pt[N - L + 1][R];
    }
    for(uint_fast64_t i = 0; i < N + 2; ++i){
        partial_sum(pt[i].begin(), pt[i].end(), pt[i].begin());
        if(i)
            for(uint_fast64_t j = 0; j < N + 2; ++j)pt[i][j] += pt[i - 1][j];
    }
    for(uint_fast64_t i = 0, p, q; i < Q; ++i){
        scanf("%llu%llu", &p, &q);
        printf("%llu\n", pt[N - p + 1][q]);
    }
    return 0;
}


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

 
const int INF = (int) 1e9;

struct point {
	int x;
    int y;
	point() : x(0), y(0) {}
};
 
struct fenwick_tree {
	int n;
	unordered_map<int, int> F;
 
    fenwick_tree() : n(INF) {
    }
	void upd(int i, int x) {
		for (; i < n; i |= i + 1)
			F[i] = max(F[i], x);
	} 
	int get(int i) {
		int res = 0;
		for (; i >= 0; i &= i + 1, --i)
			res = max(res, F[i]);
		return res;
	}
};
 
 
bool cmp(point a, point b) {
    return make_pair(a.x, a.y) < make_pair(b.x, b.y); 
}
 
 
int main() {
#ifdef NICK
	freopen("input.txt", "r", stdin);
#else

#endif
    point start, finish;
    int n;
    cin >> start.x >> start.y;
    cin >> finish.x >> finish.y;
    cin >> n;
    point p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    if (start.x > finish.x)
        swap(start, finish);
    if (start.y > finish.y) {
        finish.y = 2 * start.y - finish.y;
        for (int i = 0; i < n; i++) {
            p[i].y = 2 * start.y - p[i].y;
        }
    }
    point a[n];
    int j = 0;
    for (int i = 0; i < n; i++) {
        if (start.x <= p[i].x && p[i].x <= finish.x && start.y <= p[i].y && p[i].y <= finish.y)
            a[j] = p[i], ++j;
    }
    fenwick_tree dp;
    sort(a, a + j, cmp);
    for (int i = 0; i < j; ++i)
        dp.upd(a[i].y, dp.get(a[i].y) + 1);
    int cur = dp.get(INF);
    long double ans = 0;
    if (cur != min(finish.y - start.y, finish.x - start.x) + 1)
        ans = 100.0 * (finish.y + finish.x - start.y - start.x) - 20.0 * cur + 5 * M_PI * cur;
    else
        ans = 100.0 * (finish.y + finish.x - start.x - start.y) - 20.0 * cur + 5 * M_PI * (cur - 1) + 10 * M_PI;
    cout << fixed << setprecision(13) << ans << "\n";
	return 0;
}

Measured memory_bytes: 70864
# ABC103d
import sys
from operator import itemgetter
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
span = [list(map(int, input().split())) for _ in range(m)]
span.sort(key=itemgetter(1))

setudan = span[0][1]
ans = 1
for i in span:
    if (i[0] >= setudan):
        setudan = i[1]
        ans += 1
print(ans)

Measured memory_bytes: 29120
#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 x; cin >> x;
    int n; cin >> n;
    vector<int> P(n);
    rep(i, n){
        cin >> P[i];
    }

    for (int i = 0; i < 100; i++){
        int now = x-i;
        if(find(P.begin(), P.end(), now) == P.end()){
            cout << now << endl;
            return 0;
        }
        now = x+i;
        if(find(P.begin(), P.end(), now) == P.end()){
            cout << now << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(void)
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a<b)
    {
        printf("a < b");
    }
    if(a>b)
    {
        printf("a > b");
    }
    if(a==b)
    {
        printf("a == b");
    }
    printf("\n");
    return 0;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
int n,m;
int a[N];

int32_t main()
{
	IOS;
	cin >> n >> m;
	rep(i,1,m)
	{
		int l,r;
		cin >> l >> r;
		a[l]++;
		a[r+1]--;
	}
	rep(i,1,n)
	{
		a[i]=a[i] + a[i-1];
	}
	int c=0;
	rep(i,1,n)
	{
		if(a[i]==m)
		{
			c++;
		}
	}
	cout << c << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin>>x;
  int d=x%10;
  x/=10;
  int c=x%10;
  x/=10;
  int b=x%10;
  x/=10;
  int a=x;
  //abcd
  int l=a*10+b;
  int r=c*10+d;
  if(l<=12&&l>0&&r<=12&&r>0){
  	cout<<"AMBIGUOUS"<<endl;
  	return 0;
  }
  else if((l>12||l==0)&&(r<=12&&r>0))cout<<"YYMM"<<endl;
  else if((l<=12&&l>0)&&(r>12||r==0))cout<<"MMYY"<<endl;
  else cout<<"NA"<<endl;
  return 0;
}
  

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int x;
    cin >> x;
    vector<int> number(1000);
    for(int i=0;i<1000;i++){
        number.at(i) = i * i * i * i * i;
    }
    for(int i=0;i<1000;i++){
        for(int j=0;j<1000;j++){
            if(number.at(i) - number.at(j) == x){
                cout << i << " " << j << endl;
                return 0;
            }else if(number.at(i) + number.at(j) == x){
                cout << i << " -" << j << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

VI f(VI p, VI q){
    int n = p.size();
    VI ret(n);
    REP(i,n) ret[p[i]] = q[i];
    return ret;
}

VI inv(VI p){
    int n = p.size();
    VI ret(n);
    REP(i,n) ret[p[i]] = i;
    return ret;
}

VI mul(VI p, VI q){
    int n = p.size();
    VI ret(n);
    REP(i,n) ret[i] = p[q[i]];
    return ret;
}

void out(VI p){
    for (int x : p) cout << x + 1 << " ";
    cout << endl;
}

int main() {
    int n, k;
    cin >> n >> k;
    k--;
    VI p(n), q(n);
    REP(i,n) p[i] = in() - 1;
    REP(i,n) q[i] = in() - 1;

    VI a(n);
    REP(i,n) a[i] = i;
    VI x = mul(q, mul(inv(p), mul(inv(q), p)));
    int t = k / 6;
    while (t) {
        if (t % 2) a = mul(x, a);
        x = mul(x, x);
        t /= 2;
    }

    p = mul(a, mul(p, inv(a)));
    q = mul(a, mul(q, inv(a)));

    VI ans;
    if (k % 6 == 0) ans = p;
    else if (k % 6 == 1) ans = q;
    else{
        REP(i,(k%6)-1){
            VI r = f(p, q);
            p = q;
            q = r;
        }
        ans = q;
    }
    out(ans);

    return 0;
}


Measured memory_bytes: 4992
IDENTIFICATION DIVISION.
       PROGRAM-ID. ATCODER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  indata PIC X(100).
       01  a1 PIC 9(08).
       01  a2 PIC 9(08).
       01  r pic S9(08).
       01 disp pic Z(10)9.
       PROCEDURE DIVISION.
        ACCEPT indata.
        
        UNSTRING indata DELIMITED BY SPACE INTO a1.

        COMPUTE r = a1 * a1 * a1

        MOVE FUNCTION TRIM(r) to disp
        DISPLAY disp


       STOP RUN.


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector < int >a(N + 1), boxes(N + 1, 0);
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}

	vector < int >ans;
	for (int i = N; i > 0; i--) {
		int ii = i;
		int sum = 0;
		while (ii <= N) {
			sum += boxes[ii];
			ii += i;
		}
		if (sum % 2 != a[i]) {
			boxes[i] = 1;
			ans.push_back(i);
		}
	}

	cout << ans.size() << endl;
 for (auto i:ans) {
		cout << i << " ";
	}
	if (ans.size() != 0) {
		cout << "\n";
	}

	return 0;
}


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

int n, k;
long long  A[100000];

bool Check(long long p) {
	int i = 0;
	for (int j = 0; j < k; j++) {			//k個のトラック
		long long S = 0;
		while (S + A[i] <= p) {
			S += A[i];
			i++;
			if (i == n) {
				return true;
			}
		}
	}
	return false;
}


int Allocation() {
	long long left = 0;
	long long right = 10000 * 100000;
	long long mid;
	while (right - left > 1) {
		mid = (left + right) / 2;
		if (Check(mid)) {				//その時のpは条件を満たす
			right = mid;
		}
		else {
			left = mid;					//pは条件を満たさない
		}
			
	}
	return right;
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	cout << Allocation() << endl;


}



Measured memory_bytes: 3864
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.sqrt

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val d = readInteger()
    val cList = readIntegerList()
    val sPerDay = Array(d) { readIntegerList() }
    val tArray = Array(d) { readInteger() }

    calcScore(d, cList, sPerDay, tArray)
}

fun calcScore(d: Int, cList: List<Int>, sPerDay: Array<List<Int>>, tArray: Array<Int>) {
    var score = 0L
    val last = IntArray(26)
    for (i in 0 until d) {
        val contestNo = tArray[i] - 1
        score += sPerDay[i][contestNo]

        last[contestNo] = i + 1

        for (j in 0 until 26) score -= cList[j] * ((i + 1) - last[j])

        out.println(score)
    }
}


fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


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

int main(){

    string b;

    cin >> b;

    if(b == "A")cout << "T" << endl;
    if(b == "C")cout << "G" << endl;
    if(b == "G")cout << "C" << endl;
    if(b == "T")cout << "A" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  int a,b;cin>>a>>b;
  if(b<0){
      if(a-b>a*b){
      cout<<a-b<<endl;
    }else{
      cout<<a*b<<endl;
    }
  }else{
    if(a+b>a*b){
      cout<<a+b<<endl;
    }else{
      cout<<a*b<<endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
	int a, b; // a:N-S road, b:E-W road
	std::cin >> a >> b;

	while(a != 0 || b != 0){
		int n; // n:the number of work place
		std::cin >> n;
		std::vector<std::vector<int>> work; // work:the coordinte of work place
		work.resize(b); // work is divided into each E-W road

		// input work
		int buf_x, buf_y;
		for(int i = 0; i < n; ++i){
			std::cin >> buf_x >> buf_y;
			work.at(buf_y - 1).push_back(buf_x - 1);
		}

		
		std::vector<int> way; // way:the number of ways to go its place
		way.resize(a);
		way[0] = 1; // start location

		for(int i = 0; i < b; ++i){
			for(int j = 0; j < a; ++j){
				if(std::find(work[i].begin(), work[i].end(), j)	== work[i].end()){
					if(j != 0) way[j] += way[j-1];
				}else{
					way[j] = 0; // under construction
				}
			}
		}

		std::cout << way[a-1] << std::endl; // output

		std::cin >> a >> b;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <math.h>

#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 10000000;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem2252 : koukyoukoukyoukikou **/
int main()
{
	string l="qwertasdfgzxcvb", r="yuiophjklnm";
	string s;
	while (cin>>s, s!="#") {
		int ans=0;
		char now;
		if (l.find(s[0])!=string::npos)
			now='l';
		else
			now='r';
		
		REP(i, 1, s.size()) {
			if (now=='l') {
				if (l.find(s[i])==string::npos) {
					ans++;
					now = 'r';
				}
			} else {
				if (r.find(s[i])==string::npos) {
					ans++;
					now = 'l';
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1188
import copy

def check(s, sw, p):
    num_ok = 0
    flag = True
    if len(sw) == 1:
        for i in range(len(s)):
            if sw[0] in s[i]:
                if p[i] == 0:
                    flag = False
                    break
            elif p[i] == 1:
                flag = False
                break
                
        if flag:
            num_ok = num_ok + 1
        
        if sum(p) == 0:
            num_ok = num_ok + 1        
    
    else:
        p_a = copy.deepcopy(p)
        for i in range(len(s)):
            if sw[0] in s[i]:
                p_a[i] = int((p_a[i]+1)%2)
        num_ok = num_ok + check(s, sw[1:], p_a)
        num_ok = num_ok + check(s, sw[1:], p)

    return num_ok

n, m = map(int, input().split())

s = []
for i in range(m):
    s.append(list(map(int, input().split()))[1:])

p = list(map(int, input().split()))

print(check(s, list(range(1, n+1)), p))

Measured memory_bytes: 3572
n, m = gets.strip.split.map(&:to_i)
lrd = readlines.map {|line| line.split.map(&:to_i) }

graph = Array.new(n+1) { [] }
lrd.each {|l, r, d|
  graph[l] << [r, d]
  graph[r] << [l, -d]
}

checker = Array.new(n+1)

def bfs(start, checker, graph)
  checker[start] = 0
  queue = [start]

  until queue.empty?
    from = queue.shift
    graph[from].each do |to, cost|
      if checker[to].nil?
        checker[to] = checker[from] + cost
        queue << to
      else
        return false if checker[to] != checker[from] + cost
      end
    end
  end

  return true
end

if (1..n).all? {|num| checker[num] || bfs(num, checker, graph) }
  puts 'Yes'
else
  puts 'No'
end


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

using namespace std;

typedef long long ll;

int main()
{
    int K, zbir;
    cin>>K;
    zbir=0;
    for(int a=1; a<=K; a++)
    {
        for(int b = 1; b <= K; ++b)
        {
            int gcd = __gcd(a,b);
            for(int c = 1; c <= K; ++c)
            {
                zbir += __gcd(gcd, c);
            }
        }
    }
    cout << zbir << '\n';

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    int ans = 0;
    for(int i = 1; i <= N; ++i) {
        for(int j = 10; j <= K; ++j) {
            int d1 = j % 10;
            int d2 = j / 10;
            if(d1 >= 2 && d2 >= 2 && i == d1*d2) ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio();
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long double a,n,i,product=1;
   	cin>>n;
  	for(i=0;i<n;i++){
     cin>>a;
          if(a==0)
        product=0;
      if(product!=-1)
       product*=a;
		if(product>1000000000000000000||product<0)
          product=-1;
    }
  cout<<(long long int) product;
    return 0;
}


Measured memory_bytes: 3724
#include<iostream>
#include<stdio.h>
 
using namespace std;
int main()
{
  int a;
  string s;
  cin>>a;
  cin>>s;
  if(a<3200 && a>=2800)
    cout<<"red";
  if(a>=3200 && a<5000)
    cout<<s<<endl;
  return 0;
}

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

using namespace std;

// 戻り値は交換回数
int bubble_sort(vector<int> &arr, int num) {

    int exchange = 0;
    bool flag = true;
    while (flag) {
        flag = false;
        for (int j = num - 1; j > 0; j--) {
            if (arr[j] < arr[j - 1]) {
                int v = arr[j - 1];
                arr[j - 1] = arr[j];
                arr[j] = v;
                flag = true;
                exchange++;
            }
        }
    }

    return exchange;
}

int main() {

    int num;
    cin >> num;

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

    int exchange = bubble_sort(arr, num);

    for (int i = 0; i < num; i++) {
        cout << arr[i];
        if (i != num - 1) {
            cout << " ";
        } else {
            cout << endl;
        }
    }

    cout << exchange << endl;

    return 0;
}


Measured memory_bytes: 3092
#coding:utf-8
a, b, k= map(int,input().split())
div = []

#a, bが100までの数なので、最大公約数の約数を探す
for i in range(1, 101):
    if a % i == 0 and b %i == 0:
        div.append(i)

div.sort(reverse = True)

print(div[k-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll ans, N;
    cin >> N;
    ans = 0;
    ans += (N / 500) * 1000;
    N %= 500;
    ans += (N / 5) * 5;
    cout << ans << '\n';
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

public class Hello
{

    struct Pair
    {
        public Pair(int a, int b)
        {
            Item1 = a;
            Item2 = b;
        }
        public int Item1;
        public int Item2;
    }

    public static void Main()
    {
        var N = int.Parse(Console.ReadLine().Trim());

        int zero = 0;
        var map = new Dictionary<Tuple<long, long>, int[]>();

        for(var i = 0; i < N; i++)
        {
            var A_B = Console.ReadLine().Trim().Split().Select(e=> long.Parse(e)).ToArray();
            var x = A_B[0];
            var y = A_B[1];

            if(x == 0 && y == 0) {
                zero++;
                continue;
            }
            var g = Gcd(x, y);
            x /= g;
            y /= g;
            if (y < 0) { x = -x; y = -y; }
            if (y == 0 && x < 0) { x = -x; y = -y; }
            bool rot90 = (x <= 0); 
            if (rot90) {
                var tmp = x;
                x = y; y = -tmp;
            }

            var t = Tuple.Create(x,y);
            if (rot90) {  
                if(map.ContainsKey(t)) {
                    map[t][0]++;
                } else {
                    map[t] = new []{1,0};
                }
            }
            else {
                if(map.ContainsKey(t)) {
                    map[t][1]++;
                } else {
                    map[t] = new []{0,1};
                }
            }
        }

        ModInt ans = 1;
        foreach(var p in map.Values)
        {
            int s = p[0];
            int t = p[1];
            ModInt now = 1;
            now += ModInt.Pow(2, s) - 1;
            now += ModInt.Pow(2, t) - 1;
            ans *= now;
        }
        ans -= 1;

        ans += zero;
        Console.WriteLine(ans);
   }

    class ModInt
    {
        public const long Mod = 1000000007;

        public long num;

        public ModInt(long n) { num = n; }

        public override string ToString() { return num.ToString(); }
        public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }
        public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }
        public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
        public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }

        public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }

        public static ModInt Pow(long v, long k)
        {
            long ret = 1;
            for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)
                if ((k & 1) == 1) ret = ret * v % Mod;
            return new ModInt(ret);
        }

        public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
    }

    private static long Gcd(long a, long b)
    {
        if (a < b)
        {
            return Gcd(b, a);
        }
        while (b != 0)
        {
            long r = a % b;
            a = b;
            b = r;
        }
        return a;
    }



}

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


int main() {
	int N, M;
	cin >> N >> M;
	rep(i, M) {
		int A;
		cin >> A;
		N -= A;
	}
	if (N < 0)cout << -1;
	else cout << N;
}





Measured memory_bytes: 3636
A, B, K = map(int, input().split(' '))
# A,B,K = 10**12,10**12,10**12

# print(A,B,K)

def main(a, b, k):
    if a == 0 and b == 0:
        print(0, 0)

    elif k <= a:
        print(a - k, b)

    elif k >= a + b:
        print(0, 0)

    elif a < k < a + b:
        print(0, b - (k-a))


main(A, B, K)


Measured memory_bytes: 3064
main = do
  getLine
  a <- map read . words <$> getLine
  let ans = solve a
  if ans > 10^18 then print (-1) else print ans

solve :: [Integer] -> Integer
solve [i] = i
solve a = solve la * solve ra
  where n = length a `div` 2
        (la,ra) = splitAt n a




Measured memory_bytes: 191476
N = int(input())


def divisors(n):
    divisors = []
    for i in range(1, n // 2 + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return set(divisors)


c = 0
for i in range(1, N + 1):
    if len(divisors(i)) == 8 and i % 2:
        c += 1

print(c)


Measured memory_bytes: 3060
# from collections import defaultdict
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
K = int(input())
keta = len(str(N))
dp = [[0]*(keta) for i in range(4)]
ans = 0

for k in range(1, 4):
    for i in range(1, keta):
        if i<k:
            continue
        else:
            dp[k][i] = comb(i-1, i-k)*(9**k)
#print(dp)
# dp[k][i]: i桁で、k個の0でない数            

ans += sum(dp[K]) # (N の桁)-1 までの累積和

count = 0

for j in range(keta):
    t = int(str(N)[j])
    

    if j==0:
        count+=1
        ans += sum(dp[K-count])*(t-1)
        if count == K: # K==1
            ans+=t
            break
        continue
        
    elif j==keta-1:
        if t!=0:
            count+=1
        if count==K:
            ans+=t
        break
        
        
    if t !=0:
        count+=1
        if count==K:
            ans+=sum(dp[K-count+1][:keta-j]) #0のとき
            ans+=t
            break
        
        ans += sum(dp[K-count][:keta-j])*(t-1)  #0より大きいとき
        ans += sum(dp[K-count+1][:keta-j])   #0のとき
        
   
        
print(ans)

Measured memory_bytes: 9248
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

int main()
{
  uint16_t N, K;
  cin >> N >> K;

  uint16_t max_pair = (N-1)*(N-2)/2;
  
  if (K > max_pair) {
    cout << -1 << endl;
    return 0;
  }

  cout << N-1 + max_pair - K << endl;
  
  for (uint8_t n=1; n<(uint8_t)N; ++n)
    cout << (uint16_t)n << ' ' << (uint16_t)N << endl;

  uint16_t count = 0;
  for (uint8_t ii=1; ii<(uint8_t)N; ++ii) {
    for (uint8_t jj=ii+1; jj<(uint8_t)N; ++jj) {
      if (max_pair-++count < K)
	break;
      cout << (uint16_t)ii << ' ' << (uint16_t)jj << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}
public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			long K = inputArray[1];

			var marutas = retreiveLongArray();
			long minLength = 1;
			var maxLength = marutas.Max();

			//長さ1以下にできる場合は1を返せばよい
			var onecut = getNeccesaryCutCount(marutas, 1);
			if (onecut <= K) {
				Console.WriteLine(1);
				return;
			}

			//Kが0回のとき
			if (K==0) {
				Console.WriteLine(maxLength);
				return;
			}


			while (maxLength > minLength) {
				var mid = (maxLength + minLength) / 2;

				var cutCount = getNeccesaryCutCount(marutas,mid);
				var cutCount2 = getNeccesaryCutCount(marutas, mid+1);

				if (cutCount2 <= K && K < cutCount) {
					Console.WriteLine(mid+1);
					return;
				}

				if (cutCount <= K) {
					maxLength = mid;
				}
				if (K < cutCount2) {
					minLength = mid;
				}

			}


			//答えの出力
			var ans = "error";
			Console.WriteLine(ans);

		}

		/// <summary>
		/// ある丸太をlengthの長さ以下にするのに必要なカットの数
		/// </summary>
		/// <param name="marutas"></param>
		/// <param name="length"></param>
		/// <returns></returns>
		private static long getNeccesaryCutCount(long[] marutas,long length) {

			long count = 0;

			foreach (var maruta in marutas) {

				var cutCount = maruta / length;
				if (maruta % length ==0) {
					cutCount--;
				}
				count += cutCount;

			}
			return count;
		}


		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}

	}
}


Measured memory_bytes: 45168
#include "bits/stdc++.h"
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;

int main()
{
	int n, h;
	cin >> n >> h;
	vector<int> a(n);
	vector<int> b(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i] >> b[i];
	}

	//剣を振るポイントでソート→最大値を得る
	sort(rall(a));
	int maxpoint = a[0];

	//剣を投げるポイントでソート→
	//maxpointより大きい要素を取得
	sort(all(b));
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		if (b[i] >= maxpoint)
		{
			index = i;
			break;
		}
	}

	//先に投げて、できる限り剣を振る
	int anscount = 0;

	//投げる
	for (int i = n - 1; i >= index; i--)
	{
		h -= b[i];
		anscount++;
		if (h <= 0)
		{
			cout << anscount << endl;
			return 0;
		}
	}

	//振る
	while (h > 0)
	{
		h -= maxpoint;
		anscount++;
	}

	cout << anscount << endl;

	return 0;
}

Measured memory_bytes: 1024
# - どの横一行を揃えるかで場合分け
#   - 上から i 行目を揃える場合、左から i 列目が # になっている行が必要
#     - もともとそのような行があるなら、i 行目を揃えるのに必要な操作回数は
#        N - (初期状態の i 行目の # の数)
#     - そのような行が無い場合、# のある適当な行を i 列目に置くことで作る
#       - 操作回数は N - (初期状態の i 行目の # の数) + 1
# - 横が一行以上揃ったら、縦を揃える
#   - 操作回数は N - (初期状態で揃ってる縦列の数)

N = int(input())
A = [input().replace("#", "1").replace(".", "0") for _ in range(N)]
A_T_bit = [int("".join(a), 2) for a in zip(*A)]

if A_T_bit.count(0) == N:
    print(-1)
    exit()
ans = float("inf")
for row, col in zip(A, A_T_bit):
    if col > 0:
        ans = min(ans, N - row.count("1"))
    else:
        ans = min(ans, N - row.count("1") + 1)
ans += N - A_T_bit.count((1<<N)-1)
print(ans)


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

int main() {
    int n;
    cin >> n;
    vector<int> d1(n), d2(n);
    for (int i = 0; i < n; i++) {
        cin >> d1.at(i) >> d2.at(i);
    }
    int sum = 0;
    int m = 0;
    for (int i = 0; i < n; i++) {
        if (d1.at(i) == d2.at(i)) {
            sum++;
            m = max(m, sum);
        } else {
            sum = 0;
        }
    }
    if (m >= 3) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int Count = 0; //    global

int solve(int E) {
  int x,ans=1000110;
  Count=0;
  for (int z=0; z*z*z<=E; ++z)
    for (int y=0; y*y<=(E-z*z*z); ++y)
      {
	Count++;
	x=(int)E-y*y-z*z*z;
	if(x+y*y+z*z*z==E)
	  {
	    if(ans>x+y+z)
	      ans=x+y+z;
	  }
      }
  return ans;
}

int main() {
  int E;
  while (cin >> E && E>0) {
    cout << solve(E) << endl;
    //cout<<"count="<<Count<<endl;
  }
}

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

#define N 101

double Minkowski_p1(int, int *, int *);
double Minkowski_p2(int, int *, int *);
double Minkowski_p3(int, int *, int *);
double Minkowski_pinf(int, int *, int *);

int main() {
    int i, n, x[N], y[N];
    double p1, p2, p3, pinf;

    scanf("%d", &n);

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

    p1 = Minkowski_p1(n, x, y);
    p2 = Minkowski_p2(n, x, y);
    p3 = Minkowski_p3(n, x, y);
    pinf = Minkowski_pinf(n, x, y);

    printf("%f\n%f\n%f\n%f\n", p1, p2, p3, pinf);

    return 0;
}


double Minkowski_p1(int n, int *x, int *y) {
    int i;
    double ans = 0;

    for (i = 0; i < n; i++) {
        ans += fabs(x[i] - y[i]);
    }

    return ans;
}

double Minkowski_p2(int n, int *x, int *y) {
    int i;
    double ans = 0;

    for (i = 0; i < n; i++) {
        ans += (x[i] - y[i]) * (x[i] - y[i]);
    }

    return sqrt(ans);
}

double Minkowski_p3(int n, int *x, int *y) {
    int i;
    double ans = 0;

    for (i = 0; i < n; i++) {
        ans += (x[i] - y[i]) * (x[i] - y[i]) * fabs(x[i] - y[i]);
    }

    return pow(ans, (double)1/3);
}

double Minkowski_pinf(int n, int *x, int *y) {
    int i;
    double max = -1;

    for (i = 0; i < n; i++) {
        if (fabs(x[i] - y[i]) > max) {
            max = fabs(x[i] - y[i]);
        }
    }

    return max;
}



Measured memory_bytes: 2148
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
  int key;
  Node *next,*prev;
};

Node *nil;

Node* listSearch(int key){
  Node *cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur -> next;
  }
  return cur;
}

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  Node *cur = nil->next;
  int isf = 0;
  while(1){
    if(cur == nil)break;
    if(isf++ > 0)printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key,n,i;
  int size = 0;
  char com[20];
  int np = 0,nd = 0;
  scanf("%d",&n);
  init();
  for(i = 0;i < n;i++){
    scanf("%s%d",com,&key);
    if(com[0] == 'i'){insert(key);np++;size++;}
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
	if(com[6] == 'F')deleteFirst();
	else if(com[6] == 'L')deleteLast();
      }else{
	deleteKey(key);nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}
  

  

  



Measured memory_bytes: 33856