akhauriyash/Code-Regression huggingface dataset:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, W = map(int, readline().split())
    G = [readline().strip() for _ in range(H)]

    row = [False] * H
    col = [False] * W

    for i in range(H):
        for j in range(W):
            if G[i][j] == '#':
                row[i] = col[j] = True

    for i in range(H):
        if not row[i]:
            continue
        for j in range(W):
            if col[j]:
                print(G[i][j], end='')
        print('')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define pb push_back
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
#endif
    int x;
    cin >> x;
    string s = (x >= 30) ? "Yes" : "No";
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main(){
	const char TABLE[6][5] = {{'a','b','c','d','e'},{'f','g','h','i','j'},{'k','l','m','n','o'},{'p','q','r','s','t'},{'u','v','w','x','y'},{'z','.','?','!',' '}};
	string s;
	while(cin>>s){
		string ans="";
		for(int i=0;i<s.size();i+=2){
			if(s[i]>='1'&&s[i]<='6'&&s[i+1]>='1'&&s[i+1]<='5'&&i+1<s.size()){
				ans+=TABLE[s[i]-'0'-1][s[i+1]-'0'-1];
			}else{
				ans="NA";
				break;
			}
		}
		cout<<ans<<"\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
#define N_MAX 2000002
const ll MOD = 1000000007;


ll inv[N_MAX],fac[N_MAX],finv[N_MAX];

void init(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        fac[i]=fac[i-1]*(ll) i%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll inv_(ll n){
    if(n == 1) return 1;
    else return MOD-inv_(MOD%n)*(MOD/n)%MOD;
}

ll comb(ll n, ll r){
  ll ans;
  if(n < r){
      ans = 0;
  }else{
      ans = (fac[n]*finv[r])%MOD;
      ans = (ans*finv[n-r])%MOD;
      ans = (ans+MOD)%MOD;
  }
  return ans;
}

ll S11[1000001];
ll S12[1000001];
ll S21[1000001];
ll S22[1000001];

ll calc(ll r,ll c){
    ll ans = 0;
    r++; c++;
    for(int i = 0; i <= c; i++) {
        ans += comb(r+i-1, i);
    }
    // cout << ans << endl;
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll r1, r2, c1, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    init();
    r1--;c1--;
    ll ans = calc(r2, c2);
    ans -= calc(r2, c1);
    ans -= calc(r1, c2);
    ans += calc(r1, c1);
    ans %= MOD;
    ans += MOD;
    ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 47744
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(long long int i=a; i<n; i++)
#define rloop(i,a,n) for(long long int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define mod 1000000007
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define stkll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1;
    while(power>0)
    {
        if(power%2==1)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1)
    {
        return false;
    }
    if(n<=3)
    {
        return true;
    }
    if(n%2==0 || n%3==0)
    {
        return false;
    }
    for(ll i=5; (i*i)<=n; i+=6)
    {
        if(n%i==0 || n%(i+2)==0)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second<b.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y)
{
    return ((x%mod)*(P(y,mod-2,mod)%mod))%mod;
}
int main()
{
    FAST
    FO
    FI
    ll n,a,b;
    IN n>>a>>b;
    if((b-a)%2LL==0LL)
    {
        ll temp1= a-1LL;
        ll a1=1LL;
        ll b1= b-temp1;
        ll ans1= temp1;
        if((b1-a1)%2LL==1LL)
        {
            ans1++;
            b1--;
        }
        ans1+=((b1-a1)/2LL);
        ll temp2= n-b;
        ll a2= a+temp2;
        ll b2= n;
        ll ans2= temp2;
        if((b2-a2)%2LL==1LL)
        {
            ans2++;
            a2++;
        }
        ans2+=((b2-a2)/2LL);
        OUT min({(b-a)/2LL,b-1LL,n-a,ans1,ans2})<<endl
    }
    else
    {
        ll temp1= a-1LL;
        ll a1=1LL;
        ll b1= b-temp1;
        ll ans1= temp1;
        if((b1-a1)%2LL==1LL)
        {
            ans1++;
            b1--;
        }
        ans1+=((b1-a1)/2LL);
        ll temp2= n-b;
        ll a2= a+temp2;
        ll b2= n;
        ll ans2= temp2;
        if((b2-a2)%2LL==1LL)
        {
            ans2++;
            a2++;
        }
        ans2+=((b2-a2)/2LL);
        OUT min({ans1,ans2,b-1LL,n-a})<<endl
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  string s;
  cin >> n >> s;
  if (n == 1 || n % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 0; i < n/2; i++) {
    if (s[i] != s[i+n/2]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 3548
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict

MOD = 10**9+7
N = int(input())
dic = defaultdict(int)
zero = 0
left_zero = 0
right_zero = 0
for i in range(N):
    a, b = map(int, input().split())
    if b < 0:
        a = -a
        b = -b
    if a == 0 and b == 0:
        zero += 1
    elif a == 0:
        left_zero += 1
    elif b == 0:
        right_zero += 1
    else:
        g = math.gcd(a, b)
        a //= g
        b //= g
        dic[a,b] += 1
done = set()
ans = 1
for a,b in dic:
    k = (a, b)
    if k in done: continue
    rk = (-b, a)
    rk2 = (b, -a)
    done.add(k)
    done.add(rk)
    done.add(rk2)
    c = pow(2, dic[k], MOD)-1
    if rk in dic:
        c += pow(2, dic[rk], MOD)-1
    if rk2 in dic:
        c += pow(2, dic[rk2], MOD)-1
    c += 1
    ans *= c
    ans %= MOD
c1 = pow(2, left_zero, MOD)-1
c2 = pow(2, right_zero, MOD)-1
c = c1+c2+1
ans *= c
ans += zero
print((ans-1)%MOD)


Measured memory_bytes: 175880
#%%
x = input()

if len(x) <= 2:
	ans = 0
elif int(x) >= 2000:
	ans = 1
else:
	if len(x) == 3:
		a = x[0]
		b = x[1:]
	else:
		a = x[0:2]
		b = x[2:]
	a = int(''.join(a))
	b = int(''.join(b))
	if a*5 >= b:
		ans = 1
	else:
		ans = 0
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <cassert>
using namespace std;

const double PI = 3.14159265359;

int main() {
    double R; cin >> R;
    printf("%.10f\n", 2*PI*R);
    return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <vector>

using namespace std;

/// <summary>p???k??°??§?????????????????????????±???????</summary>
/// <param name='k'>??°??°</param>
/// <param name='p'>?????§?????????</param>
/// <param name='n'>???????????°</param>
/// <param name='w'>??????</param>
long long getCapaciry(int k, long long p, int n, vector<int> w)
{
	// k??°????????????
	int count = 0;
	for (int i = 0; i < k; i++)
	{
		long long sum = 0;

		// p????¶????????????§??????
		while (sum + w[count] <= p)
		{
			sum += w[count];
			count++;

			// ??????????????????
			if (count == n)
				return n;
		}
	}

	return count;
}

int main()
{
	long long sum = 0;
	int N, K;
	cin >> N >> K;

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

	long long right = sum + 1;
	long long left = 0;
	long long mid;
	while (left + 1 < right)
	{
		mid = (left + right) / 2;

		if (getCapaciry(K, mid, N, W) >= N)
			right = mid;
		else
			left = mid;
	}

	cout << right << endl;

	return 0;
}

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

int main() {
  // 入力
  int N;
  cin >> N;

  vector<int> A;
  for (int i=0; i<N; i++) {
    int A_tmp;
    cin >> A_tmp;
    A.push_back(A_tmp);
  }
  
  string s = "APPROVED";
  for (int i=0; i<N; i++) {
    if (A.at(i)%2==0) {
      if (A.at(i)%3!=0 && A.at(i)%5!=0) {
        s = "DENIED";
        break;
      }
    }
  }
  
  // 出力
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long long long int
int main(){
    int  n,m;
    cin>>n>>m;
    vector<int> a(n);
    int i,sum = 0;
    for(i=0;i<m;i++){
        cin>>a[i];
        sum+=a[i];
    }
    if(n-sum<0)
        cout<<"-1";
    else
        cout<<n-sum;

}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    double a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    double dp[n+1][n+1];
    memset(dp,0,sizeof(dp));
    dp[1][0]=1-a[0];
    for(int i=2;i<=n;i++)
        dp[i][0]=dp[i-1][0]*(1-a[i-1]);
    dp[1][1]=a[0];
    for(int i=2;i<=n;i++)
        dp[i][i]=dp[i-1][i-1]*a[i-1];
    for(int i=1;i<=n;i++){
        for(int j=1;j<i;j++)
            dp[i][j]=dp[i-1][j-1]*a[i-1]+dp[i-1][j]*(1-a[i-1]);
    }
    double ans=0;
    for(int i=0;i<=n;i++){
        if(i>n-i) ans+=dp[n][i];
    }
    cout<<fixed<<setprecision(10)<<ans;
    return 0;
}


Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=5010;
const ll mod=1e9+7;


int main(){
  int n,d; cin >> n >> d;
  cout << (n+2*d)/(2*d+1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b) { return a>b?a:b;}
ll min(ll a,ll b) { return a<b?a:b;}

int n,m;
char a[7][7];
char b[7][7];
bool solve(int k)
{ 
  int c =0 ;
  fi(i,0,n)
  {
    fi(j,0,m)
      {c+=(b[i][j] == '#');}
      
  }
  
  return (c==k);
}
int main() {
  
    int k;
    cin>>n>>m>>k;
    
    fi(i,0,n)
    {
      fi(j,0,m)
        {cin>>a[i][j];
         b[i][j] = a[i][j];}
    }
    int cn=0;
    for(int i=0;i<pow(2,n);i++)
    {
        int no = i;
        vector<int> row;
        while(no)
        {
          row.pb(no%2);
          no/=2;
        }

        while(row.size() < n)
          row.pb(0);
        
       
        for(int r = 0;r<n;r++)
        {
          if(row[r]==1)
          {
            for(int c = 0;c<m;c++)
              b[r][c] = 'R';
          }
        }
        int c[n][m];
        fi(ii,0,n)
        {
          fi(jj,0,m)
            c[ii][jj] = b[ii][jj];
        }
            
            for(int j=0;j<pow(2,m);j++)
            {
              int no = j;
              vector<int> col;
              while(no)
              {
                col.pb(no%2);
                no/=2;
              }
              while(col.size()<m)
                col.pb(0);
             
              for(int c = 0;c<m;c++)
              {
                if(col[c] == 1)
                {
                  for(int tm = 0;tm<n;tm++)
                    b[tm][c] = 'R';
                }
              }
              cn+=solve(k);
              fi(ii,0,n)
              {
                fi(jj,0,m)
                  b[ii][jj] = c[ii][jj];
              }
              
            }
      
      for(int ii=0;ii<n;ii++)
      {
        for(int jj=0;jj<m;jj++)
          b[ii][jj] = a[ii][jj];
      }
    }
    cout<<cn;

 
    
    return 0;
}


Measured memory_bytes: 4084
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());
            var a = int.Parse(ReadLine());

            WriteLine(n * n - a);
        }
    }
}



Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

typedef signed long long ll;
typedef long double ld;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) x.begin(), x.end()

#define DEBUG

int main()
{
	int n, num;
	char mark;
	bool card[4][13];

	rep(i, 4) rep(j, 13)
	{
		card[i][j] = false;
	}

	cin >> n;
	rep(i, n)
	{
		cin >> mark >> num;
		switch (mark)
		{
		case 'S':
			card[0][num - 1] = true;
			break;

		case 'H':
			card[1][num - 1] = true;
			break;

		case 'C':
			card[2][num - 1] = true;
			break;

		case 'D':
			card[3][num - 1] = true;
			break;

		default:
			break;
		}
	}

	rep(i, 4) rep(j, 13)
	{
		if (card[i][j] == false)
		{
			switch (i)
			{
			case 0:
				cout << "S " << j + 1 << endl;
				break;

			case 1:
				cout << "H " << j + 1 << endl;
				break;

			case 2:
				cout << "C " << j + 1 << endl;
				break;

			case 3:
				cout << "D " << j + 1 << endl;
				break;

			default:
				break;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 3088
//https://atcoder.jp/contests/agc031/tasks/agc031_b
//B - Reversi
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
constexpr ll MOD=1e9+7;
int main() {
#if LOCAL&0
    std::ifstream in("./test/sample-1.in");
    //std::ifstream in("./input.txt");
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N; cin>>N;
    vector<ll> cn(N+1);
    vector<ll> cn2; cn2.reserve(N+1); //重複部分を消したもの
    cn2.push_back(1);
    FOR(i,1,N+1){
        ll c; cin>>c;
        cn.at(i)=c;
        if (cn.at(i-1)!=cn.at(i)) cn2.push_back(c);
    }
    unordered_map<ll,ll> colnum;
    vector<ll> ansv(cn2.size());
    ansv[0]=1;
    FOR(i,1,cn2.size()){
        auto c=cn2.at(i);
        auto& m = colnum[c];
        ansv[i] = (ansv[i-1] + m)%MOD;
        m = (m + ansv[i-1])%MOD;
    }    
    cout<<ansv.back()<<endl;
    return 0;
}

Measured memory_bytes: 13256
#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 main() {
  int n;
  cin >> n;
  vector<int> as(n);
  rep(i, n) {
    cin >> as[i];
  }

  map<int, bool> m;
  string ans = "YES";
  rep(i, n) {
    int num = as[i];
    if (m.count(num)) {
      ans = "NO";
      break;
    }
    m.insert(make_pair(num, true));
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 10368
/**
 * Title: D - Knight
 * Url: https://atcoder.jp/contests/abc145/tasks/abc145_d
 */
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long

const int MAX = 10000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int x, y; cin >> x >> y;
    if((x+y)%3!=0) {
        cout << 0 << endl;
        return 0;
    }
    vector<pair<int, int>> paths;
    int q = (x+y)/3;
    for(int a=0; a<=q; a++) {
        int b = q-a;
        if(x==a+2*b&y==2*a+b) {
            paths.push_back(pair<int, int>(a, b));
        }
    }

    // 前処理
    COMinit();

    ll ans = 0;
    for(auto path:paths) {
        ans += COM(path.first+path.second, path.first);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 234752
function Main(input) {
 	// 1行目がinput[0], 2行目がinput[1], …に入る
	var tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(tmp[0], 10);
	var b = parseInt(tmp[1], 10);
    var result =  (a * b) % 2 ==1 ? "Odd" : "Even"
	//出力
	console.log('%s',result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));

Measured memory_bytes: 21064
#include<stdio.h>
int main(){
   long long n,k,x,y,sum=0;
   scanf("%lld%lld",&n,&k);
   scanf("%lld%lld",&x,&y);
   if(n<=k){
      sum=n*x;
   }
   else{
      sum=(k*x);
      sum+=((n-k)*y);
   }
   printf("%lld\n",sum);

   return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

ll gcd(ll n, ll m){

    if(m > n)  return gcd(m, n);

    ll r = n % m;
    if(r == 0) return m;
    else       return gcd(m, r);
}

ll lcm(ll n, ll m){
    return n / gcd(n, m) * m;
}

int main(){

    int n; cin >> n;

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

    ll tnow = t[0];
    ll anow = a[0];
    for(int i=1; i<n; i++){
        ll mt = tnow/t[i];
        ll ma = anow/a[i];
        if(tnow % t[i] != 0) mt++;
        if(anow % a[i] != 0) ma++;
        ll m = max(mt, ma);

        tnow = t[i]*m;
        anow = a[i]*m;
    }

    cout << tnow + anow;

    return 0;
}

Measured memory_bytes: 256
n,w = map(int,input().split())
info = [[0,0]]+[list(map(int,input().split())) for i in range(n)]

## dp[i][j]:i番目までのアイテムを重さjのナップサックに詰めるときの最大価値
dp = [[0]*(w+1) for i in range(n+1)]
for i in range(n+1):
  for j in range(w+1):
    if j-info[i][0]>=0:
      dp[i][j] = max(dp[i-1][j],dp[i-1][j-info[i][0]]+info[i][1])
    else:
      dp[i][j] = dp[i-1][j]

print(dp[n][w])


Measured memory_bytes: 120428
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


//naosu
long int gcd(long int a,long int b){
  long int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


long int lcm(long int a,long int b){
  return a/gcd(a,b)*b;
}


long int f(long int n,long int c,long int d){
  long int cnt=n/c+n/d-n/lcm(c,d);
  return n-cnt;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  char s[10];
  scanf("%s",s);
  if(s[2]-s[3] || s[4]-s[5]){
    printf("No\n");
  }
  else{
    printf("Yes\n");
  }

  return 0;
}

Measured memory_bytes: 1640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  //INPUT
  int N,M;
  cin >> N >> M;
  
  int H[N];
  for(int i=0;i<N;i++) cin >> H[i];
  
  bool flag[N];
  for(int i=0;i<N;i++) flag[i] = true;
  
  /*
  int A[N];
  int B[N];
  
  for(int i=0;i<N;i++){
    cin >> A[i];
  	cin >> B[i];
  }
  */
  int A,B;
  
  for(int i=0;i<M;i++){
    cin >> A >> B;
    if(H[A-1] == H[B-1]){
      flag[A-1] = false;
      flag[B-1] = false;
    }
    if(H[A-1] > H[B-1]){
      flag[B-1] = false;
    }
    if(H[A-1] < H[B-1]){
      flag[A-1] = false;
    }
  }
  
  //flag count
  int answer=0;
  for(int i=0;i<N;i++){
   if(flag[i]==true) answer++; 
  }
  
  cout << answer <<endl;
}

Measured memory_bytes: 4040
#include<bits/stdc++.h>
#include<unistd.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    string s;
    int N;cin>>N;
    int l=0,r=N;
    vector<int> seat(N+1);
    cout<<0<<endl;
    fflush(stdout);
    cin>>s;
    if(s=="Male"){
        seat[0]=seat[N]=0;
    }
    else if(s=="Female"){
        seat[0]=seat[N]=1;
    }
    else return 0;
    REP(i,19){
        int mid=(l+r)/2;
        cout<<mid<<endl;
        fflush(stdout);
        cin>>s;
        if(s=="Male"){
            seat[mid]=0;
        }
        else if(s=="Female"){
            seat[mid]=1;
        }
        else return 0;
        if(((mid-l)&1)^(seat[l]^seat[mid])){
            r=mid;
        }
        else{
            l=mid;
        }
    }
}


Measured memory_bytes: 1236
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
    long long  N,K,ans=1;
    cin >> N >> K;
    long long M=K;
    ans *=K;
    for(int i=1;i<N;i++){
        ans *= (K-1);
    }

    cout << ans << endl;
}

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

int main()
{
    int n, m, k;
    char a[6][6];
    cin >> n >> m >> k;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    int sol = 0;
    for(int i = 0; i < (1 << n); i++) {
        for(int j = 0; j < (1 << m); j++) {
            int s = 0;
            for(int k = 0; k < n; k++) {
                for(int p = 0; p < m; p++) {
                    if(!(i & (1 << k)) && !(j & (1 << p)) && a[k][p] == '#') {
                        //cout << k << p << '\n';
                        s++;
                    }
                }
            }
            if(s == k) {
                sol++;
            }
        }
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

map<ll,ll> M;

int main(){
    ll N,C=0,X;
    cin >> N;
    rep(i,N){
        cin >> X;
        M[X]++;
    }
    for(auto P : M){
        if(P.second>1){
            C+=P.second-1;
        }
    }
    if(C%2==0){
        cout << N-C << endl;
    }
    else{
        cout << N-C-1 << endl;
    }
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std; 
 
#define FAST_I0 ios_base::sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"
#define int long long 
#define vvi vector<int>
#define pb push_back

void think(){
	int a,b,c,d;
	cin >>  a >> b >> c >> d;
	int x = a*c;
	x = max(x,a*d);
	x = max(x,b*c);
	x = max(x,b*d);
	cout << x << endl;
}

int32_t main(){
	FAST_I0; 
	int testcase = 1; 
//	cin >> testcase;
	while(testcase--){
		think();
		}
	return 0;	

}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define Would
#define you
#define please

int sosuu(int A) {
	if (A <= 1) return 0;
	int saidai = pow(A, 0.5);
	for (int i = 2; i <= saidai; i++) {
		if (A % i == 0) return 0;
	}
	return 1;
}

int main() {
	//おまじない
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;

	int suuretu[56] = {};
	int iretakazu = 0;

	for (int i = 3; i <= 55555; i += 10) {
		if (sosuu(i) == 1) {
			//int dame = 0;
			//if (iretakazu >= 4) {
			//	rep1(i1, iretakazu) {
			//		for (int i2 = i1 + 1; i2 <= iretakazu; i2++) {
			//			for (int i3 = i2 + 1; i3 <= iretakazu; i3++) {
			//				for (int i4 = i3 + 1; i4 <= iretakazu; i4++) {
			//					int goukei = suuretu[i1] + suuretu[i2] + suuretu[i3] + suuretu[i4] + i;
			//					if (sosuu(goukei) == 1) dame = 1;
			//				}
			//			}
			//		}
			//	}
			//}
			//if (dame == 0) {
				suuretu[iretakazu + 1] = i;
				iretakazu++;
			//}
		}
		if (iretakazu == N) break;
	}

	rep1(i, N) cout << suuretu[i] << " ";
	cout << "\n";
	Would you please return 0;
}

Measured memory_bytes: 256
local s = io.read()
local n = #s
local t = {}
for i = 1, n do
  t[i] = s:byte(i, i)
end
local alpha = {}
for i = 1, 26 do alpha[i] = false end
for i = 1, n do
  alpha[t[i] - 96] = true
end
local found = false
for i = 1, 26 do
  if not alpha[i] then
    print(string.char(96 + i))
    found = true
    break
  end
end
if not found then print("None") end


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

struct RQ {
 using RQV = LL;
 using RQRV = LL;
 static RQV Zero(){ return 0; }
 static RQRV RZero(){ return 0; }
 // addition
 static RQV f(RQV a,RQV b){ return max(a,b); }
 // update function
 static void uf(RQV& a,RQV b){ a = b; }
 // effect of range queries n-sized
 static void ef(RQV& a,RQRV b,int n){  }
 // range query update
 static void ruf(RQRV& a,RQRV b){  }
 // comparation
 static bool cmp(RQV l,RQV r){ return l<=r; }
 struct Node{
  RQV v; RQRV r;
 };
 int N;
 vector<Node> V;

 void init(int n){
  N=1; while (N<n) N*=2;
  V.assign(N*2,{Zero(),RZero()});
 }

 void spread(int i,int z){
  if (z!=1) {
   ef(V[i*2].v,V[i].r,z/2);
   ruf(V[i*2].r,V[i].r);
   ef(V[i*2+1].v,V[i].r,z/2);
   ruf(V[i*2+1].r,V[i].r);
  }
  V[i].r = RZero();
 }

 void upd(int p,RQV v){
  for(int d=N; d>=1; d/=2) spread(p/d,d);
  p+=N; uf(V[p].v,v);
  int z=1;
  while(p!=1){
   p/=2; z*=2;
   V[p].v = f(V[p*2].v,V[p*2+1].v);
   ef(V[p].v,V[p].r,z);
  }
 }

 void updr(int l,int r,RQRV v,int a=0,int b=0,int i=-1){
  if(i==-1){ a=0; b=N; i=1; }
  spread(i,b-a);
  if(r<=a || b<=l) return;
  if(l<=a && b<=r){
   ruf(V[i].r,v);
   ef(V[i].v,V[i].r,b-a);
   return;
  }
  updr(l,r,v,a,(a+b)/2,i*2);
  updr(l,r,v,(a+b)/2,b,i*2+1);
  V[i].v = f(V[i*2].v,V[i*2+1].v);
  ef(V[i].v,V[i].r,b-a);
 }

 RQV query(int l,int r,int a=0,int b=0,int i=-1){
  if(i==-1){ a=0; b=N; i=1; }
  if(r<=a || b<=l) return Zero();
  if(l<=a && b<=r) return V[i].v;
  RQV q1 = query(l,r,a,(a+b)/2,i*2);
  RQV q2 = query(l,r,(a+b)/2,b,i*2+1);
  q1 = f(q1,q2);
  ef(q1,V[i].r,min(r,b)-max(l,a));
  return q1;
 }

 int find(int l,RQV v,int a=0,int b=0,int i=-1){
  static RQV x;
  if(i==-1){ a=0; b=N; i=1; x=Zero(); }
  if(b<=l) return N;
  if(l<=a && !cmp(v,f(x,V[i].v))){ x=f(x,V[i].v); return N; }
  if(b-a==1) return a;
  int q1 = find(l,v,a,(a+b)/2,i*2);
  if(q1!=N) return q1;
  return find(l,v,(a+b)/2,b,i*2+1);
 }
};

int N,Q;
RQ G;

int main(){
 scanf("%d%d",&N,&Q);
 G.init(N);
 rep(i,N){
  int a; scanf("%d",&a);
  G.upd(i,a);
 }
 rep(q,Q){
  int c; scanf("%d",&c);
  if(c==1){
   int x,v; scanf("%d%d",&x,&v); x--;
   G.upd(x,v);
  }
  if(c==2){
   int l,r; scanf("%d%d",&l,&r); l--;
   printf("%lld\n",G.query(l,r));
  }
  if(c==3){
   int x,v; scanf("%d%d",&x,&v); x--;
   printf("%d\n",min(G.find(x,v),N)+1);
  }
 }
 
 return 0;
}


Measured memory_bytes: 11464
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
count = sum(B)

for x in range(len(A)):
    if x != len(A) - 1:
        if A[x] + 1 == A[x + 1]:
            count += C[A[x]-1]
print(count)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long h, w;
    long long s, ss = 0, mi = 1e9;
    cin >> h >> w;
    s = h * w;
    for (int i = 1; i < h; i++) {
        ss += w;
        long long s2 = (h - i) * w;
        if (s2 % 2 == 0) mi = min(mi, abs(ss - s2/2));
        else {
            long long d = h - i;
            long long ss1 = (d - 1)/2 * w;
            long long ss2 = (d + 1)/2 * w;
            long long sma = max({ss, ss1, ss2});
            long long smi = min({ss, ss1, ss2});
            mi = min(mi, sma - smi);
            ss1 = d * (w - 1) / 2;
            ss2 = d * (w + 1) / 2;
            sma = max({ss, ss1, ss2});
            smi = min({ss, ss1, ss2});
            mi = min(mi, sma - smi);
        }
    }
    ss = 0;
    swap(h, w);
    for (int i = 1; i < h; i++) {
        ss += w;
        long long s2 = s - ss;
        if (s2 % 2 == 0) mi = min(mi, abs(ss - s2/2));
        else {
            long long d = h - i;
            long long ss1 = (d - 1)/2 * w;
            long long ss2 = (d + 1)/2 * w;
            long long sma = max({ss, ss1, ss2});
            long long smi = min({ss, ss1, ss2});
            mi = min(mi, sma - smi);
            ss1 = d * (w - 1) / 2;
            ss2 = d * (w + 1) / 2;
            sma = max({ss, ss1, ss2});
            smi = min({ss, ss1, ss2});
            mi = min(mi, sma - smi);
        }
    }
    cout << mi;
    return 0;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

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

int cnt[100100];

vector<int> v[100000];

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

    int N, M;
    std::cin >> N >> M;

    for(int i=0;i<N;++i){
        int X;
        std::cin >> X;

        ++cnt[X];
    }

    for(int i=1;i<=100000;++i){
        for(int j=0;j<(cnt[i]&1);++j){
            v[i % M].emplace_back(i);
        }
    }

    for(int i=1;i<=100000;++i){
        for(int j=0;j<cnt[i]-(cnt[i]&1);++j){
            v[i % M].emplace_back(i);
        }
    }

    int res = 0;
    for(int i=0;i<M;++i){
        int i2 = (M - i) % M, v_size = v[i].size();
        if(i2 < i){break;}
        if(i == i2){
            for(int j=0;j<v_size-(v_size&1);j+=2){
                ++res;
                --cnt[v[i][j]];
                --cnt[v[i][j+1]];
                // std::cout << "double: " << v[i][j] << ", " << v[i][j+1] << std::endl;
            }
        }else{
            int mn = min(v[i].size(), v[i2].size());
            for(int j=0;j<mn;++j){
                ++res;
                --cnt[v[i][j]];
                --cnt[v[i2][j]];
                // std::cout << "single: " << v[i][j] << ", " << v[i2][j] << std::endl;
            }
        }
    }

    for(int i=1;i<=100000;++i){
        res += cnt[i] / 2;
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 6144
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

#define N 100

int g[N][N];
int n,m;

void warshall_floyd(void){
    rep(i,n)rep(j,n)
        if(g[i][j]==0)g[i][j]=inf;
    rep(k,n)rep(i,n)rep(j,n){
        if(i==j)continue;
        if(g[i][j]>g[i][k]+g[k][j])
            g[i][j]=g[i][k]+g[k][j];
    }
}

void run(){
    int t,l,A,H;
    cin>>n>>t>>l>>m>>A>>H;
    if(!n)return;
    MEMSET(g);
    vector<bool> f(n);
    f[A]=f[H]=true;
    rep(i,l){
        int x;
        cin>>x;
        f[x]=true;
    }
    rep(i,m){
        int x,y,z;
        cin>>x>>y>>z;
        g[x][y]=g[y][x]=z;
    }
    warshall_floyd();
    rep(i,n){
        rep(j,n){
            if(!f[i]||!f[j]||g[i][j]>t)g[i][j]=inf;
        }
    }
    warshall_floyd();
    // rep(i,n){rep(j,n)cout<<g[i][j]<<sp;cout<<endl;}
    if(g[A][H]==inf)cout<<"Help!"<<endl;
    else cout<<g[A][H]+max(0ll,g[A][H]-t)<<endl;
    run();
}


Measured memory_bytes: 3316
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let h: usize = input();
    let w: usize = input();
    let s: Vec<Vec<char>> = (0..h)
        .map(|_| input::<String>().chars().collect())
        .collect();

    let mut sum_b = 0;
    for i in 0..h {
        for j in 0..w {
            if s[i][j] == '#' {
                sum_b += 1;
            }
        }
    }

    let mut q = std::collections::VecDeque::new();
    q.push_back((0, 0));
    let mut d = vec![vec![-1i64; w]; h];
    d[0][0] = 0;
    while !q.is_empty() {
        let (x, y): (i64, i64) = q.pop_front().unwrap();
        for &(dx, dy) in &[(1, 0), (0, 1), (-1, 0), (0, -1)] {
            if x + dx < 0 || x + dx >= h as i64 || y + dy < 0 || y + dy >= w as i64 {
                continue;
            }
            let (px, py) = ((x + dx) as usize, (y + dy) as usize);
            if s[px][py] == '#' {
                continue;
            }
            if d[px][py] >= 0 {
                continue;
            }
            d[px][py] = d[x as usize][y as usize] + 1;
            q.push_back((px as i64, py as i64));
        }
    }

    println!(
        "{}",
        if d[h - 1][w - 1] < 0 {
            -1
        } else {
            h as i64 * w as i64 - d[h - 1][w - 1] - 1 - sum_b
        }
    );
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
const int maxn=1000+10;
int n;
ll f[maxn];
int main(){
	scanf("%d",&n);
	f[0]=2ll;
	f[1]=1ll;
	for(int i=2;i<=n;i++)
		f[i]=f[i-1]+f[i-2];
	printf("%lld\n",f[n]);
	return 0;
}

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

int main()
{
    int A, B;
    int C, D;
    int L;

    cin >> L;
    cin >> A >> B >> C >> D;

    while (1){
        A -= C;
        B -= D;
        L--;
        if (A <= 0 && B <= 0){
            break;
        }
    }
/*    while (A > 0){
        A -= C;
        L--;
    }
    while (B > 0){
        B -= D;
        L--;
    }*/
    cout << L << endl;
    return (0);
}



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

constexpr int mod = 1e5;

int main() {
    int M, N, K;
    cin >> M >> N >> K;
    vector<string> v(M);
    for(int i=0; i<M; ++i) {
        cin >> v[i];
    }
    vector<vector<int>> J(M+1, vector<int>(N+1)), O(M+1, vector<int>(N+1));
    for(int i=0; i<M; ++i) {
        for(int j=0; j<N; ++j) {
            J[i+1][j+1] = v[i][j] == 'J';
            O[i+1][j+1] = v[i][j] == 'O';
        }
    }
    for(int i=0; i<M+1; ++i) {
        for(int j=0; j<N; ++j) {
            J[i][j+1] += J[i][j];
            O[i][j+1] += O[i][j];
        }
    }
    for(int j=0; j<N+1; ++j) {
        for(int i=0; i<M; ++i) {
            J[i+1][j] += J[i][j];
            O[i+1][j] += O[i][j];
        }
    }
    for(int i=0; i<K; ++i) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int res_j = J[c][d] - J[a-1][d] - J[c][b-1] + J[a-1][b-1];
        int res_o = O[c][d] - O[a-1][d] - O[c][b-1] + O[a-1][b-1];
        int res_i = (c - a + 1) * (d - b + 1) - res_j - res_o;
        cout << res_j << ' ' << res_o << ' ' << res_i << endl;
    }
}


Measured memory_bytes: 11676
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int main(){
    char s[4];
    scanf("%s",s);
    if(s[1]=='B'){
        printf("ARC\n");
    }else{
        printf("ABC\n");
    }
    return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
Scanner scan=new Scanner(System.in);
String a=scan.next();
int ans=0;
if(a.charAt(0)=='a'||a.charAt(1)=='a'||a.charAt(2)=='a') {
	ans++;
}if(a.charAt(0)=='b'||a.charAt(1)=='b'||a.charAt(2)=='b') {
	ans++;
}if(a.charAt(0)=='c'||a.charAt(1)=='c'||a.charAt(2)=='c') {
	ans++;
}
if(ans==3) {
	System.out.println("Yes");
}
else {
	System.out.println("No");
}
	}
	}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef list<int>L;
int main(void){
	int n,q;
	int x,y,z;
	int i;
	L li[1000];
	cin>>n>>q;
	for(i=0;i<q;i++){
		cin>>x>>y;
		if(x==0){
			cin>>z;
			li[y].push_back(z);
		}
		else if(x==1){
			if(!li[y].empty()){
				for(auto it=li[y].begin();it!=li[y].end();it++){
					if(it!=li[y].begin())	cout<<" ";
					cout<<*it;
				}
				cout<<endl;
			}
			else	cout<<endl;
		}
		else{
			cin>>z;
			li[z].splice(li[z].end(),li[y]);
		}
	}
	return 0;
}
			


Measured memory_bytes: 18720
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
    ll n,i,j,cc=0;cin>>n;
    string str;
    cin>>str;
    map<string,ll>check;
    check[str]++;
    for(i=1;i<n;i++){
        char ch=str[str.size()-1];
        cin>>str;
        if(ch!=str[0] || check[str]>0){
            cout<<"No"<<endl;
            return 0;
        }
        check[str]++;
    }
    cout<<"Yes"<<endl;
return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ll long long int
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)
#define sp(n) setprecision(n)
#define mp make_pair
#define mt make_tuple
#define pi 3.14159265358979323846264
#define MOD 1000000007

using namespace std;
/*
int primeFactors(ll n)  
{  ll f=0;
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        f++;
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            f++; 
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        f++;
        
 return f;        
}  
  
bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}
 
ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = ((C[i - 1][j - 1] + C[i - 1][j]))%MOD;}}}
    return C[n][k];
 }
 
ll gcd(ll a, ll b){if (b == 0)
        return a;return gcd(b, a % b);}
 
ll expmod(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}
//define temp-functions below
 
 
//some definitions and global variables
vector<ll> primes;
void storePrime(ll n){
    fori(n){
        if(isPrime(i+1)&&(n%(i+1)==0)){primes.push_back(i+1);}
    }
}*/


int main(){ //ake cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
ll n;ll k;cin>>n>>k;
ll b[n+1]={0};ll x=0;
for(ll i=0;i<k;i++){
    ll c;cin>>c;
    for(ll i=0;i<c;i++){ll h;cin>>h;b[h]=1;}
    
}
for(ll i=1;i<=n;i++) {if(b[i]!=1) x++;}
cout<<x;

return 0;}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// leave to tomorrow anything that can be done today
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    map<int,int> cont;
    rep(i,2,sqrt(n)+1){
        if(n%i==0){
            while(n%i==0){
                n/=i;
                cont[i]++;
            }
        }
    }
    if(n!=1){
        cont[n]++;
    }
    // cout<<cont[2]<<endl;
    ll ans=0;
    for(auto e: cont){
        // cout<<e.first<<" "<<endl;
        int cont2=1;
        while(e.second>=cont2){
            e.second-=cont2++;
        }
        ans+=cont2-1; 
    }
    cout<<ans<<'\n';
    return 0;   
}   

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, cnt = 0, sum = 0;
  cin >> n >> m;
  vector <int> a(n);
  for (int i = 0; i < n; ++i){
	cin >> a[i];
	sum += a[i];
  }
  (sum % (4*m)) ? sum = sum / (4*m) + 1 : sum /= (4*m);
  for (int i = 0; i < n; ++i){
	if (a[i] >= sum){
		++cnt;
	}
}
	(cnt >=m) ? cout << "Yes\n" : cout << "No\n";
return 0;
}

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

using namespace std;

int gcd(int u, int v)
{
    return (v != 0) ? gcd(v, u % v) : u;
}


int main() {
    long long int A, B, C, D;
    cin >> A >> B >> C >> D;
    A = A - 1;

    cout << (B - (((B / C) + (B / D)) - (B / ((C * D) / gcd(C, D))))) - (A - (((A / C) + (A / D)) - (A / ((C * D) / gcd(C, D)))));
}


Measured memory_bytes: 256
use proconio::input;
fn main (){
let mut _a: i128;
let mut _b: i128;
let mut _c: i128;


input! {
    a: i128,
    b: i128,
    c: i128,

}
 

let x = a + b ;
let y = b + c ;
let z = a + c ;

if x < y && x < z  {
    println!("{}",x);
}else if y < x && y < z {
    println!("{}",y);
}else if z < x && z < y{
    println!("{}",z);

}else {
    println!("{}",x);
}

}


Measured memory_bytes: 2104
#include <stdio.h>
int n, d, ans, l;
int x[10][10];
int s[200];
int main() {
	scanf("%d%d", &n, &d);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			scanf("%d", &x[i][j]);
		}
	}
	for (int i = 0; i < 200; i++)s[i] = i * i;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			l = 0;
			for (int k = 0; k < d; k++) {
				l += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}
			for (int k = 0; k < 200; k++) {
				if (l == s[k])ans++;
			}
		}
	}
	printf("%d\n", ans);
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int main(){
  int n;
  scanf("%d",&n);
  printf("%d\n",n * (n + 1) / 2);
}


Measured memory_bytes: 256
from collections import defaultdict
from itertools import combinations


def get_pair(s, cmb):
    g, h = 0, 0
    for i in range(n):
        if i in cmb:
            g <<= 5
            g += s[i]
        else:
            h <<= 5
            h += s[i]
    return g, h


def patterns(k, d, e):
    ret = 0
    f = defaultdict(int)
    for cmb in combinations(range(n), k):
        f[get_pair(d, cmb)] += 1
    for cmb in combinations(range(n), k):
        ret += f[get_pair(e, cmb)]
    return ret


def solve(n, b):
    d = b[:n]
    e = b[2 * n - 1:n - 1:-1]
    ans = 0

    if n % 2 == 0:
        for k in range(n // 2):
            ans += 2 * patterns(k, d, e)
        ans += patterns(n // 2, d, e)
    else:
        for k in range(n // 2 + 1):
            ans += 2 * patterns(k, d, e)
    return ans


n = int(input())
s = input()
a = ord('a') - 1
b = [ord(c) - a for c in s]
print(solve(n, b))


Measured memory_bytes: 29448
from collections import defaultdict
import heapq

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

if sum(a) < sum(b):
    ans = -1
else:
    ans = 0
    res = 0
    rep = []
    for i in range(N):
        diff = b[i] - a[i]
        if diff > 0:
            ans += 1
            res += diff
        elif diff < 0:
            heapq.heappush(rep, diff)
    while res > 0:
        ans += 1
        res += heapq.heappop(rep)

print(ans)


Measured memory_bytes: 18740
def main():
    H, W, A, B = (int(i) for i in input().split())
    for i in range(B):
        print("0"*A+"1"*(W-A))
    for i in range(H-B):
        print("1"*A+"0"*(W-A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 39792
H, W = (int(i) for i in input().split())

inp = [[_ for _ in input().strip()] for i in range(H)]

for i in inp:
    i.insert(0, ".")
    i.append(".")
a = ["." for _ in range(W+2)]
inp.append(a)
inp.insert(0, a)

for h in range(H):
    for w in range(W):
        if(inp[h][w] == "#"):
            if inp[h+1][w] == "." and \
                    inp[h][w+1] == "." and \
                    inp[h-1][w] == "." and \
                    inp[h][w-1] == ".":
                print("No")
                exit(0)
print("Yes")


Measured memory_bytes: 3064