akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define Se second
#define Fi first
#define rep(i, n) for(int i=0;i<n;i++)
#define pb(x) push_back(x)

const int MX = 100005;

int N;
int D[MX];
char ans[105][105];

int main()
{
	int A, B;
	scanf("%d%d", &A, &B);
	A--; B--;
	printf("%d %d\n", 100, 100);
	for(int i = 1; i <= 100; i++) for(int j = 1; j <= 100; j++) ans[i][j] = '.';
	for(int i = 1; i <= 49; i++){
		for(int j = 1; j <= 49; j++) ans[i][j] = '#';
	}
	for(int i = 2; i <= 48; i += 2){
		for(int j = 2; j <= 48; j += 2){
			if( A ) A--, ans[i][j] = '.';
		}
	}
	for(int i = 52; i <= 100; i += 2){
		for(int j = 52; j <= 100; j += 2){
			if( B ) B--, ans[i][j] = '#';
		}
	}
	for(int i = 1; i <= 100; i++) printf("%s\n", ans[i]+1);
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))

L.sort()

from bisect import*
ans = 0
for i in range(N):
    for j in range(i+1, N):
        a = L[i]
        b = L[j]
        r = bisect_left(L, (a + b))
        l = j + 1
        ans += max(0, r-l)
print(ans)

Measured memory_bytes: 44892
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
    int a,b; cin >> a >> b;
    int ans = 0;

    for (int i = a; i <= b; ++i) {
        int r_1 = i % 10;
        int r_10 = i / 10 % 10;
        int r_1000 = i / 1000 % 10;
        int r_10000 = i / 10000 % 10;
        if(r_1 == r_10000 && r_10 == r_1000)ans++;
    }
    print(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;
void print(long double a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}


//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];
//ll dp[1001][1001];
//char a[1001][1001];
long double dp[301][301][301];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
	cout <<setprecision(10) << fixed ;

	ll n;
	cin >> n;
	ll a[n+1];
	ll mp[4] = {0};
	for(int i=1;i<=n;i++){
		cin>>a[i];
		mp[a[i]]++;
	}
	
	for(int i=0;i<=n;i++){
		for(int j=0;i+j<=n;j++){
			for(int k=0;i+j+k<=n;k++){
				if(i==0 && j==0 && k==0){
					continue;
				}
				dp[i][j][k] = n;
				if(i!=0){
					dp[i][j][k] += dp[i-1][j+1][k]*i;
				}
				if(j!=0){
					dp[i][j][k] += dp[i][j-1][k+1]*j;
				}
				if(k!=0){
					dp[i][j][k] += dp[i][j][k-1]*k;
				}
				dp[i][j][k] /= (i+j+k);
			}
		}
	}
	
	cout<<dp[mp[3]][mp[2]][mp[1]];
	return 0;
}


Measured memory_bytes: 426240
n, m = gets.split.map(&:to_i)

students = []
n.times do
  a, b = gets.split.map(&:to_i)
  students << { x: a, y: b }
end

points = []
m.times do
  c, d = gets.split.map(&:to_i)
  points << { x: c, y: d}
end

students.each do |student|
  distance = []
  points.each do |point|
    distance << (point[:x] - student[:x]).abs + (point[:y] - student[:y]).abs
  end
  puts distance.index(distance.min)+1
end


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<double> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }

  vector<vector<double>> dp(n, vector<double>(n + 1, 0.0));
  dp[0][1] = p[0];
  dp[0][0] = 1.0 - p[0];
  for (int i = 1; i < n; ++i) {
    dp[i][0] = (i > 0 ? dp[i-1][0]: 1.0) * (1.0 - p[i]);
    for (int j = 1; j <= i + 1; ++j) {
      dp[i][j] = dp[i-1][j-1] * p[i] + dp[i-1][j] * (1.0 - p[i]);
    }
  }

  double ans = 0.0;
  for (int i = n/2 + 1; i <= n; ++i) {
    ans += dp[n-1][i];
  }
  cout << setprecision(10) << ans << '\n';

  return 0;
}


/*
 dp[i][j]: probability of j heads using i first coins
 * C(n, 0)
 * total 2^n
 */


Measured memory_bytes: 73776
use std::io;

fn judge(a:i64, b:i64) -> bool {
    a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0
}

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin
        .read_line(&mut buf)
        .expect("ERROR Can't read array size");
    let v: Vec<i64> = buf.split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect();

    if judge(v[0],v[1]) {
        println!("Possible");
    } else {
        println!("Impossible"); 
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int a, b;
  cin >> a >> b;

  int count = 0;
  for(int i = a; i <= b; i++){
    string s = to_string(i);
    int n = s.length();
    bool p = true;
    for(int j = 0; j < n / 2; j++){
      if(s[j] != s[n - 1 - j]){
        p = false;
        break;
      }
    }
    if(p) ++count;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define in freopen("input.txt", "r" ,stdin)
#define out freopen("output.txt", "w" , stdout)
#define ll long long
#define inf 200005
#define fr first
#define  sc second
#define pb push_back
#define p_b pop_back
#define mp make_pair
#define N 100100
#define mod 1000000007
#define pi 3.1415926535
using namespace std;
int n;
double p[100005];
double dp[3005][3005];
int main (){
//in;out;
ios_base::sync_with_stdio(0);
cin >> n;
cout << fixed << setprecision(9);
for (int i = 1; i <= n; i++){
    cin >> p[i];
}
dp[0][0] = 1;
for (int i = 1; i <=n; i++) {
    dp[i][0] = dp[i-1][0] * (1-p[i]);
}

for (int i = 1; i <= n; i++){
     for (int j = 1; j <= i; j++){
        dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]);
     }
}
double sum = 0;
for (int i = n/2+1; i <=n; i++){
    sum += dp[n][i];
}

cout << sum;
}


Measured memory_bytes: 69120
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long,long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    veci L(N);
    REP(i,N) cin >> L[i];
    sort(L.begin(),L.end());
    int ans = 0;
    for(int i = 0; i < N-2; i++) {
        for(int j = i+1; j < N-1; j++) {
            for(int k = j+1; k < N; k++) {
                int a = L[i];
                int b = L[j];
                int c = L[k];
                if(a < b+c && b < c+a && c < a+b) ans++;
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

// Verified: AOJ-DSL1A
class UFSet {
 private:
  vector<int> ranks;
  vector<int> prevs;

 public:
  UFSet(int n) : ranks(n), prevs(n) {
    for (int i = 0; i < n; i++) prevs[i] = i;
  }

  // Returns a root of a tree which x belongs to.
  int Find(int x) {
    if (x != prevs[x]) prevs[x] = Find(prevs[x]);
    return prevs[x];
  }

  // Merges a set which x blongs to and a set which y belongs to.
  void Union(int x, int y) {
    int x_root = Find(x);
    int y_root = Find(y);
    if (ranks[x_root] > ranks[y_root]) {
      prevs[y_root] = prevs[x_root];
    } else if (ranks[x_root] < ranks[y_root]) {
      prevs[x_root] = prevs[y_root];
    } else if (prevs[x_root] != prevs[y_root]) {
      prevs[y_root] = prevs[x_root];
      ranks[x_root]++;
    }
  }
};

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

  int n, k, l;
  cin >> n >> k >> l;

  UFSet ufs1(n);
  UFSet ufs2(n);
  for (int i = 0; i < k; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    v1--;
    v2--;
    ufs1.Union(v1, v2);
  }
  for (int i = 0; i < l; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    v1--;
    v2--;
    ufs2.Union(v1, v2);
  }

  map<pair<int, int>, int> m;
  for (int i = 0; i < n; i++) {
    int c1 = ufs1.Find(i);
    int c2 = ufs2.Find(i);
    m[make_pair(c1, c2)]++;
  }

  for (int i = 0; i < n; i++) {
    int c1 = ufs1.Find(i);
    int c2 = ufs2.Find(i);
    cout << m[make_pair(c1, c2)] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
const ll MOD=1000000007;

int main(){
    int N;
    string S,T;
    cin >> N >> S >> T;
    int c=0;
    for (int i=0;i<N;i++){
        if (S.substr(N-1-i,i+1)==T.substr(0,i+1)){
            c=i+1;
        }
    }
    cout << 2*N-c << endl;
}

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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

int cnt[NAX];
class Solution
{
private:
public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        int n;
        cin >> n;
        for (size_t i = 1; i < n; i++)
        {
            int x;
            cin >> x;
            cnt[x]++;
        }
        for (size_t i = 0; i < n; i++)
        {
            cout << cnt[i + 1] << '\n';
        }
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 4428
k=int(input())
x=[i for i in range(1,10)]
for i in range(k//2):
  if x[i]%10!=0:
    x.append(10*x[i]+x[i]%10-1)
  x.append(10*x[i]+x[i]%10)
  if x[i]%10!=9:
    x.append(10*x[i]+x[i]%10+1)
print(x[k-1])



Measured memory_bytes: 9204
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	int ans;
	for (int i = (min(x, y)); i >= 1; i--) {
		if (x%i == 0 && y%i == 0) {
			ans = i;
			break;
		}
	}
	return ans;
}
int yakusuunowa(int n) {
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (n%i == 0)ans += i;
	}
	return ans;
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int ketanowa(int n) {
	int cnt = 0, sum = 0;
	for (int i = 10; i <= n * 10; i *= 10) {
		if (i == 10)cnt += n % i;
		else sum += (n%i - n % (i / 10)) / (i / 10);
	}
	return cnt + sum;
}
signed main() {
	string s;
	int w;
	cin >> s >> w;
	for (int i = 0; i < s.size(); i += w)cout << s[i];
	cout << endl;
	ll
}

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

#define FOR(i,j,k) for (int (i) = (j);(i) < (k);(i)++)
#define REP(i,j) FOR ((i),0,(j))

typedef unsigned long long ull;

inline ull POW(ull a, ull b) { ull c = 1; while (b > 0) { if (b & 1) { c = a * c; }a = a * a; b >>= 1; }return c; }

unsigned long long pnum = 1000000007;

unsigned long long get_hash(int l,int r,vector<unsigned long long> &hash) {
	unsigned long long res_hash = hash[r] - POW(pnum,r - l + 1) * hash[l - 1];
	return res_hash;
}

int main() {
	int n,m;
	cin >> n >> m;
	string s;
	cin >> s;

	vector<unsigned long long> hash_table(n + 1);
	hash_table[0] = 0;

	REP (i,n) {
		hash_table[i+1] = hash_table[i] * pnum + s[i];
	}

	int l = 1,r = 1;
	set<unsigned long long> se;

	REP (i,m) {
		string x;
		cin >> x;
		if (x == "R++") {
			r++;
		} else if (x == "R--") {
			r--;
		} else if (x == "L++") {
			l++;
		} else {
			l--;
		}

		se.insert(get_hash(l,r,hash_table));
	}
	cout << se.size() << endl;
}


Measured memory_bytes: 19576
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,K = map(int,input().split())
S = input().rstrip()

# 隣あう2人の向きが同じ をカウントする
cnt = 0
for i in range(N-1):
    if S[i]==S[i+1]:
        cnt += 1

# 1回の反転で +2 される => 最大で 2K 増える
cnt += 2*K

# ただし 最大値は 全員が同じ向きを向いた場合の N-1
print(min(N-1,cnt))

Measured memory_bytes: 3316
def main():
    h,w = map(int,input().split())
    s=[]
    for _ in range(h):
        s.append(list(input()))
    ans=[[0 for _ in range(w)] for _ in range(h)]
    L=[[0 for _ in range(w)] for _ in range(h)]
    R=[[0 for _ in range(w)] for _ in range(h)]
    U=[[0 for _ in range(w)] for _ in range(h)]
    D=[[0 for _ in range(w)] for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if i==0:
                if s[i][j]==".":
                    U[i][j]=1
                else:
                    U[i][j]=0
            else:
                if s[i][j]==".":
                    U[i][j]=U[i-1][j]+1
                else:
                    U[i][j]=0
            if i==0:
                if s[h-1-i][j]==".":
                    D[h-1-i][j]=1
                else:
                    D[h-1-i][j]=0
            else:
                if s[h-1-i][j]==".":
                    D[h-1-i][j]=D[h-i][j]+1
                else:
                    D[h-1-i][j]=0
    
    
    for i in range(h):
        for j in range(w):
            if j==0:
                if s[i][j]==".":
                    L[i][j]=1
                else:
                    L[i][j]=0
            else:
                if s[i][j]==".":
                    L[i][j]=L[i][j-1]+1
                else:
                    L[i][j]=0
            if j==0:
                if s[i][w-1-j]==".":
                    R[i][w-1-j]=1
                else:
                    R[i][w-1-j]=0
            else:
                if s[i][w-1-j]==".":
                    R[i][w-1-j]=R[i][w-j]+1
                else:
                    R[i][w-1-j]=0
                    
    for i in range(h):
        for j in range(w):
            ans[i][j]=L[i][j]+R[i][j]+U[i][j]+D[i][j]
    a=1
    for i in range(len(ans)):
        b=max(ans[i])
        a=max(a,b)
    print(a-3)
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 347016
import java.util.Scanner;
public class Main {

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

Measured memory_bytes: 41636
#include<bits/stdc++.h>
#define MOD 1000000007
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define forf(i,a,b) for(i=a;i<b;i++)
#define forr(i,a,b) for(i=a;i>b;i--)
#define mp make_pair
#define f first
#define s second
#define pb(x) push_back(x)
typedef  long long  int ll;
typedef std::vector<ll> vi;

#define input(vec,a,b) for(ll i =a;i<b;i++) cin>>vec[i]
#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" " ;cout<<endl;
#define all(a) a.begin(),a.end()
using namespace std;


void solve(){
        ll i,n;
        cin>>n;
        ll h[n],c[n];
        for(i=0;i<n;i++)
        cin>>h[i];
        c[0]=0;
        c[1]=abs(h[0]-h[1]);
        for(i=2;i<n;i++)
        {
                 c[i]=min(c[i-1]+abs(h[i]-h[i-1]),c[i-2]+abs(h[i]-h[i-2]));
        }
        cout<<c[n-1];
}

int main()
{
      IO;
      ll t=1;
      //cin>>t;


      while(t--)
      {

          solve();
      }
    return 0;
}

Measured memory_bytes: 5120
#include <stdio.h>

#define MAX 100000

int N;
int a[MAX];

int logdata[MAX];
int visited[MAX];
int result[MAX];

int main(void) {
	int i, j;
	int count = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &a[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		int current = i;
		int log_entry = 0;
		while (result[current] == 0 && visited[current] != i + 1) {
			visited[current] = i + 1;
			logdata[log_entry++] = current;
			current = (current + a[current]) % N;
		}
		if (result[current] != 0) {
			/* loop ni iku node agari niwa naranai */
			for (j = 0; j < log_entry; j++) {
				result[logdata[j]] = -1;
			}
		} else {
			/* loop ni iku made no yatu wa agari ni naranai */
			for (j = 0; logdata[j] != current; j++) {
				result[logdata[j]] = -1;
			}
			/* loop ni haitteiru yatu wa agari ni naru */
			for (; j < log_entry; j++) {
				result[logdata[j]] = 1;
			}
		}
	}
	for (i = 0; i < N; i++) {
		if (result[i] == 1) count++;
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 2152
#include<bits/stdc++.h>
using namespace std;
//macro
#define in(i,l,r) (l<i&&i<r)
#define linr(i,l,r) (l<=i&&i<=r)
#define lin(i,l,r) (l<=i&&i<r)
#define inr(i,l,r) (l<i&&i<=r)
#define f(i,L,R) for (int i = L; i < R; i++)
#define fe(i,L,R) for (int i = L; i <= R; i++)
#define ff(i,L,R) for (int i = L; i > R; i--)
#define ffe(i,L,R) for (int i = L; i >= R; i--)
#define all(c) (c).begin(),(c).end()
#define by(x) [](const auto& a, const auto& b){return a.x < b.x;}
#define io ios_base::sync_with_stdio(false);cin.tie(0);
#define mod 1000000007
#define pi acos(-1)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define ins insert
//typedef
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define vii vector<pair<int,int>>
#define vvii vector<vector<pair<int,int>>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define pq priority_queue
#define um unordered_map
#define us unordered_set
typedef pair<int,int> ii;
typedef pair<int,pair<int,int>> iii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
vii fx = {{0,1}, {0,-1}, {1,0}, {-1,0}};
//vii fx = {{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};
//operator
template<typename T,typename U>
pair<T,U> operator+(const pair<T,U> &l,const pair<T,U> &r){   
    return {l.first+r.first,l.second+r.second};
}
template<typename T,typename U>
pair<T,U> operator-(const pair<T,U> &l,const pair<T,U> &r){
    return {l.first-r.first,l.second-r.second};
}
template<typename T,typename U>
void operator+=(pair<T,U> &l,const pair<T,U> &r){
    l={l.first+r.first,l.second+r.second};
}
template<typename T,typename U>
void operator-=(pair<T,U> &l,const pair<T,U> &r){
    l={l.first-r.first,l.second-r.second};
}
struct cmp{
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};
/*
- array bounds
- int overflow
- negative modulo
- special cases (n=1)
*/

int main(){
	int n; cin >> n;
	vi h(n,0); for(int &i: h) cin >> i;
	vi dp(n,INT_MAX); dp[0]=0;
	for(int i=1;i<n;i++){
		for(int j=1;j<=min(i,2);j++) dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
	}
	cout << dp[n-1];
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
#include<array>
#include<algorithm>
#include<queue>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}
//long nHr(int n, int r) {
//	n = n + r - 1;
//	return nCr(n, r);
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI N;
	cin >> N;
	vector<LLI>vec(N);
	for (int i = 0; i < N;i++) {
		cin >> vec[i];
	}
	LLI MAX = 0;
	LLI cnt = 0;
	for (int i = 0; i < N - 1;i++) {
		if (vec[i] >= vec[i + 1]) {
			cnt++;
		}
		else {
			MAX = max(MAX,cnt);
			cnt = 0;
		}
	}
	MAX = max(MAX, cnt);
	cout << MAX << endl;
}

Measured memory_bytes: 1152
module Main where

import Control.Applicative

evenOrOdd :: Integer -> Integer -> Bool
evenOrOdd a b = even (a * b)

main :: IO ()
main = do
    [a,b] <- map read . words <$> getLine
    if evenOrOdd a b then
        putStrLn "Even"
    else
        putStrLn "Odd"

Measured memory_bytes: 508
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  rep(i, ty - sy) cout << 'U';
  rep(i, tx - sx) cout << 'R';
  rep(i, ty - sy) cout << 'D';
  rep(i, tx - sx) cout << 'L';

  cout << 'L';

  rep(i, ty - sy + 1) cout << 'U';
  rep(i, tx - sx + 1) cout << 'R';

  cout << 'D';
  cout << 'R';

  rep(i, ty - sy + 1) cout << 'D';
  rep(i, tx - sx + 1) cout << 'L';

  cout << 'U' << endl;
  
  return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
a = list(map(int, input().split()))
average = sum(a) / n
if average % 1 >= 0.5:
    average = math.ceil(average)
else:
    average = math.floor(average)
ans = 0
for i in range(n):
    ans += (average - a[i]) ** 2
print(ans)

Measured memory_bytes: 3060
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;
static const ll MOD = (ll)1e9 + 7;
static const double EPS = 1e-9;

#define REP(i, n) for(ll i = 0; i < static_cast<ll>(n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= static_cast<ll>(n); ++i)
#define RRANGE(i, m, n) for(ll i = static_cast<ll>(m); i >= static_cast<ll>(n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

ll power(ll x, ll y) {
    ll ret = 1;
    while(y-- > 0) ret *= x;
    return ret;
}

ll gcd(ll a, ll b) {
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll extgcd(ll a, ll b, ll& x, ll& y) {
    x = 1; y = 0;
    assert(a >= 0);
    assert(b >= 0);
    if (b == 0) return a;
    ll X, Y;
    auto d = extgcd(b, a % b, X, Y);
    x = Y;
    y = X - (a / b) * Y;
    return d;
}

int run(istream& in, ostream& out) {
    ll N, X, T;
    in >> N >> X >> T;
    ll ans = T*((N + X - 1)/X);

    out << ans << endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


Measured memory_bytes: 3636
n = int(input())
multi = list(map(int,input().split()))
result = 1 

if 0 in multi:
    result = 0
    print(0)
    exit()

for i in range(n):
    result = result * multi[i]
    if (result > 10**18):
        result = -1
        break 
        
print(result)

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

int main() {
	int n, ans = 0;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	ans = h[0];
	for (int i = 1; i < n; i++) {
		if (h[i - 1] < h[i]) ans += (h[i] - h[i - 1]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3608
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String []args){
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		Task solver = new Task();
		solver.solve(1,in,out);
		out.close();
	}
	static class Task{
		public void solve(int testNumber,Scanner in,PrintWriter out){
			int n = in.nextInt();
			int Max = (int)(-1e6 + 10);
			int Min = (int)(1e6 + 10);
			int posMax = 0;
			int posMin = 0;
			for(int i = 0 ; i < n ; i++){
				int x = in.nextInt();
				if(x > Max) {
					Max = x;
					posMax = i + 1;
				}
				if(x < Min){
					Min = x;
					posMin = i + 1;
				}
			}
			if(Math.abs(Max) >= Math.abs(Min)){
				out.println(2 * n - 2);
				for(int i = 1 ; i <= 2 ; i++){
					out.println(posMax + " " + 2);
				}
				for(int i = 2 ; i <= n - 1; i++){
					for(int j = 1 ; j <= 2 ; j++){
						out.println(i + " " + (i + 1));
					}
				}
			} else {
				out.println(2 * n - 2);
				for(int i = 1 ; i <= 2 ; i++){
					out.println(posMin + " " + (n - 1));
				}
				for(int i = n - 2 ; i >= 1 ; i--){
					for(int j = 1 ; j <= 2 ; j++){
						out.println((i + 1) + " " + i);
					}
				}
			}
		}
	}
}

Measured memory_bytes: 23764
n = int(input())
arr = list(map(int,input().split()))
dp = [0]*n

dp[1] = abs(arr[1]-arr[0])

for i in range(2,n):
    op1 = dp[i-2] + abs(arr[i]-arr[i-2])
    op2 = dp[i-1] + abs(arr[i]-arr[i-1])
    dp[i] = min(op1,op2)

print(dp[-1])

Measured memory_bytes: 20452
n,a=list(map(int,input().split()))
x=list(map(lambda x:int(x)-a,input().split()))
d={0:1}
for i in range(n):
  nd={}
  for j in d:
    if j in nd:
      nd[j]+=d[j]
    else:
      nd[j]=d[j]
    if (j+x[i]) in nd:
      nd[j+x[i]]+=d[j]
    else:
      nd[j+x[i]]=d[j]
  d=nd
print(d[0]-1)

Measured memory_bytes: 9232
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
#define MAX 505
#define MOD 1000000007
 
typedef long long ll;
 
 
int main(int, char**)
{
    ll a, b, n;
    cin >> a >> b >> n;
 
    cout << a * min(n, b-1) / b << endl;
 
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
#define FOR(i, n) for(int i = 1; i<=n; i++)
#define F0R(i, n) for(int i = 0; i<n; i++)
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
const LD pi = (LD)4 * atan(1);
LD a, b, x, ans, ar;

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

	cin >> a >> b >> x;
	ar = a*a*b;
	if((LD)2*x < ar){
		ans = a*b*b;
		ans /= (LD)2*x;
		ans = atan(ans);
		ans *= (LD)180;
		ans /= pi;
		cout << fixed << setprecision(8);
		cout << ans << endl;
		return 0;
	}
	ans = (LD)2*b;
	ans -= (LD)2*x/(a*a);
	ans /= a;
	ans = atan(ans);
	ans *= (LD)180;
	ans /= pi;
	cout << fixed << setprecision(8);
	cout << ans << endl;

	cout.flush();
	return 0;
}

Measured memory_bytes: 3868
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;

int64_t mod = 1e9 + 7;

int64_t factrial(int64_t n){
    int64_t v = 1;
    for(int i = n; i > 0; i--){
        v *= i;
        v %= mod;
    }
    return v;
}

int main(){

    int64_t N, M;
    cin >> N >> M;

    if(N == M){
        cout << (factrial(N) * factrial(M) * 2) % mod << endl;
    }else if(N - 1 == M || N == M - 1){
        cout << (factrial(N) * factrial(M)) % mod << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;

const int N=200005;
const int inf=1000000000;

int n,m,s1[N],s0[N];
struct tree{int mn,tag;}t[N*5];
vector<int> vec[N];
pair<int,int> a[N];

int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

void pushdown(int d,int l,int r)
{
	if (!t[d].tag||l==r) return;
	int w=t[d].tag;t[d].tag=0;
	t[d*2].tag+=w;t[d*2+1].tag+=w;
	t[d*2].mn+=w;t[d*2+1].mn+=w;
}

void ins(int d,int l,int r,int x,int y)
{
	pushdown(d,l,r);
	if (l==r) {t[d].mn=min(t[d].mn,y);return;}
	int mid=(l+r)/2;
	if (x<=mid) ins(d*2,l,mid,x,y);
	else ins(d*2+1,mid+1,r,x,y);
	t[d].mn=min(t[d*2].mn,t[d*2+1].mn);
}

void modify(int d,int l,int r,int x,int y,int z)
{
	if (x>y) return;
	pushdown(d,l,r);
	if (l==x&&r==y) {t[d].tag+=z;t[d].mn+=z;return;}
	int mid=(l+r)/2;
	modify(d*2,l,mid,x,min(y,mid),z);
	modify(d*2+1,mid+1,r,max(x,mid+1),y,z);
	t[d].mn=min(t[d*2].mn,t[d*2+1].mn);
}

int query(int d,int l,int r,int x,int y)
{
	if (x>y) return inf;
	pushdown(d,l,r);
	if (l==x&&r==y) return t[d].mn;
	int mid=(l+r)/2;
	return min(query(d*2,l,mid,x,min(y,mid)),query(d*2+1,mid+1,r,max(x,mid+1),y));
}

int main()
{
	n=read();
	for (int i=1;i<=n;i++)
	{
		s0[i]=s0[i-1];s1[i]=s1[i-1];
		int x=read();
		if (!x) s0[i]++;
		else s1[i]++;
	}
	m=read();
	for (int i=1;i<=m;i++) a[i].first=read(),a[i].second=read();
	sort(a+1,a+m+1);
	for (int i=1;i<=m;i++) vec[a[i].first].push_back(a[i].second);
	for (int i=1;i<=n*4+4;i++) t[i].mn=inf;
	ins(1,0,n,0,0);
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<vec[i].size();j++) ins(1,0,n,vec[i][j],query(1,0,n,0,vec[i][j]));
		if (s1[i]-s1[i-1]) modify(1,0,n,0,i-1,1);
		else modify(1,0,n,0,i-1,-1);
	}
	printf("%d",query(1,0,n,0,n)+s0[n]);
	return 0;
}

Measured memory_bytes: 19840
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=10007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int n;
int L[100],R[100];
bool X[100];
void a(int i){if(i<0){return;}cout<<" "<<i;a(L[i]);a(R[i]);}
void b(int i){if(i<0){return;}b(L[i]);cout<<" "<<i;b(R[i]);}
void c(int i){if(i<0){return;}c(L[i]);c(R[i]);cout<<" "<<i;}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>n;
	while(n--){
		int id,Le,Ri;cin>>id>>Le>>Ri;
		L[id]=Le;
		R[id]=Ri;
		X[Le+1]=1;X[Ri+1]=1;
	}
	int o=1;
	while(X[o]){o++;}
	o--;
	cout<<"Preorder"<<endl;
	a(o);cout<<endl;
	cout<<"Inorder"<<endl;
	b(o);cout<<endl;
	cout<<"Postorder"<<endl;
	c(o);cout<<endl;
	return 0;
}



Measured memory_bytes: 3208
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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 (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B;
	cin >> A >> B;
	if (A >= 13) {
		cout << B << endl;
	}
	else if (A >= 6) {
		cout << B / 2 << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

inline int sq(int n) {
    return n*n;
}

struct Circle {
    int x, y, r, c;

    bool collide(const Circle &other) const {
        return sq(x-other.x) + sq(y-other.y) < sq(r+other.r);
    }
};

int main() {
    while(true) {
        int N;
        cin >> N;
        if(!N) break;

        vector<Circle> circles(N);
        vector<int> blocking(N, 0);
        for(int i = 0; i < N; ++i) {
            Circle &circle = circles[i];
            cin >> circle.x >> circle.y >> circle.r >> circle.c;
            for(int j = 0; j < i; ++j) {
                if(circle.collide(circles[j])) {
                    blocking[i] |= 1<<j;
                }
            }
        }

        int ans = 0;
        vector<unsigned char> memo(1<<N, 0);
        queue<int> q;
        q.push((1<<N)-1);
        memo[q.front()] = 1;
        while(!q.empty()) {
            int cur = q.front();
            q.pop();
            ans = max(ans, N - __builtin_popcount(cur));

            for(int i = 0; i < N; ++i) {
                if((blocking[i] & cur) != 0) continue;
                if((cur & (1<<i)) == 0) continue;
                for(int j = 0; j < i; ++j) {
                    if(circles[i].c != circles[j].c) continue;
                    if((blocking[j] & cur) != 0) continue;
                    if((cur & (1<<j)) == 0) continue;

                    int mask = (1<<i) | (1<<j);
                    int next = cur & ~mask;
                    if(memo[next]) continue;
                    memo[next]  = 1;
                    q.push(next);
                }
            }
        }
        
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 18000
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<cmath>
using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;

ll gcd( ll a, ll b ){//最大公約数
    ll tmp;
    if( a < b ) { tmp = a; a = b; b = tmp; }
    if( b < 1 ) return -1;

    if( a % b == 0 ) return b;
    return gcd( b, a % b );
}

ll lcm(ll a, ll b){//最小公倍数
    return a * b / gcd(a, b);
}

ll sosuu(ll x){
    for(int i = 2; i < x; i++){
        if(x % i == 0) return false;
    }

    return true;
}


//入力

int main(){

    int s, w;
    cin >> s >> w;

    if(s <= w){
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }


    return 0;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    
    int saidai = Math.max(Math.max(A,B),C);
    int all = A+B+C;
    int tyuusyou =all-saidai;
    
    System.out.println(saidai*10+tyuusyou);
    }
}


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

int main(){

    string s;
    cin>>s;
    string ans="Yes";
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]=='L'){
                ans="No";
            }
        }
        else{
            if(s[i]=='R'){
                ans="No";
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()
 
int main(){
  ll N,ans=0;
  cin >> N;
  rep(i,N){
    ll a;
    cin >> a;
    if(i%2==0&&a%2==1){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace Atcoder.Abc
{
    //https://atcoder.jp/contests/abc175/tasks/abc175_a
    public class Abc175_A
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            string S = Console.ReadLine();

            switch (S)
            {
                case "RRR":
                    WriteLine("3"); 
                    break;
                case "RRS":
                case "SRR":
                    WriteLine("2");
                    break;
                case "SSS":
                    WriteLine("0");
                    break;
                default:
                    WriteLine("1");
                    break;
            }


            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 17248
#include<iostream>
#include<vector>
int main(){
	float n,max=0,mini=10000000;
	std::vector<int> high;
	while(1){
		std::cin>>n;
		high.push_back(n);
		if(std::cin.eof())break;
		//if(n==1000)break;
		if(n>max)max=n;
		if(n<mini)mini=n;
	}
	std::cout<<max-mini<<std::endl;
}

Measured memory_bytes: 1296
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

int main()
{
  ll h, w;
  cin >> h >> w;

  string c[2*h];

  for(int i = 0; i < 2*h; i += 2){
    cin >> c[i];
    c[i+1] = c[i];
  }

  for(int i = 0; i < 2*h; i++)
    cout << c[i] << endl;
}


Measured memory_bytes: 3608
n=int(input())
X=list(map(int,input().split()))

sortedX=sorted(X)
m1=sortedX[n//2-1]
m2=sortedX[n//2]
for i in range(n):
  if X[i]<=m1:
    print(m2)
  else:
    print(m1)

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N;
vector<string> ss;
map<char, ll> use;

signed main() {
    cin >> N;
    REP(i, N) ss.emplace_back(IN<string>());
    for(char i = 'a'; i <= 'z'; i++) {
        use[i] = count(All(ss[0]), i);
        FOR(j, 1, N) use[i] = min((ll)count(All(ss[j]), i), use[i]);
    }
    string ans = "";
    FOREACH(x, use) ans += string(x.second, x.first);
    cout << ans << "\n";
}

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

using namespace std;

#define ll long long
#define f(i,a,n) for(ll i=a;i<n;i++)

int main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    ll n,k;
    cin>>n>>k;
    
    ll a=n%k;
    
    if(abs(a-k)<a)
    cout<<abs(a-k);
    else
    cout<<a;
    
    return 0;
}


Measured memory_bytes: 256
args = input().split()
n = int(args[0])
d = int(args[1])
points = []
for i in range(n):
    points.append([int(p) for p in input().split()])


def isSquare(n):
    if n == 1:
        return True
    for i in range(2, n + 1):
        tmp = 0
        while n % i == 0:
            n = n // i
            tmp += 1
        if tmp % 2 != 0:
            return False
        if n == 1:
            return True

cnt = 0
for i in range(n):
    left = points[i]
    for j in range(i + 1, n):
        right = points[j]
        tmp = []
        for p in range(d):
            tmp.append(left[p] - right[p])
        dis = 0
        for k in tmp:
            dis += k ** 2
        if isSquare(dis):
            cnt += 1
        
print(cnt)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int n;
long long a[50];
long long b[50];
long long sum;
bool check(long long t) {
    long long sum1 = 0;
    for (int i = 0; i < n; i++) {
        b[i] = (a[i] + t) % (n + 1);
        //cout << b[i];
        if (b[i] >= n) return false;
        sum1 += b[i];
    }
    if (sum - t == (sum1)) return true;
    return false;
}
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
            cin >> a[i];
            sum += a[i];
    }
    check(3);
    for (long long i = max(sum - 50 * 50, 1LL * 0); i <= sum; i++) {
        if (check(i)) {
            cout << i;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#define MOD_P 1000000007
#define ll long long
using namespace std;



int main()
{
	int left, right;
	cin >> left >> right;
	int min = 2019;

	//printf("[%d:%d] = [%d:%d]\n", left, right, left % 2019, right % 2019);

	if (left % 2019 >= right % 2019 || right - left >= 2019) {
		printf("%d", 0);
	} else {
		for (int i = left; i < right; i++) {
			for (int j = i + 1; j <= right; j++) {
				//printf("[%d,%d]\n", i, j);
				int m = ((i % 2019) * (j % 2019)) % 2019;
				if (min > m) {
					min = m;
				}
			}
		}
		printf("%d", min);
	}




	return 0;
}

Measured memory_bytes: 256
import math
n,m=map(int,input().split())
mod=10**9+7
if abs(n-m)>1:
    print(0)
elif abs(n-m)==1:
    print(math.factorial(n)*math.factorial(m)%mod)
else:
    print(2*math.factorial(n)*math.factorial(m)%mod)

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

int main(){
    vector<int> vec(3);
    for (int i = 0; i < vec.size(); i++){
        cin >> vec.at(i); 
    }

    sort(vec.begin(), vec.end());
    cout << vec.at(0) + vec.at(1) << endl;
}

Measured memory_bytes: 256