akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int MAX=105;
char a[MAX],b[MAX],c[MAX];
int main(){
  queue<char>card[5];
  scanf("%s%s%s",a,b,c);
  for (int i=0; a[i]; ++i){
    card[0].push(a[i]);
  }
  for (int i=0; b[i]; ++i){
   card[1].push(b[i]);
  }
  for (int i=0; c[i]; ++i){
    card[2].push(c[i]);
  }
  char f='a';
  while (1){
    char last=f;
   f=card[f-'a'].front();
   card[last-'a'].pop();
   if (card[f-'a'].empty()){
     printf("%c\n",f-32);
     break;
   }
  }
}

Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    dxs=[-1,0,1]
    dys=[-1,0,1]
    h,w=INTM()
    s=['.'*(w+2)]
    ans=[[0]*(w+2) for i in range(h+2)]
    for i in range(h):
        st='.'+STR()+'.'
        s.append(st)
    s.append('.'*(w+2))
    #print(s)
    #print(ans)
    for i in range(1,h+1):
        for j in range(1,w+1):
            if s[i][j]=='#':
                ans[i][j]='#'
                for dx in dxs:
                    for dy in dys:
                        if s[i+dx][j+dy]=='.':
                            #print(ans)
                            ans[i+dx][j+dy]=int(ans[i+dx][j+dy]+1)
    for i in range(1,h+1):
        print(*ans[i][1:w+1],sep='')
                
        
if __name__ == '__main__':
    do()

Measured memory_bytes: 3572
#pragma GCC optimize ("O3")
char buf[20000];sz;
inline int rd()
{
	int ret=0;
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		ret=ret*10+k-'0';
	}
	return ret;
}
int d[3001],d2[3001];
const int mod=998244353;
main()
{
	read(0,buf,20000);
	int N=rd();
	int S=rd();
	int ans=0;
	for(int i=0;i<N;i++)
	{
		++d[S];
		int A=rd();
		for(int j=0;j<=S-A;j++)d2[j]=d[j+A];
		for(int j=0;j<=S-A;j++)
		{
			d[j]+=d2[j];
			d[j]-=mod*(d[j]>=mod);
		}
		ans+=d[0];
		ans-=mod*(ans>=mod);
	}
	printf("%d",ans);
}

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


signed main(){
   
   int k;
   cin>>k;
   
   int ans =0;

   for(int a =1;a<=k;a++){
   	for(int b=1;b<=k;b++){
   		for(int c =1;c<=k;c++){
   			ans += __gcd(__gcd(a,b),c);
   		}
   	}
   }

   cout<<ans<<"\n";
 
  
	return 0;
}



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

int main() {
    string S;
    getline(cin, S);

    vector<int> modcounts(2019, 0);
    int premod = 0;
    int tensmod = 1;  // 10^0 % 2019
    for (int i = S.length() - 1; i >= 0; i--) {
        int c = S.at(i) - '0';
        int m = (c * tensmod + premod) % 2019;
        modcounts[m]++;
        tensmod = (tensmod * 10) % 2019;
        premod = m;
    }
    modcounts[0]++;

    int64_t result = 0;
    for (uint m = 0; m < modcounts.size(); m++) {
        result += (int64_t)modcounts[m] * (modcounts[m] - 1) / 2;
    }
    cout << result << endl;
}


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

const int mN = 200200;
int a[mN], nodes[mN];
int pos[mN];

int main()
{
    int n;
    long long k;
    cin >> n >> k;
    for (int i=1; i<=n; i++) cin >> a[i];
    int cnt = 0, start = 0, length = 1;
    memset(pos, -1, sizeof(pos));
    for (int u=1; ; u = a[u]) {
        if (pos[u] != -1) {
            start = pos[u];
            length = cnt - start + 1;
            break;
        }
        nodes[++cnt] = u;
        pos[u] = cnt;
    }
//    cerr << "cycle : "; for (int i=1; i<=cnt; i++) cerr << nodes[i] << " ";
//    cerr << "start loop from : " << start << " length = " << length << "\n";
    k++;
    if (k <= start) cout << nodes[k];
    else {
        //cerr << k << "\n";
        int ord = (k-(start-1)) % length;
        if (ord == 0) ord = length;
        //cerr << ord << "\n";
        cout << nodes[start + ord - 1];
    }
}


Measured memory_bytes: 5896
N, K = map(int, input().split())

mod = 10 ** 9 + 7
fac = [1, 1]
finv = [1, 1]
inv = [0, 1]

def comb(n, r):
  if n < r:
    return 0
  else:
    return fac[n] * ( finv[r] * finv[n-r] % mod ) % mod
 
for i in range(2, N + 1):
  fac.append( ( fac[-1] * i ) % mod )
  inv.append( mod - ( inv[mod % i] * (mod // i) % mod ) )
  finv.append( finv[-1] * inv[-1]  % mod )

for i in range(1, K+1):
  print(comb(N-K+1, i) * comb(K-1, i-1) % mod)

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

// https://www.hamayanhamayan.com/entry/2018/09/15/130935

ll dp[10010][(1<<4)]; // i行目まで見て、箱が埋まっている状態がjである
ll ng[10010][5];

// 与えられるbitが貨物室のもとから置けない状態と一致するか
ll check(ll y, ll bit){
  rep(x,4) if(ng[y][x]) if((bit>>x&1)==0) return 0;
  return 1;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll H,n; cin>>H>>n;
  
  rep(i,n){
    ll x,y; cin>>x>>y;
    ng[y][x]=1;
  }
  
  rep(y,H-1) rep(bit,1<<4) if(check(y,bit)) {
    rep(bit2,1<<4) if(check(y+1,bit2)){
      // 1
      rep(x,3){
        if(bit>>x&1) continue;
        if(bit>>(x+1)&1) continue;
        if(bit2>>x&1) continue;
        if(bit2>>(x+1)&1) continue;
        ll nbit=(bit2|(1<<x)|(1<<(x+1)));
        chmax(dp[y+1][nbit],dp[y][bit]+1);
      }
      // 2
      if(bit==0 && bit2==0){
        chmax(dp[y+1][(1<<4)-1],dp[y][0]+2);
      }
      
      chmax(dp[y+1][bit2],dp[y][bit]);
    }
  }
  
  ll ans=0;
  rep(bit,1<<4) chmax(ans,dp[H-1][bit]);
  
  cout<<ans<<endl;
}


Measured memory_bytes: 4860
#include<iostream>
using namespace std;
int main()
{
    long long a, b, c;
    cin>>a>>b;
    if(a*2>=b)
    {
        cout<<b/2;
    }
    else
    {
        c=a;
        b-=2*a;
        c+=b/4;
        cout<<c;
    }
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>

const int LOG_A = 60;

int basis[LOG_A];

void insert(int mask) 
{
	for (int i = LOG_A - 1; i >= 0; i--) 
    {
		if ((mask & 1LL << i) == 0) continue;

		if (!basis[i]) {
			basis[i] = mask;
			return;
		}

		mask ^= basis[i];
	}
}

bool check(int mask)
{
    for(int i = LOG_A - 1; i >= 0; i --)
    {
        if ((mask & 1LL << i) == 0) continue;

		if (!basis[i]) 
        {
			return 0;
		}

		mask ^= basis[i];
    }
    
    return 1;
}

void solve()
{
   for(int i=0;i<LOG_A;i++) basis[i] = 0;
    
   int n;
   cin >> n;
  
   int a[n];
   f(i,n) cin >> a[i];
    
   string s;
   cin >> s;
    
   vi a1;
   vi b1; 
    
   int flag = 1;
    
   for(int i=n-1;i>=0;i--)
   {
      if(s[i] == '0') insert(a[i]);
      else flag&=check(a[i]);
   }  
    
   cout << 1-flag << '\n'; 
}

signed main()
{
    fast;
    
    int t = 1;
    
    cin >> t;
    
    while(t--)
        
    solve();
}

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

template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[ ";
    for(auto a : v)
        os << a << " ";
    os << "]";
    return os;
}

int main() {
    cout << fixed << setprecision(0);
    string N;
    cin >> N;
    int nine_sum = 0;
    for(auto n : N) {
        nine_sum += (n - '0');
    }

    cout << (nine_sum % 9 ? "No" : "Yes") << endl;

    return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

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


    double ans = 0;

    rep(i,n){
        double x;
        string s;
        cin >> x >> s;
        if(s=="JPY"){
            ans += x;
        }else{
            ans += x*380000;
        }
    }
    
    cout << fixed << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<string,int>P;
typedef map<string,int>M;
int main(void){
	int n,m;
	string s;
	int i;
	M mp,mp2;
	int MAX;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>s;
		if(mp.find(s)==mp.end()){
			mp.insert(P(s,1));
		}
		else{
			mp[s]++;
		}
	}
	cin>>m;
	for(i=0;i<m;i++){
		cin>>s;
		if(mp2.find(s)==mp2.end()){
			mp2.insert(P(s,1));
		}
		else{
			mp2[s]++;
		}
	}
	MAX=0;
	for(auto it=mp.begin();it!=mp.end();it++){
		if(mp2.find(it->F)==mp2.end()){
			MAX=max(MAX,it->S);
		}
		else{
			auto it2=mp2.find(it->F);
			MAX=max(MAX,it->S-it2->S);
		}
	}
	cout<<MAX<<endl;
	return 0;
}

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

using namespace std;

using ll=long long;

constexpr ll mod=998244353;

int main(){
    int n;
    cin>>n;
    vector<int>d(n);
    for(int i=0;i<n;++i){
        cin>>d[i];
    }
    if(d[0]!=0){
        cout<<0;
        return 0;
    }
    sort(d.begin(),d.end());
    if(d[1]!=1){
        cout<<0;
        return 0;
    }

    ll f=1,count=1;
    ll ans=1;
    for(int i=1;i<n;++i){
        if(d[i-1]!=d[i]){
            if(d[i]-d[i-1]>1){
                cout<<0;
                return 0;
            }
            f=count;
            count=1;
        }else{
            count++;
        }
        ans*=f;
        ans%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
def main():
    n, k = map(int, input().split())
    answer = 0
    for i in range(1, n + 1):
        answer += max(0, i - k) * (n // i) + max(0, n % i - k + 1)
    print(answer if k > 0 else n ** 2)


if __name__ == '__main__':
    main()



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

struct node {
  int number;
  struct node *next,*fir;
};

struct node *nil;

struct node* listsearch(int);

void initem();
void print();
void deletenode(struct node *);
void deleteFirst();
void deleteLast();
void deletenum();
void insert(int);

struct node* listsearch(int number)
{
  struct node *x = nil->next;

  while(x != nil && x->number!= number) 
    x = x->next;

  return x;

}

void initem()
{
  nil = (struct node*)malloc(sizeof(struct node));
  nil->next = nil;
  nil->fir = nil;
}

void print()
{
  int isfirst = 0;
  struct node *y = nil->next;

  while(1) {
    if(y == nil)
      break;

    if(isfirst++ > 0)
      printf(" ");

    printf("%d",y->number);

    y = y->next;
  }
  printf("\n");

}

void deletenode(struct node *z)
{
  if(z == nil)
    return;

  z->fir->next = z->next;
  z->next->fir =  z->fir;

  free(z);
}

void deleteFirst()
{
  deletenode(nil->next);
}

void deleteLast()
{
  deletenode(nil->fir);
}

void deletenum(int number)
{
  deletenode(listsearch(number));
}

void insert(int number)
{
  struct node *r = (struct node*)malloc(sizeof(struct node));
  r->number = number;
  r->next = nil->next;
  nil->next->fir= r;
  nil->next = r;
  r->fir= nil;
}

int main()
{
  int n,i,number,size=0,a=0,b=0;
  char c[20];

  scanf("%d",&n);

  initem();
 
  for(i=0;i<n;i++) {

    scanf("%s%d",c,&number);

    if(c[0] == 'i') {
      insert(number);
      a++;
      size++;
    }
    else if(c[0] == 'd') {
      if(strlen(c) > 6) {
	if(c[6] == 'F') 
	  deleteFirst();
	  else if(c[6] == 'L')
	  deleteLast();
	}
    else{
	  deletenum(number);
	  b++;
      }
      size--;
    }
  }

  print();

  return 0;
}




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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;

  if(a + b < 24) cout << a + b << endl;
  else cout << a + b - 24 << endl;
}


Measured memory_bytes: 256
N,K = list(map(int,input().split()))
gakki = list(map(int,input().split()))


for i in range(N - K):
    temp1 = gakki[i]
    temp2 = gakki[K + i]
    if temp1 < temp2:
        print("Yes")
    else:
        print("No")
    temp1 = temp2
    


Measured memory_bytes: 31440
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    int n;
    cin>>n;
    int a=0;
    int b=0;
    int c=0;
    int d=0;
    for(int i=0;i<n;i++){
        string p;
        cin>>p;
        if(p=="AC"){
            a++;
        }else if(p=="WA"){
            b++;
        }else if(p=="TLE"){
            c++;
        }else{
            d++;
        }
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;
}

Measured memory_bytes: 3584
import sys, math
from functools import lru_cache
from collections import defaultdict
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

# 素因数分解
def prime_decomposition(n):
    i = 2
    table = defaultdict(int)
    while i * i <= n:
        while n % i == 0:
            n //= i
            table[i] += 1
        i += 1
    if n > 1:
        table[n] += 1
    return table


def main():
    N, P = mi()
    ans = 1
    for k, v in prime_decomposition(P).items():
        ans *= k**(v//N)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9556
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,k = readline() |> split |> parseMap
	s = readline() |> chomp
	if n==1
		println(0)
	elseif n==2
		if k>0
			println(1)
		else
			println(s[1]==s[2]?1:0)
		end
	else
		v = 0
		if s[1]==s[2]=='R'
			v += 1
		end
		if s[n-1]==s[n]=='L'
			v += 1
		end
		for i in 2:n-1
			if s[i-1]==s[i]=='L' || s[i]==s[i+1]=='R'
				v += 1
			end
		end
		println(min(n-1,v+2k))
	end
end

main()

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

char BUF[1 << 21] , *buf = BUF;
void putch(char c){*(buf++) = c;}
void putint(int x){if(!(x / 10)){putch('0' + x); return;} putint(x / 10); putch('0' + x % 10);}
void flush(){fwrite(BUF , buf - BUF , 1 , stdout);}

bool vis[603][603]; int N , D1 , D2;
void color(int dist){
	int now = 0; while(!(dist & 3)){dist >>= 2; ++now;}
	if(dist % 4 == 3) return;
	for(int i = 0 ; i < 2 * N ; ++i)
		for(int j = 0 ; j < 2 * N ; ++j)
			vis[i][j] |= ((dist & 2) && (i >> now & 1)) || ((dist & 1) && (((i >> now) + (j >> now)) & 1));
}

int main(){
	cin >> N >> D1 >> D2; color(D1); color(D2); int num = 0;
	for(int i = 0 ; i < 2 * N ; ++i)
		for(int j = 0 ; j < 2 * N ; ++j)
			if(!vis[i][j] && ++num <= N * N){putint(i); putch(' '); putint(j); putch('\n');}
	flush(); return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string ans;
	rep(i,0,9){
		char c; cin>>c;
		if(i==0 || i==4 || i==8) ans.push_back(c);
	}
	cout<<ans;
	
	return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    cout<<(n*(n+1))/2;
    return 0;
}

Measured memory_bytes: 3600
N = int(input())
ans = 0
C = [[0 for j in range(10)] for i in range(10)]

for k in range(N+1):
    sk = str(k)
    C[int(sk[0])][int(sk[-1])] += 1

for i in range(10):
    for j in range(10):
        if i == j == 0:continue
        ans += C[i][j] * C[j][i]

print(ans)

Measured memory_bytes: 3064
h,w,n=map(int,input().split())
sr,sc=map(int,input().split())
s=input()[::-1]
t=input()[::-1]
l,r,u,d=0,w+1,0,h+1
for i in range(n):
 si,ti=s[i],t[i]
 if l+1>=r or u+1>=d:break
 r=min(w+1,r+1)if ti=="L"else r
 l=max(0,l-1)if ti=="R"else l
 d=min(h+1,d+1)if ti=="U"else d
 u=max(0,u-1)if ti=="D"else u
 r-=1 if si=="R"else 0
 l+=1 if si=="L"else 0
 d-=1 if si=="D"else 0
 u+=1 if si=="U"else 0
print("YES"if l<sc<r and u<sr<d else"NO")

Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>

using namespace std;
vector<string> split(string s, char del = ' '){
  vector<string> res;
  replace(s.begin(),s.end(),del,' ');
  stringstream ss(s);
  string elem;
  for(int i=0; ss >> elem; i++){
    res.push_back(elem);
  }
  return res;
}

int main(){
  int vl, hl;
  string s;

  cin >> vl;
  cin >> hl;

  int lines[vl];
  for(int i=0; i<vl; i++){
    lines[i] = i+1;
  }

  int a, b, k;
  cin.ignore();
  for(int j=0; j<hl; j++){
    getline(cin,s);
    vector<string> str = split(s,',');
    a = atoi(str[0].c_str());
    b = atoi(str[1].c_str());

    k = lines[a-1];
    lines[a-1] = lines[b-1];
    lines[b-1] = k;
  }

  for(int m=0; m<vl; m++){
    cout << lines[m] << endl;
  }
}

Measured memory_bytes: 1228
ss = input("").split()
a = int(ss[0])
b = ss[1]
c = int(ss[2])

while b != "?":
    if b == "+":
        result = int(a + c)
    elif b == "-":
        result = int(a - c)
    elif b == "*":
        result = int(a * c)
    elif b== "/":
        result = int(a / c)

    print("{0}".format(result))
    ss = input("").split()
    a = int(ss[0])
    b = ss[1]
    c = int(ss[2])

Measured memory_bytes: 7672
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
class SegmentTree {
private:
  int siz;
  vector<long long> dat;

  public:
  SegmentTree(vector<long long> v) {
    siz = 1;
    while(siz < (int) v.size()) siz <<= 1;
    dat.resize(2 * siz - 1, -LLONG_MAX);
    for(int idx = 0; idx < (int) v.size(); idx++) {
      dat[idx + siz - 1] = v[idx];
    }
    for(int idx = siz - 2; idx >= 0; idx--) {
      dat[idx] = max(dat[2 * idx + 1], dat[2 * idx + 2]);
    }
  }

  void update(int idx, long long val) {
    idx += (siz - 1);
    dat[idx] = val;
    while(idx > 0) {
      idx = (idx - 1) / 2;
      dat[idx] = max(dat[2 * idx + 1], dat[2 * idx + 2]);
    }
  }
  //[a, b)
  long long get(int a, int b, int idx = 0, int l = 0, int r = -1) {
    if(r < 0) r = siz;
    if(r <= a || b <= l) return -LLONG_MAX;
    if(a <= l && r <= b) return dat[idx];
    long long val1 = get(a, b, 2 * idx + 1, l, (l + r) / 2);
    long long val2 = get(a, b, 2 * idx + 2, (l + r) / 2, r);
    return max(val1, val2);
  }
};
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<int> h(n), a(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  SegmentTree sgt(vector<long long>((int) 200005));
  for (int i = 0; i < n; i++) {
    long long val = sgt.get(0, h[i]);
    sgt.update(h[i], val + a[i]);
  }
  long long ans = 0;
  for (int i = 0; i < 200001; i++) {
    ans = max(ans, sgt.get(i, i + 1));
  }
  cout << ans << endl;
  return 0;	
}

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

int main() {

    int X, Y;
    cin >> X >> Y;
    int total = 0;
    if(X == 1 || X==2 || X==3){
        total += 100000 * (4-X);
    }
    if(Y == 1 || Y==2 || Y==3){
        total += 100000 * (4-Y);
    }
    if(X==1&&Y==1){
        total += 400000;
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007LL;
int N;
int x[100010];
int y[100010];
vector<int> G[100010];
ll dp[2][100010];
bool used[100010];

void dfs (int v)
{
    used[v] = true;
    ll black = 1, white = 1;
    REP(i,G[v].size()) {
        if (used[G[v][i]]) continue;
        dfs(G[v][i]);
        black *= dp[0][G[v][i]];
        white *= dp[0][G[v][i]] + dp[1][G[v][i]];
        black %= MOD;
        white %= MOD;
    }
    dp[0][v] = white;
    dp[1][v] = black;
    return;
}

int main ()
{
    cin >> N;
    REP(i,N - 1) cin >> x[i] >> y[i];
    REP(i,N - 1) {
        G[x[i]].push_back(y[i]);
        G[y[i]].push_back(x[i]);
    }
    REP(i,2)REP(j,100010) dp[i][j] = -1;

    dfs(1);

    cout << (dp[0][1] + dp[1][1]) % MOD << endl;
 
    return 0;
}


Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
inline int read()
{
  int x=0,f=1;
  char ch=getchar();
  while(ch<'0'||ch>'9')
  {
    if(ch=='-')
      f=-1;
    ch=getchar();
  }
  while(ch>='0'&&ch<='9')
  {
    x=(x<<1)+(x<<3)+(ch^48);
    ch=getchar();
  }
  return x*f;
}
int main()
{
  int n;
  n=read();
  int a[105];
  for(int i=1; i<=n; i++)
  {
    a[i]=read();
    if(a[i]%2==0&&a[i]%3!=0&&a[i]%5!=0)
    {
      printf("DENIED");
      return 0;
    }
  }
  printf("APPROVED");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/
int main(){
    int n; cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    int ans = 0;
    int _min = *min_element(h.begin(), h.end());
    rep(i, n) h[i] -= _min;
    ans += _min;

    int h_min;
    int _max = *max_element(h.begin(), h.end());;
    while(_max > 0){
        h_min = 1000;
        rep(i, n){
            if(i == n - 1){
                if(h_min != 1000){
                    rep(j, n) h[j] -= h_min;
                    ans += h_min;
                }else{
                    ans += h[n - 1];
                    h[n - 1] = 0;
                }
                break;
            }else if((h[i] > 0 and h_min > 0) and i != n - 1){
                h_min = min(h_min, h[i]);
            }else if((h[i] <= 0 and h_min != 1000) or i == n - 1){
                int m = i;
                rep(j, m) h[j] -= h_min;
                ans += h_min;
                break;
            }
        }
        _max = *max_element(h.begin(), h.end());
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   char a,b;
   while(cin>>a>>b)
   {
       if(a==b)
       {
           cout<<"H"<<endl;
       }
       else
       {
           cout<<"D"<<endl;
       }
   }


   return 0;
}


Measured memory_bytes: 384
N, M = map(int, input().split())

dic = {i+1:[] for i in range(N)}

for i in range(M):
  p, y = map(int, input().split())
  dic[p].append((i,y))

for i in range(N):
  dic[i+1].sort(key=lambda x:x[1])
  
ans = [0] * M
for k, vs in dic.items():
  order = 1
  for c, y in vs:
    ans[c] = (k, order)
    order += 1

for city, order in ans:
  print(str(city).zfill(6)+str(order).zfill(6))


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

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d;
  
  e = a + b;
  f = c + d;
  
  if (e > f) {
    cout << "Left" << endl;
  }else if (e == f) {
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
    
  
}


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

using namespace std;

int main()
{
	int x, y;	cin >> x >> y;

	int _2 = 0, _4 = 0;
	for (int i = 0; i <= x; i++)
		if (i * 2 + (x - i) * 4 == y)
			return cout << "Yes\n", 0;
	
	cout << "No\n";
	return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long unsigned n;
	cin>>n;
	std::vector<long long unsigned> v;
	for(auto i=0;i<n;i++)
	{
		long long unsigned a;
		cin>>a;
		v.push_back(a);
		if(a==0)
		{
			cout<<0;
			return 0;
		}
	}

	long long unsigned ans=v[0];
	long long unsigned c=1e18;
	for (long long unsigned i=1;i<v.size();i++)
	{
		if(v[i]>c/ans) {
			cout<<-1;
			return 0;
		}
		ans*=v[i];

	}
	if(ans>0&&ans<=c)
		cout<<ans;
	else cout<<-1;


	return 0;
}

Measured memory_bytes: 4252
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;


    
    
    int main(){
        int n,m;cin>>n>>m;
        ll s = n,t = m;
        if(n>m)rep(i,n)cout<<m;
        else rep(i,m)cout<<n;
    }
    


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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

#define ll __int128

ll P,L,A,B;

struct Mat{
	ll a[3][3];

	Mat(){memset(a,0,sizeof a);}
	
	ll* operator [] (int x){return a[x];}
	const ll* operator [] (int x)const{return a[x];}

	Mat operator * (const Mat &rhs) const
	{
		Mat ret;
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++)
				for(int k=0;k<3;k++)
					(ret[i][j]+=a[i][k]*rhs[k][j]%P)%=P;
		return ret;
	}
};

ll ksm(ll a,ll b)
{
	ll ret=1;
	for(;b;b>>=1,(a*=a)%=P)
		if(b&1)
			(ret*=a)%=P;
	return ret%P;
}

Mat ksm(Mat a,ll b)
{
	Mat ret;
	ret[0][0]=ret[1][1]=ret[2][2]=1;
	for(;b;b>>=1,a=a*a)
		if(b&1)
			ret=ret*a;
	return ret;
}

ll Calc(__int128 fir,__int128 num,ll len)
{
	if(num<=0)
		return 0;
	Mat trans;
	trans[0][0]=ksm(10,len+1);
	trans[1][0]=trans[1][1]=1;
	trans[2][0]=trans[2][1]=B%P;trans[2][2]=1;
	Mat B;
	B[0][0]=B[0][1]=fir%P;B[0][2]=1;
	return (B*ksm(trans,num-1))[0][0];
}

__int128 get(int b) //10^b
{
	__int128 ret=1;
	while(b--)
		ret*=10;
	return ret;
}

__int128 Ceil(__int128 a,__int128 b)
{
	return (a+b-1)/b;
}

__int128 Floor(__int128 a,__int128 b)
{
	return a/b;
}

int main()
{
	long long _L,_A,_B,_P;
	cin>>_L>>_A>>_B>>_P;
	L=_L;A=_A;B=_B;P=_P;
	ll Ans=0;
	__int128 lst=A+((__int128)B)*(L-1);
	for(int i=0;i<=36;i++)
	{
		if(get(i)>lst)
			continue;
		__int128 downlim=get(i),uplim=min(get(i+1)-1,lst);
		if(uplim<A)
			continue;
		if(downlim>lst)
			continue;
		__int128 First=A+Ceil(downlim-A,B)*B;
		if(A>downlim&&A<=uplim)
			First=A;
		if(First>lst)
			continue;
		if(downlim>uplim)
			continue;
		if(uplim<First)
			continue;
		Ans=(Ans*ksm(10,(__int128)(i+1)*(Floor(uplim-First,B)+1))%P+Calc(First%P,Floor(uplim-First,B)+1,i))%P;
	}
	printf("%lld\n",(long long)(Ans%P));
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static int Check(char c) {
		if(c == '#') {
			return 1;
		} else {
			return 0;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] dp = new int[h][w];
		String[] masu = new String[h];
		for(int i = 0; i < h; i++) {
			masu[i] = sc.next();
		}
		if(masu[0].charAt(0) == '#') {
			dp[0][0] = 1;
		} else {
			dp[0][0] = 0;
		}
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				if(i == 0 && j == 0)
					continue;
				if(i == 0) {
					dp[i][j] = dp[i][j - 1] + (dp[i][j - 1] % 2 == Check(masu[i].charAt(j)) ? 0 : 1);
				} else if(j == 0) {
					dp[i][j] = dp[i - 1][j] + (dp[i - 1][j] % 2 == Check(masu[i].charAt(j)) ? 0 : 1);
				} else {
					dp[i][j] = Math.min(dp[i][j - 1] + (dp[i][j - 1] % 2 == Check(masu[i].charAt(j)) ? 0 : 1), dp[i - 1][j] + (dp[i - 1][j] % 2 == Check(masu[i].charAt(j)) ? 0 : 1));
				}
			}
		}
		System.out.println((dp[h - 1][w - 1] + 1) / 2);

	}

}


Measured memory_bytes: 24404
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	run()
}

func run() {
	setSpace()
	M, N := readN(), readN()
	m, n := readN(), readN()
	fmt.Println((M - m) * (N - n))
}

// ------以下、ユーティリティ------

var sc = bufio.NewScanner(os.Stdin)

func setSpace() {
	sc.Split(bufio.ScanWords)
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readN() int {
	n, err := strconv.Atoi(read())
	if err != nil {
		panic(err)
	}
	return n
}


Measured memory_bytes: 640
import math

while True:
    N = int(input())
    if N == 0:
        break
    table = list(map(int,input().split()))
 
    tmp_sum = 0
    for i in range(len(table)):
        tmp_sum += table[i]
    b = tmp_sum/len(table)
 
    squared_sum = 0
    for i in range(len(table)):
        squared_sum += table[i]*table[i]
    a = squared_sum/len(table)
 
    print("%.10f"%(math.sqrt(a-b*b)))


Measured memory_bytes: 5688
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int[][] array = new int[4][13];
		for (int i = 0; i < a; i++) {
			String b = scanner.next();
			int c = scanner.nextInt();
			if (b.equals("S"))
				array[0][c - 1] = 1;
			else if (b.equals("H"))
				array[1][c - 1] = 1;
			else if (b.equals("C"))
				array[2][c - 1] = 1;
			else
				array[3][c - 1] = 1;
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 13; j++) {
				if (array[i][j] == 0)
					if (i == 0)
						System.out.println("S " + (j + 1));
					else if (i == 1)
						System.out.println("H " + (j + 1));
					else if (i == 2)
						System.out.println("C " + (j + 1));
					else
						System.out.println("D " + (j + 1));
			}
		}
	}
}

Measured memory_bytes: 18128
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)


int main() {
	int a, b;
	cin >> a >> b;
	if (a < b) {
		rep(i, b) cout << a;
	}
	else {
		rep(i, a) cout << b;
	}
	cout << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;

int fact (int x) {

    if (x == 0 || x == 1)
        return 1;
    return x*fact(x-1);
}
int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n;
    long double dist = 0, ans = 0;

    cin >> n;

    int arr1[n], arr2[n];
    long double f = fact(n) * 1.00;
    vector <int> v;

    for (int i = 0; i < n; i++) {

        cin >> arr1[i] >> arr2[i];
        v.push_back(i);
    }

    do {

        for (int i = 1; i < n; i++) {

            dist += sqrt(((arr1[v[i]] - arr1[v[i-1]]) * (arr1[v[i]] - arr1[v[i-1]])) + ((arr2[v[i]] - arr2[v[i-1]]) * (arr2[v[i]] - arr2[v[i-1]])));
    	}
    }
    while (next_permutation(v.begin(), v.end()));

    dist /= f;

    cout << fixed << setprecision(10) << dist;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
int main(void)
{
   char a[3][3];
   for(int i  =  0;i < 3; ++i)
    cin>>a[i];
   string s ;
   for(int i = 0;i < 3; ++i)
    cout<<a[i][i];
   return 0;
}


Measured memory_bytes: 256
n = int(input())
S = [int(input()) for _ in range(n)]
s = sum(S)
sort_S = sorted(S)
if s%10 != 0:
    print(s)
    exit()
else:
    for i in sort_S:
        if i%10 != 0:
            s -= i
            print(s)
            exit()
    print(0)

Measured memory_bytes: 9168
n = gets.to_i
arr = gets.chomp.split.map(&:to_i).sort
stop = false
for i in 0..(n-2)
    for j in (i+1)..(n-1)
        if (arr[j] - arr[i]) % (n - 1) == 0
            puts "#{arr[i]} #{arr[j]}"
            stop = true
        end
        break if stop
    end
    break if stop
end


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,a,b;
    cin>>n>>a>>b;
    ll x= min(a,b);
    ll y= max(0LL, a+b-n);
    cout<<x<<" "<<y<<endl;
    return  0;
}


Measured memory_bytes: 256
#include<stdio.h>  
#include<string.h>  
char map[105][105];  
int n,m,dx[]={0,0,-1,1},dy[]={1,-1,0,0},ans;  
void dfs(int x,int y,char ch)  
{  
    map[x][y]=0;  
    for(int i=0;i<4;++i)  
    {  
        int tx=x+dx[i],ty=y+dy[i];  
        if(tx<0||tx>=n||ty<0||ty>=m||map[tx][ty]!=ch)  
        {  
            continue;  
        }  
        dfs(tx,ty,ch);  
    }  
}  
int main()  
{  
    while(scanf("%d%d",&n,&m),n|m)  
    {  
        for(int i=0;i<n;++i)  
        {  
            scanf("%s", map[i]);  
        }  
        ans=0;  
        for(int i=0;i<n;++i)  
        {  
            for(int j=0;j<m;++j)  
            {  
                if(map[i][j])  
                {  
                    ++ans;  
                    dfs(i,j,map[i][j]);  
                }  
            }  
        }  
        printf("%d\n",ans);  
    }  
    return 0;  
}  


Measured memory_bytes: 2220
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <utility>
#include <vector>
#include <map>
using namespace std;
typedef long long int ll;
typedef double db;
const int INF = 1e9 + 5;

void solve()
{
	int s, w;
	cin >> s >> w;
	if (s > w)
		cout << "safe" << endl;
	else
		cout << "unsafe" << endl;
}
int main()
{
//	int t;
//	cin >> t;
//	while (t-- > 0)
	solve();
}


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

int main(){
    vector<int> haiku(3);
  	cin >> haiku[0] >> haiku[1] >> haiku[2];
  	//cout << haiku[0] <<endl;
    sort(haiku.begin(),haiku.end());
    if(haiku[0] == 5 && haiku[1] == 5 ){
        if(haiku[2] == 7)cout << "YES" <<endl;
        else cout << "NO" <<endl;
    }
  	else cout << "NO" <<endl;
    
}

Measured memory_bytes: 256
if __name__ == '__main__':
    from sys import stdin
    # from collections import defaultdict
    # from collections import deque
    # from collections import Counter
    # import copy
    # import numpy as np
    # import math
    # import random
    input = stdin.readline

    CONTEST_NUM = 26

    d = int(input())
    cc = [0]+list(map(int, input().split()))
    ss = [[0]*(CONTEST_NUM+1) for _ in range(d)]
    for i in range(d):
        ss[i] = [0]+list(map(int, input().split()))

    last_day = [-1]*(CONTEST_NUM+1)
    content = 0
    for i in range(d):
        t = int(input())
        content += ss[i][t]
        last_day[t] = i
        for contest in range(1, CONTEST_NUM+1):
            content -= cc[contest]*(i-last_day[contest])
        print(content)
            




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

using namespace std;
#define IO                 \
  ios::sync_with_stdio(0); \
  cin.tie(0);              \
  cout.tie(0);
#define forn(i, n) for (int i = 0; i < n; i++)
#define forse(i, s, e) for (int i = s; i < e; i++)
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define mp make_pair
#define all(vec) vec.begin(), vec.end()
#define getcurrtime() \
  cerr << "Time = " << ((double)clock() / CLOCKS_PER_SEC) << endl

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll>> Matrix;
const int sqr = 500;
const int P = 1e9+7;
const int arrn = 1e5 + 3;
const int arrn2 = 5e3 + 3;

int n,m,s,t;
int ans[arrn][3] = {};
vector<int> graph[arrn] = {};

void  dijs(){
	priority_queue<pair<int,pair<int,int>>> proc;
	proc.push(mp(0,mp(0,s)));
	int  done[arrn][3] = {};
	while(!proc.empty()){
		pair<int,pii> cur = proc.top();
		proc.pop();
		int dis = -cur.first;
		int ind = cur.second.first;
		int ver = cur.second.second;
		if(!done[ver][ind]){
			done[ver][ind] = 1;
			ans[ver][ind] = dis;
			if(ver == t && ind == 0) {
				cout << ans[ver][ind]/3;
				return;
			}
			forn(i,(int)graph[ver].size()){
				if(!done[graph[ver][i]][(1+ind)%3])
					proc.push(mp(-(1+dis),mp((1+ind)%3,graph[ver][i])));
			}
		}
	}
	cout << -1;
}

void solve() {
	cin >> n >> m;
	forn(i,m){
		int u,v;
		cin >> u >> v;
		graph[u].pb(v);
	}
	cin >> s >> t;
	dijs();
} 


int main() {
  IO;
  int T;
	T = 1;
  while (T--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323846264338327950L

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

	for ( int ii = 0; ii < S.length(); ii++ ) {
		if ( S[ii] == '7' ) {
			cout << "Yes" << endl;
			return 0;
		}
	} 
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <vector>
#include <set>

using namespace std;

typedef struct {
  int s;
  int t;
  int x;
} T1;

typedef struct T2 {
  int d;
  int i;
  struct T2* n;
} T2;

bool cmp_a(const T1& a, const T1& b)
{
  int c = a.x - b.x;
  return 0 <= c ? false : true;
}

bool cmp_b(const T2& a, const T2& b)
{
  int c = a.d - b.d;
  return 0 <= c ? false : true;
}

typedef pair<int, int> P;

int main() {
  int n, q;
  cin >> n >> q;
  vector<T1> a;
  a.resize(n);
  set<P> b;
  vector<int> c;
  c.resize(q, -1);
  int i, j;
  for (i = 0; i < n; i++) {
    int s, t, x;
    cin >> s >> t >> x;
    a[i].s = max(s - x, 0);
    a[i].t = max(t - x, 0);
    a[i].x = x;
  }
  for (j = 0; j < q; j++) {
    int d;
    cin >> d;
    b.insert(P(d, j));
  }
  sort(a.begin(), a.end(), cmp_a);
  // for (auto it : b) {
  //   cout << it.first << " " << it.second << endl;
  // }
  for (i = 0; i < n; i++) {
    auto it = b.lower_bound(P(a[i].s, -1));
    while (it != b.end()) {
      if (a[i].t <= it->first)
        break;
      c[it->second] = a[i].x;
      b.erase(it++);
    }
  }
  for (j = 0; j < q; j++) {
    cout << c[j] << endl;
  }
  return 0;
}


Measured memory_bytes: 14336
#include <iostream>

void call(int n) {
    int x;
    for (int i = 1; i <= n; i++) {
        x = i;
        if (x % 3 == 0) {
            std::cout << " " << i;
        } else {
            while (x) {
                if (x % 10 == 3) {
                    std::cout << " " << i;
                    break;
                } else {
                    x = x / 10;
                }
            }
        }
    }
    std::cout << std::endl;
}


int main()
{
    int n;
    std::cin >> n;
    call(n);
    return 0;
}

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int s = Integer.parseInt(chr[0]);
			int w = Integer.parseInt(chr[1]);
			System.out.println(s > w ? "safe" : "unsafe");
		}
	}
}

Measured memory_bytes: 25376
#include <cctype>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#include <set>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

const ll MOD = 998244353;

int ds[100000+10];
int hist[100000+10];


ll mypow(ll x, ll n) {
  if(n == 0) return 1;
  if(n % 2 == 0) return mypow(x * x % MOD, n / 2);
  return mypow(x * x % MOD, n / 2) * x % MOD;
}

int solve(int n) {
  if(ds[0] != 0) return 0;
  int maxi = 0;
  REP(i, n) {
    if(i != 0 && ds[i] == 0) {
      return 0;
    }
    maxi = max(maxi, ds[i]);
    hist[ds[i]]++;
  }
  ll res = 1;
  REP(i, maxi+1) {
    if(hist[i] == 0) {
      return 0;
    }
    if(i >= 2) {
      res = res * mypow(hist[i-1], hist[i]) % MOD;
    }
  }
  return res;
}

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%d", &ds[i]);
  }
  int res = solve(n);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1656
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int x, y, a, b, c;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> x >> y >> a >> b >> c;

  vector<ll> p(a);
  vector<ll> q(b);
  vector<ll> r(c);

  REP(i, a) cin >> p[i];
  REP(i, b) cin >> q[i];
  REP(i, c) cin >> r[i];

  sort(p.begin(), p.end(), greater<ll>());
  sort(q.begin(), q.end(), greater<ll>());
  sort(r.begin(), r.end(), greater<ll>());

  vector<ll> select;
  REP(i, x) select.push_back(p[i]);
  REP(i, y) select.push_back(q[i]);
  REP(i, c) select.push_back(r[i]);

  sort(select.begin(), select.end(), greater<ll>());
  ll ans = 0;
  REP(i, x + y) {
    ans += select[i];
  }

  cout << ans << endl;
}


Measured memory_bytes: 8560