akhauriyash/Code-Regression huggingface dataset:
from operator import itemgetter
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
data = []
now = 0
for i in range(m):
    b,c = map(int,input().split())
    data.append((b,c))
for i,j in sorted(data,key=itemgetter(1),reverse=True):
    while A[now] < j and i:
        A[now] = j
        i -= 1
        now += 1
        if now == n:
            print(sum(A))
            exit()
    if A[now] >= j:
        print(sum(A))
        break
else:
    print(sum(A))        

Measured memory_bytes: 22836
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){

	int a,b,c,d,p,res;

	cin >> a >> b >> c >> d >> p;
	
	if(p < c) res = b;
	else if(c < p) res = b + (d * (p - c));

	cout << ((a*p > res) ? res : a*p) << endl;

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[311];
int dp[311][311][311],K;
int main()
{
	scanf("%s%d",s,&K);int n=strlen(s);
	for(int i=n;i>=1;i--)s[i]=s[i-1];
	for(int i=1;i<=n;i++)dp[i][i][0]=1;
	for(int len=2;len<=n;len++)
	{
		for(int i=1;i+len-1<=n;i++)
		{
			int j=i+len-1;
			for(int k=0;k<=min(len>>1,K);k++)
			{
				dp[i][j][k]=max(dp[i+1][j][k],dp[i][j-1][k]);
				if(s[i]==s[j])dp[i][j][k]=max(dp[i][j][k],dp[i+1][j-1][k]+2);
				else if(k>0)dp[i][j][k]=max(dp[i][j][k],dp[i+1][j-1][k-1]+2);
			}
		}
	}
	int ans=0;
	for(int i=0;i<=K;i++)ans=max(ans,dp[1][n][i]);
	printf("%d",ans);return 0;
}

Measured memory_bytes: 114560
#include<iostream>
#include<queue>
using namespace std;
int p[32000];
int gcd(int a, int b);
int gcd1[100002];
int gcd2[100002];
int main() {
	
	//D
	/*int n;
	cin >> n;
	long long int a[100000];
	int i;
	int minuscount = 0;
	long long int suma = 0;
	long long int mina = 1000000001;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] >= 0) {
			suma = suma + a[i];
			if (a[i] < mina)mina = a[i];
		}
		else {
			minuscount++;
			if (-a[i] < mina)mina = -a[i];
			suma = suma - a[i];
		}
	}
	if (minuscount % 2 == 1)suma = suma - 2 * mina;
	cout << suma << endl;
	return 0;
	*/

	//C再
	int n;
	cin >> n;
	int a[100002];
	int i;
	for (i = 1; i <= n; i++) {
		cin >> a[i];
	}
	a[n + 1] = 0;
	//gcd1は0からiまでのgcd
	//gcd2はiからn+1までのgcd
	int j;
	gcd1[0] = 0;
	for (i = 1; i <= n; i++) {
		gcd1[i] = gcd(gcd1[i - 1], a[i]);
	}
	gcd2[n + 1] = 0;
	for (i = n; i > 0; i--) {
		gcd2[i] = gcd(gcd2[i + 1], a[i]);
	}
	int gcdmax = 0;
	int gcdcheck;
	for (i = 1; i <= n; i++) {
		gcdcheck = gcd(gcd1[i - 1], gcd2[i + 1]);
		if (gcdcheck > gcdmax)gcdmax = gcdcheck;
	}
	cout << gcdmax << endl;
	return 0;


	//C
	/*int n;
	cin >> n;
	int a[100000];
	int i,j;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	//int p[32000];
	int flag = 0;
	int pp = 0;
	for (i = 2; i < 32000; i++) {
		for (j = 0; j * j <= i; j++) {
			if (i % j == 0) {
				flag = 1;
				break;
			}
		}
		if (flag == 0) {
			p[pp] = i;
			pp++;
		}
	}
	for (i = 0; i < pp; i++) {
		for (j = 0; j < n; j++) {
			if (a[i] % p[pp] == 0) {

			}
		}
	}*/

	//B
	/*int n;
	cin >> n;
	int i;
	int cost = 0, v[20], c[20];
	for (i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (i = 0; i < n; i++) {
		cin >> c[i];
	}
	for (i = 0; i < n; i++) {
		if (v[i] - c[i] > 0) {
			cost = cost + v[i] - c[i];
		}
	}
	cout << cost << endl;
	return 0;
	*/
	//A
	/*
	int a, b, t;
	cin >> a >> b >> t;
	int bb = 0;
	int aa = 0;
	while (aa + a <= t) {
		bb = bb + b;
		aa = aa + a;
	}
	cout << bb << endl;
	return 0;
	*/
}
int gcd(int a, int b) {

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

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


int main() {
    int a[3], k;
    for (int i=0; i < 3; i++)cin >> a[i];
    cin >> k;
    sort(a , a + 3 );
    for (int i=0; i < k; i++) { a[2] *= 2; }
    cout << a[0]  + a[1] + a[2] << endl;
   
    return 0;
   
}

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

vector<vector<pair<int,int>>> vp(15);

int check(int n, vector<int>& c){
    int num = 0;
    for(int i=0; i<n; i++){
        if(c[i] == 0) continue;
        for(auto e: vp[i]){
            if(c[e.first] != e.second) return 0; //, cout << " false"<< endl;
        }
        num++;
    }
    return num;
}

void comb(int i, int n, vector<int>& c, int& ans){
    if (i == n){
        ans = max(ans, check(n, c));
        return;
    }
    c[i] = 1;
    comb(i+1, n, c, ans);
    c[i] = 0;
    comb(i+1, n, c, ans);
}

int main()
{
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        int m;
        cin >> m;
        for(int j=0; j<m; j++){
            int x,y;
            cin >> x >> y;
            x--;
            vp[i].push_back({x,y});
        }
    }
    vector<int> c(n);
    int ans = 0;
    comb(0, n, c, ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

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

    P x[n];
    for(int i = 0; i < n; i++){
        cin >> x[i].first >> x[i].second;
    }

    sort(x, x + n);

    map<P, int> m;
    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            P t = make_pair(x[j].first - x[i].first, x[j].second - x[i].second);
            auto itr = m.find(t);
            if(itr == m.end()){
                m[t] = 1;
            }else{
                m[t]++;
            }
        }
    }

    int k = 0;

    for(auto i = m.begin(); i != m.end(); ++i){
        if(k < i->second){
            k = i->second;
        }
    }

    int ans = 0;
    ans = n - k;

    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;

int32_t main(){
	ios::sync_with_stdio(0);
	int n, k;
	cin >> n >> k;
	ll r, s, p;
	cin >> s >> p >> r;
	string st;
	cin >> st;
	ll ans = 0;
	for(int i=0; i<k; ++i){
		int j = i;
		while(j<n){
			int c = st[j];
			ll cnt = 0;
			while(j<n and st[j]==c) ++cnt, j+=k;
			cnt = (cnt+1)/2;
			if(c=='r') ans += cnt*r;
			if(c=='s') ans += cnt*s;
			if(c=='p') ans += cnt*p;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  int x,t;cin>>x>>t;
  cout<<max(0,x-t)<<endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=0
d=[]
z=0
for i in range(n):
    if a[i]<b[i]:
        c+=b[i]-a[i]
    else:
        z+=1
        d.append(a[i]-b[i])
if sum(a)<sum(b):
    print(-1)
elif z==n:print(0)
else:
    d.sort()
    d=d[::-1]
    for i in range(len(d)):
        if c<=d[i]:
            print(n-(len(d)-(i+1)))
            break
        else:
            c-=d[i]

Measured memory_bytes: 18356
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
 
const int MAXN = 1005;
const int INF = 1<<28;
int N;
bool used[MAXN];
string name[MAXN];
bool sell[MAXN];
string mono[MAXN];
int price[MAXN];
 
map<string, int> low, high, sum, num;
map<string, int> B, S;
 
int main() {
  while(cin >> N && N) {
    low.clear();
    high.clear();
    sum.clear();
    num.clear();
    B.clear();
    S.clear();
    for(int i = 0; i < N; ++i) {
      string sb;
      cin >> name[i] >> sb >> mono[i] >> price[i];
      sell[i] = (sb == "SELL");
      low[mono[i]] = INF;
      high[mono[i]] = -INF;
      sum[mono[i]] = 0;
      num[mono[i]] = 0;
      B[name[i]] = 0;
      S[name[i]] = 0;
    }
    fill(used, used+MAXN, false);
    for(int i = 0; i < N; ++i) {
      if(used[i]) continue;
      int p = sell[i] ? -1 : 1;
      int bestP = INF;
      int bestJ = -1;
      for(int j = 0; j < i; ++j) {
	if(used[j]) continue;
	if(name[i] == name[j]) continue;
	if(!(sell[i] ^ sell[j])) continue;
	if(mono[i] != mono[j]) continue;
	int newP = price[j] * p;
	if(newP < bestP) {
	  bestP = newP;
	  bestJ = j;
	}
      }
      if(bestJ == -1) continue;
      bestP *= p;
      int buyP, sellP;
      if(sell[i]) {
	buyP = bestP;
	sellP = price[i];
      } else {
	buyP = price[i];
	sellP = bestP;
      }
      if(sellP > buyP) continue;
      int v = (buyP+sellP)/2;
      used[i] = used[bestJ] = true;
      low[mono[i]] = min(low[mono[i]], v);
      high[mono[i]] = max(high[mono[i]], v);
      sum[mono[i]] += v;
      ++num[mono[i]];
      if(sell[i]) {
	B[name[bestJ]] += v;
	S[name[i]] += v;
      } else {
	B[name[i]] += v;
	S[name[bestJ]] += v;
      }
    }
 
    for(map<string,int>::iterator it = low.begin();
	it != low.end(); ++it) {
      if(num[it->first] == 0) continue;
      cout << it->first;
      cout << " " << low[it->first];
      cout << " " << sum[it->first]/num[it->first];
      cout << " " << high[it->first] << endl;
    }
    cout << "--" << endl;
    for(map<string,int>::iterator it = B.begin();
	it != B.end(); ++it) {
      cout << it->first;
      cout << " " << B[it->first];
      cout << " " << S[it->first] << endl;
    }
    cout << "----------" << endl;
  }
  return 0;
}

Measured memory_bytes: 1356
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        String s1 = ns();
        String s2 = ns();

        int n1 = s1.length();
        int n2 = s2.length();

        int[][] dp = new int[n1 + 1][n2 + 1];

        for (int i = 1; i <= n1; i++) {
            dp[i][0] = i;
        }
        for (int i = 1; i <= n2; i++) {
            dp[0][i] = i;
        }

        for (int i = 1; i <= n1; i++) {
            for (int j = 1; j <= n2; j++) {
                dp[i][j] = Math.min(dp[i - 1][j] + 1, dp[i][j - 1] + 1);
                dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - 1] + (s1.charAt(i - 1) == s2.charAt(j - 1) ? 0 : 1));
            }
        }

        out.println(dp[n1][n2]);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

int main() {
    string s, t; 
    cin>> s >> t;
    vector<vector<int>> DP(s.size()+1, vector<int>(t.size()+1, 0));
    REP(i, 1, s.size()+1){
        REP(j, 1, t.size()+1){
            if(s[i-1] == t[j-1]) DP[i][j] = max(DP[i][j], DP[i-1][j-1]+1);
            DP[i][j] = max(DP[i][j], DP[i][j-1]);
            DP[i][j] = max(DP[i][j], DP[i-1][j]);
        }
    }
    /*
    REP(i, 0, s.size()+1){
        REP(j, 0, t.size()+1){
            cout << DP[i][j] << " ";
        }
        cout << endl;
    }
    */

    int i = s.size(); int j = t.size();
    string ans = "";
    while(i > 0 && j > 0){
        if(DP[i][j] == DP[i-1][j]){
            i--;
        }
        else if(DP[i][j] == DP[i][j-1]){
            j--;
        }
        else{
            ans = s[i-1] + ans;
            i--; j--;
        }
    }
    cout << ans << endl;
}

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

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

#define INF 1000000000
#define MOD 1000000007
#define EPS 1e-12

#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())

// bitmask operations
#define SETBIT(S, j) S |= (1 << j)
#define CLEARBIT(S, j) S &= ~(1 << j)
#define ISSET(S, j) S & (1 << j)
#define FLIPBIT(S, j) S ^= (1 << j)
#define LSBIT(S) (S & (-S))

// debug
#define DEBUGSTR(S) cout << "(" << S << ")\n";

int main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int N;
    scanf(" %d", &N);

    printf("%d\n", N/3);

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using ll = long long int;

ll mpow(ll a, ll n, ll mod)
{
	ll r = 1;
	while (n) {
		if (n&1) r = r*a%mod;
		a = a*a%mod;
		n >>= 1;
	}
	return r;
}

const int N = 1e6+5;
int Div[N];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	ll n, x, m; cin >> n >> x >> m;
	vector<int> mark(m+1);
	vector<ll> seq;
	int st = -1, done = 0;
	ll sum = 0;
	while (1) {
		if (mark[x] == 0) {
			sum += x;
			++done;
			mark[x] = done;
			seq.push_back(x);
			x = (x*x)%m;
			if (done == n) return cout << sum << '\n', 0;
		}
		else {
			st = mark[x];
			break;
		}
	}
	ll ans = 0;
	for (int i = 1; i < st; ++i) {
		ans += seq[i-1];
		--n;
	}
	int cyc_len = seq.size()+1-st;
	ll cycle = 0;
	for (int i = st; i <= (int)seq.size(); ++i)
		cycle += seq[i-1];
	ll times = n/cyc_len;
	ans += cycle*times;
	n %= cyc_len;
	for (int i = 0; i < n; ++i)
		ans += seq[st-1+i];
	cout << ans << '\n';
	// k before + n*cycle + remainder

}

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

using namespace std;

int main(){
	int N; cin >> N;
	int K; cin >> K;
	for(int i = 0; i < K; i++){
		int x, y;
		cin >> x >> y;
		if(N % 2 == 0){
			x -= (2 * (x - (N / 2 + 1)) + 1) * (x > N / 2);
			y -= (2 * (y - (N / 2 + 1)) + 1) * (y > N / 2);
		}
		x = abs(x - ((N + (N % 2)) / 2));
		y = abs(y - ((N + (N % 2)) / 2));
		
		int n = max(x, y);
		cout << ((N / 2) - n - (N + 1) % 2) % 3 + 1 << endl;
	}
	return 0;
}

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

#define thegamebegins   ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fileio          freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define int             long long
#define float           long double
#define test            int T; cin>>T; while(T--)
#define in(a,n)         for(int i=0; i<n; ++i)  cin>>a[i]
#define r0              return 0
#define E               "\n"
#define S               " "
#define elif            else if 
#define M               1000000007
#define fi(i,x,y)       for(int i=x; i<y; ++i)
#define fa(i,s)         for(auto i:s)
#define fp(i,s)         for(auto i=(s).begin(); i!=(s).end(); ++i)
#define sz(s)           (s).size()
#define vi              vector <int>
#define vpii            vector <pair <int,int> >
#define mii             map <int,int>
#define pii             pair <int,int>
#define seti            set <int>
#define setd            set <int,greater <int> >
#define all(s)          (s).begin(),(s).end()
#define sortd(a,n)      sort(a, a+n, greater<int>())
#define pb              push_back
#define mp              make_pair
#define fr              first
#define sc              second
#define lb              lower_bound
#define ub              upper_bound
#define er              equal_range
 
const int INF = 0x3f3f3f3f;

signed main()
{
    thegamebegins

    int n,k;    cin>>n>>k;
    if(n<k)
    {
        cout<<min(n,abs(n-k));
        r0;
    }
    n-=(n/k)*k;
    cout<<min(n,abs(n-k));
    r0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

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

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

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

    ll ans = 0;

    char pre = '\0';

    for(int i = 0; i < str.size() - 1; i++){
        if(pre == str[i]){
            i++;
            pre = '\0';
            if(i == str.size() - 1){
                pre = str.back();
            }
        }else{
            pre = str[i];
        }
        ans++;
    }

    if(str.size() > 1 && pre == str.back()){

    }else{
        ans++;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

using ll = long long;

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

    ll n, k;

    cin >> n >> k;
    ll cnt = 0;
    for (ll a = 1; a <= n; ++a) {
        if ((2 * a) % k != 0) continue;

        ll x = (n + a) / k, y = a / k, z = x - y;
        cnt += z * z;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int ans = 0;
        ans += n * (n - 1) / 2;
        ans += m * (m - 1) / 2;
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
string s;
int a[6];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		cin>>s;
		if(s=="AC") ++a[0];
		else if(s=="WA") ++a[1];
		else if(s=="TLE") ++a[2];
		else if(s=="RE") ++a[3];
	}
	cout<<"AC x "<<a[0]<<"\nWA x "<<a[1]<<"\nTLE x "<<a[2]<<"\nRE x "<<a[3]<<"\n";
	return 0;
} 

Measured memory_bytes: 3536
# ABC139E - League
from collections import deque


def main():
    N = int(input())
    A = [0] + list(deque(map(int, input().split())) for _ in range(N))
    cnt, cur, days = 0, [0] * (N + 1), [0] * (N + 1)
    q = deque(list(range(1, N + 1)))
    while q:
        x = q.popleft()
        if not A[x]:  # player x has finished all games
            continue
        y = A[x].popleft()  # the opponent of x
        if cur[y] == x:  # player y's next game is against x and vice versa
            cnt += 1
            days[x] = days[y] = max(days[x], days[y]) + 1  # day of playing the game
            cur[x], cur[y] = 0, 0  # no next game is currently planned
            q.append(x), q.append(y)
        else:  # the opponent will do another game before playing against x
            cur[x] = y
    flg = cnt == N * (N - 1) // 2  # finished all scheduled games or not
    print(max(days) if flg else -1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 36096
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
namespace AOJ.Volume28
{
    class _2802
    {
        public static void Main()
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            System.Console.SetOut(sw);
            var target = System.Console.ReadLine().Trim();
            var pattern = System.Console.ReadLine().Trim();
            if (target.Length < pattern.Length) return;
            var match = new MatchPattern(pattern);
            var targetIndex = 0; var matchIndex = 0;
            while (targetIndex + matchIndex < target.Length)
            {
                if (target[targetIndex + matchIndex] == match[matchIndex])
                {
                    ++matchIndex;
                    if (matchIndex == pattern.Length)
                    {
                        System.Console.WriteLine(targetIndex);
                        targetIndex += matchIndex - match.BackTrack(matchIndex);
                        matchIndex = match.BackTrack(matchIndex);
                    }
                }
                else
                {
                    targetIndex += matchIndex - match.BackTrack(matchIndex);
                    if (matchIndex > 0) matchIndex = match.BackTrack(matchIndex);
                }
            }
            System.Console.Out.Flush();
        }
    }

    class MatchPattern
    {
        String mPattern;
        int[] mBackTrack;
        public MatchPattern(String pattern)
        {
            mPattern = pattern;
            mBackTrack = new int[pattern.Length + 1];
            mBackTrack[0] = -1; mBackTrack[1] = 0;
            var j = 0;
            for (var i = 2; i < mBackTrack.Length;)
            {
                if (mPattern[i - 1] == mPattern[j])
                {
                    mBackTrack[i] = j + 1; ++i; ++j;
                }
                else if (j > 0) j = mBackTrack[j];
                else
                {
                    mBackTrack[i] = 0; ++i;
                }
            }
        }
        public int BackTrack(int index)
        {
            return mBackTrack[index];
        }
        public char this[int index]
        {
            get { return mPattern[index]; }
        }
    }
}



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

int n;
priority_queue<pair<ll, ll>> q;

int main()
{
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
        q.push({a[i] + b[i], i});
    }
    int x = 0;
    ll ans = 0;
    while (!q.empty())
    {
        pair<ll, ll> p = q.top();
        q.pop();
        if (x)
        {
            ans -= b[p.second];
        }
        else
        {
            ans += a[p.second];
        }
        x ^= 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<ctype.h>
using namespace std;
int main(){
	string a, b, c;
	cin >> a >> b >> c;
	cout << char(toupper(int(a[0]))) << char(toupper(int(b[0]))) << char(toupper(int(c[0]))) << endl;
	return 0;
}

Measured memory_bytes: 256
X=int(input())
a=0
if X<=599:
  a=8
elif (X>=600)&(X<=799):
  a=7
elif (X>=800)&(X<=999):
  a=6
elif (X>=1000)&(X<=1199):
  a=5
elif (X>=1200)&(X<=1399):
  a=4
elif (X>=1400)&(X<=1599):
  a=3
elif (X>=1600)&(X<=1799):
  a=2
elif (X>=1800)&(X<=1999):
  a=1
print(a)

Measured memory_bytes: 9192
N,T=map(int,input().split())
t=list(map(int,input().split()))
t.append(t[N-1]+T)
ans=0

for i in range(N):
    if t[i+1]-t[i]<=T:
        ans+=t[i+1]-t[i]
    else:
        ans+=T

print(ans)    

Measured memory_bytes: 103860
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4
6 5 6 8"""
        output = """3"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """5
4 5 3 5 4"""
        output = """3"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """5
9 5 6 8 4"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    N=int(input())
    A=[int(i) for i in input().split()]
    mx=0
    count=0
    for i in A:
        if mx<=i:
            count+=1
            mx=i
    print(count)

if __name__ == "__main__":
    resolve()

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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define MP make_pair
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double EPS = 1e-9;
const double PI = acos(-1);
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

ll addMod(ll a, ll b){
	return (a+b) % MOD;
}

ll mulMod(ll a, ll b){
	return (a*b) % MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp, tmp);
	if(b & 1) tmp = mulMod(tmp, a);
	return tmp;
}

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

const int N = 5000;

ll n,m,p;
ll dist[N + 5];
ll u[N + 5], v[N + 5], w[N + 5];
vi G[N + 5], G2[N + 5];
bool vis[N + 5][3];

void dfs(int u){
	vis[u][1] = true;
	for(auto v : G[u]){
		if(!vis[v][1]){
			dfs(v);
		}
	}
}

void dfs2(int u){
	vis[u][0] = true;
	for(auto v : G2[u]){
		if(!vis[v][0]){
			dfs2(v);
		}
	}
}

ll solve(){
	REP(i,1,n) dist[i] = INF;
	dist[1] = 0;
	FOR(j,n){
		FOR(i,m){
			if(vis[v[i]][0] && vis[u[i]][0] && vis[v[i]][1] && vis[u[i]][1] && dist[v[i]] > dist[u[i]] + w[i]){
				dist[v[i]] = dist[u[i]] + w[i];
				if(j == n-1){
					return -1;
				}
			}
		}
	}
	if(dist[n] > 0) dist[n] = 0;
	return -dist[n];
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	memset(vis,0,sizeof vis);
	cin >> n >> m >> p;
	FOR(i,m){
		cin >> u[i] >> v[i] >> w[i], w[i] = p - w[i];
		G[u[i]].PB(v[i]);
		G2[v[i]].PB(u[i]);
	}
	dfs(1); dfs2(n);
	cout << solve() << endl;
	return 0;
}

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

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

  int count = 0;
  
  if(s.size() % 2 == 0) {
    for(int i = 0; i < s.size()/2 - 1; i++) {
      if(s.at(2 * (i + 1)) != s.at(0)) {
        count ++;
      }
    }
    for(int i = 0; i < s.size()/2;i++) {
      if(s.at(2 * (i + 1) - 1) == s.at(0)) {
        count ++;
      }
    }
  } else {
    for(int i = 0; i < s.size()/2; i++) {
      if(s.at(2 * (i + 1)) != s.at(0)) {
        count ++;
      }
    }
    for(int i = 0; i < s.size()/2 ;i++) {
      if(s.at(2 * (i + 1) - 1) == s.at(0)) {
        count++;
      }
    }
  }
  
  cout << count << endl;
}
    
      

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}


int N,K;
int table[2005][2005];
int S[2005][2005];

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> N >> K;
  const int L = 2*K;
  rep(i,N){
    int x,y;cin >> x >> y;
    char c; cin >> c;
    x%=L;
    y%=L;
    int black = 1;
    if(c=='W')black^=1;
    if(x>=K)black^=1;
    if(y>=K)black^=1;
    x%=K;
    y%=K;
    if(black){
      ++table[0][0];
      --table[0][y+1];
      --table[x+1][0];
      table[x+1][y+1]+=2;
    }else{
      ++table[0][y+1];
      ++table[x+1][0];
      table[x+1][y+1]-=2;
    }
  }
  rep(x,K)repp(y,1,K)table[x][y] += table[x][y-1];
  rep(y,K)repp(x,1,K)table[x][y] += table[x-1][y];
  int ans = 0;
  rep(x,K)rep(y,K){
    ans= max(ans,max(table[x][y],N-table[x][y]));
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 10496
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int h = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int maxa = 0;
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            if(a[i] > maxa){
                maxa = a[i];
            }
        }
        sc.close();
        
        int ans = 0;
        Arrays.sort(b);

        for(int i=0; i<n; i++){
            if(b[n-i-1] > maxa && h > 0){
                h -= b[n-i-1];
                ans++;
            }else{
                break;
            }
        }

        if(h > 0){
            ans += h / maxa;
            if(h%maxa != 0){
                ans++;
            }
        }
        
        System.out.print(ans);
	}
}

Measured memory_bytes: 66764
K =int(input())

from collections import deque
d = deque([])
for i in range(1,10):
    d.append(i)
for i in range(K):
    x = d.popleft()
    if x %10 != 0:
        d.append(10*x+x%10-1)
    d.append(10*x+x%10)
    if x%10 != 9:
        d.append(10*x+x%10+1)

print(x)

Measured memory_bytes: 11908
#include <stdio.h>

int main(){
	
int n;
scanf ("%d",&n);

int a = n/100;
int b = (n%100)/10;
int c = (n%10);

if (a == 7){
	printf ("Yes");
}
else if (b == 7){
	printf ("Yes");
}
else if (c == 7){
	printf ("Yes");
}
else {
	printf ("No");
}
	return 0;
}

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

using ll = long long;

bool check (vector <pair<int, int>> a) {
	int cur = 0;
	for (auto i:a) {
		if (cur + i.first < 0) return 0;
		cur += i.second;
	}
	return 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, total = 0;
	cin >> n;
	vector <pair<int, int>> ls, rs;
	for (int i=0; i<n; i++) {
		string s;
		cin >> s;
		int mn = 0, cur = 0;
		for (char &i:s) {
			cur += (i == '(' ? 1 : -1);
			mn = min(mn, cur);
		}
		total += cur;
		if (cur > 0) {
			ls.push_back({mn, cur});
		} else {
			rs.push_back({mn-cur, -cur});
		}
	}
	sort(ls.rbegin(), ls.rend());
	sort(rs.rbegin(), rs.rend());
	if (!total && check(ls) && check(rs)) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	return 0;
}


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

N = int(input())
prob_table = list(map(float, input().split()))

dp = [[0 for _ in range(2*N+2)] for _ in range(N)]


dp[0][N-1] = 1 - prob_table[0]
dp[0][N+1] =   prob_table[0]

for i in range(1,N):
	for j in range(N-i-1,N+i+2):
		if(j > 0 and j < 2*N+1):
			dp[i][j] = dp[i-1][j-1]*prob_table[i] + dp[i-1][j+1]*(1-prob_table[i])
		elif(j <= 0):
			dp[i][j] = dp[i-1][j+1]*(1-prob_table[i])
		else : 
			dp[i][j] = dp[i-1][j-1]*prob_table[i]
print(sum(dp[N-1][N+1:]))

Measured memory_bytes: 483080
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>
#include <complex>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <regex>
using namespace std;

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



#include <stdio.h>

int main()
{
    int N;

    scanf("%d", &N);

    cout << "ABC" << N << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for(int i = 0; i < n; i++){
    int v;
    cin >> v;
    a[i] = make_pair(v, i);
  }
  sort(a.begin(), a.end());
  for(int i = 0; i < n; i++){
    cout << a.at(i).second + 1 << " ";
  }
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  string s;
  int diff = INT_MAX;
  const int target = 753;
  
  cin >> s;

  for(int i = 0; i < s.size() - 2; i++){
    string ss = s.substr(i, 3);
    int x = stoi(ss);
    if(abs(target - x) < diff){
      diff = abs(target - x);
    }
  }

  cout << diff << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int max, min, sum,n,x,ans;
    while(true){
        cin>>n;
        if(n!=0){
            cin>>x;
            max=x;
            min=x;
            sum=x;
            for(int i=1;i<n;i++){
                cin>>x;
                sum+=x;
                if(max<x){
                    max=x;
                }
                if(min>x){
                    min=x;
                }
            }
            ans=(sum-min-max)/(n-2);
            cout<<ans<<endl;
        }else{
            break;
        }
    }
    return 0;
}

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

using namespace std;


int main() {
    int h, w;
    
    cin >> h >> w;

    vector<vector<char>> cam(h+2, vector<char>(w+2, '.'));
    
    for(int i = 1; i < cam.size()-1; ++i)
        for(int j = 1; j < cam[i].size()-1; ++j)
            cin >> cam[i][j];

    bool yn = true;
    
    for(int i = 1; i < cam.size()-1; ++i)
        for(int j = 1; j < cam[i].size()-1; ++j)
            if(cam[i][j] == '#' &&
                cam[i-1][j] == '.' && cam[i][j-1] == '.' &&
                cam[i+1][j] == '.' && cam[i][j+1] == '.') {
                yn = false;
                break;
            }
    
    cout << (yn ? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author c0113142
 */
public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
        String line =br.readLine();
        
        int x=Integer.parseInt(line);
        
        System.out.println(x*x*x);
    }
}

Measured memory_bytes: 17044
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  ll N,K;
  cin >> N >> K;
  ll cnt = 0;
  FOR(i,1,N+1){
    if(i%K==0){
      cnt++;
    }
  }
  ll ans = cnt*cnt*cnt;
  if(K%2==1){
    cout << ans << endl;
  }else{
    ll cnt2 = 0;
    FOR(i,1,N+1){
      if(i%K==K/2){
        cnt2++;
      }
    }
    ans+=cnt2*cnt2*cnt2;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
S = []
for i in range(N):
    s = input()
    S.append(s)

from collections import Counter
c = Counter()

for si in S:
    c[si] += 1

a = []

for k, v in c.items():
    a.append([v, k])

from operator import itemgetter
a.sort(key=itemgetter(1))
a.sort(key=itemgetter(0), reverse=True)


for ai in a:
    if ai[0] == a[0][0]:
        print(ai[1])

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

using namespace std;

int cs[1000],vt[1000];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;++i) cin>>cs[i];
    int b;
    for(int i=0;i<m;++i){
        cin>>b;
        for(int j=0;j<n;++j){
            if(cs[j]<=b){
                ++vt[j];break;
            }
        }
    }
    int mx=0,ans;
    for(int i=0;i<n;++i){
        if(mx<vt[i]) ans=i+1;
        mx=max(mx,vt[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    string a,b;cin>>a>>b;
    int m  = 0;
    for(int i = 0;i<a.length();i++){
        if(a[i] != b[i]) m+=1;
        
    }
    cout<<m;
    return 0;
}

Measured memory_bytes: 3916
import math

def triangle(co1, co2):
    ans = []
    x1 = co1[0]
    y1 = co1[1]
    x2 = co2[0]
    y2 = co2[1]
    part1 = [(2 * x1 + x2) /3, (2 * y1 + y2) / 3]
    part2 = [(x1 + 2 * x2) /3, (y1 + 2 * y2) / 3]
    #part2をpart1中心に60度回転
    edge = [(part2[0] - part1[0])/2 - (part2[1] - part1[1])/ 2 * math.sqrt(3) + part1[0], (part2[0] - part1[0])/2 * math.sqrt(3) + (part2[1] - part1[1])/ 2 + part1[1]]
    ans.extend([part1, edge, part2, co2])
    return ans
def rec(A, n):
    if n == 0:
        return
    
    rec(A, n-1)
    for i in range(4 ** (n-1)):
        A[n].extend(triangle(A[n-1][i], A[n-1][i+1]))

n = int(input())
koch = [[[0.0, 0.0]] for i in range(n + 1)]
koch[0].append([100.0, 0.0])
rec(koch, n)
for i in range(4 ** n + 1):
    print(*koch[n][i])


Measured memory_bytes: 6340
package main

import (
	"fmt"
)

func main() {
	var str string
	fmt.Scanf("%s", &str)
	l := len(str)
	if str[l-1:] == str[l-2:l-1] && str[l-3:l-2] == str[l-4:l-3] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int a[100000];
int main() {
	int n; scanf("%d", &n);
	int Min = INT_MAX, Max = 0;
	rep(i, n) {
		scanf("%d", &a[i]);
		Min = min(Min, a[i]);
		Max = max(Max, a[i]);
	}
	if (Min != Max) {
		if (Max - Min > 1) {
			puts("No"); return 0;
		}
		int cnt = 0;
		rep(i, n) {
			if (Min == a[i])cnt++;
		}
		//色の数はcnt+b
		if(Max-cnt&&(n-cnt)/(Max-cnt)>=2)puts("Yes");
		else puts("No");
		return 0;
	}
	if (n / a[0] >= 2) {
		puts("Yes"); return 0;
	}
	if (n == a[0] + 1) {
		puts("Yes"); return 0;
	}
	puts("No");
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<Int> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }

	sort(a.begin(), a.end());
	auto check = [&](int mid) {
		Int sum = 0;
		for (int i = 0; i < N; ++i) {
			if (i > mid && sum * 2 < a[i]) { return false; }
			sum += a[i];
		}
		return true;
	};

	int low = -1, high = N - 1;
	while (high - low > 1) {
		int mid = (high + low) / 2;
		(check(mid) ? high : low) = mid;
	}
	cout << N - high << endl;

	return 0;
}


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


using namespace std;
const long long INF = 1LL <<60;

int main(void){
  long long n,res;
  long f[10000001];
  long long i,j;
  
  cin>>n;

  //f[0]=0;
  for(i=0;i<=10000000;i++){
    f[i]=0;
  }
  
  for(i=1;i<=10000000;i++){
    for(j=i;j<=10000000;j=j+i){
      f[j]++;
    }
  }

  res=0;
  for(i=1;i<=n;i++){
    //cout<<f[i]<<endl;
    res+=i*f[i];
  }
  
  cout<<res<<endl;
  
}    

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

int main() {

	ll n; cin >> n;
	vector<ll> a(n), b(n), c(n);
	for (ll i = 0; i < n; i++) cin >> a[i];
	for (ll i = 0; i < n; i++) cin >> b[i];
	for (ll i = 0; i < n; i++) cin >> c[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	
	ll ans = 0;
	for (int j = 0; j < n; j++) {

		ll a_num, c_num;

		auto Iter_a = lower_bound(a.begin(),a.end(), b[j]);
		auto Iter_c = upper_bound(c.begin(), c.end(), b[j]);

		a_num = Iter_a - a.begin();
		c_num = c.end() - Iter_c;

		ans += a_num * c_num;
	}

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

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;



int main() {
    int a,b;
    cin >> a >> b;
    if(a == b) {
        rep(i,a) cout << a;
    } else {
        rep(i,max(a,b)) cout << min(a,b);
    }
}

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

#define println(msg) cout << msg << endl
#define yes_or_no(flag) if (flag) { println("Yes"); } else { println("No"); }
#define sort_vec(vec) sort(vec.begin(), vec.end())
#define rsort_vec(vec) sort(vec.rbegin(), vec.rend()) // greater<int>()

int main() {
  // 入力
  string S;
  cin >> S;
  
  // 計算
  map<char, int> m;
  for (auto s : S) {
    if (m.count(s)) {
      m[s]++;
    } else {
      m[s] = 1;
    }
  }
  
  // 出力
  for (char i = 'a'; i <= 'z'; i++) {
    if (!m.count(i)) {
      println(i);
      return 0;
    }    
  }
  println("None");
}


Measured memory_bytes: 3740
/*g++ file.cpp -o file.out*/
/*./file.out*/

#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

char sov[4000050];
int main()
{
    int sx,sy,tx,ty,flag=0,x,y;
    scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
    x=tx-sx;
    y=ty-sy;
    for(int i=0;i<x;i++)
    {
        sov[flag]='R';
        flag++;
    }
    for(int i=0;i<y;i++)
    {
        sov[flag]='U';
        flag++;
    }
    for(int i=0;i<x;i++)
    {
        sov[flag]='L';
        flag++;
    }
    for(int i=0;i<y;i++)
    {
        sov[flag]='D';
        flag++;
    }
    sov[flag]='L';
    flag++;
    for(int i=0;i<y+1;i++)
    {
        sov[flag]='U';
        flag++;
    }
    for(int i=0;i<x+1;i++)
    {
        sov[flag]='R';
        flag++;
    }
    sov[flag]='D';
    flag++;
    sov[flag]='R';
    flag++;
    for(int i=0;i<y+1;i++)
    {
        sov[flag]='D';
        flag++;
    }
    for(int i=0;i<x+1;i++)
    {
        sov[flag]='L';
        flag++;
    }
    sov[flag]='U';
    puts(sov);
    return 0;
}


Measured memory_bytes: 256
S = gets.to_i
M = 10**9 + 7

@fac, @inv, @fiv = [1, 1], [1, 1], [1, 1]
(2 .. S).each do |i|
  @fac[i] = @fac[i - 1] * i % M
  @inv[i] = M - @inv[M % i] * (M / i) % M
  @fiv[i] = @fiv[i - 1] * @inv[i] % M
end
c = ->(a, b){a < b ? 0 : @fac[a]*@fiv[b]*@fiv[a - b] % M}
puts (1 .. S/3).inject(0){|s, n| (s + c[S - 3*n + n - 1, n - 1]) % M}

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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

//#define MAX 1000200

int main(){
    int n;
    cin >> n;
    vector<int> a;
    rep(i, n){
        int height;
        cin >> height;
        a.push_back(height);
    }
    long cnt=0;
    map<long, long> l, r;
    //int minim=INT_MAX, maxim=0;
    // rep(i, MAX+1){
    //     l[i] = 0;
    //     r[i] = 0;
    // }
    //cout << "OK" << endl;
    rep(i, n){
        l[a[i]+i+1]++;
        if(i+1-a[i]>=0){
            r[i+1-a[i]]++;
        }
        // cout << l[a[i]+i+1] << endl;
    }
    map<long, long>::iterator L;
    for(L=l.begin(); L != l.end(); L++){
        long item = (*L).first;
        //cout << item << " : " << l[item] << 
        // if(r.find(item)!=r.end()||item==(*r.end()).first){
        //     cnt +=  l[item] * r[item];
        // }
        cnt +=  l[item] * r[item];
        // cout << cnt << endl;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 29208
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define STEP 0.0005
// sort(a.begin(), a.end(), std::greater<int>());

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a<=c && c<=a+b){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int x,y=1;
    while(x!=0 || y!=0)
      {
      scanf("%d%d",&x,&y);
      if(x!=0 ||  y!=0){
	if (x<y){
           printf("%d %d\n",x,y);}
        else{
	  printf("%d %d\n",y,x);}}}
  return 0;
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;
    int S_len = S.length();
    int same_num_starting_from_black = 0;
    for (int i = 0; i < S_len; i++)
    {
        if (i % 2 == 0)
        {
            if (S[i] == '0')
            {
                same_num_starting_from_black++;
            }
        }
        else
        {
            if (S[i] == '1')
            {
                same_num_starting_from_black++;
            }
        }
    }

    if (same_num_starting_from_black < (S_len - same_num_starting_from_black))
    {
        cout << same_num_starting_from_black;
    }
    else
    {
        cout << S_len - same_num_starting_from_black;
    }
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

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

ll mod = 1e9+7;

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,m,k;
  cin >> n >> m >> k;

  vvi fr(n,vi());
  UnionFind uf(n);

  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    uf.unite(a,b);
    fr[a].push_back(b);
    fr[b].push_back(a);
  }

  vvi br(n,vi());
  rep(i,k){
    int c,d;
    cin >> c >> d;
    c--;d--;
    br[c].push_back(d);
    br[d].push_back(c);
  }

  vi cnt(n);
  rep(i,n){
    cnt[uf.root(i)]++;
  }

  rep(i,n){
    int bc = 0;
    rep(j,br[i].size()){
      if(uf.same(i,br[i][j]))bc++;
    }
    cout << cnt[uf.root(i)] - 1 - fr[i].size() - bc << " ";
  }
  cout << endl;
}

Measured memory_bytes: 13048