akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
 
int main(void) {
  int N, i, j;
  scanf("%d", &N);
  
  for(i = 0; i <= N; i+=7){
    j = N - i;
    if(j % 4 == 0){
      printf("Yes");
      return 0;
    }
  }
  printf("No");
}

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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

double dp[3010][3010];

int main() {

	int n;
	cin >> n;
	vector<double> p(n);
	rep(i,n) {
		cin >> p[i];
	}
	rep(i,3010) rep(j, 3010) dp[i][j] = 0;
	dp[0][0] = 1;
	for(int i=0; i<=n-1; i++) for(int j=0; j<=n-1-i; j++) {
		//cout << "i: " << i << " j:" << j << endl;
		dp[i+1][j] += dp[i][j] * p[i+j];
		dp[i][j+1] += dp[i][j] * (1-p[i+j]);
		/*rep(i,n+1) {
			rep(j,n+1) {
				cout << setw(4) << dp[i][j];
			}
			cout << endl;
		}*/
	}
	double ans=0;
	for(int i=n; i>=n/2+1; i--) {
		ans += dp[i][n-i];
	}
	cout << setprecision(20) <<  ans << endl;
	
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

template<int MAX_V>
class dinic{
    struct edge{
        int to;
        uint64_t cap;
        int rev;
    };
    vector<edge> edges[MAX_V];
    int level[MAX_V];
    int next[MAX_V];

    void set_level(int s){
        memset(level, -1, sizeof(level));
        queue<int> Q;
        level[s] = 0;
        Q.push(s);
        while(!Q.empty()){
            int v = Q.front();
            Q.pop();
            for(edge e:edges[v]){
                if(e.cap > 0 && level[e.to] < 0){
                    level[e.to] = level[v] + 1;
                    Q.push(e.to);
                }
            }
        }
    }

    uint64_t blockingflow(int v, int t, uint64_t f){
        if(v == t) return f;
        for(int &i = next[v];i<edges[v].size();i++){
            edge &e = edges[v][i];
            if(e.cap > 0 && level[v] < level[e.to]){
                uint64_t d = blockingflow(e.to, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    edges[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
public:
    void add_edge(int from, int to, uint64_t cap){
        edges[from].push_back({to, cap, (int)edges[to].size()});
        edges[to].push_back({from, 0, (int)edges[from].size()-1});
    }

    uint64_t max_flow(int s, int t){
        uint64_t flow = 0;
        while(true){
            set_level(s);
            if(level[t] < 0) return flow;
            memset(next, 0, sizeof(next));
            int f;
            while((f = blockingflow(s, t, -1)) > 0) flow += f;
        }
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int H, W;
    char a[100][100];
    pair<int,int> s,t;
    cin >> H >> W;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> a[i][j];
            if(a[i][j] == 'S') s = {i,j};
            if(a[i][j] == 'T') t = {i,j};
        }
    }
    if(s.first == t.first || s.second == t.second){
        cout << -1 << endl;
        return 0;
    }

    dinic<20000> G;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(a[i][j] == '.') continue;
            G.add_edge(2*(i*100+j), 2*(i*100+j)+1, 1);
            for(int k=i+1;k<H;k++){
                if(a[k][j]=='.') continue;
                G.add_edge(2*(i*100+j)+1, 2*(k*100+j), -1);
                G.add_edge(2*(k*100+j)+1, 2*(i*100+j), -1);
            }
            for(int k=j+1;k<W;k++){
                if(a[i][k]=='.') continue;
                G.add_edge(2*(i*100+j)+1, 2*(i*100+k), -1);
                G.add_edge(2*(i*100+k)+1, 2*(i*100+j), -1);
            }
        }
    }

    cout << G.max_flow(2*(s.first*100+s.second)+1, 2*(t.first*100+t.second)) << endl;
    
    return 0;
}

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

using ll = long long;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;

int main() {
    string s;
    cin >> s;
    bool f[4] = {};
    for(auto c : s) {
        if(c == 'N') {
            f[0] = true;
        } else if(c == 'S') {
            f[1] = true;
        } else if(c == 'E') {
            f[2] = true;
        } else {
            f[3] = true;
        }
    }
    if(!(f[0] ^ f[1]) && !(f[2] ^ f[3])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



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

using namespace std;

int main(){
	int ans,N,tmp;
	string S;
	cin >> N >> S;
	tmp=0;
	ans=N;
	for(int i=1;i<N;i++){ 
		if(S[i] == 'E'){
			tmp++;
		}
	}
	if(ans > tmp){ ans = tmp;}

	for(int pivot=1;pivot<N;pivot++){
		if(S[pivot]=='E'){ tmp--;}
		if(S[pivot-1]=='W'){ tmp++;}
		if(ans > tmp){ ans = tmp;}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
using namespace std;
const int N=1e6+69;
int n,t1,x1,y,czas;
int32_t main(void) {
    boost;
    cin>>n;
    pii akt=MP(0,0);
    f0(i,n) {
        cin>>t1>>x1>>y;
        int odl=abs(x1-akt.f)+abs(y-akt.s);
        if((odl%2)==((t1-czas)%2)&&odl<=(t1-czas)) {
            akt.f=x1;
            akt.s=y;
            czas=t1;
        }
        else {
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
}


Measured memory_bytes: 256
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from decimal import Decimal 		# a = Decimal(a)	# use this for math questions
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
5
24 11 8 3 16
'''

def solve(l):
	n = len(l)
	ans,maxx = 0,max(l)
	done = [0]*(maxx+1)
	l.sort()
	ans = 0
	d = dict(Counter(l))
	for i in l:
		zz = 2
		while(i*zz <= maxx):
			done[i*zz] = 1
			zz += 1
	for i in l:
		if(not done[i] and d[i] == 1):
			ans += 1
	return ans

N = int(stdin.readline())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l)
print(ans)



Measured memory_bytes: 164240
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int A[1010][1010];
int G[1010][1010];
int nextbattle[1010];
bool used[1010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    rep(i, N) {
        rep(j, N - 1) {
            cin >> A[i][j];
            A[i][j]--;
        }
    }
    bool battle = false;
    int ans = 0;
    int cnt = 0;
    set<int> st;
    set<int> st2;
    rep(i, N) st.insert(i);
    while(cnt < N * (N - 1) / 2) {
        vector<int> v;
        for(auto itr = st.begin(); itr != st.end();) {
            int i = *itr;
            if (nextbattle[i] == N - 1) continue;
            int t = A[i][nextbattle[i]];
            G[i][t] = 1;
            if(G[t][i] && !used[i] && !used[t]) {
                G[i][t] = 0;
                G[t][i] = 0;
                nextbattle[i]++;
                nextbattle[t]++;
                used[i] = true;
                used[t] = true;
                v.push_back(i);
                v.push_back(t);
                battle = true;
                cnt++;
            } else if (G[t][i]) battle = true;
            itr++;
            if (!G[t][i]) st.erase(i);
        }
        // rep(i, N) {
        //     rep(j, N) {
        //         cout << G[i][j];
        //     }
        //     cout << endl;
        // }
        //cout << endl;
        rep(i, v.size()) {
            if (nextbattle[v[i]] != N - 1) st.insert(v[i]);
            used[v[i]] = false;
        }
        //rep(i, N) cout << used[i] << " ";
        //cout << endl;
        ans++;
        if(!battle && cnt < N * (N - 1) / 2) {
            cout << -1 << endl;
            return 0;
        }
        battle = false;

    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 16256
#include<stdio.h>
  
int main(){
    int S[10001],T[501],U[10001];
    int i,j,lengh1,lengh2,count=0,count2=0;
     
    scanf("%d",&lengh1);
    for(i=1;i<=lengh1;i++){
        scanf("%d",&S[i]);}
      
    scanf("%d",&lengh2);
    for(i=1;i<=lengh2;i++){
        scanf("%d",&T[i]);
    }
      
    for(i=1;i<=lengh1;i++){
        for(j=1;j<=lengh2;j++){
        	if(S[i]==T[j]){	
        		count++;
        		U[count]=T[j];}
              }}
	
     count2=count;
	
	for(i=1;i<=count2;i++){
		for(j=i+1;j<=count2;j++){
			if(U[j]==U[i]){
				count--;
				break;}
		}}

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

Measured memory_bytes: 652
#include <iostream>
using namespace std;
int main()
{
	int q;
	cin >> q;
	for(int i=0;i<q;i++)
	{
		int from,to;
		cin >> from >> to;
		if(from < to)
		{
			for(int j=from;j<to;j++)cout << j << ' ';
			cout << to << endl;
			continue;
		}
		if(from<=5)
		{
			for(int j=from;j>to;j--)cout << j <<  ' ';
			cout << to << endl;
		}
		else if(to>5)
		{
			for(int j=from;j<=9;j++)cout << j << ' ';
			for(int j=5;j>=0;j--)cout << j << ' ';
			for(int j=1;j<5;j++)cout << j << ' ';
			for(int j=5;j<to;j++)cout << j << ' ';
			cout << to << endl;
		}
		else
		{
			for(int j=from;j<=9;j++)cout << j << ' ';
			for(int j=5;j>to;j--)cout << j << ' ';
			cout << to << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#define taskname ""

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
#define long long long

const int N = 16 + 10;
const int MOD = 1e9 + 7;

int n, a[N][N], mark[1 << N];
long dp[1 << N];

inline int bit(int i, int mask) {return (mask >> i) & 1;}
void cre_dp()
{
    for (int mask = 1; mask < (1 << n); ++mask) {
        for (int i = 0; i < n; ++i) if (bit(i, mask))
            for (int j = i + 1; j < n; ++j) if (bit(j, mask))
                dp[mask] += a[i][j];
    }
}

long get(int mask)
{
    if (mark[mask]) return dp[mask];
    for (int t = (mask - 1) & mask; t; t = (t - 1) & mask)
        dp[mask] = max(dp[mask], get(t) + get(mask ^ t));

    mark[mask] = 1;
    return dp[mask];
}

int main()
{
//    freopen(taskname".INP", "r", stdin);
//    freopen(taskname".OUT", "w", stdout);
    cin.tie(nullptr); ios_base::sync_with_stdio(false);

    cin >> n;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j) cin >> a[i][j];
    cre_dp();
    cout << get((1 << n) - 1);

    return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> vec;
	vec.resize(M);
	rep(i,M){
		cin >> vec[i];
	}

	int total = 0;
	rep(i,M){
		total += vec[i];
	}
	int ans = N - total;
	if(ans>=0) cout << ans << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s;
    cin>>n>>s;
    ll num=0;
    for(int i=0;i<n;i++){
        if(i==0){
            num++;
        }
        else{
            if(s[i]!=s[i-1])num++;
        }
    }
    cout << num<<endl;
    return 0;
}

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

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int n;
  cin >> n;

  int ans = 0;
  for(int i = 3; i <= n; i+=2) {
    int count = 0;
    for(int j = 1; j <= i; ++j) {
      if(i%j == 0) count++;
    }
    if(count == 8) {
      ans++;
    }
  }
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3652
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
#define MAX_N 3000
#define INF 1000000000
vector<ll> G[MAX_N];
ll d[MAX_N];
signed main(){
  init_io();
  ll n,x,y;
  ll ans[MAX_N]={};
  cin >> n >> x >> y;
  x--;
  y--;
  for(int i=0;i<n-1;i++){
    G[i+0].push_back(i+1);
    G[i+1].push_back(i+0);
  }
  G[x].push_back(y);
  G[y].push_back(x);
  queue<P> que;
  for(int i=0;i<n;i++){
    fill(d,d+MAX_N,INF);
    que.push(P(i,0ll));
    while(!que.empty()){
      P tmp = que.front();
      que.pop();
      ll v = tmp.first,dis=tmp.second;
      if(d[v]<=dis) continue;
      d[v] = dis;
      for(auto nv:G[v]){
        que.push(P(nv,dis+1));
      }
    }
    for(int j=0;j<n;j++){
      ans[d[j]]++;
    }
  }
  for(int i=1;i<=n-1;i++){
    cout << ans[i]/2<<endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
map<string,int> mp;
int main() {
    long test=1;
    // cin>>test;
    while(test--)
    {
	long t,i,j,n,a,b,c,d,ans,A,B;
	string s,s1,s2,s3;
	cin>>s1>>s2;
	if(s1.length()!=s2.length())
	{
	    if(s1.length()<s2.length())cout<<"LESS";
	    else cout<<"GREATER";
	}
	else
 	{
	    if(s1==s2)cout<<"EQUAL";
	    else if(s1>s2)cout<<"GREATER";
	    else cout<<"LESS";
 	}
    }
	return 0;
}

Measured memory_bytes: 256
i = list(map(int, input().split()))
j=int(i[0]/(i[1]+i[2]))
k=j*i[1]
if i[0]%(i[1]+i[2])>=i[1]:
  print(k+i[1])
else:
  print(k+i[0]%(i[1]+i[2]))

Measured memory_bytes: 3060
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

a, b, h, m = MAP()
sheta = abs(math.radians(((60*h+m)/2)-6*m))
print(math.sqrt(a**2 + b**2 -2*a*b*math.cos(min(sheta, math.pi*2-sheta))))

Measured memory_bytes: 73004
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
aN =LIST()

# Kがでかいのは論外
if max(aN) < K:
    print('IMPOSSIBLE')
    exit()

# aN全部の最大公約数を取る
base = gcd_list(aN)
if K % base == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


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

int main() {
  int count=0;
  int N;
  string S;
  cin>>N>>S;
  rep(i,N-2){
    if(S[i]=='A' and S[i+1]=='B' and S[i+2]=='C'){
    count++;
    }
  }
  cout<<count;
}

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

int main(){
	int n; cin>>n;
	int arr[n], dp[n];
	for(int i = 0; i < n; i++) cin>>arr[i];
	dp[0] = 0; dp[1] = abs(arr[1] - arr[0]);
	for(int i = 2; i < n; i++) dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]), dp[i-2] + abs(arr[i] - arr[i-2]));
	cout<<dp[n-1]<<endl;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    string s;
    cin >> s;

    printf("%c%d%c\n", s[0], s.size() - 2, s[s.size() - 1]);
    return 0;
}


Measured memory_bytes: 3720
N=int(input())
A=[int(input()) for i in range(N)]
A.sort()
c=1
ans=0

for i in range(1,N):
    if A[i]!=A[i-1]:
        if c%2==1:
            ans+=1
        c=1
    else:
        c+=1

if c%2==1:
    ans+=1

print(ans) 

Measured memory_bytes: 7388
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int n, k, x, y;

    cin >> n >> k >> x >> y;

    if (n > k) {
        n -= k;
        cout << k * x + n * y << endl;
    }
    else {
        cout << n * x << endl;
    }
}


Measured memory_bytes: 256
import collections
n = int(input())
s = []
for _ in range(n):
    s.append(input())

c = collections.Counter(s)
max_count = max(c.values())
ans = []
for k, v in c.items():
    if v == max_count:
        ans.append(k)
ans.sort()
for ans_one in ans:
    print(ans_one)

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

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

void _main() {
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    REP (i, H) cin >> s[i];
    REP (i, H) REP (j, W) {
        if (s[i][j] == '#') {
            bool ok = false;
            REP (k, 4) {
                int ny = i + dy[k];
                int nx = j + dx[k];
                if (ny >= 0 && ny < H && nx >= 0 && nx < W && s[ny][nx] == '#') {
                    ok = true;
                }
            }
            if (!ok) {
                cout << "No" << endl;
                return;
            }
        }
    }
    cout << "Yes" << endl;
}

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

Measured memory_bytes: 256
import sys


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


def next_int() -> int:
    return int(next_str())


def main() -> None:
    n = next_int()
    pre = -1
    ans = 0

    for i in range(n):
        a = next_int()
        if a == pre:
            ans += 1
            pre = -1
        else:
            pre = a

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int A, B, Q;
    cin >> A >> B >> Q;
    ll s[100002], t[100002], x[100000][5];
    for(int i=1;i<A+1;i++)
        cin >> s[i];
    for(int i=1;i<B+1;i++)
        cin >> t[i];
    for(int i=0;i<Q;i++){
        cin >> x[i][0];
        for(int j=1;j<=4;j++)
            x[i][j] = -1;
    }
    s[0] = -1;
    t[0] = -1;
    s[A+1] = LLONG_MAX;
    t[B+1] = LLONG_MAX;

    // 二分探索
    // 神社s
    int l, r;
    for(int i=0;i<Q;i++){
        r = int(lower_bound(s, s + A + 2, x[i][0]) - s);
        // cout << "r =  " << r << endl;
        l = r - 1;
        if(r != A+1)
            x[i][3] = s[r] - x[i][0];
        if(l != 0)
            x[i][1] = x[i][0] - s[l];
    }
    // 寺t
    for(int i=0;i<Q;i++){
        r = int(lower_bound(t, t + B + 2, x[i][0]) - t);
        // cout << "r =  " << r << endl;
        l = r - 1;
        if(r != B+1)
            x[i][4] = t[r] - x[i][0];
        if(l != 0)
            x[i][2] = x[i][0] - t[l];
    }

    /*
    // 神社s
    for(int i=0;i<Q;i++){
        for(int j=0;j<A;j++){
            if(j==0 && x[i][0] < s[j])
                x[i][3] = s[j] - x[i][0];
            if(j<A-1 && s[j] <= x[i][0] && x[i][0] <= s[j+1]){
                x[i][1] = x[i][0] - s[j];
                x[i][3] = s[j+1] - x[i][0];
            }
            if(j==A-1 && s[j] < x[i][0])
                x[i][1] = x[i][0] - s[j];
        }
    }
    
    // 寺t
    for(int i=0;i<Q;i++){
        for(int j=0;j<B;j++){
            if(j==0 && x[i][0] < t[j])
                x[i][4] = t[j] - x[i][0];
            if(j<B-1 && t[j] <= x[i][0] && x[i][0] <= t[j+1]){
                x[i][2] = x[i][0] - t[j];
                x[i][4] = t[j+1] - x[i][0];
            }
            if(j==B-1 && t[j] < x[i][0])
                x[i][2] = x[i][0] - t[j];
        }
    }
    */

    /*
    for(int i=0;i<Q;i++){
        cout << x[i][0] << " " << x[i][1] << " " << x[i][2] << " " << x[i][3] << " " << x[i][4] << endl;
    }
    */

    
    ll min, d;
    for(int i=0;i<Q;i++){
        min = LLONG_MAX;
        // 左直進
        if(x[i][1] != -1 && x[i][2] != -1){
            d = max(x[i][1], x[i][2]);
            if(d < min)
                min = d;
        }
        // 右直進
        if(x[i][3] != -1 && x[i][4] != -1){
            d = max(x[i][3], x[i][4]);
            if(d < min)
                min = d;
        }
        // 左神社右寺
        if(x[i][1] != -1 && x[i][4] != -1){
            d = 2*x[i][1] + x[i][4];
            if(d < min)
                min = d;
            d = x[i][1] + 2*x[i][4];
            if(d < min)
                min = d;
        }
        // 左寺右神社
        if(x[i][2] != -1 && x[i][3] != -1){
            d = 2*x[i][2] + x[i][3];
            if(d < min)
                min = d;
            d = x[i][2] + 2*x[i][3];
            if(d < min)
                min = d;
        }
        cout << min << endl;
    }

    return 0;
}

Measured memory_bytes: 6784
from collections import deque
def solve():
    n,q = map(int,input().split())
    l = [[] for _ in range(n)]
    fl = [True for _ in range(n)]
    dp = [0]*n
    for _ in range(n-1):
        a,b = map(int,input().split())
        l[a-1].append(b-1)
        l[b-1].append(a-1)
    for _ in range(q):
        p,x = map(int,input().split())
        p-=1
        dp[p]+=x
    d = deque()
    d.append(0)
    fl[0] = False
    while len(d):
        it = d.pop()
        for i in l[it]:
            if fl[i]:
                dp[i]+=dp[it]
                fl[i]=False
                d.append(i)
    for i in range(n):
        print(dp[i],end=' ')
    print()
if __name__=='__main__':
    solve()

Measured memory_bytes: 52988
#include <iostream>

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

ll n;
ll k;
ll fsum;
ll bsum;
ll ans;
int main() {
  cin >> n >> k;

  for(int i = 0; i < k; i++) fsum += i;
  for(int i = n; i > n - k; i--) bsum += i;
  ans += bsum - fsum + 1;
  for(int i = k; i <= n; i++) {
    fsum += i;
    bsum += n - i;
    ans += bsum - fsum + 1;
  }

  cout << ans % mod << endl;
}
  
 


Measured memory_bytes: 3628
n = gets.to_i
as = gets.split.map(&:to_i)

ss = Array.new(n + 1, 0)
min = 2020202020

as.each_with_index do |a, i|
  ss[i + 1] = ss[i] + a
end

total = ss.last
ss.each do |sl|
  sr = total - sl
  diff = (sl - sr).abs

  min = diff if diff <= min
end

puts min


Measured memory_bytes: 17668
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> x(N);
  REP(i, N) cin >> x[i];
  int ans = abs(x[0] - X);
  REP(i, N) ans = gcd(ans, abs(x[i] - X));
  cout << ans << endl;
  return 0;
}

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

int main()
{
	int n,m;
	cin >> n >> m;
	vector<string> a(n);
	vector<string> b(m);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(int i = 0; i < m; i++) {
		cin >> b[i];
	}
	for(int i = 0; i <= n-m; i++) {
		for(int j = 0; j <= n-m; j++) {
			bool ok = true;
			for(int k = 0; k < m; k++) {
				for(int l = 0; l < m; l++) {
					if(a[j+l][i+k] != b[l][k]) {
						ok = false;
						break;
					}
				}
				if(!ok)
					break;
			}
			if(ok) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

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

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 400005;
const int mod = 1e9 + 7;

ll fat[N];

ll expr(ll b, ll e){
	ll ans = 1;
	while(e){
		if(e&1){
			ans = (ans * b) % mod;
		}
		e >>= 1;
		b = (b * b) % mod;
	}
	return ans;
}

ll inv(ll b){
	return expr(b, mod-2);
}

ll C(int k, int n){
	return fat[n] * inv(fat[k] * fat[n-k] % mod) % mod;
}

int main() {
	fat[0] = 1;
	for(int i = 1; i < N; i++){
		fat[i] = (fat[i-1] * i) % mod;
	}
	int n, k;
	scanf("%d %d", &n, &k);
	ll ans = 0;
	for(int i = 0; i <= min(n-1, k); i++){
		ll aux = C(i, n);
		aux *= C(i, n-1);
		ans += aux;
		ans %= mod;
		//cerr << i << " " << n << " " << aux << endl;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3328
import scala.io.StdIn.readLine

object Main extends App {

  for (_ <- 1 to 300) {
    val input = readLine.split(" ").map(_.toInt)
    val (h, w) = (input(0), input(1))

    if (h == 0 && w == 0) sys.exit() else {
      for (e <- 1 to h) {
        var line = scala.collection.mutable.ArrayBuffer[String]()
        // 奇数行
        if (e % 2 == 1) for (e <- 1 to w) {
          if (e % 2 == 1) line += "#" else line += "."
        }
        // 偶数行
        else for (e <- 1 to w) {
          if (e % 2 == 1) line += "." else line += "#"
        }
        println(line.mkString)
      }
      println()
    }
  }

}



Measured memory_bytes: 47928
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
using namespace std;
typedef long long LL;
const int N=2e5;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int son[N][2],len[N],dis[N];
LL ans,mid;
vector< pair<LL,LL> >v[N];
pair<LL,LL>p1[N],p2[N];
#define lc son[k][0]
#define rc son[k][1]
#define x first
#define y second
#define pb push_back
#define mp make_pair
inline void init(int k,LL &pre) {
	if (!len[k]) ans=max(ans,pre),pre=dis[k];
	else {
		init(lc,pre+=dis[lc]);
		init(rc,pre+=dis[rc]);
		pre+=dis[k];
	}
}
inline void dfs(int k) {
	v[k].clear();
	if (!len[k]) { v[k].pb(mp(dis[k],dis[k])); return; }
	dfs(lc);
	dfs(rc);
	int ls=v[lc].size(),rs=v[rc].size(),i,j,l1=0,l2=0,len=-1;
	for (i=0,j=rs;i<ls;i++) {
		while (j&&v[lc][i].y+v[rc][j-1].y<=mid) j--;
		if (j==rs) continue;
		if (!l1||v[rc][j].x<p1[l1].y) p1[++l1]=mp(v[lc][i].x,v[rc][j].x);
	}
	swap(ls,rs);
	swap(lc,rc);
	for (i=0,j=rs;i<ls;i++) {
		while (j&&v[lc][i].y+v[rc][j-1].y<=mid) j--;
		if (j==rs) continue;
		if (!l2||v[rc][j].x<p2[l2].y) p2[++l2]=mp(v[lc][i].x,v[rc][j].x);
	}
	for (i=j=1;i<=l1||j<=l2;)
		if (i<=l1&&(j>l2||p1[i].x<p2[j].x)) {
			if (len==-1||p1[i].y<v[k][len].y) v[k].pb(p1[i]),len++;
			i++;
		} else if (i>l1||p1[i].x>p2[j].x) {
			if (len==-1||p2[j].y<v[k][len].y) v[k].pb(p2[j]),len++;
			j++;
		} else v[k].pb(mp(p1[i].x,min(p1[i].y,p2[j].y))),i++,j++,len++;
	for (i=0;i<=len;i++) v[k][i].x+=dis[k],v[k][i].y+=dis[k];
}
int main()
{
	int n=gi(),i,k;LL t=0,l,r;
	for (i=2;i<=n;i++) k=gi(),son[k][len[k]++]=i,dis[i]=gi();
	init(1,t);
	for (l=0,r=ans;l!=r;) {
		mid=(l+r)>>1;
		dfs(1);
		if (v[1].size()) r=mid;
		else l=mid+1;
	}
	printf("%lld\n",l);
	return 0;
}


Measured memory_bytes: 32616
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int f(int x,int y)
{
	return (x+y-1)/y;
}
int solve(int n,int k)
{
	while(n%k!=0){
		int to=n/k*k;
		n-=f(n-to,n/k+1)*(n/k+1);
	}
	return n/k;
}
int main()
{
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int a,k;
		scanf("%d %d",&a,&k);
		ans^=solve(a,k);
	}
	if(ans)printf("Takahashi\n");
	else printf("Aoki\n");
	return 0;
}

Measured memory_bytes: 256
n=int(input())
ab=[list(map(int,input().split()))for i in range(n)]
ab.sort(key=lambda x:x[0]+x[1],reverse=True)
b=[i[1]for i in ab]
s=[i[0]+i[1]for i in ab]
print(sum(s[::2])-sum(b))

Measured memory_bytes: 32232
/*********************
*                    *
* Nothing Impossible *
*                    *
*********************/
#include <algorithm>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for (int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld; 
using namespace std;

int main()
{
	string s;
	cin >> s;
	int x;
	Rep(i, 0, s.size())
	{
		if((i) % 2 == 0)
		{
			cout << s[i];
		}
	}
	return 0;
}





Measured memory_bytes: 512
N = int(input())
C = []
S = []
F = []
T = [0 for i in range(N)]

for i in range(N-1):
    c,s,f = map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(1,N):
    time = S[-i] + C[-i]
    for j in range(1,i):
        if time < S[-(i-j)]:
            time = S[-(i-j)] + C[-(i-j)]
        else:
            dev = (time - S[-(i-j)]) % F[-(i-j)]
            if(dev != 0):
                time = (time + (F[-(i-j)] - dev) + C[-(i-j)])
            else:
                time = time + C[-(i-j)]
    T[-(i+1)] = time

for t in T:
    print(t)

Measured memory_bytes: 3188
#include <iostream>
#define LEN 10001

using namespace std;
int prime_pair(int N);
int prime_list(int MAX);
bool prime[LEN] = {0};

int main(void){
	int input;
    prime_list(LEN);
    while(cin >> input){
        cout << prime_pair(input) << endl;
	}
	return 0;
}

int prime_list(int MAX){
    prime[0] = 1;
    prime[1] = 1;
    for(int i = 2; i*i < MAX; i++){
        for(int j = i*2; j < MAX; j += i){
            prime[j] = 1;
        }
    }
    return 0;
}

int prime_pair(int N){
    int count = 0;
    for(int i = 1; i <= N; i++){
        if((!prime[i]) && (!prime[N-i+1])) count++;
    }
    return count;
}

Measured memory_bytes: 1168
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  int N, M, C;  //N個のソースコード, M個の数字, Cというバイアス
  cin >> N >> M >> C;

  //長さMの配列を作る。要素を0で初期化
  vector<int> B(M, 0);
  for (int i = 0; i < M; i++){
    cin >> B[i];
  }

  //N*Mの配列を作る
  //Aは, vector<int>の長さNの配列
  //これを, vector<int>(M)で初期化(長さMの配列)
  vector<vector<int> > A(N, vector<int>(M));
  for (int i = 0; i < N; i++){
    for (int j = 0; j < M; j++){
      cin >> A[i][j];
    }
  }

  int ans = 0;
  for(int i = 0; i < N; i++){
    int sum = 0;
    for(int j = 0; j < M; j++){
      sum += A[i][j] * B[j];
    }
    sum += C;
    if(sum>0) ans++;
  }
  cout << ans << endl;
}


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

int main()
{
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < W + 2; ++i)
    cout << "#";
  cout << endl;
  for (int i = 0; i < H; ++i)
  {
    cout << "#";
    {
      string s;
      cin >> s;
      cout << s;
    }
    cout << "#";
    cout << endl;
  }
  for (int i = 0; i < W + 2; ++i)
    cout << "#";
  return 0;
}


Measured memory_bytes: 256
def main():
    n,x,m = map(int,input().split())
    
    #Compute i^2%m
    rem = [(i**2)%m for i in range(m)]

    #Find the cycle and its sum in n
    visited = [False for i in range(m)]
    idx = x
    s = x
    d = 1

    while not visited[idx]:
        visited[idx] = True
        s += rem[idx]
        idx = rem[idx]
        d += 1
        #print(s,idx,d)

    newsum = x
    newidx = x
    newd = 1
    while newidx!=idx:
        newsum += rem[newidx]
        newd += 1
        newidx = rem[newidx]

    #Adds newsum until it gets to idx, until n=newd
    #Cycles with sum s-newsum taking d moves
    d = d - newd
    s = s - newsum

    ans = x
    ansn = 1
    if newd<n:
        ans = newsum
        ansn = newd
    if ansn+d<=n:
        ans += s*((n-ansn)//d)
        ansn += ((n-ansn)//d) * d    
    #print(ans)
    while ansn<n:
        ansn += 1
        ans += rem[idx]
        idx = rem[idx]

    print(ans)
    #print(rem,newsum,newd,s,d)


if __name__=="__main__":
    main()

Measured memory_bytes: 79864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second

int main() {

   string s;
   cin>>s;
   
   if(s[0]=='9'||s[1]=='9')
      cout<<"Yes";
   
   else
      cout<<"No";
    
    

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

/* RangeMinimumQuery(0-index) */

struct RMQ{
  typedef int Type;
  int segn2;
  Type inf;
  vector<Type> data;
  
  RMQ(int n){
    inf = INF; //init value
    for(segn2=1;segn2<n;segn2*=2);
    data.assign(segn2*2,inf);
  }
  
  //get minimum value [a,b]
  Type query(int a,int b,int l=0,int r=-1,int k=0){
    if(r==-1) r+=segn2;
    if(a<=l && r<=b) return data[k];
    if(r<a || b<l) return inf;
    return min(query(a,b,l,(l+r)/2,k*2+1),query(a,b,(l+r)/2+1,r,k*2+2));
  }
  
  //set kth number x
  void set(int k,Type x){
    k+=segn2-1;
    data[k]=x;
    while(k>0){
      k=(k-1)/2;
      data[k]=min(data[k*2+1],data[k*2+2]);
    }
    return;
  }
};




int main(){
  int n,t,a[SIZE];
  
  scanf("%d%d",&n,&t);

  RMQ rmq(n);

  for(int i=0;i<n;i++){
    scanf("%d",a+i);
    rmq.set(i,a[i]);
  }

  int max_d = 0;
  int ans = 0;
  
  for(int i=n-1;i>=0;i--){
    
    int d = a[i] - rmq.query(0,i);
    
    if(max_d == d){
      ans ++;
    }
    
    if(max_d < d){
      max_d = d;
      ans = 1;
    } 

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


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

class dice {
private:
	int n[7];

public:
	dice(int, int, int, int, int, int);
	int getcur() { return n[1]; }
	void rotate(char);
};

dice::dice(int n1, int n2, int n3, int n4, int n5, int n6) {
	n[1] = n1;
	n[2] = n2;
	n[3] = n3;
	n[4] = n4;
	n[5] = n5;
	n[6] = n6;
}

void dice::rotate(char op) {
	dice copy(n[1], n[2], n[3], n[4], n[5], n[6]);
	switch (op) {
	case'W':
		n[1] = copy.n[3];
		n[3] = copy.n[6];
		n[6] = copy.n[4];
		n[4] = copy.n[1];
		break;
	case'E':
		n[1] = copy.n[4];
		n[3] = copy.n[1];
		n[6] = copy.n[3];
		n[4] = copy.n[6];
		break;
	case'S':
		n[1] = copy.n[5];
		n[2] = copy.n[1];
		n[6] = copy.n[2];
		n[5] = copy.n[6];
		break;
	case'N':
		n[1] = copy.n[2];
		n[2] = copy.n[6];
		n[6] = copy.n[5];
		n[5] = copy.n[1];
		break;
	}

}

int main() {
	int n[7];
	for (int i = 1; i <= 6; i++) {
		cin >> n[i];
	}
	dice a(n[1], n[2], n[3], n[4], n[5], n[6]);

	char op;
	while (cin >> op) {
		a.rotate(op);
		//cerr << a.getcur() << endl;
	}
	cout << a.getcur() << endl;
	return 0;
}

Measured memory_bytes: 1160
fn main() {
    proconio::input! {
        n: usize,
        uv: [(usize, usize); n - 1],
    }

    let mut r = n * (n + 1) * (n + 2) / 6;
    for (u, v) in uv {
        let (u, v) = if u < v { (u, v) } else { (v, u) };
        r -= u * (n - v + 1);
    }

    println!("{}", r);
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; ll M; cin >> N >> M;
    vector<vector<ll>> dp(3*N+1,vector<ll>(N+1,0));
    dp[0][0]=1;
    for (int i=0;i<3*N;++i){
        for (int j=0;j<=N;++j){
            (dp[i+1][j]+=dp[i][j])%=M;
            if (i+2<=3*N&&j+1<=N) (dp[i+2][j+1]+=dp[i][j]*(i+1)%M)%=M;
            if (i+3<=3*N&&j+1<=N) (dp[i+3][j+1]+=dp[i][j]*(i+2)*(i+1)%M)%=M;
        }
    }
    ll ans=0;
    for (int j=0;j<=N;++j) (ans+=dp[3*N][j])%=M;
    cout << ans << '\n';
}

Measured memory_bytes: 94336
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <queue>
using namespace std;

int main(){
  int n, l;
  cin >> n >> l;
  vector<int>a(n);
  for(int i=0; i<n; i++)cin >> a[i];
  for(int i=0; i<n-1; i++){
    if(a[i]+a[i+1]>=l){
      cout << "Possible\n";
      for(int j=1; j<i+1; j++)cout << j << endl;
      for(int j=n-1; j>=i+1; j--)cout << j << endl;
      return 0;
    }
  }
  cout << "Impossible";
  return 0;
}


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

int main() {
	int number,a = 1;
	cin >> number;
	while (number >= std::pow(10,a)) {
		a++;
	}

	int c = number, d = 0, s = 0;
	for (int i = a; 0 < i; i--) {
		if (i != 1) {
			d = std::pow(10, i - 1);
			s += c / d;
			c -= (c / d) * d;
		}
		else s += c;
	}
	if (number % s == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	system("pause");
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, K;
int a[110];
bool dp[110000];
signed main() {
    cin >> N >> K;
    rep(i, N) { cin >> a[i]; }
    reps(i, 110000 - 1) {
        rep(j, N) {
            if (i >= a[j] && !dp[i - a[j]]) { dp[i] = true; }
        }
    }
    if (dp[K]) { cout << "First" << endl; }
    else { cout << "Second" << endl; }
}


Measured memory_bytes: 3732
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7; 
const int MINF = -1050000000;


int main() {
	
	int n;
	cin >> n;
	map<int,int> a;
	rep(i, n) {
		int x;
		cin >> x;
		a[x]++;
	}
	int cnt = 0;
	for (auto x : a) {
		if (x.second % 2 == 1) cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
//#define int long long
    



signed main(){
    string s;
    cin >> s;
    int a = int(s[0]-'0')*1000+int(s[1]-'0')*100+int(s[2]-'0')*10+int(s[3]-'0'),b=int(s[5]-'0')*10+int(s[6]-'0'),c=int(s[8]-'0')*10+int(s[9]-'0');
  int k=a*10000+b*100+c;
  if(k<=20190430)cout<<"Heisei";
  else cout << "TBD";
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	
int a,b,d,r;
double f;

	scanf("%d %d",&a,&b);
	d = a/b;
	r = a%b;
	f =(double)a/(double)b;
	
	printf("%d %d %lf",d,r,f);
	return 0;
}

Measured memory_bytes: 636
def solve(str):
  for idx, s in enumerate(str):
    if idx+1 < len(str) and s == str[idx+1]:
      return idx+1, idx+2
    elif idx+2 < len(str) and s == str[idx+2]:
      return idx+1, idx+3
  return -1, -1

if __name__ == "__main__":
  s = input()
  first, last = solve(s)
  print(first, last)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;

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

int n, ans, a[N], dp[N];

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

    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
      scanf("%d", a + i);
    }
    dp[1] = 1;//i. elemana kadar gelen artmayan subsegmentin basi hangi indisten basliyor.
// a[]    10 4 8 7 3
// dp[]    1 1 3 3 3
    for(int i = 2; i <= n; i++){
      if(a[i] <= a[i - 1])
        dp[i] = dp[i - 1];
      else
        dp[i] = i;
      ans = max(ans, (i - dp[i]));
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 4736
N = int(input())
s = input()

# 「連続する1の数」のリストに変換する
s = s[s.find('1'):] # 先頭の'0'を取り除く
while s.count('000'):
    s = s.replace('000', '00')
cs = list(map(len, s.split('0')))

# dp[i]: i番目の「連続する1」への各処理（操作に使わない／左の１つだけ使う／右の１つを残して使う／全て使う）
#        に対して、現時点での操作回数の最大値
dp = [[-float('inf')] * 4 for i in range(len(cs))]
dp[0][0] = 0
for i in range(1, len(cs)):
    if cs[i] == 0:
        dp[i][3] = max(dp[i - 1])
        continue

    # 使わない
    dp[i][0] = max(dp[i - 1])
    # 全て使う
    dp[i][3] = max(dp[i - 1][0] + max(cs[i - 1], cs[i]), \
                   dp[i - 1][1] + max(cs[i - 1] - 1, cs[i]), \
                   dp[i - 1][2] + cs[i], \
                   dp[i - 1][3])
    if cs[i] >= 2:
        # 左の１つだけ使う
        dp[i][1] = max(dp[i - 1][0] + cs[i - 1], \
                       dp[i - 1][1] + cs[i - 1] - 1, \
                       dp[i - 1][2] + 1, \
                       dp[i - 1][3])
        # 右の１つを残して使う
        dp[i][2] = max(dp[i - 1][0] + max(cs[i - 1], cs[i] - 1), \
                       dp[i - 1][1] + max(cs[i - 1] - 1, cs[i] - 1), \
                       dp[i - 1][2] + cs[i] - 1, \
                       dp[i - 1][3])

print(max(dp[-1]))        


Measured memory_bytes: 36904
#include<stdio.h>

int main(){
  int box[100001]={},i,n,cnt=0;
  long a[100000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
    if(a[i]>100000)
      cnt++;
    else if(box[a[i]]<a[i])
      box[a[i]]++;
    else
      cnt++;
  }
  for(i=1;i<=100000;i++){
    if(box[i]!=i)
      cnt+=box[i];
  }
  printf("%d\n",cnt);
}

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

using namespace std;


int main() {
    int H, W, h, w;
    int res;

    cin >> H;
    cin >> W;
    cin >> h;
    cin >> w;

    res = H * W - h * W - H * w + h * w;

    cout << res;

    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  for (int v1 : G[0]) {
    for (int v2 : G[v1]) {
      if (v2 == N - 1) {
        cout << "POSSIBLE" << '\n';
        return 0;
      }
    }
  }
  cout << "IMPOSSIBLE" << '\n';
  return 0;
}


Measured memory_bytes: 12016
#include <iostream>

using namespace std;
int n;
int a[4];
string s;
int main()
{
    //freopen("test.inp","r", stdin);
    cin >> n;
    while (n--)
    {
        cin >> s;
        if (s == "AC") a[0]++;
        if (s == "WA") a[1]++;
        if (s == "TLE") a[2]++;
        if (s == "RE") a[3]++;
    }
    cout << "AC x " <<a[0] <<endl;
    cout << "WA x " <<a[1] <<endl;
    cout << "TLE x " <<a[2] <<endl;
    cout << "RE x " <<a[3] <<endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> h(n,0);
	vector<int> dp(n,INT_MAX);
	dp[0] = 0;

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

	for(int i=1; i<n; i++){
		if(n < k){
			dp[n-1] = abs(h[n-1] - h[0]);
			break;
		}else{
			for(int j=1; j<=k; j++){
				if (i < j) break;
				dp[i] = min(dp[i-j]+abs(h[i-j]-h[i]),dp[i]);
			}
		}
	}
	// for(int j=1; j<=k; j++){
	// 	if(n < k){
	// 		dp[n-1] = abs(h[n-1] - h[0]);
	// 		break;
	// 	}else{
	// 		for(int i=1; i<n; i++){
	// 			if (j == 1) {
	// 				dp[i] = dp[i-1]+abs(h[i-1]-h[i]);
	// 			}else{
	// 				if (i < j) break;
	// 				compare_num = dp[i];
	// 				cout << compare_num << " ";
	// 				dp[i] = min(dp[i-j]+abs(h[i-j]-h[i]),compare_num);
	// 			}
	// 			// cost_num = min(dp[i-j]+abs(h[i-j]-h[i]),dp[i-j+1]+abs(h[i-j+1]-h[i]));
	// 			// cost_num = min(dp[i-j]+abs(h[i-j]-h[i]),dp[i]);
	// 			// dp[i] = min(dp[i],cost_num);
	// 		}
	// 	}
	// }
	// for(int i=0; i<n; i++){
	// 	cout << dp[i] << " ";
	// }
	cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024