akhauriyash/Code-Regression huggingface dataset:
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

void _yn(bool p) {
	p ? _y() : _n();
}

void _YN(bool p) {
	p ? _Y() : _N();
}


LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 



/*****************************************************************************/

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

	int n, k;
	cin >> n >> k;
	vi a(n);
	f_vI(a, n);
	sort(all(a), greater<int>());
	int M = a[0];
	int g = a[0];
	f(i, 0, n) {
		g = gcd(g, a[i]);
	}
	if (k%g == 0&&M>=k) {
		cout << "POSSIBLE";
	}
	else {
		cout << "IMPOSSIBLE";
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdlib>
#include<stack>
#include<string>
#include<cctype>
#include<sstream>
using namespace std;
int main(){
    string str;
    while(getline(cin,str)){
        stack<double>S;
        stringstream ss;
        ss<<str;
        while(ss>>str){
            if(str[0]>='0'&&str[0]<='9'||str.size()>1){
                S.push(atoi(str.c_str()));
            }
            else{
                char ope=str[0];
                double d1=S.top();S.pop();
                double d2=S.top();S.pop();
                if(ope=='+')S.push(d1+d2);
                else if(ope=='-')S.push(d2-d1);
                else if(ope=='*')S.push(d1*d2);
                else S.push(d2/d1);
            }
        }
        cout<<fixed<<S.top()<<endl;
    }
}

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

dp = [[0]*n for _ in range(n)]
# dp[i][j] : 残っている石がi からj の時の手番から見た終了得点の最大値

for i in range(n):
    dp[i][i] = a[i]
for j in range(1,n):
    for i in range(n-j):
        dp[i][i+j] = max(a[i]-dp[i+1][i+j], a[i+j]-dp[i][i+j-1])
print(dp[0][n-1])


Measured memory_bytes: 112476
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define cl clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string sp=" ";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<long long>
#define vs  vector<string>
#define MX LLONG_MAX
#define MN LLONG_MIN
#define MOD 1000000007
#define vp(vi,x) cin>>x; vi.pb(x);
#define bsearch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,p,q,a,b,c=0;
    bool f=0,ff=0;
    string st;
    char ch;
    while(cin>>n>>k>>a>>b)
    {
        if(k>=n)s=n*a;
        else s=k*a+(n-k)*b;
        cout<<s<<en;
    }
}




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

cnt = [0] * 9
free = 0

for _a in a:
    r = _a//400
    if r < 8:
        cnt[r] = 1
    else:
        free += 1

if free == n:
    print(1, free)
else:
    print(sum(cnt), sum(cnt) + free)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
using ll = long long;
using namespace std;

vector<pair<int, int>> vp;

bool operator<(const pair<int, int> &a, const pair<int, int> &b)
{
    if (a.first == b.first)
        return a.second < b.second;
    return a.first < b.first;
}
int main(void)
{
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; ++i)
    {
        int a, b;
        cin >> a >> b;
        vp.push_back({b, a});
    }
    sort(vp.begin(), vp.end());

    int t = vp[0].first;
    int ans = 1;
    for (int i = 1; i < M; ++i)
    {

        if (t <= vp[i].second)
        {
            ans++;
            t = vp[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}

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

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}

#define N 2106 
int u,v,n,k,q,ans,d[N],op[N];
multiset<int>s,o;
struct node {
	int w, i;
	bool operator < (const node&a)const {  
		return w<a.w; 
	}
}a[N];

int main()
{
	n=read();k=read();q=read();
	for(int i=1; i<=n; ++i)a[i].w=d[i]=read(),a[i].i=i;
	ans=2e9; 
	sort(a+1,a+n+1);
	for(int i=1; i<=n; ++i)if(a[i].w!=a[i-1].w){
		o.clear(); s.clear();  
		for(int j=1; j<=n; ++j)if(op[j]){
			while(s.size()>=k){
				o.insert(*s.begin()); //it??
				s.erase(s.begin());
			}
			s.clear();
		} else s.insert(d[j]);
		while(s.size()>=k){
			o.insert(*s.begin());
			s.erase(s.begin());//erase  end() //0 //empty??  //ins cunzai??
		}
		s.clear();
		
		if(o.size()<q)break;	
		
		u=*o.begin();
		
		for(int i=1; i<q; ++i)o.erase(o.begin());
		
		v=*o.begin();
		
		ans=min(ans,v-u);
		
		for(int j=i; j<=n; ++j){
			if(a[j].w!=a[i].w)break;
			op[a[j].i]=1;//true
		}
	}
	cout<<ans;
}

Measured memory_bytes: 384
N, M = map(int, input().split())
P = list(map(int, input().split()))


class UnionFind(object):
    def __init__(self, N):
        self.parent = [-1] * N #parent[i] は(i+1)番目の要素が含まれる要素数の(-1)倍
    #要素が負-->その数を親とするグループに属する要素の数×(-1)
    #要素が正-->親のindex

    #Aがどのグループに属しているかを調べる
    def root(self, A):
        if self.parent[A-1] < 0: #負の数-->その数は親
            return A
        self.parent[A-1] = self.root(self.parent[A-1]) #負では無い時、親の場所が入っているから、親が属しているグループを、自分自身に入れる(一度確認したところは直接親を見れるようにする)
        return self.parent[A-1] #親の位置を返す

    #Aが含まれているグループに属している数を返す
    def size(self, A):
        return -1 * self.parent[self.root(A)-1]

    #AとBをくっ付ける
    def connect(self, A, B):
        A = self.root(A) #Aを含むグループの親を返す
        B = self.root(B) #Bを含むグループの親を返す
        if A == B: #親が同じならなにもしない
            return False
        
        #大きい方(A)に小さい方(B)をつなぎたい
        if self.size(A) < self.size(B): #大小関係が逆の時は入れ替える
            A, B = B, A
        
        self.parent[A-1] += self.parent[B-1] #大きい方に小さい方を加える　（負の数＋負の数 = 新しいグループに含まれる数×(-1)）
        self.parent[B-1] = A #加えられた親の値を、加えた先の親の位置に書き変える
        return True
    
    def same(self, A, B):
        if self.root(A) == self.root(B):
            return True
        else:
            return False

uni = UnionFind(N + 1)

for _ in range(M):
    x, y = map(int, input().split())
    uni.connect(x, y)

count = 0

for index, p in enumerate(P):
    if uni.same(p, index + 1):
        count += 1

print (count)


Measured memory_bytes: 13812
#include <stdio.h>
#include <vector>
#include <list>
#include <map>
#include <array>
#include <memory>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <stdexcept>


using std::string;
using std::vector;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// util
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

std::vector<std::string> split(const std::string& input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// user func
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void printList(const vector<int>& list) {
    // print
    for(int i = 0; i < list.size(); i++){
        printf(" %d", list[i]);
    }
    printf("\n");
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// logic
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct _Matrix {
    int row;
    int col;
} Matrix;

std::map<string, int> memo;
int GetCost(const vector<Matrix> list, int begin, int end)
{
    // printf("%d - %d\n", begin, end);
    if (begin == end) return 0;
    string hash = std::to_string(begin) + "," + std::to_string(end);
    if (memo[hash] != 0) return memo[hash];
    int min = std::numeric_limits<int>::max();
    for(int p = begin; p < end; p++){
        int r  = list[begin].row;
        int c1 = list[p].col;
        int c2 = list[end].col;
        int left = GetCost(list, begin, p);
        int right = GetCost(list, p + 1, end);
        min = std::min(min, left + right + r * c1 * c2);
        string lhash = std::to_string(begin) + "," + std::to_string(p);
        string rhash = std::to_string(p + 1) + "," + std::to_string(end);
        memo[lhash] = left;
        memo[rhash] = right;
        // min = std::min(min, GetCost(list, begin, p) + GetCost(list, p + 1, end) + r * c1 * c2);
    }
    return min;
}

void solve() {
    int n;
    scanf("%d", &n);
    vector<Matrix> matrixList(n);
    for(int i = 0; i < n; i++){
        int r, c;
        scanf("%d %d", &r, &c);
        matrixList[i] = {r,c};
    }
    int cost = GetCost(matrixList, 0, n - 1);
    printf("%d\n", cost);
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// main
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    solve();
    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false); cin.tie(NULL);
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    a[i] /= 2;
  }
  ll start = a[0];
  for (ll i = 1; i < n; i++) {
    ll g = __gcd(start, a[i]);
    if ((start / g) % 2 == 0 || (a[i] / g) % 2 == 0) {
      start = m + 1;
      break;
    }
    ll k = (start / g) / 2;
    start = a[i] * (2 * k + 1);
    if (start > m) break;
  }
  ll ans = ((m / start) + 1) / 2;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder
{
  class Program
  {
    static void Main(string[] args)
    {
      string[] ss = Console.ReadLine().Split(' ');
      int N = int.Parse(ss[0]);
      int Y = int.Parse(ss[1]);
      int amount = 0;
      int a = 0, b = 0, c = 0;
      int rate = Y / N;
      if(rate > 10000 || 1000 > rate)
      {
        Console.WriteLine("-1 -1 -1");
        Console.ReadLine();
        return;
      }
      while(N > 100)
      {
        rate = (Y - amount) / N;
        if(rate > 7000)
        {
          a++;
          amount += 10000;
        }
        else if(rate > 3300)
        {
          b++;
          amount += 5000;
        }
        else
        {
          c++;
          amount += 1000;
        }
        N--;
      }
      if(NewMethod(Y, amount, N, a, b, c))
        return;

      Console.WriteLine("-1 -1 -1");
      Console.ReadLine();
    }
    private static bool NewMethod(int X, int amount, int N, int A, int B, int C)
    {
      if(amount == X && N == 0)
      {
        Console.WriteLine(string.Format("{0} {1} {2}", A, B, C));
        Console.ReadLine();
        return true;
      }

      if(N == 0)
        return false;

      if(amount > X)
        return false;

      if(NewMethod(X, amount + 10000, N - 1, A + 1, B, C))
        return true;
      if(NewMethod2(X, amount + 5000, N - 1, A, B + 1, C))
        return true;
      if(NewMethod3(X, amount + 1000, N - 1, A, B, C + 1))
        return true;
      return false;
    }
    private static bool NewMethod2(int X, int amount, int N, int A, int B, int C)
    {
      if(amount == X && N == 0)
      {
        Console.WriteLine(string.Format("{0} {1} {2}", A, B, C));
        Console.ReadLine();
        return true;
      }

      if(amount >= X || N == 0)
        return false;

      if(NewMethod2(X, amount + 5000, N - 1, A, B + 1, C))
        return true;
      if(NewMethod3(X, amount + 1000, N - 1, A, B, C + 1))
        return true;
      return false;
    }
    private static bool NewMethod3(int X, int amount, int N, int A, int B, int C)
    {
      if(amount == X && N == 0)
      {
        Console.WriteLine(string.Format("{0} {1} {2}", A, B, C));
        Console.ReadLine();
        return true;
      }

      if(amount >= X || N == 0)
        return false;

      if(NewMethod3(X, amount + 1000, N - 1, A, B, C + 1))
        return true;
      return false;
    }

  }
}

Measured memory_bytes: 27464
while 1:
  H, W=map(int, raw_input().split())
  if H==0 and W==0:
    break
  for i in range(H):
    L=list("#"*W)
    if i==0 or i==(H-1):
      s="".join(L)
      print s
    else:
      for j in range(1, W-1):
        L[j]="."
        s="".join(L)
      print s
  print ""

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

const int MOD = (int)1e9+7;

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

	vector<vector<long long>> dp(S.size()+1,vector<long long>(13,0));
	dp.at(0).at(0)=1;
	for(int i=0;i<S.size();i++){
		if(S.at(i)=='?'){
			for(int j=0;j<=9;j++){
				for(int k=0;k<13;k++){
					long long aa=(k*10+j)%13;
					dp.at(i+1).at(aa)+=dp.at(i).at(k);
					dp.at(i+1).at(aa)%=MOD;
				}
			}
		}
		else{
			int x=S.at(i)-'0';
			for(int k=0;k<13;k++){
				int aa=(k*10+x)%13;
				dp.at(i+1).at(aa)+=dp.at(i).at(k);
				dp.at(i+1).at(aa)%=MOD;
			}
		}
	}
	cout << dp.at(S.size()).at(5) << endl;

	return 0;
}


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

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        long a=fsc.nextLong(), b=fsc.nextLong();
        long[] x=new long[n];
        long ans=0;
        for(int i=0;i<n;i++){
            x[i]=fsc.nextLong();
            if(i>0){
                ans+=Math.min(a*(x[i]-x[i-1]), b);
            }
        }
        fsc.close();
        System.out.println(ans);
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


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

#define PI acos(-1)
#define pb push_back
#define int long long int
#define mp make_pair
#define pi pair<int, int>
#define pii pair<int, pi>
#define fir first
#define sec second
#define MAXN 200001
#define MAXL 20
#define mod 1000000007

int n, m, k;
vector<int> a, b, aa, bb;

signed main()
{
  cin >> n >> m >> k;
  a.resize(n);
  b.resize(m);
  aa.resize(n);
  bb.resize(m);
  int at = 0;
  for (int i = 0; i < n; i++)
    cin >> a[i], at += a[i], aa[i] = at;
  at = 0;
  for (int i = 0; i < m; i++)
    cin >> b[i], at += b[i], bb[i] = at;
  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    int rem = k - aa[i];
    if (rem < 0)
      break;
    int kappa = upper_bound(bb.begin(), bb.end(), rem) - bb.begin();
    ans = max(ans, (kappa + i + 1));
  }
  for (int i = 0; i < m; i++)
  {
    int rem = k - bb[i];
    if (rem < 0)
      break;
    int kappa = upper_bound(aa.begin(), aa.end(), rem) - aa.begin();
    ans = max(ans, (kappa + i + 1));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9588
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 1000000007;
const int MOD = 1000000007;

int main(){
    string s;
    cin >> s;
    int ind = 0;
    int k = 0;
    int s_len = s.size();
    while(ind < s_len){
        int lv_j = 0, lv_o = 0, lv_i = 0;
        while(ind < s_len && s[ind] == 'J'){
            ++lv_j; ++ind;
        }
        if(ind == s_len || lv_j == 0){
            ++ind; continue;
        }
        while(ind < s_len && s[ind] == 'O'){
            ++lv_o; ++ind;
        }
        if(ind == s_len || lv_j < lv_o || lv_o == 0) continue;
        while(ind < s_len && s[ind] == 'I'){
            ++lv_i; ++ind;
        }
        if(lv_o <= lv_i){
            k = max(lv_o, k);
        }
    }
    cout << k << endl;
    return 0;
}

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

int main(void) {
    string x;
    stack<char> st;
    cin >> x;
    for (char item : x) {
        if (item == 'S')
            st.push('S');
        if (item == 'T') {
            if (!st.empty() && st.top() == 'S')
                st.pop();
            else 
                st.push('T');
        }
    }
    cout << st.size() << endl;
}


Measured memory_bytes: 644
n, m, q = map(int, input().split())
l = [[int(i) for i in input().split()] for _ in range(q)]
m -= 1
mx = 0


def main(x, y, A, c):
  global mx
  if x == n and y == m:
    pts = 0
    for i in l:
      if int(A[i[1]-1])-int(A[i[0]-1]) == i[2]:
        pts += i[3]
    mx = max(mx, pts)
    return
  if x < n:
    nA = A+str(c)
    main(x+1, y, nA, c)
  if y < m:
    nc = c+1
    main(x, y+1, A, nc)


main(0, 0, "", 0)
print(mx)

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

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int h, n;
    scan(h, n);

    auto a = new int[](n);
    auto b = new int[](n);
    foreach (i ; 0 .. n) {
        scan(a[i], b[i]);
    }

    auto dp = new long[][](n + 1, h + 1);
    foreach (j ; 1 .. h + 1) {
        dp[0][j] = inf6;
    }

    foreach (i ; 1 .. n + 1) {
        foreach (j ; 0 .. h + 1) {
            dp[i][j] = dp[i - 1][j];
            if (j - a[i - 1] < 0) {
                chmin(dp[i][j], dp[i][0] + b[i - 1]);
            }
            if (j - a[i - 1] >= 0) {
                chmin(dp[i][j], dp[i][j - a[i - 1]] + b[i - 1]);
            }
        }
        foreach_reverse (j ; 0 .. h) {
            chmin(dp[i][j], dp[i][j + 1]);
        }
    }

    auto ans = dp[n][h];
    writeln(ans);
}
















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 82300
#include<stdio.h>
#include<algorithm>

int nextInt();

class CompareInt{
public:
  bool operator()(const int& a, const int& b) const{
    return a > b;
  }
};

int N, i;
int A, B, C[100000];
long long int a, b;

int main(){
	N=nextInt();
	for(i=0; i<N; i++){
		A=nextInt();
		B=nextInt();
		C[i] = A + B;
		b += B;
	}
	std::sort(C, C+N, CompareInt());
	for(i=0; i<N; i+=2){
		a += C[i];
	}
	printf("%lld\n", a-b);
	return 0;
}

int nextInt(){
	int f=0; char c=getchar();
	while((c<'0')||('9'<c)){c=getchar();}
	while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=getchar();}
	return f;
}


Measured memory_bytes: 512
def main():
	N, M, Q = map(int, input().split())
	LR = [[0 for _ in range(N+1)] for _ in range(N+1)]
	ans = [0]*Q
	for _ in range(M):
		l, r = map(int, input().split())
		LR[l][r] += 1
	for i in range(1, N+1):
		for j in range(1, N+1):
			LR[i][j] += LR[i][j-1]
	for i in range(1, N+1):
		for j in range(1, N+1):
			LR[i][j] += LR[i-1][j]

	for i in range(Q):
		p, q = map(int, input().split())
		ans[i] = LR[q][q] + LR[p-1][p-1] - LR[p-1][q] - LR[q][p-1]
	for a in ans:
		print(a)


if __name__ == '__main__':
    main()

Measured memory_bytes: 17652
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)



















int main(){
    string s;
    cin >> s;
    ll c = 0;
    REP(i, 3){
        if(s[i] == '1') c++;
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
 
int judge(int);
 
int main(){
    int n,age;
 
    for(;;){
	int cnt[7] = {0};
 
	cin >> n;
	if(n == 0) break;
 
	for( int i = 0 ; i < n ; i++ ){
	    cin >> age;
	    cnt[judge(age)]++;
	}
	for( int i = 0 ; i < 7 ; i++ ) cout << cnt[i] << endl;
    }
    return 0;
}
 
int judge(int age){
    return min(age/10,6);
}

Measured memory_bytes: 1156
n=int(input())
l=list(map(int,input().split()))
l.sort()
L=[l[0]]
for i in range(1,n):
  L.append(L[-1]+l[i])
ct=1
for i in range(1,n):
  if l[i]>2*L[i-1]:
    ct=1
  else:
    ct+=1
print(ct)

Measured memory_bytes: 14320
#include<stdio.h>
int main()
{
	int a,b,c;
	
	scanf("%d%d%d",&a,&b,&c);
	
	while(1){
		if(a+b==c)puts("Yes");
		else if(a+c==b)puts("Yes");
		else if(b+c==a)puts("Yes");
		else puts("No");
		break;
	}
	return 0;
}

Measured memory_bytes: 128
#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, n, m) for (int i = m; i < n; i++)
#define MM(i, n, m) for (int i = m; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;

/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 * pair<型, 型> 変数名
 * map<型, 型> 変数名  // 連想配列
 * priority_queue<型> 変数名  // 最大値から出てくるヒープ
*/
int main()
{
    ll H;
    cin >> H;
    ll cnt = 0;
    while (H != 1)
    {
        H /= 2;
        cnt++;
    }
    ll ans = 0;
    // cout << cnt << endl;
    while (cnt != 0)
    {
        ans += pow(2, cnt);
        --cnt;
        // cout << ans << endl;
    }
    cout << ans + 1 << endl;
    // cout << pow(2, 1) << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

template <class T>
struct Kruskal {
  struct UnionFind {
    int N;
    vector<int> sz_tree, parent;
    UnionFind() {}
    UnionFind(int N) : N(N), sz_tree(N, 1), parent(N) {
      iota(parent.begin(), parent.end(), 0);
    }
    int root(int x) {
      return parent[x] == x ? x : parent[x] = root(parent[x]);
    }
    void merge(int x, int y) {
      if ((x = root(x)) == (y = root(y))) return;
      if (sz_tree[x] < sz_tree[y]) swap(x, y);
      sz_tree[x] += sz_tree[y];
      parent[y] = x;
    }
    bool same(int x, int y) {
      return root(x) == root(y);
    }
    int size(int x) {
      return sz_tree[root(x)];
    }
  };
  struct edge {
    int from, to; T cost;
    edge() {}
    edge(int f, int t, T c) : from(f), to(t), cost(c) {}
  };
 
  int N;
  vector<edge> es;
  Kruskal() {}
  Kruskal(int N) : N(N) {}
 
  void add_edge(int from, int to, T cost) {
    es.emplace_back(from, to, cost);
  }
  T mst() {
    T res = 0;
    UnionFind uf(N);
    sort(es.begin(), es.end(), [&](edge a, edge b) {
      return a.cost < b.cost;
    });
    for (auto &e : es) {
      if (uf.same(e.from, e.to)) continue;
      uf.merge(e.from, e.to);
      res += e.cost;
    }
    return res;
  }
};

struct hoge {
  int n, x, y;
  hoge() {}
  hoge(int n, int x, int y) : n(n), x(x), y(y) {}
};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N;
  cin >> N;
  Kruskal<ll> K(N);

  vector<hoge> v;
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    v.emplace_back(i, x, y);
  }
  sort(v.begin(), v.end(), [&](hoge a, hoge b) {
    return a.x != b.x ? a.x < b.x : a.y < b.y;
  });
  for (int i = 0; i + 1 < N; i++) {
    K.add_edge(v[i].n, v[i + 1].n, v[i + 1].x - v[i].x);
  }
  sort(v.begin(), v.end(), [&](hoge a, hoge b) {
    return a.y != b.y ? a.y < b.y : a.x < b.x;
  });
  for (int i = 0; i + 1 < N; i++) {
    K.add_edge(v[i].n, v[i + 1].n, v[i + 1].y - v[i].y);
  }
  cout << K.mst() << endl;

  return 0;
}

Measured memory_bytes: 8560
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;


int rick[256];

int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	
	
	ini(n);
	ini(n1);
	vi dp(100004,INF);
	dp[0] = 0;
	FOR(i,0,n1){
		ini(x);
		ini(x1);
		FOR(i1,0,n)dp[i1+x] = min(dp[i1+x],dp[i1]+x1);
	}
	int rick = INF;
	FOR(i,n,100004)rick = min(rick,dp[i]);
	out(rick);







	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 505;
const int MAXM = 250005;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int n, m, x[MAXM], y[MAXM];
int dist[MAXN][MAXN]; bool vis[MAXN][MAXN];
void dec(int x, int y) {
	dist[x][y]--;
	for (int i = 0; i <= 3; i++) {
		int tx = x + dx[i];
		int ty = y + dy[i];
		if (dist[tx][ty] > dist[x][y] + !vis[tx][ty]) dec(tx, ty);
	}
}
int main() {
	read(n);
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= n; j++)
		m++, x[m] = i, y[m] = j;
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= n; j++)
		dist[i][j] = min(min(i, j), min(n - i + 1, n - j + 1));
	int ans = 0;
	for (int i = 1; i <= n * n; i++) {
		int p; read(p);
		int tx = x[p], ty = y[p];
		ans += dist[tx][ty] - 1;
		vis[tx][ty] = true;
		dec(tx, ty);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 26112
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

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

bool is_prime(int x) {
  if (x <= 1) {
    return false;
  }

  int lim = sqrt(x);

  for (int i = 2; i <= lim; ++i) {
    if (x % i == 0) {
      return false;
    }
  }

  return true;
}

int main(void) {
  int x;
  cin >> x;
  while (true) {
    if (is_prime(x)) {
      break;
    }
    ++x;
  }
  cout << x << endl;
  return 0;
}


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

def check(l):
    u = [0]*W
    mid = W % 2
    for i in range(W):
        if u[i]:
            continue
        for j in range(i+1, W):
            for p, q in l:
                sp = S[p]; sq = S[q]
                if sp[i] != sq[j] or sp[j] != sq[i]:
                    break
            else:
                u[j] = 1
                break
        else:
            if mid:
                for p, q in l:
                    sp = S[p]; sq = S[q]
                    if sp[i] != sq[i]:
                        break
                else:
                    mid = 0
                    continue
            break
    else:
        return 1
    return 0

def make(c, l, u, p):
    while c in u:
        c += 1
    if c == H:
        if check(l):
            print("YES")
            exit(0)
        return
    if p:
        l.append((c, c))
        make(c+1, l, u, 0)
        l.pop()
    for i in range(c+1, H):
        if i in u:
            continue
        u.add(i)
        l.append((c, i))
        make(c+1, l, u, p)
        l.pop()
        u.remove(i)

make(0, [], set(), H%2)
print("NO")

Measured memory_bytes: 3192
from math import ceil
dp = [1] + [0 for i in range(30)]
for i in range(1,31):
	for step in [1,2,3]:
		if step <= i:
			dp[i] += dp[i-step]
unit = 3650.
while 1:
	n = int(raw_input())
	if n == 0:
		break
	print int(ceil(dp[n] / unit))

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

/*
当前状态.
E: 每种苹果的个数是偶数
O: 有>=1种个苹果的个数是奇数
如果当前面对的状态是E(全是0).对方赢.
E -> O : 随便吃>=1种苹果
E 不能保持 E

O -> E : 吃掉所有是奇数个数种类的苹果

1. 初始状态是E.first下一步可以将E-> O
second就可以把O -> E.这样first就一直保持在E的情况.second
就赢了.

2. 初始状态是O. first吃掉所有奇数的苹果.这样O->E.second就面对
E的情况.first可以一直模仿second使得second一直面对E.first就赢了
*/

int main(){
	//freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(0); cin.tie(0);
	int s = 0, n, x;
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> x;
		if(x&1) s = 1;
	}
	cout << (s ? "first" : "second") << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int answer = K;

		for (int i = 0; i < N - 1; i++) {
			answer *= K - 1;
		}
		System.out.println(answer);
	}
}


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

int gcd(int a, int b) {
  // a&b
  if (a<b) swap(a,b);
  if (b == 0) return a;

  return gcd(b, a % b);
  
}

int teg(int a, int b, int c) {
  if (a == b && c == b) return 1;
  if (a == b || b == c || c == a) return 3;
  return 6;
}

int main() {
  int N;
  cin >> N;
  int sum = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = i; j <= N; j++) {
      for (int k = j; k <= N; k++) {
        sum += (gcd(gcd(i,j),k) * teg(i, j, k));
      }
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var a = p[0];
		var b = p[1];
		var c = p[2];
		
		if(b-a == c-b)
		{
			Console.WriteLine("YES");
			return;
		}
		
		Console.WriteLine("NO");
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 27484
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
int main()
{
	int n;
	cin>>n;
	vector<ll> a(n);

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

	map<ll,ll> mp;

	ll count=0;

	for(int i=0;i<n;i++)
	{
		ll temp=-(a[i]-i);

		count+=mp[temp];

		mp[a[i]+i]++;
	}

	cout<<count<<endl;

	return 0;
}

Measured memory_bytes: 27416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
#define rep(i,n) for(int i = 0;i<n;i++)

int main(){
	int n;
	cin >> n;
	vector<string>s(n);

	int ac = 0;
	int wa = 0;
	int tle = 0;
	int re = 0;

	
	rep(i,n){
		cin >> s[i];
		if(s[i] == "AC")ac++;
		else if(s[i] == "WA") wa++;
		else if(s[i] == "TLE") tle++;
		else if(s[i] == "RE") re++;
	}

	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;

	return 0;
}

Measured memory_bytes: 6424
# coding: utf-8
H, W = gets.chomp.split.map(&:to_i)
# p H, W
a = []
nodes = []
(0..(H-1)).each do |h|
  b = gets.chomp
  m = Array.new(W)
  (0..(W-1)).each do |w|
    if b[w] == "#" then
      m[w] = 0
      nodes << [w, h]
    end
  end
  a << m
end
# p a
# p nodes

max_op = 0
while not nodes.empty? do
  w, h = nodes.shift
  t = a[h][w] +1

  # 上
  if (h > 0) and not a[h-1][w] then
    a[h-1][w] = t
    max_op = t if max_op < t
    nodes.push [w, h-1]
  end

  # 下
  if (h + 1 < H) and not a[h+1][w] then
    a[h+1][w] = t
    max_op = t if max_op < t
    nodes.push [w, h+1]
  end
  
  # 右
  if (w > 0) and not a[h][w-1] then
    a[h][w-1] = t
    max_op = t if max_op < t
    nodes.push [w-1, h]
  end
  
  # 左
  if (w + 1 < W) and not a[h][w+1] then
    a[h][w+1] = t
    max_op = t if max_op < t
    nodes.push [w+1, h]
  end
end
puts max_op


Measured memory_bytes: 87164
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n;
    int a;
    int timing[100010];
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a;
        timing[a] = i;
    }
    for(int i=1;i<=n;i++){
        cout << timing[i];
        if(i == n){
            cout << "\n";
        }else{
            cout << " ";
        }
    }
    return 0;
}



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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 2e5+5;

int N,M;

LL uf_par[maxn];
LL uf_rank[maxn];

void uf_init(){ // Initialize Union-find set
    _for(i,0,maxn){
        uf_par[i] = i;
        uf_rank[i] = 1;
    }
}

LL uf_find(const LL& a){ // Find parent
    return (uf_par[a]==a)?(a):(uf_par[a] = uf_find(uf_par[a])); // Compress path
}

void uf_unite(const LL& a, const LL& b){
    auto x = uf_find(a), y = uf_find(b);
    if(x == y) return;
    if (uf_rank[x] < uf_rank[y]) { uf_par[x] = y; uf_rank[y] += uf_rank[x];}
    else {uf_par[y] = x; uf_rank[x] += uf_rank[y];}
}

int main()
{
    cin >> N >> M;
    uf_init();
    _for(i,0,M){
        int a,b;
        cin >> a >> b;
        uf_unite(a,b);
    }
    LL res = 0;
    _rep(i,1,N){
        res = max(res,uf_rank[i]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 6664
#include <stdio.h>
#include <limits.h>
#define N 100



int min(int x,int y)
{
  if(x<=y) return x;
  else return y;
}


int main()
{
  int n,i,j,k,l,p[N+1],m[N+1][N+1];

  scanf("%d",&n);

  for(i=1;i<=n;i++) scanf("%d%d",&p[i-1],&p[i]);

  for(i=1;i<=n;i++) m[i][i] = 0;

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i+l-1;
      m[i][j]=INT_MAX;
      for(k=i;k<=j-1;k++){
        m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}



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

using namespace std;

bool isPalindrome(string s) {
    int j = s.length() - 1;
    for (int i = 0; i < s.length() / 2; i++) {
        if (s[i] != s[j]) {
            return false;
        }
        j--;
    }
    return true;
}

int main() {
    string palindrome;
    cin >> palindrome;
    int n = palindrome.length();
    if (!isPalindrome(palindrome)) {
        cout << "No" << endl;
    } else {
        string sub1 = palindrome.substr(0, ((n - 1) / 2));
        string sub2 = palindrome.substr(((n + 3) / 2) - 1, n - 1);
        if (isPalindrome(sub1) && isPalindrome(sub2)) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int stare(int n){
	if(n==0) return 1;
	return n*stare(n-1);
}


void pathsum(vector<int> q, vector<pair<double,double>> &r, int n, double &sum, int &cnt){
	if(q.size()==0){ 
		cnt++;	
		return;
	}
	rep(i,q.size()){
		sum += sqrt((r[n].first-r[q[i]].first)*(r[n].first-r[q[i]].first) 
				+ (r[n].second-r[q[i]].second)*(r[n].second-r[q[i]].second))
				*(q.size()?stare(q.size()-1):1);
//				cout << n << " to " << q[i] << endl;
//		out(sqrt((r[n].first-r[q[i]].first)*(r[n].first-r[q[i]].first)+ (r[n].second-r[q[i]].second)*(r[n].second-r[q[i]].second)));
		vector<int> q2 = q;
		q2.erase(q2.begin()+i);
		pathsum(q2,r,q[i],sum,cnt);
	}
}

int main(void) {
	int n; cin >> n;
	vector<pair<double,double>> r(n);
	rep(i,n) cin >> r[i].first >> r[i].second;
	double sum = 0.0;
	int cnt = 0;
	rep(i,n){
		vector<int> q;
		rep(j,n) q.push_back(j);
		q.erase(q.begin()+i);
		pathsum(q,r,i,sum,cnt);
	}
	out16(sum/stare(n));
//	out16(cnt);

}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>

int main(void){
 std::vector<long long int> A;
 long long int a,N,median;
 long long int b;
 long long int sum=0;
 std::cin>>N;
 for(int i=0; i<N; i++){
  std::cin>>a;
  A.push_back(a-(i+1));
 }
 std::sort(A.begin(),A.end());

 median=A[N/2];

 for(int i=0; i<N; i++){
  if(A[i]>=median)sum+=A[i]-median;
  else sum+=median-A[i];
 }

 std::cout<<sum<<std::endl;
}

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

int main(){
  int c1,c2,c3,c4,c5;
  cin >> c1 >> c2 >> c3 >> c4 >> c5;
  int ans = 0;
  
  if (c1 == 0) ans = 1;
  if (c2 == 0) ans = 2;
  if (c3 == 0) ans = 3;
  if (c4 == 0) ans = 4;
  if (c5 == 0) ans = 5;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3548
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		double ans = arr[0];
		for (int i = 1; i < n; i++) {
		    ans = (ans + arr[i]) / 2;
		}
		System.out.println(ans);
   }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string a, b;
  cin >> a >> b;
  stringstream s1, s2;
  s1 << setw(101) << setfill('0') << a;
  a = s1.str();
  s2 << setw(101) << setfill('0') << b;
  b = s2.str();

  if (a > b)
    cout << "GREATER" << endl;
  else if (a < b)
    cout << "LESS" << endl;
  else
    cout << "EQUAL" << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
p=[2,5,5,4,5,6,3,7,6]
num=[]
for x in a:
	num.append(p[x-1])
inf=10**8
dp=[-inf]*(n+1)
dp[0]=0
for i in range(n):
	for j in range(m):
		if i+num[j]<=n and dp[i]!=-inf:
			dp[i+num[j]]=max(dp[i+num[j]],dp[i]+1)
ans=""
now=n
for i in range(dp[n]):
	for j in range(m-1,-1,-1):
		if now-num[j]<0:
			continue
		if dp[now-num[j]]==dp[now]-1:
			now-=num[j]
			ans+=str(a[j])
			break
print(ans)

Measured memory_bytes: 3420