akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>

#define INPUT_FROM_FILE (0)
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif
	int n = 0;
	std::vector<int> vec;
	std::vector<int> p_vec;

#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif
	vec.resize(n);

	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> vec[i];
#else
		std::cin >> vec[i];
#endif
	}

	std::sort(vec.begin(), vec.end());
	int max_i = vec.size() > 4 ? 4 : vec.size();
	for(int i = 0; i < max_i; i++){
		for(int j = i + 1; j < max_i; j++){
			std::string str0 = std::to_string(vec[i]) + std::to_string(vec[j]);
			std::string str1 = std::to_string(vec[j]) + std::to_string(vec[i]);
			p_vec.push_back(std::atoi(str0.c_str()));
			p_vec.push_back(std::atoi(str1.c_str()));
		}
	}

	std::nth_element(p_vec.begin(), p_vec.begin() + 2, p_vec.end());
	
	std::cout << p_vec[2] << std::endl;
	return 0;
}


Measured memory_bytes: 3224
program main
	implicit none
	integer(8) :: N, i, zero, all_plus, ans
	integer(8), allocatable :: A(:), hugo(:)
	read(*, *) N
	allocate(A(1:N), hugo(1:N))
	read(*, *) A(1:N)
	zero = 0
	do i = 1, N
		if(A(i) < 0) then
			hugo(i) = -1
		else if(A(i) > 0) then
			hugo(i) = 1
		else
			zero = 1
			exit
		end if
	end do
	if(zero == 0) then
	
		do i = 1, N-2
			if(hugo(i) == -1) then
				hugo(i) = 1
				hugo(i+1) = -hugo(i+1)
			end if
		end do
		if(hugo(N-1)*hugo(N) > 0) then
			all_plus = 1
		else
			all_plus = -1
		end if
	end if

	A(1:N) = abs(A(1:N))
	ans = sum(A(1:N))
	if(zero == 1 .OR. all_plus == 1) then
		write(*, *) ans
	else
		ans = ans - 2*minval(A(1:N))
		write(*, *) ans
	end if
end program main

Measured memory_bytes: 2304
from itertools import accumulate
n,c = map(int,input().split())
wv = [[0,0]]+[list(map(int,input().split())) for i in range(n)]+[[c,0]]
n += 2
ansls = []
ls1 = [0]*n
ls2 = [0]*n
ls3 = [0]*n
ls4 = [0]*n
for i in range(1,n):
  w,v = wv[i]
  w -= wv[i-1][0]
  ls1[i] = v-w*2
  ls2[i] = v-w
for i in range(n-2,-1,-1):
  w,v = wv[i]
  w -= wv[i+1][0]
  ls3[n-i-1] = v+w*2
  ls4[n-i-1] = v+w
als1 = list(accumulate(ls1))
als2 = list(accumulate(ls2))
als3 = list(accumulate(ls3))
als4 = list(accumulate(ls4))
als1 = list(accumulate(als1,max))
als2 = list(accumulate(als2,max))
als3 = list(accumulate(als3,max))
als4 = list(accumulate(als4,max))
for i in range(n-1):
  ansls.append(als1[i]+als4[n-2-i])
  ansls.append(als2[i]+als3[n-2-i])
print(max(ansls))

Measured memory_bytes: 68832
#include <bits/stdc++.h>
using namespace std;
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int n,x;cin>>n>>x;
  if(x==1||x==2*n-1)fin("No");
  cout<<"Yes"<<endl;
  int cnt=2;
  for(int i=0;i<(2*n-1-3)/2;i++){
    if(cnt==x)cnt++;
    cout<<cnt++<<endl;
  }
  cout<<1<<endl<<x<<endl<<2*n-1<<endl;
  for(int i=0;i<(2*n-1-3)/2;i++){
    if(cnt==x)cnt++;
    cout<<cnt++<<endl;
  }
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

/*
if you have any question about any part of my code,
please don't shy to ask anytime :)
*/

void solve()
{
    ll a;
    long double b;
    cin >> a >> b;
    cout<<(ll)(a*b+0.001)<<endl;
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 3748
#include<iostream>
#include<cstdio>
#define max(a,b) (a>b?a:b)
using namespace std;
int n,a[111],maxs=0,num[111];
int limi;
bool fail;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i]; maxs=max(a[i],maxs);
        num[a[i]]++;
    }
    if(maxs&1){
        limi=((maxs+1)>>1);
        for(int i=0;i<limi;i++)
            if(num[i]) fail=true;
        if(num[limi]!=2) fail=true;
        for(int i=limi+1;i<=maxs;i++){
            if(num[i]<2) fail=true;
        } 
    }
    else{
        limi=(maxs>>1);//cout<<num[limi]<<endl;
        for(int i=0;i<limi;i++)
            if(num[i]) fail=true;
        if(num[limi]!=1) fail=true;
        for(int i=limi+1;i<=maxs;i++){
            if(num[i]<2) fail=true;
        }
    }
    puts(fail?"Impossible":"Possible");
    return 0;
}

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

int a,b,c;

int main(){
	scanf("%d %d %d",&a,&b,&c);
	if(a==b){
		printf("%d\n",c);
	}else if(a==c){
		printf("%d\n",b);
	}else{
		printf("%d\n",a);
	}
	return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int n,k;
    cin >> n >> k;
    cout << (k == 1?0:n-k) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////
//

int main(){

  int n;
  I(n);
  int ar[n+2],br[n+2];
  for(int i=0;i<n;i++)cin>>ar[i];
  for(int i=0;i<n;i++)cin>>br[i];
  ll res = 0;
  for(int i=0;i<(1<<n);i++){

      ll x= 0,y=0;

      for(int j=0;j<n;j++){
          if((i&(1<<j))){
              x+=ar[j];
              y+=br[j];
          }
      }
      res = max(res, x-y);
  }
  cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
 
 
public class Main{
    public static void main(String[] args) throws IOException {
    	Scanner sc = new Scanner(System.in);
    	
    	while(true){
    		final int N = sc.nextInt();
    		
    		if(N == 0){
    			break;
    		}
    		
    		int[] input = new int[N];
    		for(int i = 0; i < N; i++){
    			input[i] = sc.nextInt();
    		}
    		
    		int[] rnd = new int[N + 1];
    		int[] output = new int[N];
    		
    		int[] alpha = new int[256];
    		
    		double min = Double.MAX_VALUE;
    		int min_S = -1, min_A = -1, min_C = -1;
    		
    		for(int S = 0; S <= 15; S++){
    			for(int A = 0; A <= 15; A++){
    				for(int C = 0; C <= 15; C++){
    					rnd[0] = S;
    					Arrays.fill(alpha, 0);
    					
    					for(int i = 1; i < N + 1; i++){
    						rnd[i] = (A * rnd[i - 1] + C) % 256;
    					}
    					
    					for(int i = 0; i < N; i++){
    						output[i] = (input[i] + rnd[i + 1]) % 256;
    						alpha[output[i]]++;
    					}
    					
    					double score = 0;
    					for(int i = 0; i < 256; i++){
    						if(alpha[i] == 0){
    							continue;
    						}
    						score -= (alpha[i] / (double)(N)) * Math.log(alpha[i] / (double)(N));
    					}
    					
    					
    					
    					if(score < min - 1e-9){
    						min_A = A;
    						min_S = S;
    						min_C = C;
    						min = score;
    						//System.out.println(S + " " + A  + " " + C + " " + score);
    						//System.out.println(Arrays.toString(output));
    					}
    					
    				}
    			}
    		}
    		
    		System.out.println(min_S + " " + min_A + " " + min_C);
    		
    	}
    	
    	
    	
    }
     
}

Measured memory_bytes: 28176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18;
int main(){
    ll n,ans = 0;
    cin>>n;
    vector<ll>a(n+1,0),b(n+1,0);
    repi(i,1,n+1){
        cin>>a[i];
        a[i]+=a[i-1];
    }
    repi(i,1,n+1){
        cin>>b[i];
        if(i!=0)b[i]+=b[i-1];
    }
    repi(i,1,n+1){
        ans = max(ans,(a[i])+(b[n]-b[i-1]));
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	ll n,x,t;
	cin>>n;
	vector<ll> a(n);
	for(int i=0;i<n;i++)
	cin>>a[i];
	ll mi=0,ans=0;
	for(int i=0;i<n;i++){
		if(a[i]<mi)
		ans+=mi-a[i];
		mi=max(mi,a[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4844
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 4e5+5;

int main() {
    int n;
    string s;
    cin >> n >> s;
    if(n & 1){
        puts("No");
        return 0;
    }

    for(int i = 0; i < n/2; i++){
        if(s[i] != s[n / 2 + i]){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
}


Measured memory_bytes: 256
#coding utf-8
N=int(input())
H=list(map(int,input().split()))

H.reverse()
ans=0
for i in range(N-1):
  if H[i]<(H[i+1]-1):
    ans=1
    break
  elif H[i]==H[i+1]-1:
    H[i+1] -=1
    
if ans==0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14252
n=int(input())
S=[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
H=[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
C=[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
D=[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
for i in range(n):
    k=input().split()
    j=int(k[1])
    if k[0]=="S":
        S[j]=1
    if k[0]=="H":
        H[j]=1
    if k[0]=="C":
        C[j]=1
    if k[0]=="D":
        D[j]=1
for i in range(1,14):
    if S[i]==0:
        print("S "+str(i))
for i in range(1,14):
    if H[i]==0:
        print("H "+str(i))
for i in range(1,14):
    if C[i]==0:
        print("C "+str(i))
for i in range(1,14):
    if D[i]==0:
        print("D "+str(i))



Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

void solve(){
    string s;
    cin >> s;
    int n = s.size();
    char c = s[0];
    string t{c};
    for(int i=1; i<n; i++){
        if(s[i-1]=='B' && s[i]=='C') {
            t.pop_back();
            t = t + "D";
        }
        else {
            t = t + s[i];
        }
    }

    //ADDADA のような文字列を、DDDAAAにソートするのに必要な交換回数
    //これは、Aについて自分より右にあるDの数を数えると良い
    //逆に、各Dについて、自分より左にあるAの数ということになり、これは線型的に導出できる
    ll ans = 0;
    ll count = 0;
    rep(i,t.size()){
        if(t[i]=='B'||t[i]=='C'){
            count=0;
        }
        else if(t[i]=='A'){
            count++;
        }
        else{
            ans += count;
        }
    }

    cout << ans << endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}



Measured memory_bytes: 1452
#include<iostream>
//#include<windows.h>
//#include<errno.h>

#define Iset int i,j,l
#define man 10000
#define cn continue

int pas[101], dt[101][4][4];

using namespace std;

int main() {
	int n, k;
	Iset;
	int ans = 0;
	//scanf("%d%d", &n, &k);
	cin >> n >> k;
	for (i = 0; i < k; i++) {
		int a, b;
	//	scanf("%d%d", &a, &b);
		cin >> a >> b;
		pas[a] = b;
	}
	dt[0][0][0] = 1;
	for (i = 1; i <= n; i++) {
		if (pas[i] == 0) {
			for (j = 1; j <= 3; j++) {
				for (k = 0; k <= 3; k++) {
					for (l = 0; l <= 3; l++) {
						if (j == k && l == k) cn;
						dt[i][j][k] += dt[i - 1][k][l];
						dt[i][j][k] %= man;
					}
				}
			}
		}
		else {
			for (k = 0; k <= 3; k++) {
				for (l = 0; l <= 3; l++) {
					if (pas[i] == k && l == k)cn;
					dt[i][pas[i]][k] += dt[i - 1][k][l];
					dt[i][pas[i]][k] %= man;
				}
			}
		}
	}
	for (i = 1; i <= 3; i++) {
		for (j = 1; j <= 3; j++) {
			ans += dt[n][i][j];
			ans %= man;
		}
	}
	//printf("%d\n", ans);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int INF=1e9;

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N){
        cin>>a[i];
        a[i]--;
    }

    vint dist(N,INF);
    dist[0]=0;
    int cur=0;
    while(true){
        if(cur==1){
            cout<<dist[cur]<<endl;
            return 0;
        }
        int nxt=a[cur];
        if(dist[nxt]==INF){
            dist[nxt]=dist[cur]+1;
        }
        else{
            cout<<-1<<endl;
            return 0;
        }
        cur=nxt;
    }
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    import collections
    D = collections.deque(A)
    ans = []
    for i in range(N-1):
        a, b = D.popleft(), D.pop()
        if not D or D[-1] < 0:
            D.append(b - a)
            ans.append((b, a))
        else:
            D.appendleft(a - b)
            ans.append((a, b))
    print(D.pop())
    for x, y in ans:
        print(x, y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20120
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(int, N);
	vector<ll> A(N), B(N);
	loop(i, N) {
		in(ll, a, b);
		A[i] = a;
		B[i] = b;
	}
	ll ans = 0;
	for (int i = N - 1; i >= 0; --i) {
		ans += ((B[i] - (A[i] + ans)) % B[i] + B[i]) % B[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#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 FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;

int main(){
  char C;
  cin >> C;
  printf("%c",C+1);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007; 
struct T {
	int H;
	int P;
	bool operator<(const T& right) const {
		return H + P < right.H + right.P;
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<T> t(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> t[i].H >> t[i].P;
	}
	sort(t.begin(), t.end());
	int p = 0;
	vector<pair<int, int> >dp;
	vector<pair<int, int> >tdp;
	dp.push_back(make_pair(0, 0)); 
	int mx = -1;
	for (int i = 0; i < N; i++) {
		tdp = dp;
		//tdp.clear();
		for (int j = 0; j < dp.size();j++){
			//cerr << dp[j].first << " " << dp[j].second << endl;
			if (dp[j].first <= t[i].H) {
				tdp.push_back(make_pair(dp[j].first + t[i].P, dp[j].second + 1));
				res = max(dp[j].second + 1, res);
			}
		}
		swap(dp, tdp);
		//cerr << dp.size() << endl;
		sort(dp.begin(), dp.end());
		tdp.clear();
		mx = -1;
		for (int j = 0; j < dp.size(); j++) {
			if (mx < dp[j].second) {
				mx = dp[j].second;
				tdp.push_back(dp[j]);
			}
			else if (mx == dp[j].second) {
				//tdp[tdp.size() - 1] = dp[j];
			}
		}
		swap(dp, tdp);
	}

	cout << res << endl;
}

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

int main()
{  int a,b,c;
cin>>a>>b>>c;
if (a!=b &&a!=c && b!=c){
    cout<<"3"<<endl;
}
else if (a!=b || a!=c || b!=c){
    cout<<"2"<<endl;
}
else {
    cout<<"1"<<endl;
}

    return 0;
}



Measured memory_bytes: 3604
# N M
# p1 S1
# p2 S2
# ...
# pn Sn

_, m = gets.chomp.split(" ").map(&:to_i)

acs = []
was = []

as = m.times.map do |_|
  p, s = gets.chomp.split(" ")
  [p.to_i, s]
end

as.each do |p, s|
  next if acs[p]

  case s
  when "AC"
    acs[p] = true
  when "WA"
    was[p] ||= 0
    was[p] += 1
  end
end

a = acs.compact.count
was2 = acs.each_with_index.map {|e, i| was[i] if e }
b = was2.compact.inject(0) {|s, i| s + i }
puts "#{a} #{b}"


Measured memory_bytes: 18552
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;typedef long long ll;
int n,x;
int a[2001],b[2001];
ll Ans;
int main(){
	scanf("%d%d",&n,&x);
	F(i,1,n) scanf("%d",a+i), Ans+=a[i], b[i]=a[i];
	F(i,1,n-1){
		ll sum=0;
		swap(a,b);
		F(j,1,n) b[j]=min(b[j],a[(j+n-2)%n+1]), sum+=b[j];
		Ans=min(Ans,sum+(ll)i*x);
	} printf("%lld",Ans);
	return 0;
}

Measured memory_bytes: 256
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n,M = i_map()
    a = i_list()

    cd = []
    new_a = []
    for i in a:
        cd.append(i//2)
        new_a.append((i//2))

    def pow2(x):
        ret = 0
        while x%2 == 0:
            ret += 1
            x//=2
        return ret

    P = []
    for a in new_a:
        P.append(pow2(a))

    if len(set(P)) != 1:
        print(0)
    else:
        m = 1
        for a in new_a:
            m = (m*a)//gcd(m,a)
        print(-(-(M//m)//2))









if __name__=="__main__":
    main()


Measured memory_bytes: 104128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iterator>
#include <cstdio>
#include <numeric>
using namespace std;
int main(){
  for(int tc = 1;; ++tc){
    int W;
    cin >> W;
    if(W == 0){
      break;
    }
    int n;
    cin >> n;
    int value[n], weight[n];
    for(int i = 0; i < n; ++i){
      scanf("%d,%d", &value[i], &weight[i]);
    }
    int table[n+1][W+1];    
    fill_n((int*)table, (n+1)*(W+1), 0);
    table[0][0] = 0; 
    for(int i = 0, j = 1; i < n; ++i, ++j){
      for(int w = 0; w <= W; ++w){
	if(table[i][w] != -1){
	  table[j][w] = table[i][w];
	}
      }
      for(int w = weight[i]; w <= W; ++w){
	int tmp = w - weight[i];
	if(table[i][tmp] >= 0){
	  table[j][w] = max(table[j][w], table[i][tmp] + value[i]);
	}
      }    
    }
    int ans_w = 0, ans_v = 0;
    for(int w = 0; w <= W; ++w){
      if(ans_v < table[n][w]){
	ans_v = table[n][w];
	ans_w = w;
      }
    }
    cout << "Case " << tc << ":" << endl;
    cout << ans_v << endl;
    cout << ans_w << endl;
  }
  return 0;
}

Measured memory_bytes: 5164
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	r := nextInt()
	g := nextInt()
	b := nextInt()

	if (r*100+g*10+b)%4 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 640
from itertools import product

N,A,B,C=map(int,input().split())
l = [int(input()) for _ in range(N)]

minscore=10**9
for p in product(range(-1,3),repeat=N):
  flag=0
  score = 0
  n_abc=[0,0,0]
  sumlen = [0,0,0]
  for i in range(N):
    if p[i] != -1:
      n_abc[p[i]] += 1
      sumlen[p[i]] += l[i]
  for j in range(3):
    if n_abc[j] == 0:
      flag=1
      break
    score += (n_abc[j]-1)*10 + abs(sumlen[j]-[A,B,C][j])
    
  if flag:
    continue
    
  if score < minscore:
    minscore = score
    
print(minscore)

Measured memory_bytes: 9236
#include <algorithm>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

const int maxn = 1e5 + 10;

struct Point
{
	int x, y, id;
	Point(int x = 0) : x(x) {}
	bool operator<(const Point &rhs) const { return x < rhs.x; }
};

map<int, set<Point>> add, sub;
map<int, vector<Point>> addv, subv;

bool vis[maxn];
Point p[maxn];

int main()
{
	int N, a, b;
	scanf("%d %d %d", &N, &a, &b);
	for (int i = 1; i <= N; ++i)
	{
		scanf("%d %d", &p[i].x, &p[i].y);
		p[i].id = i;
		addv[p[i].x + p[i].y].push_back(p[i]);
		subv[p[i].x - p[i].y].push_back(p[i]);
	}
	for (auto &p : addv)
	{
		sort(p.second.begin(), p.second.end());
		add[p.first] = set<Point>(p.second.begin(), p.second.end());
	}
	for (auto &p : subv)
	{
		sort(p.second.begin(), p.second.end());
		sub[p.first] = set<Point>(p.second.begin(), p.second.end());
	}
	int d = abs(p[a].x - p[b].x) + abs(p[a].y - p[b].y);
	queue<int> q;
	q.push(a);
	q.push(b);
	vis[a] = vis[b] = true;
	long long ans = 0;
	while (!q.empty())
	{
		int i = q.front();
		int x = p[i].x;
		int y = p[i].y;
		q.pop();
		vector<int> nxt;
		{
			int t = x - d - y;
			int l = x - d;
			int r = x;
			auto st = sub[t].lower_bound(Point(l));
			auto ed = sub[t].lower_bound(Point(r));
			for (auto it = st; it != ed; ++it)
				nxt.push_back(it->id);
			ans += lower_bound(subv[t].begin(), subv[t].end(), Point(r)) -
				   lower_bound(subv[t].begin(), subv[t].end(), Point(l));
		}
		{
			int t = x + d - y;
			int l = x + 1;
			int r = x + d + 1;
			auto st = sub[t].lower_bound(Point(l));
			auto ed = sub[t].lower_bound(Point(r));
			for (auto it = st; it != ed; ++it)
				nxt.push_back(it->id);
			ans += lower_bound(subv[t].begin(), subv[t].end(), Point(r)) -
				   lower_bound(subv[t].begin(), subv[t].end(), Point(l));
		}
		{
			int t = x + y - d;
			int l = x - d + 1;
			int r = x + 1;
			auto st = add[t].lower_bound(Point(l));
			auto ed = add[t].lower_bound(Point(r));
			for (auto it = st; it != ed; ++it)
				nxt.push_back(it->id);
			ans += lower_bound(addv[t].begin(), addv[t].end(), Point(r)) -
				   lower_bound(addv[t].begin(), addv[t].end(), Point(l));
		}
		{
			int t = x + y + d;
			int l = x;
			int r = x + d;
			auto st = add[t].lower_bound(Point(l));
			auto ed = add[t].lower_bound(Point(r));
			for (auto it = st; it != ed; ++it)
				nxt.push_back(it->id);
			ans += lower_bound(addv[t].begin(), addv[t].end(), Point(r)) -
				   lower_bound(addv[t].begin(), addv[t].end(), Point(l));
		}
		for (int j : nxt)
		{
			if (vis[j])
				continue;
			q.push(j);
			int x = p[j].x, y = p[j].y;
			add[x + y].erase(p[j]);
			sub[x - y].erase(p[j]);
		}
	}
	printf("%lld\n", ans / 2);
	return 0;
}


Measured memory_bytes: 81280
#include <iostream>
using namespace std;
int main(void){
    long long t1, t2, a1, a2, b1, b2, c1, c2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    c1 = (a1 - b1) * t1;
    c2 = (a2 - b2) * t2;

    if(c1 < 0){
        c1 *= -1;
        c2 *= -1;
    }

    if(c1+c2 == 0){
        puts("infinity");
        return 0;
    }else if(c1 < 0 || c1+c2 > 0){
        puts("0");
        return 0;
    }
    long long c3 = - c1 - c2, ans;
    ans = c1 / c3 * 2 + 1;
    if(c1 % c3 == 0) ans--;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000000000000;
#define PI 3.1415926535
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;}
char upper(char c){
    if('a' <= c && c <= 'z'){
        c = c - ('a' - 'A');
    }
    return c;
}
char lower(char c){
    if('A' <= c && c <= 'Z'){
        c = c + ('a' - 'A');
    }
    return c;
}
int GetDigit(int num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}
ll enum_divisors(ll N) {
    ll res = 0;
    for (ll i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res++;
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res++;
        }
    }
    // 小さい順に並び替える
    return res;
}
//input



//processing
int ans;



//dpTable
//int dp[100050];
int main(){
    int N;
    cin >> N;
    vector<int> L(N);
    rep (i,N) cin >> L.at(i);
    sort (L.begin(),L.end());
    rep(b,N)rep(a,b) {
        int ab = L[a] + L[b];
        int r = lower_bound(L.begin(),L.end(),ab) - L.begin();
        int l = b + 1;
        ans += max(0,r - l);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>

#define MUN 1000001
int p[MUN];

int main(void)
{
	int n;
	int i, j;
	
	for (i = 2; i < MUN; i++){
		p[i] = 1;
	}
	
	for (i = 2; i * i < MUN; i++){
		if (p[i] == 1){
			for (j = i * i; j < MUN; j += i){
				p[j] = 0;
			}
		}
	}
	
	for (i = 1; i < MUN; i++){
		p[i + 1] += p[i];
	}
	
	while (scanf("%d", &n) != EOF){
		printf("%d\n", p[n]);
	}
	return (0);
}

Measured memory_bytes: 4500
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//↑templete
signed main(){

	int N, M;
	cin>>N>>M;

	bool ACed[SIZE]={};
	int pena[SIZE]={};
	for(int i=0;i<M;i++){
		int p;
		string S;
		cin>>p>>S;
		if(ACed[p])
			continue;
		
		if(S=="AC"){
			ACed[p]=1;
		}
		else{
			pena[p]++;
		}
	}

	int alpha=0, beta=0;
	for(int i=1;i<=N;i++){
		if(ACed[i]){
			alpha++;
			beta+=pena[i];
		}
	}
	cout<<alpha<<" "<<beta<<endl;

	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // 入力
    int N, M;
    cin >> N >> M;
    long long a[100010];
    rep(i,M) cin >> a[i];

    // DP テーブル
    long long dp[100010];

    // 初期化 
    rep(i,100010) {
        dp[i] = INF;
    }
    rep(i,M) {
        dp[a[i]] = 0;
    }

    // 初期条件
    dp[0] = 1;

    // ループ
    rep2(i,N+1) {
        if (i > 1) {
            if(dp[i] !=  0) {
                dp[i] = dp[i-1] + dp[i-2];
                dp[i] %= 1000000007; 
            }
        }
        else {
            if(dp[i] !=  0) dp[i] = dp[i-1];
            dp[i] %= 1000000007;
        }
    }

    // 答え
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
void pr(){ln;}
template<Z A,Z...B>void pr(const A &a,const B&...b){cout<<a<<' ';pr(b...);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  string s;
  R s;
  if(s[1]=='B') pr("ARC");
  else pr("ABC");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3616
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int rdn()
{
  int ret=0;bool fx=1;char ch=getchar();
  while(ch>'9'||ch<'0'){if(ch=='-')fx=0;ch=getchar();}
  while(ch>='0'&&ch<='9')ret=ret*10+ch-'0',ch=getchar();
  return fx?ret:-ret;
}
const int N=2e5+5;
int n,m,a[N],len[N],ct[N],ans;
int main()
{
  n=rdn();m=rdn();
  for(int i=1,d;i<=n;i++)
    { a[i]=rdn(); len[a[i]]++;}
  for(int i=1;i<=n;i++)
    for(int j=0;j<len[i]&&j<i;j++)//j<i
      ct[i-j]++;
  for(int i=1;i<=n;i++)if(!ct[i])ans++;
  for(int i=1,x,y,tp;i<=m;i++)
    {
      x=rdn();y=rdn(); tp=a[x]; a[x]=y;
      int p1=tp-len[tp]+1; len[tp]--;
      if(p1>0){ ct[p1]--; if(!ct[p1])ans++;}
      int p2=y-len[y]; len[y]++;
      if(p2>0){ ct[p2]++; if(ct[p2]==1)ans--;}
      printf("%d\n",ans);
    }
  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a==2||b==2){
    cout<<"No";
    return 0;
  }
  int n[]={4,6,9,11};
  bool x=false,y=false;
  for(int i=0;i<4;i++){
    if(a==n[i])x=true;
    if(b==n[i])y=true;
  }
  if(x==y){
    cout<<"Yes";
    return 0;
  }else cout<<"No";
  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 = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(a <= c && c <= b){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	Real A, B, H, M; cin >> A >> B >> H >> M;
	Real minutes = H*60 + M;
	Real deg = min(abs(0.5*minutes - 6*M), 360.0 - abs(0.5*minutes - 6*M));
	if(abs(deg - 180.0) <= eps){
		dcout << A+B << ln;
	} else if(abs(deg) <= eps){
		dcout << abs(A-B) << ln;
	} else {
		Real rad = deg * pi / 180.0;
		Real cs = cosl(rad);
		dcout << sqrtl(A*A + B*B - 2*A*B*cs) << ln;
	}
}

Measured memory_bytes: 4164
#include <stdio.h>
int main(){
	int A;
	int B;
	int C;
	
	scanf("%d %d %d",&A,&B,&C);
	if (A==B && B!=C && C!=A) {
		printf("Yes\n");
	}
	else if (A==C && A!=B && C!= B){
		printf("Yes\n");
	}
	else if (B==C && A!=B && C!=A){
		printf ("Yes\n");
	}
	else printf ("No\n");
	return 0;
}

Measured memory_bytes: 2076
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second


ll n, a[200010], b[21][200010] = { 0 }, ans = 0, sum[200100] = {0};

bool f(int l, int r) {
	if (r > n)return 0;
	ll s = 0;
	for (int i = 0;i < 20;i++) {
		if (b[i][r] - b[i][l - 1] == 1) {
			s += (1 << i);
		}
	}
	if (s == sum[r] - sum[l - 1])return 1;
	return 0;
}


int main() {
	
	cin >> n;
	for (int i = 1;i <= n;i++) {
		cin >> a[i];
		sum[i] = sum[i - 1] + a[i];
		for (int j = 0;j < 20;j++) {
			if (a[i] & (1 << j)) b[j][i] = b[j][i - 1] + 1;
			else b[j][i] = b[j][i - 1];
		}
	}

	for (int i = 1;i <= n;i++) {
		int l = i, r = n + 1, m, ma = -1;
		for (int j = 0;j < 20;j++) {
			m = (r + l) / 2;
			if (f(i, m)) {
				l = m;
				ma = max(ma, m);
			}
			else r = m;
		}
		ans += (ma - i + 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 36224
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i=j; i<k; i+=step)
#define loop(i, j, k) for (int i=j; i<k; i++) 
#define rloop1(i, j, k, step) for (int i=j; i>=k; i-=step)
#define rloop(i, j, k) for(int i=j; i>=k; i--)
#define rep(i, k) for(int i = (0); i < (k); i++ )
#define rrep(i, k) for(int i = k-1; i >= 0; i-- )

#define forall(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define endl "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;


void solve()
{
	int n,i,j,k,l,d,cnt=0,a,b,flag=0,m;
	cin>>n>>m;
	vi v(n+1);
	v[0]=0;
	loop(i,1,n+1)cin>>v[i];
	map<int,vi> m1;
	rep(i,m){
		cin>>a>>b;
		m1[a].pb(b);
		m1[b].pb(a);
	}
	loop(i,1,n+1){
		flag=0;
		forall(it,m1[i]){
			if(v[*it]>=v[i]){
				flag=1;
				break;
			}
		}
		if(flag==0)
			cnt++;
	}
	cout<<cnt<<endl;
}
int  main() 
{
	auto start=clock();
	fast_io;
    int t=1;
    //cin>>t;
    while(t--)
    	solve();
    auto stop =clock();
    cerr<<"time taken:"<<double(stop-start)/double(CLOCKS_PER_SEC)<<" s"<<endl;
	return 0; 
}

Measured memory_bytes: 14412
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int fie[82][82][7000];
int main(){
    int H,W;
    cin>>H>>W;
    int fieA[100][100]={0},fieB[100][100]={0};
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>fieA[i][j];
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>fieB[i][j];
        }
    }
    fie[0][0][abs(fieA[0][0]-fieB[0][0])]=1;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            for(int k=0;k<7000;k++){
                if(fie[i][j][k]){
                    int yuki1=abs(k-abs(fieA[i][j+1]-fieB[i][j+1]));
                    int yuki2=k+abs(fieA[i][j+1]-fieB[i][j+1]);
                    if(yuki1<7000){
                        fie[i][j+1][yuki1]=1;
                    }
                    if(yuki2<7000){
                        fie[i][j+1][yuki2]=1;
                    }
                    yuki1=abs(k-abs(fieA[i+1][j]-fieB[i+1][j]));
                    yuki2=k+abs(fieA[i+1][j]-fieB[i+1][j]);
                    if(yuki1<7000){
                        fie[i+1][j][yuki1]=1;
                    }
                    if(yuki2<7000){
                        fie[i+1][j][yuki2]=1;
                    }

                }
            }
        }
    }

    int ans=10000;
    for(int k=0;k<7000;k++){
        if(fie[H-1][W-1][k]==1)ans=min(ans,k);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> l(n);

  rep(i,n) cin >> l[i];

  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());

  int ans = 0;
  rep(i,k) ans += l[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3560
N = int(input())

ans = [0] * 10**4
for x in range(1, 110):
    for y in range(1, 110):
        for z in range(1, 110):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if n <= 10**4:
                ans[n-1] += 1
                
for i in range(N):
    print(ans[i])

Measured memory_bytes: 9124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		String A = scn.nextLine();
		String ans = "";
		switch(A) {
		case "A":
			ans = "T";
			break;
		case "T":
			ans = "A";
			break;
		case "C":
			ans = "G";
			break;
		case "G":
			ans = "C";
			break;

		}
		System.out.println(ans);
	}

}


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

int main() {
    int i,j,k,l,M,N,H,W,a,b,c,d,x,temp ;
  	long long lng,num1,num2,num3,num4;
    string str,ans;
    cin >> num1 >> num2 >> lng;
  	num3 = num1 / lng;
  	num4 = num2 / lng;
 
  	if(num1%lng == 0){cout << num4 - num3 +1 << endl;}
  	else{cout << num4 - num3  << endl;}
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define int ll
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
// int MOD = 998244353;
int MOD = 1000000007;
queue<int> que[100010];
int K[100100] = {};
int A1[100100] = {};
int A2[100100] = {};
// int ans[300100];
/*----------------------------------------------------------------*/
signed main(){
	
	
	int a,b;cin >> a >> b;
	cout << a*b << endl;
	
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://abc161.contest.atcoder.jp/tasks/abc161_a

Measured memory_bytes: 70828
n, m = map(int, input().split())
a = list(map(int, input().split()))

ans = 0

temp = 0
b = {0:1}
for x in a:
    temp = (temp + x) % m
    if temp in b:
        b[temp] += 1
    else:
        b[temp] = 1

for x in b.values():
    ans += x * (x - 1) // 2

print(ans)

Measured memory_bytes: 14696
#include<iostream>

int main(){
    int n[100],x[100];

    for(int i=0;i<100;i++){
        std::cin>>n[i]>>x[i];
        if(n[i]==0 && x[i]==0){
            break;
        }
    }
    
    for(int i=0;i<100;i++){
        if(n[i]==0 && x[i]==0){
            break;
        }
        int count=0;
        for(int fir=1;fir<n[i];fir++){
            for(int sec=fir+1;sec<=n[i];sec++){
                int thr =x[i]-fir-sec;
                if(thr<=n[i]  && thr>sec){
                    count+=1;
                }
            }
        }
        std::cout<<count<<std::endl;
        
    }
}


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

using namespace std;

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

  int row = sqrt(2*N);
  bool is_exist = ( 2*N == row*(row+1) );
  
  cout << ( is_exist ? "Yes" : "No" ) << endl;

  if (!is_exist)
    return 0;
  
  cout << row+1 << endl;

  // diagonal
  cout << row;
  for (int ii=1; ii<=row ; ++ii)
    cout << ' ' << ii*(ii+1)/2;
  cout << endl;

  // others
  for (int r_start=0; r_start<row; ++r_start) {
    cout << row;
    for (int c=0; c<(r_start+1); ++c)
      cout << ' ' << r_start*(r_start+1)/2 + c + 1;
    for (int r=r_start+1; r<row; ++r)
      cout << ' ' << r*(r+1)/2 + r_start + 1;
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int kansu(int);
int a[50];

int main(){
  int i,n;
  for(i=0;i<50;i++)
    a[i] = -1;

  scanf("%d",&n);
  printf("%d\n",kansu(n));

  return 0;
}

int kansu(int n){
  if(n==0 || n==1)
    return a[n]=1;
  if(a[n] != -1)
    return a[n];
  return a[n]=kansu(n-1)+kansu(n-2);
}



Measured memory_bytes: 2144
#include<iostream>
using namespace std;
#define MAXN 100100
int dp[MAXN][3];
int n,a,b,c,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a>>b>>c;
		dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=c+max(dp[i-1][0],dp[i-1][1]);
		
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll>prime;
bitset<10000009>bs;
ll ans=0;
void find_prime(ll  val)
{
    bs.set();
    bs[1]=0;
    for(ll i=2; i*i<=val; i++)
    {
        if(bs[i]==1)
            for(ll j=i*i; j<=val; j+=i)
                bs[j]=0;
    }
    for(ll i=1; i<=val; i++)
        if(bs[i]==1)
            prime.emplace_back(i);
}
ll prime_fact(ll val)
{
    ll total=1;
    for(auto x:prime)
    {
        ll res=0;
        while(val%x==0 and x>1)
        {
            val/=x;
            res++;
        }
        total*=(res+1);
        if(bs[val]==1)
        {
            total*=2;
            break;
        }
        if(val==1)
            break;
    }
    return total;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    find_prime(10000009);
    ll n;
    cin>>n;
    ans+=1;//for 1.
    for(ll i=2; i<=n; i++)
    {
        if(bs[i]==1)
            ans+=(2*i);
        else
        {
            ll ok=prime_fact(i);
            ans+=ok*i;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 12764
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll a1, a2, a3;
    cin >>a1>>a2>>a3;
    if (a1+a2+a3<=21) cout << "win" << endl;
    else cout << "bust" << endl;
    return 0;
}


Measured memory_bytes: 256