akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
#始点を定めて(n)終点を定めて(n)その間の数を足し合わせる(～n)と計算量オーダーはO(n^3)
#累積和を用いると、始点を定めて(n)終点を定めて(n)差をとればいいので計算量オーダーはO(n^2)
#以下のコードでは、Aのループ処理(n)において随時累積和のmod mを算出し、そのmod mが何回現れたかを示す辞書の検索、挿入を行う(1)ので、計算量オーダーはO(n)
#（辞書の検索計算量オーダーについていまいち理解できていない。本当にO(1)なのだろうか？）

n,m = list(map(int,input().split()))
A = list(map(int,input().split()))

modm = 0
#累積和を別のリストに格納する必要はなく、bという変数を1つ用意して、modmにその時点での累積和のmod mを格納すればよい
dic = {0:1}
#{x:y}:Aの各要素を順に処理していくとき、mod mがxである要素が現時点までにy個見つかっていることを表す

cnt = 0
for a in A:
    modm = (modm+a) %m
    cnt += dic.get(modm,0)
    dic[modm] = dic.get(modm,0) + 1
#c[b]では、bをキーとする要素が見つからなかった場合エラーが発生してしまう。
#c.get(b,default)なら、bをキーとする要素が見つからなかった場合デフォルト値を返してくれる。

print(cnt)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

struct Doubling {
  const int LOG = 63;
  vector< vector< int > > table;
 
  Doubling(int sz) {
    table.assign(LOG, vector< int >(sz, -1));
  }
 
  void set_next(int k, int x) {
    table[0][k] = x;
  }
 
  void build() {
    for(int k = 0; k + 1 < LOG; k++) {
      for(int i = 0; i < table[k].size(); i++) {
        if(table[k][i] == -1) table[k + 1][i] = -1;
        else table[k + 1][i] = table[k][table[k][i]];
      }
    }
  }
 
  int query(int k, int64_t t) {
    for(int i = LOG - 1; i >= 0; i--) {
      if((t >> i) & 1) k = table[i][k];
    }
    return k;
  }
};

signed main(){

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

  Doubling d(n);
  for(int i = 0; i < n; i++){
    d.set_next(i, a[i]-1);
  }
  d.build();

  cout << d.query(0, k) + 1 << endl;

  return 0;
}

Measured memory_bytes: 104884
#include<iostream>
using namespace std;
long long m,n,a,d;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>m>>n;
    for (int i=1;i<=n;i++){
        cin>>a;
        d+=a;
    }
    if (d<=m)cout<<m-d;
        else cout<<-1;
}

Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    ll X, Y;
    cin >> X >> Y;

    ll ans = 0;
    while (X <= Y) {
        X *= 2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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


int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    long long cnt(0), cnt1(0);

    if(k & 1) {
        for(int i = 1; i <= n; ++i) if(i % k == 0) cnt++;
    } else {
        for(int i = 1; i <= n; ++i) if(i % k == 0) cnt++; else if(i % k == k / 2) cnt1++;

    }
    printf("%lld\n", cnt * cnt * cnt + cnt1 * cnt1 * cnt1);
}

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

#define ll long long
#define ld double
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define setpr(pp) fixed<<setprecision(pp)
#define FOR(I,N) for(I=0;I<N;++I)
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod	%1000000007
#define pi 3.141592653
#define MX 1000000000000001
ll a[1000005];
int main()
{	
	IOS;
	ll n;
	cin>>n;
	ll i,tmp=1;
	vector<char> ans;
	while(n>0)
	{
		--n;
		ans.pb('a'+n%26);
		n/=26;
	}
	auto it = ans.rbegin();
	for(;it!=ans.rend();++it)
		cout<<*it;
}


Measured memory_bytes: 3640
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
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 ) * } } ; }
//入力マクロここまで

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;

fn main() {
    input! {
        a: u64,
        b: u64,
    }

    for i in 0..10000 {
        if i * 108 / 100 - i == a && i * 110 / 100 - i == b {
            println!("{}", i);
            return;
        }
    }

    println!("-1");
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
// #include <bits/stdc++.h>

using namespace std;
typedef long long li;

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

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

    li ans = 1e9;
    for (int i = 0; i < n - k + 1; ++i) {
        li p = xs[i];
        li q = xs[i + k - 1];
        li tans;
        if (q <= 0) {
            tans = -p;
        } else if (p >= 0) {
            tans = q;
        } else {
            tans = min(-p, q) + (q - p);
        }
        ans = min(ans, tans);
    }

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


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

void solve()
{
	int n;
	while (cin >> n, n)
	{
		map<string, int> table;
		for (int i = 0; i < n; ++i)
		{
			string name;
			int cost;
			cin >> name >> cost;
			table[name] = cost;
		}
		int m;
		cin >> m;
		for (int i = 0; i < m; ++i)
		{
			string name;
			int num;
			cin >> name >> num;
			int sum = 0;
			for (int j = 0; j < num; ++j)
			{
				string material;
				cin >> material;
				sum += table[material];
			}
			table[name] = min(table[name], sum);
		}
		string name;
		cin >> name;
		cout << table[name] << endl;
	}
}

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

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

int main() {
	char s[100000];
	gets(s);
	for(int i=0;i<strlen(s);i++){
		if(i%2==0){
			printf("%c",s[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h,e = 0,n-1
print(0)
g = input()

while g != 'Vacant':
    mid = (h+e)//2
    print(mid)
    s = input()
    if s=='Vacant':exit()
    if g==s and mid%2==0 or g!=s and mid%2==1:
        h = mid + 1
    else:
        e = mid - 1


Measured memory_bytes: 62000
#include <stdio.h>
int main(void)
{
int N,x,y;
scanf ("%d",&N);
if(N>=1 && N<=100){
x=800*N;
y=N/15;
printf ("%d\n",(x-(y*200)));
}
else{
scanf ("%d",&N);
}
return 0;
}

Measured memory_bytes: 128
# /usr/bin/python
# -*- coding: utf-8 -*-
import math



def main():
  N,M = map(int, input().split())
  route = [0 for _ in range(N+1)]

  for _ in range(M):
    a,b = map(int, input().split())
    if a == 1:
      route[b] += 1
    elif b == N:
      route[a] += 1

  if max(route) >= 2:
    return True
  else:
    return False


if __name__ == "__main__":
  if main():
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')



Measured memory_bytes: 53360
#include <iostream>
#include <vector>
using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;

vector<int> dir;

void dfs(const Graph &G, int v, int p, int cur) {
    dir[v] = cur;
    for(auto e : G[v]) {
        if(e.first == p) continue; // e.first(nv)が親pだったらダメ
        
        if(e.second % 2) dfs(G, e.first, v, 1-cur);
        else dfs(G, e.first, v, cur);
    }
}

int main() {
    int N; cin >> N;
    
    Graph G(N); G.assign(N, vector<Edge>());
    for(int i = 0; i < N-1; ++i) {
        int a, b, w; cin >> a >> b >> w;
        --a, --b;
        G[a].push_back(Edge(b, w));
        G[b].push_back(Edge(a, w));
    }
    
    dir.assign(N, 0);
    dfs(G, 0, -1, 0);
    for(int i = 0; i < N; ++i) cout << dir[i] << endl;
}


Measured memory_bytes: 9728
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(int argc, char *argv[])
{
	int sInput;
	int h, m, s;
	char str[256];
	fgets(str, 256, stdin);

	sInput = atoi(str);

	h = sInput / 3600;
	m = ( sInput % 3600 ) / 60;
	s = sInput % 60;

	printf("%d:%d:%d\n", h, m ,s);
	return 0;
}

Measured memory_bytes: 528
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  string S;
  cin >> S ;
  if(S[2] == S[3]&& S[4] == S[5] )cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int R = scan.nextInt();
		scan.close();
		if(R < 1200) {
			System.out.println("ABC");
		} else if(R < 2800) {
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}
	}

}


Measured memory_bytes: 23764
n = int(input())
sl = list(input())

bl = [0]
wl = [0]
a = 0
b = 0
for s in sl:
   if s == "#":
      b += 1
   if s == ".":
      a += 1
   bl.append(a)
   wl.append(b)

ans = float("inf")
for i in range(n):
   tmp = wl[i+1] + bl[-1] - bl[i+1]
   ans = min(ans, tmp)

ans = min(wl[-1],ans)
ans = min(bl[-1],ans)
print(ans)

Measured memory_bytes: 14184
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
string s;
int main()
{
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
	cin>>s;
	int len=s.length();
	int l;
	int r;	
	rep(i,0,len)
	{
		if(s[i]=='A')
		{
			l=i;
			break;
		}
	}
	rep(i,0,len)
	{
		if(s[i]=='Z')
		{
			r=i;
		}
	}
	cout<<r-l+1<<endl;
	
	
    return 0;
}

inline void getInt(int* p) {char ch;do {ch = getchar();} 
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9') 
{*p = *p * 10 + ch - '0';}}}

Measured memory_bytes: 640
#include <iostream>
#include <stack>
#include <string>
#include <cstdlib>

using namespace std;


int main() {
    string word;
    stack<int> s;
    while(cin >> word)
    {
        if(word=="+")
        {
            int rem = s.top();
            s.pop();
            rem += s.top();
            s.pop();
            s.push(rem);
        }
        else if(word=="-")
        {
            int rem = s.top();
            s.pop();
            rem -= s.top();
            s.pop();
            rem *= -1;
            s.push(rem);
        }
        else if(word=="*")
        {
            int rem = s.top();
            s.pop();
           rem *= s.top();
            s.pop();
            s.push(rem);
        }
        else
        {
            s.push(atoi(word.c_str()));
        }
        
    }
    cout << s.top() << endl;
    
    return 0;
}

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



int main(){
    ll n;
    cin >> n;
    ll a[n];
    ll res=0;
    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    for(ll i=0;i<n-1;i++){
        if(a[i]%2==0){
            res+=a[i]/2;
        }
        else{
            res+=a[i]/2;
            if(a[i+1]>0){
                res++;
                a[i+1]--;
            }
        }
    }
    res+=a[n-1]/2;
    cout << res << endl;
    return 0;
}  


Measured memory_bytes: 4436
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()

A=[0]*N

for i in range(N):
    if T[i]==T[i-K] and A[i-K]!=0:
        A[i]=0
    else:
        if T[i]=="r":
            A[i]=P
        elif T[i]=="s":
            A[i]=R
        else:
            A[i]=S

print(sum(A))

Measured memory_bytes: 4084
// https://atcoder.jp/contests/abc134/tasks/abc134_d

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
// ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// ll lcm(long a, long b) { return a * b / gcd(a, b); }

int a[200001];
bool b[200001];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = n; i >= 1; i--) {
        int x = a[i];
        for (int j = i << 1; j <= n; j += i) {
            x ^= b[j];
        }
        b[i] = x;
        if (x)
            ans++;
    }
    cout << ans << "\n";
    for (int i = 1; i <= n; i++) {
        if (b[i]) {
            cout << i << " ";
        }
    }

    return 0;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define ENDL "\n"
#define PRINT(x) cout << (x) << ENDL

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

inline int in(int& a) {return scanf("%d", &a);}
inline void out(int n) {printf("%d\n", n);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


ll A[100000];
ll M[100000];

signed main(){
    int N;
    cin >> N;
    REP(i, N) cin >> A[i];
    M[0] = 0;
    REP(i, N){
        if(i % 2 == 0) M[0] += A[i];
        else M[0] -= A[i];
    }
    cout << M[0] << " ";
    FOR(i, 1, N){
        M[i] = 2 * A[i - 1] - M[i - 1];
        if(i < N - 1) cout << M[i] << " ";
        else cout << M[i] << ENDL;
    }
    return 0;
}

Measured memory_bytes: 2816
import java.util.Scanner;
import java.util.Stack;

public class Main{
	
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in); 
		String input = in.nextLine(); 
		
		System.out.println(reversePolish(input));
		
	}
	public static int reversePolish(String input) {
		
		Stack<Integer> st = new Stack<Integer>(); 
		
		String[] arr = input.split(" "); 
		
		for(int i = 0; i < arr.length; i++) {
			 
			if(isNumeric(arr[i]))
				st.push(Integer.parseInt(arr[i])); 
			else {
				int ans = 0; 
				int x1 = st.pop(); 
				int x2 = st.pop(); 
				ans = performMath(x2, x1, arr[i]); 
				st.push(ans); 
			}
		}
		return st.pop()	; 
	}
	public static int performMath(int a, int b, String str) {
		switch(str){
	    case "+":
	        return a + b;
	    case "-":
	        return a - b;
	    case "*":
	        return a * b;
	    case "/":
	        return a / b;
	    default:
	        return 0;
	    }
	}
	public static boolean isNumeric(String strNum) {
	    try {
	        int i = Integer.parseInt(strNum);
	    } catch (NumberFormatException | NullPointerException nfe) {
	        return false;
	    }
	    return true;
	}

}



Measured memory_bytes: 26396
while True:
    (H,W) = [int(x) for x in input().split()]
    if H == W == 0:
     break

    for h in range(H):
     for w in range(W):
      if h == 0 or h == H - 1 or w == 0 or w == W - 1:
       print("#", end="")
      else:
       print(".", end="")
     print()

    print()

Measured memory_bytes: 6812
N = int(input())
cij = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1, N+1):
    A = str(i)
    cij[int(A[0])][int(A[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += cij[i][j] * cij[j][i]
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include <unordered_set>

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 1000000000
#define PI 3.14159265358979323846

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vll;

//==============================================
vi pre, in, post;
int pos = 0;

int rec(int l, int r) {
	if (l >= r) return 0;
	int root = pre[pos++];
	int mid = distance(in.begin(), find(ALL(in), root));

	rec(l, mid);
	rec(mid + 1, r);
	post.push_back(root);
}

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

	int n;
	cin >> n;

	pre.resize(n);
	in.resize(n);

	REP(i, n) cin >> pre[i];
	REP(i, n) cin >> in[i];

	rec(0, pre.size());

	REP(i, n) {
		if (i) cout << " ";
		cout << post[i];
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 3228
N,M=map(int,input().split())

#A=list()
#B=list()
ans=[0]*N


H = list(map(int, input().strip().split()))

for i in range(M):
    At,Bt=map(int,input().split())
#    A.append(At-1)
#    B.append(Bt-1)

    if(H[Bt-1]<=H[At-1]):
        ans[Bt-1]=1
    if(H[At-1]<=H[Bt-1]):
        ans[At-1]=1
    
print(ans.count(0))


Measured memory_bytes: 20772
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
A = LI()


def gcd(a, b):
    while b:
        a, b = b, a%b
    return a


l = list(accumulate(A, lambda x, y: gcd(x, y)))
r = list(reversed(list(accumulate(reversed(A), lambda x, y: gcd(x, y)))))
ret = max(l[n-2], r[1])
for i in range(n-2):
    ret = max(ret, gcd(l[i], r[i+2]))


print(ret)

Measured memory_bytes: 15292
#!/usr/bin/env python3

numbers = input().split(" ")
n = int(numbers[0])
k = int(numbers[1])
have_okashi = [0] * n
r = 0

for i in range(k):
  input()
  numbers = input().split(" ")
  for x in numbers:
    have_okashi[int(x) - 1] = 1


print(have_okashi.count(0)  )


Measured memory_bytes: 9032
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n;
  while(cin>>n,n) {
    int ma = 0;
    for (int i=0; i*i*i<=n; ++i) {
      int hoge = n-i*i*i;
      for (int j=0; j*(j+1)*(j+2)/6<=hoge; ++j) {
        ma = max(ma, i*i*i+j*(j+1)*(j+2)/6);
      }
    }
    cout << ma << endl;
  }
}

Measured memory_bytes: 0
def run():
  H, N = map(int, input().split())
  ab_li = [tuple(map(int, input().split())) for n in range(N)]
  dp = [0]*(H+1)
  for i in range(1, H+1):
    new_li = []
    for n in range(N):
      a, b = ab_li[n]
      if a <= i:
        new_li.append(dp[i-a]+b)
      else:
        new_li.append(b)
    dp[i] = min(new_li)
  print(dp[-1])
  
if __name__ == '__main__':
  run()

Measured memory_bytes: 42588
#include <bits/stdc++.h>
#define debug(x) cout << #x << " -> " << x << endl
#define booga cout << "booga" << endl
#define ll long long int
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;


void testcase(){
	char c;
	cin >> c;
	if(c >= 'a' && c <= 'z'){
		cout << "a" << "\n";
	}
	else{
		cout << "A" << "\n";
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		testcase();
	}
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
struct BipartiteMatching {
    vector<vector<int>> E; int n, m; vector<int> match, dist;
    void init(int _n,int _m){n=_n,m=_m;E.resize(n+m+2);match.resize(n+m+2);dist.resize(n+m+2);}
    bool bfs() {
        queue<int> que;
        rep(i, 1, n + 1) {
            if (!match[i]) dist[i] = 0, que.push(i);
            else dist[i] = inf;
        }
        dist[0] = inf;
        while (!que.empty()) {
            int u = que.front(); que.pop();
            if (u) fore(v, E[u]) if (dist[match[v]] == inf) {
                dist[match[v]] = dist[u] + 1;
                que.push(match[v]);
            }
        }
        return (dist[0] != inf);
    }
    bool dfs(int u) {
        if (u) {
            fore(v, E[u]) if (dist[match[v]] == dist[u] + 1) if (dfs(match[v])) {
                match[v] = u; match[u] = v;
                return true;
            }
            dist[u] = inf;
            return false;
        }
        return true;
    }
    void add(int a, int b) { b += n; E[a + 1].push_back(b + 1); E[b + 1].push_back(a + 1); }
    int whois(int x) { return match[x + 1] - 1; }
    int solve() {
        rep(i, 0, n + m + 1) match[i] = 0;
        int res = 0;
        while (bfs()) rep(i, 1, n + 1) if (!match[i] && dfs(i)) res++;
        return res;
    }
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, M, L;
int D[101][101];
int P[1010], T[1010];
//---------------------------------------------------------------------------------------------------
void _main() {
    while (cin >> N >> M >> L) {
        if (N == 0) return;
        rep(i, 0, N) rep(j, 0, N) D[i][j] = inf;
        rep(i, 0, N) D[i][i] = 0;
        rep(i, 0, M) {
            int a, b, c; cin >> a >> b >> c;
            D[a][b] = D[b][a] = c;
        }
        rep(k, 0, N) rep(i, 0, N) rep(j, 0, N) chmin(D[i][j], D[i][k] + D[k][j]);
        rep(i, 0, L) {
            cin >> P[i] >> T[i];
        }

        BipartiteMatching bm;
        bm.init(L, L);
        rep(i, 0, L) rep(j, 0, L) if (i != j) if (T[i] + D[P[i]][P[j]] <= T[j]) bm.add(i, j);

        int ans = L - bm.solve();
        cout << ans << endl;
    }
}


Measured memory_bytes: 8352
#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    int q, p, n;
    char c;
    ll r = 0, l = 0;

    cin >> q;
    while (q--) {
        cin >> p >> c >> n;
        if (c == '(')
            l += n;
        else
            r += n;

        if (l == r)
            cout << "Yes\n";
        else
            cout << "No\n";
    }

    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> B(N);
    for(int i = 0;i < N;i++){
        cin >> B[i];
    }
    map<int,int> A;
    for(int i = 0;i < N;i++){
        A[B[i]] += 1;
    }
    ll sum = 0;
    for(auto x : A){
        ll v = x.second;
        sum += v*(v-1)/2;
    }
    for(int i = 0;i < N;i++){
        cout << sum - A[B[i]] + 1 << endl;
    }
}


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

using namespace std;

#define pb push_back
#define prr pair<int,int> 
#define int long long
#define fir first
#define sec second
#define double long double
#define ll long long



int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    vector<int> v1;
    int mx=(int)1e18;
    int n1=100;
    while(n1<mx){
        n1=n1*(1.01);
        if(n1<=mx && n1>0)
        v1.pb(n1);
        // cout<<n1<<"\n";
    }
    int n2;
    cin>>n2;
    auto itr=lower_bound(v1.begin(),v1.end(),n2);
    int diff=itr-v1.begin();
    cout<<diff+1;
}



Measured memory_bytes: 3688
n = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))
MOD = 10**9+7
only = [False]*n
h = [0]*n
mx = 0
for i, t in enumerate(T):
    if t > mx:
        only[i] = True
        h[i] = t
        mx = t
    else:
        h[i] = t

mx = 0
for i, a in enumerate(A[::-1]):
    k = n-i-1
    if only[k]:
        if a > mx:
            if h[k] != a:
                print(0)
                exit()
            else:
                mx = a
                continue
        else:
            if h[k] <= a: continue
            else:
                print(0)
                exit()
    else:
        if a > mx:
            if a <= h[k]:
                only[k] = True
                h[k] = a
                mx = a
            else:
                print(0)
                exit()
        else:
            if a <= h[k]:
                h[k] = a

ans = 1
for i in range(n):
    if only[i]: continue
    ans *= h[i]
    ans %= MOD
print(ans)

Measured memory_bytes: 25064
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
class nextPermutation{
  constructor(x){
    this.p = nextPermutation.f(x);
  }
  get next(){
    return this.p.next().value;
  }
  static *f(x){
    var q;
    if(typeof x === "number")q = [[],Array(x).fill().map((a,i)=>i+1)];
    else if(typeof x === "string")q = ["",x];
    else q = [[],x];
    while(q.length){
      var b = q.pop(), a = q.pop();
      if(b.length === 0)yield a;
      else for(var i = b.length; i--;){
        q.push(a.concat(b[i]), b.slice(0,i).concat(b.slice(i+1)));
      }
    }
  }
}

var myOut = main();
if(myOut !== undefined)console.log(myOut);
function main(){
  var n = o.a();
  var p = o.l();
  var q = o.l();
  var a = [p.join(""), q.join("")];
  a.sort();
  var np = new nextPermutation(Array(n).fill().map((a,i)=>i+1).join(""));
  var t;
  while(1){
    t = np.next;
    if(t === a[0])break;
  }
  var ans = 0;
  while(1){
    if(t === a[1])break;
    ans++;
    t = np.next;
  }
  return ans;
}

Measured memory_bytes: 10280
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;
const string YES = "Yes";
const string NO = "No";

void solve(ll N, ll K, vector<ll> A) {
  FOR(i, K, N) {
    if (A[i] > A[i - K])
      cout << YES << endl;
    else
      cout << NO << endl;
  }
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;
  ll K;
  cin >> K;
  vector<ll> A(N);
  REP(i, N) {
    cin >> A[i];
  }

  solve(N, K, move(A));

  return 0;
}


Measured memory_bytes: 4764
n=int(input())
ab = []
for _ in range(n-1):
    a, b, c = (int(x) for x in input().split())
    ab.append([a, b, c])

for i in range(n-1):
    ans = ab[i][0]+ab[i][1]
    for j in range(i+1,n-1):
        if ans <= ab[j][1]:
            ans = ab[j][1]
        elif (ans-ab[j][1])%ab[j][2]!=0:
            ans += ab[j][2]-(ans-ab[j][1])%ab[j][2]
        ans += ab[j][0]
    print(ans)
        
print(0)

Measured memory_bytes: 42348
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, N, X;
  string S, T;
  cin >> N;
  if (N % 10 <= 1 || N % 10 == 6 || N % 10 == 8)
    cout << "pon" << endl;
  else if (N % 10 == 3)
    cout << "bon" << endl;
  else
    cout << "hon" << endl;

  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll ret=a*b;
    ll u=gcd(a,b);
    return ret/u;
}
ll f(ll a,ll b,ll n){
    ll ret=b/n-a/n;
    if(a%n==0)ret++;
    return ret;
}
int main(){
    ll n;cin>>n;
    ll a[n],b[n];
    vector<pll> v;
    rep(i,0,n){
        cin>>a[i]>>b[i];
        v.push_back(make_pair(b[i],a[i]));
    }
    sort(v.begin(),v.end());
    ll now=0;
    rep(i,0,n){
        now+=v[i].second;
        if(now>v[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 9456
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include <cmath>
//#include <bits/stdc++.h>
using namespace std;

int main(){
    int X,Y,Z;
    cin>>X>>Y>>Z;
    int a,b,c;
    cout<<Z<<' '<<X<<' '<<Y<<endl;
    return 0;
}

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

typedef long long ll;

ll a[1000001];

int main()
{
    ll n;
    scanf("%lld", &n );

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

    sort( a, a + n * 3, greater<ll>() );

    ll sum = 0;
    for ( ll i = 1; i <= n * 2; i += 2 ) {
        sum += a[i];
    }

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

    return 0;
}



Measured memory_bytes: 4352
use io::*;
use std::*;

const YES: &'static str = "Yes";
const NO: &'static str = "No";

fn solve(S: String) {
    let r: char = S.as_bytes()[0] as char;
    for s in S.chars() {
        if s != r {
            println!("{}", YES);
            return;
        }
    }
    println!("{}", NO);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut S: String;
    S = scanner.next();
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(S)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 8572
# Algorithms and Data Structures 1
# Stack
# Name: Ryuya Asada
# ID: s1260064


class Stack():
    def __init__(self, size):
        self.__top = 0
        self.__stack = [int] * (size+1)

    def isEmpty(self) -> bool:
        return self.__top == 0

    def isFull(self) -> bool:
        return self.__top >= len(self.__stack)-1

    def push(self, x):
        if self.isFull():
            print("Overflow!")
        
        self.__top += 1
        self.__stack[self.__top] = x

    def pop(self):
        if self.isEmpty():
            print("Underflow!")

        self.__top -= 1
        return self.__stack[self.__top+1]


def main():
    s = Stack(100)
    operation = input().split(" ")
    for o in operation:
        if o == '+':
            a, b = s.pop(), s.pop()
            s.push(a + b)
        elif o == '-':
            b, a = s.pop(), s.pop()
            s.push(a - b)
        elif o == '*':
            a, b = s.pop(), s.pop()
            s.push(a * b)
        else:
            s.push(int(o))

    print(s.pop())


if __name__ == "__main__":
    main()



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
const int Q = 998244353;
int I[N];
int main() {
    int n , A , B;
    long long K;

    cin >> n >> A >> B >> K;

    I[0] = I[1] = 1;
    for (int i = 2 ; i <= n ; ++ i) {
        I[i] = (long long)(Q - Q / i) * I[Q % i] % Q;
    }
    for (int i = 1 ; i <= n ; ++ i) {
        I[i] = (long long)I[i] * I[i - 1] % Q;
    }

    int res = 0;
    for (int ik = max(0LL , (K - (long long)B * n + A - 1) / A) ; ik <= n ; ++ ik) {
        long long jks = (K - (long long)ik * A);
        if (jks < 0 || jks % B) continue; int jk = jks / B;
        //cout << ik << ' ' << jk << endl;
        res += (long long)I[jk] * I[n - jk] % Q * I[ik] % Q * I[n - ik] % Q;
        res %= Q;

    }
    for (int i = 1 ; i <= n ; ++ i) res = (long long)res * i % Q;
    for (int i = 1 ; i <= n ; ++ i) res = (long long)res * i % Q;

    cout << res << endl;
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  int n,t;
  cin >> n >> t;
  double a;
  cin >> a;
  int cand = -1000;
  double minDiff = 100000;
  for(int i=0;i<n;i++){
    int h;
    cin >> h;
    double tmp = t - h*0.006;
    double diff;
    if(tmp>a){
      diff = tmp - a;
    } else {
      diff = a - tmp;
    }
    if(diff < minDiff){
      minDiff = diff;
      cand = i;
    }
  }

  cout << cand+1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int tcs;cin>>tcs;while(tcs--)
const int N=200007;
const int MOD=1e9+7;
// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
int a[N],b[N];
vector<int> v(N);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define printclock cerr<<"Time : "<<1000*(int)clock()/(int)CLOCKS_PER_SEC<<"ms\n"


int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/

int n;
cin>>n;
int arr[n+1];
int count=0;
for(int i=1;i<=n;i++)
{
	cin>>arr[i];
}
for(int i=1;i<=n;i++)
{
	if(i%2 && arr[i]%2)
	count++;
}
cout<<count;


cout<<endl;
printclock;
}



Measured memory_bytes: 4656
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long n, k;
    cin >> n >> k;

    long ans = 0;
    if(k == 0)
    {
      ans = n * n;
      cout << ans << endl;
      return 0;
    }
  
    for(long b = k + 1; b <= n; b++)
    {
        ans += (n / b) * (b - k) + max( long(0), (n % b) - k + 1);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String b = "";
        loop:
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= 9; j++) {
                if (a == i * j) {
                    b = "Yes";
                    break loop;
                } else {
                    b = "No";
                }
            }
        }
        System.out.println(b);
    }
}

Measured memory_bytes: 21844
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e5+4;

vector<int> v[N];

int col[N],sz[N];

ll ans[N],cur_size[N],processed;

int dfs(int node,int par)
{
	ll temp=cur_size[col[node]];

	sz[node]=1;

	for(int it:v[node])
	if(it!=par)
	{
		ll prev = processed - cur_size[col[node]];

		sz[node]+=dfs(it,node);

		ll cur = processed - cur_size[col[node]];

		// (cur-prev) will give me in this case the no. of paths I can chose
		//such that there is no node of col[node]. 
		ll to_remove = (cur-prev)*(cur-prev+1)/2;

		ans[col[node]] -= to_remove;
	}

	processed++;

	cur_size[col[node]] = temp + sz[node];

	return sz[node];
}

int main()
{
	int n;

	scn(n);

	rep(i,1,n+1)
	scn(col[i]),ans[i]=1LL*n*(n+1)/2;

	rep(i,0,n-1)
	{
		int a,b;

		scn(a); scn(b);

		v[a].pb(b); v[b].pb(a);
	}

	dfs(1,-1);

	rep(i,1,n+1)
	{
		ll extra = (n-cur_size[i])*(n-cur_size[i]+1)/2;

		ans[i] -= extra;
	}

	rep(i,1,n+1)
	lpriln(ans[i]);

    return 0;
}

Measured memory_bytes: 37964
import math


def main():
    n = int(input())
    array = [int(s) for s in input().split(" ")]
    min_v = min(array)
    max_v = max(array)
    min_ans = float("inf")
    for i in range(min_v, max_v + 1):
        total = 0
        for a in array:
            total += (a - i) ** 2
        if min_ans > total:
            min_ans = total
    print(min_ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
from itertools import accumulate, chain

n, c = map(int, input().split())
xs, vs = zip(*(map(int, input().split()) for _ in range(n)))

ds = [j - i for i, j in zip(chain([0], xs), chain(xs, [c]))]

vs_running_clock = list(accumulate(vs))
ds_running_clock = list(accumulate(ds))
vs_running_antic = list(accumulate(vs[::-1]))
ds_running_antic = list(accumulate(ds[::-1]))

clockwise = chain([0], (v - d for v, d in zip(vs_running_clock, ds_running_clock)))
anticlockwise2 = [0] + [v - d*2 for v, d in zip(vs_running_antic, ds_running_antic)]
anticlock_clock = (x + y for x, y in zip(accumulate(clockwise, func=max), reversed(anticlockwise2)))

anticlockwise = chain([0], (v - d for v, d in zip(vs_running_antic, ds_running_antic)))
clockwise2 = [0] + [v - d*2 for v, d in zip(vs_running_clock, ds_running_clock)]
clock_anticlock = (x + y for x, y in zip(accumulate(anticlockwise, func=max), reversed(clockwise2)))

print(max(chain(anticlock_clock, clock_anticlock)))

Measured memory_bytes: 59224
MOD = 10 ** 9 + 7
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [0] * 60
    for i in A:
        for j in range(60):
            if i & (1 << j):
                B[j] += 1
    r = 0
    for ii, i in enumerate(A[:-1]):
        for j in range(60):
            if i & (1 << j):
                B[j] -= 1
                r = (r + (1 << j) * (N - ii - 1 - B[j])) % MOD
            else:
                r = (r + (1 << j) * B[j]) % MOD
    print(r)

main()


Measured memory_bytes: 125624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#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, x) vector<vector<T>> xs(n, vector<T>(m, x))
#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, 0); For(i, n) For(j, m) cin >> xs[i][j]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cinss(int, 2, n, a);
    Cusum(int, n, a[0], us);
    Cusum(int, n, a[1], ds);
    int m = -1;
    For(i, n){
        m = max(m, us[i+1]-us[0] + ds[n]-ds[i]);
    }
    Cout(m);
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){

  int x, y;
  int g1, g2;

  scanf("%d%d",&x,&y);
    if (x==1 || x==3 || x==5 || x==7 || x==8 || x==10 || x==12) { g1=1; }
    else if (x==4 || x==6 || x==9 || x==11) { g1=2; }
    else { g1=3; }

    if (y==1 || y==3 || y==5 || y==7 || y==8 || y==10 || y==12) { g2=1; }
    else if (y==4 || y==6 || y==9 || y==11) { g2=2; }
    else { g2=3; }

    if (g1 == g2)
      puts("Yes");
    else
      puts("No");

  return 0;
}


Measured memory_bytes: 128
n=int(input())
d=[[-1 for j in range(n)] for i in range(n)]
ans=0
for i in range(n):
    for j in range(int(input())):
        x,y=map(int,input().split())
        d[i][x-1]=y


for x in range(2**n):
    s=bin(x)[2:].zfill(n)
    sgn=1
    for i in range(n):
        if int(s[i])==1:
            for j in range(n):
                if d[i][j]!=-1 and d[i][j]!=int(s[j]):
                    sgn=0

                    break

        if sgn==0: break
    if sgn==1:
        tmp=sum(int(s[k]) for k in range(n))
        ans=max(ans,tmp)

print(ans)

Measured memory_bytes: 3064
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import qualified Data.Vector.Unboxed as V

main::IO()
main= do
    _ <- readLn::IO Int
    a <- V.fromList .  map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    let elmnt = V.drop 1 $ V.zip (V.scanl (+) 0 (V.init a)) (V.scanr (+) 0 a)
    print $ V.minimum $ V.map (abs) $ V.map (\e -> (fst e - snd e)) elmnt 



Measured memory_bytes: 12412