akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

#include <random>
std::random_device seed_gen;
std::mt19937_64 engine(seed_gen());
// ull a = engine();
ll D;
vll now, c(26);
vvl s;
vector<set<ll>> st(26);
ll now_score = 0;

void init(ll d){
  D = d;
  now.resize(d, 0);
  s = VV(d, 26, 0, ll);
}
void make_set(vll t){
  for(int i=0;i<D;i++) st[t[i]].insert(i);
  for(int i=0;i<26;i++) st[i].insert(-1);
  for(int i=0;i<26;i++) st[i].insert(D);
}
ll calc(vll t){
  ll score = 0;
  vll cnt(26, 0);
  for(int i=0;i<D;i++){
    ll idx = t[i];
    for(int j=0;j<26;j++){
      if(j==idx) cnt[j] = 0;
      else{
        cnt[j]++;
        score -= cnt[j]*c[j];
      }
    }
    score += s[i][idx];
  }
  return score;
}

ll ch_score(ll day, ll after){
  ll score = now_score;
  ll prev = now[day];//前に選択していたもの
  if(prev==after) return score;

  //prevを消したことで減るスコア
  score -= s[day][prev];

  auto itr = st[prev].find(day);
  auto p = itr, q = itr;
  ll x = day - (*--p) - 1;
  ll y = (*++q) - day - 1;

  ll z = x + y + 1;
  //x, y分増え、z分減る
  score += c[prev]*((x*(x+1))/2 + (y*(y+1))/2);
  score -= c[prev]*((z*(z+1))/2);
  //afterを挿入した事で増えるスコア
  score += s[day][after];
  itr = st[after].upper_bound(day);
  p = itr;
  p--;

  z = (*itr) - (*p) - 1;
  x = day - (*p) - 1;
  y = (*itr) - day - 1;

  score += c[after]*(z*(z+1)/2);
  score -= c[after]*((x*(x+1))/2 + (y*(y+1))/2);
  return score;
}

void change(ll day, ll after){
  ll prev = now[day];
  st[prev].erase(day);
  st[after].insert(day);
  now[day] = after;
  now_score = ch_score(day, after);
}
vvl table;

int main(int argc, char const *argv[]) {
  ll d;scanf("%lld", &d);
  init(d);
  re(i, 26) scanf("%lld", &c[i]);
  re(i, D) re(j, 26) scanf("%lld", &s[i][j]);
  //初期値
  re(i, D) now[i] = i%26;
  //初期化
  make_set(now);
  now_score = calc(now);
  table = VV(D, 1500, -1, ll);//値が大きいものがよく現れるようにする

  for(int i=0;i<D;i++){
    ll S = 0;
    for(int j=0;j<26;j++) S += s[i][j];
    ll cnt = 0;
    for(int j=0;j<26;j++){
      ll per = (1500*s[i][j])/S;
      for(int k=0;k<per;k++){
        table[i][k+cnt] = j;
      }
      cnt += per;
    }
    for(int j=cnt;j<1500;j++) table[i][j] = 0;
  }

  //関数:
  // change(day, after) dayをafterに変更
  // ch_score(day, after) dayをafterに変更した場合の試算
  // 共に計算量10~20くらい
  // シミュレート回数10^7
  ll sim = 14000000;
  while(--sim){
    unsigned long long a = engine();
    unsigned long long b = engine();//after
    //unsigned long long C = engine();//
    a %= D, b %= 1500;
    b = table[a][b];
    if(now_score < ch_score(a, b)) change(a, b);
  }
  for(int i=0;i<D;i++) std::cout << now[i]+1 << '\n';
  return 0;
}


Measured memory_bytes: 7560
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

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

Measured memory_bytes: 256
#include<stdio.h>
#include<cstring>
int main()
{
	char s[5],a[5];
	strlen(s)==2||strlen(s)==3;
	scanf("%s",s);

	if(strlen(s)==2)  printf("%s\n",s);
	if(strlen(s)==3) {
	
	 for(int i=0;i<=2;i++)
	{
		a[2-i]=s[i];
	 
	 }
	  printf("%c%c%c\n",a[0],a[1],a[2]);
}
return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;

int main()
{
    const char shp = '#';

    int H, W;

    if (scanf("%d%d", &H, &W) < 2) return 0;

    for (int i = 0; i < W + 2; i++) printf("%c", shp);

    printf("\n");

    for (int i = 0; i < H; i++)
    {
        char a[101];
        scanf("%s", a);

        printf("%c", shp);
        printf("%s", a);
        printf("%c", shp);
        printf("\n");
    }

    for (int i = 0; i < W + 2; i++) printf("%c", shp);

    printf("\n");

    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

static class Program
{
    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

    static void Main(string[] args)
    {
        int N = ReadInt();
        long[] A = ReadLongs();
        int count = 1;
        long d1 = 0;
        for (int i = 1; i < N; ++i)
        {
            long d2 = A[i] - A[i - 1];
            if (d1 * d2 < 0)
            {
                ++count;
                d1 = 0;
            }
            else if (d2 != 0)
            {
                d1 = d2;
            }
        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 18912
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
#define PI 3.14159265358979323846
using namespace std;
using ll = long long;
const int INF = -100100100;
typedef pair<vector<int>,int> P;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<int> d(n);
    
    rep(rs, 2){
        int cnt = 0;
        rep(i,n){
            if(s[i]=='R')cnt++;
            else{
                d[i]+=cnt/2;
                d[i-1]+=(cnt+1)/2;
                cnt=0;
            }
        }
        reverse(s.begin(),s.end());
        reverse(d.begin(),d.end());
        rep(i,n){
            if(s[i]=='L')s[i]='R';
            else s[i] ='L';
        }
    }
    rep(i,n){
        printf("%d%c", d[i], i==n-1?'\n':' ');
    }
}

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

using namespace std;

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

int main(){
    string str;cin>>str;
    cout<<str.front()<<str.length()-2<<str.back()<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll M = 1000000007;
ll inv[100005], fac[100005], fiv[100005];

ll combination(ll x, ll y) {
    if (y < 0) return 0;
    if (y > x) return 0;
    return fac[x] * fiv[y] % M * fiv[x-y] % M;
}

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

    int n;
    cin >> n;

    int a[n+1];
    map <int, int> mp;
    int key;
    for (int i = 0; i <= n; i++) {
        cin >> a[i];
        mp[a[i]]++;
        if (mp[a[i]] == 2) key = a[i];
    }

    int interval_count = 0;
    bool flag = false;
    for (int i = 0; i <= n; i++) {
        if (flag) {
            if (a[i] == key) break;
            interval_count++;
        } else {
            if (a[i] == key) flag = true;
        }
    }

    inv[1]=fac[1]=fiv[1]=inv[0]=fac[0]=fiv[0]=1;
    for (ll i = 2; i <= n; i++) {
        fac[i] = fac[i-1] * i % M; // n!
        inv[i] = inv[M%i] * (M-M/i) % M; // n^-1
        fiv[i] = fiv[i-1] * inv[i] % M; // (n!)^-1
    }

    for (int k = 1; k <= n+1; k++) {
        ll ans = 0;
        ans += combination(n-1, k-2);
        ans += combination(n-1, k);
        ans += 2 * combination(n-1, k-1);
        ans += M - combination(n-1-interval_count, k-1);
        cout << ans % M << "\n";
    }

    return 0;
}

Measured memory_bytes: 8704
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = map(int, input().split())
s = input()
c = n
ans = []
while True:
    p = None
    for i in range(1,m+1):
        if c-i>=0 and s[c-i]=="0":
            p = i
    if p is None:
        ans = -1
        break
    c -= p
    ans.append(p)
    if c==0:
        break
if ans==-1:
    print(ans)
else:
    write(" ".join(map(str, ans[::-1])))

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

int main(){
  
 int X,Y;
  
  cin >> X >> Y;
  
  int Z=Y-2*X;
  
  if(Z%2==0 && Z/2<=X){
    if(Z>=0){
   cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl; 
    }
    }
  
  else{
   cout << "No" << endl; 
  }
  
}

Measured memory_bytes: 3592
#include <stdio.h>

int main(void)
{
    int h,w,i,a;
    
    while(1){
        scanf("%d%d",&h,&w);
        if(h==0 && w==0)break;
        
        for(i=0;i<h;i++){
            for(a=0;a<w;a++){
                putchar((i & 1)^(a & 1) ==0 ? '#' : '.');
            }
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}


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

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

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n;
char str[1000005];
int dp[6][1000005];


int main(){
	rep(a,6)rep(b,1000005) dp[a][b] = INF;
	scanf("%s",&str); n = strlen(str);
	dp[0][0] = 0;
	reverse(str,str+n);str[n] = '0'; n++;
	//printf("%s\n",str);
	rep(i,n){
		rep(j,6){
			if(dp[j][i] > INF/2) continue;
			rep(add,20){
				int num = (str[i]-'0' + j + add);
				if(num >= 60) break;
				dp[num/10][i+1] = min(dp[num/10][i+1], dp[j][i]+num%10+add);
			}
		}
	}
	printf("%d\n",dp[0][n]);
}

Measured memory_bytes: 24704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//--<for debugging>
#define whatis(x) cout << #x << " is " << x<<" ";
#define whatisl(x) cout << #x << " is " << x<<"\n";
#define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
#define lline cout<<"\n";
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
    
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a <<" , ";
    err(++it, args...);
}
//--</for debugging> 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define testcase ll tt; cin >> tt; while(tt--)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
#define vll vector<ll>
#define pll pair<ll,ll>
#define sll set<ll>
#define pint pair<int,int>
const ll INF=1e9+7;
const ll MOD=1e9+7;
int main()
{
    boost vars
    cin>>a>>b;
    ans=b;
    for(i=1;i<a;i++)
    {
        ans*=(b-1);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
// #define inf 1e15
    
const int N=1e5+5;
const int M=1e9+7;
void solve()
{
	double a,b;
	cin>>a>>b;
	a=a*b;
	int ans=floor(a);
	cout<<ans;

}
signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(a,b) (0<=(a)&&(a)<(b))

using namespace std;


int main(){
	int n;
	while(cin>>n,n){
		string s;
		pair<int,int> now={0,0};
		bool b=true;//true:floor
		int ans=0;
		REP(i,0,n){
			cin>>s;
			if(s=="lu") now.first=1;
			else if(s=="ru") now.second=1;
			else if(s=="ld") now.first=0;
			else if(s=="rd") now.second=0;

			if((now==make_pair(1,1)&&b)||(now==make_pair(0,0)&&!b)){
				ans++;
				b=!b;
			}
		}
		p(ans);
	}
	return 0;
}

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

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N, P; cin >> N >> P;

    bool allofEven = true;
    for (size_t i = 0; i < N; ++i) {
        size_t a; cin >> a;
        if (a % 2) {
            allofEven = false;
        }
    }

    if (allofEven) {
        cout << (P == 0 ? (intmax_t) pow(2, N) : 0) << "\n";
    } else {
        cout << (intmax_t) pow(2, N - 1) << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
   int n ,d ,x ,a[100], s, j, i;

   scanf("%d", &n);
   scanf("%d%d", &d, &x);
   for(i=0; i<n; i++) scanf("%d", &a[i]);

   s = 0;

   for(i=0; i<n; i++) {
      for(j=1; j<=d; j=j+a[i]) s++;
   }

   printf("%d\n", s+x);

   return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1.0);
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int k;
    string s;
    cin>>k>>s;
    if(k<(int)s.size()) s=s.substr(0, k)+"...";
    cout<<s<<"\n";
    return 0;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#include<iostream>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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

int n,m;

int main()
{

    cin>>n>>m;
    int l,r;

    vector<int> v;
    v.resize(n+2,0);
    for(int i=0;i<m;i++){
        cin>>l>>r;
        l--; r--;
        v[l]+=1;
        v[r+1]--;
    }
    int cur=0;
    int cnt=0;
    for(int i=0;i<n;i++){
        cur=cur+v[i];
        if(cur==m){
            cnt++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; For(i, n){ Cin(T, x); map[x] ++; }
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Couty(cond) Cout((cond) ? "Yes" : "No")
#define CoutY(cond) Cout((cond) ? "YES" : "NO")

using namespace std;
using ll = long long;

int main(void){
  Cin(int, n);
  Cin(int, k);
  int t = 1;
  while(n){
    n --;
    t += (min(t, k));
  }
  Cout(t);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

vector<set<ll>> v(101);
vector<ll> st(101,-1);
vector<ll> et(101,-1);

ll dfs(ll n,ll time) {
  st[n]=time;
  time++;
  for(auto p:v[n]) {
    if(st[p]<0) {
      time=dfs(p,time);
    }
  }
  et[n]=time;
  return time+1;
}

int main() {
  ll n;
  cin >> n;
  for(ll i=0;i<n;i++) {
    ll f,tn;
    cin >> f >> tn;
    for(ll j=0;j<tn;j++) {
      ll temp;
      cin >> temp;
      v[f].insert(temp);
    }
  }
  for(ll i=1;i<=n;i++) {
    v[0].insert(i);
  }
  dfs(0,0);
  for(ll i=1;i<=n;i++) {
    cout << i << " " << st[i] << " " << et[i] << endl;
  }
}


Measured memory_bytes: 3132
n, m = map(int, input().split())
h = list(map(int, input().split()))
h.insert(0, -1)
group = {i: 0 for i in range(1, n+1)}
searched = {i: 0 for i in range(1, n+1)}
edge = {i: [] for i in range(1, n+1)}
for _ in range(m):
    a, b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)

count = 0
for i in range(1, n+1):
    flag = 1
    for b in edge[i]:
        if h[i] <= h[b]:
            flag = 0
    if flag:
        count += 1

print(count)


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

int main() {
    int n, m;
    cin >> n >> m;
    map<int, int> digit;
    int ans[n + 1];
    for(int i = 0; i <= n; i++) {
        ans[i] = -1;
    }
    map<int, int> :: iterator itr;
    for(int i = 1; i <= m; i++) {
        int pos, val;
        cin >> pos >> val;
        if((digit.count(pos) == true && digit[pos] != val)) {
            cout << "-1" << endl;
            return 0;
        }
        digit[pos] = val;
    }
    for(itr = digit.begin(); itr != digit.end(); itr++) {
        ans[itr->first] = itr->second;
    }
    if(n != 1 && ans[1] == 0) {
        cout << "-1" << endl;
        return 0;
    }
    for(int i = 1; i <= n; i++) {
        if(i == 1 && n != 1) {
            if(ans[i] == -1)
                cout << "1";
            else
                cout << ans[i];
        }
        else {
            if(ans[i] == -1)
                cout << "0";
            else
                cout << ans[i];
        }
    }
    cout << endl;
    return 0;
}


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

char rot(char a,int n);

int main(){
  string s;
  int n;
  cin>>n>>s;
  for(int i=0;i<s.size();i++){
  s[i]=rot(s[i],n);
  }
  cout<<s<<endl;
return 0;
}

char rot(char a,int n){
  char aa='A';
  n=a-aa+n;
  if(n>25) n-=26;
  char L[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
  a=L[n];
  return a;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

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

Measured memory_bytes: 512
#include<stdio.h>
int dp[100001],h[100001];
int abs(int x);
int main(void)
{
  int i,j,n,a;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
  }
  for(i=0;i<n;i++) dp[i]=1000000000; 
  dp[0]=0;
  for(i=0;i<n-1;i++){
    if(abs(h[i]-h[i+1])+dp[i]<=dp[i+1]){
      dp[i+1]=abs(h[i]-h[i+1])+dp[i];
    }
    if(i<n-1){
      if(abs(h[i]-h[i+2])+dp[i]<=dp[i+2]){
        dp[i+2]=abs(h[i]-h[i+2])+dp[i];
       // printf("%d.",dp[i+2]);
      }
    }
  }
 // for(i=0;i<n;i++) printf(".%d.",dp[i]);
  printf("%d\n",dp[n-1]);
}

int abs(int x){
  if(x < 0) x = -x;
  return x;
}

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

int main() {
  int N,D,X,sum=0;
  cin >> N >> D >> X;
  vector<int> a(N);
  vector<int> b(N);
  for (int i=0;i<N;i++){
  cin >> a.at(i);
  b.at(i)=(D-1)/a.at(i)+1;
  sum+=b.at(i);
  }
  cout << sum+X << endl;
  
}

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

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        string s = sc.Next();
        int ans = 0;
        for (int i = 0; i < s.Length / 2; i++)
        {
            int j = s.Length - i - 1;
            if (s[i] != s[j]) ans++;
        }
        Console.WriteLine(ans);
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 13140
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [long(input_raw[0]), long(input_raw[1])]
    input_raw = read_func().strip().split()
    A = []
    for i in range(N):
        A.append(long(input_raw[i]))

    max_x = 0L
    for i in range(40):
        mask = 0x01 << i
        one_count = 0
        for j in range(len(A)):
            one_count += 1 if (A[j] &  mask ) > 0 else 0
        if one_count <= N/2:
            max_x += (0x01 << i)

    x = 0L
    flag = False
    for i in range(40, -1, -1):
        mask = 0x01 << i
        if K & mask != 0 & flag == False:
            if (max_x & mask) == 0:
                flag = True
            else:
                x += (max_x & mask)
        elif flag == True:
            x += (max_x & mask)

    fx = 0L
    for i in range(len(A)):
        fx += (x ^ A[i])
    max_fx = fx

    for i in range(40, -1, -1):
        mask = ~(0x01L << i)
        x = max_x & mask
        max_x = x
        if x <= K:
            fx = 0L
            for i in range(len(A)):
                fx += (x ^ A[i])
            max_fx = max(max_fx, fx)
    print max_fx



if __name__ == '__main__':
    main()


Measured memory_bytes: 16700
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1)
using namespace std;
const int mod=1e9+7;
const int N=2005;
inline ll rd(){
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?x:-x;
}int n,k,mx;
ll f[N][N],fac[N*N],inv[N*N];
inline ll kasumi(ll x,int mi){
	ll res=1;
	while(mi){
		if(mi&1) res=res*x%mod;
		x=x*x%mod;mi>>=1;
	}return res;
}
inline ll C(int n,int m){
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main(){
	n=rd(),k=rd();mx=n*k;
	if(k==1){
		puts("1");
		return 0;
	}fac[0]=inv[0]=1;
	for(int i=1;i<=mx;i++) fac[i]=fac[i-1]*i%mod;
	inv[mx]=kasumi(fac[mx],mod-2);
	for(int i=mx-1;i>=1;i--) inv[i]=inv[i+1]*(i+1)%mod;
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			f[i][j]=(f[i][j]+f[i-1][j])%mod;
			if(j){
				f[i][j]=(f[i][j]+1ll*f[i][j-1]*(n-(j-1))%mod*C(n*k-i-(j-1)*(k-1)-1,k-2)%mod)%mod;
			}
		}
	}cout<<f[n][n];
	return 0;
}

Measured memory_bytes: 94464
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

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

    stack<uint32_t> s;
    vector<pair<uint32_t, uint32_t>> v;
    for (uint32_t i = 0; i < str.length(); i++) {
        if (str[i] == '\\') {
            s.push(i);
        } else if (str[i] == '/' && !s.empty()) {
            uint32_t j = s.top();
            s.pop();
            uint32_t area = i - j;
            while (!v.empty() && v.back().first > j) {
                area += v.back().second;
                v.pop_back();
            }
            v.push_back(make_pair(j, area));
        }
    }

    cout << accumulate(v.begin(), v.end(), 0, [](uint32_t sum, pair<uint32_t, uint32_t> p) {
        return sum + p.second;
    }) << endl;
    cout << v.size();
    for (pair<uint32_t, uint32_t> p : v) cout << " " << p.second;
    cout << endl;

    return 0;
}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define Mp make_pair
#define pb push_back

using ll = long long;
using db = double;
using pii = pair<int, int>;
using vi = vector<int>;
mt19937 mrand(time(0));
ll get(ll r) { return ((ll)mrand() * mrand() % r + r) % r; }
ll get(ll l, ll r) { return get(r - l + 1) + l; }

signed main() {
    int n; cin >> n; ll ans = 0;
    for(int i = 1; i <= n; i++)
        ans += (n - 1) / i;
    cout << ans << endl;
    fprintf(stderr, "time=%.4f\n", (db)clock()/CLOCKS_PER_SEC);
    return 0;
    /* 取模直接除，爆零两行泪
     * 不开ll见祖宗
     */
}

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;


void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif
	string s;
	cin >> s;
	s = s.substr(0, s.size() - 8);

	cout << s << endl;
}



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

	solve();
#ifdef _WIN32
	system("PAUSE");
#endif
	return 0;
}

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

#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define i64 long long int
#define MEM(a,x) memset(a,x,sizeof(x))
#define INF 1000000000
#define mod 998244353

using namespace std ;

#define maxn 100005

i64 cum[maxn] , a[maxn] , valPos[maxn] ;

int main()
{
    i64 i , j , k , l , m , n ;

    scanf("%lld %lld",&n,&k) ;

    for(i=1 ; i<=n ; i++)
    {
        scanf("%lld",&a[i]) ;
    }

    for(i=1; i<=n ; i++)
    {
        valPos[i] = valPos[i-1] ;
        if( a[i]>0 ) valPos[i] += a[i] ;

        cum[i] = cum[i-1] + a[i] ;
    }

    i64 ret = 0LL ;

    for(i=k ; i<=n ; i++)
    {
        ret = max( ret , valPos[i-k] + valPos[n]-valPos[i] + max( 0LL , cum[i]-cum[i-k] ) ) ;
    }

    printf("%lld\n",ret) ;

    return 0 ;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int n, k;
string s, tmp, res = "{";
int main() {
	cin >> n >> k >> s;
	tmp = s; reverse(s.begin(), s.end());
	s = tmp + s; --k;
	for (int i = 0; i < n * 2; ++i) {
		int cnt = 0;
		for (int j = i; j < n * 2; ++j)
			if (s[j] == s[i]) ++cnt;
			else break;
		if (i + cnt < n) continue;
		for (int j = 1; j <= k; ++j) {
			cnt *= 2; if (cnt >= n) break;
		}
		cnt = min(cnt, n);
		string tmp;
		for (int j = 1; j <= cnt; ++j) tmp += s[i];
		for (int j = 1; j <= n - cnt; ++j)
			tmp += s[i - j];
		res = min(res, tmp);
	}
	cout << res;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_H 300
#define MAX_W 300
#define LOG_N 20
using P = pair<i64, i64>;
P C[LOG_N + 1][MAX_H * MAX_W + 10];

int main() {
    i64 H, W, D; cin >> H >> W >> D;
    i64 N = H * W + 1;
    vector<P> Num(N);
    REP(y, H) {
        REP(x, W) {
            i64 a; cin >> a;
            Num[a] = P(y, x);
        }
    }

    auto cost = [](const P &p1, const P &p2) {
        return abs(p1.first - p2.first) + abs(p1.second - p2.second);
    };

    REPS(i, N) {
        if (i + D >= N) {
            C[0][i] = mp(-1, -1);
            continue;
        }
        C[0][i] = mp(i + D, cost(Num[i], Num[i + D]));
    }

    REP(k, LOG_N) {
        REPS(i, N) {
            if (C[k][i].first == -1) C[k + 1][i] = mp(-1, -1);
            else {
                C[k + 1][i] = mp(C[k][C[k][i].first].first, C[k][i].second + C[k][C[k][i].first].second);
            }
        }
    }

    i64 Q; cin >> Q;
    while(Q--) {
        i64 l, r; cin >> l >> r;
        i64 n = (r - l) / D;

        i64 cur = l;
        i64 s = 0;
        REP(k, LOG_N) {
            if (cur == -1) break;
            if ((n >> k) & 1) {
                s += C[k][cur].second;
                cur = C[k][cur].first;
            }
        }
        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 32128
#[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, 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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      x: usize,
      y: usize,
    }

    let mut ans = 0;
    ans += match x {
        1 => 300000,
        2 => 200000,
        3 => 100000,
        _ => 0,
    };

    ans += match y {
        1 => 300000,
        2 => 200000,
        3 => 100000,
        _ => 0,
    };

    if x == 1 && y == 1 {
        ans += 400000;
    }
    puts!("{}\n", ans);
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	
	string s;
	cin >> s;
	
	int count = 0;
	for (int i = 0; i < n && count <= n / 2; ++i) {
		if (s[i] == 'R')
			++count;
	}
	
	cout << (count > n / 2 ? "Yes" : "No") << endl;
}

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

int main()
{
    int a, b, c, d, e, ans;
    cin >> a >> b >> c >> d >> e;
    
    if (a == 0) ans = 1;
    if (b == 0) ans = 2;
    if (c == 0) ans = 3;
    if (d == 0) ans = 4;
    if (e == 0) ans = 5;
    
    cout << ans << endl;
}

Measured memory_bytes: 3524
/* ex3_2
   masaaki52	*/
#include <stdio.h>
int main(void){
  int number;
  int one;
  scanf("%d",&number);//numberに値を入力
  one = number % 10;//numberを10で割った余りをoneに代入
  if(one == 3){//oneが3の場合
    printf("bon\n");//bonを出力
  }
  else if(one == 0 || one == 1 || one == 6 || one == 8){//oneが0,1,6,8の場合
    printf("pon\n");//ponを出力
  }
  else{//上記以外の場合
    printf("hon\n");//honを出力
  }
  return 0;
}


Measured memory_bytes: 1580
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define pb  				push_back
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define mk(arr,n,type)      type *arr=new type[n];
#define dbg(x) cerr << #x << " is " << x << endl;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
clock_t beg = clock();
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
const double pi = 3.1415926535897932384626433;
void FILE_IO(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
int dp[100005];
void calculate(){
	for(int i=1;i<=101;i++){
		for(int j=1;j<=101;j++){
			for(int k=1;k<=101;k++){
				int temp=i*i+j*j+k*k+i*j+j*k+i*k;
				if(temp<100005){
					dp[temp]++;
				}
			}
		}
	}
}
void JH(){
    int d=0,e=0,f=0,g=0,p=0,w=0,flag=0,ans=0,res=0,cnt=0,sum=0;double f1=0.0,f2=0.0,f3=0.0;
    calculate();
    int n;cin>>n;
    fo1(i,n){
    	cout<<dp[i]<<endl;
    }

}

int32_t main()
{
    FILE_IO();FAST_IO;int t=1;
    // cin>>t;
    while(t--){JH();}cerr<<fixed<<setprecision(3)<<(double)(clock()-beg)/1000<<"s ";
}

Measured memory_bytes: 4200
#include<bits/stdc++.h>
int main() {
	long long num1, num2; std::cin >> num1 >> num2;
	long long a = num1, b = num2;
	std::map<long long, long long>mp;

	for (long long x = 2; x * x < num1; x++) {
		while (a % x == 0) {
			a /= x; mp[x] = 1;
		}
	}if (a != 1)mp[a] = 1;
	long long cnt = 0;
	for (long long x = 2; x * x < num2; x++) {
		while (b % x == 0) {
			b /= x; if (mp[x] == 1) { mp[x] = 2; cnt++; }
		}
	}if (b != 1)if (mp[b] == 1)cnt++;
	std::cout << cnt + 1;
}

Measured memory_bytes: 3580
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    if (n <= 3) {
        cout << *max_element(all(a)) << endl;
        return;
    }
    if (n % 2 == 0) {
        LL l = 0, r = 0;
        REP(i,0,n/2) {
            l += a[i*2];
            r += a[i*2+1];
        }
        LL ans = -(1LL<<60);
        //cout << max(l,r) << endl; 
        ans = max({ans, l, r});

        VLL lru(n), rru(n);
        lru[0] = a[0];
        lru[1] = a[1];
        rru[n-2] = a[n-2];
        rru[n-1] = a[n-1];
        REP(i,2,n) lru[i] = lru[i-2] + a[i];
        RREP(i,0,n-2) rru[i] = rru[i+2] + a[i];
        REP(i,0,n-3) {
            if (i % 2 == 1) continue;
            LL sum = lru[i] + rru[i+3];
            ans = max(ans, sum);
            //dump(sum);
        }
        cout << ans << endl;
        return;
    }

    // n > 3
    VVLL dp(n,VLL(3, -(1LL<<50)));
    dp[0][0] = a[0];
    dp[1][1] = a[1];
    dp[2][2] = a[2];
    dp[2][0] = a[0] + a[2];
    REP(i,3,n) {
        dp[i][2] = a[i] + max({dp[i-2][2], dp[i-3][1]});
        if (i > 3) chmax(dp[i][2], a[i] + dp[i-4][0]);
        if (i < n - 1) dp[i][1] = a[i] + max({dp[i-2][1], dp[i-3][0]});
        if (i < n - 2) dp[i][0] = a[i] + dp[i-2][0];
    }
    cout << max({dp[n-1][2], dp[n-2][1], dp[n-3][0]}) << endl;

    return;

    REP(i,0,n) {
        cout << a[i] << ": ";
        REP(j,0,3) {
            cout << (dp[i][j] < -1000 ? -1000 : dp[i][j]) << " ";
        }
        cout << endl;
    }
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 15576
#include<iostream>
#include<string>

using namespace std;

int main() {
    string S;

    cin >> S;

    for(int i = 0; i < S.size(); i++) {
        if((i + 1) % 2 == 1) {
            cout << S[i];
        }
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 512
N = int(input())

ans = 0
c_list = [[0]*10 for i in range(10)]

for i in range(1,N+1):
    s = str(i)
    c_list[int(s[0])][int(s[-1])] += 1

    
for i in range(10):
    for j in range(10):
        ans += c_list[i][j]*c_list[j][i]
    
print(ans)

Measured memory_bytes: 3064
/*
AIZU ONLINE A0048
Class
*/
#include <stdio.h>

struct box_class
       {char class_name[15];
        float low;
        float high;} ;

struct box_class boxing_weight[]=
  {
    {"light fly",0        ,48.00},
    {"fly"	     ,48.00    ,51.00},
    {"bantam"   ,51.00    ,54.00}, 
    {"feather"  ,54.00    ,57.00}, 
    {"light"    ,57.00,60.00},
    {"light welter",	60.00,64.00},
    {"welter"   ,64.00    ,69.00},
    {"light middle"       ,69.00,75.00},
    {"middle"   ,75.00    ,81.00},
    {"light heavy"        ,81.00,91.00},
    {"heavy",	91.00,1000.0}
  };

main()
{
  float w;
  int i;
  
  while(EOF != scanf("%f",&w))
    {  for(i=0;i<11;i++)
         if(boxing_weight[i].low < w && w <= boxing_weight[i].high) 
           printf("%s\n",boxing_weight[i].class_name);
    }
return(0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5;
vector <vector <int> > adj(N + 1);
vector <int> col(N + 1);
int ans;
void dfs(int v, int p)
{
	col[v] = 1;
	for(int j = 0;j < adj[v].size();j++)
	{
		int u = adj[v][j];
		if(u == p)
			continue;
		if(col[u] == 0)
			dfs(u, v);
	}
	ans++;
}
int main()
{
	int n, m;
	cin >> n >> m;
	set <pair <int, int> > st;
	for(int i = 1;i <= m;i++)
	{
		int u, v;
		cin >> u >> v;
		st.insert({u, v});
		st.insert({v, u});
	}
	for(auto it = st.begin();it != st.end();it++)
	{
		pair <int, int> edge = (*it);
		adj[edge.first].push_back(edge.second);
		adj[edge.second].push_back(edge.first);
	}
	int mx = 1;
	for(int i = 1;i <= n;i++)
	{
		if(col[i] == 0)
		{
			ans = 0;
			dfs(i, 0);
			mx = max(mx, ans);
		}
	}
	cout << mx;
	return 0;
}

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

int main(){
    int N,K;
    cin>>N>>K;
    vector<int>d(K);
    vector<vector<int>>A(K,vector<int>(N));
    vector<int>a(N);
    int count=0;
    rep(i,K){
        cin>>d[i];
        rep(j,d[i]){
            cin>>A[i][j];
            a[A[i][j]-1]++;
        }
    }

    rep(i,N){
        if(a[i]==0){
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
int main()
{
    int a,b;
    char op;
    while(true){
    std::cin >> a >> op >> b;
    if (op=='+'){
        std::cout << a+b<<std::endl;
    }
    if (op=='-'){
        std::cout << a-b<<std::endl;
    }
    if (op=='*'){
        std::cout << a*b<<std::endl;
    }
    if (op=='/'){
        std::cout << a/b<<std::endl;
    }
    if (op=='?'){
        return 0;
    }
    }
    return 0;
}

Measured memory_bytes: 3092
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))

dic = {}
for x in a:
    dic[x] = dic[x] + 1 if x in dic else 1

ans = all(k == 0 for k in dic.keys())
if n % 3 == 0:
    if all(v == n // 3 for v in dic.values()):
        x, y, z = dic.keys()
        ans |= (x ^ y == z)
    else:
        ans |= all(v == n * 2 // 3 or (v == n // 3 and k == 0) for k, v in dic.items())
print(['No', 'Yes'][ans])


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n, x;
    cin >> n >> x;
    int sum = 0, mini = IINF;
    rep(i, n){
        int m;
        cin >> m;
        sum += m;
        mini = min(mini, m);
    }
    x -= sum;
    int ans = n + x / mini;
    cout << ans << endl;
    return 0;
}

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

int main() {
  int a, b;
  scanf("%d %d", &a, &b);

  if (a >= 1 && a <= 9 && b >= 1 && b <= 9)
    printf("%d\n", a * b);
  else
    printf("-1\n");

  return 0;
}

Measured memory_bytes: 256