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

int main() {
  int L, R;
  cin >> L >> R;
  int gap = R - L;
  
  if (gap >= 2019) {
    cout << 0 << endl;
  }
  
  else {
    //0 < gap < 2019
    L = L%2019;
    R = L + gap;
    vector<int> mod(0);
    
    for (int i=L; i<R; i++) {
      for (int j=i+1; j<=R; j++) {
        int m = (i*j)%2019;
        mod.push_back(m);
      }
    }
    sort(mod.begin(), mod.end());
    cout << mod[0] << endl;
  }
}

Measured memory_bytes: 9708
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const int INF = 0x3f3f3f3f;
ll max(ll a, ll b){return a > b ? a : b;}
ll min(ll a, ll b){return a < b ? a : b;}

int mpow(int b, int e)
{
    int ret=1;
    for(int i=0; i<e; i++)
    {
        ret=ret*b%mod;
    }
    return ret;
}

int n, m, x ,y;
int dp[300001];
bool v[300001];
vector<int> g[300001];

int dfs(int n)
{
    if(dp[n]) return dp[n];
    int ret=0;
    for(int i=0; i<g[n].size(); i++)
    {
        ret = max(ret, 1+dfs(g[n][i]));
    }
    dp[n]=ret;
    return ret;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for(int i=0; i<m; i++)
    {
        cin >> x >> y;
        g[x].push_back(y);
    }
    for(int i=1; i<=n; i++)
    {
        dfs(i);
    }
    int ans=0;
    for(int i=1; i<=n; i++) ans = max(ans, dp[i]);
    cout << ans;
}
//TODO: 56
//come back to 50D, 55D


Measured memory_bytes: 13568
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n, n)
    {
        int ans = 0;
        int tmp = 1;
        for(int i = 1; tmp <= 20000; i++)
        {
            tmp = pow(5, i);
            ans += n / tmp;
        }
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3216
# Reference: https://qiita.com/dn6049949/items/afa12d5d079f518de368

# self.data: 1-indexed
#    __1__
#  _2_   _3_
# 4   5 6   7

# f(f(a, b), c) == f(a, f(b, c))

class SegmentTree:
    # a = [default] * n
    # O(n)
    def __init__(self, n, f=max, default=-2**30):
        self.num_leaf = 2 ** (n-1).bit_length()
        self.data = [default] * (2*self.num_leaf)
        self.f = f

    # a[i] = x
    # O(log(n))
    def update(self, i, x):
        i += self.num_leaf
        self.data[i] = x
        i >>= 1
        while i > 0:
            self.data[i] = self.f(self.data[2*i], self.data[2*i+1])
            i >>= 1

    # return f(a[l:r])
    # O(log(n))
    def query(self, l, r):
        l += self.num_leaf
        r += self.num_leaf - 1
        lres, rres = self.data[0], self.data[0] # self.data[0] == default
        while l < r:
            if l & 1:
                lres = self.f(lres, self.data[l])
                l += 1
            if not r & 1:
                rres = self.f(self.data[r], rres)
                r -= 1
            l >>= 1
            r >>= 1
        if l == r:
            res = self.f(self.f(lres, self.data[l]), rres)
        else:
            res = self.f(lres, rres)
        return res

    # You can use min_index only if f == max.
    # return min({i | x <= i and v <= a[i]}, self.num_leaf)
    # O(log(n))
    def min_index(self, x, v):
        x += self.num_leaf
        while self.data[x] < v:
            if x & 1:
                if x.bit_length() == (x+1).bit_length():
                    x += 1
                else:
                    return self.num_leaf
            else:
                x >>= 1
        while x < self.num_leaf:
            if self.data[2*x] >= v:
                x = 2*x
            else:
                x = 2*x + 1
        return x - self.num_leaf

from sys import stdin
def input():
    return stdin.readline().strip()

def main():
    n = int(input())
    s = list(input())

    forest = [SegmentTree(n, f=max, default=0) for _ in range(26)]
    for ind, si in enumerate(s):
        forest[ord(si) - 97].update(ind, 1)

    q = int(input())
    ans = []
    for _ in range(q):
        typ, l, r = input().split()
        l = int(l) - 1

        if typ == '1':
            forest[ord(s[l]) - 97].update(l, 0)
            s[l] = r
            forest[ord(r) - 97].update(l, 1)

        else:
            cnt = 0
            for tree in forest:
                if tree.min_index(l, 1) < int(r):
                    cnt += 1
            ans.append(cnt)

    for i in ans:
        print(i)

main()

Measured memory_bytes: 314540
package main

import (
	"fmt"
)

func main() {
	var k, s int
	fmt.Scan(&k, &s)

	ans := 0
	for x := 0; x <= k; x++ {
		for y := 0; y <= k; y++ {
			if 0 <= s-(x+y) && s-(x+y) <= k {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mii make_pair<int, int>
#define mll make_pair<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vc vector<char>
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    string s;
    cin >> s;
    for (char c : s)
        if (c == '7')
        {
            cout << "Yes";
            return 0;
        }
    cout << "No";
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0);


	string s; cin >> s;
	for(int i=0;i<s.length();i++){
		s[i] = 'x';
	}
	cout << s;


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j, e, sum;
  /*   
   */
  int cost[MAX];
  int M[MAX][MAX];
  int p[MAX];
  int VI[MAX];
  int mn;
  int tmp;
  scanf("%d", &n);

  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }

 for (i = 0; i < n; i++ ){
    cost[i] = INFTY;
    VI[i] = 0;
    p[i] = -1;
  }
  cost[0] = 0;
  while (1){
    tmp = -1;
    mn = INFTY;
    for (i = 0; i < n; i++ ){
      if (cost[i] < mn && !VI[i]){
    tmp = i;
    mn = cost[i];
      }
    }
    if (tmp == -1 ) break;
    VI[tmp] = 1;  
    for (i = 0; i < n; i++ ){        
      if ( M[tmp][i] < cost[i] && !VI[i]){
    cost[i] = M[tmp][i];
    p[i] = tmp;
      }
    }
  }
   





  sum = 0;

  for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) sum += M[i][p[i]];
  }

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

  return 0;
}

Measured memory_bytes: 804
using System;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            string[] str;
            while (true)
            {
                str = Console.ReadLine().Split(' ');
                int x = int.Parse(str[0]);
                int y = int.Parse(str[1]);
                if (x == 0 && y == 0) { break; }
                for (int i = 0; i < x; i++)
                {
                    for (int j = 0; j < y; j++)
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}



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

int a[200010];
int L, n;

long long solve(){
	long long res = a[n - 1], last = a[n - 1];
	for (int i = n - 2; i > 0; i--){
		int pos = n - 1 - (n - 1 - i) / 2;
		long long now = last + a[i] * 2 - a[pos];
		if ((n - 1 - i) & 1) now += L - a[pos];
		else now += L - a[pos + 1];
		res = max(res, now), last = now;
	}
	return res;
}

int main(){
	scanf("%d%d", &L, &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	long long res = a[n - 1], last = a[n - 1];
	for (int i = n - 2; i >= 0; i--){
		int pos = n - 1 - (n - 1 - i) / 2;
		long long now = last + a[i] * 2 - a[pos];
		if ((n - 1 - i) & 1) now += L - a[pos];
		else now += L - a[pos + 1];
		res = max(res, now), last = now;
	}
	for (int i = 0; i < n; i++){
		a[i] = L - a[i];
	}
	reverse(a, a + n);
	long long ans = res;
	res = a[n - 1], last = a[n - 1];
	for (int i = n - 2; i >= 0; i--){
		int pos = n - 1 - (n - 1 - i) / 2;
		long long now = last + a[i] * 2 - a[pos];
		if ((n - 1 - i) & 1) now += L - a[pos];
		else now += L - a[pos + 1];
		res = max(res, now), last = now;
	}
	printf("%lld\n", max(res, ans));
	return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# fv 全頂点の合計 fe 全辺の合計
N = int(readline())
fv = 0
for i in range(1,N+1):
    fv += ((N+1)*N - i*(i-1) - (N+1-i)*(N-i)) // 2
fe = 0
for _ in range(N-1):
    x,y = map(int,readline().split())
    if x > y:
        x,y = y,x
    fe += x * (N+1-y)
ans = fv-fe
print(ans)

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

int main() {
  int n;
  bool y=false;
  cin >> n;
  
  int i;
  string s;
  for(i=0;i<n;i++){
    cin >> s;
    if(s=="Y"){
      y=true;
    }
  }
  cout << (y ? "Four" :"Three") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;

}
//##################################################################
int main(){
   ll n,k;
   cin>>n>>k;
   if(n%k==0){
       cout<<0;
       return 0;
   }
   ll ans;
   n=(n%k);
    ans=min(n,(k-n));
   cout<<ans;
}

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

res = [0 for i in range(N)]
for i in range(N, 0, -1):
    othors_idxs = [(j+1)*i-1 for j in range(int(N/i)) if j != 0]
    othors = [res[idx] for idx in othors_idxs]
    if sum(othors + [1]) % 2 == A[i-1]:
        res[i-1] = 1

ans = [str(i+1) for i in range(N) if res[i] == 1]
l = len(ans)
if l > 0:
    print(l)
    print(' '.join(ans))
else:
    print(0)
    

Measured memory_bytes: 119048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  string S,T;
  cin >> S >> T;

  vector<int> to(26,-1);
  vector<int> from(26,-1);
  rep(i,sz(S)){
    int a=S.at(i)-'a';
    int b=T.at(i)-'a';
    if(to.at(a)==-1)  to.at(a)=b;
    else if(to.at(a)!=b){
      cout << "No" << endl;
      return 0;
    }
    if(from.at(b)==-1)  from.at(b)=a;
    else if(from.at(b)!=a){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)
#define SORT(a) sort(ALL(a))
#define VSORT(a, type) sort(ALL(a),greater<type>())
#define MAPIN(a,i,j) (a).insert(make_pair(i,j))

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef unsigned long long lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > Matrix;

int main() {
    double ans;
    ll i,j,k,n;
    vector<double>v;

    cin>>n;
    SIZE(v,n);
    rep(i,n){
        cin>>v[i];
    }
    SORT(v);
    rep(i,n-1){
        ans=(v[i]+v[i+1])/2;
        v[i+1]=ans;
    }
    cout<< setprecision(15)<<v[i];

	return 0;
}


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

int main()
{
    long n, ans;
    cin >> n;
    long a[n];
    for(int i =0; i<n; i++){
        cin >> a[i];
    }
    bool flag = true;
    ans = 0;
    while(flag){
        for(auto& c : a){
            if(c % 2 ==1 || c == 0){
                flag = false;
                break;
            }else{
                c /= 2;
            }
        }
        if(flag) ans++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    long K, A, B;
    cin >> K >> A >> B;

    if (A >= B - 1) {
        cout << K + 1 << endl;
        return 0;
    }

    if (K + 1 < A + 2) {
        cout << K + 1 << endl;
        return 0;
    }

    K -= A - 1;
    cout << A + (K / 2) * (B - A) + (K % 2) << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
            ulong[] input = Input.ScanUlongArray();
            ulong A = input[0], B = input[1], C = input[2], D = input[3];

            ulong sum = B - A + 1;

            sum -= B / C - (A - 1) / C;
            sum -= B / D - (A - 1) / D;

            ulong lcm = MyMath.LCM(C, D);
            sum += B / lcm - (A - 1) / lcm;

            Console.WriteLine($"{sum}");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13396
def main():
    K, A, B = map(int, input().split())

    if A >= K:
        print(1)
        exit()
    elif A <= B:
        print(-1)
        exit()

    n, m = divmod(K - A, A - B)
    ans = n * 2 + 1
    a = -A
    b = B
    while m > 0:
        m += b
        a, b = b, a
        ans += 1
    print(ans)

main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t,a,b;
    vector<int>v1;
    cin>>n>>t;
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
        if(b<=t)
            v1.push_back(a);

    }

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

    if(v1.size()==0)
        cout<<"TLE"<<endl;
    else
        cout<<v1[0]<<endl;

    v1.clear();
    return 0;
}


Measured memory_bytes: 256
s=input()
a=0
r=0
for i in range(len(s)-1):
  if s[i]=="A":
    a=a+1
    if s[i+1]=="C":
      a=0
  elif s[i]=="B":
    if s[i+1]=="C":
      r=r+a
    else:
      a=0
  elif s[i]=="C":
    if s[i+1]=="C":
      a=0
print(int(r))

Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,e=0;
    cin>>a>>b;
    char c[a+b+1];
    for(int i=0;i<a+b+1;i++) cin>>c[i];
    for(int i=0;i<a+b+1;i++){
    if(c[i]=='0'||c[i]=='1'||c[i]=='2'||c[i]=='3'||c[i]=='4'||c[i]=='5'||c[i]=='6'||c[i]=='7'||c[i]=='8'||c[i]=='9') e++;
    }
    if(a+b==e&&c[a]=='-') cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,k,q,p;
    cin>>n>>k>>q;
    int a[n]={0};
    int i=0;
    for(i=0;i<q;i++)
    {
        cin>>p;
        a[p-1]+=1;
    }
    for(i=0;i<n;i++)
    {
        if(k+a[i]-q > 0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
'use strict'

function main(input) {

    input = input.split(/\n|\s/).map(v => ~~v)
    const n = input[0]
    let nums = input.slice(1, input.length)

    let cnt = 0
    let odd = false
    while (!odd) {

        odd = false

        for (let i = 0; i < n; i++) {
            let tmp
            if (nums[i] % 2 > 0) {
                odd = true
                continue
            }
        }
        cnt += (!odd) ? 1 : 0

        nums = nums.map(v => v / 2)
    }

    console.log(cnt)

}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define MAXN 2005
#define MYINF 1000000000

using namespace std;

static int dp[MAXN][MAXN];

static int a[2*MAXN];
static int s[MAXN];
static int mins[MAXN][MAXN];

int N, K;
int res;

void DFS (int point, int par)
{
	dp[point][0] = 1;
	int i, j;
	for (i = s[point]; i < s[point+1]; i++)
	{
		if (a[i] != par)
		{
			DFS(a[i], point);
			dp[point][0] += dp[a[i]][0];
			mins[a[i]][0] = dp[a[i]][0];
			for (j = 1; j <= K+1; j++)
			{
				mins[a[i]][j] = min(mins[a[i]][j-1], dp[a[i]][j]);
			}
		}
	}
	dp[point][1] = dp[point][0] - 1;
	for (j = K+1; j > 1; j--)
	{
		int minSum = 0;
		for (i = s[point]; i < s[point+1]; i++)
		{
			if (a[i] != par)
			{
				minSum += mins[a[i]][min(K-j+1, j-1)];
			}
		}
		dp[point][j] = MYINF;
		for (i = s[point]; i < s[point+1]; i++)
		{
			if (a[i] != par)
			{
				int temp = dp[a[i]][j-1] + minSum - mins[a[i]][min(K-j+1, j-1)];
				dp[point][j] = min(dp[point][j], temp);
			}
		}
	}
	for (j = 0; j <= K+1; j++)
	{
		res = min(res, dp[point][j] + (N - dp[point][0]));
	}
}

int main ()
{
	static pair<int, int> data[MAXN];
	scanf("%d %d",&N,&K);
	int M = N-1;
	int i;
	memset(s, 0, sizeof(s));
	for (i = 0; i < M; i++)
	{
		scanf("%d %d",&data[i].first,&data[i].second);
		data[i].first--;
		data[i].second--;
		s[data[i].first]++;
		s[data[i].second]++;
	}
	for (i = 1; i <= N; i++) s[i] += s[i-1];
	for (i = 0; i < M; i++)
	{
		s[data[i].first]--;
		a[s[data[i].first]] = data[i].second;
		s[data[i].second]--;
		a[s[data[i].second]] = data[i].first;
	}
	res = N;

	DFS(0, -1);
	printf("%d\n",res);

	return 0;
}


Measured memory_bytes: 31744
#include<bits/stdc++.h>
#define mod 1000000000000000000
#define int long long 
#define garou ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int pow(int p,int r){
	int ans=1;
	while(r>0){
     if(r&1){
		 ans=((ans%mod)*(p%mod))%mod;
	 }
	 r=r>>1;
     p=((p%mod)*(p%mod))%mod;
	}
	return ans;
}
signed main() {
garou;
int n;
cin>>n;
int re=0;
for(int i=1;i<=n;i++){
	int a;
	cin>>a;
	if((i%2)==1&&(a%2)==1)
	re++;
}
cout<<re;
}

Measured memory_bytes: 3508
#include <bits/stdc++.h>
using i64 = long long;

long long *fact, *inv;

template <class T>
T pow(T x, T n, T mod) {
    T ret = 1;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

template <class T>
T inverse(T x, T p) { return pow(x, p - 2, p); }

void init_factorial(int n, long long mod) {
    fact = new long long[n + 1];
    inv = new long long[n + 1];
    fact[0] = 1;
    for (long long i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % mod;
    inv[n] = inverse(fact[n], mod);
    for (long long i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}

int main() {
    i64 n, m, k;
    constexpr i64 mod = 1000000007;
    std::cin >> n >> m >> k;
    init_factorial(n * m, mod);
    i64 co = fact[n * m - 2] * inv[k - 2] % mod * inv[n * m - k] % mod;
    i64 ret = 0;
    for (i64 i = 0; i < n; i++) for (i64 j = 0; j < m; j++) {
        i64 t1 = (i * (i + 1) % mod * inv[2] % mod + (n - i) * (n - 1 - i) % mod * inv[2] % mod) * m % mod;
        i64 t2 = (j * (j + 1) % mod * inv[2] % mod + (m - j) * (m - 1 - j) % mod * inv[2] % mod) * n % mod;
        ret = (ret + t1 + t2) % mod;
    }
    std::cout << ret * co % mod * inv[2] % mod << std::endl;

    return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define SIZE 60
#define rep(i, N) for (i = 0; i < N; i++) //制御変数iを用いてN回転
#define array(N, t) (t*)calloc(N, sizeof(t)) //t型N要素の1次元配列を動的確保後0クリア(freeを忘れずに)
#define zero(a); {int iter; rep(iter, sizeof(a)/sizeof((a)[0])) (a)[iter]=0;} //1次元配列aのゼロ初期化?
typedef long long ll;
void printa_int(int *a, int size); //int型の1次元配列aを出力(for debug)

int A[SIZE][200002];

int main() {
    int N, i, j;
    ll K;
    scanf("%d %lld", &N, &K);
    rep(i, N) {
        scanf("%d", &A[0][i]);
        A[0][i]--;
    }
    for (i = 1; i < SIZE; i++) {
        rep(j, N)
        A[i][j] = A[i - 1][A[i - 1][j]];
    }
    int pos = 0;
    rep(i, SIZE) {
        if (!K) break;
        if (K & 1) pos = A[i][pos];
        K >>= 1;
    }
    printf("%d\n", pos + 1);

    return 0;
}

void printa_int(int *a, int size) {
    int i;
    for (i = 0; i < size; i++)
        printf("%d, ", a[i]);
    printf("\n");
}

Measured memory_bytes: 48604
import math
import itertools
import statistics
#import collections
x = int(input())

s =  x//11

if 11*s == x:
    ans = s*2
elif 11*s < x:
    if 11*s+6 >= x:
        ans = s*2+1
    else:
        ans = s*2+2
else:
    ans = s*2-1

#print(11*s)
print(ans)

Measured memory_bytes: 5264
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    while(1){
        int cnt_10,cnt_50,cnt_100,cnt_500;
        cin >> cnt_10 >> cnt_50 >> cnt_100 >> cnt_500;
        int sum_num = cnt_10+cnt_50+cnt_100+cnt_500;
        int ans = inf;
        int a_10,a_50,a_100,a_500;
        for(int i=0; i<=cnt_10; i++){
            for(int j=0; j<=cnt_50; j++){
                for(int k=0; k<=cnt_100; k++){
                    for(int l=0; l<=cnt_500; l++){
                        int sum = i*10+j*50+k*100+l*500;
                        if(sum >= N){
                            int res = sum_num - (i+j+k+l);
                            int temp = sum - N;
                            while(temp >= 500){
                                res++;
                                temp -= 500;
                            }
                            while(temp >= 100){
                                res++;
                                temp -= 100;
                            }
                            while(temp >= 50){
                                res++;
                                temp -= 50;
                            }
                            res += temp/10;
                            if(chmin(ans,res)){
                                a_10 = i;
                                a_50 = j;
                                a_100 = k;
                                a_500 = l;
                            }
                        }
                    }
                }
            }
        }
        if(a_10){
            cout << "10 " << a_10 << endl;
        }
        if(a_50){
            cout << "50 " << a_50 << endl;
        }
        if(a_100){
            cout << "100 " << a_100 << endl;
        }
        if(a_500){
            cout << "500 " << a_500 << endl;
        }
        cin >> N;
        if(N == 0) break;
        cout << endl;
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll x,ans;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>x;
    ll c1=x/500;
    ans+=c1*1000;
    x%=500;
    ll c2=x/5;
    ans+=c2*5;
    cout<<ans;
    return 0;
}


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

string str;
int n, ans;
void dfs(string pre, char ch, int idx, int ite)
{
	char cc = pre[0];
	int ok = 1;
	for (int i = 1; i < pre.size(); i++){
		if (cc != pre[i]){
			ok = 0; break;
		}
	}
	if (ok){
		ans = min(ans, ite); return;
	}
	string now;
	for (int i = 0; i <= idx; i++){
		if (pre[i] == ch || pre[i + 1] == ch)now.push_back(ch);
		else now.push_back(pre[i]);
	}
	dfs(now, ch, idx - 1, ite + 1);
}

int main(){
	ans = 1e9;
	cin >> str;
	n = (int)str.size();
	
	for (int i = 0; i < str.size(); i++){
		dfs(str, str[i], n - 2, 0);
	}
	printf("%d", ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<random>

//使い方がよくわからない
#include<stack>
#include<queue>
#include<bitset>
#include<sstream>

#define rep(i,n) for(int i=0;i<(n);i++) 
#define rep1(i,n) for(int i=1;i<(n);i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]){
    string alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int n;
    string s;
    cin >> n >> s;
    rep(i,s.size()){
        char t = s[i];
        rep(j,26){
            if(t==alp[j]) cout << alp[(j+n)%26];
        }
    }
    co("");
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N;
  cin >> N;
  cout << N/3 << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;

int main(){

    string s;
    cin >> s;

    if(s == "KIHBR") cout << "YES" << endl;
    else if(s == "KIHBRA") cout << "YES" << endl;
    else if(s == "KIHBAR") cout << "YES" << endl;
    else if(s == "KIHBARA") cout << "YES" << endl;
    else if(s == "KIHABR") cout << "YES" << endl;
    else if(s == "KIHABRA") cout << "YES" << endl;
    else if(s == "KIHABAR") cout << "YES" << endl;
    else if(s == "KIHABARA") cout << "YES" << endl;
    else if(s == "AKIHBR") cout << "YES" << endl;
    else if(s == "AKIHBRA") cout << "YES" << endl;
    else if(s == "AKIHBAR") cout << "YES" << endl;
    else if(s == "AKIHBARA") cout << "YES" << endl;
    else if(s == "AKIHABR") cout << "YES" << endl;
    else if(s == "AKIHABRA") cout << "YES" << endl;
    else if(s == "AKIHABAR") cout << "YES" << endl;
    else if(s == "AKIHABARA") cout << "YES" << endl;
    else cout <<"NO" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

            // 整数の入力
            int a = int.Parse(Console.ReadLine());

            int result = a + a*a  + a*a*a;

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


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

int main(){
    string s, t;
    cin >> s;
    cin >> t;
    int ans = 0;
    rep(i, s.length()){
        if(s[i]!=t[i])ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3792
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Hello
{
    public static void Main()
    {
        int N = NextInt();
        Node[] nodes = new Node[N];
        for (int i = 0; i < N; i++) { nodes[i] = new Node(i); nodes[i].relate = new List<Edge>(); }
        for (int i = 0; i < N - 1; i++)
        {
            int u = NextInt() - 1;
            int v = NextInt() - 1;
            int w = NextInt();
            Edge e = new Edge(v);
            e.cost = w;
            nodes[u].relate.Add(e);
            e = new Edge(u);
            e.cost = w;
            nodes[v].relate.Add(e);
        }

        //適当に塗る
        nodes[0].color = 1;
        Queue<Node> Q = new Queue<Node>();
        Q.Enqueue(nodes[0]);
        while (Q.Count() != 0)
        {
            var now = Q.Dequeue();
            now.visit = true;
            foreach (var e in now.relate)
            {
                if (!nodes[e.to].visit)
                {
                    if (e.cost % 2 == 1)
                    {
                        //違う色
                        nodes[e.to].color = -now.color;
                    }
                    else
                    {
                        //同じ色
                        nodes[e.to].color = now.color;
                    }
                    Q.Enqueue(nodes[e.to]);
                }
            }
        }

        for (int i = 0; i < N; i++)
            Console.WriteLine(nodes[i].color == -1 ? 0 : 1);
    }
}

public class Node
{
    public List<Edge> relate = new List<Edge>();
    public int name = 0;
    public bool visit = false;
    public long cost = 0;
    public int color = 0;
    public Node(int name) { this.name = name; }
}
public class Edge
{
    public int to;
    public long cost;
    public Edge(int to) { this.to = to; }
}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 41576
import Data.List (foldl')
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B

solve :: B.ByteString -> Int -> B.ByteString
solve s k = S.toAscList go !! (k-1) where
  go = foldl' go' S.empty [1..k]
  go' arg p = foldl' go'' arg [0..max (B.length s - p) 0] where
    go'' substrs i
      | S.size substrs < k || sub < (S.toAscList substrs) !! (k-1) = S.insert sub substrs
      | otherwise = substrs
      where
        sub = B.take p $ B.drop i s

main = do
  s <- B.getLine
  k <- (fst . (\(Just x) -> x) . B.readInt) <$> B.getLine
  B.putStrLn $ solve s k



Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int n;
  scanf("%d",&n);
  vp p(n);
  cin>>p;
  rep(i,n) p[i].se++;
  int ans = 0;
  rep(i,n) maxs(ans,p[i].se-p[i].fi);
  int l = -INF, r = INF;
  rep(i,n) maxs(l,p[i].fi);
  rep(i,n) mins(r,p[i].se);
  ans += max(0,r-l);
  {
    int now = -INF*2;
    sort(rng(p));
    int nr = p.back().se;
    drep(i,n-1) {
      maxs(now,nr-p[i].fi);
      mins(nr,p[i].se);
    }
    now += r-l;
    maxs(ans,now);
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, t;
	cin >> n;
	int a[n+1];
	cin >> a[1];
	t=a[1];
	for (int i=2; i<=n; i++){
		cin >> a[i];
		t^=a[i];
	}
	for (int i=1; i<=n; i++){
		t^=a[i];
		cout << t << ' ';
		t^=a[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 4408
/*****************Bismillahir Rahmanir Rahim***********************/

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

/************************Start Of Template*************************/

/******** Mahin Shefat - GhOstMan *************/


#define     pb              push_back
#define     popb            pop_back
#define     ll              long long int
#define     ull             unsigned long long int
#define     max3(a,b,c)     max(a,max(b,c))
#define     max4(a,b,c,d)   max(max3(a,b,c),d)
#define     min3(a,b,c)     min(a,min(b,c))
#define     min4(a,b,c,d)   min(a,min3(b,c,d))
#define     MOD             1000000007
#define     f               first
#define     s               second
#define     mem(a,v)        memset(a,v,sizeof(a))
#define     mp              make_pair
#define     check           printf("check")
#define     sqr(x)          (x)*(x)
#define     all(v)          v.begin(),v.end()
#define     fast            ios_base::sync_with_stdio(0);cin.tie(0)
#define     pii             pair<int,int>
#define     Pair            pair<ll,ll>
#define     MAX             1000000000000014
#define     MIN             -1000000000000014
#define     endl            '\n'
#define     Fread           freopen("inputdur.txt","r",stdin)
#define     Fwrite          freopen("output.txt","w",stdout)

/************************End Of Template*************************/
ll dp[300005];
ll arr[300005];
int main(){
	
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> arr[i];
	}	
	dp[2] = abs(arr[1] - arr[2]);
	for(int i = 3; i <= n; i++){
		dp[i] = min(dp[i - 1] + (abs(arr[i] - arr[i - 1])) , dp[i - 2] + (abs(arr[i] - arr[i - 2])));
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 3072
#include <stdio.h>

int main(void) {

  int n;

  int hit;
  int sum;

  int i;


  while(1) {

    scanf("%d",&n);

    if(n==0) break;

    sum=0;

    for(i=0;i<n/4;i++) {

      scanf("%d",&hit);

      sum+=hit;

    }

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

  }

  return 0;

}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>

int main()
{
	using namespace std;

	int values[5];
	for (int i = 0; i < 5; i++)
	{
		cin >> values[i];
	}

	sort(values, values + 5);

	int answer = 1 << 20;
	do
	{
		int time = 0;
		int last = 0;
		for (int i = 0; i < 5; i++)
		{
			time += values[i];
			last = time;
			time = ((time - 1) / 10 + 1) * 10;
		}

		answer = min(answer, last);
	} while (next_permutation(values, values + 5));

	cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int n,num = 0;
long long val[200010];
struct edge {
	int v;
	long long len;
};
struct EDGE {
	int u,v;
	long long len;
}e[10000010];
bool cmp (EDGE x,EDGE y){
	return x.len<y.len;
}
vector<edge> vec[200010];
int size[200010],maxp[200010],rt,sum;
int minnode;
long long nowval;
bool vis[200010];
void getsize(int u,int f){
	size[u] = 1;
	maxp[u] = -1;
	for (register int i = 0; i < vec[u].size(); i++){
		int v = vec[u][i].v;
		if (!vis[v]&&v!=f){
			getsize(v,u);
			size[u] += size[v];
			maxp[u] = max(maxp[u],size[v]);
		}
	}
	maxp[u] = max(maxp[u],sum-size[u]);
	if (maxp[u]<maxp[rt]){
		rt = u;
	}
}
void getdis(int u,int f,long long deep){
	if (val[u]+deep<nowval){
		nowval = val[u]+deep;
		minnode = u;
	}
	for (register int i = 0; i < vec[u].size(); i++){
		int v = vec[u][i].v;
		if (!vis[v]&&v!=f){
			getdis(v,u,deep+vec[u][i].len);
		}
	}
} 
void addedge(int u,int f,long long deep){
	e[++num] = EDGE{u,minnode,deep+val[u]+nowval};
	for (register int i = 0; i < vec[u].size(); i++){
		int v = vec[u][i].v;
		if (!vis[v]&&v!=f){
			addedge(v,u,deep+vec[u][i].len);
		}
	}
} 
void divid(int u){
	//cout << "vis[" << u << "] = true" << endl;
	vis[u] = true;
	nowval = 1e18;
	getdis(u,0,0);
	addedge(u,0,0);
	for (register int i = 0; i < vec[u].size(); i++){
		int v = vec[u][i].v;
		if (!vis[v]){
			sum = size[v];
			maxp[rt=0] = inf;
			getsize(v,0);
			divid(rt);
		}
	}
}
int fa[200010];
int get(int x){
	if (fa[x]==x){
		return x;
	}
	return fa[x]=get(fa[x]);
}
void kru() {
	sort(e+1,e+num+1,cmp);
	for (register int i = 1; i <= n; i++){
		fa[i] = i;
	}
	long long ans = 0;
	int ccnt = 0;
	for (register int i = 1; i <= num; i++){
		int fx = get(e[i].u);
		int fy = get(e[i].v);
		//cout << e[i].u << " " << e[i].v << " " << e[i].len << endl;
 		if (fx!=fy){
			fa[fx] = fy;
			ccnt++;
			ans += e[i].len;
			if (ccnt==n-1){
				break;
			}
		}
	}
	printf("%lld",ans);
}
int main () {
	scanf("%d",&n);
	for (register int i = 1; i <= n; i++){
		scanf("%lld",&val[i]);
	}
	for (register int i = 1; i <= n-1; i++){
		int a,b;
		long long c;
		scanf("%d%d%lld",&a,&b,&c);
		vec[a].push_back(edge{b,c});
		vec[b].push_back(edge{a,c});
	}
	sum = n;
	maxp[rt=0] = inf;
	getsize(1,0);
	divid(rt);
	kru();
	return 0;
}

Measured memory_bytes: 87808
S = input()
s = len(S)

se = [0]*s
so = [0]*s

for i in range(s):
  if i%2 == 0:
    se[i] = 1
  else:
    so[i] = 1

ce = 0
co = 0

for j in range(s):
   x = int(S[j])
   if x != se[j]:
      ce += 1
   if x != so[j]:
      co += 1

print(min(ce,co))
  

Measured memory_bytes: 4724
#include <stdio.h>

int main(){
    char number[1001];
    int i, sum;
    while(1){
        scanf("%s", number);
        if(number[0]=='0')break;
        sum=0;
        for(i=0;number[i]!='\0';i++){
            sum+=number[i]-'0';
        }
        printf("%d\n", sum);
    }

    return 0;
}

Measured memory_bytes: 2716
#define _USE_MATH_DEFINES

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

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////
#define R(i,n) for(int i=0;i<(n);i=i+1)
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////
struct edge {
	int to; LL cost;
};
vector<vector<edge>>G(200);
void solve() {
	int N, M, R;
	cin >> N >> M >> R;
	vector<int> path(R);
	for (int i = 0; i < R; ++i) {
		cin >> path[i];
		path[i]--;
	}
	vector<vector<LL>>dist(N, vector<LL>(N, LINF) );
	R(i, N)dist[i][i] = 0;
	R(i, M) {
		int a, b, c;
		cin >> a >> b >> c; --a; --b;
		dist[a][b] = c;
		dist[b][a] = c;
	}
	
	R(k, N)R(i, N)R(j, N)chmin(dist[i][j], dist[i][k]+ dist[k][j]);
	
	SO(path);
	LL ans = LINF;
	do {
		LL res = 0;
		for (int i = 0; i < R - 1; ++i) {
			res += dist[path[i]][path[i + 1]];
		}
		chmin(ans, res);
	} while (next_permutation(path.begin(), path.end()));
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

Measured memory_bytes: 640
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::vec::Vec;
use std::{vec, cmp, num};


struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

// create Vec<char> from String
#[allow(dead_code)]
fn to_chars(s: String) -> vec::Vec<char> {
    let mut cs = s.chars();
    let mut res = vec::Vec::new();
    while let Some(c) = cs.next() {
        res.push(c);
    }
    res
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n: i32 = sc.read();
    let a: i32 = sc.read();
    println!("{}", n * n - a);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace std;
#define ll long long int
#define ld long double
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,
tree_order_statistics_node_update> in_set;
#define rep(n) for(ll i=0;i<(n);i++)
#define jrep(n) for(ll j=0;j<(n);j++)
#define all(a) (a).begin(), (a).end()
#define dpp(a) cout<<(a).first<<" "<<(a).second<<endl;
#define append push_back
#define mod 1000000007
#define ff first
#define ss second
#define ffast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fast ios::sync_with_stdio(0);
ll pw(ll x,ll y,ll p=mod){ll r=1; x=x%p;while(y>0){ if(y&1)r=(r*x)%p;
y=y>>1;x=(x*x)%p;} return r; } vector<ll> uniq(vector<ll> arr)
{vector<ll>brr;sort(all(arr));brr.append(arr[0]);
for(auto i:arr)if(brr.back()!=i)brr.append(i);return brr;}
 
void solve(){
    string s; cin>>s; string a=s; reverse(all(a));
    if(a!=s){ cout<<"No"<<endl; return; }
    reverse(a.begin(),a.begin()+(a.size()-1)/2);
    reverse(a.end()-(a.size()-1)/2,a.end());
    if(a!=s){ cout<<"No"<<endl; return; }
    cout<<"Yes"<<endl;
}
 
int main(){
    ffast
    ll t=1;
    //cin>>t;
    rep(t) solve();
}
 
 
// *p.find_by_order(n) : nth value (0 indexed)
// p.order_of_key(7): index of 7 (0 indexed)


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


using ll = long long;
int N, M;
vector<int> a;


int solve()
{
    ll lcma = 1;
    for (int i = 0; i < N; i++) {
        ll g = __gcd(lcma, (ll)a[i]);
        lcma = lcma / g * a[i];
        if (lcma > M) return 0;
    }
    for (int i = 0; i < N; i++) {
        if (lcma / a[i] % 2 == 0) return 0;
    }
    return (M / lcma + 1) / 2;    
}


int main()
{
    cin >> N >> M;
    a.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        a[i] /= 2;
    }
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int K;
  string S;
  cin >> K;
  cin >> S;

  if(S.size()<=K){
    cout << S << endl;
  }
  else{
    for(int i=0; i<K; i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }

return 0;
}

Measured memory_bytes: 3632