akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("O3","Ofast")
using namespace std;

template<class T> ostream& operator<<(ostream &os,vector<T> V){os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";}
template<class L,class R> ostream& operator<<(ostream &os,pair<L,R> P){return os<<"("<<P.first<<","<<P.second<<")";}
#define DEBUG1(x) cout  << '>' << " " << #x << ':' << " " <<  x << endl;
#define DEBUG2(x,y) cout  << '>' << " " << #x << ':' << " " <<  x <<  " " << #y << ':' << " " <<  y <<endl;
#define DEBUG3(x,y,z) cout  << '>' << " " << #x << ':' << " " <<  x << " " << #y << ':' << " " <<  y <<" " << #z << ':' << " " <<  z << " " <<endl;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define TC int t; cin >> t;while(t--)
#define forn(i,n) for(int i=0;i<n;i++)

#define ALL(x) x.begin(),x.end()
#define LL long long int
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define endl "\n"

typedef pair<int,int>PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<PII> VPII;

const int mod = 10*9+7;
const int inf = 2e9;
const LL linf = 2e18;
const double eps = 1e-9;

/////////////////////////////

int main(){
    int n;
    cin >> n;
    int arr[n];
    forn(i,n){
        cin >> arr[i];
    }
    int dp[n + 1];
    fill(dp, dp + n, inf);
    dp[1] = abs(arr[1] - arr[0]);
    dp[0] = 0;
    for (int i = 2; i < n;i++){
        dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[i - 2] + abs(arr[i] - arr[i - 2]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> A(200001);
  rep(i, n) {
    int x;
    cin >> x;
    A[x]++;
  }

  int cnt = 0;
  sort(A.begin(), A.end(), greater<int>());
  rep(i, 200001) {
    if (A[i] == 0) break;
    cnt++;
  }
  int tmp = 0;
  int ans = 0;
  rep(i, 200001) {
    if (A[i] == 0) break;
    if (k <= tmp) ans += A[i];
    else tmp++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define V vector<int>
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int s[10];

int n;
int ans = 0;
void dfs(int i, int sum, int now) {
	if (i == n - 1) {
		ans += sum + now;
	}
	else {
		dfs(i + 1, sum + now, s[i + 1]);
		dfs(i + 1, sum, now * 10 + s[i + 1]);
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string str; cin >> str;
	n = str.size();
	rep(i, str.size()) {
		s[i] = str.at(i) - '0';
	}
	dfs(0, 0, s[0]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
      int[] A = new int[5];
      for(int i = 0; i < 5; i++) A[i] =sc.nextInt();
      int ans = 1;
      for(int i = 0; i < 5; i++){
        if(A[i] == 0) ans +=i;
      }
      System.out.println(ans);
    } 
}

Measured memory_bytes: 26972
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
if(a==5&&b==5&&c==7||a==5&&b==7&&c==5||a==7&&b==5&&c==5)
    cout<<"YES";
else
    cout<<"NO";
    return 0;
}




Measured memory_bytes: 3036
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int n,K;
int main() {
	scanf("%d%d",&n,&K);
	int t=n/K;
	LL ANS=0;
	ANS+=1ll*t*t*t;
	if(!(K&1)&&n>=K/2) {
		int g=(n-K/2)/K+1;
		ANS+=1ll*g*g*g;
	}
	printf("%lld\n",ANS);
	return 0;
}

Measured memory_bytes: 256
// D.

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n, h;
	cin >> n >> h;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i] >> b[i];
	}
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	int d = a[0];
	int ans = 0, tot = 0;
	for (int i = 0; i < n; ++i) {
		if (b[i] > d) {
			++ans;
			tot += b[i];
			if (tot >= h) {
				break;
			}
		}
	}
	ans += (max(0, h - tot) + d - 1) / d;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int max=-1000000000,res,num;
        int n=sc.nextInt();
        int min=sc.nextInt();
        for(int i=0;i<n-1;i++){
            num=sc.nextInt();
            res=num-min;
            if(res>max){
                max=res;
            }
            if(min>num){
                min=num;
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 67976
#include <stdio.h>
int main()
{   int n;
    scanf("%d",&n);
    int a[n],max=0,pm=-1,sec=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(max<=a[i]){
            sec=max;
            max=a[i];
            pm=i;
        }else if(sec<a[i]){
            sec=a[i];
        }
    }
    for(int i=0;i<n;i++){
        if(i==pm){
            printf("%d\n",sec);
        }else{
            printf("%d\n",max);
        }
    }
    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    ll X,Y;
    cin >> X >> Y;
    ll ans=0;
    while(X<=Y){
        ans++;
        X*=2;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
constexpr ll MOD = 1000000007;
//---------------------------------//

ll mod_pow(ll x, ll n, ll mod = MOD) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	return res;
}


int main() {
	ll N, M;
	cin >> N >> M;
	
	ll ans = 0;
	
	if (N == 1) {
		ans = (M + 1) % MOD;
		cout << ans << endl;
		return 0;
	}
	
	// d \geq 0
	// 0 \leq a_1leq m - (n - 1)d
	ll pat = M / (N - 1) % MOD;
	(ans += (M % (N - 1) + 1) % MOD * (pat + 1) % MOD) %= MOD;
	(ans += (N - 1) % MOD * (1 + pat) % MOD * pat % MOD * mod_pow(2, MOD - 2) % MOD) %= MOD;
	

	
	// d < 0
	// (n - 1)l \leq a_1 \leq m
	// 0 \leq a_1 \leq m - (n - 1)l
	
	M -= N - 1;
	if (M < 0) {
		cout << ans << endl;
		return 0;
	}
	
	pat = M / (N - 1) % MOD;
	(ans += (M % (N - 1) + 1) % MOD * (pat + 1) % MOD) %= MOD;
	(ans += (N - 1) % MOD * (1 + pat) % MOD * pat % MOD * mod_pow(2, MOD - 2) % MOD) %= MOD;
	
	cout << ans << endl;
	
	return 0;
}



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

int main() {
  int N,a,b,c,d;
  cin >> N;
  for(int i=0;i<N;i++){
    string S;
    cin >> S;
  if(S=="P"){
    a+=1;
  }else if(S=="W"){
    b+=1;
  }else if(S=="G"){
    c+=1;
  }else if(S=="Y"){
    d+=1;
  }
}
 if (d == 0){
   cout <<"Three"<<endl;
 }
 else if(d >=1){
   cout <<"Four"<<endl;
 }
}


Measured memory_bytes: 256
//AtCoder 
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N; cin>>N;
    vector<ll> an(N);
    for(auto&& a:an){
        cin>>a;
    }
	ll ans=0;
    for(ll i=1;i<an.size();++i){
        if (an[i]==an[i-1]){
            ++ans;
            ++i;
        }
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;

const ll md = 998244353; 

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}
 
inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}
 
inline int mul(int a, int b) {
#if !defined(_WIN32) || defined(_WIN64)
  return (int) ((long long) a * b % md);
#endif
  unsigned long long x = (long long) a * b;
  unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
  asm(
    "divl %4; \n\t"
    : "=a" (d), "=d" (m)
    : "d" (xh), "a" (xl), "r" (md)
  );
  return m;
}
 
inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
 
inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
 

int main(){
 
  ll n,a,b,k;
  cin >> n >> a >> b >> k;
  
  vector <int> c(n+1); //comb % modの前計算
  c[0] = 1; // nC0 = 1;
  
  REP(i,n+1)  c[i+1] = mul(c[i],mul(n-i,inv(i+1))); //nCi+1 = nCi * n-i/(i+1)
//  REP(i,n+1) debug (c[i]);
  
  int ans = 0;
  REP(i,n+1){
    ll X = k-a*i;
    if(X % b != 0 || X < 0) continue;
    ll B = X/b; // Bの数
    if(B >= 0 && B <= n)
    add(ans,mul(c[i],c[B]));
  }
    
  
  cout << ans << endl; 
    
  return 0;
}

Measured memory_bytes: 1408
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

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

        final int N = sc.nextInt();
        final int K = sc.nextInt();

        final Integer[] L = new Integer[N];
        for (int i = 0; i < N; i++) L[i] = sc.nextInt();

        Arrays.sort(L, Comparator.reverseOrder());

        int len = 0;
        for (int i = 0; i < K; i++) len += L[i];

        System.out.println(len);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=0;
    cin>>n;
    string s[n];
    set <string> u;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
        u.insert(s[i]);
    }
    cout<<u.size();
    return 0;
}


Measured memory_bytes: 25352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static int A;
    static int B;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        A = sc.nextInt();
        B = sc.nextInt();

        System.out.println(solve() ? "Yes" : "No");
    }

    static boolean solve() {
        for (int c = 1; c < 3; c++) {
            if( A * B * c % 2 == 1 ) return true;
        }
        return false;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

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

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

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int C=0,F=0;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='C') C=1;
		if(s[i]=='F'&&C==1) F=1;
	}
	if(C==1&&F==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int a, b, c, d;

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    cin>>a;
    for(int i=1;;i++){
        if(i*i>a){
            cout<<(i-1)*(i-1);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
number =[]
for x in range (0, N+1):
  for y in range (0, N+1-x):
    z = N -x -y
    if z >= 0 and x*10000 + 5000*y + z*1000 == Y:
        number.append(x)
        number.append(y)
        number.append(z)

if len(number) >=3:
  print('{} {} {}'.format(number[0],number[1],number[2]))
else:
  print('-1 -1 -1')
  

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

string s, t;
vector<ll> c[30];
ll x, times;
int main() {
	ll i, j, k;
	cin >> s >> t;
	for(i=0; s[i]; i++) c[s[i]-'a'].push_back(i);
	for(i=0, j=-1; t[i]; i++) {
		x = t[i] - 'a';
		if(c[x].size()==0) return puts("-1"), 0;
		k = upper_bound(c[x].begin(), c[x].end(), j) - c[x].begin();
		if(k == c[x].size()) {
			times++;
			j = c[x][0];
		} else {
			j = c[x][k];
		}
	}
	cout << times * (ll)s.size() + j + 1;
	return 0;
}


Measured memory_bytes: 1852
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;cin >> k;
    string s;cin >> s;
    if(s.size()<=k){
        cout << s << endl;
    }
    else{
        cout << s.substr(0,k) << "..." << endl;
    }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int ct=0;
void solve(int d)
{ 
  long double b;
  long p,q;
  cin>>p>>q;
  b=sqrt(p*p+q*q);
  
  if(b<=d)
    ct++;


  
  }
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Pranab
   freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
   #endif  
 
   int t=1,d; 
   cin>>t>>d;
 
   while(t--)
   {solve(d);}
    cout<<ct;
   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

   return 0;
}

Measured memory_bytes: 3816
#pragma GCC optimize("Ofast")

//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main() {
  // 高速化
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n, m;
    cin >> n >> m;
    int ans = 0;

    if(n>=2) ans += n *(n-1)/2;
    if(m>=2) ans += m *(m-1)/2;

    cout << ans << "\n"; 

    return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
mod=10**9+7
ans=1

if K%2==1 and A[-1]<0:
    for i in range(K):
        ans=ans*A[N-(i+1)]%mod
    print(ans)
    exit()

l=0
r=N-1
if K%2==1:
    ans=ans*A[r]
    r-=1

for _ in range(K//2):
    ml=A[l]*A[l+1]
    mr=A[r]*A[r-1]
    if ml>mr:
        ans=ans*ml%mod
        l+=2
    else:
        ans=ans*mr%mod
        r-=2

print(ans)


Measured memory_bytes: 31656
#include<stdio.h>
int main(){
	int a[4],b[4],x=0,y=0,i;
	for(i=0;i<4;i++){
		scanf("%d",&a[i]);
		x=x+a[i];
	}
	for(i=0;i<4;i++){
		scanf("%d",&b[i]);
		y=y+b[i];
	}
	if(x<y)x=y;
	printf("%d\n",x);
	return 0;
}


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

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

using namespace std;

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


signed main(){
    string S;
    cin>>S;
    if(S=="AAA"||S=="BBB") cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


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

using namespace std;

typedef long long ll;

const int N = 3005;

string s0, s1;

int memo[N][N];
bool vis[N][N];

int dp(int id0, int id1){
    if(id0 == - 1 || id1 == - 1) return 0;
    if(vis[id0][id1]) return memo[id0][id1];
    vis[id0][id1] = true;
    int ans = max(dp(id0, id1 - 1), dp(id0 - 1, id1));
    if(s0[id0] == s1[id1]) ans = max(ans, dp(id0 - 1, id1 - 1) + 1);
    return memo[id0][id1] = ans;
}

string r;
void re(int id0, int id1){
    if(id0 == - 1 || id1 == - 1) return;
    if(memo[id0][id1] == dp(id0, id1 - 1)) re(id0, id1 - 1);
    else if(memo[id0][id1] == dp(id0 - 1, id1)) re(id0 - 1, id1);
    else{
        re(id0 - 1, id1 - 1);
        r.push_back(s0[id0]);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s0 >> s1;
    dp(s0.size() - 1, s1.size() - 1);
    re(s0.size() - 1, s1.size() - 1);
    cout << r << endl;
}

Measured memory_bytes: 44672
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
const int M = 100000;
const double pi = 3.141592653589;

int main(){
	int n;
	int b[M], f[M], r[M], v[M];

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b[i] >> f[i] >> r[i] >> v[i];
	}

	for (int i = 0; i < 4; i++) {
		int a[3][10] = { 0 };
		for (int k = 0; k < n; k++) {
			if (b[k] == i+1) {
				a[f[k] - 1][r[k] - 1] = a[f[k] - 1][r[k] - 1]+v[k];
			}
		}
		for (int m = 0; m < 3; m++) {
			for (int l = 0; l < 10; l++) {
				cout <<" "<< a[m][l];
				if (l == 9) cout << endl;
			}
		}
		if (i != 3) {
			cout << "####################" << endl;
		}
	}
	return 0;
}

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

using namespace std;



int main()
{   int x1, x2, x3, x4, y1, y2, y3, y4;
    cin>>x1>>y1>>x2>>y2;
    int a = x1-x2, b = y1-y2;
    x3 = x2+b; y3 = y2-a;
    x4 = x1+b; y4 = y1-a;
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
mod=10**9+7

def cmb(n,r):
  global mod
  if r<0 or r>n:
    return 0
  return (g1[n]*g2[r]*g2[n-r])%mod

def perm(n,r):
  global mod
  if r>n:
    return g1[n]
  if r<0:
    return 0
  return (g1[n]*g2[n-r])%mod

g1=[1,1]
g2=[1,1]
inv=[0,1]
for i in range(2,M+M+5):
  g1.append((g1[-1]*i)%mod)
  inv.append((-inv[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inv[-1])%mod)
P=0
for i in range(N+1):
  P+=pow(-1,i)*cmb(N,i)*perm(M,i)*perm(M-i,N-i)**2
print(P%mod)

Measured memory_bytes: 213196
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;i++){
            a[i] = sc.nextInt();
        }
        for(int i=n-1;i>0;i--){
            System.out.printf("%d ",a[i]);
        }
        System.out.printf("%d\n",a[0]);
        sc.close();

    }
}


Measured memory_bytes: 26596
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

std::vector<int> vec(13);
bool solve(int l = 5, int r = 7, bool f = true) {
	std::vector<int> c(3, 0);
	for(int i = l + 1; i < r; i++) c[vec[i]]++;
	if(c[0] == 6) return false;
	if(c[1] == 6) return true;
	
	bool ret = false;
	if(f) {
		ret = false;
		bool move = false;
		if(l >= 0 and vec[l] == f) {
			ret |= solve(l - 1, r, !f);
			move = true;
		}
		if(r < 13 and vec[r] == f) {
			ret |= solve(l, r + 1, !f);
			move = true;
		}
		if(!move) ret = solve(l, r, !f);
	} else {
		ret = true;
		bool move = false;
		if(l >= 0 and vec[l] == f) {
			ret &= solve(l - 1, r, !f);
			move = true;
		}
		if(r < 13 and vec[r] == f) {
			ret &= solve(l, r + 1, !f);
			move = true;
		}
		if(!move) ret = solve(l, r, !f);
	}
	return ret;
}

int main() {
	int q; cin >> q;
	while(q--) {
		vec.assign(13, 0); vec[6] = 2;
		for(int i = 0; i < 6; i++) {
			int a; cin >> a;
			
			vec[a - 1] = 1;
		}
		
		if(solve()) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}



Measured memory_bytes: 3120
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}

signed main() {
	int n, m;
	cin >> n >> m;
	int x[100005], y[100005];
	rep(i, n) cin >> x[i];
	rep(i, m) cin >> y[i];
	int tate = 0, yoko = 0;
	rep(i, n - 1) {
		int a = (i + 1) * (n - i - 1) % MOD;
		int b = (x[i + 1] - x[i]) % MOD;
		tate += a * b % MOD;
		tate %= MOD;
	}
	rep(i, m - 1) {
		int a = (i + 1) * (m - i - 1) % MOD;
		int b = (y[i + 1] - y[i]) % MOD;
		yoko += a * b % MOD;
		yoko %= MOD;
	}
	cout << tate * yoko % MOD << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

const int Maxn=2000;
const int INF=2100000000;

int n;
int A,B;
int num[Maxn+5];
int pool[Maxn+50],tot;
int dp[Maxn+5][Maxn+5][2];

int dfs(int rv,int st,int isMax){
	if (dp[rv][st][isMax]!=-1) return dp[rv][st][isMax];

	int ret=isMax?-INF:INF;
	for (int i=st+1;i<=n;i++){
		int now=0;
		if (i==n) now=abs(pool[num[i]]-pool[rv]); else now=dfs(num[i],i,isMax^1);
		if (isMax){
			ret=max(ret,now); 
		}else ret=min(ret,now); 
	}

	//printf("%c >%d [%d] = %d\n",isMax?'A':'B',st,pool[rv],ret);
	return dp[rv][st][isMax]=ret;
}

int main(){
	//freopen("in.txt","r",stdin);
	scanf("%d%d%d",&n,&A,&B);
	for (int i=1;i<=n;i++) scanf("%d",&num[i]);
	memset(dp,-1,sizeof(dp));

	tot=0;
	for (int i=1;i<=n;i++) pool[++tot]=num[i];
	pool[++tot]=A; pool[++tot]=B;
	sort(pool+1,pool+tot+1);
	tot=unique(pool+1,pool+tot+1)-pool;

	for (int i=1;i<=n;i++) num[i]=lower_bound(pool+1,pool+tot,num[i])-pool;
	A=lower_bound(pool+1,pool+tot,A)-pool; 
	B=lower_bound(pool+1,pool+tot,B)-pool;

	printf("%d\n",dfs(B,0,true));
	return 0;
}

Measured memory_bytes: 31744
#--------------------------------------------
#ライブラリ呼び出し
import sys
import math
#--------------------------------------------
K, N = map(int, input().split())
arr = list(map(int, input().split()))
List=[]
for i in range(N-1):
    sa =int(arr[i+1]-arr[i])
    List.append(sa)

max_num = max(List)
hasi = K-arr[N-1]+arr[0]
PPP = (max(max_num,hasi))
ans = K-PPP
print(ans)

Measured memory_bytes: 26444
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse=True)

l = -1
r = 10 ** 12


def ok(c):
    s = 0
    for a, f in zip(A, F):
        s += max(0, a - c//f)
    return s <= K


while r - l > 1:
    c = (l+r)//2
    if ok(c):
        r = c
    else:
        l = c

print(r)


Measured memory_bytes: 119500
H, W = map(int, input().split())
S = [input() for i in range(H)]
h, w = [True for _ in range(H)], [True for _ in range(W)]
for i in range(H):
  cnt = 0
  for j in range(W):
    if S[i][j] == '.':
      cnt += 1
  if cnt == W:
    h[i] = False
for i in range(W):
  cnt = 0
  for j in range(H):
    if S[j][i] == '.':
      cnt += 1
  if cnt == H:
    w[i] = False
for i in range(H):
  if h[i]:
    T = ""
    for j in range(W):
      if w[j]:
        T = T[:] + S[i][j]
    print(T)

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


int main()
{
	int n,m;
	cin>>n>>m;
	set<int>se;
	while(m--)
	{
		int x,y;
		cin>>x;
		while(x--) cin>>y,se.insert(y);
	}
	cout<<n-se.size(); 
	return 0;
}

Measured memory_bytes: 3608
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    int answer = c - a + b;
    
    if (answer < 0) {
      System.out.println(0);
    } else {
	  System.out.println(answer);
    }
  }
}

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

int main()
{
	int a,b;
	cin>>a>>b;
	
	int v=0;
	for(int i=a;i<=b;i++){
		if(i/10000==i%10&&i%10000/1000==i%100/10) v++;
	}
	
	cout<<v<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
int n;
int A[20];

int saiki(int num,int index){
  if(num==0){
    return 1;
  }
  if(index==n||num<0){
    return 0;
  }
  if(saiki(num-A[index],index+1)||saiki(num,index+1)){
    return 1;
  }
  return 0;
}

int main(){
  std::cin>>n;
  int i;
  for(i=0;i<n;i++){
    std::cin>>A[i];
  }
  int q;
  std::cin>>q;
  int num;
  for(i=0;i<q;i++){
    std::cin>>num;
    if(saiki(num,0)==0){
      std::cout<<"no\n";
    }else{
      std::cout<<"yes\n";
    }
  }
  return 0;
}


Measured memory_bytes: 3088
//B.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <stdio.h>
using namespace std;

int main(){
  string S;
  cin >> S;
  int l = S.length();
  string subS;
  int num;
  int min = 1000;
  for(int i = 0; i < l-2;i++){
    subS = S.substr(i,3);
    num = atoi(subS.c_str());
    if(abs(753-num) < min) min = abs(753-num);
  }
  printf("%d\n", min);
  return 0;
}


Measured memory_bytes: 256
import numpy as np
from heapq import *

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

h = []
heappush(h, (-A[0]-B[0]-C[0], 0, 0, 0))
used = set()
result = []

for _ in range(K):
    sum, i, j, k = heappop(h)
    result.append(-sum)
    if i < X-1 and (i+1, j, k) not in used:
        heappush(h, (-A[i+1]-B[j]-C[k], i+1, j, k))
        used.add((i+1, j, k))
    if j < Y-1 and (i, j+1, k) not in used:
        heappush(h, (-A[i]-B[j+1]-C[k], i, j+1, k))
        used.add((i, j+1, k))
    if k < Z-1 and (i, j, k+1) not in used:
        heappush(h, (-A[i]-B[j]-C[k+1], i, j, k+1))
        used.add((i, j, k+1))

for v in result:
    print(v)

Measured memory_bytes: 14024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

/*
 * 
 */
int main(int argc, char** argv) {
    
    int Num;
    scanf("%d",&Num);
    int A[100+5]; 
    for(int a = 0; a < Num; a++){
        
        scanf("%d",&A[a]);
    }

    int swap = 0;
    int temp1, temp;
    int min, k, exe;
    
    for(int i = 0; i < Num - 1; i++){
        min = i;
        exe = i;
       for(int j = i + 1; j <  Num; j++){
              if(A[exe] > A[j]){
                  exe = j;
              }
       }
        if(A[i] > A[exe]){
           temp = A[i];
           A[i] = A[exe];
           A[exe] = temp;
           swap++;
        }
    }
    for(int a = 0; a < Num; a++){
        
            printf("%d",A[a]);
            if(a < Num - 1){
                printf(" ");
            } 
    }
    
    printf("\n%d\n",swap);
    return (0);
}


Measured memory_bytes: 2108
/*
 * 	Just close your eyes
 * 		The sun is going down
 * 			You'll be alright...
 * 				No one can hurt you now
 * 					Come, morning light...
*/
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#ifndef rd
#define endl '\n'
#endif
#define deb cout<<"Line: "<<__LINE__<<" plz "
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
#define pii pair<int,int>
#define sz(x) ((int)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define all(con) con.begin(),con.end()
const ll inf=1e18;
const int mod=1e9+7;
typedef vector<int> vi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vector<int> gra[100005];
int dsu[100005];
int wei[100005];
int pend[100005];
vector<pair<int,pii>> edges;
int fpar(int i) {
	return (dsu[i]<0)?i:dsu[i]=fpar(dsu[i]);
}
void merge(int i, int j) {
	if((i=fpar(i))!=(j=fpar(j))) {
		if(dsu[i]>dsu[j])
			swap(i,j);
		pend[i]+=pend[j];
		wei[i]+=wei[j];
		dsu[i]+=dsu[j];
		dsu[j]=i;
	}
}
void solve()
{
	int n,m,u,v,w;
	cin>>n>>m;
	for(int i=1; i<=n; i++)
		dsu[i]=-1;
	int ans=0;
	for(int i=1; i<=n; i++) {
		cin>>wei[i];
	}
	for(int i=1; i<=m; i++) {
		cin>>u>>v>>w;
		edges.pb({w,{u,v}});
	}
	sort(all(edges));
	for(int i=0; i<m; i++) {
		merge(edges[i].se.fi,edges[i].se.se);
		int comp=fpar(edges[i].se.fi);
		pend[comp]++;
		if(wei[comp]>=edges[i].fi) {
			ans+=pend[comp];
			pend[comp]=0;
		}
	}
	cout<<m-ans<<endl;
}
signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	auto clk=clock();
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

signed main ()
{
    fastio
    lli n , d , r = 0 ;
    cin >> n >> d ;
    r = d * 2 + 1 ;

    if (n < r)
        cout << 1 ;
    else if (n % r == 0)
        cout <<  n / r  ;
    else
        cout << n / r + 1 ;
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
import math

def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

cnt = 0
for _ in range(int(input())):
    if(is_prime(int(input()))):
        cnt += 1
print(cnt)




Measured memory_bytes: 5668
#include "bits/stdc++.h"

using namespace std;
using uint = unsigned int;
using int64 = long long;
using i64 = int64;
using uint64 = unsigned long long;
using vint = vector<int>;
using vint64 = vector<int64>;
template<typename T>
using p_que = priority_queue<T>;
#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rep1(i,N) for(int i=1;i<=(int)(N);++i)
#define fs first
#define sc second
#define eb emplace_back
#define all(x) x.begin(),x.end()

template<typename T>
vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "[";
	for (auto& e : v) os << e << ", ";
	return os << "]";
}

template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U> p) {
	return os << "P(" << p.first << ", " << p.second << ")";
}

template<class T, class U> ostream& operator<<(ostream& os, const map<T, U>& mp) {
	os << "{";
	for (auto& e : mp) os << e << " ";
	return os << "}";
}

void Main();
signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
}

/* Cut from here! */

#define int long long

void Main() {
	int x; cin >> x;
	string ans[] = {
		"fri","sat","sun","mon","tue","wed","thu",
		"fri","sat","sun","mon","tue","wed","thu",
		"fri","sat","sun","mon","tue","wed","thu",
		"fri","sat","sun","mon","tue","wed","thu",
		"fri","sat","sun","mon","tue","wed","thu",
	};
	cout << ans[x-1] << endl;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    int x = n*800;
    int y = (n/15)*200;
    cout<<x-y<<endl;
    return 0;
}

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

int main(){
    int N; cin >> N;
    string s; cin >> s;
    
    int right=0;
    int left=0;
    for(int i=0;i<N;i++){
        if(s[i]=='(') right++;
        else{
            if(right==0) left++;
            else right--;
        }
    }
    string l,r;
    l=r="";
    for(int i=0;i<left;i++){
        l+='(';
    }
    for(int i=0;i<right;i++){
        r+=')';
    }
    cout << l+s+r << endl;
    
}

Measured memory_bytes: 256
n = int(input())
li = [0]
for i in range(n):
    li.append(int(input()))
x = 1
visited = set([1])
ans = 0

while True:
    x = li[x]
    if x in visited:
        ans = -1
        break
    visited.add(x)
    ans += 1
    if x == 2:
        break
print(ans)

Measured memory_bytes: 13216
import java.util.*;
import java.io.*;

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		NScanner sc = new NScanner(System.in);
		String W = sc.next().toUpperCase();
		int cnt = 0;
		for(;;){
			String T = sc.next();
			if(T.equals("END_OF_TEXT")) break;
			T = T.toUpperCase();
			
			if(T.equals(W)) ++cnt;
		}
		System.out.println(cnt);
	}

}

class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	public boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


Measured memory_bytes: 24360
#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,m;
    cin >> n>> m;
    vector<int> a;
    int sum=0;
    rep(i,n){
        int b;
        cin >> b;
        a.push_back(b);
        sum+=b;
    }

    sort(a.begin(),a.end());

    rep(i,m){
        if(a[a.size()-1-i]*4*m<sum){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	while (true){
		int a[5];
		int f[4] = { 0 };
		for (int i = 0; i < 5; i++){
			cin >> a[i];
			if (i == 0 && a[i] == 0){
				return 0;
			}
			f[a[i]]++;
		}
		if (f[1]>0 && f[2] > 0 && f[3] > 0 || f[1] > 4 || f[2] > 4 || f[3] > 4){
			for (int i = 0; i < 5; i++){
				cout << "3" << endl;
			}
		}
		else if (f[1]>0 && f[3] > 0){
			for (int i = 0; i < 5; i++){
				if (a[i] == 1){
					cout << "2" << endl;
				}
				else{
					cout << "1" << endl;
				}
			}
		}
		else if (f[2] > 0 && f[3] > 0){
			for (int i = 0; i < 5; i++){
				if (a[i] == 3){
					cout << "2" << endl;
				}
				else{
					cout << "1" << endl;
				}
			}
		}
		else{
			for (int i = 0; i < 5; i++){
				cout << a[i] << endl;
			}
		}
	}
}

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

int main(){
	int N,T,Y,res = 0;
	cin >> N >> T >> Y;
	vector<int> a(N),b(N);
	for(int i = 0;i < N; i++){
		cin >> a.at(i) >> b.at(i);
	}
	for(int i = 0;i < N;i++){
		if((a.at(i) >= T) && (b.at(i) >= Y)){
			res = res + 1;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cstdlib>
#include <list>
#include <limits.h>
#include <utility>
#include <functional>
#include <deque>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/

int a[300010];

int main() 
{
	int n;
	
	scanf("%d", &n);
	for (int i = 1; i <= 3 * n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a + 1, a + 3 * n + 1);
	long long s = 0;
	for (int i = n + 1; i <= 3 * n; i += 2) {
		s += a[i];
	}
	printf("%lld\n", s);
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

typedef struct {
    Int y, x;
} p_t;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {    
    COMinit();
    Int n, k;
    cin >> n >> k;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    Int add = 0;
    for (Int i = k - 1; i < n; i++) {
        add += a[i] * COM(i, k - 1) % mod;
        add %= mod;
    }
    Int sub = 0;
    for (Int i = 0; i < n - k + 1; i++) {
        sub += a[i] * COM(n - i - 1, k - 1) % mod;
        sub %= mod;
    }
    //cout << add << " " << sub << endl;
    dump((add - sub + mod) % mod);
    return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair



ll solve(int N,int M,vi& x,vi& y) {
    vi p(N, 0), k(N, 1);
    p[0] = 1;
    rep(i,M){
        int fr = x[i]-1, to = y[i]-1;
        if (p[fr]) p[to] = 1;
        --k[fr]; ++k[to];
        if (k[fr] == 0) p[fr] = 0;
    }
#ifdef DEBUG
    cerr << k << endl;
    cerr << p << endl;
#endif
    int cnt = 0;
    rep(i,N){
        if (k[i] != 0) cnt += p[i];
    }
    return cnt;
}

int main() {
    int N,M; cin>>N>>M; // 2-1e5 1-1e5
    vi x(M),y(M);
    rep(i,M) cin>>x[i]>>y[i];
    cout << solve(N,M,x,y) << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const int INF=0x3f3f3f3f,max_n=200005,mod=19260817;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll pow(ll a,ll b,ll mod){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;}
ll a[max_n],b[max_n];int x;
vector<int>v[max_n];
ll ans1;
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		a[i]=x+i;
		b[i]=i-x;
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]>=2&&b[i]<=199999)
		{
			v[b[i]].push_back(i);
		}
	}
	for(int i=1;i<=n;i++)
	{
		x=a[i];
		if(x>=2&&x<=199999)
		{
			if(v[x].size()!=0)
			{
				//¶þ·ÖµØÕÒµÚÒ»¸ö´óÓÚiµÄÊý×Ö
				int ll=upper_bound(v[x].begin(),v[x].end(),i)-v[x].begin();
				//cout<<ll<<endl;
				ans1+=v[x].size()-ll;
			}
		}
	}
	cout<<ans1<<endl;
    return 0;
}

Measured memory_bytes: 15364