akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;   
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll t=0,b=0,c=0,d=0,n,min=100000000000,k,ans=0;
    string s,s2;
    cin >> n >> t;
    rep(i,n){
        cin >> c >> d;
        if(t >= d){
            if(min > c){
                min = c;
            }
        }
    }
    if(min==100000000000){
        cout << "TLE" <<endl;
    }
    else cout << min <<endl;
    return 0;
}


Measured memory_bytes: 256
import math
 
N, K = map(int, input().split())
 
def f(n, k):
    return 0.5 ** math.ceil(math.log2(k/float(n)))
ans = 0
if K > N:
    for n in range(1, N+1):
       ans += f(n, K) * 1/N
       
else:
    for n in range(1, K):
        ans += f(n, K) * 1/N
    ans += float(N-K+1)/N
    
print(ans)

Measured memory_bytes: 3188
#include<cstdio>

int main(){
	int sx,sy,tx,ty;
	scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
	int nx=sx,ny=sy;//当前位置
	//去
	while(ny<ty){
		printf("U");
		ny++;
	} 
	while(nx<tx){
		printf("R");
		nx++;
	}
	//回
	 while(ny>sy){
		printf("D");
		ny--;
	} 
	while(nx>=sx){
		printf("L");
		nx--;
	}
	//2去
	while(ny<=ty){
		printf("U");
		ny++;
	} 
	while(nx<tx){
		printf("R");
		nx++;
	}
	printf("D");
	ny--;
	//2回
	printf("R");
	nx++;
	while(ny>=sy){
		printf("D");
		ny--;
	} 
	while(nx>sx){
		printf("L");
		nx--;
	}
	printf("U");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong()-1;
		long val = 26;
		int cnt = 1;
		while (N >= val) {
			cnt++;
			N -= val;
			val *= 26;
		}
		StringBuilder sb = new StringBuilder();
		long tmp = N;
		for (int i=0;i<cnt;i++) {
			sb.append((char)((int)'a'+(tmp%26)));
			tmp /= 26;
		}

		StringBuilder ans = new StringBuilder();
		for (int i=0;i<cnt;i++) {
			ans.append(sb.charAt(cnt-1-i));
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 35796
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e6 + 3;

vector<long long int> inverse;
vector<long long int> f, f_inverse;

void factorial_Initialize(int max){
    vector<long long int> a(max+1,1);
    inverse = a;
    f = a;
    f_inverse = a;

    for (int i=2; i<=max; i++){
        inverse[i]   = MOD - inverse[MOD % i] * (MOD / i) % MOD;
        f[i]         = f[i-1]         * i          % MOD;
        f_inverse[i] = f_inverse[i-1] * inverse[i] % MOD;
    }
}

long long int modpow(long long int b, long long int p){// modinv(x) = modpow(x, MOD-2)
    long long int num = 1, power = b;
    for(int i=0; i<=30; i++){
        if((p>>i) & 1){
            num *= power;
            num %= MOD;
        }

        power *= power;
        power %= MOD;
    }
    return num;
}

int main(){
    int q;
    cin >> q;
    factorial_Initialize(3*1e6);

    for(int i=0; i<q; i++){
        long long int x, d, n;
        cin >> x >> d >> n;
        if(x == 0){ cout << 0 << endl; continue; }
        if(d == 0){ cout << modpow(x,n) << endl; continue; }
        if(n >= MOD){ cout << 0 << endl; continue; }

        long long int x0 = x * modpow(d, MOD-2) % MOD;
        long long int ans = f[x0 + n-1] * modpow(f[x0 - 1], MOD-2) % MOD;
        ans *= modpow(d, n);
        ans %= MOD;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 96908
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    string S, T;
    cin >> S >> T;
    cout << T + S << endl;
    return 0;
}

Measured memory_bytes: 256
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vll vector< pair<ll,ll> > 
#define mpl map<ll, ll>
#define pr pair<ll,ll>
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x*x);if(p%2==0) return x;else return (x*n);}
ll pd(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}  
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;
//	   cin>>t;
	      while(t--)
{
ll n,m,a,b,c,d;
cin>>a>>b;
cin>>c>>d;
ll ans=a*c;
//ee;
if(a*b<=0)
ans=0;
if(c*d<=0)
ans=0;
ans=max(max(a*c,a*d),ans);
ans=max(max(b*c,b*d),ans);
cout<<ans;
ee;
}
return 0;
}



Measured memory_bytes: 3640
from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    a = ii()
    b = ii()
    for i in range(1,4):
        if a == i:
            continue
        elif b == i:
            continue
        print(i)
        exit()


    
main()


Measured memory_bytes: 2940
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector<ll> a(100010);
    rep(0, i, N)
    {
        cin >> a.at(i);
    }

    vector<ll> num(100010, 0), T(100010, 0);
    map<ll, ll> m;
    ll ans = 1;
    T.at(0) = 3;
    rep(0, i, N)
    {
        if (i != 0)
        {
            rep(0, j, 3)
            {
                if (a.at(i) == num.at(j))
                {
                    T.at(i)++;
                }
            }
        }
        num.at(m[a.at(i)])++;
        m[a.at(i)]++;
        if (a.at(i) != 0 && m[a.at(i) - 1] == 0)
        {
            T.at(i) = 0;
        }
        ans *= T.at(i);
        ans %= MOD;
    }

    cout << ans << endl;
}


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

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


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

using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

int main() {
  ll H, W, m;
  cin >> H >> W >> m;
  vector<ll> h(m), w(m), hs(H), ws(W);
  rep(i, m) {
    cin >> h[i] >> w[i];
    --h[i];
    --w[i];
    ++hs[h[i]];
    ++ws[w[i]];
  }
  using pll = pair<ll, ll>;
  set<pll> s;
  rep(i, m) s.emplace(h[i], w[i]);
  ll hsmax = -1, wsmax = -1;
  itr(x, hs) updatemax(hsmax, x);
  itr(x, ws) updatemax(wsmax, x);
  vector<ll> hsmaxi, wsmaxi;
  rep(i, H) if (hs[i] == hsmax) hsmaxi.push_back(i);
  rep(i, W) if (ws[i] == wsmax) wsmaxi.push_back(i);
  ll ans = hsmax + wsmax;
  if (hsmaxi.size() * wsmaxi.size() <= m) {
    itr(hi, hsmaxi) itr(wi, wsmaxi) {
      if (s.find(pll(hi, wi)) == s.end()) goto end;
    }
    --ans;
  }
end:
  cout << ans << endl;
}


Measured memory_bytes: 39716
#include <bits/stdc++.h>
using namespace std;
/*
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    map<int,int> m;
    int n;
    cin>>n;
    int a[n];
    int i;
    for(i=0;i<n;i++)
    {
    	cin>>a[i];
    	m[a[i]]++;
	}
	int j;
	int ans=0;
	for(i=0;i<n;i++)
	{
		m[a[i]]--;
		for(j=1;j*j<=a[i];j++)
		{
			if(a[i]%j==0)
			{
				if(m[a[i]/j]>0 || m[j]>0)
				break;
			}
		}
		if(j*j>a[i])
		ans++;
		m[a[i]]++;
	}
	cout<<ans<<endl;
	return 0;
}
*/
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 	int n;
	cin>>n;
	int i;
	int a[n];
	int b[1000001];
	memset(b,0,sizeof(b));
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		if(b[a[i]])
		{
			b[a[i]]=2;
			continue;
		}
		int j;
		for(j=a[i];j<=1000000;j+=a[i])
		b[j]++;	
	}
	int ans=0;
	for(i=0;i<n;i++)
	if(b[a[i]]==1)
	ans++;
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8344
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x)-1 for x in sys.stdin.readline().split()]

def main():
    N = I()
    A = LI()
    ans = 0
    cnt = 0
    cur = 0
    for i in range(N):
        if A[i] == cur:
            ans += cnt
            cnt = 0
            cur += 1
        else:
            cnt += 1
    if cur != 0:
        ans += cnt
    else:
        ans = -1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 70988
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int n = scan.nextInt();
        int d = scan.nextInt();
        double a = (double) n / (d * 2 + 1);
        if(a % 1 != 0){
            System.out.println(n / (d * 2 + 1) + 1);
        }else{
            System.out.println(n / (d * 2 + 1));
        }
    }
}

Measured memory_bytes: 23252
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;



struct E {
  int a, b, c;
};

int nNode, nEdge;
vector<E> g[100000+10];
bool visited[100000+10];
ll diff[100000+10];
int eff[100000+10];
ll ass[100000+10];

bool isOK(int x, ll c) {
  queue<int> q;
  memset(visited, 0, sizeof visited);
  ass[x] = c;
  visited[x] = true;
  q.push(x);
  while(!q.empty()) {
    int u = q.front(); q.pop();
    if(ass[u] <= 0) {
      return false;
    }
    REP(i, g[u].size()) {
      E e = g[u][i];
      ll tobe = e.c - ass[u];
      if(visited[e.b]) {
        if(ass[e.b] != tobe) {
          return false;
        }
      } else {
        ass[e.b] = tobe;
        visited[e.b] = true;
        q.push(e.b);
      }
    }
  }
  return true;
}

int go(void) {
  queue<int> q;
  eff[0] = 1;
  diff[0] = 0;
  visited[0] = true;
  q.push(0);
  while(!q.empty()) {
    int u = q.front(); q.pop();
    // cerr << "> " << u << endl;
    REP(i, g[u].size()) {
      E e = g[u][i];
      ll d = e.c - diff[u];
      // cerr << e.b << " " << d << endl;
      if(visited[e.b]) {
        if(eff[e.b] != -1*eff[u]) {
          ll dd = d - diff[e.b];
          ll pp = eff[e.b] + eff[u];
          if(dd % pp != 0) {
            return 0;
          }
          return isOK(0, dd / pp) ? 1 : 0;
        } else {
          if(d != diff[e.b]) {
            return 0;
          }
        }
      } else {
        eff[e.b] = -1 * eff[u];
        diff[e.b] = d;
        visited[e.b] = true;
        q.push(e.b);
      }
    }
  }
  // REP(u, nNode) {
  //   cerr << diff[u] << " ";
  // }
  // cerr << endl;
  ll lb = -100000000000000000LL;
  ll ub = 100000000000000000LL;
  REP(u, nNode) {
    if(eff[u] == 1) {
      // x + diff[u] >= 1
      lb = max(lb, 1-diff[u]);
      REP(i, g[u].size()) {
        E e = g[u][i];
        // x + diff[u] <= e.c-1;
        ub = min(ub, e.c-1-diff[u]);
      }
    } else {
      // -x + diff[u] >= 1
      // x <= diff[u] - 1
      ub = min(ub, diff[u] - 1);
      REP(i, g[u].size()) {
        E e = g[u][i];
        // -x + diff[u] <= e.c-1;
        // x >= diff - e.c + 1;
        lb = max(lb, diff[u] - e.c+1);
      }
    }
  }
  return max(ub - lb + 1, 0LL);
}

int main(void) {
  scanf("%d%d", &nNode, &nEdge);
  REP(iEdge, nEdge) {
    E e;
    scanf("%d%d%d", &e.a, &e.b, &e.c);
    --e.a;
    --e.b;
    g[e.a].push_back(e);
    swap(e.a, e.b);
    g[e.a].push_back(e);
  }
  int res = go();
  cout << res << endl;
  return 0;
}


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



int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;
    int flag = 0;
    int a[26] = {0};
    cin >> s;
    for(int i = 0; i<s.length(); i++)
    {
        if(islower(s[i]))
        {
            a[s[i] - 'a']++;
        }
    }
    for(int i = 0; i<26; i++)
    {
        if(a[i]%2 != 0)
        {
            cout << "No";
            flag++;
            return 0;
        }
    }
    if(flag ==0)
    cout << "Yes";
    else cout << "No";
}

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

constexpr int max_t = 300000;

int main(){
    int n; cin >> n;
    int c; cin >> c;
    vector<int> v[32];
    for(int i=0;i<32;i++) v[i].assign(max_t+20,0);

    for(int i=0;i<n;i++){
        int s,t; cin >> s >> t;
        int x; cin >> x;
        x--;

        v[x][2*s]++;
        v[x][2*t]--;
    }
    for(int i=0;i<max_t;i++){
        for(int j=0;j<32;j++) v[j][i+1] += v[j][i];
    }

    vector<int> v2(max_t+20,0);
    for(int i=0;i<max_t;i++){
        for(int j=0;j<32;j++){
            if(v[j][i] > 0 || v[j][i+1] > 0){
                v2[i] |= (1<<j);
            }
        }
    }

    //for(int i=0;i<20;i++){
    //    cout << bitset<4>(v2[i]) << " ";
    //}
    //cout << endl;

    int ans = 0;
    for(int i=0;i<max_t;i++){
        int cnt = 0;
        for(int bit = 0; bit < 32;bit++){
            if(v2[i] & (1<<bit)) cnt++;
        }
        ans = max(ans,cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 38912
#include<stdio.h>

int main() {
	unsigned int n = 0, x = 0;

	while (1) {
		scanf("%d %d", &n, &x);
		if (n == 0 && x == 0) {
			break;
		}
		int count = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++) {
					if (i + j + k == x) {
						count++;
					}
				}
			}
		}
		printf("%d\n", count);
	}

	return 0;
}



Measured memory_bytes: 2112
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    auto nk = readln.chomp.split.to!(long[]).array;
    long n = nk[0], k = nk[1];

    long[int] d;
    for (int i = 0; i < n; i++) {
        auto ab = readints;
        int a = ab[0], b = ab[1];

        d[a] += b;
    }

    // Warning: use std.algorithm.sort instead of .sort property
    long cnt = 0;
    foreach (x; d.keys.sort()) {
        if (k <= cnt + d[x]) {
            writeln(x);
            break;
        }
        cnt += d[x];
    }
}


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

using namespace std;
using ll = long long;
const int INF = 1001001001;

int main(){
    string s, t;
    cin >> s >> t;
    int n = (int)s.size();
    int m = (int)t.size();

    vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));

    for(int i=0;i<n;++i) for(int j=0;j<m;++j) {
        if (s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
        else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
    }

    string ans = "";

    while (n > 0 && m > 0) {
        if (dp[n][m] == dp[n-1][m]) {
            n--;
        } else if (dp[n][m] == dp[n][m-1]) {
            m--;
        } else {
            ans = s[n-1] + ans;
            n--;
            m--;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 35584
#include <iostream>
#include <string>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

int main() {
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> per(n,k-q);

	for (int i = 0; i < q; ++i) {
		int a;
		cin >> a;
		per[a-1]++;
	}

	for (int i = 0; i < n; ++i) {
		if (per[i] > 0) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;
int list[10001];

int find(int x) {
	if (x != list[x]) {
		list[x] = find(list[x]);
	}
	return list[x];
}

void unite(int x,int y){
	x=find(x),y= find(y);
	if (list[x] > list[y]) {
		list[y] = x;
	}
	else {
		list[x] = y;
	}find(x), find(y);

}

bool same(int x,int y) {
	return find(x) == find(y);
}

int main() {
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		list[i] = i;
	}
	int p, a, b;
	for (int i = 0; i < q; i++) {
		cin >> p >> a >> b;
		if (p == 0) {
			unite(a, b);
		}
		else {
			if (same(a, b) == 1) {
				cout << 1 << endl;
			}
			else {
				cout << 0 << endl;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define vc vector
void read(vector<int>& arr){
    for(int i=0;i<arr.size();i++)
        cin>>arr[i];
}
void solve(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*c,max(a*d,max(b*c,b*d)));
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL

#define PI 3.14159265358979

int main(){
	ll N, M;
	cin >> N >> M;
	vll A(M);
	ll sum = 0;
	for(int i = 0; i < M; i++){
		cin >> A.at(i);
		sum += A.at(i);
	}
	if(sum > N) cout << -1 << endl;
	else cout << N - sum << endl;

}

Measured memory_bytes: 3676
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
#include <queue>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<pair<int,int> > VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

/*int n,cnt;
PII p[1010];
map<VI,int> vis;
queue<VI> q;*/
const int N=101000;
int n,a[N],b[N],c[N],vis[N],pos[N],lab[N],num[N];
int main() {
/*	n=5;
	rep(i,0,n) p[i]=mp(i,0);
	vis[VI(p,p+n)]=1;
	q.push(VI(p,p+n));
	while (!q.empty()) {
		VI x=q.front(); q.pop();
		bool vv=1;
		rep(i,0,n) vv&=x[i].fi==i;
		if (vv) {
			printf("%d",++cnt);
			for (int i=0;i<n;i++) printf(" %d,%d",x[i].fi,x[i].se);
			puts("");
		}
		rep(i,0,n-2) {
			VI y=x;
			swap(y[i],y[i+2]);
			y[i].se^=1; y[i+1].se^=1; y[i+2].se^=1;
			if (!vis[y]) {
				vis[y]=1;
				q.push(y);
			}
		}
	}*/
	scanf("%d",&n);
	rep(i,0,n) scanf("%d",a+i);
	rep(i,0,n) scanf("%d",b+i);
	rep(i,0,n) scanf("%d",c+i);
	rep(i,0,n) {
		if (b[i]%3!=2) {
			puts("No");
			return 0;
		}
		if (vis[b[i]/3]) {
			puts("No");
			return 0;
		}
		vis[b[i]/3]=1; pos[b[i]/3]=i;
		if (b[i]/3%2!=i%2) {
			puts("No");
			return 0;
		}
		num[i]=b[i]/3;
		if (a[i]==b[i]-1&&c[i]==b[i]+1) lab[b[i]/3]=0;
		else if (a[i]==b[i]+1&&c[i]==b[i]-1) lab[b[i]/3]=1;
		else {
			puts("No");
			return 0;
		}
	}
//	rep(i,0,n) printf("%d %d\n",pos[i],lab[i]);
	rep(i,0,n) {
		int p=pos[i],r=(p-i)/2%2;
		if (p==i) continue;
		int n1=num[i],n2=num[i+1];
		lab[n2]^=1; lab[n1]^=r; lab[i]^=r;
		swap(pos[i],pos[n1]);
		swap(num[i],num[p]);
	}
//	rep(i,0,n) printf("%d %d\n",pos[i],lab[i]);

	rep(i,0,n-3) {
		if (lab[i]) lab[i]^=1,lab[i+1]^=1,lab[i+2]^=1,lab[i+3]^=1;
	}
	if (lab[n-1]==lab[n-3]&&lab[n-2]==0) {
		puts("Yes");
	} else {
		puts("No");
	}
}


Measured memory_bytes: 2944
S = input()
N = len(S)
L = [1]*N

for i,s in enumerate(S):
  if s == "R":
    s2 = S[i+1]
    if s2 == "R":
      L[i+2] += L[i]
      L[i] = 0

for i in range(N-1,-1,-1):
  s = S[i]
  if s == "L":
    s2 = S[i-1]
    if s2 == "L":
      L[i-2] += L[i]
      L[i] = 0

print(*L)

Measured memory_bytes: 6400
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <fstream>
#include <cassert>
#include <cstdio>
#include <bitset>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define ll long long
#define maxn 205
int main()
{
   string s;
   cin>>s;
   ll t;
   cin>>t;
   int flag=0;
   if(t<=s.length()){
	   int hh=0,st=0;
	   for(int i=0;i<t;++i)
	   {
		   if(s[i]!='1'){hh=1;st=i;break;}
	   }
	   if(hh) cout<<s[st]<<endl;
	   else cout<<"1"<<endl;
   }
   else{
   for(int i=0;i<s.length();++i)
    {
		if(s[i]!='1') {cout<<s[i]<<endl;flag=1;break;}
	}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;

int main(){
    long n;
    cin >> n;
    long digit = 10000000000;
    double sq = sqrt(static_cast<double>(n+1));
    for(int i=1; i<=n; i++){
        if (n%i==0) {
            long a = max(std::to_string(i).length(),std::to_string(n/i).length());
            digit = min(a,digit);
        } else if (sq < double(i)) {
            break;
        }
    }
    cout << digit << endl;
    return 0;
}

Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace B_ABC132
{
    class MainClass
    {

        static int[] s;
        static int[] n;

        public static void Main(string[] args)
        {
            n = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            int cnt = 0;

            for(int i= 1;i<n[0]-1;i++){
                if((s[i]>s[i-1]&&s[i]<s[i+1])||(s[i]<s[i-1]&&s[i]>s[i+1])){
                    cnt++;

                }

            }
            WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
using namespace std;
using uint = unsigned;
int main(){
    uint sum = 0;
    uint max = 0;
    uint n, tmp;
    cin >> n;

    while(n--) {
        cin >> tmp;
        sum += tmp;
        if (tmp > max) {
            max = tmp;
        }
    }
    sum -= max;
    cout << ((max < sum) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

static const ll MAX_N = 100001;
static const ll MAX_M = 200001;

ll V, E;
struct edge {
	ll from, to, cost;
};
edge es[MAX_M];
ll d[MAX_N];
void bellmanford(ll s) {
	fill(d, d + V, INF);
	d[s] = 0;
	ll cnt = 0;
	while (1) {
		cnt++;
		bool update = false;
		rep(i, 0, E) {
			edge e = es[i];
			if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				if (cnt == V - 1) {
					cout << "NEGATIVE CYCLE" << endl;
					exit(0);
				}
				update = true;
			}
		}
		if (!update) break;
	}
}
vector<edge> G[MAX_N];
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> que;

void dijkstra(ll s) {
	fill(d, d + V, INF);
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top(); que.pop();
		ll v = p.second;
		if (p.first > d[v])continue;
		rep(i, 0, G[v].size()) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main() {
	ll r; cin >> V >> E >> r;
	//rep(i, 0, E) {
	//	ll s, t, d; cin >> s >> t >> d;
	//	G[s].push_back(edge{ t, d });
	//	//G[t].push_back(edge{ s, d });
	//}
	rep(i, 0, E) {
		ll s, t, d; cin >> s >> t >> d;
		es[i].from = s;
		es[i].to = t;
		es[i].cost = d;
	}

	//dijkstra(r);
	bellmanford(r);

	rep(i, 0, V) {
		if (d[i] == INF)cout << "INF" << endl;
		else cout << d[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 5476
#include <stdio.h>
#include <ctype.h>
#include <string.h>


int main() {
	int A, B, C;
	int K;
	int sum = 0;
	scanf("%d %d %d %d", &A, &B, &C, &K);
	if (K > A) {
		sum = A;
		K = K - A;
	}
	
	else if (K == A) {
		sum = A;
		K = 0;
	}
	else if (K < A) {
		sum = K;
		K = 0;
	}
	//printf("%d", sum);
	if (K > B) {
		K = K - B;
	}
	else if (K == 0) {
		K = 0;
	}
	else if (K <= B) {
		K = 0;
	}
	//printf("%d", sum);
	if (K > 0) {
		sum = sum - K;
	}
	printf("%d", sum);
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    bool ans   = true;
    int mx = 0;
    rep(i, N) {
        int H;
        cin >> H;
        if (H >= mx - 1) {
            mx = max(mx,H);
        }
        else {
            ans = false;
            break;
        }
    }

    if (ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
//B
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

int main() {
	string S, T;
	cin >> S >> T;
	int ans = 0;
	int l1 = S.length();
	for (int i = 0; i < l1; i++) {
		if (S[i] != T[i]) ans++;
	}
	printf("%d\n", ans);
}

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

int main() {
    int n;
    cin >> n;
    int t[100000];
    int maxi = -1;
    rep(i, n) {
        cin >> t[i];
        maxi = max(maxi, t[i]);
    }

    vector<int> div;
    for (int i = 1; i*i <= maxi; i++) {
        if (maxi%i == 0) {
            div.push_back(i);
            if (i != maxi/i) div.push_back(maxi/i);
        }
    }
    sort(div.begin(), div.end());

    //rep(i, div.size()) cout << div[i] << " ";

    int ans = 0;
    rep(i, n) rep(j, div.size()-1) {
        if (div[j] < t[i] && t[i] <= div[j+1]) ans += div[j+1]-t[i];
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3504
n,h = map(int,input().split())
a = []
b = []
for i in range(n):
    ai,bi = map(int,input().split())
    a.append(ai)
    b.append(bi)
Ma = max(a)
b.sort(reverse = True)
count = 0
for i in range(n):
    if b[i] > Ma:
        count += 1
        h -= b[i]
        if h <= 0:
            print(count)
            exit()
    else:
        break
count += -(-h//Ma)
print(count)

Measured memory_bytes: 11348
import java.util.*;
public class Main
{static int c=0;
    public static void main(String[] args)
    { Scanner sc=new Scanner(System.in);
        int num=sc.nextInt();
        int k=sc.nextInt();
        double sum_power=0,count=0;
        if ((num>=1 && num<=100000) && (k>=1 && k<=100000)){
        for(int i=1;i<=num;i++){
            count=doublet(i,k);
        double p=Math.pow(2,count)*num;
            sum_power=sum_power+1/p;
            c=0;
        }
        System.out.println(sum_power);
    }
}

    static int doublet(int n,int f){
        if (n<f){
            c=c+1;
            return doublet(2*n,f);}
        else
            return c;}
        }



Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 100;
set<int> s;
int h[N], d[N], cnt, n, k, q[N], p[N];
priority_queue<int, vector<int>, greater<int> > r;
struct edge{
	int to, next;
}e[N<<2];

template<class I> inline void gi(I & x) {
	int f = 1;
	char c; x = 0;
	while (!isdigit(c = getchar())) if (c == '-') f = -1;
	while (isdigit(c)) x = x * 10 + (c & 15), c = getchar();
}

void add(int u, int v) {
	e[++cnt] = (edge) {v, h[u]}; h[u] = cnt;
	d[v] ++;
}

int main() {
	gi(n), gi(k);
	for (int i = 1; i <= n; i++) gi(p[i]), q[p[i]] = i;
    set<int>::iterator it;
	for (int i = 1; i <= n; i++) {
		if (i > k) s.erase(p[i - k]);
		it = s.insert(p[i]).first;
		if (++it != s.end()) add(i, q[*it]);
	}
	s.clear();
	for (int i = n; i; i--) {
		if (i + k <= n) s.erase(p[i+k]);
		it = s.insert(p[i]).first;
		if (++it != s.end()) add(i, q[*it]);
	}
	for (int i = 1; i <= n; i++) if (!d[i]) r.push(i);
	for (int i = 1; i <= n; i++) {
		int x = r.top(); r.pop();
		p[x] = i;
		for (int j = h[x]; j; j = e[j].next) {
			int v = e[j].to;
			d[v] --;
			if (!d[v]) r.push(v);
		}
	}
	for (int i = 1; i <= n; i++) printf("%d\n", p[i]);

}




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

int main(int argc, char const *argv[]) {
    int n, T;
    cin >> n >> T;

    vector<int> c, t;
    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >> tmp;
        c.push_back(tmp);

        cin >> tmp;
        t.push_back(tmp);
    }

    int index = -1;
    int min = INT_MAX;
    for (int j = 0; j < n; ++j) {
        if (t.at(j) > T) continue;

        if (c.at(j) < min) {
            min = c.at(j);
            index = j;
        }
    }

    if (index != -1) {
        cout << c.at(index) << endl;
    } else {
        cout << "TLE" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = (1LL<<31) - 1;
const ll inf_l = 1LL<<61;
const int MAX = 1e5;

int main() {
    int a, b; cin >> a >> b;
    if (a + b == 15) cout << '+' << endl;
    else if (a * b == 15) cout << '*' << endl;
    else cout << 'x' << endl;
}

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

class dice{

public:
  int _1,_2,_3,_4,_5,_6,temp;

  void moveN(){
    temp=_1;
    _1=_2;
    _2=_6;
    _6=_5;
    _5=temp;
  }

  void moveE(){
    temp=_1;
    _1=_4;
    _4=_6;
    _6=_3;
    _3=temp;
  }

  void moveW(){
    temp=_1;
    _1=_3;
    _3=_6;
    _6=_4;
    _4=temp;
  }

  void moveS(){
    temp=_1;
    _1=_5;
    _5=_6;
    _6=_2;
    _2=temp;
  }

  void spin(){
    temp=_2;
    _2=_3;
    _3=_5;
    _5=_4;
    _4=temp;
  }

};
int main(){
  dice d[100];
  int i,j,k,l,n;
  cin>>n;
  for(i=0; i<n; i++)cin>>d[i]._1>>d[i]._2>>d[i]._3>>d[i]._4>>d[i]._5>>d[i]._6;
  for(i=0; i<n; i++)for(j=0; j<n; j++){
     if(i==j)continue;
      for(k=0; k<3; k++){
        if(k==1)d[i].moveE();
        if(k==2){
          d[i].moveE();
          d[i].moveE();
        }
          for(l=0; l<4; l++){
            d[i].spin();
            if(d[i]._1==d[j]._1 &&
               d[i]._2==d[j]._2 &&
               d[i]._3==d[j]._3 &&
               d[i]._4==d[j]._4 &&
               d[i]._5==d[j]._5 &&
               d[i]._6==d[j]._6){
              cout<<"No"<<endl;
              return 0;
              }
        }
      }
    }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<math.h>
#include<queue>
#include<stack>
#include<string.h>
#include<algorithm>
#include<cctype>
#include<vector>
#include<map>
#include<set>
typedef long long ll;
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a+b+c>=22)printf("bust\n");
	else printf("win\n");
}

Measured memory_bytes: 128
/*
The year is 2050, league is played by less than 100 people. T1 has finally reached Masters,
"Macaiyla I did it!" he yells excitedly. The sound echoes through the empty trailer. Macaiyla left long ago...
 */
import java.io.*;
import java.util.*;
import java.lang.Math;
import java.math.BigInteger;

public class Main {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

        public int nextInt() {return Integer.parseInt(next());}

        public long nextLong() {return Long.parseLong(next());}

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        final int MOD = 1000000007;

        int m = sc.nextInt();
        int d = sc.nextInt();

        int cnt = 0;
        for(int i=12;i<=d;i++) {
            int d1 = i / 10;
            int d10 = i % 10;
            if(d1 >= 2 && d10 >= 2 && d1 * d10 <= m) cnt++;
        }

        pw.println(cnt);
        pw.close();
    }
}

// ceil(a/b) = (a+b-1)/b
// PRO TIP: THE BEST ANSWER IS THE RIGHT ANSWER



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

int main() {
    int N; cin >> N;
    long long x; cin >> x;
    vector<long long> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    int res = 0;
    for (int i = 0; i < N; ++i) {
        if (x >= a[i]) ++res, x -= a[i];
        else break;
    }
    if (res == N && x) --res;
    cout << res << endl;
}

Measured memory_bytes: 3636
'''A - Cats and Dogs
https://atcoder.jp/contests/abc094/tasks/abc094_a

猫と犬が合わせて A + B 匹います． このうち A 匹は猫であることがわかっていますが，
残りの B 匹は猫と犬のどちらであるかわかっていません．

この A + B 匹の中に，猫がちょうど X 匹いるということはありうるかどうか判定してください．

>>> main(3, 5, 4)
YES
>>> main(2, 2, 6)
NO
>>> main(5, 3, 2)
NO'''


def main(a, b, x):
    if a <= x <= a + b:
        print('YES')
    else:
        print('NO')


if __name__ == "__main__":
    a, b, x = map(int, input().split(' '))
    main(a, b, x)


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

int main() {
  int N;
  cin >> N;
    bool a=false;
  for (int i = 0; i < N; i++){
    string s;
    cin >> s;
    if(s=="Y") a=true;

  }  
  
  if(a) cout<<"Four";
  else cout<<"Three";

}

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

using namespace std;

const int MAXN = 1E5;
int h[MAXN];
int dp[MAXN];

int main()
{
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> h[i];
    for (int i = 1; i < n; i++)
    {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        for (int j = 2; j <= k && i - j >= 0; j++)
        {
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<((int)n);i++)
#define rep1(i,n) for(ll i=1;i<=((int)n);i++)
#define pb push_back
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define int long long
#define F first
#define S second
typedef long long ll;

signed main()
{
    //IOS;
    string s;
    while(cin>>s)
    {
        ll sum=0;
        rep(i,s.size())
        {
            if(s[i]!=s[s.size()-1-i]) sum++;
        }
        cout<<sum/2<<"\n";
    }

}


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

using namespace std;


int main(){
	int n=0;
	string str;
	cin >> str;
	char s=str[0];

	for(int i=1; i<str.length(); i++){
		if(str[i] != s){
			s=str[i];
			n++;
		}
	}

	cout << n << endl;

	return 0;
}

Measured memory_bytes: 512
N = int(input())
Alist = list(map(int,input().split()))

anslist = [0]*(N+1)
for i in range(len(Alist)):
  anslist[Alist[i]]+=1
#print (anslist)
for i in range(len(anslist)):
  if i!=0:
    print (anslist[i]) 

Measured memory_bytes: 32296
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	static final boolean debugMode = false;

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

		int k = readInt(sc);
		int[][] memo = new int[k + 1][k + 1]; // 0

		int ans = 0;

		for (int a = 1; a <= k; a++) {
			for (int b = a; b <= k; b++) {
				for (int c = b; c <= k; c++) {
					int bc = 0;

					if (memo[b][c] != 0)
						bc = memo[b][c];
					else {
						bc = gcd(b, c);
						memo[b][c] = bc;
					}

					int g = 0;
					if (memo[a][bc] != 0)
						g = memo[a][bc];
					else {
						g = gcd(a, bc);
						memo[a][bc] = g;
					}

					if (a == b && b == c)
						ans += g;
					else if (a == b || b == c)
						ans += g * 3;
					else
						ans += g * 6;

				}
			}
		}

		System.out.println(ans);
	}

	// con.) a >= b
	static int gcd(int a, int b) {
		while (true) {
			if (b == 0)
				break;

			int mod = a % b;
			a = b;
			b = mod;
		}
		return a;
	}

	static int readInt(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	static void log(String s) {
		if (debugMode) {
			System.out.println(s);
		}
		return;
	}
}

class Pair {
	private int x;
	private int y;

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public Pair() {

	}

	public Pair(int x, int y) {
		this.x = x;
		this.y = y;
	}

}

Measured memory_bytes: 27364
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;
const int mod= 1e9 + 7;


ll A[200002],B[200002],C[200002];
ll ans;
ll N;


bool isOK(ll index, ll key) {
	if (C[index] >= key)return true;//ここの配列名を適宜変えよう！
	else return false;
}


ll binary_search(ll key) {

	ll left = 0, right = N;//ここの配列名を適宜変えよう！
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;

		if (isOK(mid, key))right = mid;
		else left = mid;
	}
	return right;
}

map<int, int> mp;

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

	

	cin >> N;

	FOR(i, 1, N+1) {
		cin >> A[i];
		B[i] = i - A[i];
		mp[B[i]]++;
		C[i] = A[i] + i;
	}


	FOR(i, 1, N + 1) {
		ans += mp[C[i]];
	}


	cout << ans << endl;





	return 0;
}


Measured memory_bytes: 24848
#include"bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())

int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int dy = y2 - y1;
	int dx = x2 - x1;
	cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int main(){
	int n;
	int a[maxn][4];
	int dp[maxn][4];
	memset(dp,0,sizeof(dp));
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= 3;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= 3;j++){
			dp[i][1] = max(dp[i-1][2]+a[i][1],dp[i-1][3]+a[i][1]);
			dp[i][2] = max(dp[i-1][1]+a[i][2],dp[i-1][3]+a[i][2]);
			dp[i][3] = max(dp[i-1][1]+a[i][3],dp[i-1][2]+a[i][3]);
		}
	}
	int ans = max(dp[n][1],max(dp[n][2],dp[n][3]));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int base=a.at(0);
    int m=1;
    for(int i=1;i<n;i++){
        if(a.at(i)<base){
            m++;
            base=a.at(i);
        }
    }
    cout<<m<<endl;
}

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

int main()
{
  int N;
  cin >> N;
  int min_;
  cin >> min_;
  int ans = 1;
  rep(i, N - 1)
  {
    int p;
    cin >> p;
    if (p <= min_)
    {
      min_ = p;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    a = list(map(int, input().split()))

    count = 0
    pointer = 1
    for a_i in a:
        if a_i == pointer:
            pointer += 1
        else:
            count += 1

    if count == N:
        count = -1

    print(count)
        

if __name__ == "__main__":
    main()


Measured memory_bytes: 24744
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int dp[100100];

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];

    rep(i,n) dp[i] = INF;
    dp[0] = 0;
    rep(i,n) {
        dp[i+1] = min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
        dp[i+2] = min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        int[] n=System.Console.ReadLine().Trim().Split(' ').Select(x=>int.Parse(x)).ToArray();
        if((n[0]*n[1])%2==0)
        System.Console.WriteLine("Even");
        else
        System.Console.WriteLine("Odd");
    }
}

Measured memory_bytes: 13268
#include<cstdio>
#include<iostream>
using namespace std;
int n,k;
int a[300010];
int main()
{
	scanf("%d%d",&k,&n);
	if(k&1)
	{
		for(int i=1;i<=n;i++)
			a[i]=(k+1)/2;
		int last=n;
		for(int i=1;i<=n/2;i++)
			if(a[last]==1) last--;
			else 
			{
				a[last]--;
				for(int j=last+1;j<=n;j++)
					a[j]=k;
				last=n;
			}
		for(int i=1;i<=last;i++)
			printf("%d ",a[i]);	
	}
	else
	{
		printf("%d ",k/2);
		for(int i=2;i<=n;i++)
			printf("%d ",k);
	}
	return 0;
}

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

using namespace std;
using ll = long long;

const ll INF = 1LL << 58;

template <class T> int former(const vector<T> &v, T x) {
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}

template <class T> int latter(const vector<T> &v, T x) {
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B, Q;
  cin >> A >> B >> Q;
  vector<ll> S(A), T(B);
  for (int i = 0; i < A; i++)
    cin >> S[i];
  for (int i = 0; i < B; i++)
    cin >> T[i];
  S.push_back(INF);
  S.push_back(-INF);
  sort(S.begin(), S.end());
  T.push_back(INF);
  T.push_back(-INF);
  sort(T.begin(), T.end());

  for (int k = 0; k < Q; k++) {
    ll x;
    cin >> x;
    ll res = INF;

    for (int i = 0; i < 2; i++) {
      ll first = (i ? S[former(S, x)] : S[latter(S, x)]);
      for (int j = 0; j < 2; j++) {
        ll second = (j ? T[former(T, first)] : T[latter(T, first)]);
        res = min(res, abs(x - first) + abs(first - second));
      }
    }

    for (int i = 0; i < 2; i++) {
      ll first = (i ? T[former(T, x)] : T[latter(T, x)]);
      for (int j = 0; j < 2; j++) {
        ll second = (j ? S[former(S, first)] : S[latter(S, first)]);
        res = min(res, abs(x - first) + abs(first - second));
      }
    }
    cout << res << '\n';
  }
  return 0;
}


Measured memory_bytes: 2912
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>

typedef long long ll;
const ll INF = 1e18;

int main(int argc, char* argv[])
{
  ll N, T;
  std::cin >> N >> T;

  ll ans = INF;
  for (ll i = 0; i < N; i++) {
    ll c, t;
    std::cin >> c >> t;
    if (t <= T) {
      ans = std::min(c, ans);
    }
  }    

  if (ans == INF) {
    std::cout << "TLE" << std::endl;
  } else {
    std::cout << ans << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256