akhauriyash/Code-Regression huggingface dataset:
from queue import Queue

q = Queue()
Q=[]
time=0
N = list(map(int, input().split()))
qt=N[1]
for i  in range(N[0]):
  Q.append(list(map(str, input().split())))
for i in range(N[0]):
  q.put(Q[i])

while q.empty()==False:
  i=q.get()
  i[1]=str(int(i[1])-qt)
  if int(i[1])<=0:
    time=time+int(i[1])+qt
    print(i[0],time)
    pass
  else:
    time=time+qt
    q.put(i)





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

using namespace std;

typedef long long int ll;

ll n;

ll f(ll k){
  ll tmp = n;
  while(n % k == 0){
    n /= k;
  }
  if(n % k == 1){
    n = tmp;
    return 1;
  }
  n = tmp;
  return 0;
}

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

  cin >> n;
  ll t = n - 1;
  ll cnt = 0, ans = 0;
  for(int i = 2; (ll)i * i <= t; i++){
    if(t % i == 0){
      ans++;
      if(t / i != i) ans++;
    }
  }
  if(t > 1) ans++;

  vector < ll > v;
  for(int i = 2; (ll)i * i <= n; i++){
    if(n % i == 0){
      v.push_back(i);
      if(n / i != i) v.push_back(n / i);
    }
  }
  if(n > 1) v.push_back(n);

  for(auto i : v){
    ans += f(i);
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int r,g,b,n;cin >> r >> g >> b >> n;
	int ret = 0;
	rep(i,n+1)rep(j,n+1){
		int rest = n-r*i - g*j;
		ret += (rest >= 0 && rest %b == 0);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<string>
using namespace std;

int main(){
    int N;
    vector<int64_t> L(90);
    
    L.at(0) = 2;
    L.at(1) = 1;
    
    //Nの読み込み
    cin >> N;
    
    if(N == 1){
        cout << L.at(1) <<endl;
    }
    else{
        for(int i=2;i<N+1;i++){
            L.at(i) = L.at(i-1) + L.at(i-2);
        }
        cout << L.at(N) << endl;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H, W, K, S):
    ans = [[0] * W for _ in range(H)]
    V = []
    k = 1
    for i in range(H):
        t = 0
        for j in range(W):
            if S[i][j] == '#':
                V.append((i, j, k))
                ans[i][j] = k
                t = k
                k += 1
                for l in range(j-1, -1, -1):
                    if ans[i][l] == 0:
                        ans[i][l] = t
            else:
                ans[i][j] = t
    
    for i in range(1, H):
        for j in range(W):
            if ans[i][j] == 0:
                ans[i][j] = ans[i-1][j]

    for i in range(H-2, -1, -1):
        for j in range(W):
            if ans[i][j] == 0:
                ans[i][j] = ans[i+1][j]

    for r in ans:
        print(' '.join(map(str, r)))


def main():
    H, W, K = read_int_n()
    S = [read_str() for _ in range(H)]
    (slv(H, W, K, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 17376
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
using namespace std;

struct Point{
    int x;
    int y;
};


int main(){
    int N;
    cin >> N;
    int xy[N][2];
    int zw[N][2];

    for (int i = 0; i < N; ++i){
        cin >> xy[i][0] >> xy[i][1];
        zw[i][0] = xy[i][0] + xy[i][1];
        zw[i][1] = xy[i][0] - xy[i][1];
    }

    int z_MAX = zw[0][0], w_MAX = zw[0][1],
        z_min = zw[0][0], w_min = zw[0][1];

    for (int i = 1; i < N; ++i){
        z_MAX = max(z_MAX, zw[i][0]);
        z_min = min(z_min, zw[i][0]);
        w_MAX = max(w_MAX, zw[i][1]);
        w_min = min(w_min, zw[i][1]);
    }

    cout << max(z_MAX - z_min, w_MAX - w_min) << endl;

}



Measured memory_bytes: 6684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

const char nl = '\n';

void solve()
{
    string s, t; cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        ans += s[i] != t[i];
    }
    cout << ans << nl;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    solve();
    return 0;
}

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

typedef long long ll;
typedef long double ld;

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

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

int main(){

    ll N, K, X, Y;

    cin >> N >> K >> X >> Y;

    cout << N * X + (N >= K + 1 ? (N - K) * (Y - X) : 0) << endl;

    return 0;
}

Measured memory_bytes: 256
ABCD = list(map(int, input().split()))

t = ABCD[0]
a = ABCD[2]
tAttackFlag = True
while (t > 0 and a > 0):
    if (tAttackFlag):
        a -= ABCD[1]
    else:
        t -= ABCD[3]
    tAttackFlag = not bool(tAttackFlag)

if (t <= 0):
    print("No")
else:
    print("Yes")

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> v(N);
  rep(i, N){
    cin >> v.at(i);
  }
  vector<bool> isBad(N);
  rep(i, M){
    int A, B;
    cin >> A >> B;
    if(v.at(A-1) > v.at(B-1)) {
      isBad.at(B-1) = true;
    } else if(v.at(A-1) < v.at(B-1)){
      isBad.at(A-1) = true;
    } else {
      isBad.at(A-1) = true;
      isBad.at(B-1) = true;
    }
  }
  int ans = 0;
  rep(i, N){
    if(!isBad.at(i)) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
#define w(t) int t;cin>>t;while(t--)
#define pb   push_back
#define mk   make_pair
#define u_s  unordered_set
#define endl "\n"
#define prDouble(x) cout<<fixed<<setprecision(10)<<x
#define ll long long int
#define ipair pair<int,int>
#define all(x) (x).begin(), (x).end()

const int mod=pow(10,9)+7;

bool compare(pair<int,int>p1,pair<int,int>p2){
    return p1.second<p2.first;
}
void open_file(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}
void fast_io(){
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr);
      
}
/*
  ll C(ll n,ll k){
  
  if(k>n)return 0;
  
  ll ans=1;

  if(k>n-k)
    k=n-k;
  for(ll i=1;i<=k;i++)
    ans*=(n-i+1),ans/=i;

  return ans;
  }
  unsigned long long fact(long long a)
  {
  unsigned long long res=1;
  for(long long i=a;i>0;i--)
    res*=i;
  return res;
  }
  unsigned long long comb(long long a,long long b)
  {
  if((a-b)<b) b=a-b;
  if(a<=19) return fact(a)/(fact(a-b)*fact(b));
  if(a==b||b==0) return 1;
  if(b==1) return a;
  return comb(a-1,b-1)+comb(a-1,b);
  }
*/



void solve(){
     
  int n,k; cin>>n>>k; vector<int>A(n);

  for(int i=0;i<n;i++)cin>>A[i];
  
  bool dp[k+2];
  sort(all(A));
  memset(dp,0,sizeof dp);
  
  for(int i=1;i<=k;i++){

      for(int move:A){

         if(move>i)continue;
         if(dp[i-move]==0)
          dp[i]=1;
      }
  }
  
  cout<<(dp[k]==1 ? "First" : "Second");
}
int main(){

//  open_file();
  fast_io();
  
  solve();
  
  return 0;  
    
}


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

int debug=0;

long long x;
long long n500=0;
long long n5=0;

int main()
{
    cin >> x;

    n500 = x / 500;
    x -= 500 * n500;
    n5 = x /5;

    cout << n500*1000 + n5 *5 << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    int n; cin >> n;
    int res = 0;
    REP(i,n+1){
        if(i%2==0) continue;
        set<int> facts;
        for (int j=1;j*j<=n;j++){

            if(i % j == 0){
                facts.insert(j);
                facts.insert(i/j);
            }
        }
        if (facts.size()==8) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

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

    int ans=K;
    REP(i,N-1) ans*=K-1;
    cout<<ans<<endl;

}


Measured memory_bytes: 256
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))
if N >= M:
    print(0)
    quit()
X_dis = []
for i in range(1, M):
    X_dis.append(X[i] - X[i-1])

# N-1個のX_disから小さいものをN-M個選んで足す
X_dis = sorted(X_dis)
ans = sum(X_dis[:M-N])
print(ans)

Measured memory_bytes: 58408
/**Bismillahir Rahmanir Raheem
    Author:Refatul Fahad**/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e5 + 5;
const ll M = (ll)1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}

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

int main() {

    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1;
    ///cin>>test;
    for(int cs=1; cs<=test; ++cs) {
        int n,x,ans;
        //cin>>n;
        for(int i=1;i<=5;++i){
            cin>>x;
            if(x==0)ans=i;
        }
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 3608
#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false)
int main()
{   long long int b;
  //long int a[100000];
  cin>>b;
  b=b-1;
  b=((b+1)*b)/2;
  cout<<b;

}

Measured memory_bytes: 256
program ABC083B;
var 
	n,a,b,r,i,j,s: integer;
begin
	read(n);
	read(a);
	read(b);
	r:=0;
	for i:=1 to n do begin
		s:=0;
		j:=i;
		while j>0 do begin
			s:=s+(j mod 10);
			j:=j div 10;
		end;
		if (a<=s) and (s<=b) then begin
			r:=r+i;
		end;
	end;
	writeln(r);
end.


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b,m;
    cin >> a >> b >> m;
    ll al[a],bl[b],ans=INF;
    for (ll i=0;i<a;i++){
        cin >> al[i];
    }
    for (ll i=0;i<b;i++){
        cin >> bl[i];
    }
    for (ll i=0;i<m;i++){
        ll x,y,c;
        cin >> x >> y >> c;
        ans=min(ans,al[x-1]+bl[y-1]-c);
    }
    sort(al,al+a);
    sort(bl,bl+b);
    ans=min(ans,al[0]+bl[0]);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cstdint>

using namespace std;

#define N 100005

bool ok = true;

int64_t paths[N];
vector<int> adj[N];

int64_t dfs(int cur, int root)
{
	int64_t out = paths[cur];

	if (adj[cur].size() > 1)
	{
		out += paths[cur];
	}

	for (int next : adj[cur])
	{
		if (next == root) continue;

		int64_t in = dfs(next, cur);
		if (in > paths[cur]) ok = false;

		out -= in;
	}

	if (out < 0) ok = false;
	if (out > paths[cur]) ok = false;

	return out;
}

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

	int n;
	cin >> n;

	for (int i=1 ; i<=n ; i++)
	{
		cin >> paths[i];
	}

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

		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	int64_t out = dfs(1, 0);
	if (out != 0) ok = false;

	if (ok) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<int,int>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
   lli A,B,C,L,R,N,M,K,X=0,Y=0,W,H=INF,sum=0,num=0,flag=0;string S,T,O;
   cin >> N;
   Vec(P,lli,0,0);
   Vec(Q,lli,0,0);
   rep(i,0,N){
      cin >> A;
      if(i%2)Q.pb(A);
      else P.pb(A);
   }
   if(N%2){
      Rev(P);
      rep(i,0,P.size())cout << P[i] << " ";
      rep(i,0,Q.size())cout << Q[i] << " ";
      cout << endl;
   }
   else{
      Rev(Q);
      rep(i,0,Q.size())cout << Q[i] << " ";
      rep(i,0,P.size())cout << P[i] << " ";
      cout << endl;
   }
}

Measured memory_bytes: 3948
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(),(obj).end()

using namespace std;


int main() {
	speed;
	int n;
	cin >> n;
	int ans = n;
	if (n % 2 == 1)ans = n * 2;
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i ,n ,total ,pasta ,juice;
  scanf( "%d" ,&pasta );

  for( i=0 ; i<2 ; i++ ){
    scanf( "%d" ,&n );
    if( n < pasta ){
      pasta = n;
    }
  }

  scanf( "%d" ,&juice );
  scanf( "%d" ,&n );
  if( juice > n ){
    juice = n;
  }
 
  printf( "%d\n" ,pasta + juice - 50 );
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <tuple>
#include <cmath>
#define ll 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 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
using namespace std;

int N;
int hap[100000 + 10][3];
ll dp[100000 + 10][3]; // dp[k][a]:k日目に活動aを行う場合の最大幸福度

int main(void) {
    cin >> N;
    REP(i, 1, N) {
        cin >> hap[i][0] >> hap[i][1] >> hap[i][2];
    }
    
    dp[1][0] = hap[1][0];
    dp[1][1] = hap[1][1];
    dp[1][2] = hap[1][2];
    
    REP(i, 2, N) {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + hap[i][0];
        dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + hap[i][1];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + hap[i][2];
        rep(j, 3) {
            // printf("dp[%d][%d]=%lld\n", i, j, dp[i][j]);
        }
    }
    
    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;
    return 0;
}



Measured memory_bytes: 3840
///cREATED bY BERNARB.01
#include<bits/stdc++.h>
using namespace std;

bool srt(pair<int, string> a, pair<int , string> b){
    if(a.first == b.first) return a.second < b.second;
    return a.first > b.first ;
}
int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i = 0; i<n; i++){
        string s;
        cin >> s;
        mp[s]++;
    }
    pair<int, string> p[n];
    int j = 0;
    for(auto x : mp){
        p[j] = {x.second, x.first};
        j++;
    }
    sort(p, p+mp.size(), srt);
    int last = p[0].first;
    for(int i=0; i<mp.size(); i++){
        if(p[i].first==last) cout << p[i].second << endl;
        else break;
    }
    return 0;
}


Measured memory_bytes: 29312
#include<bits/stdc++.h>
typedef long long ll;
#define endl "\n"

using namespace std;

//ll const N = 32000;

int main()
{
    int A, B, C, K;
    scanf("%d %d %d %d", &A, &B, &C, &K);

    for(int i = 0; i < K; i++)
    {
        if(B > A && B < C)break;

        if(B <= A)
        {
            B *= 2;
            continue;
        }
        if(B > A)
        {
            C *= 2;
            continue;
        }
    }

    if(C > B && B > A)cout << "Yes";
    else cout << "No";

    return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> x = {a, b, c};
  sort(x.begin(), x.end());

  if (x.at(0) == 5 && x.at(1) == 5 && x.at(2) == 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll s;
  cin >> s;
  
  ll a = 1000000000;
  ll b = 1;
  ll c = (a - s%a)%a;
  ll d = (c+s)/a;
  
  cout << "0 0 " << a << " " << b << " " << c << " " << d << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a,const void *b){
	return *(int *)b-*(int *)a;
}

int main(){
	int N,M;
	int i,c;
	int result=0;
	
	scanf("%d %d",&N,&M);
	
	int X[M];
	int deff[M-1];
	
	for(i=0;i<M;i++){
		scanf("%d",&X[i]);
	}
	
	if(N>M)	result=0;
	else{
		qsort(X,M,sizeof(int),compare);
		
		for(i=0;i<M-1;i++){
			deff[i]=X[i]-X[i+1];
			deff[i]=abs(deff[i]);
		}
		
		if(N==1)	result=X[0]-X[M-1];
		else{
			qsort(deff,M-1,sizeof(int),compare);
			
			for(i=0;i<N-1;i++){
				deff[i]=0;
			}
			
			for(i=N-1;i<M-1;i++){
				result+=deff[i];
			}
		}
	}
	
	printf("%d",result);
	
	return 0;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef set<int>        si;

template<typename T> T sgn (T x)      {return x<0? -1:x!=0; }
template<typename T> T gcd (T a, T b) {return a ? gcd (b % a, a) : b; }
//pi=acos(-1)
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define popcount __builtin_popcount
#define eb emplace_back
#define emp emplace
#define ss second
#define ff first
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}

int n;
int v[N];
string s, t, ans;
void solve(){
    ans="No";
    reads(s);
    reads(t);
    n = sz(s);
    if(sz(t)==n+1){
        if(t.substr(0,n)==s)ans="Yes";
    }
    printf("%s\n", ans.data());
}

int main(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;//scanf("%d",&t);
    while(t--)solve();
}

Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  (B) <= (A) && (A) <= (C)
#define AIN(A, B, C) assert(IN(A, B, C))
void solve(){
    int n,x;
    cin>>n>>x;
    int ar[n];
    f(i,0,n)cin>>ar[i];
    sort(ar,ar+n);
    int ans=0;
    f(i,0,x)ans+=ar[i];
    cout<<ans;
}
int main() {
    ios;
	int t=1;
	//cin>>t;
	while(t--)solve();
 
    
}


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

int main(){
	string a,b,c;
	cin >> a >> b >> c;
	cout << a[0] << b[1] << c[2] << endl;
	return 0;

}




Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    int[] input = readln.split.to!(int[]);
    int W = input[0];
    int H = input[1];
    int N = input[2];
    int ans = 0;
    int[] point = readln.split.to!(int[]);
    foreach(int i; 1..N) {
        int[] _point = readln.split.to!(int[]);
        int dx = _point[0]-point[0];
        int dy = _point[1]-point[1];
        if (dx*dy > 0) {
            dx = abs(dx);
            dy = abs(dy);
            ans += min(dx, dy) + max(dx-dy, dy-dx);
        } else {
            ans += abs(dx)+abs(dy);
        }
        point = _point;
    }
    ans.writeln;
}

Measured memory_bytes: 2504
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
using namespace std;
int num = 1000000007;
long long facctorialMethod(int k) {
	long long sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum = (i*sum) % num;
	}
	return sum;
}
int main() {
	int N, M;	cin >> N >> M;
	if (abs(N - M) > 1) {
		cout << "0" << endl;
		return 0;
	}
	long long ans = 0;
	if (N == M) {
		ans = (facctorialMethod(N) * facctorialMethod(M) * 2) % num;
		cout << ans << endl;
		cin >> N;
		return 0;
	}
	ans = (facctorialMethod(N) * facctorialMethod(M)) % num;
	cout << ans << endl;
	cin >> N;
}

Measured memory_bytes: 256
#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, m;
    cin >> n >> m;
    int a[n];
    int sum=0;
    rep(i,n) {
        cin >> a[i];
        sum += a[i];
    }
    sort(a, a+n, greater<int>());
    if (a[m-1] >= ceil(float(sum)/(4*m))) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<iomanip>
using namespace std;

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

	vector<int> pv(n);
	for (auto& p : pv) {
		cin >> p;
	}

	int sumMax = 0;
	for (int i = 0; i < k; ++i) {
		sumMax += pv[i];
	}

	int maxI = 0;
	int maxJ = k - 1;
	int curMax = sumMax;
	int i = 1;
	for (int j = k; j < n; ++j) {
		curMax -= pv[i - 1];
		curMax += pv[j];
		if (sumMax < curMax) {
			sumMax = curMax;
			maxI = i;
			maxJ = j;
		}
		++i;
	}

	double ret = 0.0;
	for (int a = maxI; a <= maxJ; ++a) {
		double c = (double)pv[a];
		for (int b = 1; b <= pv[a]; ++b) {
			ret += (double)b / c;
		}
	}

	cout << fixed;
	cout << setprecision(10) << ret << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<ctype.h>
using namespace std;

int main(){
    string str;
    getline(cin,str);
    for(int i=0;i<str.size();i++){
        if(isupper(str[i])==0){
            str[i] = toupper(str[i]);
            cout << str[i] ;
            continue;
        }
        else{
            str[i] = tolower(str[i]);
            cout << str[i] ;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono>
#include <climits>
#include <unordered_map>
#include <iomanip> 

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;

void dfs(int st, vector<vector<int>> &g, vector<int> &visited, vector<int> &topo_sort){
	visited[st] = 1;
	for(int i = 0; i < g[st].size(); i++){
		if (visited[g[st][i]] == 0)
			dfs(g[st][i], g, visited, topo_sort);
	}
	topo_sort.pb(st);
} 

int main(){
	fast;
	#ifdef LOCAL_PROJECT
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif

	auto start = high_resolution_clock::now(); 

	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(n);
	vector<int> in_deg(n, 0);
	for(int i = 0; i < m ; i++){
		int x, y;
		cin >> x >> y;
		g[x-1].pb(y-1);
		in_deg[y-1]++;
	}
	vector<int> topo_sort;
	vector<int> visited(n, 0);

	for(int i = 0; i < n; i++){
		if (in_deg[i] == 0)
			dfs(i, g, visited, topo_sort);
	}

	reverse(topo_sort.begin(), topo_sort.end());

	vector<int> dp(n, 0);

	for(int i = 0; i < n; i++){
		int node = topo_sort[i];
		for(int j = 0; j < g[node].size(); j++){
			dp[g[node][j]] = max(dp[g[node][j]], 1 + dp[node]);
		}
	}

	int ans = -1;
	for(int i = 0; i < n; i++)
		ans = max(ans, dp[i]);

	cout << ans <<"\n";

	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << fixed << setprecision(9) << double(duration.count()) / 1000000 << endl; 

	return 0;
}


Measured memory_bytes: 13688
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int cnt=0;
    for(int i=a;i<=b;i++){
        if(c%i==0){
            cnt++;
        }
    }
    
    cout << cnt << endl;
}


Measured memory_bytes: 3088
x=range(int(input()))
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
_=0
P+=[P[0]]
for j in x:
    i = j+1
    _+=P[j][0]*P[i][1]-P[j][1]*P[i][0]
print(_*0.5)

Measured memory_bytes: 7728
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

int A, B;

int main() {
    cin >> A >> B;
    auto x = B * 10;
    auto y = (B + 1) * 10;
    for (int i = x; i < y; ++i) {
        if (static_cast<int>(i * 0.08) == A) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, L;
    cin >> N >> L;
    vector<ll> O(N);
    rep(i, N) O[i] = L + i;
    sort(O.begin(), O.end(), [](ll &a, ll &b) { return abs(a) > abs(b); });
    O.pop_back();
    cout << accumulate(O.begin(), O.end(), 0LL) << endl;
    return 0;
}


Measured memory_bytes: 3624
from collections import defaultdict

ans,n = 0,int(input())
a_list = list(map(int,input().split()))
a_dict = defaultdict(int)
for i in range(n):
    a_dict[a_list[i]]+=1
for key,value in a_dict.items():
    if value>key:
        ans += value-key
    elif value<key:
        ans += value
print(ans)

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

int main() {
  int i;
  int a[100000];
  int b[100000];

  for (int i = 0; i < 100000; i++) {
    a[i] = 0;
    b[i] = 0;
  }

  int n;
  int temp;
  long int sum = 0;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%d%d", &a[i], &b[i]);
  }

  for (i = n - 1; i >= 0; i--) {
    if ((a[i]+sum) % b[i] == 0) {
      temp = 0;
    } else {
      temp = b[i] - ((a[i]+sum) % b[i]);
    }
    sum += temp;
  }

  printf("%ld", sum);

  return 0;
}


Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static int a;
        static int b;

        static void Main(string[] args)
        {
            //[summary]A - New Year
            var line = ReadLine();
            a = line[0];
            b = line[1];

            string s = Console.ReadLine();

            if (IsPostalCode(s))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static bool IsPostalCode(string s)
        {
            var hyphen = s.Substring(a, 1);

            if (hyphen == "-")
            {
                if (s.Replace("-", "").Length == a + b)
                {
                    return true;
                }
            }

            return false;
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x, i = 0;
		while (true) {
			i++;
			x = scanner.nextInt();

			if (x == 0)
				break;

			System.out.println("Case " + i + ": " + x);
		}
	}
}

Measured memory_bytes: 44780
#include <bits/stdc++.h>
using namespace std ;
#define int long long
int32_t main() 
{
    int n, x, t ;
    cin >> n >> x >> t ;
    if (n % x == 0 ) {
        cout << t * (n / x) << endl;
    }
    else {
        cout << t * ( (n /x) + 1 ) << endl ;
    }
    return 0 ;
}

Measured memory_bytes: 3628
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

a,b=input().rstrip().split(" ")
if a==b:
    print("H")
else:
    print("D")

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]), b = int.Parse(input[1]), q = int.Parse(input[2]);

            long[] s = new long[a];
            for (int i=0; i<a; i++) s[i] = long.Parse(Console.ReadLine());

            long[] t = new long[b];
            for (int i=0; i<b; i++) t[i] = long.Parse(Console.ReadLine()); 

            for (int i=0; i<q; i++)
            {
                long x = long.Parse(Console.ReadLine());
                int al = -1, bl = -1;
                int ar = a, br = b;
                while (ar - al > 1)
                {
                    int ap = (ar + al) / 2;
                    if (s[ap] > x) ar = ap;
                    else al = ap;
                } 
                while (br -bl > 1)
                {
                    int bp = (br + bl) / 2;
                    if (t[bp] > x) br = bp;
                    else bl = bp;
                }
                
                long alPos, arPos, blPos, brPos;
                if (al == -1) alPos = -10000000000;
                else alPos = s[al];
                if (ar == a) arPos = 20000000000;
                else arPos = s[ar];
                if (bl == -1) blPos = -10000000000; 
                else blPos = t[bl];
                if (br == b) brPos = 20000000000;
                else brPos = t[br];
                long ans1 = Math.Max(arPos, brPos) - x;
                long ans2 = x - Math.Min(alPos, blPos);
                long aNear = Math.Min(arPos-x, x-alPos);
                long bNear = Math.Min(brPos-x, x-blPos);
                long ans3 = aNear + bNear + Math.Min(aNear, bNear);
                long ans = Math.Min(ans1, Math.Min(ans2, ans3));
                Console.WriteLine(ans);

            }
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 17616
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    string s = to_string(n);
    int ans = 0;
    rep(i,s.size())if(s[i]=='2')ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    ll M;
    cin >> M;
    ll sum=0,ans=0;
    rep(i,M){
        ll d,c;
        cin >> d >> c;
        sum+=d*c;
        ans+=c;
    }
    while(sum>9){
        ll divided=sum/10;
        ans+=divided;
        sum%=10;
        sum+=divided;
    }
    cout << ans-1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   for(int i=0;i<(n);++i)
#define SORT(c)    sort((c).begin(),(c).end())
#define CLR(a)     memset((&a), 0 ,sizeof(a))//clear memory
#define dump(x)    cerr << #x << " = " << (x) << endl;//debug
#define debug(x)   cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define EPS        1e-10//sample:if((double)>=(double)+EPS)
//cin,cout release
//std::cin.tie(0);
//ios::sync_with_stdio(false);

using namespace std;



int main(){
  int n;
  cin>>n;
  int a[105][105]={};
  int s,t,u;
  //int maxs=INT_MIN,maxu=INT_MIN;
  rep(i,n){
    cin>>s>>t;
    rep(j,t){
      cin>>u;
      a[s][u]=1;
      //u=max(maxu,u);
    }
    //s=max(maxs,s);
  }
  //int maxn=max(maxs,maxu);
  
  rep(i,n){
    rep(j,n){
      cout<<a[i+1][j+1];
      if(j!=n-1)cout<<" ";
    }cout<<endl;
  }
  

  return 0;
}



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

int main(){
    int a,b,c,k;
    int count = 0;
    int ans = 0;
    cin >> a >> b >> c >> k;
    if(k <= a){
        ans = k;
    }
    else if(k > a && k <= a+b){
        ans = a;
    }
    else if(k > a+b){
        ans = a - (k - a - b);
    }
    cout << ans << endl;

}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
//自作関数
template<class T> ll llpow(T x,T n){ll ans=1;while(n--){ans*=x;}return ans;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
    const long double PI = (acos(-1));
    const long double eps=1e-9;

long long INF = 1LL<<60;
void xlfp(double x){printf("%.10lf\n",x);}

long double f(long double a,long double b,long double x){
    if(a*a*b<=2*x){
        return atan(2*(a*a*b-x)/(a*a*a));
    }
    else{
        return PI/2-atan(2*x/(a*b*b));
    }
}
int main(){
    long double a,b,x;
    cin>>a>>b>>x;
    xlfp(f(a,b,x)/PI*180);
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main() {
	map<char, char>toupper;
	toupper['a'] = 'A';
	toupper['b'] = 'B';
	toupper['c'] = 'C';
	toupper['d'] = 'D';
	toupper['e'] = 'E';
	toupper['f'] = 'F';
	toupper['g'] = 'G';
	toupper['h'] = 'H';
	toupper['i'] = 'I';
	toupper['j'] = 'J';
	toupper['k'] = 'K';
	toupper['l'] = 'L';
	toupper['m'] = 'M';
	toupper['n'] = 'N';
	toupper['o'] = 'O';
	toupper['p'] = 'P';
	toupper['q'] = 'Q';
	toupper['r'] = 'R';
	toupper['s'] = 'S';
	toupper['t'] = 'T';
	toupper['u'] = 'U';
	toupper['v'] = 'V';
	toupper['w'] = 'W';
	toupper['x'] = 'X';
	toupper['y'] = 'Y';
	toupper['z'] = 'Z';
	string a, b, c; cin >> a >> b >> c;
	cout << toupper[a[0]] << toupper[b[0]] << toupper[c[0]] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int N, Q;
    cin >> N >> Q;
    if (N == 0 && Q == 0){
      break;
    }
    vector<string> S(N);
    vector<int> E(N);
    vector<int> W(N);
    for (int i = 0; i < N; i++){
      cin >> S[i] >> E[i] >> W[i];
    }
    for (int i = 0; i < Q; i++){
      int q;
      cin >> q;
      string ans1 = "Unknown";
      int ans2 = -1;
      for (int j = 0; j < N; j++){
        if (W[j] - E[j] + 1 <= q && q <= W[j]){
          ans1 = S[j];
          ans2 = E[j] - (W[j] - q);
        }
      }
      if (ans1 == "Unknown"){
        cout << ans1 << endl;
      } else {
        cout << ans1 << ' ' << ans2 << endl;
      }
    }
  }
}


Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  map<string,int> mp;
  string s,t;
  cin>>s>>t;
  int a,b;
  cin>>a>>b;
  mp[s]=a;
  mp[t]=b;
  string ss;
  cin>>ss;
  mp[ss]--;
  cout<<mp[s]<<" "<<mp[t]<<endl;

  return 0;
}


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

class Program {
    internal static void Main(string[] args) {
        var N = int.Parse(ReadLine());
        var a = ReadLine().Split(' ').Select(s => long.Parse(s)).OrderBy(l => l).ToList();
        var copy = new long[a.Count];
        a.CopyTo(copy);
        copy = copy.Distinct().ToArray();
        var ans = 0L;

        var cnt = a.GroupBy(l => l)
                   .Select(l => l.Count())
                   .ToArray();

        for (int i = 0; i < copy.Length; i++) {
            var count = cnt[i];
            if (count > copy[i]) {
                ans += count - copy[i];
            } else if (count < copy[i]) {
                ans += count;
            }
        }

        WriteLine(ans);
    }
}

Measured memory_bytes: 42980
import numpy as np
from collections import deque

N, K = map(int, input().split())
p = [float(x) for x in input().split()]
p = np.array(p)

p = (1.+p)/2.
q = deque()

ans = 0.
tmp = 0.
for i in range(len(p)) : 
    q.append(p[i])
    tmp += p[i]
    if ( len(q) == K ) : 
        ans = max(ans, tmp)
        tmp -= q.popleft()

print("{:.10f}".format(ans))
    


Measured memory_bytes: 32264
#include <stdio.h>

int main(void){
  int i;
  int N, X;
  scanf("%d %d", &N, &X);
  int L[N+1];
  int d;//座標
  int count;

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

  //d_1は含まれる
  d=0;
  count=1;
  for(i=2; i<=N+1; i++){
    d=d+L[i-1];
    if(d<=X) count++;
  }

  printf("%d\n", count);

  return 0;
}


Measured memory_bytes: 128
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
    
    def isSame(self, x, y):
        return self.find(x) == self.find(y)

def solve():
    N,M = map(int,input().split())
    uf = UnionFind(N)
    for i in range(M):
        x,y,z = map(int,input().split())
        x -= 1
        y -= 1
        uf.unite(x,y)
    
    st = set()

    for i in range(N):
        st.add(uf.find(i))
    
    print(len(st))
    
if __name__ == '__main__':
    solve()

Measured memory_bytes: 89760
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

const int INF = 1e9;

int main() {
	int h, w; cin >> h >> w;
	vector<string>s(h); for (auto&& x : s)cin >> x;
	
	int whiteSum = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '.')whiteSum++;
		}
	}

	vector<vector<int>>dp(h, vector<int>(w, INF));
	queue<pair<int, int>>que;
	int gx = h - 1, gy = w - 1;
	que.push({ 0,0 });
	dp[0][0] = 1;
	int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };

	while (!que.empty()) {
		int x = que.front().first, y = que.front().second; que.pop();
		if (x == gx && y == gy)break;
		for (int i = 0; i < 4; i++) {
			int nx = x + dx[i], ny = y + dy[i];
			if (nx < 0 || nx >= h || ny < 0 || ny >= w || s[nx][ny] == '#' || dp[nx][ny] != INF)continue;
			que.push({ nx,ny });
			dp[nx][ny] = dp[x][y] + 1;
		}
	}
	int ans = whiteSum - dp[gx][gy];
	cout << (ans >= 0 ? ans : -1) << endl;

	return 0;
}

Measured memory_bytes: 256