akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int,null_type, less<int>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=1e5+10, mod=1e9+7;

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int n; ll res=0;
	cin>>n;
	int a[n],l[n],r[n];
	for(int i=0;i<n;i++)cin>>a[i];
	stack<pair<int,int>> st;
	
	for(int i=0;i<n;i++){
		while( !st.empty() && st.top().xx < a[i] ){
			st.pop();
		}

		if(st.empty()) l[i]=-1;
		else l[i]= st.top().yy;
		
		st.push({a[i],i});
	}
	while(!st.empty())st.pop();
	
	for(int i=n-1;i>=0;i--){
		while( !st.empty() && st.top().xx < a[i] ){
			st.pop();
		}
		if(st.empty()) r[i]=n;
		else r[i]= st.top().yy;
		st.push({a[i],i});
	}
	
	for(int i=0;i<n;i++){ 
		if(l[i]==-1&&r[i]==n){
			continue;
		}else if(l[i]==-1){
			int r2=r[i]+1;
			while( r2<n && a[r2]<a[i] ){
				r2=r[r2];
			}
			res+=1LL*a[i]*(i+1)*(r2-r[i]);
		}else if(r[i]==n){
			int l2=l[i]-1;
			while(l2>=0 && a[l2]<a[i]  ){
				l2=l[ l2 ];
			}
			res+=1LL*a[i]*(n-i)*(l[i]-l2);
		}else{
			int r2=r[i]+1;
			while( r2<n && a[r2]<a[i] ){
				r2=r[r2];
			}
			int l2=l[i]-1;
			while(l2>=0 && a[l2]<a[i]  ){
				l2=l[ l2 ];
			}
			res+=1LL*a[i]*( l[i]-l2 )*(r[i]-i);
			res+=1LL*a[i]*(i-l[i])*(r2-r[i]);
		} 
	}
	cout<<res;
	
}


Measured memory_bytes: 2176
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl

#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a,
             const pair<int,int> &b)
{
    if(a.ff == b.ff) {
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff);
}

bool prime[10000001];
void SieveOfEratosthenes(int n) 
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.

    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int32_t main()
{
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    /********************* From here ***********************/
    int n;
    cin >> n;
    double ans = 0;
    rep(i, 0, n){
        double a;
        string b;
        cin >> a >> b;
        if(b[0] == 'J'){
            ans += a;
        }
        else{
            ans += 380000.0*a;
        }

    }

    cout << ans ;

}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1568>
問題文============================================================
 ジェニファーとマリアンはカーラに文字列Sをプレゼントしました。
 しかし、カーラは文字列Sをもらっても嬉しくありません。
 文字列Tが欲しかったのです。
 3人は協力して文字列Sを文字列Tに変えることにしました。
 最初にジェニファーが文字を任意の順番に並び替えます。
 
 次にマリアンが２種類のアルファベットの小文字を交換することを任意の回数行います。
 この操作では、例えば以下のように、文字列中の同じ文字が全て交換されます。
 aab → aとbを交換 → bba
 aab → aとcを交換 → ccb
 最後にカーラがある1文字を別の1文字に置換することをTになるまで繰り返します。
 ジェニファーとマリアンはカーラの置換回数が少なくなるようにしてあげることにしました。
 カーラが行う置換の回数の最小値を求めてください。
 
=================================================================

解説=============================================================
考察を進めると、SとTの各文字の個数だけに注目すればいいことがわかる
 ソートされたSとTの各文字の個数に関して順番にその差の絶対値の和をとり、その半分が答え
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    string S,T; cin >> S >> T;
    int sc[26] = {0};
    int tc[26] = {0};
    for(char c : S) sc[c - 'a']++;
    for(char c : T) tc[c - 'a']++;
    sort(sc,sc+26); sort(tc,tc+26);
    int ans = 0;
    for(int i = 0; i < 26;i++) ans += abs(sc[i] - tc[i]);
    cout << ans / 2 << endl;
	return 0;
}



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

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    if(abs(C-A)<=D||(abs(B-A)<=D&&abs(C-B)<=D)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1);
  vector<int> d(k);
  for (int i = 0; i < n + 1; i++) a[i] = 0;
  for (int i = 0; i < k; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      int x;
      cin >> x;
      a[x]++;
    }
  }
  int cnt = 0;
  for (int i = 1; i < n + 1; i++) {
    if (a[i] == 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
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; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int n,m,c=0;cin>>n>>m;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];c+=a[i];
  }
  sort(all(a),greater<int>());
  double t=(double)c/((double)m*4.0);
  rep(i,m){
    if((double)a[i]<t){
      cout<<"No";return 0;
    }
  }
  cout<<"Yes";
}

Measured memory_bytes: 256
#include <stdio.h>

int nx, ny;
char b[21][21];

int a(int x, int y) {
	if (x > nx || y > ny) return 0;
	if (x == nx && y == ny) {
		return 1;
	}
	if (b[x][y] == 1) return 0;
	int res = 0;
	res += a(x+1,y) + a(x,y+1);
	return res;
}

int main() {
	while (1) {
		int as = 0, x, y, cp = 0, cpp = 0, bp;
		scanf("%d%d", &nx, &ny);
		if (nx+ny == 0) break;
		scanf("%d", &bp);
		while (cp < 21) {
			for (cpp=0;cpp<21;cpp++) {
				b[cp][cpp] = 0;
			}
			cp++;
		}
		while (as < bp) {
			scanf("%d%d", &x, &y);
			b[x][y] = 1;
			as++;
		}
		printf("%d\n", a(1,1));
	}
	return 0;
}

Measured memory_bytes: 600
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
vector<pint> gr[100100];
int col=0;
int out[100100];
void dfs(int v,int u,int c){
	int ne=1;
	rep(i,gr[v].size()){
		pint p=gr[v][i];
		if(p.fi==u) continue;
		if(ne==c) ne++;
		out[p.se]=ne;
		dfs(p.fi,v,ne);
		ne++;
	}
}
int main()
{
	int n,a,b;
	cin>>n;
	rep(i,n-1){
		cin>>a>>b;gr[a].pb(mp(b,i));gr[b].pb(mp(a,i));
	}
	REP(i,1,n+1) col=max(col,(int)gr[i].size());
	dfs(1,0,0);
	cout<<col<<endl;
	rep(i,n-1) cout<<out[i]<<endl;
}


Measured memory_bytes: 9344
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> e(n + 1);
	for (int i = 1; i <= m; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		e[x].pb(y);
		e[y].pb(x);
	}
	vector<bool> visit(n + 1);
	queue<int> q;
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (visit[i]) continue;
		cnt++;
		q.push(i);
		visit[i] = true;
		while(!q.empty()) {
			int u = q.front();
			q.pop();
			for (int uu: e[u]) {
				if (visit[uu]) continue;
				visit[uu] = true;
				q.push(uu);
			}
		}
	}
	cout << cnt << "\n";
	return 0;
}

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

using namespace std;

int main()
{
	int a,b,sum=0, sub =0, mul =0;
	cin>>a>>b;
	sum =a+b;
	sub = a-b;
	mul = a*b;
	if(sum>=sub && sum >=mul ) cout<<sum<<endl;
	else if(sub>=sum && sub >=mul ) cout<<sub<<endl;
	else
	 cout<<mul<<endl;
	
	return 0;

	
}

Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
a = sorted([list(map(int, input().split())) for _ in range(n)])
r,j,x=0,0,[]
heapq.heapify(x)
for i in range(m):
    while j < n and a[j][0] <= i+1:
        heapq.heappush(x, -a[j][1])
        j += 1
    if x:
        r -= heapq.heappop(x)
print(r)

Measured memory_bytes: 31964
using System;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            for(int i = 0; i < n; i++)
            {
                var ds = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
                double xa = ds[0];
                double ya = ds[1];
                double ra = ds[2];
                double xb = ds[3];
                double yb = ds[4];
                double rb = ds[5];
                double r2 = (ra + rb) * (ra + rb);
                var length2 = (xa - xb) * (xa - xb) + (ya - yb) * (ya - yb);
                if (length2 > r2)
                {
                    Console.WriteLine("0");
                }
                else
                {
                    if ((ra - rb) * (ra - rb) > length2)
                    {
                        Console.WriteLine(rb < ra ? "2" : "-2");
                    }
                    else
                    {
                        Console.WriteLine("1");
                    }
                }
            }
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    int m,d;
    cin>>m>>d;

    int ans=0;
    REP(i,m){
        REP(j,d){
            int mon = i+1;
            int day = j+1;
            if(day%10 < 2) continue;
            if(day/10 < 2) continue;
            if((day/10)*(day%10) != mon) continue;

            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
    {
        static long mod = 1000000007;
        static long sq(long i){
            return times(i, i) % mod;
        }

        static long times(long a, long b)
        {
            return a * b % mod;
        }

        static long pow(long a, long n)
        {
            int p = 0;
            long ret = 1;
            long buf = a;
            while ((1 << p) <= n)
            {
                if(((n >> p) & 1) > 0)
                {
                    ret = times(ret, buf);
                }
                buf = sq(buf);
                p++;
            }
            return ret;
        }

        static long inv (long a)
        {
            return pow(a, mod - 2);
        }

    	static void Main(string[] args)
    	{
            string[] s = Console.ReadLine().Split(' ');
            long b = long.Parse(s[0]), w = long.Parse(s[1]);

            long black = 0, white = 0;
            long nCb = 1, nCw = 1;

            for (int i=0; i<b+w; i++)
            {

                if (i < b) ;
                else if (i == b) black = inv(pow(2, b));
                else
                {
                    nCb = nCb * (i - 1) % mod * inv(i - b) % mod;
                    black = (black + (nCb % mod * inv(pow(2, i))) % mod) % mod;
                }
                if (i < w) ;
                else if (i == w) white = inv(pow(2, w));
                else
                {
                    nCw = nCw * (i - 1) % mod * inv(i - w) % mod;
                    white = (white + (nCw % mod * inv(pow(2, i))) % mod) % mod;
                }

                long i2 = inv(2);

                long ans = 1 * i2 % mod;
                ans += white * i2 % mod;
                ans -= black * i2 % mod;
                ans = ans % mod;
                if (ans < 0) ans += mod;
                //Console.WriteLine("white: " + white);
                //Console.WriteLine("black: " + black);
                Console.WriteLine(ans);
            }
                        
        }
    }

Measured memory_bytes: 17232
#include<iostream>
#include<math.h>
#include<stdlib.h>

#define INF -99999999999;
using namespace std;

void findcloss(int* A, int low, int high, int mid, int* maxleft, int* maxright, int* val)
{
    int leftsum = INF;
    int rightsum = INF;
    int sum = 0;
    
    for (int i = mid; i >= low; i--) {
        sum += A[i];
        if (sum > leftsum) {
            leftsum = sum;
            int* p = &i;
            *maxleft = *p;
        }
    }

    sum = 0;
    for (int i = mid+1; i <= high; i++) {
        sum += A[i];
        if (sum > rightsum) {
            rightsum = sum;
            int* p = &i;
            *maxright = *p;
        }
    }
    sum = leftsum + rightsum;
    int *p = &sum;
    *val = *p;
}

void findmax(int* A, int low, int high, int* anslow, int* anshigh, int* ansval)
{
    if (high == low) {
        int* p = &low;
        int* q = &high;
        int* r = &A[low];
        *anslow = *p;
        *anshigh = *q;
        *ansval = *r;
    }
    else {
        int mid = (int)floor((low + high) / 2);
        int leftlow = INF;
        int lefthigh = INF;
        int leftsum = INF;
        findmax(A, low, mid, &leftlow, &lefthigh, &leftsum);
        int rightlow = INF;
        int righthigh = INF;
        int  rightsum = INF;
        findmax(A, mid+1, high, &rightlow, &righthigh, &rightsum);
        int crosslow = INF;
        int crosshigh = INF;
        int crosssum = INF;
        findcloss(A, low,high,mid, &crosslow, &crosshigh, &crosssum);

        if (leftsum >= rightsum&&leftsum >= crosssum) {
            int* a = &leftlow;
            int* b = &lefthigh;
            int* c = &leftsum;
            *anslow = *a;
            *anshigh = *b;
            *ansval = *c;
        }
        else if (rightsum >= leftsum&&rightsum >= crosssum) {
            int* a = &rightlow;
            int* b = &righthigh;
            int* c = &rightsum;
            *anslow = *a;
            *anshigh = *b;
            *ansval = *c;
        }
        else {
            int* a = &crosslow;
            int* b = &crosshigh;
            int* c = &crosssum;
            *anslow = *a;
            *anshigh = *b;
            *ansval = *c;
        }
    }
}
int main()
{
    int N;
    cin >> N;
    int* A = (int*)malloc(sizeof(int)*(N + 1));
    int* B = (int*)malloc(sizeof(int)*(N + 1));
    A[0] = 0;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        B[i] = A[i]-A[i-1];
    }
    //B[i]?????????????????§??¨??????????????????????????°??????.
    int anslow = INF;
    int anshigh = INF;
    int ansval = INF;
    findmax(B, 2, N, &anslow, &anshigh, &ansval);
    cout << ansval << "\n";

    return 0;
}

Measured memory_bytes: 4660
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define MOD 1000000007
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) (v).begin() , (v).end()
#define sumof(v) accumulate(all(v), 0LL, plus<ll>())
#define maxof(v) max_element(all(v))
#define minof(v) min_element(all(v))
#define inf INT_MAX

int main(){
    FASTIO
    ll N; cin>>N;
    vector<int> h(N);
    for(int i=0; i<N; ++i) cin>>h[i];
    vector<int> cost(N, inf);
    cost[0] = 0;
    for(int i=0; i<N-1; ++i){
        if(i+1<N) cost[i+1] = min(cost[i+1], cost[i] + abs(h[i+1]-h[i]));
        if(i+2<N) cost[i+2] = min(cost[i+2], cost[i]+abs(h[i]-h[i+2]));
    }
    cout<<cost[N-1]<<endl;
}

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

int main(){
    int N;
    cin >> N;
    long nums[max(N + 1, 2)];
    nums[0] = 2;
    nums[1] = 1;
    for(int i = 2; i <= N; i++){
        nums[i] = nums[i - 2] + nums[i - 1];
    }
    cout << nums[N] << endl;
}

Measured memory_bytes: 256
// Best practice

#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// #include <functional> // for less

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
// using namespace __gnu_pbds;

// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds;

// #define fbo find_by_order
// #define ook order_of_key

// Code from Here -------------------------------------------------------------------------------


signed main() {
	tezz


	int n;
	cin >> n;
	int a, b;
	cin >> a >> b;
	if (a % n == 0)cout << "OK" << endl;
	else {
		int x = (a / n + 1) * n;
		if (x <= b)cout << "OK" << endl;
		else cout << "NG" << endl;
	}

	return 0;
}


Measured memory_bytes: 3656
#include<iostream>
using namespace std;
const int N = 2005, M = 1e9 + 7;
int n, m, f[N];
int main() {
	scanf("%d%d", &n, &m);
	f[n + 1] = 1;
	for (int i = 1; i < m; i++) {
		int sum = f[n - i + 2];
		for (int j = n - i + 1; j >= 2; j--) {
			(sum += f[j]) %= M;
			if (j <= n - i + 1)f[j] = sum;
		}
	}
	int ans = 0;
	if (m == 1)ans = 1;
	else for (int j = 2; j <= n - (m - 1) + 1; j++)(ans += f[j]) %= M;
	for (int i = 1; i <= n - m - 1; i++)(ans *= 2) %= M;
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <stdio.h>

const int mod = (int) 1e9 + 7;

long long f[404][404];
long long coef[404][404];

long long power( int a, int b ) {
	long long ret = 1;
	
	while( b > 0 ) {
		if( b % 2 ) {
			ret = (ret * a) % mod;
		}
		
		b /= 2;
		a = ((long long) a * a) % mod;
	}
	
	return ret;
}

long long sum( long long coef[], int l, int r ) {
	return (coef[r] - coef[l-1] + mod) % mod;
}

int main( void ) {
	int n, c;
	scanf("%i %i", &n, &c);
	
	int L[n+1];
	for( int i = 0; i < n; i++ ) {
		scanf("%i", &L[i]);
	}
	
	int R[n+1];
	for( int i = 0; i < n; i++ ) {
		scanf("%i", &R[i]);
	}
	
	for( int j = 0; j <= 400; j++ ) {
		coef[j][1] = 1;
		for( int i = 2; i <= 400; i++ ) {
			coef[j][i] = (coef[j][i-1] + power(i, j)) % mod;
		} 
	}
	
	f[n][0] = 1;
	for( int i = n-1; i >= 0; i-- ) {
		for( int j = 0; j <= c; j++ ) {
			long long cur = 0;
			for( int k = 0; k <= j; k++ ) {
				cur += (sum(coef[k], L[i], R[i]) * f[i+1][j-k]) % mod;
				cur %= mod;
			}
			f[i][j] = cur;
		}
	}
	
	printf("%lld\n", f[0][c]);
	
	return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[]) {
  int N, K,count=1;
  std::cin >> N >> K;
  for(int n=N-K;;n=n-K+1,count++) if(n<=0)break;
  std::cout << count << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.io.*;

class Main
{
  static void do_left(String s, int[] v, int idx){
	while(idx > 0 && s.charAt(idx) == '>'){
      v[idx - 1] = Math.max(v[idx] + 1, v[idx - 1]);
      idx -= 1;
    }
  }

  static void do_right(String s, int[] v, int idx){
    while(idx < s.length() - 2 && s.charAt(idx + 1) == '<'){
      v[idx + 1] = Math.max(v[idx] + 1, v[idx + 1]);
      idx += 1;
    }
  }
  
  public static void main(String... args) throws Exception {
	BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	String s = ">" + reader.readLine() + "<";
    int[] v = new int[s.length() - 1];

    for(int i = 0; i < s.length() - 1; i++){
      if(s.charAt(i) == '>' && s.charAt(i + 1) == '<'){
        do_left(s, v, i);
        do_right(s, v, i);
      }
    }

    //Arrays.stream(v).forEach(x -> System.out.print(x + ","));
    //System.out.println();
	long sum = 0;
    for(int i = 0; i < v.length; i++){
      sum += v[i];
    }
    System.out.println(sum);    
  }
}


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

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

            // 解析
            int iMin = (iX - iK) + 1;
            int iMax = (iX + iK) - 1;
            List<string> sOut = new List<string>();
            for(int i = iMin; i <= iMax; i++) { sOut.Add(i.ToString()); }

            // 出力
            System.Console.WriteLine("{0}", string.Join(" ", sOut.ToArray()).ToString().Trim());

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

}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;

    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <unordered_map>
#include <utility>
#include <map>
#include <set>
using namespace std;

int judge(int n){
    int i = 0;
    int ans = 0;
    int count = 0;
    for(i = 1; i <= sqrt(n); i++){
        if(i*i == n){
            count += 1;
        }else{
            if(n%i == 0){
                count += 2;
            }
        }
    }
    
    if(count == 8){
        ans = 1;
    }
    
    return ans;
}

int main(){
    int n;
    cin >> n;
    int ans = 0;
    
    int i;
    
    for(i = 1; i <= n; i++){
        if(i%2 == 1){
            if(judge(i)){
                ans += 1;
            }
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
from fractions import gcd
n = int(input())
A = list(map(int, input().split()))

m = []
left = [0]
right = [0]
for i in range(n):
    left.append(gcd(left[i], A[i]))
    right.append(gcd(right[i], A[n-i-1]))
    

for i in range(n):
    m.append(gcd(left[i], right[n-i-1]))
    
print(max(m))

Measured memory_bytes: 99168
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll; 
const int mod=1e9+7;
int n;
int main (){
   cin>>n;
   vector<int> a(n);
   int s=0;
  for(int i=0;i<n;i++){
   cin>>a[i];
    s=((ll)s+a[i])%mod;
  }
  s=(ll)s*s%mod;
  for(int ai:a)s=(s-ai*(ll)ai)%mod;
  s=(ll)s*((mod+1)/2)%mod;
  cout<<((ll)s+mod)%mod<<endl;
  return 0;
}



Measured memory_bytes: 4056
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)
	fmt.Println(divisor(a, b, k))
}

func divisor(a, b, k int) int {
	var i int
	if a > b {
		i = b
	} else {
		i = a
	}
	var count int
	for {
		if a%i == 0 && b%i == 0 {
			count++
		}
		if count == k {
			return i
		}
		i--
	}
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

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

signed main() {
  int a, b;
  cin >> a >> b;
  
  int s = 0, n = (int)1e6;
  rep(i0,n) {
    int i = i0 + 2, fa = 0, fb = 0;
    while(a % i == 0) a /= i, fa = 1;
    while(b % i == 0) b /= i, fb = 1;
    s += (fa && fb);
  }
  
  cout << s + 1 + (a != 1 && a == b) << endl;
  return 0;
}

Measured memory_bytes: 3560
#include <stdio.h> 

int main()
{
    int n = 0,i = 0;

    scanf("%d",&n);

    if(n<1200)
    {
        printf("ABC\n");
        return 0;
    }

    else if(n>=1200 && n<2800){
    printf("ARC\n");
    }

    else if(n >= 2800)
    printf("AGC\n");

    return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
#include <fstream>
using namespace std;

int main()
{
    //  freopen("timber_input.txt", "r", stdin);
   // freopen("out3_test.txt", "w", stdout);
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--) {
    ll n,i,j;
    cin>>n;
    ll arr[n+1],dp[n+1];

    for(i=0;i<n;i++)
        cin>>arr[i];
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(i=2;i<n;i++)
    {
        ll x=abs(arr[i]-arr[i-1])+dp[i-1];
        ll y=abs(arr[i]-arr[i-2])+dp[i-2];
        dp[i]=min(x,y);
    }
    cout<<dp[n-1];
    }

}


Measured memory_bytes: 5172
#include<stdio.h>
int main()
{
	int n,m;
	while(~scanf("%d %d",&n,&m))
	{
		int t=n/(2*m+1);
		if(n%(2*m+1)!=0)
		{
			t++;
		}
	    printf("%d\n",t);
	}
}

Measured memory_bytes: 1716
#include<iostream>

using namespace std;

int main(void)

{
    int n,r,a,i;
    cin>>n>>r;
    if(n>=10){
        cout<<r<<endl;
    }
    else{
            i = 100*(10-n);
        a = r+i;
        cout<<a<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
fun main(args:Array<String>):Unit {
    val vector = Vector()
    repeat(readLine()!!.toInt()){
        val arg = readLine()!!.split(' ').map(String::toInt)
        when(arg.first()){
            0 -> vector.pushBack(arg.last())
            1 -> println(vector[arg.last()])
            else -> vector.popBack()
        }
    }
}

class Vector {
    var capacity:Int = 100
        private set
    var size:Int = 0
        private set
    private var mArray:Array<Int> = Array(100){0}
    fun pushBack(value:Int):Unit  {
        if (size == capacity){
            capacity *= 2
            val newArray = Array(capacity * 2){0}
            mArray.forEachIndexed{
                index, v-> newArray[index] = v
            }
            mArray = newArray
        }
        mArray[size++] = value
    }
    fun popBack():Unit { --size}
    operator fun get(index:Int):Int = mArray[index]
}


Measured memory_bytes: 115944
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p) {
    return out << "(" << p.first << ", " << p.second << ")";
}
template<class A> ostream& operator <<(ostream& out, const vector<A> &v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        if(i) out << ", ";
        out << v[i];
    }
    return out << "]";
}

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

    int n, k;
    cin >> n >> k;
    vector<int> vec(k);
    int s = 0;
    for (int i = 0; i < k; i++) {
        cin >> vec[i];
        s += vec[i];
    }
    cout << (n >= s ? n - s : -1) << '\n';


    return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
int main(){
  int num=0;
  int i=0;
  int j=0;
  for(i=1;i<10;i++){
    for(j=1;j<10;j++){
      num=i*j;
      printf("%dx%d=%d\n", i, j, num);
    }
  }
  return 0;
}

Measured memory_bytes: 520
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll N;
  ll A[5];
  cin >> N >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
  sort(A,A+5);
  ll ans = 4 + ((N + A[0] - 1)/A[0]);
  cout << ans << endl;
  return 0;
}

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

int main()
{
    string S;
    cin >> S;
    
    int count = 0;
    int N;
    N = S.length();
    
    if(N == 1){
        cout << 1 << endl;
        return 0;
    }
    
    vector<int> dp(N+1, 0);
    
    dp[0] = 0;
    dp[1] = 1;
    if(S[0] == S[1]) dp[2] = 1;
    else dp[2] = 2;
    
    for(int i = 3; i<N+1; i++){
        if(S[i-2] != S[i-1]){
            dp[i] = dp[i-1]+1;
        }
        else{
            dp[i] = dp[i-3]+2;
        }
    }
    cout << dp[N] << endl;
    return 0;
}



Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

signed main() {
    ll K, A, B;
    cin >> K >> A >> B;

    bool exc = B - A > 2;
    ll ans = 0;

    if (exc)
    {
        ans = A;
        K -= A - 1;

        ans += K / 2 * (B - A) + (K % 2);
    }
    else
    {
        ans = K + 1;
    }
    cout << ans << LF;

    return 0;
}


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

string s;

int main(void) {
  cin >> s;
  int w, b;
  w = b = 0;
  char nowch = s[0];
  for(int i = 0; i < s.size(); ++i) {
    if(s[i] != nowch) {
      if(nowch == 'W') w++;
      else b++;
      nowch = s[i];
    }
  }
  cout << w+b << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
void change(string &s, int num)
{
    int length = (int)s.size();
    char ch = num + '0';
 
    for (int i = 0; i < length; i++) {
	if (s[i] == 'X') {
	    s[i] = ch;
	}
    }
}
 
bool check(char ch, int size)    
{
    return (ch == 'X' && size > 1);
}
 
char calc(char x, char y, char z, bool &C)
{
    int a = x - '0', b = y - '0', c = z - '0';
    int d = a + b + c;
    if (d >= 10) {
	C = true;
	d -= 10;
    }
    return d + '0';
}
 
string sum(string a, string b)
{
    string res = "";
 
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
 
    int length;
    if ((int)a.size() > (int)b.size()) {
	length = (int)a.size();
     
	for (int i = (int)b.size(); i < length; i++) {
	    b += '0';
	}
    } else {
	length = (int)b.size();
 
	for (int i = (int)a.size(); i < length; i++) {
	    a += '0';
	}
    }
 
    for (int i = 0; i <= length; i++) {
	res += '0';
    }
 
    for (int i = 0; i < length; i++) {
	bool C = false;
	res[i] = calc(a[i], b[i], res[i], C);
	if(C) res[i+1] = ((res[i+1]-'0') + 1) + '0';
    }
 
    for (int i = length; i > 0; i--) {
	if (res[i] == '0') {
	    res.erase(res.begin()+i);
	} else {
	    break;
	}
    }
    reverse(res.begin(), res.end());  
    return res;
}
 
int main()
{
    string str;
 
    while (cin >> str) {
	int pos_plus = str.find('+'), pos_equal = str.find('=');    
 
	string x = str.substr(0, pos_plus);
	string y = str.substr(pos_plus+1, pos_equal - pos_plus - 1);
	string z = str.substr(pos_equal + 1);
 
	int start = 0;
	if (check(x[0],x.size()) || 
            check(y[0],y.size()) || 
            check(z[0],z.size()) ) {
	    start = 1;
	}    
 
	int ans;
	bool found = false;
	for (int i = start; i < 10; i++) {
	    string a = x, b = y, c = z;
    
	    change(a, i); change(b, i); change(c, i);
 
	    if (sum(a,b) == c) {
		found = true;
		ans = i;
		break;
	    }
	}
 
	if (found) {
	    cout << ans << endl;
        } else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

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

int main(){
  int maxup=0, maxdown=0, n, t;
  cin >> t;

  for(int m = 0; m<t; ++m){
    maxup = maxdown = 0;
    
    cin >> n;

    int *h = new int[n];
    
    for(int i=0; i<n; ++i){
      cin >>h[i];
      
      if( i != 0){
	if(h[i-1] - h[i] < 0){
	  if(maxup < h[i] - h[i-1]) maxup = h[i] - h[i-1];
	}
	if(h[i-1] - h[i] > 0){
	  if(maxdown < h[i-1] - h[i]) maxdown = h[i-1] - h[i];
	}
      }
    }


    cout << maxup << " "<< maxdown << endl;

    delete[] h;
  }
  return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll S; cin >> S;

    // |x1y2+ x2y3 + x3y1 - x2y1 - x3y2 - x1y3| = S
    // |x2y3 - x3y2| = S
    // x2 = 1e9, y2 = 1;
    const ll L = 1e9;
    ll Q = S/L, R = S%L;
    if (R > 0) ++Q, R = L-R;
    cout << 0 << ' ' << 0 << ' ' << L << ' ' << 1 << ' ' << R << ' ' << Q << '\n';
}



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

using namespace std;

int main() {
	int n, k, a[55], p = 99;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	stringstream s;
	for (int i = 0; i < k + 1; i++) {
		int m = 111, x;
		for (int j = 0; j < n; j++)
			if (j != p && a[j] < m) m = a[x = j];
		if (!m) {
			cout << -1 << endl;
			return 0;
		}
		for (int j = 0; j < n; j++)
			if (j != p && j != x)
				s << j + 1 << ' ', a[j]--;
		s << x + 1 << ' ', a[x]--;
		p = x;
	}
	cout << n + (n - 1)*k << '\n' << s.str() << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int n;

int days(int y, int m, int d) {
    // day
    int days = d;
    
    // month
    if (y % 3 == 0) {
        d += (m - 1) * 20;
    } else {
        d += 20 * (m / 2) + 19 * ((m - 1) / 2);
    }

    // year
    int uruu = (y - 1) / 3;
    d += uruu * 200 + (y - 1 - uruu) * 195;

    return d;
}

int main() {
    cin >> n;
    int mille = days(1000, 1, 1);
    for (int i = 0; i < n; ++i) {
        int y, m, d;
        cin >> y >> m >> d;
        cout << mille - days(y, m, d) << endl;
    }
}

Measured memory_bytes: 3008
X, K, D = map(int, input().split())

ans = 0
if K*D < abs(X):
    ans = abs(X) - K*D
else:
    a1 = X//D
    a2 = X%D
    K -= a1
    # 往復する
    if K%2 == 0:
        ans= a2
    else:
        ans = abs(a2-D)
print(ans)

# 1000000000000000 1000000000000000 1000000000000000

Measured memory_bytes: 9180
n,l=[int(x) for x in input().split()]
a=l
pie=0
app=[]
for i in range(n):
  apple=l+i
  pie+=apple
  app.append(apple)
b=[]
for i in app:
  j=abs(i)
  b.append(j)
c=min(b)
d=b.index(c)
pie-=app[d]
print(pie)

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int n;cin >>n;
    set<char>s;
    for (int i = 0; i < n; ++i) {
        char c;cin >>c;
        s.insert(c);
    }
    if(s.size()==3){
        puts("Three");
    }
    else puts("Four");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
ll test[1234][1234];
signed main() {
	ll n = 0, a, cnt = 1, ans = 0; string s; cin >> n >> s;
	for (int h = 1; h < n; h++) {
		vector<ll> v(27); ll sum = 0;
		for (int i = 0; i < h; i++) { v[(int)(s[i]) - 97] = 1; }
		for (int i = h; i < n; i++) {
			if (v[(int)(s[i]) - 97] == 1) { v[(int)(s[i]) - 97] = 0; sum++; }
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
	cin >> n; return 0;
}

Measured memory_bytes: 256
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define int ll
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
ll get(ll a,ll b,ll c){
	return (b-a+1)-(b/c-(a-1)/c);
}
ll gcd(ll a,ll b){
	if(!b)return a;
	return gcd(b,a%b);
}
ll a,b,sumc,sumd,sumcd;int c,d;
signed main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	printf("%lld\n",get(a,b,c)+get(a,b,d)-get(a,b,1ll*c*d/gcd(c,d)));
	return 0;
}


Measured memory_bytes: 256
while True:

    H, W =(int(i) for i in input().split())
    line1, line2 = "", ""
    line3, line4 ="#", "."
    if H == 0 and W ==0:
        break
    
    elif W % 2 == 0:
        for i in range(W//2):
            line1 += "#."
            line2 += ".#"
        if H % 2 == 0:
            for i in range(H//2):
                print(line1)
                print(line2)
            print()
        else:
            print(line1)
            for i in range(H//2):
                print(line2)
                print(line1)
            print()
            
    
    
    else:
        for i in range(W//2):
            line3 += ".#"
            line4 += "#."
        if H % 2 == 0:
            for i in range(H//2):
                print (line3)
                print (line4)
            print()
        else:
            print(line3)
            for i in range(H//2):
                print(line4)
                print(line3)
            print()
    
    

Measured memory_bytes: 7804
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

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

    int Q;
    cin >> Q;

    vector<int> T(Q), F(Q);
    vector<char> C(Q);

    for (int i = 0; i < Q; i++){
        cin >> T.at(i);
        if (T.at(i) == 1){
            F.at(i) = 0;
            C.at(i) = ' ';
        }
        else{
            cin >> F.at(i) >> C.at(i);
        }
    }

    string head = "";
    string tail = "";
    bool even = true;
    for (int i = 0; i < Q; i++){
        // reverse
        if (T[i] == 1){
            even = not even;
            swap(head, tail);
        }
        // append
        else{
            if (even){
                if (F[i] == 1){
                    head = C[i] + head;
                }
                else{
                    tail = tail + C[i];
                }
            }
            else{
                if (F[i] == 1){
                    head = head + C[i];
                }
                else{
                    tail = C[i] + tail;
                }
            }
        }
    }

    if (not even){
        reverse(head.begin(), head.end());
        reverse(tail.begin(), tail.end());
        reverse(S.begin(), S.end());
    }

    cout << head + S + tail << endl;

    return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

Graph g;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  for(int i = 0; i < n; ++i) cin >> h[i];
  g.resize(n);
  for(int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  int ans = 0;
  for(int i = 0; i < n; ++i) {
    bool ok = true;
    for(int u : g[i]) {
      if (h[u] >= h[i]) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8728
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <ctime>

#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL)
#define TT int test_cases; cin >> test_cases; while(test_cases--)
#define TT1 int test_cases=1; while(test_cases--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
using namespace std;
typedef long long int ll;


int main() {
    
    FAST;
    TT1{
        
        string s;cin>>s;
        string t;cin>>t;
        int n=s.size();
        int c=0;
        for(int i=0;i<n;i++) if(s[i]!=t[i]) c++;
        cout<<c<<"\n";
        
    }
}

Measured memory_bytes: 3816
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)


//2部最大マッチング verified AOJ GRL_7_A
#define MAX_V 800
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u,int v){
    G[u].pb(v);
    G[v].pb(u);
}

// 増大路をDFSで探す
bool dfs(int v){
    used[v]=true;
    rep(i,G[v].size()){
        int u=G[v][i],w=match[u];           //u:vからの移動先の頂点 , w:uとマッチングしている頂点
        if(w<0 || (!used[w] && dfs(w))){    //uがフリーか、このdfsではwを使っておらず かつwの別のペアが見つかった(=増大路発見) 場合
            match[v]=u;
            match[u]=v;
            return true;
        }
    }
    return false;
}

int bipartite_matching(int V){
    int res=0;
    rep(i,MAX_V)match[i]=-1;
    rep(v,V){
        if(match[v]<0){
            rep(i,MAX_V)used[i]=0;
            if( dfs(v) ) res++;       //増大路が見つかればres+=1
        }
    }
    return res;
}

int main(){
    int ans = 0;
    int v,a,b;
    cin>>v>>a>>b;
    
    vector<int> s(v),t(v);
    rep(i,v){
        cin>>s[i]>>t[i];
        if(abs(s[i]-t[i])<=a or (b<=abs(s[i]-t[i]) and abs(s[i]-t[i])<=2*a))ans++;
    }
    
    auto g = [](int ai,int bi, int aj, int bj){
        return abs((ai+aj)-(bi+bj));
    };
    
    rep(i,v){
        if(abs(s[i]-t[i])<=a or (b<=abs(s[i]-t[i]) and abs(s[i]-t[i])<=2*a))continue;
        rep(j,v){
            if(abs(s[j]-t[j])<=a or (b<=abs(s[j]-t[j]) and abs(s[j]-t[j])<=2*a))continue;
            
            if(g(s[i],t[i],s[j],t[j])<=a or (b<=g(s[i],t[i],s[j],t[j]) and g(s[i],t[i],s[j],t[j])<=2*a) ){
                G[i].pb(j);
            }
        }
    }
    cout<<bipartite_matching(v)+ans<<endl;
}


Measured memory_bytes: 3408
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

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

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  long double sum = 0; ll n; cin >> n;
  vl x(n); vl y(n);
  rep(i,n){
    cin >> x[i] >> y[i];
  }
  
  rep(i,n){
    rep(j,n){
      if(i != j){
        ll dx = x[i]-x[j]; ll dy = y[i]-y[j]; 
        sum += sqrt(dx*dx+dy*dy);
      }
    }
  }
  
  dec(10);
  cout << sum/n << endl;
  
  
}

Measured memory_bytes: 3896
#include<iostream>
#include<complex>
using namespace std;
typedef complex<double> P;
double det(P a,P b){
  return (conj(a)*b).imag();
}
double solve(P a,P b,P p){
  return (conj(p)*b).imag()/det(a,b);
} 
int main(){
  P a,b,c,p;
  while(cin>>a.real()>>a.imag()>>b.real()>>b.imag()>>
	c.real()>>c.imag()>>p.real()>>p.imag()){
    double s=solve(b-a,c-a,p-a),t=solve(c-a,b-a,p-a);
    cout<<(0<s&&s<1&&0<t&&t<1&&s+t<1?"YES":"NO")<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.size();i++){
        if(s[0]!='A'){
            cout<<"WA"<<endl;
            return 0;
        }
        if(s[1]=='C'){
            cout<<"WA"<<endl;
            return 0;
        }
        if(s[s.size()-1]=='C'){
            cout<<"WA"<<endl;
            return 0;
        }
        if(int(s[i])<=95&&s[i]!='A'&&s[i]!='C'){
			cout<<"WA"<<endl;
			return 0;
		}
        if(i>=2&&s[i]=='C'){
            sum++;
        }
        else{
        }
    }
    if(sum==1){
        cout<<"AC"<<endl;
    }
    else{
        cout<<"WA"<<endl;
    }
}


Measured memory_bytes: 256
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;


//(int)'a'は97 (int)'A'は65
//おまじない



int main() {

	ll m, n;
	ll t[100];
	ll sum = 0;
	ll dri[100][2];

	cin >> n;
	roop(i, 0, n) {
		cin >> t[i];
		sum += t[i];
	}

	cin >> m;

	roop(i, 0, m) {
		cin >> dri[i][0] >> dri[i][1];
		dri[i][0]--;
	}

	roop(i, 0, m) {
		ll ans = 0;
		ans = sum - (t[dri[i][0]] - dri[i][1]);
		cout << ans << endl;
	}


	return 0;
}


Measured memory_bytes: 256