akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,m,n) for(int i=m;i<(n);i++)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> pii;

bool done[110][110];
double dp[110][110];
int N,T,L,B;
bool isL[110],isB[110];
double rec(int i,int t){
	if(t<0)return 0;
	if(i==N){
		if(t==0)return 1;
		else return 0;
	}
	if(done[i][t])return dp[i][t];
	double ret = 0;
	if(isL[i]){
		FOR(j,1,7){
			int nxt = i+j;
			if(nxt>N){
				nxt= N-(nxt-N);
			}
			ret+=(1.0/6)*rec(nxt,t-2);
		}
	}
	else if(isB[i]){
		FOR(j,1,7){
			int nxt = j;
			if(nxt>N){
				nxt= N-(nxt-N);
			}
			ret+=(1.0/6)*rec(nxt,t-1);
		}
	}
	else{
		FOR(j,1,7){
			int nxt = i+j;
			if(nxt>N){
				nxt= N-(nxt-N);
			}
			ret+=(1.0/6)*rec(nxt,t-1);
		}
	}

	done[i][t]=true;
	return dp[i][t]=ret;
}

void init(){
	cin>>N>>T>>L>>B;
	if(N==0)exit(0);
	REP(i,101){
		isL[i]=false;
		isB[i]=false;
		REP(j,101){
			done[i][j]=false;
			dp[i][j]=0;
		}
	}
	REP(i,L){
		int x;cin>>x;
		isL[x]=true;
	}
	REP(i,B){
		int x;cin>>x;
		isB[x]=true;
	}
	REP(t,T+1){
		done[N][t]=true;
		dp[N][t]=0;
	}
	dp[N][0]=1;
	REP(i,N){
		done[i][0]=true;
		done[i][1]=true;
		dp[i][0]=0;
		if(i+6<N){
			dp[i][1]=0;
		}
		else if(isL[i]){
			dp[i][1]=0;
		}
		else if(isB[i]){
			if(N<=6)dp[i][1]=1.0/6;
		}
		else{
			dp[i][1]=1.0/6;
		}
	}
} 

void solve(){
	init();
	double ans = 0;
	REP(t,T+1){
		ans+=rec(0,t);
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
	//printf("%.10lf\n",ans);
}

signed main() {
	while (true) {
		solve();
	}
}


Measured memory_bytes: 3352
#include<stdio.h>
int main(void){
  char b[2];
  
  scanf("%s",b);
 
  switch(b[0]){
    case 'A': puts("T"); break;
    case 'T': puts("A"); break;
    case 'C': puts("G"); break;
    case 'G': puts("C"); break;
  }

  return 0;
}

Measured memory_bytes: 128
/*
 *
 */
#include <cstdio>
#include <iostream>

using namespace std;

int main(){
    //freopen("b4.in", "r", stdin);
    int N, M, K;
    cin >> N >> M >> K;

    bool flag = false;
    for (int i = 0; i <= N; ++i) {
        if (i * M == K) flag = true;
    }
    for (int j = 0; j <= M; ++j) {
        if (N * j == K) flag = true;
    }
    for (int i = 1; i < N; ++i) {
        for (int j = 1; j < M; ++j) {
            if ((N - i) * j + i * (M - j) == K) flag = true;
        }
    }
    if (flag) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n,m;
    cin >> n >> m;
    vector<int> h(n);
    vector<unordered_set<int>> adj(n);
    for(auto &i:h){
        cin >> i;
    }
    while(m--){
        int u,v;
        cin >> u >> v;
        u--;v--;
        adj[u].insert(v);
        adj[v].insert(u);
    }
    int count=0;
    for(int i=0;i<n;i++){
        bool flag=1;
        for(auto v:adj[i]){
            //cout<<v<<endl;
            if(h[i]<=h[v]){
                flag=0;
                break;
            }
        }
        count+=(flag?1:0);
    }
    cout<<count;
    return 0;
}


Measured memory_bytes: 18516
//
//  abc167_Teleporter.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef unsigned long long ll;
ll mod = 1000000007;
ll INF = 1000000007;
#define PI 3.14159265

std::map<int, int> factorization (int n) {
  std::map<int, int> f;
  for (int i = 2; i*i <= n; i++) {
    while (n%i == 0) {
      f[i] += 1;
      n /= i;
    }
  }
  if (n > 1) {
    f[n] += 1;
  }
  return f;
}

ll modpow (int x, int n) {
  if (n==0) return 1%mod;
  ll u = modpow(x, n/2);
  u = (u*u)%mod;
  if (n%2==1) u = (u*x)%mod;
  return u;
}

int main() {
  ll n, k;
  std::cin >> n >> k;
  ll a[n+1];

  ll pos[n+1];

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


  int start_loop = 0;
  int end_loop = 0;
  bool visited[n+1];
  bool get_end_loop = false;
  for (int i = 1; i <= n; i++) {visited[i] = false;}
  pos[0] = 1;
  pos[1] = a[1];
  visited[1] = true;
  for (int i = 2; i <= n; i++) {
    pos[i] = a[pos[i-1]];

    if (visited[pos[i]] && !get_end_loop) {
      end_loop = i;
      get_end_loop = true;
    }
    visited[pos[i-1]] = true;
  }

  for (int i = 1; i < end_loop; i++) {
    if (pos[i] == pos[end_loop]) {
      start_loop = i;
      break;
    }
  }
  if (k > n) {
    std::cout << pos[(k-start_loop)%(end_loop-start_loop) + start_loop] << std::endl;
  }
  else {
    std::cout << pos[k] << std::endl;
  }

  return 0;
}

Measured memory_bytes: 6896
#include <iostream>
#include <vector>
using namespace std;
int main(void){
   long long a,b;
   cin >> a >> b;
   if(a == 1 || b == 1){
       cout << 1 << endl;
   }else{
        cout << (a * b + 1) / 2 << endl;
   }
}


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

namespace Atc_0028
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            int A = int.Parse(str.Split(' ')[0]);

            int B = int.Parse(str.Split(' ')[1]);

            int C = int.Parse(str.Split(' ')[2]);

            int tmp = A - B;

            tmp = C - tmp;

            if (tmp < 0)
            {
                tmp = 0;
            }

            Console.WriteLine(tmp);

        }
    }
}


Measured memory_bytes: 27428
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto n = lread();
    auto a = aryread();
    auto b = aryread();
    auto sum_a = a.sum();
    // writeln(a.sum());
    // writeln(a);
    // writeln(b);
    auto tmp = new long[](n);
    // writeln(tmp);
    foreach (i; 0 .. n)
    {
        tmp[i] = a[i] - b[i];
    }
    // writeln(tmp);
    if (func(tmp))
    {
        writeln(0);
        return;
    }
    auto tmp_so = tmp.sort();
    // writeln(tmp_so);
    long sum_m;
    foreach (i; 0 .. n)
    {
        if (tmp_so[i] < 0)
        {
            sum_m += tmp_so[i];
        }
    }
    // writeln(sum_m);
    long cntcnt;
    foreach (i; 0 .. n)
    {
        if (tmp_so[i] < 0)
        {
            cntcnt += 1;
        }
    }
    long cnt;
    foreach_reverse (i; 0 .. n)
    {
        if (sum_m < 0)
        {
            sum_m += tmp_so[i];
            cnt += 1;
        }
        else
        {
            break;
        }
    }
    if (sum_m >= 0)
    {
        writeln(cntcnt + cnt);
    }
    else
    {
        writeln(-1);
    }
}

auto func(long[] x)
{
    foreach (i; 0 .. x.length)
    {
        if (x[i] >= 0)
        {
            continue;
        }
        else
        {
            return false;
        }
    }
    return true;
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


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

#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz(a) int((a).size())
#define F first
#define S second

#define rep(i, a, b) for(int i = a; i < b; ++i)
#define per(i, a, b) for(int i = a; i >= b; --i)
#define travel(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define INDEX(arr,ind)			(lower_bound(all(arr),ind)-arr.begin())

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;
typedef vector<pii> vpii;
typedef vector<piii> vpiii;

inline ll powmod(ll x, ll n, ll _mod){ 
  ll res = 1; 
  while (n){
    if (n & 1)res = (res*x) % _mod; 
    x = (x*x) % _mod; 
    n >>= 1;
    }
    return res; 
  }

int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};
//******************************************************************//
#define N 100005
int h,w;

int main(){
 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 // freopen("in.txt","r",stdin);
 // freopen("o.txt","w",stdout);

cin>>h>>w;
vpii v;
rep(i,0,h)rep(j,0,w){
	char c;
	cin>>c;
	if(c=='#')v.pb(mp(i,j));
}
sort(all(v));
int n=sz(v);
bool ok=true;
if(v[0]!=mp(0,0) or v[n-1]!=mp(h-1,w-1))ok=0;
rep(i,1,n){
	int x1=v[i-1].F;
	int y1=v[i-1].S;
	int x2=v[i].F;
	int y2=v[i].S;
	if(y1>y2)ok=0;
}
if(ok)cout<<"Possible\n";
else cout<<"Impossible\n";

return 0;
}

Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		System.out.println((A * N < B)? A * N : B);
	}
}

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

using namespace std;

int main(){
    long long n, ans = 0;
    cin >> n;
    vector<long long>v;
    for(long long i = 0; i < n; ++i){
        long long tmp; cin >> tmp;
        v.push_back(tmp);
    }
    for(long long i = 0; i < n - 1; ++i){
        for(long long j = 0; j < n; ++j){
            ans = max(ans, abs(v[i] - v[j]));
        }
    }
    cout << ans;
    return 0;

}


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

long long max(long long a, long long b){
    return (a > b) ? a : b;
}

long long F(long long A, long long B){
    long long a = floor(log10(A)) + 1;
    long long b = floor(log10(B)) + 1;
    return max(a, b);
}

int main()
{
    long long N;
    std::cin >> N;

    long long n = floor(sqrt(N));
    long long A = 1;
    for(int i=2; i<=n; i++){
        if(N % i == 0) A = i;
    }
    long long B = N / A;
    std::cout << F(A, B) << std::endl;
}

Measured memory_bytes: 256
s=input()
n=len(s)

res=0
for i in range(n):
  if s[i]=="U" or s[i]=="D":
    1
  else:
    if i%2==1 and s[i]=="L":
      1
    elif i%2==0 and s[i]=="R":
      1
    else:
      res=1
print("Yes" if res == 0 else "No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x,y;
  	x=0;
  	y=0;
	cin>>n;
	vector<int> a(n);
	for(int i=0;n>i;i++){
		cin>>a.at(i);
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	for(int i=0;n>i;i+=2){
		x+=a.at(i);
	}
	for(int i=1;n>i;i+=2){
		y+=a.at(i);
	}
	cout<<x-y<<endl;
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    string s; cin >> s;

    int ans = 0;

    for (int i = 0; i < s.size()-1; ++i) {
        if ((s[i] == 'W' && s[i+1] == 'B') || (s[i] == 'B' && s[i+1] == 'W')) {
            ++ans;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <climits>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()

int main()
{
  int H, W;
  cin >> H >> W;
  string A[H];
  for (int i = 0; i < H; ++i) {
    cin >> A[i];
  }
  ll Q=1000000007;
  ll dp[H][W];
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      dp[i][j] = 0;
    }
  }

  dp[0][0] = 1;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (i != H-1) {
        if (A[i+1][j] == '.') {
          dp[i+1][j] = (dp[i+1][j] + dp[i][j])%Q;
        }
      }
      if (j != W-1) {
        if (A[i][j+1] == '.') {
          dp[i][j+1] = (dp[i][j+1] + dp[i][j])%Q;
        }
      }
    }
  }
  cout << dp[H-1][W-1] << "\n";
  return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    mint ans = mint(0);
    mint num = mint(0);
    ll a;
    for(int i=0;i<n;i++){
        cin >> a;
        ans += a;
        num += a * a;
    }
    ans *= ans;
    ans -= num;
    ans /= mint(2);
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
int main(){
	int n,k,x,y,sum=0;
	scanf("%d\n%d\n%d\n%d",&n,&k,&x,&y);
	if(1<=n&&k<=10000&&1<=y&&y<x&&x<=10000){
	if(n>=k){
	for(int i=1;i<=k;i++) sum += x;
    for(int j=k+1;j<=n;j++) sum += y;
    }
    else if(n<k){
    for(int i=1;i<=n;i++) sum += x;
	}
    printf("%d\n",sum);	
    }
    return 0;	
	}

Measured memory_bytes: 128
#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>
#define INF 0x3f3f3f3f
#define MOD 1000000007
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	int N,mincos=INF;
	int a[100];
	int cost[201]={};
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	for(int i=0;i<=200;i++){
		for(int j=0;j<N;j++){
			cost[i]+=(a[j]-i+100)*(a[j]-i+100);
		}
		mincos=min(mincos,cost[i]);
	}
	cout<<mincos<<endl;
	return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
if h==1:
    a=1
elif w==1:
    a=1
elif h%2==0:
    a=int((h*w)/2)
else:
    if w%2==0:
        b=int(w/2)
    else:
        b=int((w/2)+1)
    a=int((((h-1)*w)/2)+b)
print(a)


Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#define ll long long
#include<string>
#include<vector>
ll int mark[1005];
using namespace std;
int main(){
    ll int n,i,l,j=0;
    string a;
    cin>>a;
    cin>>n;
    l=a.size();
    //cout<<l<<endl;
    for(i=0;i<l;i++){
        if(j==0){ mark[i]=1;}
        j++;
        if(j==n) j=0;

    }
    for(i=0;i<l;i++){
        if(mark[i]==1) cout<<a[i];

    }
    cout<<endl;


}


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

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  string s;cin>>s;
  int ans = 1;
  rep(i,1,n){
    if (s[i]!=s[i-1]) ans++;
  }
  cout << ans << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
typedef long long ll;
ll n,k;
int main(void){
    cin>>n>>k;
    if(k==0){
        for(int i=0;i<(1LL<<n);i++){
            cout<<i<<" "<<i<<" ";
        }
        cout<<endl;
        return 0;
    }
    if(n==1||0>k||k>=(1LL<<n)){
        cout<<-1<<endl;
        return 0;
    }
    cout<<0<<" "<<k<<" "<<0<<" ";
    for(int i=1;i<(1LL<<n);i++){
        if(i==k)continue;
        cout<<i<<" ";
    }
    cout<<k<<" ";
    for(int i=(1LL<<n)-1;i>0;i--){
        if(i==k)continue;
        cout<<i<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 1792
n = gets.to_i
as = gets.split
  .each_with_object(Hash.new(0)) { |a, h| h[a.to_i] += 1 }
  .select { |_, v| v >= 2 }

ans = 0
prev = 0

as.keys.sort.reverse.each do |k|
  v = as[k]
  s = v >= 4 ? [prev * k, k ** 2].max : prev * k

  if s > ans
    ans = s
    break
  end

  prev = k
end

puts ans


Measured memory_bytes: 14212
#include <stdio.h>
#define kate 1000000000
int main(void)
{
	long long int xm,xc,xa,ym,yc,ya;
	long long int S;
	scanf("%lld",&S);
	xm = 0;
	ym = 0;
	if(S <= kate){
		xa = 1;
		ya = 0;
		xc = 0;
		yc = S;
		printf("%lld %lld %lld %lld %lld %lld",xm,ym,xc,yc,xa,ya);
		return 0;
	}
	else if(S % kate == 0)
	{
		xa = kate;
		ya = 0;
		xc = 0;
		yc = S/kate;
		printf("%lld %lld %lld %lld %lld %lld",xm,ym,xc,yc,xa,ya);
		return 0;
	}
	xa = kate;
	ya = 1;
	yc = S / kate;
	yc++;
	xc = yc*kate - S;
	printf("%lld %lld %lld %lld %lld %lld",xm,ym,xc,yc,xa,ya);
	
	return 0;
}



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

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

  if(K%2==0){
    cout << (K/2)*(K/2) << endl;
  }
  else{
    cout << ((K/2)+1)*(K/2) << endl;
  }

return 0;  
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

vector<ll> dx={0,1,0,-1};
vector<ll> dy={1,0,-1,0};


int main(){
    ll h,w;
    cin>>h>>w;
    vector<vector<ll>> dp(h,vector<ll>(w,E));
    queue<pll> Q;
    ll ans=0;
    for(int i=0;i<h;i++){
        string s;
        cin>>s;
        for(int t=0;t<w;t++){
            if(s[t]=='#'){dp[i][t]=0; Q.push({i,t});}
        }
    }
    while(!Q.empty()){
        pll W=Q.front(); Q.pop();
        for(int i=0;i<4;i++){
            ll x=W.F+dx[i];
            ll y=W.S+dy[i];
            if(x<0 || y<0 || x>=h || y>=w || dp[x][y]<=dp[W.F][W.S]+1){continue;}
            dp[x][y]=dp[W.F][W.S]+1;
            ans=max(ans,dp[x][y]);
            Q.push({x,y});
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 24500
#include <iostream>
#include <algorithm>
using namespace std;
int n, m, v[100], w[100], dp[102][10007];
int main() {
	cin >> n >> m;
	for(int i = 0; i < n; i++) cin >> v[i] >> w[i];
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			dp[i][j] = dp[i - 1][j];
			if(j >= w[i - 1]) dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
		}
	}
	cout << dp[n][m] << endl;
}

Measured memory_bytes: 7000
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void) {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<int> p(A), q(B), r(C);
    for(int i=0; i<A; i++) {
        cin >> p[i];
    }
    for(int i=0; i<B; i++) {
        cin >> q[i];
    }
    for(int i=0; i<C; i++) {
        cin >> r[i];
    }

    sort(p.rbegin(), p.rend());
    for(int i=0; i<X; i++) {
        r.push_back(p[i]);
    }
    sort(q.rbegin(), q.rend());
    for(int i=0; i<Y; i++) {
        r.push_back(q[i]);
    }

    sort(r.rbegin(), r.rend());
    cout << accumulate(r.begin(), r.begin()+X+Y, 0LL) << endl;
    return 0;
}


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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=20, mod=1e9+7;
inline int add(int x,int y) {return (x+y>=mod) ? (x+y-mod) : (x+y);}
inline void up(int &x,int y) {x=add(x,y);}

int n,m,k,lim[N+20][N+20];
int bin[N+20],y,f[2][(1<<(N-1))+50],nxt[(1<<(N-1))+50][N];
inline int trans(int sta,int pos) {
	int p=nxt[sta][pos];
	sta^=bin[pos]; 
	if(p<n-1) sta^=bin[p];
	return sta;
}
inline void trans(int id) {
	for(int i=0;i<n-1;i++) {
		y^=1; memset(f[y],0,sizeof(f[y]));
		for(int pre=0;pre<bin[n-1];++pre) if(f[y^1][pre]) {
			if(!(pre&bin[i]) && (lim[id][i]!=2)) up(f[y][pre],f[y^1][pre]);
			if(lim[id][i]!=1) up(f[y][trans(pre,i)],f[y^1][pre]);
		}
	}
}

int main() {
	n=rd(), m=rd(), k=rd();
	if(n==1) return puts("1"),0;
	for(int i=0;i<=n;i++) bin[i]=1<<i;
	for(int i=0;i<bin[n-1];i++) 
		for(int j=0,z=0;j<n-1;j++) {
			while(z<n-1 && (z<j || (!(i&bin[z])))) ++z;
			nxt[i][j]=z;
		}
	for(int i=1;i<=k;i++) {
		int x=rd(), y=rd()-1;
		lim[x][y]=rd()+1;
	}
	f[y][0]=1;
	for(int i=1;i<=m;i++) trans(i);
	int ans=0;
	for(int i=0;i<bin[n-1];i++) up(ans,f[y][i]);
	cout<<ans<<'\n';
}

Measured memory_bytes: 45312
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
#define enld endl
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int snuke[100];
    Fill(snuke,0);
    int n,k; cin >> n >> k;
    for(int i=0;i<k;i++){
        int d; cin >> d;
        for(int j=0;j<d;j++){
            int a; cin >> a;
            a--;
            snuke[a]++;
        }
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        if(snuke[i] == 0) ans++;
    }
    cout << ans << enld;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	long long a, b, c, d, e, f, g, s = -101, x = 101, y = 0;
	cin >> a >> b >> c >> d;
	for (int k = 1; k <= a; k++) {
		cin >> f;
		s = max(f, s);
	}
	for (int h = 1; h <= b; h++) {
		cin >> g;
		x = min(g, x);
	}
	for (int j = c + 1; j <= d; j++) {
		if (j > s && j <= x && y == 0) {
			cout << "No War" << endl;
			y++;
		}
	}
	if (y == 0) {
		cout << "War" << endl;
	}
	cin >> e;
}

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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>

using namespace std;
using ll = long long;


vector<int> c;
vector<vector<int>> s;
int D;

ll calc(vector<int> v){
    ll ans = 0;
    vector<int> last(26, 0);
    for(int i = 0;i < D;i++){
        last[v[i] - 1] = i + 1;
        ans += s[i][v[i] - 1];
        //cout<<s[i][v[i] - 1]<<endl;
        for(int j = 0;j < 26;j++){
            ans -= (ll)(i + 1 - last[j]) * c[j];
        }
        cout<<ans<<endl;
    }
    return ans;
}

int main(){
    cin >> D;
    for(int i = 0;i < 26;i++){
        int a;cin >> a;
        c.push_back(a);
    }
    for(int i = 0;i < D;i++){
        vector<int> a;
        for(int j = 0;j < 26;j++){
            int b;cin >> b;
            a.push_back(b);
        }
        s.push_back(a);
    }
    vector<int> v;
    for(int i = 0;i < D;i++){
        int a;cin >> a;
        v.push_back(a);
    }
    calc(v);
}

Measured memory_bytes: 3688
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

#include <atcoder/dsu.hpp>
#include <atcoder/fenwicktree.hpp>
#include <atcoder/segtree.hpp>
#include <atcoder/lazysegtree.hpp>
#include <atcoder/maxflow.hpp>
#include <atcoder/mincostflow.hpp>

using namespace std;
using namespace atcoder;

////////////////	型名など
typedef long long ll;
#define endl '\n'

////////////////	各種定数
const ll INF = 1LL << 60;
const double EPS = 1e-12;

////////////////	便利なテンプレート関数
template<typename T>
inline bool chmin(T& x, T a) {
	if (x >= a) { x = a; return true; }
	return false;
}

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

////////////////	UnionFind
#define UnionFind dsu

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

	int N; cin >> N;
	vector<pair<pair<int, int>, int>> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i].first.first >> A[i].first.second;
		A[i].first.first--;
		A[i].first.second--;
		A[i].second = i;
	}

	sort(A.begin(), A.end());

	set<pair<int, int>> st;// y座標とインデックス
	UnionFind uf(N);
	for (int i = 0; i < N; i++) {
		pair<int, int> p = { A[i].first.second, A[i].second };
		if (st.size() == 0 || st.begin()->first > p.first) {
			st.insert(p);
		}
		else {
			auto end = st.lower_bound(p);
			auto itr = st.begin();
			while (1) {
				itr++;
				if (itr == end) { break; }
				uf.merge(itr->second, p.second);
			}
			uf.merge(st.begin()->second, p.second);
		}
	}

	for (int i = 0; i < N; i++) {
		cout << uf.size(i) << endl;
	}

	return 0;
}

Measured memory_bytes: 10956
#include<bits/stdc++.h>
#define N 300010
#define EPS 1e-9
#define PI acos(-1)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define fs first
#define sc second
#define db double
#define pb push_back
#define ll long long
#define VI vector<int>
#define PII pair<int,int>
#define PQ priority_queue
#define NP next_permutation
#define ull unsigned long long
#define sz(a) (int)a.size()
#define len(a) (int)strlen(a)
#define all(a) a.begin(),a.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define F(i,j,k) for(register int i=j;i<=k;i++)
#define CK1(x) cout<<"["<<(x)<<"]\n";
#define CK2(x,y) cout<<"["<<(x)<<","<<(y)<<"]\n";
#define CK3(x,y,z) cout<<"["<<(x)<<","<<(y)<<","<<(z)<<"]\n";
#define IOS ios::sync_with_stdio(false)
using namespace std;
istream &operator >> (istream &in,VI &v){for(auto &i:v)in>>i;return in;}
ostream &operator << (ostream &out,VI &v){for(auto i:v)out<<i<<" ";return out;}
int n,m,k,ans;
string s[7],tt[7];
void dfs(int t,int vis)
{;
    if(t>n+m)return;
    if(t==n+m)
    {
        for(int i=0;i<n;i++)tt[i]=s[i];
        for(int i=0;i<n+m;i++)
        {
            if(vis&(1<<i))
            {
                if(i<n)for(int j=0;j<m;j++)s[i][j]='.';
                else for(int j=0;j<n;j++)s[j][i-n]='.';
            }
        }
        int c=0;
        for(int i=0;i<n;i++)for(int j=0;j<m;j++)c+=(s[i][j]=='#');
        if(c==k)ans++;
        for(int i=0;i<n;i++)s[i]=tt[i];
        return;
    }
    dfs(t+1,vis);
    dfs(t+1,vis+(1<<t));
}
int main()
{
//    IOS;
#if 0
    int T;cin>>T;
    while(T--)
#endif
    {
        cin>>n>>m>>k;
        for(int i=0;i<n;i++)
            cin>>s[i];
        dfs(0,0);
        cout<<ans<<"\n";
    }
}


Measured memory_bytes: 3596
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll Pow(ll A, ll B, ll mod){
  if (B == 0) return 1;
  else{
    if (B % 2 == 0){
      return Pow(A * A % mod, B / 2, mod) % mod;
    }else{
      return A * Pow(A * A % mod, B / 2, mod) % mod;
    }
  }
}

ll nCr(ll N, ll R, ll mod){
  ll ans = 1; R = min(R, N - R);
  for (ll i = 1; i <= R; i++){
    ans *= N - i + 1; ans %= mod;
    ans *= Pow(i, mod - 2, mod); ans %= mod;
  }
  return ans;
}

int main(){
  int N; cin >> N;
  vector <Pii> graph[N];

  for (int i = 0; i < N - 1; i++){
    int A, B; cin >> A >> B;
    A--; B--;
    graph[A].push_back(make_pair(B, i));
    graph[B].push_back(make_pair(A, i));
  }

  int M = 0;
  for (int i = 0; i < N; i++){
    int now = graph[i].size();
    M = max(M, now);
  }

  vector <int> ans(N - 1);
  queue <int> que;
  vector <bool> visited(N);
  que.push(0); visited[0] = true;

  while (!que.empty()){
    int Q = que.front(); que.pop();
    vector <bool> checked(M + 1);

    queue <int> que2;
    for (int i = 0; i < graph[Q].size(); i++){
      int next = graph[Q][i].first;
      if (visited[next] == false){
        visited[next] = true;
        que.push(next);
      }

      int num = graph[Q][i].second;
      if (ans[num] != 0){
        checked[ans[num]] = true;
      }else{
        que2.push(num);
      }
    }

    int now = 1;
    while (!que2.empty()){
      int num = que2.front(); que2.pop();
      for (int i = now; i < M + 1; i++){
        if (checked[i] == false){
          checked[i]  = true;
          ans[num] = i;
          now = i;
          break;
        }
      }
    }
  }
  
  cout << M << endl;
  for (int i = 0; i < N - 1; i++){
    cout << ans[i] << endl;
  }
  

  return 0;
}


Measured memory_bytes: 7040
import java.util.*;

public class Main{
  static int N;
  static String[] zero = {"0", "00", "000", "0000"};
  static String[] nine = {"9", "99", "999", "9999"};
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    N = sc.nextInt();
    int ans = 0;
    for(int i = 1; i <= N; i++){
      String S = i+"";
      char c1 = S.charAt(0);
      char c2 = S.charAt(S.length()-1);
      ans += func(c1, c2);
    }
      
    System.out.println(ans);
  }
  static int func(char c1, char c2){
    int ret = 0;
    if(c1 == c2){
      ret++;
    }
    if(c1 == '0' || c2 == '0'){
      return 0;
    }
    String S = String.valueOf(c1);
    String T = String.valueOf(c2);
    
    int B = Integer.parseInt(T+S);
    if(B <= N){
      ret += 1;
    }else{
      return ret;
    }
    
    int A = Integer.parseInt(T+zero[0]+S);
    B = Integer.parseInt(T+nine[0]+S);
    if(B <= N){
      ret += 10;
    }else if(A <= N){
      int C = (N-A)/10+1;
      ret += C;
    }else{
      return ret;
    }
    
    A = Integer.parseInt(T+zero[1]+S);
    B = Integer.parseInt(T+nine[1]+S);
    if(B <= N){
      ret += 100;
    }else if(A <= N){
      int C = (N-A)/10+1;
      ret += C;
    }else{
      return ret;
    }
    
    A = Integer.parseInt(T+zero[2]+S);
    B = Integer.parseInt(T+nine[2]+S);
    if(B <= N){
      ret += 1000;
    }else if(A <= N){
      int C = (N-A)/10+1;
      ret += C;
    }else{
      return ret;
    }
    
    A = Integer.parseInt(T+zero[3]+S);
    B = Integer.parseInt(T+nine[3]+S);
    if(B <= N){
      ret += 10000;
    }else if(A <= N){
      int C = (N-A)/10+1;
      ret += C;
    }
    return ret;
  }
}

Measured memory_bytes: 65464
from math import factorial as frac

N, M = map(int, input().split())

INF = 10**9 + 7

if abs(N-M) > 1:
    print(0)
elif abs(N-M) == 1:
    print(frac(N)*frac(M)%INF)
else:
    print(((frac(N)*frac(M))*2)%INF)


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

using namespace std;

#define li long long int
#define FOR(i, a, b) for (li (i) = (a) ; (i) < (b) ; ++(i))
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    li N, T;
    cin >> N >> T;

    li c[N];
    li t[N];

    FOR(i, 0, N) {
        cin >> c[i] >> t[i];
    }
    li TLECost = 2000;
    li minCost = 2000; // 考えられるコストの上限より大きい数
    FOR(i, 0, N) {
        if (t[i] <= T && c[i] < minCost) {
            minCost = c[i];
        }
    }

    if (minCost == TLECost) {
        cout << "TLE"; 
    } else {
        cout << minCost;
    }

    return 0;
}

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

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

	while(n--){
		int a,b,c;
		cin>>a>>b>>c;
		a *= a;
		b *= b;
		c *= c;
		cout<<(a+b==c || a+c==b || b+c==a ? "YES" : "NO")<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
int n,a[maxn],b[maxn];
struct node{
	int B,id;
	bool operator<(const node& x)const{
		return B<x.B;
	}
	bool operator<(int x)const{
		return B<x;
	}
};
multiset<node> ms;
int vis[maxn];
int mp[maxn];
int dfs(int x){
	if(vis[x]) return 0;
	vis[x]=1;
	return 1+dfs(mp[x]);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	for(int i=1;i<=n;i++) {
		scanf("%d",b+i);
		ms.insert((node){b[i],i});
	}
	for(int i=1;i<=n;i++){
		auto it=ms.lower_bound((node){a[i],0});
		if(it==ms.end()){
			puts("No");
			return 0;
		}
		a[i]=it->B;
		mp[i]=it->id;
		ms.erase(it);
	}
	if(dfs(1)==n){
		puts("No");
	}
	else{
		puts("Yes");
	}
	
	
}


Measured memory_bytes: 6528
h, w = map(int, input().split())
a = []
for _ in range(h):
    a.append(list(map(int, input().split())))
ans = []
for i in range(h):
    for j in range(w-1):
        if a[i][j]%2==1:
            a[i][j+1] += 1
            ans.append((i+1, j+1, i+1, j+2))
for i in range(h-1):
    if a[i][-1]%2==1:
        a[i+1][-1] += 1
        ans.append((i+1, w, i+2, w))
print(len(ans))
for i in ans:
    print(*i)

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<55)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli dd[60][60];
char d[60][60];

int main(){

    lli h,w;
    cin>>h>>w;

    REP(i,1,h+1)REP(j,1,w+1){
        cin>>d[i][j];
        if(d[i][j]=='#')dd[i][j]=-1;
    }

    REP(i,1,h+1)REP(j,1,w+1){
        lli dx[8]={0,1,1,1,0,-1,-1,-1};
        lli dy[8]={-1,-1,0,1,1,1,0,-1};

        if(dd[i][j]==-1)continue;
        lli cnt=0;
        REP(k,0,8){
            lli nextI = i+dy[k];
            lli nextJ = j+dx[k];
            if(dd[nextI][nextJ]==-1)cnt++;
        }
        dd[i][j]=cnt;
    }

    REP(i,1,h+1){
        REP(j,1,w+1){
            if(dd[i][j]==-1)cout<<"#";
            else cout<<dd[i][j];
        }
        cout<<endl;
    }

    return 0;
}


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

typedef long long ll;
static const ll INF = 100000000000000;

struct Node {
  int id;
  ll cost;
  Node() {}
  Node(int id, ll cost) : id(id), cost(cost){}
  bool operator< (const Node& node) const {
    return node.cost < cost;
  } 
};

// N: 頂点数, E: 辺の数, d: 距離 を格納する配列, 
// t: 始点, flag: true なら　無向辺, false なら 有向辺
void dijkstra(int N, int E, ll d[], int t, int from[], int to[], ll cost[], bool flag) {
  static const int WHITE = 0;
  static const int GRAY = 1;
  static const int BLACK = 2;
  
  int color[N];
  vector<Node> adj[N];
  for (int i = 0; i < N; i++) {
    d[i] = INF;
    color[i] = WHITE;
  }
  // 隣接リストの作成
  for (int i = 0; i < E; i++) {
    adj[from[i]].push_back(Node(to[i], cost[i]));
    if (flag) adj[to[i]].push_back(Node(from[i], cost[i]));
  }
  priority_queue<Node> pq;
  d[t] = 0;
  pq.push(Node(t, 0));
  while (!pq.empty()) {
    Node f = pq.top();
    pq.pop();
    int u = f.id;
    color[u] = BLACK;
    if (d[u] < f.cost) continue;
    for (int j = 0; j < adj[u].size(); j++) {
      int v = adj[u][j].id;
      if (color[v] == BLACK) continue;
      if (d[v] > d[u] + adj[u][j].cost) {
        d[v] = d[u] + adj[u][j].cost;
        pq.push(Node(v, d[v]));
        color[v] = GRAY;
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int u[N - 1], v[N - 1];
  ll w[N - 1];
  for (int i = 0; i < N - 1; i++) {
    cin >> u[i] >> v[i] >> w[i];
    u[i]--;
    v[i]--;
  }
  ll d[N];
  dijkstra(N, N - 1, d, 0, u, v, w, true);
  for (int i = 0; i < N; i++) {
    if (d[i] % 2 == 0) {
      cout << "1\n";
    } else {
      cout << "0\n";
    }
  }
  return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
#include <map>
#include <cmath>
typedef long long int ll;
using namespace std; 
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	ll n,k,s;cin>>n>>k>>s;
	ll arr[n];
	for(int i=0;i<k;i++){
		arr[i] = s;
	}
	if(s==pow(10,9)){
		for(int i=k;i<n;i++){
			arr[i] = s-1;
		}
	}
	else{
		for(int i=k;i<n;i++){
			arr[i] = s+1;
		}
	}
	for(int i=0;i<n;i++){
		cout<<arr[i]<<" ";
	}
	cout<<endl;
}


Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();

		//int A = 46979;
		int intAns = 0;
		int intAns1 = 0;
		int intH = 3600;
		int intM = 60;
		int intS = 1;
	//	if() {
			intAns = A / intH;
			int intAmari = A % intH;
			intAns1 = intAmari / intM;
			intAmari = intAmari % intM;
			System.out.println(intAns+":"+intAns1+":"+intAmari);
		//}
	}
}

Measured memory_bytes: 26300
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	string s,t ;
	cin >> s >> t ;
	for(int i=0;i<t.size();i++) cout << s.at(i) << t.at(i) ;
	if(s.size()>t.size()) cout << s.at(s.size()-1) ;
	cout << endl ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)

const int MOD = 1e9 + 7;
int N;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}//modinv(i,mod)でi^-1のmodをとる。

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

ll sum = 0;
vector<vector<int> > G;

ll dfs(int idx, int par){
    ll psum = 1;
    for(auto &to: G[idx]){
        if(to == par) continue;

        psum += dfs(to, idx);
    }
    sum += (modpow(2,psum, MOD) - 1 + MOD) % MOD * ((modpow(2, N - psum, MOD) - 1 + MOD) % MOD);
    sum %= MOD;
    cerr << idx << " " << psum << " " <<  sum << endl;
    return psum;
}

int main(){
    cin >> N;
    G.resize(N);
    rep(i, 0, N - 1){
        int a, b; cin >> a >> b; a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0, -1);
    ll ans = (sum * modpow(modinv(2,MOD), N, MOD) % MOD) + (1 + MOD - modpow(modinv(2,MOD), N, MOD) % MOD) - N * modinv(2,MOD) % MOD;
    ans = (ans + MOD) % MOD;
    cout << ans << endl;
}


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

int main(){
  int P, Q, R;
  
  cin >> P >> Q >> R;
  
  int tmp = P + Q;
  
  if (P > R) {
    tmp = R + Q;
    if (Q > P) {
      tmp = R + P;
    }
  }
  
  else if (Q > R) {
    tmp = P + R;
    if (P > Q){
      tmp = Q + R;
    }
  }

  cout << tmp << endl;
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var res = num;
        for(var i = 0; i <= num; i++)
        {
            var cc = 0;
            var t = i;
            while (t > 0)
            {
                cc += t % 6;
                t /= 6;
            }
            t = num - i;
            while (t > 0)
            {
                cc += t % 9;
                t /= 9;
            }
            res = Min(res, cc);
        }
        WriteLine(res);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 11220
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

class Imos{
public:
    int H, W;
    vector<vector<int>> d;
public:
    //1-indexed
    Imos(vector<vector<int>>& field){
        H = field.size();
        W = field[0].size();
        d = vector<vector<int> >(H+1, vector<int>(W+1));
        
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                d[i+1][j+1] = d[i+1][j] + d[i][j+1] - d[i][j] + field[i][j];
            }
        }
    }
    int area(int h1, int w1, int h2, int w2){
        //size of area s.t. [h1, h2) and [w1, w2)
        return d[h2][w2] - d[h2][w1] - d[h1][w2] + d[h1][w1];
    }
};

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.precision(16);
    
    int N, M; cin >> N >> M;
    
    vector<int> xs(N), ys(N);
    vector<int> xps(N), yps(N);
    
    for(int i=0; i<N; i++){
        scanf("%d %d", &xs[i], &ys[i]);
        xps[i] = xs[i];
        yps[i] = ys[i];
    }
    
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    ys.erase(unique(ys.begin(), ys.end()), ys.end());
    
    vector<vector<int>> d(xs.size(), vector<int>(ys.size()));
    for(int i=0; i<N; i++){
        int x = xps[i], y = yps[i];
        int xi = lower_bound(xs.begin(), xs.end(), xps[i]) - xs.begin();
        int yi = lower_bound(ys.begin(), ys.end(), yps[i]) - ys.begin();
        
        d[xi][yi]++;
    }
    
    Imos imos = Imos(d);
    
    while(M--){
        int x1, y1, x2, y2;
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        
        int x1i = lower_bound(xs.begin(), xs.end(), x1) - xs.begin();
        int y1i = lower_bound(ys.begin(), ys.end(), y1) - ys.begin();
        int x2i = upper_bound(xs.begin(), xs.end(), x2) - xs.begin();
        int y2i = upper_bound(ys.begin(), ys.end(), y2) - ys.begin();
        
        printf("%d\n", imos.area(x1i, y1i, x2i, y2i));
    }
    return 0;
}

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

int main() {
  
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for (int i=0; i<N; i++) cin >> vec.at(i);
  
  vector<int> vec2(N);
  for (int k=0; k<N; k++) {
    for (int j=0; j<1000000; j++) {
      for (int i=0; i<N; i++) {
        if (vec.at(i)==j+1) {
          vec.at(i)=0;
          vec2.at(k)=j+1;
          break;
        }
      }
     if (vec2.at(k)!=0) break;
    }
      if (k==N-1) break;
  }
    
    int s=0;
    for (int i=0; i<N; i++) {
      if (i%2==0) s+=vec2.at(N-i-1);
      else s-=vec2.at(N-i-1);
    }
  
  cout << s << endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))

b = [format(t, "045b") for t in a]
# print(b)

c = []
for i in range(45):
  q = 0
  for t in b:
    q += int(t[i])
  c += [q]
# print(c)

d = [int(t) for t in list(format(k, "045b"))]
# print(d)
m = []
for i in range(45):
  if d[i] == 0:
    continue
  s = 0
  for j in range(i):
    s += (2**(44-j))*(d[j]*(n-c[j])+(1-d[j])*c[j])
  s += (2**(44-i))*c[i]
  for j in range(i+1,45):
    s += (2**(44-j))*max(c[j],n-c[j])
  m += [s]

s = 0
for j in range(45):
  s += (2**(44-j))*(d[j]*(n-c[j])+(1-d[j])*c[j])
m += [s]
print(max(m))  

Measured memory_bytes: 19500
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<pair<int,int>> p(n);
    for(int i=0;i<n;i++){
        int a,b;
        cin >> a >> b;
        p[i]=make_pair(b,a);
    }
    sort(p.begin(),p.end());
    int t=0; bool flag=true;
    for(int i=0;i<n;i++){
        t+=p[i].second;
        if(t>p[i].first) flag=false;
    }
    if(flag) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 1792
#include <stdio.h>

int search(int A[], int n, int key){
  int i=0;
  A[n]=key;
  
  while(A[i] != key)
    i++;
   
  return i != n;
}

int main(){
  int i, n ,A[10000+1], q, key, sum=0;

  scanf("%d", &n);
  for(i=0; i<n; i++)
    scanf("%d", &A[i]);

  scanf("%d", &q);
  for(i=0; i<q; i++)
    {
      scanf("%d", &key);      
      if(search(A, n, key))
	sum++;
    }
  printf("%d\n", sum);
  
  return 0;
}



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

main(){
    int n;cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll dp[n];
    dp[0]=0;
    dp[1] = abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1];
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int len=s.size();
    int flag=0;
    for(int i=0;i<len-1;i++)
    {
        if(s[i]=='A'&&s[i+1]=='C')
            flag=1;
    }
    if(flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256