akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC optimize(2)
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
#define db double
#define pb push_back
#define pa pair<signed, signed>
#define mp make_pair
#define sc(z) scanf("%d", &(z))
#define _ff(i, a, b) for(signed i = (a); i <= (b); ++i)
#define _rr(i, a, b) for(signed i = (a); i >= (b); --i)
#define _f(i, a, b) for(signed i = (a); i < (b); ++i)
#define _r(i, a, b) for(signed i = (a); i > (b); --i)
#define lson node<<1, l, mid
#define rson node<<1|1, mid + 1, r
#define lowbit(x) x&(-x)
const signed inf = 0x3f3f3f3f;
const signed maxn = 1e5 + 5;
vector<int> G[maxn];
int tot, v[maxn];
void dfs(int u) {
    v[u] = 1;
    _f(i, 0, G[u].size()) {
        int k = G[u][i];
        if (v[k]) continue;
        dfs(k);
    }
}
int main() {
    memset(v, 0, sizeof(v));
    int n, m; sc(n), sc(m);
    int u, w;
    while (m--) {
        sc(u), sc(w);
        G[u].pb(w);
        G[w].pb(u);
    }
    _ff(i, 1, n) {
        if (v[i]) continue;
        tot++;
        dfs(i);
    }
    printf("%d\n", tot - 1);
    return 0;
}

Measured memory_bytes: 10172
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 998244353
#define int long long
#define ll long long
#define EPS 0.00000000000001
#define ld long double
#define inf 1e14
#define N 500001
#define K 4
#define ALPHA 1.1
#define BETA 1.0



int32_t main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("int.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int d;
    cin >> d;
    vector<int> c(26);
    double average = 0.0;

    for(int i = 0;i < 26;i++)
        cin >> c[i];
    vector<vector<int>> v(d,vector<int>(26,0));
    for(int i = 0;i < d;i++)
    {
        for(int j = 0;j < 26;j++)
        {
            cin >> v[i][j];
            average += v[i][j];
        }
    }
    average /= (d * 26);
    vector<int> last(26,-1);
    for(int i = 0;i < d;i++)
    {
        double mxgain = -inf;
        int ind = -1;

        for(int j = 0;j < 26;j++)
        {
            double gain = pow(v[i][j],BETA) + pow((i - last[j]) * c[j],ALPHA);
            // cerr << j << " " << gain << endl;
            if(gain > mxgain)
            {
                mxgain = gain;
                ind = j;
            }
        }
        last[ind] = i;
        cout << ind + 1 << endl;
    }

    
    return 0;    
} 



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

using namespace std;

int main(){
    int M, D;
    cin >> M >> D;
    int max_d10 = D/10;
    int max_d1  = D%10;
    if(D < 22 || M < 4) cout <<0 <<endl;
    else{
        int c =0;
        for(int i=2;i<max_d10;i++){
            c+=min(8, max(M/i-1, 0));
        }
        for(int i=2;i<=max_d1;i++){
            if(M>=max_d10*i) c++;
        }
    
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		String s = "abc", t = sc.next();
		System.out.println(t.indexOf('a')==-1||t.indexOf('b')==-1||t.indexOf('c')==-1 ? "No" : "Yes");
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35476
#include <bits/stdc++.h>
using namespace std;
int main()
{
  double a,b,c,d,S;cin>>a>>b>>c;
  S=(0.5)*a*b*sin(M_PI*c/180);
  d=sqrt(a*a+b*b-2*a*b*cos(M_PI*c/180));
  printf("%.8lf\n",S);
	printf("%.8lf\n",a+b+d);
	printf("%.8lf\n",2*S/a);
}


Measured memory_bytes: 3524
for i in range(int(input())):
    data = input().split()

    length = []
    for j in range(3):
        length.append(int(data[j]))
    length.sort()

    if (length[0]**2) + (length[1]**2) == (length[2]**2):
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 5608
/*
10 8
1 4 7 3 4 10 1 3
*/
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstdio> 
using namespace std;
int e[200007];
int a[200007];
int main()
{
	int n,m,tem;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i){
		scanf("%d",&e[i]);
	    a[e[i]]++;
	}
	for(int i=m;i>=1;i--)
	{
		if(a[e[i]]>0){
		printf("%d\n",e[i]);
	    a[e[i]]=-1;
		}
	}
	for(int i=1;i<=n;i++)
	if(!a[i])printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 4360
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll a;
  cin>>a;
  vector<string>vec(a);
  string b;
  cin>>b;
  char c=b.at(b.size()-1);
  vec.at(0)=b;
  
  
  for(ll i=1;i<a;i++){
    string d;
    cin>>d;
    vec.at(i)=d;
    if(c!=d.at(0)){
      cout<<"No"<<endl;
      return 0;
    }
    c=d.at(d.size()-1);
  }
  sort(vec.begin(),vec.end());
  for(ll i=0;i<a-1;i++){
    if(vec.at(i)==vec.at(i+1)){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  
    
  return 0;
}



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

int main() {
  int N;
  bool ans = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (s == "Y") {
      ans = 1;
      break;
    }
    else {}
  }
  if (ans) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}

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

signed main(){
	int n;
	cin>>n;
	int v[n];
	for(int i=0;i<n;i++)cin>>v[i];
	int odd[n],even[n],j=0,res=0;

	for(int i=0;i<n;i++){
		even[i]=100005; odd[i]=100005;
	}
	int M=0;
	for(int i=0;i<n;i+=2){
		even[j] = v[i];
		//M=max(M,v[i]);
		j++;
	}
	j=0;
	for(int i=1;i<n;i+=2){
		odd[j] = v[i];
		//M=max(M,v[i]);
		j++;
	}
//	////cout<<M<<endl;
	/*
	sort(even,even+n);
	sort(odd,odd+n);*/

	for(int i=0;i<n/2;i++){
		////cout<<"even:"<<even[i]<<" odd:"<<odd[i]<<endl;
	}

	int e_cnt=1,o_cnt=1,e_max=0,o_max=0,e_sec=0,e_mode=0,o_mode=0;
	int e_cnt_in[n],o_cnt_in[n],e_cnt_num[n],o_cnt_num[n],o_sec=0;
	sort(even,even+n);
	sort(odd,odd+n);

	for(int i=0;i<n;i++){
		e_cnt_in[i]=0;
		o_cnt_in[i]=0;
		e_cnt_num[n]=0;
		o_cnt_num[n]=0;
	}

	j=0;
	for(int i=0;i<(n/2);i++){
		if(even[i]==even[i+1]){
			e_cnt++;
			////cout<<i<<"kaime"<<endl;
		}else{
			if(even[i]==100005){
				////cout<<i<<"kaime"<<endl;
				////cout<<"even:"<<even[i]<<endl;
				continue;
			}
			e_cnt_in[j]=e_cnt;
			e_cnt_num[j]=even[i];
			j+=e_cnt;
			e_cnt=1;
		}
	}
	j=0;
	for(int i=0;i<(n/2);i++){
		if(odd[i]==odd[i+1]){
			////cout<<"i:"<<i<<" odd[i]:"<<odd[i]<<endl;
			o_cnt++;
		}else{
			if(odd[i]==100005)continue;
			o_cnt_in[j]=o_cnt;
			o_cnt_num[j]=odd[i];
			j+=o_cnt;
			o_cnt=1;
		}
	}

	for(int i=0;i<n;i++){
		////cout<<"e_cnt_in:"<<e_cnt_in[i]<<" o_cnt:"<<o_cnt_in[i]<<endl;
	}

	for(int i=0;i<n/2+1;i++){
		if(e_cnt_in[i]>e_max){
			e_max=e_cnt_in[i];
			e_mode=e_cnt_num[i];
		}
	}

	for(int i=0;i<n/2+1;i++){
		//cout<<e_cnt_in[i]<<endl;
		if(e_cnt_in[i]>e_sec){
			//cout<<i<<"aa"<<endl;
			//cout<<"mode"<<e_mode<<endl;
			//cout<<"even"<<even[i]<<endl;
			if(e_mode==even[i])continue;
			if(e_cnt_in[i]==100005)continue;
			e_sec=e_cnt_in[i];
		}
	}

	for(int i=0;i<n/2+1;i++){
		if(o_cnt_in[i]>o_max){
			o_max=o_cnt_in[i];
			o_mode = o_cnt_num[i];
		}
	}

	for(int i=0;i<n/2+1;i++){
		if(o_cnt_in[i]>o_sec){
			if(o_mode==odd[i])continue;
			if(o_cnt_in[i]==100005)continue;
			o_sec=o_cnt_in[i];
		}
	}

	if(e_mode==o_mode){
		//cout<<"esec"<<e_sec<<endl;
		//cout<<"osec"<<o_sec<<endl;
		if(e_sec>o_sec){
			e_max = e_sec;
		}else{
			o_max = o_sec;
		}
	}
	//cout<<"emax:"<<e_max<<" o_max:"<<o_max<<endl;

	res = (n/2-e_max) + (n/2-o_max);

	//res = n - res;
	cout<<res<<endl;
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fe first
#define se second
#define pii pair<int,int>
#define PI  3.14159265358979323846
const int N=1e5+10;
const int INF=1e9+10;
int a[N];

void solve()
{ int n;
	cin>>n;
	vector<int> dp(3,0),dp1(3,0);
	vector<int >v(3,0);

	for(int i=0;i<n;i++)
	 { 
	 	 for(int j=0;j<3;j++)
	 	 	 cin>>v[j];
	 	 for(int j=0;j<3;j++)
	 	   { for(int k=0;k<3;k++)
	 	   	   { if(j!=k)
	 	   	   	   { dp[k]=max(dp[k],dp1[j]+v[k]);
	 	   	   	   }
	 	   	   }
	 	   }
	 	  dp1=dp;
	 }
	cout<<max({dp[0],dp[1],dp[2]});
}


int main()
{  cool;
   int t=1;
   while(t--)   
     solve(); 

  return 0; 
}



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

N = int(input())
SP = list()
for i in range(N):
    s, p = map(str, input().split())
    SP.append([s, int(p), i + 1])

SP.sort(key=lambda x: x[1], reverse=True)
SP.sort(key=lambda x: x[0])

for sp in SP:
    print(sp[2])


Measured memory_bytes: 3060
let () = Scanf.scanf "%d\n" @@ fun n ->
  let sum = ref 0 in
  let count = Array.make 100001 0 in
  for i = 0 to n - 1 do
    Scanf.scanf "%d " @@ fun a ->
      sum := a + !sum;
      count.(a) <- 1 + count.(a)
  done;
  Scanf.scanf "%d\n" @@ fun q ->
    for i = 0 to q - 1 do
      Scanf.scanf "%d %d\n" @@ fun b c ->
        sum := !sum + (c - b) * count.(b);
        count.(c) <- count.(b) + count.(c);
        count.(b) <- 0;
        Printf.printf "%d\n" !sum
    done;


Measured memory_bytes: 6744
v[20];char t[9],s[9],c;main(a,L,i,j,k){for(;scanf("%d%d",&a,&L),L;)
for(v[0]=a,k=1;;v[k++]=a){
for(sprintf(s,"%%0%dd",L),sprintf(t,s,a),s[L]=i=0;i<L;s[i]=t[L-i-1],i++)for(j=1;j<L-i;j++)if(t[j]<t[j-1])c=t[j],t[j]=t[j-1],t[j-1]=c;
for(a=atoi(s)-atoi(t),i=0;i<k;i++)if(v[i]==a)break;
if(i<k){printf("%d %d %d\n",i,a,k-i);break;}
}}

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

int main() {
  int n, t, a = 0;
  cin >> n;
  cin >> t >> a;
  double min = 9999;
  double x = 0;
  int res = 1;
  for( int i = 0; i < n; i++) {
    double h = 0;
    cin >> h;
    x = fabs(a - (t - h * 0.006));
    if (x < min) {
      min = x;
      res = i + 1;
    }
  }
  cout << res << endl;
  return 0;
      
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000000

int main(){

	int N;
	cin>>N;
	
	set<int> S;
	
	for(int i=0;i<N;i++){
		int A;
		cin>>A;
		S.insert(A);
	}
	
	if(S.size()==N)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	return 0;
}

Measured memory_bytes: 9600
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

f (one, many) 0 = (one, many)
f (one, many) 1 = (one+1, many)
f (one, many) _ = (one, many+1)

main = do
    n <- getInt
    unless (n==0) $ getInts >>= putStrLn . maybe "NA" show . fmap ((+1) . uncurry (+)) . mfilter ((>=1) . snd) . Just . foldl f (0,0) >> main
    
    


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

typedef long long ll;

#define rep(var,n) for(int var=0;var<(n);++var)

int main(){

  cin.tie(0);
  ios::sync_with_stdio(false);

  int n; cin >> n;
  string s; cin >> s;

  int ans = 0;

  rep(i,n-1)
    if(s[i] != s[i+1])
      ans++;
  cout << ans+1 << endl;
  return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		int k = Integer.parseInt(scan.next());
		int[] h = new int[n];
		for(int i = 0;i < n; ++i){
			h[i] = Integer.parseInt(scan.next());
		}
		Arrays.sort(h);
		int min = Integer.MAX_VALUE;
		for(int i = 0;i < n - k +1; ++i){
			min = Math.min(min,h[i + k-1] - h[i]);
		}
		System.out.print(min);
	}
}


Measured memory_bytes: 49280
N, M = map(int, input().split())
kouho = {}
kouho[1]=True
Nlist = [1]*(N+1)
ans = 0
for i in range(M):
    x, y = map(int, input().split())
    if x in kouho:
        kouho[y] = True
        Nlist[x] -= 1
        Nlist[y] += 1
    else:
        Nlist[x] -= 1
        Nlist[y] += 1
    if Nlist[x]==0:
        if x in kouho:
            del kouho[x]

for i in range(1, N+1):
    if Nlist[i] == 0:
        continue
    if i in kouho:
        ans += 1

print(ans)


Measured memory_bytes: 20052
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
#include <unordered_map>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
ll n,m;
string s;
string t;
unordered_map<ll,char> mp;
ll gcd(ll m,ll n)
{
  if((m==0) || (n==0)) return 0;
  while(m!=n)
    {
      if(m>n) m-=n;
      else n-=m;
    }
  return m;
}

ll lcm(ll m,ll n)
{
  if((m==0) || (n==0))
    {
      return 0;
    }
  return ((m/gcd(m,n))*n);
}
int main(int argc,char const* argv[])
{
  cin >> n >> m;
  cin >> s;
  cin >> t;
  ll mini=lcm(m,n);
  if(s[0]!=t[0])
    {
      cout << -1 << endl;
      return 0;
    }
  for(int i=0;i<n;i++)
    {
      mp[1+(i*mini)/n]=s[i];
    }
  for(int i=0;i<m;i++)
    {
      auto itr=mp.find(1+(i*mini)/m);
      if(itr!=mp.end())
	{
	  if(itr->second!=t[i])
	    {
	      cout << -1 << endl;
	      return 0;
	    }
	}
    }
  cout << mini << endl;
  return 0;
}


Measured memory_bytes: 4260
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define gc getchar
#define pc putchar
#define cs const

inline
ll getint(){
	re ll num;
	re char c;
	re bool f=0;
	while(!isdigit(c=gc()))f^=c=='-';num=c^48;
	while(isdigit(c=gc()))num=(num<<1)+(num<<3)+(c^48);
	return f?-num:num;
}

inline
void outint(ll a){
	static char ch[23];
	if(a==0)pc('0');
	while(a)ch[++ch[0]]=a-a/10*10,a/=10;
	while(ch[0])pc(ch[ch[0]--]^48);
}

cs ll INF=0x3f3f3f3f3f3f3f3f;
cs int N=1005;
cs int dx[4]={1,-1,0,0};
cs int dy[4]={0,0,-1,1};
cs char s[4]={'R','L','D','U'};

int n;
ll x[N],y[N];
vector<ll> len;
bool flag;

signed main(){
	n=getint();
	for(int re i=1;i<=n;++i){
		x[i]=getint(),y[i]=getint();
		if(i^1){
			if(((x[i]^y[i])&1)!=flag)return puts("-1"),0;
		}
		else flag=(x[i]^y[i])&1;
	}
	for(int re i=0;i<=30;++i){
		len.push_back(1ll<<i);
	}
	if(flag==0)len.push_back(1);
	
	sort(len.rbegin(),len.rend());
	
	outint(len.size()),pc('\n');
	for(int re i=0;i<len.size();++i)
	outint(len[i]),pc(' ');
	pc('\n');
	
	for(int re i=1;i<=n;++i){
		ll xx=x[i],yy=y[i];
		for(int re j=0;j<len.size();++j){
			int pos;
			ll minn=INF;
			for(int re k=0;k<4;++k){
				ll tmpx=xx-len[j]*dx[k];
				ll tmpy=yy-len[j]*dy[k];
				if(abs(tmpx)+abs(tmpy)<minn){
					minn=abs(tmpx)+abs(tmpy);
					pos=k;
				}
			}
			pc(s[pos]);
			xx=xx-len[j]*dx[pos];
			yy=yy-len[j]*dy[pos];
		}pc('\n');
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

#define INF 1e9
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(m);
    vector<int> d(m);
    rep(i, n) {
        cin >> a.at(i) >> b.at(i);
    }
    rep(i, m) {
        cin >> c.at(i) >> d.at(i);
    }
    int dis;
    vector<int> diss(n, INF);
    vector<int> ans(n);
    rep(i, n) {
        rep(j, m) {
            dis = abs(a.at(i) - c.at(j)) + abs(b.at(i) - d.at(j));
            if (dis < diss.at(i)) {
                diss.at(i) = dis;
                ans.at(i) = j + 1;
            }
        }
    }
    rep(i, n) {
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 256
////////////////////////////////////
////////////////////////////////////
////                            ////
////                            ////
////     Please give me AC!     ////
////     Please give me AC!     ////
////                            ////
////                            ////
////////////////////////////////////
////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す//計算量は0(log(max(a,b))
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す//計算量は0(log(max(a,b))
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す//計算量は0(log(y))
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す//計算量は0(sqrt(a))
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
vector<int> Z;
void z_algorithm(string str){//計算量はO(str.size())
  Z.resize(str.size());
  Z.at(0)=str.size();
  int m=1,n=0;
  while(m<(int)str.size()){
    while(m+n<(int)str.size()&&str.at(n)==str.at(m+n)){n++;}
    Z.at(m)=n;
    if(n==0){
      m++;
      continue;
    }
    int k=1;
    while(k+Z.at(k)<n){
      Z.at(m+k)=Z.at(k);
      k++;
    }
    m+=k;
    n-=k;
  }
}
int main(){
  ll a;
  cin>>a;
  cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

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

	vector<string> a(n);

	for(auto& x: a)
	{
		cin >> x;
		sort(x.begin(), x.end());		
	}

	sort(a.begin(), a.end());
	ll answ = 0;

	for(int i = 0; i < n;)
	{
		int j = i;

		while(j + 1 < n && a[j + 1] == a[i])
			++j;

		ll cnt = j - i + 1;
		answ += (cnt * (cnt - 1)) / 2;

		i = j + 1;
	}

	cout << answ << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 5760
// https://programming-place.net/ppp/contents/cpp/rev_res/array002.html
#include<iostream>
#include<cmath>
#include<iomanip>
#include<functional>
#include<algorithm>
using namespace std;

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

/*
namespace {
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << std::ends;
        }
        std::cout << std::endl;
    }
}
*/

int main(){
  int N, K;
  cin >> N >> K;
  long long array[N];
  for(int i=0; i<N; i++) {
      cin >> array[i];
  }

  std::sort(array, array + SIZE_OF_ARRAY(array));
  // printElems(array, array + SIZE_OF_ARRAY(array));

  long long wa=0;

  for(int i=0; i<N-K; i++) {
      wa += array[i];
  }
  
  std::cout.setf(std::ios::left, std::ios::adjustfield);
  cout << setw(25) << setprecision(15) << wa << endl;
  return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

int main()
{
    int n; cin >> n;
    set<int> A;
    rep(i,n){
        int Ai; cin >> Ai;
        A.insert(Ai);
    }
    int i = 0;
    for(auto Ai: A){
        cout << Ai;
        if(i != A.size()-1) cout << " ";
        i++;
    }
    cout << endl;
}


Measured memory_bytes: 7776
n, m, x = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(n)]

ans = 1000000000000
flag = 0
for i in range(2**n):
    u = [0]*m
    tmp = 0
    for j in range(n):
        if ((i>>j)&1) :
            l = li[j]
            tmp += l[0]
            for k in range(m):
                u[k] += l[k+1]
    if all(i >= x for i in u):
        flag = 1
        ans = min(tmp, ans)
if flag:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 9228
n, x, y = map(int,input().split())

ans = [0] * (n+10)

for i in range(1, n+1):
    for j in range(i+1, n+1):
        distance = min(abs(j-i), abs(x-i) + 1 + abs(y-j), abs(y-i) + 1 + abs(x-j))
        ans[distance] += 1
        
for i in range(1, n):
    print(ans[i])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int n;
    cin >> n;
    map<string,int> mp;
    rep(i,n){
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;


    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

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

  set<string> sub;
  for(int i = 0; i < s.size(); i++){
    string t = "";
    for(int j = i; j < min((int)s.length(),i+6); j++){
      t += s[j];
      sub.insert(t);
    }
  }

  vector<string> sol;
  for(string s : sub){
    sol.push_back(s);
  }

  sort(sol.begin(),sol.end());
  cout << sol[k-1] << endl;

  return 0;
}

Measured memory_bytes: 2560
import networkx as nx

n, m = map(int, input().split())
s = [input() for _ in range(n)]
g = nx.DiGraph()
S, T = n*m, n*m+1
pot, cnt = 0, 0
for i in range(n):
	for j in range(m):
		if s[i][j] == "#":
			continue
		g.add_edge(i*m+j, T, capacity=1, weight=n+m-i-j)
		if s[i][j] == "o":
			g.add_edge(S, i*m+j, capacity=1, weight=0)
			pot += n+m-i-j
			cnt += 1
		if i < n-1 and s[i+1][j] != "#":
			g.add_edge(i*m+j, (i+1)*m+j, capacity=100, weight=0)
		if j < m-1 and s[i][j+1] != "#":
			g.add_edge(i*m+j, i*m+j+1, capacity=100, weight=0)
g.add_node(S, demand=-cnt)
g.add_node(T, demand=cnt)
ans, _ = nx.algorithms.flow.network_simplex(g)
print(pot - ans)

Measured memory_bytes: 59916
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using ll = long long;

using namespace std;

int main(){
	
	int n;
	ll k;
	cin >> n >> k;
	vector<int> a(n + 1);
	for(int i = 1; i <= n; i++)cin >> a[i];
	a[0] = 1;
	
	vector<int> table(n + 1 , -1);
	vector<int> memo;
	int now = 0;
	
	while(table[a[now]] == -1){
		memo.push_back(a[now]);
		table[a[now]] = memo.size();
		now = a[now];
	}

	int cycle = memo.size() + 1 - table[a[now]];
	int before_cycle = table[a[now]] - 1;
	
	if(k <= before_cycle){
		cout << memo[k] << endl;
	}else{
		cout << memo[before_cycle + ((k - before_cycle) % cycle)] << endl;
	}
	
	return 0;
}
 

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


int main() {
long int N,X,M;
  cin >>N>>X>>M;
  if(M>1){vector<long int>vec(2*M);
  vec.at(0)=X%M;
  for(long int i=1;i<=2*M-1;i++){
  long int k=vec.at(i-1)%M;
  long int l=(k*k)%M;
    vec.at(i)=l;
  }
  long int s=0;
  long int t=0;
  for(long int p=0;p<2*M-2;p++){
    if(s>0){break;}
  for(long int q=p+1;q<2*M-1;q++){
    if(vec.at(p)==vec.at(q)){
    s=p;
      t=q;
    break;}
  }}
  long int r=t-s;
  
  long int a=0;
  if(r>1){
  for(long int b=s;b<t;b++){
  a+=vec.at(b);
  }}else{a=vec.at(s);}
 
  long int A=0;
  for(long int w=0;w<s;w++){A+=vec.at(w);}
  
  long int f=0;
  f=(N-s)/r;

  
  long int d=0;
  if((N-s)%r!=0){
  for(long int y=s;y<=s+(N-s)%r-1;y++){d+=vec.at(y);}}
  A+=a*f+d;
cout<<A<<endl;}
  else if(M==1){
                cout<<0<<endl;}
}

Measured memory_bytes: 4836
#include<stdio.h>
#include<stdlib.h>

int main(){
  int A[1000]; 
  int i,j,k,v,N;

  scanf("%d",&N); 
  
  //constraint
  if(N<1 || N>100){
    exit(1);
  }

  //input array
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  //insertion sort
  for(i=1;i<N;i++){

    //output
    for(k=0;k<N;k++){
      if(k==N-1){
	printf("%d\n",A[k]);
	break;
      }
      printf("%d ",A[k]);
    }

    v=A[i];
    j=i-1;

    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
      A[j+1]=v;
    }
  }

  //output
  for(k=0;k<N;k++){
    if(k==N-1){
      printf("%d\n",A[k]);
      break;
    }
    printf("%d ",A[k]);
  }

  return 0;
}
  

Measured memory_bytes: 600
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

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

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

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

bool prime(int n) {
  for (int i = 2; i <= sqrt(n); ++i) {
    if (n % i == 0) { return false; }
  }
  return n != 1;
}

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

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll powmod(ll x, ll y) {
  ll r = 1;
  while (y) {
    if (y & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    y >>= 1;
  }
  return r;
}

const int COM_MAX = 500010;
ll fac[COM_MAX], facinv[COM_MAX], inv[COM_MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  facinv[0] = facinv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < COM_MAX; ++i) {
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    facinv[i] = facinv[i-1] * inv[i] % MOD;
  }
}

ll COM(ll n, ll k) {
  return (fac[n] * facinv[k] % MOD) * facinv[n-k] % MOD;
}

ll PERM(ll n, ll k) {
  return (fac[n] * facinv[k] % MOD);
}

int main(int argc, char** argv) {
  int N, M;
  cin >> N >> M;
  vector<int64_t> A(N);
  rep(i, N) {
    cin >> A[i];
  }

  priority_queue<int64_t> q;
  rep(i, N) {
    q.push(A[i]);
  }

  rep(i, M) { // M times
    int64_t price = q.top(); q.pop();
    price /= 2;
    q.push(price);
  }

  int64_t r = 0;
  while (!q.empty()) {
    int64_t price = q.top(); q.pop();
    // For Debug
    // cout << price << endl;
    r += price;
  }

  cout << r << endl;

  return 0;
}


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

int main()
{
  string a;
  bool frag = false;

  cin >> a;

  
  for(int i = 0; i < a.size() - 1; i++)
  {
    if(a[i] == a[i+1])frag = true;
  }

  if(frag == true)cout << "Bad" << endl;
  
  else
  {
    cout << "Good" << endl;
  }
  
  
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys

DEBUG = False

def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep = " "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    n = read(str)
    if "7" in list(n):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9124
#include <stdio.h>
#include <math.h>
 
int main(void)
{
  int i, n, a[2000001], b[2000001];
  
  scanf("%d", &n);
  
  for( i = 1; i < n; i++ ){
     scanf("%d", &a[i]);
  }
  
  for( i = 1; i < n; i++ ){
    b[a[i]-1] += 1;
  }
    
  for( i = 0; i < n; i++ ){
    printf("%d\n", b[i]);
  }
    
  return 0;
}

Measured memory_bytes: 3232
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
typedef long long ll;
#define MAX(a,b) ((a)>(b)?(a):(b))

int main(void){
    ll a,b,k;
    scanf("%lld %lld %lld", &a, &b, &k);
    if (k >= a) {
        printf("0 %lld\n", MAX(b + a - k, 0));
    } else {
        printf("%lld %lld\n", a - k, b);
    }
    return 0;
}


Measured memory_bytes: 128
// abc043_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  string S;
  cin>>S;
  vector<string> ans;
  for (int i=0, str_size=S.size();i<str_size;++i) {
    if (S[i] == '0') ans.push_back("0");
    if (S[i] == '1') ans.push_back("1");
    if (S[i] == 'B' && !ans.empty()) ans.erase(ans.end());
  }
  for(auto x : ans) cout<<x;
  cout<<endl;
  return 0;
}


Measured memory_bytes: 3596
#[allow(dead_code)]
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()
}

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

#[allow(dead_code)]
fn read_vec3<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read::<T>()).collect()
}

fn is_prime(x: u32) -> bool {
    let two: u32 = 2;
    let three: u32 = 3;
    match x {
        x if x == two => true,
        x if x < two || x % two == 0 => false,
        _ => {
            let mut i = three;
            while i * i <= x {
                if x % i == 0 {
                    return false;
                }
                i = i + two;
            }
            true
        }
    }
}

fn main() {
    let n = read::<usize>();

    let v = read_vec3::<u32>(n);
    let mut count = 0;
    for i in 0..n {
        if is_prime(v[i]) {
            count += 1;
        }
    }
    println!("{}", count);
}



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

int main() {
  int n, k; cin >> n >> k;
  int ans = 1;
  for(int i = 0; i < n; ++i) {
    ans = min(ans * 2, ans + k );
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
template<typename T>
T minch(T& l, T r) {
    return l = min(l, r);
}
template<typename T>
T maxch(T& l, T r) {
    return l = max(l, r);
}
template<typename T>
void output(const T& val) {
    cout << val << endl;
}
template<typename T>
void output(const vector<T>& vec, const bool newline = false) {
    for (const T& val : vec)cout << val << (newline ? '\n' : ' '); cout << endl;
}
template<typename T>
void output(const vector<vector<T>>& mat) {
    for (const auto& row : mat)output(row);
}
// ============ template finished ============

void dfs(
    const vector<vector<int>>& edges,
    const vector<int>& a,
    const int now,
    const int parent,
    vector<vector<int>>& dp,
    vector<int>& res
) {
    // find
    vector<int> base = { a[now] };
    auto itr = lower_bound(dp.begin(), dp.end(), base,
        [](const vector<int>& l, const vector<int>& r) {
        return l.back() < r.back();
    });
    // update
    int idx = itr - dp.begin();
    if (itr == dp.end()) {
        dp.push_back({});
    }
    dp[idx].push_back(a[now]);
    res[now] = dp.size();

    // go to leaf
    for (int next : edges[now])if (next != parent) {
        dfs(edges, a, next, now, dp, res);
    }

    // back to route
    dp[idx].pop_back();
    if (dp[idx].empty()) {
        assert(dp.size() == idx + 1);
        dp.pop_back();
    }
}

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N)cin >> a[i];
    vector<vector<int>> edges(N);
    rep(i, N - 1) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    vector<int> res(N);
    vector<int> route;
    vector<vector<int>> dp;
    dfs(edges, a, 0, -1, dp, res);
    for (int num : res) {
        cout << num << endl;
    }
    return 0;
}


Measured memory_bytes: 45608
n=int(input())
h=list(map(int,input().split()))
def changemin(a,b):
    if a>b:
        a=b
        return a
    return a
dp=[]
dp.append(0)
for i in range(1,n):
    dp.append(10000000000)
for j in range(1,n):
    dp[j]=changemin(dp[j],dp[j-1]+abs(h[j]-h[j-1]))
    if j>1:
        dp[j]=changemin(dp[j],dp[j-2]+abs(h[j]-h[j-2]))
print(dp[n-1])

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

int main()
{
    ll N, M; cin >> N >> M;
    vector<set<ll>> V(N);
    rep(i,M) {
        ll a, b; cin >> a >> b;
        a--;
        b--;
        V[a].insert(b);
        V[b].insert(a);
    }
#if 0
    rep(i,N) {
        for (auto v : V[i]) {
            cout << v << " ";
        }
        cout << endl;
    }
#endif
    vector<ll> ans(N, 0);
    vector<ll> m(N, 0);
    for (int i = 0; i < N; ++i) {

        if (m[i] != 0) continue;

        queue<ll> q;
        q.push(i);
        m[i] = 1;
        ll num = 0;

        while (1) {

            if (q.empty()) break;

            ll f = q.front();
            q.pop();
            num++;
            //cout << "f = " << f << ",num++" << endl;

            for (auto v : V[f]) {
                if (m[v] == 0) {
                    q.push(v);
                    m[v] = 1;
                }
            }

        }

        ans[i] = num;

        //cout << endl;
    }

    sort(ans.begin(), ans.end(), greater<ll>());
    cout << ans[0] << endl;


}


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

int main() {

	int A, B;
	cin >> A >> B;

	if ((A + B) % 3 == 0 || A % 3 == 0 || B % 3 == 0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;

	return 0;
}

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

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

int main() {
    int A, B, C, X, count = 0;
    cin >> A >> B >> C >> X;

    rep(i, min(A, (X / 500))){
        rep(j, min(B, ((X - (500*i)) / 100))){
            if (C >= (X - ((500*i)+(100*j))) / 50) {
                count++;
            }
        }
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut seq = vec![(0, 0, 0); n - 1];
    for i in 0..n-1 {
        seq[i].0 = read();
        seq[i].1 = read();
        seq[i].2 = read();
    }
    let mut anss: Vec<usize> = vec![0; n];
    for i in 0..n-1 {
        let mut t = 0;
        for j in i..n-1 {
            t = std::cmp::max(t, seq[j].1);
            if t % seq[j].2 != 0 {
                t += seq[j].2 - (t % seq[j].2);
            }
            t += seq[j].0;
        }
        anss[i] = t;
    }
    for v in anss.iter() {
        println!("{}", v);
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
string str;
int k,flag=1;
void Solve(){
    cin>>str;
    cin>>k;
    for(int i=0;i<k;i++) if(str[i]-'0'>1){
        cout<<str[i];
        flag=0;
        break;
    }
    if(flag==1) cout<<str[k-1]<<endl;
}
int main(){
    Solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((lint)1000000007)

using namespace std;

void execute()
{
	int N;
	string A, B;
	int start;
	bool same;
	lint ans;
	cin >> N;
	cin >> A >> B;

	if (A[0] == B[0])
	{
		same = true;
		start = 1;
		ans = 3;
	}
	else
	{
		same = false;
		start = 2;
		ans = 6;
	}

	for (int i = start; i < N;)
	{
		if (A[i] == B[i])
		{
			if (same)
			{
				ans *= 2;
			}
			else
			{
				ans *= 1;
			}
			same = true;
			i += 1;
		}
		else
		{
			if (same)
			{
				ans *= 2;
			}
			else
			{
				ans *= 3;
			}
			same = false;
			i += 2;
		}
		ans %= INV;
	}

	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mx 100001
#define tc int t;cin>>t;for(int raf=1;raf<=t;raf++)
#define fm cout<<"Case "<<raf<<": "
using namespace std;
bool prime[100005];

int main()
{
    int a,b,c=0,i,j,n,k;
    cin>>n>>k;
    long long x[n],l,r,o=0,d,e;
    for(i=0;i<n;i++)
    {
        cin>>x[i];
        if(x[i]<0)o=i,c=1;
    }
    if(!c)
    {
        cout<<x[k-1];
        return 0;
    }
    else if((x[n-1]!=0)&&(o!=n-1))
    {
        o++;
    }
    else
    {
        cout<<-x[n-k]<<endl;
        return 0;
    }
    long long ans=numeric_limits<int>::max(), tmp;
    for(i=0;i<(n-k+1);i++)
    {
        l=i;
        r=l+k-1;
        if(x[l]<0&&x[r]>0)
        {
            if(-x[l]>x[r])
            {
                tmp=2*x[r]-x[l];
            }
            else
            {
                tmp=x[r]-2*x[l];
            }
        }
        else if(x[l]<=0&&x[r]<=0)
        {
            tmp=-x[l];
        }
        else
        {
            tmp=x[r];
        }

        if(ans>tmp)ans=tmp;
    }
    cout<<ans<<endl;










    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <algorithm>

using  namespace std;

int main() {

    int n, k;
    cin >> n >> k;
    vector <int> prices;
    int total = 0;

    for (int i = 0 ; i < n; i++){
        int p;
        cin >> p;
        prices.push_back(p);
    }

    sort(prices.begin(), prices.end());

    for (int i = 0; i < k; i++){
        total += prices[i];
    }

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 3196
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;

signed main() {
int A=0,B=0,C;
string T;
cin >> T;
C = T.size();
REPD(i,C){
  if(T.at(i) == '?'){
    T.at(i) = 'D';
  }
}
answer(T);
}

Measured memory_bytes: 3696
#include "bits/stdc++.h"
using namespace std;
int main(){
	int n; cin>>n;
	int a[220]={0};
	for(int i=0;i<n;i++)cin>>a[i];

	int cnt=0;
	bool can = true;
	while(can){
		for(int i=0;i<n;i++){
			if(a[i]%2 != 0)	can = false;
			a[i] = a[i]/2;
		}
		if(can)cnt++;
	}

	cout<< cnt <<endl;

	return 0;
}

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

signed main(){
	int N, K, i;
	scanf("%lld%lld", &N, &K);
	if(2 * K > N + 1){
		printf("-1\n");
		return 0;
	}
	vector<int> a(N), b(N), c(N);
	for(i = 0; i < N; i++){
		c[i] = K + 2 * N + i;
	}
	if(N % 2 == 0){
		for(i = 0; i < N / 2; i++){
			a[i] = K + 2 * i;
		}
		for(i = 0; i < N / 2; i++){
			a[N / 2 + i] = K + 1 + 2 * i;
		}
		for(i = 0; i < N / 2; i++){
			b[i] = K + N + N / 2 - 1 - i;
		}
		for(i = 0; i < N / 2; i++){
			b[N / 2 + i] = K + N + N - 1 - i;
		}
	}
	else{
		for(i = 0; i <= N / 2; i++){
			a[i] = K + 2 * i;
		}
		for(i = 0; i < N / 2; i++){
			a[N / 2 + i + 1] = K + 1 + 2 * i;
		}
		for(i = 0; i <= N / 2; i++){
			b[i] = K + N + N / 2 - i;
		}
		for(i = 0; i < N / 2; i++){
			b[N / 2 + i + 1] = K + N + N - 1 - i;
		}
	}
	for(i = 0; i < N; i++){
		printf("%lld %lld %lld\n", a[i], b[i], c[i]);
	}
	return 0;
}

Measured memory_bytes: 4608
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

const int N=2e5+5;

int n,k,a[N],c[N];

int main()
{ios_base::sync_with_stdio(false);
cin>>n>>k;
rep(i,1,n)cin>>a[i];

rep(j,1,min(k,400))
{
	rep(i,1,n)c[i]=0;
	rep(i,1,n)
	{
		c[max(i-a[i],1)]++;
		c[min(i+a[i]+1,n+1)]--;
	}
	rep(i,1,n)
	{
		c[i]+=c[i-1];
		a[i]=c[i];
	}
}
rep(i,1,n)
{
	ol(a[i]);os;
}
return 0;
}



Measured memory_bytes: 5216