akhauriyash/Code-Regression huggingface dataset:
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace
 
#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define CIN(x) int x;cin>>x;
#define COUT(x) cout<<(x)<<endl;
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;
 
#define ALL(obj) (obj).begin(),(obj).end()// iterator
 
#define P pair<int,int>
#define V vector<int>
 
#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair
 
 
int main(){
 
    CIN(a);CIN(b);CIN(c);CIN(d);
    COUT(max(a*b,c*d));
    return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll h, a;cin >> h >> a;
	cout << (h + a - 1) / a << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = sc.nextInt();
        }
 
        long sum1 = 0;
        long ans1 = 0;
        for (int i = 0; i < n; ++i) {
            sum1 += a[i];
            if (i % 2 == 0 && sum1 <= 0) {
                ans1 += 1 - sum1;
                sum1 = 1;
            } else if (i % 2 == 1 && sum1 >= 0) {
                ans1 += 1 + sum1;
                sum1 = -1;
            }
        }
 
        long sum2 = 0;
        long ans2 = 0;
        for (int i = 0; i < n; ++i) {
            sum2 += a[i];
            if (i % 2 == 0 && sum2 >= 0) {
                ans2 += 1 + sum2;
                sum2 = -1;
            } else if (i % 2 == 1 && sum2 <= 0) {
                ans2 += 1 - sum2;
                sum2 = 1;
            }
        }
 
        _out.println(Math.min(ans1, ans2));
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 52640
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

const ll INF = (1LL << 60);

int n, m, s;
ll  C[50], D[50];
vector<vector<pair<ll, ll>>> a_lis, b_lis;

void input() {
	cin >> n >> m >> s;
	a_lis.resize(n);
	b_lis.resize(n);
	for (int i = 0; i < m; ++i) {
		int u, v;
		ll a, b;
		cin >> u >> v >> a >> b;
		--u, --v;
		a_lis[u].emplace_back(v, a);
		a_lis[v].emplace_back(u, a);
		b_lis[u].emplace_back(v, b);
		b_lis[v].emplace_back(u, b);
	}
	for (int i = 0; i < n; ++i) {
		ll c, d; cin >> c >> d;
		C[i] = c, D[i] = d;
	}
}

template<typename T>
vector<T> dijkstra(int s, vector<vector<pair<int, T>>>& G) {
	const int n = G.size();
	vector<T> d(n, numeric_limits<T>::max());
	vector<int> b(n, -1);
	priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> q;
	d[s] = 0;
	q.emplace(d[s], s);
	while (!q.empty()) {
		pair<T, int> p = q.top();
		q.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (auto& e : G[v]) {
			int u = e.first;
			T c = e.second;
			if (d[u] > d[v] + c) {
				d[u] = d[v] + c;
				b[u] = v;
				q.emplace(d[u], u);
			}
		}
	}
	return d;
}

void solve() {
	if (s >= 2500) s = 2500;
	vector<vector<pair<int, ll>>> g(n * 2501);
	for (int i = 0; i < n; ++i) {
		ll c = C[i], d = D[i];
		// 両替
		for (int mo = 0; mo < 2500; ++mo) {
			int p = 2501 * i + mo;
			int money = (int)min(2500LL, mo + c);
			int nx = 2501 * i + money;
			g[p].emplace_back(nx, d);
		}
		// 移動
		for (int j = 0; j < (int)(a_lis[i].size()); ++j) {
			int nx_idx = a_lis[i][j].first;
			ll a = a_lis[i][j].second;
			ll b = b_lis[i][j].second;
			for (int mo = a; mo <= 2500; ++mo) {
				int p = 2501 * i + mo;
				int nx = 2501 * nx_idx + mo - a;
				g[p].emplace_back(nx, b);
			}
		}
	}
	auto res = dijkstra<ll>(s, g);
	for (int i = 1; i < n; ++i) {
		ll tmp = INF;
		for (int id = 2501 * i; id < 2501 * (i + 1); ++id)
			tmp = min(tmp, res[id]);
		cout << tmp << endl;
	}
}

int main() {
	input();
	solve();
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int n,d,x;cin>>n>>d>>x;

  int count=0;
  rep(i,0,n){
    int a;cin>>a;
    count+=(d-1)/a+1;
  }
  out(x+count);

  return 0;
}


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

using namespace std;
using ll = long long;

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


Measured memory_bytes: 3624
S = input()

idx = len(S)
while idx > 0:
    if S[idx-7:idx] == "dreamer":
        idx -= 7
    elif S[idx-6:idx] == "eraser":
        idx -= 6
    elif S[idx-5:idx] in ["dream", "erase"]:
        idx -= 5
    else:
        print("NO")
        break
else:
    print("YES")

Measured memory_bytes: 9192
#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--) // [a, b)
#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)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

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;
}

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; };

ll gcd(ll a, ll b) {
    if (a<b) swap(a, b);
    while(b!=0) {
        ll t = a;
        a = b;
        b = t%b;
    }
    return a;
}

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

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

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

int const H = 81;
int const W = 81;
bool dp[H][W][(H+W)*H];

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

    int h, w; cin >> h >> w;
    vector<vector<int>> a(H, vector<int>(W));
    vector<vector<int>> b(H, vector<int>(W));

    repr(i, 1, h+1) repr(j, 1, w+1) cin >> a[i][j];
    repr(i, 1, h+1) repr(j, 1, w+1) cin >> b[i][j];

    dp[1][1][abs(a[1][1]-b[1][1])] = true;
    repr(i, 1, h+1) repr(j, 1, w+1) rep(k, 80*(80+80)+1) {
        if (!dp[i][j][k]) continue;

        if (i+1 <= h) {
            dp[i+1][j][abs(k + a[i+1][j] - b[i+1][j])] = true;
            dp[i+1][j][abs(k - a[i+1][j] + b[i+1][j])] = true;
        }
        if (j+1 <= w) {
            dp[i][j+1][abs(k + a[i][j+1] - b[i][j+1])] = true;
            dp[i][j+1][abs(k - a[i][j+1] + b[i][j+1])] = true;
        }
    }

    rep(k, 80*(80+80)+1) if (dp[h][w][k]) { cout << k << endl; return 0; }
    
    return 0;
}


Measured memory_bytes: 82944
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

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

struct P{
  int h, w;
}

void solve(){
  int h = scan!int, w = scan!int, m = scan!int;
  P[] ps;
  foreach(i; 0 .. m) ps ~= P(scan!int - 1, scan!int - 1);
  
  int[] xs = new int[](h);
  foreach(p; ps) xs[p.h] += 1;
  
  int[] ys = new int[](w);
  foreach(p; ps) ys[p.w] += 1;
  
  // Holizontal and vertical can be done separatedly
  
  int[] ansi, ansj;
  int bestx, besty;
  foreach(i; 0 .. h){
    if(xs[i] > bestx) bestx = xs[i], ansi = [];
    if(xs[i] >= bestx) ansi ~= i;
  }
  foreach(j; 0 .. w){
    if(ys[j] > besty) besty = ys[j], ansj = [];
    if(ys[j] >= besty) ansj ~= j;
  }
  
  // If there is no box at some crossing, ans(h) + ans(w) is the answer; else ans(h) + ans(w) - 1
  
  bool[P] pset;
  foreach(p; ps) pset[p] = 1;
  int ansvalue = bestx + besty - 1;
  A: foreach(i; ansi){
    foreach(j; ansj){
      // This loop breaks in at most M times
      if(P(i, j) in pset) continue;
      else{
        ansvalue = bestx + besty;
        break;
      }
    }
  }
  ansvalue.writeln;
  
}


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

int main()
{
	for(int i = 0; i < 5; i++)
	{
		int ans;
		scanf("%d", &ans);
		if(ans == 0)
		{
			printf("%d", i + 1);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3704
//52行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

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--)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

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

vector<ll> divisors(long long N){
    vector<ll> res;
    for(ll i = 1;i * i <= N;i++){
        if(N % i == 0){
            res.pb(i);
            if(i != (N / i)){
                res.pb(N / i);
            }
        }
    }
    sort(all(res));
    return res;
}
int main(int argc, char const *argv[])
{
    ll n;cin >> n;
    vl d_n = divisors(n - 1);
    vl d_n1 = divisors(n);
    set<ll> ans;
    for(auto i : d_n)if(i != 1)ans.insert(i);
    for(auto i : d_n1){
        if(i == 1)continue;
        else{
            ll m = n;
            while(m > 0 && (m % i == 0)){
                m = (m / i);
            }
            if(m % i == 1)ans.insert(i);
        }
    }
    cout << ans.size() << '\n';
    return 0;
}

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

int main() {
	int N;
	string S;
	cin >> N >> S;
	int ans = N;
	rep(i, N - 1) {
		if (S.at(i) == S.at(i + 1)) {
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int i,j,flag=0,t;
int x[6],y[6],z[6];

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

void N(int w[]){
    t = w[0];
    w[0] = w[1];
    w[1] = w[5];
    w[5] = w[4];
    w[4] = t;
}
 
void S(int w[]){
    t = w[0];
    w[0] = w[4];
    w[4] = w[5];
    w[5] = w[1];
    w[1] = t;
}
 
void W(int w[]){
    t = w[0];
    w[0] = w[2];
    w[2] = w[5];
    w[5] = w[3];
    w[3] = t;
}
 
void E(int w[]){
    t = w[0];
    w[0] = w[3];
    w[3] = w[5];
    w[5] = w[2];
    w[2] = t;
}

void turn(int w[]){
    t = w[1];
    w[1] = w[2];
    w[2] = w[4];
    w[4] = w[3];
    w[3] = t;
}

int main(void){
    input();
    for(i=0;i<6;i++){
        if(x[0]==y[i]){
            memcpy(z,y,sizeof(int)*6);
            switch(i){
                case 0:
                break;
                case 1:
                N(z);
                break;
                case 2:
                W(z);
                break;
                case 3:
                E(z);
                break;
                case 4:
                S(z);
                break;
                case 5:
                N(z);
                N(z);
                break;
            }
            for(j=0;j<4;j++){
                if(x[0]==z[0] && x[1]==z[1] && x[2]==z[2] && x[3]==z[3] && x[4]==z[4] && x[5]==z[5]){
                flag=1;
                break;
                }else turn(z);
            }
        }
        if(flag==1) break;
    }
    if(flag==1) printf("Yes\n");
    else printf("No\n");
    
}


Measured memory_bytes: 1804
a,b,c = map(int,input().split())
for i in range(600):
  if a&1 or b&1 or c&1:
    break
  a,b,c = a//2, b//2, c//2
  a, b, c = b + c, a + c, a + b
ans = i if i < 500 else -1
print(ans)

Measured memory_bytes: 3060
def main():
  import sys
  input = sys.stdin.readline
  import math 
  import itertools 
  n=int(input())
  xy=[list(map(int,input().split())) for _ in [0]*n]
  l=''.join([str(i) for i in range(n)])
  sum=0
  for i in itertools.permutations(l):
    i=''.join(list(i))
    for j in range(n-1):
      a,b=int(i[j+1]),int(i[j])
      sum+=pow(pow(xy[a][0]-xy[b][0],2)+pow(xy[a][1]-xy[b][1],2),0.5)
  m=math.factorial(n)
  print(sum/m)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int N;
    cin >> N;

    vector<string> S(N);

    map<string, int> str;

    for(int i = 0; i < N; i++)
    {
        cin >> S.at(i);
        str[S.at(i)]++;
    }

    int max = 0;
    for(auto x : str)
    {
        if(x.second > max)
        {
            max = x.second;
        }
    }

    for(auto x : str)
    {
        if(x.second == max)
        {
            cout << x.first << "\n";
        }
    }
    
    return 0;
}

Measured memory_bytes: 26752
#include <cstdio>

using s32 = int;
using u32 = unsigned int;
using s64 = long long int;
using u64 = unsigned long long int;
using u128 = __uint128_t;

s32 n;

int main(){
  scanf("%d", &n);

  u128 ans = 1;
  bool zero = false;
  for(int i = 0; i < n; ++i){
    s64 a;
    scanf("%lld", &a);
    zero |= a == 0;
    if(!zero){
      ans *= a;
      if(ans > 1000000000000000000ULL){
        ans = -1;
      }
    }
  }
  printf("%lld\n", zero ? 0 : (u64) ans);
  return 0;
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
int main()
{

 string s;

 cin>>s;

     if(s[0]==s[1])
        cout<<"Bad"<<"\n";
     else if(s[1]==s[2])
        cout<<"Bad"<<"\n";
     else if(s[2]==s[3])
        cout<<"Bad"<<"\n";
     else
        cout<<"Good"<<"\n";
return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int A[2002];
int N;
int memo[2002][2002][2];
int score(int player, int i, int j){
  if(memo[i][j][player] > 0) return memo[i][j][player];
  if(player){//X の番　最大化したい
    int ret = abs(A[N-1]-A[j]);
    for(int k = i; k < N-1; ++k){
      ret = max(ret, score(0,k+1,k));
    }
    memo[i][j][player] = ret;
    return ret;
  }else{//最小化
    int ret = abs(A[N-1]-A[j]);
    for(int k = i; k < N-1; ++k){
      ret = min(ret, score(1,k+1,k));
    }
    memo[i][j][player] = ret;
    return ret;
  }
}

int main(){
  int Z, W;
  cin >> N >> Z >> W;
  for(int i = 0; i < N; ++i) cin >> A[i];
  A[N] = Z;
  A[N+1] = W;
  for(int i = 0; i < N+2; ++i) for(int j = 0; j < N+2; ++j) for(int k = 0; k < 2; ++k) memo[i][j][k] = -1;
  cout << score(1,0,N+1) << endl;
  return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()

using namespace std;

template <typename T>
class Mat
{
    vector<vector<T>> mat;
    int rows, columns;
public:
    Mat<T>(int r, int c) : rows(r), columns(c) {
        mat = vector<vector<T>>(rows, vector<T>(columns));
    }

    Mat<T>(initializer_list<initializer_list<T>> _mat) : rows(_mat.size()), columns(_mat.begin()->size()){
        mat = vector<vector<T>>(rows, vector<T>(columns));
        int i = 0;
        for (auto&& row : _mat) {
            copy(row.begin(), row.end(), mat[i++].begin());
        }
    }

    vector<T> &operator[](int m) {
        return mat[m];
    }

    vector<T> operator*(const vector<T> v) const {
        auto ret = vector<T>(rows);
        for (int m = 0; m < rows; m++) {
            T sum = 0;
            for (int n = 0; n < columns; n++) {
                sum += mat[m][n] * v[n];
            }
            ret[m] = sum;
        }
        return ret;
    }

    Mat<T> &t() {
        auto _mat = vector<vector<T>>(columns, vector<T>(rows));
        for (int m = 0; m < rows; m++) for (int n = 0; n < columns; n++) {
            _mat[n][m] = mat[m][n];
        }
        mat = _mat;
        swap(rows, columns);
        return *this;
    }
};

const vector<Mat<int>> Rot = {
    {{ 1, 0 }, { 0, 1 }},
    {{ 0, 1 }, { -1, 0 }},
    {{ -1, 0 }, { 0, -1 }},
    {{ 0, -1 }, { 1, 0 }}
};

void normalize(vector<int> &x, vector<int> &y)
{
    for (int i = x.size()-1; i >= 0; i--) {
        x[i] -= x[0], y[i] -= y[0];
    }

    int d = 0;
    if (y[1] > 0) d = 1;
    if (x[1] < 0) d = 2;
    if (y[1] < 0) d = 3;

    loop (x.size(), i) {
        auto a = Rot[d] * vector<int>({ x[i], y[i] });
        x[i] = a[0];
        y[i] = a[1];
    }
}

int main()
{
    while (1) {
        int n; cin >> n;
        if (!n) break;
        int m; cin >> m;
        vector<int> orig_x(m), orig_y(m);
        loop (m, i) cin >> orig_x[i] >> orig_y[i];
        normalize(orig_x, orig_y);

        loop (n, i) {
            cin >> m;
            vector<int> x(m), y(m);
            loop (m, j) cin >> x[j] >> y[j];
            normalize(x, y);

            loop (2, k) {
                if (orig_x == x && orig_y == y) {
                    cout << i + 1 << endl;
                    break;
                }

                reverse(all(x));
                reverse(all(y));
                normalize(x, y);
            }
        }
        cout << "+++++" << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void) {
  int k, a, b;
  scanf("%d %d %d", &k, &a ,&b);
  if (!((b / k) - (a / k)) && (a % k)) printf("NG\n");
  else printf("OK\n");

  return 0;
}


Measured memory_bytes: 1660
#include<iostream>
#include<functional>
#include<atcoder/all>
using namespace std;
typedef long long li;
#define M_MAX 1000000001
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

struct mono{
  li ma,mi;
  mono(li a=-1,li b=M_MAX){ma=a,mi=b;};
};

mono e(){
  return mono();
}

mono op(mono m,mono n){
  return {max(m.ma,n.ma),min(n.mi,n.mi)};
}
// pair 型
std::ostream& operator<<(std::ostream& os, const mono& p){
  cout << "(" << p.ma << "," << p.mi << ")";
  return os;
}


int main(){
  int n,q; cin >>n >>q;
  vector<mono> v(n);
  rep(i,n){
    li a; cin >>a;
    v[i]={a,a};
  }
  atcoder::segtree<mono,op,e> sgt(v);
  if(df) rep(i,n)print(sgt.get(i));
  
  
  rep(_,q){
    int t; cin >>t;
    if(t==1){
      int x;li v; cin >>x >>v; x--;
      if(df)print(x,v);
      sgt.set(x,v);
    }else if(t==2){
      int l,r; cin >>l >>r;l--;
      mono p=sgt.prod(l,r);
      print(p.ma);
    }else{
      int x;li v; cin >>x >>v; x--;
      auto f=
        [&](mono p){
          return p.ma<v;
        };
      print(sgt.max_right<decltype(f)>(x,f)+1);
    }
  }
  
}


Measured memory_bytes: 14628
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

bool func(string S) {
    int N = S.size();
    rep(i,N/2) {
        if (S[i] != S[N-1-i]) return false;
    }
    return true;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S; cin >> S;
    int N = S.size();

    bool ok = true;
    if (!func(S)) ok = false;
    string T = S.substr(0,(N-1)/2);
    string U = S.substr((N+3)/2-1,(N-1)/2);
    if (!func(T)) ok = false;
    if (!func(U)) ok = false;
    cout << (ok ? "Yes" : "No") << ln;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int a,b,c; cin >> a >> b >> c;
  set<int> st;
  st.insert(a);
  st.insert(b);
  st.insert(c);
  if(st.size()==2) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

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

    bool t = true;
    rep(i, k){
        if(t){
            if(a % 2 != 0){
                a--;
            }
            b += a / 2;
            a /= 2;
            t = false;
        }else{
            if(b % 2 != 0){
                b--;
            }
            a += b / 2;
            b /= 2;
            t = true;
        }
    }
    cout << a << " " << b << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void dfs(int root,vector<bool> &vis,vector<int> adj[])
{
    vis[root]=true;
    for(auto it:adj[root])
    {
        if(!vis[it])
        {
            dfs(it,vis,adj);
        }
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    //freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    int N,K;
    cin>>N>>K;
    vector<int> adj[N+1];
    while(K--)
    {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    vector<bool> vis(N+1,false);
    dfs(1,vis,adj);
    int FLAG=0;
    for(int i=1;i<=N;i++)
    {
        if (vis[i]==false)
        {
            FLAG=1;
            break;
        }
    }
    if(FLAG==1)
    {
        cout<<"No";
    }
    else
    {
        queue< pair<int,int> > S;
        S.push(make_pair(-1,1));
        vector<bool> visi(N+1,false);
        map<int,int> Hash;
        while(!S.empty())
        {
            int size=S.size();
            while(size--)
            {
                pair<int,int > temp=S.front();
                S.pop();
                Hash[temp.second]=temp.first;
                for(auto it:adj[temp.second])
                {
                    if(!visi[it])
                    {
                        visi[it]=true;
                        S.push(make_pair(temp.second,it));
                    }
                }
            }

        }
        cout<<"Yes"<<endl;
        for(int i=2;i<=N;i++)
        {
            cout<<Hash[i]<<endl;
        }

    }
}

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

int main() {
    std::vector<bool> isin(101);
    std::vector<int> t;
    int n; std::cin >> n;
    for (int i = 0; i < n; ++i) {
        int a; std::cin >> a;
        if (a > 0) {
            if (isin[a]) {
                std::cout << i + 1 << std::endl;
                return 0;
            }
            isin[a] = true;
            t.push_back(a);
        } else {
            a = -a;
            if (!isin[a] || t.empty() || t.back() != a) {
                std::cout << i + 1 << std::endl;
                return 0;
            }
            isin[a] = false;
            t.pop_back();
        }
    }
    std::cout << "OK" << std::endl;
}


Measured memory_bytes: 3140
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
#mod = 10 ** 9 + 7 
mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
D = LIST()

d = Counter(D)

if D[0] != 0 or 2 <= d[0]:
	print(0)
	exit()

ans = 1

for i in range(1, max(d.keys())+1):
	ans = ans * pow(d[i-1], d[i], mod) % mod
	tmp = d[i]

print(ans)


Measured memory_bytes: 23056
w, h, n = map(int, input().split())

x_min = 0
y_min = 0
x_max = w
y_max = h
for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1 and x_min < x:
        x_min = x
    elif a == 2 and x_max > x:
        x_max = x
    elif a == 3 and y_min < y:
        y_min = y
    elif a == 4 and y_max > y:
        y_max = y
if x_max < x_min or y_max < y_min:
    print(0)
else:
    print((x_max - x_min) * (y_max - y_min))



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1e18;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i){
    cin >> A[i];
  }
  vector< vector<long long> > DP(N+1,vector<long long>(N+1,-INF));
  for(int i = 0; i <= N; ++i) DP[i][i] = 0;
  for(int i = 1; i <= N; ++i){
    for(int j = 0; j <= N-i; ++j){
      DP[j][i+j] = -max(A[j+i-1]+DP[j][i+j-1],A[j]+DP[j+1][i+j]);
      //cerr << j << " " << j+i << " " << DP[j][i+j] << endl;
    }
  }
  cout << -DP[0][N] << endl;
}


Measured memory_bytes: 70784
#include<stdio.h>
#include<string.h>

int main(void)
{
    char str[255];
   
    scanf("%s", str);

    if(str[2]==str[3] && str[4]==str[5]) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    
    
    

    return 0;
}

Measured memory_bytes: 1656
#include <iostream>

int main() {
    using namespace std;
    int wk = 0;
    int num[3];

    cin >> num[0] >> num[1] >> num[2];
    
    for (int i=0; i < 3; i++) {
       for (int j = 2; j > i; j--) {
         if (num[j] < num[j-1] ){
           wk = num[j-1];
           num[j-1] = num[j];
           num[j] = wk;
         }
       }
    }
    for (int k=0; k < sizeof(num)/sizeof(num[0]); k++) {
      if (k < sizeof(num)/sizeof(num[0]) -1) {
        cout << num[k] << " ";
      } else {
        cout << num[k] << endl;           
      }
    }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=1; i<=(n); ++i)
typedef long long ll;
ll comb(ll n){
  return n*(n-1)/2;
}
int main(){
  ll n; cin >> n;
  vector<ll> a;
  map<ll, ll> m;
  rep(i,n){
    ll t; cin >> t;
    a.push_back(t);
    // はまりポイント１　
    // mapはatメソッドだと空番ができるので[]を使う
    m[t] +=1;
  }
  a.resize(n);
  ll sum=0;
  // はまりポイント２
  // mapに拡張for文は使えない（用確認）
  rep(i,n){
    sum += comb(m[i]);
  }
  
  rep(i,n){
    ll b = a[i-1];
    cout << max((sum-(m[b]-1)),(ll)0) << endl;
  }
}

Measured memory_bytes: 16624
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
int main(){
 
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    long long int n, w;
    cin >> n >> w;
 
    vector<pair<long long int, long long int>> wt;
 
    long long int x, y;
    for(long long int i=1; i<=n; i++){
        cin >> x >> y;
        wt.push_back({x,y});
    }
 
    sort(wt.begin(),wt.end());    
 
    vector<ll> dp(w+1);
    for(int i=0; i<=w; i++){
        if(wt[0].first<=i) dp[i]=wt[0].second;
        else dp[i]=0;
    }
 
    for(int i=1; i<n; i++){
        vector<ll> new_dp(w+1);
        for(int cap=0; cap<=w; cap++){
            if(wt[i].first>cap) new_dp[cap]=dp[cap];
            else new_dp[cap]=max(wt[i].second+dp[cap-wt[i].first],dp[cap]);
        }
        dp=new_dp;
    }
    cout<<dp[w]<<'\n';
 
    return 0;
}

Measured memory_bytes: 4764
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

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

int main() {
    int N; // 200
    int M; // N * (N - 1) / 2
    int R; // min(8, N)
    scanf("%d %d %d", &N, &M, &R);

    vector<int> r;
    REP(i, R) {
        int ri = 0;
        scanf("%d", &ri);
        ri--;
        r.push_back(ri);
    }
    sort(r.begin(), r.end());

    int d[N][N];
    REP(i, N) REP(j, N) {
        d[i][j] = 1e9;
    }

    REP(i, M) {
        int A, B;
        int C; // 町 Ai と町 Bi の間の距離, 1e5
        scanf("%d %d %d", &A, &B, &C);
        A--; B--;
        if (d[A][B] > C) d[A][B] = d[B][A] = C;
    }

    REP(k, N) REP(i, N) REP(j, N) {
        if (d[i][j] > d[i][k] + d[k][j]) {
            d[i][j] = d[i][k] + d[k][j];
        }
    }

    int ans = 1e9;
    do {
        // REP(i, R - 1) {
        //     printf("%d, ", r[i]);
        // }
        // printf("%d\n", r[R - 1]);

        int temp = 0;
        REP(i, R - 1) {
            temp += d[r[i]][r[i + 1]];
        }
        ans = min(ans, temp);
    } while(next_permutation(r.begin(), r.end()));

    printf("%d\n", ans);

    return 0;
}


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

int N;
int x[10], y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> x[i] >> y[i];
    double ans = 0.0;
    for(int i = 1; i <= N; i++) {
        for(int j = i + 1; j <= N; j++) ans += dist(i, j) * 2 / N;
    }
    cout << fixed << setprecision(10) << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 4248
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll x,y,z;
  cin >> x >> y >> z;
  ll ans=MAXL;
  ans=min(ans,x%2*y*z);
  ans=min(ans,y%2*x*z);
  ans=min(ans,z%2*y*x);
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
const main = (input) => {
  input = input.trim().split('\n')
  const N = parseInt(input[0], 10)
  const nums = input[1].split(' ')

  const x = {}
  let sum = 0
  for (let i = 0; i < N; i++) x[nums[i]] = ~~x[nums[i]] + 1
  for (let [, v] of Object.entries(x)) sum += v*(v-1) / 2
  for (let i = 0; i < N; i++) console.log(sum === 0 ? 0 : sum - Math.max(0, ~~x[nums[i]] - 1))
}


process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 99476
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<bool> dp(n + 1);
	dp[0] = true;
	
	for (int i = 100; i <= 105; ++i){
		for (int j = i; j <= n; ++j){
			if (dp[j - i]){
				dp[j] = true;
			}
		}
	}
	cout << dp[n];
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N, K; cin >> N >> K;
    vector<int>h(N);
    rep(i, N)cin >> h[i];
    sort(h.begin(), h.end());
    int ans = h[K - 1] - h[0];
    REP(i, N - K + 1)ans = min(ans, h[i + K - 1] - h[i]);
    cout << ans << endl;
}

Measured memory_bytes: 3708
program A319A
    implicit none
    integer(8)::N,i,j,flg,ac
    character(10)::wi
    character(10),dimension(100)::W
    read*,N
    ac=1
    flg=0
    do i=1,N
        read*,wi
        if(i==1)then
            W(ac)=wi
            ac=ac+1
        else if(wi(1:1)==W(ac-1)(len_trim(W(ac-1)):len_trim(W((ac-1)))))then
            do j=1,ac-1
                if(wi(1:len_trim(wi))==W(j)(1:len_trim(W(j))))then
                    flg=1
                    exit
                end if
            end do
            if(flg==0)then
                W(ac)=wi
                ac=ac+1
            end if
        else
            flg=1
        end if
        !print'(i0)',flg
    end do
    if(flg==0)print'(A)',"Yes"
    if(flg==1)print'(A)',"No"
end program A319A

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,k;
    scanf("%d %d %d %d", &a, &b, &c, &k);
    int sum = 0;
    
    if(a >= k)
        sum = k;
    else if(a+b >= k)
        sum = a;
    else
        sum = a - (k-a-b);
        
    printf("%d\n",sum);
}


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

int art[401][401];
P square[201];
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
int main(void){
    int N, n, d;
    while(cin >> N && N) {
        rep(i, 401) rep(j, 401) art[i][j] = 0;
        square[0] = P(200, 200);
        art[200][200] = 1;
        int minx=200, miny=200, maxx=200, maxy=200;
        rep(i, N-1) {
            cin >> n >> d;
            int nx = square[n].first+dx[d];
            int ny = square[n].second+dy[d];
            square[i+1] = P(nx, ny);
            art[nx][ny] = 1;
            minx = min(minx, nx);
            maxx = max(maxx, nx);
            miny = min(miny, ny);
            maxy = max(maxy, ny);
        }
        cout << maxx-minx+1 << " " << maxy-miny+1 << endl;
    }
}

Measured memory_bytes: 1788
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())

def bs(ok, ng, solve):
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if solve(mid):
            ok = mid
        else:
            ng = mid
    return ok

ok = n
ng = 0
ans = bs(ok, ng, lambda x: x * 1.08 >= n)
if int(ans * 1.08) == n:
    print(ans)
else:
    print(':(')


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

using namespace std;
// Problem https://atcoder.jp/contests/abc065/tasks/abc065_b

int solver(int LAMPNUM,vector<int> NEXTSHINE){
    int result;
    result = -1;
    int switchCounter,nowShining;
    switchCounter = 0;
    nowShining = 0;
    static int targetShining = (2-1);
    while(true){
        if(targetShining == nowShining){
            result = switchCounter;
            break;
        }
        if(switchCounter <= LAMPNUM){
            switchCounter = switchCounter + 1;
            nowShining = NEXTSHINE.at(nowShining);
        }
        else{
            break;
        }
    }
    return result;
}


int main(void){
    int answer;
    answer = -1;
    int N;
    cin >> N;
    vector<int> Ai;
    Ai.clear();
    for(int j=0;j<N;j++){
        int lamp;
        cin >> lamp;
        Ai.push_back(lamp-1);
    }
    answer = solver(N,Ai);
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>//復習必須
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int main () {
    ll A , B , C , K ;
    cin >> A >> B >> C >> K ;

    if(K < A ){
        cout << K << endl;
    }else if(K <= A+B){
        cout << A << endl;
    }else{
        cout << A - (K - A  - B) << endl;
    }

    
    return 0 ;
}

 


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
struct point
{
    int x;
    int y;
    int index;
}stu[55],check[55];
int cnt=0;
int N,M;

bool comp(const point&p1,const point &p2)
{
    if((abs(p1.x-stu[cnt].x)+abs(p1.y-stu[cnt].y))<(abs(p2.x-stu[cnt].x)+abs(p2.y-stu[cnt].y)))
    {
        return true;
    }
    else if((abs(p1.x-stu[cnt].x)+abs(p1.y-stu[cnt].y))==(abs(p2.x-stu[cnt].x)+abs(p2.y-stu[cnt].y)))
    {
        if(p1.index<p2.index)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        return false;
    }
}
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>N>>M;
    for(int i=1;i<=N;i++)
    {
        cin>>stu[i].x>>stu[i].y;
    }
    for(int i=1;i<=M;i++)
    {
        cin>>check[i].x>>check[i].y;
        check[i].index=i;
    }
    for(int i=1;i<=N;i++)
    {
        cnt++;
        sort(check+1,check+1+M,comp);
        cout <<check[1].index<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>

#define pb(a) push_back(a)
#define mp make_pair


int main(){

  LCIN(k);
  if(!k){COUT(2);SCOUT(0);EN(0);}
  COUT(50);
  V v(50);
  ll n = 50;
  iota(ALL(v),0);
  ll t = 1LL*k%50;
  if(!t)t=50;

  if(t==50)
    REP(i,n)
      v[i]--;
  else if(t==49)v[0]--;
  else 
    REP(i, 50 - t){
      v[i]=v[50-t]-2;
    }
  
  REP(i,n)
    v[i] += 1LL * k/50 + 1;


  VECCOUT(v);

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) arr[i] = in.nextInt();
		long count = 0;
		Hashtable<Integer, Integer> hc = new Hashtable<Integer, Integer>();
		hc.put(arr[0], 1);
		for (int i = 1; i < n; i++) {
			if (hc.get(i-arr[i]) != null) count += hc.get(i-arr[i]);
			if (hc.get(arr[i]+i) == null) hc.put(arr[i]+i, 1);
			else hc.replace(arr[i]+i, hc.get(arr[i]+i)+1);
		}
		System.out.println(count);
	}
}


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


int main()
{
	int H, W;
	while (cin >> H >> W){
		if (H == 0 && W == 0){
			break;
		}
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

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

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let a = read_vec::<i64>();

    let mut accum_max = vec![0; n];
    accum_max[0] = 0;
    for i in 1..n {
        accum_max[i] = max(accum_max[i - 1], a[i - 1]);
    }

    let mut ans = std::i64::MAX;
    for state in 0..1 << n {
        if ((state as u64).count_ones() as usize) < k {
            continue;
        }

        let mut chosen = vec![];
        for i in 0..n {
            if state >> i & 1 == 1 {
                chosen.push(i);
            }
        }

        let mut cost = 0;
        let mut prev_height = 0;
        for i in 0..chosen.len() {
            let next_height = max(max(accum_max[chosen[i]] + 1, a[chosen[i]]), prev_height + 1);
            cost += next_height - a[chosen[i]];
            prev_height = next_height;
        }
        ans = min(ans, cost);
    }
    println!("{}", ans);
}

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

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


Measured memory_bytes: 4352