akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n); pri(n * (n + 1) / 2);

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k,s;
	cin>>k>>s;
	int i,j,l,ans=0;
	for(i=0;i<=k;i++)
		for(j=0;j<=k;j++){
			l=s-i-j;
			if(l<=k&&l>=0)ans++;
		}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/


//BinaryIndexTree(siz):長さsizで初期化
//sum(k):区間[0,k]の和を求める
//add(k,x):要素kにxを加える

template<typename T>
struct BinaryIndexTree {

	vector<T> data;
	T siz;

	BinaryIndexTree(T n)
	{
		//1-indexなので配列は1つ多めに用意する
		siz = n;
		data.resize(siz + 1, 0);
	}
	T sum(T k)
	{
		//a_1～a_kまでの和を計算
		T ret = 0;
		for (int i = k; i > 0; i -= (i & -i))
		{
			ret += data[i];
		}
		return ret;
	}

	T sum_between(T i, T j) {
		if (i > j) {
			return 0;
		}
		else
		{
			return sum(j) - sum(i - 1);
		}
	}

	void add(T k, T x)
	{
		//a_kにxを加算する
		for (T i = k; i < data.size(); i += (i & -i))
		{
			data[i] += x;
		}
	}

	T lower_bound(T w) {
		if (w <= 0) return 0;
		T x = 0, r = 1;
		while (r < siz) r <<= 1;
		for (T k = r; k > 0; k >>= 1) {
			if (x + k <= siz && data[x + k] < w) {
				w -= data[x + k];
				x += k;
			}
		}
		return x + 1;
	}


};




int main() {

	int n, q;
	cin >> n >> q;
	BinaryIndexTree<int> bit(n);

	for (int i = 0; i < q; i++)
	{
		int a, b, c;
		cin >> a >> b >> c;
		if (a == 0) {
			bit.add(b, c);
		}
		else
		{
			cout << bit.sum_between(b, c) << endl;
		}


	}




	return 0;
}



Measured memory_bytes: 3124
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::cmp::{max, min};
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        csf: [(usize, usize, usize); n-1],
    }
    let mut c = vec![0;n];
    let mut s = vec![0;n];
    let mut f = vec![0;n];
    for i in 0..csf.len() {
        c[i] = csf[i].0;
        s[i] = csf[i].1;
        f[i] = csf[i].2;
    }
    for i in 0..n {
        let mut t = 0;
        for j in i..n-1 {
            if t < s[j] {t=s[j];}
            else if t % f[j]==0 {}
            else {t=t+f[j] - t%f[j]};
            t+=c[j];
        }
        println!("{}", t);
    }
}

Measured memory_bytes: 4352
import sys
from collections import deque
H, W = map(int, input().split())
c = [int(i) + 1 for i in input().split()]
d = [int(i) + 1 for i in input().split()]

s = []
s.append('#'*(W+4))
s.append('#'*(W+4))
for i in range(H):
    a = input()
    s.append('##' + a + '##')
s.append('#'*(W+4))
s.append('#'*(W+4))

q = deque([]) # 探索開始点
qq = deque([])
q.append((c[0], c[1], 0))
visited = [[False for __ in range(W+4)] for _ in range(H+4)]

while q:
    xx, yy, kaisuu = q.popleft()
    if visited[xx][yy] == True:
        continue
    qq.append((xx, yy))
    ls = deque()
    while qq:
        x, y = qq.pop()
        visited[x][y] = True
        ls.append((x, y, kaisuu))
        if x == d[0] and y == d[1]:
            print(kaisuu)
            sys.exit()
        if s[x+1][y] == '.' and visited[x+1][y] == False:
            qq.append((x+1, y))
        if s[x-1][y] == '.' and visited[x-1][y] == False:
            qq.append((x-1, y))
        if s[x][y+1] == '.' and visited[x][y+1] == False:
            qq.append((x, y+1))
        if s[x][y-1] == '.' and visited[x][y-1] == False:
            qq.append((x, y-1))
    for u in ls:
        a, b, e = u
        for i in range(-2, 3):
            for j in range(-2, 3):
                if i == 0 and j == 0:
                    continue
                if abs(i) == 1 and abs(j) == 0:
                    continue
                if abs(j) == 1 and abs(i) == 0:
                    continue
                if s[a+i][b+j] == '.' and visited[a+i][b+j] == False:
                    q.append((a+i, b+j, e+1))
print(-1)

Measured memory_bytes: 133744
N,K=map(int,input().split())
A=[0]*1000000
for i in range(N):
  a,b=map(int,input().split())
  A[a-1]+=b
s=0
for i in range(100000):
  if A[i]==0: continue
  if s+A[i]<K:
    s+=A[i]
  else:
    print(i+1)
    exit()

Measured memory_bytes: 12788
/*
C language 162bytes

char s[1<<20];m[1<<20],n,t;main(){for(gets(s);s[n];m[++n]=--t)for(;t&&s[~t]-s[n];t=m[~t]);t-=~n;n=!printf(t*2<n?"Love %.*s!\n":"mitomerarenaiWA\n",t*=n/3/t+1,s);}
*/


#include <stdio.h>
#include <string.h>

char s[1000010];
int mp[1000010];

int main(){
	int i, n, t, p, q = 0;

	fgets(s, sizeof(s), stdin);
	n = strlen(s) - 1;

	mp[0] = -1;
	t = -1;
	for(i = 0; i < n; ++i){
		while(t >= 0 && s[t] != s[i]){
			t = mp[t];
		}
		mp[i + 1] = ++t;
	}
	
	p = n - mp[n];
	q = p * (n / (3 * p) + 1);
	if(q * 2 >= n){
		q = 0;
	}

	if(q != 0){
		printf("Love %.*s!\n", q, s);
	}
	else{
		puts("mitomerarenaiWA");
	}

	return 0;
}

Measured memory_bytes: 5428
import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		InputReader in = new InputReader();
		int n = in.nextInt();
		int k = in.nextInt();
		
		int[] Alldigits = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
		for (int i=0; i<k; i++) 
			Alldigits[in.nextInt()] = -1;
		
		ArrayList<Integer> digits = new ArrayList<>();
		for (int i: Alldigits) if (i != -1)
			digits.add(i);
		int[] num = toIntArray(n);
		num[0] = -1;
		
		num = replaceBadDigits(num, digits);
		
		while(isSmaller(num, n))
			num = increment(num, digits);
		
		String res = "";
		for (int i=0; i<num.length; i++) if (num[i] != -1) {
			res += Integer.toString(num[i]);
		}
		System.out.println(res);
	}
	
	public static int[] toIntArray(int n) {
		int numDigits = Integer.toString(n).length();
		int[] arr = new int[numDigits + 1];
		
		int pos = numDigits;
		while (n > 0) {
			arr[pos--] = n%10;
			n /= 10;
		}
		return arr;
	}
	
	public static int[] replaceBadDigits(int[] num, ArrayList<Integer> digits) {
		boolean done = false;
		int pos = 2;
		for (int i=1; i<num.length; i++) {
			if (!digits.contains(num[i])) {
				done = true;
				if (i == 1 && digits.get(0) == 0)
					num[i] = digits.get(1);
				else
					num[i] = digits.get(0);
			}
			if (done)
				break;
			++pos;
		}
		
		for (int i=pos; i<num.length; i++)
			num[i] = digits.get(0);
		return num;
	}
	
	public static boolean isSmaller(int[] num, int n) {
		String str = "";
		for (int i=0; i<num.length; i++) if (num[i] != -1)
			str += Integer.toString(num[i]);
		int N = Integer.parseInt(str);
		return n > N;
	}
	
	public static int[] increment(int[] num, ArrayList<Integer> digits) {
		int place = num.length-1;
		while (true) {
			int pos = digits.indexOf(num[place]) + 1;
			if (pos < digits.size()) {
				num[place] = digits.get(pos);
				break;
			}
			else {
				num[place--] = digits.get(0);
			}
		}
		if (num[0] == 0)
			num[0] = digits.get(1);
		return num;
	}
	
	static class InputReader {
		public BufferedReader br;
		public StringTokenizer st;
		
		public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = null;
		}
		
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


Measured memory_bytes: 20564
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long long n, a, b, c, d[100009]; vector<pair<long long, long long>>x[100009]; bool used[100009];
void dfs(int pos) {
	if (used[pos] == true)return;
	used[pos] = true;
	for (int i = 0; i < x[pos].size(); i++) {
		if (used[x[pos][i].first] == false) { dfs(x[pos][i].first); d[pos] += d[x[pos][i].first]; }
	}
	d[pos]++;
}
int main() {
	cin >> n; long long minx = (1LL << 60);
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b >> c;
		x[a].push_back(make_pair(b, c));
		x[b].push_back(make_pair(a, c));
	}
	dfs(1); long long T = 0; bool OK = false;
	for (int i = 1; i <= n; i++) {
		bool I = false;
		for (int j = 0; j < x[i].size(); j++) {
			if (d[x[i][j].first] > n / 2 && d[x[i][j].first] < d[i])I = true;
		}
		if (n - d[i] > n / 2)I = true;
		if (I == false) {
			for (int j = 0; j < x[i].size(); j++) {
				minx = min(minx, x[i][j].second);
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < x[i].size(); j++) {
			long long p1 = i, p2 = x[i][j].first;
			if (d[p1] < d[p2])swap(p1, p2);
			long long V1 = d[p2], V2 = n - d[p2], S;
			if (V1 != V2) { S = min(V1, V2) * 2; }
			if (V1 == V2) { S = min(V1, V2) * 2 - 1; OK = true; }
			T += x[i][j].second*S;
		}
	}
	T /= 2;
	if (OK == false)T -= minx;
	cout << T << endl;
	return 0;
}

Measured memory_bytes: 12800
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a[];
		int b[];
		int c[];
		int d[];
		String st;
		boolean flag;

		a = new int[13];
		b = new int[14];
		c = new int[12];
		d = new int[10];
		while (sc.hasNext()) {
			st = sc.next();
			for (int i = 0; i < 13; i++) {
				a[i] = st.charAt(i) - '0';
			}
			for (int i = 1; i <= 9; i++) {
				flag = false;
				b[0] = i;
				d[i] = 0;
				for (int j = 0; j < 13; j++) {
					b[j + 1] = a[j];
				}
				sort(b);
				if (!isNotFifth(b)) {
					continue;
				}
				int head = 0;
				for (int j = 0; j < 13; j++) {
					if (b[j] == b[j + 1] && head < b[j]) {
						int index = 0;
						head = b[j];
						for (int k = 0; k < 14; k++) {
							if (k != j && k != j + 1) {
								c[index++] = b[k];
							}
						}
						if (check(c)) {
							flag = true;
						}
					}
				}
				if (flag) {
					d[i] = 1;
				}
			}
			String s = "";
			for (int i = 1; i <= 9; i++) {
				if (d[i] == 1) {
					System.out.print(s + i);
					s = " ";
				}
			}
			if (s == "") {
				System.out.print("0");
			}
			System.out.println();
		}
	}

	public static void sort(int a[]) {
		for (int i = 0; i < 14; i++) {
			int min = i;
			for (int j = i; j < 14; j++) {
				if (a[j] < a[min]) {
					min = j;
				}
			}
			int swap = a[min];
			a[min] = a[i];
			a[i] = swap;
		}
	}

	public static boolean isNotFifth(int a[]) {
		int count = 0;
		for (int i = 0; i < 13; i++) {
			if (a[i] == a[i + 1]) {
				count++;
			} else {
				count = 0;
			}
			if (4 <= count) {
				return false;
			}
		}
		return true;
	}

	public static boolean check(int a[]) {
		for (int i = 0; i < 4; i++) {
			if (a[0] == a[1] && a[1] == a[2]) {
				for (int j = 0; j < 12 - 3 * (i + 1); j++) {
					a[j] = a[j + 3];
				}
			} else {
				int dif = 1;
				for (int j = 1; j < 12 - 3 * i; j++) {
					if (a[j] - a[0] == dif) {
						a[j] = 0;
						dif++;
					}
					if (dif == 3) {
						a[0] = 0;
						int index = 0;
						for (int k = 0; k < 12 - 3 * i; k++) {
							if (a[k] != 0) {
								a[index++] = a[k];
							}
						}
						break;
					}
				}
				if (dif < 3) {
					return false;
				}
			}
		}
		return true;
	}
}

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

#define MOD 1000000007
#define lli long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define endl "\n"

using namespace std;

void solve(){
    ///start solving
	lli n;
	cin >> n;
	set<string>s;
	while(n--){
		string temp;
		cin >> temp;
		s.insert(temp);
	}
	cout << s.size() << endl;
}

int main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    
solve();//In case of problems without test case

	return 0;
}




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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

int main()
{
    int n;
    ll ans = 0;
    cin >> n;
    vector <int> a(n-1);
    for (int i = 0; i < n-1; i++) cin >> a[i];
    ans += a[0];
    for (int i = 1; i < n-1; i++) {
        ans += min(a[i-1], a[i]);
        //cout << ans << endl;
    }
    ans += a[n-2];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
v = [int(i) for i in input().split()]

o = v[::2]
e = v[1::2]
co = list(Counter(o).items()) + [(-1, 0)]
ce = list(Counter(e).items()) + [(-2, 0)]
co.sort(key=lambda x: x[1], reverse=True)
ce.sort(key=lambda x: x[1], reverse=True)

if co[0][0] == ce[0][0] :
    print(min(n - co[0][1] - ce[1][1], n - co[1][1] - ce[0][1]))
else :
    print(n - co[0][1] - ce[0][1])

Measured memory_bytes: 63432
program main
  implicit none
  integer(8) A, B, C, D, N
  integer i, Taihijo, Irekawari, Tsukodome
  character(200000) S 
  read(*, *) N, A, B, C, D
  read(*, *) S
  !BD区間待避所の有無を調べます。
  taihijo = 1
  do i = B, min(D,N-1)
    if (S(i-1:i+1) == '...') then
      taihijo = 0
    end if
  end do
  !AがBを追い越す必要があるかどうかを調べます。
  if (C > D) then
    Irekawari = 1
  else
    Irekawari = 0
  end if
  !両方1なら無条件で通行止め
  Tsukodome = taihijo * Irekawari
  do i = A,C-1
    if (S(i:i+1) == '##') then
      tsukodome = 1
    end if
  end do
  do i = B,D-1
    if (S(i:i+1) == '##') then
      tsukodome = 1
    end if
  end do
  if (tsukodome == 1) then
    write(* ,*) 'No'
  else
    write(* ,*) 'Yes'
  end if
end program main


Measured memory_bytes: 1084
x, y = map(int, input().split())

P = [1, 3, 5, 7, 8, 10, 12]
Q = [4, 6, 9, 11]
R = [2]

if x in P:
    if y in P:
        print('Yes')
    else:
        print('No')
if x in Q:
    if y in Q:
        print('Yes')
    else:
        print('No')
if x in R:
    if y in R:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3064
CONST = 1000000007

def noboru(n):
    a1 = 1
    a2 = 2
    ans = 0
    if (n == 0 or n == 1): return a1
    elif (n == 2): return a2
    else:
        for i in range(1, n-1):
            ans = a2 + a1
            a1 = a2
            a2 = ans
        return a2

def func(N, M, a):
    ans = 1
    pos = 0
    for i in range(M):
        if (pos == a[i]):
            return 0
        else:
            ans = (ans * noboru(a[i] - pos - 1)) % CONST
            pos = a[i] + 1
    ans = (ans * noboru(N - pos)) % CONST
    return ans

N, M = map(int, input().split(" "))
a = [int(input()) for _ in range(M)]
print(func(N, M, a))

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


using namespace std;

const int N = 21000;
const int B = 20010;

int p[N], rev[N];
int a[N], b[N];


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

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

	for (int i = 0; i < n; ++i) {
		a[i] = i * B + rev[i] + 1;
		b[i] = (n-i) * B;
	}

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

Measured memory_bytes: 896
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  vector<ll> a(n), b(4, 0);
  REP(i, n) cin >> a[i], a[i] %= 4, b[a[i]]++;
  n -= max(0ll, b[2]-1);
  if(b[0] >= n/2) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
constexpr int INF = (numeric_limits<int>::max() == INT_MAX ? (int)1e9 : (long long)1e18);
constexpr long double eps = 1e-6;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;using pii = pair<int,int>;using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void fast_io(){ios::sync_with_stdio(false); cin.tie(nullptr);}
signed main(){
    int N,M; cin >> N >> M;
    vector<pii>v(N); for(auto& e : v) cin >> e.first >>e.second;
    sort(all(v));
    int ans = 0;
    for(auto p : v){
        int t = min(p.second,M);
        M -= t;
        ans += p.first * t;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
 
using namespace std;
 
int n;
 
string s;
 
main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> s;
    int n = s.size();
    s = " " + s;
    bool flag0 = true;
    for (int i = 1; i <= n / 2; ++ i)
        if (s[i] != s[n - i + 1]) flag0 = false;
    bool flag1 = true;
    for (int i = 1; i <= (int) (n / 2) / 2; ++ i)
        if (s[i] != s[(int)(n / 2) - i + 1]) flag1 = false;
    bool flag2 = true;
    for (int i = (n + 3) / 2; i <= n; ++ i)
        if (s[i] != s[n - i + 1]) flag2 = false;
    if (flag0 && flag1 && flag2) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
n, x, y = map(int, input().split())

x -= 1
y -= 1

ans = [0] * n


for i in range(n):
    for j in range(i + 1, n):
        ans[min(abs(j - i), abs(j - x) + abs(y - i) + 1, abs(j - y) + abs(x - i) + 1)] += 1

for i in range(1, n):
    print(ans[i])


Measured memory_bytes: 3444
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();
		boolean ans = true;
		if (x - a >= b || a > x) {
			ans = false;
		}
		System.out.println(ans ? "YES" : "NO");
	}

}

Measured memory_bytes: 35612
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get_line().parse::<usize>().unwrap();
    let a = get_line()
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect::<Vec<usize>>();

    let mut v = (0..n).map(|_| 0).collect::<Vec<usize>>();

    for i in &a {
        v[i - 1] += 1;
    }

    for i in &v {
        println!("{}", i);
    }
}


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

int main(){
    ll a, b, N;
    ll x,y,z,zz;
    cin >> a >> b >> N;
   // for (x = 1; x < n + 1;x++){
     //   y = x / b;
       // z = a * x / b - a * y;
        /*  if(x==1){
            zz = z;
            xx = x;
        }
        if(z>zz){
            zz = z;
            xx = x;
        }*/
       //cout << z << endl;
        /*
        if (b == 1||a==1)
        {
            cout << 0 << endl;
            break;
       }
       if(x==b-1){
           cout << z << endl;
           break;
       }*/
      /* if(z==0){
           y = (x - 1) / b;
           cout << a * (x - 1) / b - a * y << endl;
           break;
       }*/
    //}
    y = N / b;
    ll y2 = (b - 1) / b;

//N > b - 1 && a * N / b - a * y != 0
    
    
    if (b == 1||a==1){
        cout << 0 << endl;
    }else if (N<=b-1)
    {
        cout << a * N / b - a * y << endl;
    }else if(N > b - 1 ){
        cout << a * (b-1) / b - a * y2 << endl;
    }

        //cout << zz << endl;
}

Measured memory_bytes: 3624
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

ll n, ans, a[20202];

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> n;

rep(i, 1, n){
cin >> a[i];
a[i]--;
ans+=a[i];

}

cout << ans << endl;






return 0;}
///.... Maria Otonashi


Measured memory_bytes: 256
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"]
a = [0 for i in range(26)]
s = ""
while True:
    try:
        s += input().lower()
    except EOFError:
        break

for i in range(len(s)):
    if s[i] in alphabet:
        a[alphabet.index(s[i])] += 1

for i in range(26):
    print(alphabet[i], ":", a[i])



Measured memory_bytes: 5580
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,(n)-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,(n)-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    int prev = a[0];
    rep(i,n){
        if(i<k)continue;
        if(prev < a[i])cout << "Yes" << endl;
        else cout << "No" << endl;
        prev = a[i-k+1];
    }


    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3996
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
int minima(int i, int a[], int h[], int k){ 
int arr[k];
int min =  abs(h[i-1]-h[i])+a[i-1];
for(int j=0;j<k;++j){
    arr[j] = abs(h[i-j-1]-h[i])+a[i-j-1];
    if(arr[j]<min) min = arr[j];
}
return min;
}
int main() {
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;++i) cin>>h[i];
    int a[n];
    for(int i=0;i<=k && i<n;++i) a[i] = abs(h[i]-h[0]); 
    for(int i=k+1;i<n;++i) a[i] = minima(i,a,h,k);
    cout<<a[n-1];
}


Measured memory_bytes: 1024
/* Author : A110011 - 00:19 "CodeIn Hard Way" */

#include<bits/stdc++.h>

#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000
#define inf             1e18
#define sp(x,y)         fixed<<setprecision(y)<<x
typedef long long int ll;

using namespace std;


int solve(int i,vector<int> &res, vector<int> &dp){
        
    if(i<=0){
        return 0;
    }
    
    if(i==1){
        return abs(res[i]-res[i-1]);
    }
    if(dp[i]!=-1){
        return dp[i];
    }
    if(i>1){
        return dp[i]= min(abs(res[i]-res[i-1])+solve(i-1,res,dp),abs(res[i]-res[i-2])+solve(i-2,res,dp));
    }
    return 0;
}

int main(){

	// For fast I/O.
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    
   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif */
    
   
    int n;
    cin>>n;
    
    vector<int> res;
    
    
    for(int i=0;i<n;i++){
        int val;
        cin>>val;
        res.push_back(val);
    }
    
    
    vector<int> dp(n,-1);
    
    cout<<solve(n-1,res,dp)<<endl;
   



return 0; 
}


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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

bool ispal(string s){
    int n = s.size();
    for(int i = 0; i < n/2; i++){
        if(s[i] != s[n - i - 1])return 0;
    }
    return 1;
}
int main(){
    FAST
    string s; cin >> s;
    int n = s.size();
    string s2 = "", s3 = "";
    for(int i = 0; i < n/2; i++){
        s2 += s[i];
    }
    for(int i = (n + 1)/2; i < n; i++){
        s3 += s[i];
    }
    if(ispal(s) && ispal(s2) && ispal(s3)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int x = scanner.nextInt();
    int y = scanner.nextInt();
    int z = scanner.nextInt();

    System.out.println(z +  " " + x + " " + y);
  }
}


Measured memory_bytes: 23764
// https://atcoder.jp/contests/abc067/tasks/abc067_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    REP(i, n) cin >> v[i];
    sort(ALLR(v));
    int sum = 0;
    REP(i, k) sum += v[i];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,x;
bool rev;
int out(int x)
{
	if(rev)putsi(2*n-x);else putsi(x);
}
int main()
{
	getii(n,x);
	if(x==1||x==2*n-1)
	{
		puts("No");
		return 0;
	}
	puts("Yes");
	if(n==2)
	{
		puts("1\n2\n3");
		return 0;
	}
	if(x==2)rev=1,x=2*n-x;
	int it=3;
	for(int i=1;i<=2*n-1;i++)
	{
		if(i==n)out(x);
		else if(i==n-1)out(2*n-1);
		else if(i==n-2)out(1);
		else if(i==n+1)out(2);
		else
		{
			while(it==1||it==2||it==x)it++;
			out(it);
			it++;
		}
	}
	return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e3+10,inf=1e9+10,mod=1e9+7;
int a[M],n;
pii cur;
int p[M][M][2];
int sum=0;
vector<int>hlp,hlp2;
vector<int>ans;
main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i+=2)
	{
		if(a[i]>0)sum+=a[i],hlp.pb(i);
	}
	int sum2=0;
	for(int i=2;i<=n;i+=2)
	{
		if(a[i]>0)sum2+=a[i],hlp2.pb(i);
	}
	if(hlp.size())
		cout<<max(sum,sum2)<<"\n";
	if(sum2>sum)
	{
		hlp.clear();
		for(int j=0;j<hlp2.size();j++)hlp.pb(hlp2[j]);
	}
	if(hlp.size()==0)
	{
		int maxx=-inf;
		int ind;
		for(int j=1;j<=n;j++)
		{
			maxx=max(maxx,a[j]);
			if(maxx==a[j])ind=j;
		}
		cout<<maxx<<endl<<n-1<<endl;
		for(int j=n;j>ind;j--)cout<<j<<"\n";
		for(int j=1;j<ind;j++)cout<<1<<"\n";
		return 0;
	}
	if(hlp.size()>0)
	{
	//	cout<<hlp[0]<<endl;
		for(int j=n;j>hlp.back();j--)ans.pb(j);
		for(int j=1;j<hlp[0];j++)ans.pb(1);
		for(int j=(int)hlp.size()-1;j>=0;j--)hlp[j]-=hlp[0],hlp[j]++;
	}
	for(int i=(int)hlp.size()-1;i>=1;i--){
		int tmp=hlp[i];
		for(int j=tmp-2;j>hlp[i-1];j-=2)
		{
		//	cout<<j<<"*******"<<" "<<tmp<<" "<<hlp[j-1]<<endl;
			ans.pb(j);
		}
	}
	for(int j=(int)hlp.size()-1;j>=1;j--)ans.pb(j*2);
	cout<<ans.size()<<"\n";
	for(int i=0;i<ans.size();i++)cout<<ans[i]<<"\n";
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var abx = Sarray();
            var a = abx[0];
            var b = abx[1];
            var x = abx[2];
            var anum = (a - 1) / x + 1;
            if (a == 0) anum = 0;
            var bnum = b / x + 1;
            var ans = bnum - anum;
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

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

int main() {
 int n, d;
    cin >> n >>d;
    
    cout << (n + 2 * d) / (2 * d +1);
    
}

Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

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

int main() {
  int N; cin >> N;
  vector<int> P(N), Q(N); cin >> P >> Q;

  int p = -1, q = -1, cnt = 0;
  std::vector<int> v(N);
  for (int i = 0; i < N; ++i) v[i] = i+1;
  do {
    if (v == P) p = cnt;
    if (v == Q) q = cnt;
    ++cnt;
  } while(next_permutation(v.begin(), v.end()));
  cout << abs(p - q) << endl;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> v(N);
    REP(i, M){
        int x, y;
        cin >> x >> y;
        v[x - 1].push_back(y - 1);
        v[y - 1].push_back(x - 1);
    }
    vector<bool> seen(N);
    queue<int> que;
    int MAX = INT_MIN;
    REP(i, N){
        if(!seen[i]){
            que.push(i);
            seen[i] = true;
            int count = 1;
            while(!que.empty()){
                int x = que.front();
                que.pop();
                for(auto y:v[x]){
                    if(!seen[y]){
                        que.push(y);
                        seen[y] = true;
                        count++;
                    }
                }
            }
            MAX = max(MAX, count);
        }
    }
    cout << MAX << "\n";
    return 0;
}

Measured memory_bytes: 14900
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,K;
LL A[3];
string T;
vector<int>v[100001];
LL dp[2][100001];
int main(){
	cin>>N>>K;
	cin>>A[1]>>A[2]>>A[0];
	cin>>T;
	REP(i,T.size()){
		if(T[i]=='r'){
			v[i%K].push_back(0);
		}else if(T[i]=='s'){
			v[i%K].push_back(1);
		}else{
			v[i%K].push_back(2);
		}
	}
	LL ans=0;
	REP(i,K){
		if(v[i].size()==0)continue;
		dp[0][0]=A[v[i][0]];
		dp[1][0]=0;
		REP(j,v[i].size()){
			if(j==0)continue;
			if(v[i][j]==v[i][j-1]){
				dp[0][j]=dp[1][j-1]+A[v[i][j]];
				dp[1][j]=max(dp[1][j-1],dp[0][j-1]);
			}else{
				dp[0][j]=max(dp[1][j-1],dp[0][j-1])+A[v[i][j]];
				dp[1][j]=max(dp[1][j-1],dp[0][j-1]);
			}
		}
		ans+=max(dp[0][v[i].size()-1],dp[1][v[i].size()-1]);
		REP(j,v[i].size()){
			dp[0][j]=0;
			dp[1][j]=0;
		}
	}
	cout<<ans<<endl;
}

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

// 内部定数
#define D_TURN_MAX		100000									// 最大ターン数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 改行カット
// 戻り値：文字数
int
fCutCfLf(
	char *pcpStr				// <I> 文字列
)
{
	int i;

	for (i = 0; pcpStr[i] != '\0'; i++) {
		if (pcpStr[i] == '\n') {
			pcpStr[i] = '\0';
			break;
		}
	}

	return i;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 手を取得
	char lc1Turn[D_TURN_MAX + 5];
#ifdef D_TEST
	fgets(lc1Turn, sizeof(lc1Turn), szpFpT);
#else
	fgets(lc1Turn, sizeof(lc1Turn), stdin);
#endif

	// 改行カット・ターン数取得
	int liTCnt = fCutCfLf(lc1Turn);

	// 得点計算
	int liSum = 0;
	for (i = 0; i < liTCnt; i++) {
		if (i % 2 == 0) {
			if (lc1Turn[i] == 'p') {
				liSum--;
			}
		}
		else {
			if (lc1Turn[i] == 'g') {
				liSum++;
			}
		}
	}

	// 結果セット
	sprintf(lc1Out, "%d\n", liSum);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



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

int main() {
    int n;
    cin >> n;
    set<string> st;
    char last;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        if (i == 0) last = s[0];
        if (last != s[0] || st.count(s)) {
            cout << "No" << endl;
            return 0;
        }
        st.insert(s);
        last = s[s.size() - 1];
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
void setIO(string name = "") { // name is nonempty for USACO file I/O
    ios_base::sync_with_stdio(0); cin.tie(0); // see Fast Input & Output
    if(sz(name)){
        freopen((name+".in").c_str(), "r", stdin); // see Input & Output
        freopen((name+".out").c_str(), "w", stdout);
    }
}

ll dp[105][100005];

int main(){
    int n, w; cin >> n >> w;
    vi a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    } 
    memset(dp, 0x3f3f3f, sizeof(dp)); //fill dp with a large value
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= 100000; j++) {
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            if (j - b[i - 1] >= 0) {
                dp[i][j] = min(dp[i][j], dp[i - 1][j - b[i - 1]] + a[i - 1]);
            }
        }
    }
    int ans = -1;
    for (int i = 0; i <= 100000; i++) {
        if(dp[n][i] <= w){
            ans = i;
        }
    }
    cout << ans << '\n';
}

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

int main(int argc, char *argv[]) {
    int A, B;
    cin >> A >> B;

    if (A >= 13) {
        cout << B << endl;
    } else if (A >= 6 && 12 >= A) {
        cout << B / 2 << endl;
    } else if (A < 6) {
        cout << 0 << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  for (int i = 0; i + 1 < s.size(); i++) {
    if (s.substr(i, 2) == "AC") {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}

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

public class Main {

	 private static double n;
	 private static double max_n;
	 private static double min_n;

	 public static void main(String args[]) throws Exception {
	        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	        max_n = Double.MIN_VALUE;
	        min_n = Double.MAX_VALUE; 
	        String val;

	        
        	while((val = br.readLine()) !=null){
	        	double n = Double.parseDouble(val);
	            if(max_n<n){
	            	max_n =n;
	            }
	            else if(min_n>n){
	            	min_n=n;
	            }
	        }
	        System.out.println(max_n-min_n);
	 }	 
}

Measured memory_bytes: 16912
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

template <typename T>
void warshall_floyd(vector<vector<T>> &d) {
  for (int k = 0; k < d.size(); k++) {
    for (int i = 0; i < d.size(); i++) {
      for (int j = 0; j < d.size(); j++) {
        if (d[i][k] == INF || d[k][j] == INF) continue;
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main(){
  int n,m,l;
  cin >> n >> m >> l;
  vector<vector<ll>> dist(n,vector<ll>(n));
  rep(i,n)rep(j,n){
    if(i==j)dist[i][j]=0;
    else dist[i][j]=LINF;
  }
  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    a--,b--;
    //if(c>l)continue;
    dist[a][b]=c;
    dist[b][a]=c;
  }
  warshall_floyd(dist);
  rep(i,n)rep(j,n){
    if(dist[i][j]<=l)dist[i][j]=1;
    else dist[i][j]=LINF;
  }
  warshall_floyd(dist);
  int q;
  cin >> q;
  rep(i,q){
    int s,t;
    cin >> s >> t;
    s--,t--;
    if(dist[s][t]!=LINF)cout << dist[s][t]-1 << endl;
    else cout << -1 << endl;
  }
}

Measured memory_bytes: 1280
#include <iostream>
#include <map>

using namespace std;

int main()
{
    int N;
    cin >> N;
    map<int, int> m;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        m[a]++;
    }

    int count = 0;
    for (auto p: m) {
        int x = p.first;
        int n = p.second;
        if (n < x) count += n;
        else count += n - x;
    }

    cout << count << endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 900005;

int inv[MAX_N],fac[MAX_N],finv[MAX_N];

void make()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2;i<MAX_N;i++){
		inv[i] = MOD - (ll)inv[MOD%i] * (MOD/i) % MOD;
		fac[i] = (ll)fac[i-1] * i % MOD;
		finv[i] = (ll)finv[i-1] * inv[i] % MOD;
	}
}

int comb(int a,int b)
{
	if(a<b){
		return 0;
	}
	return fac[a] * ((ll)finv[b] * finv[a-b] % MOD) % MOD;
}

inline int add(int x,int y)
{
    return (x+y)%MOD;
}

inline int sub(int x,int y)
{
    return (x+MOD-y)%MOD;
}

inline int mul(int x,int y)
{
    return (ll)x*y%MOD;
}

inline int mod_pow(int a, int b)
{
    int res = 1;
    while(b){
        if(b & 1){
            res = (ll)res * a % MOD;
        }
        a = (ll)a * a % MOD;
        b >>= 1;
    }
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, K;
    cin >> n >> m >> K;
    if(K > m) swap(m, K);
    make();
    int tm = 0;
    int cri = 1;
    int inv3 = mod_pow(3, MOD-2);
    int cri2 = mod_pow(inv3, n+1);
    srep(i, n+1, n+K+1){
        tm = add(tm, mul(comb(i-2, n-1), mul(cri, cri2)));
        cri = mul(cri, 2);
        cri2 = mul(cri2, inv3);
    }
    srep(i, n+K+1, n+m+2){
        tm = add(tm, mul(comb(i-2, n-1), mul(cri, cri2)));
        cri = sub(mul(cri, 2), comb(i-n-1, i-n-K-1));
        cri2 = mul(cri2, inv3);
    }
    cri = 0;
    srep(i, m-K+1, m+1){
        cri = add(cri, comb(m+1, i));
    }
    srep(i, n+m+2, n+m+K+2){
        tm = add(tm, mul(comb(i-2, n-1), mul(cri, cri2)));
        cri = sub(mul(cri, 2), add(comb(i-n-1, i-n-K-1), comb(i-n-1, m)));
        cri2 = mul(cri2, inv3);
    }
    cout << mul(tm, mod_pow(3, n+m+K+1)) << "\n";
    return 0;
}


Measured memory_bytes: 10752
//
//AtCoder Regular Contest 102
//C
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
#include <numeric>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    ll ans1=0;
    ll ans2=0;
    FOR(i,1,n){
        if (k%2==0){
            if (i%k==0) ans1++;
            else if (i%k == k/2) ans2++;
        }else{
            if (i%k==0) ans1++;
        }
    }
    cout << ans1*ans1*ans1 + ans2*ans2*ans2 << endl;
    return 0;
}


Measured memory_bytes: 3644