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

typedef pair<int,int> P;

int n, A[1<<18];

signed main(){
  
  cin>>n;

  for(int i=0;i<(1<<n);i++) cin>>A[i];
  
  vector<P> dp[1<<18];
  
  for(int i=0;i<n;i++){
    dp[1<<i].push_back( P( A[1<<i], 1<<i ) );
    dp[1<<i].push_back( P( A[0], 0 ) );
    sort( dp[1<<i].begin(), dp[1<<i].end(), greater<P>() );
  }
  
  int ans = 0;
  
  for(int i=1;i<(1<<n);i++){
    
    if( __builtin_popcount( i ) >= 2 ){
    
      for(int j=0;j<n;j++){
      
	if( i & ( 1 << j ) ){
	
	  int pi = i ^ ( 1 << j );
	  
	  set<int> S;
	
	  int idx = 0;
	
	  while( S.size() < 2 ){
	    
	    if( S.count( dp[pi][idx].second ) == 0 ){
	      dp[i].push_back( dp[pi][idx] );
	    }
	    
	    S.insert( dp[pi][idx].second );
	    
	    idx++;
	  
	  }
		
	}
      
      }
      
      dp[i].push_back( P( A[i], i ) );
      
      sort( dp[i].begin(), dp[i].end(), greater<P>() );
	  
    }    
    
    vector<int> top2;
    
    set<int> S;
  
    int idx = 0;
    
    while( S.size() < 2 ){
      
      if( S.count( dp[i][idx].second ) == 0 ){
	top2.push_back( dp[i][idx].first );
      }
      
      S.insert( dp[i][idx].second );
      
      idx++;
      
    }
  
    ans = max( ans, top2[0] + top2[1] );

    cout<<ans<<endl;
    
  }
    
  return 0;
}


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

using namespace std;

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

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		100050

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2147483647 (Max int)
const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//


int DP[105][4];

//
int main(){
	ll N,A,B,C,D,E;
	cin >> N>>A>>B>>C>>D>>E;

	ll minl = A;
	minl=min(minl,B);minl=min(minl,C);minl=min(minl,D);minl=min(minl,E);

	printf("%lld\n",4LL + N/minl + (N%minl!=0)*1);

	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <array>
#include <bitset>
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define endl '\n'
using namespace std;

const int mn = 1e6 + 10;
int n;
int a[mn];

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

signed main() {
    fastio;
    cin >> n;
    rep (i, n) {
        cin >> a[i];
    }

    set<int> st, temp; // set of all factors
    int g = a[0];
    bool pairwise = true;
    for (int i = 0; i < n; i++) {
        int ai = a[i];
        // check for setwise coprime
        if (i > 0)
            g = gcd(g, ai);

        if (pairwise) {
            // factorize ai
            for (int i = 2; i * i <= ai; i++) {
                if (ai % i == 0) {
                    temp.insert(i);
                }
                while (ai % i == 0)
                    ai /= i;
            }

            if (ai != 1) temp.insert(ai);
            for (auto& t : temp) {
                if (st.count(t)) {
                    pairwise = false;
                }
                else st.insert(t);
            }
        }
        temp.clear();
    }

    if (pairwise) {
        cout << "pairwise coprime" << endl;
    }
    else if (g == 1) {
        cout << "setwise coprime" << endl;
    }
    else {
        cout << "not coprime" << endl;
    }
}

Measured memory_bytes: 10908
#include<bits/stdc++.h>
using namespace std;
struct pr{int64_t mn,mx;};

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int64_t>a(n+1); for(auto&&i:a)cin>>i;
	vector<pr>b(n+1); for(int i=0;i<=n;++i)b.at(i).mx=a.at(i); b.back().mn=a.back();
	for(auto i=b.rbegin()+1;i!=b.rend();++i){
		i->mn=((i-1)->mn+1)/2;
		i->mx+=(i-1)->mx;
	}
	bool yes=true;
	int64_t j=1,ans=0;
	for(int i=0;i<=n;++i){
		if(j<b.at(i).mn)yes=false;
		ans+=j=min(j,b.at(i).mx);
		j-=a.at(i);
		j*=2;
	}
	cout<<(yes?ans:-1)<<"\n"s;
}

Measured memory_bytes: 5548
n, m, x, y = list(map(int, input().split()))
xn = list(map(int, input().split()))
ym = list(map(int, input().split()))

xn.sort(reverse = True)
ym.sort()

z = ym[0]

if xn[0] < z:
    if x < z:
        if z < y:
            print("No War")
            exit()
print("War")


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
using namespace std;
const int Maxn=100000+20;
int n,m,ans;
bool vis[Maxn];
int main()
{
	scanf("%d",&n);
	m=min(n+233,100000+5);
	for(int i=2;i<=m;++i)
	{
		if(vis[i])continue;
		
		if(i>=n){ans=i;break;}
		int j=i<<1;
		while(j<=m)
		vis[j]=1,j+=i;
	}
	
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;

int main() {

  int n;
  string mise,str;

  cin >> n;
  cin >> mise;

  int ans = 0;
  for(int i=0;i<n;i++) {
    cin >> str;

    //for(int i=0;i<str.size();i++)cout<< i<<str[i]<<"|";
    //cout << endl;
    
    int c = 0;
    int site[101] = {0};
    for(int j=0;j<str.size();j++) {
      if(mise[c] == str[j]) {
	//cout << mise[c] <<" = "<< str[j] << endl;
	site[c] = j;
	//cout << "site" << site[c] << endl;
	c++;
      }
      
      if(c >= 3 && site[c-2] - site[c-3] != site[c-1] - site[c-2]) {
	//	cout << site[c-2] - site[c-3] << " != "<<site[c-1] - site[c-2]<< endl;
	c--;
	j = site[c];
	site[c] = 0;
      }if(c >=2 && site[c-1] - site[c-2] < j - site[c-1]) {
	//cout <<"koeta"<<endl;
	c--;
	j = site[c];
	site[c] = 0;
      }
	  
      
      if(c == mise.size()) {
	ans++;
	break;
      }
      
      if(c !=0 &&j == str.size()-1) {
	//cout << "j= size" <<endl;
	c--;
	j = site[c];
	site[c] = 0;
	//cout << "j = " <<j<<endl;
	//cout << c<<endl;
	if(c != 0 && j == str.size()-1) {
	  c--;
	  j = site[c];
	site[c] = 0;
	}
	
      }
      
      
    }

  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1208
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(int x){write(x);putchar('\n');}
const int MAXN=2005;
int f[2*MAXN][MAXN],ps[MAXN][2];
int sum[2*MAXN][MAXN][2];
char ch[10];
int n,a[2*MAXN],b[2*MAXN];
int main()
{
	n=read();
	
	for(int i=1;i<=2*n;i++)
	{
		scanf("%s",ch+1);int x=read();a[i]=x;
		if(ch[1]=='W')ps[x][1]=i,b[i]=1,sum[i][x][1]++;
		else ps[x][0]=i,b[i]=0,sum[i][x][0]++;
	}
	for(int i=2*n;i>=1;i--)
	{
		for(int j=1;j<=n;j++)for(int k=0;k<=1;k++)sum[i][j][k]+=sum[i][j-1][k];
		for(int j=1;j<=n;j++)for(int k=0;k<=1;k++)sum[i][j][k]+=sum[i+1][j][k];
	}
	memset(f,63,sizeof(f));f[0][0]=0;
	for(int i=1;i<=2*n;i++)
		for(int x=0;x<=min(i,n);x++)
		{
			int u=i-x;
			if(u<=n)f[i][x]=min(f[i][x],f[i-1][x]+ps[u][0]+sum[ps[u][0]][u-1][0]+sum[ps[u][0]][x][1]-i);
			if(x-1>=0&&u<=n)f[i][x]=min(f[i][x],f[i-1][x-1]+ps[x][1]+sum[ps[x][1]][x-1][1]+sum[ps[x][1]][u][0]-i);
		}
	//有多少个白色 
	pr2(f[2*n][n]);
	return 0;
}



Measured memory_bytes: 94464
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int n;
char s;
set<char> ans;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
    for (int i = 0; i < n; ++i) {
        cin >> s;
        ans.insert(s);
    }
    string out = ans.size() == 3 ? "Three" : "Four";
    cout << out << endl;
    return;
}

int main() {
    cin >> n;
    solve();
    return 0;
}



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

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
    _typer init = 0;
    char ch = getchar(), k = 0;
    for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
    for ( ; isdigit(ch); ch = getchar())
        init = (init << 3) + (init << 1) + (ch ^ 48);
    return k ? -init : init;
}
const ll N = 0, INF = 1e9;


int main() {
    int k, x; cin >> k >> x;
    rep (i, x - k + 1, x + k - 1) cout << i << " \n"[i == x + k - 1];
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define long long ll
char s[30000];
int cnt;
int main(){
    cin>>s;
    int flag=1,k;
    cnt=strlen(s);
    for(int i=1;i<=cnt;i++){
        flag=1;
        if((cnt-i)%2!=0) continue;
        if((cnt-i)%2==0){
            k=(cnt-i)/2;
            for(int j=0;j<k;j++){
                if(s[j]!=s[j+k]){
                    flag=0;
                    break;
                }
            }
            if(flag){
                cout<<cnt-i<<endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

		List<Long>[] options = new ArrayList[4];
		for (int i = 0; i < 4; i++) {
			options[i] = new ArrayList<>();
		}

		long w1 = sc.nextLong();
		options[0].add(sc.nextLong());
		for (int i = 1; i < n; i++) {
			options[(int) (sc.nextLong() - w1)].add(sc.nextLong());
		}

		for (int i = 0; i < 4; i++) {
			options[i].sort(Comparator.reverseOrder());
		}

		for (int i = 0; i < 4; i++) {
			for (int j = 1; j < options[i].size(); j++) {
				options[i].set(j, options[i].get(j - 1) + options[i].get(j));
			}
		}

		for (int i = 0; i < 4; i++) {
			options[i].add(0, 0L);
		}

		long answer = 0;
		for (int i = 0; i < options[0].size(); i++) {
			for (int j = 0; j < options[1].size(); j++) {
				for (int k = 0; k < options[2].size(); k++) {
					for (int l = 0; l < options[3].size(); l++) {
						if (w1 * i + (w1 + 1) * j + (w1 + 2) * k + (w1 + 3) * l > w) continue;
						answer = Math.max(answer, options[0].get(i) + options[1].get(j) + options[2].get(k) + options[3].get(l));
					}
				}
			}
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 22996
#include<cstdio>
long long h;
int main() {
	scanf("%lld",&h);
	long long n=1;
	while (n<=h)n*=2;
	n/=2;
	long long p=1,ans=0;
	while (p<=n) {
		ans+=p;
		p*=2;
	}
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 128
import java.io.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import static java.lang.Math.*;

public class Main {
  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

          final long n = atol(in.readLine());
          List<Long> list = new ArrayList<>();
          for (int i = 0; i < 5; i++) {
            list.add(atol(in.readLine()));
          }

          final long m = Collections.min(list);
          
          final long ans = 5 + ((n + m - 1)/ m) - 1;
          System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  int  atoi(String s) { return Integer.parseInt(s); }
  long atol(String s) { return Long.parseLong(s);   }
}

Measured memory_bytes: 21328
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long N, long long A, long long B){
  cout << A*(N/(A+B)) + min((N%(A+B)),A) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
}


Measured memory_bytes: 384
#include<iostream>
#define debug(x) std::cout<<x<<std::endl;
#define fori(i,a,z) for(i=a;i<=z;i++)
int main(){
  int i=0,A=0,B=0,C=0,ans;
  std::cin>>A>>B>>C;
  ans = A*C - B; 
  std::cout << ans << std::endl;
  
  fori(i,0,8){
      ans = A * ans - B;
      std::cout << ans << std::endl;
  }
  return 0;
}

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

using namespace std;

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

  int h = N / 100;
  int t = (N % 100) / 10;
  int o = (N % 100) % 10;

  if ( h != 7 && t != 7 && o != 7 ) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }


}


Measured memory_bytes: 3624
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    a = [i_input() for _ in range(5)]
    k = i_input()

    if a[-1] - a[0] > k:
        print(":(")
        exit()
    print("Yay!")







if __name__=="__main__":
    main()


Measured memory_bytes: 65452
/* ex 3-3
    kas056*/
#include <stdio.h>
int main(void){
    int N , K ;
    // N,Kの読み込み
    scanf("%d %d", &N, &K);
 
    //何乗したかのカウンターcountとその時点の数値valueを用意
    int count = 1;
    int value = K;
 
    /*K進法の桁数はK^count>Nとなるようなcountに決まるので、そのcountになるまでvalueにK
    を掛けていく*/
    while (value <= N){
        value *= K;
        count += 1;
    }
    //countを出力
    printf("%d\n",count);
    return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> p(n);
    for(int i = 0; i < n; ++i){
        cin >> p.at(i);
    }

    ll ans = 0;
    for(int i = 0; i < n; ++i){
        if(i < n - 1){
            if(p.at(i) == i + 1){
                swap(p.at(i), p.at(i + 1));
                ans++;
            }
        }else{
            if(p.at(i) == i + 1){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef complex<double> cdouble;
typedef vector<complex<double>> vcd;
typedef vector<vector<complex<double>>> vvcd;

/*******************************************************/

int main() {
  int n; cin >> n;
  int now_x = 0, now_y = 0, now_t = 0;
  bool judge = true;
  Loop(i, n) {
    int t, x, y; cin >> t >> x >> y;
    int d = abs(now_x - x) + abs(now_y - y);
    int dt = t - now_t;
    if (dt >= d && (dt - d) % 2 == 0) {
      now_x = x;
      now_y = y;
      now_t = t;
    }
    else judge = false;
  }
  if (judge) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

const int inf = 1<<27;

struct State{
  int side;
  int now;
  int cost;
  State(int side, int now, int cost):side(side),now(now),cost(cost){}
};

int bfs(int side, const vector<int> &A, const vector<int> &B)
{
  int ret = inf;
  queue<State> Q;
  bool vis[2][A.size()];
  for(int i = 0; i < 2; ++i){
    for(int j = 0; j < (int)A.size(); ++j){
      vis[i][j] = false;
    }
  }
  int st=0;
  const vector<int> &vT = side==0?A:B;
  if(vT[0]==2)return inf;
  if(vT[0]==1){
    for(st = 0; st < (int)vT.size()-1; ++st){
      if(vT[st+1]!=1)break;
    }
  }
  //cout << "start : " << st<< endl;
  Q.push(State(side,st,0));
  while(!Q.empty()){
    State nst = Q.front();Q.pop();
    //cout << " side : " << nst.side << "now : " << nst.now << " cost : " << nst.cost << endl;
    if(nst.now==(int)B.size()-1)ret=min(ret,nst.cost);
    int ops = (nst.side==0)?1:0;
    for(int k=0;k<=2;++k){
      if(nst.now+k>=(int)B.size())continue;
      int next = nst.now + k;
      const vector<int> &T = ops==0?A:B; 
      if( T[next] == 0 ){
	if(!vis[ops][next]){
	  vis[ops][next]=true;
	  Q.push(State(ops,next,nst.cost+1));
	}
      }else if( T[next] == 1 ){
	int j;
	for(j = next; j < (int)T.size()-1; ++j){
	  if( T[j+1] != 1 ) break;
	}
	next=j;
	if(!vis[ops][next]){
	  vis[ops][next]=true;
	  Q.push(State(ops,next,nst.cost+1));
	}
      }else if( T[next] == 2 ){
	int j;
	for(j = next; j >= 1; --j){
	  if( T[j-1] != 2 ) break;
	}
	--j;
	next=j;
	if(next==0&&T[next]==2)return inf;
	if(!vis[ops][next]){
	  vis[ops][next]=true;
	  Q.push(State(ops,next,nst.cost+1));
	}
      }
    }
  }
  return ret;
}

int main()
{
  while(true){
    int n;
    vector<int> A,B;
    scanf("%d", &n);
    if( n == 0 ) break;
    for(int i = 0; i < n; ++i){
      int t; scanf("%d", &t); A.push_back(t);
    }
    for(int i = 0; i < n; ++i){
      int t; scanf("%d", &t); B.push_back(t);
    }
    int cost0 = bfs(0,A,B);
    int cost1 = bfs(1,A,B);
    int cost = min( cost0, cost1 );
    if( cost >= inf ){
      puts("NA");
    }else{
      printf("%d\n", cost);
    }
  }
  return 0;
}

Measured memory_bytes: 0
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include<iostream>
#include<iomanip>


using namespace std;

int main()
{
    int r;
    cin>>r;
    
    double pi = 3.14159265358979323846;
    cout<<setprecision(9)<<pi*2*r;
    
}


Measured memory_bytes: 3228
N=int(input())
a=list(map(int,input().split()))
b=[0 for i in range(N)]
for i in range(N):
    x=a[i]
    a[i]=i-x
    b[i]=i+x
from collections import Counter
a=dict(Counter(a))
b=dict(Counter(b))
ans=0
for key in a.keys():
    if key in b.keys():
        ans+=a[key]*b[key]
print(ans)
 

Measured memory_bytes: 170096
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include <random>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("No"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n;
  scanf("%d",&n);
  vi a(n);
  cin >> a;
  vi ans(n*n);
  vp p(n);
  rep(i,n) p[i] = P(a[i]-1,i+1);
  sort(rng(p));
  {
    int pi = 0;
    int ci = 0, cnt = 0;
    rep(i,sz(ans)) {
      while (ci < n && p[ci].se-1 == cnt) {
        cnt = 0;
        ++ci;
      }
      if (pi < n && p[pi].fi == i) {
        ans[i] = p[pi].se;
        if (ci == pi) dame;
        ++pi;
      }
      if (!ans[i] && ci < n) {
        ans[i] = p[ci].se;
        cnt++;
      }
    }
  }
  reverse(rng(p));
  {
    int pi = 0;
    int ci = 0, cnt = 0;
    drep(i,sz(ans)) {
      while (ci < n && n-p[ci].se == cnt) {
        cnt = 0;
        ++ci;
      }
      if (pi < n && p[pi].fi == i) {
        if (ci == pi) dame;
        ++pi;
      }
      if (!ans[i] && ci < n) {
        ans[i] = p[ci].se;
        cnt++;
      }
    }
  }
  cout<<"Yes"<<endl;
  cout<<ans<<endl;
  return 0;
}































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

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

	bool f = true;
	for (auto &c : s)
	{
		f &= c == s[0];
	}

	cout << (f ? "No" : "Yes") << endl;

	return 0;
}

Measured memory_bytes: 256
// Problem: E - Coprime
// Contest: AtCoder - AtCoder Beginner Contest 177
// URL: https://atcoder.jp/contests/abc177/tasks/abc177_e
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
 
using namespace std;
#define int long long
#define ll long long
const int N = 2e5+5;
const int mod = 1e9;
#define ld long double
#define PI 3.14159265358979323846
const int INF = 10000000;
 
void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(9);
}
 
//3. Structure or classes
//3. Ends here
 
//1. Data structures declaration here
map<int,int>mp;
bool pr=1;
//1. Ends here
 
//2. Extra Functions here
void go(int n){
	bool yo=0;
	while(n%2==0){
		n/=2;
		yo=1;
	}
	
	if(yo==1){
		if(mp[2]>0)pr=0;
		mp[2]++;
	}
	
	for(int i=3;i<=sqrt(n);i+=2){
		yo=0;
		while(n%i==0){
			n/=i;yo=1;
		}
		if(yo==1){
			if(mp[i]>0)pr=0;
			mp[i]++;
		}
	}
	if (n > 2) {
		if(mp[n]>0)pr=0;
		mp[n]++;
	}
}
//2. Ends here
 
 
void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}
 
 
 
void solve()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	for(int i=0;i<n;i++){
		go(a[i]);
	}
	
	if(pr==1){
		cout<<"pairwise coprime\n";return;
	}
	else if(pr==0){
		for(auto i:mp){
			if(i.second==n){
				cout<<"not coprime\n";return;
			}
		}
	}
	
	cout<<"setwise coprime\n";
	
    return;
}
// how r u bro

Measured memory_bytes: 16232
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<queue>
using namespace std;
int main (void){
	int n,m;
	cin>>n>>m;
	int a,b;
	map<int,int> lmost;
	while (m--){
		cin>>a>>b;
		if (!lmost[a]) lmost[a]=b;
		else lmost[a]=min(lmost[a],b);
	}
	vector<pair<int,int>> quest;
	for (auto i:lmost) quest.push_back(make_pair(i.first,i.second));
	int ans=0,lmin=-1;
	for (auto i:quest){
		if (lmin!=-1&&i.first>=lmin){
			++ans;
			lmin=-1;
		}
		if (lmin==-1) lmin=i.second;
		else lmin=min(lmin,i.second);
	}
	++ans;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6136
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	int[][string] indexes;
	foreach (line; stdin.byLine) {
		auto x = line.chomp.split;
		auto str = x[0].to!string;
		auto page = x[1].to!int;
		indexes[str] ~= page;
	}

	foreach (k; indexes.keys.array.sort) {
		k.writeln;
		indexes[k].sort.map!(to!string).join(" ").writeln;
	}
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

const double PI = acos(-1);
#define MOD 1000000007

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (abs(a*b)/gcd(a,b))
#define sqr(a) (a*a)

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

main()
{
    optimize();
    ll n,i,s=0;
    cin>>n;
    for(i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0) s+=i;
    }
    cout<<s el;
}










//Brainless_Loco Terminates Here!


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


int calc(int w){
	int s=1150;
	w-=min(10,w);
	s += min(10,w)*125;
	w-=min(10,w);
	s += min(10,w)*140;
	w-=min(10,w);
	s += w*160;
	return s;
}

int main(){
	int w;
	while(cin>>w&&~w){
		cout<<4280-calc(w)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import sys
from io import StringIO
import unittest

def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))

    ans = 0

    for i in range(n):
        ans += b[a[i] - 1]

        if i < n - 1 and a[i + 1] - a[i] == 1:
            ans += c[a[i] - 1]

    print(ans)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3
3 1 2
2 5 4
3 6"""
        output = """14"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """4
2 3 4 1
13 5 8 24
45 9 15"""
        output = """74"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """2
1 2
50 50
50"""
        output = """150"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 5680
#include<iostream>
using namespace std;
int solve(int p, int q, int a, int n, int down);
int mx(int x, int y);
int xy(int x, int n);
int main(){
  int p,q,a,n;
  while(cin >>p>>q>>a>>n,p||q||a||n){
    int ans = 0;
    for(int i=1; i<=n; i++) ans+=solve(p,q,a,i,q/p);
    cout <<ans<<endl;
  }
  return 0;
}
int solve(int p, int q, int a, int n, int down){
  int ans = 0;
  if(p == 0) return 0;
  if(n == 1 && q%p == 0 && q/p<=a && down<=q/p){
    return 1;
  }
  int up = n*q/p;
  for(int i=down; i<=up; i++){
    if(i == 0) continue;
    if(a<xy(i,n)) break;
    int after = q*i/mx(q,i);
    if(p*after/q-after/i>0) ans+=solve(p*after/q-after/i,after,a/i,n-1,i);
  }
  return ans;
}
int mx(int x, int y){
  if(y == 0) return x;
  return mx(y,x%y);
}
int xy(int x, int n){
  if(n == 1) return x;
  return xy(x,n-1)*x;
}

Measured memory_bytes: 1160
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, cos, radians, pi, sin
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


n, m = LI()
G = [[] for _ in range(n)]
for _ in range(m):
    a, b = LI()
    G[a - 1] += [b - 1]
    G[b - 1] += [a - 1]

D = [-1] * n
D[0] = 0
q = deque([0])
while q:
    u = q.popleft()
    for v in G[u]:
        if D[v] == -1:
            D[v] = D[u] + 1
            q += [v]

print('Yes')
for i in range(1, n):
    ret = INF
    for j in G[i]:
        if D[j] < ret:
            ret = D[j]
            ans = j
    print(ans + 1)







Measured memory_bytes: 106848
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

const int MAXN = 1000000;
Int fact[MAXN], inv[MAXN];

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

void init_fact() {
    fact[0] = 1;
    for(int i=1; i<MAXN; i++) {
        fact[i] = (fact[i-1] * i) % MOD;
    }

    inv[MAXN - 1] = mod_pow(fact[MAXN - 1], MOD-2);
    for(int i=MAXN - 2; i>=0; i--) {
        inv[i] = (inv[i+1] * (i+1)) % MOD;
    }
}

Int comb(int n, int r) {
    if(r < 0 || n < r) return 0;
    return fact[n] * inv[n-r] % MOD * inv[r] % MOD;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

Int cnt[50];

Int calc(Int N, Int k){
    Int ret = 0;
    ret += ((N+1)/(1LL << (k+1)))*(1LL<<k);
    ret += max((N+1)%(1LL << (k+1))-(1LL<<k), 0LL);
    return ret;
}

int main(){
    cin.tie(0);

    Int A, B; cin >> A >> B;
    if (A) A--;

    for (int i = 0; i < 40; i++){
        cnt[i] = calc(B, i);
    }
    for (int i = 0; i < 40; i++){
        cnt[i] -= calc(A, i);
    }
    Int ans = 0;
    for (int i = 0; i < 40; i++){
        if (cnt[i] % 2) ans += (1LL << i);
    }
    cout << ans << endl;


}



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

int main() {
    int N, h, pre_h = 0, max_count = 0, tmp_count = 0;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> h;
        tmp_count = (h <= pre_h) ? (tmp_count + 1) : 0;
        if (max_count <= tmp_count) max_count = tmp_count;
        pre_h = h;
    }
    cout << max_count << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
Ans = [ ['.']*100 for _ in range(50) ]+[ ['#']*100 for _ in range(50) ]
for i in range(b-1):
    x, y = (i%50)*2, (i//50)*2
    Ans[y][x] = "#"
for i in range(a-1):
    x, y = (i%50)*2, 51+(i//50)*2
    Ans[y][x] = "."
print(100, 100)
for ans in Ans:
    print(''.join(ans))

Measured memory_bytes: 38384
n = int(input())
s = []
ans = 0
for i in range(n):
    a = input()
    s.append(list(a))
for i in range(n):
    s[i].sort()
s.sort()
anslist = []
p = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        p += 1
    else:
        anslist.append(p)
        p = 0
anslist.append(p)
for i in range(len(anslist)):
    ans += anslist[i]*(anslist[i]+1)//2
print(ans)

Measured memory_bytes: 25256
N, K, C = map(int,input().split())
S = input()
workable = []
#はたらける日付を出しとく(後で使う)
for i in range(N):
    if S[i] == 'o':
        workable.append(i+1)

#print(workable)

#j-1日目までに頑張ってはたらいたときの最大値(bfore_j)
bfore_j = {1:0}

work = 0
pas = 0
work_a = []
for j in range(N-1):
    if pas == 0:
        if S[j] == 'o':
            work += 1
            pas = C
            work_a.append(j+1)
            
    else:
        pas -= 1
    bfore_j[j+2] = work

#print(bfore_j)

#j+1日目以降に頑張ってはたらいたときの最大値

after_j = {N:0}


work = 0
pas = 0
for l in range(N):
    if pas == 0:
        if S[N-1-l] == 'o':
            work += 1
            pas = C    
    else:
        pas -= 1

    after_j[N-l-1] = work

#print(after_j)

for m in workable:
    if bfore_j[m] + after_j[m] < K:
        print(m)


            



        

    


Measured memory_bytes: 79696
N,M = map(int,input().split())
array = [ list(map(int,input().split())) for _ in range(M) ]
if N == 1:
  for i in range(10):
    number = list(str(i))
    ans = True
    for t in range(M):
      if number[ array[t][0] - 1 ] != str( array[t][1] ):
        ans = False
    if ans == True:
      print(i)
      exit()
else:
  for i in range(10**(N-1),10**N ):
    number = list(str(i))
    ans = True
    for t in range(M):
      if number[ array[t][0] - 1 ] != str( array[t][1] ):
        ans = False
    if ans == True:
      print(i)
      exit()
print(-1)
  

Measured memory_bytes: 66780
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

template<typename T>
void cout_mat(vector<vector<T>> &mat){
    for(int i=0; i<mat.size(); i++){
        vector<T> vec = mat[i];
        cout_vec(mat[i]);
    }
}

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<char> > mat(H,vector<char>(W,' '));
    vector<bool> vec(H,false);
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> mat[i][j];
            if(mat[i][j]=='#'){
                vec[i]=true;
            }
        }
    }

    vector<vector<int> > ans(H,vector<int>(W,0));
    bool flag=false;
    int num=1;
    
    if(vec[0]==false){
        for(int i=0; i<H; i++){
            if(vec[i]==true){
                for(int j=0; j<W; j++){
                    char tmp=mat[0][j];
                    mat[0][j]=mat[i][j];
                    mat[i][j]=tmp;
                }
                vec[0]=true;
                vec[i]=false;
                break;
            }
        }
    }

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(vec[i]==false){
                ans[i][j]=ans[i-1][j];
                if(j==W-1){
                    num--;
                }
                continue;
            }

            if(mat[i][j]=='#'){
                if(flag==true){
                    num++;
                }else{
                    flag=true;
                }
            }
            ans[i][j]=num;
        }
        flag=false;
        num++;
    }

    cout_mat(ans);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;

int main(){
	cin>>n;
	n%=10;
	if(n==3) cout<<"bon"<<endl;
	else if(n==0||n==1||n==6||n==8) cout<<"pon"<<endl;
	else cout<<"hon"<<endl;
}

Measured memory_bytes: 3620
using System;
class Program
{
    static void Main(string[] args)
    {
        // 整数の入力
        int s = int.Parse(Console.ReadLine());
        int a = s / 3600;
        int b = (s - 3600* a)/60;
        int c = s - 3600 * a - 60 * b; 
        //出力
        Console.WriteLine(a + ":" + b + ":" + c);
    }
}


Measured memory_bytes: 15952
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    string S, T;
    rep(i, a) T.push_back((char)(b + '0'));
    rep(i, b) S.push_back((char)(a + '0'));
    if (S > T) {
        cout << T << endl;
    } else {
        cout << S << endl;
    }

    return 0;
}


Measured memory_bytes: 256
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    
    let s = get().as_bytes();
    
    let mut ok = true;
    
    ok &= s[0] == b'A';
    
    ok &= b'a' <= s[1] && s[1] <= b'z';
    let e = s.len() - 1;
    ok &= b'a' <= s[e] && s[e] <= b'z';
    let mut c = 0;
    for &ch in &s[2..e] {
    	if b'A' <= ch && ch <= b'Z' {
        	if ch == b'C' {
            	c += 1;
            } else {
            	ok = false;
                break;
            }
        }
    }
	
    ok &= c == 1;
    
    if ok {
    	println!("AC");
    } else {
    	println!("WA");
    }
    
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
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];
    }
    return 0;
}

Measured memory_bytes: 3636
main = do
  [a,b,c,d]<- map read  . words<$>getLine :: IO [Float]
  --putStrLn $ if floor (a / d) >= floor (c / b) then "Yes" else "No"
  putStrLn $ takahasi a b c d

  where
    takahasi a b c d | a <= 0 = "No"
    takahasi a b c d | c <= 0 = "Yes"
    takahasi a b c d = aoki a b (c - b) d

    aoki a b c d | a <= 0 = "No"
    aoki a b c d | c <= 0 = "Yes"
    aoki a b c d = takahasi (a - d) b c d

Measured memory_bytes: 3912
#include <iostream>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H,W,c[10][10],a,magic=0,lche[10];
	cin>>H>>W;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			cin>>c[i][j];
		}
	}
		
	for(int k=0;k<10;k++){
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				c[i][j]=min(c[i][j],c[i][k] + c[k][j]);
			}
		}
	}
	for(int j=0;j<W*H;j++){
			cin>>a;
			if(a==-1 || a==1)continue;
			magic += c[a][1];
	}
	cout<<magic<<endl;
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}

signed main(){
    int H,W,K;
    cin>>H>>W>>K;

    vint dp(W);
    dp[0]=1;

    rep(ukunichia,H){
        vint dp2(W);
        rep(b,1<<(W-1)){
            bool ok=true;
            rep(i,W-2)if((b>>i&3)==3)ok=false;
            if(!ok)continue;
            rep(i,W){
                if(i+1<W&&(b>>i&1))add(dp2[i+1],dp[i]);
                else if(i&&(b>>(i-1)&1))add(dp2[i-1],dp[i]);
                else add(dp2[i],dp[i]);
            }
        }
        dp=dp2;
    }
    cout<<dp[K-1]<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  i64 A, B, V, W, T;
  cin >> A >> V >> B >> W >> T;

  bool result;
  if (W >= V) {
    result = false;
  }
  else {
    i64 t = abs(A - B) / (V - W);
    if ((V - W) * t < abs(A - B)) t++;
    result = t <= T;
  }
  cout << (result ? "YES" : "NO");
}
#endif


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

class Program {
    static void Main(string[] args) {
        //入力
        string S = Console.ReadLine();

        //検証
        //出現している文字を取得する
        char S1 = S[0];
        char S2 = S[1];
        char S3 = S[2];
        char S4 = S[3];

        //取得した文字を、配列に加える
        char[] list = {S1, S2, S3, S4};
        //アルファベット順に並び替え
        Array.Sort(list);

        //出力
        if (list[0] == list[1] && list[2] == list[3] && list[0] != list[2]) {
            Console.WriteLine("Yes");
        } else {
            Console.WriteLine("No");
        }
            
    }
}

Measured memory_bytes: 11348
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using static System.Math;

class P
{
  static int[] Input(){
    return Console.ReadLine().Split().Select(int.Parse).ToArray();
  }
  static int[][] Input2(int n){
    int[][] X = new int[n][];
    for(int i = 0; i < n; i++){
      X[i] = Input();
    }
    return X;
  }
  static void Main()
  {
    int N = Input()[0];
    int[] X = Input();
    var d = new Dictionary<int, int> ();
    foreach(var x in X){
      if(! d.ContainsKey(x)){
        d[x] = 0;
      }
      d[x] += 1;
    }
    int R = 0;
    foreach(int key in d.Keys){
      if (key > d[key]){
        R += d[key];
      }else{
        R += d[key]-key;
      }
    }
    var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
    Console.SetOut(sw);
    Console.WriteLine(R);
    Console.Out.Flush();
  }
}


Measured memory_bytes: 27872
#include<iostream>
#include<cstdio>
#include<cstdlib>
#define N 500010
using namespace std;
int f[N],sum[N],num[N];
int main()
{
	int n;
	scanf("%d%d",&n,&sum[0]);
	for(int i=1;i<=n;i++) scanf("%d",&num[i]),sum[i]=min(sum[i-1],abs(sum[i-1]-num[i]));
	for(int i=n;i>=1;i--)
	if(f[i+1]*2+1-num[i]>=0) f[i]=f[i+1]+num[i];
	else f[i]=f[i+1];
	int m;
	scanf("%d",&m);
	while(m--)
	{
		int a;
		scanf("%d",&a);
		puts(sum[a-1]>f[a+1]?"YES":"NO");
	}
	return 0;
}


Measured memory_bytes: 7808
def turn():
  global drc
  if moves[drc][-1] != 0:
    moves[drc].append(0)
  drc=(drc+1)%2

def forward():
  moves[drc][-1]+=1
  
OP={"T":turn,"F":forward}

ops=input()
target=list(map(int,input().split()))
moves=[[0],[0]]
drc=0
first_F=0

# データ加工
for i,o in enumerate(ops):
  if o=="T" or i+1==len(ops):
    first_F=i
    break

for i in range(first_F,len(ops)):
  OP[ops[i]]()

# 組み合わせ演算
x_set=set([first_F])
for move in moves[0]:
  tmp_set=set()
  for xx in x_set:
    tmp_set.add(xx+move)
    tmp_set.add(xx-move)
  x_set=tmp_set
  
y_set=set([0])
for move in moves[1]:
  tmp_set=set()
  for yy in y_set:
    tmp_set.add(yy+move)
    tmp_set.add(yy-move)
  y_set=tmp_set

if target[0] in x_set and target[1] in y_set:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9528