akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = [list(map(int,input().split())) for i in range(n)]
sum = 0
for i in range(n):
  for j in range(i+1,n):
    sum += ((a[i][0]-a[j][0])**2+(a[i][1]-a[j][1])**2)**0.5
print(2*sum/n)

Measured memory_bytes: 9432
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

#define trace(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}

int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

int n,m;
vector<int> adj[N];

int cache[N];

int dfs(int v){
    int &ans=cache[v];
    if(ans!=-1) return ans;
    ans=0;
    for(auto u: adj[v]){
        ans=max(ans,dfs(u)+1);
    }
    return ans;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    rep(i,0,m){
        int x,y;
        cin >> x >> y;
        adj[x].push_back(y);
    }
    mst(cache,-1);
    int res=0;
    for(int i=1; i<=n; i++){
        res=max(res,dfs(i));
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m;
ll ans;
signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    if (m == 1ll || n == 1ll) return cout << "1" << endl, 0;
    for (int i = 1; i <= n; ++i) {
        if (i & 1) {
            if (m & 1ll) ans += (m >> 1ll) + 1ll;
            else ans += (m >> 1ll);
        }
        else ans += (m >> 1ll);
    }
    return cout << ans << endl, 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;

//while(c){
//    total += c%10;
//    c/=10;
//}

int main() {
    int n; cin >> n;
    int a[n];
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    sort(a,a+sizeof(a)/sizeof(a[0]),greater<int>());
    int x=0,y=0;
    for(int i = 0;i < n;i++){
        if(i % 2 == 0){
            x += a[i];
        }else{
            y += a[i];
        }
    }
    cout << x - y;
    
}




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

#define f first
#define s second
#define pb push_back
#define all(c) c.begin(),c.end()
#define mp make_pair
#define gi(x) scanf("%d", &x)
#define pi(x) printf("%d", x)
#define gl(x) scanf("%lld", &x)
#define pl(x) printf("%lld", x)
#define sp printf(" ")
#define nl printf("\n")

typedef long long int lld;
typedef long double ldb;

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define trace(...)
#endif
#define int lld
int t[1000010];

void update(int node, int lo, int hi, int in, int v){
    if(lo == hi){
        t[node] += v;
        return;
    }
    int md = (lo + hi) >> 1;
    if(in <= md) update(node << 1, lo, md, in, v);
    else update(node << 1 | 1, md+1, hi, in, v);
    t[node] = t[node << 1] + t[node << 1 | 1];
}

int query(int node, int lo, int hi, int l, int r){
    if(lo >= l and hi <= r) return t[node];
    if(l > hi or r < lo or lo > hi) return 0;
    int md = (lo + hi)/2;
    int p1 = query(node << 1, lo, md, l, r);
    int p2 = query(node << 1 | 1, md+1, hi, l, r);
    return p1 + p2;
}


map <char, stack<int> > stk;
int mode = 0;
main(){
    string str;
    cin >> str;
    char ch = '*';
    int o = 0, n = str.size();
    map <char, int> mpp, cnt;
    for(auto i: str) mpp[i]++;
    for(auto i: mpp){
        o += (i.s&1ll);
        if(i.s&1ll) ch = i.f;
    }
    int pos = -1;
    if(o > 1) return cout << "-1\n",0;
    vector <pair <int,int> > vct;
    for(int i = 0; i < n; ++i){
        if(ch == str[i] and cnt[str[i]] == mpp[str[i]]/2 and mode == 0){
            mode = 1;
            pos = i; // vct.pb({i,i});
        }
        else{
            if(cnt[str[i]] == mpp[str[i]]/2){
                vct.pb({stk[str[i]].top(), i});
                stk[str[i]].pop();
            }
            else {
                cnt[str[i]]++;
                stk[str[i]].push(i);
            }
        }
    }
    sort(all(vct));
    int ans = 0;
    for(auto i: vct){
        lld t = (int)(lower_bound(vct.begin(), vct.end(), mp(i.s, (lld)-1)) - vct.begin());
        ans += 2*(vct.size()-t);
        // cout << t << endl;
        update(1, 0, n, i.f, 1);
        update(1, 0, n, i.s+1, -1);
    }
    for(auto i: vct){
        update(1, 0, n, i.f, -1);
        update(1, 0, n, i.s+1, 1);
        // cout <<query(1, 0, n, i.f, i.s) << endl;
        ans += query(1, 0, n, i.f, i.s);
        if(pos!=-1) if(pos > i.s or pos < i.f) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 9560
x1, y1, x2, y2  = gets.chop.split.map(&:to_i)
x = x2 - x1
y = y2 - y1
x3 = x2 - y
x4 = x3 - x
y3 = y2 + x
y4 = y3 - y
puts x3
puts y3
puts x4
puts y4


Measured memory_bytes: 3836
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    ll N;

    cin >> N;

    ll A[N];
    ll num[N + 1];
    ll same[N + 1];
    ll sum = 0;
    ll ans = 0;

    for(int i = 0; i < N + 1; i++){
        num[i] = 0;
    }
    for(int i = 0; i < N; i++){
        cin >> A[i];
        num[A[i]]++;
    }
    for(int i = 0; i < N + 1; i++){
        same[i] = (num[i] * (num[i] - 1)) / 2;
        sum += same[i];
    }

    for(int i = 0; i < N; i++){
        ans = sum;
        ans -= same[A[i]];
        ans += ((num[A[i]] - 1) * (num[A[i]] - 2)) / 2;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 7296
n=int(input())
li=[]
cnt=0
for i in range(n):
    li.append(input())

li.sort()
last=li[0]

for i in range(1,n):
    if last==li[i]:
        li[i]=0
    
    else:
        last=li[i]

print(n-li.count(0))


Measured memory_bytes: 23948
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int t = sc.nextInt();

		if(x <= t) {
			System.out.println(0);
		} else {
			System.out.println(x - t);
		}
	}
}


Measured memory_bytes: 23764
#X匹Y本の組み合わせが存在するか。b=x-aを2a+4b=yに代入してループ
X,Y = map(int,input().split())
ans = "No"
for a in range(X+1):
  b = X - a
  f = 2 * a + 4 * b
  if f == Y:
    ans = "Yes"
print(ans)

Measured memory_bytes: 9132
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;
const long long int MOD=1e9+7;

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	char a,b;
	cin>>a>>b;
	if(a=='H'&&b=='H'||a=='D'&&b=='D')
	{
		cout<<'H';
	 } 
	 else
	 {
	 	cout<<'D';
	 }
 } 

Measured memory_bytes: 256
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x % y == 0:
    return y
  else:
    while x % y != 0:
      z = x % y
      x = y
      y = z
    else:
      return z

def lcm(m,n):
  return int((m*n)/gcd(m,n))

numbers = input().split(" ")
num1 = int(numbers[0])
num2 = int(numbers[1])
print(lcm(num1,num2))

Measured memory_bytes: 3064
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int n,m,I,P,Q;
int cnt,head[100010],to[400010],nxt[400010],linker[100010];
bool f,vis[100010];
void add(int x,int y)
{
	cnt++;
	to[cnt]=y;
	nxt[cnt]=head[x];
	head[x]=cnt;
}
void dfs(int x,int fa)
{
	vis[x]=true;
	linker[x]=linker[fa]^1;
	for (int i=head[x];i;i=nxt[i])
	{
		int y=to[i];
		if (y!=fa)
		{
			if (vis[y])
			{
				if (linker[x]==linker[y])
				{
					f=true;
				}
				continue;
			}
			else
			{
				dfs(y,x);
			}
		}
	}
}
int main()
{
	cin>>n>>m;
	int x,y;
	for (int i=0;i<m;i++)
	{
		cin>>x>>y;
		add(x,y);
		add(y,x);
	}
	for (int i=1;i<=n;i++)
	{
		if (!vis[i])
		{
			if (!head[i])
			{
				I++;
				vis[i]=true;
				continue;
			}
			f=false;
			dfs(i,0);
			if (f)
			{
				P++;
			}
			else
			{
				Q++;
			}
		}
	}
	long long ans=2LL*I*n-1LL*I*I+1LL*P*P+2LL*P*Q+2LL*Q*Q;
	printf("%lld\n",ans);
    return 0;
}

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

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

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

int main() {
	string s, t;
	cin >> s >> t;
	s += s;
	bool flag = false;
	for (int i = 0; i <= SZ(s) - SZ(t); i++) {
		if (s.substr(i, SZ(t)) == t) {
			flag = true;
		}
		//cout << s.substr(i, SZ(t)) << endl;
	}
	puts(flag ? "Yes" : "No");
}


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

    if (S[5] == '1'){
        cout << "TBD" << endl;
    }
    else if (S[5] == '0' && S[6] <= '4'){
        cout << "Heisei" << endl;
    }
    else {
        cout << "TBD" << endl;
    }
}

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

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();
            var s = cin.next();
            var t = cin.next();

            var ans = "";
            for (int i = 0; i < n; i++)
            {
                ans += s[i];
                ans += t[i];
            }

            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 int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N+ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            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 long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            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;
        }
    }   

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>

using namespace std;

int main(){
  
   string s,t;
   long unsigned int i,j,change = 0,mini = INT_MAX;
   
   cin>>s>>t;
   
   for(i = 0;i<=s.length()-t.length();++i){
       j = 0;
       change = 0;
       for(j = 0;j<t.length();++j){
           if(s[i+j] != t[j])
              ++change;
            
            
       }
       mini = min(mini,change);
   }
   
   cout<<mini;
 
   
  
    return 0;
}

Measured memory_bytes: 3628
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define db long double
# define IOS ios_base :: sync_with_stdio(0)
# define halt(...) {fo << (__VA_ARGS__) << '\n';exit(0);}
# define pp(n) cerr << #n << " = " << n << '\n'
# define ppp(v) for (auto it : v) cerr << it << ' ';cerr << '\n'
int s[1 << 20];
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n,k;
    IOS;
    fi>>n>>k;
    for (int i = 1;i <= n;++i) fi>>s[i];
    int mx = 1;
    for (int i = 1;i < n;++i)
        if (s[i] + s[i+1] > s[mx] + s[mx + 1])
            mx = i;
    if (s[mx] + s[mx + 1] >= k) fo << "Possible\n";
    else return fo << "Impossible\n",0;
    for (int i = 1;i < mx;++i) fo << i << '\n';
    for (int i = n - 1;i >= mx;--i) fo << i << '\n';
    return 0;
}

Measured memory_bytes: 1280
#include <cstdio>
#include <utility>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n';)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;if((c=gcu())=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
	_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int main() {
	for (int b, r, g, c, s, t; b = in, r = in, g = in, c = in, s = in, t = in;)
		outl(100 + b * 95 + r * 63 + g * 7 + c * 2 + s * 3 - t * 3);
}


Measured memory_bytes: 2404
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int aka=0;
  int ao=0;
  string S;
  cin>>S;
  for(int X=0;X<S.size();X++){
    if(S.at(X)=='0'){
      aka++;
    }
    else{
      ao++;
    }
  }
  int tou=min(ao,aka);
  cout<<tou*2<<endl;
}

Measured memory_bytes: 3668
I = [int(_) for _ in open(0).read().split()]
N, Q = I[:2]
C = [0] + I[2:2 + N]
LR = I[2 + N:]
L, R = LR[::2], LR[1::2]


class BinaryIndexedTree():
    def __init__(self, n):
        """
        constructs binary indexed tree

        Parameters
        ----------
        n : int
            maximum index value
        """
        self.n = n
        self.dat = [0] * (n + 1)

    def sum(self, i):
        """
        returns the sum of [1, i]

        Parameters
        ----------
        i : int
            right end of the interval
        """
        s = 0
        while i:
            s += self.dat[i]
            i -= i & -i
        return s

    def add(self, i, x):
        """
        adds x to i-th element

        Parameters
        ----------
        i : int
            index
        x : int
            additional value
        """
        while i <= self.n:
            self.dat[i] += x
            i += i & -i


BIT = BinaryIndexedTree(500010)

arr = [5 * 10**5 + 4] * (5 * 10**5 + 5)
RLI = sorted(r * (2 ** 40) + l * (2 ** 20) + i for r, l, i in zip(R, L, range(Q)))
ans = [None] * Q
j = 0
for rli in RLI:
    r, li = divmod(rli, 2 ** 40)
    l, i = divmod(li, 2 ** 20)
    for j in range(j + 1, r + 1):
        BIT.add(arr[C[j]], -1)
        arr[C[j]] = j
        BIT.add(j, 1)
    ans[i] = BIT.sum(r) - BIT.sum(l - 1)
print('\n'.join(map(str, ans)))


Measured memory_bytes: 239192
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = list(map(int, sys.stdin.readline().split()))
ST = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]

graph = [[] for _ in range(N + 1)]
for s, t in ST:
    graph[s].append(t)

# 解説AC
# 閉路ないから後ろから見てけばOK


# dp[v][u]: u からの出口を塞いだときの、v から N までのステップ数の期待値の最小値
dp = np.full((N + 1, N + 1), IINF, dtype=float)
dp[N] = 0.0
for v in reversed(range(1, N)):
    # 塞がない
    dp[v, :] = dp[graph[v], :].sum(axis=0) / len(graph[v]) + 1
    if len(graph[v]) >= 2:
        # 塞ぐ
        s = dp[graph[v], v].sum() - dp[graph[v], v].max()
        dp[v, v] = s / (len(graph[v]) - 1) + 1
print(dp[1].min())


Measured memory_bytes: 58384
h,w,k=gets.split.map &:to_i
a=(1..h).map{gets.chomp}

res=0
(2**h).times{|i|
    (2**w).times{|j|
        b=a.dup
        (0...h).each{|k| b[k]=?R*w if i[k]==1 }
        b=b.map(&:chars).transpose
        (0...w).each{|k| b[k]=?R*h if j[k]==1 }
        
        res+=1 if b.sum{_1.count ?#}==k
    }
}
puts res


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    sort(a.rbegin(), a.rend());

    ll ai = a[0];

    ll aj = -1;
    ll adif = 1e9;
    for(int i = 1; i < n; i++){
        if(abs(ai - 2 * a[i]) < adif){
            aj = a[i];
            adif = abs(ai - 2 * a[i]);
        }
    }

    cout << ai << " " << aj <<endl;

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
using namespace std;

typedef long long ll;

ll h[222222];

int main(void)
{
	ll n, k, i;

	scanf("%lld %lld" ,&n, &k);
	for (i = 1; i <= n; i++)
		scanf("%lld" ,&h[i]);

	sort(h + 1, h + n + 1);

	ll sum = 0;
	for (i = 1; i <= n - k; i++)
		sum += h[i];

	printf("%lld" ,sum);
	return 0;
}


Measured memory_bytes: 1664
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class AWeatherPrediction {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        string S;
        in>>S;
        if(S=="Sunny") out<<"Cloudy"<<'\n';
        else if(S=="Cloudy") out<<"Rainy"<<'\n';
        else out<<"Sunny"<<'\n';
    }
};


int main() {
	AWeatherPrediction solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3636
import numpy as np

N,L = list(map(lambda x: int(x),input().split()))
a = [L+i for i in range(N)]
c = 1000
b = 1000
for i in a:
    if abs(i)<c:
        c = abs(i)
        b = i
print(int(np.sum(a))-b)

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

int main() {
  int N, Q, R;
  cin >> N;
  Q = N / 10;
  R = N % 1000;
    
  if (Q*R % 111 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define NIL -1
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<char>>;
using P =pair<int,int>;

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const ll mod=1000000007;

ll n;
ll ans=0;

void check(ll x){
    if(x>n)return;
    int cnt[3]={};
    while(x){
        if(x%10==3)cnt[0]++;
        if(x%10==5)cnt[1]++;
        if(x%10==7)cnt[2]++;
        x/=10;
    }
    if(cnt[0]>0&&cnt[1]>0&&cnt[2]>0)++ans;
}
void dfs(ll x){
    check(x);
    if(x<=1000000000){
        dfs(10*x+3);
        dfs(10*x+5);
        dfs(10*x+7);
    }
}


int main(){
    cin>>n;
    dfs(0);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3624
#pragma region Macros
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn, now, ans;
int kk;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos) n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos) a[i + 1] = a[i + 1] * 10 + *pos++ - '0';
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos) pos++;
                pos++;
            }
            break;
        }
    }
    while(*pos and *pos <= 32) pos++;
    rep(i, m) {
        while('0' <= *pos) b[i + 1] = b[i + 1] * 10 + *pos++ - '0';
        pos++;
        b[i + 1] += b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    now = ans = nn;
    for(i = 1; i <= m; i++) {
        kk = k - b[i];
        while(a[now] > kk) now--;
        ans = max(ans, i + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


Measured memory_bytes: 7704
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<limits>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;

int INF = std::numeric_limits<int>::max();
ll LLINF = 2e18+10;
int NINF = std::numeric_limits<int>::min();
int MOD = 1e9+7;

int col[] = {0,-1,0,1,1,1,-1,-1};
int row[] = {-1,0,1,0,1,-1,1,-1};

//knight moves
int cc[] = {1,2,2,1,-1,-1,-2,-2};
int rr[] = {-2,-1,1,2,-2,2,1,-1};

int main()
{
    //cout << LLINF ;
    ios::sync_with_stdio(0);
    cin.tie(0);

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

    vi wts(n), vals(n);

    for(int i = 0; i < n ; ++i)
    {
        cin >> wts[i] >> vals[i];
    }

    vvll dp(n,vll(1e5+5,LLINF));

    //initialize dp table
    for(int i = 0; i < n ; ++i)
        dp[i][vals[i]] = wts[i];


    for(int i = 1 ; i < n; ++i)
    {
        for(int j = 1; j <=  1e5 ; ++j)
        {
            dp[i][j] =  min(dp[i][j],dp[i-1][j]);

            if(vals[i] <= j)
                dp[i][j] = min(dp[i][j], dp[i-1][j-vals[i]] +wts[i]);
        }

    }

    int mn = 0;

    for(int j = 1; j <= 1e5 ; ++j)
    {
        if(dp[n-1][j] <= w)
            {
            //    cout << j << " " << dp[n-1][j] << " " << mn << endl;
                mn = max(mn,j);
            }
            //cout  << mn << " ";
    }
    //cout << endl;

    cout << mn;

    return 0;
}


Measured memory_bytes: 82376
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl "\n"
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <ll, ll> pll;
const ll M=1e9+7;
ll inf=1e18;
int main()
{
    fast;
    ll n,k;
    cin>>n>>k;
    ll a=0,b=n,x=a,y=b;
    ll ans=0;
    for(int i=2;i<=k;i++){
        a++;
        b--;
        x+=a;
        y+=b;
    }
    for(int i=k;i<=n+1;i++){
        ans=(ans+((y%mod-x%mod+mod)%mod+1)%mod)%mod;
        a++;
        b--;
        x+=a;
        y+=b;
    }
    cout<<ans;
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
using Graph = vector<vector<int>>;
const long long m = (1e+9) + 7;

int N, K;
long long ans = 1;
void dfs(const Graph& G, int v, int p, int n) {
	ans = ans * (K - n) % m;
	n = 1;
	if (p != -1) ++n;
	for (auto nv : G[v]) {
		if (nv != p) {
			dfs(G, nv, v, n);
			++n;
		}
	}
}

int main() {
	cin >> N >> K;
	Graph G(N);
	int a, b;
	for (int i = 0; i < N - 1; ++i) {
		cin >> a >> b;
		--a;
		--b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(G, 0, -1, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int N;
ll a[1000];
bool deleted[1000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    ll o = 0, e = 0;
    vector<int> vo, ve;
    for(int i = 0; i < N; i++){
        if(i%2 == 0){
            if(a[i] > 0){
                e += max((ll)0, a[i]);
                ve.push_back(i);
            }
        }else{
            if(a[i] > 0){
                o += max((ll)0, a[i]);
                vo.push_back(i);
            }
        }
    }
    int maxa = -2e9;
    int maxidx;
    if(e == 0 && o == 0){
        for(int i = 0; i < N; i++){
            if(a[i] > maxa) {
                maxa = a[i];
                maxidx = i;
            }
        }
        o = -2e9;
        e = maxa;
        ve.push_back(maxidx);
    }
    vector<int> ans;
    if(o > e) swap(vo, ve);
    int s = ve.size();
    int cnt = 0;
    for(int i = N-1; i > ve[s-1]; i--){
        ans.push_back(i);
    }
    for(int i = 0; i < ve[0]; i++){
        ans.push_back(0);
        cnt++;
    }
    for(int i = 1; i < s; i++){
        int m = (ve[i]-ve[i-1])/2;
        for(int j = 0; j < m; j++){
            ans.push_back(ve[i-1]+m-j-cnt);
        }
        cnt += m*2;
    }
    cout << max(o, e) << endl;
    cout << ans.size() << endl;
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i]+1 << endl;
    }
}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define int long long
//for set
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   
// for multiset
// typedef tree<
// int,
// null_type,
// less<int>,
// rb_tree_tag,
// tree_order_statistics_node_update> ordered_multiset;

#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
// int MOD=998244353;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<int> vi; typedef pair<int,int> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
int addmod(int a, int b, int md) {return (a+b)%md;}
int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

int cmp(const ii& p1, const ii& p2) {
	return (p1.ss>p2.ss);
}

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

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

struct StExpr
{
  StExpr() : m_nPerson(0), m_nAttr(0) { }

  int m_nPerson;
  int m_nAttr;
};

void input(vector<vector<StExpr>>& rvvoExpr)
{
  int nPersonSiz;
  cin >> nPersonSiz;
  rvvoExpr.resize(nPersonSiz);

  for (int i = 0; i < rvvoExpr.size(); i++)
  {
    int nAttrSiz;
    cin >> nAttrSiz;
    rvvoExpr[i].resize(nAttrSiz);

    for (int j = 0; j < rvvoExpr[i].size(); j++)
      cin >> rvvoExpr[i][j].m_nPerson >> rvvoExpr[i][j].m_nAttr;
  }
}
 
int isHonest(const vector<vector<StExpr>>& cnrvvoExpr, 
                  const vector<int>& cnrvnHonest, int nMan)
{
  if (cnrvnHonest[nMan])               // Honest
  {
    for (int j = 0; j < cnrvvoExpr[nMan].size(); j++)
      if (cnrvvoExpr[nMan][j].m_nAttr  !=
          cnrvnHonest[ cnrvvoExpr[nMan][j].m_nPerson - 1 ] )
        return 0;

    return 1;
  }
  else                                 // UnKind
  {
    for (int j = 0; j < cnrvvoExpr[nMan].size(); j++)
      if (cnrvvoExpr[nMan][j].m_nAttr  !=
          cnrvnHonest[ cnrvvoExpr[nMan][j].m_nPerson - 1 ] )
        return 1;

    return 0;
  }
}
  
int calcMaxHonest(const vector<vector<StExpr>>& cnrvvoExpr)
{
  vector<int> vnHonest(cnrvvoExpr.size());
  int nMaxHonestCnt = 0;
  
  for (int nCtl = 0; nCtl < ( 1 << cnrvvoExpr.size() ); nCtl++)
  {
    int nHonestCnt = 0;

    for (int nEach = 0; nEach < cnrvvoExpr.size() ; nEach++)
      if (nCtl & ( 1 << nEach ))
      {
        vnHonest[nEach] = 1;            // Honest
        nHonestCnt++;
      }
      else
        vnHonest[nEach] = 0;            // UnKind

    bool bReslt = true;

    for (int nMan = 0; nMan < vnHonest.size(); nMan++)
      if (!isHonest(cnrvvoExpr, vnHonest, nMan))
      {
        bReslt = false;
        break;
      }

    if (bReslt) nMaxHonestCnt = max(nMaxHonestCnt, nHonestCnt);
  }
  return nMaxHonestCnt;
}

int main()
{
  vector<vector<StExpr>> vvoExpr;

  input(vvoExpr);
  cout << calcMaxHonest(vvoExpr) << endl;

  return 0;
}

Measured memory_bytes: 3604
S = input()

maxLen = 0
maxCnt = 0
lstString = ["A" ,"T" ,"C" ,"G"]
for i in range(len(S)):
  if S[i] in lstString:
    maxCnt = 0
    for j in range(i, len(S)):
      if S[j] in lstString:
        maxCnt += 1
      else:
        # print("ok")
        break
    maxLen = max(maxLen, maxCnt)


print(maxLen)


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

int n,m;
vector<int> seen;
vector<vector<int>> g;
int ans = 0;
int p = 0;

void dfs(int v){
  seen[v] = p++;
  if(p==n) ans++;
  for(auto nv:g[v]){
    if(seen[nv]!=-1) continue;
    dfs(nv);
  }
  seen[v] = -1;
  p--;
}

int main(){
  cin>>n>>m;
  g.resize(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--; b--;
    g[a].pb(b);
    g[b].pb(a);
  }
 
  seen.resize(n,-1);
  dfs(0);
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
    int n,d,x[10][10],i,j,k,output=0;
    double tmp;
    scanf("%d %d",&n,&d);
    for(i=0;i<n;++i){
        for(j=0;j<d;++j){
            scanf("%d",&x[i][j]);
        }
    }
    for(i=0;i<n-1;++i){
        for(j=i+1;j<n;++j){
            tmp=0.0;
            for(k=0;k<d;++k){
                tmp+=(x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
            }
            tmp = sqrt(tmp);
            if(ceil(tmp)==floor(tmp)) output++;
        }
    }
    printf("%d\n",output);
    return 0;
}


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

ll res = 0;

bool judge(int a) {
    //cout << a << endl;
    ll se=0, fi=0, th=0;
    string s = to_string(a);
    ll len = s.size();
    rep(i, len) {
        switch(s[i]) {
            case '7':
                se++;
                break;
            case '5':
                fi++;
                break;
            case '3':
                th++;
                break;
        }
    }
    if(se+fi+th==len && se>0 && fi>0 && th>0) {
        //cout << "ok" << endl;
        return true;
    }
    else return false;
}

void cal(ll n, ll x) {
    if(x > n) return;
    if(judge(x)) res++;
    cal(n, (x*10)+7);
    cal(n, (x*10)+5);
    cal(n, (x*10)+3);
}

int main() {
    ll N;
    cin >> N;

    cal(N, 7);
    cal(N, 5);
    cal(N, 3);

    cout << res << endl;
    return 0;
}

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

int main(){
  ll N,M;
  cin>>N>>M;
  vector<pair<ll,ll>> shop(N);
  for(int i=0;i<N;i++){
    cin>>shop[i].first>>shop[i].second;
  }

  sort(shop.begin(),shop.end());
  ll ans=0;
  for(ll i=0;i<N;i++){
    if(M<shop[i].second){
      ans+=M*shop[i].first;
      break;
    }
    ans+=shop[i].first*shop[i].second;
    M-=shop[i].second;
  }
  cout<<ans<<endl;
  
  return 0;
}



Measured memory_bytes: 1792
#include <iostream>

int main()
{
    std::string n;
    std::cin >> n;
    std::string s = "";
    for (const auto& c : n) {
        if (c == '1') {
            s.push_back('9');
        } else {
            s.push_back('1');
        }
    }
    std::cout << s << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int a;
        cin >> a;
        if (i % 2 != 0) {
            if (a % 2 != 0) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
program rec
	implicit none
    integer :: n, i,j,c1,c2
    integer(8),allocatable :: a(:)
    integer(8) :: l1, l2, s1, s2
    logical :: status
    read(*,*) n
    allocate(a(n))
    read(*,*) a
    call heapsort(a)
	
    s1 = 0
    s2 = 0
    c1 = n
    do i = n - 1, 1, -1
    	l1 = a(i)
        l2 = a(i+1)
    	if(l1 == l2) then
        	s1 = l1
        	c1 = i
        	exit
        else
        	l1 = a(i)
            l2 = a(i-1)
        end if
    end do
    do i = c1 - 2, 1, -1
    	l1 = a(i)
        l2 = a(i+1)
    	if(l1 == l2) then
        	s2 = l1
        	c1 = i
        	exit
        else
        	l1 = a(i)
            l2 = a(i-1)
        end if
    end do
    	
    write(*,*) s1*s2

	stop
contains
	subroutine heapsort(array)
    implicit none
    integer(8):: array(:)
    integer ::i,k,j,l
    integer(8) :: t

    n=size(array)

    if (n==1) then
       return
    end if
    
    l=n/2+1
    k=n
    do while(k.ne.1)
       if(l.gt.1)then
          l=l-1
          t=array(L)
       else
          t=array(k)
          array(k)=array(1)
          k=k-1
          if(k == 1) then
             array(1)=t
             exit
          endif
       endif
       i=l
       j=l+l
       do while(j.le.k)
          if(j.lt.k)then
             if(array(j).lt.array(j+1))j=j+1
          endif
          if (t.lt.array(j))then
             array(i)=array(j)
             i=j
             j=j+j
          else
             j=k+1
          endif
       end do
       array(i)=t
    end do
    return
  end subroutine heapsort

end program rec



Measured memory_bytes: 3836
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define SIZE 100
#define rep(i, N) for (i = 0; i < N; i++) //制御変数iを用いてN回転
#define array(N, t) ((t)*)calloc(N, sizeof(t)) //t型N要素の配列を動的確保後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 main() {
    char S[11];
    char T[12];
    int i;
    scanf("%s\n%s", S, T);
    for (i = 0; i < 11; i++) {
        if (!S[i]) {
            printf("Yes\n");
            break;
        } else if (S[i] != T[i]) {
            printf("No\n");
            break;
        }
    }
    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: 1592
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    LL A,B,C,K;
    R(A,B,C,K);
    if(K%2==0)W(A-B);
    else W(B-A);
    return 0;
}


Measured memory_bytes: 764
def main():
    n = int(input())
    h_list = list(map(int, input().split()))

    h_list[0] -= 1
    ans = 'Yes'
    for i in range(0, len(h_list)-1):
        if h_list[i] == h_list[i+1]:
            pass
        elif h_list[i] > h_list[i+1]:
            ans = 'No'
        else:
            h_list[i+1] -= 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63856
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	int N;
	cin >> N;

	int D1, D2;

	vector<int> a;

	for (int i = 1; i <= N; i++) {
		cin >> D1 >> D2;
		if (D1 == D2) {
			a.push_back(i);
		}
	}

	bool jdg = false;

	if (a.size() <= 2) {
		cout << "No" << endl;
	}
	else {
		for (int i = 0; i < a.size() - 2; i++) {
			if (a[i + 1] == a[i] + 1 && a[i + 2] == a[i] + 2) {
				jdg = true;
				break;
			}
		}

		if (jdg == true) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3636
N, M = [int(_) for _ in input().split()]

mod = 10 ** 9 + 7
def comb(x, y):
    if y * 2 > x:
        y = x - y
    result = 1
    for j in range(1, y + 1):
        result *= (x + j - y) * pow(j, mod - 2, mod)
        result %= mod
    return result
def homoprod(x, y):
    return comb(x + y - 1, y)

ans = 1
i = 2
for i in range(2, int(M ** 0.5) + 2):
    count = 0
    while M % i == 0:
        count += 1 
        M //= i
    if count > 0:
        ans *= homoprod(N, count)
        ans %= mod
if M > 1:
    ans *= homoprod(N, 1)
    ans %= mod
print(ans)

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

using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    string ans = "No";
    for (auto &c : s) {
        if (c == '7') {
            ans = "Yes";
        }
    }
    puts(ans.c_str());
    return 0;
}


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

using namespace std;
const long long INF = 1LL << 60;

void chmin(long long &a,long long b){
    if(a>b)a=b;
    return;
}

int main()
{
    int n;
    cin >> n;
    long long dp[n];
    long long  h[n];
    for(int i=0;i<n;i++){
        cin >> h[i];
    }

    for(int i=0;i<n;i++)dp[i]=INF;

    dp[0]=0;
    for(int i=1;i<n;i++){
        chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i>1)chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1]<< endl;
}


Measured memory_bytes: 1792