akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll a, b, c;
    cin >> a >> b >> c;
    if(a == b && b == c){
        cout << 1 << endl;
    }else if(a == b || b == c || c == a){
        cout << 2 << endl;
    }else{
        cout << 3 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
   int n, a[100], count = 0;
   cin >> n;
   for(int i = 0; i < n; i++) cin >> a[i];
   for(int i = 0; i < n; i++) {
	   int mina = a[i];
	   int minj = i;
	   for(int j = i+1; j < n; j++) {
		   if(mina > a[j]) {
			   mina = a[j];
			   minj = j;
		   }
	   }
	   if(minj != i) {
	       a[minj] = a[i];
		   a[i] = mina;
		   count++;
	   }
   }
   for(int i = 0; i < n; i++) {
	   if(i) cout << " " << a[i];
	   else cout <<a[i];
   } cout << endl;
   cout << count <<endl;
   return 0;

}

Measured memory_bytes: 1160
n = gets.to_i
u = n.times.map{gets.chomp}
m = gets.to_i
open = false
m.times do
    t = gets.chomp
    if !u.include?(t)
        puts "Unknown #{t}"
    else
        if open
            puts "Closed by #{t}"
            open = !open
        else
            puts "Opened by #{t}"
            open = !open
        end
    end
end

Measured memory_bytes: 6112
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
int main()
{
  lli n,W;
  cin>>n>>W;
  lli v[n];
  lli w[n];
  lli sum=0;
  for(int i=0;i<n;i++)
  {
     cin>>w[i]>>v[i];
     sum+=v[i];
  }
  lli dp[sum+1];
  fill(dp,dp+sum+1,INT_MAX);
  dp[0]=0;
  for(int i=0;i<n;i++)
  {
      for(int j=sum;j>=v[i];j--)
      {
          dp[j]=min(dp[j],w[i]+dp[j-v[i]]);
      }
  }
  lli mx=INT_MIN;
  for(int i=0;i<=sum;i++)
  {   
       if(dp[i]<=W  && dp[i]!=LONG_MAX) mx=max(mx,(lli)i);
  }
    cout<<mx<<endl;
  return 0;
}


Measured memory_bytes: 1152
use std::collections::HashMap;

fn main() {
    proconio::input! {
        n: usize,
        x: String,
    }

    let bp = x.match_indices('1').count() as u64;
    let p = if bp == 1 { vec![2, 1] } else { vec![bp + 1, bp - 1] };

    let xr: Vec<char> = x.chars().rev().collect();

    let mut pows = vec![vec![1, 1]; n];
    let mut xv = if xr[0] == '1' { vec![1; 2] } else { vec![0; 2] };
    for i in 1..n {
        for j in 0..=1 {
            pows[i][j] = (pows[i - 1][j] * 2) % p[j];
            if xr[i] == '1' {
                xv[j] += pows[i][j];
                xv[j] %= p[j];
            }
        }
    }

    let mut dic = HashMap::new();
    for i in (0..n).rev() {
        if bp == 1 && xr[i] == '1' {
            println!("0");
        } else {
            let xi = if xr[i] == '0' {
                (xv[0] + pows[i][0]) % p[0]
            } else {
                let p = if xv[1] >= pows[i][1] { 0 } else { p[1] };
                xv[1] + p - pows[i][1]
            };
            println!("{}", 1 + pop_pop_count(xi, &mut dic));
        }
    }
}

fn pop_pop_count(sv: u64, dic: &mut HashMap<u64, u64>) -> u64 {
    let mut r = 0;
    let mut v = sv;
    while v > 0 {
        if let Some(dr) = dic.get(&v) {
            v = 0;
            r += dr;
            dic.insert(sv, r);
        } else {
            v %= v.count_ones() as u64;
            r += 1;
            dic.insert(sv, r);
        }
    }
    r
}


Measured memory_bytes: 14664
i1 = []
i1.append(int(input()))
i1.append(int(input()))
i1.append(int(input()))
i1.append(int(input()))
i1.append(int(input()))
i2 =(int(input()))
#print(i1)
 
for i in i1:
  for n in i1:
    if abs(i - n) > i2:
      ans = ':('
      break
    else:
      ans = 'Yay!'
      
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){ 
    string c;
    cin >> c;
    if(c=="a"||c=="e"||c=="i"||c=="u"||c=="o"){
        cout << "vowel"<<endl;
    }
    else cout << "consonant" <<endl;
    return 0;
}

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

int main(void){
    int N, K, Q, a, flg;
    scanf("%d%d%d", &N, &K, &Q);
    
    int A[N];
    
    for(int i=0; i < N; i++){
        A[i]=0;
    }
    
    for(int i=0; i < Q; i++){
        scanf("%d", &a);
        A[a-1] += 1;
    }
    
    for(int i=0; i < N; i++){
        flg = K - Q + A[i];
        if(flg > 0){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }

    
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
ペアになるか
おりがみ、たて半分、よこ半分にして合致するかどうか
33
aba
cdc
aba
4 1
2 2
1 1
---3 4---
abba
caac
abba
4 2
2 2
3/2*3/2=2...4
4/2=2...2

---4 4---
abba
cddc
cddc
abba
4 4

---5 4---
acca
bddb
effe
bddb
acca
4 4
2 2
---5 5---
abeba
cdfdc
ghihg
cdfdc
abeba
4 4
2 4
1 1
H/2=2
W/2=2
2*2=4...4の数
5/2+5/2=4...2の数
1は1
*/
int main(){
  ll H,W; cin>>H>>W;
  vector<ll> str(26,0);
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      char a; cin>>a;
      str[a-'a']++;
    }
  }
  ll four,two,one;
  four=(H/2)*(W/2);
  if(H%2==0 && W%2==1)
    two=H/2;
  else if(H%2==1 && W%2==0)
    two=W/2;
  else if(H%2==1 && W%2==1){
    two=H/2+W/2;
    one=1;
  }
  //four
  ll Fstr=0,Tstr=0,Ostr=0;
  for(int i=0; i<26; i++){
    Fstr+=str[i]/4;
    str[i]%=4;
  }
  for(int i=0; i<26; i++){
    Tstr+=str[i]/2;
    str[i]%=2;
  }
  for(int i=0; i<26; i++){
    Ostr+=str[i];
    str[i]=0;
  }
  if(Ostr>one || four>Fstr)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
typedef pair<string, int> P;
bool comp(P &e, P &e2){
    if(e.first != e2.first){
        return e.first < e2.first;
    }
    else return e.second > e2.second;
}
int main(){
  int n;
  cin >> n;
  vector<P> g(n);
  map<P, int> m;
  for(int i = 0; i < n; i++){
    string s;
    int score;
    cin >> s >> score;
    g[i] = P(s, score);
    m[g[i]] = i + 1;
  }
  sort(g.begin(), g.end(), comp);
  for(int i = 0; i < n; i++){
    cout << m[g[i]] << endl;
  }
}


Measured memory_bytes: 3656
import collections
n = int(input())
s = []
for i in range(n):
    S = str(input())
    s.append(S)
c = collections.Counter(s)
jud = c.most_common()[0][1]
set_s = set(s)
lists = []
for i in set_s:
    if jud == int(c[i]):
        lists.append(i)
lists.sort()
for i in range(len(lists)):
    print(lists[i])

Measured memory_bytes: 46704
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){

	map <char, int> mp;
	mp['I'] = 1;
	mp['V'] = 5;
	mp['X'] = 10;
	mp['L'] = 50;
	mp['C'] = 100;
	mp['D'] = 500;
	mp['M'] = 1000;


	string p;

	while (cin >> p){
		int p_buf = 0;
		int ans[3] = { 0, 0, 0 };

		for (int i = 0; i < p.size(); i++){
			if (mp[p[i]] > p_buf){
				ans[2] = mp[p[i]] - p_buf + ans[0];
			}
			else{
				ans[2] = mp[p[i]] + ans[1];
			}
			ans[0] = ans[1];
			ans[1] = ans[2];
			p_buf = mp[p[i]];
			//cout << ans[2] << ",";
		}
		//cout << endl;

		cout << ans[2] << endl;

	}

	return 0;
}

Measured memory_bytes: 1184
#include <stdio.h>

int dp[50];
int fib(int n){
  if(n == 0 || n == 1)
    return  1;
  if(dp[n] > 0)
    return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}

int main(){
  int n;
  scanf("%d", &n);
  for(int i = 0; i < n; ++i)
    dp[i] = -1;
  printf("%d\n", fib(n));

//for(int i = 0; i < n; ++i){
//  printf("dp[%d]: %d\n", i, dp[i]);
//}
  return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <cstdlib>
#include <bitset>
#include <map>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>
#include <math.h>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecchar vector<char>
#define vecstr vector<string>
#define vec2str vector<vector<string>>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define pairll pair<ll,ll>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

#define Pi 3.1415926535897932384626

int main() {
	ll n,ans=0;
	string s,t;
	bool flag = false;

	cin >> n;

	vecll a(n),buf3(n);

	forll(i, 0, n)
		cin >> a[i];

	sort(a.begin(), a.end());

	ll buf = 0;

	forll(i, 0, a.size())
	{
		buf += a[i];
	}

	ll buf2 = 0;

	forll(i, 0, a.size())
	{
		buf2 += a[i];
		buf3[i] = buf - buf2;
		buf3[i] %= 1000000007;
	}

	forll(i, 0, a.size())
	{
		ans += buf3[i]*a[i];
		ans %= 1000000007;
	}
	cout << ans;
}

Measured memory_bytes: 6416
#include <stdio.h>
#include <string.h>

int main()
{
  char s[110];
  int len,i;
  scanf("%d",&len);
  scanf("%s",s);
 
  if(len%2==0){
    
    for(i=0;i<len/2;i++){
     if(s[i] != s[i+len/2]){
      printf("No\n");return 0;
     }
      
    }
    printf("Yes\n");
  }
  else printf("No\n");
  
 return 0; 
}

Measured memory_bytes: 128
//05, 05, 2018, 09:09:40 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
const int N = 100;
char tab[N][N];
int vi[] = {0, 0, -1, 1}, vj[] = {1, -1, 0, 0};
int n, m;

bool ok(int i, int j){
    return i >= 0 && i < n && j >= 0 && j < m && tab[i][j] == '#';
}

int main(){
    
    cin >> n >> m;

    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < m ; j++){
            cin >> tab[i][j];
        }
    }

    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < m ; j++){
            if(tab[i][j] == '#'){
                bool flag = false;

                for(int k = 0 ; k < 4 ; k++){
                    int ti = vi[k] + i, tj = j + vj[k];

                    if(ok(ti, tj)){
                        flag = true;
                    }
                }

                if(!flag){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        /*var nabc = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var ls = new int[nabc[0]];
        for (var i = 0; i < nabc[0]; i++)
            ls[i] = ToInt32(ReadLine());*/
        var abq = Array.ConvertAll(ReadLine().Split(' '), long.Parse);
        var s = new long[abq[0]];
        var t = new long[abq[1]];
        for (var i = 0; i < abq[0]; i++)
            s[i] = ToInt64(ReadLine());
        for (var i = 0; i < abq[1]; i++)
            t[i] = ToInt64(ReadLine());

        var res = new long[abq[2]];
        for(var i = 0; i < abq[2]; i++)
        {
            var x = ToInt64(ReadLine());
            var sind = Search.UpperBound(s, x);
            var tind = Search.UpperBound(t, x);
            res[i] = long.MaxValue;
            if (sind < abq[0] && tind < abq[1])
                res[i] = Min(res[i], Max(s[sind], t[tind]) - x);
            if (sind > 0 && tind > 0)
                res[i] = Min(res[i], x - Min(s[sind - 1], t[tind - 1]));
            if (sind > 0 && tind < abq[1])
                res[i] = Min(res[i], Min(x - s[sind - 1], t[tind] - x) + t[tind] - s[sind - 1]);
            if (sind < abq[0] && tind > 0)
                res[i] = Min(res[i], Min(x - t[tind - 1], s[sind] - x) + s[sind] - t[tind - 1]);
        }
        WriteLine(string.Join("\n", res));
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}

public class Search
{
    public static int UpperBound<T>(T[] array,T value)
        where T:IComparable<T>
    {
        var low = 0;
        var high = array.Length;
        while (high > low)
        {
            var mid = (high + low) / 2;
            if (array[mid].CompareTo(value) == 1) high = mid;
            else low = mid + 1;
        }
        return low;
    }

    public static int LowerBound<T>(T[] array,T value)
        where T : IComparable<T>
    {
        var low = 0;
        var high = array.Length;
        while (high > low)
        {
            var mid = (high + low) / 2;
            if (array[mid].CompareTo(value) != -1) high = mid;
            else low = mid + 1;
        }
        return low;
    }
}


Measured memory_bytes: 25168
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long x,  n, sum=0, max=-1000000, min=1000000;
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> x;
        if(x > max){
            max = x;
        }
        if(x < min){
            min = x;
        }
        sum += x;
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9+7
typedef long long int ll;
const int maxn = 3000;
ll mod = INF;

ll dp[maxn][maxn][4]={0};
ll R,C,K;
ll g[maxn][maxn];
ll ans=0;

int main(){

    cin >> R>>C>>K;

    for(int i=0;i<K;i++){
        ll a,b,v;
        cin >> a>>b>>v;
        a--;b--;
        g[a][b]=v;
        dp[a][b][1]=v;
    }

    dp[0][0][0]=0;

    for(int i=0;i<R;i++){
        for(int j=0;j<C;j++){
            for(int k=1;k<=3;k++){
                if(j>0){
                    dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
                    if(g[i][j]>0)dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k-1]+g[i][j]);
                }
            }
            if(i+1<R){
                ll M=max(max(dp[i][j][0],dp[i][j][1]),max(dp[i][j][2],dp[i][j][3]));
                dp[i+1][j][0]=max(dp[i+1][j][0],M);
                if(g[i+1][j]>0)dp[i+1][j][1]=max(dp[i+1][j][1],M+g[i+1][j]);
            }
        }
    }

// int X;
// cin >> X;
//     for(int i=0;i<r;i++){
//         for(int j=0;j<c;j++){
//             cout << dp[i][j][X]<<" ";
//         }
//         cout << endl;
//     }

    for(int i=0;i<=3;i++){
        ans=max(ans,dp[R-1][C-1][i]);
    }

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

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

int main(){
    string s; cin >> s;
    int n = s.size();
    vector<int> ans(n);
    rep(j,2){
        //左からRをLが出るまで数える
        
        int cnt = 0;
        rep(i,n){
            if(s[i] == 'R') cnt++;
            else {
                //今iを見ているのでs[i]='L'
                //cntが偶数なら2で割るだけ
                //     奇数なら切り上げ
                ans[i] += cnt / 2;
                ans[i-1] += (cnt+1) / 2;
                cnt = 0;
            } 
        }

        reverse(ALL(ans));
        reverse(ALL(s));
        rep(i,n){
            if(s[i] == 'L') s[i] = 'R';
            else s[i] = 'L';
        }
    }
    rep(i,n) printf("%d%c", ans[i], i==n-1?'\n':' ');
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rg register
#define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);
using namespace std;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
    while(c>='0'&&c<='9') x=x*10+c-48,c=getchar();
    return f*x;
}
int n,k,ans,a[200011],f[200010][60],g[200001][60],flag;
int sum[200011];
void init(){
	for(int i=1;i<=n;i++)
		g[i][0]=f[i][0]=a[i];
	for(int i=1;i<=log(n)/log(2);i++)
		for(int j=1;j<=n-(1<<i)+1;j++)
			f[j][i]=max(f[j][i-1],f[j+(1<<(i-1))][i-1]),g[j][i]=min(g[j][i-1],g[j+(1<<(i-1))][i-1]);
}
int find_max(int a,int b){
	int k=log(b-a+1)/log(2);
	return max(f[a][k],f[b-(1<<k)+1][k]);
}
int find_min(int a,int b){
	int k=log(b-a+1)/log(2);
	return min(g[a][k],g[b-(1<<k)+1][k]);
}
main(){
	n=read(),k=read();
	for(int i=1;i<=n;i++)
		a[i]=read()+1;
	init();
	for(int i=2;i<=n;i++)
		sum[i]=sum[i-1]+(a[i]>a[i-1]);
	a[0]=2147483647,a[n+1]=-2147483647;
	for(int i=1;i<=n-k+1;i++){
		if(sum[i+k-1]-sum[i]==k-1) {flag=1;continue;}
		if(find_min(i,i+k-2)>a[i-1]&&find_max(i,i+k-2)<a[i+k-1])
			continue;
		ans++;
	}
	cout<<ans+flag;
}


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

int main()
{
    int i,frag=0;
    char arr[4];

    cin>>arr;

     for(i=0;i<3;i++)
     {
         if(arr[i]==arr[i+1])
         {
             frag=1;
             break;
         }
     }
     if(frag==1)
     {
         cout<<"Bad"<<endl;
     }
     else
     {
         cout<<"Good"<<endl;
     }

    return 0;
}


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

int L, N;

long long solve(vector<long long> S, vector<long long> T) {
    long long ans = 0;
    for (int k = 0; k < N; k++) {   //X[k]ではじめて折り返す。
        if ((N - k) % 2) {
            ans = max(ans, S[(N - k) / 2 + 1 + k] + S[(N - k) / 2 + k] - 2 * S[k] + 2 * T[(N - k) / 2]);
        } else {
            ans = max(ans, 2 * S[(N - k) / 2 + k] - 2 * S[k] + T[(N - k) / 2 - 1] + T[(N - k) / 2]);
        }
    }
    return ans;
}

int main() {
    cin >> L >> N;
    vector<int> X(N + 1, 0);
    vector<long long> S(N + 1, 0), T(N + 1, 0); //座標の累積和
    int x;
    for (int i = 1; i <= N; i++) {
        cin >> x;
        X[i - 1] = x;
        S[i] = S[i - 1] + x;
    }
    for(int i = 1; i <= N; i++) {
        T[i] = T[i - 1] + L - X[N - i];
    }
    
    cout << max(solve(S, T), solve(T, S)) << endl;
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int n, k, x, y; cin >> n >> k >> x >> y;

    if (n > k) {
        cout << k * x + (n - k) * y << endl;
    } else {
        cout << n * x << endl;
    }
}

Measured memory_bytes: 256
s = input()
n = len(s)
a = int((n-1)/2)
b = int((n+3)/2)-1
sr = s[::-1]
c1 = s[0:a]
c1r = c1[::-1]
c2 = s[b:n]
c2r = c2[::-1]
if s == sr and c1 == c1r and c2 == c2r:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int n,k; cin >> n>> k;
    ll ans=k;
    REP(i,n-1) ans *= k-1;
    cout << ans << endl;
    return 0;
}

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

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

  queue<long long> que;
  for ( int i = 1; i <= 9; i++ ) {
    que.push(i);
  }

  long long x;
  while ( k-- > 0 ) {
    x = que.front();
    que.pop();
    if ( x%10 != 0 ) { que.push(10*x + x%10 - 1); }
    que.push(10*x + x%10);
    if ( x%10 != 9 ) { que.push(10*x + x%10 + 1); }
  }

  cout << x << endl;
  return 0;
}


Measured memory_bytes: 5112
#include<stdio.h>

int main(void)
{
	int n;
	int i;
	int money = 100000;
	
	scanf("%d", &n);
	
	for(i = 0; i < n;i++){
		money *= 1.05;
		if((money%1000) > 0){
			money += 1000;
			money -= money%1000;
		}
	}
	
	printf("%d\n", money);
	
	return (0);
}

Measured memory_bytes: 592
n,m = map(int,input().split())

min_i = 1
max_i = n

for i in range(m):
    l,r = map(int,input().split())
    min_i = max(min_i,l)
    max_i = min(max_i,r)

if max_i-min_i>=0:
    print(max_i-min_i+1)
else:
    print(0)

Measured memory_bytes: 9200
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String l,s="";
		while ((l=br.readLine())!=null) s+=l;
		s=s.toLowerCase();
		char[] a={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
		int r;
        for(char c:a){
        	r=0;
        	for(int i=0;i<s.length();i++){
            	if(s.charAt(i)==c) r+=1; 
        	}
        	System.out.println(c+" : "+r);
        }
	}
}

Measured memory_bytes: 24380
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int A,B,C,D; cin >> A >> B >> C >> D;
    cout << max(A*B,C*D) << endl;
    return 0;
}


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

public class Main {

	public static void main(String[] args) throws Exception{

		double r, area, circumference;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        r = Double.parseDouble(br.readLine());

        area = r * r *  Math.PI;
        circumference = 2 * r *  Math.PI;
        System.out.println(String.format("%.6f", area) + " " + String.format("%.6f", circumference));

	}

}

Measured memory_bytes: 24920
#include <bits/stdc++.h>
using namespace std;
int n;
const int MAX=1e5+8;
int dp[MAX], arr[MAX];
int f(int i) {
	if (i == n-1) return 0;
	if(dp[i]!=-1) return dp[i];
	if(i+2 < n) return dp[i] = min(abs(arr[i+2] - arr[i]) + f(i+2), abs(arr[i+1]-arr[i]) + f(i+1));
	else return dp[i] = abs(arr[i+1] - arr[i]) + f(i+1);
}
int main() {
	// your code goes here
	memset(dp, -1, sizeof(dp));
	cin >> n;
	for(int i=0;i<n;i++) cin >> arr[i];
	cout << f(0);
	return 0;
}

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

int main()
{
  int n,x ;
  cin >> n >> x ;
  
  vector<int> vec(n+1);
  for (int i = 0; i < n+1 ; i++) {
    cin >> vec.at(i);
  }

  int sum=0,num=0;
  while (sum <= x){
    if(num == n+1){break;}
    sum += vec.at(num);
    num++ ;
  }
  cout << num ;
  return 0 ;
}

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

int main()
{
 string s;
 cin >> s;
 long long int ans = 0;
 for(int i = 0; i < s.size(); i++)
    {
        ans+=(s[i] - '0');
    }
if(ans%9) cout<<"No";
else cout<<"Yes";
  return 0;
}


Measured memory_bytes: 3728
#include <algorithm>
#include <iostream>
#define INF (1e9)
#define N 15
using namespace std;

int main(){
  int n,m,b[N],cpb[N],p[N],cnt0=0,chcnt=0,begin,sample[N],l=0,ans=0,ans2=INF;
  cin>>n>>m;
  for(int i=0;i<n;i++) cin>>b[i],cpb[i]=b[i],cnt0+=!b[i];
  for(int i=0;i<m;i++){
    cin>>p[i];
    if(!(i%2)) chcnt+=p[i];
  }
  if(cnt0==n-cnt0) begin=3;
  else if(cnt0==chcnt) begin=0;
  else begin=1;
  for(int i=0;i<m;i++)
    for(int j=0;j<p[i];j++,l++){
      if(begin==0){
	if(!(i%2)) sample[l]=0;
	else sample[l]=1;
      }
      else{
	if(!(i%2)) sample[l]=1;
	else sample[l]=0;
      }
    }
  for(int i=0;i<l;i++){
    if(b[i]==sample[i]) continue;
    for(int j=i+1;j<l;j++)
      if(b[j]!=b[i]){
	ans+=j-i;
	swap(b[j],b[i]);
	break;
      }
  }
  if(begin==3){
    ans2=0;
    for(int i=0;i<l;i++) sample[i]=!sample[i],b[i]=cpb[i];
    for(int i=0;i<l;i++){
      if(b[i]==sample[i]) continue;
      for(int j=i+1;j<l;j++){
	if(b[j]!=b[i]){
	  ans2+=j-i;
	  swap(b[j],b[i]);
	  break;
	}
      }
    }
  }
  cout<<min(ans,ans2)<<endl;
  return 0;  
}

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

int main() {
  int n;
  cin >> n;
  
  int ans;
  if(n==2) ans = 2; 
  
  else {
    if(n%2==0) n++;
    for(int i=n; ; i+=2) {
      
      if(i%2==0) continue;
    
      bool prime = true;
      double x = sqrt(i);
      for (int j=3; j<=x; j+=2) {
        if(i%j==0) {
          prime = false;
          break;
        }
      }
    
      if(prime) {
        ans = i;
        break;
      }
    
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3680
# -*- coding: utf-8 -*-
h, w = map(int, input().split())
a = []
a = [[True] * (w + 2)]
for i in range(h):
    a.append([True] + [x == '#' for x in input()] + [True])
a.append([True] * (w + 2))
q = []

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if a[i][j]:
            q.append((i, j))

count = 0
while True:
    qq = []
    for i, j in q:
        if not a[i-1][j]:
            a[i-1][j] = True
            qq.append((i - 1, j))
        if not a[i+1][j]:
            a[i+1][j] = True
            qq.append((i + 1, j))
        if not a[i][j-1]:
            a[i][j-1] = True
            qq.append((i, j - 1))
        if not a[i][j+1]:
            a[i][j+1] = True
            qq.append((i, j + 1))
    q = qq
    if len(q) <= 0:
        break
    count += 1

print(count)


Measured memory_bytes: 105980
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            int w = sc.nextInt();
            int n = sc.nextInt();
            int[] values = new int[w];
            for(int i=0;i<w;i++){
                values[i] = i+1;
            }
            for(int i=0;i<n;i++){
                String str = sc.next();
                String[] ab = str.split(",");
                int a = Integer.parseInt(ab[0])-1;
                int b = Integer.parseInt(ab[1])-1;
                int work = values[a];
                values[a] = values[b];
                values[b] = work;
            }
            for(int i=0;i<values.length;i++){
                System.out.println(values[i]);
            }
        }
    }
}


Measured memory_bytes: 26252
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author verytable
 */

#include <iostream>
#include <fstream>

#include <iostream>

class TaskD {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        std::string s1, s2;
        in >> s1 >> s2;

        long long res = 1;
        long long modulo = 1000000007;

        bool is_prev_vertical = false;
        int i = 0;
        while (i < s1.size()) {
            bool is_vertical = s1[i] == s2[i];
            if (is_vertical) {
                if (i == 0) {
                    res = 3;
                } else {
                    if (is_prev_vertical) {
                        res = res * 2 % modulo;
                    }
                }
            } else {
                if (i == 0) {
                    res = 6;
                } else {
                    if (is_prev_vertical) {
                        res = res * 2 % modulo;
                    } else {
                        res = res * 3 % modulo;
                    }
                }
                ++i;
            }
            is_prev_vertical = is_vertical;
            ++i;
        }

        out << res;
    }
};


int main() {
    TaskD solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#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;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 100005

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(time(0));

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int num_nodes,M,cnt,label[MAXN];
ll og[MAXN],dp[MAXN],ans[MAXN],pref[MAXN],suff[MAXN],v[MAXN];
vector<int> connections[MAXN];
//vector<ll> v[MAXN];

ll dfs(int node, int prev){
	dp[node] = 1;
	for(int check:connections[node]){
		if(check == prev) continue;
		dp[node] = (dp[node]*(dfs(check,node)+1))%M;
	}
	return og[node] = dp[node];
}

ll solve(int node, int prev){
	ans[node] = dp[node];
	pref[0] = suff[connections[node].size()+1] = 1;

	for(int i=1; i<=connections[node].size(); i++){
		int check = connections[node][i-1];
		pref[i] = (pref[i-1]*(dp[check]+1))%M;
	}
	for(int i=(int)connections[node].size(); i>=1; i--){
		int check = connections[node][i-1];
		suff[i] = (suff[i+1]*(dp[check]+1))%M;
	}
//	v[node].resize(connections[node].size()+2);
	for(int i=1; i<=connections[node].size(); i++){
		int check = connections[node][i-1];
		if(!label[check]) label[check] = ++cnt;
		v[label[check]] = (pref[i-1]*suff[i+1])%M;
	}
//		v[node][i] = (pref[i-1]*suff[i+1])%M;
//	ll ov1 = dp[node];
	for(int i=1; i<=connections[node].size(); i++){
		int check = connections[node][i-1];
		if(check == prev) continue;
//		ll o_v = dp[check];

		ll n_v = v[label[check]];
		dp[node] = n_v;

		n_v = ((n_v+1)*dp[check])%M;
		dp[check] = n_v;

		solve(check,node);
		dp[check] = og[check];
		dp[node] = og[node];
	}
}

int main(){
	scanf("%d %d",&num_nodes,&M);
	for(int i=1; i<num_nodes; i++){
		int a,b; scanf(" %d %d",&a,&b);
		connections[a].pb(b);
		connections[b].pb(a);
	}
	dfs(1,-1);
	solve(1,-1);
	for(int i=1; i<=num_nodes; i++)
		printf("%lld\n",ans[i]);
}

Measured memory_bytes: 17408
#include<cstdio>

int main(){
	
	int n,i,j,k,a,b;
	int card[300];
	

	while(1){
		scanf("%d",&n);
		if(n==0) break;
		
		for(i=0;i<2*n;i++)card[i]=1;
		for(i=0;i<n;i++) {
			scanf("%d",&j);
			card[j-1]=-1;
		}
		
		int t=-1,c=0,d=0;
		
			//puts("");
			//for(i=0;i<2*n;i++){
			//	printf("%2d:%2d ",i+1,card[i]);
			//}
			//puts("");
		a=b=n;
		k=n*4;
		while(k-->0){
			d=c;
			for(i=c;i<2*n;i++){
				if(card[i]==t){
					c=i+1;
					card[i]=0;
					if(t==-1)b--;
					else     a--;
					t=-t;
					break;
				}
			}
			/*
			puts("");
			for(i=0;i<2*n;i++){
				printf("%2d:%2d ",i+1,card[i]);
			}
			puts("");
			*/
			
			if(a==0)break;
			if(b==0)break;
			
			if(d==c){
				if(c==0)break;

				c=2*n;
			}
			if(c==2*n){
				c=0;
				t=-t;
			}
		
		}
		/*
		a=0;b=0;
		
		for(i=0;i<2*n;i++){
			if(card[i]==1)a++;
			if(card[i]==-1)b++;
		}
		*/
		printf("%d\n%d\n",a,b);
		
	}
	
	
	
	return 0;
}

Measured memory_bytes: 1028
N, M, Q = map(int, input().split())
li = []
for q in range(Q):
    a, b, c, d = map(int, input().split())
    li.append([[a,b], c, d])
ok_list = []
def dfs(num_li, depth):
    if len(num_li) == N:
        ok_list.append(num_li)
        return
    if depth == M:
        return
    dfs(num_li, depth+1)
    while len(num_li) <N:
        num_li += str(depth)
        dfs(num_li, depth+1)
dfs("", 0)
maxpoint = 0
for ok in ok_list:
    point = 0
    for q in range(Q):
        if int(ok[li[q][0][1]-1])- int(ok[li[q][0][0]-1]) == li[q][1]:
            point += li[q][2]
    if point > maxpoint:
        maxpoint = point
print(maxpoint)

Measured memory_bytes: 78524
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repn(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define ar array
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }

int main() {
	string s, t;
	cin >> s >> t;
	cout << t + s << endl;
    return 0;
}



Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int x,y,z,k;
ll a[1001],b[1001],c[1001];
vector<ll> res;
int main()
{
    //freopen("D.INP","r",stdin);
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> x >> y >> z >> k;
    for (int i=1;i<=x;i++) cin >> a[i];sort(a+1,a+1+x,greater<ll>());
    for (int i=1;i<=y;i++) cin >> b[i];sort(b+1,b+1+y,greater<ll>());
    for (int i=1;i<=z;i++) cin >> c[i];sort(c+1,c+1+z,greater<ll>());
    for (int i=1;i<=x;i++)
        for (int j=1;j<=y;j++)
            for (int l=1;l<=z;l++)
                if (i*l*j<=k) res.push_back(a[i]+b[j]+c[l]);
    sort(res.begin(),res.end(),greater<ll>());
    for (int i=0;i<k;i++) cout << res[i] << "\n";
}


Measured memory_bytes: 1400
// arc

#include<stdio.h>
#include<iostream>

using namespace std;

long long int s,c;
int main(){
    cin >> s >> c;
    long long int b = min( c / 2 , s );
    long long int x = ( c - 2 * b ) / 4;
    cout << b + x << endl;
    return 0;
}


Measured memory_bytes: 256
/*
░░░░░░░░░░░░░░░░▄▄█▀▀██▄▄░░░░░░░
░░░░░░░░░░░░░▄█▀▀░░░░░░░▀█░░░░░░
░░░░░░░░░░░▄▀░░░░░░░░░░░░░█░░░░░
░░░░░░░░░▄█░░░░░░░░░░░░░░░█░░░░░
░░░░░░░██▀░░░░░░░▄▄▄░░▄░█▄█▄░░░░
░░░░░▄▀░░░░░░░░░░████░█▄██░▀▄░░░
░░░░█▀░░░░░░░░▄▄██▀░░█████░██░░░
░░░█▀░░░░░░░░░▀█░▀█▀█▀▀▄██▄█▀░░░
░░░██░░░░░░░░░░█░░█░█░░▀▀▄█▀░░░░
░░░░█░░░░░█░░░▀█░░░░▄░░░░░▄█░░░░
░░░░▀█░░░░███▄░█░░░░░░▄▄▄▄█▀█▄░░
░░░░░▀██░░█▄▀▀██░░░░░░░░▄▄█░░▀▄░
░░░░░░▀▀█▄░▀▄▄░▄░░░░░░░███▀░░▄██
░░░░░░░░░▀▀▀███▀█▄░░░░░█▀░▀░░░▀█
░░░░░░░░░░░░▄▀░░░▀█▄░░░░░▄▄░░▄█▀
░░░▄▄▄▀▀▀▀▀█▀░░░░░█▄▀▄▄▄▄▄▄█▀▀░░
░▄█░░░▄██▀░░░░░░░░░█▄░░░░░░░░░░░
█▀▀░▄█░░░░░░░░░░░░░░▀▀█▄░░░░░░░░
█░░░█░░░░░░░░░░░░░░░░░░█▄░░░░░░░
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define pii pair<pair <int, int>, int>
#define vi vector <int>
const ll mod = 1000000007;
const ll nmax=1000003;
#define int ll
int n, m, p, d[2505];
vi g1[2505];
vector<pi> g[2505];

bool viz[2505];

void dfs(int nod){
    viz[nod]=1;
    for(int i: g1[nod]){
        if(!viz[i]){
            dfs(i);
        }
    }
}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n>>m>>p;
    for(int i=1, x, y, c; i<=m; i++){
        cin>>x>>y>>c;
        g[x].pb({y, p-c});
        g1[y].pb(x);
    }

    dfs(n);
    vi prev;
    set<int> s;
    prev.pb(1);
    for(int i=2; i<=n; i++) d[i]=1e9;
    for(int i=1; i<=n; i++){
        for(int x : prev){
            for(pi xd: g[x]){
                int y=xd.x, c=xd.y, lol=d[y];
                d[y]=min(d[y], d[x]+c);
                if(i==n && viz[y] && lol!=d[y]) return cout<<-1, 0;
                if(lol!=d[y]) s.insert(y);
            }
        }
        prev.clear();
        for(int nod: s) prev.pb(nod);
        s.clear();
    }
    cout<<max(0LL, -d[n]);
}


Measured memory_bytes: 768
n=int(input())

A=list(map(int,input().split()))

I=[]#1~n-1
for i in range(n-1):
    I.append(0)
    
for i in range(n):
    if A[i]+i>=1 and A[i]+i<=n-1:
        I[A[i]+i-1]+=1


J=[]#1~n-1
for i in range(n-1):
    J.append(0)

for j in range(n):
    if j-A[j]>=1 and j-A[j]<=n-1:
        J[j-A[j]-1]+=1

s=0
for i in range(n-1):
    s+=I[i]*J[i]

print(s)

Measured memory_bytes: 116068
// E - Yutori
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,K,C; string S;
	cin>>N>>K>>C>>S;

	vector<int> R(N,-1);

	int r_c = 0,  r_pos = 0;
	for(int r=N-1; r>=0; --r){
		if(r_c > 0) r_c--;
		else{
			if(S[r] == 'o'){
				R[r_pos++] = r;
				if(r_pos > K) return 0; // 働ける日に余裕があると、その日に必ず働く必要がない
				r_c = C;
			}
		}
	}

	reverse(R.begin(), R.begin() + r_pos);

	int l_c = 0,  l_pos = 0;
	for(int l=0; l<N; ++l){
		if(l_c > 0) l_c--;
		else{
			if(S[l] == 'o'){
				if(R[l_pos++] == l) cout<< l + 1 <<endl;
				l_c = C;
			}
		}
	}

}

Measured memory_bytes: 2564
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]

for i in range(w):
    for j in range(h):
        if s[j][i] == ".":
            c = 0
            for p in range(-1, 2):
                for q in range(-1, 2):
                    if j+p >= 0 and j+p < h and i+q >= 0 and i+q < w:
                        x = j+p
                        y = i+q
                        if s[x][y]=="#":
                            c += 1
            s[j][i] = str(c)
for i in s:
    print("".join(i))

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int euc(int a,int b){
    if(a%b==0){
        return b;
    }else if(b%a==0){
        return a;
    }else if(a>b){
        return euc(b,a%b);
    }else{
        return euc(a,b%a);
    }
}

template<typename T>
T gcd(T u, T v) {
    if(u==0)return v;
    if(v==0)return u;
    T r;
    while (v) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

int main(){
    ll n,x;
    cin >> n >> x;
    ll res = 0;
    res += n;
    ll a = x;
    ll b = n-x;
    ll r;
    while(a){
        res += b/a*a*2;
        r = b%a;
        b = a;
        a = r;
    }
    res -= b;
    put(res);
    return 0;
}


Measured memory_bytes: 256
#coding:utf-8
#1_3_C
from collections import deque
n = int(input())
q = deque()
for i in range(n):
    cmd = input().split()
    if cmd[0] == "insert":
        q.appendleft(cmd[1])
    elif cmd[0] == "delete":
        try:
            q.remove(cmd[1])
        except ValueError:
            pass
    elif cmd[0] == "deleteFirst":
        q.popleft()
    elif cmd[0] == "deleteLast":
        q.pop()

print(" ".join(q))

Measured memory_bytes: 71836
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

constexpr ll MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;



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

	mat edge(N);
	for (int i = 0; i < M; ++i)
	{
		int A, B; cin >> A >> B; --A; --B;
		edge[A].emplace_back(B);
		edge[B].emplace_back(A);
	}

	lst Q;
	Q.emplace_back(0);
	vec used(N, -1);
	used[0] = 0;

	while (!Q.empty())
	{
		int v = Q.front(); Q.pop_front();

		for (int u : edge[v])
		{
			if (used[u] != -1) { continue; }

			used[u] = v;
			Q.emplace_back(u);
		}
	}

	cout << "Yes" << endl;
	for (int i = 1; i < N; ++i)
	{
		cout << used[i] + 1 << endl;
	}

	return 0;
}

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*alias*/
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -fsanitize=signed-integer-overflow -fno-sanitize-recover=all -o template template.cpp


signed main()
{
	int n,k;cin >>n;
	string s; cin >> s;
	cin >> k;

for(int i = 0; i < n; ++i){
	if(s[k-1] != s[i]){
		s[i] = '*';
	}
}

cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  string S;
  cin>>S;
  int wi=0;
  lint ans=0;
  REP(i,S.size()){
    if(S[i]=='W'){
      ans+=i-wi;
      wi++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define pb push_back
#define MAX 1000000000
#define MOD 1000000007
int main(){
  int N;cin>>N;
  int A[N],B[N];
  long long Asm=0,Bsm=0;
  rep(i,N){
    cin >> A[i];
    Asm+=A[i];
  }
  rep(i,N){
    cin >> B[i];
    Bsm+=B[i];
  }
  vector<int> sa(N);
  if(Asm < Bsm){
    cout << -1 << endl;
  } else {
    rep(i,N){
      sa[i] = A[i]-B[i];
    }
    sort(sa.begin(),sa.end());
    int minusadd = 0;
    long long minushukugen = 0;
    rep(i,N){
      if(sa[i] < 0){
        minusadd++;
        minushukugen += (0 - sa[i]);
      }
    }
    for(int i = N-1; 0 < i; i--){
      if(minushukugen <= 0){
        break;
      } else {
        minushukugen -= sa[i];
        minusadd++;
      }
    }
    cout << minusadd << endl;
  }

  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define CloseIO std::ios::sync_with_stdio(false)
const ll N = 8e6+1000;
const ll Mod = 100;
const ll INF = 0x3f3f3f3f3f;
int main(){
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
  }
  ll sum = 0;
  rep(i,n){
    if(i > 0 && i != n-1){
      if(a[i] > a[i-1] && a[i] < a[i+1]){
        sum++;
      }else if(a[i] < a[i-1] && a[i] > a[i+1]){
        sum++;
      }
    }
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
N, u, v = map(int, input().split())
tree = [[] for i in range(N + 1)]
for _ in range(N - 1):
	a, b = map(int, input().split())
	tree[a].append(b)
	tree[b].append(a)
    
def dfs(v: int, tree: int, N: int) -> int:
    dist = [-1] * (N + 1)
    dist[v] = 0
    stack = [v]
    
    while stack:
        now = stack.pop()
        dw = dist[now] + 1
        
        for ne in tree[now]:
            if dist[ne] >= 0:
                continue
            dist[ne] = dw
            stack.append(ne)
            
    return dist

T = dfs(u, tree, N)
A = dfs(v, tree, N)

ans = 0
for t, a in zip(T[1:], A[1:]):
    if t < a:
        ans = max(ans, a - 1)
print(ans)

Measured memory_bytes: 30000
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define mp make_pair
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) for(ll i=0;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()
using namespace std;
ll n,m;
vl x0,x4,x2;
signed main() {
 cin>>n;
 rep(i,n){
     cin>>m;
     if(m%4==0)x4.push_back(m);
     else if(m%2==0)x2.push_back(m);
     else x0.push_back(m);
 }
 if(x2.size()==0){
     Yes(x0.size()<=x4.size()+1);
 }else{
     Yes(x0.size()<=x4.size());
 }
}

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

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const int inf = 1000000000 + 7;
const int N = 1e6 + 5;

typedef long long ll;

ll n, c, k, a[N], t, cnt = 1, ans = 1;

inline void solve()
{
    cin >> n >> c >> k;

    for(int i = 1; i <= n; i ++)
        cin >> a[i];
    sort(a + 1, a + n + 1);

    t = a[1];

    for(int i = 2; i <= n; i ++)
    {
        cnt ++;
        if(a[i] > t + k)
        {
            t = a[i];
            cnt = 1;
            ans ++;
        }
        if(cnt > c)
        {
            t = a[i];
            cnt = 1;
            ans ++;
        }
    }

    cout << ans << endl;
}

int tests = 1;

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

    while(tests --)
        solve();
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
    double a, b, b2, pi=3.14159265358979323846;
    scanf("%lf", &a);
    b = a * a * pi;
    b2 = 2 * a * pi;
    printf("%.6f %.6f", b, b2);
    return 0;
}

Measured memory_bytes: 652