akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

constexpr int M = 13333;
ll dp[M][2][111];

int main(int argc, char const *argv[]) {
    int d; string s; cin>>s>>d;
    int n = s.length();
    memset(dp,0,sizeof(dp));

    dp[0][0][0] = 1ll;

    rep(i,n) {
        int D = (int)(s[i]-'0');
        rep(j,2) {
            for (int x = 0; x <= (j?9:D); ++x) {
                rep(k,d) {
                    dp[i+1][j||(x < D)][(k+x)%d] = (dp[i+1][j||(x < D)][(k+x)%d]+dp[i][j][k])%MOD;
                }
            }
        }
    }


    cout << (MOD+dp[n][0][0]+dp[n][1][0]-1)%MOD << endl;

    return 0;
}


Measured memory_bytes: 23424
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int find_left(int i, vector<int>& R) {
  int m = R.size();
  if(R[m-1]<i) {
    return R[m-1];
  }
  int ok = 0;
  int ng = m-1;
  while(ng-ok>1) {
    int mid = (ok+ng)/2;
    if(R[mid]<i) {
      ok=mid;
    } else {
      ng=mid;
    }
  }
  return R[ok];
}

int find_right(int i, vector<int>& L) {
  if(i<L[0])
    return L[0];
  int m = L.size();
  int ok = m-1;
  int ng = 0;
  while(ok-ng>1) {
    int mid = (ok+ng)/2;
    if(L[mid]>i) {
      ok = mid;
    } else {
      ng=mid;
    }
  }
  return L[ok];
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  string s;
  cin>>s;
  vector<int> Ls;
  vector<int> Rs;
  int n = s.size();
  rep(i,n) {
    if(s[i]=='R')
      Rs.push_back(i);
    else
      Ls.push_back(i);
  }
  vector<int> ans(n);
  rep(i,n) {
    if(s[i]=='L') {
      int j = find_left(i,Rs);
      //cout << "i=" << i << ",j=" << j << endl;
      if((i-j)%2==0) {
	ans[j]++;
      } else {
	ans[j+1]++;
      }
    } else {
      int j = find_right(i,Ls);
      //cout << "i=" << i << ",j=" << j << endl;
      if((j-i)%2==0) {
	ans[j]++;
      } else {
	ans[j-1]++;
      }
    }
  }
  rep(i,n) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	char c; cin >> c;
	cout << char(c+1) << endl;


}



Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

bool do_dp(vector<int> v,int sum){
	vector<bool> dp;
	dp.assign(8080,false);
	dp[0] = true;
	if(sum<0) return false;
	for(int i=0;i<v.size();i++){
		for(int j=8080;j>=0;j--){
			if(j-v[i]>=0&&dp[j-v[i]]) dp[j] = true;
		}
	}
	if(dp[sum]) return true;
	else return false;
}

int main(){
	char s[8080];
	int x,y;
	int cnt = 0;
	bool tate_desu = false;
	vector<int> tate,yoko;
	scanf("%s%d%d",s,&x,&y);
	for(int i=0;s[i]!='\0';i++){
		if(s[i]=='T'){
			if(tate_desu){
				tate_desu = false;
				tate.push_back(cnt);
			}else{
				tate_desu = true;
				yoko.push_back(cnt);
			}
			cnt = 0;
		}else{
			cnt++;
		}
	}
	if(tate_desu) tate.push_back(cnt);
	else yoko.push_back(cnt);
	int tate_total = 0;
	int yoko_total = 0;
	for(int i=0;i<tate.size();i++) tate_total += tate[i];
	for(int i=0;i<yoko.size();i++) yoko_total += yoko[i];
	int ue_sum = (tate_total + y) / 2;
	int migi_sum = (yoko_total + x) / 2 - yoko[0];
	reverse(yoko.begin(),yoko.end());
	yoko.pop_back();
	if((tate_total+y)%2!=0||(yoko_total+x)%2!=0) printf("No\n");
	else if(do_dp(tate,ue_sum)&&do_dp(yoko,migi_sum)) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 384
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        mut abc: [u8; 3]
    };
    abc.sort();
    if (abc[0] == abc[1]) && (abc[0] == 5) && (abc[2] == 7) {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 2068
#include <stdio.h>

int		main()
{
	long	squares;
	long	H, W, r;

	r = scanf("%ld %ld\n", &H, &W);
	if (r == -1)
		return (0);
	if (H == 1 || W == 1)
		squares = 1;
	else if (H * W % 2)
		squares = (H * W) / 2 + 1;
	else
		squares = (H * W) / 2;
	printf("%ld\n", squares);
	return (0);
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
for(;;){
	int l[4],o,s,i,j,n,k,c=0;
	scanf("%d",&n);
	if(n==0000){
		break;
	}
	else if(n%1111==0)
	{
		printf("NA\n");
	}
	else{
		while(n!=6174){
			l[0]=n/1000;
			l[1]=n/100%10;
			l[2]=n/10%10;
			l[3]=n%10;
			for(i=0;i<4;i++){
				for(j=i+1;j<4;j++){
					if(l[i]<l[j]){	
						k=l[i];
						l[i]=l[j];
						l[j]=k;
					}
				}
			}
			o=l[0]*1000+l[1]*100+l[2]*10+l[3];
			s=l[3]*1000+l[2]*100+l[1]*10+l[0];
			n=o-s;
			c++;
		}
	printf("%d\n",c);
	}
}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair
 
using namespace std;
 
const LL MOD=1e9+7;

int main()
{
	vector <int> v={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	cin>>n;
	cout<<v[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]

n,m = map(int, input().split())

ans = [0] * n

for i in range(m):
    a, b = map(int, input().split())
    ans[a - 1] += 1
    ans[b - 1] += 1

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





Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
 
int n;
ll knap(ll n, vector<pair<int,int>> &v) {
  vector<ll> dp(n+10, 0);
  iota(dp.begin(), dp.end(), 0);
  for(int j=0;j<v.size();j++) {
    //cout << "knap " << v[j].first  << " " << v[j].second <<endl;
    for(int i=0;i<=n-v[j].first;i++) {
      //cout << dp[i+v[j].first] << " " << dp[i] + v[j].second <<endl;
      dp[i+v[j].first] = max(dp[i+v[j].first],dp[i]+v[j].second);
    }
  }
//  for(int i=0;i<n;i++) cout << dp[i] <<" "; cerr <<endl;
  return dp[n];
}
int main(){
  cin.tie(0); ios_base::sync_with_stdio(0);
  cin >> n;
  vector<int> A(3), B(3);
  for(int i=0;i<3;i++) cin >> A[i];
  for(int i=0;i<3;i++) cin >> B[i];
  for(int i=0;i<3;i++) {
    if (A[i] > B[i]) {
      swap(A[i], A[2]), swap(B[i], B[2]);
    }
  }
  int cnt = 0;
  vector<pair<int,int>> v1, v2;
  v1.push_back({1,1});
  for(int i=0;i<3;i++) {
    if (A[i]<=B[i]) {
      cnt++;
      v1.push_back({A[i], B[i]});
    }
    else v2.push_back({B[i], A[i]});
  }
  ll tot=knap(n, v1);
  tot=knap(tot,v2);
  cout << tot <<endl;
}

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

int main() {
	int a, b;
	int empty;
	int result;

	cin >> a;
	cin >> b;

	if (b == 1) {
		cout << 0;
		return 0;
	}

	empty = a;
	result = 1;

	while (empty < b) {
		empty += a - 1;
		result++;
	}

	cout << result;

	return 0;
}

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


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int n = vals[0];
		//string res="";

		//int y = vals[0];
		//int x = vals[1];

		int[] vals = parseAry(Console.ReadLine().Split(cs));
		int res = 0;

		if (vals[0] + vals[1] <= vals[2] * 2) {//no half
			res = vals[3] * vals[0] + vals[4] * vals[1];

		} else {
			if (vals[0] >= vals[2] * 2) { res += vals[2] * vals[3] * 2; vals[4] = Math.Max(0, vals[4] -= vals[3]); vals[3] = 0; }
			if (vals[1] >= vals[2] * 2) { res += vals[2] * vals[4] * 2; vals[3] = Math.Max(0, vals[3] -= vals[4]); vals[4] = 0; }
			int m=Math.Min(vals[3], vals[4]);
			res += m * vals[2]*2;
			vals[3] -= m;
			vals[4] -= m;
			res += vals[3] * vals[0] + vals[4] * vals[1];
		}



			//deug
			Console.WriteLine(res);

		return;
	}


	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryl(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}



	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

}

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

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int fa[200006];
struct node
{
    int x,y,id;
}s[200006];
struct node2
{
    int qi,mo,bian;
}t[200006];
bool cmp(node a,node b)
{
    return a.x<b.x;
}
bool cmp2(node a,node b)
{
    return a.y<b.y;
}
bool cmp3(node2 a,node2 b)
{
    return a.bian<b.bian;
}
int find(int x)
{
    return fa[x]==x ? x:fa[x]=find(fa[x]);
}
void unio(int x,int y)
{
    int fx=find(x);int fy=find(y);
    if(fx!=fy)
    fa[fy]=fx;
}
int main()
{
    int q,n;long long int sum;
    scanf("%d",&n);
        q=0;sum=0;
        memset(s,0,sizeof(s));
        memset(t,0,sizeof(t));
        for(int i=1;i<=n;i++)
        {
            scanf("%d%d",&s[i].x,&s[i].y);
            s[i].id=i;
            fa[i]=i;
        }
        sort(s+1,s+n+1,cmp);
        for(int i=1;i<n;i++)
        {
            ++q;
            t[q].qi=s[i].id;
            t[q].mo=s[i+1].id;
            t[q].bian=s[i+1].x-s[i].x;
        }
        sort(s+1,s+n+1,cmp2);

        for(int i=1;i<n;i++)
        {
            ++q;
            t[q].qi=s[i].id;
            t[q].mo=s[i+1].id;
            t[q].bian=s[i+1].y-s[i].y;
        }

        sort(t+1,t+q+1,cmp3);
        for(int i=1;i<=q;i++)
        {
            if(find(t[i].qi)!=find(t[i].mo))
            {
                sum=sum+t[i].bian;
                unio(t[i].qi,t[i].mo);
            }
        }
        printf("%lld\n",sum);

}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
int n,x=0,y=0;
std::vector<int> a;
int main(){
  cin >> n;
  a.resize(n);
  for (size_t i = 0; i < n; i++) {
    cin >> a[i];
    if(a[i] % 4 == 0){
      x++;
    }else if(a[i] % 2 == 0){
      y++;
    }
  }
  if(y%2 == 1) y--;

  cout << (n/2 <= x+(y/2) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    int n;
    int m;
 
   cin >> n >> m;
int l, k=0;
  
int a[2*m]={};
  
    while(cin >> l){
      
     // cout << l << endl;
        a[k] = l;
       
       //  cout << a[k] << endl;
      
        k++;
    }
  

  

  
  
    for(int j = 1;j<=n;j++){
      
      int ans = 0;
      
      for(int i = 0;i<2*m;i++){
      
         if(a[i]==j){
        
            ans += 1;
          }
      
       }
      
     cout << ans << endl;
  
  
    }
  
  // cout << ans << endl;
  // cout << m << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a, b;
    char op;
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        if(op=='?'){
            break;
        }else if(op=='+'){
            printf("%d\n", a+b);
        }else if(op=='-'){
            printf("%d\n", a-b);
        }else if(op=='*'){
            printf("%d\n", a*b);
        }else if(op=='/'){
            printf("%d\n", a/b);
        }
    }
    return 0;
} 

Measured memory_bytes: 1852
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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


























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


Measured memory_bytes: 3568
package main

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

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 main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	min := n
	for i := 0; i <= n; i++ {
		c, t := 0, i
		for t > 0 {
			c += t % 6
			t /= 6
		}

		t = n-i
		for t > 0 {
			c += t % 9
			t /= 9
		}

		if min > c {
			min = c
		}
	}

	fmt.Println(min)
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
uint32_t rand32() {
    static uint32_t x = 12345;
    x ^= x << 13; x ^= x >> 17; x ^= x << 5;
    return x;
}
// https://www.slideshare.net/iwiwi/2-12188757
struct node_t {
    int val;
    node_t *lch, *rch;
    int cnt;
    int minv, minp;
    node_t(int v) : val(v), lch(nullptr), rch(nullptr), cnt(1), minv(v), minp(0) {}
};
int count(node_t *t) { return !t ? 0 : t->cnt; }
int minval(node_t *t) { return !t ? INT_MAX : t->minv; }
int minpos(node_t *t) { return !t ? 0 : t->minp; }
node_t *update(node_t *t) {
    t->cnt = count(t->lch) + count(t->rch) + 1;
    int x = minval(t->lch), y = t->val, z = minval(t->rch);
    if (x < y && x < z) {
        t->minv = x;
        t->minp = minpos(t->lch);
    } else if (y < x && y < z) {
        t->minv = y;
        t->minp = count(t->lch);
    } else {
        t->minv = z;
        t->minp = count(t->lch) + 1 + minpos(t->rch);
    }
    return t;
}
node_t *merge(node_t *l, node_t *r) {
    if (!l || !r) return !l ? r : l;
    if (rand32() % (count(l) + count(r)) < count(l)) {
        l->rch = merge(l->rch, r);
        return update(l);
    } else {
        r->lch = merge(l, r->lch);
        return update(r);
    }
}
pair<node_t*, node_t*> split(node_t *t, int k) {
    if (!t) return {nullptr, nullptr};
    if (k <= count(t->lch)) {
        auto s = split(t->lch, k);
        t->lch = s.second;
        return {s.first, update(t)};
    } else {
        auto s = split(t->rch, k - count(t->lch) - 1);
        t->rch = s.first;
        return {update(t), s.second};
    }
}
int main()
{
    int N; cin >> N;
    node_t *odd = nullptr, *even = nullptr;
    for (int i = 0; i < N; i++) {
        int p; cin >> p;
        if (i % 2 == 0) {
            odd = merge(odd, new node_t(p));
        } else {
            even = merge(even, new node_t(p));
        }
    }
    using Tup = tuple<int, node_t*, node_t*>;
    priority_queue<Tup, vector<Tup>, greater<Tup>> Q;
    Q.emplace(minval(odd), odd, even);
    while (!Q.empty()) {
        int v; node_t *odd, *even;
        tie(v, odd, even) = Q.top();
        Q.pop();
        cout << minval(odd) << ' ';
        int p = minpos(odd);
        node_t *a, *b;
        tie(a, odd) = split(odd, p);
        tie(b, even) = split(even, p);
        if (a) Q.emplace(minval(a), a, b);
        tie(ignore, odd) = split(odd, 1);
        cout << minval(even) << ' ';
        int q = minpos(even);
        tie(a, odd) = split(odd, q);
        tie(b, even) = split(even, q);
        if (b) Q.emplace(minval(b), b, a);
        tie(ignore, even) = split(even, 1);
        if (odd) Q.emplace(minval(odd), odd, even);
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 11892
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <iomanip>
#include <random>
#include <queue>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <numeric>
#include <bitset>
#include <cassert>
#include <sstream>
#include <bitset>
#include <list>

using namespace std;

#define all(x) x.begin(), x.end()
#define z(x) fixed << setprecision(x)
#define sqr(x) ((x)*(x))
#define nl '\n'
#define eb emplace_back
#define elif else if
#define dbg(a) cout << (#a) << " " << a << nl;
#define eb emplace_back
#define mineq(a, b) (a) = min(a, b)
#define maxeq(a, b) (a) = max(a, b)
#pragma comment(linker, "/STACK:216777216")

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned short int usht;
mt19937 rnd(22353128);

const ll LINF = numeric_limits<ll>::max();
const int INF = 1e9;
const int MAXN = 1e6;
const double EPS = 1e-9;

inline void IO() {
#ifdef _DIVAN
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.setf(ios::fixed);
	cout.precision(10);
}

#define int ll
#define double long double

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	map<int, int> m;
	int ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		ans += m[a[i] + i];
		m[i - a[i]]++;
	}
	cout << ans;
}

signed main() {
	IO();
	int t;
	t = 1;
	while (t--)
		solve();
	return 0;
}

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

using namespace std;

int main() {
	int n;
  	cin >> n;
  	float a[n];
  	for(int i=0;i<n;i++) {
    	cin >> a[i];
    }
  	float sum = 0;
  	for(int i=0;i<n;i++) {
    	sum += 1/a[i];
    }
  	float ans = 1/sum;
  	cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N, A, x;
  	cin >> N >> A;
  	x = N % 500;
	
  	if (x <= A) {
      cout << "Yes" << endl;
    }
  	else {
      cout << "No" << endl;
    }
}

Measured memory_bytes: 256
loop {
  n=gets.to_i
  n==0&&break

  pts=gets.split.map(&:to_i)

  m=pts.sum.to_f/n
  a2=(pts.map{|pt| (pt-m)**2 }.sum / n)
  a=Math.sqrt(a2)
  puts "%.8f" % a
}


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

void solve(int i, int used, int N, string s, vector<string> &res) {
    if(i == N) {
        res.push_back(s);
        return;
    }
    REP(j, used) {
        string p(1, 'a' + j);
        string t = s + p;
        solve(i + 1, used, N, t, res);
    }
    string p(1, 'a' + used);
    solve(i + 1, used + 1, N, s + p, res);
}

int main() {
    int N;
    cin >> N;
    vector<string> res;
    solve(1, 1, N, "a", res);
    sort(ALL(res));
    for(auto s : res) {
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 7796
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		long i=0,j=0,k=0;
		Scanner sc = new Scanner(in);
		long x = parseLong(sc.next());
		sc.close();
		long a=(x/11)*2;
		long mod=x%11;
		if(mod>0 && mod<=6) {
			a+=1;
		} else if(mod>6){
			a+=2;
		}
		out.println(a);
	}
}


Measured memory_bytes: 25044
import java.util.*;

class Main{
	
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		
		long M = 0L;
		long A = 0L;
		long R = 0L;
		long C = 0L;
		long H = 0L;
		
		char initial ;
		for(int i = 0 ; i < N ; i ++){
			initial = sc.next().charAt(0);
			switch(initial){
			case 'M':
				M = M + 1L;
				break;
			case 'A':
				A = A + 1L;
				break;
			case 'R':
				R = R + 1L;
				break;
			case 'C':
				C = C + 1L;
				break;
			case 'H':
				H = H + 1L;
				break;
			}
		}
		
		long total =   M * A * R 
		             + M * A     * C 
		             + M * A         * H 
		             + M     * R * C 
		             + M     * R     * H
		             + M         * C * H
		             +     A * R * C 
		             +     A * R     * H 
		             +     A     * C * H
		             +         R * C * H;
		
		System.out.println( total);
	}
}


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

int main()
{
	int x;
	string s;
	cin>>x;
	switch(x)
	{
		case 22:
			s="Christmas Eve Eve Eve";
			break;
		case 23:
			s="Christmas Eve Eve";
			break;
		case 24:
			s="Christmas Eve";
			break;
		default:
			s="Christmas";
			break; 
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
V=[int(a) for a in input().split()]
able=min(N,K)
ans=0
 
for a in range(able+1):
    for b in range(able+1-a):
        if b==0:
            have=V[:a]
        else:
            have=V[:a]+V[-b:]
        have.sort()

        for i in range(min(a+b,K-a-b)+1):
            val=sum(have[i:])
            if ans<val:
                ans=val
 
print(ans)


Measured memory_bytes: 3064
import java.util.*;
import java.math.*;
import java.text.*;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			int p = in.nextInt();
			if((n|p)==0) break;
			int[] counts = new int[n];
			Arrays.fill(counts, 0);
			int cup = p;
			for(int i=0;;i=(i+1)%n){
				if(cup==0){
					cup = counts[i];
					counts[i] = 0;
				}else{
					cup--;
					counts[i]++;
					if(counts[i]==p){
						System.out.println(i);
						break;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(){
	int m,d,cnt=0;
	cin >>m>>d;
	for (int i=1;i<=m;i++)
		for(int j=1;j<=d;j++){
			if ((j%10)>=2&&(j/10)>=2&&(j%10)*(j/10)==i){
				cnt++;
			}
		}
	cout <<cnt<<endl;
}

Measured memory_bytes: 256
// -YDK- {{{
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <numeric>
#include <string>
#include <cstdio>
#include <vector>
#include <tuple>
#include <cmath>
#include <queue>
#include <regex>
#include <set>
#include <map>
using namespace std;
#define eb emplace_back
#define emp emplace
#define fi first
#define se second
#define debug(...) fprintf(stderr, __VA_ARGS__ )
#define outl(x) cout << (x) << '\n'
#define outl2(x,y) cout << (x) << ' ' << (y) << '\n'
#define endl '\n'
#define rep(i,n) for(int i=0; i<(int)(n); ++i)
#define ALL(x) x.begin(), x.end()
#define YES(f,y,n) cout << ((f)? (#y):(#n)) << '\n'
#define ODD(n) ((n)&1)
#define EVEN(n) (!ODD(n))
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
template<class T>using MaxHeap = priority_queue< T, vector<T>, greater<T> >;
using ll = long long;
using pii = pair<int, int>;
using byte= unsigned char;
inline bool inside(int x, int y, int W, int H) { return x>=0 && y>=0 && x<W && y<H; }
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int dx[] = {1, 0, -1, 0};
constexpr int dy[] = {0, 1, 0, -1};
struct Point: public pii {
    int &x = this->first,   &y = this->second;
    Point(int x, int y): pii(x, y) {}
};
// }}}
constexpr int LIM = (int)1e5 + 5;

signed main(void)
{
    cin.tie(nullptr), ios::sync_with_stdio(false);

    int N;
    cin >> N;
    outl( N * N * N);

    return 0;
}




Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,mx=0,cnt=0;
    scanf("%d",&n);
    for(int i=0;i<=19;i++)
        if(n&(1<<i))mx=i,cnt++;
    printf("%d %d\n",mx+1,2*mx+cnt-1);
    for(int i=1;i<=mx;i++)printf("%d %d 0\n",i,i+1),printf("%d %d %d\n",i,i+1,1<<(i-1));
    int now=(1<<mx);
    for(int i=mx-1;i>=0;i--)
        if(n&(1<<i))printf("%d %d %d\n",i+1,mx+1,now),now+=(1<<i);
    return 0;
}

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  a=max(a,b);
  if(c%a==0){
    cout<<c/a<<endl;
  }
  else{
    cout<<c/a+1<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    ////////////////////////////
    //入力
    int n,k;
    cin >> n >> k;

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

    //計算
    sort(cnt, cnt+n+1);
    int types = 0;

    for (int i=0; i<n+1; i++){
	if (cnt[i] > 0){
	    types++;
	}
    }
    
    int num = max(0, types-k);
    int ans = 0;
    int i = 0;
    while( cnt[i] == 0 ){
	i++;
    }
    for (int j=0; j<num; j++){
	ans += cnt[i];
	i++;
    }
    cout << ans << endl;
    ////////////////////////////
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

const int DIGIT_NUM = 9;
bool outputAdjst = false;

void puzzleCheck(int num[], int nowNumber, bool *bFound){
	int zeroCount = 0;
	int twoCount = 0;

	if( *bFound ) return ;

	for(int i = 0; i < DIGIT_NUM; i++){
		if( num[i] >= 3 ){
			num[i] -= 3;
			puzzleCheck(num, nowNumber, bFound);
			num[i] += 3;
		}
		
	}
	for(int i = 0; i < DIGIT_NUM - 2; i++){
		if( num[i] >= 1 && num[i+1] >= 1 && num[i+2] >= 1 ){
			--num[i];--num[i+1];--num[i+2];
			puzzleCheck(num, nowNumber, bFound);
			++num[i];++num[i+1];++num[i+2];
		}
	}

	for(int i = 0; i < DIGIT_NUM; i++){
		switch( num[i] ){
			case 0:
				zeroCount++;
				break;
			case 2:
				twoCount++;
				break;
		}
	}

	if( twoCount == 1 && zeroCount == DIGIT_NUM - 1 ){
		if( outputAdjst ) cout << ' ' << nowNumber;
		else cout << nowNumber;
		*bFound = true;
		outputAdjst = true;
	}

	return ;
}

int main(void){
	while( true ){
		int num[DIGIT_NUM] = {0,};
		bool clear = false;
		bool end = false;

		outputAdjst = false;

		for(int i = 0; i < 13; i++){
			int d = 0;
			if( scanf("%1d", &d) != 1 ){
				end = true;
				break;
			}
			num[d-1]++;
		}

		if( end ) break;
		
		for(int i = 0; i < DIGIT_NUM; i++){
			bool found = false;
			
			if( i > 0 ) num[i - 1]--;
			num[i]++;
			if( num[i] >= 5 ) continue;

			puzzleCheck(num, i + 1, &found);

			if( found ) clear = true;
		}
		if( clear ) cout << '\n';
		else cout << "0\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 10000
int dp[MAX_N];
int fib(int n){
    dp[0]=1;
    dp[1]=1;
    for(int i=2;i<=n;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[n];
}
int main(){
    int n;
    cin>>n;
    int ans=fib(n);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,m,p,c,d;
    string a,b;
    cin>>n>>m>>a>>b;
    c=max(n,m);
    d=min(n,m);
    p = c % d;
    while(p != 0)
    {
        c = d;
        d = p;
        p = c % d;
    }
    ll x=n/d,y=m/d,flag=1;
    for(int i=0;i<d;i++)
    {
        if(a[x*i]!=b[y*i])
        flag=0;
    }
    if(flag)
    {
        cout<<m*n/d<<endl;
    }
    else cout<<"-1"<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<climits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
int n;
ll l[100010],r[100010];
bool comp(ll &a,ll &b){
  return a>b;
}
int main(){
  scan(n);
  rep(i,n){
    scan(l[i]);scan(r[i]);
  }
  sort(l,l+n,comp);
  sort(r,r+n);
  ll lsum[100010],rsum[100010];
  lsum[0]=0;rsum[0]=0;
  rep1(i,n){
    lsum[i]=lsum[i-1]+l[i-1];
    rsum[i]=rsum[i-1]+r[i-1];
  }
  lsum[n+1]=lsum[n];
  rsum[n+1]=rsum[n];
  ll res=-rsum[1];
  rep1(i,n){
    res=max(res,lsum[i]-rsum[i-1]);
    res=max(res,lsum[i]-rsum[i]);
    res=max(res,lsum[i]-rsum[i+1]);
  }
  prin(res*2);
  
  

    
  
  
  

  return 0;
}


Measured memory_bytes: 3456
def DFS(N,X):
    if N==0:return 0 if X<=0 else 1
    elif X<=1+B[N-1]:
        return DFS(N-1,X-1)
    else:
        return P[N-1]+1+DFS(N-1,X-2-B[N-1])


n,x=map(int,input().split())
B,P=[1],[1]

for i in range(n):
    P.append(P[i]*2+1)
    B.append(B[i]*2+3)

print(DFS(n,x))

Measured memory_bytes: 38256
import math
N = int(input())
C = [list(map(int,input().split())) for _ in range(N)]


D = 0
for i in range(N-1):
    for j in range(i+1,N):
        x1 = C[i][0]
        y1 = C[i][1]
        x2 = C[j][0]
        y2 = C[j][1]
        D += math.sqrt( (x1-x2)**2 + (y1-y2)**2 )

print(2*D/N)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
const int MAXV = 50000;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
char text[MAXN];
int arr[MAXN];

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    char c;
    scanf("%c", &c);
    if (c >= 'A' && c <= 'Z') {
        printf("A\n");
    } else {
        printf("a\n");
    }
    return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N;
    cin >> N;
    map<int, int> m;
    REP(i, N) {
        int a;
        cin >> a;
        m[a]++;
    }

    int v = 0, h = 0;
    for (auto&& s : m) {
        if (s.second >= 2) {
            if (v > h) {
                h = s.first;
            }
            else {
                v = s.first;
            }
        }
        if (s.second >= 4) {
            v = s.first;
            h = s.first;
        }
    }

    cout << (ll)v * h << endl;
    return 0;
}

Measured memory_bytes: 4992
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{
using v64 = vector<long long>;

template<class Array>
v64 ruisekiwa(const Array &src, int N)
{
    v64 s(N, src[0]);
    for (int i = 1; i < N; ++i) s[i] = s[i-1] + src[i];
    return s;
}

inline long long partSum(const v64 &s, int l, int r)
{
    if (l > r) swap(l, r);
    if (r >= s.size()) return 0;
    return s[r] - (l <= 0 ? 0 : s[l-1]);
}
// }}}

int N;
vector<int> a, b, c;

signed main()
{
    cin >> N;
    a.resize(N);
    b.resize(N);
    c.resize(N);
    rep(i, 0, N) cin >> a[i];
    rep(i, 0, N) cin >> b[i];
    rep(i, 0, N) cin >> c[i];
    sort(ALL(a));
    sort(ALL(b));
    sort(ALL(c));

    vector<int> k(N);
    rep(i, 0, N) {
        k[i] = c.end() - upper_bound(ALL(c), b[i]);
    }

    auto s = ruisekiwa(k, N);

    i64 ans = 0;
    rep(i, 0, N) {
        int head = upper_bound(ALL(b), a[i]) - b.begin();
        ans += partSum(s, head, N-1);
    }

    cout << ans << endl;
    return 0;
}


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

int main(){
  int n; cin >> n;
  string s,t;
  cin >> s >> t;
  rep(i,n){
    cout << s.at(i) << t.at(i);
    if(i==n-1) cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, d, x;
    cin >> r >> d >> x;
    for (int i = 0; i < 10; i++) {
        x *= r;
        x -= d;
        cout << x << endl;
    }
}

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

using namespace std;

#ifndef errOut
#define errOut(s)
#endif

int calc(const int a, const int b, const int c) {
    std::array<int, 3> values = {a, b, c};
    std::sort(values.begin(), values.end());
    int x = values[0];
    int y = values[1];
    int z = values[2];
    int ret = 0;

    int count = z - y;
    x += count;
    y += count;
    ret += count;

    count = (z - x + 1) / 2;
    x += 2 * count;
    ret += count;

    ret += x - y;

    return ret;
}

int main() {
    int a, b, c;
    std::cin >> a >> b >> c;
    int ret = calc(a, b, c);
    std::cout << ret << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

typedef long long int ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
/* -- template -- */

int main() {
    ll N; cin >> N;
    ll sum = 0;
    for(ll i = 1;i <= N;++i) {
        if(!(i % 3 == 0 || i % 5 == 0))
            sum += i;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, count, d5, d4, d2, d1 = 0;
  cin >> a >> b;
  
  for (int i = a; i <= b; i++){

    d5 = i / 10000 % 10;
    d4 = i / 1000 % 10;
    d2 = i / 10 % 10;
    d1 = i / 1 % 10;
   
    if ( d5 == d1 && d4 == d2){
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
s = input()
n = len(s)


def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True


if(is_kaibun(s) and is_kaibun(s[:(n-1)//2]) and is_kaibun(s[(n+3)//2-1:])):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;

char buf[100000+10];
vector<int> vs;
int cs[100000+10];

int main(void) {
  int K;
  int n;
  scanf("%d%d%s", &n, &K, buf);
  {
    char cur = buf[0];
    int len = 0;
    REP(i, n) {
      if(buf[i] == cur) {
        ++len;
      } else {
        vs.push_back(len);
        len = 1;
        cur = buf[i];
      }
    }
    if(len > 0) {
      vs.push_back(len);
    }
    REP(i, vs.size()) {
      cs[i+1] = cs[i] + vs[i];
    }
  }
  
  int res = -1;
  REP(i, vs.size()) {
    bool isZero = i%2 == (buf[0]-'0');
    int i2;
    if(isZero) {
      i2 = i + 2*K;
    } else {
      i2 = i + 2*K+1;
    }
    i2 = min(i2, (int)vs.size());
    int cur = cs[i2] - cs[i];
    res = max(res, cur);
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 1272
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, n, ans = 1;
  scanf("%lld", &n);
  char s[n + 10];
  scanf("%s", s);
  for(i = 1; i < n; ++i) if(s[i] != s[i - 1]) ans++;
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

void build(int i, int j, string &ans, string &a, string &b, vvi &dp){
    if(i<0 || j<0) return;

    if(a[i]==b[j]){
        ans+=a[i];
        build(i-1,j-1,ans,a,b,dp);
        return;
    }
    if((i ? dp[i-1][j] : 0)>(j ? dp[i][j-1] : 0))
        build(i-1, j, ans, a, b, dp);
    else 
        build(i,j-1,ans,a,b,dp);
}

int main(){
    string a,b; int n,m;
    while(cin>>a>>b){
        n = a.size(); m = b.size();

        vvi dp(n, vi(m));
        forn(i,n){
            forn(j,m){
                if(a[i]==b[j])
                    dp[i][j] = (i && j ? dp[i-1][j-1] : 0 ) + 1;
                else 
                    max_self(dp[i][j], max((i ? dp[i-1][j] : 0), (j ? dp[i][j-1] : 0) ) );
            }
        }

        // deb(dp[n-1][m-1]);
        // print_vv(dp);

        int i = n-1, j = m-1;
        string ans;
        build(i,j,ans,a,b, dp);
        reverse(all(ans));
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 35584
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

static const unsigned long long int MOD = 1000000007LL;

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

    for (int i = 0; i < 3; i++)
    {
        if (s[i] == s[i + 1])
        {
            cout << "Bad";
            return 0;
        }
    }

    cout << "Good";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;

int h, w;
vector<vector<char>> maze;

int zero_one_bfs(int sx, int sy, int gx, int gy) {
  vector<vector<int>> dist(h, vector<int>(w, -1));
  dist[sy][sx] = (maze[sy][sx] == '#');
  // 右 or 下にしかいけない
  int dx[] = {0, 1};
  int dy[] = {1, 0};
  deque<pair<int, int>> q;
  q.push_back(make_pair(sx, sy));
  while (!q.empty()) {
    int x = q.front().first;
    int y = q.front().second;
    q.pop_front();
    for (int i = 0; i < 2; i++) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      // 範囲外判定
      if (nx < 0 || ny < 0 || nx >= w || ny >= h) {
        continue;
      }
      // 訪問済み判定
      if (dist[ny][nx] != -1) {
        continue;
      }
      // 移動元が '.' and 移動先が '#' -> 辺のcostが 1
      int cost = (maze[y][x] == '.' && maze[ny][nx] == '#');
      dist[ny][nx] = dist[y][x] + cost;
      if (maze[y][x] == maze[ny][nx]) {
        q.push_front(make_pair(nx, ny));
      } else {
        q.push_back(make_pair(nx, ny));
      }
    }
  }
  return dist[gy][gx];
}

int main() {
  cin >> h >> w;
  maze.assign(h + 10, vector<char>(w + 10));
  for (int y = 0; y < h; y++) {
    string s;
    cin >> s;
    for (int x = 0; x < s.length(); x++) {
      maze[y][x] = s[x];
    }
  }
  cout << zero_one_bfs(0, 0, w - 1, h - 1) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	char s[n];
	cin>>s;
	int ans=0,maxans=0;
	for(int i=0;i<n;i++){
		if(s[i]=='I')ans++;
		else
		ans--;
		if(ans>maxans)maxans=ans;
	}
	cout<<maxans;
}

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

int main(){
  int N,AS=0,BS=0;
  cin >> N;
  vector<int> A(N+1,0);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  for(int i=0;i<N;i+=2){
    AS+=A.at(i);
    BS+=A.at(i+1);
  }
  cout << AS-BS << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n, m;
    cin >> n >> m;
    vector<P> c(m);
    rep(i,m) {
        cin >> c[i].second >> c[i].first;
    }
    sort(c.begin(), c.end());
    int ans = 0;
    int now = -1;
    rep(i,m) {
        if (c[i].second <= now) continue;
        ans++;
        now = c[i].first - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4032
K, N = map(int, input().split())

A = [int(x) for x in input().split()]

minV = (K - A[N-1]) + A[0]
minI = 0

for i in range(1,N+1):
    if i == N:
        tmp = K - A[i-1]
    else:
        tmp = A[i] - A[i-1]
    # print(i, tmp)
         
    if minV < tmp:
        minV = tmp
        minI = i

# print(minI)
ans = 0

for i in range(1, N):
    ans += A[i] - A[i-1]
# print(ans)
ans += (K - A[N-1]) + A[0]
# print(ans)
ans -= minV 
print(ans)   


Measured memory_bytes: 26444
#include <iostream>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N;
  cin >> N;
  vector<int> A(N);
  int a;
  for (int i = 0; i < N; i++) {
    cin >> a;
    A[a-1] = i+1;
  }

  for (auto i = 0; i != N; ++i) {
    cout << (i?" ":"") << A[i]; 
  }
  cout << endl;
  
  return 0;
}


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

int main(){

    char S[4],T[4];
    cin >> S >> T;
    int cnt = 0;

    //cout << S << endl;
    //cout << T << endl;

    for(int i = 0; i < 3; i++){
        if(S[i] == T[i]){
            cnt += 1;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
// nb_9960
#include <bits/stdc++.h> 
using namespace std; 
#define fi(i,a,n) for (ll i=a; i < n; i++) 
#define ll long long
#define pb push_back 
#define mp make_pair 
#define F first 
#define S second 
#define all(x) x.begin(), x.end() 
#define clr(x) memset(x, 0, sizeof(x)) 
#define sortall(x) sort(all(x)) 
typedef pair<ll, ll> pl; 
typedef vector<ll> vl; 
typedef vector<pl> vpii; 
#define sz(a) int((a).size())
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) (c.find(x) != c.end())
#define cpresent(c,x) (find(all(c),x) != c.end())

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

  ll t = 1; 
  // cin >> t;

  while (t--) { 
    ll n;
    cin>>n;
    ll t[n],sum=0;
    fi(i,0,n){
    cin>>t[i];
    sum+=t[i];
    }
    ll m;
    cin>>m;
    fi(i,0,m){
      ll p,x;
      cin>>p>>x;
      cout<<sum-t[p-1]+x<<endl;
    }
  } 
  return 0; 
} 


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

signed main()
{
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n; cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    vsort(v);
    double ans=v[0];
    reps(i,n-1){
        ans=((double)ans+v[i])/2;
    }
    coutd(ans);
}

Measured memory_bytes: 256