akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
template <typename F,typename T>
struct SegTree{
  T identity;
  F merge;
  int size;
  vector<T> dat;
  
  SegTree(F f,T id):merge(f),identity(id){}

  // initialize (n is number of elements)
  void init(int n){
    size = 1;
    while(size<=n) size *= 2;
    dat.resize(size*2-1,identity);
  }

  // initialize 
  void build(vector<T> vec){
    rep(i,vec.size()) dat[size-1+i] = vec[i];
    dfs(0);
  }

  T dfs(int k){
    if(k>=size-1) return dat[k];
    else return dat[k] = merge(dfs(2*k+1),dfs(2*k+2));
  }

  void update(int k,T a){
    k += size - 1;
    dat[k] += a;
    while(k > 0){
      k = (k-1)/2;
      dat[k] = merge(dat[2*k+1],dat[2*k+2]);
    }
  }

  // return query for [a,b). (k,l,r) = (0,0,seg.size)
  T query(int a,int b,int k,int l,int r){
    // out of range
    if(r<=a||b<=l) return identity;
    
    if(a<=l&&r<=b) return dat[k]; 
    else return merge(query(a,b,2*k+1,l,(l+r)/2),query(a,b,2*k+2,(l+r)/2,r));
  }
  
  void show(){
    int index = 0;
    int num = 1;
    while(index<size){
      rep(i,num){
	if(dat[i+index]==identity) cout << "e ";
	else cout << dat[i+index] << " ";
      }
      cout << "\n";
      num *= 2;
      index = index*2+1;
    }
  }
  
  
};
int main()
{
  int n,q;cin >> n >> q;
  vector<int> c(q);
  vector<ll> x(q),y(q);
  rep(i,q) cin >> c[i] >> x[i] >> y[i];
  auto f = [&](int a,int b){ return a+b;};
  ll id = 0;
  SegTree<decltype(f),ll> seg(f,id);
  seg.init(n);
  rep(i,q){
    if(c[i]==0) seg.update(x[i],y[i]);
    else cout << seg.query(x[i],y[i]+1,0,0,seg.size) << "\n";
  }
  return 0;
}



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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pcase cout<<"Case "<<++cs<<": "
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define mp make_pair
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    vi v; vscan;
    int arr[n+5];
    int cnt = 0, M = 0;
    for(i = v.size()-1; i > 0; i--){
        if(v[i] <= v[i-1]) cnt++;
        else{
            M = max(M, cnt);
            cnt = 0;
        }
    }
    M = max(M,cnt);
    cout << M << endl;
    return 0;
}


Measured memory_bytes: 892
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int result = 0;
        if(a==b){
            result = 2*a;
        }
        else{
            result = Math.max(a, b)*2-1;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 21972
package main
import . "fmt"
func main() {
  var n,m,t int
  var s string
  m = 0
  Scan(&n)
  Scan(&s)
  for i:=1;i<n;i++ {
    t = 0
    l := make(map[string]struct{})
    r := make(map[string]struct{})
    for j:=0;j<i;j++ {
      l[s[j:j+1]] = struct{}{}
    }
    for j:=i;j<n;j++ {
      r[s[j:j+1]] = struct{}{}
    }
    for key,_ := range l {
      if _,ok := r[key];ok { t++ }
    }
    if m < t { m = t }
  }
  Println(m)
}

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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
        #define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
  1 1 3 4 5 9
  4 1 9 1 5 3
*/

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

  vi a(n);
  rep(i, n){
    cin >> a[i];
  }

  sort(all(a));

  deque<int> c, d;
  repi(i, 1, n) c.push_back(a[i]);
  d.push_back(a[0]);
  rep(i, n-1){
    if(i/2%2 == 0){
      if(i%2 == 0){
        d.push_front(c.back()); 
      }else{
        d.push_back(c.back());
      }
      c.pop_back();
    }else{
      if(i%2 == 0){
        d.push_front(c.front()); 
      }else{
        d.push_back(c.front());
      }
      c.pop_front();
    }
  }

  ll ans = 0, dif = 0;
  rep(i, n-1) dif += abs(d[i+1]-d[i]);
  ans = max(ans, dif);

  c.clear(); d.clear();

  reverse(all(a));

  repi(i, 1, n) c.push_back(a[i]);
  d.push_back(a[0]);
  rep(i, n-1){
    if(i/2%2 == 0){
      if(i%2 == 0){
        d.push_front(c.back()); 
      }else{
        d.push_back(c.back());
      }
      c.pop_back();
    }else{
      if(i%2 == 0){
        d.push_front(c.front()); 
      }else{
        d.push_back(c.front());
      }
      c.pop_front();
    }
  }

  dif = 0;
  rep(i, n-1) dif += abs(d[i+1]-d[i]);
  ans = max(ans, dif);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
n = int(input())
N = n
print(N,":",sep="",end=" ")

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    b = 3
    while b * b <= n:
        if n % b == 0:
            a.append(b)
            n //= b
        else:
            b += 2
    if n != 1:
        a.append(n)
    return a
    
A = prime_factorize(n)
print(*A)
        


Measured memory_bytes: 5596
s = input()
a = int(s[0:2])
b = int(s[2:4])

if 1<= a <= 12 and 1 <= b <= 12 :
    print("AMBIGUOUS")
elif 1 <= a <= 12 and 0 <= b <= 99 :
    print("MMYY")
elif 0 <= a <= 99 and 1 <= b <= 12 :
    print("YYMM")
else : print("NA")

Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
    int  n, x;
    int  count,
         count_p;

    for (;;) {
        scanf("%d %d", &n, &x);

        if ((n == 0)&&(x == 0))
            break;

        count_p = 0;
        int i, j, k;
        for (i = 1; i <= n; i++) {
            for (j = 1; j <= n; j++) {
                for (k = 1; k <= n; k++) {
                    if ((i + j + k) == x) {
                        if ((i == j)||(j == k)||(k == i)) {
                            count_p = count_p;
                        } else {
                            count_p = count_p + 1;
                        }
                    }
                }
            }
        }
        count = count_p / (3 * 2 * 1);
        printf("%d\n", count);
    }

    return 0;
}



Measured memory_bytes: 2060
# coding: utf-8
# Your code here!
n=int(input())
a=list(map(int,input().split()))
w=int(input())
c=[]
for i in range(w):
    c.append(list(map(int,input().split())))

b=[0]*10**5
for i in range(n):
    b[a[i]-1]+=1
ans=sum(a)
for i in range(w):
    ans=ans+b[c[i][0]-1]*(c[i][1]-c[i][0])
    cnt=b[c[i][0]-1]
    b[c[i][1]-1]+=cnt
    b[c[i][0]-1]=0
    #print(b)
    print(ans)

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

int main(){
    string X;  cin >> X;
    int ns = 0;
    int len = X.length();
    int ans = len;
    for(int i=0; i<len; i++){
        if(X[i]=='S') ns++;
        if(X[i]=='T' && ns > 0){
            ns--;
            ans-=2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const ll mod = 1e9 + 7;
const int N = 3010;
ll dp[N][N];
ll dp2[N][N][2];

int main() {
    ll n, m;
    cin >> n >> m;

    dp[0][0] = 1;
    REP(i,m){
        REP(j,n+1){
            if (j == 0){
                dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % mod;
                dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j]) % mod;
            }else if (j == n){
                dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % mod;
                dp[i+1][j-1] = (dp[i+1][j-1] + dp[i][j]) % mod;
            }else{
                dp[i+1][j] = (dp[i+1][j] + 2 * dp[i][j]) % mod;
                dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j]) % mod;
                dp[i+1][j-1] = (dp[i+1][j-1] + dp[i][j]) % mod;
            }
        }
    }

    ll ans = 0;
    REP(j,n+1) ans = (ans + dp[m][j]) % mod;

    if (n > 1) FOR(j,1,n) dp2[0][j][0] = 1;
    else dp2[0][1][1] = 1;
    // dp2[0][1][0] = 1;
    REP(i,m) REP(k,2) {
        REP(j,n+1){
            if (j == 0){
                dp2[i+1][j][k] = (dp2[i+1][j][k] + dp2[i][j][k]) % mod;
                dp2[i+1][j+1][k] = (dp2[i+1][j+1][k] + dp2[i][j][k]) % mod;
            }else if (j == n){
                dp2[i+1][j][k] = (dp2[i+1][j][k] + dp2[i][j][k]) % mod;
                dp2[i+1][j-1][k] = (dp2[i+1][j-1][k] + dp2[i][j][k]) % mod;
            }else if (j == 1 && k == 0){
                dp2[i+1][j][0] = (dp2[i+1][j][0] + dp2[i][j][0]) % mod;
                dp2[i+1][j][1] = (dp2[i+1][j][1] + dp2[i][j][0]) % mod;
                dp2[i+1][j-1][1] = (dp2[i+1][j-1][1] + dp2[i][j][0]) % mod;
                dp2[i+1][j+1][0] = (dp2[i+1][j+1][0] + dp2[i][j][0]) % mod;
            }else{
                dp2[i+1][j][k] = (dp2[i+1][j][k] + 2 * dp2[i][j][k]) % mod;
                dp2[i+1][j+1][k] = (dp2[i+1][j+1][k] + dp2[i][j][k]) % mod;
                dp2[i+1][j-1][k] = (dp2[i+1][j-1][k] + dp2[i][j][k]) % mod;                
            }
        }
    }

    REP(j,n+1) ans = (ans + dp2[m][j][1]) % mod;

    cout << ans << endl;

    // REP(j,n+1){
    //     REP(i,m+1) cout << dp[i][j] << " ";
    //     cout << endl;
    // }

    // REP(j,n+1){
    //     // REP(i,m+1) cout << dp2[i][j][0] + dp2[i][j][1] << " ";
    //     REP(i,m+1) cout << dp2[i][j][1] << " ";
    //     cout << endl;
    // }

    return 0;
}


Measured memory_bytes: 212224
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
vector<ll> v;
vector<string> vs;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
map<ll, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

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

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=60;
ll n,a[N],base,ans,temp;
int main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	base=n-1;
	bool flag=1;
	while(flag){
		flag=0;
		for(int i=1;i<=n;i++){
			if(a[i]>base){
				flag=1,temp=(a[i]-base-1)/n+1;
				a[i]-=temp*n+temp;
				base-=temp,ans+=temp;
			}
		}
//		cout<<ans<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
fun main(args:Array<String>){
            val num = readLine()!!.toInt()
            val list = readLine()!!.split(" ").map(String::toInt).toMutableList()
            val manzoku = readLine()!!.split(" ").map(String::toInt).toMutableList()
            val bonusup = readLine()!!.split(" ").map(String::toInt).toMutableList()
            var m = 0
            for(i in 0 until num){
                m += manzoku[list[i]-1]
                if(i >= 1) {
                  if (list[i] == list[i-1]+1) m += bonusup[list[i]-1-1]
                }
            }
            println(m)
        }

Measured memory_bytes: 36452
S = str(input())
s = len(S)
cnt = 0
A = [0]*2019
r = 0
for i in range(s):
  x = (r+pow(10, i, 2019)*int(S[s-i-1]))%2019
  A[x] += 1
  r = x
  
for i in range(1,2019):
  if A[i] >= 2:
    cnt += A[i]*(A[i]-1)//2
cnt += A[0]*(A[0]+1)//2

print(cnt)

Measured memory_bytes: 9296
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n, k; cin>>n>>k;
    int x = n/k;
    n -= (k*x);
    int ans = n;
    n -= k;
    ans = min(ans, abs(n));
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int linearsearch(int,int);

int S[10000],T[500]; 


int main( ){

  int n,q,i,count=0;


  scanf("%d",&n);

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

    scanf("%d",&S[i]);

  }

  scanf("%d",&q);

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

    scanf("%d",&T[i]);

  }

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

    count+=linearsearch(T[i],n);
  }

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


int linearsearch(int key,int n){

  int i;

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

    if(key==S[i])return 1;

  }

  return 0;
      
}  

Measured memory_bytes: 640
from math import ceil 
n=int(input())
l=[int(i) for i in input().split()]
if all(l[i]!=i+1 for i in range(n)):
    print(0)
    exit()
s=[]
for i in range(n):
    if l[i]==i+1:
        s.append(l[i])
#print(s)
ans=0 
i=0 
grps=[]
c=0 
for i in range(1,len(s)):
    if s[i]==s[i-1]+1:
        c+=1 
    else:
        curr=c+1 
        ans+=ceil(curr/2)
        c=0 
ans+=ceil((c+1)/2)
print(ans)

Measured memory_bytes: 56300
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
int n,m,Q;
int l[200010],r[200010];
int p[100010],q[100010];
/****二次元累積和********/
int a[510][510];
int s[510][510];
void acc_sum2(){//二次元累積和 O(n*m)
  rep(i,n+1){
    s[i][0]=0;
  }
  rep(i,n+1){
    s[0][i]=0;
  }
  rep1(i,n){
    rep1(j,n){
      s[i][j]=s[i-1][j]+s[i][j-1]+a[i-1][j-1]-s[i-1][j-1];
    }
  }
}
int sec_sum2(int xl,int xr,int yl,int yr){
  return s[xr+1][yr+1]-s[xr+1][yl]-s[xl][yr+1]+s[xl][yl];
}
/**********/
int main(){
  scan(n);scan(m);scan(Q);
  rep(i,m){
    scan(l[i]);scan(r[i]);
  }
  rep(i,Q){
    scan(p[i]);scan(q[i]);
  }
  rep(i,n){
    rep(j,n){
      a[i][j]=0;
    }
  }
  rep(i,m){
    a[l[i]-1][r[i]-1]++;
  }
  acc_sum2();
  rep(i,Q){
    prin(sec_sum2(p[i]-1,q[i]-1,p[i]-1,q[i]-1));
  }

  

  return 0;
}


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

int cmp(const void* p, const void* q) {
	return *(long long*)q - *(long long*)p;
}

int main(void) {
	int n;
	long long a[100001];
	long long edge1 = 0, edge2 = 0;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	qsort(a, n, sizeof(long long), cmp);

	int flag = 0;
	for (int i = 0; i < n; i++) {
		if (flag == 0 && a[i] == a[i + 1])
			edge1 = a[i], flag = 1, i++;
		else if (flag == 1 && a[i] == a[i + 1]) {
			edge2 = a[i], flag = 2;
			break;
		}

		if (flag == 2) break;
	}
	printf("%lld", edge1*edge2);
	return 0;
}


Measured memory_bytes: 1788
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		Long[] h = new Long[n];
		for(int i=0;i<n;i++){
			h[i] = sc.nextLong();
		}
		sc.close();

		Arrays.sort(h, Collections.reverseOrder());
		long r = 0L;
		for(int i=k;i<n;i++){
			r+=h[i];
		}
		System.out.println(r);
	}
}

Measured memory_bytes: 96308
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  int n,x,y;
  cin >> n >> x >> y;
  vi ans(n+1);
  rep(i,1,n){
    rep(j,i+1,n+1){
      ans[min(j-i, abs(x-i)+1+abs(y-j))]++;
    }
  }
  rep(i,1,n){
    cout << ans[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
map<char,ll>mp;
ll n,ans;
int main(void){
    cin>>s;
    n=s.size();
    ans=n*(n-1)/2+1LL;
    for(int i=0;i<n;i++){
        mp[s[i]]++;
    }
    for(auto x:mp){
        //cout<<x.second<<endl;
        ans-=(x.second)*(x.second-1)/2;
        //cout<<ans<<"W"<<endl;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
    int N,H,W,A[1001],B[1001];

    //読み込み
    scanf("%d %d %d",&N,&H,&W);
    int i;

    i=1;
    while(i<=N)
    {
        scanf("%d %d",&(A[i]),&(B[i]));
        i++;
    }

    int count = 0;
    i=1;
    while(i<=N)
    {
        if(A[i]>=H && B[i]>=W)
        {
            count++;
        }
        i++;
    }

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

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

using namespace std;

int vec_find(vector<int> vec, int number) {
    vector<int>::iterator itr = find(vec.begin(), vec.end(), number);
    size_t index = distance(vec.begin(), itr);
    if (index != vec.size()) {
        return 1;
            } else {
        return 0;
    }
}


int main() {
    int n, m, x = 1;
    cin >> n >> m>>x;
    vector<int> a(m);

    for (int i = 0; i < m; i++) {
        cin >> a.at(i);
    }

    int cost_left = 0;
    for (int i = 1; i < x; i++) {
        if (vec_find(a, i)) {
            cost_left++;
        }
    }
    int cost_right = 0;
    for (int i = x; i < n; i++) {
        if (vec_find(a, i)) {
            cost_right++;
        }
    }
    cout << (cost_right >= cost_left ? cost_left : cost_right);
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    if A[i] >= B[i]:
        ans += B[i]
    else:
        ans += A[i]
        B[i] -= A[i]
        if A[i + 1] >= B[i]:
            ans += B[i]
            A[i + 1] -= B[i]
        else:
            ans += A[i + 1]
            A[i + 1] = 0
print(ans)


Measured memory_bytes: 19116
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
vector<int> v[110];
int dp[110][110];
int main(){
	int n=0,maxi=0;
	string z;
	while(cin>>z){
		z.push_back(',');
		int cnt=0;
		lol(i,z.size()){
			if(z[i]==','){
				v[n].push_back(cnt);
				cnt=0;
			}
			else{
				cnt*=10;
				cnt+=z[i]-'0';
			}
		}
		int tmp=v[n].size();
		maxi=max(maxi,tmp);
		n++;
	}
	lol(i,n)lol(j,maxi)dp[i][j]=0;
	lol(i,n-1)lol(j,v[i].size()){
			int tmp=dp[i][j]+v[i][j];
			if(i<maxi-1){
				dp[i+1][j]=max(dp[i+1][j],tmp);
				dp[i+1][j+1]=max(dp[i+1][j+1],tmp);
			}
			else{
				if(j+1<v[i].size())dp[i+1][j]=max(dp[i+1][j],tmp);
				if(j>0)dp[i+1][j-1]=max(dp[i+1][j-1],tmp);
			}
	}
	cout<<dp[n-1][0]+v[n-1][0]<<endl;
	return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
    int n,p; cin>>n>>p;
    int a[n];
    rep(i,n) cin>>a[i];
    map<int,int> m;
    rep(i,n){
        m[a[i]%2]++;
    }
    if(p == 1 && m[1] == 0 ){
        cout<<0<<endl;
        return 0;
    }
    if(p == 0 && m[0] == n){
        cout<<setprecision(18)<<pow(2,n)<<endl;
        return 0;
    }
    
    cout<<setprecision(18)<<pow(2,n)/2<<endl;
    
    return 0;
}


Measured memory_bytes: 4176
n,k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10**9+7
X = [0]*n
x = [0]*n
for i in range(n):
    res = 0
    for j in range(i+1,n):
        if a[i] > a[j]:res+=1
    X[i]= res
for i in range(n):
    res = 0
    for j in range(n):
        if a[i] > a[j]:res +=1
    x[i] = res
ans = 0
for i in range(n):
    ans += (k*X[i])%mod+(k*(k-1)*x[i]//2)%mod
    ans %=mod
print(ans)



Measured memory_bytes: 3188
#include "bits/stdc++.h"
#define ll long long
#define ld long double 
#define For(i, a, n) for(long long i = a; (a < n) ? (i < n) : (i > n); (a < n) ? (i++) : (i--))
#define ee 1000000007
#define pb push_back
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

void solve() {
	ll n;
	cin >> n;
	ll a[n];
	For(i, 0, n) {
		cin >> a[i];
	}
	ll dp[n] = {0};
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	For(i, 2, n) {
		dp[i] = min(dp[i - 1] + abs(a[i - 1] - a[i]), dp[i - 2] + abs(a[i - 2] - a[i]));
	}
	cout << dp[n - 1] << "\n";
}

int main() {
    fio;
    ll t = 1;
    //cin >> t;
    while(t--) {
    	solve();
    }
}

Measured memory_bytes: 5144
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
  int a,b,t,sum = 0;
  cin >> a >> b >> t;
  
  int T;
  for(int i = 1; T < t+0.5; i++) {
    T = a*i;
    sum += b;
  }
  cout << sum-b << endl;
}

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

#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'

int main()
{
 fastIO();
 long long n , accnt = 0 , wacnt = 0, tlecnt = 0 , recnt = 0;
string s;
cin>>n;
for(int i=0; i<n; i++)
{
	cin>>s;
	if(s=="WA")
	{
		wacnt++;
	}
	else if(s=="AC")
	{
		accnt++;
	}
	else if(s=="TLE")
	{
		tlecnt++;
	}
	else if(s == "RE")
	{
		recnt++;
	}
		
}

cout<<"AC x "<<accnt<<endl;
cout<<"WA x "<<wacnt<<endl;
cout<<"TLE x "<<tlecnt<<endl;
cout<<"RE x "<<recnt<<endl;

return 0;
}


Measured memory_bytes: 3624
-- Sum of 4 Integers
main = getContents >>= putStr . solve

solve :: String -> String
solve = unlines . map (show . findSum4 . read) . lines

findSum4 :: Int -> Int
findSum4 = \n -> length [[a,b,c,d]| a <- [0..9], b <- [0..9], c <- [0..9], d <- [0..9], a + b + c + d == n]

Measured memory_bytes: 3968
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		UINT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

int main()
{
	string S = "";
	string ret = "No";	// "Yes" or "No"
	ll status = 0;

	cin >> S;

	Rep(i, S.length()) {
		if ( S[i] == 'A') {
			status = 1;
		}
		else if (status == 1 && S[i] == 'C') {
			ret = "Yes";
			break;
		}
		else {
			status = 0;
		}
	}
	cout << ret << endl;

	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long 
#define MAX 25 * 1e13

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  for( int i = 0 ; i < n ; i++ ){
    cin >> a[i];
  }
  int cnt = 0;
  int cu = 1;
  for( int i = 0 ; i < n ; i++ ){
    if( a[i] == cu ){
      cu++;
    }
  }
  if( cu == 1 ) {
    cout << "-1" << endl;
    return 0;
  }
  cout << n - ( cu - 1 ) << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=100010, inf=2e9;

int n, m;
vector<int> G[MX];

deque<int> Ans;
bool vis[MX];

void dfs1(int v){
    Ans.push_back(v);
    vis[v]=true;
    for(int x:G[v])
        if(!vis[x]){
            dfs1(x);
            break;
        }
}

void dfs2(int v){
    Ans.push_front(v);
    vis[v]=true;
    for(int x:G[v])
        if(!vis[x]){
            dfs2(x);
            break;
        }
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n>>m;
    for(int i=1, u, v; i<=m; i++){
        cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs1(1);
    for(int x:G[1])
        if(!vis[x]){
            dfs2(x);
            break;
        }
    cout<<Ans.size()<<'\n';
    for(int v:Ans) cout<<v<<' ';
    return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    if (K > (N-1)*(N-2)/2) {
        cout << -1 << endl;
    }
    else {
        cout << N*(N-1)/2 - K << endl;
        for (int i = 2; i <= N; i++) {
            cout << 1 << " " << i << endl;;
        }
        int count = 0;
        bool checker = false;
        for (int i = 2; i <= N; i++) {
            for (int j = 3; j <= N; j++) {
                if (i == j) {continue;}
                else if (i > j) {continue;}
                if (count == (N-1)*(N-2)/2 - K) {
                    checker = true;
                }
                if(checker) {
                    break;
                }
                count++;
                cout << i << " " << j << endl;
            }
            if(checker) {
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#ifndef LOCAL
    #pragma GCC optimize("O3")
    #endif
    #include "bits/stdc++.h"
    using namespace std;
    #define sim template <class c
    #define ris return *this
    #define dor > debug &operator<<
    #define eni(x)                                                                    \
        sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
        {
    sim > struct rge
    {
        c b, e;
    };
    sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
    sim > auto dud(c *x) -> decltype(cerr << *x, 0);
    sim > char dud(...);
    struct debug
    {
    #ifdef LOCAL
        ~debug()
        {
            cerr << endl;
        }
        eni(!=) cerr << boolalpha << i;
        ris;
    } eni(==) ris << range(begin(i), end(i));
    }
    sim, class b dor(pair<b, c> d)
    {
        ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d)
    {
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
            *this << ", " + 2 * (it == d.b) << *it;
        ris << "]";
    }
    #else
        sim dor(const c &)
        {
            ris;
        }
    #endif
    }
    ;
    #define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
    #define fastio                        \
        ios_base::sync_with_stdio(false); \
        cin.tie(0);
    #define endl '\n'
    typedef long long ll;
    typedef long double ld;
    const ll MOD = 1e9 + 7;
    const ll N = 1e5 + 10;
    
int arr[26];
    int main()
    {
        fastio
   string h;
   cin>>h;
for (int i = 0; i < h.length(); i++)
{
    arr[h[i]-'a']++;
}
if(arr['a'-'a']>0 &&arr['b'-'a']>0 &&arr['c'-'a']>0)
cout<<"Yes"<<endl;
else
{
    cout<<"No"<<endl;
}



        return 0;
    }

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    N, K = MI()
    p = LI()
    p.sort()
    ans = 0
    for i in range(K):
        ans += p[i]
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 78084
#include <cassert>
#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>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// 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>

#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>

using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define T int t = 0; cin >> t; while(t--)
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef  long double lld;
const ll mod = 1e9 + 7;
const ll mx = 2e6 + 5;
vector<ll>fact(mx);
void initialize(){
    fact[0] = 1;
    fact[1] = 1;
    for(ll i = 2; i < mx; ++i)fact[i] = (fact[i - 1] * i) % mod;
}
ll power(ll x, ll y){
    ll res = 1;
    while(y > 0){
        if(y & 1)res = (res * x) % mod;
        y = y >> 1LL;
        x = (x * x) % mod;
    }
    return res;
}
ll inverse(ll x){
    return power(x, mod - 2);
}
void input(){
    initialize();
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    ll ans =0;++r1; ++r2; ++c1; ++c2;
    for(ll r = r1; r <= r2; ++r){
        ll x = fact[r + c2 -1] % mod;
        x = (x * inverse(fact[r])) % mod;
        x = (x * inverse(fact[c2 - 1] % mod)) % mod;
        ll y = fact[r + c1 - 2] % mod;
        y = (y * inverse(fact[r])) % mod;
        y = (y * inverse(fact[c1 - 2])) % mod;
        ll z= (x - y + mod) % mod;
        ans = (ans + z) % mod;
    }
    cout << ans << endl;
    
}
int main(){
    input();
    return 0;
}

Measured memory_bytes: 16000
#include<stdio.h>
int main()
{
	int n,k[1000],p[1000],i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&k[i],&p[i]);
	}
	/*for(i=0;i<n;i++){
		printf("i=%d k=%d p=%d\n",i,k[i],p[i]);
	}*/
	for(i=0;i<n;i++){
		if(k[i]>p[i]){
			if(k[i]%p[i]!=0){
				printf("%d\n",k[i]%p[i]);
			}
			else{
				printf("%d\n",p[i]);
			}
		}
		else{
			printf("%d\n",k[i]);
		}
	}
	return 0;
}



Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i;
	string a;
	vector<char> vi;
	vi.clear();
	vector<char>::iterator it;
	cin>>a;
	for(i=0;i<a.size();i++){
		//cout << a[i] << endl;
		if(a[i]=='1'){
			vi.push_back(a[i]);
		}
		if(a[i]=='0'){
			vi.push_back(a[i]);
		}
		if(a[i]=='B'){
			if(vi.size()>0)
				vi.erase(vi.end()-1);
		}
		//cout<<vi.size()<<endl;
	}
	for(it=vi.begin();it!=vi.end();it++){
		cout << *it;
	}
	 
	return 0;
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    string s;
    cin >> s;
    int n1 = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'p') {
            n1++;
        }
    }
    cout << (s.size() - n1 - n1) / 2 << endl;
}


Measured memory_bytes: 3724
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;


template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
	// printElems(&a[0], &a[n]);　みたいな感じで使う。
	void printElems(const int* begin, const int* end)
	{
		for (const int* p = begin; p != end; ++p) {
			cout << *p << ' ';
		}
		cout << endl;
	}
}

#define rep(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<n+1; i++)
#define repr(i,n) for(ll i=n-1; i>=0; i--)
#define repr1(i,n) for(ll i=n; i>0; i--)
#define FOR(i,j,n) for(ll i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(ll i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<ll,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const ll BIG = 1LL<<60;
const string yes = "Yes";
const string no = "No";

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

map<ll,ll> s;
ll anstmp;

int main(){
	ll n,x,m;
	cin >> n >> x >> m;
	ll tmp = x;
	ll cnt = 1;
	vector<ll> v;
	v.push_back(0);

	while(true){
		if(s.count(tmp) == 1){
			break;
		}
		s.insert(mp(tmp,cnt));
		anstmp+=tmp;
		v.push_back(anstmp);
		tmp = ((tmp%m)*(tmp%m))%m;
		cnt++;
	}
	ll ans = 0;
//	prints(n-s[tmp],cnt-s[tmp]);
	ll loop = (n-s[tmp]+1)/(cnt-s[tmp]);
	ans+=(loop)*(anstmp-v[s[tmp]-1]);
//	prints(ans);
	ans+=v[s[tmp]-1];
//	prints(ans);
//	prints(cnt-s[tmp],(n-s[tmp]+1),(cnt-s[tmp]),+s[tmp]-1,s[tmp]-1);
	ans+=v[((n-s[tmp]+1)%(cnt-s[tmp]))+s[tmp]-1]-v[s[tmp]-1];
	prints(ans);




	return 0;
}




Measured memory_bytes: 6744
#include<iostream>
#include<string>
using namespace std;
int main()
{
int a,b;
string s,t,u;
cin>>s>>t;
cin>>a>>b;
cin>>u;  
  if(u==s)
  {
    cout<<a-1<<" "<<b<<endl;
  }
	else if(u==t)
    {
      cout<<a<<" "<<b-1<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(void){
	int n;
	string s;
	int p;
	vector<pair<string,pair<int,int>>> v;
	cin>>n;
	reps(i,n){
		cin>>s>>p;
		v.push_back(pair<string,pair<int,int> >{s,pair<int,int>{-1*p,i}});
	}
	sort(all(v));
	rep(i,n){
		cout<<v[i].second.second<<endl;
	}
	return 0;
}


Measured memory_bytes: 636
while True:
    n = int(raw_input())
    if n == 0: break
    trea = [0]*n
    for i in range(n):
        trea[i] = map(int, raw_input().split())
    x,y = 10,10
    thr = [[0 for i in range(21)] for j in range(21)]
    m = int(raw_input())
    for i in range(m):
        line = raw_input().split()
        d = int(line[1])
        if line[0] == 'N':
            for i in range(1,d+1):
                thr[x][y+i] = 1
            y += d
        if line[0] == 'E':
            for i in range(1,d+1):
                thr[x+i][y] = 1
            x += d
        if line[0] == 'S':
            for i in range(1,d+1):
                thr[x][y-i] = 1
            y -= d
        if line[0] == 'W':
            for i in range(1,d+1):
                thr[x-i][y] = 1
            x -= d
    for i in range(n):
        if thr[trea[i][0]][trea[i][1]] == 0:
            print "No"
            break
        if i == n-1:
            print "Yes"

Measured memory_bytes: 6284
#include <cstdio>
#define INF 1e9
#define eps 1e-6
typedef long long ll;

int n, ans;
ll d, x, y, z;

int main(){

	scanf("%d%lld", &n, &d);
	for(int i = 1; i <= n; i++){
		scanf("%lld%lld", &x, &y);
		z = x * x + y * y;
		if(z <= d * d) ans++;
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1732
#include <stdio.h>
int main(void){
    int H,N,i,A[1000000];
   
    scanf("%d%d",&H,&N);
    for(i=0;i<N;i++)
        scanf("%d",&A[i]);
    i=0;
    while(i<N){
        H-=A[i];
        i++;
    }
    if(H<=0) printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

using namespace std;

struct data_t {
  int b;
  int f;
  int r;
  int v;

  bool operator<(const data_t& right) const {
    return b == right.b ? f == right.f ? r < right.r : f < right.f : b < right.b;
  }
};

int main(void) {
  int n;
  int count[4][3][10] = {};
  int b,f,r,v;
  cin >> n;
  vector<data_t> data_array(n);
  for(int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    data_array[i].b = b;
    data_array[i].f = f;
    data_array[i].r = r;
    data_array[i].v = v;
  }
  sort(data_array.begin(), data_array.end());
  int t = 0;
  for(int i = 0; i < 4; i++) {
    for(int j = 0; j < 3; j++) {
      for(int k = 0; k < 10; k++) {
        while(i + 1 == data_array[t].b && j + 1 == data_array[t].f && k + 1 == data_array[t].r) {
          count[i][j][k] += data_array[t++].v;
        }
      }
    }
  }
  for(int i = 0; i < 4; i++) {
    for(int j = 0; j < 3; j++) {
      for(int k = 0; k < 10; k++) {
        if(count[i][j][k])
          cout << ' ' << count[i][j][k];
        else
          cout << ' ' << '0';
      }
      cout << endl;
    }
    if(i < 3)
    cout << "####################" << endl;
  }
  return 0;
}

Measured memory_bytes: 3092
#include<iostream>
#include<string>
using namespace std;
int main(){
  long N,M;
  cin>>N>>M;
  int p[M];
  string S[M];
  for(int i=0;i<M;i++){
    cin>>p[i];
    cin>>S[i];
  }
  int WAcount[N]={0};
  int ACflag[N];
  for(int i=0;i<N;i++){
    ACflag[i]=1;
  }
  long ACnum=0;
  long WAnum=0;
  string AC="AC";
  string WA="WA";
  for(int i=0;i<M;i++){
    if(S[i]==WA){
      WAcount[p[i]-1]++;
    }else if(S[i]==AC){
      ACnum+=ACflag[p[i]-1];
      WAnum+=(WAcount[p[i]-1]*ACflag[p[i]-1]);
      ACflag[p[i]-1]=0;
    }
  }
  cout<<ACnum<<" "<<WAnum;
  return 0;
}

Measured memory_bytes: 6912
# include <iostream>
# include <string>
# include <vector>
# include <cmath>
using namespace std;

int main(){
	string s;
	cin >> s;

	for(int i=0 ; i<s.size()-1 ; ++i){
		if(s[i] == s[i+1]){
			cout << i+1 << " " << i+2 << endl;
			break;
		}else if(i < s.size()-2 && s[i] == s[i+2]){
			cout << i+1 << " " << i+3 << endl;
			break;
		}
		if(i == s.size()-2)
			cout << -1 << " " << -1 << endl;
	}


	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <algorithm>
#include<string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    char a, b;
    cin >> a >> b;
    if (a == 'H') {//honest
        if (b == 'H') {
            cout << "H" << endl;
        } else {
            cout << "D" << endl;
        }
    } else {
        if (b == 'H') {
            cout << "D" << endl;
        } else {
            cout << "H" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005
/* The judge is never wrong! Your code is buggy ??
   Look for:
 * * an easier and alternate approach
 * * if concept is corret and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
 */
 
 
 
 
int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
 
        int r;
        cin >> r;
        double x=6.28318530717958623200;
        double ans=x*r;
        cout << fixed << setprecision(12) << ans << '\n';
 
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
#define INF 1e18
long long dp[501][501],a[501],sum[501],n;
long long Sum(long long x, long long y)
{
    return sum[y] - sum[x-1];
}
long long Dp_Rec(long long L, long long R)
{
    if(dp[L][R] - INF) return dp[L][R];
    if(L == R) return dp[L][L] = 0;
    for(long long i=L; i<R; i++)
        dp[L][R] = min(Dp_Rec(L,i) + Dp_Rec(i+1,R) + Sum(L,i) + Sum(i+1,R), dp[L][R]);
    return dp[L][R];
}
int main()
{
    cin >> n;
    for(long long i=1; i<=n; i++){
        cin >> a[i];
        for(long long j=1; j<=n; j++){
            dp[i][j] = INF;
        }
        sum[i] = sum[i-1] + a[i];
    }
    cout << Dp_Rec(1,n);
}

Measured memory_bytes: 1792
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    r,g=[parseInt(readline()) for i in 1:2]
    println(g*2-r)
end
main()

Measured memory_bytes: 109696
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
using namespace std;

int main() {
int N; cin >> N;
char c;
bool flag; flag = false;
string s;
s = to_string(N);
for (int i = 0; i < N; i++){
  c = s[i];
  if (c == '7'){
    flag = true;
  }
}
if (flag == true){
  cout << "Yes" << endl;
}
else{
  cout << "No" << endl;
}
  }

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

#define rep(a, b, i) for(int i = a; i < b; i++)

char ch(int a, int b, int c) {
	return (a * (c - 'a') + b) % 26 + 'a';
}

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

	string str, res = "";
	for (; n > 0; n--) {
		getline(cin, str);

		rep(1, 27, a) {
			if (a == 2 || a == 13) continue;
			rep(1, 27, b) {
				res = str;
				c = 0;
				rep(0, str.size(), c) {
					if (res[c] == ' ') continue;

					res[c] = ch(a, b, res[c]);
				}
				if (res.find("this") != -1 || res.find("that") != -1) {
					cout << res << endl;
					a = 114514;
					b = 114514;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  int ans = 0;
  string S;
  cin >> S;
  FOR(i,1,S.size()){
    if(S[i-1] != S[i])ans++;
  }
  cout << ans << endl;
}


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

main(){
	int n,a,b;
	cin >> n >> a >> b;
	int min,max;
	if(a>b){
		max=b;
	}else{
		max=a;
	}
	min=n-(n-a)-(n-b);
	if(min<0){
		min=0;
	}
	cout << max << " " << min <<endl;
}



Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
数え=[0]*N
for i in A:
  数え[i-1]+=1
前者=0
for i in 数え:
  前者+=i*(i-1)//2
for i in A:
  後者=数え[i-1]-1
  print(前者-後者)

Measured memory_bytes: 26140