akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
int A[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) cin>>A[i];
	sort(A,A+N);
	if(A[N-1]<K) return _P("IMPOSSIBLE\n");
	int g=0;
	FOR(i,N) g=__gcd(g,A[i]);
	if(K%g==0) _P("POSSIBLE\n");
	else _P("IMPOSSIBLE\n");
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	vpint R,B;
	for(int i=0;i<N;i++){
		int a,b;
		cin>>a>>b;
		R.pb(mp(a,b));
	}
	for(int i=0;i<N;i++){
		int a,b;
		cin>>a>>b;
		B.pb(mp(a,b));
	}
	int ans=0;
	sort(B.begin(),B.end());
	for(int i=0;i<N;i++){
		int a=B[i].first,b=B[i].second;
		int ind=-1,y=-1;
		for(int j=0;j<N;j++){
			if(R[j].first<a && R[j].second<b && y<R[j].second){
				y=R[j].second;
				ind=j;
			}
		}
		if(ind!=-1){
			ans++;
			R[ind]=mp(INF,INF);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


const int64_t INF64 = int64_t(2e18) + 5;

const int N_MAX = 52;
const int S_MAX = 2505;

struct state {
    int city, silver;
    int64_t dist;

    state() {}

    state(int _city, int _silver, int64_t _dist) : city(_city), silver(_silver), dist(_dist) {
        silver = min(silver, S_MAX);
    }

    bool operator<(const state &other) const {
        return dist > other.dist;
    }
};

struct edge {
    int city, cost, time;

    edge() {}

    edge(int _city, int _cost, int _time) : city(_city), cost(_cost), time(_time) {}
};

int N, M, S;
vector<vector<edge>> adj;
vector<int> coins, exch_time;
int64_t _dist[N_MAX][S_MAX];
vector<int64_t> answers;

int64_t &dist(const state &s) {
    return _dist[s.city][s.silver];
}

void dijkstra_check(priority_queue<state> &pq, const state &s) {
    if (s.dist < dist(s)) {
        dist(s) = s.dist;
        pq.push(s);
    }
}

void dijkstra() {
    memset(_dist, 63, sizeof(_dist));
    priority_queue<state> pq;
    dijkstra_check(pq, state(0, S, 0));

    while (!pq.empty()) {
        state top = pq.top();
        pq.pop();

        // Skip if obsolete.
        if (top.dist > dist(top))
            continue;

        assert(top.dist == dist(top));
        answers[top.city] = min(answers[top.city], top.dist);

        // Use the coin exchange.
        dijkstra_check(pq, state(top.city, top.silver + coins[top.city], top.dist + exch_time[top.city]));

        for (edge &e : adj[top.city])
            if (top.silver >= e.cost)
                dijkstra_check(pq, state(e.city, top.silver - e.cost, top.dist + e.time));
    }
}

int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    cin >> N >> M >> S;
    adj.assign(N, {});

    for (int i = 0; i < M; i++) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        adj[u].emplace_back(v, a, b);
        adj[v].emplace_back(u, a, b);
    }

    coins.resize(N);
    exch_time.resize(N);

    for (int i = 0; i < N; i++)
        cin >> coins[i] >> exch_time[i];

    answers.assign(N, INF64);
    dijkstra();

    for (int i = 1; i < N; i++)
        cout << answers[i] << '\n';
}


Measured memory_bytes: 6308
/**akshaykumar99**/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;

#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;
 
int main()
{
    IOS();
 
   	int a,b,c;
   	cin>>a>>b>>c;
   	if(a+b+c>=22)
   		cout<<"bust\n";
   	else
   		cout<<"win\n";

    return 0;
}

Measured memory_bytes: 256
ACGT = ['A', 'C', 'G', 'T', '']
MOD = 10 ** 9 + 7

N = int(input())
dp = [[[[0] * 5
        for _ in range(5)]
       for _ in range(5)]
      for _ in range(N + 1)]

dp[0][4][4][4] = 1
for i in range(N):
    for p in range(5):
        for q in range(5):
            for r in range(5):
                for s in range(4):
                    if ACGT[q] + ACGT[r] + ACGT[s] not in {'AGC', 'GAC', 'ACG'} \
                            and ACGT[p] + ACGT[r] + ACGT[s] != 'AGC' \
                            and ACGT[p] + ACGT[q] + ACGT[s] != 'AGC':
                        dp[i + 1][q][r][s] += dp[i][p][q][r]
                        dp[i + 1][q][r][s] %= MOD

print(sum(sum(sum(y) for y in x) for x in dp[N]) % MOD)


Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>

using namespace std;

int Q;
int N;

int solve(int n) {
    if (0 <= n && n <= 9) return 0;
    int max_n = 0;
    for (int i = 10; i <= n; i *= 10) {
        int a = n / i;
        int b = n % i;
        max_n = max(max_n, a*b);
    }
    return solve(max_n) + 1;
}

int main() {
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        cin >> N;
        cout << solve(N) << endl;
    }
    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>

using namespace std;

void solve() {
    char c;
    int i = 1;
    while ((c = getchar()) != '\n') {
        if (i&1)
            cout << c;
        i ^=1;
    }

}

int main() {

	solve();
    return 0;
}


Measured memory_bytes: 3032
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC

int main(){
    string s;cin>>s;
    int n=s.size(),total=0,x=1;
    vector<int> vec(2019);vec[0]=1;
    lint ans=0;
    for(int i=n-1;i>=0;i--){
        total+=(s[i]-'0')*x;
        total%=2019;
        ans+=vec[total];
        vec[total]++;
        x=x*10%2019;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3708
import collections as c

n = int(input())
l = [input() for _ in range(n)]
c = c.Counter(l)
c = c.most_common()
ans = []
for i in c:
  if i[1] == c[0][1]: 
    ans.append(i[0])
ans.sort()
for i in ans:
  print(i)

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

 int main(){
   int N;
   cin >> N;
   vector<ll>a(N);
   REP(i,N) cin >> a[i];
   ll cnt = 0;
   REP(i,N){
     while(a[i] % 2 == 0) {
       cnt++;
       a[i] /= 2;
     }

   }
 
 print(cnt);
 }

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main (void)
{
    int n, x = 0, max = 0;
    string s;

    cin >> n;
    cin >> s;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'I') {
            x++;
        } else {
            x--;
        }
        max = ((max < x)? x: max);
    }
    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
using namespace std;
int main()
{
  int n,q,index,order,value,x;
  cin>>n>>q;
  stack<int>s[n];
  while(q--){

  cin>>order>>index;

  switch(order)
  {
      case 0:
                  cin>>value;
                  s[index].push(value);
                  break;
      case 1:
                  if( !s[index].empty())
                  cout<< s[index].top()<<endl;
                     break;
      case 2:
                   if( !s[index].empty())
                  s[index].pop();
                  break;
  }

  }
return 0;
}


Measured memory_bytes: 4444
#include <bits/stdc++.h>
using namespace std;
vector<int> A;
long func(int n, long y, long k, int a, int m){
    if (n == m + 1) {
        //cout << '!' << endl;
        return y + A.at(n-2)*k;
    }else{
        //cout << 'o' ;
        if (A.at(n-1)>A.at(n)){
            return func(n+1,y+A.at(n-1)*k,k-k, A.at(n),m);
        }else if (A.at(n-1)<A.at(n)){
            return func(n+1,y-A.at(n-1)*(long(y/a)),k+(long(y/a)), A.at(n),m);
        }else{
            return func(n+1,y,k, A.at(n),m);
        }
        
    }
}
int main() {
    int N, Y, K;
    Y = 1000;
    K = 0;
    cin >> N;
    int hold;
    for (int i = 0; i < N; i++) {
        cin >> hold;
        A.push_back(hold);
    }
    A.push_back(0);
    //cout << 'o' << endl;
    cout << func(1, Y, K, A.at(0), N) << endl;
   
}


Measured memory_bytes: 3560
#include<iostream>
#include<utility>
int main(){
        int A,B,C;
        std::cin >> A >> B >> C;
        if(B > A) std::swap(A,B);
        if(C > A) std::swap(A,C);
        if(C > B) std::swap(B,C);
        std::cout << A*10 + B + C;
}

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

using namespace std;


int main(){
  
  int n,l;
  cin >> n >> l;
  string a[n];
  
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  
  sort(a,a+n);
  
  for(int i=0;i<n;i++){
  cout << a[i];
  }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a,b,c int
	fmt.Scan(&a,&b,&c)
	
	ans := "Yes"
	if a == b &&  b == c {
		ans = "No"
	} else if a != b && b != c && c != a {
		ans = "No"
	}
	fmt.Println(ans)
}

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

int main(void)
{
    long long int n, k;
    long long int cases=0;
    cin >> n >> k;

    for(long long int i=k; i<=n+1; i++)
    {
        cases += (i*(n-i+1)+1)%(1000000007);
    }
    cases = cases%1000000007;
    cout << cases << "\n";
}


Measured memory_bytes: 3648
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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


int main(){
  int k,a,b,l;
  cin>>k>>a>>b;
  
  bool x=false;
  rep(i,1000){
    l+=k;
    if(l>=a && l<=b) x=true;
  }
  
  if(x) cout<<"OK"<<endl;
  else cout<<"NG"<<endl;

  return 0;
}

Measured memory_bytes: 3620
%:pragma GCC optimize(2)
%:pragma GCC optimize("inline")
#include <bits/stdc++.h>
using namespace std;

const int N = 1e6 + 5;

vector <int> G[N];

int n, m, x, y, dp[N], ans = 1e9, Can[N], CanS[N], Son[N], Sum[N];

void get(int x) {
  if(Son[x] <= 1 && CanS[x] == Son[x]) {
    dp[x] = 1;
    Can[x] = 1;
    return;
  }
  else {
    Can[x] = 0;
    dp[x] = Sum[x] - (!!CanS[x]);
  } 
}

void dfs(int x, int f) {
  Sum[x] = 0;
  for(int i = 0; i < (int) G[x].size(); ++ i) {
    int V = G[x][i];
    if(V == f) continue;
    dfs(V, x);
    ++ Son[x];
    Sum[x] += dp[V];
    if(Can[V]) ++ CanS[x];
  }
  get(x);
}

int solve(int x) {
  dfs(x, 0);
  return (Can[x]) ? 0 : dp[x];
}

void io() {
  freopen("beacon.in", "r", stdin);
  freopen("beacon.out", "w", stdout);
}

void dfs2(int x, int f) {
  if(Can[x]) ans = 1;
  ans = min(ans, dp[x] + 1);
  for(int i = 0; i < (int) G[x].size(); ++ i) {
    int V = G[x][i];
    if(V == f) continue;
    int sonx = Son[x], sonV = Son[V],
      dpx = dp[x], dpV = dp[V],
      Canx = Can[x], CanV = Can[V],
      CanSx = CanS[x], CanSV = CanS[V],
      Sumx = Sum[x], SumV = Sum[V];
    CanS[x] -= Can[V];
    Sum[x] -= dp[V];
    -- Son[x];
    get(x);

    CanS[V] += Can[x];
    Sum[V] += dp[x];
    ++ Son[V];
    get(V);
    
    dfs2(V, x);

    Son[x] = sonx, Son[V] = sonV;
    dp[x] = dpx, dp[V] = dpV;
    Can[x] = Canx, Can[V] = CanV;
    CanS[x] = CanSx, CanS[V] = CanSV;
    Sum[x] = Sumx, Sum[V] = SumV;
  }
}

void read(int &x) {
  char ch = getchar();
  while(!isdigit(ch)) ch = getchar();
  x = 0;
  while(isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
}

int main() {
  read(n);
  for(int i = 1; i < n; ++ i) {
    read(x); read(y);
++ x, ++ y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  //cerr << "HERE" << endl;
  if(n == 1) {
    puts("0");
    return 0;
  }
  ans = solve(1) + 1;
  dfs2(1, 0);
  cout << ans << endl;
}


Measured memory_bytes: 52992
#include<stdio.h>
int main(void){
    int N,M,X,Y,n,i;
    scanf("%d %d %d %d",&N,&M,&X,&Y);
    int x[N],y[M],max,min;
    for(i=1;i<=N;i++){
        scanf("%d",&x[i]);
    }
    for(n=1;n<=M;n++){
        scanf("%d",&y[n]);
    }
    min=y[1];
    max=x[1];
    for(n=1;n<=M;n++){
        if(min>y[n]){
            min=y[n];
        }
    }
    for(i=1;i<=N;i++){
            if(max<x[i]){
                max=x[i];
            }
        }
    if((max<min)&&(max<Y)&&(min>X)){
        printf("No War\n");
    }else{
        printf("War\n");
    }
    return 0;
    }

Measured memory_bytes: 128
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

 
h, w = rm()
for _ in range(h):
  s = rr()
  print(s)
  print(s)







  







Measured memory_bytes: 27104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N ;
  int sum = 0;
  for ( int i=0 ; i < N ; i++ ) {
    int l , r ; 
    cin >> l >> r ;
    sum += r-l+1 ;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3576
arr = input().split()
stack = list()
for el in arr:
    if el.isdigit():
        stack.append(int(el))
        continue
    elif el == "*":
        stack.append(stack.pop() * stack.pop())
        continue
    elif el == "+":
        stack.append(stack.pop() + stack.pop())
        continue
    elif el == "-":
        stack.append(-stack.pop() + stack.pop())
        continue
print(stack.pop())


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

signed main(){

  int A,B,N; cin >> A >> B >> N;
  if(A <= N && B <= N){
    cout << 0 << endl;
    return 0;
  }

  int ans = 1LL << 60;
  for(int i = 1; i*i <= B; i++){
    if(B%i == 0 && i <= N){
      for(int j = 1; j <= N; j++){
        ans = min(ans,abs(A - (B/i)*j));
      }
    }
  }
  cout << ans << endl;

  return 0;
}



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

int main(){

  int N,M;
  cin >> N >> M;
  long A[N];
  long long ans=0;
  priority_queue<long> B;
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=0; i<N; i++) B.push(A[i]);

  while(M>0){
    B.push(B.top() >> 1);
    B.pop();
    M--;
  }

  while(!B.empty()){
    ans += B.top();
    B.pop();
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2168
using System;

namespace _118_ABC
{
    class Program01
    {
        static void Main(string[] args)
        {
            string[] Input = Console.ReadLine().Split(' ');
            int A = int.Parse(Input[0]);
            int B = int.Parse(Input[1]);

            Console.WriteLine(B % A == 0 ? A + B : B - A);            
        }
    }
}


Measured memory_bytes: 11092
n = input()
a,b,c = n[0],n[1],n[2]
if a=="1":
  a="9"
elif a=="9":
  a="1"
if b=="1":
  b="9"
elif b=="9":
  b="1"
if c=="1":
  c="9"
elif c=="9":
  c="1"
print(a+b+c)

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        if(a < b)
            System.out.println("a < b");
        if(a > b)
            System.out.println("a > b");
        if(a == b)
            System.out.println("a == b");
    }
}

Measured memory_bytes: 26188
import java.util.Scanner;
     
public class Main {
    	
    private final static Scanner sc = new Scanner(System.in);
    	
    public static void main(String[] arg) {
    	int A = sc.nextInt() - 1;
      	int B = sc.nextInt() - 1;
      	int k = (B / A);
      	if( k*A != B) k++;
      	System.out.println(k);
   	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(long int I=X;I<Y;I++)
#define REP(I,X) for(long int I=X;I>=0;I--)
#define INF 1e9+7
using namespace std;

bool del[100010];
int imos[100010];

int main(){
  int N,M,a,b,ans=0;
  cin >> N >> M;
  vector<pair<int,int>> edges,edge;
  FOR(i,0,M){
    cin >> a >> b;
    edges.push_back(make_pair(a,b));
  }
  sort(edges.begin(),edges.end());
  a = 0;
  FOR(i,0,M){
    if(edges[i].first == a)del[i] = 1;
    a = edges[i].first;
  }
  FOR(i,0,M)if(!(del[i]))edge.push_back(edges[i]);
  a = INF;
  REP(i,edge.size()-1){
    if(edge[i].second <= a){
      ans++;
      a = edge[i].first;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2548
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val s = sc.nextLine()
    println(if (s == "ABC") "ARC" else "ABC")
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 34252
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  string s;
  cin >> s;
  int indexB = 0, indexE = 0, flagB = 0, flagE = 0;
  for(int i = 0; i < s.length(); i++){
    if(s.at(i) == 'A' && !flagB){
      indexB = i;
      flagB = 1;
    }
    if(s.at(s.length()-1-i) == 'Z' && !flagE){
      indexE = s.length() - i;
      flagE = 1;
    }
  }
  cout << indexE - indexB << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,j,ans=1;
	string s;
	cin>>n;
	cin>>s;
	for(i=0;i<n-1;i++)
	{
		if(s[i]!=s[i+1])ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)

int main(){
  int N;
  string S;
  int x;

  std::cin >> N;
  std::cin >> S;


  rep(i,S.size()){
    x = S[i] - 'A';
    x = (x+N)%26;
    S[i] = 'A' + x;
    std::cout << S[i];
  }

  puts("");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,M[101][101];
int visit[101],d[101],f[101],t;
const int WHITE=0;
const int GLAY=1;
const int BLACK=2;

void dfs(int u){
  visit[u]=GLAY;
  d[u]=++t;
  for(int v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(visit[v]==WHITE){
    dfs(v);
    }
  }
  visit[u]=BLACK;
  f[u]=++t;
}



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

  for(int i=0;i<n;i++){
    cin>>u>>k;
    u--;
    for(int j=0;j<k;j++){
      cin>>v;
      v--;
      M[u][v]=1;
    }
  }

 
 
  for(int i=0;i<n;i++){
    if(visit[i]==WHITE){
      dfs(i);
    }
  }
  for(int i=0;i<n;i++){
    cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
  }

  
  return 0;
}
  



Measured memory_bytes: 3096
# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

satis_level = sum(B)

for i in range(N-1):
    if A[i+1] - A[i] == 1:
        satis_level += C[A[i]-1]

print(satis_level)

Measured memory_bytes: 3064
#include <iostream>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> v1(n);
    for(int i=0;i<n;i++){cin>>v1[i];}
    vector<int> v2(v1);
    if(prev_permutation(v1.begin(),v1.end())){
       for(int i=0;i<n;i++){
        if(i!=0)cout<<" ";
            cout<<v1[i];
       }
       cout<<"\n";
    }
    for(int i=0;i<n;i++){
            if(i!=0)cout<<" ";
            cout<<v2[i];
    }
    cout<<"\n";
    if(next_permutation(v2.begin(),v2.end())){
        for(int i=0;i<n;i++){
            if(i!=0)cout<<" ";
            cout<<v2[i];
        }
        cout<<"\n";
    }





}




Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
  int n, a, x = 0, y = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a;
    x += a*a;
    y += a;
  }
  cout << x + (n*(y/n + (y%n > n/2)) - 2*y)*(y/n + (y%n > n/2)) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
   public static  void main(String [] args){
       Scanner sc = new Scanner(System.in);
       int a = sc.nextInt();
       int b = sc.nextInt();
       int area = a*b;
       int length = 2*(a+b);
       System.out.println(area+" "+length);
   }
}


Measured memory_bytes: 25988
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a+b>=10){
        string ans = "error";
        cout << ans << endl;
    }else{
    cout << a+b << endl;
}
}

Measured memory_bytes: 256
S = input()
T = input()
ans = "No"
def rot(s):
    return s[len(s)-1] + s[0:len(s)-1]
s = rot(S)
while(s != S):
    if (s == T):
        ans = "Yes"
        break
    s = rot(s)

if (s == T):
    ans = "Yes"
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,x,y; cin >> n >> x >> y;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  if(n==1){
    cout << abs(a[0]-y) << endl;
  }else{
    cout << max(abs(a[n-1]-y), abs(a[n-1]-a[n-2])) << endl;
  }
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
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;
}


int main(){
    ll N,Y;
    cin >> N >> Y;
    ll m,g,s = -1;
    ll max_g = int((Y - 1000 * N)/4000) + 1;
    REP(i,max_g){
        g = i;
        m = (Y - 1000 * N - 4000 * i) / 9000;
        s = N - m - g;
        if((Y - 1000 * N - 4000 * i) % 9000 == 0 and m >=0 and s >= 0){
            break;
        }
        else{
            m = -1;
            g = -1;
            s = -1;
        }
    }
    cout << m << ' ' << g << ' ' << s << endl;

}



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

const int N = 123456;
typedef vector<int> VI;
typedef pair<int, int> PI;
vector<PI> edges[N];

#define rep(i, n) for (int i = 0; i < int(n); ++i)

double p;


double dfs(int v, int par) {
	double sum = 0;
	rep(i, edges[v].size()) {
		PI w = edges[v][i];
		if (par == w.first) continue;
		double res = dfs(w.first, v) + w.second;
		sum += res * p;
	}
	return sum;
}

double dfs2(int v, int par, double single) {
	double sum = single;
	rep(i, edges[v].size()) {
		PI w = edges[v][i];
		if (par == w.first) continue;
		double res = dfs2(w.first, v, single) + w.second;
		sum += res * p;
	}
	return sum;
}


// RUPC C
int main() {
	int n;
	cin >> p >> n;
	rep(i, n - 1) {
		int x, y, c;
		cin >> x >> y >> c;
		x--, y--;
		edges[x].push_back(PI(y, c));
		edges[y].push_back(PI(x, c));
	}
	double single = dfs(0, -1); // T
	double ret = dfs2(0, -1, single);
	printf("%.15f\n", ret);
	// your code goes here
	return 0;
}

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

int main() {
    while (1) {
        int H, W;
        cin >> H >> W;
        if (H == 0 & W == 0) {
            break;
        }

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (i == 0 || i == H -1) {
                    cout << "#";
                    continue;
                }

                if (j == 0 || j == W - 1) {
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 2996
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 205
using namespace std;
typedef long long ll;
const ll mod=998244353;
int n;
int x[maxn],y[maxn];
ll mypow[maxn];
int main()
{
	scanf("%d",&n);

	mypow[0]=1;
	for(int i=1;i<=n;i++)
		scanf("%d%d",&x[i],&y[i]),mypow[i]=(mypow[i-1]<<1)%mod;

	ll ans=(mypow[n]-n-1+mod)%mod;

	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			int cnt=0;
			for(int k=j+1;k<=n;k++)
			{
				if((x[i]-x[j])*(y[i]-y[k])==(x[i]-x[k])*(y[i]-y[j]))
					cnt++;
			}
			ans=(ans-mypow[cnt]+mod)%mod;
		}
	}

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


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long ll;

class edge {
   public:
    int to;
    ll cost;

    edge() : to(), cost() {}
    edge(int to, ll cost) : to(to), cost(cost) {}
};

vector<ll> bfs(int n, const vector<vector<edge>>& g, int s) {
    vector<ll> d(n, -1);
    d[s] = 0;

    queue<int> q;
    q.push(s);

    while (!q.empty()) {
        int v = q.front();
        q.pop();

        for (const edge& e : g[v]) {
            if (d[e.to] == -1) {
                d[e.to] = d[v] + e.cost;
                q.push(e.to);
            }
        }
    }

    return d;
}

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

    vector<vector<edge>> e(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        e[a - 1].push_back(edge(b - 1, c));
        e[b - 1].push_back(edge(a - 1, c));
    }

    int q, k;
    cin >> q >> k;

    vector<ll> d = bfs(n, e, k - 1);

    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        cout << d[x - 1] + d[y - 1] << endl;
    }

    return 0;
}


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

struct Ki{
    int to, id;
};

vector<vector<Ki>> to; vector<int> ans;

void dfs(int root, int co, int pa){
    int k=1;
    rep(i,to[root].size()){
        int ba=to[root][i].to, iden=to[root][i].id;
        if(pa==ba) continue;
        if(k==co) k++;
        ans[iden]=k; k++;
        dfs(ba,ans[iden],root);
    }
}


int main(){
    int n; cin >> n;
    to.resize(n);
    ans=vector<int>(n-1);
    rep(i,n-1){
        int a,b; cin >> a >> b;
        a--; b--;
        to[a].push_back(Ki{b,i});
        to[b].push_back(Ki{a,i});
    }
    dfs(0,-1,-1);
    int mini=0;
    rep(i,n-1) mini=max(mini,ans[i]);
    cout << mini << endl;
    rep(i,n-1) cout << ans[i] << endl;


return 0;
}


Measured memory_bytes: 8320
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int sub(int a,vector<char>b,int c,int d){
  if(c%2019==0&&c!=0)return 1;
  return sub(a+1,b,c+b[d]*a,d+1);
}
int main(){ 
  char a,b,c,d;cin>>a>>b>>c>>d;
  int e=0;
  if(a=='+')e++;
  else e--;
    if(b=='+')e++;
  else e--;
    if(c=='+')e++;
  else e--;
    if(d=='+')e++;
  else e--;
  cout<<e;
  }


Measured memory_bytes: 256
from itertools import product
h,w,k=map(int,input().split())
c=[list(input()) for _ in range(h)]
ans=0
for i in product([0,1],repeat=h):
  for j in product([0,1],repeat=w):
    temp=0
    for m in range(h):
      for n in range(w):
        if i[m]==0 and j[n]==0 and c[m][n]=="#":
          temp+=1
    if temp==k:
      ans+=1
print(ans)
        
        

Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    ll n,q;
    cin >> n;
    ll ans = 0;
    vector<ll> S(n);
    rep(i,n){
        cin >> S[i];
    }
    cin >> q;
    vector<ll> T(q);
    rep(i,q){
        cin >> T[i];
    }
    rep(i,q){
        if(binary_search(all(S),T[i])){
            ans++;
        }
    }
    cout << ans <<endl;


    return 0;
    

}


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

typedef long long ll;

int main()
{
    int H,W;
    cin>>H>>W;
    ll** dp=new ll*[H];
    int** mat=new int*[H];

    for(int i=0;i<H;i++)
    {
        mat[i]=new int[W];
        dp[i]=new ll[W];
        char ch;
        for(int j=0;j<W;j++)
        {
            cin>>ch;
            if(ch=='.')
            {
                mat[i][j]=0;
                dp[i][j]=0;
            }
            else
            {
                mat[i][j]=1;
                dp[i][j]=0;
            }
        }
    }
    dp[0][0]=1;
    for(int i=0;i<H;i++)
    {
        for(int j=0;j<W;j++)
        {
            if(i==0 && j==0)
                dp[i][j]=1;
            else if(mat[i][j]==0)
            {
                ll ans=0;
                ll ans1=0;
                if(i>0)
                    ans=max(dp[i-1][j],ans);
                if(j>0)
                    ans1=max(dp[i][j-1],ans1);
                dp[i][j]=(ans+ans1)%1000000007;
            }
        }
    }
    cout<<dp[H-1][W-1];
    return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define X real()
#define Y imag()
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using comd = complex<double>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 100000;
  rep(i,n){
    ans += ans*0.05;
    if(ans % 1000 > 0)
    ans += 1000 - ans%1000;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3016
min=100000000;max=-100000000;sum=0

n=gets.chomp.to_i
str=gets.chomp
num=Array.new
number=str.split
for i in 0..n-1 do
  num[i]=number[i].to_i
end

for i in 0..n-1 do
  if num[i]<min then
    min=num[i]
  end
  if num[i]>max then
    max=num[i]
  end
  sum+=num[i]
end

puts "#{min} #{max} #{sum}"

Measured memory_bytes: 9240
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	REP(i,N){
		int O=0,P=0;
		deque<int> R{0,0,0};
		while(O<3){
			string S=in<string>();
			if(S=="HIT"){
				if(R[0]==1) P++;
				rotate(R.begin(),R.begin()+1,R.end());
				R[2] = 1;
			}
			else if(S=="OUT"){
				O++;
			}
			else{
				int sum = accumulate(ALL(R),0);
				P += sum+1;
				fill(ALL(R),0);
			}
		}
		out(P);
	}
	
	return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	int A,B,K;
	cin>>A>>B>>K;
	int m=max(A,B);
	int ans;
	int c=0;
	for(int i=m;i>=0;i--){
		if(A%i==0 && B%i==0)c+=1;
		if(c==K){
			ans=i;
			break;
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define endl "\n"
#define PI 3.141592653589793
#define vi vector<int>
#define vll vector<long long>
#define p pair<int,int>
const ll MOD = 1000000007;
inline double degcos(double ang) {return cos(ang*PI/180);}
inline double degsin(double ang) {return sin(ang*PI/180);}
#define rep(i,j,k,in) for (int i = j; i < k; i += in)
#define repr(i,j,k,in) for (int i = j; i > k; i -= in)
#define repll(i,j,k,in) for (ll i = j; i < k; i += in)
#define repllr(i,j,k,in) for (ll i = j; i > k; i -= in)

/*---END OF TEMPLATE---*/

int N;
const int MAXN = 100001;
vector<int> tree[MAXN];
ll dp[MAXN][2];
const int WHITE = 0, BLACK = 1;


ll solve(int v, int color, int parent) {
    if (v == 0) {
        return (solve(1,WHITE,0) + solve(1,BLACK,0)) % MOD;
    }
    ll tot = 1, totWhite, totBlack;
    if (dp[v][color] != -1) return dp[v][color];
    rep(i,0,tree[v].size(),1) {
        if (tree[v][i] != parent) {
            if (color == WHITE) {
                totBlack = solve(tree[v][i],BLACK,v);
            }
            else totBlack = 0;
            totWhite = solve(tree[v][i],WHITE,v);
            tot = (tot * (totWhite + totBlack)) % MOD;
        }
    }


    return dp[v][color] = tot;

    
}


int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    //ifstream fin("data.in");
    //ofstream fout("data.out");
    scan(N);
    int v1,v2;
    rep(i,0,N-1,1) {
        scan(v1); scan(v2);
        tree[v1].push_back(v2);
        tree[v2].push_back(v1);
    }

    memset(dp,-1,sizeof(dp));
    cout << solve(0,0,0);


}

Measured memory_bytes: 18908
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; 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 sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int H,W;
  cin >> H >> W;
  v(string) G(H);
  rep(i,H) {
    cin >> G[i];
  }
  vvi ans(H,vi(W,-1));
  rep(i,H) {
    rep(j,W) {
      if(G[i][j] == '#') {
        continue;
      }
      int cnt = 0;
      srep(di,-1,2) {
        srep(dj,-1,2) {
          int ni = i+di;
          int nj = j+dj;
          if(ni<0 || ni >= H) continue;
          if(nj<0 || nj >= W) continue;
          if(G[ni][nj] == '#') {
            cnt++;
          }
        }
      }
      ans[i][j] = cnt;
    }
  }
  rep(i,H) {
    rep(j,W) {
      if(ans[i][j]<0) {
        cout << "#";
      } else {
        cout << ans[i][j];
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[400005],n;
int small(int i,int k)
{
	return a[i+1]<=k&&a[i]<=k;//  
}
int big(int i,int k)
{
	return a[i+1]>k&&a[i]>k;
}
int check(int k)
{
	for(int i=0;i<=n-1;i++)
	{
		if(small(n+i,k)==1||small(n-i-1,k)==1)
		{
			return 1;
		}
		if(big(n+i,k)==1||big(n-i-1,k)==1)
		{
			return 0;
		}
	}
	if(a[1]<=k)
	{
		return 1;
	}else
	{
		return 0;
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n-1;i++)
	{
		scanf("%d",&a[i]);
	}
	int l=1,r=2*n-1;
	while(l<r)
	{
		int mid=(l+r)>>1;
		if(check(mid)==1)
		{
			r=mid;
		}else
		{
			l=mid+1;
		}
	}
	cout<<r;
	return 0;
}

Measured memory_bytes: 1024
#include <assert.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

const int cset = 8;
const int low[] = {1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200};
bool vis[100];
int main(int argc, char **argv) {
    int n;
    int a;
    int free = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a);
        for (int j = 0; j < cset; j++) 
            if (a >= low[j] && a < low[j + 1]) vis[j] = true;
        if (a >= 3200) free++;
    }
    int used = 0;
    for (int i = 0; i < cset; i++) used += vis[i];
    printf("%d %d\n", max(used, 1), max(1, used + free));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	long long n,m;
	cin>>n>>m;
	if(n<m){long long t=n;n=m;m=t;}
	if(n==1&&m==1)cout<<1<<endl;
	else if(m==1)cout<<n-2<<endl;
	else cout<<max(0ll,(n-2)*(m-2))<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <set>
#include <algorithm>


int main() {
	int n, q;
	std::cin >> n >> q;
	std::vector<std::pair<int, std::pair<int, int>>> r(n);
	for (size_t i = 0; i < n; i++)
	{
		int s, t, x;
		std::cin >> s >> t >> x;
		r[i].first = x;
		r[i].second.first = s;
		r[i].second.second = t;
	}
	std::sort(r.begin(), r.end());
	std::set<std::pair<int, int>>p;
	std::vector<int>ans(q);
	for (size_t i = 0; i < q; i++)
	{
		ans[i] = -1;
		int d;
		std::cin >> d;
		p.insert(std::make_pair(d, i));
	}
	for (size_t i = 0; i < n; i++)
	{
		int ss = r[i].second.first - r[i].first;
		int tt = r[i].second.second - r[i].first;
		std::pair<int, int> sp, tp;
		sp.first = ss;
		sp.second = -1;
		tp.first = tt;
		tp.second = -1;
		auto b = p.lower_bound(sp);
		auto e = p.lower_bound(tp);
		for (auto itr = b; itr != e; itr++) {
			ans[(*itr).second] = r[i].first;
		}
		p.erase(b, e);

	}
	for (size_t i = 0; i < q; i++)
	{
		std::cout << ans[i] << "\n";
	}
	std::cout << std::flush;

	return 0;
}

Measured memory_bytes: 14336
while True:
  try:
    alst = input().split()
    blst = input().split()

    hit = brow = 0

    for i in range(4):
      for j in range(4):
        if alst[i] == blst[j]:
          if i == j:
            hit += 1
          else:
            brow += 1

    print(hit, brow)

  except EOFError:
    break


Measured memory_bytes: 5560
#include<bits/stdc++.h>
using namespace std;
int n,a[202020],ans[202020],nw[202020];
vector<int>v[202020];
void dfs(int x,int y,int nww)
{
	int vl=a[x],p=lower_bound(nw,nw+n,vl)-nw,pp=nw[p];
	nw[p]=vl;
	ans[x]=max(nww,p+1);
	for(int i=0;i<v[x].size();i++)
	{
		int z=v[x][i];
		if(z!=y)
		{
			dfs(z,x,ans[x]);
		}
	}
	nw[p]=pp;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for(int i=0;i<n;i++)
	{
		nw[i]=1e9+100;
	}
	dfs(0,-1,0);
	for(int i=0;i<n;i++)
	{
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 31268
#include <stdio.h>
int main(void){
  int h,w;
  while(1){
    scanf("%d %d",&h,&w);
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++)printf("#");
      printf("\n");
    }
    if(h==0&&w==0)break;
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
//#include "../cxx-prettyprint/prettyprint.hpp"

std::vector<std::vector<int>> Adj;
std::unordered_set<int> nodes_unvisited;
std::unordered_map<int, int> node_component_map;

void mark_nodes(int node, int component_id) {
    node_component_map[node] = component_id;
    nodes_unvisited.erase(node);
    for (int& next : Adj[node]) {
        if (nodes_unvisited.find(next) != nodes_unvisited.end()) {
            mark_nodes(next, component_id);
        }
    }
}

int main() {
    int n, m;
    std::cin >> n >> m;

    Adj.assign(n, std::vector<int>());
    for (int i = 0; i < m; i++) {
        int s, t;
        std::cin >> s >> t;
        Adj[s].push_back(t);
        Adj[t].push_back(s);
    }

    for (int i = 0; i < n; i ++) {
        nodes_unvisited.insert(i);
    }

    int component_id = 0;
    while (!nodes_unvisited.empty()) {
        int start = *nodes_unvisited.begin();
        mark_nodes(start, component_id);
        component_id ++;
    }

    int q;
    std::cin >> q;
    for (int i = 0; i < q; i ++) {
        int s, t;
        std::cin >> s >> t;
        if (node_component_map[s] == node_component_map[t]) {
            std::cout << "yes" << std::endl;
        } else {
            std::cout << "no" << std::endl;
        }
    }
}



Measured memory_bytes: 18128
#include<stdio.h>

int main(void){

	int a,b=0;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
return 0;
}


Measured memory_bytes: 2100
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
class union_find_tree {
private:
	vector<int>par, rank_;
public:
	union_find_tree(int n) :par(n), rank_(n) {
		for (int i = 0; i < n; i++) {
			par[i] = i;
			rank_[i] = 0;
		}
	}
	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		return par[x] = root(par[x]);
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) {
			return;
		}
		if (rank_[x] < rank_[y]) {
			par[x] = y;
		}
		else if (rank_[x] == rank_[y]) {
			par[y] = x;
			rank_[x]++;
		}
		else if (rank_[y] < rank_[x]) {
			par[y] = x;
		}
	}
};

struct edge {
	int from, to, cost;
	bool operator<(const edge& other)const {
		return cost < other.cost;
	}
};

using edges = vector<edge>;

int kruskal(union_find_tree& uf, edges& es, int V) {
	sort(es.begin(), es.end());
	int E = es.size();
	int res = 0;
	for (int i = 0; i < E; i++) {
		if (!uf.same(es[i].from, es[i].to)) {
			uf.unite(es[i].from, es[i].to);
			res += es[i].cost;
		}
	}
	return res;
}

int main() {
	int V, E;
	cin >> V >> E;
	edges es(E);
	union_find_tree uf(V);
	for (int i = 0; i < E; i++) {
		cin >> es[i].from >> es[i].to >> es[i].cost;
	}
	cout << kruskal(uf, es, V) << endl;
	return 0;

}





















Measured memory_bytes: 4060