akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

                long X = scan.nextLong();
                long K = scan.nextLong();
                long D = scan.nextLong();

                long output = 0;

                long nearZeroMoveNum = Math.abs(X) / D;

                if (K <= nearZeroMoveNum) {
                	if (X >= 0) {
                		output = Math.abs(X - D * K);
                	} else {
                		output = Math.abs(X + D * K);
                	}
                } else {
                	if (X >= 0) {
                		if ((K - nearZeroMoveNum)%2 == 0) {
                			output = Math.abs(X - D * nearZeroMoveNum);
                		} else {
                			output = Math.abs(X - D * nearZeroMoveNum - D);
                		}
                	} else {
                		if ((K - nearZeroMoveNum)%2 == 0) {
                			output = Math.abs(X + D * nearZeroMoveNum);
                		} else {
                			output = Math.abs(X + D * nearZeroMoveNum + D);
                		}
                	}
                }

                System.out.println(output);

                scan.close();

        }

}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define ll long long
int main(void)
{
	int n;
	cin >> n;
	vec<ll> a(n), b(n);
	rep(i, n) cin >> a[i] >> b[i];
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());

	ll ans = 0;
	rep(i, n) {
		a[i] += ans;
		if (a[i] == 0) continue;
		ll plus = ((a[i] - 1) / b[i] + 1) * b[i] - a[i];
		ans += plus;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
				System.out.println(i + "x" + j + "=" + i * j);
			}
		}
	}
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define reps(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) reps(i, 0, n)
#define REPS(i, a, b) reps(i, a, b)
#define REP(i, n) rep(i, n)
#define deps(i, a, b) for (int i = a; i >= b; --i)
#define dep(i, n) deps(i, n, 0)
#define DEPS(i, a, b) deps(i, a, b)
#define DEP(i, n) dep(i, n)

#define pf push_front
#define pb push_back
#define mp make_pair
#define fst first
#define FST fst
#define sec second
#define SEC sec
#define sz(obj) ((int)(obj).size())
#define all(v) (v).begin(), (v).end()
#define ALL(v) all(v)

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T> void print(T x) { std::cout << x << '\n'; }

signed main()
{
  int n = in(), k = in();
  rep(i, k){
    int a = in(), b = in();
    print(min(min(a - 1, n - a), min(b - 1, n - b)) % 3 + 1);
  }

  return (0);
}

Measured memory_bytes: 3164
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    def check_palindrome(s):
        n = len(s)
        i = 0
        while i < (n - 1 - i):
            if s[i] != s[n - 1 - i]:
                return False
            i += 1
        return True
    
    s = input()
    n = len(s)
    left = s[:(n-1)//2]
    right = s[(n+3)//2 - 1:]
    print('Yes') if check_palindrome(left) and check_palindrome(right) and check_palindrome(s) else print('No')


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define rrdebug(i, j, x) rep(i, alength(a))rep(j, alength(a[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = 3.141592653589;
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl a[n][3];
    ccin(i,j,a);
    intl dp[n+1][3];
    rep(i,n+1){
        rep(j,3){
            dp[i][j] = 0;
        }
    }
    rep(i,n){
        rep(j,3){
            rep(k,3){
                if(j == k)continue;
                chmax(dp[i + 1][j],dp[i][k] + a[i][j]);
            }
        }
    }
    cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ll long long
#define vrednost first
#define tezina second

using namespace std;

int n,w;
ll vmax=100009;
pair<ll,ll> predmeti[110];
ll dp[100010][110];

int main()
{
	ios::sync_with_stdio(false);	
	cin.tie(0);
	
	cin>>n>>w;
	ll t,v;
	for(int i=1;i<=n;i++)
	{
		cin>>t>>v;
		predmeti[i]=make_pair(v,t);
	}
	
	for(int j=0;j<=n;j++)
		for(int i=1;i<=vmax;i++)
			dp[i][j]=2*w;
			
	for(int i=0;i<n;i++)
		dp[predmeti[i].vrednost][i]=predmeti[i].tezina;
	
	
	sort(predmeti,predmeti+n);
	for(int j=1;j<=n;j++)
		for(int i=1;i<=vmax;i++)
			if(predmeti[j].vrednost<=i)
				dp[i][j]=min(dp[i][j-1],dp[i-predmeti[j].vrednost][j-1]+predmeti[j].tezina);
			else
				dp[i][j]=dp[i][j-1];
	//cout<<dp[w][n];
	for(int i=vmax;i>0;i--)
		if(dp[i][n]<=w)
		{
			cout<<i;
			return 0;
		}
	cout<<0;
	
	return 0;
}


Measured memory_bytes: 86400
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n), B(n);
  rep(i, n) cin >> A[i];
  rep(i, n) cin >> B[i];
  if(accumulate(all(A), 0LL) < accumulate(all(B), 0LL)) {
    cout << -1 << "\n";
  } else {
    ll tarinai = 0;
    priority_queue<ll> yobun;
    int ans = 0;
    rep(i, n) {
      if(B[i] > A[i]) {
        tarinai += B[i]-A[i];
        ans++;
      } else if(B[i] < A[i]) {
        yobun.push(A[i]-B[i]);
      }
    }
    ll sum = 0;
    while(sum < tarinai) {
      sum += yobun.top(); yobun.pop();
      ans++;
    }
    cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 5440
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,x,num,y,ans,s1,s2,r;
int main(){
	cin>>a>>b>>c>>d;ans=b-a+1;
	x=a/c;
	if(a%c==0) x--;
	y=b/c;
	num+=y-x;
	x=a/d;
	if(a%d==0) x--;
    y=b/d;
	num+=y-x;
	x=c*d;
	s1=min(c,d);
	s2=max(c,d);
	r=s2%s1;
	while(r)
	{
		s2=s1;
		s1=r;
		r=s2%s1;
	}
	y=x/s1;
	x=a/y;
	if(a%y==0) x--;
	y=b/y;
	num=num+x-y;
	cout<<ans-num;
	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e2 + 5;

int g[MAXN][MAXN];
char s[MAXN];

int col[MAXN];
int n;

int dfs(int s, int cl) {
	col[s] = cl;
	REP(i, 0, n) {
		if (g[s][i]) {
			if (col[s] == col[i]) {
				return 1;
			} else if (col[i] == 0 && dfs(i, 3 - cl)) {
				return 1;
			}
		}
	}
	return 0;
}

void solve(){
	scanf("%d", &n);
	REP(i, 0, n) {
		scanf("%s", &s[0]);
		REP(j, 0, n) {
			g[i][j] = s[j] - '0';
		}
	}
	if (dfs(1, 1)) {
		printf("-1\n");
		return;
	}
	REP(i, 0, n) {
		REP(j, 0, n) {
			if (i != j && g[i][j] == 0) {
				g[i][j] = INF;
			}
		}
	}
	REP(k, 0, n) {
		REP(i, 0, n) {
			REP(j, 0, n) {
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}
	int ans = 0;
	REP(i, 0, n) {
		REP(j, 0, n) {
			ans = max(ans, g[i][j]);
		}
	}
	printf("%d\n", ans + 1);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s; cin>>s;
    map<char, ll> mp;
    ll n = s.length();
    ll ans = n*(n-1)/2+1;

    rep(i,n) {
        if (mp.count(s[i])) {
            ans -= mp[s[i]];
        }
        mp[s[i]]++;
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int a, b, c;
	
	while (~scanf("%d %d %d", &a, &b, &c)){
		if ((a == 1 && b == 1 && c == 0) || (a == 0 && b == 0 && c == 1)){
			puts("Open");
		} else {
			puts("Close");
		}
	}
	
	return (0);
}

Measured memory_bytes: 584
#include <stdio.h>

int main()
{   
		char str[10001];
		
		while (scanf("%s", str) == 1) {
			int i = 0, j = 0, a;
		for (a = 0;str[a] != '\0';a++) {
			if (str[a] == 'J'&&str[a + 1] == 'O'&&str[a + 2] == 'I')
				j++;
		}
		for (a = 0;str[a] != '\0';a++) {
			if (str[a] == 'I'&&str[a + 1] == 'O'&&str[a + 2] == 'I')
				i++;
		}

		printf("%d\n%d\n", j, i);
	}
	return 0;
}

Measured memory_bytes: 552
#include <iostream>
#include <vector>
#include<iomanip>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

int N,C;
int imos[31][100001];
int main(int argc, const char * argv[]) {
    int i,j;
    cin >> N >> C;
    
    int s,t,c;
    for (i = 0; i < N; i++) {
        cin >> s >> t >> c;
        imos[c][s-1] += 1;
        imos[c][t] -= 1;
    }
    for (j = 1; j < 31; j++) {
        for (i = 1; i < 100001; i++) {
            imos[j][i] += imos[j][i-1];
            //if (imos[j][i]) imos[j][i] = 1;
        }
    }
    
    for (j = 1; j < 31; j++) {
        for (i = 1; i < 100001; i++) {
            if (imos[j][i]) imos[j][i] = 1;
        }
    }
    
    int ans = 0;
    for (i = 1; i < 100001; i++) {
        int sum = 0;
        for (j = 1; j < 31; j++) {
            sum += imos[j][i];
        }
        ans = max(sum, ans);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 12032
/// @file up.cc
/// @brief up の実装ファイル
/// @author Yusuke Matsunaga (松永 裕介)
///
/// Copyright (C) 2019 Yusuke Matsunaga
/// All rights reserved.


#include <iostream>
#include <vector>
#include <list>

using namespace std;

class MFSetCell
{
public:

  long mId;

  MFSetCell* mParent;

  long mRank;

};

class MFSet
{
public:

  MFSet(long num);

  ~MFSet() = default;

  long
  find(long id);

  long
  merge(long id1,
	long id2);


private:

  MFSetCell*
  _find_top(MFSetCell* cell);

  vector<MFSetCell> mArray;

};


MFSet::MFSet(long num) :
  mArray(num)
{
  for ( long i = 0; i < num; ++ i ) {
    MFSetCell& cell = mArray[i];
    cell.mId = i;
    cell.mParent = &cell;
    cell.mRank = 0;
  }
}

long
MFSet::find(long id)
{
  auto tmp = &mArray[id];
  auto top = _find_top(tmp);
  return top->mId;
}

MFSetCell*
MFSet::_find_top(MFSetCell* cell)
{
  auto parent = cell->mParent;
  while ( parent->mParent != parent ) {
    cell = cell->mParent = parent->mParent;
    parent = cell->mParent;
  }
  return parent;
}

long
MFSet::merge(long id1,
	     long id2)
{
  auto cell1 = &mArray[id1];
  auto cell2 = &mArray[id2];

  if ( cell1->mParent != cell1 ) {
    cell1 = _find_top(cell1);
  }
  if ( cell2->mParent != cell2 ) {
    cell2 = _find_top(cell2);
  }
  if ( cell1 == cell2 ) {
    return cell1->mId;
  }

  if ( cell1->mRank > cell2->mRank ) {
    cell2->mParent = cell1;
    return cell1->mId;
  }
  else if ( cell1->mRank == cell2->mRank ) {
    ++ cell1->mRank;
    cell2->mParent = cell1;
    return cell1->mId;
  }
  else {
    cell1->mParent = cell2;
    return cell2->mId;
  }
}

void
no()
{
  cout << "No" << endl;
  exit(0);
}

void
yes()
{
  cout << "Yes" << endl;
  exit(0);
}

int
main(int argc,
     char** argv)
{
  cin.tie(0);
  ios::sync_with_stdio(0);

  long N;
  long M;
  long Q;
  cin >> N
      >> M
      >> Q;

  if ( Q == 0 ) {
    abort();
  }
  if ( M > ((N * (N - 1)) / 2) ) {
    abort();
  }

  MFSet mfset(N);

  vector<pair<long, long>> single_pair_list;
  vector<pair<long, long>> multi_pair_list;
  bool has_single = false;
  for ( long i = 0; i < Q; ++ i ) {
    long a, b, c;
    cin >> a >> b >> c;
    if ( c == 0 ) {
      single_pair_list.push_back(make_pair(a, b));
      mfset.merge(a, b);
      has_single = true;
    }
    else {
      multi_pair_list.push_back(make_pair(a, b));
    }
  }

  if ( M == N - 1 ) {
    // M = N - 1 の時は木構造のグラフとなる．
    if ( multi_pair_list.size() > 0 ) {
      // その場合複数経路はありえない．
      no();
    }
    else {
      yes();
    }
  }

  if ( !has_single ) {
    yes();
  }

  for ( auto p: multi_pair_list ) {
    long a = p.first;
    long b = p.second;
    if ( mfset.find(a) == mfset.find(b) ) {
      no();
    }
  }

  long K = 0;
  for ( long i = 0; i < N; ++ i ) {
    if ( mfset.find(i) == i ) {
      ++ K;
    }
  }

  long M_max = N - K + (K * (K - 1)) / 2;
  if ( M > M_max ) {
    no();
  }

  yes();

  return 0;
}


Measured memory_bytes: 4724
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut x = a.iter().enumerate().map(|(i, ai)| (ai, i + 1)).collect::<Vec<_>>();
    x.sort();
    for (_, v) in x {
        print!("{} ", v);
    }
    println!("");
}


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

int main() {
	int d;
	cin >> d;
	if (d == 25)
		cout << "Christmas" << endl;
	if (d == 24)
		cout << "Christmas Eve" << endl;
	if (d == 23)
		cout << "Christmas Eve Eve" << endl;
	if (d == 22)
		cout << "Christmas Eve Eve Eve" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int s[2020]={},n,m,x[100],a[100];
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>x[i];
    s[x[i]]=1;
  }
  cin>>m;
  for(int i=0;i<m;++i){
    cin>>a[i];
    if(x[a[i]-1]!=2019){
      if(s[x[a[i]-1]+1]==0){
	s[x[a[i]-1]]=0; s[x[a[i]-1]+1]=1;
	x[a[i]-1]++;
      }
    }
  }
  for(int i=0;i<n;++i) cout<<x[i]<<endl;
  return 0;
}



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

#define int long long

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 2e5 + 5;

int n,i,x,y,t,mn;

signed main(){
    cin >> n;
    mn = mod;
    for(i=1;i<=n;i++){
        cin >> x >> y; 
        if(x > y) mn = min(mn , y);
        t += x;
    }
    
    cout << (mn == mod ? 0 : t - mn);
    return 0;
}

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

using namespace std;
string S;
int main(){

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

cin>>S;

int n=S.size();
int mxsize=(n/2)-1;
int ans=0;

for(int i=mxsize; i>=1; i--){
  int can=1;
  for(int j=0; j<i; j++){
    if(S[j]!=S[j+i]){
      can=0; break;
    }
  }
  if(can){
    ans=i*2; break;
  }
}

cout<<ans<<endl;

}



Measured memory_bytes: 256
n = gets.to_i
for i in 1..n do
	a,b,c = gets.chomp!.split(" ").map(&:to_i)
	if a < b then
		temp = a
		a = b
		b = temp
	end
	if a < c then
		temp = a
		a = c
		c = temp
	end
	if b < c then
		temp = b
		b = c
		c = temp
	end

	if (a ** 2) == ((b**2) + (c**2)) then
		puts "YES\n"
	else
		puts "NO\n"
	end
end

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

namespace AGC024_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int[] continuousCount = new int[n + 1];

            int maxContinuousLength = 1;

            for (int i = 0; i < n; ++i)
            {
                int number = int.Parse(Console.ReadLine());

                continuousCount[number] = continuousCount[number - 1] + 1;

                if (continuousCount[number] > maxContinuousLength)
                {
                    maxContinuousLength = continuousCount[number];
                }
            }

            int count = n - maxContinuousLength;
            Console.WriteLine("{0}", count);
        }
    }
}


Measured memory_bytes: 17756
import itertools

N, M, Q = map(int, input().split())

query = [list(map(int, input().split())) for _ in range(Q)]

L = [x+1 for x in range(M)]
L2 = []

p_tuple = itertools.combinations_with_replacement(L, N)

for i, p in enumerate(p_tuple):
    tmp = p[0]
    for pp in p:
        if pp < tmp:
            break
        else:
            tmp = pp
    else:
        L2.append(list(p))

ans = 0
for l2 in L2:
    tmpmax = 0
    for qq in query:
        if l2[qq[1]-1] - l2[qq[0]-1] == qq[2]:
            tmpmax += qq[3]
    ans = max(ans, tmpmax)

print(ans)


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

int main(){
  
  int n,m;
  cin >> n >> m;
  vector<bool> stairs(n,true);
  
  for(int i=0;i<m;i++){
    int a;
    cin >> a;
    stairs[a]=false;
  }
  
  vector<long long> ans(n+1,0);
  ans[0]=1;
  if(stairs[1]) ans[1]=1;
  
  for(int i=2;i<=n;i++){
    if(stairs[i]){
      ans[i]=(ans[i-1]+ans[i-2])%1000000007;
    }
    else{
      ans[i]=0;
    }
  }
  cout << ans[n] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>

int main(int argc, char const* argv[])
{
	int H, W;

	while(true) {
		std::cin >> H >> W;
		if (H == 0 && W ==0) break;
		for (int h = 0; h < H; h++) {
			for (int w = 0; w < W; w++) {
				if (h % 2 == 0) {
					if (w % 2 == 0) {
						std::cout << "#";
					} else {
						std::cout << ".";
					}
				} else {
					if (w % 2 == 0) {
						std::cout << ".";
					} else {
						std::cout << "#";
					}
				}
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
	return 0;
}            


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int m,n;

void solve(){
    int x=m;
    int cur=0;

    bool no[10000]={0};
    for(int i=1;i<=n;i++){
        while(no[cur])cur=(cur+1)%m;
        string s;
        cin>>s;
        if(x<=1)continue;

        bool ok=true;
        if(i%3==0&&i%5==0){
            if(s!="FizzBuzz")ok=false;
        }
        else if(i%3==0){
            if(s!="Fizz")ok=false;
        }
        else if(i%5==0){
            if(s!="Buzz")ok=false;
        }
        else{
            stringstream ss;
            string d;
            ss<<i;
            ss>>d;
            if(s!=d)ok=false;
        }
        if(!ok){
            no[cur]=true;
            x--;
        }
        cur=(cur+1)%m;
    }

    bool flag=false;
    for(int i=0;i<m;i++)if(!no[i]){
        if(flag)cout<<" ";
        else flag=true;
        cout<<i+1;
    }
    cout<<endl;
}

int main(){
    while(cin>>m>>n,m||n)solve();
    return 0;
}

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

using namespace std;

int main()
{
	int n;

	scanf("%d",&n);

		while(n--)
		{
			int a[3];
		
			scanf("%d %d %d",&a[0],&a[1],&a[2]);
			sort(a,a+3);

			if(a[2]*a[2]==a[0]*a[0]+a[1]*a[1])
				printf("YES\n");

			else
				printf("NO\n");
		}
	
}

Measured memory_bytes: 1184
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int N;
vi P;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin >> N) {
        vi rank(N);
        P = vi(N);
        rep(i, N) {
            cin >> P[i];
            --P[i];
            rank[P[i]] = i;
        }
        
        vi a(N), b(N);
        rep(i, N) {
            a[i] = 30000 * (i + 1) + rank[i];
            b[i] = 30000 * (N - i);
        }
        rep(i, N)cout << a[i] << (i != N - 1 ? ' ' : '\n');
        rep(i, N)cout << b[i] << (i != N - 1 ? ' ' : '\n');
    }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << endl
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>=0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
#define maxemt(v) *max_element(v.begin(), v.end())
#define minemt(v) *min_element(v.begin(), v.end())
#define lb(v,x) v[lower_bound(v.begin(), v.end(), x) - v.begin()]
#define ub(v,x) v[upper_bound(v.begin(), v.end(), x) - v.begin()]
template<class T> inline bool print(T& x){ cout << x << endl; return true; }
template<class T> inline bool print_(T& x){ cout << x << " "; return true; }
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; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
ll lcm(ll x, ll y){
  return x / gcd(x,y) * y;
}
const int INF = 1e9;
const ll llINF = 1LL<<60;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main(){
  int k, x; cin >> k >> x;
  if(500*k>=x) cout << "Yes";
  else cout << "No";
  
  
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        int i;
        Scanner sc= new Scanner(System.in);
        int n= sc.nextInt();
        int intarr[]=new int[n];
        for(i=0;i<n;i++){
            intarr[i]=sc.nextInt(); 
        }

        for(i=0;i<n;i++){
            System.out.printf("%d",intarr[n-1-i]);
            if(i!=n-1){
                System.out.printf(" ");
            }           
        }
        System.out.println();
        sc.close();
    }    
}


Measured memory_bytes: 26460
# -*- coding: utf-8 -*-
# input
N, M, C= map(int, input().split())
B = [int(a) for a in input().split()]
A = [[i] * M for i in range(N)]
for i in range(N):
    A[i] = [int(b) for b in input().split()]

cnt = 0
for i in range(N):
    ans = C
    for j in range(M):
        ans += A[i][j] * B[j]
    if ans > 0 :
        cnt += 1

print(cnt)


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

bool isMax(string t){
    int n = t.length();
    if(n==1) return true;
    for(int i=1; i<n; i++){
        if(t[i-1]<t[i]) return false;
    }
    return true;
}

string nxtStr(string t){
    char s = t[0];
    sort(t.begin(), t.end());
    int n = t.length();
    for(int i=0; i<n; i++){
        if(t[i]==s) return t.substr(i+1,1);
    }
}

int main(){
    string s;  cin >> s;
    if(s=="zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;
        return 0;
    }

    int n = s.length();
    if(n != 26){
        vector<int> alp(26);
        for(int i=0; i<n; i++){
            alp[s[i]-'a']++;
        }
        for(int i=0; i<26; i++){
            if(alp[i] == 0){
                s.push_back('a' + i);
                break;
            }
        }
    }else{
        for(int i=1; i<=n; i++){
            string suffix = s.substr(n-i,i);
            if(isMax(suffix)) continue;
            
            s.replace(n-i,i,nxtStr(suffix));
            break;
        }
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, a, b);
  if (b < 0) {
    print((b - a) % 2 ? "Positive" : "Negative");
    return;
  } else if (a <= 0 && b >= 0) {
    print("Zero");
  } else {
    print("Positive");
  }
}


Measured memory_bytes: 256
"""
author : halo2halo
date : 8, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A, B = map(int, readline().decode('utf8').split())

print(A * B if A <= 9 and B <= 9 else -1)


Measured memory_bytes: 3060
def func1(lst, value): return [i for i, x in enumerate(lst) if x == value]
def func2(coping, lst, coefficient=1):return sum(lst[i] * coefficient for i in coping)
lst = [input().split(' ') for i in range(int(input()))]
X = [float(i[0]) for i in lst]
Y = [i[1] for i in lst]
print(func2(func1(Y,"BTC"),X,380000.0) + func2(func1(Y,"JPY"),X))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define endl "\n" 
#define p pair<int, int>
#define arrinp(i, a, start, end); for(ll i = start; i <= end; i++) cin >> a[i];
#define arrout(i, a, start, end); for(ll i = start; i <= end; i++) cout << a[i] << " ";
#define swap(a, b) {a = a + b; b = a - b; a = a - b;
#define forfront(i, start, end) for(ll i = start; i <= end; i++)
#define forback(i, start, end) for(ll i = start; i >= end; i--)
#define out(x) cout << x << " "
#define outline(x) cout << x << endl;
int main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int value;
    int temp = 0;
    while (n--)
    {
        cin >> value;
        while(value%2 == 0)
        {
            temp++;
            value /= 2;
        }
    }
    cout << temp << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std; 
int main()
{
	string a;
	cin>>a;
	if(a=="hi"||a=="hihi"||a=="hihihi"||a=="hihihihi"||a=="hihihihihi")
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
} 

Measured memory_bytes: 256
import java.util.*;
import java.math.BigInteger; 
public class Main {

  public static void main(String[] args) { 
BigInteger max = BigInteger.valueOf(1_000_000_000_000_000_000L);
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      
      long[] arr = new long[n];
      for(int i = 0; i < n; i++) {
        arr[i] = sc.nextLong();
        if(arr[i] == 0) {
          System.out.println(0);
          return;
        }
      }
      BigInteger res = BigInteger.ONE;
      for(long num : arr) {
        res = res.multiply(BigInteger.valueOf(num));
        if(res.compareTo(max) > 0) {
          System.out.println(-1);
          return;
        }
      }
      System.out.println(res);
  }
}

Measured memory_bytes: 49980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const int INF=(int)2e9;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
const ll MOD=(ll)1e9+7;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define FOR(i,n) for(int i=0;i<n;i++)
#define MAX 100005
#define wa cout<<"wa"<<endl;

void base(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if (b<=c || d<=a){
		cout<<0<<endl;
	}else if (c<=a && b<=d){
		cout<<b-a<<endl;
	}else if (a<=c && d<=b ){
		cout<<d-c<<endl;
	}else if (a<=c && c<=b && b<=d) {
		cout<<b-c<<endl;
	}else if (c<=a && d<=b){
		cout<<d-a<<endl;
	}
	else if (a<=c && b<=d){
		cout<<b-c<<endl;
	}
		
	return 0;
}



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

int main()
{
    int H, W, x, y, count;
    cin >> H >> W;
    char list[H][W]={ };

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

    for (int i = 0; i < H;i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> list[i][j];
        }
    }

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            count = 0;
            if (list[i][j] == '#')
            {
                cout << '#';
                continue;
            }             
            
            for (int k = 0; k < 8; k++)
            {                   
                x = i + dy[k];
                y = j + dx[k];

                if (x >= 0 && x < H && y >= 0 && y < W && list[x][y] == '#')
                    count++;
            }
            cout << count;
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

struct edge {int to; double cost;};
struct node {int pos; double cost;};
bool operator < (const node &a, const node &b){
    return a.cost > b.cost;
}

vector<double> dijkstra(vector<vector<edge>> &G){
    vector<double> ret(G.size(), inf);
    priority_queue<node> pq;
    pq.push({0, 0});
    while (!pq.empty()) {
        node t = pq.top();
        pq.pop();
        
        if (ret[t.pos] == inf) ret[t.pos] = t.cost;
        else continue;
        
        for (edge e : G[t.pos]) {
            pq.push({e.to, t.cost + e.cost});
        }
    }
    return ret;
}

struct barrier {
    double x, y, r;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    double xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    int N;
    cin >> N;
    vector<barrier> B(N + 2);
    vector<vector<edge>> G(N + 2);
    rep(i, 1, N + 1){
        cin >> B[i].x >> B[i].y >> B[i].r;
    }
    B[0] = {xs, ys, 0};
    B[N + 1] = {xt, yt, 0};
    rep(i, N + 2) rep(j, i + 1, N + 2){
        barrier s = B[i], t = B[j];
        double d = sqrt((s.x - t.x) * (s.x - t.x) + (s.y - t.y) * (s.y - t.y));
        double dist;
        if(d <= s.r + t.r) dist = 0;
        else dist = d - s.r - t.r;
        G[i].pb({j, dist});
        G[j].pb({i, dist});
    }
    
    
    auto dijk = dijkstra(G);
    
    output(dijk[N + 1], 10);
    
    return 0;
}

Measured memory_bytes: 33036
A, V = map(int, input().rstrip().split())
B, W = map(int, input().rstrip().split())
T = int(input().rstrip())
d = abs(A - B)
v = V - W
if v <= 0:
    print('NO')
elif T < d / v:
    print('NO')
else:
    print('YES')


Measured memory_bytes: 9176
A,M = list(map(int,input().split()))
ans = 0
x = []
y = []
z = []
w = [0 for i in range(A)]
for i in range(A):
    a,b,c = list(map(int,input().split()))
    x.append(a)
    y.append(b)
    z.append(c)
for aa in [1,-1]:
    for bb in [1,-1]:
        for cc in [1,-1]:
            #print(a)
            #print(x)
            tx = [ aa * j for j in x]
            ty = [ bb * j for j in y]
            tz = [ cc * j for j in z]
            for j in range(A):
                w[j] = tx[j] + ty[j] + tz[j]
            tw = sum(sorted(w)[::-1][:M])
            if tw > ans:
                ans = tw
print(ans)





Measured memory_bytes: 3444
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

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

	sort(A.begin(), A.end());
	int ans = 0;
	for (int i = 0; i < N; i++) ans += (A[i].second & 1) ^ (i & 1);
	assert(ans % 2 == 0);
	cout << ans / 2 << "\n";

	return 0;
}

Measured memory_bytes: 1024
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n,m;
  cin >> n >> m;
  vector<int>a(100010);
  vector<int>w(100010);
  int sumac=0;
  int sumwa=0;

  rep(i,m){
    int p; cin >> p;
    string s; cin >> s;
    if(s =="WA") w.at(p)++;
    else{
      if(a.at(p) == 0 ){ 
        sumwa += w.at(p);
        sumac ++;
        w.at(p) = 0;
      }
      a.at(p)++;
    }
  }
  cout << sumac << " "<< sumwa << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main() {
  int n;
  cin>>n;
  vi p(n);
  rep(i,n) cin>>p[i];
  int ans=0;
  rep(i,n){
    if(p[i]-1==i){
      ans++;
      i++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3768
n = gets.to_i
a = gets.chomp.split.map(&:to_i)
q = gets.to_i
m = gets.chomp.split.map(&:to_i)
sum_list = {}

1.upto(n) do |i|
  a.combination(i).each { |c| sum_list[c.inject(&:+)] = true }
end

m.each do |key|
  puts (sum_list.has_key?(key) ? "yes" : "no")
end

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

struct Point{
  int next;
  struct Point *P,*L,*R;
};

struct Point *squrt,*setsu;
void inorder(struct Point *st);
void preorder (struct Point *st);
void insert (int a);
int main()
{
  int i,n,p;
  char hi[10];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",hi);

    if(hi[0]=='i'){        //*insert*//
      scanf("%d",&p);
      insert(p);
    }else if(hi[0]=='p'){   //*print*//
      inorder(squrt);
      printf("\n");
      preorder(squrt);
      printf("\n");
    }
  }
  return 0;
}

void inorder(struct Point *st){
  if(st==setsu)
    return;
  inorder(st->L);
  printf(" %d",st->next);
  inorder(st->R);
  
}

void preorder(struct Point *st){
  if(st==setsu)
    return;
  printf(" %d",st->next);
  preorder(st->L);
  preorder(st->R);

}

void insert (int a){
  struct Point *x=squrt;
  struct Point *y=setsu;
  struct Point *z;

  z=(struct Point *)malloc(sizeof(struct Point));
  z->next=a;
  z->L=setsu;
  z->R=setsu;

  while(x!=setsu){
    y=x;
    if(x->next > z->next){
      x=x->L;
    }else
      x=x->R;
    
  }

  z->P=y;
  if(y==setsu){
    squrt=z;
  }else{
    if(y->next > z->next){
      y->L=z;
    }else
      y->R=z;
    
  }
}
  
  
    



Measured memory_bytes: 25212
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = 0
b = 0
a_time = 0
b_time = 0
max_read = 0

for i in range(m):
    if b_time + B[i] > k:
        break
    else:
        b_time += B[i]
else:
    i += 1
b = i
max_read = b

for i in range(n):
    if a_time + A[i] > k:
        break
    
    a_time += A[i]
    a += 1
    if a_time + b_time <= k:
        max_read = max(max_read, a + b)
        continue
    else:
        while(a_time + b_time > k):
            b -= 1
            if b < 0:
                break
            b_time -= B[b]
        max_read = max(max_read, a + b)

print(max_read)

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,d,a; cin >> n >> d >> a;
  vector<P<int,int>> v(n);
  for(int i = 0; i < n; ++i)cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end());
  vector<int> x(n),h(n);
  for(int i = 0; i < n; ++i)tie(x[i],h[i]) = v[i];
  ll total = 0;
  ll ans = 0;
  vector<ll> hp(n+1);
  for(int i = 0; i < n; ++i){
    total -= hp[i];
    h[i] -= total;
    ChangeMax(h[i],0);
    ll c = (h[i]+a-1)/a;
    ans += c;
    total += c*a;
    int pos = upper_bound(x.begin(), x.end(), x[i]+2*d)-x.begin();
    hp[pos] += c*a;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992