akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  int i,j,k;
  int d;	//365
  int c[26];
  int score[9490];
  int t[365] = {0};
  int day1[26] = {0};
  double x = 0.36787944117;
  int tmp1=-999999,tmp2=-999999;
  int tmpi = 0;
  
  scanf("%d",&d);
  for(i=0;i<26;i++){
      scanf("%d ",&c[i]);
  }
  for(i=0;i<d*26;i++){
      scanf("%d ",&score[i]);
  }
  //st
  
  for(i=0;i<26;i++){
    if(c[i]>tmp1){
     tmp1 = c[i];
    }
    tmpi = i;
  }
  tmp1 = -999999;/*
  for(i=0;i<d;i++){
    for(j=0;j<26;j++){
      if(score[i*26+j]-c[j]*(1+day1[j])>tmp1){
       	t[i] = j;
      }
    }
  }
  */
  //en
  int p1[26]={0};
    int p2 = 0;
  for(i=0;i<d;i++){
    if(i%26==0){
     for(j=0;j<26;j++){
      p1[j]=0; 
     }
    }
    int tp = -9999999;
    int tp2 = 0;
    for(j=0;j<26;j++){
      for(k=0;k<26;k++){
     if(p1[j]==0&&score[i*26+k]>tp){
       tp = score[i*26+k];
       tp2 = k;
     }
    }}
    
    
    //p2 = (tmpi+i+tp2)%26+1;
    p2 =tp2+1;
    
    
    printf("%d\n",p2);
    
    
    
  }
 return 0; 
}











/*
#include<stdio.h>
int main(){
  int i,j,k;
  int d;	//365
  int c[26];
  int score[9490];
  int t[365] = {0};
  int day1[26] = {0};
  double x = 0.36787944117;
  int tmp1=-999999,tmp2=-999999;
  
  scanf("%d",&d);
  for(i=0;i<26;i++){
      scanf("%d ",&c[i]);
  }
  for(i=0;i<d*26;i++){
      scanf("%d ",&score[i]);
  }
  //st
  
  for(i=0;i<d;i++){
    for(j=0;j<26;j++){
      if(score[i*26+j]-c[j]*(1+day1[j])>tmp1){
       	tmp1 =  score[i*26+j]-c[j]*(1+day1[j]);
        t[i] = j;
      }
      for(k=0;k<26;k++){
        day1[k] += 1; 
      }
      day1[t[j]] = 0;
    }
  }
  
  //en
  for(i=0;i<d;i++){
      printf("%d\n",t[i]+1);
  }
 return 0; 
}
*/




Measured memory_bytes: 2212
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    vector<int> a(n),s(n+1),t(n+1);
    int i;
    s[0]=0;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
        s[i+1]=MAX(s[i],a[i]);
    }
    t[n]=0;
    for(i=n-1; i>=0; i--) {
        t[i]=MAX(t[i+1],a[i]);
    }

    for(i=0; i<n; i++) {
        printf("%d\n", MAX(s[i], t[i+1]));
    }

    return 0;
}


Measured memory_bytes: 3968
H,W=map(int,input().split())
S=[list(input()) for _ in range(H)]

di=[1,1,0,-1,-1,-1,0,1]
dj=[0,1,1,1,0,-1,-1,-1]

for i in range(H):
    for j in range(W):
        ans=0
        if S[i][j]=='#':
            continue
        for k in range(8):
            ni=i+di[k]
            nj=j+dj[k]
            if ni<0 or nj<0 or ni>=H or nj>=W:
                continue
            if S[ni][nj]=='#':
                ans+=1
        S[i][j]=str(ans)
for i in range(H):
    for j in range(W):
        print(S[i][j],end='')
    print()


Measured memory_bytes: 9160
#include<stdio.h>

int main(void){
int a,b,c=0;
int i;
scanf("%d",&a);
scanf("%d",&b);
for(i=0;i<2;i++){
if(a>b){
c+=a;
a-=1;
}
else{
c+=b;
b-=1;
}
}
printf("%d",c);

return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll h,w;cin>>h>>w;
    string s[h];
    for(ll i=0;i<h;i++){
        cin>>s[i];
    }
    bool b;
    bool b2=true;
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            if(s[i][j]=='#'){
                b=false;
                if(i>0){
                    if(s[i-1][j]=='#'){
                        b=true;
                    }
                }
                if(j>0){
                    if(s[i][j-1]=='#'){
                        b=true;
                    }
                }
                if(i<h-1){
                    if(s[i+1][j]=='#'){
                        b=true;
                    }
                }
                if(j<w-1){
                    if(s[i][j+1]=='#'){
                        b=true;
                    }
                }
                if(b==false){
                    b2=false;
                    i=h;
                    j=w;
                }
            }
        }
    }
    if(b2==true){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#define rep(i,x) for(int i=0;i<x;i++)
using namespace std;
string s;
char tab[10][10]={"abcde","fghij","klmno","pqrst","uvwxy","z.?! "};
void solve(){
	int n=0,k=0;
	char ans[1000];
	if(s.size()%2!=0){
		cout<<"NA"<<endl;
		return ;
	}
	else{
		while(n<s.size()){
			if(s[n]>='1'&&s[n]<'7'&&s[n+1]>='1'&&s[n+1]<'6')
			ans[k++]=tab[s[n]-1-'0'][s[n+1]-1-'0'];
			else{

				cout<<"NA"<<endl;
				return ;
			}
			n+=2;
		}
		rep(i,k)
		cout<<ans[i];
		cout<<endl;
	}
}
int main(){
	while(cin>>s){
		solve();
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
    int N, K;

    cin >> N >> K;
    double res = 0.0;
    for (int i = 1; i <= N;i++){
        double tmp = 1.0 / N;
        int a = i;
        while(a<K){
            a *= 2;
            tmp /= 2;
        }
        res += tmp;
    }
    printf("%.12f", res);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,a[N],b[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++)
        scanf("%d",&a[i]);
    b[1]=a[1];
    for(int i=2;i<n;i++)
        b[i]=min(a[i],a[i-1]);
    b[n]=a[n-1];
    int ans=0;
    for(int i=1;i<=n;i++)
        ans+=b[i];
    printf("%d\n",ans);
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a)+min(b)

for _ in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1]+b[y-1]-c)

print(ans)

Measured memory_bytes: 64800
import sys
K = '.,!? '
A = 'abc'
D = 'def'
G = 'ghi'
J = 'jkl'
M = 'mno'
P = 'pqrs'
T = 'tuv'
W = 'wxyz'
L = ['', K, A, D, G, J, M, P, T, W]
count = int(input())
while count:
	count -= 1
	S = []
	n = input()
	if not '0' in n:
		print('')
		continue
	else:
		n = n.split('0')
		for ns in n:
			if ns == '':
				continue
			i = len(ns) % len(L[int(ns[0])])
			S += [[L[int(ns[0])], i-1]]
		for s in S:
			print(s[0][s[1]], end='')
		print('')
		continue


Measured memory_bytes: 5628
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

char s[110];
char ans[110];
int n;
		
int main()
{
	scanf("%s", &s);
	n = strlen(s);
	for (int i = 0 ; i < n ; i++) {
		ans[i] = 'x';
	}
	ans[n] = '\0';
	printf("%s\n", ans);
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;

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

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

  cin >> N;

  vector<int> a(N);
  vector<int> b(N);
  rep(i, N) {
    cin >> a.at(i);
  }
  rep(i, N) {
    cin >> b.at(i);
  }

  int ans = 0;
  for(int k=29; k>=0; k--) {
    rep(i, N) {
      b.at(i) %= 1<<(k+1);
    }
    sort(b.begin(), b.end());
    ll sum = 0;
    //debugln(k);
    rep(i, N) {
      int aa = a.at(i) % (1<<(k+1));
      int T = 1<<k;
      auto it1 = lower_bound(b.begin(), b.end(), T-aa);
      auto it2 = lower_bound(b.begin(), b.end(), 2*T-aa);
      auto it3 = lower_bound(b.begin(), b.end(), 3*T-aa);
      auto it4 = b.end();
      //debug(aa);
      //debug(distance(it1, it2));
      //debugln(distance(it3, it4));
      sum += distance(it1, it2) + distance(it3, it4);
    }
    ans += (sum%2)<<k;
  }
  cout << ans << endl;
}

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

int main(){
  ll n,d;
  std::cin >> n>>d;
  int ans=0;

  rep(i,n){
    ll x,y;
    std::cin >> x>>y;
    if(x*x+y*y<=d*d)ans++;
  }
  std::cout << ans << '\n';


  return 0;
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define in2(x, y) int x,y;cin>>x>>y
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)

#define lim5 100002
#define lim9 1000000002

int CanMake(int a, int b, int c) {
	if (a < b + c && b < c + a && c < a + b) {
		return 1;
	}
	return 0;
}

int main() {
	int a, b;
	cin >> a >> b;

	cout << (a < 10 && b < 10 ? a * b : -1) << endl;

	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
nn = 1
mm = 1
for i in range(1, N + 1):
  nn = (nn * i) % MOD
for j in range(1, M + 1):
  mm = (mm * j) % MOD
if abs(N - M) >= 2:
  ans = 0
elif abs(N - M) == 1:
  ans = (nn * mm) % MOD
else:
  ans = (2 * nn * mm) % MOD
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

int main_() {
	int N;
	cin >> N;
	
	int sum = 0;
	FOR(i, 1, N + 1) {
		sum += i;
	}
	
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[11][11];
int main()
{
	for(int i=1;i<=3;i++)
	for(int j=1;j<=3;j++) cin>>a[i][j];
	for(int i=1;i<=2;i++)
	{
		int x=a[i+1][1]-a[i][1];
		for(int j=2;j<=3;j++)
		{
			int y=a[i+1][j]-a[i][j];
			if(x!=y) {
				cout<<"No";
				return 0;
			}
		}
	}
	
	for(int i=1;i<=2;i++)
	{
		int x=a[1][i+1]-a[1][i];
		for(int j=2;j<=3;j++)
		{
			int y=a[j][i+1]-a[j][i];
			if(x!=y) {
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
	return 0;
} 

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

int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double x, y, z, w = 0;
  double pi = 3.141592653589793238;
  x = B*cos(pi*M/30) - A*cos(pi*(H+(M/60))/6);
  y = B*sin(pi*M/30) - A*sin(pi*(H+(M/60))/6);
  cout << fixed << setprecision(15)<< sqrt(x*x+y*y) << endl;
}


Measured memory_bytes: 4152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef long long ll;

int main() {
  int K, T;
  cin >> K >> T;
  int a[101];
  for (int i = 0; i < T; i++) {
    cin >> a[i];  
  }
  if (T == 1) {
    cout << a[0] - 1 << endl;
    return 0;
  }
  sort(a, a + T);
  int ans = a[T - 1] - 1;
  for (int i = 0; i < T - 1; i++) {
    ans -= a[i];
  }
  ans = max(ans, 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use ascii::AsciiChar;
use ascii::AsciiStr;
use itertools::Itertools as _;
use permutohedron::LexicalPermutation as _;
use petgraph::algo::dijkstra;
use petgraph::algo::min_spanning_tree;
use petgraph::data::FromElements;
use petgraph::graph::NodeIndex;
use petgraph::graph::UnGraph;
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use superslice::Ext as _;

#[fastout]
fn main() {
    input! {
        N: usize,
        Ss: [char; N],
    }

    let set: HashSet<char> = Ss.into_iter().collect();

    if set.len() == 3 {
        println!("Three");
        return;
    }

    println!("Four");
}


Measured memory_bytes: 2188
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <regex>

using namespace std;

int main()
{
    std::string s, t;
    std::cin >> s;
    std::cin >> t;
    std::regex re(s + "[a-z]");

    if(std::regex_match(t, re))
    {
        std::cout << "Yes" << std::endl;
    } else
    {
        std::cout << "No" << std::endl;
    }
    
    return EXIT_SUCCESS;
} 

Measured memory_bytes: 3168
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
#define F first
#define S second
#define MK make_pair
const ll E=1e17+7;
 
 
 
 
int main(){
    ll n;
    cin>>n;
    vector<ll> a(1000);
    for(int i=0;i<1000;i++){
        a[i]=E;
    }
    for(int i=0;i<n;i++){
        string str;
        cin>>str;
        vector<ll> b(1000);
        for(int t=0;t<str.size();t++){
            b[str[t]]++;
        }
        for(int t=0;t<b.size();t++){
            a[t]=min(a[t],b[t]);
        }
    }
    string ans;
    for(int i=0;i<a.size();i++){
        for(int t=0;a[i]!=E && t<a[i];t++){
            ans.push_back(i);
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int x,a,b,y,i;
    while(scanf("%d %d %d",&x,&a,&b)!=EOF)
    {
        y=x-a;
        for(i=1;; i++)
        {
            y=y-b;
            if(y<b)
            {
                printf("%d\n",y);
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
 
int main(void){
  int N;
  scanf("%d",&N);
  int A[200010]={0};
  int c[200010]={0};
  for(int i=2;i<N+1;i++){
    scanf("%d",&A[i]);
  }
  for(int i=2;i<N+1;i++){
    c[A[i]]++;
  }
  for(int i=1;i<N+1;i++){
    printf("%d\n",c[i]);
  }
  return 0;
}

Measured memory_bytes: 3292
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	ll n, m, k; cin >> n >> m >> k;
	vector<ll> a(n);
	vector<ll> b(m);
	for( auto &t : a ) cin >> t;
	for( auto &t : b ) cin >> t;
	vector<ll> asum(n+1);
	vector<ll> bsum(m+1);
	int ans = 0;
	for( int i = 0; i < n; ++i ) asum[i+1] = asum[i]+a[i];
	for( int i = 0; i < m; ++i ) bsum[i+1] = bsum[i]+b[i];
	bsum.push_back(inf);
	for( int p = 0; p <= n; ++p ){
		ll target = k-asum[p];
		if( target < 0 ) break;
		int q = lower_bound( bsum.begin(), bsum.end(), target ) - bsum.begin();
		if( bsum[q] > target ) --q;
		ans = max(p+q, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 11172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define println(v) cout << v << "\n";

inline vector<vector<ll>> make_vector(ll i, ll j) {
    vector<vector<ll>> v(i, vector<ll>(j, 0));
    return v;
}

int main()
{

    int N;
    cin >> N;
    vector<ll> var(3);
    REP(i, 3) cin >> var[i];

    auto option = make_vector(N, 2);
    REP(i, N) {
        string s;
        cin >> s;
        option[i][0] = s[0]-'A';
        option[i][1] = s[1]-'A';
    }

    vector<ll> ans(N);
    REP(i, N) {
        int i1 = option[i][0];
        int i2 = option[i][1];
        int iM = (var[i1] >= var[i2] ? i1 : i2);
        int im = i1 ^ i2 ^ iM;
        if (var[i1] == 1 && var[i2] == 1 && var[i1^i2^3] == 0 && i+1 < N && (option[i+1][0] == i1 || option[i+1][1] == i1)) {
            swap(iM, im);
        }
        var[iM]--;
        var[im]++;
        ans[i] = im;
        if (var[0] < 0 || var[1] < 0 || var[2] < 0) {
            println("No");
            return 0;
        }
    }

    println("Yes");
    REP(i, N) {
        println((char)('A'+ans[i]));
    }

    return 0;
}

Measured memory_bytes: 9576
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 605
#define M 360005
int n, m, deg[N];
int tar[M], nex[M], fir[N], cnt;
void Add(int a, int b)
{
	++cnt;
	tar[cnt] = b;
	nex[cnt] = fir[a];
	fir[a] = cnt;
	deg[a]++;
}
double dp[N];
double Getval(int x)
{
	dp[n] = 0;
	for (int i = n - 1; i >= 1; i--)
	{
		double sum = 0, mx = 0;
		for (int k = fir[i]; k; k = nex[k])
		{
			int v = tar[k];
			mx = max(mx, dp[v]);
			sum += dp[v];
		}
		int flg = 0;
		if (i == x && deg[i] >= 2)
			sum -= mx, flg = 1;
		dp[i] = sum / (deg[i] - flg) + 1;
	}
	return dp[1];
}

int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		Add(u, v);
	}
	double ans = 1e20;
	for(int i = 1; i <= n; i++)
		ans = min(ans, Getval(i));
	printf("%.12f\n", ans);
}


Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main() {
	int N, M, metro, i;
	int count[50] = {};
	cin >> N >> M;
	for (i = 0; i < M * 2; i++) {
		cin >> metro;
		count[metro - 1]++;
	}
	for (i = 0; i < N; i++) {
		cout << count[i] << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)

int main() {
    int a,p,ans;
    cin>>a>>p;
    ans=(a*3+p)/2;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; } /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; } /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b)
{
	return *(char *)a - *(char *)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b)
{
	return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX 100001

typedef struct
{
	long long int pri;
	long long int val;
} que;

que pq[MAX];
int pq_size = 0;

void PQadd(long long int pri, long long int val)
{
	int last = ++pq_size;
	que new;
	new.pri = pri;
	new.val = val;
	pq[pq_size] = new;

	while (last > 1 && pq[last].pri > pq[last / 2].pri)
	{
		que temp;
		temp = pq[last];
		pq[last] = pq[last / 2];
		pq[last / 2] = temp;
		last /= 2;
	}
	return;
}

que PQget(void)
{
	que root = pq[1];
	pq[1] = pq[pq_size--];

	int last = 1, bigger_child;
	while (last * 2 <= pq_size)
	{
		if (last * 2 == pq_size)
			bigger_child = last * 2;
		else
			bigger_child = pq[last * 2].pri > pq[last * 2 + 1].pri ? last * 2 : last * 2 + 1;

		if (pq[last].pri < pq[bigger_child].pri)
		{
			que temp;
			temp = pq[last];
			pq[last] = pq[bigger_child];
			pq[bigger_child] = temp;
			last = bigger_child;
		}
		else
			break;
	}
	return root;
}

int main(void)
{
	int n, m;
	scanf("%d %d", &n, &m);

	int ab[n][2];
	int i, j, k;
	for (i = 0; i < n; i++)
		scanf("%d %d", &ab[i][0], &ab[i][1]);

	qsort(ab, n, sizeof(*ab), acs);

	int ans = 0;
	i = 0;
	for (j = 1; j <= m; j++)
	{
		while (i < n && ab[i][0] <= j)
		{
			PQadd(ab[i][1], 0);
			i++;
		}
		if (pq_size != 0)
			ans += PQget().pri;
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 2540
#include <bits/stdc++.h> 
#define pb push_back
using namespace std;
vector<vector<int>>graph;
long long dp[100001];

int main(){
int x; cin>>x;

if(400<=x&&x<=599) cout<<8<<endl;
if(600<=x&& x<=799) cout<<7<<endl;
if(800<=x&& x<=999) cout<<6<<endl;
if(1000<=x&& x<=1199) cout<<5<<endl;
if(1200<=x&& x<=1399) cout<<4<<endl;
if(1400<=x&& x<=1599) cout<<3<<endl;
if(1600<=x&& x<=1799) cout<<2<<endl;
if(1800<=x&& x<=1999) cout<<1<<endl;
return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  int a, b, c; cin >> a >> b >> c;
  int sum = a+b+c; int mx = max({a,b,c});
  if(mx % 2 != sum % 2)mx+=1;
  cout << (3*mx-sum)/2 << endl;
  system("pause");
}

Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>

#define mod 1000000007
using namespace std;

long long dp[3010][3010],a[3010],l[3010],r[3010],mx;
int main(){
	string s;
	pair<int,int> p[3010],q[3010];
	int i,j,n,m,x,y;
	cin >> n >> m >> s;
	j = 0;
	cin >> l[0] >> r[0];
	mx = r[0];
	for(i=1;i<m;i++){
		cin >> l[i] >> r[i];
		if(l[i]==l[i-1]){
			mx = max(mx,r[i]);
		}else{
			q[j] = make_pair(l[i-1],mx);
			mx = r[i];
			j++;
		}
	}
	q[j] = make_pair(l[m-1],mx);
	int k = 0;
	p[0] = q[0];
	for(i=1;i<=j;i++){
		if(q[i].second>p[k].second){
			k++;
			p[k] = q[i];
		}
	}
	p[k+1] = make_pair(3010,3010);
	
	k = 0;
	a[0] = 0;
	for(i=0;i<n;i++){
		if(s[i]=='1'){
			k++;
		}
		a[i+1] = k;
	}
	
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
			dp[i][j] = 0;
		}
	}
	
	k = 0;
	dp[0][0] = 1;
	for(i=1;i<=n;i++){
		if(p[k].first==i){
			k++;
		}
		for(j=0;j<i;j++){
			if(k==0 || (i<p[k].first && i>p[k-1].second)){
				if(s[i-1]=='1'){
					dp[i][j+1] += dp[i-1][j];
					dp[i][j+1] %= mod;
				}else{
					dp[i][j] += dp[i-1][j];
					dp[i][j+1] %= mod;
				}
			}else{
				dp[i][j+1] += dp[i-1][j];
				dp[i][j+1] %= mod;
				if(a[p[k-1].second]<j+1 || a[p[k-1].second]-(p[k-1].second-i)>j+1){
					dp[i][j+1] = 0;
				}
				dp[i][j] += dp[i-1][j];
				dp[i][j] %= mod;
				if(a[p[k-1].second]<j || a[p[k-1].second]-(p[k-1].second-i)>j){
					dp[i][j] = 0;
				}
			}
		}
	}
	
	cout << dp[n][a[n]] << endl;
}


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

int N, K;

int main(int argc, char **argv)
{
	cin >> N >> K;

	unsigned long int ans = K;
	
	for (int i = 1; i < N; ++i)
	{
		ans *= K-1;
	}
	std::cout << ans<< std::endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long int n;
    long long int a,b;
    cin>>n>>a>>b;
    long long int all=a+b;
    long long int num;
    num=n/all;
    long long int lnum;
    lnum=n%all;
     long long  int ans=0;
    ans=num*a;
    if(lnum>=a)
    {
        ans+=a;
    }
    else
    {
        ans+=lnum;
    }
    cout<<ans<<endl;
}


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

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            var count = 0;
            var l = new List<string>();

            for (int i = 0; i <= 999; i++)
            {
                var password = i.ToString("000");
                if (check(password, s))
                {
                    count++;
                    l.Add(password);
                }
            }

            Console.WriteLine(count);
        }

        public static bool check(string pass, string s)
        {
            // stringの中にpassが含まれるかをチェックする。
            var newS = s.ToCharArray().ToList();
            var newP = pass.ToCharArray().ToList();

            var index1 = newS.FindIndex(x => x == newP[0]);
            if (index1 < 0) return false;
            else newS = newS.GetRange(index1+1, newS.Count()-index1-1);

            var index2 = newS.FindIndex(x => x == newP[1]);
            if (index2 < 0) return false;
            else newS = newS.GetRange(index2+1, newS.Count()-index2-1);
            
            var index3 = newS.FindIndex(x => x == newP[2]);
            if (index3 < 0) return false;
            else newS = newS.GetRange(index3+1, newS.Count()-index3-1);

            
                return true;

        }
    }
}


Measured memory_bytes: 30420
# nCr mod m
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

X, Y = map(int, input().split())
if (X+Y) % 3 != 0 or not (X <= 2*Y and Y <= 2*X):
    print(0)
    exit()

n = (X+Y) // 3
r = Y - n
#print(n, r)
print(combination(n, r))


Measured memory_bytes: 3064
import java.util.*;


public  class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        for (int i = 0; i < count; i++) {
          String color = sc.next();
          if (color.equals("Y")) {
            System.out.println("Four");
            return;
          }
        }
        System.out.println("Three");
    }
}

Measured memory_bytes: 20308
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	int s;
	int[] a = new int[10];
	int b;
	int d = 0;
	
	public void kei(){
		for(b=0;b<a.length;b++){
			s = sc.nextInt();
			d = d + s;
		}
	}
	
	public void hyouji(){
			System.out.println(d);	
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Main go = new Main();
		go.kei();
		go.hyouji();

	}

}

Measured memory_bytes: 17284
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);

    	String S = sc.next();
    	String T = sc.next();
    	char[] s = S.toCharArray();
    	char[] t = T.toCharArray();
    	int ans = 0;
    	for(int i=0;i<S.length();i++) {
    		if(s[i]!=t[i]) {
    			ans++;
    		}
    	}
    	System.out.println(ans);

    }
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M, K[15], S[15][15], P[15], ans, Solve(int);
int now[15];

int main(){
  cin >> N >> M;
  for (int i = 1; i <= M; i++){
    cin >> K[i];
    for (int j = 0; j < K[i]; j++){
      cin >> S[i][j];
    }
  }
  for (int i = 1; i <= M; i++) cin >> P[i];
  for (int i = 0; i < (1<<N); i++) Solve(i);
  cout << ans << endl;

  return 0;
}

int Solve(int num){
  for (int i = 1; i <= N; i++){
    now[i] = num % 2; num /= 2;
  }

  for (int i = 1; i <= M; i++){
    int cnt = 0;
    for (int j = 0; j < K[i]; j++){
      if (now[S[i][j]]) cnt++;
    }
    if (cnt % 2 != P[i]) return 0;
  }
  ans++;
  return 0;
}




Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
#define vpp vector<pair<ll,ll>>
#define ff first
#define ss second
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;
int main()
{
    rkc;
    ll n,k;
    cin>>n>>k;
    if(k==1)cout<<0;
    else
    cout<<n-k;
}

Measured memory_bytes: 256
#include <iostream>
int main()
{
	int a, b;
	std::cin >> a >> b;
	if (a < b) {
		std::cout << "a < b" << std::endl;
	}
	if (a > b) {
		std::cout << "a > b" << std::endl;
	}
	if (a == b) {
		std::cout << "a == b" << std::endl;
	}
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll R = 0, G = 0, B = 0;
ll t;
ll ret = 0;
string s;

void input() {
  IN(N);
  IN(s);
}

void solve() {
  if (N<3) {
    PRINT(0);
    return;
  }

  REP(i, N) {
    char c = s[i];
    if (c == 'R') R++;
    if (c == 'G') G++;
    if (c == 'B') B++;
  }

  // DEBUG(R);
  // DEBUG(G);
  // DEBUG(B);
  // LN();

  ll X = 0;

  FOR(T, 1, N/2 + 1) {
    REP(left, N) {
      if (left + 2 * T >= N) continue;
      char l = s[left];
      char m = s[left + T];
      char r = s[left + 2 * T];
      // DEBUG(l);
      // DEBUG(m);
      // DEBUG(r);
      // LN();
      if (l == m || m == r || r == l) {
        continue;
      } else {
        X++;
      }
    }
  }
  ret = R * G * B - X;
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll a, b;
    cin >> a >> b;
    ll ans = -1;
    rep(i, 10000) {
        if (((i * 8 / 100) == a) && ((i * 10 / 100) == b)) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        HashSet<Integer> set = new HashSet<Integer>();

        for (int i = 0; i < n; i++) {
            set.add(stdIn.nextInt());
        }

        if (set.size() == n) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


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

using namespace std;
typedef long long int ll;

ll getNext(ll n, int digit) {
	vector<int> min_arr (digit);
	ll ll_max = 0, ll_min = 0;

	ll ans = 0;
	for (int i = 0; i < digit; i++, n /= 10) {
		min_arr[i] = n % 10;
	}
	sort(min_arr.begin(), min_arr.end());
	vector<int> max_arr (digit);
	for (int i = 0; i < digit; i++) {
		max_arr[digit - i - 1] = min_arr[i]; 
	}
	for (int i = 0; i < digit; i++) {
		ll_min += min_arr[i];
		ll_max += max_arr[i];
		ll_min *= 10;
		ll_max *= 10;
	}
	ll_min /= 10;
	ll_max /= 10;

	return ll_max - ll_min;
}

int main() {
	int M, N;
	while (true) {	
		cin >> M >> N;
		if (M == 0 && N == 0) break;
		ll emerged[21] = { M };
		int flag = true;
		for (int i = 1; i < 21 && flag; i++) {
			M = getNext(M, N);
			emerged[i] = M;
			for (int j = 0; j < i && flag; j++) {
				if (emerged[j] == M) {
					cout << j << " " << emerged[i] 
							 << " " << i - j << endl;
					flag = false;
				}
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    ll x[n][20][2];
    for(int i=0;i<n;i++){
        cin>>a[i];
        for(int j=0;j<a[i];j++){
            cin>>x[i][j][0]>>x[i][j][1];
            x[i][j][0]--;
        }
    }
    ll ans=0;
    ll num=0;
    ll s=(1LL<<n);
    for(ll bit=0LL;bit<s;bit++){
        num=0;
        for(ll i=0LL;i<n;i++){
            if(bit&(1<<i)){
                num++;
                
                for(ll j=0LL;j<a[i];j++){
                    
                    if((x[i][j][1]&&!(bit&(1<<(x[i][j][0]))))||((!x[i][j][1]&&(bit&(1<<(x[i][j][0])))))){
                       
                        num=-100000;
                    }

                }
            }
        }
        ans=max(ans,num);
    }
    
    cout<<ans<<endl;

    return 0;
}


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

int main(){
    int x, y, r;
    cin >> x >> y;
    if(x < y) swap(x, y);
    r = x % y;
    while(r){
        x = y;
        y = r;
        r = x % y;
    }
    cout << y << endl;
    
    
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

long long sum(long long n)
{
    long long dst = n * (n + 1) / 2;
    return dst;
}

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    vector<double> num_imos(N + 1);
    num_imos[0] = 0;
    rep(i, N)
    {
        cin >> p[i];
        num_imos[i + 1] = num_imos[i] + (double)sum(p[i]) / p[i];
    }

    double ans = 0;
    rep(i, num_imos.size() - K)
    {
        ans = max(ans, num_imos[i + K] - num_imos[i]);
    }

    cout << setprecision(15) << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  string S;
  IN(S);

  ll R_count=0, G_count=0, B_count=0;
  REP(i,N){
    if(S[i]=='R') R_count++;
    else if(S[i]=='G') G_count++;
    else if(S[i]=='B') B_count++;
  }

  ll ans = R_count*G_count*B_count;

  REP(i,N){
    FOR(d,1,N){
      ll j = i+d;
      ll k = i+2*d;
      if(k>=N) continue;
      if(S[i]!=S[j] && S[i]!=S[k] && S[j]!=S[k]) ans--;
    }
  }

  OUT(ans);

  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  int ans = 0;
  cin >> n >> k;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) cin >> vec.at(i);
  sort(vec.begin(), vec.end(), greater<int>());
  for(int i = 0; i < k; i++) {
    ans += vec.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    ################
    class UnionFind():
        """
        parents : 親要素(findしない場合は根ではないことの注意)，根の場合は"-(要素数）"
        find(x):要素xの属するグループの根を返す
        size(x):要素xの属するグループの要素数を返す
        same(x,y):x,yが同じグループに属しているか返す
        重いかも！　　members(x):要素xが属するグループに属する要素をリストで返す
        roots:全ての根の要素を返す
        group_count():グループの数を返す
        重いかも！　all_group_members():{根要素：[そのグループに含まれる要素のリスト]}の辞書を返す
        """
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n

        def find(self, x):
            #根を探す&つなぎかえる
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]

        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)

            if x == y:
                return

            if self.parents[x] > self.parents[y]:
                x, y = y, x

            self.parents[x] += self.parents[y]
            self.parents[y] = x

        def size(self, x):
            return -self.parents[self.find(x)]

        def same(self, x, y):
            return self.find(x) == self.find(y)

        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]

        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]

        def group_count(self):
            return len(self.roots())

        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}

        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
        
    ################


    mod=10**9+7
    N,M=MI()
    uf=UnionFind(N)
    #連結成分の数
    
    for i in range(M):
        x,y,z=MI()
        x-=1
        y-=1
        uf.union(x,y)
        
    print(uf.group_count())
    
    

main()


Measured memory_bytes: 81384
#include <iostream>
#include <cstdio>
#include <numeric>
using namespace std;

int main()
{
    int n; cin >> n;
    int a[n];
    for(int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }

    int sum = accumulate(a, a+n, 0);
    int s = 0;
    int mn = 10000;
    for(int i=0; i<n; ++i) {
        s += a[i];
        mn = min(mn, abs(sum-2*s));
    }
    cout << mn;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[]
b=[]
for i in range(n):
  c,d=map(int,input().split())
  a.append(c)
  b.append(d)
a=sorted(a)
b=sorted(b)
if n%2==0:
  x=(a[n//2-1]+a[n//2])
  y=(b[n//2-1]+b[n//2])
  print(y-x+1)
else:
  print(b[n//2]-a[n//2]+1)

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

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

	int count[10][10]={};
	repi(i,1,n+1){
		count[to_string(i)[0]-'0'][i%10]++;
	}
	int ans=0;
	repi(i,1,10){
		repi(j,1,10){
			ans+=count[i][j]*count[j][i];
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
    char c;
    long answer[2];
    int eo = 0;
    answer[0] = 0; answer[1] = 0;
    while (scanf("%c", &c) != EOF) {
        if (c == '0') {
            answer[1 - eo]++;
        } else if (c == '1') {
            answer[eo]++;
        } else break;
        eo = 1 - eo;
    }

    printf("%ld\n", answer[0] < answer[1] ? answer[0] : answer[1]);
}
    


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		if(input.equals("SUN")) {
			System.out.print("7");
		}else if(input.equals("MON")) {
			System.out.print("6");
		}else if(input.equals("TUE")) {
			System.out.print("5");
		}else if(input.equals("WED")) {
			System.out.print("4");
		}else if(input.equals("THU")) {
			System.out.print("3");
		}else if(input.equals("FRI")) {
			System.out.print("2");
		}else if(input.equals("SAT")) {
			System.out.print("1");
		}
	}
}


Measured memory_bytes: 21716
/*g++ main.cpp -o main.out*/
/*./main.out*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    double r;
    cin>>r;
    printf("%.9f\n",2*PI*r);
    return 0;
}


Measured memory_bytes: 3780
# coding: utf-8
# Your code here!
n,y = map(int,input().split())
total = 0
for i in range(n + 1):
    
    for j in range(n - i + 1):
        total = i * 10000 + j * 5000 + (n - i - j) * 1000
        if total == y:
            print(i ,j ,n-i-j)
            exit()
print(-1,-1,-1)


Measured memory_bytes: 3064
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    let mut v: Vec<Vec<char>> = Vec::new();

    for _ in 0..n {
      let mut t: Vec<char> = read::<String>().chars().collect();
      t.sort();
      v.push(t);
    }

    v.sort();

    let mut ans: u64 = 0;
    let mut now = v[0].clone();
    let mut tmp = 1;

    for i in 1..n {
        if now == v[i] {
          tmp += 1;
          now = v[i].clone();
        } else {
          ans += ((tmp * (tmp - 1))) / 2;
          tmp = 1;
          now = v[i].clone();
        }
    }

    ans += ((tmp * (tmp - 1))) / 2;
    println!("{}", ans);
}


Measured memory_bytes: 14588
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
#define mod 200003
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using vvb=vector<vector<bool>>;
using vb= vector<bool>;
ll f(ll a,ll b,ll p){
	if(b==0) return 1;
	if(b%2==0){
		ll t=f(a,b/2,p);
		return t*t%p;
	}
	return a*(f(a,b-1,p))%p;
} 

//__builtin_popcount()
signed main(){
	ll n; cin>>n;
	ll a=0,b=0;
	rep(i,0,n){
		ll c; cin>>c;
		if(c%2==1)a++;
		else b++;
	}
	if(a%2==1){
		cout<<"NO"<<endl;
		return 0;
	}
	cout<<"YES"<<endl;



	return 0;
}

Measured memory_bytes: 3648
IDENTIFICATION DIVISION.
       PROGRAM-ID. ABC044-A.
       DATA DIVISION.
       FILE SECTION.
       WORKING-STORAGE SECTION.
       77 N PIC 9(5).
       77 K PIC 9(5).
       77 X PIC 9(5).
       77 Y PIC 9(5).
       77 ANS PIC 9(9).
       77 ANSS PIC Z(9).

       PROCEDURE DIVISION.
       MAIN-PROCEDURE.
               ACCEPT N.
               ACCEPT K.
               ACCEPT X.
               ACCEPT Y.
               IF K < N THEN
                   COMPUTE ANS = K * X + (N - K) * Y
               ELSE
                   COMPUTE ANS = N * X
               END-IF.
               MOVE ANS TO ANSS.
               DISPLAY ANSS.
               STOP RUN.
       END PROGRAM ABC044-A.


Measured memory_bytes: 636
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

int n;

int main()
{
	scanf("%d", &n);
	printf("%d\n", n * 800 - (n / 15) * 200);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;


#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision13 cout << fixed << setprecision(13)
const double PI=3.14159265358979323846;
const int MAX = 510000;
const int MOD = 1000000007;
const int INF = 1<<29;
using Graph = vector<vector<int>>;


int main()
{
  ll a,b;
  cin  >> a  >> b;
  cout << a*b << endl;

}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
 
using namespace std;
 
#define lli long long
lli M=1e9;
 
#define MAXN  10000001 
 
int main()
{
    lli q=1;
    // cin>>q;
    time_t start, end;
    time(&start);
    for(lli tc=1;tc<=q;tc++)
    {
        
        lli n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        int f[n];
        f[0]=a[0];
        for(int i=1;i<n;i++)
        {
            f[i] = a[i]^f[i-1];
        }
        int b[n];
        b[n-1]=a[n-1];
        for(int i=n-2;i>=0;i--)
        {
            b[i]=b[i+1]^a[i];
        }
        a[0] = b[1];
        a[n-1] = f[n-2];
        for(int i=1;i<n-1;i++)
        {
            a[i]=f[i-1]^b[i+1];
        }
        for(int i=0;i<n;i++)
        {
            cout<<a[i]<<' ';
        }
        cout<<endl;

    }
    
    time(&end);
    // cout<<fixed<<double(end - start)<<setprecision(10)<<endl;
    return 0;
}

Measured memory_bytes: 5972
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <map>
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main(){
	int a, p, pt, cnt, ans;
	cin >> a >> p;
	pt = a * 3;
	cnt = p + pt;
	ans = cnt / 2;
	cout << ans << endl;
}

Measured memory_bytes: 256