akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a,b;
  cin>>a>>b;
  
  if(a-b>0) cout<<a+a-1<<endl;
  else if(b-a>0) cout<<b+b-1<<endl;
  else cout<<a+b<<endl;
  
  return 0;
}

Measured memory_bytes: 3600
arraylen = int(input())
sequence = list(map(int, input().split()))
mulTwoCount = 0
mulFourCount = 0
otherCount = 0
for i in range(arraylen):
  if sequence[i] % 4 == 0:
    mulFourCount += 1
  elif sequence[i] % 2 == 0:
    mulTwoCount += 1
  else:
    otherCount += 1
if mulFourCount + 1 == otherCount and mulTwoCount == 0:
  ans = "Yes"
elif mulFourCount < otherCount:
  ans = "No"
else:
  ans = "Yes"
print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <math.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
using namespace std;
#define rep(I,N) for(int I = 0; I < (int)(N); I++)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int N, M, p;
int ans = 1000000;
vector<int> v;

int main(void){
	cin >> N >> M >> p;
	rep(i, M){
		int a;
		cin >> a;
		//??????????????¶??????????????¢
		a = (N+a-p)%N;
		v.push_back(a);
	}
	//?????????
	sort(v.begin(), v.end());
	rep(i, M){
		//??????????????????
		if(i == 0){
			ans = min(ans, N-v[i]);
		}else{
		//???????????§?????£????????????????¬?????????????????????§????¶????
			ans = min(ans, 2*(N-v[i]) + v[i-1]);
		}
		//??????????????????
		if(i == M-1){
			ans = min(ans, v[i]);
		}else{
		//
			ans = min(ans, 2*v[i] + (N-(v[i+1])));
		}
	}
	cout << ans*100 << endl;

	return 0;	
}

Measured memory_bytes: 1324
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>

#define Lens 500010

using namespace std;
struct Node
{
	int key;
	Node *p, *l, *r;
};

int N;
char A[10];
Node *root, *Nil;

void Preorder(Node *i)
{
	if (i == Nil)
		return;
	cout << ' ' << i->key;
	Preorder(i->l);
	Preorder(i->r);
}

void Inorder(Node *i)
{
	if (i == Nil)
		return;
	Inorder(i->l);
	cout << ' ' << i->key;
	Inorder(i->r);
}

void insert(int i)
{
	Node *x, *y, *z;
	x = root;
	y = Nil;
	z = (Node*)malloc(sizeof(Node));
	z->key = i;
	z->l = z->p = z->r = Nil;
	while (x != Nil)
	{
		y = x;
		if (z->key < x->key)
		{
			x = x->l;
		}
		else
		{
			x = x->r;
		}
	}
	if (y == Nil)
	{
		root = z;
	}
	else
	{
		z->p = y;
		if (z->key < y->key)
			y->l = z;
		else
			y->r = z;
	}
}

void Print()
{
	Inorder(root);
	cout << endl;
	Preorder(root);
	cout << endl;
}

int main()
{
	int k;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A;
		if (A[0] == 'i')
		{
			cin >> k;
			insert(k);
		}

		else if (A[0] == 'p')
			Print();
	}
	return 0;
}


Measured memory_bytes: 26524
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(c>=a+b&&4*a*b<(c-a-b)*(c-a-b)?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {

	lld n; cin >> n;
	vector<lld> arr(n + 1);
	for4 (i, 1ll, n + 1ll, 1ll) {
		lld temp; cin >> temp;
		arr[i] = temp;
	}

	lld cnt = 1ll, j = 1ll;
	for4(i, 1ll, n + 2ll, 1ll) {
		if (arr[j] == 2) break;
		cnt++;
		j = arr[j];
	}

	cout << ((cnt == n + 2ll) ? -1 : cnt);


	return;
}


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

	lld T3X0 = 0, T353 = 1;

	// TESTCASES()
	solveEachTest(T353 - T3X0);
	return 0;
}
// Random Thought :  null

Measured memory_bytes: 3992
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define N 200010
ll fac[N],inv[N],ivf[N];
ll c(ll n,ll k){
    return fac[n]*ivf[n-k]%mod*ivf[k]%mod;
}
int main(){
  fac[0]=ivf[0]=inv[1]=1;
  for(int i=1;i<N;i++){
      if(i>1)inv[i]=(mod-mod/i*inv[mod%i]%mod)%mod;
      fac[i]=fac[i-1]*i%mod;
      ivf[i]=ivf[i-1]*inv[i]%mod;
  }
  ll n,m,k;cin>>n>>m>>k;
  ll ans=0;
  for(int d=1;d<m;d++){
      mad(ans,(m-d)*n*n*d);
  }
  for(int d=1;d<n;d++){
      mad(ans,(n-d)*m*m*d);
  }
  ans=ans*c(n*m-2,k-2)%mod;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>

int main(){
    double five = 0, ten = 0;
    while (scanf("%lf %lf", &five, &ten)!=EOF){
        
        if(five < 35.50 && ten < 71.00){
            printf("AAA\n");
        }
        else if (five < 37.50 && ten < 77.00){
            printf("AA\n");
        }
        else if (five < 40.00 && ten < 83.00){
            printf("A\n");
        }
        else if (five < 43.00 && ten < 89.00){
            printf("B\n");
        }
        else if (five < 50.00 && ten < 105.00){
            printf("C\n");
        }
        else if (five < 55.00 && ten < 116.00){
            printf("D\n");
        }
        else if (five < 70.00 && ten < 148.00){
            printf("E\n");
        }
        else{
            printf("NA\n");
        }
    }
    return (0);
}

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

#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

int main() {
	string S;
	cin>>S;
	int ans=0;
	rep(i,4)if(S[i]=='+')ans++;else ans--;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import collections

d = collections.deque()
for i in input():
    d.append(i)
q = int(input())
is_head = True

for _ in range(q):
    tmp = input().split(" ")
    if (len(tmp) == 1):
        is_head = not is_head
    else:
        t, f, c = tmp
        if (f == '1'):
            if (is_head):
                d.appendleft(c)
            else:
                d.append(c)
        else:
            if (is_head):
                d.append(c)
            else:
                d.appendleft(c)

ans = ""
if is_head:
    while len(d) > 0:
        ans += d.popleft()
else:
    while len(d) > 0:
        ans += d.pop()
print(ans)

Measured memory_bytes: 6284
//A - Not
//Hiia
#include <stdio.h>
#include <stdlib.h>//rannsuu, zettaichi(absolute)
#include <time.h>
//srand((unsigned int) time(0));
#include <math.h>//koudona keisann
#include <string.h>//hairetsu
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
typedef long long ll;
//#define N 998244353
#define pi 3.1415926535897932384626433832

int gcd(int m,int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
int lcm(int m,int n){if((0==m)||(0==n))return 0;return(m*n/gcd(m, n));}
int fact(int x){if(x==1) return(x);else return(x*fact(x-1));}//Kaijou x!
int ruijou(int base,int exponent){int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

long long int llgcd(long long int m,long long int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
long long int lllcm(long long int m,long long int n){if((0==m)||(0==n))return 0;return(m*n/llgcd(m, n));}
long long int llfact(long long int x){if(x==1) return(x);else return(x*llfact(x-1));}//Kaijou
int llruijou(long long int base,long long int exponent){long long int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

int main()
{
  int n;
  scanf("%d", &n);
  printf("%d\n", abs(n-1));

  return 0;
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

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;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	deque<int> v(n);
	rep(i,n){
		cin>>v[i];
	}
	int ans=0;
	FOR(i,0,n+1)FOR(j,0,n+1){//左からi個,右からj個
		if(i+j>k) continue;
		priority_queue<int,vector<int>,greater<int>> que;
		deque<int> now(v);
		rep(l,i){
			if(now.empty()) break;
			que.push(now.front());
			now.pop_front();
		}
		rep(l,j){
			if(now.empty()) break;
			que.push(now.back());
			now.pop_back();
		}
		int ret=k-(i+j),cnt=0;
		while(ret--){
			if(que.empty()) break;
			if(que.top()<0){
				que.pop();
			}
		}
		while(!que.empty()){
			cnt+=que.top();
			que.pop();
		}
		chmax(ans,cnt);
	}
	cout<<ans<<endl;
}

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

using Matrix = vector<vector<int64_t>>;
constexpr int mod = 1e9 + 7;

inline Matrix make_matrix(int n) {
    return vector<vector<int64_t>>(n, vector<int64_t>(n));
}

Matrix operator*(const Matrix& a, const Matrix& b) {
    int n = a.size();
    Matrix res = make_matrix(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                res[i][k] += a[i][j] * b[j][k];
                if (res[i][k] >= 8LL * mod * mod)
                    res[i][k] %= mod;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            res[i][j] %= mod;
        }
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n;
    int64_t k;
    cin >> n >> k;
    Matrix x = make_matrix(n);
    Matrix y = make_matrix(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> y[i][j];
        }
        x[i][i] = 1;
    }
    // binary exponentation on matrix
    while (k) {
        if (k & 1) x = x * y;
        y = y * y;
        k >>= 1;
    }
    int64_t ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ans += x[i][j];
        }
    }
    cout << ans % mod << '\n';
    return 0;
}

Measured memory_bytes: 3688
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <atcoder/all>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

using namespace atcoder;

int main(){
    ll n,q;
    cin >> n >> q;
    dsu ds=dsu(n);
    rep(i,q){
        ll t,u,v;
        cin >> t >> u >> v;
        if(t==0){
            ds.merge(u,v);
        }
        else{
            if(ds.same(u,v)){
                cout << 1 << endl;
            }
            else{
                cout << 0 << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3924
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する
class UnionFind {
    vector<int> p;//p[i]はiの属する組織
public:
    UnionFind(int n){
        p = vector<int>(n);
        for(int i = 0; i < n; i++){
            p[i] = i;
        }
        return;
    }

    void printState() {
        if (DEBUG) {
            cout << "---" << endl;
            for (int i = 0; i < p.size(); i++) {
                printf("%dの親は%d\n", i, p[i]);
            }
            cout << "---" << endl;
        }
    }

/* xの属する集合を返す */
    int find(int x) {
        if (p[x] == x) return x;
        return p[x] = find(p[x]);
    }

/* yにxを統合する */
    void unite(int x, int y) {
        p[find(x)] = p[find(y)];
    }

/* xとyが属する集合が同じかを判定する */
    bool same(int x, int y) {
        return find(x) == find(y);
    }

};

int main() {
    int N,M;
    cin >> N >> M;
    UnionFind u(N);
    vector<set<int> > st(M+1);
    REP(i,0,N){
        int K;
        cin >> K;
        REP(j,0,K){
            int l;
            cin >> l;
            st[l].insert(i);
        }
    }

    REP(i,1,M+1){
        int moto = *st[i].begin();
        for (auto wrap_iter = st[i].begin(); wrap_iter != st[i].end(); ++wrap_iter) {
            u.unite(moto,*wrap_iter);
        }
    }

    REP(i,0,N-1){
        if(!u.same(i,i+1)){
            cout << "NO" << endl;
            return 0;
        }
    }

//    u.unite(0,1);
//    u.unite(0,2);
//    u.unite(3,4);
//    u.unite(3,5);
//    u.unite(0,3);


    cout << "YES" << endl;
    return 0;
}


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

int main(){
  
  int N,W;
  cin >>N>>W;
  vector<int> w(N),v(N);
  for(int i=0;i<N;i++){
    int x,y;
    cin >>x>>y;
    w[i] = x;
    v[i] = y;
  }
  
  vector<vector<long long>> dp(N+1,vector<long long>(W+1,0));
  
  for(int i=1;i<N+1;i++){
    for(int j=1;j<W+1;j++){
      long long res1 = dp[i-1][j]; //①直前の品物までの最善手
      long long res2 = 0; //②初期値
      if (j>=w[i-1]) res2 = dp[i-1][j-w[i-1]]+v[i-1];
      //②重さに余裕があれば、「その品物を入れる前までの最善手」にプラス
      dp[i][j] = max(res1,res2); //①と②を比較した本当の最善手
    }
  }
  
  //for(int i=0;i<N+1;i++){
  //  for(int j=0;j<sum+1;j++){
  //    cout << dp[i][j] << " ";
  //  }
  //  cout << endl;
  //}
  
  cout << dp[N][W] << endl;
}

Measured memory_bytes: 80256
N,K = map(int,input().split())
#N,K = map(int,'10 998244353'.split())
#N,K = map(int,'10 2'.split())
Alist = list(map(int,input().split()))
#Alist = list(map(int,'10 9 8 7 5 6 3 4 2 1'.split()))
beforeTnumber = [0]*N
afterTnumber = [0]*N
beforesum = 0
aftersum = 0
mod_num = 10**9+7

for now in range(N):
    for before in range(now):
        if Alist[before] < Alist[now]:
            beforeTnumber[now] += 1
    for after in range(now,N):
        if Alist[after] < Alist[now]:
            afterTnumber[now] += 1
            
beforesum = sum(beforeTnumber)
aftersum = sum(afterTnumber)

Kaftersum = ((K*(K+1))//2)%mod_num
Kbeforesum = ((K*(K-1))//2)%mod_num

print(int(((aftersum)*(Kaftersum)+(beforesum*Kbeforesum))%mod_num))

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w, d; cin >> h >> w >> d;
    const string str = "RYGB";
    auto floor = [&](int x, int y) {
        if (x % y == 0) return x / y;
        if (x > 0) return x / y;
        else return x / y - 1;
    };
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int s = floor(i + j, d), t = floor(i - j, d);
            int x = ((abs(s) % 2) << 1) + (abs(t) % 2);
            cout << str[x];
        }
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 512
import numpy as np

N = int(input())
n_list = list(map(int, input().split()))

M = np.max(n_list)
mid_M = M / 2
ex_M_list = list(n_list)
ex_M_list.remove(M)

best_k_cand = list(abs(ex_M_list - mid_M))
best_k = min(best_k_cand)
a = best_k_cand.index(best_k)

print(M, ex_M_list[a])


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

int main() {
  long long X,K,D;
  cin>>X>>K>>D;
  long long a=abs(X/D),ans;
  
  if(K<=a){
    ans=abs(abs(X)-K*D);
  }
  else{
    if((K-a)%2==0){
      ans=abs(X)%D;
    }
    else{
      ans=min(abs(abs(X)%D+D),abs(abs(X)%D-D));
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string.h>
#include <vector>
#include <tuple>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define PB push_back
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef tuple<int, int, int> tupiii;


// 1-indexed 1-d BIT
template <class Cls>
struct BIT {
private:
	vector<Cls> bit;
	int n;

public:
	// constructors
	BIT(int n);
	BIT();

	// initializer
	void init(int n);

	// 1-indexed
	void add(int idx, Cls val);

	// sum for [1, idx] (1-indexed)
	Cls sum(int idx);

	// sum for [left, right) (1-indexed)
	Cls sum(int left, int right);
};


class D {
	int n, m, q;
	BIT<int> bit;
	vector<tupiii> queries;
	vector<int> ans;

public:
	D()
	{
		cin >> n >> m >> q;
		queries.reserve(n + m);
		ans.resize(q + 1);
		bit.init(n);

		int l, r;
		REP(i, m)
		{
			cin >> l >> r;
			queries.PB(make_tuple(l, r, 0));
		}

		REP(i, q)
		{
			cin >> l >> r;
			queries.PB(make_tuple(l, r, i + 1));
		}
	}

	void solve()
	{
		sort(ALL(queries), [](tupiii left, tupiii right) { return (get<1>(left) != get<1>(right)) ? (get<1>(left) < get<1>(right)) : (get<2>(left) < get<2>(right)); });
		
		//cout << "print queries" << endl;
		//REP(i, (int)queries.size())
		//	cout << get<0>(queries[i]) << " " << get<1>(queries[i]) << " " << get<2>(queries[i]) << endl;
		//cout << "END print queries" << endl << endl;

		REP(i, m + q)
		{
			int left{ get<0>(queries[i]) };
			int right{ get<1>(queries[i]) };
			int question{ get<2>(queries[i]) };

			if (question)
			{
				ans[question] = bit.sum(left, right + 1);
			}
			else
			{
				bit.add(left, 1);
			}
		}

		for (int i{ 1 }; i <= q; i++)
			cout << ans[i] << endl;
	}
};

int main()
{
	D solution;
	solution.solve();

	return 0;
}

////////// 1-d BIT implementation //////////

// constructor
template <class Cls>
BIT<Cls>::BIT()
	: BIT(0)
{}

template <class Cls>
BIT<Cls>::BIT(int n)
	: bit(n + 1, 0), n{n}
{}

// initializer
template <class Cls>
void BIT<Cls>::init(int n)
{
	bit.resize(n + 1, 0);
	this->n = n;
}

// 1-indexed
template <class Cls>
void BIT<Cls>::add(int idx, Cls val)
{
	for (int i{ idx }; i <= n; i += i & (-i))
		bit[i] += val;
}

// sum for [1, idx] (1-indexed)
template <class Cls>
Cls BIT<Cls>::sum(int idx)
{
	int ret{ 0 };
	for (int i{ idx }; i > 0; i -= i & (-i))
		ret += bit[i];

	return ret;
}


// sum for [left, right) (1-indexed)
template <class Cls>
Cls BIT<Cls>::sum(int left, int right)
{
	return sum(right - 1) - sum(left - 1);
}


////////// END of 1-d BIT implementation //////////


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

using namespace std;

int g1[81][81];
int g2[81][81];
bool dp[81][81][7000];


int main() {
	int H, W;
	cin>>H>>W;
	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			cin>>g1[i][j];
		}
	}
	
	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			cin>>g2[i][j];
		}
	}
	
	dp[0][0][abs(g1[0][0] - g2[0][0])] = true;

	for (int i = 0;i < H;++i) {
		for (int j = 0;j < W;++j) {
			for (int k = 0;k <= 6400;++k) {
				if (dp[i][j][k]) {
					dp[i][j+1][abs(k - abs(g1[i][j+1] - g2[i][j+1]))] = true;
					dp[i][j+1][abs(k + abs(g1[i][j+1] - g2[i][j+1]))] = true;
					dp[i+1][j][abs(k - abs(g1[i+1][j] - g2[i+1][j]))] = true;
					dp[i+1][j][abs(k + abs(g1[i+1][j] - g2[i+1][j]))] = true;
				}
			}
		}
	}
	
	for (int i = 0;i <= 6400;++i) {
		if (dp[H-1][W-1][i]) {
			cout<<i<<endl;
			break;
		}
	}
	
	return 0;
}


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

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

    int max = 0;
    int ans = 0;
    int prev = 0;

    for (int i = 1; i <= N; ++i) {
        int h;
        cin >> h;

        if (prev >= h) {
            ++ans;
            if (max < ans) max = ans;
        }
        else {
            ans = 0;
        }

        prev = h;
    }

    cout << max << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        boolean [] primes = new boolean[1000000];
        for (int n = 0; n < 1000000; n++) {
            primes[n] = true;
        }
        primes[0] = false;
        primes[1] = false;

        for (int n = 0; n < 1000000; n++) {
            if (primes[n]) {
                for (int k = 2*n; k < 1000000; k+=n) {
                    primes[k] = false;
                }
            }
        }

        while (sc.hasNext()) {
            int n = sc.nextInt();
            int result = 0;
            for (int k = 0; k <= n; k++) {
                if (primes[k]) result += 1;
            }
            System.out.println(result);
        }

    }
}

Measured memory_bytes: 13000
package main

import "fmt"

func main() {
	var n string
	fmt.Scan(&n)
	a := n[len(n)-1:]
	var ans string
	if a == "0" || a == "1" || a == "6" || a == "8" {
		ans = "pon"
	} else if a == "3" {
		ans = "bon"
	} else {
		ans = "hon"
	}
	fmt.Println(ans)

}


Measured memory_bytes: 1752
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int N,K;cin>>N>>K;
    int h[100010],ans=0;
    for(int i=0;i<N;i++){
        cin>>h[i];
        if(h[i]>=K)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define MOD 1000000007
#define mp make_pair
#define ll long long
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug cout<<"Debugging.."<<endl
using namespace std;
int main()
{
	faster;

	string s;
	cin>>s;
	int n=s.length()-1;
	if(s[n]=='s')
	s+="es";
	else
	s+='s';
	
	cout<<s<<endl;
}




Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,X,T;
  cin >> N >> X >> T;
  int ans=0,count=0;
  bool a=true;
  while(a){
    count+=X;
    ans+=T;
    if(count>=N) a=false;
  }
  cout << ans << endl;
}

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

const int m = 1e6, M = 1e9+7;
ll inverse[3*m], fact[3*m], invfact[3*m];

ll nCr(ll n, ll r){
    ll ans = fact[n]*invfact[r]%M;
    return (ans*invfact[n-r]%M); 
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    //good luck, kittu

    inverse[1] = 1;
    for(ll i = 2; i<3*m; i++) inverse[i] = M - M/i * inverse[M%i]%M;
    fact[0] = invfact[0] = 1;
    for(ll i = 1; i<3*m; i++){
        fact[i] = fact[i-1]*i%M;
        invfact[i] = invfact[i-1]*inverse[i]%M;
    }

    ll x, y; cin>>x>>y;
    if((x+y)%3!=0) return cout<<"0\n", 0;

    ll n = (2*y - x)/3, m = (2*x - y)/3;
    if(n<0 || m<0) return cout<<"0\n", 0;

    ll ans = nCr(n+m, n);
    ans %= M;
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int a[2][N];
  for(int i=0; i<N; i++){
    cin >> a[0][i];
  }
  for(int i=0; i<N; i++){
    cin >> a[1][i];
  }
  int sum;
  int ma = 0;
  for(int i=0; i<N; i++){
    sum = 0;
    for(int j=0; j<N; j++){
      if(i==j){
        sum += a[0][j] + a[1][j];
      }
      if(i > j){
        sum += a[0][j];
      }
      if(i < j){
        sum += a[1][j];
      }
    }
    ma = max(ma,sum);
  }
  cout << ma << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int N, W;
    int w[110], v[110];
    int i, j ,k;
    long long int dp[110][110000];
    long long int dp1;
    long long int ans = 0;

    for(i=0; i<110; i++){
        for(j=0; j<110000; j++){
            dp[i][j] = 1000000000000000000;
        }
    }

    scanf("%d %d", &N, &W);
    for(i=0; i<N; i++){
        scanf("%d %d", &w[i], &v[i]);
    }

    dp[0][0] = 0;

    for(i=0; i<N; i++){
        for(j=0; j<110000; j++){
            if(j - v[i] >= 0){
                dp1 = dp[i][j-v[i]] + w[i];
                if(dp[i+1][j] > dp1){
                    dp[i+1][j] = dp1;
                }
            }
            if(dp[i+1][j] > dp[i][j]){
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    for(j=0; j<110000; j++){
        if(dp[N][j] <= W){
            ans = j;
        }
    }

    printf("%ld", ans);
    
    return 0;
}

Measured memory_bytes: 94720
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val s = sc.nextLine()
    val countR = Array(n + 1) { 0 }
    val countG = Array(n + 1) { 0 }
    val countB = Array(n + 1) { 0 }
    for (i in n - 1 downTo 0) {
        countR[i] = countR[i + 1]
        countG[i] = countG[i + 1]
        countB[i] = countB[i + 1]
        if (s[i] == 'R') {
            countR[i]++
        } else if (s[i] == 'G') {
            countG[i]++
        } else {
            countB[i]++
        }
    }
    var sum = 0L
    for (i in 0 until n) {
        for (j in i + 1 until n) {
            val k = j + 1
            val ng = 2 * j - i
            if (k >= n) break
            if (s[i] == s[j]) continue

            if (s[i] != 'R' && s[j] != 'R') {
                sum += countR[k]
                if (ng < n && s[ng] == 'R') sum--
            } else if (s[i] != 'G' && s[j] != 'G') {
                sum += countG[k]
                if (ng < n && s[ng] == 'G') sum--
            } else {
                sum += countB[k]
                if (ng < n && s[ng] == 'B') sum--
            }
        }
    }
    println(sum)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 37024
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<climits>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int A,B,T;
    cin>>A>>B>>T;
    
    cout<<T/A*B<<endl;
}


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

int main() {
  string s,t;
  cin >> s >> t;
  int ans = 0;
  rep(i,s.size()) {
    if (s.substr(i,1) != t.substr(i,1)) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3868
require 'pp'

h, w = gets.chomp!.split(" ").map(&:to_i)
s = [['.'] * (w + 2)]
h.times do |i|
    x = ['.'] + gets.chomp!.chars + ['.']
    s << x
end
s << ['.'] * (w + 2)

1.upto(h) do |i|
    1.upto(w) do |j|
        if s[i][j] == '#' && s[i-1][j] == '.' && s[i][j-1] == '.' && s[i+1][j] == "."  && s[i][j+1] == "."
            puts "No" 
            exit 0
        end
    end
end

puts "Yes"


Measured memory_bytes: 2428
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll x, ll y){return x / gcd(x, y) * y % MOD;};

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(N * A, B) << endl;


























}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int P[100000];
int inv[100000];
int main(){
  int KL2GvlyY, Q5VJL1cS, i, k, lef1, lef2, rig1, rig2;
  long long res;
  multiset<int> s;
  multiset<int>::iterator it1, it2;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(P[Lj4PdHRW]);P[Lj4PdHRW] += (-1);
    }
  }
  for(i=0;i<(N);i++){
    inv[P[i]] = i;
  }
  for(KL2GvlyY=0;KL2GvlyY<(2);KL2GvlyY++){
    s.insert(-1);
  }
  for(Q5VJL1cS=0;Q5VJL1cS<(2);Q5VJL1cS++){
    s.insert(N);
  }
  res = 0;
  for(k=N-1;k>=0;k--){
    i = inv[k];
    s.insert(i);
    it1 = it2 = s.lower_bound(i);
    lef1 = *(--it1);
    lef2 = *(--it1);
    rig1 = *(++it2);
    rig2 = *(++it2);
    res += (long long) (k+1) * (lef1-lef2) * (rig1 - i);
    res += (long long) (k+1) * (rig2-rig1) * (i - lef1);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190902-1

// --- original code ---
// int N, P[1d5];
// 
// int inv[1d5];
// {
//   int i, k;
//   int lef1, lef2, rig1, rig2;
//   multiset<int> s;
//   multiset<int>::iterator it1, it2;
//   ll res;
//   
//   rd(N,(P--)(N));
//   rep(i,N) inv[P[i]] = i;
// 
//   rep(2) s.insert(-1);
//   rep(2) s.insert(N);
// 
//   res = 0;
//   for(k=N-1;k>=0;k--){
//     i = inv[k];
//     s.insert(i);
//     it1 = it2 = s.lower_bound(i);
//     lef1 = *(--it1);
//     lef2 = *(--it1);
//     rig1 = *(++it2);
//     rig2 = *(++it2);
// 
//     res += (ll) (k+1) * (lef1-lef2) * (rig1 - i);
//     res += (ll) (k+1) * (rig2-rig1) * (i - lef1);
//   }
// 
//   wt(res);
// }


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;
  cin>>x;
  if(x<1200) cout<<"ABC";
  else cout<<"ARC";
}

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

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  int sec = H * 3600 + M * 60;

  double x_h, y_h, x_m, y_m;
  double rad_h = M_PI / 2.0 - (sec % (3600 * 12)) / (3600. * 12.) * 2 * M_PI;
  double rad_m = M_PI / 2.0 - (sec % 3600) / 3600. * 2 * M_PI;
  x_h = A * cos(rad_h);
  y_h = A * sin(rad_h);
  x_m = B * cos(rad_m);
  y_m = B * sin(rad_m);

  cout << setprecision(10)
       << sqrt((x_h - x_m) * (x_h - x_m) + (y_h - y_m) * (y_h - y_m)) << endl;
}


Measured memory_bytes: 4128
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main() {

  int64_t N;
  cin >> N;

  string str;
  cin >> str;


  int64_t x = 0, max = 0;
  for(int64_t i=0;i<N;i++) {
    if(str[i] == 'I')
      x++;
    else
      x--;
    if(x > max)
      max = x;
  }

  cout << max << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

// 最終的に1つを除き全てのりんごが1個ずつで戻ってきてほしい
// 1個減らした状態で全て取りきれば良い
// 全て取りきるためには, 相手に1個残した状態で渡したい
// 相手は1つ取らなければならないので, 複数の山に

// 11000011010100000
// 00111010100110000
// 00100111000100000
// 11111101100010000

// 10
// 01
signed main() {
  INIT;
  VAR(int,n);
  VEC(int,a,n);
  bool ok = false;
  REP(i,n) {
    ok |= (a[i]%2==1);
  }
  OUT(ok?"first":"second")BR;
  
  return 0;
}


Measured memory_bytes: 1152
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N, K = MAP()
    A = LIST()
    count = 0
    if K % 2 == 0:
        tmp1 = int(K / 2)
        tmp2 = K - 1
    else:
        tmp1 = K
        tmp2 = int((K - 1) / 2)
    for i in range(N):
        count_all = 0
        count_ = 0
        for j in range(N):
            if A[i] > A[j]:
                count_all += 1
                if i < j:
                    count_ += 1
        count += count_ * K % mod
        count += (((tmp1 * tmp2) % mod) * count_all) % mod
        count = count % mod
        # import pdb; pdb.set_trace()
    print(int(count) % mod)

if __name__ == '__main__':
    main()


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

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

        if (i % 2 == 0 && a[i] % 2 != 0) {

            count += 1;
        }


    }
    cout << count;
    return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <queue>
#include <algorithm>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, int> Q;
typedef pair<P, int> R;

const ll inf = 5e10;

struct E{
	E(int t, int c): t(t), c(c){}
	int t, c;
};

int n, m, k;
vector<E> g[2 * 200000 + 2];
ll d[2 * 200000 + 2];

void add_edge(int i, int j, int c){
	g[i].push_back(E(j, c));
	g[j].push_back(E(i, c));
}

int main(){
	scanf("%d%d%d", &n, &m, &k);
	
	vector<R> s, t;
	rep(i, k){
		int x, y;
		scanf("%d%d", &x, &y);
		--x;
		--y;
		s.push_back(R(P(x, y), i));
		t.push_back(R(P(y, x), i + k));
	}

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());

	rep(i, k - 1){
		if(s[i].first.first == s[i + 1].first.first){
			add_edge(s[i].second, s[i + 1].second, s[i + 1].first.second - s[i].first.second);
		}
		if(t[i].first.first == t[i + 1].first.first){
			add_edge(t[i].second, t[i + 1].second, t[i + 1].first.second - t[i].first.second);
		}
	}
	rep(i, k){
		add_edge(i, k + i, 1);
	}
	if(s[0].first.first == 0){
		add_edge(2 * k, s[0].second, s[0].first.second);
	}
	if(s.back().first.first == n - 1){
		add_edge(2 * k + 1, s.back().second, m - s.back().first.second - 1);
	}
	if(t.back().first.first == m - 1){
		add_edge(2 * k + 1, t.back().second, n - t.back().first.second - 1);
	}

	fill_n(d, 2 * k + 2, inf);

	priority_queue<Q, vector<Q>, greater<Q> > q;
	d[2 * k] = 0;
	q.push(Q(0, 2 * k));
	while(!q.empty()){
		Q v = q.top();
		q.pop();
		if(v.first > d[v.second]){
			continue;
		}
		rep(i, g[v.second].size()){
			E e = g[v.second][i];
			if(d[e.t] > v.first + e.c){
				d[e.t] = v.first + e.c;
				q.push(Q(d[e.t], e.t));
			}
		}
	}

	/*
	rep(i, 2 * k + 2){
		printf("%lld\n", d[i]);
	}
	*/

	printf("%lld\n", d[k * 2 + 1] != inf ? d[2 * k + 1] : -1);
	return 0;
}

Measured memory_bytes: 41216
#include<stdio.h>
    #include<stdlib.h>
    int main(void){
    int N,M,i;
    int *a,*b;
    int no = 0;
    scanf("%d %d",&N,&M);
    a = (int *)malloc(N*sizeof(int)) ;
    b = (int *)malloc(N*sizeof(int)) ;
    int tmpa,tmpb;
    for(i=0;i<M;i++){
    scanf("%d %d",&tmpa,&tmpb);
    if(tmpa==1)a[tmpb]=1;
    if(tmpb==N)b[tmpa]=1;
    }
    for(i=0;i<N;i++){
    if(a[i]==1 && b[i]==1){
    no = 1;
    }
    }
    if(no == 1) printf("POSSIBLE");
    if(no == 0) printf("IMPOSSIBLE");
    return 0;
    }

Measured memory_bytes: 1792
/*
 * atcoder/abc130/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int a, b, c;
void input() {
  cin >> a >> b >> c;
}

void solve() {
  cout << min(b/a, c) << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <stack>

using namespace std;

#define W_MAX 100
#define H_MAX 100

char map[W_MAX][H_MAX];
int W,H;

void dfs(int x, int y){
  char type = map[x][y];
  map[x][y]=0;
  int dx[] = {-1,0,0,1}; int dy[] = {0,1,-1,0};

  for(int i=0; i<4; i++){
    int nx=x+dx[i], ny=y+dy[i];
    if(nx>=0 && nx<H && ny>=0 && ny<W && map[nx][ny]==type)
      dfs(nx,ny);
  }
}

int main(){
  while(true){
    cin >> H >> W;

    if(W==0 && H==0) break;

    for(int i=0; i<H; i++){
      getchar();
      for(int j=0; j<W; j++){
	scanf("%c", &map[i][j]);
      }
    }

    int ans=0;
    for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
	if(map[i][j]!=0){
	  ans++;
	  dfs(i,j);
	}
      }
    }

    cout << ans << endl;

  }
}

Measured memory_bytes: 1976
#!/usr/local/bin/ruby
num = Hash.new(0)
max = 0
while (n=gets.to_i)!=0
#while (n=gets.to_i) != true
 num[n] += 1
end
num.to_a.sort{|p,q| -(p[1]<=>q[1])}.each do |key,value|
 if value >= max
  max = value
  puts key
 else
  break
 end
end

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

int main()

{
    int a;
    cin >> a;
    if (a < 1200)
    {
        cout << "ABC";
    }
    else if (a < 2800)
    {
        cout << "ARC";
    }
    else
    {
        cout << "AGC";
    }
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
#include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)   (x).begin(),(x).end()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define mp       make_pair
#define eb       emplace_back

int main() {
	int n, k;
	cin >> n >> k;
	int ans = 1;
	for (int i = 0; i < n; i++) {
		ans = min(ans * 2, ans + k);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/*
TASK: AGC143 - A - Curtain
LANG: C++
NAME: picolylamine
*/
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	int A, B;
	scanf("%d%d", &A, &B);
	
	int ret = max(A - (B * 2), 0);
	printf("%d", ret);

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 1000005
using namespace std;
int n,ans,q[maxn],fr=1,bk;
char s[maxn],t[maxn];
int main()
{
	scanf("%d%s%s",&n,s+1,t+1);
	if(!strcmp(s+1,t+1)) { printf("0\n"); return 0; }
	for(int i=n,pos=n;i;i--)
	{
		if(t[i]==t[i-1]) continue;
		for(pos=min(pos,i);pos&&s[pos]!=t[i];pos--);
		if(!pos) { printf("-1\n"); return 0; }
		while(fr<=bk&&q[fr]-(bk-fr+1)+1>i) fr++;
		q[++bk]=pos;
		if(i!=pos) ans=max(ans,bk-fr+1);
	}
	printf("%d\n",ans+1);
}

Measured memory_bytes: 6016
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=200100;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
ll n;
ll ans=9e18,a[N],res,x;
int main(){
	ll i,k,c;
	n=read();x=read();
	for(i=1;i<=n;i++)a[i]=read()+a[i-1];
	for(k=1;k<=n;k++){
		res=0;c=3;
		for(i=n;i>0;i-=k){
			res+=max(c,5ll)*(a[i]-a[max(i-k,0ll)]);
			c+=2;
			if(res>=ans)break;
		}
		res+=x*(k+n);
		ans=min(ans,res);
	}write(ans);puts("");
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int gcd(int a, int b){
  int r = 0;
  a = abs(a);
  b = abs(b);
  while(true){
    r = a % b;
    a = b;
    b = r;
    if(r == 0){
      break;
    }
  }
  return a;
}
int main(){
  int a, b, k;
  int G = 0;
  vector<int> ans;
  cin >> a >> b >> k;
  G = gcd(a,b);
  //cout << G << endl;
  for(int i = G; i >= 1; i--){
    if(a % i == 0 && b % i == 0){
      //cout << i << endl;
      ans.push_back(i);
    }
  }
  int Min = 101;;
  for(int i = 0; i < k; i++){
    //cout << ans[i] << endl;
    Min = min(Min,ans[i]);
  }
  cout << Min << endl;
  return 0;
}

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

int main(){
	int i;
	int j;
	while (std::cin >> i >> j){
		int t = i+j;
		int y;
		for ( y = 1; t / static_cast<int>(pow(10, y)) > 0; ++y){}
		std::cout << y << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3244
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)N;i++)
#define p(s) cout<<(s)<<endl
#define ck(n,a,b) (a)<=(n)&&(n)<(b)
typedef long long ll;
using namespace std;
const int inf=1e9;

int main(){
	string a,b,c;
	cin>>a>>b>>c;
	if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
		p("YES");
	}else p("NO");
	return 0;
}


Measured memory_bytes: 256