akhauriyash/Code-Regression huggingface dataset:
N=int(input())
X=[[0]*19 for _ in range(19)]
def f(num, x):
  ans=0
  while num%x==0:
    ans+=1
    num//=x
  return min(ans, 18)

A=[[0, 0] for _ in range(N)]

for i in range(N):
  tmp=input()
  if tmp[0]=='0':
    tmp=tmp[2:]
    tmp=int(tmp+'0'*(9-len(tmp)))
    A[i][0]=f(tmp, 2)
    A[i][1]=f(tmp, 5)
    X[A[i][0]][A[i][1]]+=1
  elif tmp.count('.')>0:
    ten=tmp.index('.')
    tmp=tmp.replace('.', '')
    tmp=int(tmp+'0'*(9-(len(tmp)-ten)))
    A[i][0]=f(tmp, 2)
    A[i][1]=f(tmp, 5)
    X[A[i][0]][A[i][1]]+=1
  else:
    tmp=int(tmp+'0'*9)
    A[i][0]=f(tmp, 2)
    A[i][1]=f(tmp, 5)
    X[A[i][0]][A[i][1]]+=1
    
for i in range(0, 19):
  for j in range(17, -1, -1):
    X[i][j]+=X[i][j+1]

ans=0
for i in range(N):
  for j in range(18-A[i][0], 19):
    ans+=X[j][18-A[i][1]]
  if A[i][0]>=9 and A[i][1]>=9:
    ans-=1
  
print(ans//2)

Measured memory_bytes: 99264
# /user/bin/python
# -*- coding: utf-8 -*-
import sys 
from itertools import accumulate


def diff(p,q,r,s):
  return abs(max(p,q,r,s) - min(p,q,r,s))


## input
N = int(sys.stdin.readline().rstrip())
An = [0] + list(map(int, sys.stdin.readline().rstrip().split()))
sum = list(accumulate(An))


ans = sys.maxsize
li,ri = 1, 3
for i in range(2, N-1):
  while sum[li] < sum[i]-sum[li]:
    li += 1
  while sum[ri]-sum[i] < sum[N]-sum[ri]:
    ri += 1

  P1,Q1 = sum[li], sum[i]-sum[li]
  P2,Q2 = sum[li-1], sum[i]-sum[li-1]
  R1,S1 = sum[ri]-sum[i], sum[N]-sum[ri]
  R2,S2 = sum[ri-1]-sum[i], sum[N]-sum[ri-1]

  ans = min(ans, diff(P1,Q1,R1,S1), diff(P1,Q1,R2,S2), diff(P2,Q2,R1,S1), diff(P2,Q2,R2,S2))

print(ans)

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

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int[] edge = new int[3];
        for(int i = 0; i < 3; i++){
            edge[i] = scan.nextInt();
        }

        // sort
        Arrays.sort(edge);

        // answer
        System.out.println(edge[0] * edge[1] / 2);
        
        

    }
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    vector<int> x(n), y(n), per(n);
    rep(i, n) cin >> x[i];
    rep(i, n) cin >> y[i];

    rep(i, n) per[i] = i + 1;

    int s, t;
    int cnt = 0;
    do
    {
        cnt++;
        if (x == per)
            s = cnt;
        if (y == per)
        {
            t = cnt;
        }
    } while (next_permutation(all(per)));

    cout << abs(t - s) << endl;
    return (0);
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define MAXN 22
#define pii pair<int, int>
#define pb push_back
typedef long long ll;

using namespace std;

int n;
ll dp[22][(int)(1 << 22)], mod = 1e9 + 7;
bool a[MAXN][MAXN];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> n;
    for(int i = 0; i < n; i++){
    	for(int j = 0; j < n; j++){
    		cin >> a[i][j];
    	}
    }
    vector<int> v[22];
    for(int b = 0; b < (1 << n); b++){
    	int t = 0, x = b;
    	while(x){
    		t += x & 1;
    		x /= 2;
    	}
    	v[t].pb(b);
    }
    for(int i = 0; i < n; i++){
    	for(auto b : v[i + 1]){
    		for(int j = 0; j < n; j++){
    			if(((b >> j) & a[i][j]) == 0)
    				continue;
    			if(i == 0){
    				dp[i][b]++;
    				continue;
    			}
    			dp[i][b] += dp[i - 1][b ^ (1 << j)];
    			dp[i][b] %= mod;
    		}
    		if(i == 0 and dp[i][b] > 1)
    			dp[i][b] = 0;
    	}
    }
    cout << dp[n - 1][(1 << n) - 1];
}

Measured memory_bytes: 331196
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <set>

using namespace std;

int main()
{
    int n;
    bool ok=true;
    set<string> S;
    cin>>n;
    string w[200];
    for (int i=1; i<=n; i++)
    {
        cin>>w[i];
        if (i!=1)
        {
            if (S.count(w[i]) || w[i-1][w[i-1].size()-1]!=w[i][0]) ok=false;
        }
        S.insert(w[i]);
    }
    if (ok) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


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

void solve(long long N, std::string S) {
    char before = S[0];
    ll ans = 1;
    for (ll i = 1; i < N; i++) {
        if (S[i] != before) {
            ans++;
        }
        before = S[i];
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 3884
#include <algorithm>
#include <cstdio>
const int MAXN = 1e6+5;
char S[MAXN];
int N;

int sgn(int x) { return (x > 0) - (x < 0); }

struct Data {
  int dep, lvl;
  
  bool operator < (const Data& o) const {
    int dl = sgn(lvl);
    int dr = sgn(o.lvl);
    // +1 -> 0 -> -1
    if (dl != dr) return (dl > dr);
    // (dl == dr)
    if (dl >= 0) return (dep < o.dep);
    // (dl == -1)
    int suml = dep + lvl;
    int sumr = o.dep + o.lvl;
    if (suml != sumr) {
      return (suml > sumr);
    }
    // (suml == sumr)
    return (dep > o.dep);
  }
};
Data A[MAXN];

bool solve() {
  int lvl = 0;
  for (int i = 0; i < N; ++i) {
    if (lvl < A[i].dep) return false;
    lvl += A[i].lvl;
    if (lvl < 0) return false;
  }
  return (lvl == 0);
}

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf(" %s", S);
    int dep = 0;
    int lvl = 0;
    for (char *ptr = S; *ptr; ++ptr) {
      if (*ptr == '(') {
        ++lvl;
      } else {
        --lvl;
      }
      dep = std::min(lvl, dep);
    }
    A[i].dep = -dep;
    A[i].lvl = lvl;
  }
  std::sort(A, A+N);
  puts(solve() ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 10920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl

int main() {
    IN(int, n);
    long double m = 0;
    REP(i, n){
        long double k;
        cin >> k;
        m += 1/k;
    }
    DCOUT(1/m, 15);
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int H[101];
  for (int i = 0; i < N; i++)
    cin >> H[i];

  int C = 1;
  for (int i = 1; i < N; i++) {
    bool canView = true;
    for (int j = 0; j < i; j++) {
      if (H[j] > H[i]) {
        canView = false;
        break;
      }
    }
    if (canView)
      C++;
  }

  cout << C << endl;

  return 0;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			1'010'000'000'000'000'017LL
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )

using namespace std;

template<class T>
bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>
bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}


void Main()
{
	ll N;
	cin >> N;
	vs S(N, "");
	rep(i, 0, N)
	{
		cin >> S[i];
	}

	map<string, int> res;
	res["AC"] = 0;
	res["WA"] = 0;
	res["TLE"] = 0;
	res["RE"] = 0;
	rep(i, 0, N)
	{
		res[S[i]] ++;
	}

	cout << "AC x " << res["AC"] << endl;
	cout << "WA x " << res["WA"] << endl;
	cout << "TLE x " << res["TLE"] << endl;
	cout << "RE x " << res["RE"] << endl;
}

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

	Main();
	return 0;
}

Measured memory_bytes: 6348
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	int i, n, s=0, m=0, a[25];
	cin >> n;
	for (i=0; i<n; i++)
	{
		cin >> a[i];
		if (a[i]>=m)
		{
			m=a[i];
			s++;
		}
	}
	cout << s << endl;
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  if(s=="SAT"){
    cout << 1 << endl;
  }else if(s=="FRI"){
    cout << 2 << endl;
  }else if(s=="THU"){
    cout << 3 << endl;
  }else if(s=="WED"){
    cout << 4 << endl;
  }else if(s=="TUE"){
    cout << 5 << endl;
  }else if(s=="MON"){
    cout << 6 << endl;
  }else{
    cout << 7 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

ll ni(ll a,ll b,ll c){
    if(b==0) return 1;
    else if(b%2==0) return ((ni(a,b/2,c)%c)*(ni(a,b/2,c)%c))%c;
    else return ni(a,b-1,c)*a;
}

int main(){
    int n; cin >> n;
    string s; cin >> s;
    ll one=0;
    rep(i,n){
        if(s[i]=='1') one++;
    }
    vector<ll> amari0(n,0);
    vector<ll> amari1(n,0);
    amari0[n-1]=1%(one+1);
    if(one>1) amari1[n-1]=1%(one-1);

    rep(i,n-1){
        amari0[n-i-2]=(amari0[n-1]*ni(2,i+1,one+1))%(one+1);
        if(one>1) amari1[n-i-2]=(amari1[n-1]*ni(2,i+1,one-1))%(one-1);
    }

    ll fund0,fund1;
    fund0=fund1=0;
    if(one==0){
        rep(i,n) cout << 1 << endl;
        return 0;
    }
    if(one==1){
        rep(i,n){
            if(s[i]=='1'){
                cout << 0 << endl;
                continue;
            }
            else{
                if(s[n-1]=='1' || i==n-1) cout << 2 << endl;
                else cout << 1 << endl;
            }
        }
        return 0;
    }
    rep(i,n){
        if(s[i]=='1'){
            fund0+=amari0[i];
            fund1+=amari1[i];
        }
    }
    rep(i,n){
        ll tone;
        ll tmp=0;
        ll fund00=fund0;
        ll fund11=fund1;
        if(s[i]=='0'){
            fund00+=amari0[i];
            fund00%=(one+1);
            while(fund00){
                tmp++;
                ll now=fund00;
                tone=0;
                while(now){
                    if(now%2==1) tone++;
                    now/=2; 
                }
                fund00%=tone;
            }
        }
        else{
            fund11-=amari1[i];
            fund11%=(one-1);
            while(fund11){
                tmp++;
                ll now=fund11;
                tone=0;
                while(now){
                    if(now%2==1) tone++;
                    now/=2; 
                }
                fund11%=tone;
            }
        }
        cout << tmp+1 << endl;;
    }

    return 0;
}


Measured memory_bytes: 6768
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,L;
    cin >> N >> L;
    vector<string>S(N);
    for(int i = 0; i < N; i++) {
        cin >> S[i];
    }
    sort(S.begin(),S.end());
    string ans;
    for(int i = 0; i < N; i++) {
        ans += S[i];
    }
    cout << ans << endl;
}


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

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

    int first = s.size();
    int last = 0;
    rep(i, s.size()) {
        if (s.at(i) == 'A') first = min(first, i);
        if (s.at(i) == 'Z') last = max(last, i);
    }

    cout << last - first + 1 << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstring>
using namespace std;

string a,b="CF"; //打表
int al,bl;

int main(){
    getline(cin,a);
    al=a.length();
    for(int i=0;i<al;i++)
        if(a[i]==b[bl]){ //当找到一个的时候加一
            bl++;
            if(bl==2)   //都找到的时候就退出
                break;
        }
    if(bl==2) cout<<"Yes"; //判断并且输出
    else cout<<"No";
    cout<<endl;
    return 0;
}

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

void main() {
    auto N = readln.chomp.to!int;
    auto A = N.iota.map!(_ => readln.split.map!(to!long).array).array;

    bool ok = true;
    auto unused = new int[][](N, N);

    foreach (i; 0..N)
        foreach (j; 0..N)
            foreach (k; 0..N)
                if (A[j][k] > A[j][i] + A[i][k])
                    ok = false;
                else if (i != j && i != k && A[j][k] == A[j][i] + A[i][k])
                    unused[j][k] = true;

    if (!ok) {
        writeln(-1);
    } else {
        long ans = 0;
        foreach (i; 0..N)
            foreach (j; i+1..N)
                if (!unused[i][j])
                    ans += A[i][j];
        ans.writeln;
    }
}


Measured memory_bytes: 5372
import { readFileSync } from 'fs'
const input: string = readFileSync("/dev/stdin", "utf8")
export function sum(input: string) {
  const K = parseInt(input.split(' ')[0]) // 最大数
  const S = parseInt(input.split(' ')[1]) // 合計数
  let count = 0
  for (let x = 0; x <= K; x++) {
    for (let y = 0; y <= K; y++) {
      const z = S - x - y
      if (z >= 0 && z <= K) {
        count++
      }
    }
  }
  console.log(count)
}

sum(input)


Measured memory_bytes: 7372
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long c;
int l;
int A[1000000];
int n;
vector<int>G;

void insert(int A[],int n,int g){
for(int i=g;i<n;i++){
int v=A[i];
int j=i-g;
while(j>=0 && A[j]>v){
A[j+g]=A[j];
j-=g;
c++;
}
A[j+g]=v;
}
}

void shell(int A[],int n){
for(int h=1; ;){
if(h>n)break;
G.push_back(h);
h=3*h+1;
}

for(int i=G.size()-1;i>=0;i--){
insert(A,n,G[i]);
}
}

int main(){
cin>>n;

for(int i=0;i<n;i++)scanf("%d",&A[i]);
c=0;

shell(A,n);

cout<<G.size()<<endl;
for(int i=G.size()-1;i>=0;i--){
printf("%d",G[i]);
if(i)printf(" ");
}
printf("\n");
printf("%d\n",c);
for(int i=0;i<n;i++)printf("%d\n",A[i]);

return 0;
}

Measured memory_bytes: 7200
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
l = inp.shift().split(' ')
M1 = l[0] * 1
D1 = l[1] * 1 
l = inp.shift().split(' ')
M2 = l[0] * 1
D2 = l[1] * 1 
if (M1 < M2) {
    console.log(1)
} else {
    console.log(0)
}


Measured memory_bytes: 22080
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define INF 10000000000

ll a, b, c, n, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s;

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

    cin >> h >> w;
    char panel[h][w];
    ll vector_x[] = {0, 1, 0, -1}, vector_y[] = {-1, 0, 1, 0};
    rep(i, h){
        rep(j, w){
            cin >> panel[i][j];
        }
    }
    rep(i, h){
        rep(j, w){
            if(panel[i][j] == '#'){
                ll flag = 1;
                rep(k, 4){
                    if(panel[i + vector_y[k]][j + vector_x[k]] == '#'){
                        flag = 0;
                        break;
                    }
                }
                if(flag){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
}



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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> Point;
typedef vector<vector<int>> Graph;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    ll n;
    cin >> n;
    vector<P> area(n);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        ll from = max(0LL, a - b);
        ll to = min((ll)INF, a + b);
        area[i] = P(to, from);
    }
    int ans = 0;
    sort(all(area));
    // // how to use priority_queue on pair
    // auto comPair = [](const P &firstElof, const P &secondElof) {
    //     if (firstElof.second != secondElof.second)
    //         return firstElof.second < secondElof.second;
    //     else
    //         return firstElof.first > secondElof.first;
    // };
    // priority_queue<P, vector<P>, decltype(comPair)> que(comPair);
    ll t = 0;
    rep(i, n) {
        if (t <= area[i].second) {
            ans++;
            t = area[i].first;
        }
    }
    out(ans);
    return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5 6
0 1
1 0
1 2
2 4
4 3
3 2
4
0 1
0 3
2 3
3 4

output:
1
0
1
1
"""

import sys
from math import isinf

sys.setrecursionlimit(int(1e5))


def generate_adj_table(_v_info):
    for v_detail in _v_info:
        v_from, v_to = map(int, v_detail)
        init_adj_table[v_from].append(v_to)
    return init_adj_table


def Tarjan(current, low, dfn, scc_stack, in_scc_stack):
    global timer
    dfn[current] = low[current] = timer
    timer += 1

    scc_stack.append(current)
    in_scc_stack[current] = True

    current_scc_set = set()
    for adj in adj_table[current]:
        if isinf(low[adj]):
            Tarjan(adj, low, dfn, scc_stack, in_scc_stack)
            low[current] = min(low[current], low[adj])

        elif in_scc_stack[adj]:
            low[current] = min(low[current], dfn[adj])

    scc_candidate = -1
    if dfn[current] == low[current]:
        while scc_candidate != current:
            scc_candidate = scc_stack.pop()
            in_scc_stack[scc_candidate] = False
            current_scc_set.add(scc_candidate)

        init_scc_sets_list.append(current_scc_set)

    return None


def scc_cluster():
    dfn = [float('inf')] * vertices
    low = [float('inf')] * vertices
    scc_stack = list()
    in_scc_stack = [False] * vertices

    for v in range(vertices):
        if isinf(low[v]):
            Tarjan(v, low, dfn, scc_stack, in_scc_stack)

    return init_scc_sets_list


def solve(_scc_sets_list):
    for question in q_list:
        flag = False
        ele1, ele2 = map(int, question)
        for each in _scc_sets_list:
            if (ele1 in each) and (ele2 in each):
                flag = True
                break
        if flag:
            print('1')
        else:
            print('0')

    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:edges + 1])
    q_num = int(_input[edges + 1])
    q_list = map(lambda x: x.split(), _input[edges + 2:])

    init_adj_table = tuple([] for _ in range(vertices))
    adj_table = generate_adj_table(v_info)

    timer = 0
    init_scc_sets_list = []
    scc_sets_list = scc_cluster()

    solve(scc_sets_list)

Measured memory_bytes: 26476
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
#define vl vector<ll>
#define vi vector<int>
 
#define ff first
#define ss second
 
#define pb push_back
#define MOD 1000000007
//const int nax = 1e6+5;
#define inf 4e18
 
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "
#define all(v) v.begin(),v.end()
ll sqr(ll x){return x*x;}
inline ll add(ll a, ll b){ ll c = a + b; if(c >= MOD) c -= MOD; return c; }
inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
const int nax = 1000*1000 + 10;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  int x,y; cin>>x>>y;
  int mx = 4*x,mn = 2*x;
  if( y < mn || y > mx)cout << "No";
  else {
      if((4*x - y)%2 == 0)cout << "Yes";
      else cout << "No";
  }
   
    return 0;
}
    

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;

int main(void){
    int h,n;
    cin >> h >> n;
    vector<int> a(n);
    int sum=0;
    rep(i,n) {
        cin >> a.at(i);
        sum += a.at(i);
    }
    if (h <= sum) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 640
A, B, C, D = map(int, input().split())

if A >= C:
  if A >= D:
    print(0)
  else:
    if B >= D:
      print(D-A)
    else:
      print(B-A)
else:
  if C >= B:
    print(0)
  else:
    if D >= B:
      print(B-C)
    else:
      print(D-C)

Measured memory_bytes: 3060
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

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

fn main(){
    let line = read_as_vec::<usize>();
    let (n, m, x) = (line[0], line[1], line[2]);
    let mut a: Vec<usize> = read_as_vec();

    println!("{}", cmp::min(
        a.iter().filter(|pos| **pos < x).count(),
        a.iter().filter(|pos| **pos > x).count()
    ));
}


Measured memory_bytes: 4352
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        public class lower_bound<T> : IComparer<T> where T : IComparable<T>
        {
            public int Compare(T x, T y) => 0 <= x.CompareTo(y) ? 1 : -1;
        }
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });

            var N = Sarray()[0];
            var Ai = Sarray();
            var A = new long[N];
            for (var i = 0; i < N; ++i)
                ++A[Ai[i] - 1];
            Array.Sort(A);
            var S = new long[N + 1];

            var lb = new lower_bound<long>();
            Func<long, long, bool> ok = (cok, kok) =>
            {
                long i = ~Array.BinarySearch(A, cok, lb);
                long sum = cok * (N - i) + S[i];
                return cok * kok <= sum;
            };
            for (var i = 0; i < N; ++i) S[i + 1] = S[i] + A[i];
            for (var k = 1; k <= N; ++k)
            {
                long l = 0, r = N / k + 1;//l:ok, r:ng
                while(l+1<r)
                {
                    var c = (l + r) / 2;
                    if (ok(c,k)) l = c;
                    else r = c;
                }
                WriteLine(l);
            }
            Out.Flush();
        }
    }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    ll N, T;
    cin >> N >> T;
    ll t[N];
    REP(i, N) cin >> t[i];
    ll res = 0;
    REP(i, N-1){
        res += min(t[i+1]-t[i], T);
    }
    res += T;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
import math
N=int(input())
x=[0]*N
y=[0]*N
for i in range(N):
  x[i],y[i]=map(int,input().split())

res=0
for i in range(N):
    for j in range(N):
        if i<j:
            res+=math.sqrt((x[i]-x[j])**2 + (y[i]-y[j])**2)
res/=N
print(2*res)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>

using namespace std;

void print_func(int *array, int size){
    for (int j = 0; j < size; ++j) {
        cout << ( j ? " " : "" ) << array[j];
    }
    cout << endl;
}

int insertionSort(int *A, int n, int g) {
    int v, cnt=0;
    for (int i = g; i < n; i++) {
        v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j + g] = v;
    }

    return cnt;
}

int get_m(int n){
    int h = 1;
    int res = 0;
    while (h <= n){
        h = 3 * h + 1;
        res++;
    }

    return res;
}

void shellSort(int *A, int n) {
    int m = min(get_m(n), 100);

    int G[m];
    int h = 1;
    for (int i = m - 1; i >= 0 ; i--) {
        G[i] = h;
        h = 3*h + 1;
    }

    int cnt = 0;
    for (int i = 0; i < m; i++) {
        cnt += insertionSort(A, n, G[i]);
    }

    cout << m << endl;
    print_func(G, m);
    cout << cnt << endl;

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

}

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

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

    shellSort(A, N);

}

Measured memory_bytes: 7004
#include <stdio.h>
#include <string.h>

int main() {
	char S[200001], T[200001];
	int i,count=0;
	scanf("%s", S);
	scanf("%s", T);
	for (i = 0; i < strlen(S); i++) {
		if (S[i] != T[i]) {
			count = count + 1;
		}
	}
	
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
int n,m,A;
vector<int> e[111111];
int col[111111];
long long int c2(long long int x){
	return x*(x-1)/2;
}
bool dfs(int x,int c){
	if(col[x] == 0){
		col[x] = c;
		if(c==1)A++;
	}else
	return col[x] == c;
	for(int y : e[x]){
		if(!dfs(y, -c))
			return false;
	}
	return true;
}
long long int calc(){
	if(dfs(1,1))
		return (long long int)A*(n-A);
	return c2(n);
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0; i<m; i++){
		int x,y;
		scanf("%d%d",&x,&y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	printf("%lld\n",calc()-m);
	return 0;
}


Measured memory_bytes: 6656
N = int(input())
edge = [set() for i in range(N)]
for i in range(N-1): #辺の情報と距離を記録
  u, v, w = map(int, input().split())
  edge[u-1].add((v-1, w))
  edge[v-1].add((u-1, w))

#幅優先検索
dist = [0] * N #距離
stack = [(0,-1)] #vrt, from
while stack: #stackが空になるまで
  vrt, _from = stack.pop()
  for _to, w in edge[vrt].copy():
    if _to == _from:
      continue
    stack.append((_to, vrt))
    dist[_to] = dist[vrt] + w
    
for i in range(N):
  print(dist[i]%2)


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

int returnGood (string gi, int start) {
  char c = gi[start];
  int i;

  for (i = start ; i < (int)(gi.size ()) ; i++) {
    if (c == gi[i]) {
      continue;
    } else 
      break;
  }

  if (i - start > 2) {
    cout << "Yes" << endl;
    return 0;
  } else {
    return 1;
  }

}

int main() {

  string GoodInteger; 
  cin >> GoodInteger;

  if (returnGood (GoodInteger, 0)) {
    if (returnGood (GoodInteger, 1)) {
      cout << "No" << endl;
    }
  }

}



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

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

  int ans = 1;
  REP(i, N) {
    int a = ans * 2;
    int b = ans + K;
    ans = min(a, b);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
int main(){
  int k,x;
  cin>>k>>x;
  for(int i=x-(k-1);i<=x+(k-1);i++){
    if(i<=1000000 && i>=-1000000){
     cout<<i<<" ";
    }
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
int dx[4]={0,0,-1,1},dy[4]={1,-1,0,0};


int n,a[200010],b[500000];
int main(int argc, char const *argv[]) {
  std::cin >> n;
  for(int i=0; i<n; i++) std::cin >> a[i];
  int l=200010,r=l+1;
  for(int i=0; i<n; i++){
    if(i%2==(n-1)%2) b[l--]=a[i];
    else b[r++]=a[i];
  }
  for(int i=l+1; i<r; i++)std::cout << b[i] << ' ';
  std::cout  << '\n';
  return 0;
}


Measured memory_bytes: 3712
N=int(input())
S=[input() for _ in range(2) ]
dp=[0]*(N+1)
dp[0]=1
mod=10**9+7
i=0
st=0
while i<N:
  if S[0][i]==S[1][i] and st==0:
    dp[i+1]=dp[i]*3
    st=1
  elif S[0][i]==S[1][i] and st==1:
    dp[i+1]=dp[i]*2%mod
  elif S[0][i]==S[1][i] and st==2:
    dp[i+1]=dp[i]
    st=1
  elif S[0][i]!=S[1][i] and st==0:
    dp[i+2]=dp[i]*6
    st=2
  elif S[0][i]!=S[1][i] and st==1:
    dp[i+2]=dp[i]*2%mod
    st=2
  elif S[0][i]!=S[1][i] and st==2:
    dp[i+2]=dp[i]*3%mod
  if S[0][i]==S[1][i]:
    i+=1
  else:
    i+=2
print(dp[N]%mod)

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();		
		int[] arr = r.ria();
		if(arr[2] < arr[0]) {
			swap(arr, 0, 2);
			swap(arr, 1, 3);
		}
		if(arr[2] >= arr[1])
			print(0);
		else
			print(Math.min(arr[1], arr[3])-arr[2]);
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static void swap(int[] arr, int pos1, int pos2) {
		int temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	public static void swap(long[] arr, int pos1, int pos2) {
		long temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}


Measured memory_bytes: 20948
size = input().split()
a_list = [[0 for m in range(int(size[1]))] for n in range(int(size[0]))]
b_list = [[0] for m in range(int(size[1]))]

for n in range(int(size[0])):
    data = input().split()
    for m in range(int(size[1])):
        a_list[n][m] = int(data[m])

for i in range(int(size[1])):
    b_list[i][0] = int(input())

for n in range(int(size[0])):
    c = 0
    for m in range(int(size[1])):
        c += a_list[n][m] * b_list[m][0]
    print(c)



Measured memory_bytes: 5964
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'
const int INF = 1000000000000000001;
const long double E = 0.00000001;

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int q = 0; q < s.size(); q++){
        ans += (s[q] != t[q]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3800
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <tuple>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

using T = tuple<ll,ll>;
using Graph = vector<vector<T>>;

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

    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);

    rep(i,0,n)
        cin >> a[i];

    ll accm = 0;
    rep(i,0,n)
        accm += a[i];

    //cout << accm << " " << m << endl;

    ll cnt(0);
    rep(i,0,n)
        if (a[i] >= accm/(4.0*m))
            ++cnt;

    //cout << cnt << endl;

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

    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		Set<Integer> s = new HashSet<Integer>();
		while (n-- > 0)
			s.add(sc.nextInt());

		System.out.println(s.size());

	}

}


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

using namespace std;
#define  F first
#define  S second
#define  pii pair<int,int>
const int MAX = 1e6+6;

int n;

int main() {

    set<char> s;
    char ss;
    for(int i = 0;i<4;i++)
    {
        cin>>ss;
        s.insert(ss);
    }
    cout<<(s.size()==2?"Yes":"No");

}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 998244353;
const int N = 5000010;
ll fact[N], invf[N];

ll add(ll x, ll y){
    return (x+y)%mod;
}

ll mul(ll x, ll y){
    return (x%mod)*(y%mod)%mod;
}

ll powll(ll x, ll y){
    x %= mod;
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    x %= mod;
    return (x * powll(y,mod-2)) % mod;
}

ll nPr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(fact[n], invf[n-r]);
}

ll nCr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(mul(fact[n], invf[r]), invf[n-r]);
}

void init_f(){
    fact[0] = 1;
    FOR(i,1,N-1){
        fact[i] = (fact[i-1] * i) % mod;
    }
    invf[N-1] = divll(1, fact[N-1]);
    FORR(i,N-1,1){
        invf[i-1] = (invf[i] * i) % mod;
    }
}

int main() {
    ll n;
    cin >> n;
    ll m = n / 2, all = 1;
    REP(i,n) all = (all * 3) % mod;

    init_f();

    VL two(m + 1);
    two[0] = 1;
    REP(i,m) two[i + 1] = (2 * two[i]) % mod;

    VL cnt(m + 1);
    for (ll x = 0; x <= m; x++){
        cnt[x] = (nCr(m, x) * two[m - x]) % mod;
    }
    VL sum(m + 1);
    sum[m] = cnt[m];
    FORR(i,m-1,0) sum[i] = (cnt[i] + sum[i + 1]) % mod;

    // FOR(i,0,m) cout << cnt[i] << " ";
    // cout << endl;
    // FOR(i,0,m) cout << sum[i] << " ";
    // cout << endl;
    ll bad = 0;
    FOR(x,1,m){
        ll y = m + 1 - x;
        (bad += cnt[x] * sum[y]) %= mod;
        // cout << cnt[x] * sum[y] << endl;
    }
    bad = (2 * bad) % mod;

    ll ans = (all - bad + mod) % mod;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 195584
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;

int n, q, chk[200005];

int main(){
	scanf("%d",&n);
	int pos = 0;
	while(n--){
		int x, y;
		scanf("%d %d",&x,&y);
		pos += x;
		pos %= 86400;
		chk[pos]++;
		pos += y;
	}
	for(int i=0; i<86400; i++) chk[i+86400] = chk[i];
	for(int i=1; i<200000; i++) chk[i] += chk[i-1];
	int ans = 0;
	for(int i=0; i<86400; i++) ans = max(ans, chk[i + 10801] - chk[i]);
	cout << ans << endl;
}


Measured memory_bytes: 1024
//g++ -std=c++17 -Wall t.cpp -o test -g -O2
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl '\n'
#define teto(a, b) (a+b-1)/(b)
 
const int MAX = 1000010;
const ll MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-6;
const ld PI = acos(-1.0);

using namespace std;

// End - Template //

int num[1000]={0};
int mat[3][3];
int main()
{sws;
    
    int n, a;
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
            cin >> mat[i][j];
        
    cin >> n;
    while(n--){
        cin >> a;
        num[a]=1;
    }

    bool t=false;

    for(int i=0;i<3;i++){
        int sum=0;
        for(int j=0;j<3;j++)
            sum+=num[mat[i][j]];
        if(sum==3)
            t=true;
    }
    for(int i=0;i<3;i++){
        int sum=0;
        for(int j=0;j<3;j++)
            sum+=num[mat[j][i]];
        if(sum==3)
            t=true;
    }

    if(num[mat[0][0]]+num[mat[1][1]]+num[mat[2][2]]==3)
        t=true;
    if(num[mat[0][2]]+num[mat[1][1]]+num[mat[2][0]]==3)
        t=true;

    if(t)
        cout << "Yes\n";
    else
        cout << "No\n";
    
    return 0;
}

Measured memory_bytes: 3636
def sum_of_list(A):
    sum = 0
    for i in A:
        sum += int(i)
    return sum

def load_number(A, p, k):
    capacity = p
    num = 0
    for i in A:
        if capacity < int(i):
            break
        elif p >= int(i) and k > 0:
            num += 1
            p -= int(i)
        elif p < int(i) and k > 1:
            num += 1
            k -= 1
            p = capacity
            p -= int(i)
        elif k == 0:
            break
    return num

def search_load_capacity(A, n, k):
    total_weight = sum_of_list(A)
    left = 0
    right = total_weight + 1
    while left < right:
        mid = int((left + right) / 2)
        if load_number(A, mid, k) >= n:
            if load_number(A, mid-1, k) < n:
                return mid
            else:
                right = mid
        else:
            left = mid + 1

n, k = (map(int,input().split()))
A = [input() for x in range(n)]
print(search_load_capacity(A, n, k))


Measured memory_bytes: 11916
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

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

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

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

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

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



int main() {

  ll N;
  cin>>N;
  ll cnt=0;
  if(N%2==0){
    FOR(i,1,N){
      FOR(j,i,N){
        if(i!=j){
          if(j!=(N+1-i)){
            cnt++;
            //cout<<i<<" "<<j<<endl;
          }
        }
      }
    }
  cout<<cnt<<endl;
    FOR(i,1,N){
      FOR(j,i,N){
        if(i!=j){
          if(j!=(N+1-i)){
            cnt++;
            cout<<i<<" "<<j<<endl;
          }
        }
      }
    }
  }else{
    FOR(i,1,N){
      FOR(j,i,N){
        if(i!=j){
          if(j!=(N-i)){
            cnt++;
            //cout<<i<<" "<<j<<endl;
          }
        }
      }
    }
  cout<<cnt<<endl;
    FOR(i,1,N){
      FOR(j,i,N){
        if(i!=j){
          if(j!=(N-i)){
            //cnt++;
            cout<<i<<" "<<j<<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);

		long N = sc.nextLong();
		long M = sc.nextLong();

		if (N == 1) {
			if (M == 1) {
				System.out.println(1);
			} else if (M == 2) {
				System.out.println(0);
			} else {
				System.out.println(M - 2);
			}
		} else if (N == 2) {
			System.out.println(0);
		} else {
			if (M == 1) {
				System.out.println(N - 2);
			} else if (M == 2) {
				System.out.println(0);
			} else {
				System.out.println((M - 2) * (N - 2));
			}
		}
	}
}


Measured memory_bytes: 21716
use std::io::*;
use std::str::FromStr;

type NodeId = usize;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn reconstruction(
    l: NodeId,
    r: NodeId,
    preorder: &Vec<NodeId>,
    inorder: &Vec<NodeId>,
    postorder: &mut Vec<NodeId>,
    position: &mut isize,
) {
    if l >= r {
        return;
    }
    *position += 1;
    let root: NodeId = preorder[*position as usize];
    let m: NodeId = inorder.iter().position(|&x| x == root).unwrap();
    reconstruction(l, m, preorder, inorder, postorder, position);
    reconstruction(m + 1, r, preorder, inorder, postorder, position);
    postorder.push(root);
}

fn main() {
    let n: usize = read();

    let preorder: Vec<NodeId> = (0..n)
        .map(|_| {
            let number: NodeId = read();
            return number - 1;
        })
        .collect();
    let inorder: Vec<NodeId> = (0..n)
        .map(|_| {
            let number: NodeId = read();
            return number - 1;
        })
        .collect();

    let mut postorder: Vec<NodeId> = vec![];

    let mut position: isize = -1;

    reconstruction(0, n, &preorder, &inorder, &mut postorder, &mut position);

    for (index, number) in postorder.iter().enumerate() {
        if index != n - 1 {
            print!("{} ", number + 1);
        } else {
            println!("{}", number + 1);
        }
    }
}



Measured memory_bytes: 5036
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void _main() {
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(A, B) << " " << max(0, (A + B - N)) << "\n";
}

Measured memory_bytes: 256