akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <string>
#include <iostream>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


const ull prime=1000000007;
// 文字列のrolling hashをコンストラクタに渡された素数と
// 渡された文字列により計算し、getRollingHashでそれを戻す
template<int MAX_N>
class RollingHash{
private:
    ll p[MAX_N];
    ull ary[MAX_N];
    int N;// 文字列長
public:
  RollingHash(const string &str){
    N=str.size();
    // prime**iを計算
    // ハッシュ値を計算
    ary[0]=0;
    for(int i=1;i<=N;i++)
        ary[i]=ary[i-1]*prime+str[i-1];
    p[0]=1;
    for(int i=1;i<N+5;i++)
        p[i]=p[i-1]*prime;
  }
    RollingHash(){}
  // 先頭をx,終端をyで指定し、その範囲のハッシュ値を取り出す
  ull getHash(const int x,const int y)const{
    return ary[y+1]-ary[x]*p[y-x+1];
  }
  // 自身の[x1,y1]の範囲でのハッシュ値と
  // rの[x2,y2]の範囲のでのハッシュ値が一致するか調べる
  bool isMatch(const int x1,const int y1,const int x2,const int y2,const RollingHash &r)const{
    return this->getHash(x1,y1)==r.getHash(x2,y2);
  }
};


using RH = RollingHash<1001>;

int N;
string field[301];
RH rhs[301];
RH chs[301];

int main(){


    fastStream();
    cin >> N;
    for(int i = 0; i < N; i++)
        cin >> field[i];

    int ans = 0;
    for(int i = 0; i < N; i++)
        rhs[i] = RH(field[i]);

    for(int A = 0; A < N; A++){

        for(int j = 0; j < N; j++){
            string s;
            for(int k = 0; k < N; k++)
                s += field[(k + A) % N][j];
            chs[j] = RH(s);
        }
        
        {
            bool ok = true;
            for(int k = 0; k < N; k++){
                if(rhs[(k + A) % N].getHash(0, N-1) != chs[k].getHash(0, N-1)){
                    ok = false;
                }
            }
            ans += ok;
        }

        for(int B = 1; B < N; B++){
            bool ok = true;
            int idx = (N-B);
            for(int i = 0; i < N; i++){
                if(!(rhs[(i + A) % N].getHash(0, N-1-B) == chs[idx].getHash(B, N-1)
                     && rhs[(i + A) % N].getHash(N-B, N-1) == chs[idx].getHash(0, B-1))){
                    ok = false;
                    break;                    
                }
                idx++;
                if(idx >= N)idx -= N;
            }
            ans += ok;
        }
    }
    cout << ans << endl;
    

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef complex<double> P;

#define pb push_back
#define pf push_front
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define int ll
#define INF 100000000

#define POS(x) cout<<((x)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define Pos(x) cout<<((x)?"Possible":"Impossible")<<endl;
#define YES(x) cout<<((x)?"YES":"NO")<<endl;
#define Yes(x) cout<<((x)?"Yes":"No")<<endl;
#define yes(x) cout<<((x)?"yes":"no")<<endl;

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

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

    if(s=="a" || s=="i" || s=="u" || s=="e" || s=="o") cout << "vowel" << endl;
    else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <float.h>
#include <stdlib.h>
#include <functional>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <fstream>
#include <bitset>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
#define sort1(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> p;
bool paircom (pair<int,int> p,pair<int,int> q){
return p.second<q.second;
}

int main() {
   int k;
   cin >>k;
   int se=7;
   for(int i=0;i<k;i++){
       if(i==0 && se%k==0){cout <<1;return 0;}else{
           se=se*10+7;
           if(se%k==0){cout <<2+i;return 0;}
           se=se%k;

       }
   }
   cout <<-1;

}

    

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
const int MX=1e6+5;
set<int> s;
int n,x,k,y,f[MX];
bool b;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    for(int i=0; i<MX; i++) f[i]=i;
    for(int i=2; i*i<MX; i++){
        if(f[i]!=i) continue;
        for(int j=i*i; j<MX; j+=i){
            if(f[j]==j) f[j]=i;
        }
    }
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> x;
        y=__gcd(y,x);
        while(x>1){
            k=f[x];
            if(s.find(k)!=s.end()) b=true;
            s.insert(k);
            while(x%k==0) x/=k;
        }
    }
    if(!b){
        cout << "pairwise coprime";
        return 0;
    }
    if(y>1) cout << "not coprime";
    else cout << "setwise coprime";
    return 0;
}

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

int main() {
	vector<int> o1(10000, 0);
	vector<int> o2(500, 0);
	int n1;
	int n2;
	int count = 0;
	cin >> n1;
	for (int i = 0; i < n1; i++)
	{
		cin >> o1[i];
	}
	cin >> n2;
	for (int j = 0; j < n2; j++)
	{
		cin >> o2[j];
	}
	for (int i = 0; i < n2; i++)
	{
		for (int j = 0; j < n1; j++)
		{
			if (o2[i] == o1[j])
			{
				count++;
				break;
			}
		}

	}
	cout << count <<endl;
	return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
using namespace std;
    
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#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()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
    
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
    
class fact {
public:
    int fmod = 1e9+7;
    vector<int> fac, inv;
    fact (int n, int Mod = 1e9+7) {
        fmod = Mod;
        fac = vector<int>(n,0);
        inv = vector<int>(n,0);
        fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
        for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
    }
    ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
    ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
    
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}
int poorpow(int b, int a) {
    int tmp = 1;
    REP (i,a) {
        tmp *= b;
    }
    return tmp;
}


bool solve() {
    int n,a; cin >> n >> a;
    if (n % 500 <= a) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();    
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
A - Double Helix
https://atcoder.jp/contests/abc122/tasks/abc122_a

"""
import sys


def main(args):
    b = input()
    pairs = {'A': 'T', 'T': 'A', 'C': 'G', 'G':'C'}
    print(pairs[b])


if __name__ == '__main__':
    main(sys.argv[1:])


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

int main(void){
    int n;
    bool check = true;
    cin >> n;
    vector<string> s(n);
    for(int i = 0;i < n;i++)cin >> s[i];
    for(int i = 0;i < n-1;i++){
        if(s[i][(s[i].size()-1)] != s[i+1][0])check = false;
    }
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            if(s[i] == s[j] && i != j)check = false;
        }
    }
    if(check == false)cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

int main(){
    int tmp,n;
    long long sum=0;

    cin>>n;                                                
        
    int min_num=1000000;
    int  max_num=-1000000;

    for(int i=0;i<n;i++){
        cin>>tmp;
        min_num=min(min_num,tmp);
        max_num=max(max_num,tmp);
        sum+=tmp;
    }   
    cout<<min_num<<" "<<max_num<<" "<<sum<<"\n";
        
        
    return 0;
}


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

int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  map<int, long long> ma;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    ma[A[i]]++;
  }
  long long sum = 0;
  for (auto m : ma) {
    sum += m.second * (m.second - 1) / 2;
  }

  for (int i = 0; i < N; i++) {
    long long diffm = ma[A[i]] * (ma[A[i]] - 1) / 2;
    long long diffp = (ma[A[i]] - 1) * (ma[A[i]] - 2) / 2;
    cout << sum - diffm + diffp << endl;
  }
  return 0;
}

Measured memory_bytes: 10880
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if( (n|m) == 0 ) break;
			
			int map[] = new int[n];
			int sai[] = new int[m];
			
			for(int i=0;i<n;i++) map[i] = sc.nextInt();
			for(int i=0;i<m;i++) sai[i] = sc.nextInt();
			int cnt, p = 0;
			for(cnt=0;cnt<m;cnt++) {
//				debug(p, sai[cnt] + p);
				if( sai[cnt] + p >= n-1 ) break;
//				debug( sai[cnt], map[sai[cnt] + p] );
				p += sai[cnt] + map[ sai[cnt] + p ];
				if( p >= n-1 ) {
					break;
				}
			}
			if( cnt == m ) cnt--;
			System.out.println(cnt+1);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String ans = "Positive";
        if(a<=0&&b>=0) ans = "Zero";
        if(b<0&&(b-a+1)%2==1) ans = "Negative";
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rs(a, b) ((a) >> (b))
#define ls(a, b) ((a) << (b))
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int maxn = 2001;
long C[maxn + 1][maxn + 1];
void build()
{
    for (int i = 1; i <= maxn; i++)
        C[0][i] = 0;
    C[0][0] = 1;
    for (int n = 1; n <= maxn; ++n) {
        C[n][0] = C[n][n] = 1;
        for (int k = 1; k < n; ++k)
            C[n][k] = (C[n - 1][k - 1] % mod + C[n - 1][k] % mod) % mod;
    }
}
int main()
{
    fast;
    //freopen("input.txt", "r", stdin);ll factorial[2001];
    build();
    int n, k;
    cin >> n >> k;
    int nr = n - k + 1;
    for (int i = 1; i <= k; i++) {
        cout << (C[nr][i] % mod * C[k - 1][i - 1] % mod) % mod << "\n";
    }
    return 0;
}


Measured memory_bytes: 30080
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) begin(x), end(x)
using namespace std;
typedef long long ll;
typedef pair <int,int> P;
      

int main(){
  ll a,b,n;
  cin>>a>>b>>n;
  ll x;
  if(b-1<n) x=b-1;
  else x=n;
  cout<<a*(x%b)/b<<endl;
  return 0;
}



Measured memory_bytes: 3636
#include <stdio.h> 
 #include <math.h> 
 #define MAX 1000 
 
 
 int main(){ 
     int n; 
     int i, j=0, sum; 
     int score[MAX]; 
     double ave, tmp; 
     double dev[MAX]; 
 
 
     while(1){ 
         scanf("%d", &n); 
         if(n==0)break; 
         sum=0; 
         for(i=0;i<n;i++){ 
             scanf("%d", &score[i]); 
             sum+=score[i]; 
         } 
         ave=(double)sum/(double)n; 
         tmp=0.0; 
         for(i=0;i<n;i++){ 
             tmp+=pow(score[i]-ave, 2); 
         } 
         dev[j++]=sqrt(tmp/(double)n); 
     } 
     for(i=0;i<j;i++){ 
         printf("%f\n", dev[i]); 
     } 
     return 0; 
 } 



Measured memory_bytes: 2036
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;
int nums[6000];
set<int> st;
int main(){
	int N, K;
	scanf("%d %d", &N, &K);
	for (int i = 0; i < N; i++)
		scanf("%d", nums + i);
	sort(nums, nums + N);
	int knot = N;
	st.clear();
	st.insert(0);
	for (int i=N-1;i>=0;i--){
		set<int>temp;
		for (auto a:st){
			int next = a + nums[i];
			if (next >= K){knot = i;break;}
			else temp.insert(next);
		}
		for(auto a : temp)
			st.insert(a);
	}
	printf("%d\n", knot);
	return 0;
}


Measured memory_bytes: 768
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let k = read::<usize>();
    for _ in 0..n {
        read::<usize>();
    }

    let rest = if (n - k) % (k - 1) == 0 {
        (n - k) / (k - 1)
    } else {
        1 + (n - k) / (k - 1)
    };
    println!("{}", 1 + rest)
}


Measured memory_bytes: 4352
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない
//UnionFind

const int maxn=100000;

int main(){
    
    int n;
    vector<vector<P>> v(maxn);
    bool can_connect_with_zero[maxn];
    bool used[maxn];
    bool is_odd[maxn];
    
    cin >> n;
    rep(i,n-1){
        int a,b,c;
        cin >> a>>b>>c;
        a--;b--;
        v[a].push_back(P(b,c));
        v[b].push_back(P(a,c));
    }
    
    
    fill(can_connect_with_zero,can_connect_with_zero+n,false);
    fill(used,used+n,false);
    fill(is_odd,is_odd+n,false);
    
    can_connect_with_zero[0]=true;
    is_odd[0]=0;
    queue<int> que;
    que.push(0);
    
    while(!que.empty()){
        int parv=que.front();que.pop();
        used[parv]=true;
        rep(j,v[parv].size()){
            int to= v[parv][j].first,cost=v[parv][j].second;
            if(!used[to]){
                que.push(to);
                is_odd[to]=(is_odd[parv]+cost)%2;
                if(!is_odd[to])can_connect_with_zero[to]=true;
            }
        }
    }
    
    rep(i,n){
        if(can_connect_with_zero[i])cout << 0<<endl;
        else cout << 1<<endl;
    }
    
    return 0;
}


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

using namespace std;

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

	vector<int> d(N);
	for (int i = 0; i < N; i++)
	{
		cin >> d.at(i);
	}

	long long ans = 0;

	for (int i = 0; i < N - 1; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			ans += d.at(i) * d.at(j);
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

a,b=map(int,input().split())
a-=2;b-=2
a%=13;b%=13
print("Alice" if a>b else "Draw" if a==b  else "Bob" )

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

int main() {
  
  int H, W; cin >> H >> W; char table[H + 2][W + 2];
  
  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      table[i][j] = '.';
    }
  }
  
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      char tmp; cin >> tmp;
      table[i][j] = tmp;
    }
  }
  
  for (int i = 1; i < H + 1; i++) {
    for (int j = 1; j < W + 1; j++) {
      
      char tmp = table[i][j];
      
      if (tmp == '.') continue;
      
      bool flag = true;
      
      char top = table[i - 1][j], bottom = table[i + 1][j];
      
      char left = table[i][j - 1], right = table[i][j + 1];
      
      if (top == '#' || bottom == '#' || left == '#' || right == '#') {
        flag = false;
      }
      
      if (flag) {
        cout << "No" << endl;
        return 0;
      }
      
    }
  }
  
  cout << "Yes" << endl;
  
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

class doubly_linked_list {
public:
    struct node {
        int key;
        node* prev;
        node* next;
    };

    doubly_linked_list() {
        nil = (node*)malloc(sizeof(node));
        nil->prev = nil;
        nil->next = nil;
    };

    void insert_key(int key) {
        node* x = (node*)malloc(sizeof(node));
        x->key = key;
        x->prev = nil;
        x->next = nil->next;
        nil->next->prev = x;
        nil->next = x;
    }

    void delete_key(int key) {
        delete_node(find_node(key));
    }

    void delete_first() {
        delete_node(nil->next);
    }

    void delete_last() {
        delete_node(nil->prev);
    }

    void delete_node(node* x) {
        if (x == nil) return;
        x->prev->next = x->next;
        x->next->prev = x->prev;
        free(x);
    }

    node* find_node(int key) {
        node* cur = nil->next;
        while (cur != nil && cur->key != key) {
            cur = cur->next;
        }
        return cur;
    }

    void print() {
        node* cur = nil->next;
        int is = 0;
        while (true) {
            if (cur == nil) break;
            if (is++ > 0) printf(" ");
            printf("%d", cur->key);
            cur = cur->next;
        }
        printf("\n");
    }

private:
    node *nil;
};

int main() {
    doubly_linked_list list = doubly_linked_list();
    int n;
    char command[20];
    int key;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%s", command);
        if (command[0] == 'i') {
            scanf("%d", &key);
            list.insert_key(key);
        } else if (command[0] == 'd') {
            if (command[6] == 'F') {
                list.delete_first();
            } else if (command[6] == 'L') {
                list.delete_last();
            } else {
                scanf("%d", &key);
                list.delete_key(key);
            }
        }
    }
    list.print();
    return 0;
}

Measured memory_bytes: 34408
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int k;
  int n;
  cin >> k >> n;
  int a[n];
  vector<int> dis(n);
  rep(i,n){
    cin >> a[i];
    if(i>0){
      dis[i-1]=abs(a[i-1]-a[i]);
    }
  }
  if(a[0]!=0){
    dis[n-1]=abs((k+a[0])-a[n-1]);
  }
  else{
    dis[n-1]=abs(k-a[n-1]);
  }

  int max = *max_element(dis.begin(), dis.end());
  cout << abs(max-k)<< endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+50;
int gi(){
    char ch=getchar(); int x=0,q=0;
    while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return q?-x:x;
}
int a[N],b[N];
int main(){
    int n; cin>>n;
    ll sum=0;
    for (int i=0; i<n; ++i) a[i]=gi(),sum+=a[i];
    ll t=1ll*n*(n+1)/2;
    if (sum%t)
	return puts("NO"),0;
    int c=sum/t;
    for (int i=0; i<n; ++i)
	b[i]=c-a[(i+1)%n]+a[i];
    int num=0;
    for (int i=0; i<n; ++i)
	if (b[i]<0||b[i]%n)
	    return puts("NO"),0;
	else num+=b[i]/n;
    if (num!=c)
	puts("NO");
    else
	puts("YES");
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int x = sc.nextInt();
  int[] m = new int[n];
  int sum = 0;
  for(int i = 0;i < n;i++){
    m[i] = sc.nextInt();
    sum += m[i];
  }
  Arrays.sort(m);
  System.out.println(n + (x - sum)/m[0]);
}}

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

using namespace std;

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

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

    bool flag = false;
    int cut = 0;
    for (int i = 0; i < n - 1; ++i) {
        if (a[i] + a[i + 1] >= l) {
            flag = true;
            cut = i + 1; // ロープiとi+1の結び目の番号はi+1
            break;
        }
    }

    if (!flag) {
        cout << "Impossible" << endl;
    } else {
        cout << "Possible" << endl;

        for (int i = 1; i < cut; ++i) {// 左から切る
            cout << i << endl;
        }
        for (int i = n - 1; i > cut; --i) {// 右から切る
            cout << i << endl;
        }
        cout << cut << endl; // 最後に
    }
    return 0;
}

Measured memory_bytes: 1152
n = int(input())
nums = sorted(map(int, input().split()))
if n % 2 == 0:
    if nums[::2] != nums[1::2]:
        print(0)
    else:
        print(2 ** (n // 2) % 1000000007)
else:
    if nums[0] == 0 and nums[1::2] == nums[2::2]:
        print(2 ** (n // 2) % 1000000007)
    else:
        print(0)

Measured memory_bytes: 13880
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }



int main() {
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    vector<string> v(k);
    for (int i = 0; i < n; ++i) {
        v[i%k] += t[i];
    }
    array<int, 3> a{p, r, s};
    array<int, 266> X{};
    X['r'] = 0, X['s'] = 1, X['p'] = 2;
    auto f = [&](string &s) -> int {
        int n = s.size();
        auto dp = make_v(n+1, 3, 0);
        for (int i = 0; i < n; ++i) {
            int val = X[s[i]];
            for (int j = 0; j < 3; ++j) {
                for (int k = 0; k < 3; ++k) {
                    if(j == k) continue;
                    dp[i+1][k] = max(dp[i+1][k], dp[i][j] + (val == k ? a[k] : 0));
                }
            }
        }
        return *max_element(dp.back().begin(),dp.back().end());
    };
    int ans = 0;
    for (int i = 0; i < k; ++i) {
        if(!v[i].empty()){
            ans += f(v[i]);
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 5888
n = int(input())
a = list(map(int, input().split()))

#print(a)

a.sort(reverse = True)
#print(a)

confort = 0
for i in range(n):
    if i == 0:
        confort += 0
    elif i == 1:
        confort += a[0]
    else:
        if i % 2 == 0:
            p = int(i/2)
            confort += a[p]
        elif i % 2 == 1:
            p = int((i-1)/2)
            confort += a[p]

print(confort)


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

int main() {
	string S; cin >> S;
	bool ans = true;
	while (S.length() > 0) {
		if (S.length() >= 5 && S.substr(S.length() - 5, 5) == "dream") S.erase(S.end() - 5, S.end());
		else if (S.length() >= 5 && S.substr(S.length() - 5, 5) == "erase") S.erase(S.end() - 5, S.end());
		else if (S.length() >= 6 && S.substr(S.length() - 6, 6) == "eraser") S.erase(S.end() - 6, S.end());
		else if (S.length() >= 7 && S.substr(S.length() - 7, 7) == "dreamer") S.erase(S.end() - 7, S.end());
		else {
			ans = false;
			break;
		}
	}
	if (ans) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

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

Measured memory_bytes: 764
-- うおおおおお競プロでHaskell勉強してやるううううううう

import Data.Char
import Data.List
import System.IO
import Control.Applicative
import Control.Monad
-- https://hoogle.haskell.org で関数検索

{- お客様の中でHaskellを書ける方はいらっしゃいますか？
    と、Haskellの例がなくて困っていたところを @tanakh さんに助けて頂きました。本当にありがとうございました。-}
main :: IO ()
main = do
    [a,b] <- getStringList
    putStrLn $ b++a
    return ()
    



  -- print
pr [] = putStrLn ""
pr (x:xs) = do
    putStr $ (show x) ++ " "
    pr xs

or2 c1 c2 x 
    | c1 x ==True    = True
    | c2 x ==True    = True
    | otherwise        = False

same3 [a,b,c]
    | a==b && b==c = True
    | otherwise         = False       
      
diff3 [a,b,c] 
    | a==b = False
    | b==c = False
    | c==a = False
    | otherwise = True

yesno cond
    | cond         = putStrLn "Yes"
    | otherwise = putStrLn "No"
    
    
    
{-


    a <- getChar
    putStrLn [chr$(ord a)+1]

ord 'a' --> 97
chr 97 --> 'a'

main = do 
    [a,b] <- getDoubleList
    print $ ceiling $  a / b
  


 「/」はdouble同士でしか使えない

main = readLn >>= print . ceiling . (/2) 


(+) 3 $ (*) 4 4
-> 19
pure (+) <*> (Just 1) <*> ( Just 3)
-> Just 4

main = do 
    [a,b] <- getIntegerList 
    print $ (a*(a-1)+b*(b-1)) `div` 2
    -- / じゃなくて'div' ！！！！！

main = do
    s <- getLine    
    samecoffee s

samecoffee [x,y,a,b,c,d] 
    | a==b && c==d = do putStrLn "Yes"
    | otherwise         = do putStrLn "No"
samecoffee s = do putStrLn ""
         
putStrLn $ (show c) ++ " " ++ (show a) ++ " " ++ (show b)


main :: IO ()
main = do
    -- 整数の入力
    a <- readLn
    -- スペース区切り整数の入力
    [b, c] <- getIntegerList

    --[b, c] <- map read . words <$> getLine
    -- 文字列の入力
    s <- getLine
    -- 出力
    putStrLn $ show (a + b + c) ++ " " ++ s
-}

-- レイアウト規則

fac 0 = 1
fac n = n * fac (n-1)

-- FileName   : 164a
-- CreatedDate: 2020-04-26 20:56:13

--------------------------------------------  https://atcoder.jp/contests/abc164/submissions/12342628

getIntList        = map (read :: String -> Int) . words <$> getLine
getIntegerList    = map (read :: String -> Integer) . words <$> getLine
getIntegerListN m = map (read :: String -> Integer) <$> replicateM m getLine

getStringList    = words <$> getLine
getDoubleList    = map (read :: String -> Double) . words <$> getLine

base :: Integer
base = 1000000007

plus :: Integer -> Integer -> Integer
plus a b = (a+b) `mod` base

times :: Integer -> Integer -> Integer
times a b = a * b `mod` base

minus :: Integer -> Integer -> Integer
minus a b
   | a < b     = a-b + base
   | otherwise = a-b

power :: Integer -> Integer -> Integer
power n k
   | k == 0         = 1
   | k `mod` 2 == 0 = power (times n n) (k`div`2)
   | otherwise      = times n $! power n (k-1)

inv :: Integer -> Integer
inv n = power n $ base - 2

binom :: Integer -> Integer -> Integer
binom n m
   | (n-m) < m = times (foldr times 1 [m+1..n]) $ inv $ foldr times 1 [1..n-m]
   | otherwise = times (foldr times 1 [n-m+1..n]) $ inv $ foldr times 1 [1..m]



















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

int main(){
  int N;
  cin >> N;
  long long ans=0;
  for (int i=0; i<N; i++){
    long long a;
    cin >> a;
    while (true){
      if (a%2 != 0) break;
      ans++;
      a /= 2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
const int MAX = 700000;
const int MOD = 1000000007;

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;
}
int main(){
  COMinit();
  ll n,k;
  cin>>n>>k;
  int a=n-k;
  for(int i=1;i<=k;i++){
    COUT(COM(a+1,i)*COM(k-1,i-1)%MOD);
  }
}


Measured memory_bytes: 16640
n = int(input())
p = list(map(int,input().split()))
c = 0
for i in range(n-2):
  if p[i] < p[i+1] < p[i+2]:
    c += 1
  elif p[i] > p[i+1] > p[i+2]:
    c += 1
print(c)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ll k, n; cin >> k >> n;
    deque<ll> a(n); cin >> a;

    ll ans = LLINF;
    FOR(i, 0, n) {
        if (a.front() < a.back()) {
            chmin(ans, a.back() - a.front());
        }
        else {
            chmin(ans, k - a.front() + a.back());
        }
        a.push_back(a.front());
        a.pop_front();
    }

    cout << ans << "\n";
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define N         100005
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
    
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
} 
ll n; string s;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
//	cout<<setprecision(12)<<fixed;
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,l,m,first,last,x,k,n;
    	cin>>n>>s;
    	ll dp[n+1][n+1],p[n+1][n+1];
    	repi(i,0,n)
    	{
    		repi(j,0,n)
    		{
    			dp[i][j]=0;
    			p[i][j]=0;
			}
		}
    	dp[0][1]=1;
    	repi(i,1,n)
    	p[0][i]=1;
    	repi(i,1,n-1)
    	{
    		repi(j,1,i+1)
    		{
    			if(s[i-1]=='>')
	    		{
	    			dp[i][j]=(p[i-1][i]-p[i-1][j-1]+mod)%mod;
				}
				else
				{
					dp[i][j]=(p[i-1][j-1]-p[i-1][0]+mod)%mod;
				}
				p[i][j]=p[i][j-1]+dp[i][j];
			}
		}
    	x=0;
    	repi(i,1,n)
    	x=(x+dp[n-1][i])%mod;
    	cout<<x;
	}
	return 0;
}

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

const int N = 1e5 + 5;

int a[N], n, b[N];
long long sum, sum2;
long long cak;

int main() {
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> a[i], sum += a[i];
	sum2 = 1LL * n * (n + 1) / 2;
	if(sum % sum2 != 0) return cout << "NO", 0;
	sum /= sum2;
	for(int i = 0; i < n; ++i)
		if((sum + a[i] - a[(i + 1) % n]) % n != 0) return cout << "NO", 0;
		else if(sum + a[i] - a[(i + 1) % n] < 0) return cout << "NO", 0;
		else cak += (sum + a[i] - a[(i + 1) % n]) / n;
	if(cak != sum) return cout << "NO", 0;
	cout << "YES";
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

def main():
	s = input().strip()
	u = set(s)
	if len(u) == 2:
		t = [1, 0]
		c = s[0]
		for i in range(1, 4):
			if c == s[i]:
				t[0] += 1
			else:
				t[1] += 1
		if t == [2, 2]:
			print('Yes')
			return
	print('No')


if __name__ == '__main__':
	main()


Measured memory_bytes: 38384
import sys
from collections import deque


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


N = I()
v = LI()
v = sorted(v)
d = deque(v)



while len(d) != 1:
    one = d.popleft()
    two = d.popleft()
    ave = (one+two)/2
    d.appendleft(ave)

print(d.pop())

Measured memory_bytes: 38384
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let nm : Vec<usize> = get_vec();
    let n : usize = nm[0];
    let m : usize = nm[1];
    let mut correct = vec!(0; n);
    let mut wrong = vec!(0; n);
    for i in 0..m {
        let ps : Vec<String> = get_vec();
        let pp = &ps[0];
        let mut p : usize = pp.parse().ok().unwrap();
        p -= 1;
        let s = &ps[1];
        if correct[p] == 0 {
            if s == "WA" {
                wrong[p] += 1;
            }
            else {
                correct[p] = 1;
            }
        }
    }
    let ac = correct.iter().fold(0, |sm,x| sm+x);
    let mut wa = 0;
    for i in 0..n {
        if correct[i] != 0 {
            wa += wrong[i];
        }
    }
    println!("{} {}", ac, wa)
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int x,a,b;
	cin>>x>>a>>b;
	if(a-b>=0)cout<<"delicious"s;
	else if(b-a<=x)cout<<"safe"s;
	else cout<<"dangerous"s;
	cout<<"\n"s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
vector<ll> imos(vector<ll> &a) {
    ll n = a.size();
    vector<ll> ims(n + 1, 0);
    for(int i = 0; i < n; i++) {
        ims[max(0LL, i - a[i])]++;
        ims[min(n, i + a[i] + 1)]--;
    }
    for(int i = 0; i < n; i++) {
        ims[i + 1] += ims[i];
    }
    ims.pop_back();
    return ims;
}
int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<ll> tmp = a;
    ll num = log2(k + 1);
    for(int i = 0; i < min(k, 10 * num); i++) {
        tmp = imos(tmp);
    }
    for(int i = 0; i < n - 1; i++) {
        cout << tmp[i] << " ";
    }
    cout << tmp.back() << endl;
}

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

/*#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#define mp make_pair
#define pb push_back
#define pll pair<LL,LL>
#define pii pair<int,int>
#define y second
#define x first
#define LL long long 
#define sqr(x) ((x)*(x))
#define pi acosl(-1)
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
using namespace std;
void solve(){
    LL a,b,c,d;
    scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
    printf("%lld\n",max(max(a*c,a*d),max(b*c,b*d)));
}
int main(){
    int t=1;
    int T=1;
    while(t--){
        solve();
    }
}
/*
100
5
5 4
4 2
4 2 3
5 4 2 3 1
*/

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

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

using namespace std;

#define MAX 101
int n, cnt[30];
char c[MAX];

int main() {
  while( cin >> n, n ) {
    memset(cnt,0,sizeof cnt);
    rep(i,n) cin >> c[i];
    rep(i,n) {
      ++cnt[c[i]-'A'];
      int rem = n - ( i + 1 );
      int maxi = 0;
      char mc = '@';
      rep(j,26) maxi = max(maxi,cnt[j]);
      int maxi_cnt = 0;
      rep(j,26) if( cnt[j] == maxi ) ++maxi_cnt, mc = (char)('A'+j);
      if( maxi_cnt != 1 ) continue;
      bool fin = true;
      rep(j,26) {
        if( cnt[j] == maxi ) continue;
        if( cnt[j] + rem >= maxi ) { 
          fin = false;
          break;
        }
      }
      if( fin ) {
        cout << mc << " " << i + 1 << endl;
        goto Skip;
      }
    }
    puts("TIE");
  Skip:;
  }
  return 0;
}

Measured memory_bytes: 3088
h,w=map(int,input().split())
l=[]
import string
abc=string.ascii_uppercase
for i in range(h):
    li=list(map(str,input().split()))
    l.append(li)
for x in range(h):
    for y in range(w):
        if l[x][y] == 'snuke':
            print(abc[y]+str(x+1))


Measured memory_bytes: 3768
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<bitset>
#include<unordered_map> 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fio ios_base::sync_with_stdio(false)
#define mod 1000000007
#define mod1 mod
#define mod2 100000009
#define li long long int
#define ll long long int
// #define INT_MAX 5000000
#define readi(x) scanf("%d",&x)
#define  reads(x)  scanf("%s", x)
#define readl(x) scanf("%I64d",&x)
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define si short int
#define INTMAX 1000000000
#define MAXN 1000000000000000000
#define MINN -1000000000000000000
// #define INTMAX 1000001000
#define pii pair<ll,ll> 
#define pdd pair<double,double>
#define pic pair<int,char>
#define N 700010
#define lgn 20
#define ddouble long double
#define minus minu
#define lgn 20

// #define INTMAX 200000000  
// using namespace boost;
// #define si short int

using namespace std;
using namespace __gnu_pbds;             
typedef priority_queue<ll, vector<ll > > max_pq;
// typedef priority_queue<pii, vector<pii> , greater<pii >  > min_pq;
ll toint(const string &s) {stringstream ss; ss << s; ll x; ss >> x; return x;}
string tostring ( ll number ){stringstream ss; ss<< number; return ss.str();}

// using namespace __gnu_pbds;         
// typedef priority_queue<pair<ll,char> , vector<pair<ll , char> > > max_pq;
// typedef priority_queue<pii , vector<pii > ,greater<pii > > min_pq;
typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> OST;
// typedef priority_queue<pair < ll , pair < pii , ll > >  , vector<pair < ll , pair < pii , ll > >  > ,greater<pair < ll , pair < pii , ll > >  > > min_pq;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
    //use cerr if u want to display at the bottom
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
ll ar[ 200000 ];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n,x;
    cin >> n >> x;
    for ( ll i =1; i <= n; i ++)
        cin >> ar[i];
    ll gc = 0;
    for ( ll i = 1; i <= n; i ++)
        gc = __gcd(gc,abs(ar[i]-x));
    cout << gc;

    
}



Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		System.out.println(Math.min(c, b / a));
 	}
}

Measured memory_bytes: 23252
s = input()

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

n = len(s)
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: 3060
#include <bits/stdc++.h>
using namespace std;

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

  int64_t x=N/K;
  int64_t res;
  int64_t res1;
  res=N-K*x;
  res1=res-K;
  if (res1<0) res1=res1*(-1);

  res=min(res,res1);
  cout << res << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>

using namespace std;

int gcd(int n, int m) {
    if (n == 0)
        return m;
    return gcd(m % n, n);
}

int bit_count(int i) {
    i = i - ((i >> 1) & 0x55555555);
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
    i = (i + (i >> 4)) & 0x0f0f0f0f;
    i = i + (i >> 8);
    i = i + (i >> 16);
    return i & 0x3f;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<long long int> p(n + 1, 0);
    vector<bool> broken(n + 1, false);
    for (size_t i = 0; i < m; i++) {
        int a;
        cin >> a;
        broken[a] = true;
    }
    if (!broken[1])
        p[1] = 1;

    if (!broken[2])
        p[2] = p[1] + 1;

    for (size_t i = 3; i <= n; i++) {
        if (broken[i])
            continue;
        if (!broken[i - 2])
            p[i] += p[i - 2];
        if (!broken[i - 1])
            p[i] += p[i - 1];
        p[i] %= 1000000007;
    }

    cout << p.back() << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#define endl '\n'
#define all(x) x.begin(), x.end()
using namespace std;

int main() {
    int n;
    cin >> n;
    multiset<string> ss;
    string prev;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        ss.insert(s);
        if(ss.count(s) == 2 ||
         ((prev[prev.size() - 1] != s[0]) && i != 0)){
            cout << "No";
            return 0;
        }
        prev = s;
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 3612