akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
using  namespace std;
vector<int> adj[200010];
int r=0,b=0,col[200010],vis[200010],ans[200010],check[200010];
void dfs(int current ,int colour){
    col[current]=colour;
    vis[current]=1;
    for(auto next:adj[current]){
        if(!vis[next])
            dfs(next,!colour);
    }
}
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs(1,1);
    for(int i=1;i<=n;i++){
        if(col[i])
            r++;
    }
    // r = 1,b = 0
    b=n-r;
    if(b<r){
        for(int i=1;i<=n;i++)
            col[i]^=1;
        swap(r,b);
    }
    // %3 more than smaller node
    if(n/3>=r){
        int cur=3;
        for(int i=1;i<=n;i++){
            if(col[i]){
                ans[i]=cur;
                check[cur]=1;
                cur+=3;
            }
        }
        //remain
        cur=1;
        for(int i=1;i<=n;i++){
            if(!ans[i]){
                while(check[cur]&&cur<=n)cur++;
                ans[i]=cur;
                cur++;
            }
        }
    }else{
        // fill %3==1 then %3==0
        //cout<<"Helo";
        int cur=1;
        for(int i=1;i<=n&&cur<=n;i++){
            if(col[i]){
                ans[i]=cur;
                check[cur]=1;
                cur+=3;
            }
        }
        cur=3;
        for(int i=1;i<=n&&cur<=n;i++){
            if(col[i]&&!ans[i]){
                ans[i]=cur;
                check[cur]=1;
                cur+=3;
                //cout<<cur<<'\n';
            }
        }
        //remain
        cur=1;
        for(int i=1;i<=n;i++){
            if(!ans[i]){
                while(check[cur]&&cur<=n)cur++;
                ans[i]=cur;
                cur++;

            }
        }
    }

    for(int i=1;i<=n;i++)
        cout<<ans[i]<<' ';


}


Measured memory_bytes: 18176
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.IllegalArgumentException
import java.lang.StringBuilder
import java.lang.reflect.Modifier
import java.util.*

fun gcd(a:Long, b:Long):Long {
    if (b == 0L) return a
    return gcd(b, a % b)
}

fun lcm(a:Long, b:Long):Long {
    return a / gcd(a, b) * b
}

fun PrintWriter.solve(sc: FastScanner) {
    val a = sc.nextLong()
    val b = sc.nextLong()
    println(lcm(a, b))
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 34560
N = int(input())
search_max = int(N**0.5)
 
min_number = 10**12
for x in range(1, search_max + 1):
    if N % x == 0:
        y = N // x
        if x + y < min_number:
         
            min_number = x + y
print(min_number-2)

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

int main() {
	int n,q,c=0;
	string s;
	cin >> n >> q >> s;
	vector<int> d(n,0);
	for(int i=0;i<n;i++)
	{
		if(s.at(i)=='A'&&i+1<n)
		{
          d.at(i)=c;
			if(s.at(i+1)=='C')
			{
				c++;
				i++;
				d.at(i)=c;
			}
		}
		else
		{
			d.at(i)=c;
		}
	}
	for(int i=0;i<q;i++)
	{
		int l,r;
		cin >> l >> r;
		cout << d.at(r-1)-d.at(l-1) << endl;
	}
	return 0;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,f,s;
  cin >> n;
  for (s=0;s<=n/7;s++) if ((n-s*7)%4==0) break;
  if (s==n/7+1) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>

using namespace std;

int main(){
	double v;

	while(cin >> v){
		double m = (v*v)/(4*4.9);
		for(int i = 0; i < 10000; i++){
			if(m <= i*5-5){
				cout << i << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main(){
  string s;cin>>s;
  string ans;
  bool isok=false;
  int x=s[0]-'0';
  ans+=s[0];
  repeat(i,2){
    if(i&1){
      ans+="+";
      ans+=s[1];
      x+=s[1]-'0';
    }else{
      ans+="-";
      ans+=s[1];
      x-=s[1]-'0';
    }
    repeat(j,2){
      if(j&1){
        ans+="+";
        ans+=s[2];
        x+=s[2]-'0';
      }else{
        ans+="-";
        ans+=s[2];
        x-=s[2]-'0';
      }
      repeat(k,2){
        if(k&1){
          ans+="+";
          ans+=s[3];
          x+=s[3]-'0';
        }else{
          ans+="-";
          ans+=s[3];
          x-=s[3]-'0';
        }
        if(x==7){
          ans+="=7";
          isok=true;
          break;
        }
        if(k&1){
          x-=s[3]-'0';
        }else{
          x+=s[3]-'0';
        }
        ans=ans.substr(0,5);
      }
      if(isok)break;
      if(j&1){
        x-=s[2]-'0';
      }else{
        x+=s[2]-'0';
      }
      ans=ans.substr(0,3);
    }
    if(isok)break;
    if(i&1){
      x-=s[1]-'0';
    }else{
      x+=s[1]-'0';
    }
    ans=s[0];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a[] = { 0,1,3,1,2,1,2,1,1,2,1,2,1 };
	int x, y;
	
	scanf("%d", &x);
	scanf("%d", &y);

	if (a[x] == a[y]) {
		printf("Yes\n");
	}
	else { printf("No\n"); }

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, p;
    cin >> s >> p;
    s = s + s.substr(0, p.size());
    if (s.find(p) != string::npos)
        cout << "Yes\n";
    else
        cout << "No\n";
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T, class Op = multiplies<T>>
T power(T a, long long n, Op op = Op(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

template <unsigned M> struct modular {
  static constexpr unsigned mod = M;
  using m = modular;
  unsigned v;
  modular(long long x = 0) : v((x %= mod) < 0 ? x + mod : x) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m b) { if ((v += b.v) >= mod) v -= mod; return *this; }
  m& operator-=(m b) { if (v < b.v) v += mod; v -= b.v; return *this; }
  m& operator*=(m b) { v = (uint64_t)v * b.v % mod; return *this; }
  m& operator/=(m b) { return *this *= power(b, mod - 2); }
  friend m operator+(m a, m b) { return a += b; }
  friend m operator-(m a, m b) { return a -= b; }
  friend m operator*(m a, m b) { return a *= b; }
  friend m operator/(m a, m b) { return a /= b; }
  friend bool operator==(m a, m b) { return a.v == b.v; }
};

using mint = modular<(int)1e9 + 7>;

vector<int> sieve(int n) {
  vector<bool> b(n / 3 + 1, true);
  vector<int> res{2, 3};
  for (int p = 5, d = 4; p * p <= n; p += d = 6 - d) if (b[p / 3])
    for (int i = p * p, di = p % 3 * 2 * p; i <= n; i += di = 6 * p - di)
      b[i / 3] = false;
  for (int p = 5, d = 4; p <= n; p += d = 6 - d) if(b[p / 3]) res.push_back(p);
  while (not res.empty() and res.back() > n) res.pop_back();
  return res;
}

template<class T> void ifmult(vector<T>& a, const vector<int>& ps) {
  int n = a.size();
  for (int p : ps) {
    for (int i = 1; i * p < n; ++i) {
      a[i] -= a[i * p];
    }
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<mint> a(k + 1);
  for (int d = 1; d <= k; ++d) {
    a[d] = power<mint>(k / d, n);
  }
  ifmult(a, sieve(k));
  DEBUG(a);
  mint res;
  for (int d = 1; d <= k; ++d) {
    res += d * a[d];
  }
  cout << res.v << '\n';
}


Measured memory_bytes: 3864
#include <iostream>
using namespace std;
 
#define MAX_W 100
#define MAX_H 100
char farm[MAX_W][MAX_H];
int W, H;
const int direction[4][2] = {
	{ -1, 0 },
	{ 1, 0 },
	{ 0, -1 },
	{ 0, 1 },
};
 
void dfs(const int& x, const int& y, const char tree)
{
	farm[x][y] = 'x';
	for (int i = 0; i < 4; ++i)
	{
		int nx = x + direction[i][0];
		int ny = y + direction[i][1];
		if (nx >= 0 && nx < W && ny >= 0 && ny < H && farm[nx][ny] == tree)
		{
			dfs(nx, ny, tree);
		}
	}
}

int main()
{
 
	while (cin >> H >> W&&W > 0)
	{
		int res = 0;
		int x, y;
		for (y = 0; y < H; ++y)
		{
			for (x = 0; x < W; ++x)
			{
				cin >> farm[x][y];
			}
		}
 
		for (y = 0; y < H; ++y)
		{
			for (x = 0; x < W; ++x)
			{
				if (farm[x][y] != 'x')
				{
					dfs(x, y, farm[x][y]);
					++res;
				}
			}
		}
		cout << res << endl;
	}
 
	return 0;
}


Measured memory_bytes: 3856
a, b = map(int, input().split())

xor_sum = 0

for i in range(a, a+5): # 123, 124,
  if i % 4 == 0:
    break
  else:
    xor_sum = xor_sum ^ i

for i in range((b-b%4),b+1):#456
  xor_sum = xor_sum ^ i
  
  
print(xor_sum)




Measured memory_bytes: 38384
#abc170
x, n = map(int, input().split())
ln = []
if n == 0:
  pass
else:
  ln = list(map(int, input().split()))
i = 0

while True:
    
    
    if (x-i in ln) == False:
        print(x-i)
        break
    elif (x+i in ln) == False:
        print(x+i)
        break  
    else:
        i +=1


Measured memory_bytes: 9136
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
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 dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    ll n,m;
    cin>>n>>m;
    UnionFind tree(n+1);
    vll p(n+1);
    rep1(i,n){
        cin>>p[i];
    }

    rep1(i,m){
        ll x,y;
        cin>>x>>y;
        tree.unite(x,y);
    }

    ll ans=0;
    rep1(i,n){
        if(tree.same(p[i],i))ans++; 
    }

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

Measured memory_bytes: 4516
#include<bits/stdc++.h>
using namespace std;
main()
{
	int t,p;
	vector<int>v;
	scanf("%d",&t);
	for(int i = 0;i < 2*t;i++)
	{
		scanf("%d",&p);
		v.push_back(p);
	}
	sort(v.begin(),v.end());
	int pp=0;
	for(int i = 0;i < v.size();i+=2)
	pp+=min(v[i],v[i+1]);
	printf("%d",pp);
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort()

def check(mid):
    size = a[mid]
    for i in range(n):
        if i == mid:
            continue
        if size*2 < a[i]:
            return False
        size += a[i]
    return True
    
if check(0):
    print(n)
else:
    ok, ng = n-1, 0
    while ok-ng > 1:
        mid = (ok + ng) // 2
        if check(mid):
            ok = mid
        else:
            ng = mid
    print(n-ok)

Measured memory_bytes: 14320
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

const int n_max = 200004;

signed main(){
    int n;
    cin >> n;
    int A[n];
    REP(i,n) cin >> A[i];

    int dp[n_max][6];
    REP(i,n+1) REP(j,6) dp[i][j] = INF;
    REP(j,6) dp[0][j] = 0;
    REP(i,n){
        dp[i+1][0] = dp[i][0] + A[i];
        dp[i+1][1] = min(dp[i][1],dp[i][0]);
        dp[i+1][2] = min(dp[i][2],dp[i+1][1]);
        dp[i+1][3] = min(dp[i][3],dp[i+1][2]);
        dp[i+1][4] = min(dp[i][4],dp[i+1][3]) + A[i];
        if(A[i] %2 == 1){
            dp[i+1][1] += 1;
            dp[i+1][3] += 1;
        }
        if(A[i] == 0){
            dp[i+1][1] += 2;
            dp[i+1][3] += 2;
        }
        if(A[i] %2 == 0) dp[i+1][2] += 1;
    }

    int ans = INF;
    REP(i,5) chmin(ans,dp[n][i]);
    cout << ans << endl;
}

Measured memory_bytes: 11136
function main(input){
  const lines = input.split('\n');
  const N = parseInt(lines[0].split(' ')[0]);
  const K = parseInt(lines[0].split(' ')[1]);
  const Xs = lines[1].split(' ').map(x => parseInt(x))

  var result = 1e9;
  for(var i=0;i<N-K+1;i++){
    var min = Xs[i];
    var max = Xs[i+K-1];

    var right = Math.abs(max-min)+Math.abs(max);
    var left = Math.abs(max-min)+Math.abs(min);

    result = Math.min(...[result,left, right]);
    //console.log([i,result,min,max]);
  }

  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

using namespace std;

int N;
long long int L[120], X;

int main(void) {

	cin >> N >> X;
	for (int i = 1; i <= N; i++) { cin >> L[i]; }

	long long int pos = 0;
	int ans = 1;

	for (int i = 1; i <= N; i++) {
		pos += L[i];
		if (pos <= X) { ans++; }
	}

	cout << ans << endl;


	return 0;
}

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

int main() {
	int k;
	cin >> k;
	if(k==4||k==6||k==9||k==10||k==14||k==21||k==22||k==25||k==26)
	{
		k = 2;
	}
	else if(k==28||k==30)
	{
		k = 4;
	}
	else if(k==8||k==12||k==18||k==20||k==27)
	{
		k = 5;
	}
	else if(k==16)
	{
		k = 14;
	}
	else if(k==24)
	{
		k = 15;
	}
	else if(k==32)
	{
		k = 51;
	}
	else
	{
		k = 1;
	}
	cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define wfile freopen("output.txt", "w", stdout)
#define rfile freopen("input.txt", "r", stdin)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
void enable_io(){
    #ifdef LOCAL_PROJECT
        wfile;
        rfile;
    #endif
}

int main(int argc, char const *argv[])
{   
    fastio;
    enable_io();
    int T = 1;
    //cin >> T;
    for(int t = 0; t < T; t++){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        int i = 0;
        //cout << a << " " << b << " " << c << " " << d << endl;
        while(a > 0 && c > 0){
            c = c - b;
            a = a - d;
            //cout << a << " " << c << endl;
            if(c <= 0){
                cout << "Yes\n";
            }
            else if(a <= 0){
                cout << "No\n";
            }
        }      
    }
    return 0;
}


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

#define MAX 200

typedef struct{
  int top;
  int stack[MAX];
}Stack;

int push(Stack*, int);
int pop(Stack*);

int push(Stack *s, int in){
  if(s->top < MAX){
    s->stack[s->top] = in;
    s->top++;
    return 1;
  }
  return 0;
}

int pop(Stack *s){
  if(s->top >= 0){
    s->top--;
    return s->stack[s->top];
  }
  printf("NO_DATA\n");
  return 0;
}
int main(int argc, char const *argv[]) {
  int t=0;
  char inp[10];
  int a, b, c, i;
  Stack s;
  s.top = 0;

  while(scanf("%s",inp) != EOF){
    //printf("%d time(s)  %s\n",++t,inp);
    if(inp[0] == '+'){
      //printf("+\n");
      b = pop(&s);
      a = pop(&s);
      c = a + b;
      push(&s, c);
    } else if(inp[0] == '-'){
      //printf("-\n");
      b = pop(&s);
      a = pop(&s);
      c = a - b;
      push(&s, c);
    } else if(inp[0] == '*'){
      //printf("-\n");
      b = pop(&s);
      a = pop(&s);
      c = a * b;
      push(&s, c);
    } else {
      //printf("?\n");
      push(&s, atoi(inp));
    }
    //for(i=0;i<s.top;i++)printf("%d ",s.stack[i]);printf("\n\n");
  }

  printf("%d\n",s.stack[0]);
  return 0;
}



Measured memory_bytes: 2128
N=int(input())

csflist=[]
for i in range(N-1):
  c,s,f=map(int,input().split())
  csflist.append((c,s,f))
#print(csflist)

for i in range(N):
  sec=0
  for j in range(i,N-1):
    c,s,f=csflist[j]
    if sec<s:
      sec=s
    elif sec%f>0:
      sec+=f-(sec%f)
    sec+=c
    #print(i,j,sec)
  print(sec)

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

int main(){
    int N;
    cin >> N;
    vector<int> b;
    vector<int> ans;
    
    for(int i=0;i<N;i++){
        int x;
        cin >> x;
        b.push_back(x);
    }
    for(int i=0;i<N;i++){
        if(b[i]>i+1){
            cout << "-1";
            return 0;
        }
    }

    while(true){
        for(int i=b.size()-1;i>=0;i--){
            if(b[i]==i+1){
                b.erase(b.begin()+i);
                ans.push_back(i+1);
                break;
            }
        }
        if(b.size()==0)break;
    }
    for(int i=ans.size()-1;i>=0;i--){
        cout << ans[i] << endl;
    } 
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define pb push_back
#define pf push_fron
#define INF 1000000000
typedef long long ll;

char S[110];

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

	int n;
	bool flag = false;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < n; i++) {
		if (S[i] == 'Y')flag = true;
	}

	cout << ((flag) ? "Four" : "Three" )<< endl;
	
	
	return 0;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
vw = [list(map(int, input().split())) for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N+1)] #i番目までみたときの重さjでの価値の最大値
for i in range(N):
  v, w = vw[i]
  for j in range(W+1):
    if w <= j:
      dp[i+1][j] = max(dp[i][j], dp[i][j-w]+v)
    else:
      dp[i+1][j] = dp[i][j]
print(dp[N][W])



Measured memory_bytes: 25516
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		//String a[] = scan.nextLine().split(" ", n - 1);
		int a[] = new int[n];
		for(int i = 0; i < n; i++){ //length???????´???°????????§??????????????§?????????
			a[i] = scan.nextInt();
		}
		for(int i = a.length - 1; i >= 0; i--){ //length???????´???°????????§??????????????§?????????
			System.out.print(a[i]);
			if(i != 0){
				System.out.print(" ");
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 26292
#include<iostream>
#include<algorithm>
#include<math.h>
#include<limits.h>
#define _USE_MATH_DEFINES

using namespace std;

long long n, l[100] = {};
char w[100][11] = {};
bool ok = true;

int main() {
	cin >> n;
	for (auto i = 0; i < n; i++) {
		cin >> w[i];

		while (w[i][l[i]] != 0) {
			l[i]++;
		}
	}

	for (auto i = 0; i < n - 1; i++) {
		if (w[i][l[i] - 1] != w[i + 1][0]) {
			ok = false;
			break;
		}
	}

	if (ok) {
		for (auto i = 0; i < n - 1; i++) {
			for (auto j = i + 1; j < n; j++) {
				if (l[i] == l[j]) {
					bool flag = true;
					for (auto k = 0; k < l[i]; k++) {
						if (w[i][k] != w[j][k]) {
							flag = false;
							break;
						}
					}
					if (flag) {
						ok = false;
					}
				}

				if (!ok) {
					break;
				}
			}

			if (!ok) {
				break;
			}
		}
	}

	if (ok) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

public class Main {
	final static long MOD = 1000000007;
	static long solveSmallDP(int N , int K){
		long dp[] = new long[N + 1];
		for(int i = 1 ; i <= N ; ++i){
			dp[i] = 1;			
		}
		for(int k = 0 ; k < K - 1; ++k){
//			System.out.println(k);
			long next[] = new long[N + 1];
			for(int i = 1 ; i <= N ; ++i){
				long S = 0;
				for(int j = 1  ; i * j <= N ; ++j){
					S = (S + dp[j]) % MOD;
				}
				next[i] = S;
			}
			dp = next;
		}
//		System.out.println(Arrays.toString(dp));		
		long S = 0;
		for(long d : dp){
			S = (S + d) % MOD;
		}
		return S;
	}
	public static void main(String[] args) {
		//
		// dp[k][i] = dp[k - 1][
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		if(N <= 100000){
			System.out.println(solveSmallDP(N, K));
			return ;
		}
		// dp[10] = dp[1]
		// dp[5]  = dp[1] + dp[2]
		// dp[4]  = dp[1] + dp[2]
		// dp[3]  = dp[1] + dp[2] + dp[3]
		// dp[2]  = dp[1] + ... + dp[3] + dp[4] * 2
		// dp[1]  = dp[1] + dp[2] + dp[3] + dp[4] * 2 + dp[5] * 5
		// (50001 .. 100000 ) dp2[1] = dp1[1]
		// (33334 .. 50000) dp2[2] = dp1[1] + dp1[2]
		// (25001 .. 33333) dp2[3] = dp1[1] + dp1[2] + dp1[3]
		// (20001 .. 25000) dp2[4] = dp1[1] + dp1[2] + dp1[3] + dp1[4]
		// ..
		// (991 .. 1000) dp2[100] = dp1[1] + ... + dp1[100]
		// dp1[990] = S + dp1[101]
		// dp1[989] = S + dp1[101] 		
		// dp1[988] = 
		int M = 1000;		
		int L = N / (M + 1);
		long dp1[] = new long[L + 1];
		long dp2[] = new long[M + 1];
		Arrays.fill(dp1, 1);
		Arrays.fill(dp2, 1);
		for(int k = 0 ; k < K - 1; ++k){
			long next1[] = new long[dp1.length];
			long next2[] = new long[dp2.length];
			long S = 0;
			for(int t = 1 ; t < dp2.length ; ++t){
				S = (S + dp1[t] ) % MOD;
				next2[t] = S;
			}
			int T = M + 1;
//			System.out.println(T +" "+ M + " "+L +" "+N+" "+(L * T));
			for(int i = dp1.length - 1; i >= 1 ; --i){
				while(i * T <= N){
					if(T < dp1.length){
						S = (S + dp1[T]) % MOD;
						T++;						
					}else{
						int len = N / i - (N / (i + 1));
						S = (S + dp2[i] * len) % MOD;
						break;
					}
				}
				next1[i] = S;
			}
			dp1 = next1;
			dp2 = next2;
		}
//		System.out.println(Arrays.toString(dp1));	
//		System.out.println(Arrays.toString(dp2));	

		long S = 0;
		for(long d : dp1){
			S = (S + d) % MOD;
		}
		// 10000 - 5000 [5001..10000]
		// 10001 - 5000 [5000..10001]
		for(int i = 1 ; i < dp2.length ; ++i){
			int len = N / i - (N / (i + 1));
			S = (S + dp2[i] * len) % MOD;
		}
		System.out.println(S);
	}
}


Measured memory_bytes: 702612
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;

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


Measured memory_bytes: 3596
#include<stdio.h>

int main(){

int N,K,Q;
scanf("%d%d%d",&N,&K,&Q);
int P[N];
for (int i = 1; i <= N; i++){ P[i]=K; }

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

for (int i = 1; i <= N; i++)
{
  P[i]-Q > 0 ? puts("Yes") : puts("No");
}

return 0;

}

Measured memory_bytes: 2400
import os, sys, re, math

N = int(input())
H = [int(n) for n in input().split()]

ups = []
for i in range(N - 1):
    if H[i] < H[i + 1]:
        ups.append(i)
ups.append(N - 1)

p = 0
max_d = 0
max_p = 0
for i in range(len(ups)):
    if ups[i] - p > max_d:
        max_d = ups[i] - p
        max_p = p
    p = ups[i] + 1

print(max_d)


Measured memory_bytes: 14508
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;
use std::collections::BTreeMap;

fn cpow(n: usize) -> usize {
    let mut ans = 1;
    for z in 0..n {
        ans *= 2;
        ans %= 1_000_000_007;
    }
    ans
}

fn main() {
    let n: usize;
    input!(n);
    let mut h = BTreeMap::new();
    let v = input_vector::<usize>();

    for z in v {
        let po = h.entry(z).or_insert(0);
        *po += 1;
    }
    let mut flag = true;
    for (i, x) in &h {
        if n % 2 == 0 && *i % 2 == 0 {
            flag = false;
            break;
        } else if n % 2 != 0 && *i % 2 != 0 {
            flag = false;
            break;
        } else if n % 2 != 0 && *x != 2 && *i != 0 {
            flag = false;
            break;
        } else if n % 2 != 0 && *x != 1 && *i == 0 {
            flag = false;
            break;
        } else if n % 2 == 0 && *x != 2 {
            flag = false;
            break;
        }
    }
    if flag {
        if n % 2 == 0 {
            p(cpow(n / 2));
        } else {
            p(cpow((n - 1) / 2));
        }
    } else {
        p(0);
    }
}

Measured memory_bytes: 6396
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;

	long ans;
	for (long i = 1; i * i < N; ++i)
	{
		/*if (N / i == N % i)
		{
			ans += i;
			//debug writeln("1:", i, " ", i);
		}*/

		auto x = N - i;
		auto y = x / i;
		if (x % i == 0 && x / y == i && N / y == i)
		{
			debug writeln("3:", y, " ", N / y, " ", i);

			ans += y;
			//debug writeln("3:", i, " ", y);
		}
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
 #include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define _for(i,j,k) for(int i=j;i<k;i++)
#define endl  '\n'
#define inf 1<<31-1
#define ull unsigned long long  
const int mod=1e9+7;
const int MAX=500000;

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int k,a;
	cin>>k;
	ll sum=0;
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=k;j++)
		{
			a=__gcd(i,j);
			for(int z=1;z<=k;z++)
			{
				sum+=__gcd(a,z);
			 } 
		}
	 } 
	cout<<sum;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
int main(){
    map<vector<char>,ll>mp;
    int n;
    cin>>n;
    rep(i,n){
    string s;
    cin>>s;
    vector<char> v;
    rep(j,s.size()){
            v.push_back(s[j]);
    }
    sort(ALL(v));
    mp[v]++;
    }
    ll ans=0;
    for (auto x: mp){
        ans+=x.second*(x.second-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11136
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

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


const long long int mod = 1000000007;
const long long int INF = 1e18;

long long int H,W,L,N,A,B,M,sum=0,res=0;
string str[1234];
int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>L;
    for(long long int i = 0; i < N; i++){
        cin>>str[i];
    }
    sort(str,str+N);
    for(long long int i = 0; i < N; i++){
        cout<<str[i];
    }
    cout<<endl;
}


Measured memory_bytes: 384
/*  ex3_1 1.10
    hangan2020 */

#include <stdio.h>
int main(void){
    int number, final_digit;
    scanf("%d", &number);
    final_digit = number % 10;
    switch (final_digit)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        printf("hon\n");
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        printf("pon\n");
        break;
    case 3:
        printf("bon\n");
        break;
    }
    return 0;
}

Measured memory_bytes: 1596
use std::io;

/// 一行を読み込んで、空白で区切ったベクタにして返す
#[allow(dead_code)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect()
}

/// n行を読み込んで、数字を空白で区切って二次元のベクタにして返す
#[allow(dead_code)]
fn read_table<T>(n: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut ret: Vec<Vec<T>> = Vec::new();
    for _ in 0..n {
        ret.push(read::<T>());
    }
    ret
}

/// n行を読み込んで、1文字ずつを二次元のベクタにして返す
#[allow(dead_code)]
fn read_char_table(n: usize) -> Vec<Vec<char>> {
    let mut ret: Vec<Vec<char>> = Vec::new();
    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let chr = buf.trim().chars().collect();
        ret.push(chr);
    }
    ret
}

/// n行を読み込んで、一次元のベクタにして返す
#[allow(dead_code)]
fn read_array<T>(n: usize) -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut array = Vec::new();

    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        array.push(buf.trim().parse().unwrap());
    }
    array
}

fn main() {
    // 数値
    let (x1, y1, x2, y2) = {
        let i = read::<isize>();
        (i[0], i[1], i[2], i[3])
    };

    let mut x3;
    let mut x4;
    let mut y3;
    let mut y4;
    use std::cmp;

    let diffx = (x1 - x2).abs();
    let diffy = (y1 - y2).abs();

    if x1 < x2 && y1 <= y2 {
        x3 = x2 - diffy;
        y3 = y2 + diffx;
        
        x4 = x3 - diffx;
        y4 = y3 - diffy; 
    } else if y2 > y1 && x2 <= x1 {
        x3 = x2 - diffy;
        y3 = y2 - diffx;
        
        x4 = x3 + diffx;
        y4 = y3 - diffy; 
    } else if x1 > x2 {
        x3 = x2 + diffy;
        y3 = y2 - diffx;
        
        x4 = x3 + diffx;
        y4 = y3 + diffy; 
    } else  {
        x3 = x2 + diffy;
        y3 = y2 + diffx;
        
        x4 = x3 - diffx;
        y4 = y3 + diffy; 
    } 

    println!("{} {} {} {}", x3, y3, x4, y4);

}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;
 
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
 
const double EPS = 1e-10;
 
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int n,k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ng = 0,ok = 1e9;
    while(ok-ng > 1){
        int mid = (ok+ng)/2;
        auto f = [&](int x){
            ll cnt = 0;
            rep(i,n){
                cnt += (a[i]-1)/x;
            }
            if(cnt <= k) return true;
            else return false;
        };
        if(f(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}


Measured memory_bytes: 3996
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

func rateAdd(m map[int]bool, rate int) {
	if _, ok := m[rate]; !ok {
		m[rate] = true
	}
}

func main() {
	var wtr = bufio.NewWriter(os.Stdout)
	var sc = bufio.NewScanner(os.Stdin)
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)

	sc.Scan()
	strconv.Atoi(sc.Text())

	sc.Scan()
	temp := strings.Split(sc.Text(), " ")
	m := map[int]int{}
	var max int
	for _, v := range temp {
		p, _ := strconv.Atoi(v)
		if _, ok := m[p+1]; ok {
			m[p+1]++
		} else {
			m[p+1] = 1
		}
		if _, ok := m[p-1]; ok {
			m[p-1]++
		} else {
			m[p-1] = 1
		}
		if _, ok := m[p]; ok {
			m[p]++
		} else {
			m[p] = 1
		}

		if m[p] > max {
			max = m[p]
		}
		if m[p+1] > max {
			max = m[p+1]
		}
		if m[p-1] > max {
			max = m[p-1]
		}
	}
	fmt.Fprintln(wtr, max)
	_ = wtr.Flush()
}


Measured memory_bytes: 10808
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long li;
#define abs(n) max((n),-(n))
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

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

int dfs(int x,int y,vector<vector<int>>& h,int now){
  int n=h.size();
  rep(i,4){
    int xx=x+dx[i],yy=y+dy[i];
    if(xx<0 or xx>=n or yy<0 or yy>=n) continue;
    //    if(df) print(now,h[xx][yy]);
    if(abs(h[xx][yy])<abs(now)) continue;
    if(abs(h[xx][yy])==now) continue;
    int t=h[xx][yy];
    h[xx][yy]+=h[xx][yy]>0?-1:+1;
    dfs(xx,yy,h,t);
  }
  return now;
}

int main(){
  int n; cin >>n;
  vector<vector<int>> h(n,vector<int>(n,0));
  rep(i,n) rep(j,n){
    h[i][j]=min({i,j,n-i-1,n-j-1});
  }
  if(df)rep(i,n)print(h[i]);
  li ans=0;
  rep(i,n*n){
    int a; cin >>a; a--;
    int x=a/n,y=a%n;
    int now=h[x][y];
    h[x][y]*=-1;
    ans+=dfs(x,y,h,now);
    if(df)rep(i,n)print(h[i]);
  }
  print(ans);
}


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

int main(){
    string s;
    cin >> s;
    rep(i, s.size()){
        if(i%2==0) cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<long long int>v(N);
	L = 0;
	R = 0;
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		L = min(L, v[i]);
		R = max(R, v[i]);
	}
	vector<pair<int, int>>ans;
	if (abs(R) > abs(L)) {
		int index = 0;
		for (int i = 1; i < N; i++) {
			if (v[i] > v[index]) {
				index = i;
			}
		}
		ans.push_back({ index,N - 1 });
		ans.push_back({ index,N - 1 });
		ans.push_back({ index,N - 1 });
		for (int i = 1; i < N - 1; i++) {
			ans.push_back({ N - 1,N - 1 });
			ans.push_back({ N - 1,i });
		}
		ans.push_back({ N - 1,N - 1 });
	}
	else {
		int index = 0;
		for (int i = 1; i < N; i++) {
			if (v[i] < v[index]) {
				index = i;
			}
		}
		ans.push_back({ index,0 });
		ans.push_back({ index,0 });
		ans.push_back({ index,0 });
		for (int i = N - 2; i >= 1; i--) {
			ans.push_back({ 0,0 });
			ans.push_back({ 0,i });
		}
		ans.push_back({ 0,0 });
	}
	cout << ans.size() << endl;
	for (auto i : ans) {
		cout << i.first + 1 << " " << i.second + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
S = input()

d = []

prev = "L"
for s in S:
  if s == "R":
    if prev == "L":
      d.append([1,0])
    else:
      d[-1][0] += 1
  else:
    d[-1][1] += 1
  prev = s

ans = []
for r,l in d:
  hidari = -(-r//2) + l//2
  migi = r//2 - (-l//2)
  ans.append("0 "*(r-1)+str(hidari)+" "+str(migi)+" "+"0 "*(l-1))
  
print(*ans,sep="")
    

Measured memory_bytes: 55404
from collections import deque
def main4():
    N, M = map(int, input().split())
    pair = [list() for i in range(N)]

    for i in range(M):
        A, B = map(int, input().split())
        pair[A - 1].append(B - 1)
        pair[B - 1].append(A - 1)

    dq = deque()
    color = ["w" for i in range(N)]

    ans = 0
    for i in range(N):
        if color[i] == "w":
            dq.append(i)

            con = 1
            while True:
                if len(dq) == 0:
                    break

                idx = dq.popleft()
                color[idx] = "g"

                for j in range(len(pair[idx])):
                    if color[pair[idx][j]] == "w":
                        dq.append(pair[idx][j])
                        color[pair[idx][j]] = "g"
                        con += 1

            ans = max(ans, con)
            
    print(ans)

if __name__ == "__main__":
    main4()

Measured memory_bytes: 44796
#include<bits/stdc++.h>
using ll= long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (ll)1e9 //10^9:∞
#define LLINF (ll)1e12
#define MOD (ll)(1e9+7) //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	ll N, M, K;
 
	cin >> N >> M >> K;
	VI A(N), B(M);
	REP(i, N) {cin >> A[i];}
	REP(i, M) {cin >> B[i];}
 
	ll ans = 0;
	ll n = 0;
	ll time = 0;
	ll a = 0;
 
	REP(i, N) {
		if (time + A[i] <= K) {time += A[i]; n++; if(i==N-1){a=N-1;}}
		else {a = i - 1; break;}//最後に入れたAのインデックス 入れれなかったら-1
	}
	//cout<<a<<endl;
	ll j = 0;
	for (ll i = a; -1 <= i; --i)
	{ 
		//cout<<i<<endl;
		while (j < M && time + B[j] <= K) {
			time+=B[j];
			n++;
			j++;
		}
		ans=max(ans,n);
		if(i>=0){time-=A[i];n--;}

		//if(i==-1){break;}
	}
 
 
 
	cout << ans << endl;


		return 0;
}


Measured memory_bytes: 4784
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#define mprint(x) printf(FORMATCONVERSION(x),(x))
#define FORMATCONVERSION(x) _Generic((x),\
                                    int:"%d",unsigned int:"%u",\
                                    double:"%lf",long long int:"%lld",\
                                    unsigned long long int:"%llu",\
                                    char :"%c",char*:"%s")

int main(void){
    int h,w,n;
    int ans;
    scanf("%d %d %d",&h,&w,&n);
    if(h > w){
        ans = n / h;
        if(n % h != 0){
            ans++;
        }
    }else{
        ans = n / w;
        if(n % w != 0){
            ans++;
        }
    }
    mprint(ans);
    return 0;
}

Measured memory_bytes: 128