akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
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;
  }
}
void wt_L(int x){
  char f[10];
  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 main(){
  int N;
  rd(N);
  if(N%2){
    N *= 2;
  }
  wt_L(N);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20180707-1 [beta]

// --- original code ---
// {
//   int N;
//   rd(N);
//   if(N%2) N *= 2;
//   wt(N);
// }


Measured memory_bytes: 768
X = sorted(list(map(lambda x: int(x), input().split(' '))))

ans = 0

# 2番目に大きい数字を1番大きい数字と同じにする
ans += X[2] - X[1]
X[1] += ans
X[0] += ans

if (X[1] - X[0]) % 2 == 0:
    ans += (X[1] - X[0]) // 2
else:
    ans += (X[1] - X[0]) // 2
    ans += 2

print(ans)




Measured memory_bytes: 38256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;

struct Data {
    int h, p;
    bool operator<(const Data &o) const {
	return min(h, o.h-p) > min(o.h, h-o.p);
    }
} D[5011];

LL X[5011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d%d", &D[i].h, &D[i].p);
    sort(D, D+N);

    memset(X, 0x3f, sizeof X);
    LL INF = X[0];
    X[0] = 0;
    REP (i, N) {
	for (int j=i; j>=0; j--) {
	    if (X[j] <= D[i].h) {
		amin(X[j+1], X[j] + D[i].p);
	    }
	}
    }
    int ans = 0;
    REP (i, N+1) if (X[i] < INF) ans = i;
    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 384
using System;

namespace A_Lucky_7
{
    class Program
    {
        static void Main(string[] args)
        {
            string ans = "No";
            string n = Console.ReadLine();
            string[] s = n.Split("7");
            
            if (s.Length > 1)
            {
                ans = "Yes";
            }
            
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 25812
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int N = Integer.parseInt(st.nextToken());

        int[] T = new int[N];
        st = new StringTokenizer(br.readLine());
        int sum=0;
        for(int i=0; i<N; i++){
            T[i]=Integer.parseInt(st.nextToken());
            sum+=T[i];
        }

        st = new StringTokenizer(br.readLine());
        int M = Integer.parseInt(st.nextToken());

        for(int i=0; i<M; i++){
            st = new StringTokenizer(br.readLine());
            int P = Integer.parseInt(st.nextToken());
            int X = Integer.parseInt(st.nextToken());
            System.out.println(sum-T[P-1]+X);
        }


    }

}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[105];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int f=1;
  int co=0;
  while(f){
    f=0;
    for(int i=n-1;i>0;i--){
      if(a[i]<a[i-1]){
	swap(a[i],a[i-1]);
	co++;
	f=1;
      }
    }
  }
  for(int i=0;i<n;i++){
    cout << a[i];
    if(i+1!=n)cout << " ";
  }
  cout << endl;
  cout << co << endl;
  return 0;
}

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

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;

    vector<vector<int>> c(10, vector<int>(10));
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {
                if (c[j][k] > c[j][i] + c[i][k]) {
                    c[j][k] = c[j][i] + c[i][k];
                }
            }
        }
    }

    int res = 0;
    for (int i = 0; i < h * w; i++) {
        int a;
        cin >> a;

        if (a != -1) {
            res += c[a][1];
        }
    }

    cout << res << endl;
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int A, B;
    cin >> A >> B;
    int res = max({2*A-1,2*B-1,A+B});
    cout << res << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll AB[2], K;
    cin >> AB[0] >> AB[1] >> K;
    rep(i, K) {
        ll index = i % 2;
        if(AB[index] % 2) AB[index]--;
        AB[index] /= 2;
        AB[!index] += AB[index];
    }
    cout << AB[0] << ' ' << AB[1] << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
ll n,h[100010];
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>h[i];
  h[0]--;
  for(int i=1;i<n;i++){
    if(h[i-1]>h[i]){
      cout<<"No"<<endl;
      return 0;
    }
    if(h[i-1]==h[i])continue;
    h[i]--;
  }
  cout<<"Yes"<<endl;
  return 0;
}



Measured memory_bytes: 1024
program prob3
    implicit none
    character(len=500005) :: s
    integer(8) :: n, i, tmp
    integer(8) , allocatable :: a(:)

    read(*,*) s
    n = len_trim(s) + 1

    allocate(a(n))

    tmp = 0
    a(1) = 0
    do i = 1, n-1
        if(s(i:i) == '<') then
            tmp = tmp + 1
            a(i+1) = tmp
        else
            tmp = 0
            a(i+1) = tmp
        end if
    end do

    a(n) = max(a(n), 0)
    tmp = 0
    do i = n-1, 1, -1
        if(s(i:i) == '>') then
            tmp = tmp + 1
            a(i) = max(a(i), tmp)
        else
            tmp = 0
            a(i) = max(a(i), tmp)
        end if
    end do

    write(*,*) sum(a)


    deallocate(a)
    stop
contains
end program prob3

Measured memory_bytes: 5216
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=1e5+10;
const int mod=1e9+7;
ll a[N],b[N];
int x,y,q;

int main()
{
    cin>>x>>y>>q;
    for(int i=0; i<x; i++)
    {
        cin>>a[i];
    }
    for(int i=0; i<y; i++)
    {
        cin>>b[i];
    }
    ll ans;
    while(q--)
    {
        ll k;
        cin>>k;
        int x1=lower_bound(a,a+x,k)-a;
        int y1=lower_bound(b,b+y,k)-b;
        ans=1e16;
		if(x1<x&&y1<y)
		{
			ans=min(ans,max(a[x1],b[y1])-k);
		}
		if(x1>0&&y1>0)
		{
			ans=min(ans,k-min(a[x1-1],b[y1-1]));
		}
		if(x1>0&&y1<y)
		{
			ans=min(ans,b[y1]-a[x1-1]+min(k-a[x1-1],b[y1]-k));
		}
		if(y1>0&&x1<x)
		{
			ans=min(ans,a[x1]-b[y1-1]+min(k-b[y1-1],a[x1]-k));
		}
		printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 5320
#include<bits/stdc++.h>
using namespace std;
map<string,int> mapa;

int main(){
    int maxi = 0;
    int n;
    string str;
    cin >> n;
    for(int i = 0;i<n;i++){
        cin >> str;
        mapa[str]++;
        maxi = max(maxi, mapa[str]);
    }

    set<string> s;

    for(auto it: mapa){
        if(it.second == maxi)
            s.insert(it.first);
    }
    for(auto it: s)
        cout<<it<<"\n";

}

Measured memory_bytes: 34560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
struct Point
{
  double x,y;
  Point(){x=0;y=0;}
  Point(double d_x,double d_y){x=d_x,y=d_y;}
  double operator*(Point obj){return obj.x*x+obj.y*y;}
  double operator%(Point obj){return obj.y*x-obj.x*y;}
  Point operator*(double b){Point tmp;tmp.x=x*b;tmp.y=y*b;return tmp;}
  Point operator/(double b){Point tmp;tmp.x=x/b;tmp.y=y/b;return tmp;}
  Point operator+(Point obj){Point tmp;tmp.x=x+obj.x;tmp.y=y+obj.y;return tmp;}
  Point operator-(){Point tmp;tmp.x=-x;tmp.y=-y;return tmp;}
  Point operator-(Point obj){Point tmp;tmp.x=x-obj.x;tmp.y=y-obj.y;return tmp;}
  Point operator-=(Point obj){x-=obj.x;y-=obj.y;return *this;}
  Point operator+=(Point obj){x+=obj.x;y+=obj.y;return *this;}
  Point operator/=(double b){x=x/b;y=y/b;return *this;}
  Point operator*=(double b){x=x*b;y=y*b;return *this;}
  double size(){return hypot(x,y);}
  Point unit(){return Point(x/size(),y/size());}
  Point normal(){return Point(y,-x);}
  double atan(){return atan2(y,x);}
};

bool operator<(Point a,Point b){return a.x!=b.x?a.x<b.x:a.y<b.y;}
bool operator>(Point a,Point b){return b<a;}
bool operator<=(Point a,Point b){return !(b<a);}
bool operator>=(Point a,Point b){return !(a<b);}
bool operator==(Point a,Point b){return (a-b).size()<eps;}
bool operator!=(Point a,Point b){return !(a==b);}

bool equal(double a,double b){return abs(a-b)<eps;}
double cross(Point a,Point b){return a%b;}
double dot(Point a,Point b){return a*b;}

int ccw(Point a,Point b,Point c)
{
  b=b-a;
  c=c-a;
  if(b%c>0) return +1;
  else if(b%c<0)return -1;
  else if(b*c<0) return +2;
  else if(b.size()<c.size()) return -2;
  else return 0;
}

int main(int argc,char const* argv[])
{
  int n;
  while(1)
    {
      cin >> n;
      if(!n) break;
      vector<vector<int> > stage(n,vector<int>(n+1,0));
      for(int i=0;i<n;i++)
	{
	  for(int j=0;j<n+1;j++)
	    {
	      cin >> stage[i][j];
	    }
	}
      vector<int> dp(1<<n,inf);
      dp[0]=0;
      for(int bit=0;bit<(1<<n);bit++)
	{
	  for(int i=0;i<n;i++)
	    {
	      if((bit & (1<<i)) !=0){continue;}
	      int cost=stage[i][0];
	      for(int j=0;j<n;j++)
		{
		  if((bit & (1<<j) ) ==0){continue;}
		  cost=min(stage[i][j+1],cost);
		}
	      int now=(bit | (1<<i));
	      dp[now]=min(dp[now],dp[bit]+cost);
	    }
	}
      cout << dp[(1<<n)-1] << endl;
    }
  return 0;
}



Measured memory_bytes: 3380
import java.io.*;
import java.util.StringTokenizer;

class CaesarCipher {
	String s;
	String alph = "abcdefghijklmnopqrstuvwxyz";

	CaesarCipher(String s) {
		this.s = s;
	}

	boolean NotFound() {
		if (this.s.indexOf("the")==-1&&
			this.s.indexOf("that")==-1&&
				this.s.indexOf("this")==-1) return true;
		else return false;
	}

	String FindWord() {
		while (NotFound()) {
			String t = "";
			for (int i=0;i<this.s.length();i++) { 
				if (alph.indexOf(this.s.charAt(i))!=-1)
					t = t+alph.charAt((alph.indexOf(this.s.charAt(i))+1)%26);
				else t = t+this.s.charAt(i);
			}
			this.s = t.toString();
		}
		return this.s;
	}
}

class Main {
    public static void main(String args[]) {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String buf;

	try {
		while ((buf = br.readLine())!=null) {
			CaesarCipher cc = new CaesarCipher(buf);
			System.out.println(cc.FindWord());
		}
	} catch (Exception e) {
	    e.printStackTrace();
	}
    }
}

Measured memory_bytes: 19392
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
ll man(ll x1, ll y1, ll x2, ll y2)
{
  return abs(x1 - x2) + abs(y1 - y2);
}

int main()
{
  int N, M;
  cin >> N >> M;
  vector<ll> a(N), b(N), c(M), d(M);
  rep(i, N)
  {
    cin >> a[i] >> b[i];
  }
  rep(i, M)
  {
    cin >> c[i] >> d[i];
  }
  rep(i, N)
  {
    ll min;
    int num;
    rep(j, M)
    {
      if (j == 0)
      {
        min = man(a[i], b[i], c[j], d[j]);
        num = j + 1;
      }
      else
      {
        if (min > man(a[i], b[i], c[j], d[j]))
        {
          min = man(a[i], b[i], c[j], d[j]);
          num = j + 1;
        }
      }
    }
    cout << num << endl;
  }
  return 0;
}

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

int main() {
	int n,d;
	cin >> n;
	d = n%10;
	if((d==2)||(d==4)||(d==5)||(d==7)||(d==9)){
		cout << "hon" << endl;
	}
	else if((d==0)||(d==1)||(d==6)||(d==8)){
		cout << "pon" << endl;
	}
	else cout << "bon" << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <string>
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <vector>
using namespace std;

int main(){
    int n, count = 1;
    string s;
    cin >> n >> s;
    for(int i = 0; i<n-1; i++){
        if(s[i] != s[i+1]){
            count++;
        }
    }
    cout << count << endl;
}


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

int main() {
  int n,k; cin >> n >> k;

  int x,a,b;
  int sum = 0;
  for(int i = 0; i < n; ++i){
    cin >> x;
    a = x;
    b = k-x;

    if(a>=b) sum += b * 2;
    else sum += a * 2;
  }
  cout << sum << "\n";
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, N;
  cin >> N >> A;
  int ans = 0;
  ans = N % 500;
  if(ans <= A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
fn main() {
    let mut ab = String::new();
    std::io::stdin().read_line(&mut ab).unwrap();
    let mut iter = ab.split_whitespace();

    let a: u32 = iter.next().unwrap().parse().unwrap();
    let b: u32 = iter.next().unwrap().parse().unwrap();

    //println!("{}", ab);
    //println!("{}, {}", a, b);

    let area = a * b;
    let perimeter = (a + b) * 2;
    println!("{} {}", area, perimeter);
}


Measured memory_bytes: 1056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll h, n; cin >> h >> n;
    ll sum = 0;
    for(int i = 0; i < n; ++i){
        ll a;cin >> a;
        sum += a;
    }
    string ans = "No";
    if(sum >= h){
        ans = "Yes";
    }
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


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

int main() {
	bool T = false;
	int K, A, B; cin >> K >> A >> B;
	for (int i = A; i <=B; i++)
	{
		if (i % K == 0) T = true;
	}
	if (T)cout << "OK";
	else cout << "NG";
}


Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iX = int.Parse(sS[0]);
            int iY = int.Parse(sS[1]);
            int iZ = int.Parse(sS[2]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            iX -= iZ;               // 左端
            iOut = iX / (iY + iZ);

            // 出力
            Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


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

long long DP[3001][3001][4];
long long value[3001][3001];

int main(){
  int R,C,K;
  scanf("%d%d%d",&R,&C,&K);
  for(int i=0;i<R+1;++i){
    for(int j=0;j<C+1;++j){
      value[i][j]=0;
    }
  }
  for(int i=0;i<K;++i){
    int tr,tc,tv;
    scanf("%d%d%d",&tr,&tc,&tv);
    value[tr][tc]=tv;
  }
  for(int i=1;i<R+1;++i){
    for(int j=1;j<C+1;++j){
      long long tv=value[i][j];
      long long left_max=0;
      for(int k=0;k<4;++k){
        left_max=max(left_max,DP[i-1][j][k]);
      }
      DP[i][j][0]=max(DP[i][j-1][0],left_max);
      DP[i][j][1]=max(DP[i][j-1][1],DP[i][j-1][0]+tv);
      DP[i][j][1]=max(DP[i][j][1],left_max+tv);
      DP[i][j][2]=max(DP[i][j-1][2],DP[i][j-1][1]+tv);
      DP[i][j][3]=max(DP[i][j-1][3],DP[i][j-1][2]+tv);
    }
  }
  long long ans=0;
  for(int k=0;k<4;++k){
    ans=max(ans,DP[R][C][k]);
  }
  cout << ans << endl;
  return 0;
}

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

int n,ans,v[25],c[25];

void dfs(int k, int x, int y)
{
	if(x-y>ans) ans = x - y;
	for(int i = k; i <= n; i++)
		dfs(i+1,x+v[i],y+c[i]);
}

int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> v[i];
	for(int i = 1; i <= n; i++) cin >> c[i];
	dfs(1,0,0);
	cout << ans << endl;
	return 0;
}

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

using namespace std;

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

#define pb push_back
#define odd(x) ((x)&1)
#define even(x) (!odd(x))
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define TEST_CASE int tc;cin>>tc;while(tc--)

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

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define JD




int main(int argv, char* argc[])
{
    FASTIO

    #ifndef JD
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif

    int n,cnt=0;
    cin>>n;
    vii v(n+1);
    for(int i=1;i<=n;++i)
    {
        cin>>v[i];
        if(odd(i)&&odd(v[i]))
            ++cnt;
    }
    cout<<cnt;



    return 0;
}


Measured memory_bytes: 3652
n,m=map(int,input().split())
l=[]
for i in range(m):
  l.append(list(map(int,input().split())))
l=l[::-1]
parent=[i for i in range(n+1)]
depth=[1 for i in range(n+1)]
def find(n):
  if parent[n]==n:
    return n
  else:
    parent[n]=find(parent[n])
    return parent[n]
def unite(n,m):
  n1=find(n)
  m1=find(m)
  if n1==m1:
    return None
  elif depth[n1]<depth[m1]:
    parent[n1]=m1
    depth[m1]+=depth[n1]
  else:
    parent[m1]=n1
    depth[n1]+=depth[m1]
sum=n*(n-1)//2
ans=[]
for i in range(m):
  ans.append(sum)
  l1=l[i]
  a,b=l1[0],l1[1]
  a1=find(a)
  b1=find(b)
  if a1==b1:
    pass
  else:
    sum-=depth[a1]*depth[b1]
    unite(a,b)
for i in range(1,m+1):
  print(ans[-i])

Measured memory_bytes: 34688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define PI 3.14159265359
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; }



int main() {
  int a,b,c;
  cin >> a >> b >> c;

  if(a+b+c>=22) cout << "bust" << endl;
  else cout << "win" << endl;

}



Measured memory_bytes: 256
import java.util.*;

class Main {
    private static Scanner sc;

    public static void main(final String[] args) {
        sc = new Scanner(System.in);
        long a = sc.nextLong(),b = 0;
        if(a >= 500) {
            b = (a / 500) * 1000;
            a %= 500;
        }
        if(a >= 5) b += (a / 5) * 5;
        System.out.println(b);
    }
}








Measured memory_bytes: 35536
N,Y = map(int,input().split())
for i in range(2001):
    for j in range(2001):
        if 10000*i+5000*j+1000*(N-i-j) == Y and N-i-j >= 0:
            print(i,j,N-i-j)
            exit()
print(-1,-1,-1) 


Measured memory_bytes: 41708
#pragma comment(linker, "/STACK:32000000")
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, _= (n); i < _; ++i)
#define DWN(i, n) for (int i = (n) - 1; i >= 0; --i)
#define FOR(i, l, r) for (int i = (l), _ = (r); i < _; ++i)
#define EDGE(u, v, e) for (int e = head[u], v; e != nil && (v = to[e], true); e = next[e])

using namespace std;

typedef unsigned int uint;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;

inline bool read(int& val)    { return scanf("%d",    &val) != -1;}
inline bool read(int64& val)  { return scanf("%I64d", &val) != -1;}
inline bool read(double& val) { return scanf("%lf",   &val) != -1;}
inline bool read(char* val)   { return scanf("%s",     val) != -1;}
template<class T1, class T2>
inline bool read(T1& a, T2& b)
{ return read(a) && read(b); }
template<class T1, class T2, class T3>
inline bool read(T1& a, T2& b, T3& c)
{ return read(a) && read(b) && read(c); }
template<class T1, class T2, class T3, class T4>
inline bool read(T1& a, T2& b, T3& c, T4& d)
{ return read(a) && read(b) && read(c) && read(d); }
template<class T1, class T2, class T3, class T4, class T5>
inline bool read(T1& a, T2& b, T3& c, T4& d, T5& e)
{ return read(a) && read(b) && read(c) && read(d) && read(e); }

const int N = 111111;

char str[N];
bool ok[N];

char val[10][10] = {"dream", "dreamer", "erase", "eraser"};
int main() {
	read(str); int n = strlen(str);
	ok[0] = true;
	REP (i, n + 1) {
		REP (j, 4) {
			int m = strlen(val[j]);
			int s = i - m;
			if (s >= 0) {
				bool eq = ok[s];
				REP (k, m) if (str[s + k] != val[j][k]) eq = false;
				ok[i] = ok[i] || eq;
			}
		}
	}
	printf("%s\n", ok[n] ? "YES" : "NO");
	return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;

int main(){
    int n;
    cin>>n;
    int a[100010];
    int sum=0;
    rep(i,0,n){
        cin>>a[i];
        sum+=a[i]-1;
    }
    cout<<sum<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int N = 1e5;
const int INF = 1e9;


int main() {
    int n, l;
    cin >> n >> l;
    string ss[n];
    for (int i = 0; i < n; i++)
        cin >> ss[i];
    sort(ss, ss + n);
    for (auto z : ss)
        cout << z;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
            foreach(var i in Enumerable.Range(0, 10))
            {

            }*/
            /*
            var a =int.Parse(Console.ReadLine());
            Console.WriteLine(a * a * a);
            */
            /*
            var a = new int[100];
            a[0] = 3;
            Console.WriteLine(a[0]);
            */
            /*
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = ab[0];
            var b = ab[1];
            Console.WriteLine("{0} {1}",a,b);
            */
            var c = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = c[0];
            var b = c[1];
            var x = (a * b);
            var y = (a * 2 + b * 2);
            Console.WriteLine("{0} {1}", x, y);
        }
    }
}

Measured memory_bytes: 9468
S = input()

MOD = 10 ** 9 + 7
count = 0
S_len = len(S)

dp = [[0 for i in range(13)] for j in range(100006)]
c = -1
if S[0] != '?':
    c = int(S[0])
for j in range(10):
    if c == -1:
        dp[1][j] = 1
    else:
        dp[1][c] = 1

for i in range(2, S_len + 1):
    c = -1
    if S[i - 1] != '?':
        c = ord(S[i - 1]) - ord('0')

    for j in range(10):
        if c != -1 and c != j:
            continue
        for k in range(13):
            dp[i][(k * 10 + j) % 13] += dp[i - 1][k] % MOD


print(dp[S_len][5] % MOD)




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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;


int H, W, K;
string S[11];
int a[11][1100];

int get_sum(int y0, int x0, int y1, int x1) {
    return a[y1][x1] - a[y1][x0] - a[y0][x1] + a[y0][x0];
}
signed main() {
    cin >> H >> W >> K;
    rep(i, H) {
        cin >> S[i];
        rep(j, W) {
            a[i + 1][j + 1] = S[i][j] - '0';
        }
    }
    rep(i, H+1)rep(j, W) { a[i][j + 1] += a[i][j]; }
    rep(i, H)rep(j, W+1) { a[i + 1][j] += a[i][j]; }
    int ans = LLONG_MAX;
    rep(i, bit(H - 1)) {
        int cur = 0;
        rep(j, H - 1) {
            cur += (i >> j) & 1;
        }
        int l = 0;
        rep(j, W) {
            int s = 0;
            int sc = 0;
            rep(k, H) {
                if ((i >> (k - 1)) & 1) {
                    s = 0;
                    sc = 0;
                }
                s += get_sum(k, l, k + 1, j + 1);
                sc += get_sum(k, j, k + 1, j + 1);
                if (sc > K) {
                    goto label;
                }
                if (s > K) {
                    l = j, cur++;
                    break;
                }
            }
        }
        chmin(ans, cur);
        label:;
    }
    cout << ans << endl;
}


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

int main(void) {
    char s[200001];

    scanf("%s", s);

    long int k = 0, ans = 0;
    int i;

    for (i = 0; i < strlen(s); i++) {
        if (s[i] == 'A')
            k++;
        else if (s[i] == 'B' && s[i + 1] == 'C') {
            ans += k;
            i++;
        }
        else
            k = 0;
    }

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

    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
#include <sstream>
using namespace std;

#define LL long long
string str;
string ans("keyence");

string Remove(int Begin, int len) {
    return str.substr(0, Begin) + str.substr(Begin + len);
}

int main() {
    #ifdef Dmaxiya
    freopen("test.txt", "r", stdin);
    #endif // Dmaxiya
    ios::sync_with_stdio(false);

    while(cin >> str) {
        if(str == ans) {
            cout << "YES" << endl;
            continue;
        }
        int len = str.length();
        bool flag = false;
        for(int i = 0; i < len; ++i) {
            for(int j = 1; i + j - 1 < len; ++j) {
                if(Remove(i, j) == ans) {
                    flag = true;
                    break;
                }
            }
        }
        if(flag) {
            cout << "YES\n";
        } else {
            cout << "NO\n";
        }
    }

    return 0;
}


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

int main(){
  // 入力
  int H, N;
  cin >> H >> N;

  vector<int> skill(N);
  for(int i = 0; i < N; i++){
    cin >> skill.at(i);
  }

  int sum = accumulate(skill.begin(), skill.end(), 0);

  string ans = (sum >= H) ? "Yes" : "No";
  cout << ans << endl;

}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

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

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

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

	ll k, a, b;cin >> k >> a >> b;
	REP(i, 10000){
		if(i < a)continue;
		if(i > b)continue;
		if(i % k == 0){
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;

	return 0;
}


Measured memory_bytes: 3688
#include <stdio.h>
#include <vector>
#include <tuple>
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)
using datum = std::pair<int, bool>;
std::vector<std::vector<datum>> P;

inline bool bitUP(int state, int k){
    return (state >> k) & 1;
}

int main(void){
    int n; scanf("%d", &n);
    P.resize(n);
    REP(i, n){
        int a; scanf("%d", &a);
        P[i].resize(a);
        REP(j, a){
            int k; int c; scanf("%d%d", &k, &c);
            P[i][j] = {k-1, c == 1};
        }
    }
    int res = -1;
    int N = 1 << n;
    REP(state, N) if(res < __builtin_popcount(state)){
        bool ok = true;
        REP(i, n){
            for(auto itr : P[i]) if(bitUP(state, i)){
                if(bitUP(state, itr.first) != itr.second){
                    ok = false; break;
                }
            }
            if(not ok) break;
        }
        if(ok) res = __builtin_popcount(state);
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 256
import sys
import math
n = int(raw_input())
start = int(math.floor(-2*n/7.))
end = int(math.ceil(-n/4.)+1)
for i in range(start,end):
	a = 2 * n + 7 * i
	b = -n - 4 * i
	if (a >= 0) & (b >= 0):
		print 'Yes'
		sys.exit()
print 'No'

Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
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; }
const long long INF = 1LL<<60;
/*0.08x = a
0.1x = b */
int main(){
    int a,b;cin >> a >> b;
    for(int i=0;i<=1009;i++){
        if(floor(i*0.08)==a&&floor(i*0.1)==b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int gcd(ll a, ll b) {
  ll v0 = a, v1 = b, v2 = v0%v1;
  while(v2>0) {
    v0 = v1;
    v1 = v2;
    v2 = v0%v1;
  }
  return v1;
}

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

int main() {
  ll N, M;
  string S, T;
  cin>>N>>M>>S>>T;
  ll len = lcm(N, M);
  bool can = true;
  map<int, char> amap;
  for(int i=0;i<S.size();++i) {
    amap[len/S.size()*i] = S[i];
  }
  for(int i=0;i<T.size();++i) {
    if(amap[len/T.size()*i] && amap[len/T.size()*i]!=T[i]) can = false;
  }
  if(can) cout<<len<<endl;
  else cout<<-1<<endl;
}



Measured memory_bytes: 11480
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <cmath>
using namespace std;

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

typedef long long ll;

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 main() {
    ll n, h, w;
    cin >> n >> h >> w;

    ll a = ((n - h) + 1) * ((n - w) + 1);
    
    cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<bool, int> pbi;
int arr[105];
struct hasher
{
	size_t operator()(const pbi &temp) const
    {
        return hash<bool>()(temp.first) ^ hash<int>()(temp.second);
    }
};
unordered_map<pbi, bool, hasher> mp;
bool play(bool turn, int n, int k)
{
	if (k == 0)
		return turn;
	pbi temp = pbi(turn, k);
	auto it = mp.begin();
	if ((it = mp.find(temp)) != mp.end())
		return it->second;
	bool flag = turn;
	for (int i = 0; i < n; ++i) {
		if (k >= arr[i]) {
			if (!turn)
				flag |= play(!turn, n, k - arr[i]);
			else
				flag &= play(!turn, n, k - arr[i]);
		}
		if ((!turn && flag) || (turn && !flag))
			break;
	}
	return mp[temp] = flag;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> arr[i];
	}
	if (play(0, n, k))
		cout << "First\n";
	else
		cout << "Second\n";
	return 0;
}

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

#define FOR(a,b,c) for (int a=(b);a<(c);++a)
#define REP(i,n) FOR(i,0,n)
#define ll long long
#define pii pair<int,int>
#define x first
#define y second
#define pb push_back
#define lf double

using namespace std;

const int MAX = (int)1e6 + 5;
const int Z = (1<<20);

int n,qc;
int p[MAX];

int out[MAX];

vector<int> cnt[MAX];
vector<pii> q[MAX];
int ind[MAX];

int tree[Z*2+5];

void inc(int x){
	int pos=x+Z;
	while(pos){
		tree[pos]++;
		pos/=2;
	}
}

void dec(int x){
	int pos=x+Z;
	while(pos){
		tree[pos]--;
		pos/=2;
	}
}

int magic(int pos,int lo,int hi,int x){
	if (hi<=x) return tree[pos];
	if (lo>x) return 0;
	int a=magic(pos*2,lo,(lo+hi)/2,x);
	int b=magic(pos*2+1,(lo+hi)/2+1,hi,x);
	return a+b;
}

int sum(int x){
	return magic(1,0,Z-1,x);
}

int main(){
	scanf ("%d%d",&n,&qc);
	REP(i,n){
		scanf ("%d",p+i);
		p[i]--;
		ind[i]=(int)cnt[p[i]].size();
		cnt[p[i]].pb(i);
	}
	REP(i,n){
		if ((int)cnt[i].size()>0){
			inc(cnt[i][0]);
		}
	}
	REP(i,qc){
		int a,b;
		scanf ("%d%d",&a,&b);
		a--;b--;
		q[a].pb({b,i});
	}
	REP(i,n){
		for (auto curr:q[i]){
			int cx=curr.x;
			int pos=curr.y;
			out[pos]=sum(cx);
		}
		dec(i);
		int val=p[i];
		
		if ((int)cnt[val].size()>ind[i]+1){
			inc(cnt[val][ind[i]+1]);
		}
	}
	
	REP(i,qc) printf ("%d\n",out[i]);
	return 0;
}


Measured memory_bytes: 86120
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

void abc_160a();

void abc_161a();

void abc_162a();

void abc_163a();

void abc_164a();

void abc_165a();

void abc_166a();

int main()
{
  //abc_160a();
  //abc_161a();
  //abc_162a();
  //abc_163a();
  //abc_164a();
  //abc_165a();
  abc_166a();


}

void abc_160a()
{
  string S;
  cin >> S;

  if (S[2] == S[3] && S[4] == S[5]) cout << "Yes\n";
  else cout << "No\n";
}

void swap(int& a, int& b)
{
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

void abc_161a()
{
  int x, y, z;
  cin >> x >> y >> z;

  swap(x, y);
  swap(x, z);

  cout << x << " " << y << " " << z << "\n";
}

void abc_162a()
{
  string s;
  cin >> s;
  for (char c : s)
  {
    if (c == '7')
    {
      cout << "Yes\n";
      return;
    }
  }

  cout << "No\n";
}

void abc_163a()
{
  int R;
  cin >> R;

  cout << (double)(2 * R * M_PI);
}

void abc_164a()
{
  int s, w;
  cin >> s >> w;

  if (s <= w) cout << "unsafe\n";
  else cout << "safe\n";
}

void abc_165a()
{
  int k, a, b;
  cin >> k >> a >> b;

  for (int i = a; i <= b; ++i)
  {
    if (i % k == 0)
    {
      cout << "OK\n";
      return;
    }
  }

  cout << "NG\n";
}

void abc_166a()
{
  string s;
  cin >> s;

  if (s == "ABC") cout << "ARC\n";
  if (s == "ARC") cout << "ABC\n";

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repab(i,a,b) for(int i=a;i<=b;i++)
#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define p() cout<<'\n'
#define p0(x) cout<<x<<" "
#define p1(x) cout<<x<<'\n'
#define p2(x,y) cout<<x<<" "<<y<<'\n'
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define get(n) ll n;cin>>n
#define getarr(arr,n) vector<ll> arr(n);for(int i=0;i<n;i++) cin>>arr[i];
#define getstr(s) string s;cin>>s
#define all(x) x.begin(),x.end()
#define countBits(x) __builtin_popcount (x)
using namespace std;


int main(){
  fio;
  get(n);
  vector<double> arr(n,0.0);
  rep(i,n)
    cin>>arr[i];
  sort(all(arr));
  double sum=arr[0];
  repab(i,1,n-1)
    sum=(sum+arr[i])/2;
  p1(sum);
  return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np
sys.setrecursionlimit(1000000)
 
N = int(input())
W = list(map(int,input().split()))

ans = 1000000

for i in range(len(W)):
    ans = min(abs(sum(W[:i]) - sum(W[i:])),ans)
    
print(ans)

Measured memory_bytes: 21388
#include <iostream>

using namespace std;

int N;

int main() {
  while (cin >> N) {
    int m = (N%2==0) ? N+1 : N;
    cout << (N * (N-1) / 2) - N/2 << endl;
    for (int i = 1; i <= N; ++i) {
      for (int j = i+1; j <= N; ++j) {
	if (i + j != m) {
	  cout << i << " " << j << endl;
	}
      }
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>
using namespace std;
typedef long long  ll;

int h, w;
int cost[10][10];
int a[201][201];
int main() {
    
    scanf("%d %d", &h, &w);
    
    for (int i = 0; i < 10; i++)
        for (int j = 0; j < 10; j++)
            scanf("%d", &cost[i][j]);
    
    for (int k = 0; k < 10; k++)
        for (int i = 0; i < 10; i++)
            for (int j = 0; j < 10; j++) {
                if (cost[i][j] > cost[i][k] + cost[k][j]) {
                    cost[i][j] = cost[i][k] + cost[k][j];
                }
            }
    
    int ans = 0;
    
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++) {
            int t;
            scanf("%d", &t);
            if (t != -1 && t != 1)
                ans += cost[t][1];
        }

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




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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;
        

        static void Main(string[] args)
        {
            var data = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var a = data[0];
            var b = data[1];
            var c = data[2];
            var d = data[3];
            long ans = 0;

            var preans = new long[] { a * c, a * d, b * c, b * d };

            /*foreach(var v in preans)
            {
                Console.WriteLine(v);
            }*/

            ans = preans.Max();

            Console.WriteLine(ans);

        }

        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }

        /*static public void DFS(int h, int w, bool[][] _visited)
        {
            
            if (w < 0 || h < 0 || h > _visited.Length - 1 || w > _visited[h].Length-1 || map[h][w]=='x')
                return;
            if (_visited[h][w])
                return;
            //Console.WriteLine(h + " " + w+" "+ _visited[h].Length + " " + _visited.Length);
            _visited[h][w] = true;

            DFS(h + 1, w,_visited);
            DFS(h - 1, w,_visited);
            DFS(h, w + 1,_visited);
            DFS(h, w - 1,_visited);

        }*/
        
        
        
    }
}


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

int main() {
  int n,x;
  cin>>n;
  map<int,int> m;
  for(int i=1;i<n;i++) {
    cin>>x;
    m[x]++;
  }
  for(int i=1;i<=n;i++) {
    cout<<m[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 12976
#include<bits/stdc++.h>
         
        using namespace std;
         
         
        int main() {
            string s;
        	ios_base::sync_with_stdio(0);
        	cin >> s;
        	for (int i = 0; i < (int) s.size(); i++)
        		s[i] = (s[i] == '?' ? 'D' : s[i]);
        	cout << s << "\n";
        	return 0;
        }

Measured memory_bytes: 3780
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=2005;
char s[N];
struct edge{
	int to,next;
}e[N*2];
int n,ans,tot,head[N];
int mx[N],mn[N],sz[N];
void add(int x,int y){
	e[++tot]=(edge){y,head[x]};
	head[x]=tot;
}
void dfs(int x,int fa){
	mx[x]=0; sz[x]=s[x]&1;
	for (int i=head[x];i;i=e[i].next)
		if (e[i].to!=fa){
			dfs(e[i].to,x);
			sz[x]+=sz[e[i].to];
			mx[x]+=mx[e[i].to]+sz[e[i].to];
		}
	mn[x]=mx[x]&1;
	for (int i=head[x];i;i=e[i].next)
		if (e[i].to!=fa){
			int v1=mn[e[i].to]+sz[e[i].to];
			int v2=mx[x]-mx[e[i].to]-sz[e[i].to];
			mn[x]=max(mn[x],v1-v2);
		}
}
int main(){
	scanf("%d%s",&n,s+1);
	For(i,1,n-1){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	ans=1<<30;
	For(i,1,n){
		dfs(i,0);
		if (mn[i]==0)
			ans=min(ans,mx[i]/2);
	}
	if (ans==1<<30) ans=-1;
	printf("%d\n",ans);
} 

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)

int main() {
    fastio
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 != m2)
        cout<<1<<endl;
    else
        cout<<0<<endl;
        
    
	return 0;
}






Measured memory_bytes: 384