akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e10
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextFloat() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func intSlicePrint(el interface{}) {
	fmt.Println(strings.Trim(fmt.Sprint(el), "[]"))
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)

	n, k := nextInt(), nextInt()
	s := make([]int, n)
	for i := 0; i < n; i++ {
		s[i] = nextInt()
	}
	sort.Ints(s)

	sum := 0
	for j := 0; j < k;j++ {
		sum += s[j]
	}

	fmt.Println(sum)
}



Measured memory_bytes: 1784
using System;

class Program
{
    static void Main()
    {
        int ans = 0;
        // Loop
        while (true)
        {
            // Input
            var input = Console.ReadLine();
            var values = input.Split(' ');
            int a = int.Parse(values[0]);
            int b = int.Parse(values[2]);
            string op = values[1];

            if (op == "+")
            {
                ans = a + b;
            }
            else if (op == "-")
            {
                ans = a - b;
            }
            else if (op == "*")
            {
                ans = a * b;
            }
            else if (op == "/")
            {
                ans = a / b;
            }
            else if (op == "?")
            {
                // Loop end.
                break;
            }
            else
            {
                continue;
            }
            // Output
            Console.WriteLine("{0}", ans);
        }
    }
}

Measured memory_bytes: 9152
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
 char a,b; cin>>a>>b;
  if(a=='H'&&b=='H')cout<<'H'<<endl;
    else if(a=='D'&&b=='D') cout<<'H'<<endl;
            else cout<<'D'<<endl;
}

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

int main(){
    int N, D, X;
    cin >> N >> D >> X;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    
    int cnt=0;
    for(int i=0; i<N; i++){
        int n=1,j=1;
        while(j<=D){
            if(j<=D){
                //cout << j << endl;
                cnt++;
            }
            j = A[i]*n+1;
            n++;
        }
    }
    
    cout << cnt+X << endl;
}


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

using namespace std;

#define mp(x, y) make_pair(x, y);
#define reset(x) memset(x, 0, sizeof(x));
#define recopy(a, b) memcpy(b, a, sizeof(a));
typedef unsigned long long ULL;
typedef long long LL;
const int mod = 1e9 + 7;
const int maxn = 1e3 + 10;
int H, W, sx, sy, ex, ey;
int nexts[4][2] = {{0,  1},
                   {1,  0},
                   {0,  -1},
                   {-1, 0}};
char pic[maxn][maxn];
int d[maxn][maxn];
struct node {
    int x, y;
};
bool flag = false;
int ans = INT_MAX;

void init () {
    for (int i = 0; i <= H; i++)
        for (int j = 0; j <= W; j++) d[i][j] = mod;
}

void bfs(int x, int y) {
    deque<node> q;
    node p;
    p.x = x;
    p.y = y;
    d[x][y] = 0;
    q.push_back(p);
    while (!q.empty()) {
        p = q.front();
        q.pop_front();
        for (int i = 0; i < 4; i++) {
            int tx = p.x + nexts[i][0];
            int ty = p.y + nexts[i][1];
            if (tx < 1 || tx > H || ty < 1 || ty > W) continue;
            if (pic[tx][ty] == '.' && d[tx][ty] > d[p.x][p.y]) {
                node e;
                e.x = tx;
                e.y = ty;
                d[tx][ty] = d[p.x][p.y];
                q.push_front(e);
            }
            for (int j = -2; j <= 2; j++) {
                for (int k = -2; k <= 2; k++) {
                    if ((abs(j) + abs(k)) <= 1) continue;
                    int tx = p.x + j;
                    int ty = p.y + k;
                    if (tx < 1 || tx > H || ty < 1 || ty > W) continue;
                    if (pic[tx][ty] == '.' && d[tx][ty] > d[p.x][p.y] + 1) {
                        node e;
                        e.x = tx;
                        e.y = ty;
                        d[tx][ty] = d[p.x][p.y] + 1;
                        q.push_back(e);
                    }
                }
            }
        }
    }
}


int main() {
    ios::sync_with_stdio(false);

    cin >> H >> W >> sx >> sy >> ex >> ey;
    for (int i = 1; i <= H; i++) cin >> (pic[i] + 1);
    init();
    bfs(sx, sy);
    if (d[ex][ey] == mod) cout << -1 << endl;
    else cout << d[ex][ey] << endl;
    return 0;
}


Measured memory_bytes: 8568
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  int n, l, asc, desc;
  while(scanf("%d%d", &n, &l) && (n || l)){
    vector<int>a;
    a.push_back(n);
    int i = 1, j;
    bool f = false;
    while(1){
      char s[8];
      sprintf(s, "%06d", a.back());
      //      puts(s);
      sort(s, s+6, greater<int>()); s[l] = '\0';
      //      puts(s);
      desc = atoi(s);
      sort(s, s+l);
      //      puts(s);
      asc = atoi(s);
      //      printf("%d %d %d\n", asc, desc, desc - asc);
      for(j = 0; j < a.size();++j) if(a[j] == desc - asc){ f= true;break;}
      if(f) break;
      a.push_back(desc - asc);
      i++;
    }
    printf("%d %d %d\n", j, desc-asc,i-j);
  }
  return 0;
}

Measured memory_bytes: 1236
s = gets.chomp.split("")
a = "a"
ans = s.size
for i in 0..25
  t = Marshal.load(Marshal.dump(s))
  temp = 0
  while !(t.all?{|w|w == a}) && t.size >= 2
    for j in 0..t.size-2
      if t[j] == a || t[j+1] == a
        t[j] = a
      end
    end
    t.pop
    temp += 1
  end
  ans = [temp,ans].min
  a.succ!
end
puts ans

Measured memory_bytes: 2172
#include <cstdio>
#include <algorithm>
int head[100001], next[199999], to[199999], q[100001], fa[100001], N, E, f[100001][20];
int main()
{
	scanf("%d", &N);
	for (int i = 1, u, v; i < N; i++)
	{
		scanf("%d%d", &u, &v);
		next[++E] = head[u], to[E] = v, head[u] = E;
		next[++E] = head[v], to[E] = u, head[v] = E;
	}
	int H = 0, T = 1, u;
	q[1] = 1;
	while (H < T)
		for (int e = head[u = q[++H]]; e; e = next[e])
			if (to[e] != fa[u])
				fa[q[++T] = to[e]] = u;
	for (int i = N; i; i--)
	{
		int u = q[i];
		for (int e = head[u]; e; e = next[e])
			if (to[e] != fa[u])
				for (int j = 0; j < 20; j++)
					f[u][j] += f[to[e]][j];
		f[u][0]++;
		int z = -1;
		for (int j = 0; j < 19; j++)
			if (f[u][j] > 1)
			{
				z = j;
				f[u][j] = 0;
				f[u][j + 1]++;
			}
		for (int j = 0; j <= z; j++)
			f[u][j] = 0;
	}
	int D = 19;
	while (!f[1][D])
		D--;
	printf("%d\n", D);
	return 0;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,q,poz[200001];
vector<int> v[200001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>q;
    for(int i=0;i<=n;i++)
    {
        poz[i]=i;
        v[i].push_back(i);
    }
    while(q--)
    {
        int tip,a,b;
        cin>>tip>>a>>b;
        if(tip==0)
        {
            int m1=poz[a];
            int m2=poz[b];
            if(m1==m2)
                continue;
            if(v[m1].size()>v[m2].size())
                swap(m1,m2);
            for(auto i:v[m1])
            {
                v[m2].push_back(i);
                poz[i]=m2;
            }
            v[m1].clear();
        }
        else if(tip==1)
            cout<<(poz[a]==poz[b]? 1:0)<<'\n';
    }
    return 0;
}


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

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

	long double ans = 0;
	for( int n = 1; n <= N; n++ ) {
		long double t = 1.0 / N;
		int i = n;
		while( i < K ) {
			i *= 2;
			t /= 2;
		}
		ans += t;
	}

	cout << fixed << setprecision(12) << ans << endl;
}


Measured memory_bytes: 3740
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100000+10;

int n;
int k;
int a;
int kq;

int main(){
  cin>>n>>k;kq=0;
  for(int i=1;i<=n;i++){
    cin>>a;if (a>=k) kq++;
  }
  cout<<kq;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;
int main() {
	cin >> A >> B;
	if (A*B & 1)cout << "Odd";
	else cout << "Even";
}

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


int main(){
    int n;
    int h[100010];

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

    int countemp = 0;
    int countMax = 0;
    for(int i = 0;i<n - 1;i++){
        if(h[i] >= h[i+1]) countemp ++;
        else{
            countMax = fmax(countemp,countMax);
            countemp = 0;
        }
        countMax = fmax(countemp, countMax);
    }

    cout << countMax << endl;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
 
#define N 1000000
#define INF 1000000

int main(void){
  int n, q, m, ans;
  int a[21];
  int dp[21][2001];
  
  cin >> n;
  for (int i=1; i<=n; i++){
    cin >> a[i];
  }
  // DPで殴る
  for (int j=1; j<=2000; j++) dp[0][j] = 0;
  for (int i=0; i<=n; i++) dp[i][0] = 1;
  for (int i=1; i<=n; i++){
    for (int j=0; j<=2000; j++){
      dp[i][j] = dp[i-1][j];
      if (j-a[i]>=0){
        dp[i][j] += dp[i-1][j-a[i]];
      }
    }
  }
/*  for (int i=0; i<=n; i++){
    for (int j=0; j<=20; j++){
      cout << dp[i][j] << " ";
    } cout << endl;
  }*/
  
  cin >> q;
  for (int i=0; i<q; i++){
    cin >> m;
    cout << (dp[n][m]?"yes":"no") << endl;
  }
  return 0;
}


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

struct node {
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key) {
  NodePointer t;
  for (t = nil->next; t != nil; t = t->next) {
    if (t->key == key) {
      return t;
    }
  }
  return nil;
}

void init(void) {
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  NodePointer cur = nil->next;
  int isf = 1;
  while(1) {
    if (cur == nil) break;
    if (isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  NodePointer a_del = t->next, b_del = t->prev;
  if (a_del == nil) {
    nil->prev = b_del;
    b_del->next = nil;
  } else if (b_del == nil) {
    nil->next = a_del;
    a_del->prev = nil;
  } else {
    a_del->prev = b_del;
    b_del->next = a_del;
  }
  free(t);
}

void deleteFirst(void) {
  NodePointer t = nil->next;
  if (t == nil) return;
  deleteNode(t);
}

void deleteLast(void) {
  NodePointer t = nil->prev;
  if (t == nil) return;
  deleteNode(t);
}

void delete(int key) {
  NodePointer t = listSearch(key);
  if (t == nil) return;
  deleteNode(t);
}


void insert(int key) {
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  if (nil->prev == NULL) {
    nil->prev = x;
  }
  
  if (nil->next == NULL) {
    nil->next = x;
    x->prev = nil;
    x->next = nil;
  } else {
    nil->next->prev = x;
    x->next = nil->next;
    x->prev = nil;
    nil->next = x;
  }  
}

int main(void) {
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for (i = 0; i < n; i++) {
    scanf("%s%d", com, &key);
    if (com[0] == 'i') {
      insert(key); 
      np++; 
      size++;
    } else if (com[0] == 'd') {
      if (strlen(com) > 6) {
        if (com[6] == 'F') deleteFirst();
        else if (com[6] == 'L') deleteLast();
      } else {
        delete(key);
        nd++;
      }
      size--;
    }
  }

  printList();
  return 0;
}

Measured memory_bytes: 31788
#if defined(LOCAL)
#define PROBLEM_NAME "d"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define C(x, ...) ;
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)
#define MAX(a,b)({__typeof__(a)__x=(a);__typeof__(b)__y=(b);__x<__y?__y:__x;})
#define MIN(a,b)({__typeof__(a)__x=(a);__typeof__(b)__y=(b);__x<__y?__x:__y;})

l popcnt(l value) { return __builtin_popcount(value); }
bool bit_set(l mask, l i) { return mask & (e0 << i); }

void solve(istream& cin, ostream& cout) {
  string s; cin >> s;
  l m = 0;
  vi v(1 << 26);
  for (auto c : s) {
    l t = c - 'a';
    m = m ^ (1 << t);
    if (popcnt(m) < 2) { v[m] = 1; continue; }
    v[m] = numeric_limits<int>::max();
    F(i, 0, 26) if (v[m ^ (1 << i)]) v[m] = min(v[m], v[m ^ (1 << i)] + 1);
  }
  cout << v[m] << lf;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 262804
import math
while True :
    color = [[0, 0, 0], [0, 0, 255], [0, 255, 0], [0, 255, 255], 
    [255, 0, 0], [255, 0, 255], [255, 255, 0], [255, 255, 255]]

    color_16 = input()
    if color_16 == "0" :
        break
    
    color_R = int(color_16[1] + color_16[2], 16)
    color_G = int(color_16[3] + color_16[4], 16)
    color_B = int(color_16[5] + color_16[6], 16)
    
    min_d = 500
    for i in range(8) :
        R = color[i][0]
        G = color[i][1]
        B = color[i][2]
        d = math.sqrt((R - color_R)**2 + (G - color_G)**2 + (B - color_B)**2)
        if min_d > d :
            min_d = d
            color_num = i
    
    if color_num == 0 :
        print("black")
    elif color_num == 1 :
        print("blue") 
    elif color_num == 2 :
        print("lime")
    elif color_num == 3 :
        print("aqua")
    elif color_num == 4 :
        print("red")
    elif color_num == 5 :
        print("fuchsia")
    elif color_num == 6 :
        print("yellow")
    else :
        print("white")
    


Measured memory_bytes: 5652
#include "bits/stdc++.h"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<vd> vvd;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define SIZE(a) int((a).size())
int main(){
  int n;cin>>n;
  int a=n/100,b=(n-a*100)/10,c=(n-a*100-b*10);
  if(a==7||b==7||c==7){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}


Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;
 
int main()
{
  int n, m, s;
  cin >> n >> m >> s;
  if(n == m){
    if(s != n){
      cout << "Yes";
    }else{
      cout << "No";
    }
  }else if( m == s){
    if(n != m){
      cout << "Yes";
    }else{
      cout << "No";
    }
  }else if(n == s){
    if(m != s){
      cout << "Yes";
    }else{
      cout << "No";
    }
  }else{
    cout << "No";
  }
  
  cout << endl;
  
  return 0;
}

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

const int64_t MOD= 1000000007;
/* 剰余環 Z/nZ */
struct mint{ // Z/nZ に関する演算(n:素数の場合は除算も)をサポートする構造体
  int64_t rep; // 出力すべき代表元 rep \in {0,1,..,MOD- 1}
  mint(int64_t x=0): rep(((x%MOD)+ MOD)% MOD){}
  mint operator-() const { return mint(-rep);}
  mint& operator+=(const mint& x){
    rep+= x.rep; 
    if(rep>= MOD) rep-= MOD;
    return *this;
  }
  mint& operator-=(const mint& x){
    rep-= x.rep;
    if(rep< 0) rep+= MOD;
    return *this;
  }
  mint& operator*=(const mint& x){
    rep*= x.rep; rep%= MOD;
    return *this;
  }
  mint operator+(const mint x) const {
    mint ans(*this);
    ans+= x;
    return ans;
  }
  mint operator-(const mint x) const {
    mint ans(*this);
    ans-= x;
    return ans;
  }
  mint operator*(const mint x) const {
    mint ans(*this);
    ans*= x;
    return ans;
  }
  bool operator==(const mint x) const {
    return rep==x.rep;
  }
  bool operator!=(const mint x) const {
    return rep!=x.rep;
  }

  mint pow(int64_t d) const{ // d \geq 0
    mint ans= 1;
    mint x= *this;
    while(d > 0){
      if(d&1){ ans*= x; }
      d >>= 1;
      x*= x;
    }

    return ans;
  }

  friend istream& operator >> (istream &is, mint& x) noexcept{
    int64_t a;
    is >> a;
    x= a;
    return is;
  }
  friend ostream& operator << (ostream &os, const mint& x) noexcept{
      return os << x.rep;
  }
  // MOD が素数(<=> Z/nZ が体)のとき
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint& x){
    *this *= x.inv();
    return *this;
  }
  mint operator/(const mint x) const {
    mint ans(*this);
    ans/= x;
    return ans;
  }
};
// ^^^ テンプレここまで ^^^

int main(){
  const int Nab= 26;
  int Nlen; string S;
  cin >> Nlen >> S;

  vector<mint> freq(Nab);
  for(auto c:S){
    freq.at(c-'a')+= 1;
  }

  mint ans= 1;
  for(auto f:freq){
    ans*= f+1;
  }
  ans-= 1; // 1文字も選ばないパターンはダメ

  cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)

int main() {
#ifndef ONLINE_JUDGE
#endif
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   ll n , k;
   cin >> n >> k;
   cout << min(n % k , k - (n % k)) << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int n;
    string s;
    cin >> n >> s;
    if(n%2==1){
        cout << "No" << endl;
        return 0;
    }
    rep(i, n/2){
        if(s[i]!=s[i+n/2]){
            // cout << s[i] << ", " << s[i+n/2]<< endl;
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
K = int(input())

rnrn = list(range(10))

idx = 0
for idx_base in range(0, K + 1):
    base = rnrn[idx_base]
    for d in (-1, 0, 1):
        digit = base % 10 + d
        if digit < 0 or 9 < digit: continue
        if base == 0: continue
        rnrn.append(10 * base + digit)
        if len(rnrn) >= K + 1: break
    if len(rnrn) >= K + 1: break

# print("#", rnrn)
print(rnrn[K])

# なんでや！阪神関係無いやろ！

Measured memory_bytes: 7272
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    string str;
    string strin[200100];
    int a[200100];
    long sum = 0;
    long size;
    cin >> str;
    size = str.size();
for(long i =0; i < size; i++){
   strin[i] = str.at(i);
     }
  
 for(long i =0; i < size; i++){
   a[i] = atoi(strin[i].c_str());
     }
  
 
  for(int i =0; i < str.size(); i++){
   sum += a[i];
     }
 
   if((sum % 9) == 0){
       cout << "Yes" << endl;
   }else{
       cout << "No" << endl;
   }
  
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;





int main(int argc, const char * argv[]) {
    
  
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    int x; cin >> x;
    int now = 0;
    int time = 0;
    
   
    while(now<x){
        time++;
        now += time;
    }
    cout << time << endl;
    
    
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int n, m, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> p){
    if(p.size() == n+1){
        int ret = 0;
        rep(i,q){
            if(p[b[i]] - p[a[i]] == c[i]) ret += d[i]; 
        }
        chmax(ans, ret);
        return;
    }

    p.push_back(p.back());
    while(p.back() <= m){
        dfs(p);
        p.back()++;
    }
}

int main(){
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    vector<int> p(1,1);
    dfs(p);
    cout << ans << endl;
}

Measured memory_bytes: 3568
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

struct ball {
    int num = 0;
    vector<int> next = {};
    int id;
    int answer;
};

int main() {
    // source
    int n;
    cin >> n;
    int a[n - 1], b[n - 1];
    rep(i, n - 1) { cin >> a[i] >> b[i]; }
    int c[n];
    int inf = pow(10, 9);
    rep(i, n) { cin >> c[i]; }

    sort(c, c + n);

    vector<ball> node(n + 1);
    rep(i, n + 1) { node[i].id = i; }

    node[0].num = inf;

    rep(i, n - 1) {
        node[a[i]].num++;
        node[b[i]].num++;
        node[a[i]].next.push_back(b[i]);
        node[b[i]].next.push_back(a[i]);
    }

    vector<int> index(n + 1);
    rep(i, n + 1) { index[i] = i; }

    sort(index.begin(), index.end(),
         [&](int x, int y) { return node[x].num < node[y].num; });

    rep(i, n - 1) {
        node[index[0]].answer = c[i];
        node[index[0]].num = inf;
        rep(l0, node[index[0]].next.size()) {
            int temp = node[index[0]].next[l0];
            node[temp].num--;
        }
        sort(index.begin(), index.end(),
             [&](int x, int y) { return node[x].num < node[y].num; });
    }

    node[index[0]].answer = c[n - 1];

    ll all_answer = 0;
    rep(i, n - 1) { all_answer += min(node[a[i]].answer, node[b[i]].answer); }

    cout << all_answer << endl;
    repd(i, 1, n + 1) { cout << node[i].answer << " "; }
    cout << endl;

    return 0;
}

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

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}


Measured memory_bytes: 1152
N = int(input())
H = list(map(int,input().split()))

flag = 0
c = [0]*N
for i in range(N):
    if i == 0:
        pass
    else:
        if H[i]-H[i-1] >= 1:
            H[i] -= 1
            c[i] = 1
        elif H[i]-H[i-1] == 0:
            pass
        elif H[i]-H[i-1] == -1:
            if i == 1:
                H[i-1] -= 1
                c[i-1] = 1
            else:
                if H[i-2] <= H[i] and c[i-1] == 0:
                    H[i-1] -= 1
                    c[i-1] = 1
                else:
                    flag = 1
                    break
        elif H[i]-H[i-1] < -1:
            flag = 1
            break
if flag == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 14708
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
using namespace std;

int main(){
  ll k,a,b;
  ll max,min;
  cin >> k >> a >> b;
  if(k<=a){
    cout << k+1 << endl;
    return 0;
  }
  if(b-a<=1){
    cout << k+1 << endl;
    return 0;
  }
  ll sum = a;
  ll num = a-1;
  ll syo = (k-num)/2;
  ll ama = (k-num)%2;
  sum = sum+syo*(b-a);
  sum+=ama;
  cout << sum << endl;
}

Measured memory_bytes: 256
main :: IO ()
main = do
    (_:t:a:hs) <- getParams
    print $ solve t a hs

getParams :: IO [Double]
getParams = map read . words <$> getContents

solve :: Double -> Double -> [Double] -> Int
solve t a hs = snd $ minimum dis
  where
    dis  = zip ds [1..]
    ds   = map (abs . subtract a) ts
    ts   = map (t `temperature`) hs
 
temperature :: Double -> Double -> Double
temperature t h = t - h * 0.006


Measured memory_bytes: 1148
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

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

const UINT mod = 1000000007;

UINT PowMod(UINT x, UINT y)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = PowMod(x, y / 2);
		return tmp * tmp % mod;
	}
	else
	{
		auto tmp = PowMod(x, y / 2);
		return (tmp * tmp % mod) * x % mod;
	}
}

UINT getModInv(UINT N)
{
	return PowMod(N, mod - 2);
}

struct uf
{
	vector<INT> p;

	uf(INT n) : p(n)
	{
		for (size_t i = 0; i < n; i++)
		{
			p[i] = i;
		}
	}

	INT rt(INT n)
	{
		return p[n] == n ? n : p[n] = rt(p[n]);
	}

	void un(INT n, INT m)
	{
		p[rt(n)] = p[rt(m)];
	}

	bool eq(INT n, INT m)
	{
		return rt(n) == rt(m);
	}
};

int main()
{
	INT n;
	cin >> n;
	vector<INT>	a(n), x(n);

	INT sum_i = 0, inv = 1;
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
		sum_i += a[i] * inv;
		inv *= -1;
	}

	x[0] = sum_i / 2;

	cout << x[0] * 2 << ' ';
	for (size_t i = 1; i < n; i++)
	{
		x[i] = a[i - 1] - x[i - 1];
		cout << x[i] * 2;
		if (x[i] != n - 1)
		{
			cout << ' ';
		}
	}
	return 0;
}


Measured memory_bytes: 2816
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		ll a,b,v,w;
		scanf("%lld%lld%lld%lld",&a,&v,&b,&w);
		int t;
		scanf("%d",&t);
		ll dis = abs(a-b);
		ll dis2 = (v-w)*t;
		dis<=dis2? puts("YES"): puts("NO");
		return 0;
}  


Measured memory_bytes: 3700
#include<iostream>
using namespace std;
int m,a,b;
bool isp[1<<17];
main()
{
	isp[0]=isp[1]=1;
	for(int i=2;i<1<<17;i++)
	{
		if(isp[i])continue;
		for(int j=i+i;j<1<<17;j+=i)isp[j]=1;
	}
	while(cin>>m>>a>>b,m)
	{
		int ansp,ansq,ans=0;
		for(int i=2;i<=m/2;i++)
		{
			if(isp[i])continue;
			for(int j=i;j<=m/i&&j<=i*b/a;j++)
			{
				if(isp[j])continue;
				if(ans<i*j)
				{
					ans=i*j;
					ansp=i;
					ansq=j;
				}
			}
		}
		cout<<ansp<<" "<<ansq<<endl;
	}
}



Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;
typedef pair<int,int> pr;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main(){
    ll n,k; cin >> n >> k;
    ll k2 = k/2;

    ll count1 = 0, count2 = 0;

    while(k2 <= n){
        count2 ++;
        k2 += k;
    }

    count1 = n/k;
    if(k%2 != 0) count2 = 0;

    cout << setprecision(20) << (pow(count1,3) + pow(count2,3));

}

Measured memory_bytes: 4180
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i,n) cin >> vec[i];
    int cnt=0;
    int i=0;
    while(cnt<=n){
        i=vec[i];
        --i;
        ++cnt;
        if(i==1){
            cout << cnt << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
#include <algorithm>
using namespace std;
using LL = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = 1e9;
const int E = numeric_limits<int>::min();


int main(void)
{
    int N;
    cin >> N;
    vector<LL> A(N);
    rep (i, N){
        cin >> A[i];
    }

    LL stepLadder = 0;
    for (int i = 1; i < N; i++){
        if (A[i] < A[i-1]){
            stepLadder += A[i-1] - A[i];
            A[i] += A[i-1] - A[i];
        }
    }

    printf("%lld\n", stepLadder);

    return 0;
}

Measured memory_bytes: 4780
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
LL K,A,B;
int main(){
	scanf("%lld%lld%lld",&K,&A,&B);
	if(A >= B){
		printf("%lld\n",K+1);
		return 0;
	}
	LL tmp = A - 1;
	LL rest = K - tmp;
	LL ans = rest/2 * (B-A) + A + (rest & 1);
	ans = max(ans,K+1);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int r[200001],c[200001];
ll v[200001];
ll ban[3001][3001];
ll dp[3001][3001][4];
int main(){
	int R,C,K;
	scan(R>>C>>K);
	rep(k,K){
		scan(r[k]>>c[k]>>v[k]);
		r[k]--;
		c[k]--;
		ban[r[k]][c[k]]=v[k];
	}
	dp[0][0][0]=0;
	dp[0][0][1]=ban[0][0];
	rep(i,R){
		rep(j,C){
			rep(k,4){
				if(i!=R-1){
					dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
					dp[i+1][j][1]=max(dp[i+1][j][1],dp[i][j][k]+ban[i+1][j]);
				}
				if(j!=C-1){
					if(k<3){
						dp[i][j+1][k+1]=max(dp[i][j+1][k+1],dp[i][j][k]+ban[i][j+1]);
					}
					dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
				}
			}
		}
	}
	ll ans=0;
	rep(k,4){
		ans=max(ans,dp[R-1][C-1][k]);
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 358188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int N;
  string S;
  cin>>N>>S;
  int ans=0;
  
  vector<int> v(N-1);//i番目で分断した場合の両方に含まれる文字の種類の最大値
  rep(i,N-1){//全部求める
    set<int> s;
    for(int j=0;j<=i;j++) s.insert(S[j]);
    for(int k=i+1;k<N;k++){
      if(s.count(S[k])){
        v[i]++;
        s.erase(S[k]);
      }
    }
    ans=max(ans,v[i]);//v[i]のMAXが答え
  }
  cout<<ans<<endl;
  return 0;
}

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

def selection_sort(A):
    cnt = 0
    for i in range(len(A)-1):
        minj = i
        for j in range(i+1,len(A)):
            if A[j] < A[minj]:
                minj = j
        if i != minj:
            cnt += 1
        A[minj],A[i] = A[i],A[minj]
    print(*A)
    print(cnt)

selection_sort(A)


Measured memory_bytes: 5608
n,a,b,c,d = map(int, input().split())
s = input()
ans = ["Yes","No"]
t = 0
if b < c:
  if "##" in s[min(a,b)-1:max(c,d)]:
    t = 1
else:
  if "##" in s[a-1,c] or "##" in s[b-1:d]:
    t = 1
if c > d:
  if not "..." in s[b-2:d+1]:
    t = 1
print(ans[t])

Measured memory_bytes: 3572
def resolve():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    p.sort()

    ans = 0
    for i in range(102):
        if i in p:
            continue
        if abs(x - ans) > abs(x - i):
            ans = i
    print(ans)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 8952
N = int(input())
W = [input() for i in range(N)]

S=0

for i in range(N-1):
    if W.count(W[i])!=1:
        ans="No"
        break
    elif W[i][-1]==W[i+1][0]:
         S=S+1

if S==N-1:
    ans="Yes"
else:
    ans="No"
    
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=105;
ll a[N],val[N];
vi v[4],v2[4];
int fun(int i,int j,int k,int c)
{
  ll done=(ll)(i+j+k)*a[1]+j+2*k;
  if(done>c) return 0;
  int take=(c-done)/(a[1]+3);
  return v2[0][i]+v2[1][j]+v2[2][k]+v2[3][take];
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,c;
  cin>>n>>c;
  rep(i,1,n+1) cin>>a[i]>>val[i],v[a[i]-a[1]].pb(val[i]);
  rep(i,0,4) sort(all(v[i])),reverse(all(v[i]));
  rep(i,0,4)
    {
      v2[i].resize(sz(v[i])+1);
      v2[i][0]=0;
      rep(j,0,sz(v[i]))
	v2[i][j+1]=v2[i][j]+v[i][j];
    }
  int ans=0;
  rep(i,0,sz(v[0])+1)
    rep(j,0,sz(v[1])+1)
    {
      ll done=(ll)(i+j)*a[1]+j;
      if(done>c) continue;
      int low=0,high=sz(v[2]);
      while(high-low>=5)
	{
	  int mid1=low+(high-low+1)/3;
	  int mid2=high-(high-low+1)/3;
	  if(fun(i,j,mid1,c)>=fun(i,j,mid2,c)) high=mid2;
	  else low=mid1;
	}
      rep(k,low,high+1)
	ans=max(ans,fun(i,j,k,c));
    }
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

namespace flow {

class bipartite_matching {
private:

  int V;
  vector<vector<int>> G;
  vector<int> match;
  vector<bool> used;

  bool dfs(int v) {
    used[v] = 1;
    for(auto& u: G[v]) {
      int w = match[u];
      if(w < 0 || (!used[w] && dfs(w))) {
        match[v] = u;
        match[u] = v;
        return true;
      }
    }
    return false;
  }


public:

  bipartite_matching(int V): V(V) {
    G.resize(V), match.resize(V), used.resize(V);
  }

  void add_edge(int u, int v) {
    G[u].push_back(v);
    G[v].push_back(u);
  }

  int maximum_matching() {
    int ret = 0;
    match.clear(), match.resize(V, -1);
    rep(v, V) {
      if(match[v] < 0) {
        used.clear(), used.resize(V, 0);
        if(dfs(v)) { ret ++; }
      }
    }
    return ret;
  }
};

}

int main() {

  int N, M, L;
  while(cin >> N >> M >> L && (N|M|L)) {
    int D[N][N]; rep(i, N) rep(j, N) D[i][j] = inf; rep(i, N) D[i][i] = 0;
    rep(i, M) {
      int u, v, d; cin >> u >> v >> d;
      minimize(D[u][v], d);
      minimize(D[v][u], d);
    }

    int P[L], T[L];
    rep(i, L) {
      cin >> P[i] >> T[i];
    }

    rep(k, N) rep(i, N) rep(j, N) {
      minimize(D[i][j], D[i][k] + D[k][j]);
    }

    flow::bipartite_matching bp(2 * L);

    rep(i, L) rep(j, L) {
      if(i == j) continue;
      if(D[P[i]][P[j]] <= T[j] - T[i]) {
        bp.add_edge(i, L + j);
      }
    }

    cout << L - bp.maximum_matching() << endl;

  }
  
  return 0;
}

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

int main()
{
  int count=0;
  int n;
  cin>>n;
  char a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  
  for(int i=0;i<n-2;i++)
    if(a[i]=='A'&&a[i+1]=='B'&&a[i+2]=='C')
      count++;
  cout<<count;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

#ifdef __APPLE__
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...)
#endif

const int N = (int)1e6 + 123;
const int MOD = (int)1e9 + 7;
const int inf = (int)5e8;
const long long infll = (long long)1e17;


long long h[N];
long long h1[N];

void solve() {
    int n;
    long long a, b;
    scanf("%d %lld %lld", &n, &a, &b);
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%lld", &h[i]);
        sum += h[i];
    }
    long long l = 0;
    long long r = 1e9 + 123;
    while (r - l > 1) {
        long long mid = (r + l) / 2;
        long long used = 0;
        for (int i = 0; i < n; ++i) {
            h1[i] = h[i] - mid * b;
            h1[i] = max(0ll, h1[i]);
            if (h1[i] > 0) {
                used += (h1[i] + (a - b) - 1) / (a - b);
            }
        }
        if (used <= mid) {
            r = mid;
        } else {
            l = mid;
        }
    }
    printf("%lld\n", r);
}

int main() {
#ifdef __APPLE__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int pre[100005],bk[100005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	int mx=0,t1,t2;
	pre[0]=a[0];
	for(int i=1;i<n;i++)
		pre[i]=__gcd(pre[i-1],a[i]);
	bk[n-1]=a[n-1];
	for(int i=n-2;i>=0;i--)
		bk[i]=__gcd(bk[i+1],a[i]);
	int ans=0;
	for(int i=0;i<n;i++)
		ans=max(ans,__gcd(pre[i-1],bk[i+1]));
	printf("%d\n",ans);
}

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

int main() {
	int a , b , c;
	cin >> a >> b >> c;
	if (a * b < c) {
		cout << a*b << endl;
	}
	else if (a * b > c) {
		cout << c << endl;
	}
	else {
		cout << c << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
static const ll LL_MAX = (ll)1 << 55;

int main()
{
	ll n, a, b; cin >> n >> a >> b;
	ll ans = 0;
	ll x[100001] = {};
	repe(i, 1, n) {
		cin >> x[i];
		if (i >= 2) ans += min((x[i] - x[i - 1])*a, b);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import Foundation
func toTuple<T>(_ args: [T]) -> (T, T, T, T) { (args[0], args[1], args[2], args[3]) }
func readInts() -> [Int] { readLine()!.split(separator: " ").map { Int($0)! } }

let main = {
  let (a, b, c, d) = toTuple(readInts())
  if b < c || a > d { print(0); return }
  if a >= c && b <= d { print(b - a); return }
  if a <= c && b >= d { print(d - c); return }
  if a <= c && b >= c && b <= d { print(b - c); return }
  if a >= c  && a <= d && b >= d { print(d - a); return }
}
main()


Measured memory_bytes: 13600
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define input() for(int i=0;i<n;i++)cin>>a[i];
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int n, k, w[105], v[105], ans;
int dp[105][500005];
signed main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= k; j++)dp[i][j] = -1;
	}
	dp[1][0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= k; j++) {
			if (dp[i][j] != -1) {
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
				if (j + w[i] <= k) {
					dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
				}
			}
		}
	}
	for (int i = 1; i <= k; i++) {
		ans = max(ans, dp[n + 1][i]);
	}
	cout << ans << endl;
	endre;
}

Measured memory_bytes: 289024
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
  string s;
  cin>>s;
  for(int i=0; i<s.size(); i++){
    if(s[i]=='1'){s[i]='9';}
    else{s[i]='1';}
  }
  cout<<s<<endl;
}


Measured memory_bytes: 256