akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

int main() {
	string S;
	cin >> S;
	int N = S.size();
	bool finished = false;
	int k = (N - 1) / 2;
	rep(i, k) {
		if (S.at(i) != S.at(N - i - 1)) {
			finished = true;
			break;
		}
	}
	if (finished == false) {
		rep(i, k) {
			if (S.at(i) != S.at(k - i - 1) || S.at(N - i - 1) != S.at(k + 1 + i)) {
				finished = true;
				break;
			}
		}
	}
	if (finished == true) cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void q(char op,int i,int j,int k){
  cout<<op<<' '<<i<<' '<<j<<' '<<k<<'\n';
  return;
}
int main(){
  cout<<65884<<'\n';
  int a=0;
  int b=1;
  int pa=2;
  int da=pa+1;
  int ca=da+1;
  int d=30;
  int pb=ca+1+d;
  int db=pb+1;
  int cb=db+1;
  int s=cb+1+d;
  q('<',pa,a,pa);
  q('+',pa,a,a);
  q('+',pa,b,b);
  q('<',pa,pa,pa);
  for(int ia=d;ia>0;ia--){
    q('<',ca,a,ca);
    for(int ja=1;ja<ia;ja++)
      q('+',ca,ca,ca);
    q('+',ca,ca+ia,ca+ia);
    q('<',ca+ia,a,ca);
    for(int ib=d;ib>0;ib--){
      q('<',cb,b,cb);
      for(int jb=1;jb<ib;jb++)
        q('+',cb,cb,cb);
      q('+',cb,cb+ib,cb+ib);
      q('<',cb+ib,b,cb);
      q('<',ca+ia,a,db);
      q('+',db,cb,s);
      q('<',db,db,db);
      q('<',db,s,db);
      q('<',db,s,db);
      q('<',s,s,s);
      for(int jb=1;jb<ib;jb++){
        q('+',db,db,db);
        q('+',cb,cb,cb);
      }
      q('+',db,pb,pb);
      for(int jb=1;jb<ib;jb++)
        q('+',cb,cb+jb,cb+jb);
      q('<',db,db,db);
      q('<',cb,cb,cb);
    }
    q('+',pb,da,da);
    for(int ja=1;ja<ia;ja++){
      q('+',da,da,da);
      q('+',ca,ca,ca);
    }
    q('+',da,pa,pa);
    for(int ja=1;ja<ia;ja++)
      q('+',ca,ca+ja,ca+ja);
    for(int ib=1;ib<=d;ib++)
      q('<',cb+ib,cb+ib,cb+ib);
    q('<',pb,pb,pb);
    q('<',da,da,da);
    q('<',ca,ca,ca);
  }
  cout<<flush;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    map<ll, int> m;
    rep(i,n) m[i+a[i]]++;

    ll ans = 0LL;
    rep(i,n){
        ans += m[i-a[i]];
    }
    cout << ans << endl;
}

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

ll ans, N, X, patties[51], levels[51];

ll patties_eaten(ll level, ll x)
{
    if (x <= 0LL)
        return 0LL;
    if (level == 0LL)
        return 1LL;
    x--;
    ll pe;
    if (x >= levels[level - 1])
        pe = patties[level - 1];
    else
        pe = patties_eaten(level - 1, x);
    x-=levels[level - 1];
    if (x > 0LL)
    {
        pe++;
        x--;
    }
    pe += patties_eaten(level - 1, x);
    return pe;
}

int main()
{
    scanf("%lld %lld", &N, &X);
    patties[0] = 1;
    levels[0] = 1;
    for (int i = 1; i <= N; i++)
    {
        patties[i] = 2*patties[i-1] + 1;
        levels[i] = 2*levels[i-1] + 3;
    }
    ans = patties_eaten(N, X);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <string.h>
#include <vector>

using namespace std;

vector<int> tsort(int v, vector<int> g[], bool zero_index = false) {
  vector<int> ret;

  int start = zero_index ? 0 : 1;
  int end = zero_index ? v : v + 1;
  int degree[end];
  memset(degree, 0, sizeof(degree));

  for (int from = start; from < end; from++) {
    for (int i = 0; i < g[from].size(); i++) {
      int to = g[from][i];
      degree[to]++;
    }
  }

  stack<int> root;

  for (int i = start; i < end; i++) {
    if (degree[i] == 0) {
      root.push(i);
    }
  }

  while (!root.empty()) {
    int from = root.top();
    root.pop();

    ret.push_back(from);

    for (int i = 0; i < g[from].size(); i++) {
      int to = g[from][i];
      degree[to]--;

      if (degree[to] == 0) {
        root.push(to);
      }
    }
  }

  return ret;
}

int main() {
  int n, m;
  cin >> n >> m;

  vector<int> g[n + 1];

  int a, b;
  for (int i = 0; i < n - 1 + m; i++) {
    cin >> a >> b;

    g[a].push_back(b);
  }

  vector<int> order = tsort(n, g);

  int ans[n + 1];
  memset(ans, -1, sizeof(ans));

  ans[order[0]] = 0;

  for (int i = 0; i < order.size(); i++) {
    int from = order[i];

    for (int j = 0; j < g[from].size(); j++) {
      int to = g[from][j];
      ans[to] = from;
    }
  }

  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


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

int main(void){
	while(true){
		int n;
		cin >> n;
		if(n == 0) break;
		bool floor = true;
		bool r = true, l = true;
		string f;
		int cnt = 0;
		for(int i = 0; i < n; ++i){
			cin >> f;
			if(f == "lu"){
				l = false;
			}
			if(f == "ru"){
				r = false;
			}
			if(f == "ld"){
				l = true;
			}
			if(f == "rd"){
				r = true;
			}
			if(!floor && r && l){
				cnt++;
				floor = !floor;
			}
			if(floor && !r && !l){
				cnt++;
				floor = !floor;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}


Measured memory_bytes: 3112
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	uint64_t N, M;
	uint64_t answer;
	if (scanf("%" SCNu64 "%" SCNu64, &N, &M) != 2) return 1;
	if (N <= 1 && M <= 1) answer = 1;
	else if (N <= 1) answer = M - 2;
	else if (M <= 1) answer = N - 2;
	else answer = (N - 2) * (M - 2);
	printf("%" PRIu64 "\n", answer);
	return 0;
}

/*

46664
69996
69996
69996
46664

23332


*/


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

string s;
vector<char> alphabet;

int main() {
  cin >> s;
  for (int i = 97; i <= 122; i++) {
    alphabet.push_back(i);
  }
  rep (i, s.size()) {
    if (find(alphabet.begin(), alphabet.end(), s.at(i)) != alphabet.end()) {
      alphabet.erase(find(alphabet.begin(), alphabet.end(), s.at(i)));
    }
  }
  if (alphabet.size() == 0) {
    cout << "None" << endl;
  }else{
    cout << alphabet.at(0) << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <typeinfo>
#include <cmath>
#include <numeric>
using namespace std;


int main()
{
    int A, B;
    std::cin >> A >> B;
    
    int coin = 0;
    if(A > B){
        coin = coin + A;
        A = A - 1;
    }else{
        coin = coin + B;
        B = B -1;
    }
    if(A > B){
        coin = coin + A;
        A = A - 1;
    }else{
        coin = coin + B;
        B = B -1;
    }
    std::cout << coin << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<char> is;
  for (int i = 0;i<n;i++) {
    int t;
    cin >> t;
    is.push_back(t);
  }
  int c =0;
  for (int i =1;i<n-1;i++) {
    if ((is[i-1] < is[i] && is[i] < is[i+1]) ||
        (is[i+1] < is[i] && is[i] < is[i-1])) c++;
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-8;
////////////////////////////////////////



int main(){
    ll a,b,c;cin>>a>>b>>c;
    cout<<a*b/2<<endl;
    
    return 0;
}




Measured memory_bytes: 256
n,x=map(int,input().split())
a=list(map(int,input().split()))
c=0
for i in range(1,n):
    p=a[i-1]+a[i]
    c+=max(0,p-x)
    a[i]=max(0,a[i]-max(0,p-x))
print(c)

Measured memory_bytes: 14252
n, m = map(int, input().split())
k = []
count_sub = 0
steps = []
j = 0
for i in range(m):
    k.append(int(input())) 
    if len(k)>1 and k[i]-k[i-1]==1:
        count_sub = 1
        
if count_sub ==1:
    steps = [0 for i in range(n)]  
else:
    for i in range(n+1):
        if k!=[] and k[j]==i:
            steps.append(0)
            if j < len(k)-1:
                j = j + 1
        elif i ==0:
            steps.append(1)
        elif i ==1:
            steps.append(1)  
        else:
            steps.append(steps[i-1]+steps[i-2])
 
print(steps[-1]%(1000000007))

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

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

   stack<char> s;

   rep(i, 0, N) {
     if (!s.empty() && s.top() == '(' && S.at(i) == ')') s.pop();
     else s.push(S.at(i));
   }

   int c1 = 0, c2 = 0;

   while(!s.empty()) {
     if (s.top() == ')') c1++;
     else c2++;
     s.pop();
   }

   rep(i, 0, c1) cout << '(';
   cout << S;
   rep(i, 0, c2) cout << ')';
   cout << endl;
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a,b,k;
  cin>>a>>b>>k;
  rep(i,k){
    if(i%2==0){
    if(a%2==0){
      a=a/2;
      b+=a;
    }
    else if(a%2==1){
      a--;
      a=a/2;
      b+=a;
    }
    }
    if(i%2==1){
    if(b%2==0){
      b=b/2;
      a+=b;
    }
    else if(b%2==1){
      b--;
      b=b/2;
      a+=b;
    }
    }
  }
  cout<<a<<' '<<b<<'\n';
  return(0);
}


Measured memory_bytes: 3640
gcd' :: Int -> Int -> Int
gcd' x 0 = x
gcd' x y = gcd' y (x `mod` y)

ans :: Int -> Int -> Int
ans x y =
  if x >= y
  then gcd' x y
  else gcd' y x

main :: IO ()
main =
  getLine >>=
    putStrLn . show
    . (\xs -> ans (xs!!0) (xs!!1))
    . map (read :: String -> Int) . words



Measured memory_bytes: 3596
N = int(input())
W = []
flag = 0
for i in range(N):
    W.append(input())
for i in range(N-1):
    if list(W[i])[len(list(W[i]))-1] != list(W[i+1])[0]:
        flag = 1
for i in range(N):
    for j in range(i+1,N):
        if W[i]==W[j]:
            flag = 1
if flag == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;
import java.util.stream.Stream;;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines = br.readLine().split(" ");
      // int  n = Integer.parseInt(lines[0]);
      int z = Integer.parseInt(lines[1]);

      final Pattern delim = Pattern.compile(" ");
      int d = delim
        .splitAsStream(br.readLine())
        .mapToInt(Integer::parseInt)
        .map(l -> l-z)
        .map(Math::abs)
        .reduce(Main::gcd)
        .getAsInt();
      
      System.out.println(d);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
  
  public static int gcd(int x, int y) {
    if( x<y ) {
      int tmp = x; x = y; y = tmp;
    }
    if( (x%y) == 0 ) return y;
    else return gcd(y,x%y);
  }
}

Measured memory_bytes: 38860
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[100000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    int p = 0, q = 0;
    int sol = 0;
    while (p < n)
    {
        while (q + 1 < n && a[q + 1] <= a[q])
            q++;
        sol = max(sol, q - p);
        p = q + 1;
        q = p;
    }
    cout << sol;
}


Measured memory_bytes: 640
//hail to jwalaji
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mod 1000000007
lli h,w;
vector<lli> r(2),d(2);
char grid[10005][10005];
vector<vector<lli>> store(10005,vector<lli>(10005,-1));
lli ans(lli i=1,lli j=1){
    lli answer=0;
    if(store[i][j]!=-1){
        answer=((answer)+(store[i][j]))%mod;
    }
    else{
    if((i+r[0])<=h&&(j+r[1])<=w&&(grid[i+r[0]][j+r[1]]=='.')){
        answer=((answer)+(ans((i+r[0]),(j+r[1]))))%mod;
    }
    if((i+d[0])<=h&&(j+d[1])<=w&&(grid[i+d[0]][j+d[1]]=='.')){
        answer=((answer)+(ans((i+d[0]),(j+d[1]))))%mod;
    }
    }
    store[i][j]=answer;
    return answer;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
r[0]=0;
r[1]=1;
d[0]=1;
d[1]=0;
cin>>h>>w;
store[h][w]=1;
for(lli i=1;i<=h;i++){
    for(lli j=1;j<=w;j++){
        cin>>grid[i][j];
    }
}
cout<<ans();
return 0;
}


Measured memory_bytes: 790868
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;

int r=0, D=0, x=0;

int calc(int r, int D, int x){
  return r * x - D;
}

int main(){
  cin >> r >> D >> x;
  rep(i, 10){
    x = calc(r, D, x);
    cout << x << endl;
  }
}

Measured memory_bytes: 256
/*
** 斐波那契数列 使用动态规划来避免重复的计算
*/

# include <cstdio>
# include <cstring>

const int MAX = 44 + 5;

int n, dp[MAX];

int fib(int i) {
    if (dp[i] != 0) {
        return dp[i];
    }
    if (i <= 1) {
        return 1;
    }
    dp[i] = fib(i - 1) + fib(i - 2);
    return dp[i];
}

void solve() {
    scanf("%d", &n);
    memset(dp, 0, sizeof(dp));
    printf("%d\n", fib(n));
}

int main() {
    // freopen("infile", "r", stdin);
    // freopen("outfile", "w", stdout);
    solve();
    return 0;
}


Measured memory_bytes: 2736
#include<bits/stdc++.h>
using namespace std;
namespace QiFeng233{
	double r,pi=3.1415926535897932384626433;
	void solve(){
		scanf("%lf",&r);
		printf("%.20lf",2.0*r*pi);
	}
}
signed main(){
	QiFeng233::solve();
	return 0;
}

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

using namespace std;

const int N = 2e5 + 3;
const int MOD = 998244353;

int n, dp[N];
pair <int, int> x[N];

int main() {
    cin >> n;

    for (int i = 0; i < n; i++) {
        scanf("%d%d", &x[i].first, &x[i].second);
    }

    sort(x, x + n);

    vector <int> next(n, n);
    vector <int> que;

    for (int i = n - 1; i >= 0; i--) {
        int d = x[i].first + x[i].second;
        while (!que.empty()) {
            int v = que.back();
            if (x[v].first < d) {
                que.pop_back();
            } else {
                break;
            }
        }
        if (!que.empty()) {
            next[i] = que.back();
        }
        que.push_back(i);
    }

    dp[0] = 1;

    for (int i = 0; i < n; i++) {
        int j = next[i];
        dp[j] += dp[i];
        if (dp[j] >= MOD) {
            dp[j] -= MOD;
        }
        dp[i + 1] += dp[i];
        if (dp[i + 1] >= MOD) {
            dp[i + 1] -= MOD;
        }
    }

    cout << dp[n] << endl;
}


Measured memory_bytes: 3832
import std.stdio,
       std.string,
       std.conv,
       std.algorithm;

void main() {
  long[] buf = readln.chomp.split.to!(long[]);
  long N = buf[0], K = buf[1];

  if (K == 0) {
    writeln(N * N);
    return;
  }
  long ans;
  for (int i = 1; i <= N; i++) {
    ans += max(0, (i - K) * (N / i));
    ans += max(0, (N % i) + (1 - K));
  }

  writeln(ans);
}


Measured memory_bytes: 256
from collections import deque
h,w = map(int,input().split())
c = list(map(int,input().split()))
d = list(map(int,input().split()))
s = []
for i in range(h):
  s += [input()]
t = [[h*w]*w for i in range(h)]
t[c[0]-1][c[1]-1] = 0
p = deque([[c[0]-1,c[1]-1]])
while p:
  q = p.popleft()
  u = t[q[0]][q[1]]
  for i in range(-2,3):
    if 0 <= q[0]+i and q[0]+i < h:
      for j in range(-2,3):
         if 0 <= q[1]+j and q[1]+j < w:
            if s[q[0]+i][q[1]+j] == ".":
              if abs(i) + abs(j) == 1:
                if t[q[0]+i][q[1]+j] > u:
                  t[q[0]+i][q[1]+j] = u
                  p.appendleft([q[0]+i,q[1]+j])
              else:
                if t[q[0]+i][q[1]+j] > u+1:
                  t[q[0]+i][q[1]+j] = u+1
                  p.append([q[0]+i,q[1]+j])
ans = t[d[0]-1][d[1]-1]
if ans == h*w:
  ans = -1
print(ans)

Measured memory_bytes: 99752
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) (a*a)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 998244353

int main() {
	LL x, y;
	cin >> x >> y;
	if (abs(x - y) <= 1)cout << "Brown" << endl;
	else cout << "Alice" << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    class unionfind():
        # size:要素数,tree：unionfind木
        def __init__(self, size):  # self,要素数
            self.size = size
            self.tree_root = list(range(self.size))
            self.tree_depth = [1]*self.size

        # rootを探す
        def root(self, index):
            temp_list = []
            temp = self.tree_root[index]
            while index != temp:
                temp_list.append(index)
                index = temp
                temp = self.tree_root[index]
            for i in temp_list:
                self.tree_root[i] = index
            return index

        # 結合
        def unite(self, index1, index2):
            r1 = self.root(index1)
            r2 = self.root(index2)
            if r1 != r2:
                d1, d2 = self.tree_depth[r1], self.tree_depth[r2]
                if d1 <= d2:
                    self.tree_root[r1] = r2
                    self.tree_depth[r2] = max(d1+1, d2)
                else:
                    self.tree_root[r2] = r1
                    self.tree_depth[r1] = max(d2+1, d1)

        # 同じか判定
        def same(self, index1, index2):
            r1 = self.root(index1)
            r2 = self.root(index2)
            return r1 == r2

        # 連結成分の個数
        def component(self):
            return len({self.root(i) for i in range(self.size)})

    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in [0]*m]
    s = [0]*n
    uf = unionfind(n)

    for a, b in ab:
        uf.unite(a-1, b-1)

    for i in range(n):
        s[uf.root(i)] += 1
    print(max(s))


main()


Measured memory_bytes: 110216
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG"<<'\n';
    return 0;
}

Measured memory_bytes: 3596
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def prime_factorize(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
        cnt=0
        while temp%i==0:
          cnt+=1
          temp //= i
        arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

def main():
  a, b = input().split()
  ab = int(a+b)
  x = prime_factorize(ab)
  ans = 'Yes'
  for i in x:
    if i[1]%2==1:
      ans= 'No'
  print(ans)
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 12920
#include <iostream>

using namespace std;

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


int main(){
  int n;
  cin >> n;
  int ans = INT_MAX;
  rep(i, n){
    int a;
    cin >> a;
    int count = 0;
    while(a % 2 == 0){
      a /= 2;
      count++;
    }
    ans = min(count, ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pob pop_back
#define ft first
#define ftt ft.ft
#define ftc ft.sc
#define sc second
#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define ctz __builtin_ctz
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 1e6 + 120;
 


int n ,a[maxn] ,dp[maxn] ,res;
int f(int a ,int b){
    if(a < 0 && b >= 0)
       return  abs(a - b);
    else if(a >= 0 && b < 0)
        return abs(b - a);
    else
        return abs(a - b);
}
int sum;
int main(){FAST;
    cin >> n;
    forp(i ,1 ,n + 1)
        cin >> a[i];
    forp(i ,0 ,n + 1)sum += abs(a[i] - a[i + 1]); 
   // forp(i ,1 ,n + 1)
    //    dp[i] = f(a[i - 1] ,a[i + 1]) - f(a[i] ,a[i - 1]) - f(a[i] ,a[i + 1]) + sum;
        forp(i ,0 ,n)
            cout<<sum-(abs(a[i+1]-a[i])+abs(a[i+2]-a[i+1]))+abs(a[i]-a[i+2])<<endl;
            


   return 0;
}
 












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

import itertools

n = int(input())

xy = []
for i in range(n):
    a = int(input())
    xy.append([list(map(int, input().split())) for _ in range(a)])
ans = 0
for i in itertools.product([0, 1], repeat=n):
    honest_list = list(i)
    flag = 0
    for index in range(n):
        if i[index] == 0:
            continue
        xy_tmp = xy[index]
        # print(xy_tmp)
        for k in range(len(xy_tmp)):
            x, y = xy_tmp[k]

            if honest_list[x-1] != y:
                flag = 1
            # if honest_list[x-1] == -1:
            #     honest_list[x-1] = y
            # else:  # 0or1
            #     if honest_list[x-1] != y:
            #         flag = 1
            #         break
            #     else:
            #         continue

        # if flag == 1:
        #     break
    if flag != 1:
        ans = max(ans, sum(honest_list))

print(ans)


Measured memory_bytes: 3064
## coding: UTF-8
from decimal import *
from itertools import permutations, combinations,combinations_with_replacement,product
import math


#input
#N
#A1 A2 ... AN
N = int(input())


#約数を表示　計算量sqrt(n)
#IFの判断をサボることで余計な計算量を入れないような作りになっています。
def yakusuu(n):
    #約数全列挙
    l = []
    border = int(math.sqrt(n))
    #print(border) #ここまでしか考えなくて良い
    for i in range(1, border+1):
        #print(i)
        if(n % i == 0):
            l.append(i)
            l.append(int(n/i))
    if(l[-1] == l[-2]):
        del l[-1]
    return l

counter = 0
for i in range(1, N+1, 2):
    #print(i)
    if(len(yakusuu(i)) == 8):
        counter += 1

print(counter)

Measured memory_bytes: 5076
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    string a, b, c;
    cin >> a >> b >> c;
    if (a.back() == b.front() && b.back() == c.front()) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <math.h>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{

	int N;
	cin >> N;
	
	vector<int> H;

	int count;
	int max;
	int tmp;

	for (int i = 0; i < N; i++) {
		cin >> tmp;
		H.push_back(tmp);
	}

	max = H[0];
	count = 1;
	for (int i = 1; i < N; i++) {
		if (H[i] >= max) {
			count++;
			max = H[i];
		}
		else {

		}
	}


	std::cout << count;

//	std::cout << coin; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,a[101];
    cin>>n>>x;
    int i,j,s=0;
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=1;i<=n;i++)
    {
        s=s+a[i];
        if(s>x)
        {

            break;
        }

    }

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

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	ll x;
	cin >> x;
	ll ans = x/11*2;
	x %= 11;
	if(0 < x && x < 7) ans++;
	else if(7 <= x) ans += 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
const int inf = 0x3f3f3f3f;
const ll linf = 123456789012345678;
const ll mod = 1000000007;
#pragma GCC optimize("Ofast")
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl
#define sz(x) ((int)(x).size())


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

    int r;
    cin >> r;
    cout << 3*r*r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
 
  string S;
  
  for (int i = 0; i < N; i++) {
    cin >> S;
    
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }

    if (i == N-1) {
      cout << "Three" << endl;
    }
    
  }

}

Measured memory_bytes: 3608
s = input()
ACGT = ["A","C","G","T"]
ans=0

for i in range(len(s)):
    flag = True
    tmp=0
    for j in range(i,len(s)):
        if s[j] not in ACGT:
            flag = False
            break
        tmp += 1
    ans=max(ans,tmp)

print(ans)

Measured memory_bytes: 3060
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
ans = 0
A,B = [],[]
for i in range(N):
    a,b = MI()
    A.append(a)
    B.append(b)

if A == B:
    print(0)
    exit()

m = sum(B)
for i in range(N):
    if A[i] > B[i]:
        m = min(m,B[i])

print(sum(B)-m)


Measured memory_bytes: 75924
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define UMap        std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd   ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm   ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs   ( llong n )          { return ( n < 0 ) ? -n : n; }
    template<class A, class B>inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B>inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    int ans = INF;

    signed call_of_Cthulhu( signed datum ) {

        String str;
        read str;
        for ( int i = 0; i < str.size()-2; i++ ) {
            int tmp = 0;
            for ( int j = i; j < i+3; j++ ) {
                tmp *= 10;
                tmp += str[j]-'0';
            }
            chmin ( ans, std::abs ( 753 - tmp ) );
        }

        echo ans fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); echo std::fixed << std::setprecision(8); int main_result = Rlyeh::call_of_Cthulhu(114514); return main_result;}


Measured memory_bytes: 256
use std::io::{stdin, Read};

macro_rules! parse {
    ($iter: ident) => {
        $iter.next().unwrap().parse().unwrap()
    };
    ($iter: ident,2) => {
        (parse!($iter), parse!($iter))
    };
    ($iter: ident,3) => {
        (parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident,4) => {
        (parse!($iter), parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident, $n: ident) => {
        $iter.take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut iter = s.split_whitespace();
    let (n, k): (usize, usize) = parse!(iter, 2);
    let p: Vec<usize> = parse!(iter, n);
    let e: Vec<f64> = p
        .iter()
        .map(|&x| ((1..(x + 1)).sum::<usize>() as f64) / (x as f64))
        .collect();
    let mut cur: f64 = e[..k].iter().sum();
    let mut res = cur;
    for l in 1..(n - k + 1) {
        let r = l + k;
        cur = cur - e[l - 1] + e[r - 1];
        res = f64::max(cur, res);
    }
    println!("{}", res);
}


Measured memory_bytes: 10492
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main () {
  int k, x;
  cin >> k >> x;

  if (k *500 >= x){
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  ll n;
  cin >> n;
  ll ans = 1;
  rep(i,n){
    ans = (ans * (i+1)) % 1000000007;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using Pii = std::pair<int, int>;

int main(int argc, char *argv[])
{
    int N, A, B, C;
    std::cin >> N >> A >> B >> C;

    std::vector<int> l(N, 0);
    for (int i = 0; i < N; i++) {
        std::cin >> l[i];
    }

    int ans = INF;
    for (int i = 0; i < std::pow(4, N); i++) {
        int cost = 0;
        std::vector<int> a(3, 0);
        std::vector<int> count(3, 0);
        for (int j = 0; j < N; j++) {
            int tmp = i;
            /*
            for (int tmp = 0; tmp < j; tmp++) {
                tmp /= 4;
            }
            tmp %= 4;
            */
            tmp = 3 & (tmp >> 2*j);

            if (tmp == 1) {
                a[0] += l[j];
                count[0]++;
            } else if (tmp == 2) {
                a[1] += l[j];
                count[1]++;
            } else if (tmp == 3) {
                a[2] += l[j];
                count[2]++;
            }
        }

        cost += std::abs(A - a[0]);
        cost += std::abs(B - a[1]);
        cost += std::abs(C - a[2]);

        if (count[0] == 0 || count[1] == 0 || count[2] == 0) {
            continue;
        }

        for (int j = 0; j < 3; j++) {
            cost += 10*(count[j]-1);
        }

        ans = std::min(ans, cost);
    }

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

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

const ll MD = 1e9+9;

int main() {
    static const int MN = 100100;
    static const int MM = 200200;
    static int a[MM], b[MM];
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i]; a[i]--; b[i]--;
    }

    static int deg[MN];
    for (int i = 0; i < m; i++) {
        deg[a[i]]++;
        deg[b[i]]++;
    }

    static int idx[MN];
    for (int i = 0; i < n; i++) {
        idx[i] = i;
    }

    sort(idx, idx+n, [&](const int &l, const int &r){
        return deg[l] < deg[r];
    });
    // printf("idx: ");
    // for (int i = 0; i < n; i++) {
    //     printf("%d ", idx[i]);
    // }
    // printf("\n");
    static int ridx[MN];
    for (int i = 0; i < n; i++) {
        ridx[idx[i]] = i;
    }


    static int par[MN];
    fill_n(par, MN, n);
    for (int i = 0; i < m; i++) {
        int x = ridx[a[i]], y = ridx[b[i]];
        if (x > y) swap(x, y);
        par[x] = min(par[x], y);
    }

    static vector<int> g[MN+1];
    for (int i = 0; i < n; i++) {
//        printf("push %d %d\n", par[i], i);
        g[par[i]].push_back(i);
    }

    static P data[MN];
    for (int i = 0; i < n; i++) {
//        printf("start %d\n", i);
        data[i] = P(0, 1);
        for (int d: g[i]) {
//            printf("edge %d\n", d);
            data[i].first += data[d].first;
            data[i].second *= data[d].second;
            data[i].second %= MD;
        }
        if (data[i].first == 0) {
            data[i] = P(1, 1);
        } else if (data[i].first == 1) {
            data[i].second++;
            data[i].second %= MD;
        }
//        printf("res %lld %lld\n", data[i].first, data[i].second);
    }

    P res = P(0, 1);
    for (int d: g[n]) {
//        printf("last %d\n", d);
        res.first += data[d].first;
        res.second *= data[d].second;
        res.second %= MD;
    }
    cout << res.first << endl;
    cout << res.second << endl;

    return 0;
}

Measured memory_bytes: 12608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

vector <int> g[maxn] ;
int par[maxn] , cnt[maxn] ;

void dfs(int u, int p)
{
    par[u] = p ;
    for(int i=0 ; i<g[u].size() ; i++)
    {
        int v = g[u][i] ;
        if(p==v) continue ;
        dfs(v,u) ;
        cnt[u] += cnt[v] ;
    }
    cnt[u]++ ;
    return ;
}

int main()
{
    int i , j , k , l, m , n , u , v ;

    scanf("%d",&n) ;

    for(i=1 ; i< n ; i++)
    {
        scanf("%d %d",&u,&v) ;
        g[u].pb(v) ;
        g[v].pb(u) ;
    }

    dfs(1,0) ;

    int len = 1 ;
    u = n ;

    while(u!=1)
    {
        u = par[u] ;
        len++ ;
    }

  //  printf("len %d\n",len) ;

    l = 1 ;
    u = n ;

    while( 1 )
    {
        if( (l+1) > len/2 ) break ;
        u = par[u] ;
        l++ ;
    }

 //   printf("u %d\n",u );

    if( (cnt[1] - cnt[u]) > cnt[u] ) printf("Fennec\n") ;
    else printf("Snuke\n") ;

    return 0 ;
}


Measured memory_bytes: 14336
#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 rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define esort(s) sort((s).begin(),(s).end())

typedef long long ll;
typedef pair<int,int> ipair;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=700000;

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

ll nCr(int n,int r){
    return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

void solve(){
    int X,Y; cin>>X>>Y;
    if((X+Y)%3!=0){cout<<0<<endl;return;} 
    int rank=(X+Y)/3;
    int num=X-rank;
    if(num<0 || num>rank){cout<<0<<endl;return;} 
    // cout<<"rank: "<<rank<<" num: "<<num<<"\n";

    fact[0]=1;
    rep(i,rank) fact[i+1]=fact[i]*(i+1)%MOD;
    fact_inv[rank]=power(fact[rank],MOD-2);
    rrepr(i,rank,0) fact_inv[i-1]=fact_inv[i]*i%MOD;

    ll ans=nCr(rank,num);
    cout<<ans<<endl;
    return;
}

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

    solve();
    return 0;
}

Measured memory_bytes: 10880
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static final long MAX = (long)1e18;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		Arrays.sort(array);
		if (array[0] <= 0) {
			System.out.println(0);
		} else {
			long res = 1l;
			double rate = MAX;
			boolean flag = false;
			for (int i = n - 1; i >= 0; --i) {
				if (array[i] >= rate) {
					flag = true;
				}
				res *= array[i];
				if (res > 0) {
					rate = MAX / res * 1.5;
				}
				if (res < 0 || res > MAX) {
					System.out.println(-1);
					return;
				}
			}
			
			if (res >= 0 && res <= MAX && !flag) {
				System.out.println(res);
			} else {
				System.out.println(-1);
			}
		}
	}
}


Measured memory_bytes: 61420
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = deque<bool>;
using pii = pair<int, int>;
using pll = pair < ll, ll>;


#define FOR(i,N) for(int i=0;i<N;i++)
#define FOR2(i, N) for(int i=1;i<=N;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define mt make_tuple
#define all(x) x.begin(), x.end() 


//cin.tie(nullptr);
//ios_base::sync_with_stdio(false);
//cout << fixed << setprecision(10);
//double pi = 3.141592653589793238;

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


int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	

	int N;
	cin >> N;
	vi a(N), b(N), c(N);
	FOR(i, N) { cin >> a[i]; }
	FOR(i, N) { cin >> b[i]; }
	FOR(i, N) { cin >> c[i]; }
	sort(all(a));
	sort(all(b));
	sort(all(c));

	vl b2(N), c2(N), acc(N + 1); ll ans = 0;
	FOR(i, N) {
		b2[i] = distance(a.begin(), lower_bound(all(a), b[i]));
		c2[i] = distance(b.begin(), lower_bound(all(b), c[i]));
	}
	FOR2(i, N) {
		acc[i] = acc[i - 1] + b2[i - 1];
	}

	FOR(i, N) {
		ans += acc[c2[i]];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3840
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		String A[]=new String[N];
		int B[]=new int[N];
		boolean key=false;
		int ans=0;
		for(int i=0;i<N;i++){
			A[i]=stdIn.next();
			B[i]=stdIn.nextInt();
		}
		String S=stdIn.next();
		for(int i=0;i<N;i++){
			if(key)
				ans+=B[i];
			if(S.equals(A[i]))
				key=true;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23124
IDENTIFICATION DIVISION.
PROGRAM-ID. A-WHITE.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP      PIC X(100).
01 IN-DATA.
   03 DT-X1 PIC X(10).
   03 DT-X2 PIC X(10).
01 IN-LEN.
   03 DT-L1 PIC 9(2).
   03 DT-L2 PIC 9(2).
01 IN-BH    PIC 9(2).
01 IN-BW    PIC 9(2).
01 IN-SH    PIC 9(2).
01 IN-SW    PIC 9(2).
01 OUT-WHT  PIC ZZ9.
 
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO DT-X1 COUNT IN DT-L1
           DT-X2 COUNT IN DT-L2.
  MOVE DT-X1(1:DT-L1) TO IN-BH.
  MOVE DT-X2(1:DT-L2) TO IN-BW.
 
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO DT-X1 COUNT IN DT-L1
           DT-X2 COUNT IN DT-L2.
  MOVE DT-X1(1:DT-L1) TO IN-SH.
  MOVE DT-X2(1:DT-L2) TO IN-SW.
 
  COMPUTE OUT-WHT = (IN-BH - IN-SH) * (IN-BW - IN-SW).  
 
  DISPLAY OUT-WHT.
 
MAIN-EXIT.
  STOP RUN.

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int a, b;
	scanf("%d%d", &a, &b);
	if (a < b)
		printf("a < b\n");
	if (a > b)
		printf("a > b\n");
	if (a == b)
		printf("a == b\n");

	return 0;
}

Measured memory_bytes: 1816
#include<iostream>

using namespace std;

int main()
{
	char s[11];
	char ans[11];
	for (size_t i = 0; i < 11; i++)
	{
		s[i] = ans[i] = '\0';
	}
	cin >> s;

	for (size_t i = 0, j = 0; s[i] != '\0'; i++)
	{
		if (s[i] == 'B')
		{
			if (j > 0)
				ans[--j] = '\0';
			continue;
		}

		ans[j++] = s[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)

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

    int d,t,s;
    cin >> d >> t >> s;
    if((s*t) >= d) cout << "Yes";
    else cout << "No";

    return 0;
  }

Measured memory_bytes: 3660
#include<stdio.h>
void swap(int *xp,int *yp);
int selectionsort(int a[],int n);
void printArray(int arr[], int size);
int main()
{
    int a[110];
    int  n,i,j,k;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    j=selectionsort(a,n);
    for(i=0;i<n;i++)
    {
        printf("%d",a[i]);
        if(i<n-1)
            printf(" ");

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


}
int selectionsort(int a[],int n)
{
    int l,p,q,min,c=0;
    for(l=0;l<n-1;l++)
    {   int flag=0;
        min=l;
        for(p=l+1;p<n;p++)
        {
        if(a[p]<a[min])
        {
            min=p;
            flag=1;
        }
        }
         if(flag==1)
            {
            swap(&a[min],&a[l]);
            c++;
            }
    }
    return c;

}
void swap(int *xp ,int *yp)
{
    int  temp=*xp;
    *xp=*yp;
    *yp=temp;
}

Measured memory_bytes: 1796
#include<stdio.h>
int main(void)
{
	double h,m;
	int cMA,cHA;
	int cMB,cHB;
	int cMC,cHC;
	int cMD,cHD;
	cMA=0;
	cHA=0;
	cMB=0;
	cHB=0;
	cMC=0;
	cHC=0;
	cMD=0;
	cHD=0;
		while(scanf("%lf %lf",&h,&m)!=EOF){
			if(h>=1.1){
				cHA++;
			}
			else if(0.6<=h){
				cHB++;
			}
			else if(0.2<=h){
				cHC++;
			}
			else{
				cHD++;
			}
			if(m>=1.1){
				cMA++;
			}
			else if(0.6<=m){
				cMB++;
			}
			else if(0.2<=m){
				cMC++;
			}
			else if(0.2>m){
				cMD++;
			}
		}
	printf("%d %d\n%d %d\n%d %d\n%d %d\n",cHA,cMA,cHB,cMB,cHC,cMC,cHD,cMD);
	return 0;
}

Measured memory_bytes: 1056
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
#define pi acos(-1.0)
int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int main()
{
	int a=read(),b=read(),x=read(),rev=0;
	if (x*2<a*a*b)
	{
		double l=0,r=90,ans=0.0;
		double t1=2.0*x,t2=1.0*a*b*b; 
		while (r-l>=1e-8)
		{
			double mid=(l+r)/2,now=mid*pi/180;
			//cout << mid << " " << now << endl;
			double tmp1=(db)t1*sin(now),tmp2=(db)t2*cos(now);
			//printf("%0.10lf %0.10lf\n",tmp1,tmp2);
			if (tmp1<tmp2) l=mid;else r=mid;
		}
		printf("%0.8lf",l);
	}
	else
	{
		x=a*a*b-x;
		double ang=2.0*x/a/a/a;
		double ans=atan2(2.0*x,1.0*a*a*a)*180/pi;
		printf("%0.8lf",ans);
	}
	return 0;
}


Measured memory_bytes: 256