akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;

vector<int> G[MAX];

int dis[MAX][2];
ll cnt[MAX][2];

void BFS(int u,int type){
    queue<int> Q;
    Q.push(u);
    dis[u][type]=0;
    
    while(!Q.empty()){
        int a=Q.front();Q.pop();
        for(int to:G[a]){
            if(dis[to][type]==INF){
                dis[to][type]=dis[a][type]+1;
                Q.push(to);
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M,s,t;cin>>N>>M>>s>>t;
    s--;t--;
    
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    for(int i=0;i<N;i++) dis[i][0]=dis[i][1]=INF;
    
    BFS(s,0);
    BFS(t,1);
    
    for(int i=0;i<N;i++){
        for(int j=0;j<2;j++){
            if(dis[i][j]==INF) continue;
            
            cnt[dis[i][j]][j]++;
        }
    }
    
    ll ans=0;
    
    int ma=dis[t][0];
    
    for(int l=0;l<=ma-2;l++){
        ans+=cnt[l][0]*cnt[ma-2-l][1];
        
        //cout<<ans<<endl;
    }
    
    cout<<ans<<endl;
    
}




Measured memory_bytes: 10236
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;

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

int main() {
    int K;
    cin >> K;
    long long sum = 0;
    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++) {
            for (int k = 1; k <= K; k++) {
                sum += gcd(gcd(i, j), k);
            }
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 3636
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){
    int N,C; cin >> N >> C;
    vector<vector<P>> v(C);
    int f = 0;
    REP(i,N){
        int s,t,c; cin >> s >> t >> c;
        v[c-1].push_back(P(s-1,t-1));
        chmax(f, t-1);
    }
    REP(i,C) SORT(v[i]);
    vector<vector<P>> newv(C);
    REP(i,C){
        if(v[i].size()) newv[i].push_back(P(v[i][0].first, v[i][0].second));
        FOR(j,1,v[i].size()){
            if(v[i][j].first == newv[i].back().second) newv[i].back().second = v[i][j].second;
            else newv[i].push_back(P(v[i][j].first, v[i][j].second));
        }
    }
    swap(v,newv);
    int n[f]; REP(i,f) n[i] = 0;
    REP(i,C){
        for(P p : v[i]){
            FOR(j, p.first, p.second+1){
                n[j]++;
            }
        }
    }
    int ans = 0;
    REP(i,f) chmax(ans, n[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#define MAXC 10000
using namespace std;

int n,a,b;
int main(){
	a=b=MAXC;
	for(int i=0;i<3;i++){
		cin >>n;
		if(n<a)a=n;
	}
	for(int i=0;i<2;i++){
		cin >>n;
		if(n<b)b=n;
	}
	cout << a+b-50<<endl;
	return 0;
}

Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int max = sc.nextInt();
		
		long result = 0;
		
		long kouyaku = 1;
		
		for(int a = 1; a <= max; a++) {
		
			for(int b = 1; b <= max; b++) {
			
				for(int c= 1; c <= max; c++) {
				
					int ap = a;
					
					int bp = b;
					
					int cp = c;
					
					for(int j= 1; j <= ap && j <= bp && j <= cp; j++) {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					}
						
						result += kouyaku;
						
						kouyaku = 1;
						
					}
					
				}
			}
		
						
		
		sc.close();
		
		System.out.println(result);
		
	}
	
}


Measured memory_bytes: 36200
#include <bits/stdc++.h>
using namespace std;
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int N;
    cin>>N;
    string S;
    cin>>S;
    if(N%2!=0)
    {
        cout<<"No";
    }
    else
    {
        for(int i=0;i<N/2;i++)
         {
            if(S[i]!=S[N/2+i])
            {
                cout<<"No";
                return 0;
            }
         }
         cout<<"Yes";
    }

}

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

int main( ) {
  string s(3,'0');
  cin >> s;
  
  for(int i = 0; i < 3; i++) {
    if(s[i] == '1'){
      s[i] = '9';
    } else if(s[i] == '9'){
      s[i] = '1';
    }
  }
  
  cout << s;
  
  /*
  if(c1 == '1'){
    c1 = '9';
  } else if(c1 == '9'){
    c1 = '1';
  }
  
  if(c2 == '1'){
    c2 = '9';
  } else if(c2 == '9'){
    c2 = '1';
  }
  
  if(c3 == '1'){
    c3 = '9';
  } else if(c3 == '9'){
    c3 = '1';
  }
  */
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ep emplace_back
#define st first
#define sc second

using namespace std;

const ll mod = 998244353;
const int e = 1e6 + 69;
const int base = 311;

// dung igt thay cho gt luc tinh giai thua
// 3
// cach tao hoan vi tu n so : n*(n+1)/2;

ll a[e];
ll dp[e][27];

int main()
{
    string s;
    cin >> s;
    for(int i=0; i<s.size() - 1; i++)
    {
        if(s[i] == s[i+1])
        {
            cout << i+1 <<" "<<i+2;
            return 0;
        }
    }
    for(int i=0; i<s.size() - 2; i++)
    {
        if(s[i] == s[i+2])
        {
            cout << i+1 <<" "<<i+3;
            return 0;
        }
    }
    cout << - 1 <<" "<< -1;
}


Measured memory_bytes: 512
from collections import deque

def simulate(h, w, s, sx, sy):
    dist = [[-1 for x in range(w)] for y in range(h)]
    dist[sy][sx] = 0
    que = deque([(sx, sy)])
    res = 0
    while que:
        cx, cy = que.popleft()
        for dx, dy in [(0,1),(1,0),(0,-1),(-1,0)]:
            nx, ny = cx+dx, cy+dy
            if (0 <= nx < w) and (0 <= ny < h) and (s[ny][nx] == ".") and (dist[ny][nx] == -1):
                que.append((nx, ny))
                dist[ny][nx] = dist[cy][cx] + 1
                res = max(res, dist[ny][nx])
    return res

def solve(h, w, s):
    best = 0
    for y in range(h):
        for x in range(w):
            if s[y][x] == ".":
                best = max(best, simulate(h, w, s, x, y))
    return best

h, w = map(int, input().split())
s = [input() for i in range(h)]
print(solve(h, w, s))

Measured memory_bytes: 3316
import sys

N = int(input())
b = list(map(int, input().split()))

ans = []
for i in range(N):
    for j in range(len(b))[::-1]:
        if b[j] == j+1:
            ans.append(b.pop(j))
            break
        if j == 0:
            print(-1)
            sys.exit()
    
for i in range(N)[::-1]:
    print(ans[i])

Measured memory_bytes: 3060
import sys

cin = sys.stdin
# cin = open("in.txt", "r")

def line2N():
    return map(int, cin.readline().split())

A = list(line2N())
N, = line2N()
B = list(A)
B[0] *= 4
B[1] *= 2
B[3] /= 2

idx = 0
bMin = B[0]
for i in range(1,3):
    if B[i]<B[idx]:
        idx = i
        bMin = B[i]

cnt = 0
if B[3]==min(B):
    cnt += N//2*A[3]
    N %= 2
    cnt += N*B[idx]
else:
    cnt += N*B[idx]

print(cnt)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
  int a, b;
  cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible";
  else cout << "Impossible";
    return 0;
}

Measured memory_bytes: 256
/*
Kaushal Jalan
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop int t;cin>>t;while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define mod 1000000007
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}
void c_p_c()
{
    crap;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
signed main()
{
    //c_p_c();
    int n;
    cin>>n;
    int a[n+1];
    for(int i=2;i<=n;i++)
        cin>>a[i];
    int ans[n+1]={0};
    for(int i=2;i<=n;i++)
        ans[a[i]]++;
    for(int i=1;i<=n;i++)
    cout<<ans[i]<<endl;
}

Measured memory_bytes: 6744
#include<iostream>
#include<climits>
using namespace std;

long n,q;
long mn[300010];
long k=0,v=1;

void update(long i, long x){
  i += v;
  //cout<<"v:"<<v<<endl;
  mn[i] = x;
//  cout<<"mn["<<i<<"]:"<<mn[i]<<endl;
  i /= 2;
  while(i>0){
    int l=mn[i*2];
    int r=mn[i*2+1];
    mn[i]=min(l,r);
  //  cout<<"mn["<<i<<"]:"<<mn[i]<<endl;
    i /= 2;
  }
}

long find(long x,long y,long bottom=0,long top= v,long node=1){
//  cout<<"x:"<<x<<" y:"<<y<<" bottom:"<<bottom<<" top"<<top<<" node:"<<node<<endl;
  if(x<=bottom && top<=y) return mn[node];
  if(top<=x || y<=bottom) return INT_MAX;

  long mid = (bottom+top)/2;
  long lmx=find(x,y,bottom,mid,node*2);
  long rmx=find(x,y,mid,top,node*2+1);
  return min(lmx,rmx);
}


int main(){
  cin>>n>>q;
  while(n>=v){
    v *=2;
    k+=1;
  }
  for(int i=0;i<300010;i++){
   mn[i]=INT_MAX;
  }
  long com,x,y;
  for(int i=0;i<q;i++){
    cin>>com>>x>>y;
    if(com==0){
      update(x,y);
    }else if(com==1){
      cout<<find(x,y+1)<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 5444
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        a[0] = sc.nextInt();
        a[1] = sc.nextInt();
        a[2] = sc.nextInt();
        Arrays.sort(a);
        if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }    
}


Measured memory_bytes: 9556
#include<bits/stdc++.h>
using namespace std;
#define int long
main(){
  int n,r=0;
  cin>>n;
  vector<int> a(n);
  map<int,int> m;
  for(auto &i:a)cin>>i,++m[i];
  sort(a.begin(),a.end());
  auto f = [](int x){
    ++x;
    if(x<=0)return 0l;
    if((x&(x-1))==0)return x;
    int res=1;
    while(x>0)res<<=1,x>>=1;
    return res;
  };
  for(int i=n-1;i>=0;--i){
    int d=f(a[i])-a[i];
    if(m[a[i]]>0&&m[d]>0){
      if(a[i]!=d)++r,--m[a[i]],--m[d];
      else if(m[d]>1)++r,m[d]-=2;
    }
  }
  cout<<r;
}

Measured memory_bytes: 26752
<?php

//整数の入力
fscanf(STDIN,"%s", $n);


//N以下の奇数の数を数える
for($i = 1; $i <= $n; $i++) {
    if($i%2 !==0){
        $b[] = $i;
    }
}

$count = count($b);
$total = $count / $n;

echo sprintf("%s",$total);


Measured memory_bytes: 3700
using System;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(ReadLine());
        int[] d = ReadLine().Split(' ').Select(int.Parse).ToArray();
        int ans = 0;
        for(int i = 0; i < N - 1; i++)
        {
            for(int j = i + 1; j < N; j++)
            {
                ans += d[i] * d[j];
            }
        }
        WriteLine(ans);
    }
}


Measured memory_bytes: 13396
#include <iostream>                               
#include <vector>                                 
                                                  
using namespace std;                              
                                                  
int main (void) {                                 
  int N;                                          
  cin >> N;                                       
  int x;                                          
  vector<int> A;                                  
  for (int i=0; i<N; i++) {                       
    cin >> x;                                     
    A.push_back(x);                               
  }                                               
  int tmp, ans=0;                                 
  for (int i=0; i<N; i++) {                       
    int minj = i;                                 
    for (int j=i; j<N; j++) {                     
      if (A[j]<A[minj]) {                         
        minj = j;                                 
      }                                           
    }                                             
    tmp = A[i];                                   
    A[i] = A[minj];                               
    A[minj] = tmp;                                
    if (i!=minj) {                                
    ans++;                                        
    }                                             
  }                                               
  for (int i=0; i<A.size(); i++) {                
    cout << (i==0?"":" ") << A[i] << flush;       
  }                                               
  cout << endl <<  ans << endl;                   
}                               

Measured memory_bytes: 3132
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a + b == 15) {
    printf("+\n");
  } else if (a * b == 15) {
    printf("*\n");
  } else {
    printf("x\n");
  }

  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    int a = 0;
    int b = 0;
    int ab = 0;
    int ret = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s[0] == 'B' && s[s.size() - 1] == 'A')ab++;
        else if (s[s.size() - 1] == 'A')a++;
        else if (s[0] == 'B')b++;
        for (int j = 0; j < s.size() - 1; j++) {
            if (s[j] == 'A' && s[j + 1] == 'B')ret++;
        }
    }

    if (ab > 0) {
        ret += ab - 1;
        if (a > 0) {
            ret++;
            a--;
        }
        if (b > 0) {
            ret++;
            b--;
        }
    }
    cout << ret + min(a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename ...Ts>
decltype(auto) zip(vector<Ts>... args){
  vector<decltype(make_tuple(args[0]...))> res;
  Int n=min({args.size()...});
  res.reserve(n);
  for(Int i=0;i<n;i++) res.emplace_back(args[i]...);
  return res;
}

//INSERT ABOVE HERE
signed main(){
  Int n,d,a;
  cin>>n>>d>>a;
  vector<Int> xs(n),hs(n);
  for(Int i=0;i<n;i++) cin>>xs[i]>>hs[i],hs[i]=(hs[i]+a-1)/a;

  auto zs=zip(xs,hs);
  sort(zs.begin(),zs.end());
  for(Int i=0;i<n;i++)
    tie(xs[i],hs[i])=zs[i];

  Int ans=0;
  using P = pair<Int, Int>;
  queue<P> que;
  Int cnt=0;
  for(Int i=0;i<n;i++){
    while(!que.empty()&&que.front().first<xs[i]){
      cnt-=que.front().second;
      que.pop();
    }
    Int need=hs[i]-cnt;
    if(need>0){
      ans+=need;
      cnt+=need;
      que.emplace(xs[i]+d+d,need);
    }
  }

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


Measured memory_bytes: 9600
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll h;
    cin >> h;

    ll ans = 1;
    ll cnt = 0;
    ll num = 1;
    if(h == 1){
        cout << 1 << endl;
        return 0;
    }
    while(true){
        h /= 2;
        num *= 2;
        ans += num;
        if(h <= 1){
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n;
  int d[50];
  int ans=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&d[i]);
  }
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      ans+=d[i]*d[j];
      //printf("%d\n",ans);
    }
  }
  printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let a: i32 = s.next().unwrap().parse().unwrap();
	let b: i32 = s.next().unwrap().parse().unwrap();
	let c: i32 = s.next().unwrap().parse().unwrap();
	let s = 3 * c;
	println!("{} {} {}", a, b, -a - b + s);
	println!("{} {} {}", 2 * s - 2 * a - b - 2 * c, c, 2 * a + b + c - s);
	println!("{} {} {}", a + b + 2 * c - s, s - b - c, s - a - c);
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,ans=0;
  float Asum=0.0;
  cin>>N>>M;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    Asum+=A.at(i);
  }

  for(int i=0;i<N;i++){
    if(A.at(i)>=Asum/M/4)ans++;
    //cout<<A.at(i)<<" "<<Asum/M/4<<endl;
  }
  
  //cout<<ans<<endl;
  
  if(ans>=M)cout<<"Yes";
  else cout<<"No";
  
}


Measured memory_bytes: 3620
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,p] <- getIntList
    as <- getIntList
    let evens = all even as
        ans | evens && p == 0 = 2^n
            | evens && p == 1 = 0
            | otherwise = 2^(n-1)
    print ans

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

int main(){
  ll h;
  cin >> h;
  
  ll ans = 1;
  ll now = 1;
  h /= 2;
  
  while(h > 0){
    h /=2;
    now *= 2;
    ans += now;
  }
  
  cout << ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 3596
drawBoard :: Int -> Int -> IO ()
drawBoard h w = sequence_ $
    take h . cycle . map (putStrLn . take w) $ [cycle "#.", cycle ".#"]

main = getContents >>= mapM_ (\[h,w] -> do drawBoard h w; putStrLn "") .
        takeWhile (/= [0,0]) . map (map read . words) . lines

Measured memory_bytes: 4100
def zan(total, flag):
    rest = 7200 - total if flag else (7200 - total) * 3
    t, rest = divmod(rest, 3600)
    h, s = divmod(rest, 60)
    print("{0:02d}:{1:02d}:{2:02d}".format(t, h, s))

while True:
    T, H, S = map(int, input().split())
    if T == -1:
        break
    total = T * 3600 + H * 60 + S
    for i in [1, 0]:
        zan(total, i)

Measured memory_bytes: 7448
n = int(input())
a = [0] + list(map(int, input().split()))
for i in range(1, n+1):  a[i] += a[i-1]
ans, m = 0, int(1e9+7)
for i in range(1, n):
    ans = (ans + (a[i]-a[i-1])*(a[n]-a[i])) % m

print(ans)


Measured memory_bytes: 31748
import Text.Printf

main = do
  x <- readLn
  mapM_ (printf . toString) $ solve x
  putStrLn ""

toString :: Int -> String
toString x = printf " %d" x

include3 :: Int -> Bool
include3 x = any (\y -> y `rem` 10 == 3) . takeWhile (/= 0) $ iterate (\y -> y `div` 10) x

solve :: Int -> [Int]
solve x = filter (\y -> include3 y || y `rem` 3 == 0) [1..x]

Measured memory_bytes: 4176
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c<=21)puts("win");
	else puts("bust");
	return 0;
}


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

vector<ll> a, b;

ll ceil(ll n, ll m) {
    return n % m == 0 ? n / m : n / m + 1;
}

ll dp[1001][10001];

ll solve(ll h, ll i, ll n) {
    if (h <= 0) return 0;
    if (i == n - 1) return ceil(h, a[i]) * b[i];
    if (dp[i][h]) {
        return dp[i][h];
    }
    ll k = 0, ans = LLONG_MAX;
    ll t = ceil(h, a[i]);
    while (k <= t) {
        ans = min(ans, solve(h - k * a[i], i + 1, n) + k * b[i]);
        ++k;
    }
    dp[i][h] = ans;
    return dp[i][h];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll h, n;
    cin >> h >> n;
    a = vector<ll>(n);
    b = vector<ll>(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    map<int,ll> mp;
    for (ll i = 0; i < n; i++) {
      if (mp.count(a[i])) {
        mp[a[i]]=min(mp[a[i]],b[i]);
      } else {
        mp[a[i]]=b[i];
      }
    }
    a.clear();
    b.clear();
    for (auto &p:mp) {
      a.push_back(p.first);
      b.push_back(p.second);
    }
    cout << solve(h, 0, a.size());
    return 0;
}


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

public class Main {
    public static long gcd(long x, long y){
        if(x<y) return gcd(y,x);
        if(y==0)return x;
        return gcd(y,x%y);
    }
    public static long buy(long current, long pace, long limit){
        long day = (current-limit)/pace;
        long ans = current-pace*day;
        if(ans>limit)ans-=pace;
        return ans;
    }
    public static long store(long current, long pace, long limit){
        long day = (limit-current)/pace;
        long ans = current+pace*day;
        if(ans<limit) ans+=pace;
        return ans;
    }
    public static boolean solve(long A, long B, long C, long D){
        long g = gcd(B,D);
        return solve_dis(A/g, B/g, C/g - (A%B>C ? 1 : 0), D/g);
    }
    public static boolean solve_dis(long A, long B, long C, long D){
        if(A<B) {
        	//System.out.println("sold out on first day.");
        	return false;
        }
        if(B>D) {
        	//System.out.println("snuke drink too much.");
        	return false;
        }
        
        
        if(B>C+1){
        	//System.out.println("unfortunately sold out.");
        	return false;
        }
        //System.out.println("snuke will buy apple juice forever.");
        return true;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        for(int t=0;t<T;t++) 
            System.out.println(solve(sc.nextLong(),sc.nextLong(),sc.nextLong(),sc.nextLong()) ? "Yes" : "No");
    }
}

Measured memory_bytes: 27412
#include <iostream>

auto initDays (int * a , int n , int & prev) -> void
{
    for (auto i = 1; i <= n; ++ i)
    {
        prev = (prev + 1) % 7;
        a [i] = prev;
    }
}

auto main () -> int
{
    const char * table [] =
    {
        "Monday" ,
        "Tuesday" ,
        "Wednesday" ,
        "Thursday" ,
        "Friday" ,
        "Saturday" ,
        "Sunday"
    };

    int day [13][32] = {{}};

    int p = 2;
    initDays (day [1] , 31, p);
    initDays (day [2] , 29, p);
    initDays (day [3] , 31, p);
    initDays (day [4] , 30, p);
    initDays (day [5] , 31, p);
    initDays (day [6] , 30, p);
    initDays (day [7] , 31, p);
    initDays (day [8] , 31, p);
    initDays (day [9] , 30, p);
    initDays (day [10] , 31, p);
    initDays (day [11] , 30, p);
    initDays (day [12] , 31, p);

    int m , d;
    while (std::cin >> m >> d && m && d)
    {
        std::cout << table [day [m] [d]] << std::endl;
    }
}

Measured memory_bytes: 3060
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

"""
状態をそのままdpのインデックスとする。
https://drken1215.hatenablog.com/entry/2019/02/10/014800
"""

def solve():
    def cost(k,i):
        ai = a[i]
        if k == 0:
            return ai
        elif k == 1:
            if ai == 0:
                return 2
            return ai&1
        elif k == 2:
            return 1-(ai&1)
        elif k == 3:
            if ai == 0:
                return 2
            return ai&1
        else:
            return ai

    l = I()
    a = IR(l)
    dp = [[float("inf")]*5 for i in range(l)]
    for i in range(5):
        dp[0][i] = cost(i,0)
    for i in range(l-1):
        ni = i+1
        for j in range(5):
            for k in range(j,5):
                c = cost(k,ni)
                nd = dp[i][j]+c
                if nd < dp[ni][k]:
                    dp[ni][k] = nd
    print(min(dp[l-1]))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 110644
#include <stdio.h>

int main(void)
{
  int i,j,N;
  int p[50]={};
  int m;

  scanf("%d",&N);

  for (i=0;i<N;i++){
    scanf("%d",&p[i]);
  }

  m = 0;
  for (i=0;i<N;i++){
    if (p[i] != i+1){
      m++;
    }
  }

  if ((m==0) || (m==2)){
    printf("YES");
  }

  else {
    printf("NO");
  }
  return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  vector<pair<int, int>> v;
  for (int i = 1; i <= 4096; i++) {
    int x = i * i * i * i * i;
    v.push_back({x, i});
    v.push_back({-x, -i});
  }
  v.push_back({0, 0});

  int x;
  cin >> x;
  for (auto a : v) for (auto b : v) {
    if (a.first - b.first == x) {
      cout << a.second << " " << b.second << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3752
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e8;
const ll linf=(ll)1e17+7;
const int N=2e5+7;

pii a[N],st,ed;
int n,tmp,f[N],sz;
dbl res;

il void rtt(){
	rep(i,1,n) a[i]=mp(inf-a[i].Y,a[i].X);
	st=mp(inf-st.Y,st.X);
	ed=mp(inf-ed.Y,ed.X);
}

int main(){
	scanf("%d%d%d%d",&st.X,&st.Y,&ed.X,&ed.Y);
	scanf("%d",&n);
	rep(i,1,n) scanf("%d%d",&a[i].X,&a[i].Y);
	while(st.X>ed.X||st.Y>ed.Y) rtt();
	rep(i,1,n) if(a[i].X<st.X||a[i].X>ed.X||a[i].Y<st.Y||a[i].Y>ed.Y){
		swap(a[i],a[n]);
		--n,--i;
	}
	cerr<<"n="<<n<<endl;
	cerr<<st.X<<","<<st.Y<<" "<<ed.X<<","<<ed.Y<<endl; 
	rep(i,1,n) cerr<<a[i].X<<","<<a[i].Y<<" ";cerr<<endl; 
	sort(a+1,a+n+1);
	rep(i,1,n){
		int p=lower_bound(f+1,f+sz+1,a[i].Y)-f;
		f[p]=a[i].Y;
		if(p>sz) sz=p;
	}
	dbl pi=acos(-1);
	dbl w1=5.0*pi-20.0;
	dbl w2=10.0*pi-20.0;
	dbl tot=100.00*(ed.X-st.X+ed.Y-st.Y);
	printf("%.15lf\n",tot+(sz==qmin(ed.Y-st.Y,ed.X-st.X)+1?(sz-1)*w1+w2:sz*w1));
	return 0;
}


Measured memory_bytes: 2560
n,m=map(int,input().split())
o,f,i=998244353,[1],1
while i<3*m+n:f+=[f[-1]*i%o];i+=1
c=lambda x,y=n-1:f[x]*pow(f[x-y]*f[y]%o,o-2,o)
a=c(-1)-n*c(n+m-2)
while~-n>m<i-n:m+=2;a-=c(n,m)*c(n-1+i-m>>1)
print(a%o)

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

int pow(int a,int n) {
    int ans = 1;
    rep(i,n) ans *= a;
    return ans;
}



int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A.at(i);
    map<int,int> res;
    for(auto val : A) {
        if(res.count(val)) 
            res[val]++;
        else 
            res[val] = 1;
        if(res.count(val+1)) 
            res[val+1]++;
        else 
            res[val+1] = 1;
        if(res.count(val-1)) 
            res[val-1]++;
        else 
            res[val-1] = 1;
    }
    int m = -1;
    int ans;
    for(auto x:res) {
        if(x.second > m) {
            m = x.second;
            ans = x.second;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5120
// ABC147-C HonestOrUnkind2
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
// cout << "\t" << endl;

int main() {
  int n;
  cin >> n;
  vector<vector<pair<int, bool>>> vr(n);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < a; j++) {
      int x;
      bool y;
      cin >> x >> y;
      vr.at(i).push_back(make_pair(--x, y));
    }
  }

  const int MAX = 15;
  int ans = 0;
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    bitset<MAX> bs = tmp;
    bool flag = true;
    for (int i = 0; i < n; i++) {
      if (!bs.test(i)) continue;
      for (auto itr = vr.at(i).begin(); itr != vr.at(i).end(); itr++) {
        if (bs.test(itr->first) != itr->second) {
          flag = false;
          break;
        }
      }
      if (!flag) break;
    }
    if (flag && bs.count() > ans) ans = bs.count();
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
char a[60][60];
bool b[60][60];
int c[60][60];
struct point
{
    int x;
    int y;
};
int calculate(int H,int W)
{
    int i,j,t=0;
    for(i=0;i<H;++i)
    {
        for(j=0;j<W;++j)
        {
            if(a[i][j]=='#'){++t;}
        }
    }
    return t;
}
int main()
{
    int H,W,i,result;
    while(~scanf("%d %d",&H,&W))
    {
        memset(a,0,sizeof(a));
        memset(b,true,sizeof(b));
        memset(c,0,sizeof(c));
        for(i=0;i<H;++i)
        {
            scanf("%s",a[i]);
        }
        c[0][0]=1;
        point t,mid;
        mid.x=0;
        mid.y=0;
        b[0][0]=false;
        queue<point> d;
        d.push(mid);
        while(d.size())
        {
            t=d.front();
            if(t.x==H-1&&t.y==W-1)
            {
                break;
            }
            d.pop();
            if(t.x+1<=H-1&&b[t.x+1][t.y]&&a[t.x+1][t.y]!='#')
            {
                b[t.x+1][t.y]=false;
                c[t.x+1][t.y]=c[t.x][t.y]+1;
                mid.x=t.x+1;
                mid.y=t.y;
                d.push(mid);
            }
            if(t.x-1>=0&&b[t.x-1][t.y]&&a[t.x-1][t.y]!='#')
            {
                b[t.x-1][t.y]=false;
                c[t.x-1][t.y]=c[t.x][t.y]+1;
                mid.x=t.x-1;
                mid.y=t.y;
                d.push(mid);
            }
            if(t.y-1>=0&&b[t.x][t.y-1]&&a[t.x][t.y-1]!='#')
            {
                b[t.x][t.y-1]=false;
                c[t.x][t.y-1]=c[t.x][t.y]+1;
                mid.y=t.y-1;
                mid.x=t.x;
                d.push(mid);
            }
            if(t.y+1<=W-1&&b[t.x][t.y+1]&&a[t.x][t.y+1]!='#')
            {
                b[t.x][t.y+1]=false;
                c[t.x][t.y+1]=c[t.x][t.y]+1;
                mid.y=t.y+1;
                mid.x=t.x;
                d.push(mid);
            }
        }
        result=H*W-calculate(H,W)-c[H-1][W-1];
        if(d.size()==0){printf("-1\n");}
        else{printf("%d\n",result);}
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using System.Text;

namespace AtCoder {
    public class Program {
        static int[] getKeys() {
            var Keys = Console.ReadLine().Split(' ');
            int N = Keys.Length;
            int[] Ns = new int[N];
            for (int i = 0; i < N; i++) {
                Ns[i] = int.Parse(Keys[i]);
            }
            return Ns;
        }
        static int[] getKeys(char delimiter) {
            var Keys = Console.ReadLine().Split(delimiter);
            int N = Keys.Length;
            int[] Ns = new int[N];
            for (int i = 0; i < N; i++) {
                Ns[i] = int.Parse(Keys[i]);
            }
            return Ns;
        }
        public static void Show<T>(T[,] map) {
            int H = map.GetLength(0);
            int W = map.GetLength(1);
            Console.WriteLine("-------------------------");
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    Console.Write(map[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine("-------------------------");
        }
        public static void Show<T>(T[,] map, string delimiter) {
            int H = map.GetLength(0);
            int W = map.GetLength(1);
            Console.WriteLine("-------------------------");
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    Console.Write(map[i, j] + delimiter);
                }
                Console.WriteLine();
            }
            Console.WriteLine("-------------------------");
        }
        public static void Show<T>(IEnumerable<T> ts) {
            foreach (var item in ts) {
                Console.Write(item + " ");
            }
            Console.WriteLine();
        }
        public static void Show<T>(IEnumerable<T> ts, string delimiter) {
            foreach (var item in ts) {
                Console.Write(item + delimiter);
            }
            Console.WriteLine();
        }
        static void Main() {
            int N = int.Parse(Console.ReadLine());
            var Key = getKeys();
            Dictionary<int, int> Count = new Dictionary<int, int>();
            for (int i = 0; i < N; i++) {
                if (Count.ContainsKey(Key[i])) {
                    Count[Key[i]]++;
                } else {
                    Count.Add(Key[i], 1);
                }
                if (Count.ContainsKey(Key[i] + 1)) {
                    Count[Key[i] + 1]++;
                } else {
                    Count.Add(Key[i] + 1, 1);
                }
                if (Count.ContainsKey(Key[i] - 1)) {
                    Count[Key[i] - 1]++;
                } else {
                    Count.Add(Key[i] - 1, 1);
                }
            }
            Console.WriteLine(Count.Values.Max());
        }
    }
}


Measured memory_bytes: 25056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  
  int n;
  cin >> n;
  
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    int c = 0;
    if(i % 2 == 0) {
      continue;
    }
    for(int j = 1; j <= n; j++) {
      if(i % j == 0) {
        c++;
      }
    }
    if(c == 8) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
#define MAX_N 300000
class union_find{
  int n;
  vector<int> par,rk,size,val;
  public:
  union_find(int max_n){
    n = max_n+1;
    for(int i=0;i<=n;i++){
      par.emplace_back(i);
      rk.emplace_back(0);
      size.emplace_back(1);
      val.emplace_back(-1);
    }
  }
  int root(int x){
    vector<int> nodes;
    while(x!=par[x]){
      nodes.emplace_back(x);
      x = par[x];
    }
    for(auto v:nodes){
      par[v] = x;
    }
    return x;
  }
  void unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x==y) return;
    if(rk[x]<rk[y]){
      par[x] = y;
      size[y] += size[x];
    }else{
      par[y] = x;
      if(rk[x]==rk[y]) rk[x]++;
      size[x] += size[y];
    }
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
  int treesize(int x){
    return size[root(x)];
  }
  void add_pval(int p){
    p = root(p);
    val[p]++;
  }
  int get_pval(int p){
    return val[root(p)];
  }
};
vector<ll> GT[MAX_N];
bool used_t[MAX_N]={};
void t_dfs(ll v,union_find &uf,ll par,set<int> &st){
  used_t[v] = true;
  if(uf.same(par,v)){
    uf.add_pval(par);
    st.insert(v);
  }
  for(auto nv:GT[v]){
    if(!used_t[nv]){
     t_dfs(nv,uf,par,st);
    }
  }
}
signed main(){
  init_io();
  ll n,k,l;
  cin >> n >> k >> l;
  union_find uft(n),ufl(n);
  vector<ll> p(k),q(k),r(l),s(l);
  vector<ll> ans(n,-1);
  map<P,ll> mp;
  for(int i=0;i<k;i++){
    cin >> p[i] >> q[i];
    p[i]--; q[i]--;
    ufl.unite(p[i],q[i]);
  }
  for(int i=0;i<l;i++){
    cin >> r[i] >> s[i];
    r[i]--; s[i]--;
    uft.unite(r[i],s[i]);
  }
  for(int i=0;i<n;i++){
    mp[P(uft.root(i),ufl.root(i))]++;
  }
  for(int i=0;i<n;i++){
    cout << mp[P(uft.root(i),ufl.root(i))] << " ";
  }
  cout << endl;
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	set<string> st;
	int n;

	cin >> n;

	while (n--) {
		string s;
		cin >> s;
		st.insert(s);
	}

	cout << st.size() << endl;

	return 0;
}


Measured memory_bytes: 19284
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef long long ll;
ll x;
ll p(ll x)
{
    return x*x*x*x*x;
}
int main()
{
    scanf("%lld",&x);
    for(int i=1;i<=200;i++)
        for(int j=-200;j<=i;j++)
    {
        if(p(i)-p(j)==x)
        {
            printf("%d %d\n",i,j);return 0;
        }
    }
}


Measured memory_bytes: 3828
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

LL gcd(LL m, LL n) {
    if (m < n) return gcd(n, m);
    if (n == 0) return m;
    else return gcd(n, m % n);

}
LL prime_factorize(long long n) {
    LL res = 0;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        while (n % p == 0) n /= p;
        res++;
    }
    if (n != 1) res++;
    return res;
}

int main() {
    ULL a, b; cin >> a >> b;
    ULL g = gcd(a, b);
    auto ans = prime_factorize(g);
    cout << ans + 1 << endl;;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main()
{
  string s;
  
  cin>>s;
  
  if(s=="abc"||s=="acb"||s=="bac"||s=="bca"||s=="cab"||s=="cba")
  {
	cout<<"Yes"<<endl;
  }
  else
  {
	cout<<"No"<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

inline long long in() {
  long long n = 0;
  char c = getchar_unlocked();
  while ('0' <= c && c <= '9') {
    n *= 10;
    n += (c - '0');
    c = getchar_unlocked();
  }
  return n;
}

inline void out(long long n) {
  long long N = n, rev; int count = 0;
  rev = N;
  if (N == 0) { putchar_unlocked('0'); return; }
  while ((rev % 10) == 0) { count++; rev /= 10;}
  rev = 0;
  while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10; }
  while (rev != 0) { putchar_unlocked(rev % 10 + '0'); rev /= 10; }
  while (count--) putchar_unlocked('0');
}

int main() {
  long long I = in(), O = in(), T = in(), J = in(), L = in();
  long long n = (I&1?I-1:I) + (J&1?J-1:J) + (L&1?L-1:L);
  if (I && J && L) {
    long m = (I&1?I-1:I-2) + (J&1?J-1:J-2) + (L&1?L-1:L-2) + 3;
    out((n<m?m:n) + O);
  } else {
    out(n + O);
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String input = sc.next();
		
		if(n%2==1) {
			System.out.println("No");
			return;
		}
		
		for(int i = 0; i < n/2; i++) {
			if(input.charAt(i)!=input.charAt(n/2+i)) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
using namespace std;

int main () {
	int r, c;
	cin >> r >> c;
	long long ans;
	if(c % 2 == 0) {
		ans = c / 2;
		ans *= r;
	}else {
		int cc = c / 2;
		cc += 1;
		ans = 0;
		if(r % 2 == 0) {
			ans += (long long)cc * (long long)(r / 2);
			ans += (long long)(cc - 1) * (long long)(r / 2);
		}else {
			ans += (long long)cc * (long long)((r / 2) + 1);
			ans += (long long)(cc - 1) * (long long)(r / 2);
		}
	}
	if(r == 1 || c == 1) {
		cout << "1" << "\n";
	}else {
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 888
import itertools

h, w, k = map(int, input().split())
c = [0]*h
d = [0]*h
for i in range(h):
    c[i] = input()

H = list(itertools.product([0,1], repeat=h))
W = list(itertools.product([0,1], repeat=w))

ans = 0

for i in H:
    for j in W:
        for e in range(h):
                d[e] = c[e]
        #print(d)
        a = 0
        for x in range(h):
            if i[x] == 1:
                d[x] = 'xxxxxx'
            else:
                for y in range(w):
                    if j[y] == 1:
                        d[x] = d[x][:y] + 'x' + d[x][y+1:]
            for D in d[x]:
                if D == '#':
                    a += 1
        #print(d, i, j)
        if a == k:
            ans += 1
print(ans)

Measured memory_bytes: 9248