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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

class modint {
  private:
    ll m_val;
    ll m_mod;
  public:
    constexpr modint() : m_val(0), m_mod() { m_mod = MOD; }
    constexpr modint(const ll x) : m_val(0), m_mod(0) { m_mod = MOD; m_val = x % m_mod; }
    constexpr modint(const ll x, const ll mod) : m_val(0), m_mod(0) { m_mod = mod; m_val = x % m_mod; }
    constexpr ll val() const { return m_val; }
    constexpr modint operator+(const modint &rhs) const { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const { return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint &rhs) {
      m_val += rhs.m_val;
      if (m_val >= m_mod) m_val -= m_mod;
      return *this;
    }
    constexpr modint &operator-=(const modint &rhs) {
      if (m_val < rhs.m_val) m_val += m_mod;
      m_val -= rhs.m_val;
      return *this;
    }
    constexpr modint &operator*=(const modint &rhs) {
      m_val = m_val * rhs.m_val % m_mod;
      return *this;
    }
    constexpr modint &operator/=(const modint &rhs) {
      *this *= rhs.inv();
      return *this;
    }
    constexpr modint pow(ll n) const {
      if (n == 0) return 1;
      modint o = pow(n >> 1);
      o *= o;
      if (n & 1) o *= *this;
      return o;
    }
    constexpr modint inv() const {
      return pow(m_mod - 2);
    }
    friend ostream& operator<<(ostream& os, const modint &a) { os << a.val(); return os; }
};

struct combination {
  vector<modint> fact, ifact;
  combination(ll n): fact(n+1), ifact(n+1) {
    fact[0] = 1;
    for (ll i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (ll i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  modint operator()(ll n, ll k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n-k];
  }
};

int main() {
  ll x, y;
  cin >> x >> y;

  ll n = 0, m = 0;
  n = (2*x-y)/3;
  m = (2*y-x)/3;

  if (n < 0 || m < 0 || (x+y)%3 != 0) {
    cout << 0 << endl;
    return 0;
  }

  combination comb(n+m);
  cout << comb(n+m, n) << endl;

  return 0;
}


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

#define endl '\n'
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define add push_back
#define MAXN 200005

int main(){ios_base::sync_with_stdio(false);

    ll n=100, x;
    cin >> x;
    
    int cnt = 0;
    while(n<x){
        n += (n/100);
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 3596
N, M, X, Y = map(int, input().split())		# 5 7

x = sorted(list( map(int, input().split()) ))	# 1 2 3 4 5 ...(ソート付き)
y = sorted(list( map(int, input().split()) ))	# 1 2 3 4 5 ...(ソート付き)

x.append(X)
x.sort()

y.append(Y)
y.sort()


if x[N]<y[0]:
	print("No War")
else:
	print("War")


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

int main (void) {
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for (int i = 0; i < N; i ++) {
        cin >> H.at(i);
    }
    
    vector<int> max_h(N, 0);
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        max_h.at(A-1) = max(H.at(B-1), max_h.at(A-1));
        max_h.at(B-1) = max(H.at(A-1), max_h.at(B-1));
    }
    
    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += (max_h.at(i) < H.at(i));
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3956
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	Int ans = 0;

	vector<Int> v(N);
	vector<Int> c(N);
	for (Int i = 0; i < N; i++) {
		cin >> v[i];
	}
	for (Int i = 0; i < N; i++) {
		cin >> c[i];
	}

	for (Int i = 0; i < N; i++) {
		if (v[i]-c[i]>0){
			ans += v[i] - c[i];
		}
	}
	cout << ans << "\n";

}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}

int main() {
  int a,b;
  cin>>a>>b;
  if(a%b==0) cout<<-1<<endl;
  else cout<<a<<endl;
}


Measured memory_bytes: 256
s = input()
q = int(input())

front = ''
back = ''
rv = False
for i in range(q):
    line = input()
    if line[0] == '1':
        rv = not rv
    else:
        ti, fi, ci = line.split()
        if (fi == '1' and rv) or (fi == '2' and not rv):
            back += ci
        else:
            front += ci

if rv:
    s = back[::-1] + s[::-1] + front
else:
    s = front[::-1] + s + back
print(s)


Measured memory_bytes: 4340
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>

#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int


int solve( ){
 
int n,k;
cin>>n>>k;
vi a(n);
rep(i,0,n)cin>>a[i];
sort(all(a));
int mn=hell;
for(int i=0;i<=n-k;i++)
{
  mn=min(mn,abs(a[i+k-1]-a[i]));
}
cout<<mn;



return 0;
}
int main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
  
   
  
  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;
   while(t--)
     {solve();
     }

         time_req = clock() - time_req;
   // cout << "Processor time taken is "
      // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}


Measured memory_bytes: 640
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip>
#include<map>
using namespace std;
map<string, bool>p;
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    long long n; string s;
    while (cin >> n)
    {
        int flag = 0;
        while (n--)
        {
            cin >> s;
            if (p[s]) flag = 1;
            p[s] = true;
        }
        if (flag) cout << "NO\n";
        else cout << "YES\n";
    }
}



Measured memory_bytes: 22144
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		StringBuilder a = new StringBuilder(scanner.nextLine());
		int b = Integer.parseInt(scanner.nextLine());
		for (int i = 0; i < b; i++) {
			String[] c = scanner.nextLine().split(" ");
			int d = Integer.parseInt(c[1]);
			int e = Integer.parseInt(c[2]) + 1;
			if (c[0].equals("print")) {
				System.out.println(a.substring(d, e));
			} else if (c[0].equals("reverse")) {
				StringBuilder builder = new StringBuilder(a.substring(d, e))
						.reverse();
				a.replace(d, e, builder.toString());
			} else {
				a.replace(d, e, c[3]);
			}

		}
	}
}

Measured memory_bytes: 21696
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 4000000000000000000
int dx8[8]={-1,0,1,1,1,0,-1,-1};
int dy8[8]={1,1,1,0,-1,-1,-1,0};
int dx4[4]={-1,0,1,0};
int dy4[4]={0,-1,0,1};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int uni[100010];
int root(int a){
    if(uni[a]<0)return a;
    return uni[a]=root(uni[a]); 
}
bool connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return false;
    if(uni[a]>uni[b]){
        swap(a,b);
    }
    uni[a]=uni[a]+uni[a];
    uni[b]=a;
    return true;
}
signed main(void){
    int n,m;cin>>n>>m;
    vector<char>V(n,'.');
    rep(i,m){
        int s;char c;cin>>s>>c;
        s--;
        if(V[s]=='.')V[s]=c;
        else{
            if(V[s]!=c){
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    if(n>1&&V[0]=='0'){
        cout<<-1<<endl;
        return 0;
    }
    if(n==1&&V[0]=='.'){
        cout<<0<<endl;
        return 0;
    }
    string s="";
    rep(i,n){
        if(i==0&&V[0]=='.')s+='1';
        else{
            if(V[i]=='.')s+='0';
            else s+=V[i];
        }
    }
    cout<<s<<endl;
}
        


Measured memory_bytes: 256
x = int(input())

if x>= 400 and x<=599:
    print('8')
    
elif x>= 600 and x<= 799:
    print('7')
    
elif x>= 800 and x<= 999:
    print('6')
    
elif x>= 1000 and x<= 1199:
    print('5')
    
elif x>= 1200 and x<= 1399:
    print('4')
    
elif x>= 1400 and x<= 1599:
    print('3')
    
elif x>= 1600 and x<= 1799:
    print('2')

elif x>= 1800 and x<= 1999:
    print('1')

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n,x;cin >>n>>x;
    ll ans=0;
    for (int i = 0; i < n; ++i) {
        ll a;cin >>a;
        a=abs(a-x);
        ans=__gcd(ans,a);
    }
    cout <<ans <<endl;
    return 0;
}

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

int P[10010]; // 親たち
int n, q;

void init() {
  for (auto i=0; i<n; i++) {
    P[i] = i;
  }
}

int root(int a) {
  if (P[a] == a) return a;
  return (P[a] = root(P[a]));
}

bool issame(int a, int b) {
  return root(a) == root(b);
}

void unite(int a, int b) {
  P[root(a)] = root(b);
}

int main() {
  cin >> n >> q;
  init();
  for (auto i=0; i<q; i++) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com == 0) { // unite(x, y)
      unite(x, y);
    } else { // issame(x, y)
      if (issame(x, y)) {
	cout << 1 << endl; 
      } else {
	cout << 0 << endl;
      }
    }
  }
}

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

int main(){
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	rep(i,3) {
		if (a[i]%2==0) {
			cout << 0 << endl;
			return 0;
		}
	}
	int d = a[2]/2, u = a[2] - d;
	ll ans = (u-d)*(ll)a[0]*(ll)a[1];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3540
S = input()
S1 = int(S[:2])
S2 = int(S[2:])

if 1<=S1<=12 and 1<=S2<=12:
    print('AMBIGUOUS')
elif 1<=S1<=12:
    print('MMYY')
elif 1<=S2<=12:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <cmath>
using namespace std;

int main(){
	vector<int> a(100,0);
	int n,i;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	int flag=1;
	int count=0;
	while(flag){
		flag=0;
		for(int j=n-1;j>=1;j--){
			if(a[j]<a[j-1]){
				int temp=a[j-1];
				a[j-1]=a[j];
				a[j]=temp;
				count++;
				flag=1;
			}

		}
	}
	for(i=0;i<n;i++){
		if(i==n-1)cout<<a[i]<<endl;
		else cout<<a[i]<<" ";
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>   
#include<tr1/unordered_map>
#define ll long long int  
#define mkp make_pair 
#define mod 1000000007 
#define maxn 1000002 
#define ff first
#define ss second 
using namespace std;      

int main(){    
  ios_base::sync_with_stdio(false);  
  cin.tie(NULL);       
  string s,t; 
  cin>>s>>t; 
  int n=s.size(); 
  int m=t.size();  
  int ans=INT_MAX; 
  int cur=0;
  for(int i=0;i<=n-m;++i){   
        cur=0;
        for(int j=0,k=i;j<m;++j,++k){  
             if(s[k]!=t[j])++cur;
        } 
      ans=min(ans,cur);
    }
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 3636
def game(t, s)
  cnt = 0
  (1...s.size).each do |i|
    l = s[i - 1]; r = s[i]
    l, r = r, l if t == 1
    if r % 3 == 1 && l % 3 != 1 || r % 3 == 2 && l % 3 == 0
      cnt += 1
    else t = 1 - t
    end
  end
  cnt
end

while s = gets.chomp
  break if s == '#'
  s = s.split('').map(&:to_i)
  p [game(0, s), game(1, s)].min
end

Measured memory_bytes: 15768
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	_ = sc.NextInt()
	s := sc.NextLine()

	mp := map[string]int{}
	for i := 0; i < len(s); i++ {
		mp[string(s[i])]++
	}
	sum := 1
	for _, v := range mp {
		sum *= (v + 1)
		sum %= (1000000007)
	}

	fmt.Printf("%v\n", (sum-1)%(1000000007))
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

using namespace std;

int main() {
    char c;
    cin >> c;
    char t;
    if (c == 'A') {
        t = 'T';
    }
    else if (c == 'T') {
        t = 'A';
    }
    else if (c == 'C') {
        t = 'G';
    }
    else if (c == 'G') {
        t = 'C';
    }

    cout << t << endl;
}

Measured memory_bytes: 3580
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());

    cout << (s < t ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define int ll
#define Endl endl

signed main(void){
    int N,K;
    cin >> N >> K;
    
    double Ans=0;
    
    for(int i=1;i<=N;i++){
        int t=i;
        double ad=1.0;
        while(t<K){
            t*=2;
            ad/=2.0;
        }
        Ans+=ad;
    }
    printf("%.14f",Ans/(double)N);
    
    return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);

        int total = (a*100) + (b*10) + c;

        if (total%4 == 0)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }

    }
}


Measured memory_bytes: 27464
#include <stdio.h>

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

  long int l[n];
  for(int i=0;i<n;i++){
    scanf("%ld", &l[i]);
  }

  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++){
	if((l[i]<l[j]+l[k]) && (l[j]<l[k]+l[i]) && (l[k]<l[i]+l[j])){
	  if((l[i]!=l[j]) && (l[j]!=l[k]) && (l[k]!=l[i])){
	    ans++;
	  }
	}
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 1732
import numpy as np

N = int(input())
mod = 10 ** 9 + 7

dp = np.zeros((N+1, 4, 4, 4), dtype=np.int64)

dp[0][3][3][3] = 1
for i in range(N):
    for c1 in range(4):
        for c2 in range(4):
            for c3 in range(4):
                if dp[i][c1][c2][c3] == 0:
                    continue
                for a in range(4):
                    if c1 == 0 and c2 == 1 and a == 2:
                        continue
                    if c2 == 0 and c3 == 1 and a == 2:
                        continue
                    if c2 == 1 and c3 == 0 and a == 2:
                        continue
                    if c2 == 0 and c3 == 2 and a == 1:
                        continue
                    if c1 == 0 and c3 == 1 and a == 2:
                        continue
                    dp[i+1][c2][c3][a] += dp[i][c1][c2][c3]
                    dp[i+1][c2][c3][a] %= mod

ans = 0
for c1 in range(4):
    for c2 in range(4):
        for c3 in range(4):
            ans += dp[N][c1][c2][c3]
            ans %= mod
print(ans)

Measured memory_bytes: 12508
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int N, K;
    string S;
    cin >> N >> K >> S;
    REP (i, N) {
        if (i + 1 == K) cout << char(S[i] + 'a' - 'A');
        else cout << S[i];
    }
    cout << endl;
}

signed main(signed argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

using namespace std;
typedef long long ll;
const int Maxn = 1e6 + 5;
int N, Q, M, Cnt;
int A, B, C;
ll Ans;
struct Node
{
    int A, B, C;
    bool operator < (const Node &Temp) const
    {
        return C < Temp.C;
    }
}Edge[Maxn];
int H[Maxn], F[Maxn];

int Find(int X)
{
    if (X == F[X]) return X;
    return F[X] = Find(F[X]);
}

int main()
{
    memset (H, 127, sizeof H);
    scanf ("%d %d", &N, &Q);
    for (int i = 1; i < N; ++i) F[i] = i;
    for (int i = 0; i < Q; ++i)
    {
        scanf ("%d %d %d", &A, &B, &C);
        Edge[++Cnt] = Node{A, B, C};
        H[A + 1] = min(H[A + 1], C + 1);
        H[B + 1] = min(H[B + 1], C + 2);
    }
    for (int i = 1; i < (N << 1); ++i) H[i] = min(H[i], H[i - 1] + 2);
    for (int i = 1; i < (N << 1); ++i)
    {
        A = i % N, B = (i - 1) % N;
        Edge[++Cnt] = Node{A, B, H[i]};
    }
    sort (Edge + 1, Edge + Cnt + 1);
    for (int i = 1; i <= Cnt; ++i)
    {
        A = Edge[i].A, B = Edge[i].B, C = Edge[i].C;
        int FA = Find(A), FB = Find(B);
        if (FA != FB) Ans += C, F[FA] = FB;
    }
    printf ("%lld\n", Ans);
}

Measured memory_bytes: 15440
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

using fint64 = int_fast64_t;
template<fint64 MOD>
struct ModInt {
	fint64 x;
	ModInt():x(0){}
	ModInt(fint64 x):
		x(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD)
		{}
	// 負号
	ModInt operator -() const{
		return ModInt(-x);
	}
	// 加算
	ModInt &operator +=(const ModInt &rhs){
		x+=rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator +(const ModInt &rhs) const{
		return ModInt(*this)+=rhs;
	}
	// 減算
	ModInt &operator -=(const ModInt &rhs){
		x+=MOD-rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator -(const ModInt &rhs) const{
		return ModInt(*this)-=rhs;
	}
	// 乗算
	ModInt &operator *=(const ModInt &rhs){
		x*=rhs.x;
		if(x>=MOD) x%=MOD;
		return (*this);
	}
	ModInt operator *(const ModInt &rhs) const{
		return ModInt(*this)*=rhs;
	}
	// 除算
	ModInt &operator /=(const ModInt &rhs){
		(*this)*=rhs.inverse();
		return (*this);
	}
	ModInt operator /(const ModInt &rhs) const{
		return ModInt(*this)/=rhs;
	}
	// 等号
	bool operator ==(const ModInt &rhs){
		return x==rhs.x;
	}
	bool operator !=(const ModInt &rhs){
		return x!=rhs.x;
	}
	// 累乗
	ModInt pow(fint64 n) const{
		fint64 tmp=x;
		fint64 ret=1;
		while(n>0){
			if(n&1) ret=ret*tmp%MOD;
			tmp=tmp*tmp%MOD;
			n>>=1ll;
		}
		return ModInt(ret);
	}
	// 逆元
	ModInt inverse() const{
		fint64 a=x,b=MOD,s=1,t=0;
		while(b>0){
			fint64 u=a/b;
			a-=u*b;
			s-=u*t;
			swap(a,b);
			swap(s,t);
		}
		return ModInt(s);
	}
	// 入出力
	friend istream &operator >>(istream &lhs,ModInt<MOD> &rhs){
		fint64 x; lhs>>x;
		rhs=ModInt<MOD>(x);
		return lhs;
	}
	friend ostream &operator <<(ostream &lhs,const ModInt<MOD> &rhs){
		return lhs<<rhs.x;
	}
};

struct Combination {
	const int MAX = 5000010;
	const int MOD;
	vector<fint64> FAC;
	vector<fint64> INV;
	vector<fint64> FAC_INV;
	Combination(fint64 MOD) :
		MOD(MOD),
		FAC(vector<fint64>(MAX)),
		INV(vector<fint64>(MAX)),
		FAC_INV(vector<fint64>(MAX))
		{
			FAC[0] = INV[1] = FAC_INV[0] = 1;
			for(int i = 1; i < MAX; ++i) {
				FAC[i] = FAC[i - 1] * i % MOD;
				if(i > 1) INV[i] = MOD - INV[MOD % i] * (MOD / i) % MOD;
				FAC_INV[i] = FAC_INV[i - 1] * INV[i] % MOD;
			}
		}
	fint64 C(int n, int r) {
		if(n < 0 or r < 0 or n < r) return 0;
		return FAC[n] * FAC_INV[r] % MOD * FAC_INV[n - r] % MOD;
	}
	fint64 P(int n, int r) {
		if(n < 0 or r < 0 or n < r) return 0;
		return FAC[n] * FAC_INV[n - r] % MOD;
	}
	fint64 H(int n, int r) {
		if(r == 0) return 1;
		return C(n + r - 1, r);
	}
};

using mint = ModInt<MOD>;
int main() {
	Combination com(MOD);
	int n, a, b; cin >> n >> a >> b;
	mint ans = 2;
	ans = ans.pow(n);
	ans -= 1;
	mint A = 1;
	for(int i = 1; i <= a; ++i) {
		A *= (n - (i - 1));
		A /= i;
	}
	ans -= A;
	mint B = 1;
	for(int i = 1; i <= b; ++i) {
		B *= (n - (i - 1));
		B /= i;
	}
	ans -= B;
	cout << ans << '\n';
	return 0;
}

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

int main() {
  int N, T;
  cin >> N >> T;

  int c, t;
  int c_min = 1001;
  for(int i=0; i < N; i++) {
    cin >> c >> t;
    if (t <= T && c < c_min) {
      c_min = c;
    }
  }
  if (c_min == 1001) {
    cout << "TLE" << endl;
  } else
  {
    cout << c_min << endl;
  }
}


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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

i64 k;

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

	cin >> k;
	if (k <= 9) {
		cout << k << '\n';
		return 0;
	}
	queue<i64> q;
	for1(i, 9) 	q.push(i);
	i64 cnt = 0;
	while (true) {
		i64 now = q.front();
		q.pop();
		++cnt;
		if (cnt == k) {
			cout << now << '\n';
			break;
		}
		i64 final = now%10;
		if (final == 0) {
			q.push(now*10);
			q.push(now*10+1);
		} else if (final == 9) {
			q.push(now*10+8);
			q.push(now*10+9);
		} else {
			q.push(now*10+final-1);
			q.push(now*10+final);
			q.push(now*10+final+1);
		}
	}

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var N int
	var A, B, C string
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)
	scanner.Scan()

	fmt.Sscanf(scanner.Text(), "%s", &A)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%s", &B)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%s", &C)

	ans := 0
	for i := 0; i < N; i++ {
		mp := make(map[string]int)
		mp[string(A[i])]++
		mp[string(B[i])]++
		mp[string(C[i])]++
		list := make([]int, 0)
		for _, v := range mp {
			list = append(list, v)
		}
		sort.Sort(sort.Reverse(sort.IntSlice(list)))
		ans = ans + 3 - list[0]
	}
	fmt.Println(ans)

}


Measured memory_bytes: 640
import sys

n = int(input())
h = list(map(int, input().split()))

def main():
  for i in reversed(range(n-1)):
    if h[i] - h[i+1] > 1:
      return False
      exit()
    elif h[i] - h[i+1] == 1:
      h[i] -= 1
    else:
      continue
  return True

if main() == True:
  print('Yes')
  sys.exit()

h[n-1] -= 1

if main() == True:
  print('Yes')

else:
  print('No')

Measured memory_bytes: 20472
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
const int N = 3e5+7;

int r[N],c[N];
map<PII,int> mp;

int main()
{
	int n,m,k,x,y;
	scanf("%d%d%d",&n,&m,&k);
	int xx=0,yy=0;
	for(int i=0;i<k;i++){
		scanf("%d%d",&x,&y);
		mp[make_pair(x,y)]=1;
		r[x]++,c[y]++;
		xx = max(xx,r[x]);
		yy = max(yy,c[y]);
	}
	vector<int> vx,vy;
	for(int i=1;i<=n;i++) if(r[i]==xx) vx.push_back(i);
	for(int i=1;i<=m;i++) if(c[i]==yy) vy.push_back(i);
	int flag=0;
	for(int i=0;i<vx.size();i++){
		for(int j=0;j<vy.size();j++){
			if(!mp[make_pair(vx[i],vy[j])]){
				flag=1; break;
			}
		}
		if(flag) break;
	}
	if(flag) cout<<xx+yy<<"\n";
	else cout<<xx+yy-1<<"\n";
	return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

int main() {
  llong N, A, B;
  vector<llong> X;

  cin >> N >> A >> B;
  X.resize(N);
  for (auto &in: X) {
    cin >> in;
  }

  llong ans1 = 0, ans2 = B;
  for (int i = 1; i < N; i++) {
    ans1 += min(B, A * (X[i] - X[i - 1]));
  }
  for (int i = N - 2; i >= 1; i--) {
    ans2 += min(B, A * (X[i + 1] - X[i]));
  }

  cout << min(ans1, ans2) << endl;

  return 0;
}

Measured memory_bytes: 4056
#include <stdio.h>

int main(){
  int H=1,W=1;
  int h,w;

  while(1){
    scanf("%d%d", &H, &W);
    if(H==0 && W==0)
      break;
    for(h=0;h<H;h++){
      for(w=0;w<W;w++)
	if(h == 0 || w == 0 || h == H-1 || w == W-1)
	  printf("#");
	else
	  printf(".");
      printf("\n");
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 572
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad
import Data.Graph


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


toTup [a,b] = (a,b)


main :: IO ()
main = do
    [n,m] <- r'
    inps <- filter (>1) . map (length . components . toBiGraph n) . holed [] . map toTup <$> replicateM m r'
    print $ length inps

flipTup :: Edge -> Edge
flipTup (a,b) = (b,a)

toBiGraph :: Vertex -> [Edge] -> Graph
toBiGraph n xs = buildG (1,n) (map flipTup xs ++ xs)

holed ac []     = []
holed ac (x:xs) = (ac++xs):(holed (x:ac) xs)

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    ll n;
    cin >> n;

    if (n == 0) {
        put('0');
    }

    string s = "";
    ll r = 1;
    while (n != 0) {
        s.push_back('0' + (n % abs(r * 2) == 0 ? 0 : 1));
        n -= r * (n % abs(r * 2) == 0 ? 0 : 1);
        r *= -2;
    }

    reverse(all(s));
    put(s);

    return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;


int main(int argc, char *argv[]) {
	int n, m;
	cin >> n >> m;
	if (n == m)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}









Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

type pair struct {
	a int
	b int
}

type pairs []*pair

func (p pairs) Len() int {
	return len(p)
}

func (p pairs) Less(i, j int) bool {
	return p[i].a < p[j].a
}

func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	var v pairs
	for i := 0; i < N; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		v = append(v, &pair{a: a, b: b})
	}
	sort.Sort(v)

	sumbuy := 0
	money := 0
	for i := 0; i < N; i++ {
		nokori := M - sumbuy
		buy := min(v[i].b, nokori)
		money += v[i].a * buy
		sumbuy += buy
	}
	fmt.Println(money)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


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

int main(){
  long long N, K; cin >> N >> K;
  long long a = pow(N/K, 3), b = pow(2*N/K - N/K, 3);
  if(K%2 != 0){
    cout << a << endl;
  }
  else{
    cout << a + b << endl;
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    N, M, C = map(int, input().split())
    B = list(map(int, input().split()))
    A = [list(map(int, input().split())) for _ in range(N)]

    ans = 0
    for i in range(N):
        if sum([A[i][j]*B[j] for j in range(M)]) + C > 0:
            ans += 1

    print(ans)    
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
//!******************************************************
//! MEMO
//! 包除原理
//!******************************************************

#include <bits/stdc++.h>

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

class Prime {
public:
    Prime(ll n) {
        mPrimeTbl.clear();
        vector<bool> u(n, false);
        for (ll i = 2; i <= n; ++i) {
            if (u[i])
                continue;
            mPrimeTbl.push_back(i);
            for (ll p = i; p <= n; p += i)
                u[p] = true;
        }
    }

    ~Prime() {}

    ll num() {
        return static_cast<ll>(mPrimeTbl.size());
    }

    ll get(ll index) {
        return mPrimeTbl[index];
    }

private:
    vector<ll> mPrimeTbl;
};

int main() {
    ll N;
    cin >> N;
    Prime prime(100005);

    vector<ll> v;
    ll t = N;
    REP(i, prime.num()) {
        ll p = prime.get(i);
        ll n = 0;
        while (t % p == 0) {
            t /= p;
            n++;
        }
        if (n > 0)
            v.push_back(p);
    }

    if (t > 1)
        v.push_back(t);

    ll ans = N;
    FOR(i, pow(2LL, v.size()), 1) {
        ll p = 1;
        ll m = 0;
        REP(j, v.size()) {
            if ((i >> j) & 1) {
                p *= v[j];
                m++;
            }
        }

        ll n = N / p;
        if (m % 2 == 1)
            ans -= n;
        else
            ans += n;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n){
    cin>>a[i];
  }
  int x=a[0];
  rep2(i,1,n)x^=a[i];
  rep(i,n){
    cout<<(x^a[i])<<endl;
  }
  return(0);
}

Measured memory_bytes: 3960
#include <stdio.h>
int main(){
  int n;
  float c,z;
  scanf("%d",&n);
  if(n%2==0){
    c=n/2;
    
  }
  else{
    c=(n/2 +1);
  }
 
  z=c/n;
 
  printf("%f",z);
  return 0;
}

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

using namespace std;
 
const int price[7][7] = {
    {-1, 300, 500, 600, 700, 1350, 1650},
    {-1, -1, 350, 450, 600, 1150, 1500},
    {-1, -1, -1, 250, 400, 1000, 1350},
    {-1, -1, -1, -1, 250, 850, 1300},
    {-1, -1, -1, -1, -1, 600, 1150},
    {-1, -1, -1, -1, -1, -1, 500}
};
 
const int dist[7][7] = {
    {-1, 6, 13, 18, 23, 43, 58},
    {-1, -1, 7, 12, 17, 37, 52},
    {-1, -1, -1, 5, 10, 30, 45},
    {-1, -1, -1, -1, 5, 25, 40},
    {-1, -1, -1, -1, -1, 20, 35},
    {-1, -1, -1, -1, -1, -1, 15}
};
 
int start = 17*60 + 30, end = 19*60 + 30;
 
int main()
{
    int sIC, sh, sm, tIC, th, tm;
 
    while (scanf("%d", &sIC) ,sIC) {
	scanf("%d%d", &sh ,&sm);
	scanf("%d%d%d", &tIC ,&th ,&tm);
 
	sIC--; tIC--;
	bool ok1 = 0, ok2 = 0;
	int ssum = sh*60 + sm, tsum = th*60 + tm;
 
	if ((start <= ssum && ssum <= end) ||
	   (start <= tsum && tsum <= end)) ok1 = 1;
 
	if (dist[sIC][tIC] <= 40) ok2 = 1;
  
	int ans = price[sIC][tIC];
	if (ok1 && ok2) {
	    ans = (ans / 50 + 1) / 2;
	    ans *= 50;
	}
	printf("%d\n" ,ans);
    }
    return 0;
}

Measured memory_bytes: 1188
import java.util.*;
import java.util.Map.Entry;



public class Main{

	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}



	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}


	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}


	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}


	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 int N=sc.nextInt();
	 int[] A=new int[N];
	 int[] B=new int[N];
	 int resultmax=0;
	 for(int i=0;i<N;i++) {
		 A[i]=sc.nextInt();
	 }
	 for(int i=0;i<N;i++) {
		 B[i]=sc.nextInt();
	 }
	 
	 for(int i=0;i<N;i++) {
		 int result=0;
		 for(int j=0;j<N;j++) {
			 if(j<i) {
				 result+=A[j];
			 }else if(j==i) {
				 result+=(A[j]+B[j]);
			 }else if(j>i) {
				 result+=B[j];
			 }
		 }
		 
		 if(result>resultmax) {
			 resultmax=result;
		 }
		 
	 }
	 
	 System.out.println(resultmax);
	 
 }
	


}


Measured memory_bytes: 21972
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
	int n;
	cin >> n;
	Vi A(n);
	rep(i, n) cin >> A[i];
	int ans = 0;
	for (int i = 0; i < n; i += 2) {
		if (A[i] % 2 == 1) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007
//#define DEBUG

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(array, 10, sizeof(int), compare_int)

int main(){
	int n, lim;
	scanf("%d", &n);
	for(int i=1; i<=5; i++){
		if(i>n) break;
		printf("0\n");
	}
	
	lim = pow(n, 0.5) + 1;
	for(int i=6; i<=n; i++){
		int count=0;
		for(int x=1; x<=lim; x++){
			for(int y=1; y<=lim; y++){
				if(x*x+y*y+x*y>i) break;
				for(int z=1; z<=lim; z++){
					int tmp1 = pow(x+y+z, 2)-(x*y+y*z+z*x);
					if(tmp1==i) count++;
					else if(tmp1>i) break;
				}
			}
		}
		//printf("i:%d, count:%d\n", i, count);
		printf("%d\n", count);
	}
	
	
	return 0;
}



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

int main(){
    string s, t;
    int a, b;
    string u;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (s == u) {
        cout << a - 1 << " " << b << endl;
    }
    if (t == u) {
        cout << a << " " << b - 1 << endl;
    }
    return 0;
}

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

int a[100010],b[100010],j1,j2,j11,j22,o1,o2,o11,o22;

int main(){
	int n,x;
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>x;
		if(i%2==1){
			a[x]++;
			if(x==j11){
				j1++;
				continue;
			}
			if(a[x]>=j1){
				j2=j1;
				j22=j11;
				j1=a[x];
				j11=x;
				continue;
			}
				if(a[x]>j2 && a[x]<j1){
					j2=a[x];
					j22=x;
					continue;
				}
		}
		if(i%2==0){
			b[x]++;
			if(x==o11){
				o1++;
				continue;
			}
			if(b[x]>=o1){
				o2=o1;
				o22=o11;
				o1=b[x];
				o11=x;
				continue;
			}
				if(b[x]>o2 && b[x]<o1){			
					o2=b[x];
					o22=x;
					continue;
				}
		}
	}
	if(j11!=o11)	cout<<n-j1-o1;
	else			cout<<n-max(j1+o2,j2+o1);
}

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

	int main(){
      int K,S;
      cin >> K >> S;
      int A=0;
      for (int i=S-min(K,S);i<=min(2*K,S);i++){
        A+=min(K,i)-max(0,i-K)+1;
      }
      cout << A;
    }


Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<ctime>
#include<cmath>
#include<deque>
#include<queue>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
#define _rep(i,s,t) for(register int i=s;i>=t;--i)
#define Rep(i,s,t) for(register int i=s;i<t;++i)
#define go(x) for(register int e=las[x];e;e=nxt[e])
#define re register
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define is insert
#define es erase
#define pii pair<int,int>
#define ms(f,x) memset(f,x,sizeof f)
#define mc(f,x) memcpy(f,x,sizeof f)
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
#define gi(x) read(x)
#define gii(x,y) read(x),read(y)
#define giii(x,y,z) read(x),read(y),read(z)
namespace IO{
    #define gc getchar()
    #define pc(x) putchar(x)
    template<typename T>inline void read(T &x){
        x=0;int f=1;char ch=gc;while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=gc;}
        while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=gc;x*=f;return;
    }
    template<typename T>inline void write(T x=0){
        T wr[51];wr[0]=0;if(x<0)pc('-'),x=-x;if(!x)pc(48);
        while(x)wr[++wr[0]]=x%10,x/=10;while(wr[0])pc(48+wr[wr[0]--]);return;
    }
}
using IO::read;
using IO::write;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
int n;
int main(){
	gi(n);
	if(n>=30)puts("Yes");
	else puts("No");
	return 0;
}

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

using namespace std;
const int maxn = 1e5+10;
const int maxd = 110;
const int mod = 1e9 + 7;

string k;
int d;
int dp[maxn][maxd][5];

int rek(int pos, int mod, bool prat) {
	//printf("%d %d %d\n", pos, mod, prat);
	if (pos == k.size()) {
		//printf("GOOD\n");
		if (mod == 0) return 1;
		return 0;
	}
	int &ret = dp[pos][mod][prat];
	if (ret != -1) return ret;
	
	ret = 0;
	if (prat) {
		for (int i = 0; i < 10; i++) {
			//printf("debug: %d\n", i);
			if (i + '0' == k[pos]) {
				ret += rek(pos + 1, (mod + i) % d, true), ret %= ::mod;
				break;
			}
			else ret += rek(pos + 1, (mod + i) % d, false);
			ret %= ::mod;
		} 
	} else {
		for (int i = 0; i < 10; i++) {
			//printf("debug: %d\n", i);
			ret += rek(pos + 1, (mod + i) % d, false), ret %= ::mod;
			//printf("debug end: %d\n", i);
		}
	}
	return ret;
}

int main() {
	memset(dp, -1, sizeof dp);
	cin >> k >> d;
	cout << (rek(0, 0, true) + mod - 1) % mod << endl;
	return 0;
}


Measured memory_bytes: 215936
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;

//static const ll MOD = 1000000007;

int main() {
    string S;

    // input
    cin >> S;

    // process
    for (ll i = 0; i < (ll) S.length(); i++) {
        if ((i % 2) == 0) {
            if (S[i] == 'L') {
                cout << "No" << endl;
                return 0;
            }
        }
        if ((i % 2) == 1) {
            if (S[i] == 'R') {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
flag = [False]*100001
c = [0]*100002
n = int(input())

for i in range(2,100000):
    if(not(flag[i])):
        for j in range(i+i,100000,i):
            flag[j] = True

for i in range(3,100000,2):
    if(not(flag[i]) and not(flag[(i+1)//2])):
        c[i]+=1
for i in range(3,100000):
    c[i]+=c[i-1]

while(n):
    n-=1
    l,r = map(int,input().split())
    print(c[r]-c[l-1])

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

vector<int> v;
char T[100100];

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

    string S;
    std::cin >> S;

    int n = S.size(), m = 0;
    int i = 0, j = 0;
    
    for(;i<n;i=j){
        while(j < n && S[j] == 'x'){
            ++j;
        }

        v.emplace_back(j - i);

        if(j == n){break;}

        T[m++] = S[j];
        ++j;

        if(j == n){
            v.emplace_back(0);
        }
    }

    // for(int i : v){
    //     std::cout << i << std::endl;
    // }
    // std::cout << "----------" << std::endl;

    for(int i=0;i<m;++i){
        if(T[i] != T[m-1-i]){
            std::cout << -1 << std::endl;
            return 0;
        }
    }

    ll res = 0ll;
    int l = v.size();
    for(int i=0;i<=m/2;++i){
        res += abs(v[i] - v[l-1-i]);
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 1100