akhauriyash/Code-Regression huggingface dataset:
from collections import deque

h,w=map(int, input().split())
S = [input() for _ in range(h)]

move=((1,0),(-1,0),(0,1),(0,-1))

def bfs(i,j): # 幅優先探索、マス i,j から始まる時の最長経路
    if S[i][j] == '#': # そのマスが壁ならスタート地点にならないのでパス
        return 0
    
    visited=[[0]*w for _ in range(h)] # 探索済のリスト
    visited[i][j]=1 # 最初のマスは探索済へ
    
    que=deque([(i,j,0)]) # キューの作成（queueは待ち行列）
    
    while len(que)>0:
        ci,cj,d = que.popleft() #キューの左側から取り出してキューから削除

        for mi,mj in move: #moveで定義したそれぞれの動きについて
            ni,nj = ci+mi,cj+mj # 移動先の座標をni,njとしている。
            if 0 <= ni < h and 0 <= nj < w and visited[ni][nj]==0:
                if S[ni][nj] == '.':
                    visited[ni][nj] = 1
                    que.append((ni, nj, d+1))
    return d
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, bfs(i, j))
print(ans)

Measured memory_bytes: 44784
#include<iostream>

using namespace std;

void trace(int matrix[], int N){
  for(int i=0;i<N;i++){
    if(i>0){
      cout << " ";
    }
    cout << matrix[i];
  }
  cout << endl;
}


void bubbleSort(int matrix[], int N){
  
  int temp=0;
  int cnt=0;

  for(int i=0;i<N;i++){
    for(int j=N-1;j>i;j--){
      if(matrix[j-1] > matrix[j]){
        temp = matrix[j];
        matrix[j] = matrix[j-1];
        matrix[j-1] = temp;
        cnt = cnt + 1;
      }else{
      }
    }
  }

  trace(matrix, N);
  cout << cnt << endl;

}

int main(void){
  
  int N_tot;
  cin >> N_tot;

  int* matrix = new int [N_tot];
  for(int i=0;i<N_tot;i++){
    cin >> matrix[i];
  }

  bubbleSort(matrix, N_tot);

  delete [] matrix;
  
  return 0;

}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<long long>
#define sz(x) (int)x.size()
#define pi pair<long long, long long>
#define endl '\n'
#define _ << ' '
#define FAST_LOG2(x) (sizeof(unsigned long)*8 - 1 - __builtin_clzl((unsigned long)(x)))
#define clog2(x) (((x) - (1 << FAST_LOG2(x))) ? FAST_LOG2(x) + 1 : FAST_LOG2(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> idxset;
//find_by_order(i) : iterator to the value at index i, order_of_key(x) : the index of value x
const ll mod = 998244353;
const ll INF = (ll)1e18+1;
const ll N = 1e5;

int a[3][3];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("B.txt", "r", stdin);
    #endif
    for(int i=0; i<3; i++)
        for(int j=0; j<3; j++)
            cin >> a[i][j];
    for(int i=0; i<2; i++)
    {
        int c = a[i][0] - a[i+1][0];
        for(int j=1; j<3; j++)
        {
            if(a[i][j] - a[i+1][j] != c)
            {
                puts("No");
                return 0;
            }
        }
    }
    for(int j=0; j<2; j++)
    {
        int c = a[0][j] - a[0][j+1];
        for(int i=1; i<3; i++)
        {
            if(a[i][j] - a[i][j+1] != c)
            {
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    int n,m,x;
    cin >> n >> m >>x;
    vector<int> vec;
    int left =0;
    int right =0;
    for(int i=0; i<m; i++){
        int a;
        cin >> a;
        vec.push_back(a);
        if(a<x){
            left++;
        }else{
            right++;
        }
    }
    if(right>left){
        cout << left <<endl;
    }else{
        cout << right <<endl;
    }
    
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
	#define int long long
	int n;
	cin >> n;
	map <string , int> mp;
	for(int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		int freq[26] = {0};
		for(int i = 0; i < (int)s.size(); i++)
		{
			freq[s[i]-'a']++;
		}
		string x;
		for(int i = 0; i < 26; i++)
		{
			if(freq[i] == 10)
			x += 'o';
			else
			x += (freq[i]-'a');
		}
		mp[x]++;
	}
	int ans = 0;
	for(auto const &s : mp)
    {
    	int l = s.second;
    	ans += (l*(l-1))/2;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> A(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A.at(i).at(j);
    }
  }
  vector<bool> all_period_row(H, true);
  vector<bool> all_period_col(W, true);
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++){
      if (A.at(i).at(j) == '#'){
        all_period_row.at(i) = false;
        all_period_col.at(j) = false;
      }
    }
  }
    
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++){
      if (!all_period_row.at(i) && !all_period_col.at(j)){
        cout << A.at(i).at(j);
      }
      if (!all_period_row.at(i)){
        if (j == W-1) cout << endl;
      }
    }
  }
    
          
  
}

Measured memory_bytes: 3580
/******************
*  Author: BD747  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;

#define MP make_pair

int n,m;
int a[200005];
bool v[200005];
vector<pair<int,int> > g[200005];
int mx,mn;

void dfs(int x){
	mn=min(a[x],mn);
	mx=max(a[x],mx);
	for(int i=0;i<g[x].size();i++){
		int y=g[x][i].first;
		if(v[y]){
			if(a[y]!=a[x]+g[x][i].second){
				cout<<"No";
				exit(0);
			}
		}else{
			v[y]=1;
			a[y]=a[x]+g[x][i].second;
			dfs(y);
		}
	}
}

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y,d;
		cin>>x>>y>>d;
		g[x].push_back(MP(y,d));
		g[y].push_back(MP(x,-d));  
	}
	for(int i=1;i<=n;i++){
		if(v[i])continue;
		mx=-1e9,mn=1e9;
		v[i]=1;
		a[i]=0;
		dfs(i);
		if(mx-mn>1e9){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}


Measured memory_bytes: 14464
n,m=map(int,input().split())
arr=[]
for _ in range(m):
  a,b=map(int,input().split())
  tl=list(map(int,input().split()))
  tmp=0
  for val in tl:
    tmp+=2**(val-1)
  arr.append((a,tmp))
dp=[10**18]*(2**n)
dp[0]=0
for val,flag in arr:
  for i in range(2**n-1,-1,-1):
    if dp[i]==10**18:
      continue
    else:
      dp[i|flag]=min(dp[i|flag],dp[i]+val)
if dp[-1]==10**18:
  print(-1)
else:
  print(dp[-1])

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

typedef long long ll;
typedef std::pair<ll, ll> l_l;
typedef std::pair<int, int> i_i;

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

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

using namespace std;

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

    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);

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

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += B[A[i]];
        if (i == 0) continue;
        if (A[i - 1] + 1 == A[i]) {
            ans += C[A[i - 1]];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    ll a,b,c;
    cin >> a >> b >> c;
    ll ans = 1;
    --c;
    if(a+b >= c){
        ans += c+b;
    }else if(a+b < c){
        ans += 2*(a+b)-a;
    }
    cout << ans << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
mv=((0,1),(0,-1),(1,0),(-1,0))
def dfs(y,x):
    if color==0:
        return False
    if y==yg-1 and x==xg-1:
        return True
    L[y][x]=0
    for i,j in mv:
        mx=x+i
        my=y+j
        if 0<=mx<w and 0<=my<h and L[my][mx]==color:
            if dfs(my,mx):
                return True
    return False

while True:
    w,h=map(int,raw_input().split())
    if w==h==0:break
    xs,ys=map(int,raw_input().split())
    xg,yg=map(int,raw_input().split())
    L=[[0]*w for i in range(h)]
    n=input()
    for i in range(n):
        c,d,x,y=map(int,raw_input().split())
        if d==0:
            for j in range(2):
                for k in range(4):
                    L[y+j-1][x+k-1]=c
        elif d==1:
            for j in range(4):
                for k in range(2):
                    L[y+j-1][x+k-1]=c
    color=L[ys-1][xs-1]
    if dfs(ys-1,xs-1):
        print "OK"
    else:
        print "NG"

Measured memory_bytes: 4424
n = int( input( ) )
t = [ int( val ) for val in input( ).rstrip( ).split( " " ) ]
q = int( input( ) )
s = [ int( val ) for val in input( ).split( " " ) ]

cnt = 0
for si in s:
	for ti in t:
		if si == ti:
			cnt += 1
			break

print( cnt )

Measured memory_bytes: 7760
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long total = 0;
        for (long i = 1; i < n + 1; i++) if (i % 5 != 0 && i % 3 != 0) total += i;
        System.out.println(total);
    }
}

Measured memory_bytes: 35804
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using i64 = int64_t;

constexpr int INF = 1 << 25;
constexpr int MOD = 1000000007;

int check(vector<int> &W, i64 P, int n, int k) {
  int i = 0;
  REP(j, k) {
    i64 s = 0;
    while (s + W[i] <= P) {
      s += W[i];
      ++i;
      if (i == n) return n;
    }
  }
  return i;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> W(n);
  REP(i, n) cin >> W[i];
  
  i64 left = 0, mid, right = n * 10000;
  while (right - left > 1) {
    mid = (left + right) / 2;
    int v = check(W, mid, n, k);
    if (v >= n) right = mid;
    else left = mid;
  }
  
  cout << right << endl;
}



Measured memory_bytes: 3112
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a: List<Long> = (0 until n).map { sc.nextLong() }
    val distinctA = a.distinct()
    if (a.size > distinctA.size) {
        println("NO")
    } else {
        println("YES")
    }
}

Measured memory_bytes: 82812
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M 1000000007
int main()
{

 

  fastio; 

  string s,t;
  cin>>s>>t;
  ll res=INT_MAX;
  ll n=s.size();
  ll m=t.size();

  int flag=0;
  for(int i=0;i<n-m+1;i++)
  {
    
      ll count=0;
      for(int j=0;j<m;j++)
      {
        if(i+j>=n)
        {
          break;
        }
        if(s[i+j]!=t[j])
          count++;
      }
     // cout<<res<<endl;

      res=min(res,count);

  }

  
    cout<<res;
 
return 0;   
}

Measured memory_bytes: 3520
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
#define inRange(x,a,b) (a <= x && x < b)

int di[4] = {0, 0, 1, -1};
int dj[4] = {1, -1, 0, 0};

int main(){
    int t;
    cin >> t;
    while(t-- > 0){
        char mat[12][6];
        for(int i = 0; i < 12; i++) for(int j = 0; j < 6; j++)  cin >> mat[i][j];
        int ans = 0;
        queue<pair<int,int>> q;
        while(1){
            bool see[12][6] = {}, del[12][6] = {}, erase = false;
            for(int i = 0; i < 12; i++){
                for(int j = 0; j < 6; j++){
                    if(mat[i][j]=='.' || mat[i][j]=='O' || see[i][j])   continue;
                    vector<pair<int,int>> tmp;
                    q.push({i,j});
                    while(!q.empty()){
                        auto p = q.front(); q.pop();
                        if(see[p.first][p.second])  continue;
                        tmp.push_back(p);
                        see[p.first][p.second] = true;
                        for(int k = 0; k < 4; k++){
                            int ni = p.first + di[k], nj = p.second + dj[k];
                            if(inRange(ni,0,12)&&inRange(nj,0,6)&&!see[ni][nj]&&mat[ni][nj]==mat[i][j]){
                                q.push({ni,nj});
                            }
                        }
                    }
                    if(tmp.size() < 4)  continue;
                    erase = true;
                    for(pair<int,int> p : tmp){
                        del[p.first][p.second] = true;
                        for(int k = 0; k < 4; k++){
                            int ni = p.first+di[k], nj = p.second+dj[k];
                            if(inRange(ni,0,12)&&inRange(nj,0,6)&&mat[ni][nj]=='O') del[ni][nj] = true;
                        }
                    }
                }
            }
            if(!erase)  break;
            for(int i = 0; i < 12; i++){
                for(int j = 0; j < 6; j++){
                    if(del[i][j])   mat[i][j] = '.';
                }
            }
            for(int i = 11; i >= 0; i--){
                for(int j = 0; j < 6; j++){
                    if(mat[i][j] == '.')    continue;
                    int cp = i;
                    while(cp+1 < 12 && mat[cp+1][j]=='.')   swap(mat[cp][j], mat[cp+1][j]), cp++;
                }
            }
            ans++;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] c = str.toCharArray();
        int k = sc.nextInt() - 1;
        
        int n = c.length;
        Set<String> set = new HashSet<String>();
        for (int i = 0; i < n; i++) {
            String s = "";
            for (int j = 0; j < Math.min(n, 5); j++) {
                if (i+j >= n) break;
                s += c[i+j];
                // System.out.println(s);
                set.add(s);
            }
        }
        List<String> list = new ArrayList<String>();
        for (String se : set) {
            list.add(se);
            // System.out.println(se);
        }
        list.sort(Comparator.naturalOrder());
        
        System.out.println(list.get(k));
    }
}

Measured memory_bytes: 27092
from sys import stdin
import sys
data = [int(stdin.readline().rstrip()) for _ in range(5)]
k = int(stdin.readline().rstrip())
result=[]
for i in range(5):
    for j in range(i+1,5):
        result.append(data[j]-data[i])
for i in result:
    if i > k:
        print(':(')
        sys.exit()
print('Yay!')

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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  int durations[n-1], start_time[n-1], periods[n-1];
  for(int i = 0; i < n-1; ++i) {
    cin >> durations[i] >> start_time[i] >> periods[i];
  }

  for(int i = 0; i < n-1; ++i) {
    int t = 0;
    for(int j = i; j < n-1; ++j) {
      if(t < start_time[j]) t = start_time[j];
      else if(t%periods[j]) t += (periods[j] - (t%periods[j])) % periods[j];
      t += durations[j];
    }
    cout << t << "\n";
  }
  cout << 0 << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k == x:
        ans = ans+1
        
print(ans)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    
    int seven = 7;
    int ans = -1;
    
    for(int i = 1; i <= K; ++i) {
      seven %= K;
      if(seven == 0) {
        ans = i;
        break;
      }
      seven = seven * 10 + 7;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 35880
#include<iostream>
using namespace std;
int main(void){
    int a,b;
    char op;
    
    while(1){
        cin >> a >> op >> b;
        if(op == '?')break;
        
        if(op == '+')cout << a + b << endl;
        
        else if(op == '-')cout << a - b << endl;
        else if(op == '*')cout << a * b << endl;
        else if(op == '/')cout << a / b << endl;
    }
}


Measured memory_bytes: 3096
#include "bits/stdc++.h" // {{{
using namespace std; typedef long long ll; typedef pair<int,int> pii;
#define val         const auto
#define eb          emplace_back
#define emp         emplace
#define fi          first
#define se          second
#define outl(x)     cout << (x) << '\n'
#define rep(i,n)    for(int i=0; i < (int)(n); ++i)
#define repr(i,h,l) for(int i=(h); i >= (int)(l); --i)
#define ALL(x)      begin(x), end(x)
#define TMPLT(T,U)  template<class T, class U>
#define ten(p)      ((long long)(1e##p))
#define FILL(a,v)   memset((a), (v), sizeof(a))
#ifdef  DEBUG
#define debug(...)  fprintf(stderr, __VA_ARGS__)
#define show(x)     clog << #x << " \t\t= " << (x) << '\n'
#define show2(x,y)  clog << '(' << #x << ',' << #y << ")\t\t= " << '(' << (x) << "\t, " << (y) << ")\n"
#define LN()        fputs("\n--------------------------------\n", stderr)
#else
#define debug(...)
#define show(x)
#define show2(x,y)
#define LN()
#endif
#define def(op) inline bool operator op (const T &that) const { return comp(that) op 0; }
template<class T> struct Ordered
{ virtual int comp(const T &that) const = 0; def(==); def(!=); def(<); def(<=); def(>); def(>=); };
#undef def
namespace {
  TMPLT(T,U) inline constexpr common_type_t<T,U> gcd(T x, U y)
  { return (x<y)? gcd(y,x) : (y <= 0)? x : gcd(y, x % y); }
  TMPLT(T,U) inline bool chmax(T &a, const U &b){return b>a ? a=b,1 : 0;}
  TMPLT(T,U) inline bool chmin(T &a, const U &b){return b<a ? a=b,1 : 0;}
  TMPLT(T,U) inline constexpr ll lcm(T x, U y) { return (ll)x/gcd(x,y) * y; }
  template<class Itr> string mkString(Itr begin, Itr end, const char *sp = " ") {
    static ostringstream oss; oss.str("");
    for(Itr i=begin; i != end; ++i) { if(i != begin)oss << sp; oss << *i; }
    return oss.str();
  }
  constexpr int INF = 0x3f3f3f3f; constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL;
  // }}}

constexpr int MX = ten(5) + 10;

int table[10];

string N;
int L;

int dp[12][2][1 << 4][2];

int check(int d) {
  return d == 3 || d == 5 || d == 7;
}

string toStr(int n) {
  static ostringstream oss;
  oss.str("");
  oss << n;
  return oss.str();
}

int slv(int idx, bool tight, int bit, bool zero, string str)
{
  if (idx == L) {
    debug("%s : %c\n", str.c_str(),  (bit == (1<<3)-1)? 'o' : 'x');
    return bit == ((1 << 3)-1)? 1 : 0;
  }

  int &ret = dp[idx][tight][bit][zero];
  if (~ret) { debug("%5s -- %d\n", str.c_str(), ret); return ret;}

  ret = 0;
  val x = N[idx] - '0';
  val r = (tight? x : 9);

  show(r);
  for (int i =0; i<=r; ++i) {
    if (check(i) || (zero && i == 0)) {
      string tmp = str + toStr(i);
      int nb = bit;
      if (i != 0) nb = nb | (1 << table[i]);
      ret += slv(idx+1, tight && i==r, nb, i==0? true : false, tmp);
    }
  }

  return ret;
}

void _main(const vector<char*> &args)
{
  table[0] = 3;
  table[3] = 0;
  table[5] = 1;
  table[7] = 2;

  cin >> N;
  L = N.length();
  show(L);
  FILL(dp, -1);

  outl( slv(0, true, 0, true, "") );
}


} // {{{
signed main(signed argc, char *argv[]) {
#ifndef DEBUG
  ios::sync_with_stdio(false); cin.tie(nullptr);
#endif
  cout << fixed << setprecision(9); _main(vector<char*>(argv, argv+argc)); return 0;
} // }}}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 100100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main() {
    ll a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    if (a[0]==a[2]){
        cout << "No" << endl;
    }else if (a[0]!=a[1] and a[1]!=a[2]){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      int[] surp = new int[Math.min(a,b)+1];
      for(int i = 1;i <= Math.min(a,b);i++){
      	if(a%i == 0 && b%i == 0){
        surp[i] = i;
        }
      }
      Arrays.sort(surp);
      System.out.println(surp[Math.min(a,b)-k+1]);
    }
}

Measured memory_bytes: 23124
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i != -1; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
const int N = 410;

struct Edge{ int to, next;} edge[N * 2];
int head[N], num = -1;
void add_edge(int a, int b){ edge[++ num] = (Edge){b, head[a]}, head[a] = num;}

LL p[N], invp[N];
LL qpow(LL a, LL b)
{
	LL ret = 1, base = a;
	while (b) {
		if (b & 1) ret = ret * base % mod;
		base = base * base % mod, b >>= 1;
	}
	return ret;
}

LL C(int a, int b) { return p[a] * invp[b] % mod * invp[a - b] % mod;}

int gcd(int a, int b) { return !b ? a : gcd(b, a % b);}

LL ans = 1;

int dfn[N], low[N], top, cn, tid, n, m, K;
bool vis[N], vise[N];
pii st[N];

void tarjan(int x)
{
	//printf("_%d %d\n", x, fa);
	dfn[x] = low[x] = ++ tid;
	RepG(i, x) if (!vise[i]) {
		vise[i] = vise[i ^ 1] = true;
		st[++ top] = mp(x, v);
		if (!dfn[v]) {
			tarjan(v);
			low[x] = min(low[x], low[v]);
			if (low[v] >= dfn[x]){
				Rep(k, n) vis[k] = false;
				int cv = 0, ce = 0;
				while (true){
					if (!vis[st[top].first]) cv ++, vis[st[top].first] = true;
					if (!vis[st[top].second]) cv ++, vis[st[top].second] = true;
					ce ++, top --;
					if (st[top + 1].first == x && st[top + 1].second == v) break;
				}
				//printf("%d %d\n", cv, ce);
				if (ce == 1) ans = ans * K % mod;
				else if (ce == cv) {
					LL tmp = 0;
					Rep(j, ce) tmp = (tmp + qpow(K, gcd(j, ce))) % mod;
					ans = ans * tmp % mod * qpow(ce, mod - 2) % mod;
				}
				else ans = ans * C(ce + K - 1, K - 1) % mod;
				
			}
		}
		else low[x] = min(low[x], dfn[v]);
	}

}

int main()
{
	scanf("%d%d%d", &n, &m, &K);
	memset(head, -1, sizeof(head));
	Rep(i, m){
		int a, b;
		scanf("%d%d", &a, &b);
		add_edge(a, b); add_edge(b, a);
	}
	p[0] = 1;
	Rep(i, 400) p[i] = p[i - 1] * i % mod;
	invp[400] = qpow(p[400], mod - 2);
	for (int i = 399; i >= 0; i --) invp[i] = invp[i + 1] * (i + 1) % mod;
	Rep(i, n) if (!dfn[i]) tarjan(i);

	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] array = new int[w];
		for(int i=0;i<w;i++){
			array[i] = i+1; 
		}
		for(int i=0;i<n;i++){
			String str = sc.next();
			String[] num = str.split(",");
			int a = Integer.parseInt(num[0])-1;
			int b = Integer.parseInt(num[1])-1;
			int tmp = array[a];
			array[a] = array[b];
			array[b] = tmp;
		}
		for(int i=0;i<w;i++){
			System.out.println(array[i]);
		}
	}

}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 998244353;


double pi = acos(-1);

int main() {

	double a, b, h, m;
	cin >> a >> b >> h >> m;

	double cb = sin(pi*m / 30)*b;
	double ca = sin((h * 60 + m) * 2 * pi / 720)*a;

	double db = cos(pi*m / 30)*b;
	double da = cos((h * 60 + m) * 2 * pi / 720)*a;

	cb -= ca;
	cb *= cb;
	db -= da;
	db *= db;

	cout << fixed << setprecision(15) << sqrt(cb + db) << endl;




}


Measured memory_bytes: 4164
#include <stdio.h> 
int main(){ 
     int a, b, d, r; 
     double f; 
     scanf("%d %d", &a, &b); 
     d=a/b; 
     r=a%b; 
     f=(double)a/(double)b; 
     printf("%d %d %f\n", d, r, f); 
     return 0; 
 } 


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

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

	vector<int> p(N);
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		cin >> p.at(i);
		if (p.at(i) != i + 1) {
			cnt++;
		}
	}

	if (cnt == 0 || cnt == 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	a--, b--, c--, d--;
	string s;
	cin >> s;
	if (c < d) {
		bool e = true;
		for (int i = a; i <= c - 1; i++) {
			string t = s.substr(i, 2);
			if (t == "##") e = false;
		}
		for (int i = b; i <= d - 1; i++) {
			string t = s.substr(i, 2);
			if (t == "##") e = false;
		}
		if (e) cout << "Yes" << endl;
		else cout << "No" << endl;
	} else {
		bool e = false;
		for (int i = b; i <= d; i++) {
			string t = s.substr(i - 1, 3);
			if (t == "...") e = true;
		}
		if (e) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

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

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
const int maxn=200010,maxc=30;
char s[maxn],t[maxn];
int n,m,_next[maxn][maxc],pos,nxt;
long long ans;
bool se[maxc];
int main(){
	scanf("%s",s);scanf("%s",t);
	n=strlen(s);m=strlen(t);
	for(register int i=0;i<n;i++) se[s[i]-'a']=true;
	for(register int i=0;i<m;i++) if(!se[t[i]-'a']){
		printf("-1\n");
		return 0;
	}
	memset(_next,-1,sizeof(_next));
	for(register int i=n;i<(n<<1);i++) s[i]=s[i-n];
	for(register int i=(n<<1)-1;i>=0;i--) for(int j=0;j<26;j++){
		if((s[(i+1)%n]-'a')==j) _next[i][j]=(i+1)%n;
		else _next[i][j]=_next[i+1][j];
	}
	for(register int i=0;i<n;i++) if(s[i]==t[0]){
		ans=(long long)i;break;
	}
	for(register int i=1;i<m;i++){
		pos=(int)(ans%(long long)n);
		nxt=_next[pos][t[i]-'a'];
		if(nxt>pos) ans+=(long long)(nxt-pos);
		else ans+=(long long)(n+nxt-pos);
	}
	printf("%lld\n",ans+1);
	return 0;
}

Measured memory_bytes: 23936
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

class UnionFind {
public:
    vector<int> par, rank;
    int cnt;

    UnionFind(int n) : cnt(n) {
        par = vector<int>(n);
        iota(par.begin(), par.end(), 0);
        rank = vector<int>(n, 0);
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = root(par[x]);
        }
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
        cnt--;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};


int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll N,K,L;
  cin >> N >> K >> L;
  UnionFind uf1= UnionFind(N+1);
  UnionFind uf2= UnionFind(N+1);

  for(int i=1;i<=K;i++){
    int p,q;
    cin >> p >> q;
    uf1.unite(p,q);
  }
  for(int i=1;i<=L;i++){
    int r,s;
    cin >> r >> s;
    uf2.unite(r,s);
  }
  ll root1[N+10];
  ll root2[N+10];
  map<P,ll> m;

  for(int i=1;i<=N;i++){
    root1[i]=uf1.root(i);
    root2[i]=uf2.root(i);
    m[P(root1[i],root2[i])]++;
  }

  for(int i=1;i<=N;i++){
    cout << m[P(root1[i],root2[i])];
    if(i==N){
      cout << endl;
    }else{
      cout << " ";
    }
  }
  return 0;
}

Measured memory_bytes: 18176
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);
function main(){
  var n = o.a();
  var sum = xArray(0,10,10);
  for(var i = 1; i <= n; i++){
    var p = i;
    var x = p%10;
    while(p>9)p=p/10|0;
    sum[p][x]++;
  }
  var ans = 0;
  for(var i = 1; i <= 9; i++)for(var j = 1; j <= 9; j++){
    ans += sum[i][j]*sum[j][i];
  }
  return ans;
}

Measured memory_bytes: 7372
import re
import numpy as np

A, B = [int(item) for item in re.split(r"\s", input())]

print(((A % 2) * (A - 1)) ^ (((A) // 2) % 2) ^ (((B + 1) % 2)) * (B) ^ (((B + 1) // 2) % 2))


Measured memory_bytes: 12448
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b,a[li],k,flag;
int cev;
string s;
vector<int> v;

int main(void){
	scanf("%d %d ",&n,&m);
	if(n<m){printf("0\n");return 0;}
	printf("10\n");
	return 0;
}


Measured memory_bytes: 256
import numpy as np


H, N = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
a, b = np.array(AB, dtype=np.int64).reshape(N, 2).T

d = np.zeros(H + 1, dtype=np.int64)

for hp in range(1, H + 1):
    c = d[np.maximum(hp - a, 0)] + b
    d[hp] = np.amin(c)

print(d[H])

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

using namespace std;

int main(){
  int A,B;
  cin >> A >> B;
  int i;
  int ans = -1;
  for(i=1;i<=100000;i++)
    if(A <= 2*i/25 && 2*i/25 < A+1 && B <= i/10 && i/10 < B+1){
      ans = i;
      break;
    }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return sorted 約数list 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(ALL(v));
  return v;
}


int main() {
    ll n,k;
    cin>>n;
    double y;
    y = (n-1)/2;
    
    pr((n%2 ==0 ) ? 0.5 : ((y+1)/(2*y+1)) );
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;

int a, b;
char c[105][105];
int main() {
	int i, j;
	scanf("%d%d", &a, &b);
	for(i=0; i<100; i++) for(j=0; j<100; j++) c[i][j] = i<50 ? '.' : '#';
	for(i=0; i<b-1; i++) c[i/50*2][i%50*2] = '#';
	for(i=0; i<a-1; i++) c[i/50*2+60][i%50*2] = '.';
	puts("100 100");
	for(i=0; i<100; i++) puts(c[i]);
	return 0;
}


Measured memory_bytes: 128
/*
  AOJ 1027
  Title:
  @kankichi573
*/
#include <stdio.h>
int K,c;


main()
{
        int i,sum;

        while(EOF!=scanf("%d",&K) && K)
        {
                for(i=0,sum=0;i<K*(K-1)/2;i++)
                {
                        scanf("%d ",&c);
                        sum += c;
                }
                printf("%d\n",sum/(K-1));
        }
        return(0);
}

Measured memory_bytes: 604
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

int A,B,C,N,W,H,ans,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};
vector<int > beau;

void solve(){

}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> S;
	for (int i = 0; i < S.size(); ++i)
	{
		if(find(beau.begin(), beau.end(),S[i]) != beau.end()){
			beau.erase(find(beau.begin(), beau.end(),S[i]));
		}else{
			beau.push_back(S[i]);
		}
	}
	if(beau.empty()){
		cout << "Yes\n"; 
	}else{
		cout << "No\n";
	}


	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
class BinaryTree:
    def __init__(self, parent, left, right):
        self.parent = parent
        self.left = left
        self.right = right
        self.sibling = -1
    

T = []
n = int(input().rstrip())
 
for _ in range(n):
    T.append(BinaryTree(-1, -1, -1))

for i in range(n):
    input_line = list(map(int, input().rstrip().split(" ")))
    u, left, right = input_line
    T[u].left = left
    T[u].right = right
    if left != -1:
        T[left].parent = u
    if right != -1:
        T[right].parent = u
    if (left != -1) and (right != -1):
        T[left].sibling = right
        T[right].sibling = left

def get_degree(T, u):
    return int(T[u].left != -1) + int(T[u].right != -1)

def get_depth(T, u):
    d = 0
    while T[u].parent != -1:
        u = T[u].parent
        d += 1
    return d

for i, t in enumerate(T):
    if t.parent == -1:
        root = i
        break
H = [0] * n

def set_height(u):
    global H
    h1 = 0
    h2 = 0
    if T[u].left != -1:
        h1 = set_height(T[u].left) + 1
    if T[u].right != -1:
        h2 = set_height(T[u].right) + 1
    H[u] = max(h1, h2)
    return H[u]

set_height(root)

def print_info(T, u):
    node = u
    parent = T[u].parent
    sibling = T[u].sibling
    degree = get_degree(T, u)
    depth = get_depth(T, u)
    height = H[u]
    type_ = "root" if parent == -1 else "leaf" if degree == 0 else "internal node"
    print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(node, parent, sibling, degree, depth, height, type_))
    
for i in range(n):
    print_info(T, i)



Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n,j) for (int i = n; j<=i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;
typedef pair<ll,ll> P;

ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int main(){
  ll N;cin>>N;
  ll a,g;cin>>g;
  REP(i,1,N){
    cin>>a;
    g=gcd(a,g);
  }
  print(g)
}


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

int main() {
	int n;
	scanf("%d", &n);
	map<int, int> mp;
	for (int i=0; i<n; i++) {
		int a;
		scanf("%d", &a);
		if (mp.find(-a)==mp.end()) {
			mp.insert({-a,1});
		}
		else mp[-a]++;
	}
	long long a1=0, a2=0;
	for (auto it=mp.begin(); it!=mp.end(); it++) {
		if (it->second>=4) {
			a1=min(a1,(long long)it->first);
			a2=it->first;
			break;
		}
		if (it->second>=2) {
			if (a1==0) a1=it->first;
			else if (a2==0) {
				a2=it->first;
				break;
			}
		}
	}
	printf("%lld\n", a1*a2);
}


Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <queue>

#include <atcoder/convolution>
#include <atcoder/modint>

using namespace std;
using namespace atcoder;

using mint = modint998244353;

template<typename T>
struct Combination {
private:
  int sz;
  vector<T> F, F_;
public:
  Combination(int sz) : sz(sz), F(sz+1), F_(sz+1) {
    F[0] = 1;
    for(int i = 0; i < sz; ++i) F[i+1] = F[i]*(i+1);
    F_.back() = (T)1/F.back();
    for(int i = sz-1; i >= 0; --i) F_[i] = F_[i+1]*(i+1);
  }
  T C(int n, int k){
    assert(n <= sz);
    if(n < 0 or k > n) return (T)0;
    return F[n]*F_[k]*F_[n-k];
  }
};

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  vector<int> H(100000+1);
  for(int i = 0; i < 2*N; ++i){
    int h;
    cin >> h;
    ++H[h];
  }
  Combination<mint> comb(100001);
  vector<mint> C(1,1);
  vector<vector<mint>> B;
  priority_queue<pair<size_t,size_t>,
                 vector<pair<size_t,size_t>>,
                 greater<pair<size_t,size_t>>> pq;
  // priority_queue<pair<size_t,size_t>> pq;
  for(auto v : H){
    if(!v) continue;
    vector<mint> T(v/2+1);
    T[0] = 1;
    for(int i = 0; i < v/2; ++i){
      T[i+1] = T[i]*comb.C(v-2*i,2)/(i+1);
    }
    pq.emplace(T.size(),B.size());
    B.emplace_back(T);
  }
  while(pq.size() > 1){
    auto [a, i] = pq.top();
    pq.pop();
    auto [b, j] = pq.top();
    pq.pop();
    B[i] = convolution(B[i],B[j]);
    pq.emplace(B[i].size(),i);
  }
  if(pq.size()) C = B[pq.top().second];
  // cerr << C.size() << '\n';
  // cerr << C.size() << endl;
  // for(auto e : C)
  //   cerr << e.val() << " ";
  // cerr << endl;
  vector<mint> A(N+1);
  A[0] = 1;
  for(int i = 1; i <= N; ++i){
    A[i] = A[i-1]*comb.C(2*i,2)/i;
  }
  // for(auto e : A)
  //   cerr << e.val() << " ";
  // cerr << endl;
  mint ans = 0;
  for(int i = 0; i < min<int>(N+1,C.size()); ++i){
    if(C[i] == 0) continue;
    ans += C[i]*(i%2 ? -1 : 1)*A[N-i];
  }
  cout << ans.val() << endl;
}


Measured memory_bytes: 11500
using System;
using System.IO;
using System.Linq;

class Program{
    static void Main(string[] args){
        var arr = Console.ReadLine().Split();
        var N = int.Parse(arr[0]);
        var M = int.Parse(arr[1]);
        var C = int.Parse(arr[2]);
        var B = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var answer = 0;
        for (int i = 1; i <= N; i++){
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var sum = 0;
            for (int j = 0; j < M; j++){
                sum += A[j] * B[j];}
            if (sum + C > 0) answer++;}
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 28316
//This Code was made by Chinese_zjc_.
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <time.h>
// #include<windows.h>
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
int n, m, a, b, dfn[500005], low[500005], tim, fa[500005], cnt, in[500005];
vector<int> to[500005], TO[500005], inside[500005];
bool ins[500005];
stack<int> sta;
queue<int> que;
void Tarjan(int now)
{
    dfn[now] = low[now] = ++tim;
    ins[now] = true;
    sta.push(now);
    for (int i = 0; i < (int)to[now].size(); ++i)
    {
        if (!dfn[to[now][i]])
        {
            Tarjan(to[now][i]);
            low[now] = min(low[now], low[to[now][i]]);
        }
        else if (ins[to[now][i]])
        {
            low[now] = min(low[now], low[to[now][i]]);
        }
    }
    if (dfn[now] == low[now])
    {
        int tmp = sta.top();
        ++cnt;
        while (tmp != now)
        {
            fa[tmp] = cnt;
            ins[tmp] = false;
            sta.pop();
            tmp = sta.top();
        }
        fa[now] = cnt;
        ins[now] = false;
        sta.pop();
    }
}
signed main()
{
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 1; i <= m; ++i)
    {
        cin >> a >> b;
        ++a;
        ++b;
        to[a].push_back(b);
    }
    for (int i = 1; i <= n; ++i)
    {
        if (!dfn[i])
        {
            Tarjan(i);
        }
    }
    for (int i = 1; i <= n; ++i)
    {
        inside[fa[i]].push_back(i);
        for (int j = 0; j < (int)to[i].size(); ++j)
        {
            if (fa[i] != fa[to[i][j]])
            {
                TO[fa[i]].push_back(fa[to[i][j]]);
                ++in[TO[fa[i]].back()];
            }
        }
    }
    cout << cnt << endl;
    for (int i = 1; i <= cnt; ++i)
    {
        if (!in[i])
        {
            que.push(i);
        }
    }
    while (!que.empty())
    {
        int now = que.front();
        que.pop();
        cout << inside[now].size();
        for (int i = 0; i < (int)inside[now].size(); ++i)
        {
            cout << ' ' << inside[now][i] - 1;
        }
        cout << endl;
        for (int i = 0; i < (int)TO[now].size(); ++i)
        {
            --in[TO[now][i]];
            if (!in[TO[now][i]])
            {
                que.push(TO[now][i]);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 94512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int A, B, C, X, Y;
int main()
{
  cin >> A >> B >> C >> X >> Y;
  int total = 0x7fffffff; // intの最大値
  for (int i = 0; i <= 100000; i++)
  {
    total = min(total, i * 2 * C + max(0, X - i) * A + max(0, Y - i) * B);
  }
  cout << total << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
N, X, Y = map(int,input().split())
def distance(i, j):
    return min(abs(i-j), abs(X-i)+1+abs(j-Y))

d = defaultdict(int)
for i in range(1,N):
    for j in range(i,N+1):
        d[distance(i,j)]+=1
for i in range(1,N):
    print(d[i])

Measured memory_bytes: 3956