akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {

    static class Question {
        int N;
        
        public int solve() {
            int i;
            for (i = 0; i < 7; i++) {
                if ( (1 << i) > N ) {
                    break;
                }
            }
            return 1 << (i-1);
        }
        
        public void main(FastScanner in, PrintWriter out) {
            N = in.nextInt();
            out.println( solve() );
        }
        
        public void p(Object o) { System.out.print(o); }
        public void pl(Object o) { System.out.println(o); }
        public void arp(int[] o) { pl( Arrays.toString(o) ); }
        public void arpp(int[][] o) { 
            for (int i = 0; i < o.length; i++) {
                for (int j = 0; j < o[0].length; j++) { p( o[i][j] + " " ); } pl("");
            }
        }
    }

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Question q = new Question();
        q.main(in, out);
        out.close();
        in.close();
    }
    
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream in) { br = new BufferedReader(new InputStreamReader(in)); }
        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
        public double nextDouble() { return Double.parseDouble(next()); }
        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try { st = new StringTokenizer(br.readLine()); } 
                catch (IOException e) { e.printStackTrace(); }
            }
            return st.nextToken();
        }
        public void close() throws IOException { br.close(); }
    }
}

Measured memory_bytes: 22740
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int ma = Integer.parseInt(sc.next());
        int mb = Integer.parseInt(sc.next());
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
            b[i] = Integer.parseInt(sc.next());
            c[i] = Integer.parseInt(sc.next());
        }
        int[][][] dp = new int[n + 1][401][401];
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= 400; j++) {
                for (int k = 0; k <= 400; k++) {
                    dp[i][j][k] = Integer.MAX_VALUE;
                }
            }
        }
        dp[0][0][0] = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= 400; j++) {
                for (int k = 0; k <= 400; k++) {
                    if (dp[i][j][k] == Integer.MAX_VALUE) {
                        continue;
                    }
                    dp[i + 1][j][k] = Math.min(dp[i][j][k], dp[i + 1][j][k]);
                    dp[i + 1][j + a[i]][k + b[i]] = Math.min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
                }
            }
        }
        int ans = Integer.MAX_VALUE;
        for (int i = 1; i <= 400; i++) {
            for (int j = 1; j <= 400; j++) {
                if (i * mb == j * ma) {
                    ans = Math.min(ans, dp[n][i][j]);
                }
            }
        }
        if (ans == Integer.MAX_VALUE) {
            ans = -1;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 54808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;

int main() {
    ll n, ans = 0;
    cin >> n;
    if(n & 1) {
        cout << 0 << endl;
        return 0;
    }
    for(ll i = 10; i <= n; i *= 5) {
        ans += n/i;
        if(i > n / 5) break;
    }
    cout << ans << endl;
    return 0;
}

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

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; }
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
using Graph = vector<vector<int>>;
queue<int> quex,quey;
const int MOD = 1000000007;




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

    int cnt=0;
    if(s.size()%2==1) cout << "No"<<endl;
    else{
    for(int i=0;i<s.size();i++){
        if( i%2==0 ){
            if(s.at(i)!='h') cnt++;
        }
        else{
            if( s.at(i)!='i' ) cnt++;
        }
    }

    if(cnt==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    }
}

Measured memory_bytes: 256
def partition(a, p, r):
    q  = p
    for i in range(p, r):
        if a[i][1] <= a[r][1]:
            a[q], a[i] = a[i], a[q]
            q += 1
    a[q], a[r] = a[r], a[q]
    return q 
  
def quicksort(a, p, r):
    if p < r:
        q = partition(a, p, r)
        quicksort(a, p, q-1)
        quicksort(a, q+1, r)
  
def check_stable(a):
    for i in range(1, len(a)):
        if a[i - 1][1] == a[i][1]:
            if a[i - 1][2] > a[i][2]:
                return 'Not stable'
    return 'Stable'
      
import sys
n = int(sys.stdin.readline())
a = []
for i in range(n):
    suit, num = sys.stdin.readline().split()
    a += [[suit, int(num), i]]
  
quicksort(a, 0, len(a) - 1)
print(check_stable(a))
  
for line in a:
    print(line[0],line[1])

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  ll N,X,T; cin >> N >> X >> T;

  ll ans = (N+X-1)/X;
  ans *= T;
  cout << ans << endl;
}


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

vector<ll> divisor(ll n) {
  vector<ll> f(n+1);
  for (ll i = 2; i <= n; i++) f[i] = 2*i;
  f[1] = 1;
  for (ll i = 2; i <= (n+1)/2; i++) {
    for (ll j = i * 2; j <= n; j += i) {
      f[j] += j;
    }
  }
  return f;
}

int main() {
  ll N;
  cin >> N;
  vector<ll> f = divisor(N);

  ll ans = 0;
  for (ll i = 1; i <= N; i++) {
    ans += f[i];
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
	string S;
	cin >> S;
	bool ok = false;
	int N = S.size();
	for (int i = 1; i < N; i++) {
		if (S.substr(i - 1, 2) == "AC") {
			ok = true;
		}
	}
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
A, B, H, M = map(int,input().split())
import math

x = H / 12 * 360 + M / 60 * 30
y = M / 60 * 360

ang = abs(y - x)
ans_2 = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(ang))
ans = math.sqrt(ans_2)
print(ans)


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

using namespace std;
typedef unsigned long long ll;
ll n,a;
ll solve(int m){
	long double x = pow(n,(double)(1/(double)m));
	ll b = x,res = 1,i;
	for(i=0;i<m;i++) res *= b;
	ll ret = b*m + a*(m-1);
	while(res<n){
		ret++;
		res /= b;
		res *= (b + 1);
	}
	return ret;
}

int main(){
	ll i,ans = 100000000000000;;
	cin >> n >> a;
	for(i=1;i<50;i++){
		ans = min(ans,solve(i));
	}
	cout << ans << endl;
}

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

int main(int argc, char *argv[]) {
  // read inputs
  long r, D, x0;
  scanf("%ld %ld %ld", &r, &D, &x0);

  // solve
  long x_cur = x0, x_next;
  for (int i = 0; i < 10; i++) {
    x_next = r * x_cur - D;
    printf("%ld\n", x_next);
    x_cur = x_next;
  }
  
  return 0;
}


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

int f[1010][1010],a,b,h,w;

int main(){
	cin>>h>>w>>a>>b;
	for(int i=1;i<=h;i++){
		if(i<=b){
			for(int j=1;j<=a;j++) f[i][j]=1; 
		}
		else for(int j=w;j>a;j--) f[i][j]=1;
	} 
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			printf("%d",f[i][j]);
		}
		printf("\n");
	}
	return 0 ;
} 

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
int p[100005];
int my_friend[100005];
int my_block[100005];
int u_find(int a){
	if(p[a]<0) return a;
	return p[a] = u_find(p[a]);
}
void merge(int a,int b){
	a = u_find(a);
	b = u_find(b);
	if(a==b) return;
	p[a]+=p[b];
	p[b] = a;
}
int main(){
	memset(p,-1,sizeof(p));
	int n,m,k;
	cin>>n>>m>>k;
	while(m--){
		int a,b;
		cin>>a>>b;
		my_friend[a]++;
		my_friend[b]++;
		merge(a,b);
	}
	while(k--){
		int a,b;
		cin>>a>>b;
		if(u_find(a)==u_find(b)){
			my_block[a]++;
			my_block[b]++;
		}
	}
	for(int i=1; i<=n; i++){
		cout<<(p[u_find(i)]*-1)-my_friend[i]-my_block[i]-1<<" ";
	}
}

Measured memory_bytes: 5884
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_B&lang=jp

#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int n, times=0;
  cin >> n;
  int A[n];
  for(int i = 0; i<n; i++){
    cin >> A[i];
  }
  //???????????????

  int minj;

  for(int i = 0; i<n; i++){
    minj = i;
    for(int j = i; j<n; j++){
      if(A[j] < A[minj]){
        minj = j;
      }
    }
    if(i != minj){
    swap(A[i],A[minj]);
    times++;
    }
  }

  for(int i = 0; i<n-1; i++){
    cout << A[i] << " ";
  }
  cout << A[n-1] << endl;
  cout << times << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <boost/dynamic_bitset.hpp>
using namespace std;
using u32 = uint32_t;

void dfs(const vector<vector<u32>>& fs, shared_ptr<boost::dynamic_bitset<>>& ac,
map<u32, shared_ptr<boost::dynamic_bitset<>>>& mm, const u32 n) {
	
	(*ac).set(n);
	for(auto f : fs[n]) {
		if(!(*ac)[f]) {
			dfs(fs, ac, mm, f);
		}
	}
	mm[n] = ac;
}

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

	vector<vector<u32>> fs(N, vector<u32>());
	vector<vector<u32>> bs(N, vector<u32>());
	
	for(u32 i=0; i<M; i++) {
		u32 A, B;
		cin >> A >> B;
		fs[A-1].push_back(B-1);
		fs[B-1].push_back(A-1);
	}
	
	for(u32 i=0; i<K; i++) {
		u32 C, D;
		cin >> C >> D;
		bs[C-1].push_back(D-1);
		bs[D-1].push_back(C-1);
	}
	
	map<u32, shared_ptr<boost::dynamic_bitset<>>> mm;
	
	for(u32 i=0; i<N; i++) {
		auto itr = mm.find(i);
		boost::dynamic_bitset<> aci;
		
		if(mm.find(i) == mm.end()) {
			shared_ptr<boost::dynamic_bitset<>> ac(new boost::dynamic_bitset<>(N));
			dfs(fs, ac, mm, i);
			aci = *ac;
		} else {
			aci = *((*itr).second);
		}
		
		for(auto f : fs[i]) aci[f] = 0;
		for(auto b : bs[i]) aci[b] = 0;
		aci[i] = 0;
		cout << aci.count() << " ";
		mm.erase(i);
	}
	
	return 0;
}

Measured memory_bytes: 51712
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int N;cin>>N;
    vector<int>A(N);
    int sum=0;
    REPS(i,N){
        int a;cin>>a;a-=i;
        A[i-1]=a;
        sum+=A[i-1];
    }
  	sort(A.begin(),A.end());
  	int d=A[N/2];
  	int e=A[N/2-1];
  	int ans=0,ans1=0;
    REP(i,N){
      	ans+=abs(A[i]-d);
      	ans1+=abs(A[i]-e);
    } 
    cout<<min(ans,ans1)<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int n,m,a[305][305],s[305][305],tot[305];
bool vis[305];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int p=1;p<=m;p++) scanf("%d",&a[i][p]);
	for(int i=1;i<=n;i++) s[a[i][1]][++tot[a[i][1]]]=i;
	int ans=0;
	for(int i=1;i<=m;i++) ans=max(ans,tot[i]),vis[i]=1;
	for(int i=1;i<m;i++){
		int mx=1;
		for(int p=1;p<=m;p++) if(tot[p]>tot[mx]) mx=p;
		vis[mx]=0;
		for(int p=1;p<=tot[mx];p++){
			int x=s[mx][p];
			for(int j=1;j<=m;j++) if(vis[a[x][j]]){
				s[a[x][j]][++tot[a[x][j]]]=x;
				break;
			}
		}
		tot[mx]=0;
		int w=0;
		for(int p=1;p<=m;p++) w=max(w,tot[p]);
		ans=min(ans,w);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int N,K;cin>>N>>K;
    if(N%K==0){
        cout<<0<<endl;
    }else{
        cout<<1<<endl;
    }
}

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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    intl i,j,n;
    cin>>n;
    j=n%1000;
    if(j==0){
        cout<<"0\n";
    }
    else
    cout<<1000-j<<"\n";    
}

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

#define int long long int
#define mod 1000000007


signed main()
{
    int i,j,n;
    cin>>n;
    if(n==0) cout<<1<<endl;
    else if(n<3) cout<<0<<endl;
    else
    {
        int dp[n+1]={0};
    dp[3]=1;
    dp[0]=1;
    for(i=4;i<=n;i++)
    {
        for(j=i-3;j>=0;j--)
        {
            dp[i]+=dp[j];
            dp[i]%=mod;
        }
    }
    cout<<dp[n];
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    string s; cin >> s;
    
    ll ans = 0;
    ll cnt = 0;
    zep(i, 0, s.size()){
    	if(s[i] == 'R'){
    		cnt++;
    		ans = max(ans, cnt);
    	}else{
    		cnt = 0;
    	}
    }
    print(max(ans, cnt))
    
    return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>

int main(){
  int no=0,n,k,i,j,l,len,defalt;//n=金額,k=嫌いな数字の個数,i=for文用,j=for文用,
  scanf("%d %d",&n,&k);
  int d[k];
  for(i=0;i<k;++i){
    scanf("%d",&d[i]);
  }
  for(i=n;i>-1;i++){
    defalt=i;
    len=0;
    //桁数計算
    while(i>0.9){
      i/=10;
      len++;
    }
    len-=1;
    i=defalt;
    for(l=0;l<=len;l++){
      for(j=0;j<k;j++){
        if(i%10==d[j]){
          no=1;
        }
      }
      i/=10;
    }
    i=defalt;
    if(no==0){
      printf("%d",i);
      return 0;
    } else {
      no=0;
    }
  }
  return 0;
}

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

using namespace std;
const int N=5e5+5;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n,a,sum=0;
    cin>>a>>n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        sum+=x;
    }
    if(sum>=a) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
n,a,b = map(int,input().split())
if (a-b) % 2 == 0:
  print(abs(a-b)//2)
else:
  can = []
  can.append(((a-1)+(b-1))//2+1)
  can.append(((n-a)+(n-b))//2+1)
  print(min(can))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 500'000;
const int LOGN = 19;

int n, m, k;

void solve(int test) {
  string s, t;
  cin >> s >> t;
  int ans = inf;
  for (int i = 0; i + t.size() <= s.size(); ++i) {
    int cnt = 0;
    for (int j = 0; j < t.size(); ++j) {
      cnt += s[i + j] != t[j];
    }
    ans = min(ans, cnt);
  }
  cout << ans << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 3660
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np
#import bisect

from itertools import product

def main():
	n,m=MI()
	li=[[] for _ in range(8)]

	for _ in range(n):
		a,b,c=MI()
		for i,e in enumerate(product((1,-1),repeat=3)):
			li[i].append(a*e[0]+b*e[1]+c*e[2])

	ans=0

	for l in li:
		l.sort(reverse=True)
		ans=max(ans,sum(l[:m]))
	print(ans)



if __name__ == "__main__":
	main()


Measured memory_bytes: 9388
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        int[,,] Kosha = new int[4, 3, 10];

        int count = int.Parse(Console.ReadLine());

        for (int i=0; i < count; i++)
        {
            string[] str = Console.ReadLine().Split(' ');

            int number = int.Parse(str[0]);
            int floor = int.Parse(str[1]);
            int room = int.Parse(str[2]);
            int ppl = int.Parse(str[3]);

            Kosha[number-1, floor-1, room-1] += ppl;
        }

        for (int i = 0;i < 3;i++)
        {
            for (int j = 0; j < 3;j++)
            {
                for (int k = 0;k<10;k++)
                {
                    Console.Write(" {0}",Kosha[i, j, k]);
                }
                Console.WriteLine();
            }
            Console.WriteLine("####################");
        }
        for (int i = 3;i < 4;i++)
        {
            for (int j = 0; j < 3; j++)
            {
                for (int k = 0; k < 10; k++)
                {
                    Console.Write(" {0}", Kosha[i, j, k]);
                }
                Console.WriteLine();
            }
        }
    }
}

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

#define pb push_back
#define mp make_pair
#define size(n) ( int( n.size() ) )
#define sqr(n) ( (n) * (n) )
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;

ll ans = 0;
const int N = 55;
ll a[N];
int n;

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n;
    for ( int i = 1; i <= n; i++ ){
        cin >> a[i];
    }
    int x;
    while(1){
        x = 0;
        for ( int i = 1; i <= n; i++ ){
            if ( a[i] > a[x] ){
                x = i;
            }
        }
        if ( a[x] <= n - 1 ){
            break;
        }
        ll cnt = ( a[x] - n + 1 ) / n;
        if ( ( a[x] - n + 1 ) % n != 0 ){
            cnt++;
        }
        ans += cnt;
        for ( int i = 1; i <= n; i++ ){
            if ( i == x ){
                a[i] -= cnt * n;
            }
            else{
                a[i] += cnt;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct edge
{
	int v;
	edge *next;
}*h[2333],pool[5555];
int top;
inline void addedge(int u,int v)
{
	edge *tmp=&pool[top++];tmp->v=v;tmp->next=h[u];h[u]=tmp;
	edge *pmt=&pool[top++];pmt->v=u;pmt->next=h[v];h[v]=pmt;
}
int n,k;
int vis[2333],dis[2333];
queue<int> q;
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n>>k;
	int x,y;
	for(int i=1;i<n;i++)cin>>x>>y,addedge(x,y);
	int ans=0;
	if(k%2)
	{
		for(int i=1;i<=n;i++)
		{
			for(edge *tmq=h[i];tmq;tmq=tmq->next)
			{
				memset(vis,0,sizeof(vis));
				memset(dis,0,sizeof(dis));
				vis[i]=vis[tmq->v]=1;
				dis[i]=dis[tmq->v]=0;
				q.push(i);
				q.push(tmq->v);
				int cnt=0;
				while(!q.empty())
				{
					int u=q.front();q.pop();
					cnt++;
					if(dis[u]>=k/2)continue;
					for(edge *tmp=h[u];tmp;tmp=tmp->next)
					{
						if(!vis[tmp->v])
						{
							dis[tmp->v]=dis[u]+1;
							vis[tmp->v]=1;
							q.push(tmp->v);
						}
					}
				}
				if(cnt>ans)ans=cnt;
			}
		}
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			memset(vis,0,sizeof(vis));
			memset(dis,0,sizeof(dis));
			vis[i]=1;
			dis[i]=0;
			q.push(i);
			int cnt=0;
			while(!q.empty())
			{
				int u=q.front();q.pop();
				cnt++;
				if(dis[u]>=k/2)continue;
				for(edge *tmp=h[u];tmp;tmp=tmp->next)
				{
					if(!vis[tmp->v])
					{
						dis[tmp->v]=dis[u]+1;
						vis[tmp->v]=1;
						q.push(tmp->v);
					}
				}
			}
			if(cnt>ans)ans=cnt;
		}
	}
	cout<<n-ans<<endl;
	return 0;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	inline int tc()
	{
		int c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		return c;
	}
}
using ae86::ty;
using ae86::tc;

const int _ = 203 , inf = 0x3f3f3f3f;

int n,e[_][_],col[_]={0};

int able=1;
void dfs(int x,int c)
{
	col[x]=c;
	for(int i=1;i<=n;i++)
	{
		if(!e[x][i])continue;
		if(!col[i])dfs(i,3-c);
		else if(col[i]!=3-c){able=0;return;}
	}
}

int dis[_][_];

int main()
{
	n=ty();
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)e[i][j]=tc()-48;

	for(int i=1;i<=n;i++)if(!col[i])dfs(i,1);
	if(!able){puts("-1");return 0;}

	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(e[i][j])dis[i][j]=1;else dis[i][j]=inf;
	for(int i=1;i<=n;i++)dis[i][i]=0;

	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(dis[i][j]<inf)ans=max(ans,dis[i][j]);
	printf("%d\n",ans+1);

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
int n;
ll a[100005],b[100005];
int main(){
	cin >> n;
	rep(i,n) cin >> a[i];
	ll lb=-1LL,ub=3e9;
	while(1){
		ll mid = (lb+ub)/2;
		b[0] = mid;
		rep(j,n-1){
			b[j+1] = a[j]*2LL-b[j];
		}
		if(b[0]+b[n-1] < a[n-1]*2LL) lb = mid;
		else if(b[0]+b[n-1] > a[n-1]*2LL) ub = mid;
		else{
			rep(i,n) cout << b[i] << (i==n-1?'\n':' ');
			return 0;
		}
	}
}

Measured memory_bytes: 2816
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = Array.init n @@ fun _ -> read_int ()

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)

let () =
  let n = read_int () in
  let xs = read_ints n in

  let m = (range 1 n) |> List.fold_left (fun i j ->
    if abs xs.(i) < abs xs.(j) then j else i) 0 in
  let res = Array.init (2*n) (fun _ -> (-1, -1)) in
  let len = ref 0 in

  let (l, u, s, cmp) = if xs.(m) >= 0 then (0, n-1, 1, (>)) else (n-1, 0, -1, (<)) in
  let rec func i m = 
    if cmp (i+s) u then () else (
      for_iter_ 0 2 (fun _ ->
        if cmp xs.(i) xs.(i+s) then (
          res.(!len) <- (m, i+s); len := !len + 1;
          xs.(i+s) <- xs.(i+s) + xs.(m)
      ));
      func (i+s) (if cmp xs.(i+s) xs.(m) then i+s else m)) in
  func l m;
  printf "%d\n" (!len);
  for_iter_ 0 (!len) (fun i -> let (x, y) = res.(i) in printf "%d %d\n" (x+1) (y+1))


Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
	public static void main(String[] args)
	{
		Scanner sc =new Scanner(System.in);
		int N=sc.nextInt();	//文字列の長さ
		String S=sc.next();	//文字列
		int x=0,x_max=0;

		for(int i=0;i<N;i++){
			if(S.charAt(i)=='I') x++;
			else if(S.charAt(i)=='D') x--;
			if(x>x_max) x_max=x;
		}

		System.out.println(x_max);
	}
} 

Measured memory_bytes: 23892
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	arry := make([]float64, 2)
	for i := 0; i < 2; i++ {
		fmt.Scan(&arry[i])
	}
	h := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}

	t := make([]float64, n)
	for i := 0; i < n; i++ {
		t[i] = math.Abs(arry[1] - arry[0] + h[i]*0.006)
	}
	var min float64 = 528
	var index = 0
	for i := 0; i < n; i++ {
		if min >= t[i] {
			min = t[i]
			index = i + 1
		}
	}
	fmt.Println(index)
}


Measured memory_bytes: 512
#include <iostream>

int main() {
    //for( int i = 1 ; i <= 10000 ; i++ ) {
    int i = 1 ;
    int x ;
    while( true ) {
        std::cin >> x ;
        
        if( x == 0 ) {
            break ;
        }
        
        std::cout << "Case " << i << ": " << x << std::endl ;
        i++ ;
    }
}


Measured memory_bytes: 3004
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,y;
	cin>>n>>y;
	if(n*10000<y)
	{
		cout<<"-1 -1 -1\n";
		return 0;
	}
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n-i;j++)
		{
			int k=n-i-j;
			if(10000*i+5000*j+1000*k==y)
			{
				cout<<i<<' '<<j<<' '<<k<<"\n";
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1\n";
	return 0;
}

Measured memory_bytes: 256
#ABC093B
A,B,K = map(int, input().split())
ans = []
if abs(A-B) > K:
    for i in range(K):
        ans.append(A+i)
        ans.append(B-i)
    ans = set(ans)
    ans = sorted(ans)
    for j in ans: 
         print(j)
else:
    for l in range(abs(A-B)+1):
        print(min(A,B) + l)

Measured memory_bytes: 3060
# include <string.h>
# include <stdlib.h>
# include <stdio.h>
int max (int a,int b){
	if(a>=b) return a;
	else return b;
}
int main(){
	char *s1,*s2;
	s1=(char*)malloc(3000*sizeof(char));
	s2=(char*)malloc(3000*sizeof(char));
	scanf ("%s %s",s1,s2);
	int **arr,i,j;
	int l_s1=strlen(s1);
	int l_s2=strlen(s2);
	arr=(int**)malloc((l_s1+1)*sizeof(int*));
	for(i=0;i<=l_s1;i++) arr[i]=(int*)malloc((l_s2+1)*sizeof(int));
	for(i=0;i<l_s2+1;i++) arr[0][i]=0;
	for(i=0;i<l_s1+1;i++) arr[i][0]=0;
	for(i=1;i<l_s1+1;i++){
		for(j=1;j<l_s2+1;j++){
			if(s1[i-1]==s2[j-1]) arr[i][j]=arr[i-1][j-1]+1;
			else arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
		}
	}
	int len=arr[l_s1][l_s2];
	char *ans;
	ans=(char*)malloc(len*sizeof(char));
	int ind=len-1;
	int r=l_s1,c=l_s2;
	while (r>=1 && c>=1){
		if(s1[r-1]==s2[c-1]) {
			ans[ind]=s1[r-1];
			r-=1;
			c-=1;
			ind-=1;
		}
		else if (arr[r][c]==arr[r-1][c]){
			r-=1;
			continue;
		}
		else{
			c-=1;
			continue;
		}
	}
	for(i=0;i<arr[l_s1][l_s2];i++)printf ("%c",ans[i]);
	return 0;
}

Measured memory_bytes: 36860
#include <bits/stdc++.h>
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
using namespace std;
const int MOD = 1000000007; 
typedef long long ll;
typedef string str;
 
int main(){
  str s; cin >> s;
  regex re("(erase|eraser|dream|dreamer)*");
  cout << (regex_match(s,re) ? "YES" : "NO");
  return 0;
}

Measured memory_bytes: 39808
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
const int MOD = 1e9 + 7;
struct UnionFind{
    vector<int> par;//親(根)
    vector<int> rank;//木の深さ

    UnionFind(int n){//初期化関数
        par.resize(n);
        rank.resize(n);
        for(int i = 0; i < n; i++){
            par[i] = i;//初めはノード一個の木なので根は自身
            rank[i] = 1;
        }
    }

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

    bool same(int x, int y){//同じ木かどうか判定
        return root(x) == root(y);//同じ木ならtrue
    }

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;//もし同じ木に属していたら何もしない
        if(rank[x] < rank[y]) swap(x, y);//数が大きい方に小さい方を結合させる
        par[y] = x;
        rank[x] += rank[y];//深さが同じ時だけ結合後深さが増える
    }

    int size(int x) {//深さを返す関数
        return rank[root(x)];
    }
};
int main(){
    int N, M;
    cin >> N >> M;
    UnionFind U(N);
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        U.unite(a, b);
    }
    set<int> s;
    for(int i = 0; i < N; i++){
        int t = U.root(i);
        s.insert(t);
    }
    cout << s.size() - 1 << endl;
}

Measured memory_bytes: 7972
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<string>
#include<functional>
using namespace std;
typedef	long long int ll;

int main(){
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int s;
    if((n-1)%(k-1) == 0) s = (n-1)/(k-1);
    else s = (n-1)/(k-1) + 1;
    cout << s << endl;
    return 0;
}

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

int main(){
    vector<int> a(5);
    rep(i,5) cin >> a[i];
    rep(i,5){
        if(a[i]==0) cout << i+1 << endl;
    }
}

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

int main(){
    string h;
    cin >> h;
    if(h == "hi" || h == "hihi" || h == "hihihi" || h == "hihihihi" || h == "hihihihihi"){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var N int
	fmt.Scan(&N)
	// sc.Split(bufio.ScanWords)
	ans := N % 1000
	if ans != 0 {
		fmt.Print(1000 - ans)
	} else {
		fmt.Print(ans)
	}

}
func nextLine() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int64 {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return int64(i)
}
func MySort(a []int) {
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

}
func SortedBinaryAppend(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinaryDelete(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinarySearch(sortedArr []int, targetValue int) int {
	post := len(sortedArr) - 1
	pre := 0
	for {
		div := (post + pre) / 2
		tim := sortedArr[div]
		if tim == targetValue {
			return pre + div
		} else if tim > targetValue {
			post = tim
		} else {
			pre = tim
		}
		if pre == post {
			return -1
		}
	}
}
func Abs(i int) int {
	if i < 0 {
		return -1 * i
	}
	return i
}
func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func CalcNum(tate int, yoko int, A int, B int, dp *map[[2]int]int) int {
	if (*dp)[[2]int{tate, yoko}] != 0 {
		return (*dp)[[2]int{tate, yoko}]
	}
	return yoko*CalcNum(tate-1, yoko, A, B, dp) + tate*CalcNum(tate, yoko-1, A, B, dp)
}
func arrSum(arr []int) int {
	sum := 0
	for _, a := range arr {
		sum += a
	}
	return sum
}
func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}
func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 2e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, m, k;
ll fac[maxn], inv[maxn];
ll pwr(ll a, ll pw)
{
    ll ret = 1;
    while(pw > 0)
    {
        if(pw & 1)
            ret = ret * a % mod;
        a = a * a % mod;
        pw >>= 1;
    }
    return ret;
}
ll modinv(ll a)
{
    return pwr(a, mod - 2);
}
ll choose(int N, int K)
{
    return fac[N] * inv[K] % mod * inv[N - K] % mod;
}
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    fac[0] = inv[0] = 1;
    for(ll i = 1; i < maxn; i++)
    {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = modinv(fac[i]);
    }
    cin >> n >> m >> k;
    ll times = choose(n * m - 2, k - 2);
    ll ans = 0;
    for(int i = 1; i <= n; i++)
    {
        ll a = 1ll * i * (i - 1) / 2 % mod;
        ans = (ans + a * times % mod * m % mod * m % mod) % mod;
    }
    for(int j = 1 ; j <= m; j++)
    {
        ll a = 1ll * j * (j - 1) / 2 % mod;
        ans = (ans + a * times % mod * n % mod * n % mod) % mod;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define EPB emplace_back
#define MP make_pair
#define d(x) cerr << #x << ":" << x << endl;
#define da(x) cerr << #x << endl; for (auto a : x) cerr << a << " "; cerr << endl;
const int MOD = 1000000007;

int main() {
	fastio();
	int n;
	cin >> n;
	int a[n];
	cin >> a[0];
	ll Xor = a[0];
	for(int i=1;i<n;i++) {
		cin >> a[i];
		Xor ^= a[i];
	}
	for(int i=0;i<n;i++)
		cout << (Xor ^ a[i]) << " ";
	cout << "\n";
	return 0;
}



Measured memory_bytes: 4336
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
int used[100005];
ll power(ll x,int v){
	if(v==0)return 1LL;
	ll lp=power(x,v>>1);
	if(v&1)return ((lp*lp)%INF)*x%INF;
	else return (lp*lp)%INF;
}
ll inv(int x){
	return power(ll(x),INF-2);
}
int main(){
	int n,x,d;
	scanf("%d",&n);n++;
	long long A1=ll(n),A2=1LL;
	rep1(k,n){
		scanf("%d",&x);
		if(!used[x])used[x]=k;
		else d=n-(k-used[x])-1;
	}
	rep1(k,n){
		printf("%I64d\n",(A1-A2+INF)%INF);
		A1=(((A1*ll(n-k))%INF)*inv(k+1))%INF;
		A2=(((A2*ll(d-k+1))%INF)*inv(k))%INF; 
	}
	return 0;
}

Measured memory_bytes: 7040
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <functional>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define P(r) do{for(auto i:r){cout<<i<<' ';}cout<<'\n';}while(0)
int main()
{
    int N, K; cin >> N >> K;
    int ans = K;
    for (int i = 1; i < N; i++) {
        ans *= K - 1;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

template<typename T> void print(T t) { cout << t << endl; }
ll MOD = 1000000007;

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
	int N, M, A, B;
    cin >> N >> M;
    UnionFind uf(N);
    for (int m = 0; m < M; m++) {
        cin >> A >> B;
        A--; B--;
        uf.merge(A, B);
    }

    int ans = 0;
    for (int n = 0; n < N; n++) {
        ans = max(ans, (int)uf.size(n));
    }
    cout << ans << endl;
}

Measured memory_bytes: 6356
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力(スペース改行関係なし)
		int x = sc.nextInt();

		if(x >= 30){
			// 出力
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		
	}
}

Measured memory_bytes: 35700
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
 
int main(){
  string S;
  cin >> S;
  int n = S.size();

  string old,nxt;
  old = S.at(0);
  int ans = 1;

  for(int i = 1; i<n;i++){
    nxt += S.at(i);
    if (old != nxt){
      ans++;
      old = nxt;
      nxt = "";
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <string>

using namespace std;

const int INF = 100100100;

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

int main()
{
    string s[50];

    int H, W;

    cin >> H >> W;

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

    for (int i = 0; i < H;i++)
    {
        for (int j = 0; j < W;j++)
        {
            if(s[i][j] == '#')
            {
                bool f = false;

                for (int k = 0; k < 4;k++)
                {
                    int nx = j + dx[k];
                    int ny = i + dy[k];
                    if (0 <= nx && nx < W && 0 <= ny && ny < H)
                    {
                        //cout << "a" << endl;
                        if (s[ny][nx] == '#')
                        {
                            f = true;
                            break;
                        }
                    }
                    
                }
                if (f == false)
                {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
N,M = map(int, input().split())
ans = 1
bro = list([])

for i in range(M):
    bro.append(int(input()))

bro.append(-1)

f = [0,0,1]

def Step (i):
    if i == bro[0]:
        bro.pop(0)
        f[0],f[1],f[2] = f[1],f[2],0
    else:
        f[0],f[1],f[2] = f[1],f[2],(f[1]+f[2])%(10**9+7)

for i in range(N):
    Step(i+1)

ans = f[2]%(10**9+7)

print(ans)


Measured memory_bytes: 7080
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second
#define pb push_back

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  string S;
  cin>>S;
  reverse(ALL(S));
  map<int,int> mp;
  mp[0]=1;

  int now=0;int digit=1;
  each(s,S){
    now=(now +(s-'0') * digit)%2019;
    digit*=10;
    digit%=2019;
    mp[now]++;
  }
  int ans=0;
  each(m,mp){
    ans+=m.second*(m.second-1)/2;
  }
  print(ans);


}


Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
int d[333][333][333],n,m;
#define mod 1000000007
int add(int x,int y){
	return (x+=y)<mod?x:x-mod;
}
int mul(int x,int y){
	return (int)((long long int)x*y%mod);
}
void addto(int&x,int y){
	x = add(x,y);
}
int main(){
	scanf("%d%d",&n,&m);
	d[0][1][0] = 1;
	for(int i=0; i<m; i++)
	for(int j=1; j<=i+1 && j<=n; j++)
	for(int k=0; j+k<=n; k++){
		if(d[i][j][k]==0)continue;
		addto(d[i+1][j+k][0],mul(d[i][j][k],j));
		addto(d[i+1][j][k],mul(d[i][j][k],k));
		if(j+k<n)
		addto(d[i+1][j][k+1],mul(d[i][j][k],n-j-k));
	}
	printf("%d\n",d[m][n][0]);
	return 0;
}


Measured memory_bytes: 128384
from fractions import gcd

# segfunc: 問題に応じて設定
def segfunc(x, y):
    return gcd(x, y)


# 配列aで初期化
def init(a):
    for i in range(n):
        seg[i+num-1] = a[i]    
    for i in range(num-2, -1, -1) :
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2]) 


# a[k]の値をxに更新
def update(k, x):
    k += num - 1
    seg[k] = x
    while k:
        k = (k - 1) // 2
        seg[k] = segfunc(seg[k*2+1], seg[k*2+2])


# [p, q)についてsegfuncを適用したものを返す
def query(p, q):
    if q <= p:
        return ide_ele
    
    p += num - 1
    q += num - 2
    res = ide_ele

    while q - p > 1:
        if p & 1 == 0:
            res = segfunc(res, seg[p])
        if q & 1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p // 2
        q = (q - 1) // 2
    
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(res, segfunc(seg[p], seg[q]))
    
    return res


n = int(input())
a = list(map(int, input().split()))

ide_ele = 0
num = 2 ** (len(bin(n - 1)) - 2)
seg = [ide_ele] * 2 * num
init(a)

res = 0
for i in range(n):
    res = max(res, gcd(query(0, i), query(i+1, n)))

print(res)


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

int main (){
	string str;
	cin>>str;
	if(str.find("A")==0){
		if(str.find("C")&&str.find_first_of("C")>=2&&str.find_first_of("C")<=str.length()-2){
			
			int cou=0;
			for(int i=0;i<str.length();i++){
				
				if(str[i]>='a'&&str[i]<='z'){
				}else{
				cou++;
				}

			}
			if(cou==2){
			cout<<"AC";
			return 0;
			}
		}
	}
	cout<<"WA"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
using namespace std;
int n,k;
const int mod = 1e9+7;
int dp[102][100005],pr[100005],a[102];
main() {
    ios::sync_with_stdio(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    dp[0][0] = 1;
    for (int i = 0; i <= k; i++)
        pr[i] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0;j <= k; j++) {
            dp[i][j] = pr[j] - (j > a[i] ? pr[j-a[i]-1] : 0);
            if (dp[i][j] < 0) dp[i][j] += mod;
        }
        pr[0] = dp[i][0];
        for (int j = 1; j <= k; j++) {
            pr[j] = pr[j-1] + dp[i][j];
            if (pr[j] >= mod) pr[j]-=mod;
        }
    }
        cout << dp[n][k];
}


Measured memory_bytes: 43076