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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}	
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


///////////////////////////BFS//////////////////////////////////
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
    } 

}

void solve()
{

}

void fac(int n, map<int, int>& ct)
{
	for(int i = 2; i <= sqrt(n); i++)
	{
		while(n%i==0)
		{
			n/=i;
			ct[i]++;
		}
	}
	if(n>=2) ct[n]++;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	
	int n;
	cin>>n;
	map<int, int> ct;
	ll ans = 1, mod = 1000000007;;
	for(int i = 2; i <= n; i++)
	{
		fac(i, ct);
	}
	for(auto i:ct)
	{
		ans = ((ans%mod)*((i.se+1)%mod))%mod;
	}
	p(ans);
	return 0;
}	

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <math.h>
#include <string.h>
#include <map>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#define INF 100000
#define MAX 100005

using namespace std;
#define For(i, a, b) for ( int i = (a); i < (b); i++ )
#define Fors(i, sz) for ( size_t i = 0; i < sz.size (); i++ )
#define Set(a, s) memset (a, s, sizeof (a))
 #define EXPLORED 2
#define VISITED 1
#define UNVISITED 0
typedef long long int ll;
 typedef pair<int,int> ii;
 typedef vector<ii> vii;
 typedef vector <int > vi;
 vector<vii> adj(MAX);
 
int main()
{
 
 //  freopen("input.txt","r",stdin);
 //freopen("output.txt","w",stdout);
 string s1,s2;
cin>>s1>>s2;
ll p=min(s1.size(),s2.size());
for(ll i=0;i<p;i++)
  cout<<s1[i]<<s2[i];
if(s1.size()<s2.size())
  cout<<s2[s2.size()-1]<<endl;
if(s1.size()>s2.size())
  cout<<s1[s1.size()-1]<<endl;
return 0;

}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main(){
    int n;
    cin>>n;
    int l[n];
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    int max=l[0];
    int sum=l[0];
    for(int i=1;i<n;i++){
        if(l[i]>max){
            max=l[i];
        }
        sum=sum+l[i];
    }
    if(sum-2*max>0){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}

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

int main()
{
    int n;
    cin>>n;
    bool ok=false;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            if(i*j==n)
            {
                ok=true;
                break;
            }
        }
    }
    if(ok)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return  0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

using ll =  long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}
}


int main() {

	int a, b;
	std::cin >> a >> b;

	if (a <= b) {
		rep(i, b) {
			std::cout << a;
		}
	}
	else {
		rep(i, a) {
			std::cout << b;
		}
	}

	std::cout << std::endl;

	return 0;
}

Measured memory_bytes: 256
from collections import deque
n,m = map(int,input().split())
rootlist = [[] for i in range(n)]
flag = [False]*n

for i in range(m):
    a,b= map(int,input().split())
    rootlist[a-1].append(b)
    rootlist[b-1].append(a)

que = deque([1])
while que:
    now = que.popleft()
    for room in rootlist[now-1]:
        if flag[room-1] == False:
            flag[room-1] = now
            que.append(room)

print('Yes')
for root in flag[1:]:
    print(root)

Measured memory_bytes: 34908
from random import random
from sys import setrecursionlimit

setrecursionlimit(10 ** 6)


class TreapNode:
    _value = None
    _priority = None
    _count = None
    _left = None
    _right = None

    def __init__(self, value):
        self._value = value
        self._priority = random()
        self._count = 1


def treap_rotate_right(n):
    l = n._left
    n._left = l._right
    l._right = n
    return l


def treap_rotate_left(n):
    r = n._right
    n._right = r._left
    r._left = n
    return r


def treap_insert(n, v):
    if n is None:
        return TreapNode(v)
    if n._value == v:
        n._count += 1
        return n
    if n._value > v:
        n._left = treap_insert(n._left, v)
        if n._priority > n._left._priority:
            n = treap_rotate_right(n)
    else:
        n._right = treap_insert(n._right, v)
        if n._priority > n._right._priority:
            n = treap_rotate_left(n)
    return n


def treap_delete(n, v):
    if n is None:
        raise Exception('no nodes')
    if n._value > v:
        n._left = treap_delete(n._left, v)
        return n
    if n._value < v:
        n._right = treap_delete(n._right, v)
        return n

    # n._value == v
    if n._count > 1:
        n._count -= 1
        return n

    if n._left is None and n._right is None:
        return None

    if n._left is None:
        n = treap_rotate_left(n)
    elif n._right is None:
        n = treap_rotate_right(n)
    else:
        # n._left is not None and n._right is not None
        if n._left._priority < n._right._priority:
            n = treap_rotate_right(n)
        else:
            n = treap_rotate_left(n)
    return treap_delete(n, v)


def treap_size(n):
    if n is None:
        return 0
    return n._count + treap_size(n._left) + treap_size(n._right)


def treap_str(n):
    if n is None:
        return ""
    result = []
    if n._left is not None:
        result.append(treap_str(n._left))
    result.append("%d:%d" % (n._value, n._count))
    if n._right is not None:
        result.append(treap_str(n._right))
    return ' '.join(result)


def treap_search(n, v):
    # v 未満で最大のノードを検索する. v 未満のノードがなければ None を返す
    if n is None:
        return None
    if n._value >= v:
        if n._left is None:
            return None
        return treap_search(n._left, v)
    # n._value < v
    if n._right is None:
        return n
    r = treap_search(n._right, v)
    if r is None:
        return n
    return r


class Treap:
    _root = None
    _size = 0

    def insert(self, v):
        self._root = treap_insert(self._root, v)
        self._size += 1

    def delete(self, v):
        self._root = treap_delete(self._root, v)
        self._size -= 1

    def __len__(self):
        return self._size

    def __str__(self):
        return treap_str(self._root)

    def search(self, v):
        return treap_search(self._root, v)


N = int(input())
A = [int(input()) for _ in range(N)]

t = Treap()
for a in A:
    n = t.search(a)
    if n is not None:
        t.delete(n._value)
    t.insert(a)
print(len(t))


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

int main(){
  int num_1,num_2;
  int i,j;
  string ID[257];
  string ID_2;
  int flg=0; //flg = 0→施錠 flg = 1→開錠 
  cin >> num_1;
  for(i = 0 ; i < num_1 ; i++){
    cin >> ID[i];
  }

  cin >> num_2;

  for(i = 0 ; i < num_2 ; i++){
    int flg_2 = 0;
    cin >> ID_2;
    for(j = 0 ; j < num_1 ; j++){
      if(ID_2==ID[j]&&flg==0){
	flg = 1;
	flg_2 = 1;
	cout << "Opened by" << " " << ID_2 << endl;
      }else if(ID_2==ID[j]&&flg==1){
	flg = 0;
	flg_2 =1;
	cout << "Closed by" << " " << ID_2 << endl;
      }else{
	continue;
      }
    }
    if(flg_2 == 0){
      cout << "Unknown" << " " << ID_2 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1220
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
MOD=10**9+7
A=get_i
num=array(N+1,0)
ans=1
A.each do|a|
  if a.zero?
      ans*=3-num[0]
  else
      ans*=(num[a-1]-num[a])
  end
  ans%=MOD
  num[a]+=1
end
#p num
puts ans

Measured memory_bytes: 21852
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long ten, K;
  cin >> N >> ten >> K;
  long long T;
  vector<long long>vec(N);
  for(int i=0;i<N;i++){
  cin >> T;
    vec.at(i)=T;
  }
  sort(vec.begin(), vec.end());
  long long A, B, C;
  A=0;//台数
  B=0;//乗車人数
  C=0;//到着時間
  C=vec.at(0);
  B=1;
  A=1;
  for(int j=1;j<N;j++){
  if(vec.at(j)<=C+K && B<ten){
  B++;
  }else{
    A++;
    B=1;
    C=vec.at(j);
  }
  }

  cout << A << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7; 
void read(int &x){
	char ch=getchar();x=0;
	for (;ch==' '||ch=='\n';ch=getchar());
	for (;ch!=' '&&ch!='\n';x=x*10+ch-'0',ch=getchar());
}
void reads(string &s){
	char ch=getchar();s="";
	for (;ch==' '||ch=='\n';ch=getchar());
	for (;ch!=' '&&ch!='\n';s+=ch,ch=getchar());
}
void write(int x){
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
string s;
int D,dp[10004][2][104];
int main(){
	reads(s),read(D);
	int n=s.size();s="$"+s;
	for (int i=1;i<=n;i++) s[i]-='0';
	dp[0][0][0]=1;
	for (int i=1;i<=n;i++)
		for (int j=0;j<2;j++)
			for (int k=0;k<D;k++)
				for (int l=0;l<10;l++){
					if (j==0 && l>s[i]) continue;
					if (j==0 && l==s[i]){
						dp[i][j][(k+l)%D]=(dp[i][j][(k+l)%D]+dp[i-1][j][k])%MOD;
						continue;
					}
					dp[i][1][(k+l)%D]=(dp[i][1][(k+l)%D]+dp[i-1][j][k])%MOD;
				}
	write((dp[n][0][0]+dp[n][1][0]-1+MOD)%MOD);
}

Measured memory_bytes: 8448
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;
int n,m,a[100][100],b[100][100],dp[81][81][12810];

bool check(int i , int j){
    return (i < n && j < m);
}

int Rec(int i , int j , int sum){

    if(i == n - 1 && j == m - 1)  return min(abs(sum  + a[i][j] - b[i][j] - 6400) , abs(sum - a[i][j] + b[i][j] - 6400));

    if(dp[i][j][sum] != -1)  return dp[i][j][sum];

    int Res = 1e9;
    if(check(i + 1 , j))
    {
        Res = min(Res , Rec(i + 1 , j , sum - a[i][j] + b[i][j]));
        Res = min(Res , Rec(i + 1 , j , sum + a[i][j] - b[i][j]));
    }

    if(check(i , j + 1)){
        Res = min(Res , Rec(i , j + 1 , sum - a[i][j] + b[i][j]));
        Res = min(Res , Rec(i , j + 1, sum + a[i][j] - b[i][j]));
    }
    return dp[i][j][sum] = Res;
}

int main()
{
    memset(dp , -1 , sizeof(dp));
    cin >> n >> m;
    for(int i =0;i<n;i++){
        for(int j =0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(int i =0;i<n;i++){
        for(int j =0;j<m;j++){
            scanf("%d",&b[i][j]);
        }
    }
    cout << Rec(0 , 0 , 6400);
    return 0;
}


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

typedef long long lli;
typedef vector<int> Vi;
typedef vector<lli> Vl;
typedef pair<int, int> Pii;
typedef pair<lli, lli> Pll;


//===


int main() {
	int N, M;
	cin >> N >> M;
	Vl A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	vector<Pll> p(M);
	for (int i = 0; i < M; ++i) {
		cin >> p[i].second >> p[i].first;
	}
	sort(p.begin(), p.end());

	int idx = 0;
	for (int i = M - 1; i >= 0; --i) {
		lli ci = p[i].first;
		lli bi = p[i].second;
		int cnt = 0;
		while (idx < N && cnt < bi && A[idx] < ci) {
			A[idx] = ci;
			++idx;
			++cnt;
		}
		if (idx >= N) break;
	}

	lli sum = 0;
	for (int i = 0; i < N; ++i) {
		sum += A[i];
	}
	cout << sum << endl;
}

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

int main() {
  int N; cin >> N;
  pair<int, pair<string, int>> R[N];
  string s; int p;
  for (int i = 0; i < N; i++) {
    cin >> s >> p;
    R[i] = make_pair(i, make_pair(s, p));
  }
  sort(R, R+N, [](auto &a, auto &b) {
    if (a.second.first == b.second.first)
      return a.second.second > b.second.second;
    return a.second.first < b.second.first;
  });
  for (int i = 0; i < N; i++) cout << R[i].first + 1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define min(a,b) ((a)>(b)?(b):(a))

int main(void){
	int n,k;
	scanf("%d%d",&n,&k);
	int i;
	int ans = 1;
	int temp = 1;
	for(i=0;i<n;i++){
		if(temp*2>(k+temp)){
			temp +=k;
		}else{
			temp *=2;
		}
		//printf("%d\n",temp);
	}
	printf("%d",temp);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

int N, W;
vector<int> v_vec, w_vec;
int dp[101][10001];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> W;
  v_vec.resize(N);
  w_vec.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> v_vec[i] >> w_vec[i];
  }
  fill(dp[0], dp[101], 0);

  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= W; j++) {
      if (j - w_vec[i] >= 0) {
        dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w_vec[i]] + v_vec[i]);
      } else {
        dp[i + 1][j] = dp[i][j];
      }
    }
  }

  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 7160
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 1e9+7;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}

int main() {
  int h,w; cin>>h>>w;
  int u[26]={};
  for(int i=0;i<h;i++) {
    string s; cin>>s;
    for(int j=0;j<w;j++) {
      u[s[j]-'a']++;
    }
  }
  int m4=0, m2=0, m1=0;
  if (h%2==1 && w%2==1) {
    m1 = 1;
    m2 = h+w-2*m1;
    m4 = h*w-(m1+m2);
  } else if (h%2==1) {
    m1 = 0;
    m2 = w;
    m4 = h*w-m2;
  } else if (w%2==1) {
    m1 = 0;
    m2 = h;
    m4 = h*w-m2;
  } else {
    m1 = m2 = 0; m4 = h*w;
  }
  m2/=2; // 上と左だけでよい
  m4/=4; // 左上部分だけでよい

  for(int i=0,j=0;i<m4;i++) {
    if (j == 26) {
      cout<<"No"<<endl;
      return 0;
    }
    if (u[j] >= 4) {
      u[j]-=4;
    } else {
      j++; i--;
    }
  }

  for(int i=0,j=0;i<m2;i++) {
    if (j == 26) {
      cout<<"No"<<endl;
      return 0;
    }
    if (u[j] >= 2) {
      u[j]-=2;
    } else {
      j++; i--;
    }
  }

  for(int i=0,j=0;i<m1;i++) {
    if (j == 26) {
      cout<<"No"<<endl;
      return 0;
    }
    if (u[j] >= 1) {
      u[j]-=1;
    } else {
      j++; i--;
    }
  }
  cout<<"Yes"<<endl;
}

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

int main(){
	int r,c,S[101][101]={0};
	cin >> r >> c;
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cin >> S[i][j];
			S[i][c]+=S[i][j];
		}
	}

	for(int i=0;i<=c;i++){
		for(int j=0;j<r;j++){
			S[r][i]+=S[j][i];
		}
	}

	for(int i=0;i<=r;i++){
		for(int j=0;j<=c;j++){
			if(j)cout << " ";
			cout << S[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

#define allof(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 105;

int N;
int arr[2][MAXN];

int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    cin >> N;
    for(int a = 1; a <= N; a++){
        cin >> arr[0][a];
    }
    for(int a = 1; a <= N; a++){
        cin >> arr[1][a];
    }
    for(int a = 1; a <= N; a++){
        arr[0][a] += arr[0][a - 1];
        arr[1][N - a] += arr[1][N - a + 1];
    }
    int ans = 0;
    for(int a = 1; a <= N; a++){
        ans = max(ans, arr[0][a] + arr[1][a]);
    }
    cout << ans;
}


Measured memory_bytes: 256
loop do
  cards = readline.chomp.chars
  break if cards.first == '-'
  times = readline.to_i
  hs = times.times.map { readline.to_i }.inject(:+)
  i = hs % cards.length
  a, b = cards[0, i], cards[i, cards.length]
  puts [b, a].flatten.join
end

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

double f(double e, double x, double y) {
    return fabs(e - sqrt(x * x + y * y));
}

int main(){
    int d, e;
    while (cin >> d >> e, d + e) {
        double ans = 1e9;
        for (int x = 0; x <= d; x++) {
            int y = d - x;
            ans = fmin(ans, f(e, x, y));
        }
        printf("%.5lf\n", ans);
    }
}



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

#define rep(i,x) for(int i=0;i<x;i++)	
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rep_to(a,i,x) for(int i=a;i<x;i++)

using namespace std;

int main()
{
	int n;
	map<string,int>F1;
	cin >> n;
	while(n--)
	{
		string s;
		cin >> s;
		F1[s]=1;
	}

	int m,ct=0;
	cin >> m;
	while(m--)
	{
		string s;
		cin >>s;
		if(F1[s])
		{
			ct++;
			if(ct%2)cout << "Opened by " << s << endl;
			else cout << "Closed by " << s << endl;
		}
		else 
			cout << "Unknown " << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1240
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i = 0;i < (n); ++i)

int main() {
	ll n, k;
	cin >> n >> k;
	ll count = 1;
	ll x = n;
	if (n == k) {
		cout << 2 << endl;
		return 0;
	}
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
		while(true) {
		
		x /= k;
		count++;
		if (x < k)break;

	}
	cout << count << endl;
	return 0;
}

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

int main() {
  string O, E;
  cin >> O >> E;
  string A;
  
  for (int i = 0 ; i < ( O.length() + E.length() ) ; i++ ){
    if ( (i + 1) % 2 == 1 ){
      A.push_back(O.at( (i+1)/2 ));
    }
    else {
      A.push_back(E.at( (i+1)/2 - 1));
    }
  }


  cout << A;
}


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

const int MAX_N = 8;
int N, A, B, C;
int l[MAX_N] = {};
const int INF = pow(10, 9);

int dfs(int num, int a, int b, int c) {
    // 使った本数が与えられた本数に達した時．
    if (num == N) {
        int abc[] = {a, b, c};
        int tmp = abs(A - a) + abs(B - b) + abs(C - c) - 30;
        return (*min_element(abc, abc + 3) > 0) ? tmp : INF;
    }
    int ret[4];
    // 合成魔法を使わない(延長,縮小魔法のみの場合など?)
    ret[0] = dfs(num + 1, a, b, c);
    // それぞれに合成魔法使う
    ret[1] = dfs(num + 1, a + l[num], b, c) + 10;
    ret[2] = dfs(num + 1, a, b + l[num], c) + 10;
    ret[3] = dfs(num + 1, a, b, c + l[num]) + 10;

    return *min_element(ret, ret + 4);
}

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

    cin >> N >> A >> B >> C;

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

    cout << dfs(0, 0, 0, 0) << "\n";

    return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1073741824")

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<deque>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<fstream>
#include<iterator>
#include<functional>
#include<bitset>
#include<memory>
#include<sstream>
#include<new>
#include<cassert>
#include<iomanip>

using namespace std::placeholders;

typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::pair<bool, bool> pbb;

const int inf = (int)2 * 1e9;
const ll linf = (ll) 1e18 * 8;
const ld eps = 1e-5;
const int mod = (int) 1e9 + 7;

#define it(v) begin(v), end(v)
#define pb push_back
#define eb emplace_back
#define mp std::make_pair
#define fst first
#define scn second
#define sgn(x) (x > 0 ? 1 : (x == 0 ? 0 : -1))

int main()
{
	std::ios_base::sync_with_stdio(false);
	ll x, y;
	std::cin >> x >> y;
	int res = 0;
	while (x <= y)
	{
		res++;
		x *= 2;
	}
	std::cout << res;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	int ans = (N + 1) / 2;
	cout << ans << endl;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int MAXM = (int)1e5 + 3;
const int MAXN = (int)403;
const int infint = (int)1e9 + 3;
const ll inf = (ll)1e15;
int u[MAXM], v[MAXM], n, m;
int bad[MAXN], has[MAXN][MAXN];
int main()
{
	ios::sync_with_stdio(false); 
	cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < m; i++)
		cin >> u[i] >> v[i];
	reverse(u, u + m), reverse(v, v + m);
	for (int i = 1; i <= n; i++)
	{
		has[i][i] = 1;
		for (int j = 0; j < m; j++)
			if(has[i][u[j]] == 1 && has[i][v[j]] == 1)
			{
				bad[i] = 1;
				break;
			}
			else
			if(has[i][u[j]] == 1 && has[i][v[j]] == 0)
				has[i][v[j]] = 1;
			else
			if(has[i][v[j]] == 1 && has[i][u[j]] == 0)
				has[i][u[j]] = 1;
	}
	int ted = 0;
	for (int i = 1; i <= n; i++)
		for (int j = i + 1; j <= n; j++)
			if(!bad[i] && !bad[j])
			{
				bool flg = 0;
				for (int k = 1; k <= n; k++)
					flg |= (has[i][k] & has[j][k]);
				ted += 1 - flg;
			}
	cout << ted;
}


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

int main(){
  int N;
  cin >> N;
  string s;
  int p;
  vector<tuple<string, int, int>> sp(0);
  for(int i=0; i<N; i++){
    cin >> s >> p;
    sp.push_back(make_tuple(s, 100 - p, i + 1)); //失点が少ない順
  }

  sort(sp.begin(), sp.end());
  
  for(int i=0; i<N; i++){
    int order = get<2>(sp.at(i));
    cout << order << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

struct UnionFind {  // {{{
    vector<int> u;
    explicit UnionFind(int n) : u(n + 5, -1) {}
    int size(int x) { return -u[root(x)]; }
    int root(int x) { return (u[x] < 0) ? x : (u[x] = root(u[x])); }
    bool same(int x, int y) { return (root(x) == root(y)); }
    bool unite(int x, int y) {
        return (x = root(x)) == (y = root(y)) ? false
                                              : (u[x] += u[y], u[y] = x, true);
    }
};  // }}}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(int, N, M);

    vector<int> a(N);
    vector<int> pos(N);

    rep(i, 0, N) {
        read(a[i]);
        --a[i];
        pos[a[i]] = i;
    }

    UnionFind uf(N);
    rep(i, 0, M) {
        var(int, p, q);
        --p, --q;
        uf.unite(p, q);
    }

    int ans = 0;
    rep(n, 0, N) {
        if (uf.same(n, pos[n])) ++ans;
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    int  x,y=0,n;
    cin>> n;
    x=n*800;



    for(int i=15;i<=n;++i){
        if (i%15==0)
        y+=200;
        else
        continue;
    }

    cout <<x-y;
}

Measured memory_bytes: 256
A = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
B = [int(input()) for _ in range(n)]

F = [0]*101
for b in B:
  F[b]=1

ans = 'No'  
for i in range(3):
  c = 0
  d = 0
  for j in range(3):    
    c += F[A[i][j]]
    d += F[A[j][i]]
  if c==3 or d==3:
    ans ='Yes'
if F[A[0][0]]+F[A[1][1]]+F[A[2][2]] == 3 or F[A[0][2]]+F[A[1][1]]+F[A[2][0]] == 3:
  ans ='Yes'
  
print(ans)

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
    ft
    int t,i,j,n,m,l,r;
    char a,b;
    cin>>a>>b;
    ((a=='H' && b=='H') || (a=='D' && b=='D'))? cout<<"H\n": cout<<"D\n";
    return 0;
}



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

const int maxn=1e5+10;
int n,m,p[maxn],ans;
int vis[maxn];
vector<int> g[maxn],vec;

void dfs1(int pos){
	vis[pos]=1;
	vec.push_back(p[pos]);
	for(int i=0;i<g[pos].size();++i)
		if(!vis[g[pos][i]])
			dfs1(g[pos][i]);
}
void dfs2(int pos){
	vis[pos]=2;
	if(binary_search(vec.begin(),vec.end(),pos))
		++ans;
	for(int i=0;i<g[pos].size();++i)
		if(vis[g[pos][i]]!=2)
			dfs2(g[pos][i]);
}

int main(){
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		cin>>p[i];
	for(int i=1,u,v;i<=m;++i){
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i=1;i<=n;++i)
		if(!vis[i]){
			vec.clear();
			dfs1(i);
			sort(vec.begin(),vec.end());
			dfs2(i);
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORr(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORr(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

int main(void){
  int n, k;
  cin >> n >> k;
  vector<double> p(n);
  REP(i, n) cin >> p[i];

  vector<double> e(n);
  //(n(n+1)/2)/n = n+2/2
  REP(i, n) e[i] = (1+p[i])/2;

  double sum_e = 0;
  //0~k-1までのk個を足しとく
  REP(i, k) sum_e += e[i];
  double ans = sum_e;
  for(int i = 1; i+k-1 < n; i++){
    sum_e += e[i+k-1];
    sum_e -= e[i-1];
    chmax(ans, sum_e);
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vvint(v, w, n) vector<int> v(n); vector<int> w(n); REP(i,n) cin >> v[i] >> w[i];
#define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v, n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v, n1, n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v, n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()
#define len(v) (v).length()
#define FIND(s, n) (s.find(n) != s.end())
#define SORT(a) sort(all(a))

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};


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

	long long x;

	cin >> x;
	if(x%11 >= 1 && x%11 <=6) cout << 2*(x/11)+1 << endl;
	else if(x%11 == 0) cout << 2*(x/11-1)+2 << endl;
	else  cout << 2*(x/11)+2 << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
arr = [1]*(n+1)
mod = 10**9+7
def factorization(n):
    global arr
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] += cnt%mod

    if temp!=1:
        arr[temp] += 1
        arr[temp] %= mod

    if arr==[]:
        arr[n] += 1
        arr[n] %= mod


for i in range(1,n+1):
    factorization(i)

#print(arr)

anslist = [0]*(n+1)
anslist[1] = arr[1]%mod
for i in range(2,n+1):
    anslist[i] = anslist[i-1]*arr[i]
print(anslist[n]%mod)

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

int main() {
    string word;
    map<string, set<int>> m;
    while(cin >> word) {
        int page;
        cin >> page;
        m[word].insert(page);
    }
    for(auto& p : m) {
        cout << p.first << endl;
        for(auto it = p.second.begin(); it != p.second.end(); ++it) {
            if(it != p.second.begin()) {
                cout << ' ';
            }
            cout << *it;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3184
from subprocess import*
with open('e.cpp','w')as f:f.write(r"""
#include<iostream>
using namespace std;
main(){
  int n;
  string s;
  cin>>n>>s;
  int a=0;
  for(int i=0;i<n;++i){
    int t=0;
    for(int j=0;j<n-i;++j){
      t=(t+1)*(s[j]==s[j+i]);
      a=max(a,min(t,i));
    }
  }
  cout<<a;
}""")
call(('g++','e.cpp'))
call('./a.out')

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

int main() {   
     int N;
     long long ans = 0;
      cin >> N;
      vector<string> s(N);
      map<string, long long> strcnt;
      for(int i = 0; i < N; i++){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        strcnt[s]++;
     }

     for(pair<string,long long> p: strcnt){
         ans += p.second * (p.second-1)/2;
     }
     cout << ans << endl;
     return 0;


    
    //  for(int i = 0; i < N; i++ ){
    //     for(int j = i+1; j < N; j++){
    //     bool flag = true;
    //     for(int k = 0; k < 10; k++){
    //     if(s[i][k] != s[j][k]){
    //     flag = false;
    //     break;
    //     }
    //     }
    //          if(flag == true){
    //              ans++;
    //          }
    //      }
    //  }
    // cout << ans << endl;
    // return 0;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vl v(n);
	REP(i, n)cin >> v[i];
	ll ret = v[0];
	REP(i, n - 1) {
		ret = ret / gcd(ret, v[i+1])*v[i+1];
	}
	cout << ret << endl;
}


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

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTS(s) printf("%s\n",(s))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

typedef long long ll;




int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	PRINTD((a + b+1) / 2);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

vector<pair<int,int>> edge[100010];
// dp[i]:=白黒
int dp[100010];

bool dfs(int from, int color){
    if(dp[from]==color) return true;
    if(dp[from]!=-1) return false;
    dp[from]=color;
    bool ret=true;
    for(auto z:edge[from]){
        int to=z.first;
        int cost=z.second;
        if(cost) ret&=dfs(to,color^1);
        else ret&=dfs(to,color);
    }
    return ret;
}

struct UnionFind{
    // 頂点数(1-indexed)
    const int V;
    // par[x]:=xのroot
    vector<int> par;
    // sz[x]:=xを含む集合のサイズ
    vector<int> sz;
    UnionFind(const int V):V(V){
        par.resize(V+1);
        for(int i=0;i<=V;i++) par[i]=i;
        sz.resize(V+1,1);
    }
    bool unite(int x,int y){
        x=root(x),y=root(y);
        if(same(x,y)) return false;
        if(y<x) swap(x,y);
        par[y]=x;
        sz[x]+=sz[y];
        return true;
    }
    int root(int x){
    	if(par[x]==x) return x; // xはroot
    	return (par[x]=root(par[x])); // xの親のroot
    }
    bool same(int x,int y){
    	return (root(x)==root(y));
    }
    int size(int x){
        return sz[root(x)];
    }
};

int main(){
    rep(i,100010) dp[i]=-1;
    int n,m; cin>>n>>m;
    UnionFind uf(n);
    for(int i=0;i<m;i++){
        int u,v,w; cin>>u>>v>>w;
        w%=2;
        edge[u].push_back({v,w});
        edge[v].push_back({u,w});
        uf.unite(u,v);
    }
    rep(i,100010) dp[i]=-1;
    bool white[100010]={};
    for(int i=1;i<=n;i++){
        if(uf.par[i]==i){
            if(dfs(i,0)) white[i]=1;
        }
    }
    rep(i,100010) dp[i]=-1;
    bool black[100010]={};
    for(int i=1;i<=n;i++){
        if(uf.par[i]==i){
            if(dfs(i,1)) black[i]=1;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(uf.par[i]==i){
            if(white[i]&&black[i]) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11776
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll N,C,K,T[100001],npos=0,shup=0,res=0;
  cin >> N >> C >> K;
  REP(i,N)cin >> T[i];
  sort(T,T+N);
  
  REP(i,N){
    npos = T[i] + K;
    shup = 1;
    for(int j=i+1;j<N;j++){
      if(shup == C){
        i = j-1;
        break;
      }
      if(T[j] <= npos)
        shup++;
      else{
        i = j-1;
        break;
      }
      if(j == N-1){
        i = N;
      }
    }
    res++;
  }
  cout << res << endl;
  return 0;
}

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

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

}

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

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

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

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  ll c=0,cnt=0,f=0,b=0;
  string s;
  cin>>s;
  for(int i=1;i<s.size();i++){
    if(s[i]==s[i-1]){
      c++;
      if(s[i]=='1') s[i]='0';
      else s[i]='1';
    }
  }
  cout<<c;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#include <string.h>

typedef long long ll;
#define MAX_N (100005)

int uf[MAX_N]; // union-find
int n;

void uf_init()
{
	for (int i = 0; i < n; i++)
	{
		uf[i] = i;
	}
}

int uf_root(int x)
{
	if (uf[x] == x)
	{
		return x;
	}
	else
	{
		uf[x] = uf_root(uf[x]);
		return uf[x];
	}
}

void uf_unite(int x, int y)
{
	int rx = uf_root(x);
	int ry = uf_root(y);
	if (rx == ry)
	{
		return;
	}
	uf[rx] = ry;
}

int main() {
	int m;
	scanf("%d %d", &n, &m);
	
	uf_init();
	for (int i = 0; i < m; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--;
		b--;
		uf_unite(a, b);
	}
	int gr = 0;
	for (int i = 0; i < n; i++)
	{
		if (uf_root(i) == i)
		{
			gr++; // 根の数を数える
		}
	}
	printf("%d", gr - 1);
	
	return 0;
}


Measured memory_bytes: 2120
#include <iostream>
using namespace std;
int n, a[200009];
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	bool ok = true;
	for (int i = 0; i < n; i++) {
		ok = ok && (a[i] <= i) && (i == 0 || a[i] - a[i - 1] <= 1);
	}
	if (!ok) cout << -1 << '\n';
	else {
		long long sum = a[n - 1];
		for (int i = 0; i < n - 1; i++) {
			if (a[i] != a[i + 1] - 1) {
				sum += a[i];
			}
		}
		cout << sum << '\n';
	}
	return 0;
}

Measured memory_bytes: 1024
while True:
   m, f, r = [int(i) for i in input().split()]
  
   if m == f == r == -1:
      break
   total = m + f
   if m == -1 or f == -1 or total < 30:
      print("F")
    
   elif total < 50 and r < 50:
      print("D")
 
   elif r >= 50 or total < 65:
      print("C")
    
   elif total < 80:
      print("B")
 
   else:
      print("A")

Measured memory_bytes: 7656
#include<iostream>
#include<cmath>

int main(void){
    const double g=9.8;
    double v;
    while(std::cin>>v){
        int n=1;
        while(1){
            if(v*v<=2*g*5*(n-1)){
                std::cout<<n<<std::endl;
                  break;
            }
            n++;
        }
    }
    return 0;
}


Measured memory_bytes: 3196
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int count = 0;
    
    for(int i = A; i <= B; i++){
    	int a = i / 10000;
        int b = i % 10;
        if(a != b) continue;
      	a = (i / 1000)% 10;
        b = (i / 10) % 10;
        if(a == b) count++;
    }
    System.out.println(count);
  }
}




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

const int mod = 1000000007;

int main() {
    int n; cin >> n;
    ll ans = 1;
    for (int i = 1; i <= n; i++) {
        ans = ans * i % mod;
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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 double PI=acos(-1.0);

int main()
{   
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];

    ll sum = 0, x = 0, ans = 0;
    int r = 0;
    rep(l, n) {
        while(r < n && ((sum + a[r]) == (x ^ a[r]))) {
            //cout << l << " " << r << endl;
            sum += a[r];
            x ^= a[r];
            //cout << sum << " " << x << endl;
            r++;
            //ans++;
        }
        //cout << l << " " << r << endl;
        ans += (r-l);
        if(l==r) r++;
        else {
            sum -= a[l];
            x ^= a[l];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4840
from collections import Counter
n = int(input())
v = list(map(int,input().split()))
v1 = v[::2]
v2 = v[1::2]
C1 = Counter(v1)
C2 = Counter(v2)
if C1.most_common(1)[0][0]!=C2.most_common(1)[0][0]: 
  print((n//2-C1.most_common(1)[0][1])+(n//2-C2.most_common(1)[0][1]))
elif C1.most_common(1)[0][1]==C2.most_common(1)[0][1]==n//2:
  print(n//2)
elif C1.most_common(1)==C2.most_common(1) and C1.most_common(2)[1][1] >= C2.most_common(2)[1][1]:
  print((n//2-C1.most_common(2)[1][1])+(n//2-C2.most_common(1)[0][1]))
else:
  print((n//2-C1.most_common(1)[0][1])+(n//2-C2.most_common(2)[1][1]))
 

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

int main()
{
    ll n, tmp;
    cin >> n;
    vector<ll> v(n);

    for(int i = 1; i < n; ++i)
    {
        cin >> tmp;
        v[tmp - 1]++;
    }

    for(auto i: v) cout << i << "\n";
    return 0;
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  lint n; cin >> n;
  cout << n * (n - 1) / 2 << '\n';
}

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


int main() {
  int N;
  cin>>N;
  int a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  int min=1000000;
  int ans=0;
  for(int i=0;i<N;i++){
    if(min>=a[i]){
      ans++;
      min=a[i];
    }
  }
    cout<<ans;
}

Measured memory_bytes: 1024