akhauriyash/Code-Regression huggingface dataset:
s=input()
k=int(input())
n=len(s)
i=0
ans=""
while i<n:
    if i!=n-1:
        if s[i]=="a":
            ans+="a"
            #print(ord(s[i]),123-ord(s[i]),k)
        elif k>=123-ord(s[i]):
            ans+="a"
            k-=(123-ord(s[i]))
            #print(ord(s[i]),123-ord(s[i]),k)
        else:
            ans+=s[i]
            #print(ord(s[i]),123-ord(s[i]),k)
    else:
        if k>=123-ord(s[i]):
            k-=(123-ord(s[i]))#一旦aにする
            k=k%26
            ans+=chr(97+k)
        else:
            ans+=chr(ord(s[i])+k)
        
    i+=1
print(ans)

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

int main()
{
    int n,i;
    cin >> n;
    vector<int> x(n);
    for(i = 0;i < n;++i){
        cin >> x.at(i);
    }
    vector<int> y = x;
    sort(x.begin(),x.end());
    for(int w : y){
        if(w <= x.at(n/2-1)){
            cout << x.at(n/2) << endl;
        }else{
            cout << x.at(n/2-1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3712
from collections import deque

H, W, K = map(int, input().split())

S = []
for _ in range(H):
    S.append(input())

answer_list = [[-1 for _ in range(W)] for _ in range(H)]

queue = deque()
i = 1
w_flag = [False for _ in range(W)]
start_w = float('inf')
for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            if w < start_w:
                start_w = w
            queue.append((h, w, i))
            answer_list[h][w] = i
            i += 1
            w_flag[w] = True


def bfs(queue, answer_list):
    """
    H軸の方向でのみ、幅優先探索
    """
    while queue:
        # キューとして使うのでpop()ではなくpopleft()
        h, w, i = queue.popleft()
        for dy in (-1, 1):
            new_h = h + dy
            if new_h < 0 or H <= new_h:
                continue
            if answer_list[new_h][w] == -1:
                answer_list[new_h][w] = i
                queue.append((new_h, w, i))
    return answer_list


answer_list = bfs(queue, answer_list)

for w in range(W):
    if not w_flag[w]:
        for h in range(H):
            if w < start_w:
                answer_list[h][w] = answer_list[h][start_w]
            else:
                answer_list[h][w] = answer_list[h][w-1]


for i in range(H):
    answer = map(str, answer_list[i])
    print(' '.join(answer))

Measured memory_bytes: 51184
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

long long doit(long long x) {
	if (x < 0) return 0;
	long long ans = 0;
	for (long long y = (x / 4) * 4; y <= x; y++) ans ^= y;
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	long long a, b; cin >> a >> b;
	long long ans = doit(b) ^ doit(a - 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
   
    int n;
    cin>>n;
    int ans=0;
    
    for(int i=1;i<n+1;i++){
        ans+=i;
    }
    
    cout<<ans<<endl;
    
    return 0;
   
}






Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long 
string s;
int main()
{
	cin>>s;
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'){
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
    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 k = sc.nextInt();

        List<Integer> nums = new ArrayList<>();

        for(int i=0; i<n; i++){
            nums.add(sc.nextInt());
        }

        int ans = nums.stream().sorted((x,y) -> y-x).mapToInt(x -> x).limit(k).sum();


        System.out.println(ans);


    }
}


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

using namespace std;

const int MOD = 1000000007;

// transition[sbit][xbit] = tranzitie de dp-uri
// newDp[x] = (newDp[x] + dp[y] * X[x][y]) % MOD
//

int transition[2][2][2][2] =
{
{ // sbit == 0
{
{1, 0},
{1, 0}
},
{
{0, 0},
{0, 1}
}
},
{ // sbit == 1
{
{0, 1},
{0, 1}
},
{
{1, 0},
{0, 0}
}
}
};

// We want to count the requested number of pairs that have the sum equal to N
// except that the last wildcards bits can be either 0 or 1
int runDp(long long N, int wildcards) {
	// dp[0][i] = how many pairs have the sum with the last i bits fixed
	//            and don't push addition carriage
	// dp[1][i] = the same thing, but they push carriage
	// We remove the i-dimension
	int dp[2];

	dp[0] = 1;
	dp[1] = 0;

	for(int i = 0; i < wildcards; ++i) {
		int newDp[2];
		newDp[0] = newDp[1] = 0;
	
		for(int sbit = 0; sbit < 2; ++sbit)
			for(int xbit = 0; xbit < 2; ++xbit)
				for(int x = 0; x < 2; ++x)
					for(int y = 0; y < 2; ++y)
						newDp[x] = (newDp[x] + dp[y] * transition[sbit][xbit][x][y]) % MOD;

		dp[0] = newDp[0];
		dp[1] = newDp[1];
	}

	for(int i = wildcards; i < 62; ++i) {
		int newDp[2] = {0, 0};

		int sbit = (((1LL << i) & N) > 0);
		for(int xbit = 0; xbit < 2; ++xbit)
			for(int x = 0; x < 2; ++x)
				for(int y = 0; y < 2; ++y)
					newDp[x] = (newDp[x] + dp[y] * transition[sbit][xbit][x][y]) % MOD;
		

		dp[0] = newDp[0];
		dp[1] = newDp[1];
	}

	return dp[0]; // We want all bits fixed and we don't want to push additional carriage
}

int main() {
	long long N;
	int rez;

	scanf("%lld", &N);

	rez = runDp(N, 0);
	for(int i = 0; i < 62; ++i) {
		if((1LL << i) & N) {
			N ^= (1LL << i);
			rez = (rez + runDp(N, i)) % MOD;
		}
	}

	printf("%d", rez);
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<unordered_map>
using namespace std;

const  int N = 1e5 + 10;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;

typedef long long ll;
typedef long double ld;

#define pa pair<int,int>
#define sc(n) scanf("%d",&n)
#define ss(n) scanf("%s",n)
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define mes(a,b) memset(a,b,sizeof a)
#define mem(a,b,n) memset(a,b,n*sizeof(int))
#define uint unsigned int
#define ie unordered_map<int,ll>::iterator

int a[N];
int T;
int n,m;
char s[N];
int dp[N][13];



int main()
{
	ss(s+1);
	dp[0][0]=1;
	for(int i=1;s[i];i++)
	{
		fo(j,0,12)
		{
			if(s[i]=='?')
			{
				fo(k,0,9)
				{
					dp[i][(j*10+k)%13]=(dp[i-1][j]+dp[i][(j*10+k)%13])%mod;
				}
			}
			else
				dp[i][(j*10+(s[i]-'0'))%13]=dp[i-1][j];
		}
	}
	cout<<dp[strlen(s+1)][5]<<endl;
	return 0;
}



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

int main(){
	int n,m;
  	cin >> n >> m;
  	int a[n],b[n],c[m],d[m];
  	for (int i=0;i<n;i++){
    	cin >> a[i] >> b[i];
    }
  	for (int i=0;i<m;i++){
    	cin >> c[i] >> d[i];
    }
  	for (int i=0;i<n;i++){
      	int k=1000000000;
    	for (int j=0;j<m;j++){
        if (abs(a[i]-c[j])+abs(b[i]-d[j])<=k) k = abs(a[i]-c[j])+abs(b[i]-d[j]); 
        }
      	for (int j=0;j<m;j++){
        	if (abs(a[i]-c[j])+abs(b[i]-d[j])==k) {
              	cout << j+1 << endl;
          		break;
            }
        }
    }
}

Measured memory_bytes: 256
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        hoge();
        System.Console.ReadLine();
    }

    public static void hoge()
    {
        var line = System.Console.ReadLine().Split(' ');

        line = System.Console.ReadLine().Split(' ');

        var s = line[0];
        var t = line[1];

        for(int i = 0; i < s.Length; i++)
        {
            System.Console.Write(s[i].ToString() + t[i].ToString());
        }
        System.Console.WriteLine("");
    }
}



Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int A, B;
  cin >> A >> B;

  cout << (A + B) % 24 << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		for (int i = 0; i < n; i++) {
			if (a[i] % 2 == 0) {
				if (a[i] % 3 != 0 && a[i] % 5 != 0) {
					System.out.println("DENIED");
					return;
				}
			}
		}

		System.out.println("APPROVED");

	}

}


Measured memory_bytes: 35980
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using P = pair<long long, long long>;

struct data {
  long long u, v, c;
};

long long n, m;
string bw;
vector<data> edge;
vector<P> d;
vector<map<long long, long long>> memo;
vector<long long> lst;

bool solve();

int main() {
  cin >> n >> m;
  d.resize(n);
  for(int i = 0; i < n; ++i) {
    cin >> d[i].fi;
    d[i].se = i;
    bw += "-";
  }
  memo.resize(n);
  for(int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    edge.push_back({u, v, (long long)1e9});
    memo[u][v] = i;
    memo[v][u] = i;
  }
  lst.assign(n, 0);
  for(int i = 0; i < n; ++i) {
    lst[i] = i;
    for(auto now : memo[i])
      if(d[lst[i]].fi > d[now.fi].fi ||
         (d[lst[i]].fi == d[now.fi].fi && lst[i] == i))
        lst[i] = now.fi;
    if(lst[i] == i) {
      cout << -1 << endl;
      return 0;
    }
  }
  if(solve()) {
    cout << bw << endl;
    for(int i = 0; i < m; ++i) cout << edge[i].c << endl;
  }
  else
    cout << -1 << endl;
  return 0;
}

bool solve() {
  sort(d.begin(), d.end());
  for(int i = 0; i < n; ++i) {
    int id = d[i].se;
    if(bw[id] != '-') continue;
    if(bw[lst[id]] == 'B')
      bw[id] = 'W';
    else
      bw[id] = 'B';
    if(bw[lst[id]] == '-') bw[lst[id]] = 'W';
    edge[memo[id][lst[id]]].c = d[i].fi;
  }
  return 1;
}


Measured memory_bytes: 40364
W=input()
sentences=''
while True:
    try:
        sentence=input()
        sentences+=sentence
        if sentence=='END_OF_TEXT':
            break
        sentences+='\n'
    except EOFError:
        pass
answer_count=0
for l in sentences.split():
    if l.lower()==W:
        answer_count+=1
print(answer_count)


Measured memory_bytes: 5556
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
#define MOD (LL)(1e9+7)

int M, D;
int main(){
	cin >> M >> D;
	int ans = 0;
	for(int i=1; i<=M; i++){
		for(int j=22; j<=D; j++){
			int a = j / 10;
			int b = j % 10;
			if(a < 2 || b < 2) continue;
			if(a*b == i) ans++;
		}
	}
	cout << ans << endl;
}

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

int modpow(int a, int x) {
	int res = 1;
	while (x) {
		if (x & 1)res = res * a%mod;
		a = a * a%mod;
		x >>= 1;
	}
	return res;
}
int s[205];
int dp[205][100005];
signed main() {
	int n, x; cin >> n >> x;
	rep(i, n)cin >> s[i];
	sort(s, s + n);
	reverse(s, s + n);
	dp[0][x] = 1;
	rep(i, n) {
		int p = modpow(n - i, mod - 2);
		rep(j, x + 1) {
			if (!dp[i][j])continue;
			dp[i + 1][j%s[i]] += dp[i][j] * p%mod;
			dp[i + 1][j] += dp[i][j] * (mod + 1 - p) % mod;
			dp[i + 1][j] %= mod;
			dp[i + 1][j%s[i]] %= mod;
		}
	}
	int sum = 0;
	rep(i, x + 1)sum = (sum + i * dp[n][i]) % mod;
	rep(i, n) {
		sum *= (i + 1); sum %= mod;
	}
	cout << sum << endl;
}

Measured memory_bytes: 155904
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<1||a>10||b<1||b>10)  return 0;
    if(a<b)
    {

       int t=a;
        a=b;
        b=t;
    }
    for(int i=0;i<a&&a>=b;i++)
    {

        printf("%d",b);
   }

    return 0;

}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
import itertools 

def solve(N: int, C: int, D: "List[List[int]]", c: "List[List[int]]"):
    answer = 10**9

    cost = [[0 for _ in range(C)] for _ in range(3)]


    for i in range(1,N+1):
        for j  in range(1,N+1):
            cost[(i+j)%3][c[i-1][j-1]-1] += 1

    for i in range(C):
        for j in range(C):
            for k in range(C):
                if i==j or j==k or k==i:
                    continue
                a = 0
                for index in range(C):
                    a += cost[0][index]*D[index][i]
                    a += cost[1][index]*D[index][j]
                    a += cost[2][index]*D[index][k]
                
                answer = min(a,answer)

    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = [[int(next(tokens)) for _ in range(C)] for _ in range(C)]  # type: "List[List[int]]"
    c = [[int(next(tokens)) for _ in range(N)] for _ in range(N)]  # type: "List[List[int]]"
    solve(N, C, D, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5492
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  V<> a(n); for (auto&& e : a) cin >> e;
  int res = 0;
  for (int l = 0; l <= k; ++l) for (int r = 0; r <= k; ++r) {
    if (l + r > k) continue;
    if (l + r > n) continue;
    V<> b;
    for (int i = 0; i < l; ++i) b.push_back(a[i]);
    for (int i = n - r; i < n; ++i) b.push_back(a[i]);
    sort(rbegin(b), rend(b));
    int c = k - l - r;
    while (c--) {
      if (!b.empty() and b.back() < 0) b.pop_back(); 
    }
    int curr = accumulate(begin(b), end(b), 0);
    res = max(res, curr);
  }
  cout << res << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int M, N;

bool is_ok(vector<int>& mem, vector<vector<int>>& rel){
    for (int i = 0; i < N - 2; i++){
        //i番目の要素からi + 1番目の要素へ行けるか判定
        if (count(rel.at(mem.at(i)).begin(), rel.at(mem.at(i)).end(), mem.at(i + 1)) <= 0){
            return false;
        }
    }
    if (count(rel.at(0).begin(), rel.at(0).end(), mem.at(0)) <= 0){
            return false;
    }
    return true;
}
int main(){
    int temp1, temp2;
    cin >> N >> M;
    vector<vector<int>> rel(N, vector<int>(0));
    for (int i = 0; i < M; i++){
        cin >> temp1 >> temp2;
        rel.at(temp1 - 1).push_back(temp2 - 1);
        rel.at(temp2 - 1).push_back(temp1 - 1);
    }
    vector<int> mem(N - 1);
    for (int i = 1; i < N; i++){
        //mem = {1, 2, 3, ... , N - 1(idx N - 2)}
        mem.at(i - 1) = i;
    }

    int cnt = 0;
    do{
        if (is_ok(mem, rel)){
            cnt++;
        }
    }while(next_permutation(mem.begin(), mem.end()));

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    string ans = string();
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            char c;
            cin >> c;
            if(i == j) ans += c;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
S = input()

min_val = 0
min_dist = 1000
for i in range(len(S)):
    X = int(S[i: min(i+3, len(S))])
    dist = abs(753 - X)
    if dist < min_dist:
        min_val = X
        min_dist = dist
print(min_dist)

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


vector<P> G[100001];
vector<P> dp1(100000);
P dfs1(int u,int t){
    P ret;
    ret.first=0;
    ret.second=0;
    for(auto v:G[u]){
        if(v.first==t) continue;
        P p = dfs1(v.first,u);
        ret.first=max(ret.first,p.first+v.second);
        ret.second=max({ret.second,p.second,v.second});
    }
    return dp1[u]=ret;
}

int dfs2(int u,int t,int d,int e){
    vector<pair<P,int>> A;
    vector<P> dd,ee;
    A.push_back({{0,0},-1});
    A.push_back({{0,0},-1});
    for(auto v:G[u]){
        if(v.first==t){
            A.push_back({{d+v.second,e},v.first});
        }
        else{
            A.push_back({{dp1[v.first].first+v.second,max(dp1[v.first].second,v.second)},v.first});
        }
    }
    sort(A.rbegin(),A.rend());
    int ret=0;
    for(auto v:A){
        int sum = v.first.second;
        if(v.second==A[0].second){
            sum += A[1].first.first;
            sum += A[2].first.first;
        }
        else if(v.second==A[1].second){
            sum += A[0].first.first;
            sum += A[2].first.first;
        }
        else{
            sum += A[0].first.first;
            sum += A[1].first.first;
        }
        ret = max(ret,sum);

        dd.push_back({v.first.first,v.second});
        ee.push_back({v.first.second,v.second});
    }
    sort(dd.rbegin(),dd.rend());
    sort(ee.rbegin(),ee.rend());
    for(auto v:G[u]){
        if(v.first==t) continue;
        int nd=dd[0].first,ne=ee[0].first;
        if(dd[0].second==v.first) nd=dd[1].first;
        if(ee[0].second==v.first) ne=ee[1].first;
        ret=max(ret,dfs2(v.first,u,nd,max(ne,v.second)));
    }
    return ret;
}

int main(){
    int n;cin >> n;
    for (int i = 0; i < n-1; i++) {
        int p,w;cin >> p >> w;
        G[i+1].push_back({p,w});
        G[p].push_back({i+1,w});
    }
    dfs1(0,-1);
    cout << dfs2(0,-1,0,0) << endl;
}



Measured memory_bytes: 46648
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m;
int main()
{
	cin >>n>>m;
	cout <<(m-1+n-2)/(n-1);
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for(int i = 0; i < n; i++)
    cin >> a[i] >> b[i];

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

  int ans = a[0] - 1;
  for(int i = 1; i < n; i++)
    ans += a[i] - a[i - 1];
  ans += b[n - 1] + 1;

  cout << ans << endl;
}


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

const int M = 1000000007;

class ModComb {
    long long *fact, *facti;
    const int mod;
public:
    explicit ModComb(int n, int m) : mod(m) {
        fact = new long long[n+1];
        facti = new long long[n+1];
        fact[0] = 1; facti[0] = 1;
        for (int i = 1; i <= n; i++) fact[i] = (fact[i-1] * i) % m;
        // calc 1/n!
        long long &inv = facti[n], pw = fact[n];
        inv = 1;
        for (int e = mod-2; e > 0; e /= 2) {
            if (e&1) inv = inv * pw % mod;
            pw = pw * pw % mod;
        }
        for (int i = n-1; i > 0; i--) facti[i] = (facti[i+1] * (i+1)) % m;
    }

    ~ModComb() {
        if (fact) delete[] fact;
        if (facti) delete[] facti;
    }

    long long get(int n, int k) const {
        if (n < 0 || k < 0 || k > n) return 0;
        return fact[n] * facti[k] % mod * facti[n-k] % mod;
    }

    long long getPerm(int n, int k) const {
        if (n < 0 || k < 0 || k > n) return 0;
        return fact[n] * facti[n-k] % mod;
    }
};

long long modexp(int x, long long e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}


int main() {
    int k; cin >> k;
    string s; cin >> s;
    int n = s.size();
    ModComb mc(n+k+1, M);
    long long ans = 0;
    for (int i = 0; i <= k; i++)
        ans += mc.get(i+n-1, i) * modexp(25, i, M) % M * modexp(26, k-i, M) % M;

    cout << ans % M << endl;
}


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

class lei
{
public:
	int data;
	lei *next;
	lei *pre;
};

int biaoji = 0;
lei *ptail;
lei *head;

int insert()
{
	lei *p;
	p = new lei;
	cin >> p->data;
	if (biaoji == 0)
	{
		p->pre = ptail;
		ptail->next = p;
		ptail = p;
		p->next = NULL;
		biaoji = 1;
	}
	else
	{
		biaoji = 0;
		p->next = head->next;
		head->next->pre = p;
		head->next = p;
		p->pre = head;
	}
	return 0;
}


int main()
{
	int n;
	cin >> n;
	lei kong;
	kong.data = 0;
	kong.next = NULL;
	kong.pre = NULL;
	ptail = &kong;
	head = &kong;
	for (int i = 0; i < n; i++)
	{
		insert();
	}

	if (n % 2 == 0)
	{
		lei *p = head->next;
		for (int i = 0; i < n; i++)
		{
			cout << p->data;
			if (i != n - 1)
			{
				cout << " ";
			}
			p = p->next;
		}
		cout << endl;
	}
	else
	{
		lei *p = ptail;
		for (int i = 0; i < n; i++)
		{
			cout << p->data;
			if (i != n - 1)
			{
				cout << " ";
			}
			p = p->pre;
		}
		cout << endl;
	}
	lei *p;
	for (int i = 0; i < n; i++)
	{
		if (head->next != NULL)
		{
			p = head->next;
			head->next = head->next->next;
			delete(p);
		}
	}

	return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
using namespace std;

int main() {
  vector<int> result;
  string n;
  string input;

  getline(cin, n);
  getline(cin, input);
  istringstream iss(input);
  string num;

  while (getline(iss, num, ' ')) {
    result.push_back(stoi(num));
  }

  long long min = *min_element(result.begin(), result.end());
  long long max = *max_element(result.begin(), result.end());
  long long sum = accumulate(result.begin(), result.end(), 0LL);

  cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3292
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());

//グラフ理論用変数
//vector<vector<llong> > graph(N);

llong isprime(llong x){
    char flg;
    for(int i=x; ;i++){
        flg = 0;
        for(int j=2; j<i; j++){
            if(i%j==0){
                flg = 1;
                break;
            }
        }
        if(flg==0){
            return i;
        }
    }
}

int main(){
    llong X;
    cin >> X;
    cout << isprime(X) << endl;
}

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

int main()
{
    int x, y, result = 0;

    scanf("%d %d", &x, &y);

    switch (x)
    {
    case 1:
        result += 300000;
        break;
    case 2:
        result += 200000;
        break;
    case 3:
        result += 100000;
        break;
    default:
        break;
    }

    switch (y)
    {
    case 1:
        result += 300000;
        break;
    case 2:
        result += 200000;
        break;
    case 3:
        result += 100000;
        break;
    default:
        break;
    }

    if( x == 1 && y == 1 )
        result += 400000;

    printf("%d\n", result);
    return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int n = read();
  vi v;
  map<int, int> evenNumCount, oddNumCount;
  auto setNumCount = [](map<int, int> &target, int num) {
    if (target.count(num) == 0)
      target[num] = 1;
    else
      target[num] += 1;
  };
  REP(i, n) {
    v.PB(read());
    if (i % 2 == 1)
      setNumCount(evenNumCount, v[i]);
    else
      setNumCount(oddNumCount, v[i]);
  }
  auto searchNumCount = [](map<int, int> &m, pi &p1, pi &p2) {
    for (pi p : m) {
      if (p1.second < p.second) {
        p2 = p1;
        p1 = p;
      } else if (p2.second < p.second) {
        p2 = p;
      }
    }
  };
  pi o1, o2, e1, e2;
  searchNumCount(oddNumCount, o1, o2);
  searchNumCount(evenNumCount, e1, e2);
  int ans;
  auto askAns = [&n](int odd, int even) {
    int ans;
    ans = n / 2 + n % 2 - odd;
    ans += n / 2 - even;
    return ans;
  };
  if (o1.first != e1.first)
    ans = askAns(o1.second, e1.second);
  else
    ans = min(askAns(o1.second, e2.second), askAns(o2.second, e1.second));
  print(ans);
}


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

const int N = 123;
const int INF = 2e9;
const int mod = 1e9+7;

long long ans, a, b;

int main() {
  scanf("%lld%lld", &a, &b);
  long long c = a;
  while (c <= b) {
    c = c+c;
    ++ans;
  }

  printf("%lld", ans);
  return 0;
}


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

signed main(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && a == c && b == c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
ls=[]

while True:
    s1,s2=tuple(input().split())
    
    x1=int(s1)
    x2=int(s2)
    
    if x1 == 0 and x2==0:
        break
    
    if x1<x2:
        ls.append((x1,x2))
    else:
        ls.append((x2,x1))
    

for i,j in ls:
    print(f"{i} {j}")


Measured memory_bytes: 6028
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_2_C
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  cout << a[0] <<" "<< a[1] <<" "<< a[2] << endl;
}

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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll x, y; cin >> x >> y;
    frep(i, 0, x) {
        ll a, b;
        a = 2*i + 4*(x-i);
        b = 4*i + 2*(x-i);
        if(a == y || b == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>

int main(){
	int n;
	while(true){
		scanf("%d", &n);
		if(n == 0){
			break;
		}
		
		int sum = 0;
		/* 3ツ暗按湘」 */
		int i,j;
		for(i = 1, j = n; i < j; i++){
			if(i == n){
				continue;
			}
			if(n % i == 0){
				// ツ姪アツ青板づーツペツアツづつスツつキ	
				sum += i;
				if(i != 1 && i * i != n){
					sum += n / i;
					j = n / i;
				}
			}
		}
		
		
		if(n == sum){
			printf("perfect number\n");
		}
		else if(n > sum){
			printf("deficient number\n");
		}
		else{
			printf("abundant number\n");
		}
	}
	return 0;
}

Measured memory_bytes: 840
#include<forward_list>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<iterator> 
#include<sstream>
#include<fstream>
#include<istream>
#include<utility>
#include<vector>
#include<stack>
#include<cmath>
#include<queue>
#include<deque>
#include<list>
#include<map> 
#include<set>
#define TitansGo ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(v) v.begin(),v.end()
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define ll long long 
#define endl "\n"
#define S second
#define F first
using namespace std;

int main()
{
	TitansGo
		int n, m, a;
	ll s = 0;
	cin >> m >> n;
	for (int i = 0;i < n; i++)
	{
		cin >> a;
		s += a;
	}
	if (s > m)cout << -1 <<endl;
	else cout << m - s << endl;







}

Measured memory_bytes: 3160
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPP(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((ll)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<ll>>

using namespace std;


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

    ll n;
    cin >> n;
    vector<ll> A(n),cnt(n+1,0);
    REP(i,n-1) cin >> A[i];

    for(ll i = 0; i < n;i++){
        cnt[A[i]]++;
    }
    for(ll i = 1; i < n+1;i++){
        cout << cnt[i] << endl;
    }




    return 0;
}

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

int main() {
  long long n, k, r, s, p,ans=0;
  cin >> n >> k >> r >> s >> p;
  string T;
  cin >> T;
  vector<long> A(n); 

for (int i = 0; i < k; i++)
{
    if(T.at(i)=='r') A.at(i)=p;
    else if(T.at(i)=='s') A.at(i)=r;
    else A.at(i)=s;
}
for (int i = k; i < n; i++)
{
    if((T.at(i-k)==T.at(i))&(A.at(i-k)>0)) A.at(i)=0;
    else{
        if(T.at(i)=='r') A.at(i)=p;
        else if(T.at(i)=='s') A.at(i)=r;
        else A.at(i)=s;
    }
}
for (int i = 0; i < n; i++)
{
    ans+=A.at(i);
}

  cout << ans << endl;

}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

int X, N, p[1000];

signed main(){
    cin >> X >> N;
    REP(i, N) cin >> p[i];
    int ans = X, d = 1000;
    REP(x, 102){
        if(abs(x - X) >= d) continue;
        bool ok = true;
        REP(i, N){
            if(x == p[i]) ok = false;
        }
        if(ok){
            d = min(d, abs(x - X));
            ans = x;
        }
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3636
s = input()
check1 = False
check2 = False
for i in range(len(s)):
    if s[i] == "C":
        if not check1:
            check1 = True
    if s[i] == "F":
        if check1:
            check2 = True
if check1 and check2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9116
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    ll a; long double b; cin >> a >> b;
    long double c = a*b;
    cout << (ll) c << endl;
    return 0;
}


Measured memory_bytes: 3736
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;

int main(int argc, const char * argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N,D;

	cin >> N >> D;

	cout << ceil((double)N / (D * 2 + 1)) << endl;

	return 0;

}

Measured memory_bytes: 256
h, w = map(int, input().split())
maze = [[-1 for i in range(w)] for j in range(h)]


ans = 0
for i in range(h):
    maze[i] = input()

INF = 1000
ans = 0


for sy in range(h):
    for sx in range(w):
        if maze[sy][sx] == '#':
            continue
        else:
            distance = [[-1 for i in range(w)] for j in range(h)]


        queue = []

        queue.insert(0, (sy, sx))

        distance[sy][sx] = 0

        while len(queue):
            y, x = queue.pop()

            for i in range(0, 4):
                nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]

                if 0 <= nx < w and 0 <= ny < h:
                    if maze[ny][nx] != '#' and distance[ny][nx] == -1:
                        queue.insert(0, (ny, nx))
                        distance[ny][nx] = distance[y][x] + 1

                        ans = max(ans, distance[ny][nx])

print(ans)


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M=MI()
    adj=[[]for _ in range(N)]
    for i in range(M):
        u,v,s=MI()
        u-=1
        v-=1
        adj[u].append((v,s))
        adj[v].append((u,s))
    
    #　頂点0を根として，ここの値aとする，各頂点Xa+Cの形で表して，最大値と最小値の候補を絞っていく．ループがあるかをしっかり判断
    
    # Xはaの係数，1orー１が入る．0ならまだ見ていない
    X=[0]*N
    C=[0]*N
    
    X[0]=1
    
    floor=1
    ceil=10**9
    
    import queue
    q=queue.Queue()
    q.put((0,-1))#v,p
    
    while not q.empty():
        v,p=q.get()
        
        
        for nv,s in adj[v]:
            if nv!=p:
                nx=X[v]*(-1)
                nc=s-C[v]
                
                #見巡回の頂点なら
                if X[nv]==0 and C[nv]==0:
                    q.put((nv,v))
                    X[nv]=nx
                    C[nv]=nc
                    
                    # aの係数が正ならば，下限を更新
                    if nx==1:
                        floor=max(floor,-1*nc+1)
                        
                    #aの係数が負ならば上限を更新
                    else:
                        ceil=min(ceil,nc-1)
                        
                else:
                    # 既存のものと変わらなければ何もしない
                    if nx==X[nv] and nc==C[nv]:
                        pass
                    #係数が同じで定数部分が違えば無理
                    elif nx==X[nv]:
                        ceil=-1
                    #係数が違う場合，一意に決まる
                    else:
                        ac=0#係数が正の方の定数
                        bc=0#係数が負の方の定数
                        if nx==1:
                            ac=nc
                            bc=C[nv]
                        else:
                            ac=C[nv]
                            bc=nc
                        
                        # 2*aの値
                        aa=bc-ac
                        
                        if aa<=0 or aa%2==1:
                            ceil=-1
                        else:
                            ceil=ceil=min(ceil,aa//2)
                            floor=max(floor,aa//2)
                # print(nv,floor,ceil)
                            
    ans=ceil-floor+1
    if ans<=0:
        ans=0
    print(ans)
    
    
                            

                        
    

main()


Measured memory_bytes: 100600
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];


int main(){
  
  ll n,q,ans=0,all=0;cin>>n;
  vll a(n),e(n,0);
  vvll c(n,vll(45,0));
  rep(i,0,n){
    cin>>a[i];
    all^=a[i];
  }
  rep(i,0,n){
    ll tmp=0;
    rep(j,0,45){
      
      if((all>>j&1)!=(a[i]>>j&1)){
        
        tmp+=pow(2,j);
      }
    }
    cout<<tmp<<' ';
  }
  cout<<endl;
  
}




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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

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

  vector<ll> a(n);

  map<ll, ll> count;

  ll s = 0;
  for (ll &x : a) {
    ll tmp;
    cin >> tmp;
    s += tmp;
    x = tmp;

    count[tmp]++;
  }

  ll q;
  cin >> q;
  for (long i = 0; i < q; i++) {
    ll b, c;
    cin >> b >> c;

    s -= b * count[b];
    s += c * count[b];
    count[c] += count[b];
    count.erase(b);

    cout << s << endl;
  }
}


Measured memory_bytes: 7912
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<ll,int>;
using G = vector<vector<int>>;
const long long INF = 1LL << 60;


int main() {
  int n;
  cin >> n;
  vector<ll> a(n,-1);
  vector<ll> b(n,-1);
  vector<ll> c(n,-1);
  rep(i,n)  cin >> a[i]; 
  rep(i,n)  cin >> b[i];
  rep(i,n)  cin >> c[i];
  sort(a.begin(),a.end());
  sort(c.begin(),c.end());
  ll ans = 0;
  for(int i=0;i<n;i++){
    ll key = b[i];
    auto pos_a = lower_bound(all(a),key);
    ll x = distance(a.begin(),pos_a);
    auto pos_c = upper_bound(all(c),key);
    ll y = distance(pos_c,c.end());
    ans+= (x*y);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main()
{
    ll n, m;
    cin >> n >> m;

    ll ans = 0;
    if (n == 1 && m == 1) ans = 1;
    if (n == 1 && m >= 2) ans = m - 2;
    if (n >= 2 && m == 1) ans = n - 2;
    if (n >= 2 && m >= 2) ans = (n - 2) * (m - 2);

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
#define int long long
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;

signed main(){
	char c,d;
	cin>>c;
	if(c=='A'){
		d='T';
	}
	else if(c=='T'){
		d='A';
	}
	else if(c=='G'){
		d='C';
	}
	else{
		d='G';
	}
	cout<<(char)d<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int m = Integer.parseInt(sc.next());
			int nmin = Integer.parseInt(sc.next());
			int nmax = Integer.parseInt(sc.next());
			if (m == 0 && nmin == 0 && nmax == 0)
				return;
			int[]p = new int[m];
			for (int i = 0; i < m; i++)
				p[i] = Integer.parseInt(sc.next());
			int diff = Integer.MIN_VALUE;
			int index = 0;
			for (int i = nmin - 1; i < nmax; i++) {
				if (diff <= p[i] - p[i + 1]) {
					index = i;
					diff = p[i] - p[i + 1];
				}
			}
			System.out.println(index + 1);
		}
	}
}


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

using namespace std;

string a, b, c;

int main() {
	cin >> a >> b >> c;
	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

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


int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int e=max(a,c);
    int f=min(b,d);
    if(f-e<0) cout<<"0"<<endl;
    else cout<<f-e<<endl;
    

}


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

const int INF = 1001001001;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<a*b/2<<endl;
  return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] train = new int[2];
        int[] bus = new int[2];
        train[0] = sc.nextInt();
        train[1] = sc.nextInt();
        bus[0] = sc.nextInt();
        bus[1] = sc.nextInt();
        Arrays.sort(train);
        Arrays.sort(bus);
        System.out.println(train[0] + bus[0]);
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  ll a, b, c, n;
  cin >> a >> b >> c >> n;
  if (n % 2) cout << b - a << endl;
  else cout << a - b << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

//long long a[1002];

int main()
{
	long long N, cnt1 = 0, cnt2 = 0, tmp, ans = 0;
	vector<long long> a, s;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> tmp;
		a.push_back(tmp - i - 1);
		s.push_back(tmp - i - 1);
	}

	sort(s.begin(), s.end());
	
	for (int i = 0; i < N; i++) {
		 cnt1 += abs(a[i] - s[N / 2]);
	}

	for (int i = 0; i < N; i++) {
		cnt2 += abs(a[i] - s[N / 2 + 1]);
	}

	cout << min(cnt1, cnt2);

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
ll dp[101][100003];
int w[101];
ll v[101];
int N,W;
ll dpf(int N,int W)
{
  if      (dp[N][W]!=-1) {return dp[N][W];                                      }
  if      (N==0||W==0  ) {return dp[N][W]=0;                                    }
  else if (w[N]<=W     ) {return dp[N][W]=max(dpf(N-1,W),v[N]+dpf(N-1,W-w[N])); }
  else if (w[N]>W      ) {return dp[N][W]=dpf(N-1,W);                           }
  return 0;
}
int main()
{  ios_base::sync_with_stdio(false); cin.tie(NULL);
   memset(dp,-1,sizeof(dp));
   cin>>N>>W;
   for(int i=1;i<=N;i++)
   {
       cin>>w[i]>>v[i];
   }
   cout<<dpf(N,W);
   return 0;
}



Measured memory_bytes: 79232
#include<iostream>
#include<complex>
#include <algorithm>
using namespace std;
int main()
{
    int n,q,num[100001]={0},b,c,i;
    long long int sum=0;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> q;
        num[q]++;
        sum+=q;
    }
    cin >> q;
    for(i=0;i<q;i++){
        cin >> b >> c;
        sum+=(c-b)*num[b];
        num[c]+=num[b];
        num[b]=0;
        cout << sum << '\n';
    }
    return 0;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	char c;
	cin >> c;
	if (isupper(c))
		cout << "A\n";
	else
		cout << "a\n";
	return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int n,ans = 0;
  cin >> n;
  vector<int> a(n+1);
  vector<int> b(n+1);
  for(int i = 1; i <= n; i++) cin >> a[i];
  for(int i = n; i >= 1; i--) {
    int r = n/i;
    int sum = 0;
    rep(j,r-1) {
      sum += b[i*(j+2)];
      sum %= 2;
    }
    if(a[i] == sum) {
      b[i] = 0;
    }else {
      b[i] = 1;
      ans++;
    }
  }
  cout << ans << endl;
  if(ans == 0) return 0;
  for(int i = 1; i <= n; i++) {
    if(b[i] == 1) {
      cout << i << ' ';
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 2432