akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
typedef long long ll;
typedef unsigned long long int llt;
const int N = 3e5 + 10;


int main()
{
  	int a;
  string s;
  cin>>a>>s;
  if(a >= 3200)
    cout<<s<<endl;
  else puts("red");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long int K, N, diff, tmpdiff;
  cin >> K;
  cin >> N;
  long int A[N];
  diff = 0;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    if (i != 0) {
      if (diff < (A[i] - A[i - 1])) {
        diff = (A[i] - A[i - 1]);
      }
    }
  }
  if ((K - A[N - 1] + A[0]) > diff) {
    diff = K - A[N - 1] + A[0];
  }
  cout << K - diff << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include<bits/stdc++.h>
#include <string>
#include <stdlib.h>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<fstream>
#include<typeinfo>
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define repi(i,a,b)  for(ll i=a;i<b;i++)
#define repj(j, a, b) for (ll j = a; j < b;j++)
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector< pii >
#define mod 1000000007
#define lim 100001
 
using namespace std;
ll factorial(ll n){return (n==1 || n==0) ? 1: n * factorial(n - 1); }
int max3(int a,int b,int c){ return max(a, max(c, b));}
int gcd(int a,int b){if(a==0){return b;}else{return gcd(b % a, a);}}
ll power(ll a, ll n){if(n==1) return a; else if(n==0) return 1; else{ ll r = power(a, n / 2); if(n%2==0) return r * r; else return r * a * r;}}
ll nCr(ll n, ll r) { return ((factorial(n)) / (factorial(n - r) * factorial(r))); }
void dfs(vector< vector<int > >& v,vi& check,int start){check[start - 1] = 1;repj(j, 0, v[start-1].size()){if(!check[v[start-1][j]-1]){dfs(v, check, v[start - 1][j]);}}}
bool isPrime(ll n) { if (n <= 1) return false;if (n <= 3)return true; if (n % 2 == 0 || n % 3 == 0)return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
//works under 2 till 1e12
 
//int i, j;
 
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int n,k;
   cin>>n>>k;
   vi rec;
   for(int i=0;i<n;i++){
       int num;
       cin>>num;
       rec.pb(num);
   }
   sort(rec.begin(),rec.end());
   int sum = accumulate(rec.begin(),rec.begin()+k,0);
   cout<<sum;
   return 0;
}


Measured memory_bytes: 3632
def calc(n):
	ans = 1
	for i in range(0, n):
		ans = ans * 2
		if ans >= 1000000007:
			ans = ans - 1000000007
	return ans

def judge(n, lst):
	start = 0
	if n%2 == 1:
		if lst[0] != 0: return False
		else: start = 1
	for i in range(0, n/2):
		if lst[2*i+start] != lst[2*i+start+1]:
			return False
		elif lst[2*i+start] != 2*i+1+start:
			return False
	return True

n = int(raw_input())
inpt = map(int, raw_input().split())
inpt.sort()

if judge(n, inpt):
	print calc(n/2)
else:
	print 0

Measured memory_bytes: 11304
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.List

main = do
  _ <- getLine
  ss <- B.lines <$> B.getContents
  let ns = (map length . groupBy (\s1 s2 -> B.head s1 == B.head s2) . sort . filter ((flip elem "MARCH") . B.head)) ss
  let ans = sum $ do
        let ins = zip [0..] ns
        (i,x) <- ins
        (j,y) <- delete (i,x) ins
        (k,z) <- delete (j,y) (delete (i,x) ins)
        guard (i<j && j<k)
        pure (x*y*z)
  print ans

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

int main(int argc, char const *argv[]) {
    string str;
    int m;
    while (cin >> str) {
        if (str == "-") {
            break;
        }

        int num;
        cin >> m;
        string str1, str2;
        for (int i = 0; i < m; i++) {
            cin >> num;
            str1 = str.substr(0, num);
            str2 = str.substr(num, str.size() - num);
            str = str2 + str1;
        }
        cout << str << endl;
    }
}



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

int gcd2(int a, int b) {
  if (b == 0) return a;
  return gcd2(b, a%b);
}

int gcd3(int a, int b, int c) {
  return gcd2(gcd2(a, b), c);
}

int main() {
  int k;
  cin >> k;
  int ans = 0;
  for (int a = 1; a <= k; ++a) {
    for (int b = 1; b <= k; ++b) {
      for (int c = 1; c <= k; ++c) {
        ans += gcd3(a, b, c);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

s=sum(b)
add_s=0
for i in range(n-1):
      if a[i]==a[i+1]-1:
            add_s += c[a[i]-1]
print(s+add_s)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
  int n;
  cin >> n;
  VI v(n);
  rep(i,n){
     v.at(i)=i+1;
  }
  VI p(n);
  rep(i,n){
     cin >> p.at(i);
  }
   VI q(n);
   rep(i,n){
      cin >> q.at(i);
   }
   int cnt=0;
   int a,b;
   do{
      cnt++;
      bool c=true;
      bool d=true;
      rep(i,n){
         if(p.at(i)!=v.at(i))c=false;
         if(q.at(i)!=v.at(i))d=false;
      }
      if(c)a=cnt;
      if(d)b=cnt;
      }while(next_permutation(v.begin(),v.end()));
      cout << abs(a-b) << endl;
   }


    

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int[] l = sc.IntArray();
        l = l.OrderBy(i => i).ToArray();

        int answer = 0;
        for (int i = 0; i < 2 * n; i++)
        {
            if (i % 2 == 0)
            {
                answer += l[i];
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13396
#include <cstdio>
#include <vector>
#include <functional>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;
#define INF 100000000

struct edge{ int to,cost; };
typedef pair<int,int> P;

vector<edge> g[101];
int d[101];
int n,k;

void dijekstra(int s){
	priority_queue<P,vector<P>,greater<P> > que;
	fill(d,d+101,INF);
	d[s] = 0;
	que.push(P(0,s));

	while(!que.empty()){
		P p = que.top(); que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0; i < g[v].size(); i++){
			edge e = g[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}

int exist(int s, int e){
	for(int i = 0; i < g[s].size(); i++){
		if(g[s][i].to == e){
			return i;
		}

	}
	return -1;
}

int main(){
	while(scanf("%d%d",&n,&k), n != 0){
		for(int i = 0; i < 101; i++){
			g[i] = vector<edge>();
		}
		for(int I = 0; I < k; I++){
			int ia,ib,ic,id;
			scanf("%d",&ia);
			if(ia == 0){
				scanf("%d%d",&ib,&ic);
				dijekstra(ib);
				printf("%d\n", d[ic] == INF ? -1 : d[ic]);
			}
			else{
				scanf("%d%d%d",&ib,&ic,&id);
				int idx = exist(ib,ic);
				if(idx == -1){
					edge e; e.to = ib; e.cost = id;
					g[ic].push_back(e);
					e.to = ic;
					g[ib].push_back(e);
				}
				else if(id < g[ib][idx].cost){
					g[ib][idx].cost = id;
					idx = exist(ic,ib);
					g[ic][idx].cost = id;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2752
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;

char s[101];

int main()
{
	scanf("%s",s);
	if(strlen(s)<4)
	{
		puts("No");
		return 0;
	}
	if(s[0]!='Y'||s[1]!='A'||s[2]!='K'||s[3]!='I')
		puts("No");
	else	
		puts("Yes");
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N, ll D, vector<vector<ll>> X) {
  int ans{};
  for (auto i = 0; i != N; ++i) {
    for (auto j = i+1; j < N; ++j) {
      double d{};
      for (auto k = 0; k != D; ++k) {
        d += pow(X[i][k]-X[j][k],2);
      }
      d = sqrt(d);
      if (abs(d-floor(d))<1e-5) {
        ++ans;
      }
    }
  }
  cout << ans << endl;
}

int main() {
  ll N;
  cin >> N;
  ll D;
  cin >> D;
  vector<vector<ll>> X(N, vector<ll>(D));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> X[i][j];
    }
  }
  solve(N, D, move(X));
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  int n;
  ll x;
  cin >> n >> x;
  VL a(n);
  REP(i, 0, n) {
    cin >> a[i];
  }
  ll tot = 0;
  REP(i, 0, n) {
    if (a[i] > x) {
      tot += a[i] - x;
      a[i] = x;
    }
  }
  REP(i, 0, n - 1) {
    if (a[i] + a[i + 1] > x) {
      ll d = a[i] + a[i + 1] - x;
      tot += d;
      a[i + 1] -= d;
    }
  }
  cout << tot << endl;
}


Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
//namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i,N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N+1),B(N);
    FOR(i, N+1) { 
        cin >> A[i];
    }
    FOR(i, N) { 
        cin >> B[i]; 
    }
    ll prev = 0;
    ll num = 0;
    FOR(i,N){
        if(prev>=A[i]){
            num += A[i];
            prev = B[i];
        }else if(prev + B[i]>=A[i]){
            num += A[i];
            prev = B[i] + prev - A[i];
        }else{
            num += prev + B[i];
            prev = 0;
        }
    }
    //N+1番目の町
    if(prev<=A[N]){
        num += prev;
    }else{
        num += A[N];
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int len=s.length();
    for(int i=0;i<len;i++){
        if(s==t){
            cout<<"Yes"<<endl;
            return 0;
        }
    char c=s[len-1];
      s.erase (len-1,len);

        s = c + s;
         // cout<<s<<endl;
    }
    cout<<"No"<<endl;
            return 0;
}


Measured memory_bytes: 256
def main():
    def get_inputs():
        li = []
        try:
            while True:
                li.append(input())
        except EOFError:
            return li

    def my_round(num, ndigits=3):
        num = num * 10**ndigits
        num = (num*2 + 1)//2
        num = num / 10**ndigits
        num = "{0:.3f}".format(num) ##
        return num

    li = get_inputs()
    for str_num in li:
        tmp = str_num.split(" ")
        for i in range(len(tmp)):
            tmp[i] = int(tmp[i])
        a,b,c,d,e,f = tmp[0],tmp[1],tmp[2],tmp[3],tmp[4],tmp[5]
        x = (c*e - b*f) / (a*e - b*d)
        x = my_round(x)
        y = (c*d - a*f) / (b*d - a*e)
        y = my_round(y)
        print("{} {}".format(x,y))
    return None


if __name__ == '__main__':
    main()

Measured memory_bytes: 7656
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long mx = -2e18;
    mx = max(mx, a * c);
    mx = max(mx, a * d);
    mx = max(mx, b * c);
    mx = max(mx, b * d);
    cout << mx;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
 
int main() {
    int a, b;
    cin >> a >> b;

    int sum = a + b;
    if(sum% 2 == 0){
        cout << sum/2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

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

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = Input.NextInt();
            int[] result = Enumerable.Repeat(10000, 26).ToArray();

            for (int i = 0; i < N; i++) {
                var tmp = Input.Line();
                var array = new int[26];

                foreach(var alpha in tmp) {
                    array[alpha - 'a']++;
                }

                result = result.Zip(array, (first, second) => Math.Min(first, second)).ToArray();
            }

            for (int i = 0; i < 26; i++) {
                char c = (char)('a' + i);
                for (int j = 0; j < result[i]; j++) {
                    Console.Write(c);
                }
            }

            Console.WriteLine();
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13396
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=1e9+7;
const int MAXN=205;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
vector<PR> e[MAXN];
int a[MAXN],f[MAXN][MAXN],g[MAXN][MAXN],b[MAXN];
int upd(int x,int y){ return x+y>=mods?x+y-mods:x+y; }
int quick_pow(int x,int y)
{
	int ret=1;
	for (;y;y>>=1)
	{
		if (y&1) ret=1ll*ret*x%mods;
		x=1ll*x*x%mods;
	}
	return ret;
}
int main()
{
	int n=read();
	for (int i=1;i<=n;i++) a[i]=b[i]=read();
	sort(b+1,b+n+1);
	for (int i=1,lst=0;i<=n;i++)
	{
		b[i]--;
		if (b[i]!=b[i-1]) 
		{
			int id=-1;
			for (int j=1;j<=n;j++)
				if (a[j]-1>=b[i]&&a[j-1]-1<b[i]) id=j;
				else if (a[j-1]-1>=b[i]&&a[j]-1<b[i]) e[j-1].PB(MP(id,b[i]-lst)),id=-1;
			if (id>0) e[n].PB(MP(id,b[i]-lst));
			lst=b[i];
		}
	}
//	for (int i=1;i<=n;i++)
//		for (auto k:e[i]) cout<<k.fi<<" "<<i<<":"<<k.se<<endl;
	f[0][0]=2;
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<=i-1;j++) f[i][1]=upd(f[i][1],f[i-1][j]);
		for (auto k:e[i]) 
			if (k.fi==i) f[i][1]=1ll*f[i][1]*quick_pow(2,k.se)%mods;
		for (int j=2;j<=i;j++)
		{
			f[i][j]=upd(f[i][j],f[i-1][j-1]);
			for (auto k:e[i])
				if (k.fi>=i-j+1) f[i][j]=1ll*f[i][j]*quick_pow(2,k.se)%mods;
		}
//		cout<<i<<":";
//		ll sum=0;
//		for (int j=0;j<=i;j++) cout<<f[i][j]<<" ",sum+=f[i][j];
//		cout<<sum<<endl;
	}
	int ans=0;
	for (int i=1;i<=n;i++) ans=upd(ans,f[n][i]);
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    int m,d; cin>>m>>d;
    int ans = 0;
    for(int i=1; i<=m; i++){
        for(int j=22; j<=d;j++){
            if(i == (j%10)*(j/10) && j%10>=2 && j/10>=2) ans++;
        }
    }    
    cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
h_list = gets.chomp.split(" ").map(&:to_i)

cnt = 0
flag = false
h_list.max.times do |i|
  n.times  do |j|
    h = h_list[j]
    if h >= i + 1
      flag = true
    else
      if flag
        flag = false
        cnt += 1
      end
    end
  end
  if flag
    cnt += 1
  end
  flag = false
end
puts cnt


Measured memory_bytes: 3836
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
int n;
LL a[200010];
LL sum, ans, d;
int main() {
	d = 1LL << 60;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%lld", &a[i]);
		sum += a[i];
	}
	for(int i = 1; i <= n - 1; i++){
		ans += a[i];
		sum -= a[i];
		d = min(d, abs(sum - ans));
	}
	printf("%lld\n", d);
}

Measured memory_bytes: 1664
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!{
        v:[isize;3],
    }
    let result = if v[0] == v[1] && v[0] != v[2] ||
        v[1] == v[2] && v[0] != v[1] ||
        v[0] == v[2] && v[1] != v[2] {"Yes".to_string()} else {"No".to_string()};
    println!("{}", result);
}

Measured memory_bytes: 4352
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    // let n: usize = sc.cin();
    // let p: usize = sc.cin();
    let s: Vec<_> = sc.chars().iter().map(|&c| ((c as u8) - ('0' as u8)) as usize).collect();
    let n = s.len();
    let p = 2019;

    let mut ans = 0;
    let mut memo = vec![0; p];
    memo[s[0] % p] += 1; ans += memo[0];
    for i in 1..n {
        let mut alt = vec![0; p];
        alt[s[i] % p] += 1;
        for z in 0..p {
            let t = (10 * z + s[i]) % p;
            alt[t] += memo[z];
        }
        ans += alt[0];
        memo = alt;
    }
    put!(ans);

}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4360
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	l := scanInt()
	a := scanInt()
	b := scanInt()
	m = scanInt()

	ans := ImatrixInit(3)
	arr := []int{1, 0, 0, 1, 1, 0, 0, b % m, 1}
	mat := MatrixInit(3, 3, arr)
	for i := 0; i < 18; i++ {
		mat.arr[0] *= 10
		mat.arr[0] %= m
		idx1 := sort.Search(l-1, func(idx int) bool {
			num := len(strconv.Itoa(a + b*(idx+1)))
			return i+1 <= num
		})
		idx2 := sort.Search(l-1, func(idx int) bool {
			num := len(strconv.Itoa(a + b*(idx+1)))
			return i+2 <= num
		})
		num := idx2 - idx1
		ans = MulMatrix(ans, PowMatrix(mat, num))
	}
	c := MatrixInit(1, 3, []int{a % m, (a + b) % m, 1})
	ans = MulMatrix(c, ans)
	fmt.Fprintln(wr, ans.At(0, 0))
}

var m int

// Matrix type
type Matrix struct {
	arr      []int
	row, col int
}

// MatrixInit function
func MatrixInit(row, col int, a []int) Matrix {
	arr := make([]int, row*col)
	copy(arr, a)
	res := Matrix{arr, row, col}
	return res
}

// ImatrixInit function
func ImatrixInit(n int) Matrix {
	arr := make([]int, n*n)
	for i := 0; i < n; i++ {
		arr[i+i*n] = 1
	}
	res := Matrix{arr, n, n}
	return res
}

// At function for Matrix
func (mat Matrix) At(i, j int) int {
	return mat.arr[i*mat.col+j]
}

// AddMatrix function
func AddMatrix(a, b Matrix) Matrix {
	if a.row != b.row || a.col != b.col {
		return Matrix{}
	}
	for i := 0; i < a.row*a.col; i++ {
		a.arr[i] += b.arr[i]
	}
	return a
}

// SubMatrix function
func SubMatrix(a, b Matrix) Matrix {
	if a.row != b.row || a.col != b.col {
		return Matrix{}
	}
	for i := 0; i < a.row*a.col; i++ {
		a.arr[i] -= b.arr[i]
	}
	return a
}

// MulMatrix function
func MulMatrix(a, b Matrix) Matrix {
	if a.col != b.row {
		return Matrix{}
	}
	res := MatrixInit(a.row, b.col, nil)
	for i := 0; i < res.row; i++ {
		for j := 0; j < res.col; j++ {
			for k := 0; k < a.col; k++ {
				res.arr[i*res.col+j] += (a.arr[i*a.col+k] * b.arr[k*b.col+j]) % m
				res.arr[i*res.col+j] %= m
			}
		}
	}
	return res
}

// PowMatrix function
func PowMatrix(a Matrix, n int) Matrix {
	if a.row != a.col {
		return Matrix{}
	}
	res := ImatrixInit(a.row)
	for n > 0 {
		if n&1 == 1 {
			res = MulMatrix(res, a)
		}
		a = MulMatrix(a, a)
		n >>= 1
	}
	return res
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int a,b,c,d,k;
int main() {
  cin >> a >> b >> c >> d >> k;
  a = a * 60;
  c = c * 60;
  cout << ((c + d) - (a + b)) - k << endl;
  return 0;
}

Measured memory_bytes: 3636
N = gets.to_i
a = []
a = gets.split.map(&:to_i)
a = a.sort

if N==2
  if a[0]*a[1] > 10**18
    puts -1
  else
    puts a[0]*a[1]
  end
  exit
end

if N % 2 == 1
  ans = a[N/2]
else
  ans = 1
end

(N/2).times do |i|
  ans = ans * (a[i] * a[N-1-i])
  if ans == 0
   puts 0
   exit
  end
  if ans > 10**18
    puts -1
    exit
  end
end
puts ans


Measured memory_bytes: 23176
#雑に考えて漏れや無限ループやrange外れが多発したので解説見た
n=int(input())
L=input().split( )
q=int(input())
M=input().split( )

S=[int(L[i]) for i in range(n)]
T=[int(M[i]) for i in range(q)]

C=0
#max=n
#min=0
#mid=n
for i in range(q):
    max=n
    min=0
    while max>min:
        mid=int((max+min)/2)
        if S[mid]==T[i]:
            C+=1
            break
        elif S[mid]<T[i]:
            min=mid+1
            #print(C,i,mid)
        elif S[mid]>T[i]:#不等号逆だったわwwww
            max=mid
            #print(C,i,mid)
print(C)



Measured memory_bytes: 22028
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class BellmanFord{
    class Edge{
        int from,to,cost;
        Edge(int from, int to,int cost){this.from=from;this.to=to;this.cost=cost;}
    }
    void add_edge(int from,int to,int cost){
        edges.add(new Edge(from,to,cost));
    }
    List<Edge> edges=new ArrayList<>();
    int[] d;
    int V;
    BellmanFord(int V){
        this.V=V;
        d = new int[V];
    }
    BellmanFord(int V,int[] from,int[] to,int[] cost){
        this.V=V;
        d = new int[V];
        for(int i=0;i<from.length;++i)add_edge(from[i], to[i], cost[i]);
    }
    boolean shortestDis(int s){
        boolean update=false;
        Arrays.fill(d, Integer.MAX_VALUE/2);
        d[s]=0;
        int cnt=0;
        do{
            ++cnt;
            if(cnt==V)return true;
            update=false;
            for(Edge e:edges)if(d[e.from]+e.cost<d[e.to]){
                d[e.to]=d[e.from]+e.cost;
                update=true;
            }
        }while(update);
        return false;
    }


    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int V = scan.nextInt();
        int E = scan.nextInt();
        int s = scan.nextInt();
        int[] from = new int[E];
        int[] to = new int[E];
        int[] c = new int[E];
        for(int i=0;i<E;++i){
            from[i]=scan.nextInt();
            to[i]=scan.nextInt();
            c[i]=scan.nextInt();
        }
        BellmanFord bell = new BellmanFord(V,from,to,c);
        bell.shortestDis(s);
        for(int i=0;i<V;++i)System.out.println((bell.d[i]<Integer.MAX_VALUE/2 ? bell.d[i]:"INF"));
    }
}
class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int V = scan.nextInt();
        int E = scan.nextInt();
        int s = scan.nextInt();
        int[] from = new int[E];
        int[] to = new int[E];
        int[] c = new int[E];
        for(int i=0;i<E;++i){
            from[i]=scan.nextInt();
            to[i]=scan.nextInt();
            c[i]=scan.nextInt();
        }
        BellmanFord bell = new BellmanFord(V,from,to,c);
        bell.shortestDis(s);
        for(int i=0;i<V;++i)System.out.println((bell.d[i]<Integer.MAX_VALUE/2 ? bell.d[i]:"INF"));
    }
}


Measured memory_bytes: 301772
#include<cstdio>
using namespace std;
int main(){
    long a,b,c;
    scanf("%ld %ld %ld",&a,&b,&c);
    if(a+b>=c){
        printf("%ld\n",b+c);
    }
    else{
        printf("%ld\n",a+b+b+1);
    }
}

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

int main()
{
	//freopen("/home/zz7/CFInput","r",stdin);
	int n,x,s=0;scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&x),s+=x-1;
	cout<<s<<'\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if(A / C < B){
  cout << "Yes" << endl;
  }else if(A / C == B){
   if(A%C == 0){
     cout << "Yes" << endl;
   }else{
     cout << "No" << endl;
   }
  }else{
  
  cout << "No" << endl;
  }
  

}

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

int pre[100005];
int a[100005];
int main(){
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%d",a+i);
        pre[i]=pre[i-1]+abs(a[i]-a[i-1]);
    }
    for(int i=1;i<n;i++){
        printf("%d\n",pre[n]+abs(a[n]) - abs(a[i]-a[i-1]) - abs(a[i+1]-a[i]) + abs(a[i+1]-a[i-1]) );
    }
    printf("%d\n",pre[n-1]+abs(a[n-1]));
	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;

    int vertical = 0;
    int horizaontal = 0;
    int flat = 1;

    int first = 0;
    while (first < s.size() && s[first] == 'F')
    {
        ++first;
    }

    x -= first;

    vs32 ver;
    vs32 hor;
    for (int i = first; i < s.size(); ++i)
    {
        if (s[i] == 'T')
        {
            flat ^= 1;
        }
        else if (flat == 0)
        {
            int num = 0;
            int j = i;
            for (; j < s.size() && s[j] == 'F'; ++j)
            {
                ++vertical;
                ++num;
            }
            ver.push_back(num);
            i = j - 1;
        }
        else
        {
            int num = 0;
            int j = i;
            for (; j < s.size() && s[j] == 'F'; ++j)
            {
                ++horizaontal;
                ++num;
            }
            hor.push_back(num);
            i = j - 1;
        }
    }

    if (horizaontal < abs(x) || (horizaontal - abs(x)) % 2 != 0 || vertical < abs(y) || (vertical - abs(y)) % 2 != 0)
    {
        cout << "No\n";
        return 0;
    }

    bool dph[hor.size() + 1][2 * horizaontal + 1];
    rep (i, hor.size() + 1) rep (j, 2 * horizaontal + 1) dph[i][j] = false;
    dph[0][horizaontal] = true;
    rep (i, hor.size())
    {
        rep (j, 2 * horizaontal + 1)
        {
            if (dph[i][j])
            {
                dph[i + 1][j + hor[i]] = true;
                dph[i + 1][j - hor[i]] = true;
            }
        }
    }

    bool dpv[ver.size() + 1][2 * vertical + 1];
    rep (i, ver.size() + 1) rep (j, 2 * vertical + 1) dpv[i][j] = false;
    dpv[0][vertical] = true;
    rep (i, ver.size())
    {
        rep (j, 2 * vertical + 1)
        {
            if (dpv[i][j])
            {
                dpv[i + 1][j + ver[i]] = true;
                dpv[i + 1][j - ver[i]] = true;
            }
        }
    }

    cout << (dph[hor.size()][x + horizaontal] && dpv[ver.size()][y + vertical] ? "Yes\n" : "No\n");
    return 0;
}



Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> e[n];
    int indeg[n]={};
    for(int i=0;i<n+m-1;i++){
        int s,t;
        cin>>s>>t;
        --s,--t;
        e[s].push_back(t);
        indeg[t]++;
    }
    int root;
    for(int i=0;i<n;i++){
        if(indeg[i]==0)root=i;
    }
    int ans[n];
    ans[root]=-1;
    queue<int> q;
    q.push(root);
    while(q.size()){
        int v=q.front();
        q.pop();
        for(int u:e[v]){
            indeg[u]--;
            if(indeg[u]==0){
                ans[u]=v;
                q.push(u);
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]+1<<endl;
    }
}


Measured memory_bytes: 7040
n=int(input())
a=list(map(int,input().split()))
alice_list=[]
bob_list=[]
a.sort()
if n%2==0:
    for x in range(0,n):
        if x%2==1:
            alice_list.append(a[x])
        else:
            bob_list.append(a[x])
else:
    for x in range(0,n):
        if x%2==1:
            bob_list.append(a[x])
        else:
            alice_list.append(a[x])

alice_sum=sum(alice_list)
bob_sum=sum(bob_list)
ans=alice_sum-bob_sum


print(ans)



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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int n, k;
    cin >> n >> k;
    cout << n/k+bool(n%k) - n/k << endl;
}


Measured memory_bytes: 764
import math
from collections import defaultdict


def gcd(a, b):
    if a < b:
        a, b = b, a
    if a % b == 0:
        return b
    return gcd(b, a % b)


def main():
    N, X = [int(a) for a in input().split()]
    Xs = [int(a) for a in input().split()]

    xs = sorted(Xs)
    a = [abs(k - X) for k in xs]

    res = a[0]
    for k in a[1:]:
        res = gcd(res, k)
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14632
def main():
    S = input()
    ans = 'Yes'
    for i in range(len(S)):
        if ((i+1)%2==1 and S[i]=='L') or ((i+1)%2==0 and S[i]=='R'):
            ans = 'No'
            break
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

struct edge {
    int from, to;
    ll cost;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    ll p;
    cin >> n >> m >> p;
    vector<edge> g(m);
    for(int i = 0; i < m; i++) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        g[i] = edge{a - 1, b - 1, -(c - p)};
    }
    vector<ll> d(n, LLINF);

    auto bellmanFord = [&](int start) {
        d[start] = 0;
        for(int i = 0; i < n; i++) {
            for(auto e : g) {
                if(d[e.from] != LLINF && d[e.to] > d[e.from] + e.cost) {
                    d[e.to] = d[e.from] + e.cost;
                }
            }
        }
    };

    vector<bool> neg(n, false);

    auto findNegativeLoop = [&]() {
        for(int i = 0; i < n; i++) {
            for(auto e : g) {
                if(d[e.from] != LLINF && d[e.to] > d[e.from] + e.cost) {
                    d[e.to] = d[e.from] + e.cost;
                    neg[e.to] = true;
                }
                if(neg[e.from]) {
                    neg[e.to] = true;
                }
            }
        }
    };

    bellmanFord(0);
    findNegativeLoop();

    cout << (neg[n - 1] ? -1 : max(0LL, -d[n - 1])) << endl;
}

Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    
    void calc()
    {
        cin = new Scanner();

        int N = cin.nextInt();
        int[] A = cin.ArrayInt(N);

        int ans = 0;
        int tmp = 0;
        for (int i = 0; i < N; i++)
        {
            if(A[i] == i + 1)
            {
                tmp++;
            }
            else
            {
                ans += (tmp + 1) / 2;
                tmp = 0;
            }
        }
        ans += (tmp + 1) / 2;
        Console.WriteLine(ans);
    }


        
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}
 

Measured memory_bytes: 18912
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {
    ll N;
    cin >> N;
    ll out = 0;
    rep(i,N){
        ll a;
        cin >> a;
        if(i%2==0&&a%2==1) out++;
    }
    cout << out << endl;
    return 0;
}



Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int a,b; cin>>a>>b; int ans=0; int p=1;

    while(p<b){
       p=p+a-1; ans++;}
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
    ll N,D;
    ll ans=0;
    cin >> N >> D;
    vector<ll> x(N);
    vector<ll> y(N);
    for(ll i=0;i<N;i++){
        cin >> x.at(i);
        cin >> y.at(i);
        if(x.at(i)*x.at(i)+y.at(i)*y.at(i)<=D*D){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6404
#include <vector>
#include <iostream>
#include <set>
#include <cstdio>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <tuple>
#include <algorithm>
#include <limits>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int MN = 1010;
int d[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
bool g[MN][MN] = {};
int main() {
    int w, h;
    int tx, ty;
    cin >> w >> h;
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++) {
            if (s[j] == 't') {
                tx = i; ty = j;
            }
            if (s[j] == '#') {
                g[i][j] = true;
            }
        }
    }
    bool used[MN][MN];
    fill_n(used[0], MN*MN, false);
    int n;
    cin >> n;
    queue<P> q;
    q.push(P(0, 0));
    bool f = false;
    for (int i = 0; i <= n; i++) {
        while (!q.empty()) {
            int x, y;
            tie(x, y) = q.front(); q.pop();
            if (used[x][y]) continue;
            used[x][y] = true;
            if (x == tx && y == ty) {
                f = true;
                break;
            }
            for (int j = 0; j < 4; j++) {
                int x2 = x, y2 = y;
                x2 += d[j][0];
                y2 += d[j][1];
                if (0 <= x2 && x2 < h && 0 <= y2 && y2 < w && !g[x2][y2]) {
                    q.push(P(x2, y2));
                }
            }
        }
        if (f) {
            printf("%d\n", i);
            return 0;
        }
        if (i == n) break;
        int x, y;
        cin >> y >> x;
        g[x][y] = false;
        for (int j = 0; j < 4; j++) {
            int x2 = x, y2 = y;
            x2 += d[j][0];
            y2 += d[j][1];
            if (0 <= x2 && x2 < h && 0 <= y2 && y2 < w && used[x2][y2]) {
                q.push(P(x, y));
                break;
            }
        }
    }
    printf("-1\n");
    return 0;
}

Measured memory_bytes: 3228
#include <stdio.h>

int main(){
   int n,i,j,f,a[200000];
 
   scanf("%d",&n);
   for (i=0;i<n;i++) scanf("%d",&a[i]);
   j=1;f=-1;
   for (i=0;i<n;i++)
      if (a[i]==j) {
         j++;
         f=i;
   }
   if (f==-1) puts("-1");
   else       printf("%d\n",n-j+1);
   return 0;
}


Measured memory_bytes: 896
#include <cstdio>
#include <algorithm>
#define LL long long
using namespace std;

int main() {
	
  	LL L, R, i, j, k=0, minval,answer;
  	  
  	scanf("%lld %lld",&L, &R);
  	
  	if(R-L>=2018){
    
      minval=0;
    
    }else{
    	
      answer=2019;//余りが2019になることはないので、便宜的に設定
      
      for(i=L;i<=R;i++){
      
      	for(j=i+1;j<R+1;j++){
        	
            answer=min(answer,(i*j)%2019);
         
        }
        
      }
        
    }
  


  printf("%lld\n", answer);
 
}

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

int main(){
	string s;
  	int i,j;
  	cin>>s;
  	s.pop_back();
  	if(s.size()%2!=0)s.pop_back();
  	for(i=0,j=s.size()/2;i<s.size()/2,j<s.size();i++,j++){
      	if(s[i]!=s[j]){
          s.pop_back();s.pop_back();
          i=0;j=s.size()/2;continue;
        }
    }
  	cout<<s.size()<<endl;
  	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    int count_e = 0;
    int count_w = 0;
    cin >> s;
    for(int i=0;i<n;++i){
        if(s[i] == 'E') ++count_e; 
    }
    int min = n;
    for(int i=0;i<n;++i){
        if(s[i]=='E')   --count_e;
        if(min > (count_e + count_w))   min = count_e + count_w;
        if(s[i]=='W')   ++count_w;
    }
    cout << min << endl;
}

Measured memory_bytes: 900