akhauriyash/Code-Regression huggingface dataset:
//   __________________
//  | ________________ |
//  ||          ____  ||
//  ||   /\    |      ||
//  ||  /__\   |      ||
//  || /    \  |____  ||
//  ||________________||
//  |__________________|
//  \###################\
//   \###################\
//    \        ____       \
//     \_______\___\_______\
// An AC a day keeps the doctor away.

#pragma GCC optimize("Ofast")
#pragma loop_opt(on)
#include <bits/extc++.h>
#ifdef local
#define safe std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#define debug(...) qqbx(#__VA_ARGS__,  __VA_ARGS__)
template <typename H, typename ...T> constexpr void qqbx(const char *s, const H &h, T &&...args) {
    for(; *s && *s != ','; ++s) if(*s != ' ') std::cerr << *s;
    std::cerr << " = " << h << (sizeof...(T) ? ", " : "\n");
    if constexpr(sizeof...(T)) qqbx(++s, args...); // C++ 17!
}
#else
#include <bits/stdc++.h>
#define debug(...) ((void)0)
#define safe ((void)0)
#endif // local
#define all(v) begin(v),end(v)
#define get_pos(v,x) (lower_bound(begin(v),end(v),x)-begin(v))
#define sort_uni(v) sort(begin(v),end(v)),v.erase(unique(begin(v),end(v)),end(v))
#define pb emplace_back
#define ff first
#define ss second
#define mem(v,x) memset(v,x,sizeof v)

using namespace std;
using namespace __gnu_pbds;
typedef int64_t ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
template <typename T> using max_heap = std::priority_queue<T,vector<T>,less<T> >;
template <typename T> using min_heap = std::priority_queue<T,vector<T>,greater<T> >;
template <typename T> using rbt = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
constexpr ld PI = acos(-1), eps = 1e-7;
constexpr ll N = 200025, INF = 1e18, MOD = 1000000007, K = 357, inf = 1e9;
constexpr inline ll cdiv(ll x, ll m) { return x/m + ((x<0 ^ m>0) && (x%m)); } // ceiling divide
constexpr inline ll modpow(ll e,ll p,ll m=MOD) { ll r=1; for(e%=m;p;p>>=1,e=e*e%m) if(p&1) r=r*e%m; return r; }

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int a,b,c,s;
    cin >> a >> b >> c;
    s = max({a,b,c});
    if((s^a^b^c) & 1) ++s;
    cout << (s*3 - a-b-c)/2 << '\n';
}



Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val n, k, s = sc.nextLong()
    s match {
      case 1000000000L =>
        print(Array.fill(k.toInt)(s).mkString(" "))
        if ((n - k) > 0) {
          print(" ")
          print(Array.fill((n - k).toInt)(1).mkString(" "))
          println()
        } else {
          println()
        }
      case _ =>
        print(Array.fill(k.toInt)(s).mkString(" "))
        if ((n - k) > 0) {
          print(" ")
          print(Array.fill((n - k).toInt)(1000000000).mkString(" "))
          println()
        } else {
          println()
        }
    }
  }
}


Measured memory_bytes: 42148
#include <stdio.h>

int main(void){
    int m,d;
    int i;
    int cnt=0;
    do{
        scanf("%d %d",&m,&d);
        if(m==0)break;
        
        cnt=0;
        for(i=1;i<m;i++){
            switch(i){
                case 1:
                case 3:
                case 5:
                case 7:
                case 8:
                case 10:
                case 12:
                    cnt=cnt+31;
                    break;
                case 2:
                    cnt=cnt+29;
                    break;
                case 4:
                case 6:
                case 9:
                case 11:
                    cnt=cnt+30;
                    break;
            }
        }
        cnt=cnt+d;
        switch(cnt%7){
            case 1:
                printf("Thursday\n");
                break;
            case 2:
                printf("Friday\n");
                break;
            case 3:
                printf("Saturday\n");
                break;
            case 4:
                printf("Sunday\n");
                break;
            case 5:
                printf("Monday\n");
                break;
            case 6:
                printf("Tuesday\n");
                break;
            case 0:
                printf("Wednesday\n");
                break;
        }
    }while(1);
        
}



Measured memory_bytes: 2036
#include <iostream>
#include <cstdio>
#include <bitset>

using namespace std;

typedef long long ll;

const ll M = 4000000;

ll n;
ll sum;
bitset<M + 5> v;
//bool v[M + 5];

int main()
{
    scanf("%lld", &n);
    v[0] = true;
    while(n--)
    {
        ll t;
        scanf("%lld", &t);
        sum += t;
        v |= (v << t);
//        for(ll i = M; i >= t; i--)
//        {
//            v[i] |= v[i - t];
//        }
    }
    for(ll i = (sum + 1) / 2; i <= sum; i++)
    {
        if(v[i])
        {
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}


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

int main() {
  int N, M;
  while(cin >> N >> M, N && M) {
    int r;
    cin >> r;
    vector<vector<int> > log(M + 1);
    vector<int> flag(M + 1,0);
    for (int i = 0; i < r; i++) {
      int t, n, m, s;
      cin >> t >> n >> m >> s;
      if(s == 1) {
	flag[m]++;
	if(flag[m] == 1) log[m].push_back(t);
      }
      else {
	flag[m]--;
	if(flag[m] == 0) log[m].push_back(t);
      }
    }
    int q;
    cin >> q; 
    for (int i = 0; i < q; i++) {
      int ts, te, qm;
      cin >> ts >> te >> qm;
      int t = 0;
      for(int i = 0; i < log[qm].size(); i += 2) {
	if (te < log[qm][i]) break;
	else if (ts <= log[qm][i + 1] && te >= log[qm][i]) {
	  t += min(te, log[qm][i + 1]) - max(ts, log[qm][i]);
	}
      }
      cout << t << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1488
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

ll N;
ll ans[10101];

int main() {
  //
  cin >> N;
  for (ll i = 1; i * i <= N; ++i) {
    for (ll j = 1; j * j <= N; ++j) {
      for (ll k = 1; k * k <= N; ++k) {
        ll sum = i * i + j * j + k * k + i * j + j * k + k * i;
        if (sum > N) continue;
        ++ans[sum];
      }
    }
  }
  repe(i, 1, N) { cout << ans[i] << "\n"; }
}


Measured memory_bytes: 3636
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(list(input()))

d = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            cnt = 0
            for r in range(8):
                y = i + d[r][0]
                x = j + d[r][1]
                if 0 <= x < W and 0 <= y < H and S[y][x] == '#':
                        cnt = cnt + 1
            S[i][j] = str(cnt)

for i in range(H):
    print(''.join(S[i]))


Measured memory_bytes: 3188
#include<stdio.h>
#include<stdlib.h>

int main(){

	int i,j,k,n,m;
	char *Ab,*Aa;
	char *tmpstr;

	while(scanf("%d",&n)!=EOF){
		if(n==0) break;
		
		Ab = (char*)malloc(sizeof(char) * n);
		Aa = (char*)malloc(sizeof(char) * n);

		for(i=0; i < n; i++){

			scanf("%s %s",&Ab[i],&Aa[i]);

		}

		scanf("%d",&m);

		tmpstr = (char*)malloc(sizeof(char)*m);

		for(j = 0; j < m; j++){

			scanf("%s",&tmpstr[j]);

			for(k = 0; k < n; k++){
				
				if(Ab[k] == tmpstr[j]){
					tmpstr[j] = Aa[k];
					break;
				}

			}

		}

		printf("%s\n",tmpstr);

	}





	return 0;

}

Measured memory_bytes: 700
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define srep(i,n,m) for(int i=(int)n;i<=(int)m;i++)
int n,m;
int dp[52][52][52][52];
bool ok[52][52][52][52];
int inf = 1000000;
vector<string>s;
int saiki(int a,int b,int c,int d){
    if(a<0||a>=n||c<0||c>=n||b<0||b>=m||d<0||d>=m)return -inf;
    if(s[a][b]=='#'||s[c][d]=='#')return -inf;
    if(a==c&&b==d)return 0;
    if(ok[a][b][c][d])return dp[a][b][c][d]; 
    ok[a][b][c][d] = 1;
    if(a>c||b>d){
        return dp[a][b][c][d] = -inf;
    }
    if(s[a][b]>='a'&&s[a][b]<='z'&&s[c][d]==s[a][b]+('A'-'a')){
        if(c==a+1&&b==d)return dp[a][b][c][d]=1;
        if(c==a&&d==b+1)return dp[a][b][c][d]=1;
        int tmp = -inf;
        tmp = max(tmp,saiki(a+1,b,c-1,d)+1);
        tmp = max(tmp,saiki(a+1,b,c,d-1)+1);
        tmp = max(tmp,saiki(a,b+1,c-1,d)+1);
        tmp = max(tmp,saiki(a,b+1,c,d-1)+1);
        if(s[a][b]!='.'&&s[c][d]!='.'){
            srep(i,a,c){
                srep(j,b,d){
                    if(i==c&&j==d)continue;
                    tmp = max(tmp,saiki(a,b,i,j)+saiki(i+1,j,c,d));
                    tmp = max(tmp,saiki(a,b,i,j)+saiki(i,j+1,c,d));
                }
            }
        }
        if(tmp<0)tmp = -inf;
        return dp[a][b][c][d] = tmp;
    }else{
        if(c==a+1&&b==d)return dp[a][b][c][d]=0;
        if(c==a&&d==b+1)return dp[a][b][c][d]=0;
        int tmp = -inf;
        tmp = max(tmp,saiki(a+1,b,c,d));
        tmp = max(tmp,saiki(a,b,c-1,d));
        tmp = max(tmp,saiki(a,b+1,c,d));
        tmp = max(tmp,saiki(a,b,c,d-1));
        if(s[a][b]!='.'&&s[c][d]!='.'){
            srep(i,a,c){
                srep(j,b,d){
                    if(i==c&&j==d)continue;
                    tmp = max(tmp,saiki(a,b,i,j)+saiki(i+1,j,c,d));
                    tmp = max(tmp,saiki(a,b,i,j)+saiki(i,j+1,c,d));
                }
            }
        }
        if(tmp<0)tmp = -inf;
        return dp[a][b][c][d] = tmp;
    }
}


int main(){
    while(cin >> n >> m &&n!=0){
        s.resize(n);
        rep(i,n)cin >> s[i];
        rep(i,52){
            rep(j,52){
                rep(k,52){
                    rep(l,52){
                        dp[i][j][k][l] = 0;
                        ok[i][j][k][l] = 0;
                    }
                }
            }
        }
        int ans = saiki(0,0,n-1,m-1);
        if(ans<0){
            cout << -1 << endl;
        }else{
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 38716
#include <stdio.h>
#include <stdlib.h>

int selectionSort(int array[], int n);

int main(void)
{
	// ????´???°???????????????
	int n;
	scanf("%d", &n);

	// ????´????????´?????????????????????¢?????????????¢????
	int *array;
	array = (int *)malloc(n * sizeof(int));
	if (array == NULL) {
		printf("error: failed to allocate memory space\n");
		return 1;
	}

	// ????´?????????????????´?
	int i;
	for (i=0; i<n; i++) {
		scanf("%d", &array[i]);
	}

	// ????????????????????????
	int swap_cnt;
	swap_cnt = selectionSort(array, n);

	// ?????????????????????
	for (i=0; i<n; i++) {
		printf("%d", array[i]);
		if (i<n-1)
			putchar(' ');
	}
	putchar('\n');
	printf("%d\n", swap_cnt);

	free(array);
	
	return 0;
}


// ???????????????
// ???????????¶???array???0<=x<=100???n????????´??°x???????´???????????????????1<=n<=100
// ???????????¶???array???????´????????????????????????????????????????swap_cnt????????????????????°(>=0)???????´????????????????
int selectionSort(int array[], int n)
{
	int i, j, min_num, min_idx, swap_cnt=0, temp;
	for (i=0; i<n-1; i++) {
		min_num = array[i];
		min_idx = i;
		for (j=i; j<n; j++) {
			if (array[j] < min_num) {
				min_num = array[j];
				min_idx = j;
			}
		}
		if (min_idx != i) {
			swap_cnt++;
			temp = array[i];
			array[i] = min_num;
			array[min_idx] = temp;
		}
	}
	return swap_cnt;
}

Measured memory_bytes: 1856
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	char map[10][10];
};

struct Data{
	Data(int arg_row,int arg_col){
		row = arg_row;
		col = arg_col;
	}
	int row,col;
};

int H,W;
int diff_row[4] = {-1,0,0,1},diff_col[4] = {0,-1,1,0};
char base_map[10][10];
bool FLG;

char to_color[3] = {'R','G','B'};

bool rangeCheck(int row,int col){
	if(row >= 0 && row <= H-1 && col >= 0 && col <= W-1)return true;
	else{
		return false;
	}
}

void back_track(Info info,int depth,int max_depth){

	if(FLG)return;

	if(depth == max_depth){
		bool is_cleared = true;
		for(int row = 0; row < H; row++){
			for(int col = 0; col < W; col++){
				if(info.map[row][col] != info.map[0][0]){
					is_cleared = false;
					break;
				}
			}
			if(!is_cleared)break;
		}

		if(is_cleared){
			FLG = true;
			return;
		}
	}

	char pre_color = info.map[0][0];

	queue<Data> Q;
	int adj_row,adj_col;

	for(int loop = 0; loop < 3; loop++){
		if(to_color[loop] == pre_color)continue;

		Info next_info;
		for(int row = 0;row < H; row++){
			for(int col = 0; col < W; col++){
				next_info.map[row][col] = info.map[row][col];
			}
		}

		next_info.map[0][0] = to_color[loop];

		Q.push(Data(0,0));

		while(!Q.empty()){

			for(int i = 0; i < 4; i++){
				adj_row = Q.front().row + diff_row[i];
				adj_col = Q.front().col + diff_col[i];

				if(!rangeCheck(adj_row,adj_col))continue;

				if(next_info.map[adj_row][adj_col] == pre_color){
					next_info.map[adj_row][adj_col] = to_color[loop];
					Q.push(Data(adj_row,adj_col));
				}
			}

			Q.pop();
		}
		if(depth < max_depth){
			back_track(next_info,depth+1,max_depth);
		}
	}
}

void func(){

	char buf[2];

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			scanf("%s",buf);
			base_map[row][col] = buf[0];
		}
	}

	FLG = false;
	int ans = 0;

	for(int i = 0; ; i++){
		Info info;

		for(int row = 0; row < H; row++){
			for(int col = 0; col < W; col++){
				info.map[row][col] = base_map[row][col];
			}
		}
		back_track(info,0,i);

		if(FLG){
			ans = i;
			break;
		}
	}

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


int main(){

	while(true){
		scanf("%d %d",&W,&H);
		if(W == 0 && H == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3208
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
using namespace std;

int main(){
    int N;
    cin >> N;
    int H[200000];
    int maxH = 0;
    bool isOK = true;
    for (int i = 0; i < N; i++){
        cin >> H[i];
        if((maxH - 1) > H[i]){
            isOK = false;
        }
        maxH = max(maxH, H[i]);
    }
    if(isOK){
        cout << "Yes"<< endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4036
function Main(input){
  const abcde = input.split("\n").map(n=>parseInt(n));
  // const len = abcde.length;
  const len = 5;
 
  var total_time = 0;
 
  var last_cal_num = 10;
  var last_cal_num_index = 0;
 
  // 最後に注文するものを割り出す
  for(var i = 0; i < len; i++){
    var j = abcde[i] % 10
    if(0 < j && j < last_cal_num){
      last_cal_num = j;
      last_cal_num_index = i;
    }
  }
   
  // 最後に注文するもの以外の時間を足す
  for(var i = 0; i < len; i++){
    if(i !== last_cal_num_index){
      var j = abcde[i];
      var k = j % 10;
      j = k ? j + (10-k) : j; // k=0の時はそのままの値を入れる
      total_time += j;
    }
  }
   
  // 最後の注文の時間を足す
  total_time += abcde[last_cal_num_index];
  console.log(String(total_time).trim());
   
}
 
Main(require("fs").readFileSync("/dev/stdin","utf-8"));


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

long long N, K, A[1 << 19], P[1 << 19], nex[1 << 19];
long long par[1 << 19][66];
bool used[1 << 19];

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) { cin >> A[i]; A[N + i] = A[i]; }
	for (int i = N * 2 - 1; i >= 0; i--) {
		nex[i] = P[A[i]] + 1;
		P[A[i]] = i;
	}
	for (int i = 0; i < N; i++) par[i][0] = (nex[i] - i);
	for (int i = 1; i < 66; i++) {
		for (int j = 0; j < N; j++) {
			long long v1 = par[j][i - 1];
			long long pos = (j + v1) % N;
			long long v2 = par[pos][i - 1];
			long long v3 = v1 + v2;
			v3 = min(v3, (1LL << 61));
			par[j][i] = v3;
		}
	}

	long long cx = 0, px = N * K;
	for (int i = 65; i >= 0; i--) {
		if (px >= par[cx][i]) {
			px -= par[cx][i];
			cx = (cx + par[cx][i]) % N;
		}
	}

	vector<int> vec;
	for (long long i = N * K - px; i < N * K; i++) {
		if (used[A[i % N]] == false) { vec.push_back(A[i % N]); used[A[i % N]] = true; }
		else {
			while (used[A[i % N]] == true) { used[vec[vec.size() - 1]] = false; vec.pop_back(); }
		}
	}

	for (int i = 0; i < vec.size(); i++) { if (i) printf(" "); printf("%d", vec[i]); } printf("\n");
	return 0;
}

Measured memory_bytes: 118772
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define UM unordered_map
#define MP map
#define ST set
#define US unordered_set
#define V vector
#define S string
#define D deque
#define L list
#define Q queue
#define PQ priority_queue
#define D deque
#define PII pair<int, int>
#define P pair
#define DB double
#define LDB long double
#define FOR(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define FFOR(i, n) for (int(i) = 0; (i) <= (n); ++(i))
#define RFOR(i, n) for (int(i) = (n)-1; (i) >= 0; --(i))
#define all(grid) (grid).begin(), (grid).end()
#define rall(grid) (grid).rbegin(), (grid).rend()

const int dr[] = {0, 1, 0, -1};
const int dc[] = {1, 0, -1, 0};

template <typename T>
void read(T& a) {
  a = 0;
  char c;
  while ((c = cin.peek()) < 48 or c > 57) cin.get();
  while ((c = cin.get()) > 47 and c < 58) a = (a << 3) + (a << 1) + c - 48;
}

template <typename T, typename... Args>
void read(T& a, Args&&... args) {
  read(a);
  read(forward<Args>(args...)...);
}

template <typename T>
void write(const S& sep, const S& end, T n) {
  char c[128] = {0};
  int i = 0;
  for (; n; ++i, n /= 10) c[i] = n % 10;

  for (--i; i >= 0; --i) cout.put(c[i] + 48);

  cout.write(end.c_str(), end.size() * sizeof(char));
}

template <typename T, typename... Args>
void write(const S& sep, const S& end, T n, Args&&... args) {
  char c[128] = {0};
  int i = 0;
  for (; n; ++i, n /= 10) c[i] = n % 10;

  for (--i; i >= 0; --i) cout.put(c[i] + 48);

  cout.write(sep.c_str(), sep.size() * sizeof(char));
  write(sep, end, forward<Args>(args...)...);
}
const int mxN = 1e5 + 5;
struct DSU {
  int parent[mxN], sz[mxN];

  DSU(int n) {
    iota(parent, parent + n, 0);
    fill_n(sz, n, 1);
  }

  int find(int i) {
    if (parent[i] == i) return i;
    return parent[i] = find(parent[i]);
  }

  void unite(int a, int b) {
    a = find(a), b = find(b);
    if (a != b) {
      if (sz[a] < sz[b]) swap(a, b);
      parent[b] = a;
      sz[a] += sz[b];
    }
  }

  int size(int i) { return sz[find(i)]; }

  bool same(int a, int b) { return find(a) == find(b); }
};

void solve() {
  int n, m, k;
  cin >> n >> m >> k;
  DSU dsu(n);
  VI ans(n);
  FOR(i, m) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    dsu.unite(u, v);
    --ans[u], --ans[v];
  }
  // for (int i = 0; i < n; ++i) cout << dsu.parent[i] << " " << dsu.sz[i] << endl;
  FOR(i, k) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    if (dsu.same(u, v)) {
      // cout << "   " << u << " " << v << endl;
      --ans[u], --ans[v];
    }
  }

  FOR(i, n) { cout << dsu.size(i) + ans[i] - 1 << " "; }
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}


Measured memory_bytes: 4464
//submitted by sldinkar
#include <algorithm>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define mod (int)1000000007
#define MOD (int)10000000007
#define infinity (int)(1e18)

#define all(a) a.begin(),a.end()
#define ll long long
#define int long long
#define pb push_back
#define precision(n) fixed<<setprecision(n)
#define endl "\n"
#define no "NO"
#define yes "YES"


#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define test(t) int t; cin >> t; while (t--)
#define init(a, i) memset(a, i, sizeof(a))


#define vi vector<int>
#define vll vector<ll>
#define pi pair<int, int>
#define vii vector<pi>

#define f first
#define s second

int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int lcm(int a,int b) {return a*b/gcd(a,b);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}

bool isPrime(int N){ for(int i=2;i*i<=N;++i){if(N%i==0) return false;}return true;}
bool isPowerOfTwo(int x) {   return x && (!(x&(x-1))); }



// main code starts from here

int arr[100001]={0};
int n;

int Cost(int ind,vector<int>&dp){
    if(ind==n-1)return 0;
    if(dp[ind]!=-1)return dp[ind];
    int c1=abs(arr[ind+1]-arr[ind])+Cost(ind+1,dp);
    int c2=INT_MAX;
    if(ind+2<=n-1) {
        c2 = abs(arr[ind + 2] - arr[ind]) + Cost(ind + 2, dp);
    }
    return dp[ind]=min(c1,c2);
}

signed main()
{

    fast;
    cin>>n;
    for(int i=0;i<n;i++)cin>>arr[i];
    vector<int>dp(n,-1);
    cout<<Cost(0,dp)<<endl;
    return 0;
}

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

typedef struct{
  double x;
  double y;
}point;

void koch(int,  point , point);

int main(){
  point a, b;
  int n;

  scanf("%d", &n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);

  koch(n, a, b);

  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}

void koch(int n, point a, point b){
  point p, q, r;
  double theta;

  theta = M_PI * 60 / 180;

  if(n == 0)
    return;

  p.x = (2 * a.x + 1 * b.x) / 3;
  p.y = (2 * a.y + 1 * b.y) / 3;
  q.x = (1 * a.x + 2 * b.x) / 3;
  q.y = (1 * a.y + 2 * b.y) / 3;
  r.x = (q.x - p.x) * cos(theta) - (q.y - p.y) * sin(theta) + p.x;
  r.y = (q.x - p.x) * sin(theta) + (q.y - p.y) * cos(theta) + p.y;

  koch(n - 1, a, p);
  printf("%.8f %.8f\n", p.x, p.y);

 koch(n - 1, p, r);
  printf("%.8f %.8f\n", r.x, r.y);

  koch(n - 1, r, q);
  printf("%.8f %.8f\n", q.x, q.y);

  koch(n - 1, q, b);
}



Measured memory_bytes: 2040
n = int(input())
for _ in range(n):
	edges = list(map(int, input().split()))
	if len(edges) == 0:
		break
	edges.sort()

	if edges[0] ** 2 + edges[1] ** 2 == edges[2] ** 2:
		print("YES")
	else:
		print("NO")

Measured memory_bytes: 7488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
int indexed[1005];
int DAY[1005];
int main(){
    int n;cin >> n;
    vector<vector<int>> a(n,vector<int>(n-1));
    for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++){
            cin >> a[i][j];
            a[i][j]--;
        }
    }
    queue<P> q;
    for(int i=0;i<n;i++){
        int enemy=a[i][0];
        indexed[i]=0;
        if(enemy>i&&a[enemy][0]==i) q.push({i,enemy}); // swapしなくて済む
    }
    while(!q.empty()){
        int me=q.front().first,enemy=q.front().second;
        q.pop();
        int day=max(DAY[me],DAY[enemy])+1;
        DAY[me]=day;
        DAY[enemy]=day;
        indexed[me]++;
        indexed[enemy]++;
        if(indexed[me]+1<n){
            int enemy2=a[me][indexed[me]];
            if(a[enemy2][indexed[enemy2]]==me){
                q.push({me,enemy2});
            }
        }
        if(indexed[enemy]+1<n){
            int enemy2=a[enemy][indexed[enemy]];
            if(a[enemy2][indexed[enemy2]]==enemy){
                q.push({enemy,enemy2});
            }
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(indexed[i]+1<n){
            cout << -1 << endl;
            return 0;
        }
        ans=max(ans,DAY[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int a,b,c;
	cin>>a>>b>>c;
	if(b/a < c)cout<<b/a<<endl;
	else cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct aaa{
	int x,y;
}a[500010];
int n,m,ans,f[500010];
bool cmp(aaa a,aaa b){
	return a.y-a.x<b.y-b.x;
}
int lowbit(int x){
	return x&(-x);
}
void ins(int x,int w){
	int i;
	for(i=x;i<=m;i+=lowbit(i))f[i]+=w;
}
int query(int x){
	int i,xlh=0;
	for(i=x;i;i-=lowbit(i))xlh+=f[i];
	return xlh;
}
int main(){
	int i,j=0,k;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)scanf("%d%d",&a[i].x,&a[i].y);
	sort(a+1,a+n+1,cmp);
	for(i=1;i<=m;i++){
		while(j<n&&a[j+1].y-a[j+1].x<i){
			j++;
			ins(a[j].x,1);ins(a[j].y+1,-1);
		}
		ans=0;
		for(k=i;k<=m;k+=i)ans+=query(k);
		printf("%d\n",ans+n-j);
	}
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

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

	string s;
	cin >> s;

	int nSize;
	int ans = 0;

	for (int i = s.length() - 1; i > 0; i--) {
		if (i % 2 != 0) continue;
		if (s.substr(0, i / 2) == s.substr(i / 2, i / 2)) {
			ans = i;
			break;
		}
	}

	out(ans);

	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>;
#define INF 100000000
const int MOD = 1000000007;


int main(){
    /*
    int n;
    cin>>n;
    map <string,int> mp;
    mp["AC"]=0;
    mp["WA"]=0;
    mp["TLE"]=0;
    mp["RE"]=0;
    for(int i=0;i<n;i++)
    {
        string x;
        cin>>x;
        mp.at(x)++;
    }

    cout<<"AC"<<" "<<"x "<<mp["AC"]<<endl;
    cout<<"WA"<<" "<<"x "<<mp["WA"]<<endl;
    cout<<"TLE"<<" "<<"x "<<mp["TLE"]<<endl;
    cout<<"RE"<<" "<<"x "<<mp["RE"]<<endl;
    */

    int n;
    cin>>n;
    int count = n/1000+1;
    if(n%1000==0)
    {
        count--;
    }
    cout<<1000*count-n<<endl;
    return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

const int dx[] = { -1 , 0 , 1 , 0 } ;
const int dy[] = { 0 , 1 , 0 , -1 } ;

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    ll x ;
    cin >> x ;

    ll N = 1000 ;

    for ( ll a = -N ; a <= N ; a ++ )
    {
        for ( ll b = -N ; b <= N ; b ++ )
        {
            ll aa = round ( pow ( a , 5 ) ) ;
            ll bb = round ( pow ( b , 5 ) ) ;

            if ( aa - bb == x )
            {
                cout << a << " " << b ;
//                cerr << "aa : " << aa << " and bb : " << bb << "\n" ;

                line ; return ;
            }
        }
    }
}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


Measured memory_bytes: 4040
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <utility>

int main()
{
	int x = 0, y = 0;

	std::cin >> x >> y;

	std::vector<std::vector<int>> g = {
		{ 1, 3, 5, 7, 8, 10, 12 } ,
		{ 4, 6, 9, 11},
		{ 2 }
	};

	bool flag = false;

	for (auto a : g)
	{
		if (std::find(a.cbegin(), a.cend(), x) != a.cend() &&
			std::find(a.cbegin(), a.cend(), y) != a.cend())
		{
			flag = true;
		}

	}

	if (flag)
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;




	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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 namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(0);
    lli n, d;
    cin >> n >> d;
    d = 2*d+1;
    cout << ceil(1.0*n/d) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int hour, minute, second;
	hour = minute = 0;
	scanf("%d", &second);
	while (second >= 60) {
		minute ++;
		second -= 60;
	}
	while (minute >= 60) {
			hour ++;
			minute -= 60;
	}
	printf("%d:%d:%d\n", hour, minute, second);
	return 0;
}

Measured memory_bytes: 592
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,ans=0
    integer(int32), allocatable:: a(:)

    read*, n
    allocate(a(n))
    read*, a(:)
    do i=1,n
        if (mod(a(i),2) == 1 .and. mod(i,2)==1) ans=ans+1
    end do

    print'(i0)', ans
end program main

Measured memory_bytes: 2800
import sys
readline = sys.stdin.readline

N, W = map(int, readline().split())

dp = [0] * (W+1)

for i in range(N):
    item_v, item_w = map(int, readline().split())
    for w in range(W-item_w+1):
        if dp[w+item_w] < dp[w] + item_v:
            dp[w+item_w] = dp[w] + item_v

print(max(dp))

Measured memory_bytes: 7884
/* attention to overflow */
#include <bits/stdc++.h>

#define dump(x) cerr<< #x << " = " << x <<endl
#define ALL(container) (container).begin(),(container).end()

using namespace std;
const int INF = 1 << 25;
void io() { cin.tie(0); ios::sync_with_stdio(false);}
template <class S,class T> ostream& operator<<(ostream& os, const pair <S,T> &s){return os<<'('<<s.first<<','<<s.second<<')';}
/*printf("%.9Lf\n",cf);*/
const int MOD = 1000000007;
const double EPS=1e-8;

int gcd(int a,int b){
	if(a<b) swap(a,b);
	if(a%b==0) return b;
	return gcd(b,a%b);
}

int main() {
	io();
	int N,M;
	cin>>N>>M;
	vector <int> A(2*N);
	for(int i=0;i<N;i++) cin>>A[i];
	for(int i=0;i<N;i++) A[i+N]=A[i];

	int ml=(M*N)/gcd(M,N);
	//cout<<ml<<endl;

	int ans=0;
	for(int j=0;j<ml/M;j++){
		int start=j*M;
		int end=(j+1)*M-1;

		start=(start-1)%N+1;
		end=(end-1)%N+1;
		if(start>end) end+=N;

		int mx=*max_element(A.begin()+start,A.begin()+end+1);
		int mn=*min_element(A.begin()+start,A.begin()+end+1);

		//cout<<mx<<' '<<mn<<endl;

		ans+=mx-mn;
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3104
fun main(args: Array<String>){
    var s = readLine()!!
    while (s.isNotEmpty()){
        s = s.dropLast(2)
        if(s.slice(0..s.length/2 - 1) == s.slice(s.length/2..s.length - 1)){
            println(s.length)
            return
        }
    }
}

Measured memory_bytes: 33852
#include <bits/stdc++.h>
#define bear ryan
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define ends ' '
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void debug_out(){
   cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
   cerr << " " << to_string(H);
   debug_out(T...);
}

#define LOCAL
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] : ", debug_out(__VA_ARGS__)
#else
#define debug(...) 917
#endif

const ll inf = 1e9;
const ll mod = 998244353;

void rmax(ll& r, ll x) { r = max(r, x); }

ll power(ll a, ll b) {
    ll r = 1, t = a;
    while(b) {
        if(b & 1)   r = r * t % mod;
        t = t * t % mod;
        b >>= 1;
    }
    return r;
}

const int maxn = 3e5 + 10;

ll n, k, a[maxn];
bool chk[maxn];
deque<int> v;
int st = -1;

void dfs(int now) {
    chk[now] = true;
    v.eb(now);
    if(chk[a[now]]) {
        st = a[now];
        return;
    }
    dfs(a[now]);
}

int main(void) {
    fastio;
    cin >> n >> k;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    dfs(1);
    while(k && v[0] != st) {
        --k;
        v.pop_front();
    }
    if(!k) {
        cout << v.front();
        return 0;
    }
    k %= v.size();
    while(k) {
        --k;
        v.pop_front();
    }
    cout << v.front();
    return 0;
}


Measured memory_bytes: 5836
N = int(input())
A = list(map(int, input().split()))

A.sort()

work = 0
lastindex = 0
for i in range(N-1):
  work += A[i]
  if work * 2 >= A[i+1]:
    if lastindex == -1:
      lastindex = i
  else:
    lastindex = -1
    
if lastindex == -1:
  print(1)
else:
  print(N-lastindex)

Measured memory_bytes: 14320
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

const LL INF = 1LL << 61;

int N;
LL L[5145];
LL R[5145];
LL W[5145];
LL dp[2][5145];
int Llast[2][5145];
int Rlast[2][5145];
vector<int> ps;

LL Solve(LL x) {
  rep(i, N) {
    L[i] -= x;
    R[i] += x;
  }

  int src = 0;
  int dst = 1;
  fill(dp[src], dp[src+1], INF);
  dp[src][0] = 0;
  rep(i, N) {
    fill(dp[dst], dp[dst+1], INF);

    int idx = ps[i];
    rep(j, i+1) {
      if (MN(dp[dst][j+1], dp[src][j] + j*W[idx] + R[idx])) {
        Llast[dst][j+1] = idx;
        Rlast[dst][j+1] = Rlast[src][j];
      }

      if (MN(dp[dst][j], dp[src][j] + (i-j)*W[idx] + L[idx])) {
        Llast[dst][j] = Llast[src][j];
        Rlast[dst][j] = idx;
      }
    }

    swap(src, dst);
  }

  LL ret = INF;
  if (N%2 == 0) {
    ret = dp[src][N/2];
  } else {
    int l = N/2;
    int idx = Rlast[src][l];
    MN(ret, dp[src][l] - (N-l)*L[idx] + l*L[idx]);
    idx = Llast[src][l+1];
    MN(ret, dp[src][l+1] - (l+1)*R[idx] + (N-1-l)*R[idx]);
  }

  rep(i, N) {
    L[i] += x;
    R[i] -= x;
  }

  return ret;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  cin >> N;

  LL ml = INF;
  LL mr = INF;
  rep(i, N) {
    cin >> L[i] >> R[i];
    W[i] = L[i] + R[i];
    ps.eb(i);
    MN(ml, L[i]);
    MN(mr, R[i]);
  }
  sort(all(ps), [&](int a, int b){return W[a] > W[b];});

  LL ans = INF;
  ans = Solve(0);
  //LL low = -ml-1;
  //LL high = mr+1;
  //while (high - low > 10) {
  //  LL lmid = (high+low*2)/3;
  //  LL rmid = (high*2+low)/3;
  //  LL lval = Solve(lmid);
  //  LL rval = Solve(rmid);
  //  if (lval < rval) high = rmid;
  //  else low = lmid;
  //}

  //for (LL i=low; i<high+1; i++) {
  //  if (i < -ml || mr < i) continue;
  //  MN(ans, Solve(i));
  //}
  cout << ans << endl;
}


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

int main() {

  int N,C; 
  cin >> N;
  
  string ANS;
  ANS = "No";     
    for (int i = 1; i <= 9; i++) {
	  for (int j = 1; j <= 9; j++) {
        C = i * j;
//    	cout << i << j << C << endl;
    
        if ( C == N ) {
		  ANS = "Yes";
  		}
  	  }
    }
   cout << ANS << endl;
}


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

int main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if((j < A && i < B ) || (j >= A && i >= B)) cout<<'1';
      else cout<<'0';
    }
    cout<<endl;
  }
}


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

int main()
{
    string x, y;
    cin >> x >> y;
    bool ok = true;
    for (int i = x.size() - 1; i >= 0; i--) {
        ok &= (x[i] == y[i]);
    }
    cout << ((ok) ? "Yes" : "No") << "\n";
}


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

map<int, int> m;
int main() {
	int n;
	cin >> n;
	for (int i = 0;i <= n - 2;i++) {
		int x;
		cin >> x;
		m[x]++;
	}

	for (int i = 1;i <= n;i++) {
		cout << m[i]<<endl;

	}
}

Measured memory_bytes: 12948
#include <cstdio>

using namespace std;

int a[100000];

int main() {
    int n, m, i;
    
    scanf("%d %d", &n, &m);
    
    for (i = 0; i < m; i++) {
        int x, y;
        
        scanf("%d %d", &x, &y);
        
        a[x - 1]++;
        a[y - 1]++;
    }
    
    for (i = 0; i < n; i++) {
        if (a[i] % 2 == 1) {
            puts("NO");
            
            return 0;
        }
    }
    
    puts("YES");
    
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  pair<pair<string, int>, int> P[110];
  rep(i, N){
    string S;
    int A;
    cin >> S >> A;
    P[i]=make_pair(make_pair(S, -A), i);
  }
  sort(P, P+N);
  rep(i, N) cout << P[i].second+1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, ans = 0;
  string s;
  cin >> n >> s;
  REP(i, n-2)
  {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    if ("ABC" == t) ans++;
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
    int A, B; cin >> A >> B;
    for(int k=1; k<=10000; ++k) {
        if(k * 8 / 100 == A && k * 10 / 100 == B) {
            cout << k << '\n';
            return 0;
        }
    }
    cout << -1 << '\n';
}

Measured memory_bytes: 256
N,M = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
x.sort!

if N >= M
  puts 0
  exit
end

y = []

(M-1).times{|i|
  y << (x[i+1]-x[i]).abs
}

y.sort!

puts y[0..M-1-N].inject(:+)

Measured memory_bytes: 9968
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var dic = new Dictionary<string, long>();
            long cnt = 0;
            for (var i = 0;i<N;i++)
            {
                var tt = string.Join("",ReadLine().OrderBy(c => c));
                if (dic.ContainsKey(tt))
                {
                    cnt += dic[tt];
                    dic[tt]++;
                }
                else dic.Add(tt, 1);
            }
            Console.WriteLine(cnt);
        }

    }
}

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

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const double PI = acos(-1.0);
const int MOD = (int)pow(10, 9) + 7;

#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define all(v) v.begin(), v.end()
#define Ini(a) ll a; cin >> a;
#define Ind(a) double a; cin >> a;
#define Ins(a) string a; cin >> a;

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

inline void finish() {
	cout << -1 << endl;
	exit(0);
}

template <typename T>
inline void debug(vector<T> v) {
	cout << "[";
	for (size_t i = 0; i < v.size() - 1; ++i) {
		cout << v[i] << ", ";
	}
	cout << v[v.size() - 1] << "]" << endl;
}

class Pos {
public:
	double x, y;
	Pos(double x, double y) {
		this->x = x;
		this->y = y;
	}
	Pos() {
		x = 0.0;
		y = 0.0;
	}

	bool isSamePos(Pos pos1, Pos pos2) {
		if (pos1.x == pos2.x && pos1.y == pos2.y) {
			return true;
		}
		return false;
	}
};

class Mod {
public:
	static inline ll Add(ll a, ll b) {
		return (a + b) % MOD;
	}

	static inline ll Sub(ll a, ll b) {
		ll ans = (a - b) % MOD;
		return (ans < 0) ? (ans + MOD) : ans;
	}

	static inline ll Mul(ll a, ll b) {
		return (a * b) % MOD;
	}
	
	static inline ll Div(ll a, ll b) {
		return (a % MOD) * modinv(b, MOD) % MOD;
	}
};

inline double distance(Pos p1, Pos p2) {
	return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
}

inline ull Kaijo(int n) {
	ull ans = 1;
	for (int i = 2; i <= n; ++i) {
		ans *= i;
	}
	return ans;
}

template <typename T>
inline int GetKeta(T num) {
	return to_string(num).length();
}

void Main();
inline void DebugMain() {
	while (true) {
		Main();
		cout << endl;
	}
}

int main() {
	bool debug = false;
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	if (debug) {
		cout << "\x1b[41m" << "Debug Mode このまま提出すると死" << endl;
	}
	try {
		(debug) ? DebugMain() : Main();
	}
	catch (exception& e) {
		cout << e.what() << endl;
	}
	return 0;
}

template <typename T>
inline bool isExistArray(vector<T>& v, T& str) {
	if (v.size() == 0) {
		return false;
	}
	for (string& s : v) {
		if (s == str) {
			return true;
		}
	}
	return false;
}

inline int ctoi(char c) {
	return (int)c - 48;
}

inline int find(vector<int>& v, int n) {
	for (int i = 0; i < v.size(); ++i) {
		if (v[i] == n) {
			return i;
		}
	}
	return -1;
}

inline bool isSameArray(vector<int>& v1, vector<int>& v2) {
	for (int i = 0; i < v1.size(); ++i) {
		if (v1[i] != v2[i]) {
			return false;
		}
	}
	return true;
}

inline bool isSeisu(double n) {

	if (std::floor(n) == n) {
		return true;
	}
	return false;
}

int gcd(int a, int b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

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


inline void Main() {
	Ini(S);
	Ini(W);

	if (S <= W) {
		cout << "unsafe";
	}
	else {
		cout << "safe";
	}
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
using namespace std;
int main(){
   int A,B,C,K;
   cin >> A >> B >> C >> K;
   for(int i=0; i<K; i++){
       if(A >= B && A >= C){
           A = A*2;
       }if(B >= A && B >= C){
           B = B*2;
       }if(C >=A && C >= B){
           C = C*2;
       }
   }cout << A+B+C << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	if (a==b&&a!=c)
		cout<<"Yes"<<endl;
	else if (a==c&&a!=b)
		cout<<"Yes"<<endl;
	else if (c==b&&a!=c)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

vector<pii> g[18];

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   f(i,0,n){
      int a;
      cin >> a;
      f(j,0,a){
         int x,y;
         cin >> x >> y;
         x--;
         g[i].pb({x,y});
      }
   }
   int ans = 0;
   f(i,0,(1<<n)){
      set<int> chk[n+5];
      vector<int> vis(n+5,0);
      int c = 1;
      int cnt = 0;
      queue<int> q;
      f(j,0,n){
         if(i&(1<<j)){
            chk[j].insert(1);
            q.push(j);
         }
      }
      while(!q.empty()){
         int tp = q.front();
         q.pop();
         if(vis[tp]) continue;
         cnt++;
         vis[tp] = 1;
         for(auto &v : g[tp]){
            chk[v.F].insert(v.S);
            if(v.S == 1){
               q.push(v.F);
            }
         }
      }
      f(j,0,n){
         if((int)chk[j].size() >= 2){
            c = 0;
            break;
         }
      }
      if(c){
         ans = max(ans,cnt);
      }
   }
   cout << ans << '\n';
   return 0;
} 

Measured memory_bytes: 256