akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
#include <unordered_map>
using namespace std;
typedef long long LL;

unordered_map<int,int> mem[23];
int n,m;
int table[10][10];
int search(int i, int j, int done)
{
	if(table[i][j]>=0&&mem[table[i][j]].find(done)!=mem[table[i][j]].end()){
		return mem[table[i][j]][done];
	}
	int ret=0;
	int dx=1;
	int dy=0;
	for(int k=0;k<4;k++,swap(dx,dy),dx=-dx){
		int x=i+dx;
		int y=j+dy;
		while(0<=x&&x<n&&0<=y&&y<m){
			if(table[x][y]>=0){
				if(done&(1<<table[x][y])){
					ret+=search(x,y,done^(1<<table[x][y]));
					break;
				}
			}
			else if(done==0&&table[x][y]==-1){
				ret++;
				break;
			}
			x+=dx;
			y+=dy;
		}
	}
	if(table[i][j]>=0){
		mem[table[i][j]][done]=ret;
	}
	return ret;
}
int main() {
while(1){
	cin >> m >> n;
	if(m==0)return 0;
	int s=0,t=0;
	int c=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			int v;
			cin >> v;
			if(v==1){
				table[i][j]=c++;
			}
			else if(v==2)
			{
				s=i;
				t=j;
				table[i][j]=-1;
			}
			else{
				table[i][j]=-2;
			}
		}
	}
	int ret=search(s,t,(1<<c)-1);
	for(int i=0;i<c;i++){
		mem[i].clear();
	}
	cout << ret << endl;
}
}

Measured memory_bytes: 49044
#include <stdio.h>

int main(void)
{
    char a[4];
    int ren;
    gets(a);
    if(a[0] == 'S' && a[1] == 'S' && a[2] == 'S'){
        ren =0;
    }
    if(a[0] == 'S' && a[1] == 'S' && a[2] == 'R'){
        ren =1;
    }
    if(a[0] == 'S' && a[1] == 'R' && a[2] == 'S'){
        ren =1;
    }
    if(a[0] == 'S' && a[1] == 'R' && a[2] == 'R'){
        ren =2;
    }
    if(a[0] == 'R' && a[1] == 'S' && a[2] == 'S'){
        ren =1;
    }
    if(a[0] == 'R' && a[1] == 'S' && a[2] == 'R'){
        ren =1;
    }
    if(a[0] == 'R' && a[1] == 'R' && a[2] == 'S'){
        ren =2;
    }
    if(a[0] == 'R' && a[1] == 'R' && a[2] == 'R'){
        ren =3;
    }
    printf("%d\n", ren);

}

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

int main(){
	int n, m;
	string s;
	while(cin >> n >> s){
		for(int i = 0; i < s.size(); i++){
			printf("%c",(s[i] - 'A' + n) % 26 + 'A');
		}
		cout << endl;
	}
	
	return 0;
}

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

def main():
    S = input().strip()
    K = int(input())

    isSameChar = True
    for s in S:
        if s != S[0]:
            isSameChar = False
    if isSameChar:
        print((len(S) * K) // 2)
        exit()

    count1 = 0
    now_count = 1
    for i in range(len(S) - 1):
        if S[i] == S[i + 1]:
            now_count += 1
        else:
            count1 += now_count // 2
            now_count = 1
    count1 += now_count // 2

    doubleS = S * 2
    count2 = 0
    now_count = 1
    for i in range(len(doubleS) - 1):
        if doubleS[i] == doubleS[i + 1]:
            now_count += 1
        else:
            count2 += now_count // 2
            now_count = 1
    count2 += now_count // 2

    ans = count1 + (count2 - count1) * (K - 1)
    print(ans)



    

if __name__ == '__main__':
    main()



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

typedef enum {
  false,
  true
}boolean;

typedef struct {
	int a;
	int b;
	int c;
}edge;

typedef struct vsub{
	int v;
	int num;
	struct vsub **nexts;
	int *c;
}vertex;

boolean search(boolean *grave, vertex *ver, int sum, int dest, int border){
	if(sum >= border){
		return false;
	}
	if(sum < border && ver->v == dest){
		return true;
	}
	int i;
	for(i = 0; i < ver->num ;i++){
		if(grave[(ver->nexts)[i]->v] == false){
			grave[(ver->nexts)[i]->v] = true;
			if(search(grave , (ver->nexts)[i], sum + (ver->c)[i], dest, border) == true){
				grave[(ver->nexts)[i]->v] = false;
				return true;
			}
			grave[(ver->nexts)[i]->v] = false;
		}
	}
	return false;
}

int main(){
	int N, M, i, a, b, c, ans = 0;
	scanf("%d%d", &N, &M);
	edge E[M];
	vertex *V[N];
	for(i = 0; i < N; i++){
		V[i] = (vertex *)malloc(sizeof(vertex));
		V[i]->v = i;
		V[i]->num = 0;
		V[i]->nexts = (vertex **)malloc(sizeof(vertex *) * N);
		V[i]->c = (int *)malloc(sizeof(int) * N);
	}
	for(i = 0; i < M; i++){
		scanf("%d%d%d", &a, &b, &c);
		a--;
		b--;
		E[i].a = a;
		E[i].b = b;
		E[i].c = c;
		(V[a]->nexts)[V[a]->num] = V[b];
		(V[a]->c)[V[a]->num] = c;
		(V[a]->num)++;
		(V[b]->nexts)[V[b]->num] = V[a];
		(V[b]->c)[V[b]->num] = c;
		(V[b]->num)++;
	}
	boolean *grave;
	grave = (boolean *)malloc(sizeof(boolean) * N);
	for(i = 0; i < N; i++){
		grave[i] = false;
	}
	for(i = 0; i < M; i++){
		grave[E[i].a] = true;
		if(search(grave, V[E[i].a], 0, E[i].b, E[i].c) == true){
			ans++;
		}
		grave[E[i].a] = false;
	}
	printf("%d\n", ans);
	free(grave);
	for(i = 0; i < N; i++){
		free(V[i]->nexts);
		free(V[i]->c);
		free(V[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int64_t> memo(100,-1);

int64_t lucas(int64_t x){
  if(memo.at(x)!= -1) return memo.at(x);
  return memo.at(x) = lucas(x-1) + lucas(x-2);
}
int main(){
  int64_t x;
  cin >> x;
  memo.at(0) = 2;
  memo.at(1) = 1;
  cout << lucas(x) << endl;
  
}

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


int main() {
    int  a, b;
    cin >> a >> b;
    if (a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 || a == 12 ) {
        if (b == 1 || b == 3 || b == 5 || b == 7 || b == 8 || b == 10 || b == 12) {
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
   }
    else if(a == 4 || a == 6 || a == 9 || a == 11 && b == 4 || a == 6 || a == 9 || a == 11) {
        if (b == 4 || b == 6 || b == 9 || b == 11) {
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }
   
    else cout << "No" << 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 N = sc.nextInt();
		int[] X = new int[N];
		for (int i = 0; i < N; i++)
			X[i] = sc.nextInt();
		sc.close();

		int[] xSort = Arrays.copyOf(X, N);
		Arrays.sort(xSort);
		int midA = xSort[(N - 1) / 2];
		int midB = xSort[N / 2];

		for (int i = 0; i < N; i++)
			System.out.println(X[i] <= midA ? midB : midA);
	}
}

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

int main(void){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  
  sort(a,a+3);

  cout << a[0] << " " << a[1] << " " << a[2] << endl;
  
  return 0;
  
}



Measured memory_bytes: 3164
#include <iostream>

using namespace std;

int main(){
        int n,ans=0;
        int v[25],c[25];
        cin>>n;
        for(int i=0; i<n; i++){
                cin>>v[i];
        }
        for(int i=0; i<n; i++){
                cin>>c[i];
        }
        for(int i=0; i<n; i++){
                if(v[i]-c[i]>0) ans+=v[i]-c[i];
        }
        cout<<ans<<endl;
        return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <math.h>

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

    int *nums;
    nums = (int *)malloc(sizeof(int) * (N+2));

    int sum = 0;
    nums[0] = 0;
    nums[N+1] = 0;
    for(i=1; i<N+1; i++){
        scanf("%d", &nums[i]);
    }
    for(i=1; i<N+2; i++){
        sum += abs(nums[i-1] - nums[i]);
    }
    
    int ans;
    for(i=1; i<N+1; i++){
        ans = sum + abs(nums[i-1] - nums[i+1]) - (abs(nums[i-1] - nums[i]) + abs(nums[i] - nums[i+1]));
        printf("%d\n", ans);
    }


    return 0;
}


Measured memory_bytes: 1536
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def main():
    N = int(input())
    A = list(map(int, input().split()))

    print(gcd(*A))

if __name__ == '__main__':
    main()


Measured memory_bytes: 91744
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class ABC125_A
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int t = int.Parse(str[2]);
            Console.Write(t / a * b);
        }
    }
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n - i; j++){
            string t = s.substr(0, j) + s.substr(j+i, n-1);
            //cout << t << endl;
            if(t == "keyence"){
                cout << "YES\n";
                return 0;
            }
        }
    }
    cout << "NO\n";
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // #ifndef ONLINE_JUDGE
  // freopen ("input.txt", "r", stdin);
  // freopen ("output.txt", "w", stdout);
  // #endif 
  int n, w_max;
  cin >> n >> w_max;
  vector <long long> v(n), dp(w_max + 1, 0);
  vector <int> w(n);
  for (int i = 0; i < n; ++i) {
    cin >> w[i] >> v[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = w_max - w[i]; j >= 0 ; --j) {
      dp[j + w[i]] = max (dp[j + w[i]], dp[j] + v[i]);
    }
  }
  cout << *max_element (dp.begin(), dp.end());
}

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

using namespace std;

int main() {
	string str;
	cin >> str;
	int ans = 0;
	for(int i = 0; i < str.length(); i++) {
		if (str[i] == '1')
			ans++;
	}
	printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define INF 1000000000000
#define MOD 1000000007
#define DEBUG(x) cerr<<'>'<<#x<<':'<<x<< endl
using namespace std;
vector <bool> visited(1000006, false);
vector <vector<ll>> adj(1000006);



signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a, b;
    cin >> a >> b;
    ll g = __gcd(a, b);
    vector <ll> factors;
    for(ll i = 1; i * i < g; i++)
    {
        if(g % i == 0)
        {
            factors.push_back(i);
            factors.push_back(g / i);
        }
    }    
    if( ((ll)sqrt(g)* (ll)sqrt(g) == g))
        factors.push_back(sqrt(g));
    
    ll siz = factors.size();
    ll ans = 1;
    for(ll i = 0; i < siz; i++)
    {
        ll cur = factors[i];
        bool prime = true;
        for(ll j = 2; j * j <= cur; j++)
        {
            if(cur % j == 0)
            {
                prime = false;
                break;
            }
        }
        if( (ll)sqrt(cur) * (ll)sqrt(cur) == cur)
            prime = false;
        ans += prime;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 23936
chomp (my ($n, $h) = split / /, readline ARGV);
my @s;
my $max_r = 0;
for (1..$n) {
  chomp (my ($r, $c) = split / /, readline ARGV);
  push @s, [$r, $c];
  $max_r = $r if $r > $max_r;
}
my @sorted = reverse sort { $a->[1] <=> $b->[1] } @s;

my $hp = $h;
my $cnt = 0;
for my $i (@sorted) {
  last if $i->[1] <= $max_r;
  $hp -= $i->[1];
  $cnt++;
  print "$cnt\n" and exit if $hp <= 0;
}

$cnt += int($hp / $max_r);
$cnt++ unless int($hp / $max_r) == $hp / $max_r;

print "$cnt\n" and exit;

Measured memory_bytes: 34300
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;


int main(){
    Long a,b;
    cin>>a>>b;
    cout<<(a*(a-1))/2+(b*(b-1))/2<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int H,W;
  cin >> H >> W;
  vector<vector<string>> S(H,vector<string>(W));
  vector<string> alphabet(26);
  alphabet = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
  rep(i,H)
  {
    rep(j,W)
    {
      cin >> S[i][j];
      if(S[i][j]=="snuke")
      {
        cout << alphabet[j] << i+1 << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
#include<bits/extc++.h>
using namespace __gnu_pbds;
using oset = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn = 1<<17, mod = 1e9 + 7, lg = 19;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vi s, t;
int n ,m;
ll dp[1<<11][1<<11], p[1<<11][1<<11];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	s.resize(n);for(auto&i:s) cin>>i;
	t.resize(m);for(auto&i:t) cin>>i;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			if(s[i]==t[j]) {
				dp[i][j] = 1;
				if(i&&j) dp[i][j] = (dp[i][j]+p[i-1][j-1])%mod;
			}
			p[i][j] = (4ll*mod + (i?p[i-1][j]:0ll)+(j?p[i][j-1]:0ll)-(i&&j?p[i-1][j-1]:0ll)+dp[i][j])%mod;
		}
	}
	cout << ++p[n-1][m-1]%mod;
	return 0;
}


Measured memory_bytes: 65792
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int a, b;
    cin >> a >> b;
    if (a <= 8 && b <= 8) cout << "Yay!\n";
    else cout << ":(\n";
}

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

    //int t; cin >> t; while (t--)
        solve();
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << endl;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

int main() {
	ll N, M;
	ll A[100005];
	vector<Pl> sorted(100005);
	ll cost = 0;
	ll num = 0;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> A[i]; --A[i];
		sorted[i] = Pl(A[i], i);
		if (i) {
			if (A[i - 1] <= A[i]) cost += A[i] - A[i - 1];
			else cost += A[i] + 1, num++;
		}
	}
	sort(rbegin(sorted), rend(sorted));

	ll minv = cost;
	//cout << " " << cost << endl;
	ll i = 0;
	ll plus = 0;

	while (i < N) {
		ll val = sorted[i].first; 
		ll cnt = 0;
		ll mae, ushiro;
		mae = ushiro = 0;

		ll d = val + plus;
		while (i < N && sorted[i].first == val) {
			ll idx = sorted[i].second;
			if (idx == 0) mae = -1;
			if (idx == N - 1) ushiro = 1;
			if (idx > 0) cost -= d - (A[idx - 1] + plus) % M;
			i++, cnt++;
		}
		cost += num * (M - d);
		cost += mae + ushiro;
		//cout << " " << cost << endl;
		num += mae + ushiro;

		plus += (M - d);
		minv = min(minv, cost);
	}

	cout << minv << endl;
	return (0);
}

Measured memory_bytes: 2560
from collections import Counter
N = int(input())
V = list(map(int,input().split()))
c1 = Counter(V[::2])
c2 = Counter(V[1::2])
n1 = N//2 + N%2
n2 = N//2

if len(c1)==1 and len(c2)==1:
    if V[0]==V[1]:
        print(n2)
    else:
        print(0)
elif len(c1)==1:
    mc = c2.most_common()
    if mc[0][0] == V[0]:
        print(n2 - mc[1][1])
    else:
        print(n2 - mc[0][1])
elif len(c2)==1:
    mc = c1.most_common()
    if mc[0][0] == V[1]:
        print(n1 - mc[1][1])
    else:
        print(n1 - mc[0][1])
else:
    mc1 = c1.most_common()
    mc2 = c2.most_common()
    if mc1[0][0] != mc2[0][0]:
        print(N - mc1[0][1] - mc2[0][1])
    else:
        ans = N
        if mc1[0][0] != mc2[1][0]:
            ans = min(ans, N - mc1[0][1] - mc2[1][1])
        if mc1[1][0] != mc2[0][0]:
            ans = min(ans, N - mc1[1][1] - mc2[0][1])
        print(ans)

Measured memory_bytes: 21184
#include <iostream>

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << #x << " = " << (x) << endl;

using namespace std;

int main(){
	int n, k, ans, a[100005];
	
	cin >> n >> k;
	REP(i,n){
		cin >> a[i];
	}
	
	ans = 0;
	while(n>1){
		n -= (k-1);
		ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const ll INF = 1e18L + 5;
const int siz = 1e5 + 5;
vector <ll> edges[siz];
vector <ll> in_degree(siz);
int dist[siz];
bool vis[siz];
void solve();

void dfs(int a)
{
	assert(!vis[a]);
	vis[a] = true;
	for(int b : edges[a])
	{
			dist[b] = max(dist[b], dist[a]+1);
			--in_degree[b];
			if(in_degree[b] == 0)
					dfs(b);
	}
	
	
}

void solve()
{
	int n, m;
	cin >> n >> m;
		while(m--)
		{
			int a, b;
			cin >> a >> b;
			edges[a].push_back(b);
			in_degree[b]++;
		}
		
		for(int i = 1; i<=n; i++){
				if(!vis[i] && in_degree[i] == 0)
					dfs(i);
		}
		int ans = 0;
		for(int i = 1; i<=n; i++)
			ans = max(ans, dist[i]);
			
		cout << ans << endl;
}

int main()
{
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		ll t = 1;
	//	cin >> t
		while(t--)
		{
			solve();
		}
	return 0;
}
	


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

public class Main {

  public static void main(String[] args) {
  
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      Card[] cards = new Card[n];
      char suit;
      int  value;

      for ( int i=0; i<n; i++ ) {
        suit = (char)br.read(); br.skip(1);
        value = Integer.parseInt(br.readLine());
        cards[i] = new Card(suit, value, i);
      }

      quickSortOfCards(cards, 0, n-1);
      dispCardArray(cards);
    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }

  public void quickSortOfCards(Card[] card, int p, int r) {

    if( p < r) {
      int q = partitionOfCards(card, p, r);
      quickSortOfCards(card, p, q-1);
      quickSortOfCards(card, q+1, r);
    }
  }

  public int partitionOfCards(Card[] card, int p, int r) {

    int x = card[r].value;
    int i = p-1;
    Card t;

    for(int j=p; j<r; j++) {
      if(card[j].value <= x) {
        t = card[++i]; card[i] = card[j]; card[j] = t;
      }
    }
    t = card[i+1]; card[i+1] = card[r]; card[r] = t;

    return i+1;
  }

public void dispCardArray(Card[] target) {
  StringBuilder s = new StringBuilder();
  int l=target.length;
  boolean isStable = true;
  String sortState = "Stable";

  s.append(target[0]).append("\n");
  for (int i=1; i<l; i++) {
    s.append(target[i]).append("\n");
    if(isStable && target[i-1].value == target[i].value 
      && target[i-1].storedNo > target[i].storedNo) {
      sortState = "Not stable";
      isStable = false;
    }
  }

  System.out.println(sortState);
  System.out.print(s);
  }
}

class Card {
  char suit;
  int value;
  int storedNo;

  public Card( char suit, int value, int storedNo ) {
    this.suit  = suit;
    this.value = value;
    this.storedNo = storedNo;
  }
  public Card( Card card ) {
    this(card.suit, card.value, card.storedNo);
  }

  @Override
  public String toString() {
    return suit + " " + String.valueOf(value);
  }
}


Measured memory_bytes: 65000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


int main() {
    int n; cin >> n;
    if(n <= 999){
        cout << "ABC";
    }else{
        cout << "ABD";
    }
}


Measured memory_bytes: 256
def main():
    S = input()
    N = len(S)
    l = [0] * N
    t = 0
    for i in range(N):
        if S[i] == 'R':
            t += 1
            if S[i+1] == 'L':
                l[i] = t
                t = 0
    t = 0
    for i in range(N-1, 0, -1):
        if S[i] == 'L':
            t += 1
            if S[i-1] == 'R':
                l[i] = t
                t = 0
    p = False
    for i in range(N-1):
        if p:
            p = False
            continue
        if l[i] != 0 and l[i+1] != 0:
            h = (l[i] + l[i+1])//2
            if (l[i] + l[i+1]) % 2 == 0:
                l[i] =  l[i+1] = h
            elif (l[i] > l[i+1] and l[i] % 2 == 0) or (l[i+1] > l[i] and l[i+1] % 2 == 1):
                l[i] = h
                l[i+1] = h + 1
            else:
                l[i] = h + 1
                l[i+1] = h
            p = True
    print(' '.join(str(i) for i in l))
main()


Measured memory_bytes: 10612
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,mx,count=0;
    cin >> n;
    vector<int> h(n, 0);
    for(int i=0;i<n;i++) cin >> h.at(i);
    mx = h.at(0);
    for(int i=0;i<n;i++){
        if(h.at(i) >= mx){
            count++;
            mx = h.at(i);
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll f = 0;
    string x = "";
    FOR(i,0,(s.size()-1)/2){
        x.push_back(s[i]);
    }
    string y = "";
    FOR(i,(s.size()+3)/2-1,s.size()){
        y.push_back(s[i]);
    }

    FOR(i,0,x.size()){
        if(x[i] != x[x.size()-1-i]) f = 1;
    }
    FOR(i,0,y.size()){
        if(y[i] != y[y.size()-1-i]) f = 1;
    }
    FOR(i,0,s.size()){
        if(s[i] != s[s.size()-1-i]) f = 1;
    }
    
    if(f == 1)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "math.h"
using namespace std;

int main (){
    string s;
    int count = 0;
    cin >> s;

    for(int i = 0;i < s.length() / 2;i++){
        if(s[i] != s[s.length() - 1 - i]){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N, M;
  map<int, vector<int>> mp;
  cin >> N >> M;
  int a, b;
  vector<int> v(N);
  int count = 1;
  for (int& x : v) {
    x = count;
    count++;
  }
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    if (mp.count(a)) {
      mp[a].push_back(b);
    } else {
      mp[a] = {b};
    }
    if (mp.count(b)) {
      mp[b].push_back(a);
    } else {
      mp[b] = {a};
    }
  }
  int path_count = 0;
  bool result;
  do {
    if (v[0] != 1) {
      break;
    }
    for (int i = 0; i < N - 1; i++) {
      vector<int> v_ = mp[v[i]];
      int next_num = v[i + 1];
      result =
          any_of(v_.begin(), v_.end(), [&](int x) { return x == next_num; });
      if (!result) {
        break;
      }
    }
    path_count += result;
  } while (next_permutation(v.begin(), v.end()));
  cout << path_count << endl;
  return 0;
}

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

using namespace std;

const int MAX_N = 100010;
bool isPrime[MAX_N];
int cumulative2017LikeNumberCount[MAX_N];

void SieveOfEratosthenes(int N) {
  fill(isPrime, isPrime + sizeof(isPrime), true);
  isPrime[0] = false;
  isPrime[1] = false;
  for (int i = 2; i < N; i++) {
    if (!isPrime[i]) {
      continue;
    }

    for (int j = 2 * i; j < N; j += i) {
      isPrime[j] = false;
    }
  }
}

bool Is2017LikeNumber(int i) {
  return isPrime[i] && isPrime[(i + 1) / 2];
}

void ComputeCumulative2017LikeNumberCount(int N) {
  memset(cumulative2017LikeNumberCount, 0, sizeof(cumulative2017LikeNumberCount));
  for (int i = 1; i < N; i++) {
    if (Is2017LikeNumber(i)) {
      cumulative2017LikeNumberCount[i] = cumulative2017LikeNumberCount[i - 1] + 1;
    } else {
      cumulative2017LikeNumberCount[i] = cumulative2017LikeNumberCount[i - 1];
    }
  }
}

int main() {
  SieveOfEratosthenes(MAX_N);
  ComputeCumulative2017LikeNumberCount(MAX_N);

  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int L, R;
    cin >> L >> R;
    printf("%d\n", cumulative2017LikeNumberCount[R] - cumulative2017LikeNumberCount[L - 1]);
  }
  return 0;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <queue>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
typedef pair<int,int> ii;
int n,m;
vector<int> al[100005];
bool parity[100005];

struct ufds{
    int p[100005];
    int r[100005];

    ufds(){
        for (int x=0;x<100005;x++){
            p[x]=x;
            r[x]=0;
        }
    }
    int parent(int i){return (p[i]==i)?i:p[i]=parent(p[i]);}
    bool unions(int i,int j){
        i=parent(i),j=parent(j);
        if (i==j) return false;
        if (r[i]<r[j]){
            p[i]=j;
        }
        else{
            p[j]=i;
            if (r[i]==r[j]) r[i]++;
        }
        return true;
    }
}*dsu=new ufds();

void dfs(int i,int p){
    for (auto &it:al[i]){
        if (it==p) continue;
        dfs(it,i);
    }
    if (p==-1) return;
    if (parity[i]) printf("%d %d\n",i,p);
    else printf("%d %d\n",p,i), parity[p]^=true;
}

int main(){
    scanf("%d%d",&n,&m);
    if (m&1){
        printf("-1\n");
        return 0;
    }
    int a,b;
    while (m--){
        scanf("%d%d",&a,&b);
        if (dsu->unions(a,b)){
            al[a].push_back(b);
            al[b].push_back(a);
        }
        else{
            parity[a]^=true;
            printf("%d %d\n",a,b);
        }
    }
    
    dfs(1,-1);
}

Measured memory_bytes: 11776
// https://atcoder.jp/contests/abc118/tasks/abc118_c

// http://ctylim.hatenablog.com/entry/2015/08/30/191553
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>

#define ALL(a) (a).begin(), (a).end()
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define MAXINDEX(c) distance((c).begin(), max_element((c).begin(), (c).end()))
#define MININDEX(c) distance((c).begin(), min_element((c).begin(), (c).end()))
#define DEBUG(x) std::cerr << #x << " = " << (x) << " (" << __FILE__ << "::" << __LINE__ << ")" << std::endl;
#define ERROR(s) std::cerr << "Error::" << __FILE__ << "::" << __LINE__ << "::" << __FUNCTION__ << "::" << (s) << std::endl;
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)

#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

template <typename T>
T inputValue()
{
  T a;
  std::cin >> a;
  // scanf("%d", &a);
  return a;
}

void inputArray(int *p, int a)
{
  rep(i, a)
  {
    std::cin >> p[i];
    // scanf("%d",p+i);
  }
}

template <typename T>
void inputVector(std::vector<T> *p, int a)
{
  rep(i, a)
  {
    T input;
    // std::cin >> input;
    scanf("%llu", &input);
    p->push_back(input);
  }
}

template <typename T>
void output(T a, int precision)
{
  if (precision > 0)
  {
    std::cout << std::setprecision(precision) << a << "\n";
  }
  else
  {
    std::cout << a << "\n";
  }
}

using namespace std;

int gcd(int a, int b)
{
  while (1)
  {
    if (a < b)
      swap(a, b);
    if (!b)
      break;
    a %= b;
  }
  return a;
}

typedef unsigned long long int ulli;
int main(int argc, char **argv)
{

  ulli N = inputValue<ulli>();
  ulli K = inputValue<ulli>();
  vector<ulli> v;
  inputVector<ulli>(&v, N);


  vector<ulli> bitSum(64,0);

  EACH(k, v)
  {
    ulli t = *k;
    for(int i=0; i<64&&t!=0; i++){
      bitSum[i] = bitSum[i] + (t&1) ;
      t = t >> 1;
    }
  }

  // ulli d = 0;

  int flag = 0;

  ulli sum0 = 0;
  for (int i = 63; i >= 0; i--)
  {

    ulli K_bit = (K >> i) & 1ll;
    ulli A_bit = (bitSum[i] > N / 2 ? 0 : 1);
    ulli D_bit = A_bit;
    if (!flag)
    {
      D_bit = K_bit && A_bit;
      flag = K_bit && (!A_bit);
    } 
    // K: kkkkkk1kkkkk 
    // A: aaaaaa0aaaaa
    // D: dddddddddddd
    // 1-0のパターンの左は D=K&A
    // 右は D=A

    if (!D_bit)
    {
      sum0 = sum0 + (bitSum[i] << i);
    }else{
      sum0 = sum0 + ((N-bitSum[i]) << i);
    }
  }
  cout << sum0 << endl;

}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define ll long long  int
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
void solve()
{
       ll n;
       cin>>n;
      ll arr[n][3],i;
      ll dp[n][3];
      for(i=0;i<n;i++)
      	cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
        dp[0][0]=arr[0][0];
        dp[0][1]=arr[0][1];
        dp[0][2]=arr[0][2];
        for(i=1;i<n;i++)
        {
        	dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
        	dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
        	dp[i][2]=arr[i][2]+max(dp[i-1][1],dp[i-1][0]);
        }
        cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}
int main()
{
    fast();
    {
      solve();
    }
    return 0;
}


Measured memory_bytes: 8304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=4000+7;
char s[N];
ll numR[N];
ll numG[N];
ll numB[N];
ll n;
ll cal(ll start,char x,char y){
	ll sum=0;
	for(ll i=start+1;i<=n;i++){
		if(s[i]==x){
			if(y=='R') sum+=numR[i];
			else if(y=='B') sum+=numB[i];
			else sum+=numG[i];
			if(i+i-start<=n&&s[i-start+i]==y) sum--;
		}
	}
	return sum;
}
int main(){
	cin>>n;
	scanf("%s",s+1);
	for(ll i=n;i>=1;i--) {
		if(s[i]=='R') numR[i]=1;
		else if(s[i]=='G') numG[i]=1;
		else numB[i]=1;
	}
	for(ll i=n;i>=1;i--){
		numR[i]+=numR[i+1];
		numB[i]+=numB[i+1];
		numG[i]+=numG[i+1];
	}
	ll ans=0; 
	for(ll i=1;i<=n;i++){
		if(s[i]=='R'){
			ans+=cal(i,'G','B');
			ans+=cal(i,'B','G');
		}
		else if(s[i]=='B'){
			ans+=cal(i,'R','G');
			ans+=cal(i,'G','R'); 
		}
		else {
			ans+=cal(i,'R','B');
			ans+=cal(i,'B','R');
		}
//		cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

ll f(ll n)
{
    ll r=n%4;
    if(n<0) return 0;
    if(r==0) return n;
    else if(r==1) return 1;
    else if(r==2) return n+1;
    return 0;
}

int main(void)
{
    
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(all(a));
    cout<<a[n-1]-a[0]<<endl;
    return 0;
}

Measured memory_bytes: 3632
def abc():
    w, h, n = map(int, input().split())
    field = [[1] * w] * h
    for i in range(n):
        x, y, a = map(int, input().split())
        if a == 1:
            for f in field:
                f[:x] = [0] * x
        if a == 2:
            for f in field:
                f[x:] = [0] * (w - x)
        if a == 3:
            for j in range(y):
                field[j] = [0] * w
        if a == 4:
            for j in range(y, h):
                field[j] = [0] * w
    ans = 0
    for f in field:
        ans += sum(f)
    print(ans)


abc()


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int c = 0;
    while(c == 0){
      int a = sc.nextInt();
      String op = sc.next();
      int b = sc.nextInt();
      if (op.equals("+")){
        System.out.println(a + b);
      }else if (op.equals("-")){
        System.out.println(a - b);
      }else if (op.equals("*")){
        System.out.println(a * b);
      }else if (op.equals("/")){
        System.out.println(a / b);
      }else if (op.equals("?")){
        c++;
      }else{
        System.out.println("Error.");
      }
    }
  }
}



Measured memory_bytes: 26172
N, M = map(int, input().split())
a = [-1] + [int(input()) for i in range(M)] + [N+1]

da = max([a[i+1] - a[i] for i in range(len(a)-1)])
b = [0 for i in range(da+1)]
b[0] = 1
b[1] = 1
for i in range(2, da + 1):
    b[i] = b[i-1] + b[i-2]

ans = 1
MOD = 1000000007
for j in range(1, M+2):
    index = a[j] - a[j-1] - 2
    if index == -1:
        ans = 0
        break
    ans = ans * b[index]
    ans = ans % MOD
print(ans)

Measured memory_bytes: 460056
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int n; cin >> n;

  for (int i = 0; i < (1<<n); ++i) {
    cout << i << ':';
    bitset<20> bit(i);
    for (int j = 0; j < 20; ++j) {
      if (bit.test(j)) {
        cout << " " << j;
      }
    }
    cout << '\n';
  }

  return 0;
}


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

int main() {
    int h, w;
    cin >> h >> w;
    char s[2020][2020];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> s[i][j];
        }
    }

    int L[2020][2020]; //left
    int R[2020][2020]; //right
    int U[2020][2020]; //up
    int D[2020][2020]; //down

    //左から右の照らす個数
    int cnt = 0;
    for (int i = 0; i < h; i++) {
        cnt = 0;
        for (int j = w - 1; j >= 0; j--) {
            if (s[i][j] == '#') {
                cnt = 0;
                R[i][j] = cnt;
            }
            else {
                cnt++;
                R[i][j] = cnt;
            }
        }

        cnt = 0;
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') {
                cnt = 0;
                L[i][j] = cnt;
            }
            else {
                cnt++;
                L[i][j] = cnt;
            }
        }
    }

    //上から下の照らす個数
    for (int j = 0; j < w; j++) {
        cnt = 0;
        for (int i = h - 1; i >= 0; i--) {
            if (s[i][j] == '#') {
                cnt = 0;
                D[i][j] = cnt;
            }
            else {
                cnt++;
                D[i][j] = cnt;
            }
        }

        cnt = 0;
        for (int i = 0; i < h; i++) {
            if (s[i][j] == '#') {
                cnt = 0;
                U[i][j] = cnt;
            }
            else {
                cnt++;
                U[i][j] = cnt;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') continue;
            ans = max(ans, R[i][j] + L[i][j] + U[i][j] + D[i][j] - 3);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 67840
#include<cstdio>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    int val=100000;
    while(n--){
        val=val/100*105;
        if(val%1000){
            val=val/1000*1000;
            val+=1000;
        }
    }
    printf("%d\n",val);

    return 0;
}

Measured memory_bytes: 1020
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
double EPS=1e-10;
double EQ(double a,double b){
    return abs(a-b)<EPS;
}
void fast_stream(){
  std::ios_base::sync_with_stdio(0);
}
template<class T>
string IntToString(T num){
  string res;stringstream ss;ss<<num;
  return ss.str();
}
ll StringToInt(string &str){
  ll res=0;
  for(int i=0;i<(int)str.size();i++)
    res=(res*10+str[i]-'0');
  return res;
}

const ll P=1000000007;
const ll N=1000010;

ll p[N],aa[N];
// rolling hashを計算
void calcRollingHash(string s){
  int n=s.size();
  p[0]=1;
  // P**iを計算
  for(int i=1;i<n+5;i++)p[i]=p[i-1]*P;
  aa[0]=0;
  // hash値を計算
  for(int i=1;i<=n;i++)aa[i]=aa[i-1]*P+s[i-1];
}
// 文字列の先頭位置を終端位置を指定し、ハッシュ値を取り出す
inline ll hh(int x,int y){
  return aa[y+1]-aa[x]*p[y-x+1];
}

int l,r;
set<ll> hash;
int main(){
  l=r=1;
  int N,M;
  cin>>N>>M;
  string str;
  cin>>str;
  string s;
  calcRollingHash(str);
  for(int i=0;i<M;i++){
    cin>>s;
    if(s=="L++")l++;
    else if(s=="L--")l--;
    else if(s=="R++")r++;
    else if(s=="R--")r--;
    hash.insert(hh(l-1,r-1));
  }
  cout<<hash.size()<<endl;
  
  return 0;
}

Measured memory_bytes: 23496
N = int(input())
A, B = [int(_) for _ in input().split()]
P = [int(_) for _ in input().split()]

P.sort()

a = 0
b = 0
c = 0
for pi in P:
    if pi <= A:
        a += 1
    if A < pi <= B:
        b += 1
    if B < pi:
        c += 1

print(min(a, b, c))

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
//const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================

	ll N, K;
	cin >> N >> K;
	vll H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}

	sort(H.begin(), H.end(), greater<ll>());
	ll ans = 0;
	for (int i = K; i < N; i++) {
		ans += H[i];
	}

	cout << ans;

}


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while(1) {
		int N, M, num = 0;
		int x = 10, y = 10;	//ロボットの現在座標
		int jewels[21][21];	//宝石の座標

		cin >> N;	//宝石の個数を取得する

		if( N == 0 ) break;	//終了処理

		//配列変数の初期化
		for(int i = 0; i < 21; i++)
			for(int j = 0; j < 21; j++)
				jewels[i][j] = 0;

		//宝石の座標を取得する
		for(int i = 0; i < N; i++) {
			int _x, _y;
			cin >> _x >> _y;
			jewels[_x][_y] ++;
		}

		cin >> M;	//命令の数を取得する
		for(int i = 0; i < M; i++) {
			int vx = 0, vy = 0;
			char d_j;
			int l_j;
			cin >> d_j >> l_j;

			//移動方向による場合分け
			switch(d_j) {
				case 'N':
					vy = 1;
					break;
				case 'E':
					vx = 1;
					break;
				case 'S':
					vy = -1;
					break;
				case 'W':
					vx = -1;
					break;
			}

			
			//移動を行う
			for(int j = 0; j < l_j; j ++) {
				x += vx;
				y += vy;
				if(jewels[x][y] > 0) {
					num ++;
					jewels[x][y] = 0;
				}
			}

		}

		if(num == N) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}

	}

	//while(1){}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    string st;
    cin>>st;
    for(int i=0;i<st.size();i+=2){
        cout<<st[i];
    }cout<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define w(e) int e ; cin >> e ; while (e--)  
#define ll long long 
#define endl "\n"
#define mod  10000000007
#define pi 3.141592653589793
#define setbit(x) __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)  
/*
*/
int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n ; cin >> n;
    string s ; cin >> s ;
    if (s.length() > n)
    {
        for (int i=0 ;i< n ;i++)
        {
            cout << s[i] ;
        }
        cout << "..." << endl;
    }
    else 
        cout << s << endl;
	return  0;
}

Measured memory_bytes: 3648