akhauriyash/Code-Regression huggingface dataset:
import * as fs from "fs";

function strArr2numArr(strArr: string[]): number[] {
    let numArr: number[] = [];
    strArr.map((item) => {
        numArr.push(+item);
    });
    return numArr;
}

const MOD: number = 1e9 + 7;

const input = fs.readFileSync("/dev/stdin", "utf8").split("\n");

let n: number;
let d: number;
let x: number[] = [];
let y: number[] = [];

input.map((line, i) => {
    var [a, b] = line.split(" ");
    if (i == 0) {
        n = +a;
        d = +b;
    } else if (i <= n) {
        x.push(+a);
        y.push(+b);
    }
});

let ans: number = 0;
for (let i = 0; i < n; i++) {
    if (x[i] * x[i] + y[i] * y[i] <= d * d) ans++;
}
console.log(ans);


Measured memory_bytes: 72964
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

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

Measured memory_bytes: 256
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define VECV(a,n,m) vector<vector<int>> a(n, vector<int>(m));
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  string divide[4] = {"dream", "dreamer", "erase", "eraser"};
  reverse(s.begin(),s.end());
  rep(i,4) reverse(divide[i].begin(),divide[i].end());
  bool f,f2;
  f2=true;
  for(int i=0;i<s.size();){
    f=false;

    rep(j,4){
      if(s.substr(i,divide[j].size())==divide[j]){

        i+=divide[j].size();
        f=true;
      }
    }
    if(!f){
      f2=false;
      break;
    }
  }
  if(f2) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 592
num = int(input())
s = input().rstrip().split(' ')
s = [ int(x) for x in s]
count = 0
key = True

while key:
    for i in range(num):
        if( s[i] % 2 == 0):
            s[i] = s[i] // 2
        else:
            key = False

    if key:
        count += 1

print(count)


Measured memory_bytes: 3064
N = int(input())
# input_line = [input() for _ in range(N)]
count = {}
for w in [input() for _ in range(N)]:
    if w in count:
        count[w] += 1
    else:
        count[w] = 1
max_values = max(count.values())
keys = [k for k, v in count.items() if v == max_values]
for w in sorted(keys):
    print(w)


Measured memory_bytes: 35216
H,W,K = map(int,input().split())
c = [input() for i in range(H)]

#for h in range(H):
#  for w in range(W):
#    if c[h][w] == '#':

h = len(c)
hl = []
for i in range(2 ** h):
 bit_set = []
 for j in range(h):
   if ((i >> j) & 1):
     bit_set.append(j)

 hl.append(bit_set)

wl = []
for i in range(2 ** W):
 bit_set = []
 for j in range(W):
   if ((i >> j) & 1):
     bit_set.append(j)
 wl.append(bit_set)


ans = 0
for w in wl:
  wll = []
  for ww in w:
    wll.append(ww)

  for h in hl:
    count = 0
    for i, cc in enumerate(c):
      if not i in h:
        for k, ccc in enumerate(cc):
          if not k in wll:
            if ccc == '#':
              count += 1

    if count == K:
      ans += 1


print(ans)

 

Measured memory_bytes: 9112
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = INT_MAX;
const int mod = 1e9+7;

const int N = 2e5 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
clock_t time_p=clock();



int32_t main(){
  fast;

  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);

  int n;
  cin >> n;
  vector<pair<string,int>>v(n);
  FOR(i,0,n-1)cin >> v[i].F >> v[i].S;
  string x;
  cin >> x;
  int ans = 0;
  int ff = 0;
  FOR(i,0,n-1) {
    if(ff)ans += v[i].S;
    if(v[i].F == x)ff = 1;
  }  
  cout << ans;

  time_p=clock()-time_p;
  cerr<<"\nTime Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";

  return 0;
}

Measured memory_bytes: 256
#![allow(dead_code, unused_imports, deprecated)]
use std::cmp::{max, min, Reverse};
use std::collections::*;
use maplit::*;
use num::Integer;
use proconio::input;
use proconio::marker::*;
use proconio::fastout;
const INF: usize = 1_000_000_007;

#[fastout]
fn main() {
  input! {
    d : usize,
    c : [isize; 26],
  };
  input! {
    s : [[isize; 26]; d],
  };

  for i in 0..d {
    let mut v = vec![];

    let mut res = 0;
    for j in 0..26 {
      v.push(s[i][j] + i as isize * (d as isize - i as isize) * c[j]);
      if v[j] > v[res] {
        res = j;
      }
    }
    println!("{}", res + 1);
  }
}


Measured memory_bytes: 2336
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	LL N;
	cin >> N;
	for (LL a = 1; a <= 3500; ++a)
	{
		for (LL b = 1; b <= 3500; ++b)
		{
			LL bunbo = 4 * a * b - N * b - N * a;
			LL bunsi = N * a * b;
			if (bunbo != 0 && bunsi % bunbo == 0)
			{
				LL c = bunsi / bunbo;
				if (c > 0)
				{
					cout << a << " " << b << " " << c << endl;
					return 0;
				}
			}
		}
	}
	return -1;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
#define rep_re(i,s,n)for(int i = n;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_M = 100001;

//////////////////////////////////////////////////
//nCr Calculation/////////////////////////////////
//////////////////////////////////////////////////
static const ll FACT_SIZE = 1000000;
ll fact[FACT_SIZE] = {};

ll Pow(ll n, ll p) {
	if (p == 0)return 1;
	if (p == 1)return n;
	ll t = Pow(n, p / 2);
	if (p & 1) return (t * t % MOD) * n % MOD;
	else return t * t % MOD;
}
void factorial(ll f) {
	fact[0] = fact[1] = 1;
	rep(i, 1, FACT_SIZE) fact[i] = fact[i - 1] * i % MOD;
}

ll nCr(ll n, ll r) {
	if (fact[0] == 0)	factorial(1000000);
	return ((fact[n] * (Pow(fact[r], MOD - 2) % MOD)) % MOD * Pow(fact[n - r], MOD - 2)) % MOD;
}
// Combination Table
ll C[51][51]; // C[n][k] -> nCk

void comb_table(int N) {
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= i; ++j) {
			if (j == 0 or j == i) {
				C[i][j] = 1LL;
			}
			else {
				C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
			}
		}
	}
}

ll v[51];
map<ll, ll> m;
int main() {
	comb_table(50);

	ll n, a, b; cin >> n >> a >> b;
	rep(i, 0, n) {
		cin >> v[i];
		m[v[i]]++;
	}
	sort(v, v + n);
	reverse(v, v + n);

	double ans = 0;
	rep(i, 0, a) {
		ans += v[i];
	}
	printf("%.7f\n", ans / a);

	ll minV = v[a - 1];
	ll M = m[minV];

	bool all = true;
	rep(i, 0, a) {
		if (minV != v[i]) {
			all = false;
			break;
		}
		//if (i > 0) {
		//	all &= (v[i] == v[i - 1]);
		//}
	}

	if (!all) {
		ll P = 0;
		rep(i, 0, a) {
			if (v[i] == minV) P++;
		}
		cout << C[M][P] << endl;
	}
	else {
		ll cnt = 0;
		//repe(i, a, b) cnt += C[n][i];
		repe(i, a, min(b, M)) cnt += C[M][i];
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    ll n,w;
    cin >> n >> w;
    vector<vector<ll>> v(4);
    ll w1,v1;
    cin >> w1 >> v1;
    v[0].push_back(v1);
    for(int i = 1; i < n; i++){
        ll x,y;
        cin >> x >> y;
        v[x-w1].push_back(y);
    }
    rep(i, 4)sort(ALL(v[i]), greater<ll>());

    ll dp[4][101] = {};
    rep(i, 4)rep(j, v[i].size())dp[i][j+1] = dp[i][j] + v[i][j];
 
    ll ans = 0;
    rep(i,v[0].size()+1)rep(j,v[1].size()+1)rep(k,v[2].size()+1)rep(l,v[3].size()+1){
        ll weight = w1*i + (w1+1)*j + (w1+2)*k + (w1+3)*l;
        if(weight > w) continue;
        ll value = dp[0][i] + dp[1][j] + dp[2][k] + dp[3][l];
        ans = max(ans, value);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
import heapq
INF = 1e9

H, W = map(int, input().split())

n = 10
adj_matrix = []

for i in range(n):
    c = list(map(int, input().split()))
    adj_matrix.append(c)

Adj_list = defaultdict(set)

for i in range(n):
    for j in range(n):
        Adj_list[i].add((j, adj_matrix[i][j]))


def dijkstra(x, vertex):
    d = [INF] * x
    d[vertex] = 0
    hq = [(0, vertex)]
    
    while hq:
        u = heapq.heappop(hq)[1]
        for (v, c) in Adj_list[u]:
            if d[v] > d[u] + c:
                d[v] = d[u] + c
                heapq.heappush(hq, (d[u]+c, v))

    return d

ans = INF
t_dis = 0

table = {}
for i in range(n):
    table[i] = dijkstra(n, i)


t_dis = 0

for i in range(H):
    l = list(map(int, input().split()))
    for j in range(W):
        if l[j] != -1:
            t_dis += table[l[j]][1]
            
print(t_dis)

Measured memory_bytes: 3444
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

    public static void main(String[] args) {

        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);

        String strN[] = new String[6];

        long lngNin = 0;
        long lngTime[] = new long[5];

        PrintWriter out = new PrintWriter(System.out);
        try {

        	for (int i=0 ; i < 6 ; i++) {
        		strN[i] = br.readLine();
        	}
        	lngNin = Long.parseLong(strN[0]);

        	int idx = 0;

        	for (int i=0 ; i < 5 ; i++) {
        		lngTime[i] =  Long.parseLong(strN[i+1]);

        		if (lngTime[idx] > lngTime[i]) idx = i;
        	}

        	long intResult = lngNin / lngTime[idx]  + 4 + (lngNin % lngTime[idx] == 0 ? 0 : 1);

//        	double dtmp =  Math.ceil((double)intNin / intTime[intMin]);
//        	long intResult = (long)dtmp + 4;

    		System.out.println(intResult);

            out.flush();


        } catch (IOException e) {

        }


    }

}

Measured memory_bytes: 22100
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                String s = sc.next();
                char[] x = new char[20];
                int idx = 0;
                for (int i = 0; i < s.length(); i++) {
                        if (s.charAt(i) == 'B') {
                                idx--;
                        } else {
                                if (idx < 0) {
                                        idx = 0;
                                }
                                x[idx] = s.charAt(i);
                                idx++;
                        }
                }
                for (int j = 0; j < idx; j++) {
                        System.out.print(x[j]);
                }
                System.out.println("");

        }
}

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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

ll dis[10000000];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	double b ;
	cin>>b;

	cout<<fixed<<setprecision(7)<<(double)(b*b*b)/27.0<<endl;
}


Measured memory_bytes: 256
N = int(input())
S = [int(input()) for _ in range(N)]

sum = 0
for s in S:
    sum += s

S.sort()
if sum % 10 != 0:
    print(sum)
else:
    for s in S:
        if s % 10 != 0:
            sum = sum - s
            break
    if sum % 10 == 0:
        print(0)
    else:
        print(sum)


Measured memory_bytes: 2940
N = int(input())
A = list(map(int, input().split()))

# 残り１、２、３枚の皿がi, j, k種類ある時に食べきるのに必要な回数をdpで求める
dp = [[[-1]*(N+1) for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 0

def mem_rec(i, j, k):
    if dp[i][j][k] != -1:
        return dp[i][j][k]
    
    ans = 0
    if i > 0:
        ans += mem_rec(i-1, j, k)*i
    if j > 0:
        ans += mem_rec(i+1, j-1, k)*j
    if k > 0:
        ans += mem_rec(i, j+1, k-1)*k
    ans += N
    ans /= i+j+k

    dp[i][j][k] = ans
    return ans

print(mem_rec(A.count(1), A.count(2), A.count(3)))

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

int main(){
  int n, taro, hanako;
  string a, b;

  cin >> n;

  taro = 0;
  hanako = 0;
  for(int i = 0; i < n; i++) {
    cin >> a >> b;
    if (a > b) {
      taro += 3;
    }
    else if (a < b) {
      hanako += 3;
    }
    else {
      taro += 1;
      hanako += 1;
    }
  }

  cout << taro << " " << hanako << endl;

  return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
ll MOD = 1e9+7;
ll MOD2 = 998244353;
int inf = 1e8;
ll INF = 1e16;
string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    map<int, ll> mp;
    rep2(i, 2, N){
        int j = 2, k = i;
        while(j*j <= k){
            while(k%j == 0){
                k /= j;
                mp[j]++;
            }
            j++;
        }
        if(k != 1){
            mp[k]++;
        } 
    }
    ll ans = 1;
    for(auto &e: mp){
        ans *= e.second+1, ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 100005;

ll n, x, y, a[N], ans;

int main()
{
	scanf("%lld%lld%lld",&n,&x,&y);
	for(ll i=0;i<n;i++) {
		scanf("%lld",&a[i]);
		if(i) ans += min((a[i]-a[i-1])*x,y);
	}
	printf("%lld\n",ans);
}


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

int main() {
	int N;
    cin >> N;
    int count = 0;
    for( int i=0; i < N; i++){
      int front, aft;
      cin >> front >> aft;
     count += aft -front +1;
         }
	cout << count ;	
}


Measured memory_bytes: 256
#include<stdio.h>

main(void)
{

    int i,roop=0;
    int x[10000];
    for(i=0;i<10000;i++){
        roop++;
        scanf("%d",&x[i]);
        if(x[i]==0) break;
    }
    for(i=0;i<roop;i++){
        printf("Case %d: %d\n",i+1,x[i]);
    }
}


Measured memory_bytes: 1928
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n,q;
    scanf(" %d %d", &n, &q);

    vector<int> u;
    map<int,vector<int>> IN,OUT;
    rep(i,n){
        int s,t,x;
        scanf(" %d %d %d", &s, &t, &x);
        IN[s-x].pb(x);
        OUT[t-x].pb(x);

        // printf(" [%d %d)\n", s-x,t-x);
        u.pb(s-x);
        u.pb(t-x);
    }

    set<int> ASK;
    rep(i,q){
        int d;
        scanf(" %d", &d);
        ASK.insert(d);
        u.pb(d);
    }

    sort(all(u));
    u.erase(unique(all(u)), u.end());

    set<int> X;
    for(int i:u){
        for(int j:OUT[i]) X.erase(j);
        for(int j:IN[i]) X.insert(j);

        if(ASK.count(i)){
            int ans = -1;
            if(!X.empty()) ans = *X.begin();
            printf("%d\n", ans);
        }
    }
    return 0;
}


Measured memory_bytes: 128492
A,B,M = gets.split.map &:to_i
a = gets.split.map &:to_i
b = gets.split.map &:to_i
m = Array.new(M){ 
  x,y,c = gets.split.map &:to_i
  [x-1, y-1, c]
}

# 割引券なしで一番安い組み合わせ
ans = a.min + b.min

# 各割引券について合計金額を求め、安ければ入れ替える
m.each do |x,y,c|
  cnt = a[x] + b[y] - c
  ans = [ans, cnt].min
end

puts ans

Measured memory_bytes: 18844
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

string t;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> t;
	
	for(int i = 0; i < t.size(); i++){
		if(t[i] == '?') t[i] = 'D';
	}
	cout << t << endl;
	
	return 0;
}

Measured memory_bytes: 3792
import sys
input = sys.stdin.readline
N,M,X = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
r = 0
l = 0
for i in range(M) :
    if X - A[i] > 0 :
        l+=1
    else :
        r+=1
print(min(r,l))

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
char st[200200];
int len,sum[200200];

int main()
{
	scanf("%s",st+1);
	len=strlen(st+1);
	for(int i=1;i<=len;i++) sum[st[i]-'a'+1]++;
	ll ans=(ll)len*(ll)(len-1)/2;
	for(int i=1;i<=len;i++){
		int c=st[i]-'a'+1;
		sum[c]--;
		ans-=sum[c];
	}
	printf("%lld\n",ans+1);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  vi x(n),y(n);
  rep(i,n){
    int a,b; cin >> a >> b;
    x[i] = a-b;
    y[i] = a+b;
  }
  sort(all(x));
  sort(all(y));
  cout << max(x.back()-x[0],y.back()-y[0]);
  cout << "\n";
  return 0;
}


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

#define ll long long
#define vi vector<int>
#define vc vector<char>
#define si set<int>
#define sc set<char>

using namespace std;
int main()
{
    int n;
    cin>>n;
    map<int,int>mp;
    set<string>s;
    vector<pair<string,int>>v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i].first>>v[i].second;
        s.insert(v[i].first);
        mp[v[i].second]=i+1;
    }
    for(auto e:s)
    {
        vector<int>ans;
        for(int i=0;i<v.size();i++)
        {
            if(e==v[i].first)
            {
                ans.push_back(v[i].second);
            }
        }
        sort(ans.begin(),ans.end(),greater<int>());
        for(auto f:ans)
        cout<<mp[f]<<endl;
        }
    return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    new_s=""
    i=0
    if n==0:
        print(0)
        sys.exit()
    while n:
        x=(n>>i)&1
        new_s=str(x)+new_s
        n-=x*(-2)**i
        i+=1
    print(new_s)


if __name__=='__main__':
    main()

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

#define rep(i, a, n) for(int i=(a);i<(n);++i)
#define per(i, a, n) for(int i=(a);i>(n);--i)
#define pb emplace_back
#define mp make_pair
#define lowbit(x) (x & -x)

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

const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1.0);

int n, ans;
LL d, x, y;

int main(){
	scanf("%d %lld", &n, &d);
	ans = 0;
	d = d * d;
	rep(i, 0, n){
		scanf("%lld %lld", &x, &y);
		if(x*x+y*y<=d)	ans++;
	}

	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3824
#include <iostream>
#include <iomanip>
using namespace std;
 
void call(int n); 
int main(){
 
int n;
cin >> n;
call(n);
 
 
return 0;
}
 
 
void call(int n){
  int i;
 
  for(i=1;i<=n;i++){
    int x=i;
    if(x%3==0){
        cout << " " << i;
    }else if(x%10==3){
        cout << " " << i;
    }else{
        while(x!=0){
            x /= 10;
            if(x%10==3){
                    cout << " " << i;
                    break;
            }
        }
    }
  }
  cout << endl;
}

Measured memory_bytes: 1160
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define pu push_back           
#define pp pop_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const int MOD=1e9+7 ;
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+2;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> ivc;
typedef pair<ll,ll> ipr;

int main()
{
    IOS();
  
    string s,t;
    cin>>s>>t;
    int i,j;
    bool a[26]={0},b[26]={0};
    vector<int> v[26];
    int ss=s.length(),tt=t.length();
    f(i,0,ss)
    {
        a[s[i]-'a']=1;
        v[s[i]-'a'].pu(i);
    }
    f(i,0,tt)
    {
      b[t[i]-'a']=1;
    }
    f(i,0,26)
    {
      if(b[i])
        if(!a[i])
        {
          cout<<-1;
          return 0;
        }
    }
    ll res=0,p=-1;
    f(i,0,tt)
    {
      
      auto z=upper_bound(all(v[t[i]-'a']),p);
            if(z!=v[t[i]-'a'].end())
            {
              p=*z;
                // cout<<*z<<'\n';//<<" "<<res;
            
            }
            else
            {
              p=-1;
              res++;
              i--;
            }
                // cout<<z;//<<" "<<res;

    }
    // cout<<p<<" "<<res;
    cout<<res*ss+p+1;

  return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int N,A,B,C;
char c[100000];
bool func(){
	string s;
	rep(i,0,N){
        cin>>s;
		if(s == "AB"){
			if(A == 0 && B == 0) return false;
			else if(A < B){ c[i] = 'A'; A++; B--; }
			else{ c[i] = 'B'; A--; B++; }
		}else if(s == "BC"){
			if(B == 0 && C == 0) return false;
			else if(B < C){ c[i] = 'B'; B++; C--; }
			else{ c[i] = 'C'; B--; C++; }
		}else if(s == "AC"){
			if(C == 0 && A == 0) return false;
			else if(C < A){ c[i] = 'C'; C++; A--; }
			else{ c[i] = 'A'; C--; A++; }
		}
	}
	return true;
}
int main(){
	cin>>N>>A>>B>>C;
	if(A + B + C == 2){
		string s[N];
		rep(i,0,N) cin>>s[i];
		rep(i,0,N){
			if(s[i] == "AB"){
				if(A == 0 && B == 0){ cout<<"No"<<endl; return 0; }
				else if(A < B){ c[i] = 'A'; A++; B--; }
				else if(A > B){ c[i] = 'B'; A--; B++; }
				else{
					if(i == N-1 || s[i+1] == "AB"){ c[i] = 'A'; A++; B--; }
					else if(s[i+1] == "BC"){ c[i] = 'B'; B++; A--; }
					else{ c[i] = 'A'; A++; B--; }
				}
			}else if(s[i] == "BC"){
				if(B == 0 && C == 0){ cout<<"No"<<endl; return 0; }
				else if(B < C){ c[i] = 'B'; B++; C--; }
				else if(B > C){ c[i] = 'C'; B--; C++; }
				else{
					if(i == N-1 || s[i+1] == "BC"){ c[i] = 'B'; B++; C--; }
					else if(s[i+1] == "AC"){ c[i] = 'C'; C++; B--; }
					else{ c[i] = 'B'; B++; C--; }
				}
			}if(s[i] == "AC"){
				if(C == 0 && A == 0){ cout<<"No"<<endl; return 0; }
				else if(C < A){ c[i] = 'C'; C++; A--; }
				else if(C > A){ c[i] = 'A'; C--; A++; }
				else{
					if(i == N-1 || s[i+1] == "AC"){ c[i] = 'C'; C++; A--; }
					else if(s[i+1] == "AB"){ c[i] = 'A'; A++; C--; }
					else{ c[i] = 'C'; C++; A--; }
				}
			}
		}
	}else{
		if(!func()){ cout<<"No"<<endl; return 0; }
	}
	cout<<"Yes"<<endl;
	rep(i,0,N) cout<<c[i]<<endl;
}

Measured memory_bytes: 6768
import math
N,D=map(int,input().split(' '))
X=[]
Y=[]
for i in range(N):
    x,y=map(int,input().split(' '))
    X.append(x)
    Y.append(y)
n=0
for i in range(N):
    if math.sqrt(X[i]**2+Y[i]**2)<=D:
        n=n+1
print(n)

Measured memory_bytes: 24916
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main(){
  int n,y,i,j,k;
  scanf("%d %d",&n,&y);
  for(i=n;i>=0;i--)
    for(j=n-i;j>=0;j--)
      if((i*10000+j*5000+(n-i-j)*1000)==y){
        printf("%d %d %d\n",i,j,n-i-j);
        return 0;
      }
  printf("%d %d %d\n",-1,-1,-1);
  return 0;    
}

Measured memory_bytes: 128
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
void solve()
{
	int n,sol;
	cin >> n;
	sol = 3 * n * n;
	cout << sol;
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    int d;
    cin>>d;
    if(d==25) cout<<"Christmas";
    if(d==24) cout<<"Christmas Eve";
     if(d==23) cout<<"Christmas Eve Eve";
      if(d==22) cout<<"Christmas Eve Eve Eve";
    
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(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 (b<a) { a=b; return 1; } return 0; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<60;
 
int main() {
	int N, M;
	cin >> N >> M;

	vector<tuple<int, int, int>> data(M);

	for (int i = 0; i < M; ++i) {
		int p, y;
		cin >> p >> y;
		data[i] = make_tuple(y, p, i);
	}


	sort(data.begin(), data.end());

	vector<int> cnt(N + 1);


	vector<pair<int, int>> id(M);

	for (int i = 0; i < M; ++i) {
		int y, p, idx;
		tie(y, p, idx) = data[i];
		++cnt[p];
		id[idx] = make_pair(p, cnt[p]);
	}

	for (int i = 0; i < M; ++i) {
		cout << setw(6) << setfill('0') << id[i].first;
		cout << setw(6) << setfill('0') << id[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll h, w;
  cin >> h >> w;
  vector <vector <ll>> v(h, vector <ll> (w));
  rep(i, h) {
    rep(j, w) {
      cin >> v.at(i).at(j);
    }
  }
  vector <vector <ll>> dp(h, vector <ll> (w));
  ll res = 0;
  rep(i, h) {
    rep(j, w) {
      if (i==0 && j==0) {
        if (v.at(i).at(j)) {
          dp.at(i).at(j) = 0;
        } else {
          dp.at(i).at(j) = 1;
          chmax(res, dp.at(i).at(j));
        }
      } else if (i==0 && j!=0) {
        if (v.at(i).at(j)) {
          dp.at(i).at(j) = 0;
        } else {
          dp.at(i).at(j) = 1;
          chmax(res, dp.at(i).at(j));
        }
      } else if (i!=0 && j==0) {
        if (v.at(i).at(j)) {
          dp.at(i).at(j) = 0;
        } else {
          dp.at(i).at(j) = 1;
          chmax(res, dp.at(i).at(j));
        }
      } else {
        if (v.at(i).at(j)) {
          dp.at(i).at(j) = 0;
        } else {
          dp.at(i).at(j) = min(dp.at(i-1).at(j-1), min(dp.at(i-1).at(j), dp.at(i).at(j-1))) + 1;
          chmax(res, dp.at(i).at(j));
        }
      }
    }
  }
  cout << res*res << endl;
}


Measured memory_bytes: 33428
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll a,b;
cin>>a>>b;
ll tmp=b-a;
ll sum=0;
for(int i=1;i<tmp;i++){
    sum+=i;
}
cout<<sum-a<<endl;
}












Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

int main()
{
  int n;
  cin >> n;
  ll a[100100];
  int parity = 0;
  ll minabs = 100000000000;
  ll ans = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    if (a[i] < 0)
    {
      parity++;
    }
    if (minabs > abs(a[i]))
    {
      minabs = abs(a[i]);
    }
    ans += abs(a[i]);
  }
  cout << (parity % 2 == 0 ? ans : ans - 2 * minabs) << "\n";
}

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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  for (int i = 0; i < N; i++) cin >> m[i];
  sort(m.begin(), m.end());
  int sum = 0, cnt = 0;
  for (int i = 0; i < N; i++) {
    sum += m[i];
    cnt++;
  }
  while (sum <= X) {
    sum += m[0];
    cnt++;
  }
  cout << cnt - 1 << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    LL N,K; cin >> N >> K;
    vector<pair<LL,LL>> ab(N);
    REP(i,N)
    {
        LL ta,tb; cin >> ta >> tb;
        ab[i] = make_pair(ta,tb);
    }

    sort(ab.begin(), ab.end());

    LL ans;
    LL acc = 0;

    REP(i,N)
    {
        acc += ab[i].second;
        if(acc >= K) 
        {
            ans = ab[i].first;
            break;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	int R,G;
	scanf("%d %d", &R, &G);

	int d = G-R;
	printf("%d\n", G+d);

	return 0;
}


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

int main(){
	int x, i, j, flag;
    cin >> x;
    for(i=x;i<=x+100;i++)
    {
        flag = 0;
        for(j=2;j<i/2;j++)
        {
			if(i%j==0){
                flag=1;
            }
		}
		if(flag==0) break;
	}
	cout << i;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> size;
    UnionFind(int N): par(N),size(N) {

         //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++){
            par[i] = i;
            size[i] = -1;
        }
            
    }
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        size[ry] += size[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    int getsize(int x){
        return -size[root(x)];
    }
};


int main(){
    int N,M;
    cin >> N >> M;
    vector<int> a(M),b(M);
    rep(i,M){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    int cnt = 0;
    rep(i,M){
        UnionFind tree(N);
        rep(j,M){
            if(j==i)continue;
            tree.unite(a[j],b[j]);
        }
        if(tree.getsize(0) != N) cnt++;
    }
    cout << cnt << endl;
}


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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    int N, tmp, ans = 0;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        if (i % 2 == 0 && tmp % 2 == 1)
            ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int H[21];
    int ans = 0;
    rep(i, N) cin >> H[i];
    rep(i, N) {
        bool ok = true;
        REP(j, 0, i - 1) {
            if (H[j] <= H[i]) continue;
            ok = false;
        }
        if (ok) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> s(N);
  vector<string> t(N);
  for(int i=0; i<N; i++) cin >> t.at(i) >> s.at(i);
  string X;
  cin >> X;
  int cnt;
  for(int i=0; i<N; i++){
    if(t.at(i)==X) cnt=i;
  }
  int ans=0;
  for(int i=cnt+1; i<N; i++) ans+=s.at(i);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {  
 long N=0, K=0;
  scanf("%ld%ld",&N,&K);

long f = N/K;
 N = N-f*K;

  while (1){
    long dif =N-K;

    if (dif < 0) dif *= -1;

    if (N >= dif) N = dif;
    else break;

  }

  printf ("%ld",N);
  
  return 0;
}

Measured memory_bytes: 128
N = int(input())
A = [int(input()) for _ in range(N)]
selected = [False for _ in range(N)]

a = 1
cnt = 0
while a != 2 and not selected[a - 1]:
    selected[a - 1] = True
    a = A[a - 1]
    cnt += 1
if a == 2:
    print(cnt)
else:
    print('-1')


Measured memory_bytes: 13852
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int N; cin>>N;
  if(N==1) cout	<< "Hello World" << endl;
  else {
    int	A, B; cin>>A>>B;
    cout << A+B	<< endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main()
{
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  a--;b--;c--;d--;
  string s;
  cin >> s;
  bool sharp = false;
  for(int i = a; i < c; i++) {
    bool now = s[i] == '#';
    if(sharp && now) {
      cout << "No" << endl;
      return 0;
    }
    sharp = now;
  }
  for(int i = b; i < d; i++) {
    bool now = s[i] == '#';
    if(sharp && now) {
      cout << "No" << endl;
      return 0;
    }
    sharp = now;
  }
  if (c < d) {
    cout << "Yes" << endl;
    return 0;
  } else {
    int cnt = 0;
    for(int i = b - 1; i <= d + 1; i++) {
      if (s[i] == '.') {
        cnt++;
        if (cnt >= 3) {
          cout << "Yes" << endl;
          return 0;
        }
      } else {
        cnt = 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


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


ll p = 1000000007, kai[200000+1];

ll pow(ll a, ll b){
ll c = a, d = 1;
while (b>0){
if (b%2==1){
d*=c;
d%=p;
}
c=c*c%p;
b/=2;
}
return d;
}

ll co(ll a,ll b){
return kai[a]*pow(kai[b],p-2)%p*pow(kai[a-b],p-2)%p;
}


int main(){
ll n,k;
cin >>n>>k;
kai[0]=1;
for (ll i=1;i<=n;i++){
kai[i]=kai[i-1]*i%p;}
k = min(n-1,k);
ll ans = 0;
for (ll i=0;i<=k;i++){
ans += co(n,i)*co(n-1,i);
ans%=p;
}
cout <<ans<<endl;
}

Measured memory_bytes: 1792
// ConsoleApplication7.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char* argv[])
{
	int i;
	int n;
	int a[100];

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (i = n-1; i >= 0; i--) {
		cout << a[i];
		if (i != 0) cout << " ";
	}
	cout << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> uup;
  vector<int> ddown;
  int sum = 0;

  for (int k = 0; k < n; k++) {
    int t;
    cin >> t;
    uup.push_back(t);
  }
  sum = uup[0];
  int max_sum = sum;

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

  for (int k = 1; k < n; k++) {
    for (int l = 1; l < n; l++) {
      if (l >= k) sum += ddown[l];
      else sum += uup[l];
    }
    if (max_sum < sum) max_sum = sum;
    sum = uup[0];
  }
  max_sum += ddown[(ddown.size()-1)];

  cout << max_sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define test() ull t;cin>>t;while(t--)
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define ins insert
#define nl cout<<endl
#define P 1000000007
#define MOD(x) ((x%P)+P)%P
#define NMAX 100100

#define INF 100000000
int mod=1e9;

int main() 
{


    ll n,w;
    cin>>n>>w;

    ll wg[n],v[n];
    ll t = 0;
    for(int i=0;i<n;i++)
    {
        cin>>wg[i]>>v[i];
        t+=v[i];
    }

    ll dp[t+1];
    for(int i=1;i<=t;i++)
        dp[i] = INT_MAX;
    dp[0]=0;

    for(int i=0;i<n;i++)
    {
        for(int j=t-v[i];j>=0;j--)
        {
            dp[j+v[i]] = min(dp[j+v[i]],dp[j]+wg[i]); 
        }
    }

    int ans=0;
    for(int i = 0;i<=t;i++)
    {
        if(dp[i] <= w)
        {
            ans=i;
        }
    }
    cout<<ans;
	return 0;
    	
}

















Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef pair <int,int> pii;
int N;
unordered_map <int, vector <pii>> edges;
unordered_map <int, int> vis;
unordered_map <int, int> indegree;
unordered_set <int> roots;
unordered_map <int, int> depth;
int INF = 0x3f3f3f3f;
int base = 1005;

int convertTo(pii a){ return a.first*base + a.second; }
pii convertFrom(int a){ return {a/base, a%base}; }

int dfs(pii v){
    int node = convertTo(v);
    vis[node] = 1;
    for (pii e: edges[node]){
        if (!vis[convertTo(e)]) depth[node] = max(depth[node], dfs(e)+1);
        else if (vis[convertTo(e)] == 2)
            depth[node] = max(depth[node], depth[convertTo(e)]+1);
        else depth[node] = INF;
    }
    vis[node] = 2;
    return depth[node];
}

int main() {
    cin >> N;
    int prev, cur;
    for (int i=1; i<=N; i++){
        scanf("%d", &prev);
        for (int j=3; j<=N; j++){
            scanf("%d", &cur);
            edges[convertTo({min(i, prev), max(i, prev)})].push_back({min(i, cur), max(i, cur)});
            indegree[convertTo({min(i, cur), max(i, cur)})]++;
            prev = cur;
        }
    }
    for (int i=1; i<=N; i++){
        for (int j=i+1; j<=N; j++){
            vis[convertTo({i,j})] = false;
        }
    }
    for (int i=1; i<=N; i++){
        for (int j=i+1; j<=N; j++){
            if (indegree[convertTo({i,j})] == 0) roots.insert(convertTo({i,j}));
        }
    }
    if (roots.empty()) {
        printf("-1\n");
    } else {
        int ans = 0;
        for (auto it: roots){
            ans = max(ans, dfs(convertFrom(it)));
        }
        if (ans >= INF) printf("-1\n");
        else printf("%d\n", ans+1);
    }
    return 0;
}

Measured memory_bytes: 102504
#include<iostream>
using namespace std;
int main() {
	int a, b, c, x, cnt = 0;
	cin >> a >> b >> c >> x;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (500 * i + 100 * j + 50 * k == x)cnt++;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, K = map(int, input().split())
    S = input()
    ret = 0
    for i in range(1,N-1):
        if (S[i]=='L' and S[i-1]=='L') or (S[i]=='R' and S[i+1]=='R'):
            ret += 1
    if S[0]=='R' and S[1]=='R':
        ret += 1
    if S[N-1]=='L' and S[N-2]=='L':
        ret += 1

    print(min(N-1,ret+2*K))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9320