akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
const int MAXN = (int)1e6+7;

bool OK(int x) {
    int num = 0;
    while (x) {
        x/=10;
        num++;
    }
    if (num&1) return true;
    else       return false;
}

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

    int N;
    cin >> N;
    int ans = 0;
    rep(i,1,N) {
        if (OK(i)) ans ++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
main = do
  s <- getLine
  let as = map (read . return) s :: [Int]
  let bs = zipWith (==) (cycle[0,1]) as
  print $ func bs

func :: [Bool] -> Int
func bs = if x < y then x else y
  where x = length $ filter (==True) bs
        y = length $ filter (==False) bs



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

int main(){   
	int m,n;
	int a;
	int k,c,cc,res=0;
	char *s;
	while(1){
		scanf("%d",&m);
		if(m==0)break;
		scanf("%d",&n);
		s=(char*)malloc(sizeof(char)*(n));
		scanf("%s",s);
		for(a=0;a<=n-m*2;a++){
			if(s[a]=='I'){
				k=0;
				c=m;
				cc=0;
				while(c>0){
					if(s[a+k*2+1]=='O' && s[a+k*2+2]=='I')cc++;else break;
					c--;
					k++;
				}
				if(m==cc)res+=1;
			}
		}
		printf("%d\n",res);
		res=0;
	}
	return 0;
} 

Measured memory_bytes: 1460
import javax.xml.crypto.Data;
import java.util.*;
import java.io.*;

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

        //入力
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();


        // 出力
        if(B - A <= 0){
            System.out.println("delicious");
        }
        else if(B - A <= X){
            System.out.println("safe");
        }
        else{
            System.out.println("dangerous");
        }
    }
}

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

int main(void){
   
 int a,b,c=0;
 cin >> a >> b;
 
 for(int i=1;i<=a;i++){
     c++;
     if(i == a && b < a) c--;
 }
 cout << c << endl;
}

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

#define dbg(x) cerr<<#x": "<<x<<"\n"
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"


using namespace std;

long long n;
int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n;
	long long x = 1, s=0;
	while(s + x <= n)
		s+=x, x++;
	x--;
	if(x*(x+1)/2 == n)
	{
		cout << x;
		return 0;
	}
	cout << x+1;

}


Measured memory_bytes: 256
/*   Abhijith  */
#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define	endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vector<lld> v(3001);
lld dp[3001][3001][2];
lld ans=0,n;
lld rec(lld l,lld r,lld pla)
{
    if(dp[l][r][pla]!=-1)
        return dp[l][r][pla];
    if(l>r)
    {
        return dp[l][r][pla]=0;
    }
    if(pla==0)
    {
        ans=max(v[l]+rec(l+1,r,1),v[r]+rec(l,r-1,1));
    }
    else
    {
        ans=min(rec(l+1,r,0)-v[l],rec(l,r-1,0)-v[r]);
    }
    return dp[l][r][pla]=ans;
}
int main()
{
     ios;
     cin>>n;
     rep(i,1,n)
     {
         cin>>v[i];
     }
     rep(l,1,n)
     {
         rep(i,1,n-l+1)
         {
             lld j=i+l-1;
             if(l==1)
             {
                 dp[i][j][0]=v[i];
                 dp[i][j][1]=-v[i];
             }
             else
             {
                 dp[i][j][0]=max(dp[i+1][j][1]+v[i],dp[i][j-1][1]+v[j]);
                 dp[i][j][1]=min(dp[i+1][j][0]-v[i],dp[i][j-1][0]-v[j]);
             }
         }
     }
     //lld ans= rec(1,n,0);
     cout<<dp[1][n][0]<<endl;
    return 0;
}


Measured memory_bytes: 139648
a, b, c, d = map(int, input().split())
ac_displacement = abs(c - a)
ab_displacement = abs(b - a)
bc_displacement = abs(c - b)
if ac_displacement <= d:
    print('Yes')
elif ab_displacement <= d and bc_displacement <= d:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a < b){
			if(b < c){
				System.out.printf("%d %d %d\n", a, b, c);
			}else if(a < c){
				System.out.printf("%d %d %d\n", a, c, b);
			}else{
				System.out.printf("%d %d %d\n", c, a, b);
			}
		}else{
				if(a < c){
					System.out.printf("%d %d %d\n", b, a, c);
					}else if(b < c){
						System.out.printf("%d %d %d\n", b, c, a);
					}else{
						System.out.printf("%d %d %d\n", c, b, a);
					}
				}
			}
		}

Measured memory_bytes: 26192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

vector<int> role(8,-1);
vector<int> l(8,0);
int a, b, c;

int dfs(int n, int depth){
    if(depth == n){
        int anum=0, bnum=0, cnum=0;
        int alen=0, blen=0, clen=0;
        for(int i = 0; i < n; i++){
            if(role[i] == 1){anum++; alen+=l[i];}
            else if(role[i] == 2){bnum++; blen+=l[i];}
            else if(role[i] == 3){cnum++; clen+=l[i];}
        }
        if(anum == 0 || bnum == 0 || cnum == 0){
            return 999999999;
        }
        int cost = (anum-1)*10+(bnum-1)*10+(cnum-1)*10;
        cost += abs(alen-a)+abs(blen-b)+abs(clen-c);
        return cost;
    }
    int cost = 999999999;
    for(int i = 0; i < 4; i++){
        role[depth] = i;
        cost = min(cost, dfs(n, depth+1));
    }
    return cost;
}

int main(){
    int n;
    cin >> n >> a >> b >> c;
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    int ans = dfs(n,0);

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


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MP make_pair
#define MT make_tuple
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

	string S;
	cin >> S;

	int K;
	cin >> K;

	string ret = "";

	EACH(c, S){
		if(c != 'a' && 'z' - c + 1 <= K){
			K -= 'z' - c + 1;
			//cout << K << endl;
			ret += 'a';
		}
		else{
			ret += c;
		}
	}

	ret[ret.length() - 1] = (ret[ret.length() - 1] - 'a' + K) % ('z' - 'a' + 1) + 'a';

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 720
from itertools import combinations
from collections import deque

n,m,x = map(int,input().split())

c = []
a = []
for _ in range(n):
	tmp = deque(map(int,input().split()))
	c.append(tmp.popleft())
	a.append(list(tmp))

l = []
ans = 10 ** 9
for i in range(2**n):
	l = []
	tmp = 0
	for j in range(n):
			if i & (1<<j):
				l.append(j)
				tmp += c[j]
	res = [0 for _ in range(m)]
	for j in l:
		for k in range(m):
			res[k] += a[j][k]
	flag = True
	for j in range(m):
		if res[j] < x:
			flag = False
			break
	if flag:
		ans = min(ans,tmp)

if ans == 10 ** 9:
	print(-1)
else:
	print(ans)


Measured memory_bytes: 9476
N, Y = [int(e) for e in input().split(' ')]

for i in range(N+1):
  for j in range(N+1-i):
    sum = i * 1000 + j * 5000
    if (sum <= Y) and ((Y - sum) % 10000 == 0) and (i + j + (Y - sum) / 10000 == N):
      print('%d %d %d' % ((Y - sum) / 10000, j, i))
      quit()

print('-1 -1 -1')

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

int main() { 
  string s;
  cin >> s;
  int c = s.size();
  int p = 0;
  int q = 0;

  for (int i = 0; i < c; i++){
    p *= 10;
    p += s.at(i) - '0';

    q += s.at(i) - '0';
  } 
  if(p%q==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3576
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define int long long

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

typedef pair<int,int> P;

signed main() {
    int N, M;
    cin >> N >> M;
    vector<P> vs(N);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        vs[i].first = a, vs[i].second = b;
    }
    sort(vs.begin(), vs.end(), [](P x, P y) {
        return x.first < y.first;
    });

    int cost = 0, cur = 0;
    for (int i = 0; i < N; i++) {
        cost += vs[i].first * vs[i].second;
        cur += vs[i].second;
        if (cur > M) {
            int tmp = abs(cur - M);
            cost -= vs[i].first * tmp;
            break;
        }
    }
    cout << cost << endl;
}


Measured memory_bytes: 1792
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int P, Q, R;
    
    cin >> P >> Q >> R;
    int ans = 400;
    int a = P+Q;
    if(a < ans){
        ans = a;
    }
    int b = P + R;
    if(b < ans){
        ans = b;
    }
    int c = Q+R;
    if(c < ans){
        ans = c;
    }


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

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

int32_t main() {
        int arr[101];

        int n, sum = 0,  idx = 1; cin >> n;
        for(int i = 1; i <= n; i++) {
                cin >> arr[i];
                sum += arr[i];
        }

        for(int i = 2; i <= n; i++) {
                if(abs(n * arr[i] - sum) < abs(n * arr[idx] - sum)) idx = i;
        }

        cout << idx - 1 << endl;

}


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

int main(){
  string str;
  int sum=0;
  while(1){
    
    cin >> str;
    if(str=="0") break;
    for (int i=0;i<(int)str.size();i++){
      sum+=str[i]-'0';
    }
    cout << sum << endl;
    sum=0;
  }
}


Measured memory_bytes: 3140
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define TRACE(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << endl;}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "[" << *it << " = " << a << "]";
	err(++it, args...);
}

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define LOG(x) if(DEBUG) cerr << x << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

ll n;
ll a[MAXN];
ll ans;
map <ll, ll> f, s;

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
		
		f[i + a[i]]++;
		s[i - a[i]]++;
	}

	for(auto x : f)
		if(s.count(x.first))
			ans += x.second * s[x.first];

	cout << ans << endl;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

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

int main() {
  int N, K;
  cin >> N >> K;

  int count = 1;
  for (int i = 0; i < N; i++) {
    if (count * 2 > count + K) {
      count += K;
    } else {
      count *= 2;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]


INF = float("inf")
MOD = 10**9 + 7


def main():
    N = INT()
    A = LIST()
    A.sort()
    M = A[-1] + 1
    table = [0] * (M)

    for i in A:
        if table[i] == 0:
            table[i] = -1
            for j in range(i + i, M, i):
                table[j] = 1
        elif table[i] == -1:
            # 重複しているということ
            table[i] = -2
    # print(table)
    cnt = 0
    for i in range(N):
        if table[A[i]] == -1:
            cnt += 1
    print(cnt)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 103100
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

class stack{
    int sd[128];
    int sp;
public:
    stack():sp(0){};
    void push(int d) {sd[sp++]=d;};
    int pop() {return sd[--sp];};
};

int strtoint(string &str) {
    istringstream is(str);
    int ans;
    is>>ans;
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    stack st;
    string com;
    int a, b;
    while(cin>>com) {
        if(com=="+") {
            b=st.pop();
            a=st.pop();
            st.push(a+b);
        } else if(com=="-") {
            b=st.pop();
            a=st.pop();
            st.push(a-b);
        } else if(com=="*") {
            b=st.pop();
            a=st.pop();
            st.push(a*b);
        } else {
            st.push(strtoint(com));
        }
    }
    cout<<st.pop()<<'\n';
    return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>


using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)


int main()
{
    double l;
    cin >> l;
    // l /= 3.0;
    l = pow(l,3);
    cout << setprecision(10) << l/27 << endl;
}


Measured memory_bytes: 256
def burg(lev,x):
  if lev <= 0:
    return int(x>0)
  if x <= 1:
    return 0
  if 1 < x < h[lev-1]+2:
    return burg(lev-1,x-1)
  if x == h[lev-1]+2:
    return p[lev-1] + 1
  if h[lev-1]+2 < x < h[lev]:
    return p[lev-1] + 1 + burg(lev-1,x-(h[lev-1]+2))
  if x >= h[lev]:
    return p[lev]

n,x = map(int, input().split())
h = [1]*(n+2)
p = [1]*(n+2)
for i in range(1,n+2):
  h[i] = h[i-1]*2 + 3
  p[i] = p[i-1]*2 + 1
print(burg(n,x))

Measured memory_bytes: 3064
from sys import stdin

def main():

    input = stdin.readline

    N,K = map(int,input().split())

    ans = []

    for _ in range(K):
        tmp = input()
        ans.extend(list(map(int,input().split())))
    
    ans_num = N-len(set(ans))

    print(ans_num)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9152
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int i;
	int a[100005];
	for(i=0;i<n;i++)
	  scanf("%d",&a[i]);
	int ans=0;
	int now=1;
	int x[100005]={};
	while(x[now-1]==0)
	{
		if(now==2)
		{
			printf("%d\n",ans);
			return 0;
		}
		ans++;
		x[now-1]=1;
		now=a[now-1];
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 896
n,x,y = map(int, input().split())
g = [0]*(n)
for i in range(1,n+1):
  for j in range(1,i):
    e = abs(y-i)+1+abs(x-j)
    f = i-j
    g[min(e,f)]+=1
for i in g[1:]:
  print(i)

Measured memory_bytes: 9304
#include<iostream>
#include<algorithm>
using namespace std;
int a[200000+1];
int b[200000+1];
int c[200000+1];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	for(int i=1;i<=n;++i)
		b[i]=max(b[i-1],a[i]);
	for(int i=n;i>=1;--i)
		c[i]=max(c[i+1],a[i]);
	for(int i=1;i<=n;++i)
		cout<<max(b[i-1],c[i+1])<<endl;
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int d,n;
  cin>>d>>n;
  int x=1;
  rep(i,0,d) x*=100;
  if(n!=100)
  cout<<n*x<<endl;
  else cout<<(n+1)*x<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


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

int main(void) {
	int N, M, C;
	scanf("%d %d %d", &N, &M, &C);
	int B[20];
	int A[20];
	for (int i = 0; i < M; i++) {
		scanf("%d", &B[i]);
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int val = 0;
		for (int j = 0; j < M; j++) {
			scanf("%d", &A[j]);
			val += A[j] * B[j];
		}
		val += C;
		if (val > 0) ans++;
	}

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


Measured memory_bytes: 3796
//#pragma warning(disable:4996)
//#pragma comment(linker, "/STACK:336777216")
//#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
const int N=200005;

void solve()
{
    int a,b;
    cin>>a>>b;
    if(a==b)
    {
        for(int i=0;i<min(a,b);i++)
            cout<<a;
    }
    else if(a>b)
    {
        for(int i=0;i<a;i++)
            cout<<b;
    }
    else
    {
        for(int i=0;i<b;i++)
            cout<<a;
    }
    cout<<endl;
}

int32_t main()
{
    IOS;
    int t;
    t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

int main() {
    int n;
    double a;
    string s;
    cin >> n;
    double sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a >> s;
        if (s == "BTC") a *= 380000;
        sum += a;
    }
    cout << sum << endl;
}

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

int main() {

	char str[100001];
	bool exist[26];

	scanf("%s", str);
	int length = strlen(str);
	for(int L10 = 0; L10 < 26; L10++) {
		exist[L10] = false;
	}

	for(int L10 = 0; L10 < length; L10++) {
		exist[(str[L10] - 'a')] = true;
	}

	for(int L10 = 0; L10 < 26; L10++) {
		if(exist[L10])continue;
		char result[2];
		result[0] = L10 + 'a';
		result[1] = '\0';

		printf(result);
		return 0;
	}
	printf("None");
	return 0;
}

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

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  

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

  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }

  for(j=1;j<=n;j++){
    C[A[j]]++;
  }

  for(i=1;i<=VMAX;i++){
    C[i] = C[i] + C[i-1];
  }
  
  for(j=n;j>=1;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i=0;i<n-1;i++){
    printf("%d ",B[i+1]);
  }
  printf("%d\n",B[n]);
  return 0;
}



Measured memory_bytes: 9568
word = input()


#%%
# word = "BWBWBW"


#%%
word.count("W")
#%%
ans = 0
to_plus = word.count("W")
for i in range(len(word)):
    if word[i] == "B":
        ans += to_plus
    else:
        to_plus -= 1

    
print(ans)



Measured memory_bytes: 3500
{-# LANGUAGE BangPatterns, MultiWayIf #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Int
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> Int -> VU.Vector Int32 -> Int32
solve !n !k !an = VU.last $ V.last dp
 where
  dp :: V.Vector (VU.Vector Int32)
  dp = V.postscanl'
    (\(!dpi) (!i) -> VU.scanl'
      (\(!dpij) (!j) ->
        let !p = if j - fromIntegral (an VU.! i) - 1 >= 0
              then dpi VU.! (j - fromIntegral (an VU.! i) - 1)
              else 0
            !q = dpi VU.! j
            !a = dpij + q - p
        in  a `mod` (10 ^ 9 + 7)
      )
      1
      (VU.fromList [1 .. k])
    )
    (VU.generate (k + 1) (\i -> if i == 0 then 1 else 0))
    (V.convert $ VU.fromList [0 .. n - 1])

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (n, k) <-
    (\(!vec) -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  an <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n k an


Measured memory_bytes: 6140
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			int M = sc.nextInt();
			long[] dp = new long[N + 3];
			boolean[] broken = new boolean[N + 3];
			int mul = 1000000007;
			for (int i = 0; i < M; i++) {
				int a = sc.nextInt();
				broken[a] = true;
				if (broken[a - 1] && broken[a]) {
					System.out.println(0);
					return;
				}
			}
			dp[0] = 1;
			for (int i = 1; i <= N; i++) {
				if (i == 1) {
					if (!broken[i]) dp[i]++;
				}
				else {
					if (broken[i]) dp[i] = 0;
					else dp[i] = (dp[i - 1] + dp[i - 2]) % mul;
				}
			}
			System.out.println(dp[N]);
		}
	}

}

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

using namespace std;

const int mod = 1e9 + 7;

long long add(long long a, long long b) {
    long long res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

long long sub(long long a, long long b) {
    long long res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

long long mul(long long a, long long b) {
    return (((a % mod) * (b % mod)) % mod);
}

long long gcd(long long x, long long y){
    if(y == 0){
        return x;
    }
    if(x > y){
         return gcd(y, x % y);
    }
    else{
         return gcd(x, y % x);
    }
}

void dfs(vector<vector<int>> &v, vector<int> &visited, int node, int &ans){
    if(visited[node]){
        return;
    }
    visited[node] = 1;
    ans++;
    for(auto i : v[node]){
        dfs(v, visited, i, ans);
    }
}

/*bool good(vector<int> &v, int d, int mid){
    vector<int> p(v.size());
    p[0] = v[0] - mid;
    for(int i = 1;i < v.size();i++){
        p[i] = p[i - 1] + (v[i] - mid);
    }
    vector<int> m(v.size());
    m[0] = p[0];
    int mi = m[0];
    for(int i = 1;i < v.size();i++){
        mi = min(mi, p[i]);
        m[i] = mi;
    }
    for(int r = 0;r < v.size();r++){
        if(r - d > 0){
            if(m[r - d - 1] <= p[r]){
                L = r - d;
                R = r;
                return true;
            }
        }
    }
    return false;
}*/

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> v(n + 1, vector<int>());
    vector<int> visited(n + 1);
    set<pair<int, int>> s;
    for(int i = 0;i < m;i++){
        int x, y;
        cin >> x >> y;
        if(s.count({x ,y}) || s.count({x, y})){
            continue;
        }
        else{
            v[x].push_back(y);
            v[y].push_back(x);
            s.insert({x, y});
            s.insert({y, x});
        }
    }
    int ans = 0;
    for(int i = 1;i <= n;i++){
        int tmp = 0;
        if(!visited[i]){
            dfs(v, visited, i, tmp);
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;













    /*int n, d;
    cin >> n >> d;
    vector<int> v(n);
    for(int i = 0;i < n;i++){
        cin >> v[i];
    }
    int l = -1,
        r = 101;
    while(r > l + 1){
        int mid = (l + r) / 2;
        if(good(v, d, mid)){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    cout << L + 1 << " " << R + 1<< endl;
    cout << l << endl;*/
}
/*
5 2
-1 -2 -3 4 5
2 3
4

-3 -2 -1 4 5
2 3
5 + (-3) = 2
4 + -2 = 2
ans = 4

-3 -2 -1 4 5
3 2
5 + -3 = 2
4 + -1 = 3
ans = 5
*/


Measured memory_bytes: 43000
#include <stdio.h>
 
int main(void)
{
    int a, b, r, tmp;
 
    scanf("%d %d", &a, &b);
  
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
 
    r = a % b;

    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
 
    printf("%d\n", b);
    
    return 0;
}


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

int main()
{
    char s[101], t[101];
    scanf("%s%s", s, t);
    int len = strlen(s);
    int i, j;
    bool flag = false;
    char tmp;
    for (i=0; i<len; i++)
    {
        tmp = s[len-1];
        for (j=len-2; j>=0; j--)
        {
            s[j+1] = s[j];
        }
        s[0] = tmp;
        if (strcmp(s, t) == 0) {
            flag = true;
            break;
        }
    }
    if (flag) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

constexpr int MAX = 1e5 + 10;

int h[MAX];
std::vector<int> g[MAX];

int main()
{

    int n, m;

    std::cin >> n >> m;

    for (int i = 1; i <= n; ++i)
        std::cin >> h[i];

    for (int i = 0; i < m; ++i)
    {
        int a, b;
        std::cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    //std::cerr << "de" << std::endl;

    int ans = 0;

    for (int i = 1; i <= n; ++i)
    {
        bool f = 1;
        for (int x : g[i])
        {
            f = f && (h[x] < h[i]);
        }

        ans += f;
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 8688
ans=[0 for i in range(10**4+1)]

n=int(input())

def calc(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x

for i in range(1,100):
    for q in range(1,100):
        for p in range(1,100):
            if calc(i,q,p)<=10**4:
                ans[calc(i,q,p)]+=1

for i in range(1,n+1):
    print(ans[i])

            


Measured memory_bytes: 9316
a, b = map(int, input().split())
s = str(input())
lst = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
for i in range(len(s)):
    if(i != a):
        if(s[i] not in lst):
            print("No");
            exit(0)
    else:
        if(s[i] != '-'):
            print("No");
            exit(0)
print("Yes")


Measured memory_bytes: 38448
use std::io::*;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();

    let ns = s
        .as_bytes()
        .iter()
        .map(|&c| {
            if b'A' <= c && c <= b'Z' {
                (c - b'A' + b'a') as char
            } else if b'a' <= c && c <= b'z' {
                (c - b'a' + b'A') as char
            } else {
                c as char
            }
        })
        .collect::<String>();
    print!("{}", ns);
}



Measured memory_bytes: 5028
#include<stdio.h>
#define N 2000000   
int main(){
   
  int n,i,max=-100000000000,min,r[N];
   
 scanf("%d",&n);
 
 for(i=0;i<n;i++){
 scanf("%d",&r[i]);
 }
   
 min=r[0];
   
  
   
for(i=1;i<n;i++){
 
  if(r[i]-min>max){
  max=r[i]-min;
  }
  if(min>r[i]){
  min=r[i];
  }
}
   
printf("%d\n",max);
   
return 0;
}

Measured memory_bytes: 3004
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val N = rd.readInt()

    val C = CharArray(N)

    var l = 0
    println(l)
    val sl = rd.readString()
    if (sl == "Vacant") return
    C[l] = sl[0]

    var r = N-1
    println(r)
    val sr = rd.readString()
    if (sr == "Vacant") return
    C[r] = sr[0]

    for (q in 0 until 20) {
        val m = (l+r)/2
        println(m)
        val sm = rd.readString()
        if (sm == "Vacant") return

        C[m] = sm[0]
        if ((m-l)%2==1 && C[l]==C[m]
                || (m-l)%2==0 && C[l]!=C[m]) {
            r = m
        } else {
            l = m
        }
    }

    return
}


//val rd = debug.Reader("etc", "apc001", "c", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)
typealias ALI = ArrayList<Int>
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListIntCols: (Int) -> List<List<Int>> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toInt() } } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val readListLongCols: (Int) -> List<List<Long>> = { N -> (0 until N).map { br.readLine().split(' ').map { it.toLong() } } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 34884
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a,b;
  cin >> a>>b;
 
  cout << 2*b-a << endl;
  
}



Measured memory_bytes: 256
import collections

n,k,q = map(int,input().split())

a_L = []
for val in range(q):
    a_L.append(int(input()))

a_L = [i-1 for i in a_L]

count = collections.Counter(a_L)

all_L = list(map(lambda x:x-q,[k]*n))

for val in range(n):
    point = all_L[val] + count[val]
    if point > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 65752
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef pair<int,int> P;
const int MAXH = 501;
const int MAXW = 501;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};
int R;
int W[2], H[2], X[2], Y[2];
int L[2][MAXH][MAXW];
int lev[2][MAXH][MAXW];

void bfs(int k) {
  priority_queue<pair<int,P>, vector<pair<int,P> >, greater<pair<int,P> > > que;
  fill(lev[k][0], lev[k][MAXH], -1);
  que.push(make_pair(L[k][Y[k]][X[k]],P(X[k],Y[k])));
  while(!que.empty()) {
    P p = que.top().second;
    int l = que.top().first;
    que.pop();
    if(lev[k][p.second][p.first] != -1) continue;
    lev[k][p.second][p.first] = l;
    for(int i = 0; i < 4; ++i) {
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if(nx < 0 || nx >= W[k]) continue;
      if(ny < 0 || ny >= H[k]) continue;
      if(lev[k][ny][nx] != -1) continue;
      que.push(make_pair(max(l,L[k][ny][nx]),P(nx,ny)));
    }
  }
}

int solve() {
  vector<pair<int,int> > v[2];
  for(int k = 0; k < 2; ++k) {
    bfs(k);
    map<int,int> m;
    m[0] = 0;
    for(int i = 0; i < H[k]; ++i) {
      for(int j = 0; j < W[k]; ++j) {
	++m[lev[k][i][j]];
      }
    }
    v[k] = vector<pair<int,int> >(m.begin(), m.end());
    for(int i = 1; i < v[k].size(); ++i) v[k][i].second += v[k][i-1].second;
  }
  for(int i = 0; i < v[1].size(); ++i) swap(v[1][i].first, v[1][i].second);
  sort(v[1].begin(), v[1].end());
  int res = (1<<28);
  for(int i = 0; i < v[0].size(); ++i) {
    int tmp = lower_bound(v[1].begin(), v[1].end(), P(R-v[0][i].second, -(1<<28)))->second;
    res = min(res, v[0][i].first + tmp);
  }
  return res;
}

int main() {
  while(cin >> R && R) {
    for(int k = 0; k < 2; ++k) {
      cin >> W[k] >> H[k] >> X[k] >> Y[k];
      --X[k]; --Y[k];
      for(int i = 0; i < H[k]; ++i) {
	for(int j = 0; j < W[k]; ++j) {
	  cin >> L[k][i][j];
	}
      }
    }
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 12720
<?php
fscanf(STDIN, "%d%d", $n, $m);
$a = array_map("intval", explode(" ", trim(fgets(STDIN))));
$b = array_map("divCount", $a);
if(min($b) == max($b)){
    echo intdiv(intdiv($m, lcmAll($a)/2) + 1, 2);
}else{
    echo 0;
}

function divCount($n){
    for($i = 0; $i < 100; $i++){
        if($n >> $i & 1 == 1){
            return $i;
        }
    }
}

//最大公約数
function gcd($m, $n){
    if(!$n)return $m;
    return gcd($n, $m % $n);
}
//配列の最小公倍数
function lcmAll($array){
    $lcm = $array[0];
    for($i = 1; $i < count($array); $i++){
        $lcm = lcm($lcm, $array[$i]);
    }
    $lcm = min($lcm, 10**10);
    return $lcm;
}
//最小公倍数
function lcm($a, $b) {
    return $a / gcd($a, $b) * $b;
}


Measured memory_bytes: 16884
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int L, R, d;
  int cnt = 0;
  cin >> L;
  cin >> R;
  cin >> d;
  for(int i = L; i <= R; i++){
    if(i%d == 0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

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


int main()
{
	int N,M;
	cin>>N>>M;
	vector<int> wa(N,0);
	vector<bool> ac(N,false);
	rep(i,M)
	{
		int p;
		cin>>p;
		string s;
		cin>>s;
		p--;
		if(s=="AC")
		{
			ac[p]=true;
		}	
		else if(!ac[p])
		{
			wa[p]++;
		}
	}
	int ans_ac=0;
	int ans_wa=0;
	rep(i,N)
	{
		if(ac[i])
		{
			ans_ac++;
			ans_wa+=wa[i];
		}
	}
	cout<<ans_ac<<" "<<ans_wa<<endl;
	return 0;
}


Measured memory_bytes: 3772
#include <iostream>


using namespace std;


using ull = unsigned long long;


int main()
{
    ull N;
    ull cnt_mul2, cnt_mul4, cnt_odd;
    cnt_mul4 = cnt_mul2 = cnt_odd = 0;
    cin >> N;
    for (ull i = 0; i < N; i++) {
        ull tmp;
        cin >> tmp;
        if (tmp % 4 == 0) {
            cnt_mul4++;
        } else if (tmp % 2 == 0) {
            cnt_mul2++;
        } else {
            cnt_odd++;
        }
    }

    if (cnt_mul2 == 0) {
        if (cnt_mul4 + 1 >= cnt_odd)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    } else {
        // cnt_mul2 == 1
        if (cnt_mul4 + 1 >= cnt_odd + 1)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}


Measured memory_bytes: 384
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        s = "*"+s;
        char[] a = s.toCharArray();
        if(inValid(a)){
            System.out.println(-1);
            System.exit(0);
        }
        int n = a.length-1;
        ArrayList<Integer>[] map = new ArrayList[n+1];
        for(int i=0;i<=n;i++) map[i] = new ArrayList<>();
        int root = n-1;
        map[n-1].add(n);
        //int cnt = 2;
        for(int cnt=2;cnt<n;cnt++){
            if(a[cnt]=='0') map[root].add(n-cnt);
            else{
                map[n-cnt].add(root);
                root = n-cnt;
            }
        }
        PrintWriter out = new PrintWriter(System.out);
        for(int i=1;i<=n;i++){
            for(int w:map[i]){
                out.println(Integer.toString(i)+" "+Integer.toString(w));
            }
        }
        out.flush();
    }
    static boolean inValid(char[] a){
        int n = a.length-1;
        if(a[1]=='0'||a[n]=='1') return true;
        for(int i=1;i<=n/2;i++){
            if(a[i]!=a[n-i]) return true;
        }
        return false;
    }
}


Measured memory_bytes: 56816
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


class UnionFind():
    def __init__(self, n):
        self.n = n
        # parents[i]: 要素iの親要素の番号
        # 要素iが根の場合、parents[i] = -(そのグループの要素数)
        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

    # 要素xが属するグループの要素数を返す
    def size(self, x):
        return -self.parents[self.find(x)]

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

    # 要素xが属するグループに属する要素をリストで返す
    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()}

    # print()での表示用
    # all_group_members()をprintする
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    N, M = MAP()
    
    tree = UnionFind(N)
    for _ in range(M):
        a, b = MAP()
        tree.union(a - 1, b - 1)

    ans = 0
    for i in range(N):
        ans = max(ans, tree.size(i))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15540
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long int;
const int N_MAX = 100005;
ll S[N_MAX];
vector<int> A, B;
 
int main(){
    ll n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        A.push_back(a);
        B.push_back(a);
    }
    sort(A.begin(), A.end(), greater<int>());
    sort(B.begin(), B.end());
 
    ll lb = 0;
    ll ub = 200005;
    while(ub - lb > 1){
        ll mid = (lb + ub)/2;
        ll count = 0;
        int j = 0;
        for(int i = 0; i < n; i++){
            while(j < n && B[i] + A[j] >= mid)j++;
            count += j;
        }
        if (count >= m)lb = mid;
        else ub = mid;
    }
    ll ans = 0;
    ll count = 0;
    S[0] = 0;
    for(int i = 1; i <= n; i++){
        S[i] = S[i-1] + A[i-1];
    }
    int j = 0;
    for(int i = 0; i < n; i++){
        while(j < n && B[i] + A[j] > lb) j++;
        count += j;
        ans += (ll)B[i] * j + S[j];
    }
    ans += lb * (m - count);
    if(count > m) assert(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  ll a, b;
  cin >> a >> b;
  ll x = a + b;
  ll y = a - b;
  ll z = a * b;
  chmax(x, y);
  chmax(x, z);
  cout << x << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
a = []
for _ in range(M):
	n, m = map(int, input().split())
	a.append(n)
a.sort(reverse=True)
result = 0
for i in range(M-1):
	if a[i]<N: result += N-a[i]

print(result)



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

int main(){
  int w,h,x,y;
  cin>>w>>h>>x>>y;
  double ans=(double)w*h/2;
  int num=0;
  if(w==x*2&&h==y*2) num++;
  cout<<fixed<<setprecision(15)<<ans<<" "<<num<<endl;
}


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

typedef long long ll;

using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


int N;
int A[100010];
int B[100010];

int main(){

    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];
    
    ll tot_a = 0;
    ll tot_b = 0;
    for(int i = 0; i < N; i++){
        tot_a += A[i];
        tot_b += B[i];
    }
    if(tot_a < tot_b) {
        cout << -1 << endl;
        return 0;
    }


    // 余ってるやつから使う
    // 余ってるやつで、足りないやつを補完できるかという話をやっていく

    ll need = 0;
    ll c = 0;
    priority_queue<ll> pq;
    for(int i = 0; i < N; i++){
        if(A[i] < B[i]){
            need += B[i] - A[i];
            c++;
        }
        else if(A[i] > B[i]){
            pq.push(A[i] - B[i]);
        }
    }

    if(need == 0){
        cout << 0 << endl;
        return 0;
    }

    ll rem = 0;
    ll cnt = 0;
    while(pq.size()){
        rem += pq.top(); pq.pop(); cnt++;
        if(rem >= need){
            cout << c + cnt << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main() {
    fastio
    
	ll n,i,j,x,t,k,w;
	cin>>n;
	
	double a[n+1];
	
	for(j=1;j<=n;j++)
	cin>>a[j];
	
	vector<vector<double> > dp(n+1,vector<double> (n+1,0));
	double ans=0;
	dp[0][0]=1;
	
	for(i=1;i<=n;i++){
	    for(j=0;j<=n;j++){
	        if(j==0) dp[i][j]=dp[i-1][j]*(1-a[i]);
	        else if(i==j) dp[i][j]=dp[i-1][j-1]*a[i];
	        else if(j<i) dp[i][j]=dp[i-1][j-1]*a[i]+dp[i-1][j]*(1-a[i]);
	    }
	}
	
	for(j=(n+1)/2;j<=n;j++)
	ans+=dp[n][j];
	
	cout<<fixed<<setprecision(10)<<ans;
	
	return 0;
}



Measured memory_bytes: 73708
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val X = in.nextLong

  def calc(deposit: Long, y: Int): Int = {
    if (deposit >= X) y
    else calc((deposit * 1.01).toLong, y + 1)
  }

  println(calc(100, 0))
}

Measured memory_bytes: 55304
n = gets.to_i
ss = gets.chomp.chars
b = 0
w = 0
n.times do |i|
  w += 1 if ss[i] == '.'
end
res = w
n.times do |i|
  ss[i] == '.' ? w -= 1 : b += 1
  res = [res, (w + b)].min
end
puts res

Measured memory_bytes: 16764
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
const int INF = 1e9;
using namespace std;
typedef long long ll;


int main()
{
    int a[5];
    for(int i = 0; i < 5; i++){
        cin >> a[i];
    }
    int m = 10;
    int tmp = -1;
    for(int i = 0; i < 5; i++){
        if(a[i] % 10 != 0){
            if(m > a[i] % 10){
                m = a[i] % 10;
                tmp = i;
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < 5 ;i++){
        if(a[i] % 10 == 0){
            ans += a[i];
        }else if(i != tmp){
            ans += ((a[i] / 10) + 1) * 10;
        }else{
            ans += a[tmp];
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N, M, X;
    cin >> N >> M >> X;
    mat A(N, vec(M));
    vec C(N);
    Rep (i, N) {
        cin >> C[i];
        Rep (j, M) {
            cin >> A[i][j];
        }
    }

    ll ans = inf;
    Rep (mask, 1 << N) {
        vec power(M, 0);
        ll tmp = 0;
        Rep (i, N) {
            if (mask & (1 << i)) {
                tmp += C[i];
                Rep (j, M) {
                    power[j] += A[i][j];
                }
            }
        }

        bool flag = true;
        Rep (i, M) {
            if (power[i] < X) flag = false;
        }

        if (flag) chmin(ans, tmp);
    }

    if (ans == inf) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  ll n;
  cin >> n;
  ll ans = 1e12 + 1;
  for (ll a = 1; a * a <= n; a++) {
    if (n % a == 0 && 1 <= n / a) {
      ans = min(a + (n / a) - 2, ans);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256