akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int main(){

    int n,m;
    scanf("%d%d",&n,&m);

    int i;
    int ints[m],intc[m];
    char s[m],c[m];
    for(i=0;i<m;i++){
        scanf("%d%d",&ints[i],&intc[i]);
        s[i]='0'+ints[i];
        c[i]='0'+intc[i];
    }

    // printf("s is %c\n",s[0]);

    if(n==1){
        char ansstr='F';
        
        for(i=0;i<m;i++){
            // printf("inkya");
            // if(s[i]!=1){
            //     printf("-1");
            //     return 0;
            // }
            if(ansstr=='F'){
                ansstr=c[i];
                // printf("sounyuu %c",ansstr[s[i]-1]);
            } else if(ansstr!=c[i]){
                printf("-1");
                return 0;
            }
        }
        if(ansstr=='F') ansstr='0';
        printf("%c",ansstr);

    } else if(n==2){
        char ansstr[2];
        for(i=0;i<2;i++){
            ansstr[i]='F';
        }
        for(i=0;i<m;i++){
            // printf("inkya");
            // if(ints[i]!=1&&ints[i]!=2){
            //     printf("-1");
            //     return 0;
            // }
            if(ansstr[ints[i]-1]=='F'){
                ansstr[ints[i]-1]=c[i];
                // printf("sounyuu %c",ansstr[s[i]-1]);
            } else if(ansstr[ints[i]-1]!=c[i]){
                printf("-1");
                return 0;
            }
        }

        if(ansstr[0]=='0'){
            printf("-1");
            return 0;
        } else if(ansstr[0]=='F'){
            ansstr[0]='1';
        }

        if(ansstr[1]=='F'){
            ansstr[1]='0';
        }

        for(i=0;i<2;i++){
            printf("%c",ansstr[i]);
        }


    } else if(n==3){
        char ansstr[3];
        for(i=0;i<3;i++){
            ansstr[i]='F';
        }
        for(i=0;i<m;i++){
            // printf("inkya");
            // if(ints[i]!=1&&ints[i]!=2&&ints[i]!=3){
            //     printf("-1");
            //     return 0;
            // }
            if(ansstr[ints[i]-1]=='F'){
                ansstr[ints[i]-1]=c[i];
                // printf("sounyuu %c",ansstr[s[i]-1]);
            } else if(ansstr[ints[i]-1]!=c[i]){
                printf("-1");
                return 0;
            }
        }
        if(ansstr[0]=='0'){
            printf("-1");
            return 0;
        } else if(ansstr[0]=='F'){
            ansstr[0] = '1';
        }

        if(ansstr[1]=='F') ansstr[1]='0';
        if(ansstr[2]=='F') ansstr[2]='0';

        for(i=0;i<3;i++){
            printf("%c",ansstr[i]);
        }
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll n;cin>>n;
  vector<ll> a(n);
  rep(i,n){
  	cin>>a[i];
  	a[i]-=(i+1);
  }
  sort(all(a));
  ll b=a[(n-1)/2];
  ll ans=0;
  rep(i,n){
  	ans+=abs(a[i]-b);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main(){

	int a,b,c;
	cin>>a>>b>>c;
	if(a>b){
		swap(a,b);
	}if(a>c){
		swap(a,c);
	}if(b>c){
		swap(b,c);
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
}

Measured memory_bytes: 1168
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

const int MOD = 1000*1000*1000+7;
void chadd(int& a, int b) { a = ((ll)a+b)%MOD; }
int mul(int a, int b) { return ((ll)a*b)%MOD; }

int fact[1020], invfact[1020];
int powinvfact[1020][1020];
ll inv(ll a, ll p) {
  return ( a == 1 ? 1 : (1 - p*inv(p%a, a)) / a + p );
}
ll power(ll a,ll b,ll mod) {
  if (b==0) return 1LL;
  if (b%2) return (a*power(a,b-1,mod))%mod;
  else {
    ll x=power(a,b/2,mod);
    return (x*x)%mod;
  }
}

int dp[1020][1020];  // dp[num][total] := counting

int main() {
  fact[0] = 1;
  for (int i : range(1, 1020)) {
    fact[i] = mul(fact[i - 1], i);
  }
  for (int i : range(1020)) invfact[i] = inv(fact[i], MOD);

  for (int i : range(1020)) {
    for (int j : range(1020)) {
      powinvfact[i][j] = power(invfact[i], j, MOD);
    }
  }

  int N;
  int A, B, C, D;
  while (cin >> N >> A >> B >> C >> D) {
    memset(dp, 0, sizeof(dp));
    dp[A - 1][0] = 1;

    for (int n = A; n <= B; ++n)
    for (int total = 0; total <= N; ++total) {
      if (dp[n - 1][total] == 0) continue;
      //cout << n - 1 << " " << total << " : " << dp[n - 1][total] << endl;

      for (int x = C; x <= D; ++x) {
        int ntotal = total + x * n;
        if (ntotal > N) break;

        int pie = N - total;
        int choose = N - ntotal;
        int comb = mul(fact[pie], mul(invfact[choose], invfact[pie - choose]));
        int comb2 = mul(fact[x * n], mul(powinvfact[n][x], invfact[x]));
        int coef = mul(comb, comb2);

        // cout << "#" << n << " " << total << " " << x << " : " << comb <<" " << comb2 << " ( " << ntotal << endl;

        chadd(dp[n][ntotal], mul(dp[n - 1][total], coef));
      }

      // x == 0
      chadd(dp[n][total], dp[n - 1][total]);
    }

    cout << dp[B][N] << endl;
  }
}


Measured memory_bytes: 8448
N = gets.to_i
S = gets.chomp.chars
ans = S.count(?R) * S.count(?G) * S.count(?B)
for i in 0..N
    j = 1
    while i+2*j < N
        if S[i] != S[i+j] && S[i+j] != S[i+2*j] && S[i+2*j] != S[i]
            ans -= 1
        end
        j += 1
    end
end
p ans

Measured memory_bytes: 14372
#include<iostream>
//#include<vector>

int main(){
    int K, N;
    std::cin >> K >> N;
    //std::vector< int > A(N);
    int pre;
    int max = 0;
    int first;
    std::cin >> first;
    pre = first;
    for(int i=1; i<N; i++){
        int tmp;
        std::cin >> tmp;
        int dist = tmp - pre;
        if(dist > max){ max = dist;}
        pre = tmp;
    }
    int dist = K - pre + first;
    if(dist > max){ max = dist;}
    
    std::cout << K - max << std::endl;
    
    return 0;
}



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

int main(){
	
	int N, D, result = 0;
	cin >> N >> D;

	int points[N][2];
	for(int i = 0; i < N; i++){
		for(int j = 0; j < 2; j++){
			cin >> points[i][j];
		}
	}
	
	for(int k = 0; k < N; k++){
		double temp = sqrt(pow(points[k][0], 2) + pow(points[k][1], 2));
		if(temp <= D){
			result++;
		}
	}

	cout << result;
	return 0;
}


Measured memory_bytes: 5240
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
long long int i,n;
  string u;
  double sum = 0, x;

cin >> n;
  for(i=0; i<n; i++){
    cin >> x;
    cin >> u;
    
    if(u=="JPY")
      sum += x;
    else
      sum += x*380000.0;
  }
    cout << sum;
return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
        k: usize,
        q: usize,
        a: [usize; q],
    }
    let mut b = vec![0; n];
    for ai in a {
        b[ai - 1] += 1;
    }
    for i in 0..n {
        if q - b[i] < k {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


Measured memory_bytes: 6780
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    string s;
    cin>>s;
    int n=s.size(),i,ctr=0;
    vector<ll> f;
    while (n)
    {
        ll k=(1<<(ctr-1));
        for (i=0;i<f.size();i++)
        {
            f[i]=10*f[i]+k;
        }
        k=1<<ctr;
        f.pb(k);
        ctr++;
        n--;
    }
    ll ans=0;
    for (i=0;i<f.size();i++)
        ans+=f[i]*(s[i]-'0');
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k,x;
    cin >> k >> x; 
    for(int i=x-k+1; i<=x+k-1; i++){
        cout << i << ((i!=x+k-1)?" ":"\n");
    }
}

Measured memory_bytes: 256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {
	
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d) cout << "Left" << endl;
	else if (a + b == c + d) cout << "Balanced" << endl;
	else cout << "Right" << endl;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

struct DSU {
    vi p; vi sum; void init(int n) {p = vi (n, -1); sum = vi (n, 0);}
    int findSet(int x) { return p[x] < 0 ? x : findSet(p[x]);}
    bool sameSet(int a, int b) { return findSet(a) == findSet(b); }
	int size(int x) { return -p[findSet(x)]; }
	bool joinSet(int x, int y) { // union-by-rank
		x = findSet(x), y = findSet(y); if (x == y) return 0;
		if (p[x] > p[y]) swap(x,y);
		sum[x] += sum[y]; p[x] += p[y]; p[y] = x; return 1;
	}
};

int main() {
    // ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string S; cin >> S;
	
	DSU dsu; dsu.init(S.size()-1);
	FOR(i, 1, S.size()) dsu.sum[i-1] = S[i] - S[i-1];
	for (int i = 0; i < (S.size() - 1) / 2; ++i) dsu.joinSet(i, S.size()-2-i);
	vi solve = vi ();
	int N; cin >> N;
	F0R(i, N) {
		int l, r; cin >> l >> r; --l; --r;
		if ((l == 0) && (r == S.size()-1)) {}
		else if (r == S.size()-1) solve.push_back(l-1);
		else if (l == 0) solve.push_back(r);
		else dsu.joinSet(l-1, r);
	}
	for(int x : solve) dsu.sum[dsu.findSet(x)] = 0;
	bool works = true;
	F0R(i, S.size()-1) {
		if ((dsu.sum[dsu.findSet(i)] % 26 + 26) % 26 != 0) works = false;
	}
	print(works ? "YES" : "NO");
}

Measured memory_bytes: 4320
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n,a[200005],ans=0;
cin>>n;
rep(i,0,n-1)cin>>a[i];
sort(a,a+n);

if(a[n/2-1]==a[n/2])
{
	ol("0");
}
else
{
	ol(a[n/2]-a[n/2-1]);
}
return 0;
}



Measured memory_bytes: 640
#include<stdio.h>                                                 
                                                                  
int main(void){                                                   
   int N,page;                                                    
   scanf("%d",&N);                                                
   page = (N / 2);                                                
                                                                  
   if(N % 2 == 1){                                                
      page += 1;                                                  
   }                                                              
   printf("%d\n",page);                                           
   return 0;                                                      
}  

Measured memory_bytes: 1708
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <type_traits>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	static constexpr uint32 INF = UINT32_MAX / 3;
	uint32 h, w;
	std::cin >> h >> w;
	std::vector<std::vector<char>> s(h, std::vector<char>(w));
	uint32 ans = 0;
	for (uint32 i = 0;i < h;++i) {
		for (uint32 j = 0;j < w;++j) {
			std::cin >> s[i][j];
			if (s[i][j] == '.') ++ans;
		}
	}
	std::queue<std::pair<uint32, uint32>> Q;
	std::vector<std::vector<uint32>> d(h, std::vector<uint32>(w, INF));
	d[0][0] = 0;
	Q.push({ 0,0 });
	while (!Q.empty()) {
		uint32 x, y;
		std::tie(x, y) = Q.front();Q.pop();
		if (y > 0) {
			if (s[x][y - 1] == '.') {
				if (d[x][y - 1] > d[x][y] + 1) {
					d[x][y - 1] = d[x][y] + 1;
					Q.push({ x,y - 1 });
				}
			}
		}
		if (y != w - 1) {
			if (s[x][y + 1] == '.') {
				if (d[x][y + 1] > d[x][y] + 1) {
					d[x][y + 1] = d[x][y] + 1;
					Q.push({ x,y + 1 });
				}
			}
		}
		if ((x != h - 1)) {
			if (s[x + 1][y] == '.') {
				if (d[x + 1][y] > d[x][y] + 1) {
					d[x + 1][y] = d[x][y] + 1;
					Q.push({ x + 1,y });
				}
			}
		}
		if (x) {
			if (s[x - 1][y] == '.') {
				if (d[x - 1][y] > d[x][y] + 1) {
					d[x - 1][y] = d[x][y] + 1;
					Q.push({ x - 1,y });
				}
			}
		}
	}
	if (d[h - 1][w - 1] == INF) std::cout << "-1\n";
	else {
		std::cout << ans - d[h - 1][w - 1] - 1 << "\n";
	}
	return 0;
}

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

typedef struct _body{
	struct _body *next;
	char color[11];
	int time;
} BODY;

BODY *head, *tail, *newnode;

int solve_time(char *start);
void change_color(char col, char *before, int i);
int check(char *str);
int sansin(char *str);
void erase(void);

int main(void)
{
	BODY *temp;
	
	char start[11];
	int judge;
	
	do {
		scanf("%s", start);
		if (start[0] - '0'){
			newnode = (BODY *)malloc(sizeof(BODY));
			head = tail = newnode;
			newnode->next = NULL;
			strcpy(newnode->color, start);
			head->time = 0;
			
			judge = solve_time(head->color);
			
			if (judge >= 0){
				printf("%d\n", judge);
			}
			else {
				printf("NA\n");
			}
		}
		while (head != NULL){
			temp = head;
			head = head->next;
			free(temp);
		}
	} while (start[0] != '0');
	
	return (0);
}

int solve_time(char *start)
{
	BODY *temp;
	int len = strlen(start);
	char change[11];
	char memo[59050] = {0};
	int i;
	
	memo[sansin(start)] = 1;
	if (check(start) == len * 'r' || check(start) == len * 'g' || check(start) == len * 'b') {
		return (0);
	}
	
	else {
		while (1){
			if (head->time > 30) break;
			for (i = 0; i < len - 1; i++){
				if (head->color[i] != head->color[i + 1] && head->color[i] != 'r' && head->color[i + 1] != 'r'){
					change_color('r', head->color, i);
					if (memo[sansin(tail->color)] == 1) erase();
					else memo[sansin(tail->color)] = 1;
					tail->time = head->time + 1;
					if (check(tail->color) == len * 'r') return (tail->time);
				}
				if (head->color[i] != head->color[i + 1] && head->color[i] != 'g' && head->color[i + 1] != 'g'){
					change_color('g', head->color, i);
					if (memo[sansin(tail->color)] == 1) erase();
					else memo[sansin(tail->color)] = 1;
					tail->time = head->time + 1;
					if (check(tail->color) == len * 'g') return (tail->time);
				}
				if (head->color[i] != head->color[i + 1] && head->color[i] != 'b' && head->color[i + 1] != 'b'){
					change_color('b', head->color, i);
					if (memo[sansin(tail->color)] == 1) erase();
					else memo[sansin(tail->color)] = 1;
					tail->time = head->time + 1;
					if (check(tail->color) == len * 'b') return (tail->time);
				}
			}
			
			temp = head;
			if (head->next == NULL) return (-1);
			head = head->next;
			free(temp);
		}
	}
	return (-1);
}

void change_color(char col, char *before, int i)
{
	BODY *temp;
	
	newnode = (BODY *)malloc(sizeof(BODY));
	strcpy(newnode->color, before);
	newnode->color[i] = newnode->color[i + 1] = col;
	temp = head;
	while (temp->next != NULL){
		temp = temp->next;
	}
	temp->next = newnode;
	newnode->next = NULL;
	tail = newnode;
}

int check(char *str)
{
	int sum = 0;
	int i = 0;
	
	while (str[i] != '\0'){
		sum += str[i];
		i++;
	}
	
	return (sum);
}

int sansin(char *str)
{
	int kekka, temp;
	int i = 0;
	kekka = temp = 0;
	
	while (str[i] != '\0'){
		if (str[i] == 'r') temp = 0;
		else if (str[i] == 'g') temp = 1;
		else temp = 2;
		kekka = kekka * 3 + temp;
		i++;
	}
	return (kekka);
}

void erase(void)
{
	BODY *temp, *pre;
	
	temp = head;
	while (temp->next != NULL){
		pre = temp;
		temp = temp->next;
	}
	pre->next = NULL;
	tail = pre;
	free(temp);
}

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

int main(){
	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
		return 0;
	}
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << 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 repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  string s;
  cin >> s;
  int n=s.length();
  vector<pair<int,int>> dp(n+1);
  vector<int> pos(26,-1);
  for(int i=n;i>=0;i--){
    dp[i]={IINF,-1};
    for(int j=0;j<26;j++){
      if(pos[j]==-1){
        dp[i]={1,-j};
        break;
      }
      if(dp[i].first>dp[pos[j]].first+1){
        dp[i]={dp[pos[j]].first+1,pos[j]};
      }
    }
    if(i>0) pos[s[i-1]-'a']=i;
  }
  string ans="";
  int now=0;
  while(1){
    now=dp[now].second;
    if(now<=0){
      ans+=string(1,'a'-now);
      break;
    }
    ans+=string(1,s[now-1]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2180
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

int main()
{
    ll s[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll k;
    cin >> k;
    cout << s[k-1] << endl;
    return 0;
} 

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

int main() {
  int64_t x,k,d;
  cin>>x>>k>>d;

  int64_t ans;

  int64_t max_d = 10000000000000000/k;  //10^16
  if(d<max_d && abs(x)>k*d) {
    ans = abs(x)-k*d;
    cout<<ans<<endl;
    return 0;
  }

  int64_t rest = k - abs(x)/d;
  if(rest%2==0) {
    ans = (abs(x)-(abs(x)/d)*d);
  }
  else {
    ans = -(abs(x)-(abs(x)/d+1)*d);
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3632
import sys

sys.setrecursionlimit(10 ** 4)

w = h = 0
islands = []


def dfs(ii: int, jj: int) -> None:
    global islands
    islands[jj][ii] = 0

    for i in range(ii - 1, ii + 2):
        for j in range(jj - 1, jj + 2):
            if 0 <= i < w and 0 <= j < h and islands[j][i] > 0:
                dfs(i, j)


def main() -> None:
    ans = []
    global islands, w, h
    while True:
        cnt = 0
        w, h = map(int, input().split())
        if w + h == 0:
            break
        islands = [list(map(int, input().split())) for _ in range(h)]
        for j in range(h):
            for i in range(w):
                if islands[j][i] > 0:
                    cnt += 1
                    dfs(i, j)
        ans += [cnt]
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()



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


int main() {

    int n;
    cin >> n;
    rep(i,10) {
        rep(j,10) {
            if (n == i*j) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e6+3)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int main()
{
	owo
	int n,w;
	cin>>n>>w;
	vector<ll>dp(w+1,0);
	vector<PII>knap(n);
	for(PII &x:knap)cin>>x.fi>>x.se;
	ll ans = 0;
	for(int i=0;i<n;i++){
		for(int j=w;j>0;j--){
			if(j-knap[i].fi >= 0)dp[j] = max(dp[j],dp[j-knap[i].fi]+knap[i].se);
			else break;
		}
	}
	for(int i=0;i<=w;i++)ans = max(ans,dp[i]);
	cout<<ans;
}

Measured memory_bytes: 3988
#include <cstdio>
int N, M, Q, maxn = -9999999;
int a[101], b[101], c[101], d[101];
int flag[11], A[11];
void clear()
{
	int res = 0;
	for(int i=1;i<=Q;i++)
	{
		if(A[b[i]]-A[a[i]]==c[i])
		    res += d[i];
	}
	if(res>maxn)
	    maxn = res;
}
void dfs(int k)
{
	for(int i=A[k-1];i<=M;i++)
	{
		if(i!=0)
		{
			A[k] = i;
			if(k==N)
			{
				clear();
			}
			else dfs(k+1);
			A[k] = 0;
		}
	}
}
int main()
{
	scanf("%d%d%d", &N, &M, &Q);
	for(int i=1;i<=Q;i++)
	{
		scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
	}
	dfs(1);
	printf("%d\n", maxn);
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N;
  cin >> N;
  vector <int> A(N);
  rep(i,N) cin >> A[i];
  sort(all(A));
  for (int i = 0; i < N - 1; i++){
    if (A[i] == A[i + 1]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 4036
use strict;
use warnings;

sub main {
    chomp(my $N = <STDIN>);
    chomp(my $S = <STDIN>);
    print solve($N, $S);
}
main() unless caller;

sub solve {
    my ($N, $S) = @_;
    my @ar=split(//,$S);
    my $x = 0;
    my $max = 0;
    for my $s(@ar){
        $s eq "I" ? $x++ : $x--;
        $max = $max > $x ? $max : $x;
    }
    return $max;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

vector<LL> prime_list(1100, 0);

void factorize_gen(LL n){
    for(LL i=2; i*i<=n; i++){
        if(n%i!=0){
            continue;
        }
        LL num=0;
        while(n%i==0){
            num++;
            n/=i;
        }
        prime_list[i]+=num;
    }
    if(n!=1){
        prime_list[n]+=1;
    }

    return;
}

int main() {
    LL n;
    LL ans=1;
    cin >> n;
    for(LL i=2; i<=n; i++){
        factorize_gen(i);
    }

    for(LL i=0; i<=n; i++){
        ans=ans*(prime_list[i]+1);
        ans=ans%MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3524
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main() {
	int n, s[200] = {}, num[200] = {}, result = 0, lamp = 1, in, ax, h, w, m,a,b,c,r,tmp;
	string str ,str2;
	cin >>str>>str2;
	for (int i = 0; i < str2.length(); i++) {
		cout << str[i] << str2[i];
	}
	if (str.length() > str2.length()) { cout << str[str.length()-1]; return 0; }
}

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

#define M 1046527/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M/* your task */; }
int h2(int key){ return 1+(key%(M-1))/* your task */; }

int find(char str[]){
  long long a,i,b;
  a=getKey(str);
  for(i=0;;i++){
    b=(h1(a)+i*h2(a))%M;
    if(strcmp(H[b],str)==0)return 1;
    else if(strlen(H[b])==0){
      return 0;
    }
  }
return 0;
}
    /* your task */



int insert(char str[]){
 long long a,i,b;
  a=getKey(str);
  for(i=0;;i++){
    b=(h1(a)+i*h2(a))%M;
    if(strcmp(H[b],str)==0)return 1;
    else if(strlen(H[b])==0){
      strcpy(H[b],str);
      return 0;
    }
  }
return 0;
}
    /* your task */


int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 16052
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;
typedef double dou;
dou area(dou a, dou b, dou c){
    dou s = (a+b+c)/2;
    return sqrt(s*(s-a)*(s-b)*(s-c));
}

int main(){
    dou a,l,x;
    while(cin >> a >> l >> x){
        dou s1 = area(l,l,a);
        dou t = (l+x)/2;
        dou s2 = area(t,t,l);
        printf("%.10f\n",s1 + 2*s2);
    }
}

Measured memory_bytes: 1240
{-# LANGUAGE RecursiveDo        #-}
{-# LANGUAGE OverloadedStrings  #-}
{-# LANGUAGE NumericUnderscores #-}

import qualified Data.ByteString.Char8 as C8
import Data.List
import Data.Char

f :: Int -> [Int] -> [Int]
f k hs@(h:_) = map (abs . subtract h) (take k hs)

g :: Int -> [Int] -> [Int] -> [Int] -> Int
g _ costs _      []                  = head costs
g k costs starts dists@(dist:dists') = g k costs' starts' dists'
  where cost    = minimum $ zipWith (\ c s -> c + abs (dist - s)) costs starts
        costs'  = cost : take (k - 1) costs
        starts' = dist : take (k - 1) starts

solve :: Int -> Int -> [Int] -> Int
solve n k h
    | n > k     = g k (reverse $ f k h) (reverse $ take k h) (drop k h)
    | otherwise = last $ f n h

main = do
  [n, k] <- unfoldr (C8.readInt . C8.dropWhile isSpace) <$> C8.getLine
  h      <- unfoldr (C8.readInt . C8.dropWhile isSpace) <$> C8.getLine
  print $ solve n k h


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

int	main() {
	int	a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	if (2 * c >= a + b) {
		cout << x * a + y * b << endl;
		return 0;
	}
	if (x > y && a <= 2 * c) {
		cout << (x - y) * a + y * 2 * c << endl;
		return 0;
	}
	if (x < y && b <= 2 * c) {
		cout << x * 2 * c + (y - x) * b << endl;
		return 0;
	}
	cout << max(x, y) * 2 * c << endl;
	return 0;
}


Measured memory_bytes: 256
def modinv(a, m):
    b = m
    u = 1
    v = 0
    while b:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u %= m
    if u < 0:
        u += m
    return u

def nCk(N, k, mod):
    ret_val = 1
    for i in range(k):
        ret_val *= (N - i)
        ret_val %= mod
        ret_val *= modinv(i + 1, mod)
        ret_val %= mod
    return ret_val


n, a, b = map(int, input().split())
MOD = 10 ** 9 + 7
all_cnt = pow(2, n, MOD) - 1
a_cnt = nCk(n, a, MOD)
b_cnt = nCk(n, b, MOD)
ans = all_cnt - a_cnt - b_cnt
while ans < 0:
    ans += MOD
print(ans)


Measured memory_bytes: 9232
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

from collections import Counter

def solve():
    n = II()
    V = LI()
    
    even = V[::2]
    odd = V[1::2]
    harf = n // 2
    
    ec = Counter(even).most_common()
    oc = Counter(odd).most_common()
    #print(n)
    #print(ec[:3])
    #print(oc[:3])

    
    if ec[0][0] == oc[0][0]:
      # 小さい方を変える
      if ec[0][1] < oc[0][1]:
        ans = n - oc[0][1] - (ec[1][1] if len(ec) > 1 else 0)
      elif ec[0][1] == oc[0][1]:
        ans = n - ec[0][1] - max((ec[1][1] if len(ec) > 1 else 0), (oc[1][1] if len(oc) > 1 else 0))
      else:
        ans = n - ec[0][1] - (oc[1][1] if len(oc) > 1 else 0)
    else:
      ans = n - ec[0][1] - oc[0][1]
    
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 21060
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll mod = 1e9+7;

int main() {
    string s, t;
    cin >> s >> t;
    string sa{s};
    rep(i, sa.size()) {
        if (sa[i] == '?') sa[i] = 'a';
    }
    vector<string> buf;
    rep(i, s.size()-t.size()+1) {
        bool match = true;
        rep(j, t.size()) {
            if (s[i+j] != '?' && s[i+j] != t[j]) {
                match = false;
                break;
            }
        }
        if (match) {
            string s1{sa};
            rep(j, t.size()) s1[i+j] = t[j];
            buf.emplace_back(s1);
        } 
    } 
    sort(all(buf));
    string ret =  (buf.empty() ? "UNRESTORABLE" : buf[0]); 
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
var main = (input: string) => {
    const n: number = parseInt(input);

    let ans = powmod(10, n) - powmod(9, n) - powmod(9, n) + powmod(8, n);
    ans = ans % mod;
    ans = (ans + mod) % mod;
    console.log(ans);
}

let powmod = (radix: number, index: number) {
    let val: number = 1;
    for (let i: number = 0; i < index; i++) {
        val = val * radix % mod;
    }
    return val;
}

const mod = 1000000007;

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(void)
{
    string S;
    cin >> S;

    if(S == "RRR"){
        cout << 3 << endl;
    }else if (S == "RRS" || S == "SRR" ){
        cout << 2 << endl;
    }else if (S == "SSS"){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }

}

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

int main()
{
  int n;
  cin >> n;
  vector<pair<pair<string,int>,int>> sp;
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    int p; cin >> p;
    sp.push_back(pair<pair<string,int>,int>(pair<string,int>(s,-1*p),i+1));
  }
  sort(sp.begin(),sp.end());
  for (auto && a : sp) {
    cout << a.second << endl;
  }
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<assert.h>
#include<numeric>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
using namespace std;

using ll = long long;

string s;

int snum[12];

ll ans = 0;

int main() {
	cin >> s;
	int N = s.size();
	rep(i, 0, N) {
		snum[i] = s[i] - '0';
	}
	rep(bit, 0, (1<<(N-1))) {
		ll num = 0;
		ll temp = snum[0];
		rep(i, 0, N - 1) {
			if (bit & (1 << i)) {
				num += temp;
				temp = snum[i + 1];
			}
			else {
				temp = 10 * temp + snum[i + 1];
			}
		}
		num += temp;
		ans += num;
	}
	cout << ans;
	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 int long long
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int h,w;
    cin >> h >> w;
    int a[h][w];
    vector<tuple<int,int,int,int>> v;
    rep(i,h){
        rep(j,w){
            cin >> a[i][j];
        }
    }
    int ans=0;
    rep(i,h){
        rep(j,w){
            if(a[i][j]%2==0) continue;
            else{
                if(j!=w-1){
                    ans++;
                    a[i][j]--;
                    a[i][j+1]++;
                    v.push_back(make_tuple(i+1,j+1,i+1,j+2)); 
                }
                else{
                    if(i!=h-1){
                        ans++;
                        a[i][j]--;
                        a[i+1][j]++;
                        v.push_back(make_tuple(i+1,j+1,i+2,j+1)); 
                    }
                    else continue;
                }
            }
        }
    }
    cout << ans << endl;
    for(auto t:v){
        cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << " " << get<3>(t) << endl;
    }


}

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

struct node {
  struct node *prev;
  int key;
  struct node *next;
};
typedef struct node *NodePointer;

void insert(int);
void delete(NodePointer);
void listprint(void);
NodePointer make_1node(int, NodePointer,NodePointer);

NodePointer head;
NodePointer tail;

int list_count=0;

int main(){
  NodePointer n;
  char command[12];
  int count,num,time=0,flag=0;
  char command_list[4][12]={{"insert"},{"delete"},{"deleteFirst"},{"deleteLast"}};
  head = make_1node(0,NULL,NULL);
  tail = make_1node(0,NULL,NULL);
  scanf("%d",&count);
  while(count>0){
    count--;
    scanf("%s",command);

    if(strcmp(command,command_list[0]) == 0){ //insert
      scanf("%d",&num);
      insert(num);
      list_count++;
    }

    else if(strcmp(command,command_list[1]) == 0){ // delete
      scanf("%d",&num);
      for(n = head->next;n != tail->next;n=n->next){
	if(n->key == num){
	  flag=1;
	  if(n == head->next){
	    head->next = n->next;
	    tail->next->next = head->next;
	    head->next->prev = tail->next;
	    delete(n);
	  }
	  else{
	    n->prev->next=n->next;
	    n->next->prev=n->prev;
	    delete(n);
	  }
	  break;
	}
      }
      if(n->key == num && flag == 0){
	tail->next = n->prev;
	tail->next->next = head->next;
	head->next->prev = tail->next;	
	delete(n);
      }
      flag=0;
    }  
    else if(strcmp(command,command_list[2]) == 0){ //deleteFirst
     n = head->next;
     head->next = n->next;
     tail->next->next = head->next;
     head->next->prev = tail->next;
     delete(n);
      
    }
    else if(strcmp(command,command_list[3]) == 0){ // deleteLast
      n = tail->next;
      tail->next = n->prev;
      tail->next->next = head->next;
      head->next->prev = tail->next;	
      delete(n);
    }
   
  }
  for(n=head->next;n != tail->next; n=n->next)printf("%d ",n->key);
  printf("%d\n",n->key);  
  
  return 0;
}
void insert(int num)
{
  NodePointer newnode;
  if(head->next == NULL){
  newnode = make_1node(num,NULL,NULL);
  head->next = newnode;
  tail->next = newnode;
  newnode->next=newnode;
  newnode->prev=newnode;  
  }
  else{
    newnode = make_1node(num,tail->next,head->next);
    head->next->prev = newnode;
    tail->next->next = newnode;
    head->next = newnode;
    
  }
    
}
NodePointer make_1node(int num, NodePointer pre,NodePointer nex)
{
  NodePointer n;
  
  if ((n = (NodePointer)malloc(sizeof(struct node))) == NULL) {
    printf("Error in memory allocation\n");
    exit(8);
  }
  n->key = num;
  n->next = nex;
  n->prev = pre;
  return n;
}
void delete(NodePointer n){
  if(list_count==1) {
    head->next = NULL;
    tail->next = NULL;
  }
  list_count--;
  free(n);
}


Measured memory_bytes: 32968
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

int main() {
  int n;
  std::cin >> n;
  std::vector<std::pair<int, int>> array(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> array[i].first;
    array[i].second = i;
  }
  std::sort(array.begin(), array.end());
  long long double_result = 0;
  for (int i = 0; i < n; ++i) {
    double_result += ((((array[i].second - i) % 2) + 2) % 2);
  }
  std::cout << double_result / 2 << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void){
	long long n,h;cin >> n >> h;
	vector<long long> a(n+1),b(n+1);
	for(int i=1; i<=n; i++)cin >> a[i] >> b[i];
	sort(a.begin(),a.end());sort(b.begin(),b.end());
	long long sord=a[n];
	long long ans=0;
	for(int i=n; i>0; i--){
		if(b[i]>sord){
			h-=b[i];ans++;
		}else break;
		if(h<=0)break;
	}
	if(h>0)ans+=(h+sord-1)/sord;
	cout << ans << endl;
	return 0;
}

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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/
const ll mod=1e9+7;
const ll INF=1e18;
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	string s; int n; cin >>n >>s;
	if (sz(s)<=n) {
		cout <<s;
		return 0;
	}
	for (int i=0;i<n;i++) cout <<s[i];
	cout <<"...";
	return 0;
}
/******************************************************************************
******************************************************************************/


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(T x,T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> T modinv(T x,const T mod){return modpow(x,mod-2,mod);}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getdiff(const T &a,const T &b,T &c) {
  set_difference(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> T deg2rad(T deg) {return deg*2*M_PI/360;}
template<class T> T rad2deg(T rad) {return rad*360/(2*M_PI);}

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD=1e9+7;
const ll MAX=5e6;


int main() {
  // それぞれのカウンター出力
  // 単純にQでループして、ツリーをたどると時間が無い
  // ルートに近い方から順番に足していって、子要素は最初親のを足した状態で
  int N,Q;cin>>N>>Q;
  vector<vector<ll>> G(N);
  REP(i,N-1) {
    int a,b;cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  map<int,ll> mp;
  REP(i,Q) {
    int p,x;cin>>p>>x;
    p--;
    mp[p]+=x;
  }
  // DUMPP(mp);

  vector<ll> ans(N,0);
  ans[0]=mp[0];
  deque<int> q{0};
  set<int> used{0};
  while (!q.empty()) {
    int v = q.front();q.pop_front();
    for (int nv:G[v]) if (used.find(nv)==used.end()) {
      used.insert(nv);
      ans[nv]=mp[nv]+ans[v];
      q.push_back(nv);
    }
  }
  DUMP(ans);

  return 0;
}

Measured memory_bytes: 39024
//
// Created by Tzyark on 2018/10/10.
//
#include <iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    int l = s.size();
    if (s[0] == s[l-1]) {
        if (l & 1) cout << "Second";
        else cout << "First";
    } else {
        if (l & 1) cout << "First";
        else cout << "Second";
    }
    return 0;
}


Measured memory_bytes: 512