akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <set>

#pragma GCC optimize(2)

#define ll long long
#define ull unsigned long long

#define gc (c = getchar())
#define gi(x) scanf("%d", &x)
#define gid(x, y) scanf("%d%d", &x, &y)
#define gll(x) scanf("%lld", &x)
#define glld(x, y) scanf("%lld%lld", &x, &y)

#define pi(x) printf("%d\n", x)
#define pr(x) return !(printf("%lld\n", (long long)(x)))
#define pcs(ch, cs, x) printf("Case %s%d: %d\n", ch, cs, x)
#define pllcs(ch, cs, x) printf("Case %s%d: %lld\n", ch, cs, x)
#define pyncs(cs, st) printf("Case %s%d: %s\n", ch, cs, (st) ? "YES" : "NO")
#define pyn(st) printf("%s\n", (st) ? "yes" : "no")
#define pryn(st) return !(printf("%s\n", (st) ? "YES" : "NO"))
#define pll(x) printf("%lld\n", x)

#define dbg(x) std::cerr << #x << " " << x << std::endl
#define fi(x) freopen("in.txt", "r", stdin)
#define fo(x) freopen("out.txt", "w", stdout)

inline ll abs(ll x) { return x > 0 ? x : -x; }
inline ll max(ll x, ll y) { return x > y ? x : y; }
inline ll min(ll x, ll y) { return x > y ? y : x; }
inline ll gcd(ll x, ll y) { return y == 0 ? x : gcd(y, x % y); }

const int lm = -1000000;
const int rm = 1000000;
int main(){
    int k,x;
    gid(k,x);
    for(int i = max(lm,x - k + 1); i <= min(rm,x + k - 1); ++ i){
        std::cout << i << " ";
    }
    std::cout << std::endl;
}

Measured memory_bytes: 256
use proconio::input;
fn main() {
    input!{
        mut s: String,
        t: String
    }
    if let Some((l, _)) = s[..s.len()-t.len()+1]
        .chars().enumerate()
        .filter(|&(i, _)| t.chars()
            .zip(s[i..i+t.len()].chars())
            .filter(|&(y, z)| z=='?' || y == z )
            .count() == t.len())
        .last()
    {   
        println!("{}{}{}", 
        s[..l].replace('?', "a"), t, s[l+t.len()..].replace('?', "a"));
    }
    else{
        println!("UNRESTORABLE");
    }
    
}





Measured memory_bytes: 2112
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := makeScanner(16384)
	n := eGetInt(scanner)
	s := eGetLine(scanner)
	rs := make([]byte, len(s))
	alpha := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	for i, c := range s {
		order := c - 'A'
		slide := (int(order) + n) % 26
		rs[i] = alpha[slide]
	}
	fmt.Println(string(rs))
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fore(i,j,k) for(unsigned int i=j;i<k;i++)
#define mm(a,b) memset(a,b,sizeof(a))
#define SZ(n) ((int) (n).size())
#define ALL(s) s.begin(),s.end()
#define bs binary_search
#define mp make_pair
#define pb push_back
#define snd second
#define fst first
typedef long double ld;
typedef long long ll;
using namespace std;
const ll M = 1e9+7;
const ll INF = 1e16;
const ll MAXN = 1000000000;

int main(){
	FIN;
	string s;
	cin>>s;
	ll black = 0;
	ll res=0;
	fore(i,0,s.size()){
		if (s[i] == 'B') black+=1;
		else res+=black;
	}
	cout<< res;
	return 0;
}

Measured memory_bytes: 720
import java.util.*;
// cin=sc.nextInt();
// List<Integer> a = new ArrayList<Integer>(n);
 
public class Main {
    public static void main(String args[]) throws InterruptedException {
		    Scanner sc = new Scanner(System.in);	
			int a = sc.nextInt();
            if(a==1){
                System.out.println("Hello World");
            }
            else{
                int b = sc.nextInt();
                int c = sc.nextInt();
                System.out.println(b+c);
            }
	}
}

Measured memory_bytes: 23252
/*Let's start*/
//It's fun time..........................
#define  ll               long long
#define  pb               push_back
#define  ff               first
#define  ss               second
#define  srt(v)           sort(v.begin(),v.end())
#define  inf              1000000000
#define  mxn              1009
#define  pi               acos(-1)
#define  MOD              1000000007
#define  ordered_set      sum<ll, null_type,less<ll>, rb_sum_tag,sum_order_statistics_node_update>
#define  db(x)            printf("### VALUE: (%lld) ###\n",(ll)x)
#include <bits/stdc++.h>
using namespace std;

char arr[mxn][mxn];
ll n,m;
ll dp[mxn][mxn];
ll solve(ll i,ll j)
{
    if(i == n && j == m) return 1;
    if(i > n || j > m) return 0;
    if(dp[i][j] != -1) return dp[i][j];
    ll ret1 = 0;
    ll ret2 = 0;
    if(arr[i][j] == '#') return 0;
    ret1 = solve(i+1,j);
    ret2 = solve(i,j+1);
    return dp[i][j] =  (ret1%MOD + ret2%MOD) % MOD;
}

int main()
{
    memset(dp,-1,sizeof dp);
    cin >> n >> m;
    for(ll i = 1;i <= n;i++){
        string s;cin >> s;
        for(int j  = 0;j < s.size();j++){
            arr[i][j+1] = s[j];
        }
    }
    cout << solve(1,1) << endl;
    return 0;
}
/*
".....but the truth is that you can increase it slightly."
Day 14.

5
abdcced
bdacdac
ecb
dc
eaeeebdd

*/


Measured memory_bytes: 9216
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int dy[] = {-2, -2, -2, -1, 0, 1, 2, 2, 2, 1, 0, -1};
    int dx[] = {-1, 0, 1, 2, 2, 2, 1, 0, -1, -2, -2, -2};

    for(;;){
        int sy, sx, n;
        cin >> sx >> sy >> n;
        if(sx == 0)
            return 0;

        vector<int> py(n), px(n);
        for(int i=0; i<n; ++i)
            cin >> px[i] >> py[i];

        queue<pair<int, int> > q;
        q.push(make_pair(sy, sx));
        for(int i=0; i<n; ++i){
            vector<vector<bool> > check(10, vector<bool>(10, false));
            int m = q.size();
            while(--m >= 0){
                int y0 = q.front().first;
                int x0 = q.front().second;
                q.pop();
                for(int j=0; j<12; ++j){
                    int y = y0 + dy[j];
                    int x = x0 + dx[j];
                    if(0 <= y && y < 10 && 0 <= x && x < 10 && !check[y][x] && abs(y-py[i%n]) <= 1 && abs(x-px[i%n]) <= 1){
                        q.push(make_pair(y, x));
                        check[y][x] = true;
                    }
                }
            }
        }

        if(!q.empty())
            cout << "OK" << endl;
        else
            cout << "NA" << endl;
    }
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
import queue
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, C):
    mod = 10**9 + 7
    if N == 1:
        return (C[0] * 2) % mod

    C.sort()
    ans = 0
    a = pow(2, N, mod)
    b = pow(2, N-1, mod)
    c = pow(2, N-2, mod)
    for i in range(N):
        d = (N-i-1) * c
        d %= mod
        n = a * (b + d)
        n %= mod
        ans += n * C[i]
        ans %= mod

    return ans % mod




def main():
    N = read_int()
    C = read_int_n()
    print(slv(N, C))


if __name__ == '__main__':
    main()


Measured memory_bytes: 79048
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	k := intScanner()
	as := make([]int, n)
	for i := 0; i < n; i++ {
		as[i] = intScanner()
	}
	ans := mod * mod
	for bit := 1; bit < (1 << uint(n)); bit += 2 {
		mx := as[0]
		x := 1
		cost := 0
		for i := 1; i < n; i++ {
			if (bit>>uint(i))&1 == 1 {
				if as[i] <= mx {
					cost += mx + 1 - as[i]
					mx = mx + 1
				} else {
					mx = as[i]
				}
				x++
			} else {
				if as[i] > mx {
					mx = as[i]
					x++
				}
			}
		}
		if x >= k {
			ans = smaller(ans, cost)
		}
	}
	fmt.Println(ans)
}
func smaller(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}


Measured memory_bytes: 1756
def mayCorrect(line)
  words = line.split()
  if words.include?("the") || words.include?("this") || words.include?("that")
    return true
  else
    return false
  end
end

def shiftLine(line, n)
  alphabet = ('a'..'z').to_a.join
  i = n % alphabet.size
  encript = alphabet[i..-1] + alphabet[0...i]
  return line.tr(alphabet, encript)
end

while line = gets
  correct_line = line
  i = 1
  while true
    if mayCorrect(correct_line)
      break
    end
    correct_line = shiftLine(line, i)
    i += 1
  end
  puts correct_line
end

Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> N >> K;
    vi arr(N);
    for (int i = 0; i < N; i++) cin >> arr.at(i);

    sort(all(arr));

    rep(i,K)
    {
        A += arr[i];
    }
    cout << A;
    
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <algorithm>

int const MAXN = 1e5 + 7;
int a[MAXN], b[MAXN][2], max[2], smax[2], maxv[2], smaxv[2];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) b[a[i]][i % 2]++;
    int cnt1 = (n + 1) / 2, cnt2 = n / 2;
    for (int i = 0; i <= 1; i++) 
        for (int j = 1; j <= MAXN; j++) 
            if (b[j][i] >= max[i]) smaxv[i] = maxv[i], smax[i] = max[i], max[i] = b[j][i], maxv[i] = j;
                else if (b[j][i] >= smax[i]) smaxv[i] = j, smax[i] = b[j][i];
    int ans = 0;
    if (maxv[0] == maxv[1]) ans = std::min(cnt1 - max[0] + cnt2 - smax[1], cnt1 - smax[0] + cnt2 - max[1]);
    else ans = cnt1 - max[0] + cnt2 - max[1];
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
  string s,t;
  cin >> s >> t;
  vector<int> start(26,-1);
  vector<int> goal(26,-1);
  
  rep(i,s.size()){
    int a = s[i] - 'a';
    int b = t[i] - 'a';
    
    if(start[a] != -1 || goal[b] != -1){
      if(start[a] != b || goal[b] != a){
        cout << "No" << endl;
        return 0;
      }
    }
    else{
      start[a] = b;
      goal[b] = a;
    }
  }
  
  cout << "Yes" << endl;
  
  return 0;
}

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

class Progaram
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();
        var ans = 0;
        if (s == "SUN") ans = 7;
        else if (s == "MON") ans = 6;
        else if (s == "TUE") ans = 5;
        else if (s == "WED") ans = 4;
        else if (s == "THU") ans = 3;
        else if (s == "FRI") ans = 2;
        else  ans = 1;
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
#include<iostream>
using namespace std;
#define MAX 500000
#define banhei 2000000000

int L[MAX/2+2];
int R[MAX/2+2];
int count;

void merge(int A[],int n,int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	for(int i=0;i<n1;i++)L[i]=A[left+i];
	for(int i=0;i<n2;i++)R[i]=A[mid+i];
	L[n1]=R[n2]=banhei;
	int i=0;
	int j=0;
	for(int k=left;k<right;k++){
		count++;
		if(L[i]<=R[j]){
			A[k]=L[i++];
		}else{
			A[k]=R[j++];
		}
	}
}

void mergesort(int A[],int n,int left,int right){
	if(left+1<right){
		int mid=(left+right)/2;
	mergesort(A,n,left,mid);
	mergesort(A,n,mid,right);
	merge(A,n,left,mid,right);
	}
}

int main(){
	int A[MAX],n,i;
	count=0;

	cin>>n;
	for(i=0;i<n;i++)cin>>A[i];

	mergesort(A,n,0,n);
	
	for(i=0;i<n;i++){
		if(i)cout<<" ";
		cout<<A[i];
	}
	cout<<endl<<count<<endl;

	return 0;
}


Measured memory_bytes: 7040
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let S = rl().chars().collect::<Vec<_>>();

    let mut W = vec![0; N + 1];
    let mut B = vec![0; N + 1];

    for i in 0..N {
        W[i + 1] = W[i];
        B[i + 1] = B[i];

        if S[i] == '.' {
            W[i + 1] += 1
        } else {
            B[i + 1] += 1
        }
    }

    let mut min_score = N;
    for i in 0..N + 1 {
        let score = B[i] + (W[N] - W[i]);
        min_score = min(min_score, score);
    }

    println!("{}", min_score)
}


Measured memory_bytes: 8444
//By Koios1143
#include<bits/stdc++.h>
#define LL long long
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pii pair<int,int>
using namespace std;
const int MaxN = 105,MaxV = 100005;
int n,w,cost[MaxN],value[MaxN];
long long dp[MaxV];
int main(){
	IOS
	while(cin>>n>>w){
		int tot_value=0;
		for(int i=0 ; i<n ; i++){
			cin>>cost[i]>>value[i];
			tot_value+=value[i];
		}
		for(int i=1 ; i<=tot_value ; i++){
			dp[i] = INT_MAX;
		}
		for(int i=0 ; i<n ; i++){
			for(int j=tot_value ; j>=value[i] ; j--){
				dp[j]=min(dp[j], dp[j-value[i]]+cost[i]);
			}
		}
		int ans=0;
		for(int i=tot_value ; i>0 ; i--){
			if(dp[i]<=w){
				ans=i;
				break;
			}
		}
		cout<<ans<<"\n";
	}
	return 0;
}


Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    int a, b;
    vector<pii> v(N);
    for (int i = 0; i < N; i++) {
        cin >> a >> b;
        v[i] = pii(b, a);
    }
    sort(v.begin(), v.end());
    int sum = 0;
    for (int i = 0; i < N; i++) {
        sum += v[i].second;
        if (sum > v[i].first) {
            cout << "No" << '\n';
            return 0;
        }
    }
    cout << "Yes" << '\n';
}


Measured memory_bytes: 1792
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))
ans = [[0] * W for i in range(H)]
pre = 0
cur = 1
for i in range(H):
    if i % 2 == 0:
        cnt = 0
        while cnt < W:
            if a[cur - 1] == 0:
                cur += 1
            ans[i][cnt] = cur
            a[cur - 1] -= 1
            cnt += 1
        #print(ans)
    else:
        cnt = W - 1
        while cnt >= 0:
            if a[cur - 1] == 0:
                cur += 1
            ans[i][cnt] = cur
            a[cur - 1] -= 1
            cnt -= 1
        #print(ans)
for i in range(H):
    print(*ans[i])


Measured memory_bytes: 3912
x,k,d = map(int,input().split())

x = abs(x)
a = x // d
b = k - a

if b < 0:
    s = abs(x - k * d)
else:
    if b % 2 == 0:
        s = abs(x - a * d)
    else:
        s = abs(x - (a+1) * d)

print(s)


Measured memory_bytes: 9172
N,A = map(int, input().split())
alist = list(map(int, input().split()))

blist = list(map(lambda x:x-A,alist))
sum_plus = 0
sum_minus = 0
for i in blist:
    if i >0:
        sum_plus +=i
    else:
        sum_minus +=i

N=len(alist)
dp = [[0 for i in range(sum_plus - sum_minus + 1)] for j in range(N+1)]
dp[0][0-sum_minus]=1

for i in range(N):
    for j in range(sum_plus - sum_minus+1):
        if j-blist[i] <= (sum_plus - sum_minus):
            dp[i+1][j]=dp[i][j-blist[i]]+dp[i][j]
        else:
            dp[i+1][j]=dp[i][j]

print(dp[N][0-sum_minus]-1)

Measured memory_bytes: 4084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();
		int D = scan.nextInt();
		if(A * B > C * D) {
			System.out.println(A * B);
		} else {
			System.out.println(C * D);
		}
		scan.close();

	}

}


Measured memory_bytes: 21844
s = input()
n = len(s)
flg = True
for i in range(n):
  if i % 2 == 0 and s[i] == 'L':
    flg = False
    break
  elif i % 2 == 1 and s[i] == 'R':
    flg = False
    break

if flg:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9092
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
	int n;
	cin >> n;
	vector<pair<string, int> > v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i].first >> v[i].second;
	}
	string x;
	cin >> x;
	int ans = 0;
	bool ok = false;
	for (int i = 0; i < n; ++i) {
		if (ok) ans += v[i].second;
		if (x == v[i].first) ok = true;
	}
	cout << ans;
	return 0;
}

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

namespace ConsoleApplication21
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = 0;
            for (int c = 1; c < a + 1; c++)
                b += c;
            Console.WriteLine(b);
        }
    }
}


Measured memory_bytes: 2648
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel

signed main()
{
    fasterthanlight;
    int n; cin >> n; int k;
    cin >> k;
    int arr[n]; for (int i = 0; i < n; i++)cin >> arr[i]; sort(arr, arr + n);
    //string s;cin>>s;
    int sum = 0;
    for (int i = 0; i < k; i++)
        sum += arr[i];
    cout << sum << endl;

    //cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
    return 0;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  vector<int> xx(x); // 元の配列を保持
  sort(x.begin(), x.end());
  // 中央値候補2つ
  int med1 = x[x.size() / 2 - 1];
  int med2 = x[x.size() / 2];

  rep(i, n) {
    int res;
    if (xx[i] <= med1) {
      res = med2;
    } else {
      res = med1;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    int a, b, h;
    cin >> a  >> b >> h;
    cout << (a+b)*h/2 << endl;
    return 0;
}

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

int main(){
    char org[200000];
    char str[200000];
    long i,j,n,k,len,nflag=0;

    scanf("%s",org);
    len=strlen(org);
    str[0]=org[0];
    str[1]=0;
    k=1;

    for(i=1;i<len;i+=n){
        n=1;
        if(nflag==0){
        for(j=0;j<256;j++){
            if(i+j>=len){
                break;
                }
            if(org[j+i]==str[j]){
               n++;
               nflag++;
               str[j]=org[j+i];
            }else{
                k++;
                str[j]=org[j+i];
                break;
            }
        }
        }else{
            k++;
            str[0]=org[i];
            nflag=0;
        }
        
        str[n]=0;
    }


    printf("%ld\n",k);
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#define INF (1 << 25)
int field[100][100], pict[50][50], n, m, ansx, ansy;

int mach(int x, int y, int k){
  int firstx = -1, firsty = -1, match = 1, i, j;

  for(i = 0;i < m && match;i++){
    for(j = 0;j < m && match;j++){
      if(k == 0 && pict[i][j] == -1)continue;
      if(k == 1 && pict[j][m - i - 1] == -1)continue;
      if(k == 2 && pict[m - j - 1][i] == -1)continue;
      if(k == 3 && pict[m - i - 1][m - j - 1] == -1)continue;
      if(firstx == -1){
	firstx = i + x;
	firsty = j + y;
      }
      if(k == 0 && field[x + i][y + j] != pict[i][j])
	match = 0;
      if(k == 1 && field[x + i][y + j] != pict[j][m - i - 1])
	match = 0;
      if(k == 2 && field[x + i][y + j] != pict[m - j - 1][i])
	match = 0;
      if(k == 3 && field[x + i][y + j] != pict[m - i - 1][m - j - 1])
	match = 0;
    } 
  }  
  if(match)
    if(ansx > firstx + 1){
      ansx = firstx + 1;
      ansy = firsty + 1;
    }
    else if(ansx == firstx + 1 && ansy > firsty + 1){
      ansx = firstx + 1;
      ansy = firsty + 1;
    }

  return match;
}

int main(){
  int i, j, k;
  while(1){
    scanf("%d%d", &n, &m);
    if(n == 0 && m == 0)return 0;
    ansx = ansy = INF;
    for(i = 0;i < n;i++)
      for(j = 0;j < n;j++)
	scanf("%d", &field[i][j]);
    
    for(i = 0;i < m;i++)
      for(j = 0;j < m;j++)
	scanf("%d", &pict[i][j]);

    for(i = 0;i + m - 1 < n;i++){
      for(j = 0;j + m - 1 < n;j++){
	for(k = 0;k < 4;k++){
	  mach(i, j, k);
	}
      }
    }
    if(ansx == INF)
      puts("NA");
    else
      printf("%d %d\n", ansy, ansx);
  }
}

Measured memory_bytes: 660
#include <stdio.h>          // putchar(), getchar()
#include <ctype.h>          // islower(), tolower(), toupper()
#include <stdbool.h>

int
main(int argc, char** argv)
{
	int oc;

	while (true)
	{
		const int c = getc(stdin);
		if (c == EOF)
			break;

		if (islower(c))
			oc = toupper(c);
		else
			oc = tolower(c);

		putchar(oc);
	}

	return 0;
}

Measured memory_bytes: 524
#include<iostream>
//#include<bits/stdc++.h>
#include<string>
#include<climits>
#include<queue>
#include<stack>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include <algorithm>
#include<utility>
using namespace std;
#define IOS ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; cout.tie(NULL);
#define int long long

#define pi pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007 

#define N 100000
int32_t main()
{
	    IOS;
 
	    string s,t;

	    cin>>s>>t;

	    int n = s.length();
	    int m = t.length();

	    int dp[n+1][m+1];


	    for(int i=0; i<=n ; i++)
	    {
	    	for(int j=0; j<=m ; j++)
	    	{
	    		if(i==0 || j==0)
	    			dp[i][j]=0;
	    		else if(s[i-1]==t[j-1])
	    		{
	    			dp[i][j]= 1+ dp[i-1][j-1];
	    		}
	    		else 
	    		{
	    			dp[i][j]= max(dp[i-1][j],dp[i][j-1]);
	    		}
	    	}
	    }

	  
	    string out = "";
    int i = s.size(), j = t.size();
    while(i != 0 and j != 0){
        if(s[i-1] == t[j-1])out.push_back(s[i-1]), i--, j--;
        else if(dp[i-1][j] > dp[i][j-1])i--;
        else j--;
    }
    reverse(out.begin(), out.end());
    cout << out;
 
	return 0;
}


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

using namespace std;
typedef long long ll;
#define mp make_pair

int main() {
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);	
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	if (H % h != 0) {
		cout << "Yes\n";
	   	int r = H % h;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (i % h < r)
					cout << 5 * H << " ";
				else if (i % h == r)
					cout << -5 * H * r - 1 << " ";
				else
					cout << "0 ";
			}
			cout << "\n";
		}
		return 0;
	}
	if (W % w != 0) {
		cout << "Yes\n";
		int r = W % w;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (j % w < r) 
					cout << 5 * W << " ";
				else if (j % w == r)
					cout << -5 * W * r - 1 << " ";
				else
					cout << "0 ";
			}
			cout << "\n";
		}
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1664
N = list(input())
A = int(N[0])
B = int(N[1])
C = int(N[2])
D = int(N[3])
def op(x):
    if x == 0:
        return '+'
    if x ==1:
        return '-'

for i in range(2):
    for j in range(2):
        for k in range(2):
            if A+B*(-1)**i+C*(-1)**j+D*(-1)**k == 7:
                print(str(A)+op(i)+str(B)+op(j)+str(C)+op(k)+str(D)+'=7')
                exit()


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long  LLINF = 1e18;

using namespace std;


/*==================================================*/

/*==================================================*/

string S;

int main(){

  cin>>S;
  cout<<S[0]<<S.size()-2<<S[S.size()-1]<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
 
int main(int argc, const char * argv[]) {
 
  ll N, K; cin >> N >> K;
 
  ll k;
  if (K%2 == 0)
    k = K/2;
  else
    k = K;
  
  ll a, count=0;
  for (ll i=1; i*k<=N; i++){
    a = i*k;
    count += ((N+a)/K - a/K)*((N+a)/K - a/K);
  }
  
  cout << count << endl;
  return 0;
}

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

class Main {
   public static void main(String args[]) {
      int x=0 ,y=0;
      int sum = 0;
      String s;
      Scanner scanner = new Scanner(System.in);
      x = scanner.nextInt();
      y = scanner.nextInt();
      s = scanner.next();
      scanner.close();

      String s1 = null;
      if (y-1>-1) {
         s1 = s.substring(0,y-1);
      }
      char s4 = s.charAt(y-1);
      String s3 = null;
      if (y<s.length()) {
         s3 = s.substring(y,s.length());
      }
      String s2 = String.valueOf(s4);
      s2 = s2.toLowerCase();
      if (s1 != null && s3 != null) {
         System.out.println(s1 + s2 + s3);
      } else if (s1 != null) {
         System.out.println(s1 + s2);
      } else if (s3 != null) {
         System.out.println(s2 + s3);
      } else{
         System.out.println(s2);
      }
   }
}


Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

int main()
{
	int w,h;
	cin>>w>>h;
	string s[105];
	for(int i=0;i<w;i++)
	{
		cin>>s[i];
	}
	for(int i=0;i<w;i++)
	{
		cout<<s[i]<<endl;
		cout<<s[i]<<endl;
	}
	return 0;
}
 

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

int main() {
    int x, y;
    cin >> x >> y;
    int groupx = 0;
    int groupy = 0;
    if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12){
        groupx = 1;
    } else if(x == 2){
        groupx = 3;
    } else {
        groupx = 2;
    }
    if(y == 2){
        groupy = 3;
    } else if(y == 4 || y == 6 || y == 9 || y == 11){
        groupy = 2;
    } else {
        groupy = 1;
    }
    if(groupx == groupy){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    ll a;
    cin >> a;
    cout << (a + a * a + a * a * a) << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
typedef long long int ll;
constexpr int kMod = int(1E9 + 7);
int a[30][30];
ll dp[30][1 << 21];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) if (a[i][j]) {
			for (int k = 0; k < (1 << n); k++) if ((1 << (j - 1)) & k) dp[i][k] += dp[i - 1][k ^ (1 << (j - 1))];
		}
		for (int j = 0; j < (1 << n); j++) dp[i][j] %= kMod;
	
	}
	printf("%lld\n", dp[n][(1 << n) - 1]);
}


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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  if(k==0){
    cout<<a[n-1]<<endl;
    return 0;
  }
  if(n>k&&a[0]==a[n-1]){
    cout<<a[n-1]<<endl;
    return 0;
  } 
  int l=0;
  int r=a[n-1];
  int kijun=0;
  int atai=0;
  int kotae=a[n-1];
  while(r-l>1){
    int kaisuu=0;
    kijun=(l+r)/2;
    //cout<<kijun<<endl;
    atai=0;
    for(int i=0;i<n;i++)kaisuu+=(a[i]+kijun-1)/kijun-1;
    /*while(kijun+atai<a[n-1]){
      int kazu=n-(upper_bound(a.begin(),a.end(),kijun+atai)-a.begin());
      kaisuu+=kazu;
      atai+=kijun;
    }*/
    //cout<<"kaisuu"<<kaisuu<<" "<<kijun<<endl;
    if(kaisuu>k){
      l=kijun;
    }else {
      r=kijun;
      kotae=kijun;
    }
  }
  cout<<kotae<<endl;
  return 0;
}
      


Measured memory_bytes: 4040
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  int N;
  cin >> N;
  lint A[N],B[N],C[N];
  lint ans=0;
  rep(i,N) cin >> A[i];
  rep(i,N) cin >> B[i];
  rep(i,N) cin >> C[i];
  sort(A,A+N);
  sort(C,C+N);
  rep(i,N){
    lint Acount=(upper_bound(A,A+N,B[i]-1)-A);
    lint Ccount=(C+N)-upper_bound(C,C+N,B[i]);
    ans+=Acount*Ccount;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    vector<string> words(n);
    for(int i = 0; i < n; i++) cin >> words[i];
    for(int i = 0; i < n; i++){
      for(int j = i+1; j < n; j++){
        if(words[i] == words[j]){
          cout << "No" << '\n';
          return 0;
        }
      }
    }

    for(int i = 0; i < n-1; i++){
      if(words[i].back() != words[i+1].front()){
        cout << "No" << '\n';
        return 0;
      }
    }

    cout << "Yes" << '\n';
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	string s = rstring;
	long k = rlong;
	long n = s.length;
	
	bool f = 0;
	long[] ans;
	long an = 0;
	char last = '0';
	
	ans ~= an;
	foreach(c; s){
		if(last != c) last = c;
		else an += 1, last = '0';
	}
	
	ans ~= an;
	foreach(c; s){
		if(last != c) last = c;
		else an += 1, last = '0';
	}
	
	ans ~= an;
	foreach(c; s){
		if(last != c) last = c;
		else an += 1, last = '0';
	}
	
	ans ~= an;
	foreach(c; s){
		if(last != c) last = c;
		else an += 1, last = '0';
	}
	
	ans ~= an;
	
	log("ans:", ans);
	
	if(k <= 4) ans[k].writeln;
	else if(k % 2 > 0){
		(ans[1] + (ans[3] - ans[1]) * ((k - 1) / 2)).writeln;
	}
	else{
		(ans[2] + (ans[4] - ans[2]) * ((k - 2) / 2)).writeln;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int fact(int n)
{
    if(n==1)return 1;
    return n*fact(n-1);
}
int main(){
    int n,x,y,lx,ly,absx,absy;
    vector<pair<int,int> >vxy;
    double totalSum =0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        vxy.push_back({x,y});
    }

    int tomul=fact(n-1);
    int todiv=fact(n);
    for(int i = 0;i<n;i++)
    {
        lx = vxy[i].first;
        ly = vxy[i].second;
        for(int j=i+1;j<n;j++)
        {
            x = vxy[j].first;
            y = vxy[j].second;
            absx = abs(x-lx);
            absy = abs(y-ly);
            totalSum += (1.0*sqrt(absx*1.0*absx+absy*absy)*tomul);
        }
    }
    cout<<fixed<<setprecision(7) <<totalSum/todiv*2<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int H = sc.nextInt();
    int W = sc.nextInt();
    int h = sc.nextInt();
    int w = sc.nextInt();

    System.out.println((H - h) * (W - w));

  }
}

Measured memory_bytes: 36112
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

int Grundy(int N, int K){
    int n = N / K, r = N % K;
    if(r == 0) return n;
    else return Grundy(N - ((r - 1) / (n + 1) + 1) * (n + 1), K);
}

signed main(){

    int N; cin >> N;
    vec A(N), K(N);
    REP(i, N) cin >> A[i] >> K[i];
    int G = 0;
    REP(i, N) G ^= Grundy(A[i], K[i]);
    if(G != 0) cout << "Takahashi";
    else cout << "Aoki";
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

lli n;

int main(void){
    cin >> n;
    vector<lli> a(n);
    rep(i, n){
        cin >> a[i];
        a[i]-=i+1;
    }
    sort(a.begin(), a.end());
    lli b = a[(n-1)/2];
    lli ans = 0;
    rep(i, n){
        ans+=abs(a[i]-b);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4788
#include <iostream>

using namespace std;

int main()

{
	int a; int b;
	cin >> a >> b;
	if (a < b){
		cout << "a < b"<<endl;
	}
	else if (a > b){
		cout << "a > b"<<endl;
	}
	else{
		cout << "a == b"<<endl;
	}

	return 0;
}
 

Measured memory_bytes: 1156
n = int(input())
s = [[] for i in range(n+1)]
s[1].append('a')
ans_s = []
for num in range(1,n):
    for st in s[num]:
        for add in range(97, max(map(ord,st))+2):
            s[num+1].append(st + chr(add))
for sw in s[n]:
    print(sw)

Measured memory_bytes: 14548
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

void solve()
{
    int n, m;
    scanf("%d%d", &n, &m);

    if (n % 2 == 0) {
        n--;
    }

    int n0 = n / 2;
    int n1 = n - n0;

    if (n0 % 2) swap(n0, n1);

    vector<pair<int, int> > v0;
    int i;
    for (i = 0; i < n0 / 2; i++) {
        v0.push_back(make_pair(i, n0 - 1 - i));
    }

    vector<pair<int, int> > v1;
    for (i = 0; i < n1 / 2; i++) {
        v1.push_back(make_pair(i, n1 - 1 - i));
    }

    for (i = 0; i < (int)v1.size(); i++) {
        v0.push_back(make_pair(v1[i].first + n0, v1[i].second + n0));
    }

    for (i = 0; i < m; i++) {
        printf("%d %d\n", v0[i].first + 1, v0[i].second + 1);
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 4020
#include<stdio.h>
int main() {
int A, B, C, D;

scanf("%d", &A);
scanf("%d", &B);
scanf("%d", &C);
scanf("%d", &D);

if (A >= B && C >= D) { 
    printf("%d\n", B + D);
} else if(A >= B && C < D) {
    printf("%d\n", B + C);
} else if(A < B && C >= D) {
    printf("%d\n", A + D);
} else if(A < B && C < D) {
    printf("%d\n", A + C);
}
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 10010;

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

    deque<char> q;
    for(char c : s) {
        q.pb(c);
    }

    bool flip = false;

    ll Q;
    cin >> Q;
    string t;
    rep(loop, Q) {
        ll ty;
        cin >> ty;
        if(ty == 1) {
            flip = !flip;
        }
        else {
            ll f;
            char c;
            cin >> f >> c;
            if(flip) {
                f = 3 - f;
            }
            if(f == 1) {
                q.push_front(c);
            }
            else {
                q.pb(c);
            }
        }
    }

    if(flip) {
        reverse(all(q));
    }
    
    for(char c : q) {
        cout << c;
    }
    
    cout << endl;
    re0;
}

Measured memory_bytes: 896
N = int(input())
A = list(map(int, input().split()))

before = A[0]
before_ = "="
count = 1
for idx, a in enumerate(A[1:]):
    if before == a:
        now = before_
    if before < a:
        now = "+"
    if before > a:
        now = "-"

    if (before_ == "+" and now == "-") or (before_ == "-" and now == "+"):
        count += 1
        before_ = "="
    else:
        before_ = now
    before = a
print(count)

Measured memory_bytes: 62704
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#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 vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

ll x,ret;
int main() {
	scanf("%lld",&x);
	ret=(x/11)*2;
	if (x%11>=1&&x%11<=6) ret++;
	else if (x%11>6) ret+=2;
	printf("%lld\n",ret);
}


Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;

int main(void) {
	int N;
	string S;
	scanf("%d", &N);
	cin >> S;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (i == 0) {
			ans++;
		} else if (S[i] != S[i - 1]) {
			ans++;
		}
	}
	printf("%d", ans);

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
using ull = unsigned long long;

/*
ull f(ull a, ull b) {
	if (a == b) {
		return a;
	}

	return 2 * a + f(min(a, b - a), max(a, b- a));
}
*/


ull f(ull a, ull b) {
	if (b % a == 0) {
		return 2 * b - a;
	}

	return 2 * (b / a) * a + f(min(a, b % a), max(a, b % a));
}

int main()
{
	ull N, X;
	cin >> N >> X;

	ull ans = N + f(min(X, N - X), max(X, N - X));
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
lis=[0 for i in range(7)]
lis[0]="Wednesday"
lis[1]="Thursday"
lis[2]="Friday"
lis[3]="Saturday"
lis[4]="Sunday"
lis[5]="Monday"
lis[6]="Tuesday"
while 1:
    date=0
    x,y=map(int,input().split())
    if x!=0 and y!=0:
        for i in range(1,x):
            if i==4 or i==6 or i==9 or i==11:
                date=date+30
            elif i==2:
                date =date+29
            else:
                date=date+31
        k=(date+y)%7
        print(lis[k])
    else:
        break

Measured memory_bytes: 5596
#include<stdio.h>
int main()
{
	int counter = 0;
	int n;
	int a[200];

	scanf("%d", &n);
	int i;
	for ( i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}

	while (1)
	{
		for (i = 0; i < n; i++)
		{
			if (a[i] % 2 == 1)
			{
				printf("%d", counter);
				return 0;
			}
			else
				a[i] = a[i] / 2;
		}
		counter++;
	}
	return 0;
}

Measured memory_bytes: 128
n = int(input())
h = list(map(int, input().split()))
s = 0
m = 0
for i in range(n):
	s += h[i]
while s > 0:
	b = 0
	for i in range(n):
		if h[i] > 0:
			h[i] -= 1
			s -= 1
			if b == 0:
				b = 1
				m += 1
		else:
			b = 0
print(m)

Measured memory_bytes: 3060
def main():
    buf = input()
    S = buf
    if S[0:len("keyence")] == "keyence" or S[len(S)-len("keyence"):len(S)] == "keyence":
        print("YES")
        return
    for i in range(len("keyence")):
        if S[0:i] == "keyence"[0:i] and S[len(S)-(len("keyence")-i):len(S)] == "keyence"[i:len("keyence")]:
            print("YES")
            return
    print("NO")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main(void) {
	int d;
	int sum = 0;
	while (cin >> d) {
		for (int i = 0; i < 600 / d; i++) {
			sum += d*i*d*i*d;
		}
		cout << sum << endl;
		sum = 0;
	}

	return 0;
}

Measured memory_bytes: 1160