akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,k,t = 1;
	cin >> n >> k;
	for(int i = 0;i < n;i++){
		t = min(t + k,t * 2);
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define Yes(a) if(a)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define plaese return
constexpr auto AC = 0;
using namespace std;

int main(){
	int n;
	ll w;
	cin >> n >> w;
	vector<ll> g(n), v(n);
	vector<vector<ll>> dp(n+1, vector<ll>(w+1, 0));
	rep(i, n)cin >> g[i] >> v[i];
	rep(i, n) {
		rep(j, w + 1) {
			if (j - g[i] >= 0)dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - g[i]] + v[i]);
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
		}
	}
	cout << dp[n][w] << endl;
	plaese AC;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
long long n,f[100001][5],l=0,r,mid,a[1000001],b[100001],c[100001];
int main()
{
    cin>>n;
    for(int j=1;j<=n;++j)
    {
        cin>>a[j];
    }
    for(int j=1;j<=n;++j)
    {
        cin>>b[j];
    }
    for(int j=1;j<=n;++j)
    {
        cin>>c[j];
    }
    sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	sort(c+1,c+1+n);
    for(int i=1;i<=n;++i)
    {
        f[i][1]=i;
    }
    for(int j=1;j<=n;++j)
    {
        {
            l=1,r=n;
            while(l<=r)
            {
                mid=(l+r)/2;
                if(b[j]<=a[mid])
                {
                    r=mid-1;
                }
                else
                l=mid+1;
            }
            f[j][2]=f[j-1][2]+f[r][1];
 		}
    }
    for(int j=1;j<=n;++j)
    {
        {
            l=1,r=n;
            while(l<=r)
            {
                mid=(l+r)/2;
                if(c[j]<=b[mid])
                {
                    r=mid-1;
                }
                else
                l=mid+1;
            }
            f[j][3]=f[j-1][3]+f[r][2];
        }
	}
	cout<<f[n][3]<<endl;
    return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

long long X, Y;

int main() {
  cin >> X >> Y;

  long long diff = (X > Y) ? X - Y : Y - X;

  if (diff > 1) {
    cout << "Alice" << endl;
  } else {
    cout << "Brown" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
using namespace std;
int main()
{
    FLASH
    int s,w;
    cin >> s >> w;
    if(w >= s)
        cout <<"unsafe";
    else
        cout<<"safe";
    return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	int s=0,n;
	cin>>a;
	n=a.size();
	for(int i=0;i<n;i++)
	{
		if(a[i]!=a[n-i-1]){s++;a[n-i-1]=a[i];}
	}
	cout<<s<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>

const int W_LIM = 10000;

int n, k;
std::vector<int> w;

int check(int p) {
  int i = 0;
  for (int j = 0; j < k; ++j) {
    int s = 0;
    while (s + w[i] <= p) {
      s += w[i];
      ++i;
      if (i == n) return n;
    }
  }
  return i;
}

int solve() {
  int left = 0;
  int right = n * W_LIM;
  int mid;
  while (right - left > 1) {
    mid = left + (right - left) / 2;
    int v = check(mid);
    if (v >= n) right = mid;
    else left = mid;
  }
  return right;
}

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

  w.reserve(n);
  int x;
  for (int i = 0; i < n; ++i) {
    std::scanf("%d", &x);
    w.push_back(x);
  }

  int p = solve();
  std::printf("%d\n", p);
}



Measured memory_bytes: 2768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  ll c = min(k, x / d);
  x = x - c * d;
  k -= c;

  if (k % 2 == 0) {
    cout << x << endl;
  } else {
    cout << abs(x - d) << endl;
  }
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;


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

    vector<int> b(N + 1);
    b[0] = 0;
    for (int count = 0, n = 0; n < N; n++) {
        if (S[n] == '#') count++;
        b[n + 1] = count;
    }

    vector<int> w(N + 1);
    w[N] = 0;
    for (int count = 0, n = N - 1; n >= 0; n--) {
        if (S[n] == '.') count++;
        w[n] = count;
    }

    vector<int> res(N + 1);
    for (int n = 0; n <= N; n++) {
        res[n] = b[n] + w[n];
    }

    sort(res.begin(), res.end());
    cout << res[0] << endl;

    return 0;
}


Measured memory_bytes: 2948
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	static int[] houmon;
	static ArrayList<Integer>[] rinList;
	static int kaisou;
	static boolean sFlag = true;

	public static void main(String[] args) {
		long startT = System.currentTimeMillis();

		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());

		rinList = new ArrayList[N + 1];
		for (int i = 1; i <= N; i++) {
			rinList[i] = new ArrayList<Integer>();
		}

		int[] rinN = new int[N + 1];
		for (int i = 1; i <= N; i++) {
			String s = sc.next();
			for (int j = i + 1; j <= N; j++) {
				if(s.charAt(j - 1) == '1') {
					rinList[i].add(j);
					rinList[j].add(i);
					rinN[i]++;
					rinN[j]++;
				}
			}
		}

		sc.close();

//		int min = 201;
//		int minIndex = 1;
//		for(int i = 1;i <= N;i++) {
//			if(rinN[i] < min) {
//				min = rinN[i];
//				minIndex = i;
//			}
//		}

		int resMin = 0;

		ArrayList<Integer> firstNodeList = new ArrayList<Integer>();

		for(int i = 1;i <= N;i++) {
			firstNodeList.add(i);
		}
		Collections.shuffle(firstNodeList);

		for(int f : firstNodeList) {
			kaisou = 1;
			Queue<Integer> firstNode = new ArrayDeque<Integer>();
			firstNode.add(f);
			houmon = new int[N + 1];
			houmon[f] = 1;

			myBFS(firstNode);

			if(sFlag) {
				if(kaisou > resMin) resMin = kaisou;
			}else {
				System.out.println(-1);
				return;
			}

			if(System.currentTimeMillis() - startT > 1700) {
				break;
			}
		}

		System.out.println(resMin);


	}

	private static void myBFS(Queue<Integer> nodeQ) {
//		System.out.println("func" + kaisou);
		if(!sFlag) return;
		Queue<Integer> nextNodeQ = new ArrayDeque<Integer>();
		while(!nodeQ.isEmpty()) {
			int node = nodeQ.poll();
//			System.out.println("node:" + node);
			if(rinList[node] == null) break;
			for(int nextNode : rinList[node]) {
//				System.out.print("	nextnode:" + nextNode);
				if(houmon[nextNode] != 0) {
//					System.out.println("×");
					if(kaisou % 2 + 1 != houmon[nextNode]) {
						sFlag = false;
						return;
					}
					continue;
				}
//				System.out.println("○");
				houmon[nextNode] = kaisou % 2 + 1;
				nextNodeQ.add(nextNode);
			}
		}
		if(!nextNodeQ.isEmpty()) {
			kaisou++;
			myBFS(nextNodeQ);
		}
	}
}


Measured memory_bytes: 31540
//けんちょんさんのコード
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    int N, K; cin >> N >> K;
    string S; cin >> S;

    // 「1 の個数」「0 の個数」を交互に記録していく
    vector<int> nums;    
    if (S[0] == '0') nums.push_back(0); // 先頭が 0 だったら
    for (int i = 0; i < S.size();) {
        int j = i;
        while (j < S.size() && S[j] == S[i]) ++j; // S[i] の数値がどこまで続くか
        nums.push_back(j - i);
        i = j;
    }
    if (S.back() == '0') nums.push_back(0); // 最後尾が 0 だったら

    // 累積和
    vector<int> sums((int)nums.size() + 1, 0);
    for (int i = 0; i < nums.size(); ++i) sums[i+1] = sums[i] + nums[i];

    // 偶数番目の添字から始まる、長さ 2K+1 (以下) の区間の総和のうち、最大値を求める
    int res = 0;
    for (int left = 0; left < sums.size(); left += 2) {
        int right = left + K*2+1;
        if (right >= sums.size()) right = (int)sums.size() - 1;
        res = max(res, sums[right] - sums[left]);
    }
    cout << res << endl;
}

Measured memory_bytes: 1336
#include<stdio.h>
int main()
{
	int b1,b2,b3;
	scanf("%d %d %d",&b1,&b2,&b3);
	if(b1==1 && b2 ==0 && b3==0)
	puts("Close");
	if(b1==0 && b2 ==1 && b3==0)
	puts("Close");
	if(b1==1 && b2 ==1 && b3==0)
	puts("Open");
	if(b1==0 && b2 ==0 && b3==1)
	puts("Open");
	if(b1==0 && b2 ==0 && b3==0)
	puts("Close");
	return 0;
}


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

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}


int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int n=s.size();
    if(s[n-1]!='s') s+='s';
    else{
        s+="es";
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<sstream>
 
using namespace std;

int N,K;

int main(){
  
  cin>>N>>K;
  
  vector<bool> snukes(N, false);

  int d;
  
  for(int i = 0; i < N; ++i){
    int d;
    cin>>d;
    for(int j = 0; j < d; ++j){
      int A;
      cin>>A;
      snukes[A-1] = true;
    }
  }
  
  int trick = count(snukes.begin(), snukes.end(), false);
    
  cout << trick <<endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	string a,b; cin >> a >> b;

	for (int i = 0;i < a.size();i++){
		for (int j = 0;j < a.size();j++){
			if(a[j] != b[(i+j)%a.size()]) break;
			if(j == a.size()-1){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;

}


Measured memory_bytes: 256
H, W = map(int, input().split())

coins_list = [list(map(int, input().split())) for _ in range(H)]

def one_line(coins, line_num, ori="lr"):
    ans_list = []
    for i in range(len(coins)-1):
        if coins[i]%2!=0:
            if ori=="lr":
                ans = "{:d} {:d} {:d} {:d}".format(line_num, i+1, line_num, i+2)
            else:
                ans = "{:d} {:d} {:d} {:d}".format(i+1, line_num, i+2, line_num)
            coins[i+1] += 1
            ans_list.append(ans)
    return ans_list, coins[-1]

ans_list = []
right_column = []
for h in range(H):
    ans, r = one_line(coins_list[h], h+1)
    ans_list += ans
    right_column.append(r)

ans, _ = one_line(right_column, W, ori="ud")
ans_list += ans

print(len(ans_list))
for ans in ans_list:
    print(ans)


Measured memory_bytes: 16472
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int k, s;
    cin >> k >> s;
    
    int cnt = 0;
    rep(x, k+1) rep(y, k+1) {
        int z = s- x - y;
        if (0 <= z && z <= k) {
            cnt ++;
        }
    }

    put(cnt);
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
using namespace std;
 
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string str;
	while(getline(cin, str)){
	
	while(1){
		for(size_t i = 0; i < str.size(); ++i){
			if('a' <= str[i] && str[i] <= 'z'){
				if(str[i] == 'z'){
					str[i] = 'a';
				}
				else {
					str[i]++;
				}
			}
		}
		bool check = false;
		for(size_t i = 0; i < str.size(); ++i){
			if(str[i] == 't' && (i == 0 || str[i - 1] == ' ')){
				if(str.substr(i, 3) == "the" && (str[i + 3] == ' ' || str[i + 3] == '.') ){
					check = true;
					break;
				}
				if((str.substr(i, 4) == "this" || str.substr(i, 4) == "that") && (str[i + 4] == ' ' || str[i + 4] == '.') ){
					check = true;
					break;
				}
			}
		}
		if(check){
			break;
		}
	}
	cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
  
using namespace std;
  
int N,C,cnt;
bool flg,visited[10][10];
vector<int> G[10];
int dx[6] = {-1,-1,0,0,1,1};
int dy[6] = {-1,0,-1,1,0,1};
  
bool inField(int x,int y){
    if(x > y || y >= N || x < 0 || y < 0){
	return false;
    }
    return true;
}
  
bool dfs(int x,int y,int c){
    if(G[y][x] == 0) return true;
    if(G[y][x] != c || visited[y][x]) return false;
    visited[y][x] = true; cnt++;
    bool res = false;
    for(int i = 0 ; i < 6 ; i++){
	int nx = x + dx[i];
	int ny = y + dy[i];
	if(!inField(nx,ny)) continue;
	res |= dfs(nx,ny,c);
    }
    return res;
}
 
int solve(int x,int y){
    int res = 0;
    memset(visited,false,sizeof(visited));
    for(int i = 0 ; i < N ; i++){
	for(int j = 0 ; j <= i ; j++){
	    if(G[i][j] == 0) continue;
	    if(visited[i][j]) continue;
       
	    cnt = 0; flg = false;
	    if(dfs(j,i,G[i][j])) continue;
	    res += (G[i][j] != C ? cnt : -cnt);
	}
    }
    return res;
}
  
int main(){
    int in;
    while(cin >> N >> C,(N|C)){
	for(int i = 0 ; i < N ; i++){
	    G[i].clear();
	    for(int j = 0 ; j <= i ; j++){
		cin >> in;
		G[i].push_back(in);
	    }
	}
	int res = INT_MIN;
	for(int i = 0 ; i < N ; i++){
	    for(int j = 0 ; j <= i ; j++){
		if(G[i][j] == 0){
		    G[i][j] = C;
		    res = max(res,solve(j,i));
		    G[i][j] = 0;
		}
	    }
	}
	cout << res << endl;
    }
    return 0;
}

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

const int N = 1e5 + 5;

vector<int> g[N];
int dp[N];

int n;

void dfs(int u) {
	for (auto v: g[u])
		dfs(v);

	sort(begin(g[u]), end(g[u]), [&](int a, int b) {
		return dp[a] > dp[b]; });
	for (int i = 0; i < g[u].size(); ++i)
		dp[u] = max(dp[u], 1 + dp[g[u][i]] + i); }

int main() {
#ifdef HOME
	freopen("agc9b.in", "r", stdin);
	freopen("agc9b.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n;
	for (int t, i = 2; i <= n; ++i) {
		cin >> t;
		g[t].push_back(i); }

	dfs(1);

	cout << dp[1] << endl;

	return 0; }


Measured memory_bytes: 10752
S = input()
ch = 0
if S == 'AKIHABARA':
    ch = 1
elif S == 'KIHABARA' or S == 'AKIHBARA' or S == 'AKIHABRA' or S == 'AKIHABAR' or S == 'AKIHABARA' or S == 'AKIHABARA':
    ch = 1
elif S == 'KIHBARA' or S == 'KIHABRA' or S == 'KIHABAR':
    ch = 1
elif S == 'AKIHBRA' or S == 'AKIHBAR':
    ch = 1
elif S == 'AKIHABR':
    ch = 1
elif S == 'KIHBRA' or S == 'KIHBAR' or S == 'KIHABR':
    ch = 1
elif S == 'AKIHBR':
    ch = 1
elif S == 'KIHBR':
    ch = 1

if ch == 0:
    print('NO')
else:
    print('YES')


Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var N, K int
	fmt.Scanf("%d %d", &N, &K)
	h := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &h[i])
	}
	cost := make([]int, N)

	for i := 1; i < N; i++ {
		mi := 10000000000
		for k := 1; k <= K && i-k >= 0; k++ {
			if mi > cost[i-k]+abs(h[i]-h[i-k]) {
				mi = cost[i-k] + abs(h[i]-h[i-k])
			}
		}
		cost[i] = mi
	}
	fmt.Println(cost[N-1])
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}


Measured memory_bytes: 5504
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

ll gcd(ll a, ll b) {
    while (b) {
        ll c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int main() {
    ios::sync_with_stdio(false);
    int n, a[8] = {}, b[8] = {}, c[8] = {1, 2, 3, 4, 5, 6, 7, 8}, x = 0, y = 0, z = 0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    do {
        bool u = 0, v = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] != c[i]) u = 1;
            if (b[i] != c[i]) v = 1;
        }
        if (!u) x = z;
        if (!v) y = z;
        z++;
    } while (next_permutation(c, c + n));
    cout << abs(x - y);
}


Measured memory_bytes: 3536
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

//constexpr int inf = 2147483647;
//constexpr int64_t inf64 = 9223372036854775807;
//constexpr int mod = 1e9+7;

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

  char c;
  cin >> c;

  cout << (char)(c+1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <set>
#include <string>

using namespace std;

int main() {
  string a;
  int k;
  cin >> a >> k;
  int n = static_cast<int>(a.size());
  priority_queue<string> que;
  set<string> buf;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      string tmp = a.substr(i, j - i + 1);
      if (buf.find(tmp) != buf.end()) {
        continue;
      } else if (int(que.size()) < k) {
        buf.insert(tmp);
        que.push(tmp);
      } else if (tmp < que.top()) {
        buf.insert(tmp);
        buf.erase(que.top());
        que.pop();
        que.push(tmp);
      }
    }
  }

  cout << que.top() << endl;
}

Measured memory_bytes: 3668
n=int(input())
if n==1:
    print("0")
    exit()
l=[list(map(int,input().split())) for _ in range(n-1)]
for i in range(n):
    t=0
    k=i
    while k<n-1:
        if l[k][1]>t:
            t=l[k][0]+l[k][1]
            k+=1
            continue
        elif t%l[k][2]==0:
            t+=l[k][0]
            k+=1
            continue
        else:t+=l[k][2]-t%l[k][2]
    print(t)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

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

    std::string ans = (N < 1000) ? "ABC" : "ABD";

    std::cout<<ans<<std::endl;

    return 0;
}

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

/*

i-2 i-1 i i+1 i+1


[i-c ,    i+1]
    [i-1 ,     i+c]

*/

typedef pair<int,int> PII;

const int M=2e5+5;
int n,k,c;
char s[M];

int l[M],r[M];

deque<PII> dq;

int main()
{
	//freopen("E.in","r",stdin);
	scanf("%d%d%d",&n,&k,&c);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
	{
		l[i]=l[i-1];
		if(s[i]!='x')
			l[i]=max(l[i],i-c-1>=1?l[i-c-1]+1:1);
	}
	for(int i=n;i>=1;i--)
	{
		r[i]=r[i+1];
		if(s[i]!='x')
			r[i]=max(r[i],i+c+1<=n?r[i+c+1]+1:1);
	}
	// for(int i=1;i<=n;i++)
	// 	cout<<l[i]<<" ";
	// cout<<endl;
	// for(int i=1;i<=n;i++)
	// 	cout<<r[i]<<" ";
	// cout<<endl;
	if(c==0) c++;
	for(int i=0;i<c-1;i++)
	{
		while(!dq.empty()&&dq.back().first<=r[i+2])
			dq.pop_back();
		dq.push_back({r[i+2],i+2});
	}
	for(int i=1;i<=n;i++)
	{
		while(!dq.empty()&&dq.front().second<=i)
			dq.pop_front();
		int v=l[i-1]+(i+c<=n?r[i+c]:0);
		//cout<<"v "<<v<<endl;
		while(!dq.empty()&&dq.back().first<=v)
			dq.pop_back();
		dq.push_back({v,i+c});
		if(dq.front().first>=k) continue;
		printf("%d\n",i);
	}
	//cout<<"!! end"<<endl;
	return 0;
}


Measured memory_bytes: 3200
#include "bits/stdc++.h"
using namespace std;

long long b1(long long x, long long a, long long b) {
	if (a > b) swap(a, b);
	long long ato1 = a - 1 + 1;
	long long bnew = b - ato1;
	return ato1 + abs(1 - bnew) / 2;
}

long long bn(long long x, long long a, long long b) {
	if (a > b) swap(a, b);
	long long bton = x - b + 1;
	long long anew = a + bton;
	// if (anew > b + bton) return LLONG_MAX;
	// cout << anew << ' ' << bton << endl;
	return bton + abs(x - anew) / 2;
}


int main() {
	
	long long x, a, b;
	cin >> x >> a >> b;
	long long d = abs(a - b);
	if (d % 2 == 0) {
		cout << d / 2 << endl;
	}
	else {
		long long f = max(a - 1, b - 1);
		f = min(f, max(x - a, x - b));
		f = min(f, b1(x, a, b));
		f = min(f, bn(x, a, b));
		cout << f << endl;
	}
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
vector<int> prime;
int N;
int dfs(int idx, int num){
    //cout << idx << " " << num << endl;
    if(idx == prime.size()){
        //cout << idx << " " << num << endl;
        if(num == 75)return 1;
        else return 0;
    }
    if(num > 75)return 0;
    if(num == 75)return 1;
    //cout << idx << " " << num << endl;
    int res = 0;
    rep(i,1,prime[idx]+2){
        res += dfs(idx+1, num * i);
    }
    return res;
}
main(){
    cin >> N;
    prime.resize(N+1);
    rep(i,2,N+1){
        int num = i;
        for(int j = 2;j * j <= num;j++){
            while(num % j == 0){
                num /= j;
                prime[j]++;
            }
        }
        if(num != 1)prime[num]++;
    }
    //rep(i,0,N+1)cout << i << " " << prime[i] << endl;
    
    rep(i,0,prime.size())if(prime[i] == 0){
        prime.erase(prime.begin() + i);
        i--;
    }
    
    //or(auto i:prime)cout << i << endl;
    cout << dfs(0, 1) << endl;
}

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

sum_a = 0
c = 0
for i in range(n):
    sum_a += a[i]
    if i % 2 == 0 and sum_a <= 0:
        c += 1 - sum_a
        sum_a = 1
    elif i % 2 == 1 and sum_a >= 0:
        c += sum_a + 1
        sum_a = -1

sum_a = 0
ans = c
c = 0
for i in range(n):
    sum_a += a[i]
    if i % 2 == 0 and sum_a >= 0:
        c += sum_a + 1
        sum_a = -1
    elif i % 2 == 1 and sum_a <= 0:
        c += 1 - sum_a
        sum_a = 1

print(min(ans, c))


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){
  while(u != NIL && k != (*u).key)
    {
      if(k < (*u).key)
	u = (*u).left;
      else 
	u = (*u).right;
    }
  return u; 
}

Node treeSuccessor(Node x){

  
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  
  
  
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x;
    if((*z).key < (*x).key)
      x = (*x).left;
    else x = (*x).right;
    (*z).parent = y;
  }
  if(y == NIL)
    root = z;
  else if((*z).key < (*y).key)
    (*y).left = z;
  else (*y).right = z; 
}

void inorder(Node u){
  if(u != NIL)
    {
      inorder((*u).left);
      
      printf(" %d",(*u).key);
      
      inorder((*u).right);
    }
}

void preorder(Node u){
 if(u != NIL)
    {   
      printf(" %d",(*u).key);

      preorder((*u).left);
      
      preorder((*u).right);
    }
}


int main(){
  int n,i,x;
  char com[20];
  scanf("%d",&n);

  for (i=0; i<n; i++){
    scanf("%s",com);
    if (com[0] == 'f'){
      scanf("%d",&x);
      Node t = treeSearch(root,x);
      if (t != NIL) printf("yes\n");
      else printf("no\n");
    }
    else if (com[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    }
    else if (com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if (com[0] == 'd'){
      scanf("%d",&x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;

}

Measured memory_bytes: 24040
#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, n, ans = INF; cin >> x >> n;
    set<ll> p;
    rep(i, n) {
        ll tmp; cin >> tmp;
        p.insert(tmp);
    }

    frep(i, 0, 101) {
        if(p.count(i)) continue;
        else {
            if(my_abs(x-i) < my_abs(x-ans)) {
                ans = i;
            }
        }
    }
    cout << ans << 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: 3636
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
#define int long long

int gcd(int a, int b){
        int c;
        while (a!=0){ c=a; a=b%a; b=c;}
        return b;
}

signed main(){
        int a, b;
        while( scanf("%lld %lld", &a, &b) != EOF ){
                int c = gcd(a,b);
                printf("%lld %lld\n", c, (a/c)*(b/c)*c);
        }

        return 0;
}

Measured memory_bytes: 3232
import numpy as np

def main():

    N, M = list(map(int, input().split()))

    num = [0] * N
    if N > 1:
        num[0] = 1

    used = set()
    pair = []
    for i in range(M):
        s, c = list(map(int, input().split()))
        if s == 1 and c == 0 and N > 1:
            print(-1)
            return

        if s in used and [s,c] not in pair:
            print(-1)
            return

        num[s - 1] = c
        used.add(s)
        pair.append([s,c])

    for c in num:
        print(c, end="")
    print()
        


main()

Measured memory_bytes: 12504
#include<stdio.h>
#define N 100001
#define NIL -1

 struct Node{
  int parent;
  int left;
  int right;
};
struct Node T[N]; 
int cnt=0;

int depth(int nodeid) {
  if(T[nodeid].parent == NIL) {
    return cnt;
  }
  else {
 cnt++;
 return depth(T[nodeid].parent);
  }
}

void degree(int nodeid) {
  if(nodeid != NIL) {
    if(cnt != 0){
      printf(", ");
	}
    printf("%d",nodeid);
    cnt++;
    degree(T[nodeid].right);
  }
}  

int main(void) {
  
  int i,j,n,m,newnode,child,left,right;
  
  scanf("%d",&n);

  for(i=0;i<n;i++)
    T[i].parent = T[i].left = T[i].right = NIL; 

  for(i=0;i<n;i++) {
    scanf("%d%d",&newnode,&m);
    for(j=0;j<m;j++) {
      scanf("%d",&child);
      T[child].parent = newnode;
      if(j != 0) {
	T[left].right = child;
      }
      else {
	T[newnode].left = child;
      }
      left = child;
    }
  }
  for(i=0;i<n;i++) {
    cnt = 0;
    printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,depth(i));
      if(T[i].parent == NIL) {
	printf("root, [");
      }
      else if (T[i].left == NIL) {
	printf("leaf, [");
      }  
      else  {
	printf("internal node, [");
      }    
    cnt=0;
    degree(T[i].left);
    printf("]\n");
  }
  return 0;
}

Measured memory_bytes: 1784
using System;
using System.Collections.Generic;

class AOJ
{

    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());


        for (int i = 0; i < n; i++)
        {

            string[] s = Console.ReadLine().Split(' ');
            int[] a = new int[10];

            for (int j = 0; j < 10; j++)
                a[j] = int.Parse(s[j]);

            int r = 0, l = 0, k;

            for (k = 0; k < 10; k++)
            {
                if (r < a[k])
                    r = a[k];
                else if (l < a[k])
                    l = a[k];
                else
                    break;
            }

            if (k == 10)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}

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

int main() {
    int n,count=0;
    cin >>n;
    vector<int> data(n);
    for (int i = 0; i < n; i++){
        cin >> data.at(i);
    }
    for (int i = 1 ; i < n-1; i++){
        if(data.at(i) < data.at(i-1) && data.at(i+1) < data.at(i))
        count ++;
        else if(data.at(i) < data.at(i+1) && data.at(i-1) < data.at(i))
        count ++;
    }
    cout << count << endl;
}

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

col=[0,0,0]
res=1

for ai in a:
    cnt=0
    for i in range(3):
        if col[i]==ai:
            if cnt==0:
                col[i]=col[i]+1

            
            cnt+=1
            
    
    res=(res*cnt)%1000000007

print(res)


Measured memory_bytes: 53996
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

#define MAX_N 20

int main() {
    int n;
    int a[MAX_N], b[MAX_N], c[MAX_N];

    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }
    for(int i=0; i<n; i++) {
        cin >> b[i];
    }
    for(int i=0; i<n-1; i++) {
        cin >> c[i];
    }

    int s = 0;
    for(int i=0; i<n; i++) {
        s += b[a[i]-1];
        if (i>0 && a[i] == a[i-1]+1) {
            s += c[a[i-1]-1];
        }
    }

    cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,m; cin >> n >> m;
    long long ans = 0;
    if(2*n <= m){
        ans += n;
        m -= 2*n;
        ans += m/4;
    }else{
        ans += m/2;
    }
    cout << ans << endl;
}

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

#define REP(i, n) for (int i = 0; i < (int)(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 ALL(v) v.begin(), v.end()

int main() {
  int a,b;
  cin >> a >> b;
  if ((a+b)%2==0) {
    cout << ((a+b)/2) << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;

    bool vis[100][100][100];
    for(int i=0; i<100; i++)
        for(int j=0; j<100; j++)
            for(int k=0; k<100; k++)
                vis[i][j][k] = false;

    queue<tuple<int, int, int, int>> que;
    que.push(make_tuple(A, B, C, 0));
    while(!que.empty()){
        int a, b, c, cnt;
        tie(a, b, c, cnt) = que.front();
        que.pop();

        if(vis[a][b][c]) continue;
        vis[a][b][c] = true;

        if(a == b && b == c){
            cout << cnt << endl;
            return 0;
        }

        que.push(make_tuple(a+1, b+1, c, cnt+1));
        que.push(make_tuple(a+1, b, c+1, cnt+1));
        que.push(make_tuple(a, b+1, c+1, cnt+1));
        que.push(make_tuple(a+2, b, c, cnt+1));
        que.push(make_tuple(a, b+2, c, cnt+1));
        que.push(make_tuple(a, b, c+2, cnt+1));
    }

    return 0;
}

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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long int n,m;
  long int sum=0;
  cin>>n>>m;
  long int arr[m];
  for(long int i=0;i<m;i++)
  {
    cin>>arr[i];
    sum+=arr[i];
  }
  if(sum>n)
    cout<<"-1"<<endl;
  else 
    cout<<(n-sum)<<endl;
}

Measured memory_bytes: 3688
H, W = map(int, input().split())
M = []
for i in range(H):
    M.append(list(input()))
answer = 'Yes'
for i in range(H):
    for j in range(W):
        elem = M[i][j]
        if elem == '#':
            neib = []
            if i != 0:
                neib.append(M[i-1][j])
            if i != H-1:
                neib.append(M[i+1][j])
            if j != 0:
                neib.append(M[i][j-1])
            if j != W-1:
                neib.append(M[i][j+1])
            if '#' not in neib:
                answer = 'No'
                break

print(answer)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String word = sc.next();
        int len = word.length();
        if(!(len > 0)){
            return;
        }
        String lastChar = String.valueOf(word.charAt(len - 1));
        String toAppend = "s";
        if(lastChar.equals("s")){
            toAppend = "es";
        }
        System.out.println(word+toAppend);
    }
}


Measured memory_bytes: 39280
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;
import std.typecons : Tuple;


void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(int[]);
    auto b = readln.split.to!(int[]);
    int ue = a[0], sita = b.sum();
    int ans = ue + sita;

    foreach (i ; 1 .. n) {
        ue += a[i];
        sita -= b[i-1];

        ans = max(ans, ue + sita);
    }

    writeln(ans);
}




void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    ll a[n];
    ll ans=0;
    ll cnt=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]==0){
            ans+=cnt/2;
            cnt=0;
        }
        else cnt+=a[i];
    }
    ans+=cnt/2;
    cout<<ans<<endl;
}




Measured memory_bytes: 1152
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int R0=sc.nextInt();
		int M=R0;
		int m=R0;
		int M2=R0;
		int Mn=0;
		int mn=0;
		int M2n=0;
		int R=sc.nextInt();
		if(m>R){
			m=R;
			mn=1;
		}
		if(M<=R){
			M=R;
			Mn=1;
		}
		int d=R-R0;
		for(int i=2;i<n;i++){
			R=sc.nextInt();
			if(mn<=Mn){
				if(m>R){
					m=R;
					mn=i;
				}
				if(M<=R){
					M=R;
					Mn=i;
					d=M-m;
				}
			}else{
				if(m>R){
					m=R;
					mn=i;
				}else if(M<=R){
					M=R;
					Mn=i;
					d=M-m;
				}else if(M2<R||M2n<mn){
					M2=R;
					M2n=i;
					if(d<R-m){
						d=R-m;
					}
				}
			}
		}
		System.out.println(d);
	}
}

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    set<int> st;
    if(n < 6){
        st = set<int>({2, 3, 25});
        for(int i=1;st.size()<n;++i)st.insert(30*i);
    }else{
        int sum = 0;
        for(int i=0;st.size()<n;++i){
            st.insert(6*i+2);
            sum += 6*i+2;
            if(st.size() >= n)break;
            st.insert(6*i+3);
            sum += 6*i+3;
            if(st.size() >= n)break;
            st.insert(6*i+4);
            sum += 6*i+4;
            if(st.size() >= n)break;
            st.insert(6*i+6);
            sum += 6*i+6;
        }
        if(sum % 6 == 2){
            st.erase(8);
            st.insert(30000);
        }else if(sum % 6 == 3){
            st.erase(9);
            st.insert(30000);
        }else if(sum % 6 == 5){
            st.erase(9);
            st.insert(29998);
        }
    }
    vector<int> v(st.begin(), st.end());
    for(int i=0;i<n;++i){
        if(i)cout << " ";
        cout << v[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1408
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl
#define CE cout<<endl

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[1010];
bool r,ra,rb,rc[200010];
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc,vd,ve;
set<int> st;

template<typename MAIN> ostream & operator<<(ostream & osys,const vector<MAIN> target){ for(MAIN it:target)osys<<it<<" "; return osys; }

int main(){
    cin>>a>>b;
    c=abs(a+b);
    if(c%2){
        C "IMPOSSIBLE" E;
    }
    else{
        C c/2 E;
    }
}


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

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

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

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

    long long ans = 0;

    for(int i = 0; i < n; i++){
        ans += (distance(a.begin(), lower_bound(a.begin(), a.end(), b[i])) * (distance(upper_bound(c.begin(), c.end(), b[i]), c.end())));

    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include<iostream>

using namespace std;

int main(){
  int n,k,cnt=0;
  int v[1000000];
  
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> v[i];
    if(v[i] >= k)cnt++;
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
const int MAXN=2e5+10;
int a[MAXN];
int main(void)
{
    sync;
    int n;
    cin>>n;
    for(int i=0;i<n-1;++i)
    {
        int t;
        cin>>t;
        ++a[t];
    }
    for(int i=1;i<=n;++i)
        cout<<a[i]<<'\n';
    return 0;
}

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

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

//prototype declaration
int getint();
long long getllint();
double getdint();
char getch();
void setstring(char *s);
void showint(int i);
void showllint(long long i);
void showdint(double i);
void showchar(char c);
void showstring(char *s);

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main(void) {
	int i;
	int count = 0;
	int smCount = 0;
	char s[10];
	scanf("%s", s);
	if (s[0] == 'A') {
		ROOP(i, strlen(s)) {
			if (2 <= i && i <= strlen(s) - 2) {
				if (s[i] == 'C') {
					count++;
				}
			}
			if ( (s[i]>= 'a') && (s[i]<='z') ) {
				smCount++;
			}
		}
		if (count == 1 && smCount == strlen(s) - 2) {
			showstring("AC");
			return 0;
		}
	}
	showstring("WA");
	return 0;
}

int getint() {
	int i;
	scanf("%d", &i);
	return i;
}

long long getllint() {
	long long i;
	scanf("%lld", &i);
	return i;
}

double getdint() {
	double i;
	scanf("%lf", &i);
	return i;
}

char getch() {
	char c;
	scanf("%c", &c);
	return c;
}

void setstring(char *s) {
	scanf("%s", s);
}

void showint(int i) {
	printf("%d\n", i);
}

void showllint(long long i) {
	printf("%lld\n", i);
}

void showdint(double i) {
	printf("%lf\n", i);
}

void showchar(char c) {
	printf("%c\n", c);
}

void showstring(char *s) {
	printf("%s\n", s);
}


Measured memory_bytes: 128
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = ins()
if n[0]=='7' or n[1]=='7' or n[2]=='7':
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9132
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int n;cin>>n;
  vector<ll> a(n);rep(i,n)cin>>a[i];
  vector<ll> b(n+1);
  rep(i,n)b[i+1] = (b[i] + a[i]);
  
  ll ans = 0;
  rep(i,n-1){
    ll tmp = b[n] - b[i+1];
    tmp %= INF;
    ans += a[i]*tmp;
    ans %= INF;
  }

  print(ans);
  return 0;
}

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

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

  vector<int> v;

  while (n > 0) {
    int m = n % k;
    v.push_back(m);
    n /= k;
  }

  cout << v.size() << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
    public:
    static const int MAXN=60;
    static const int MAXK=110;
    static const int INF=0x3f3f3f3f;
    int N,K;
    int f[MAXN][MAXK];
    int g[MAXN][MAXK];
    int v[MAXN];
    void solve(){
        ios::sync_with_stdio(false);
        cin>>N>>K;
        for(int u=1;u<=N;u++)cin>>v[u];
        for(int s=1;s<=N;s++){
            for(int t=0;t<=s;t++){
                f[s][t]=-INF;
                if(t>0)f[s][t]=max(f[s][t],f[s-1][t-1]);
                f[s][t]=max(f[s][t],f[s-1][t]+v[s]);
            }
        }
        reverse(v+1,v+1+N);
        for(int s=1;s<=N;s++){
            for(int t=0;t<=s;t++){
                g[s][t]=-INF;
                if(t>0)g[s][t]=max(g[s][t],g[s-1][t-1]);
                g[s][t]=max(g[s][t],g[s-1][t]+v[s]);
            }
        }
        int ans=0;
        for(int s=0;s<=min(N,K);s++){
            for(int t=0;t<=s;t++){
                for(int x=0;x<=min(N,K);x++){
                    for(int y=0;y<=x;y++){
                        if(s+t+x+y>K||s+x>N)break;
                        ans=max(ans,f[s][t]+g[x][y]);
                    }
                }
            }
        }
        cout<<ans;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

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

int main(void) {
    string s[3];
    char diff = 'a' - 'A';
    cin >> s[0] >> s[1] >> s[2];

    for(int i=0;i<3;i++) {
        s[i][0] -= diff;
    }
    cout << s[0][0] << s[1][0] << s[2][0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
vector<pair<int,int> > v;
int main(void){
  int n;
  while(cin >> n){
    if(!n) break;
    v.clear();
    for(int j = 0; j < n; j++){
      int c = 0;
      int id;
      cin >> id;
      for(int i = 0; i < 4; i++){
	int m,s;
	cin >> m >> s;
	c += m*60 + s;
      }
      v.push_back(make_pair(c,id));
    }
    sort(v.begin(),v.end());
    cout << v[0].second << endl;
    cout << v[1].second << endl;
    cout << v[v.size()-2].second << endl;
  }
}

Measured memory_bytes: 1304