akhauriyash/Code-Regression huggingface dataset:
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  map<vec,int> mp;

  REP(i,n){
    string s;
    cin >> s;
    vec t(26,0);
    REP(i,s.size()) t[s[i]-'a']++;
    mp[t]++;
  }

  int ans = 0;
  ITR(itr,mp) ans += itr->sc*(itr->sc-1)/2;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 29952
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int b[n],w[n];
    for(int i=0;i<n;++i) cin>>b[i]>>w[i];
    for(int i=0;i<n;++i){
      for(int j=n-1;j>i;--j){
        if(w[i]>w[j]){
          swap(b[i],b[j]);
          swap(w[i],w[j]);
        }
      }
    }
    int flag=0,cnt=0;
    for(int i=0;i<n;++i){
      cnt+=b[i];
      if(w[i]<cnt) flag=1;
    }
    if(flag) cout<<"No\n";
    else cout<<"Yes\n";
  }
  return 0;
}

Measured memory_bytes: 3016
pow5 = [0, 1, 32, 243]

def find_x(x):
    while True:
        size = len(pow5)
        for a in range(size):
            for b in range(size):
                pp = pow5[a] - pow5[b]
                if pp == x:
                    return a, b
                pm = pow5[a] + pow5[b]
                if pm == x:
                    return a, -b
                mp = - pow5[a] - pow5[b]
                if mp == x:
                    return -a, b
                mm = - pow5[a] + pow5[b]
                if mm == x:
                    return -a, -b
        pow5.append(size ** 5)


X = int(input())
A, B = find_x(X)
print(A, B)


Measured memory_bytes: 9212
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <set>
#include <cassert>

using namespace std;

vector<vector<int>> e;
set<int> g[2];

void color(int n, int c) {
	g[c].insert(n);
	c = (c + 1) % 2;
	for (int x : e[n]) {
		if (g[c].find(x) == g[c].end()) {
			color(x, c);
		}
	}
}

void assign(set<int>& g, vector<int>& pool, vector<int>& v) {
	set<int> r = g;
	for (int x : g) {
		if (pool.empty()) {
			break;
		}
		v[x] = pool.back();
		pool.pop_back();
		r.erase(x);
	}
	g = r;
}

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = -1, a, b;
		cin >> n;
		if (n < 0) return 0;
		e.clear();
		e.resize(n);
		g[0].clear();
		g[1].clear();
		for (int i = 0; i < n - 1; ++i) {
			cin >> a >> b;
			--a, --b;
			e[a].push_back(b);
			e[b].push_back(a);
		}
		color(0, 0);
		if (g[0].size() > g[1].size()) {
			swap(g[0], g[1]);
		}
		vector<int> pool[3];
		for (int i = 1; i <= n; ++i) {
			pool[i % 3].push_back(i);
		}
		vector<int> vars(n, -1);
		if (g[0].size() <= pool[0].size()) {
			assign(g[0], pool[0], vars);
			for (auto p : pool) {
				assign(g[1], p, vars);
			}
		} else if (g[0].size() >= pool[2].size() && g[1].size() >= pool[1].size()) {
			assign(g[0], pool[2], vars);
			assign(g[0], pool[0], vars);
			assign(g[1], pool[1], vars);
			assign(g[1], pool[0], vars);
		}
		for (int a : vars) {
			cout << " " << a;
			if (a < 0) break;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 31100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF=(1LL<<60);
const int mod=1000000007;

int main(){
    string s; cin >> s;
    int a=0,b=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='0') a++;
        else if(s[i]=='1') b++;
    }

    cout << 2*min(a,b) << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
#include<string.h>
int main(){
    int a[5],max=0,maxid=0,sum=0;
    for(int i=0;i<5;i++){
        scanf("%d",&a[i]);
        if(a[i]%10!=0&&10-a[i]%10>max){
            max=10-a[i]%10;
            maxid=i;
        }
    }
    for(int i=0;i<5;i++){
        if(a[i]%10!=0&&i!=maxid)sum+=a[i]/10*10+10;
        else sum+=a[i];
    }
    printf("%d\n",sum);
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int n;
  int ans = 0;
  cin >> n;
  int v[n], c[n];
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  for(int i = 0; i < n; i++){
    cin >> c[i];
    if(v[i] > c[i]){
      ans += v[i] - c[i];
    }
  }

  cout << ans << endl;
}


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

int main() {
    std::string s;
    std::cin >> s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
    {
        std::cout << "Bad" << std::endl;
    }
    else
    {
        std::cout << "Good" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((100 * a + 10 * b + c) % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a+b+c == 17 && a*b*c == 175){
  cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
    }
}

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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int goo = 0, sichi = 0;
    rep(i, 3){
        int a;
        cin >> a;
        if(a == 5)goo++;
        if(a ==7) sichi++;
    }
    if(goo==2&&sichi==1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int MOD = 1e9 + 7;

signed main(){

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

  vector<int> dp(n+1, 0), pos(n+1 + 2e5, -1);
  for(int i = 0; i < n; i++){
    if(i > 0 && a[i-1] == a[i]){
      dp[i+1] = dp[i];
      continue;
    }
    if(pos[a[i]] == -1){
      dp[i+1] = max(1LL, dp[i]);
      pos[a[i]] = i+1;
    }else{
      dp[i+1] = (dp[i] + dp[pos[a[i]]]) % MOD;
      pos[a[i]] = i+1;
    }
  }
  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 6528
n = int(input())
a = list(map(int, input().split()))
dp = [0]*n
for i in range(n):
  if i == 0:
    pass
  elif i == 1:
    dp[i] = abs(a[i]-a[i-1]) + dp[i-1]
  else:
    dp[i] = min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2])
print(dp[-1])

Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define pb push_back
#define ff first
#define ss second
#define BS binary_search
#define all(c) (c).begin(),(c).end()
#define sz(x) (int)(x).size()
#define EPS 0.000000001 //1e-9
using pii=pair<int,int>;
const long long INF=2e9;

template <class A, class B> ostream& operator<<(ostream& os, const pair<A,B> p) {return os << "(" << p.first << "," << p.second << ")";} 

void dprint(string s) { cout << endl;}
template <class T, class... U> void dprint(string s, T t, U... u) 
{int w = s.find(','); cout << "[" << s.substr(0,w) << ": " << t << "] "; dprint(s.substr(w+1, (int)s.size()-w), u...);} 

#define DEBUG 
#ifdef DEBUG
#define dbg(X...) dprint(#X,X)
#else
#define dbg(X...) "KEEP CALM" 
#endif

const int N=1e5+5; // Don't forget to CHANGE this value ACC. TO Q.

int dp[N];

int32_t main()
{
    IOS;
    int n,W; cin>>n>>W;
    int wt[n+1], val[n+1];
    for(int i=1;i<=n;i++)
        cin>>wt[i]>>val[i];
    for(auto &x: dp)
    {
        x=INF;
    }
    dp[0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=N;j-val[i]>=0;j--)
        {
            dp[j]=min(dp[j], dp[j-val[i]]+wt[i]);
        }
    }

    for(int i=N-1;i>=0;i--)
    {
        if(dp[i]<=W)
            {cout<<i; break;}
    }
    return 0;
}

Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define digit(N) cout << fixed << setprecision((N))

int N, K, R, S, P, ans;

string t, pre = "";

int main()
{
    cin >> N >> K >> R >> S >> P >> t;

    map<char, char> mp;

    mp['r'] = 'p';
    mp['s'] = 'r';
    mp['p'] = 's';

    for (int i = 0; i < N; i++)
    {
        int add;
        if (t[i] == 'r')
            add = P;
        else if (t[i] == 's')
            add = R;
        else if (t[i] == 'p')
            add = S;

        pre += mp[t[i]];

        if (i >= K && pre[i] == pre[i - K])
        {
            add = 0;
            pre[i] = '-';
        }

        ans += add;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
list_w=[]
for x in range(10):
    x=int(input())
    list_w.append(x)
    
list_k=[]    
for y in range(10):
    y=int(input())
    list_k.append(y)
    
list_w.sort()
list_k.sort()

a=list_w[9]+list_w[8]+list_w[7]
b=list_k[9]+list_k[8]+list_k[7]

print(a,b)


Measured memory_bytes: 5600
using System;

namespace AtCoder132D
{
    class Program
    {
        static int MOD = 1000000007;

        static void Main(string[] args)
        {

            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);

            int[][] C = Combinatation(K - 1 < N - K + 1 ? N - K + 1 : K - 1);

            for(int i=1;i<=K;i++)
            {
                long ans = 0;
                if (i <= N - K + 1)
                {
                    long B = C[K - 1][i - 1];
                    long R = C[N - K + 1][i];

                    ans = (B * R) % MOD;
                }


                Console.WriteLine(ans.ToString());
            }
        }

        static int[][] Combinatation(int n)
        {
            int[][] C = new int[n+1][];

            C[0] = new int[1];
            C[0][0] = 1;

            for (int i=1;i<=n;i++)
            {
                C[i] = new int[i + 1];
                C[i][0] = 1;
                C[i][i] = 1;

                for(int j=1;j<i;j++)
                {
                    C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
                }
            }

            return C;
        }
    }
}


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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

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

  int h1[4] = {0, 0, 1, 1}, h2[4] = {0, 1, 0, 1};

  rep(i, 0, 4) {
    int m[n] = {h1[i], h2[i]};
    rep(j, 1, n - 1) {
      m[j + 1] = s[j] == 'o' ? m[j - 1] : !m[j - 1];
      if(!m[j]) m[j + 1] = !m[j + 1];
    }

    int k = s[n - 1] == 'o' ? m[n - 2] : !m[n - 2];
    if(!m[n - 1]) k = !k;
    if(k == m[0]) {
      k = s[0] == 'o' ? m[n - 1] : !m[n - 1];
      if(!m[0]) k = !k;

      if(k == m[1]) {
        rep(i, 0, n) cout << (m[i] ? 'S' : 'W');
        cout << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 976
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void) {
  int n, k, i, cou=0, tmp, len, m;
  long long mod=1000000007;
  char s[100000];
  scanf("%s", s);
  for(len=0; s[len] != '\0'; ++len)
    ; //文字数
  long long dp[len + 1][13]; //dp[上n桁まで][13で割った余り]

  for(i=0; i < len + 1; i++)
    for(k=0; k < 13; k++)
      dp[i][k]=0;

  if(s[0] == '?') for(k=0; k < 10; k++)
    dp[1][k]=1;
  else dp[1][s[0] - 48]=1;

  for(i=1; i < len; i++){
    for(k=0; k < 13; k++){
      if(s[i] == '?'){
        for(m=0; m < 10; m++){
          tmp=(10 * k + m) % 13;
          dp[i + 1][tmp]=(dp[i + 1][tmp] + dp[i][k]) % mod;
        }
      }else{
        tmp=(10 * k + s[i] - 48) % 13;
        dp[i + 1][tmp]=(dp[i + 1][tmp] + dp[i][k]) % mod;
      }
    }
  }
  printf("%lld", dp[len][5]);
  return 0;
}


Measured memory_bytes: 10368
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

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

    if (S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2) == S.at(3)) {
        cout << "Bad" << endl;
    }
    else {
        cout << "Good" << endl;
    }
}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
using namespace std;

int main(){
    int N;
    string s,t;
    cin >> N >> s >> t;
    for(int i=N;i>0;i--){
        bool match=true;
        for(int j=0;j<i;j++){
            if(s[N-i+j] != t[j]) match=false;
        }
        if(match){
            cout << 2*N-i << endl;
            return 0;
        }
    }
    cout << 2*N << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
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

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    if(N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    N /= 2;
    int ans = 0;
    while(N >= 5) {
        ans += N / 5;
        N /= 5;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int size,ans=0,i;
  char s[101];
  scanf("%s",s);
  for(i=7;i<101;i++){
    if(s[i]!=0) size=i;
    else break;
  }
  if(s[0]=='k'&&s[1]=='e'&&s[2]=='y'&&s[3]=='e'&&s[4]=='n'&&s[5]=='c'&&s[6]=='e') {
    ans=1;
  }
  else if(s[0]=='k'&&s[1]=='e'&&s[2]=='y'&&s[3]=='e'&&s[4]=='n'&&s[5]=='c'&&s[size]=='e') {
    ans=1;
  }
  else if(s[0]=='k'&&s[1]=='e'&&s[2]=='y'&&s[3]=='e'&&s[4]=='n'&&s[size-1]=='c'&&s[size]=='e') {
    ans=1;
  }
  else if(s[0]=='k'&&s[1]=='e'&&s[2]=='y'&&s[3]=='e'&&s[size-2]=='n'&&s[size-1]=='c'&&s[size]=='e') {
    ans=1;
  }
  else if(s[0]=='k'&&s[1]=='e'&&s[2]=='y'&&s[size-3]=='e'&&s[size-2]=='n'&&s[size-1]=='c'&&s[size]=='e') {
    ans=1;
  }
  else if(s[0]=='k'&&s[1]=='e'&&s[size-4]=='y'&&s[size-3]=='e'&&s[size-2]=='n'&&s[size-1]=='c'&&s[size]=='e') {
    ans=1;
  }
  else if(s[0]=='k'&&s[size-5]=='e'&&s[size-4]=='y'&&s[size-3]=='e'&&s[size-2]=='n'&&s[size-1]=='c'&&s[size]=='e') {
    ans=1;
  }
  else if(s[size-6]=='k'&&s[size-5]=='e'&&s[size-4]=='y'&&s[size-3]=='e'&&s[size-2]=='n'&&s[size-1]=='c'&&s[size]=='e') {
    ans=1;
  }
  puts(ans?"YES":"NO");
}

Measured memory_bytes: 128
#include <iostream>
// #include <string>
// #include <cstdio>
// #include <functional>
#include <algorithm>
#include <vector>
// #include <stack>
// #include <cmath>
// #include <climits>
// #include <bitset>
// #include <array>
using namespace std;
typedef long long ll;

int V, Mod;
vector<vector<int>> es;
vector<ll> dp0, dp1, x, y;

void erase(vector<int>& v, int x) { v.erase(remove(v.begin(), v.end(), x), v.end()); }

// par[0]=-1 は常に白とする
// dp0[u]=(uを黒, par[u]を白に塗る場合の数)
ll dfs0(int u, int p)
{
	erase(es[u], p);
	for (int v : es[u]) dp0[u] = dp0[u] * (dfs0(v, u) + 1) % Mod;
	return dp0[u];
}

// dp1[u]=(uを白, par[u]を黒に塗る場合の数)
void dfs1(int u)
{
	int W = es[u].size();
	y[W] = 1;
	for (int i = 0; i < W; i++) x[i + 1] = x[i] * (dp0[es[u][i]] + 1) % Mod; // 前からの累積積, x[i] = t[0]*...*t[i-1]
	for (int i = W - 1; i >= 0; i--) y[i] = y[i + 1] * (dp0[es[u][i]] + 1) % Mod; // 後ろからの累積積, y[i] = t[i]*...*t[W-1]
	for (int i = 0; i < W; i++) dp1[es[u][i]] = (dp1[u] + 1) * x[i] % Mod * y[i + 1] % Mod;
	for (int v : es[u]) dfs1(v);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> V >> Mod;
	dp0 = vector<ll>(V, 1);
	dp1 = vector<ll>(V);
	x = vector<ll>(V + 1, 1);
	y = vector<ll>(V + 1, 1);
	for (int i = 0; i < V; i++) es.emplace_back(vector<int>());
	for (int i = 0; i < V - 1; i++)
	{
		int x, y; cin >> x >> y;
		es[x - 1].push_back(y - 1);
		es[y - 1].push_back(x - 1);
	}
	dfs0(0, -1);
	dfs1(0);
	for (int u = 0; u < V; u++) cout << dp0[u] * (dp1[u] + 1) % Mod << endl;
    return 0;
}


Measured memory_bytes: 14192
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long N, long long T, std::vector<long long> c,
           std::vector<long long> t) {
  LL minim = 100000;
  for (int i = 0; i < N; i++) {
    if (t[i] <= T) chmin(minim, c[i]);
  }
  if (minim == 100000) {
    cout << "TLE" << endl;
    return;
  }
  cout << minim << endl;
}

int main() {
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  long long T;
  scanf("%lld", &T);
  std::vector<long long> c(N);
  std::vector<long long> t(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &c[i]);
    scanf("%lld", &t[i]);
  }
  solve(N, T, std::move(c), std::move(t));
  return 0;
}


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

ll powll(ll base,ll exp) { ll res = 1; while(exp>0){ if(exp & 1)res = res * base; base = base * base; exp >>= 1; } return res;}
ll mod_pow(ll base,ll exp) { ll res = 1; while(exp>0){ if(exp & 1)res = res * base % mod; base = base * base % mod; exp >>= 1; } return res % mod;}

ll modinv(ll a) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}


class MComb {
public:
   vector<ll> fact;
   vector<ll> inversed;
   MComb(int n) { // O(n+log(mod))
       fact = vector<ll>(n+1,1);
       for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*i%mod;
       inversed = vector<ll>(n+1);
       inversed[n] = mod_pow(fact[n],(mod-2));
       for (int i = n - 1; i >= 0; i--) inversed[i]=inversed[i+1]*(i+1)%mod;
    }
    ll ncr(int n, int r) {
        if (n < r) return 0;
        if (n < 0 || r < 0) return 0;
       return (fact[n] * inversed[r] % mod * inversed[n-r] % mod);
    }
    ll npr(int n, int r) {
        if (n < r) return 0;
        if (n < 0 || r < 0) return 0;
       return (fact[n] * inversed[n-r] % mod);
    }
    ll nhr(int n, int r) {
       assert(n+r-1 < (int)fact.size());
       return ncr(n+r-1, r);
    }
    ll fac(int n) {
       if(n < 0)return 0;
       return fact[n];
    }
};
MComb comb(2000000);
 
ll ncr(int n, int r) {
   ll res = 1;
   for (int i = n - r + 1; i <= n; i++) res = res * i % mod;
   for (int i = 1; i <= r; i++) res = res * modinv(i) % mod;
   return res;
}

int main()
{
    int x, y; cin >> x >> y;
    if((x + y) % 3) {
        cout << 0 << endl;
        return 0;
    }
    int n = (x + y) / 3;
    x -= n, y -= n;
    if(x < 0 || y < 0) {
        cout << 0 << endl;
        return 0;
    }

    cout << comb.ncr(n, x) << endl;

}

Measured memory_bytes: 34156
N,M=list(map(int,input().split()))
d=[]
for i in range(M):
    p,y=list(map(int,input().split()))
    d.append([p,y,i])

ans=[]
d.sort()
num=1
year=1
i=0
while(i<len(d)):
    if(d[i][0]==num):
        ans.append(['{0:06d}'.format(num)+'{0:06d}'.format(year),d[i][2]])
        year+=1
        i+=1
    else:
        year=1
        num+=1
ans.sort(key=lambda x:x[1])
for i in ans:
    print(i[0])

Measured memory_bytes: 42908
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();//年の数
		int M = scan.nextInt();
		
		int[] kazuN = new int[N];//都市ごとの本数
		
		
		int[] a = new int [M];
		int[] b = new int [M];
		
		for(int i = 0;i<M;i++){
			
			a[i] = scan.nextInt();
			b[i] = scan.nextInt();
			
		}
		
		
		for(int i = 0;i<M;i++){
			for(int j = 1;j<=N;j++){
				
				if(j==a[i]){
					kazuN[j-1]+=1;
				}
				if(j==b[i]){
					kazuN[j-1]+=1;
				}
			
				
			}
			
		
		}
		
		
		
		
		
		
		
		
		
		
		
		for(int i = 0;i<N;i++){//入力したん個の都市ぶん出力
			System.out.println(kazuN[i]);	
		}
		
	}

}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
const int DN=1e5+5;
int n,k,dp[DN],a[DN];
int main() 
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(i>=a[j])
			{
				if(dp[i-a[j]]==0)
				{
					dp[i]=1;
					break;
				}
			}
			else
				break;
		}
	}
	if(dp[k])
		cout<<"First";
	else
		cout<<"Second";
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <functional>
#include <string>
#include <vector>
#include <set>
using namespace std;

#define int long long
#define rep(n, i) for (int i = 0; i < n; i++)
#define rep2(m, n, i) for (int i = m; i < n; i++)
#define rep_r(n, i) for (int i = n - 1; i >= 0; i--)

const int INF = 1LL << 60;
const int MOD = 1e9 + 7;

signed main() {
    int n, k, q;
    cin >> n >> k >> q;
    int count[n];
    fill(count, count + n, 0);
    rep(q, i) {
        int a;
        cin >> a;
        a--;
        count[a]++;
    }
    int score[n];
    fill(score, score + n, k);
    rep(n, i) {
        score[i] -= q - count[i];
    }
    rep(n, i) {
        if (score[i] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}


int main() {
    int n;
    cin >> n;
    map<int,int>mp;
    rep(i,n) {
        int a;
        cin >> a;
        mp[a]++;
    }
    vector<int>edge1;
    for(auto i : mp) {
        if(i.second >= 2)edge1.push_back(i.first);
    }
    sort(edge1.rbegin(),edge1.rend());
    ll ans1 = 0;
    if(edge1.size() >= 2) {
        ans1 = (ll)(edge1[0]) * (ll)(edge1[1]); // 正方形でないとき
    }
    vector<int>edge2;
    ll ans2 = 0;
    for(auto i : mp) {
        if(i.second >= 4) edge2.push_back(i.first);
    }
    sort(edge2.rbegin(),edge2.rend());
    if(edge2.size() >= 1) {
        ans2 = (ll)(edge2[0]) * (ll)(edge2[0]); // 正方形のとき
    }
    if(ans1 == 0 && ans2 == 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << max(ans1,ans2) << endl;

    
    


}

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

int n1,n2;

struct Kruskal{

  struct UnionFind{
    int n;
    vector<int> r,p;
    UnionFind(){}
    UnionFind(int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
    int find(int x){
      return (x==p[x]?x:p[x]=find(p[x]));
    }
    bool same(int x,int y){
      return find(x)==find(y);
    }
    void unite(int x,int y){
      x=find(x);y=find(y);
      if(x==y) return;
      if(r[x]<r[y]) swap(x,y);
      r[x]+=r[y];
      p[y]=x;
    }
  };
  
  struct edge{
    int from,to,cost,used;
    edge(){}
    edge(int from,int to,int cost):
      from(from),to(to),cost(cost),used(0){}
    bool operator<(const edge& e) const{
      return cost<e.cost;
    }
  };

  int n;
  vector<edge> edges;

  Kruskal(){}
  Kruskal(int sz):n(sz){}
  
  void add_edge(int u,int v,int c){
    edges.emplace_back(u,v,c);
  }

  void input(int m,int offset=0){
    int a,b,c;
    for(int i=0;i<m;i++){
      cin>>a>>b>>c;
      add_edge(a+offset,b+offset,c);
    }
  }
  
  int build(){
    sort(edges.begin(),edges.end());
    UnionFind uf(n+1);
    int res=0;
    for(auto &e:edges){
      if(!uf.same(e.from,e.to)){
        int f1=0,f2=0;
        rep(i,n1)if(uf.same(e.from,i))f1++;
        rep(i,n1)if(uf.same(e.to,i))f2++;
        if(!f1||!f2)res+=e.cost;
        uf.unite(e.from,e.to);
      }
    }
    return res;
  }
};
int main(){
  while(cin>>n1>>n2,n1){
    Kruskal K(n1+n2);
    rep(i,n1){
      rep(j,n2){
        int x;
        cin>>x;
        if(x)K.add_edge(i,j+n1,x);
      }
    }
    for(int i=0;i<n2;i++){
      for(int j=i+1;j<n2;j++){
        int x;
        cin>>x;
        if(x)K.add_edge(i+n1,j+n1,x);
      }
    }
    cout<<K.build()<<endl;
  }
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll r;
    cin>>r;
    cout << PI * 2 * r << endl;
}   

Measured memory_bytes: 3800
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b,k;
    scanf("%d%d%d",&a,&b,&k);
    int ans=0;
    for(int i=100;i>=1;i--)
    {
        if(a%i==0&&b%i==0)
            ans++;//printf("%d %d\n",i,ans);
        if(ans==k)
        {
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
#define fir first
#define sec second
using namespace std;

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

const int inf1=2e9+9;
const ll inf2=8e18+9;
const ll mol=1e9+7;
const int maxn=1e6+9;
const ll maxx=1e12+9;

int k;
int vis[maxn];

int main()
{
    cin>>k;
    int num=7,cnt=1;
    while(!vis[num]&&num%k!=0) vis[num]=1,cnt++,num=(num*10+7)%k;
    if(num%k==0) cout<<cnt<<endl;
    else cout<<-1<<endl;
}


Measured memory_bytes: 7060
#include<bits/stdc++.h>
const long long maxn=1e5+100;
using namespace std;
long long n,m,k,t,f[maxn],x,y,d[maxn];bool le;
int getf(int u)
{
    int k;
    if(f[u]==u)
        return u;
    k=f[u];
    f[u]=getf(f[u]);
    d[u]=d[u]+d[k];
    return f[u];
}
void jia(int x,int y,int k)
{
    int i,j;
    i=getf(x);
    j=getf(y);
    f[j]=i;
    d[j]=d[x]-d[y]-k;
}
int main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;++i)
        f[i]=i;
    for(int i=1;i<=m;++i)
    {
        scanf("%lld%lld%lld",&x,&y,&k);
        if(getf(x)!=getf(y))
            jia(y,x,k);
        else
            if(d[y]-d[x]!=k)
        {
            le=1;
        }
    }
    if(le)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}


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


int main(){
	  int H,W;
	  cin >> H >> W;
	  int m[H][W];
	  for(int i=0; i<H; i++)
			for(int j=0; j<W; j++)
				  cin >> m[i][j];

	  int dp[H][W]={};
	  for(int i=0; i<H; i++)
			if(m[i][0] != 1) dp[i][0] = 1;
	  for(int j=0; j<W; j++)
			if(m[0][j] != 1) dp[0][j] = 1;
				  

	  for(int i=1; i<H; i++){
			for(int j=1; j<W; j++){
				  if(m[i][j] == 1) dp[i][j] = 0;
				  else dp[i][j] = min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1])) + 1;
			}
	  }
/*
	  for(int i=0; i<H; i++){
			for(int j=0; j<W; j++)
				  cout << dp[i][j] << " ";
			cout << endl;
	  }
*/
	  
	  int ans = 0;
	  for(int i=0; i<H; i++)
			for(int j=0; j<W; j++)
				  ans = max(ans,dp[i][j]);
	  cout << ans*ans << endl;
	  
}

Measured memory_bytes: 18320
x1,y1,x2,y2 = map(int,input().split())

x = x2 - x1
y = y2 - y1

x3 = x2 - y
y3 = y2 + x
x4 = x1 - y
y4 = y1 + x

print(x3,y3,x4,y4)

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

int main(){
  int N,K,sum=0;
  cin >> N >> K;
  vector<int> x(N);
  rep(i,N){
    cin >> x.at(i);
  }
  rep(i,N){
    int a,b;
    a = x.at(i)*2;
    b = abs(K-x.at(i))*2;
    sum += min(a,b);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
// Problem : 
// 			D - Teleporter
// 			Editorial
// 		
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define re(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	ll n,k;
	cin>>n>>k;
	vi a(n),place;
	loop(i,n)
	{
		cin>>a[i];
		a[i]--;
	}
	vector<bool> vis(n);
	int i=0,len=0;
	while(!vis[i])
	{
		vis[i]=true;
		i=a[i];
		len++;
		if(len==k)
		{
			cout<<i+1<<nl;
			return 0;
		}
	}
	int ssz=1,cpy=i;
	vi ans;
	ans.pb(i);
	i=a[i];
	ans.pb(i);
	while(i!=cpy)
	{
		ssz++;
		i=a[i];
		ans.pb(i);
	}
	int val=(k-len)%ssz;
	cout<<ans[val]+1<<nl;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 4572
#include <bits/stdc++.h>
#define LL long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define MOD(x) ((x)%1000000007)

using namespace std;
const int maxn = 1e5+7;
int odd,even;

struct node
{
    int id,val;
    node(){}
    bool operator < (const node&rhs) const
    {
        return (val>rhs.val);
    }
}cntodd[maxn],cnteven[maxn];

int main()
{
    int n;scanf("%d",&n);
    odd=even=0;
    for (int i=1;i<=n;i++)
    {
        int tmp;
        scanf("%d",&tmp);
        if (i&1) cntodd[tmp].val++;else cnteven[tmp].val++;
    }
    for (int i=1;i<=100000;i++) cntodd[i].id=cnteven[i].id=i;
    sort(cntodd+1,cntodd+1+100000);
    sort(cnteven+1,cnteven+1+100000);
    int mx=0;
    if (cntodd[1].id!=cnteven[1].id)
    {
        mx=cntodd[1].val+cnteven[1].val;
    }
    else
    {
        mx=max(cntodd[1].val+cnteven[2].val,cntodd[2].val+cnteven[1].val);
    }
    printf("%d",n-mx);
    return 0;
}


Measured memory_bytes: 1792
A,B =  map(int,input().split())
b = []
count = 0
if A <0 and B<0:
  A =A + B
if A <= 0 and B >= 0:
  print('Zero')
elif A<0 and A % 2 == 0:
  print('Negative')
else:
  print('Positive')

Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long LL;
const int N=100005;
int l[N],r[N],v[N*2],t[N*4],n,m,k;
LL f[N];
void modify(int p,int l,int r,int x,int y,int z){
	if (x>y) return;
	if (x<=l && r<=y){
		t[p]=z;return;
	}
	if (t[p]) t[p<<1]=t[p<<1|1]=t[p],t[p]=0;
	int mid=(l+r)>>1;
	if (x<=mid) modify(p<<1,l,mid,x,y,z);
	if (y>mid) modify(p<<1|1,mid+1,r,x,y,z);
}
int query(int p,int l,int r,int x){
	if (l==r) return t[p];
	if (t[p]) t[p<<1]=t[p<<1|1]=t[p],t[p]=0;
	int mid=(l+r)>>1;
	if (x<=mid) return query(p<<1,l,mid,x);
		else return query(p<<1|1,mid+1,r,x);
}
LL calc(int x){
	int y=query(1,1,m,x);
	return y?f[y]+(v[l[y]]-v[x]+k)%k:0;
}
int main(){
	scanf("%d%d\n",&n,&k);
	LL sum=0;
	for (int i=1,s=0;i<=n;i++){
		int a,b;
		scanf("%d%d\n",&a,&b);
		sum+=a*=2;
		if (b==1 && a>k){
			printf("-1\n");
			return 0;
		}
		a=(s-a%k+k)%k;
		if (b==1) l[i]=s,r[i]=a;
			else l[i]=0,r[i]=k-1;
		s=a;
	}
	for (int i=1;i<=n;i++)
		v[++m]=l[i],v[++m]=r[i];
	sort(v+1,v+m+1);
	m=unique(v+1,v+m+1)-v-1;
	for (int i=n;i>=1;i--){
		l[i]=lower_bound(v+1,v+m+1,l[i])-v;
		r[i]=lower_bound(v+1,v+m+1,r[i])-v;
		f[i]=calc(l[i]);
		if (l[i]>r[i]) modify(1,1,m,r[i]+1,l[i]-1,i);
			else modify(1,1,m,1,l[i]-1,i),modify(1,1,m,r[i]+1,m,i);
	}
	LL ans=f[1];
	for (int i=1;i<=m;i++) ans=min(ans,calc(i));
	printf("%lld\n",sum+ans);
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  int count=1;
  vector<int>V(N);
  for(int i=0;i<N;i++){
    cin>>V.at(i);
  }
  sort(V.begin(),V.end());
  for(int i=0;i<N-1;i++){
    if(V.at(i)!=V.at(i+1)){
      count++;
    }
  }
  cout <<count <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define LL long long 
LL H, W, A, B;
LL mod = 1000000007;
LL mul[200010];
LL dis[200010];
LL ans;
LL fermat(LL x, LL y) {
	//std::cout << y << std::endl;
	if (y == 0) return 1;
	if (y == 1)	return x;
	if (y % 2 == 1) {
		LL F = fermat(x, y / 2);
		F *= F;
		F%=mod;
		return F*x%mod;
	}
	if (y % 2 == 0) {
		LL F = fermat(x, y / 2);
		F *= F;
		return F%mod;
	}
}

int main() {
	std::cin >> H >> W >> A >> B;
	mul[1] = 1;
	mul[0] = 1;
	for (LL i = 1; i <= H + W - 2; i++) {
		mul[i] = mul[i - 1] * i;
		mul[i]%=mod;
	}
	dis[H + W - 2] = fermat(mul[H + W - 2], mod - 2);
	for (LL i = H + W - 3; i > 0; i--) {
		dis[i] = dis[i + 1] * (i + 1);
		dis[i] %= mod;
	}
	dis[0] = 1;
	for (LL i = B; i < W; i++) {
		LL plus = mul[H - A + i - 1] * dis[i];
		plus %= mod;
		plus *= dis[H - A - 1];
		plus %= mod;
		plus *= mul[W + A - i - 2];
		plus %= mod;
		plus *= dis[A - 1];
		plus %= mod;
		plus *= dis[W - i - 1];
		plus %= mod;
		ans += plus;
		ans %= mod;
	}
	std::cout << ans << std::endl;
	return 0;
}

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

int main()
{
	int n;
	cin>>n;
	long long arr[n];
	long long i,j,b,k,l;
	for(i=0;i<n;i++)
	cin>>arr[i];
	long long minq=INT_MAX;
	for(k=1;k<=100;k++)
	{   b=0LL;
		for(i=0;i<n;i++)
		{   
		   l=(arr[i]-k)*(arr[i]-k);
			b+=l;
		}
		minq=min(minq,b);
	}
	cout<<minq;
}

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

//1
int main()
{
	int n;
	cin >> n;
	int* m = new int[n+1];
	int* o = new int[n + 1];
	for (int i = 1; i <= n; i++)
		cin >> m[i];
	int a = 1;
	for (int i = 1; i <= n; i++)
	{
		o[m[i]] = i;
	}
	for (int i = 1; i <= n; i++)
	{
		cout << o[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
typedef long double ld;
using ll=long long;
using namespace std;
const auto mod=1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  ll n,k; cin >> n >> k;
  int i=0;
  if(n<k) n=min(n,abs(n-k));
  else if(n==k) n=0;
  else{
  	n=min(n%k,abs(k-n%k));
  }
  
 cout << n << endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
cnt=[0]*n
for _ in range(m):
	a,b=map(int,input().split())
	cnt[a-1]+=1
	cnt[b-1]+=1
f=1
for i in range(n):
	if cnt[i]%2!=0:
		f=0
		break
print("YES" if f else "NO")

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int n,m,ans;
int main(){
	cin>>n>>m;
	if (m>=0)
		for (int i=2;i<=n;i++) ans+=m+i-1;
	else if (n<=abs(m))
		for (int i=1;i<=n-1;i++) ans+=m+i-1;
	else
		for (int i=1;i<=n;i++) ans+=m+i-1;
	cout<<ans<<endl;
	return 0;
}

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

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;


int main( ){
    int n;
    cin>>n;
    vi dp(n+1,0);
    dp[0]=dp[1]=1;
    rep(i,2,n+1){
        dp[i]=dp[i-1]+dp[i-2];
    }
    cout<<dp[n]<<endl;
    return 0;
}





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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	5e5;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll vis[MAXN] = {};
/*
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //



ll T = 1;
ll n, x, k, m, r, sum = 0, a, b, l;
string s;

// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	vll a(n+1);
	ll cou = 0;
	for(ll i=1;i<=n;i++) cin >> a[i];
		for(ll i=1;i<=n;i+=2) cou+=(a[i]%2);
	cout<<cou; 
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 15376
/*  -*- coding: utf-8 -*-
 *
 * 2952.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_H = 30;
const int MAX_W = 30;
const int MAX_N = MAX_H * MAX_W;

/* typedef */

/* global variables */

int xs[MAX_N], ys[MAX_N];
char s[MAX_W + 4];

/* subroutines */

inline void setmax(int &a, int b) { if (a < b) a = b; }

/* main */

int main() {
  int h, w;
  scanf("%d%d", &h, &w);

  int n = 0;
  for (int y = 0; y < h; y++) {
    scanf("%s", s);
    for (int x = 0; x < w; x++)
      if (s[x] == 'B') xs[n] = x, ys[n] = y, n++;
  }

  int maxd = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      setmax(maxd, abs(xs[j] - xs[i]) + abs(ys[j] - ys[i]));

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



Measured memory_bytes: 3232
import math

a, b, c, x = [int(input()) for _ in range(4)]

ans = 0
a_min = max(0, math.ceil((x - 100 * b - 50 * c) / 500))
a_max = min(a, math.floor(x / 500))
for ai in range(a_min, a_max + 1):
    b_min = max(0, math.ceil((x - 500 * ai - 50 * c) / 100))
    b_max = min(b, math.floor((x - 500 * ai) / 100))
    ans += b_max - b_min + 1
print(ans)


Measured memory_bytes: 9112
local n=io.read("*n","*l")
local s=io.read()
local t=io.read()

local common=0
for i=1,n do
    if s:sub(#s-i+1,#s)==t:sub(1,i) then
        common=math.max(common,#t:sub(1,i))
    end
end
print(n+n-common)

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

int main() {
	int temp; int count = 0;
	multiset<int, greater<int>> mul;
	while (cin >> temp) mul.insert(temp);
	for (auto itr : mul) {
		cout << itr << endl; count++;
		if (count == 3) break;
	}
	return 0;
}


Measured memory_bytes: 3088
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int B[MAX], C[MAX];

void countingSort(int A[], int B[], int k, int n){
  int i, j;
  for( i = 0 ; i <= k ; i++ ){
    C[i] = 0;
  }
  for( j = 1 ; j <= n ; j++ ){
    C[A[j]]++;
  }
  for( i = 1 ; i <= k ; i++){
    C[i] =  C[i] + C[i-1];
  }
  for( j = n ; j >= 1 ; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  for( i = 1 ; i <= n ; i++ ){
    if( i > 1 ) printf(" ");
    printf("%d", B[i] );
  }
  printf("\n");

}

int main(){
  int A[MAX];
  int n, i, j, k = 0;
  scanf("%d", &n);

  for( i = 0 ; i < n ; i++ ){
    scanf("%d", &A[i+1] );
    if(k < A[i]) k = A[i];
  }

  countingSort(A, B, k, n);

  return 0;
}



Measured memory_bytes: 17428