akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = 1e18;
const int IMOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

int main(void)
{
    int n, p;
    cin >> n >> p;
    
    v_int a(n);
    int sum = 0;
    irep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    
    ll dp[n+1][sum+1];
    irep(i, n+1) {
        irep(j, sum+1) {
            dp[i][j] = 0;
        }
    }

    dp[0][0] = 1;
    irep(i, n) {
        irep(j, sum+1) {
            dp[i+1][j+a[i]] += dp[i][j];
            dp[i+1][j] += dp[i][j];
        }
    }
    
    ll ans = 0;
    irep(j, sum+1) {
        if(j % 2 == p) {
            ans += dp[n][j];
        }
    }
    cout << ans << endl;

    return 0;
}
/** atcoder **/



Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const long long hashnu=456123;
long long hashx[10000007];
long long ans[10000007];
int dx[9]={-2,-2,-2,-1,-1,-1,0,0,0};
int dy[9]={-2,-1,0,-2,-1,0,-2,-1,0};
int tot;
int main()
{
	long long H,W,N;
	cin>>H>>W>>N;
	long long ans0=(H-2)*(W-2);
	for(int i=0;i<N;i++)
	{
		int x,y;
		cin>>x>>y;
		for(int j=0;j<9;j++)
		{
			int xx=x+dx[j];
			int yy=y+dy[j];
			if(xx>=1&&xx<=H-2&&yy>=1&&yy<=W-2)
			{
				hashx[tot++] =xx*hashnu+yy;
			}
		}
	}
	sort(hashx,hashx+tot);
	int cnt=1;
	for(int i=0;i<tot;i++)
	{
		if(hashx[i]==hashx[i+1])
			cnt++;
		else
		{
			ans[cnt]++;
			cnt=1;
			ans0--;
		}
	}
	cout<<ans0<<endl;
	for(int i=1;i<10;i++)
	cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 8448
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i = 1;
		while(sc.hasNext()) {
			int x = sc.nextInt();
			if(x == 0)	break;
			System.out.printf("Case %d: %d\n", i, x);
			i++;
		}
	}
}



Measured memory_bytes: 64080
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.stream.Stream;

public class Main {
    private static final BufferedReader READER = new BufferedReader(new InputStreamReader(System.in));

    private static int getInt() {
        try {
            return Integer.parseInt(READER.readLine());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private static int[] getIntArr(int n) {
        int[] ans = new int[n];

        StringTokenizer stringTokenizer = null;
        try {
            stringTokenizer = new StringTokenizer(READER.readLine(), " ");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        for (int i = 0; i < n && stringTokenizer.hasMoreTokens(); i++) {
            ans[i] = Integer.parseInt(stringTokenizer.nextToken());
        }

        return ans;
    }

    private static long solve() {
        int[] nw = getIntArr(2);
        int n = nw[0];
        int w = nw[1];

        Item[] items = new Item[n];
        for (int i = 0; i < n; i++) {
            items[i] = Item.of(getIntArr(2));
        }
        return solveInternal(n, w, items);
    }

    private static long solveInternal(int n, int W, Item[] items) {
        int maxV = Stream.of(items).mapToInt(x -> x.v).max().getAsInt();
        int NA = W + 1;

        long[][] dp = new long[n + 1][maxV * n + 1];
        for (int v = 1; v <= maxV * n; v++) {
            dp[0][v] = NA;
        }

        for (int i = 1; i <= n; i++) {
            for (int v = 1; v <= maxV * n; v++) {
                Item item = items[i - 1];
                if (v < item.v) {
                    dp[i][v] = dp[i - 1][v];
                } else {
                    dp[i][v] = Math.min(dp[i - 1][v], dp[i - 1][v - item.v] + item.w);
                }
            }
        }

        long[] ws = dp[n];
        for (int v = ws.length - 1; v >= 0; v--) {
            if (ws[v] <= W) {
                return v;
            }
        }
//        for (int i = 0; i <= n; i++) {
//            for (int w = 0; w <= W; w++) {
//                System.out.println(String.format("dp[%s,%s]=%s", i, w, dp[i][w]));
//            }
//        }

        return 0;
    }


    public static final class Item {
        public final int v;
        public final int w;

        private Item(int w, int v) {
            this.v = v;
            this.w = w;
        }

        public static Item of(int[] arr) {
            return new Item(arr[0], arr[1]);
        }
    }

    public static void main(String... args) {
        System.out.println(solve());
//        System.out.println(
//                solveInternal(6, 15, new Item[]{
//                        new Item(6, 5),
//                        new Item(5, 6),
//                        new Item(6, 4),
//                        new Item(6, 6),
//                        new Item(3, 5),
//                        new Item(7, 2)
//                })
//        );
    }
}

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

int main(){
    int a, b;
    string op;

    while(true){
        cin>>a>>op>>b;
        if(op=="?") return 0;
        if(op=="+") cout<<a+b<<endl;
        if(op=="-") cout<<a-b<<endl;
        if(op=="*") cout<<a*b<<endl;
        if(op=="/") cout<<a/b<<endl;
    }
}



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

typedef long long ll;

using namespace std;

int main() {
	string s; cin >> s;
	int q; cin >> q;
	bool st = 0;
	vector<char> v[2];
	while(q--) {
		int qt; cin >> qt;
		if (qt == 1) st = !st;
		else {
			int f;
			char c;
			cin >> f >> c, f--;
			v[f^st].push_back(c);
		}
	}
	string t;
	for(int i=(int)v[0].size()-1; ~i; i--) {
		t += v[0][i];
	}
	t += s;
	for(char c : v[1]) {
		t += c;
	}
	if (st) reverse(t.begin(), t.end());
	cout << t;
}





Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    vector<string> table(h);
    int used[h + 1][w + 1] = {};
    for(int i = 0; i < h; i++) cin >> table[i];
    vector<pair<int, int>> vec;
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            if(table[i][j] == '#') vec.push_back(make_pair(i, j));
        }
    }
    int pos = 0;
    vector<pair<int, int>> tmp;
    bool flag = false;
    int ans = 0;
    while(true)
    {
        if(pos >= vec.size())
        {
            if(flag == false) break;
            vec = tmp;
            ans++;
            pos = 0;
            flag = false;
            tmp.clear();
        }
        for(int i = 0; i < 4; i++)
        {
            int ny = vec[pos].first + dy[i];
            int nx = vec[pos].second + dx[i];
            if(ny < 0 || nx < 0 || nx >= w || ny >= h) continue;
            if(table[ny][nx] == '#') continue;
            flag = true;
            table[ny][nx] = '#';
            tmp.push_back(make_pair(ny, nx));
        }
        pos++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 19436
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    // cout << fixed << setprecision(10) << flush;

    string s, t;
    cin >> s >> t;
    int maxl = 0;
    for(int i=0; i<s.size()-t.size()+1; i++){
        int num = 0;
        for(int j=0; j<t.size(); j++){
            if(s[i+j] == t[j]) num++;
        }
        maxl = max(maxl, num);
    }
    cout << t.size() - maxl << endl;

    return 0;
}

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

struct edge{
    int node;
    edge *next;
}nodes[105];

int n,t[105][2],visit[105],cnt=0;

void dfs_visit(int i){
    t[i][0]=++cnt;
    visit[i]=1;
    edge *e=nodes[i].next;
    if(e!=NULL){
        while(e!=NULL){
            if(!visit[e->node])dfs_visit(e->node);
            e=e->next;
        }
    }
    t[i][1]=++cnt;
}

void dfs(){
    int i;
    for(i=1;i<=n;i++){
        if(visit[i]==0)dfs_visit(i);
    }
}

int main(){
    memset(visit,0,sizeof(visit));
    memset(t,0,sizeof(t));
    cin>>n;
    int i,j;
    for(i=1;i<=n;i++){
        int ii,n_i;
        cin>>ii>>n_i;
        edge* first=&nodes[i];
        for(j=0;j<n_i;j++){
            edge *e=new edge();
            cin>>e->node;
            first->next=e;
            first=e;
        }
    }
    dfs();
//    for(i=0;i<n;i++){
//        edge *e=nodes[i].next;
//        while(e!=NULL){
//            cout<<e->node<<" ";
//            e=e->next;
//        }
//        cout<<endl;
//    }
    for(i=1;i<=n;i++){
        cout<<i<<" "<<t[i][0]<<" "<<t[i][1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main()
{
  ll X,K,D; cin>>X>>K>>D;
  X=abs(X);
  ll s=X/D;
  if(K<=s) {cout<<X-K*D<<endl; return 0;}
  K-=s,X-=s*D;
  //cout<<"X:"<<X<<" "<<"K:"<<K<<endl;
  if(K%2==0) cout<<X<<endl;
  else cout<<D-X<<endl;
  
  return 0;
}

Measured memory_bytes: 3636
#bを固定すればaの個数をo(1)で計算できそうぷりね

N,K = map(int,input().split())

ans = 0

for b in range(1,N+1,1):
    ans += max(0,(b-K))*(N//b) + max(0,(N%b-K+1))
    if K ==0:
        ans-=1

print(ans)

Measured memory_bytes: 66184
import re
s=input().replace("?",".")
t=input()
for i in range(len(s)-len(t),-1,-1):
    if re.match(s[i:i+len(t)],t):
        s=s.replace(".","a")
        print(s[:i]+t+s[i+len(t):])
        exit()
print("UNRESTORABLE")


Measured memory_bytes: 3188
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef long long int llo;
#define a first
#define  b second
#define endl "\n"
vector<llo> adj[200001];
llo tot=1;
llo tot2=3;
llo tot3=2;
llo col[200001];
llo cot=0;
llo dfs(llo no,llo co=0,llo par=-1){
	col[no]=co;
	if(co==0){
		cot+=1;
	}
/*	if(co==0){
		if(tot<=n){
			col[no]=tot;
			tot+=3;
		}
		else if(tot2<=n){
			col[no]=tot2;
			tot2+=3;
		}
		else{
			if(tot3<n){

			}
		}
	}
	else{
		if(tot2<=n){
			col[no]=tot2;
			tot2+=3;
		}
		else{
			col[no]=tot3;
			tot3+=3;
		}
	}
*/
	
	for(auto j:adj[no]){
		if(j==par){
			continue;
		}
		dfs(j,(co+1)%2,no);
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	llo aa,bb;
	llo n;
	cin>>n;
	for(llo i=0;i<n-1;i++){
		cin>>aa>>bb;
		adj[aa-1].pb(bb-1);
		adj[bb-1].pb(aa-1);
	}
	dfs(0);
	llo ans[n];

	memset(ans,0,sizeof(ans));
	llo val=0;
	if(cot<n-cot){
		val=1;
		cot=n-cot;
	}
	for(llo i=0;i<n;i++){
		if(col[i]==val){
			if(tot<=n){
				ans[i]=tot;
				tot+=3;
				continue;
			}
			if(cot-(n+2)/3>n/3){
				if(tot3<=n){
					ans[i]=tot3;
					tot3+=3;
				}
				else{
					ans[i]=tot2;
					tot2+=3;
				}
				continue;

			}
			else if(tot2<=n){
				ans[i]=tot2;
				tot2+=3;
			}
			else{
				ans[i]=tot3;
				tot3+=3;
			}
		}
	}
	for(llo i=0;i<n;i++){
		if(col[i]==1-val){
			if(tot2<=n){
				ans[i]=tot2;
				tot2+=3;
			}
			else{
				ans[i]=tot3;
				tot3+=3;
			}
		}
	}
	for(llo i=0;i<n;i++){
		cout<<ans[i]<<" ";
	}
 
	return 0;
}

Measured memory_bytes: 19072
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String s = sc.next();
        
        if (a < 3200) {
            System.out.println("red");
        } else {
            System.out.println(s);
        }
    }
}

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

int N, M;
set<vector<int>> SE;

void dfs(vector<int> A, int depth) {
  if (depth == N) {
    SE.insert(A);
    return;
  }
  int Max = max(1, *max_element(A.begin(), A.end()));
  for (int i = Max; i <= M; i++) {
    vector<int> newA = A;
    newA.at(depth) = i;
    dfs(newA, depth + 1);
  }
}

int main() {
  cin >> N >> M;
  vector<int> A(N);
  dfs(A, 0);

  int Q;
  cin >> Q;
  vector<int> a(Q), b(Q), c(Q), d(Q);
  for (int i = 0; i < Q; i++) {
    cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
  }

  int ans = 0;
  for (auto A : SE) {
    int sum = 0;
    for (int i = 0; i < Q; i++) {
      if (A.at(b.at(i) - 1) - A.at(a.at(i) - 1) == c.at(i)) {
        sum += d.at(i);
      }
    }
    ans = max(ans, sum);
  }
  cout << ans << "\n";
}

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

using namespace std;

#define ll long long int

ll n,ara[100005][4],dp[100005][4];

ll func(ll indx, ll prev)
{
    if(indx==n+1)
    {
        return 0;
    }

    if(dp[indx][prev]!=-1)
    {
        return dp[indx][prev];
    }

    ll ans=-1e18;

    if(prev==0)
    {
        for(ll i=1; i<=3; i++)
        {
            ans=max(ans,ara[indx][i]+func(indx+1,i));
        }
    }

    else
    {
        for(ll i=1; i<=3; i++)
        {
            if(i!=prev)
            {
                ans=max(ans,ara[indx][i]+func(indx+1,i));
            }
        }
    }

    return dp[indx][prev]=ans;
}

int main()
{
    ll i,j;

    scanf("%lld",&n);

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

    memset(dp, -1, sizeof dp);

    ll ans=func(1,0);

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

    return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,s;
  while(cin >> n&&n){
    ll tar;
    vary(int,v,n,0);
    rep(i,n){
      cin >> v[i];
    }
    cin >> tar;
    int lb = 0,ub = n-1;
    int ans = 0;
    while(1){
      int mid = (lb+ub)/2;
      if(lb > ub){
        break;
      }
      ++ans;
      if( tar == v[mid]) break;
      if(v[mid] < tar){
        lb = mid+1;
      }
      else{
        ub = mid-1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    cin >> a;
    cout << a+a*a+a*a*a << endl;
    return 0;
}


Measured memory_bytes: 3616
n = int(input())
anses = []
ans = 0
if n == 1:
    print(1)
    exit()
elif n == 2:
    print(2)
    exit()

for i in range(1, n):
    if ans >= n:
        break
    else:
        ans += i
        anses.append(i)

if ans > n:
    anses.remove(ans-n)

for i in anses:
    print(i)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
//F6編譯，右上三角形執行，ctrl+c強制停止執行  F5開啟exe
#define ll long long
#define maxn 200005
#define mod 1000000007
using namespace std;

typedef pair<int, int> P;

int n;
int h[maxn];
int a[maxn], top = 0;

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        scanf("%d", &h[i]);
    reverse(h, h + n);
    int ans = 0;
    int now = 0;
    int cnt = 0;
    h[n] = -1;
    for (int i = 0; i <= n; i++)
    {
        if (h[i] >= now)
        {
            cnt++;
            now = h[i];
        }
        else
        {
            ans = max(ans, cnt);
            cnt = 1;
            now = h[i];
        }
    }
    printf("%d\n", ans - 1);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int n, a, b, c;
std::vector<int> l;
int solve(int i = 0, int A = 0, int B = 0, int C = 0, int cost = 0) {
	if(i == n) {
		if(!A or !B or !C) return 1 << 30;
		return std::abs(A - a) + std::abs(B - b) + std::abs(C - c) + cost;
	}
	int ret = solve(i + 1, A, B, C, cost);
	if(A) ret = std::min(ret, solve(i + 1, A + l[i], B, C, cost + 10));
	else ret = std::min(ret, solve(i + 1, A + l[i], B, C, cost));
	if(B) ret = std::min(ret, solve(i + 1, A, B + l[i], C, cost + 10));
	else ret = std::min(ret, solve(i + 1, A, B + l[i], C, cost));
	if(C) ret = std::min(ret, solve(i + 1, A, B, C + l[i], cost + 10));
	else ret = std::min(ret, solve(i + 1, A, B, C + l[i], cost));
	return ret;
}

int main() {
	scanf("%d%d%d%d", &n, &a, &b, &c); l.resize(n);
	for(int i = 0; i < n; i++) scanf("%d", &l[i]);
	
	printf("%d\n", solve());
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const ll inf=1001001001001001;
const int Inf=1001001001;
const int mod=1000000007;
int main(){
    ll ans=inf,n;cin>>n;
    rep(i,5){
        ll a;cin>>a;
        chmin(ans,a);
    }
    cout<<(n-1)/ans+5<<endl;
}

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

using namespace std;


const int MAX = 100005;
const int NIL = -1;
typedef long long ll;

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r) {
    if (l >= r)
        return;
    int root = pre[pos++];
    int m = distance(begin(in), find(begin(in), end(in), root));
    rec(l, m);
    rec(m + 1, r);
    post.push_back(root);
}

void solve() {
    pos = 0;
    rec(0, pre.size());
    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << post[i];
    }
    cout << endl;
}

int main() {
    cin >> n;

    for (int i = 0; i < n; i++) {
        int k; cin >> k; pre.push_back(k);
    }

    for (int i = 0; i < n; i++) {
        int k; cin >> k; in.push_back(k);
    }

    solve();
}


Measured memory_bytes: 3144
#include <stdio.h>
#define MAX 100
#define INF (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,G[MAX][MAX];

void dijkstra(void){
    int i,v,u,min;
    int d[MAX],color[MAX];
    
    for(i=0;i<n;i++){
        d[i]=INF;
        color[i]=WHITE;
    }
    d[0]=0;
    color[0]=GRAY;
    while(1){
        min=INF;
        u=-1;
        for(i=0;i<n;i++){
            if(min>d[i]&&color[i]!=BLACK){
                u=i;
                min=d[i];
            }
        }
        if(u==-1)break;
        color[u]=BLACK;
        for(v=0;v<n;v++){
            if(color[v]!=BLACK&&G[u][v]!=INF){
                if(d[v]>d[u]+G[u][v]){
                    d[v]=d[u]+G[u][v];
                    color[v]=GRAY;
                }
            }
        }
    }
    
    for(i=0;i<n;i++){
        printf("%d ",i);
        if(d[i]==INF){
            printf("-1\n");
        }else{
            printf("%d\n",d[i]);
        }
    }
}

int main(){
    int i,j,k,u,v,c;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            G[i][j]=INF;
        }
    }
    
    for(i=0;i<n;i++){
        scanf("%d%d",&u,&k);
        for(j=0;j<k;j++){
            scanf("%d%d",&v,&c);
            G[u][v]=c;
        }
    }
    
    dijkstra();
    
    return 0;
}





Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  //input
  int ans=0;
  vector<int>vec;
 
  //compute
  for(int i=0;i<5;i++){
    int minutes;
    cin>>minutes;
    if (minutes%10==0){
      ans+=minutes;
    }
    else{
      vec.push_back(minutes%10); 
      ans+=minutes; 
    }    
  }
  sort(vec.begin(),vec.end());
  for(int i=1;i<vec.size();i++){
    ans+=10-vec[i];
  }
  
  
  //output
  cout<<ans<<endl;  
}
  


Measured memory_bytes: 256
#include <iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<math.h>
#include<utility>
#define ll long long
#define check(x) cout<<'>'<<'#x'<<':'<<x<<endl;
#define REP(i,n) for(int i=0;i< int(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define max(x,y) (x>y)?x:y
#define min(x,y) (x<y)?x:y
#define vi vector<int>
#define vl vector<long>
#define pb push_back
#define pii pair<int,int>
#define pll pair<long,long>
#define pi 3.14159265
using namespace std;
 ll lcm(int a, int b)
 {
		 return((a*b)/__gcd(a,b));
 }
 
int maxint = 998244353;

int main()
{
	 // #ifdef _ONLINEJUDGE_
	 //freopen("input.txt","r",stdin);
		//#endif // _ONLINEJUDGE_
		ios_base::sync_with_stdio(false);
		cin.tie(0);
		//code from here
		
		int n,m,temp;
		cin>>n>>m;
		temp =m;
		vector<int> v;
		for(int i =0;i<n-1;i++)
		{
			v.push_back(--temp);
		}
		temp = m;
		v.push_back(temp);
		for(int i =0;i<n-1;i++)
		{
			v.push_back(++temp);
		}
		sort(v.begin(),v.end());
		for(auto i = v.begin();i!=v.end();i++)cout<<*i<<" ";
		
		return 0;
		
 
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int i,len,p,u,y,e=0,g,r[6],s,m=0,q,z=0;
    char x[100];
    for(i=0;i<6;i++){
    	scanf("%d",&r[i]);
    }
    scanf("%d",&p);
    for(g=0;g<p;q++){
    	scanf("%d %d",&u,&y);
    	if(u==6&&y==2){
    		printf("4\n");
    		g++;
    	}else if(u==6&&y==4){
    		printf("5\n");
    		g++;
    	}else if(u==6&&y==5){
    		printf("3\n");
    		g++;
    	}else if(u==6&&y==3){
    		printf("2\n");
    		g++;
    		break;
    	}else{
    	while(r[0]!=u){
    	s=r[0];
    	r[0]=r[4];
    	r[4]=r[5];
    	r[5]=r[1];
    	r[1]=s;
    	m++;
    	if(m==7){
    		break;
    	}
    	}
    while(r[1]!=y){
    	s=r[1];
    	r[1]=r[2];
    	r[2]=r[4];
    	r[4]=r[3];
    	r[3]=s;
    	z++;
    	if(m==7){
    		while(r[0]!=u){
    	s=r[0];
    	r[0]=r[4];
    	r[4]=r[5];
    	r[5]=r[1];
    	r[1]=s;
    	if(z==7){
    		while(r[1]!=y){
    			s=r[1];
    	r[1]=r[2];
    	r[2]=r[4];
    	r[4]=r[3];
    	r[3]=s;
    		}
    	}
    		}
    	}
    }
    	if(r[0]==u&&r[1]==y){
    		printf("%d\n",r[2]);
    		g++;
    	}
    	}
    }
    return 0;
}

Measured memory_bytes: 608
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let n = input::<i64>();
    let t = input::<i64>();
    let a = input::<i64>();
    let h = (0..n).map(|_| input()).collect::<Vec<i64>>();

    let mut ans = 0;
    let mut d_min = std::i64::MAX as f64;
    for i in 0..n {
        let tt = t as f64 - h[i as usize] as f64 * 0.006;
        let d = f64::abs(tt - a as f64);
        if d < d_min {
            ans = i + 1;
            d_min = d;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b = 0, n, k;
string s, t;
//cout<<<<endl;


int main()
{
	cin >> n;
	int x[100][2];
	rep(j,2)
	{
		rep(i, n)
			cin>>x[i][j];
	}
	for (int i = 1; i < n; i++)
		x[i][0] += x[i - 1][0];
	x[0][1] += x[0][0];
	for (int i = 1; i < n; i++)
		x[i][1] += max(x[i - 1][1], x[i][0]);

	cout << x[n - 1][1] << endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <string>
#include <set>
#include <stdio.h>

using namespace std;

using ll = long long;
using pi = pair<int, int>;

const ll MOD = 1000000007;

ll f[200001];

ll modPow(ll base, ll exp, const ll MOD) {
	ll ans = 1;
	while (exp) {
		if (exp % 2 == 1)
			ans = (ans * base) % MOD;
		base *= base;
		base %= MOD;
		exp = exp >> 1;
	}
	return ans;
}
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll modInverse(ll n, ll MOD)
{
	return modPow(n, MOD - 2, MOD);
}

ll modBinomial(ll n, ll k, const ll p) {
	// calculates C(n,k) mod p (assuming p is prime).

	ll numerator = 1; // n * (n-1) * ... * (n-k+1)
	for (int i = 0; i < k; i++) {
		numerator = (numerator * (n - i)) % p;
	}

	ll denominator = 1; // k!
	for (int i = 1; i <= k; i++) {
		denominator = (denominator * i) % p;
	}

	// numerator / denominator mod p.
	return (numerator * modInverse(denominator, p)) % p;
}

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	ll ans = modPow(2, n, MOD) - 1 + 3 * MOD - modBinomial(n, a, MOD) - modBinomial(n, b, MOD);
	cout << ans % MOD;
}

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

#define Fi first
#define Se second
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<(n);i++)
typedef tuple<int, int, int> t3;

int n, m;
char In[120][120];
int dp[120][120];

int main() {
	scanf("%d%d", &n, &m);
	for(int i=1;i<=n;i++) scanf("%s", In[i] + 1);
	if(In[1][1] == '#') dp[1][1] = 1;
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) {
		if(i == 1 && j == 1) continue;
		dp[i][j] = 1e9;
		if(i > 1) {
			if(In[i][j] == '#' && In[i-1][j] == '.') dp[i][j] = min(dp[i][j], dp[i-1][j] + 1);
			else dp[i][j] = min(dp[i][j], dp[i-1][j]);
		}
		if(j > 1) {
			if(In[i][j] == '#' && In[i][j-1] == '.') dp[i][j] = min(dp[i][j], dp[i][j-1] + 1);
			else dp[i][j] = min(dp[i][j], dp[i][j-1]);
		}
	}
	printf("%d\n", dp[n][m]);
	return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<assert.h>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define de_x(x) cout<< #x <<"->debug_val: "<<x<<endl;
#define de_ve(x) for(auto it: x) cout<<it<<" ";
#define rep(i,a,n) for (int i=a;i<n;i++)
#define _rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef double db;
//std::mt19937 mrand(random_device{}());
//int rnd(int x) { return mrand() % x ; }
const ll mod=1e7;
ll ksm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int _,n,m;
/***********************/
void run(){
}
int main(){
//    for(scanf("%d",&_);_;_--) run();
    ll x,y,z;
    cin>>x>>y>>z;
    cout<<x/(y+z)*y+min(x%(z+y),y)<<endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    readLine()?.toInt()?.let {
        val list = mutableListOf<String>()
        repeat(it) {
            readLine()?.let {
                list.add(it)
            }
        }
        val ac = list.filter { it == "AC" }.count()
        val wa = list.filter { it == "WA" }.count()
        val tle = list.filter { it == "TLE" }.count()
        val re = list.filter { it == "RE" }.count()
        println("AC x $ac")
        println("WA x $wa")
        println("TLE x $tle")
        println("RE x $re")
    }
}

Measured memory_bytes: 60348
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int n;
	cin >> n;
	vector<int>odd(100010,0), even(100010,0);
	for (int i = 0; i < n / 2; ++i) {
		int a, b;
		cin >> a;
		odd.at(a)++;
		cin >> b;
		even.at(b)++;
	}
	vector<pii>odd_count, even_count;
	for (int i = 1; i < 100010; ++i) {
		odd_count.push_back(make_pair(odd[i], i));
		even_count.push_back(make_pair(even[i], i));
	}
	sort(even_count.begin(), even_count.end(),greater<pii>());
	sort(odd_count.begin(), odd_count.end(),greater<pii>());
	if (even_count[0].second != odd_count[0].second) {
		cout << n - even_count[0].first - odd_count[0].first << endl;
	}
	else {
		cout << min(n - even_count[0].first - odd_count[1].first, n -
			even_count[1].first - odd_count[0].first);
	}
	return 0;
}

Measured memory_bytes: 2804
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
int m(long long a, long long b)
{
	if (a < b) {
		swap(a, b);
	}
	while (a % b != 0) {
		long long tmp = b;
		b = a % b;
		a = tmp;
	}
	return b;
}
long long x[100000];
int main()
{
	int N;
	long long X;
	scanf("%d%lld", &N, &X);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &x[i]);
	}
	long long sa[100000];
	sa[0] = abs(X - x[0]);
	for (int i = 1; i < N ; i++) {
		sa[i] = abs(x[i] - x[i - 1]);
	}
	long long an = sa[0];
	for (int i = 1; i < N ; i++) {
		//printf("%d\n", sa[i]);
		an = m(an, sa[i]);
	}
	printf("%lld", an);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n;
  cin >> n;
  vector<ll>a(3*n);
  rep(i,3*n) cin >> a[i];
  sort(a.begin(),a.end(),greater<ll>());
  ll ans=0;
  rep(i,2*n){
    if(i%2==1)ans+=a[i];
  }
  cout << ans << endl;
  
}


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

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++) // repマクロ
#define all(v) v.begin(), v.end() // sort等の関数呼び出しを簡潔にする

using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

int main() {
    int N, M;
    cin >> N >> M;
    cout << N*(N-1)/2 + M*(M-1)/2 << endl;
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}
struct list{
	int a;
	struct list *prev;
	struct list *next;
};
struct list *head,*tail;
struct list *make(int a){
	struct list *p;
	p=malloc(sizeof(struct list));
	p->a=a;
	p->prev=NULL;
	p->next=NULL;
	return p;
}

int main(void){
	long long h=llin(),w=llin(),i,ans=INF,x,t[3],a,b;
	for(i=1;i<h;i++){
		t[0]=i*w;
		x=w/2;
		t[1]=(h-i)*x;
		t[2]=(h-i)*(w-x);
		a=max(max(t[0],t[1]),t[2]);
		b=min(min(t[0],t[1]),t[2]);
		ans=min(ans,a-b);
		x=(h-i)/2;
		t[1]=x*w;
		t[2]=(h-x-i)*w;
		a=max(max(t[0],t[1]),t[2]);
		b=min(min(t[0],t[1]),t[2]);
		ans=min(ans,a-b);
	}
	for(i=1;i<w;i++){
		t[0]=h*i;
		x=h/2;
		t[1]=x*(w-i);
		t[2]=(h-x)*(w-i);
		a=max(max(t[0],t[1]),t[2]);
		b=min(min(t[0],t[1]),t[2]);
		ans=min(ans,a-b);
		x=(w-i)/2;
		t[1]=h*x;
		t[2]=h*(w-x-i);
		a=max(max(t[0],t[1]),t[2]);
		b=min(min(t[0],t[1]),t[2]);
		ans=min(ans,a-b);
	}
	llprint(ans);
	return 0;
}

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

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

#define F first
#define S second
#define MP make_pair

const int MAX = 1e5+9;
const ll MOD = 1e9+7;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	ll a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	a = min(a, 2*c);
	b = min(b, 2*c);
	c = min(2*c, a+b);
	ll res = 0;
	if (x < y)
		res = x * c + (y-x) * b;
	else
		res = y * c + (x-y) * a;
	cout << res << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
using namespace std;
typedef long long llong;

int main()
{
	int A, P;
	cin >> A >> P;
	A *= 3;
	cout << (A + P) / 2;

	return 0;
}

Measured memory_bytes: 764
# D - Teleporter
def main():
    N, K, *A = map(int, open(0).read().split())
    A = [0] + A
    last_visit = [-1] * (N + 1)
    last_visit[1] = 0
    cur_pos, i = 1, 1

    while True:
        nxt_pos = A[cur_pos]

        if i == K:
            print(nxt_pos)
            break
        elif (j := last_visit[nxt_pos]) != -1:  # detect a loop
            print(last_visit.index(j + (K - i) % (i - j)))
            break

        cur_pos = nxt_pos
        last_visit[cur_pos] = i
        i += 1


if __name__ == "__main__":
    main()


Measured memory_bytes: 31812
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
using P = pair<int, int>;

constexpr ll mod = 1e9 + 7;
const double PI = acos(-1.0);

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

  double t, x; cin >> t >> x;
  cout << setprecision(10) << t/x << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    if(n == 1)
    {
        cout << "Hello World";
    }
    else
    {
        int a, b;
        cin >> a >> b;
        cout << a + b;
    }

    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    ll prev_b = numeric_limits<ll>::max();
    for (ll i = 0; i < N-1; i++) {
        ll Bi;
        cin >> Bi;
        ans += min(prev_b, Bi);
        prev_b = Bi;
    }
    ans += prev_b;
    cout << ans << endl;
}



Measured memory_bytes: 888
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

using namespace std;
int main() {
	int N, a;
	int ans=0;
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		scanf("%d", &a);
		if (i % 2 == 1 && a % 2 == 1)ans++;
	}
	printf("%d", ans);
}



Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    ll r, d, x;
    cin >> r >> d >> x;
    rep(i, 10) {
        x = r*x-d;
        cout << x << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
ll f(ll x,ll y){
    if(y==0)return 1;
    if(y%2)return f(x,y-1)*x%MOD;
    return f(x,y/2)*f(x,y/2)%MOD;
}
ll f2(ll x){
    if(x==0)return 1;
    return f2(x-1)*x%MOD;
}
ll n,m,k;
int main(void){
    cin>>n>>m>>k;
    cout<<f2(n*m-2)*f(f2(n*m-k),MOD-2)%MOD*f(f2(k-2),MOD-2)%MOD*(m+n)%MOD*(n*m-1)%MOD*n*m%MOD*f(6,MOD-2)%MOD<<endl;
}


Measured memory_bytes: 3328
N, Ma, Mb = gets.split.map(&:to_i)
A, B, C = [nil], [nil], [nil]
readlines.each{|l| a, b, c = l.split.map(&:to_i); A << a; B << b; C << c}

INF = 1 << 30
Wmax = 40 * 10
dp = Array.new(N + 1){Array.new(Wmax + 1){Array.new(Wmax + 1, INF)}}
dp[0][0][0] = 0
(1 .. N).each do |i|
  (0 .. Wmax).each do |j|
    (0 .. Wmax).each do |k|
      next if dp[i - 1][j][k] == INF
      dp[i][j][k] = [dp[i][j][k], dp[i - 1][j][k]].min
      dp[i][j + A[i]][k + B[i]] = [dp[i][j + A[i]][k + B[i]], dp[i - 1][j][k] + C[i]].min
    end
  end
end
ans = [*1 .. Wmax].repeated_permutation(2).select{|a, b| a*Mb == b*Ma}.map{|a, b| dp[N][a][b]}.min
puts ans == INF ? -1 : ans


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

int main() {
  int H, W;
  cin >> H >> W;
  
  for (int i = 0; i < (W + 2); i++) {
    cout << "#";
  }
  
  cout << endl;
  
  for (int i = 0; i < H; i++) {
    string a;
    cin >> a;
    cout << "#" << a << "#" << endl;
  }
  
  for (int i = 0; i < (W + 2); i++) {
    cout << "#";
  }
  
  cout << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = scanner.nextInt();
        //0 = swim/ 1 = bugs/ 2 = hw
        int[][] act = new int[N][3];
        for(int i = 0; i < N; i++) {
            act[i][0] = scanner.nextInt();
            act[i][1] = scanner.nextInt();
            act[i][2] = scanner.nextInt();
        }
        int[][] dp = new int[N][3];
        dp[0][0] = act[0][0];
        dp[0][1] = act[0][1];
        dp[0][2] = act[0][2];
        for(int i = 1; i < N; i++) {
            dp[i][0] = act[i][0] + Math.max(dp[i-1][1], dp[i-1][2]);
            dp[i][1] = act[i][1] + Math.max(dp[i-1][2], dp[i-1][0]);
            dp[i][2] = act[i][2] + Math.max(dp[i-1][0], dp[i-1][1]);
        }
        int max = 0;
        for(int i = 0; i < 3; i++) {
            max = Math.max(max, dp[N-1][i]);
        }
        out.println(max);
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        
        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }
    }
}


Measured memory_bytes: 49472
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
using namespace std;

const int undef = 0;
const int null = 1;

struct info{
	int sz, rc;
	bool fr;

	info(int s, int r, bool f): sz(s), rc(r), fr(f) {}
};

int m;
const char *ptr;
vector<info> ref;
int vars[26];

int alloc(int s){
	if(s > m){
		return null;
	}
	m -= s;
	ref.push_back(info(s, 0, false));
	return ref.size() - 1;
}

int expr(){
	if(*ptr == '('){
		++ptr;
		int k = expr();
		++ptr;
		return k;
	}
	if(*ptr == 'N' && ptr[1] == 'U'){
		return null;
	}
	if(*ptr == 'm'){
		char *endp;
		int s = strtol(ptr + 7, &endp, 10);
		ptr = endp + 1;
		return alloc(s);
	}
	if(*ptr == 'c'){
		ptr += 6;
		int k = expr();
		++ptr;

		if(ref[k].fr) throw 0;
		if(k == null) return null;
		return alloc(ref[k].sz);
	}

	int &v = vars[*ptr++ - 'A'];
	if(*ptr == '='){
		++ptr;
		int k = expr();

		--ref[v].rc;
		++ref[k].rc;
		v = k;
	}
	return v;
}

int main() try{
	ref.push_back(info(0, 1000000, true));
	ref.push_back(info(0, 1000000, false));

	string s;
	getline(cin, s);
	m = strtol(s.c_str(), 0, 10);

	while(getline(cin, s)){
		ptr = s.c_str();

		if(*ptr == 'f'){
			ptr += 5;
			int k = expr();
			if(ref[k].fr) throw 0;
			if(k != null){
				--ref[k].rc;
				m += ref[k].sz;
				ref[k].fr = true;
			}
		}
		else{
			expr();
		}
	}

	int ans = 0;
	for(int i = 2; i < ref.size(); ++i){
		if(ref[i].rc == 0 && !ref[i].fr){
			ans += ref[i].sz;
		}
	}
	cout << ans << '\n';
}catch(...){
	cout << "Error\n";
}

Measured memory_bytes: 1244
n, m = map(int, input().split())
ac = [False] * n
cnt = [0] * n
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC" and not ac[p - 1]:
        ac[p - 1] = True
    if s == "WA" and not ac[p - 1]:
        cnt[p - 1] += 1
ans_ac = 0
ans_wa = 0
for i in range(n):
    if ac[i]:
        ans_ac += 1
        ans_wa += cnt[i]
print(ans_ac, ans_wa)

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+5;
signed main(){
	int n,k;cin>>n>>k;
	int sb[N];
	for(int i=0;i<n;i++)cin>>sb[i];
	sort(sb,sb+n);int sum=0;
	for(int i=0;i<k;i++)sum+=sb[i];
	cout<<sum<<"\n";
} 

Measured memory_bytes: 3648
# count number of R
# if R is 2, then check if S is in the middle

s = input()
ans = 0
for i in s:
    if i == "R":
        ans += 1
if ans != 2:
    print(ans)
else:
    if s[1] == 'S':
        print(1)
    else:
        print(2)

Measured memory_bytes: 9036
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string.h>
using namespace std;

#define left 2
#define right 3
#define MAX 100000

int main(void) {
	int N, K, answer = 0, cross_point_num = 0;
	char S[MAX], LorR;
	cin >> N >> K >> S;
	LorR = S[0];
	for (int i = 1; i < strlen(S); i++) {
		if (LorR != S[i]) {
			cross_point_num++;
			LorR = S[i];
		}
		else {
			answer++;
		}
	}
	answer += min(cross_point_num, K * 2);
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

// 最大公約数
long gcdFunc(long a, long b)
{
	if (a % b == 0)
	{
		return b;
	}
	else
	{
		return gcdFunc(b, a % b);
	}
}

int main()
{
	int N;
	long X;
	cin >> N >> X;
	vector<long> x(N);

	for (int i = 0; i < N; i++)
	{
		cin >> x[i];
		// この値がキーポイント
		x[i] = X - x[i];
	}

	long answer = abs(x[0]);
	for (int i = 0; i < N; i++)
	{
		answer = gcdFunc(answer, abs(x[i]));
	}

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 1024