akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define per(i,n,k) for(int i=n;i>=k;i--)
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define ll long long
using namespace std;
const int maxn=105;
int n,k,a[maxn];
bool f[100005];
int main()
{
	cin>>n>>k;rep(i,1,n) cin>>a[i];
	rep(i,a[1],k) rep(j,1,n) if(i-a[j]<0) break; else f[i]|=(!f[i-a[j]]);
	cout<<(f[k]?"First":"Second");return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main()
{
    char a[100],b[100],c[100];
   scanf("%s %s %s",a,b,c);
    a[0]=a[0]-32;
    b[0]=b[0]-32;
    c[0]=c[0]-32;
    printf("%c%c%c\n",a[0],b[0],c[0]) ;
    return 0;
    }



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

dp = ['First']*(K+1)
dp[0] = 'Second'
def solve(dp):
    for i in range(1,K+1):
        for j in range(N):
            dp[i] = 'Second'
            if dp[i-A[j]]=='Second':
                dp[i] = 'First'
                break
    ans = dp[K]
    return ans
print(solve(dp))

Measured memory_bytes: 40688
n = STDIN.readline.to_i
h_list = STDIN.readline.split().map{|h|h.to_i}
sum = 0
for i in Range.new(1, h_list.max) do
    counts = 0
    prev = 0
    for j in Range.new(0, n, true) do
        if h_list[j] > 0 then
            if prev == 0 then
                counts += 1
            end
            prev = 1
            h_list[j] -= 1
        else
            sum += counts
            counts = 0
            prev = 0
        end
    end
    sum += counts
end

puts(sum)

Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main(){
  int k,a,b;cin>>k>>a>>b;
  bool f=false;
  for(int i=a;i<=b;i++){
  	if(i%k==0){
    	f=true;break;
    }
  }
  if(f)  cout << "OK" << endl;
  else   cout << "NG" << endl;
  return 0;
}  


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MAXN = 301;

//vector<set<ll>> G(MAXN);
//ll N, M;
//ll C[MAXN][MAXN];
//ll D[MAXN][MAXN];

int main() {
    int N; cin >> N;
    vector<vector<int>> C(N+1, vector<int>(N+1)), C_(N+1, vector<int>(N+1));
    ll ans=0;
    for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) cin >> C[i][j];
    C_ = C;

    for(int k = 0; k < N; k++){
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                if(C[i][k]+C[k][j] < C[i][j]) {
                    cout << -1 << endl;
                    //cout << i << " " << j << " " << k << " " << C[i][k]+C[k][j]  << " " << C[i][j] << endl;
                    return 0;
                }
                if(C[i][j] == C[i][k]+C[k][j] && i!=k && k!=j) {
                    C_[i][j] = 0;
                    //cout << i << " " << j << endl;
                    //ans -= C[i][j];
                }
            }
        }
    }
    for(int i = 0; i < N-1; i++) for(int j = i+1; j < N; j++) ans += C_[i][j];
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  if(a*b>c*d){
    printf("%d\n",a*b);
  }else{
    printf("%d\n",c*d);
  }
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	
	public static char[][] array = new char[104][104];
	public static final int UP_MODE = 0;
	public static final int DOWN_MODE = 1;
	public static final int LEFT_MODE = 2;
	public static final int RIGHT_MODE = 3;
	
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		boolean first = false;
		
		int n = sc.nextInt();
		for(int i = 0; i < n; i++){
			int num = sc.nextInt();
			
			if(first == true){
				System.out.println();
			}
			
			for(int j = 0; j < (num+4); j++){
				for(int k = 0; k < (num+4); k++){
					if(j < 1 || j > (num + 2) || k < 1 || k > (num + 2)){
						array[j][k] = '#';
					}else{
						array[j][k] = ' ';
					}
				}
			}
			
			int n_x = 2,n_y = num + 1;
			boolean n_end = true;
			boolean changed = false;
			int state = UP_MODE;
			while(n_end){
				/*
				for (int j = 2; j < (num + 2); j++) {
					for (int k = 2; k < (num + 2); k++) {
						System.out.print(array[j][k]);
					}
					System.out.println();
				}
				System.out.println();
				*/
				if(array[n_y][n_x] == ' '){
					array[n_y][n_x] = '#';
				}
				
				switch(state){
				case UP_MODE:
					if(array[n_y-2][n_x] == ' '){
						n_y--;
						changed = false;
					}else if(changed == false){
						if(array[n_y-1][n_x+1] == ' ' && array[n_y+1][n_x+1] == ' '){
							state = RIGHT_MODE;
							changed = true;
						}else{
							n_end = false;
						}
					}else{
						n_end = false;
					}
					
					break;
				case DOWN_MODE:
					if(array[n_y+2][n_x] == ' '){
						n_y++;
						changed = false;
					}else if(changed == false){
						if(array[n_y-1][n_x-1] == ' ' && array[n_y+1][n_x-1] == ' '){
							state = LEFT_MODE;	
							changed = true;
						}else{
							n_end = false;
						}
					}else{
						n_end = false;
					}
					
					break;
				case LEFT_MODE:
					if(array[n_y][n_x-2] == ' '){
						n_x--;
						changed = false;
					}else if(changed == false){
						if(array[n_y-1][n_x-1] == ' ' && array[n_y-1][n_x+1] == ' '){
							state = UP_MODE;
							changed = true;
						}else{
							n_end = false;
						}
					}else{
						n_end = false;
					}
					
					break;	
				case RIGHT_MODE:
					if(array[n_y][n_x+2] == ' '){
						n_x++;
						changed = false;
					}else if(changed == false){
						if(array[n_y+1][n_x-1] == ' ' && array[n_y+1][n_x+1] == ' '){
							state = DOWN_MODE;
							changed = true;
						}else{
							n_end = false;
						}
					}else{
						n_end = false;
					}
					
					break;
				}
			}
			
			
			for (int j = 2; j < (num + 2); j++) {
				for (int k = 2; k < (num + 2); k++) {
					System.out.print(array[j][k]);
				}
				System.out.println();
			}
			
			if(first == false){
				first = true;
			}
		}
		
	}
	
}

Measured memory_bytes: 13000
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int N;
    long long D;
    cin >> N >> D;
    int count=0;
    for(int i=0; i<N; i++){
        long long x,y;
        cin >> x >> y;
        if(x*x + y*y <= D*D)count++;
    }
    cout << count << '\n';
    return 0;
}

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

const double pi = acos(-1);
const double eps = 0.000000001;

double a, b, x;

double func(double theta) {
    if (theta >= pi / 2.0) {
        return 0.0;
    }
    double r;
    if (b / tan(theta) > a) {
        r = a * a * b - a * a * a * tan(theta) / 2.0;
    } else {
        r = a * b * b / tan(theta) / 2.0;
    }
    return r;
}

int main() {
    cout << fixed << setprecision(10);
    cin >> a >> b >> x;
    double ok =  0.0;
    double ng = pi / 2.0;
    rep(i, (int)1e6) {
        double mid = (ok + ng) / 2.0;
        if (func(mid) >= x) ok = mid;
        else ng = mid;
    }
    cout << ok / pi * 180 << endl;
}

Measured memory_bytes: 4144
<?php

$output_count = array(
    'a' => 0, 'b' => 0, 'c' => 0, 'd' => 0,
    'e' => 0, 'f' => 0, 'g' => 0, 'h' => 0,
    'i' => 0, 'j' => 0, 'k' => 0, 'l' => 0,
    'm' => 0, 'n' => 0, 'o' => 0, 'p' => 0,
    'q' => 0, 'r' => 0, 's' => 0, 't' => 0,
    'u' => 0, 'v' => 0, 'w' => 0, 'x' => 0,
    'y' => 0, 'z' => 0,);
while($stdin = trim(fgets(STDIN))){
    $charactor_array = str_split(strtolower($stdin));
    foreach ($charactor_array as $charactor) {
        if (array_key_exists($charactor, $output_count)) {
            $output_count[$charactor]++;
        }
    }
}

foreach ($output_count as $key => $val) {
    echo $key . ' : ' . $val . PHP_EOL;
}


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

using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)
int main(){
	string o,e;
	cin >> o >> e;
	//合計文字数回出力する
	for(int i = 0; i < o.size() + e.size(); i++){
		if(i % 2 == 0)cout << o[i / 2]; //i=0からなのでiが偶数なら奇数番目を出力
		else cout << e[i / 2];
	}
	cout << endl; //最後に改行
	return 0;
}

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

int main() {
double N,K;
  cin >> N >> K;
  double a;
  vector<double> retu(N);
  for(int i = 0; i < N; i++){
  	cin >> a;
    retu[i] = a+1;
  }
  double mm = 0;
  for(int i = 0; i < K; i++){
  	mm += retu[i];
  }
  //これでmmはまずi = 0からK個の期待値の和
  vector<double> kitai(N);
  kitai[0] = mm;
  for(int i = 0; i < N-K; i++){
  	kitai[i+1] = kitai[i] - retu[i] + retu[i+K];
    mm = max(mm, kitai[i+1]);
  }


  cout << fixed << setprecision(12) << mm/2 << endl;
}

Measured memory_bytes: 3328
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        s: chars,
        t: chars,
    }
    let mut res = "No";
    for i in 0..s.len() {
        if t == [&s[i..], &s[..i]].concat() {
            res = "Yes";
            break;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(){

	int n1, n2, n3;

	

	scanf("%d %d %d", &n1, &n2, &n3);
		

	if(n1 < n2 && n2 < n3){
		printf("Yes\n");
	}

	else{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 580
#include<cstdio>
#include<algorithm>
using namespace std;
char p[2010][2010];
int n, m, res, U[2010], R[2010], L[2010], st[2010], top;
int main(){
    int i, j;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++){
        scanf("%s",p[i]+1);
        for(j=1;j<=m;j++){
            if(p[i][j]=='#')p[i][j]=1;
            else p[i][j]=0;
        }
    }
    U[m]=U[0]=-1;
    res = max(n,m);
    for(i=1;i<n;i++){
        for(j=1;j<m;j++){
            int c =(p[i][j]+p[i+1][j+1]-p[i][j+1]-p[i+1][j]+3)%2;
            U[j]++;
            if(!c)U[j]=0;
        }
        top = 0;
        for(j=1;j<=m;j++){
            while(top && U[st[top]] > U[j]){
                R[st[top]] = j;
                top--;
            }
            st[++top] = j;
        }
        top = 0;
        for(j=m-1;j>=0;j--){
            while(top && U[st[top]] > U[j]){
                L[st[top]] = j;
                top--;
            }
            st[++top] = j;
        }
        for(j=1;j<m;j++)res = max(res, (U[j]+1) * (R[j]-L[j]));
    }
    printf("%d\n",res);
}

Measured memory_bytes: 4096
#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
 
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <sstream>
#include <deque>
#include <queue>
#include <random>
#include <cassert>
 
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FIXED cout << fixed << setprecision(12)
#define RANDOM srand(94385)
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define graph vector<vector<int>>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define f first
#define s second
#define hashmap unordered_map
#define hashset unordered_set
#define eps 1e-9
#define mod 1000000007
#define inf 3000000000000000007ll
#define sz(a) signed(a.size())
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define shuffle(a) \
    for (int i = 0; i < sz(a); ++i) \
        swap(a[i], a[rand() % sz(a)]);
 
template<class T, class U> inline void checkmin(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void checkmax(T &x, U y) { if (y > x) x = y; }
template<class T, class U> inline bool ifmax(T &x, U y) { if (y > x) return x = y, true; return false; }
template<class T, class U> inline bool ifmin(T &x, U y) { if (y < x) return x = y, true; return false; }
template<class T> inline void sort(T &a) { sort(all(a)); }
template<class T> inline void rsort(T &a) { sort(rall(a)); }
template<class T> inline void reverse(T &a) { reverse(all(a)); }
template<class T, class U> inline istream& operator>>(istream& str, pair<T, U> &p) { return str >> p.f >> p.s; }
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

signed main() {
    FAST; FIXED; RANDOM;
    int n;
    cin >> n;
    vector<vector<int>> color(n, vector<int>(n, -1));
    vector<vector<int>> ans(n, vector<int>(n, 1e9));
    for (int l = 1; l < n; ++l)
        for (int i = 0, j = l; i < n; ++i, ++j, j %= n) {
            for (int c = 0; c < n; ++c) {
                if (color[c][i] == color[c][j] && color[c][i] != -1) continue;
                checkmin(ans[min(i, j)][max(i, j)], c);
                if (color[c][i] != -1) {
                    color[c][j] = !color[c][i];
                } else if (color[c][j] != -1) {
                    color[c][i] = !color[c][j];
                } else {
                    color[c][i] = 0;
                    color[c][j] = 1;
                }
                break;
            }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j)
            cout << ans[i][j] + 1 << ' ';
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 2432
#include <stdio.h>

int main(void)
{
	int a = 0, b = 0;
	int s, l;

	scanf("%d", &a);	scanf("%d", &b);

	s = a * b;
	l = (2 * a) + (2 * b);

	printf("%d %d\n", s, l);

	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define pb push_back
#define hell 1000000007

using namespace std;
void solve()
{

ll int  m,i,j,k,d=1,b,c=0,sum=0,z=0,q,x=0,y=0,n;
cin>>n>>k;
string s;
cin>>s;
rep(i,0,n)
 {
     if(i==k-1)
     {
         if(s[i]<97) cout<<(char(s[i]+'a'-'A'));
     }
     else cout<<s[i];
 }
}



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

 int t=1;
//cin>>t;
 while(t--)
  solve();
}


Measured memory_bytes: 256
/* ex 7_3
   KKOO */

#include <stdio.h>
#include <stdlib.h>

int main(void){
    int i, j, row, column;
    char **ptr;
    int remain_row[100]={}, remain_column[100]={};

    scanf("%d %d\n", &row, &column);

    //各行の配列へのポインタ分のメモリ領域を確保
    ptr = (char**)calloc(row, sizeof(char*));
    if(ptr == NULL){
        fprintf(stderr, "calloc error.\n");
        exit(1);
    }
    //各行の要素分のメモリ領域を確保
    for(i = 0; i < row; i++){
        ptr[i] = (char*)calloc(column, sizeof(char));
        if(ptr[i] == NULL){
            fprintf(stderr, "calloc error.\n");
            exit(1);
        }
    }

    //マス目の配色の入力
    //'#'を含む行および列を記憶しておく
    for(i = 0; i < row; i++){
        for(j = 0; j < column; j++){
            scanf(" %c", &ptr[i][j]);
            if(ptr[i][j] == '#'){
                remain_row[i] = 1;
                remain_column[j] = 1;
            }
        }
    }

    //'#'を含む行および列のみ出力する
    for(i = 0; i < row; i++){
        if(remain_row[i] == 1){
            for(j = 0; j < column; j++){
                if(remain_column[j] == 1){
                    printf("%c", ptr[i][j]);
                }
            }
            printf("\n");
        }
    }

    //メモリ領域の解放，各行の要素分の領域を解放し，
    //各行の配列へのポインタの領域を解放
    //（メモリ領域の確保と逆順）
    for(i = 0; i < row; i++){
        free(ptr[i]);
    }
    free(ptr);

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll A[100100];
pair<ll, int> P[100100];

int main(){
    ll N, T;
    cin >> N >> T;
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
    }

    ll ma = -1;
    for(int i = N-1; i >= 0; i--){
        ll a = A[i];
        ma = max(ma, a);
        P[i] = make_pair(ma-a, i);
    }

    sort(P, P+N);
    ll diffmax = P[N-1].first;
    set<int> se;
    for(int i = N-1; i >= 0; i--){
        auto p = P[i];
        ll a = p.first;
        int idx = p.second;
        if(a != diffmax) break;
        se.insert(idx);
    }

    ll ans = se.size();

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


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define int long long int
#define boost ios_base::sync_with_stdio(false)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repp(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
//#define test int t;cin>>t; while(t--)
#define vi vector<int> 
#define mi map<int,int> 
#define rrep(i,a,b) for(int i=a;i>=b;i--)
//typedef pair <int,int> pii
//typedef vector<pii> vpi
#define build(arr,n) { int arr[n+1]; repp(i,1,n)cin>>arr[i]; }
#define buildv(v,n) { vi v; repp(i,1,n){int x; cin>>x; v.pb(x);} } 
#define in_edges(m) repp(i,1,m){int a,b; cin>>a>>b; adj[a].pb(b); adj[b].pb(a);}
#define mod 1000000007
#define pi 3.1415926
#define mx(arr) {*max_element(arr+1,arr+n+1);} 
using namespace std;
//vector<int> adj[100003];
//int vis[100003]={0};
//int dp[n+1]={0};
//vector<int> leaf;
signed main()
{
    int t; cin>>t; 
    string ans;
    cin>>ans;
    int chck=ans.size();
    if(chck<=t)cout<<ans;
    else{
    rep(i,0,t)cout<<ans[i];
    cout<<"...";}
        
    
    
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int n , m;

void solve()
{
	int n;
	cin >> n;

	vector<int> v1(n), v2(n);

	loop(i,0,n)
	{
		int x , y;
		cin >> x >> y;
		v1[i] = x+y;
		v2[i] = x-y;
	}

	S(v1);
	S(v2);

	cout << max(v1[n-1] - v1[0] , v2[n-1] - v2[0]);
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 6360
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=result.begin();i!=result.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
//#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    lli n,d;
    cin>>n>>d;
  	lli t=2*d+1;
  	if(n%t==0)cout<<n/t;
	else cout<<n/t+1;









    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

/* 二分累乗法 */
ll bipow(ll a, ll b) {
    ll res = 1;
    for (; b; a = a * a , b >>= 1){
        if (b & 1) res = res * a;
    }
    return res;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int a,b;
    cin >> a >> b;
    bool ok = 0;
    a = a*bipow(10,to_string(b).size())+b;
    REP(i,1000){
        if(i*i == a)ok = 1;
    }
    cout << (ok ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
# 0028
array = []
while True:
    try:
        a = input()
        array.append(int(a))
    except EOFError:
        break
s = set(array)
mx = max(list(map(lambda a: array.count(a), s)))
modes = list(filter(lambda a: array.count(a) == mx, sorted(s)))
print(*modes, sep = '\n')

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

const int mod = 1000000007;

int N;
string s;

long long dp[3009][3009];

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

    for(int j = 0; j < N; j++)
        dp[0][j] = 1;

    for(int i = 0; i < N - 1; i++) {
        // 累積和
        long long sum[3009];
        sum[0] = 0;
        for(int j = 0; j < N - i; j++)
            sum[j + 1] = (sum[j] + dp[i][j]) % mod;

        if(s[i] == '<') {
            for(int j = 0; j < N - i; j++)
                dp[i + 1][j] = (sum[N - i] - sum[j + 1] + mod) % mod;
        }
        if(s[i] == '>') {
            for(int j = 0; j < N - i; j++)
                dp[i + 1][j] = sum[j + 1];
        }
    }

    cout << dp[N - 1][0] << endl;

    return 0;
}


Measured memory_bytes: 70144
#include<stdio.h>
#define N 100

void trace(int a[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", a[i]);
  }
  printf("\n");
}

int main(void){
  int n,i,j,sw,judge,mini,co=0,a[N];
  
  scanf("%d",&n);  
  for ( i = 1; i <= n; i++ ) scanf("%d", &a[i]);
  
  for(i=1; i<n+1; i++){
    judge=0;
    mini=i;
    for(j=i; j<n+1; j++){
      if(a[j]<a[mini]){
	mini=j;
	judge=1;
      }
    }
    if(judge==1){
      sw=a[mini];
      a[mini]=a[i];
      a[i]=sw;
      co++;
    }
  }
  
  trace(a,n);
  printf("%d\n",co);
  return 0;
}

Measured memory_bytes: 604
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int ans = 0;
    for (int i = 0; i <= A; ++i) {
        for (int j = 0; j <= B; ++j) {
            for (int k = 0; k <= C; ++k) {
                if (500 * i + 100 * j + 50 * k == X) {
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector <string> s(n);
  for (long long i = 0; i < n; i++) {
	  cin >> s[i];
	  sort(s[i].begin(), s[i].end());
	}
  sort(s.begin(), s.end());
  s.push_back("");
  long long ans = 0;
  long long c   = 1;
  for (long long i = 1; i <= n; i++) {
	  if (s[i] == s[i - 1]) {
		  c++;
		} else {
		  ans += c * (c - 1) / 2;
		  c    = 1;
		}
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

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

  int n = s.size();
  int ans1 = 0;
  for (int i=0;i<n;i++) {
    if (i %2 == 0 && s[i] == '0') ans1++;
    else if (i % 2 ==1 && s[i] == '1') ans1++;
  }

  int ans2=0;
  for (int i=0;i<n;i++) {
    if (i %2 == 1 && s[i] == '0') ans2++;
    else if (i % 2 ==0 && s[i] == '1') ans2++;
  }

  if (ans1 > ans2) cout << ans2;
  else cout << ans1;

}


Measured memory_bytes: 512
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
s = list(map(int, readline().split()))
t = list(map(int, readline().split()))
dp = [[0] * (n + 1) for _ in range(m + 1)]
cumsum = [[0] * (n + 1) for _ in range(m + 1)]
dp[0][0] = 1
mod = 10 ** 9 + 7
for i, tt in enumerate(t):
    i += 1
    for j, ss in enumerate(s):
        j += 1
        if tt == ss:
            dp[i][j] = cumsum[i - 1][j - 1] + 1
            dp[i][j] %= mod
        else:
            dp[i][j] = 0
        cumsum[i][j] = cumsum[i - 1][j] + cumsum[i][j - 1] - cumsum[i - 1][j - 1] + dp[i][j]
        cumsum[i][j] %= mod
print(cumsum[-1][-1] + 1)


Measured memory_bytes: 105564
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

a,b,x = lr()
if a<=x<=a+b:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 77320
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	string s;cin>>s;
	if (s.size() == 2){
		cout << s << endl;
	}
	else{
		for(int i = 0; i < 3; i++) {
			cout << s[3 - i - 1];
		}
		cout << endl;
	}
	return 0;
}

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

int main(void) {
	long long  N, T,z,X, t[200000], A[20000];

	X = 0;

	cin >> N >> T;

	for (int s = 1; s <= N; s++) {
		cin >> t[s];
	}

	for (int i = 1; i <= N-1; i++) {
		if ((t[i + 1] - t[i]) > T)
			A[i] = T;
		else
			A[i] = t[i + 1] - t[i];
	}

	for (int k = 1; k <= N-1; k++) {
		z = A[k];
		X = X + z;
	}
	X = X + T;

	cout << X << endl;
}

Measured memory_bytes: 1920
#include<stdio.h>
int main(){
int n,a,min=1000000,max=-1000000,i;
long long int sum=0;
scanf("%d",&n);
for (i=0;i<n;i++){
scanf("%d",&a);
if(a<min)min=a;
if(a>max)max=a;
sum+=a;
}
printf("%d %d %ld\n",min,max,sum);
return 0;
}

Measured memory_bytes: 600
#include<iostream>
using namespace std;
int main() {
	int a[3][3];
	for (int i = 0; i < 3; ++i) {
		for(int j = 0; j < 3; ++j) {
			cin >> a[i][j];
		}
	}
	int n;
	cin >> n;
	int b[10];
	for (int i = 0; i < n; ++i) {
		cin >> b[i];
	}
	
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 10; ++k) {
				if (a[i][j] == b[k]) {
					a[i][j] = 101;
				}
			}
		}
	}
	
	for (int i = 0; i < 3; ++i) {
		int yc(0);
		for (int j = 0; j < 3; ++j) {
			if (a[i][j] == 101) {
				++yc;
			}
		}
		
		if (yc == 3) {
			cout << "Yes";
			return 0;
		}
		
	}
	
	for (int j = 0; j < 3; ++j) {
		int yc(0);
		for (int i = 0; i < 3; ++i) {
			if (a[i][j] == 101) {
				++yc;
			}
		}
		if (yc == 3) {
			cout << "Yes";
			return 0;
		}
	}

	if (a[0][0] == 101 && a[1][1] == 101 && a[2][2] == 101) {
		cout << "Yes";
		return 0;
	}
	if (a[0][2] == 101 && a[1][1] == 101 && a[2][0] == 101) {
		cout << "Yes";
		return 0;
	}
	
		cout << "No";
		
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long long> L(n);
  for (int i = 0; i < n; i++){
    int l;
    cin >> l;
    L.at(i) = l;
  }
  int ans = 0;
  for (int i = 0; i < n; i++){
    for (int j = i+1; j < n; j++){
      for (int k = j+1; k < n; k++){
        if (L.at(i) == L.at(j) || L.at(i) == L.at(k) || L.at(j) == L.at(k)){
          continue;
        }else{
          if (L.at(i)+L.at(j) > L.at(k) && L.at(j)+L.at(k) > L.at(i) && L.at(i)+L.at(k) > L.at(j)){
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
N = int(input())
p_array = [int(x) for x in input().split()]

my_array = list(range(1,N+1))
ans_array = []
num = 0

for i in range(0,N):
	num = p_array[i] - my_array[i]
	ans_array.append(num)

new_lst = [e for e in ans_array if e != 0]
if len(new_lst)==0:
	ans = "YES"
elif len(new_lst)==2:
	ans = "YES"
else:
	ans = "NO"
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <ll, ll> P;

const ll MOD=1000000007;
ll N;
P p[200000];
bool used[100000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    ll a=0,b=0;
    rep(i,0,N){
        ll A,B;
        cin>>A>>B;
        p[2*i]=P(A,i);
        p[2*i+1]=P(B,i);
        a+=A;
        b+=B;
    }
    ll ans=min(a,b);
    sort(p,p+2*N);
    ll res=0;
    bool t=false;
    rep(i,0,N){
        if(!used[p[i].sc]){
            used[p[i].sc]=1;
            res+=p[i].fr;
        }
        else{
            t=true;
            res+=p[i].fr;
        }
    }
    if(t) cout <<res<<"\n";
    else{
        ll rres=res;
        res+=p[N].fr;
        if(p[N-1].sc==p[N].sc)  res-=p[N-2].fr;
        else res-=p[N-1].fr;
        ans=min(ans,res);
        rres+=p[N+1].fr;
        if(p[N-1].sc==p[N+1].sc)  rres-=p[N-2].fr;
        else rres-=p[N-1].fr;
        ans=min(ans,rres);
        cout <<ans<<"\n";
    }
}

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

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

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

  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);

  for (int i = 2; i < n; i++)
  {
    int m = INT_MAX;
    for (int j = 1; j < min(i, k) + 1; j++)
    {
      m = min(m, dp[i - j] + abs(h[i - j] - h[i]));
    }
    dp[i] = m;
  }
  cout << dp[n - 1] << endl;
}


Measured memory_bytes: 4288
#include <iostream>
#include <math.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	long long int N,ans=0;
	cin >> N;
	vector<string>S(N);
	set<string>count;
	map<string,int>A;
	for (int i = 0; i < N; i++)
	{
		cin >> S[i];
		sort(S[i].begin(), S[i].end());
		if (count.find(S[i]) != count.end()) {
			ans += A[S[i]];
		}
		else
		{
			count.insert(S[i]);
		}
		A[S[i]]++;
	}
	cout << ans;
}

Measured memory_bytes: 27648
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

ll a, b;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> a >> b;
	ll res = 1;
	for (ll i = 2; i * i <= a; i++) {
		if (a % i == 0) {
			while (a % i == 0)
				a /= i;
			if (b % i == 0)
				res++;
		}
	}
	if (a > 1 && b % a == 0)
		res++;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b && b==c)
		cout<<1<<endl;
	else if((a==b && b!=c) || (a==c && c!=b) || (b==c && c!=a))
		cout<<2<<endl;
	else
		cout<<3<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

int main(){
  ll r;
  cin >> r;
  cout << 3*pow(r,2) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=1e5+5;

vi G[MAX];

int main(){
	int N,M;
	cin>>N>>M;
	int ct[MAX];
	rep1(i,N)ct[i]=0;
	int a[MAX],b[MAX];
	rep(i,M){
		int a,b;
		cin>>a>>b;
		ct[a]++;ct[b]++;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	bool ok=true;
	rep1(i,N)if(ct[i]%2==1)ok=false;
	if(M<=N+1)ok=false;
	if(M==N+2){
		vi c4;
		rep1(i,N)if(ct[i]==4)c4.push_back(i);
		int l=sz(c4);
		if(l==2){
			int s=c4[0],t=c4[1];
			int lp=0;
			rep(i,4){
				int u=s;
				int v=G[s][i];
				while(true){
					int w=G[v][0]+G[v][1]-u;
					u=v;
					v=w;
					if(v==s){lp++;break;}
					if(v==t){break;}
				}
			}
			if(lp==0)ok=false;
		}
	}
	if(ok)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}

Measured memory_bytes: 6144
def aux(txt)
  txts=[]
  l0=(0..25).to_a.map{|x|(x+'a'.ord).chr}
  len=l0.length
  re=Regexp.new("the|this|that")
  len.times{|d|
    l1=(l0+l0).slice(d,len)
    txt1=txt.split(//).map{|c|
      idx=l1.index(c)
      if idx
        l0[idx]
      else
        c
      end
    }.join
    txts.push(txt1) if re.match(txt1)
  }
  return txts
end

def main
  dat=[]
  fh=STDIN
  #fh=File.new("x.txt", "r")
  while fh.gets
    txts=aux($_.chomp)
    1/0 if txts.length>1
    puts txts[0]
  end

end

if $0 == __FILE__ then
  main
end


Measured memory_bytes: 6980
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
// 検索タグ
int main() {
	// 入力
	ll N,K;cin>>N>>K;
   
	// 解法
	ll cand1 = N%K;
	ll cand2 = -(cand1-K);
	ll ans = min(cand1, cand2);

	//出力
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
auto rd=read<int>;

int n, a[19], l[1<<16], r[1<<16], u[1<<16], v[1<<16];
long long f[1<<17][19][19];
int main() {
	n=rd();
	for(int i=1; i<=n; ++i) a[i]=rd();
	if(n==2) {
		printf("%d\n", a[1]+a[n]);
		return 0;
	}
	u[1]=v[1]=l[1]=1;
	r[1]=n;
	for(int i=1; i<1<<(n-3); ++i) {
		u[i<<1]=u[i];
		v[i<<1]=u[i<<1|1]=u[i]+v[i];
		v[i<<1|1]=v[i];
		l[i<<1]=l[i], r[i<<1]=r[i]-1;
		l[i<<1|1]=l[i]+1, r[i<<1|1]=r[i];
	}
	for(int x=1<<(n-2); --x; ) {
		for(int i=l[x]; i<=r[x]; ++i)
			for(int j=i+2; j<=r[x]; ++j)
				f[x][i][j]=4e18;
		for(int i=l[x]; i<r[x]; ++i)
			for(int j=i+1; j<r[x]; ++j)
				for(int k=j+1; k<=r[x]; ++k)
					cmin(f[x][i][k], f[x<<1][i][j]+f[x<<1|1][j][k]+(long long)(u[x]+v[x])*a[j]);
	}
	printf("%lld\n", a[1]+a[n]+f[1][1][n]);
	return 0;
}


Measured memory_bytes: 188672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> broken(n+1);
  rep(i,m){
  int a;
  cin>>a;
    broken[a]=1;
  }
  vector<int>dp(n+2);
  dp[n]=1;
  for(int i= n-1;i>=0;i--){
    if(broken[i]){
      dp[i]=0;
      continue;
    }
    dp[i]=(dp[i+2]+dp[i+1])%1000000007;
  }
  cout<<dp[0]<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

const int MAX = 30;

int main(){
    cout << fixed << setprecision(10);
    vector<double> prob(MAX);
    prob[0] = 1;

    vector<double> zyou(MAX);
    zyou[0] = 1;
    for(int i=1;i<MAX;i++) zyou[i] = zyou[i-1] / 2;

    vector<double> ans;
    double ret = 0;
    for(int i=1;i<=100010;i++){
        for(int j=0;j<MAX;j++){
            ret += zyou[j]*prob[j];
        }
        ans.push_back(ret);
        vector<double> next(MAX);
        for(int j=0;j<MAX;j++){
            if(j != MAX-1){
                next[j+1] += prob[j]*zyou[j];
            }
            next[0] += prob[j]*(1-zyou[j]);
        }
        prob = next;
    }

    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        cout << ans[n-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1984
#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<int> a(9);
    for (int i = 0; i < 9; i++)
    {
        cin >> a.at(i);
    }

    int n;
    cin >> n;

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

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 9; j++)
        {
            if (b.at(i) == a.at(j))
            {
                a.at(j) = 0;
                exit;
            }
        }
    }

    string result = "No";

    // tate
    for (int i = 0; i < 3; i++)
    {
        int index = (i * 3) + 1;
        if (a.at(i) == 0 && a.at(i + 3) == 0 && a.at(i + 6) == 0)
        {
            result = "Yes";
        }
    }

    // yoko
    for (int i = 0; i < 3; i++)
    {
        int index = (i * 3);
        if (a.at(index) == 0 && a.at(index + 1) == 0 && a.at(index + 2) == 0)
        {
            result = "Yes";
        }
    }

    if (a.at(0) == 0 && a.at(4) == 0 && a.at(8) == 0)
    {
        result = "Yes";
    }
    else if (a.at(2) == 0 && a.at(4) == 0 && a.at(6) == 0)
    {
        result = "Yes";
    }

    cout << result << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int A[110];

signed main() {
    int N;
    cin >> N;
    rep(i, N) {
        cin >> A[i];
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (i != 0) {
            if (A[i - 1] == A[i]) {
                A[i] = A[i + 1] + 1;
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	string S; cin >> S;
	string res = "";
	rep(i, S.size()) {
		if (S[i] != 'B') {
			res += S[i];
		} else if (res.size() > 0) {
			res.erase(res.size() - 1);
		}
	}
	cout << res << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

MOD = 10 ** 9 + 7

N = int(readline())
m = map(int,read().split())
AB = zip(m,m)

D = 2000

U = 10 ** 4
fact = [1] * U
for n in range(1,U):
    fact[n] = fact[n-1] * n % MOD
fact_inv = [1] * U
fact_inv[-1] = pow(fact[-1],MOD-2,MOD)
for n in range(U-1,0,-1):
    fact_inv[n-1] = fact_inv[n] * n % MOD

C_to_A = [[] for _ in range(D+D+1)]
remove = 0
for a,b in AB:
    c = a+b
    C_to_A[c].append(D-a)
    remove += fact[c+c] * fact_inv[a+a] * fact_inv[b+b]

dp = np.zeros(D+D+1,np.int64)
for A in C_to_A[::-1]:
    dp[1:] += dp[:-1].copy()
    np.add.at(dp,A,1)
    dp %= MOD

x = (dp * dp[::-1] % MOD).sum() % MOD
x -= remove % MOD
x *= fact_inv[2]
x %= MOD

print(x)


Measured memory_bytes: 40384
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
	int n;
  cin >> n;
  int arr[n];
  for(int i = 0;i<n;i++) cin >> arr[i];
  long long ans = 0;
  for(int i = 0;i<n;i++){
  	for(int j = i+1;j<n;j++){
    	ans += arr[i]*arr[j];
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256