akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<ll,ll>;
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((ll)x.size())
#define MOD (ll)(998244353)
#define INF (9e18)
#define EPS (1e-6)
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif

void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
	INIT();
	//code...
	bool yes[6]={0};
	For(i,0,4){
		int t; cin>>t;
		yes[t]=true;
	}
	For(i,1,5) if(!yes[i]) cout<<i<<"\n";
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
using namespace std;
typedef long long int lli;
int main(void)
{
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] != t[i])
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3828
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

class AtCoder
{
    const int MOD = 1000000007;
    public void Slove()
    {
        var inputs = Console.ReadLine().Split();
        var a = int.Parse(inputs[0]);
        var b = int.Parse(inputs[1]);
        if(((a + b) & 1) == 0)
            Console.WriteLine((a + b) / 2);
        else
            Console.WriteLine("IMPOSSIBLE");
    }
    static void Main()
    {
        var ac = new AtCoder();
        ac.Slove();
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll x;
    ll ans;
    cin >> x;
    if(x <= 6) {
        ans = 1;
    } else if(x <= 11) {
        ans = 2;
    } else {
        ans = x / 11;
        ans *= 2;
        if(x % 11 != 0) {
            if(x % 11 <= 6) {
                ans++;
            } else {
                ans += 2;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
int A,B,C,D,E,N,M,x,y,cou=0,cou2,v[1000000],w[1000000],min_i,en=0;
    char S[20],W[100],s[10],X,Y;
   scanf("%s %s %s",&S,&W,&s);
   printf("%c%c%c",S[0],W[0],s[0]);
   
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<30;
vector<int> A;
const int mod = 1e9+7;

bool ok(int N) {
  if(N % 2 == 1) {
    for(int i = 0; i < N; i++) {
      // A[i]: 0, 2, 2, 4, 4, ...
      if(A[i] != (i+1)/2*2) return false;
    }
    return true;
  } else {
    for(int i = 0; i < N; i++) {
      // A[i]: 1, 1, 3, 3, 5, 5, ...
      if(A[i] != i/2*2+1) return false;
    }
    return true;
  }
}

int main() {
  int N; cin >> N;
  A.resize(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  if(!ok(N)) {
    cout << 0 << endl;
    return 0;
  } else {
    long long ans = 1;
    for(int i = 0; i < N/2; i++) {
      ans *= 2;
      ans %= mod;
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
    int main(){
        int N,M;cin>>N>>M;

    vector<vector<bool>> v(N,vector<bool> (N));

    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;a--;b--;
        v[a][b]=v[b][a]=true;

    }

    vector<int> num(N);
    iota(num.begin(),num.end(),0);
    int res=0;

    do{
        if(num[0]!=0)break;
        bool ok=true;
        for(int i=0;i+1<N;i++){
            
            int from=num[i];
            int to=num[i+1];
            if(v[from][to]!=true)ok=false;
        }
        if(ok)res++;
        }while(next_permutation(num.begin(),num.end()));

        cout<<res<<endl;
    }






Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const int MAX=1e5+10;
const ll INF=1e18;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(),d.end());
    int ans=1;
    rep(i,n-1) {
        if (d[i]!=d[i+1]) ++ans;
    }
    cout << ans << endl;


    return 0;   
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int, char**)
{

	uint n, x, m;
	unsigned long long ans = 0;
	std::cin >> n;

	m = 0;
	for (uint i = 0; i < n; i++) {
		cin >> x;
		ans += x;
		if (m < x) m = x;
	}

	ans -= m / 2;
	cout << ans << endl;

	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 k = sc.nextInt();
    int x = sc.nextInt();
    String ans = "Yes";
    if((500 * k) < x) ans = "No";
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.length(), m = t.length();

    string ans;
    REP(i,n-m+1){
        bool ok = true;
        REP(j,m){
            if (s[i+j] != '?' && s[i+j] != t[j]) ok = false;
        }
        // cout << i << ok << endl;
        if (ok){
            string tmp = s;
            REP(j,m) tmp[i+j] = t[j];
            REP(i,n) if (tmp[i] == '?') tmp[i] = 'a';
            if (ans.empty()) ans = tmp;
            else ans = min(ans, tmp);
        }
    }

    cout << (ans.empty() ? "UNRESTORABLE" : ans) << endl;
    return 0;
}


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

vector<int> prime;
vector<int>::iterator it,it2;
int main(){
	long i,j,n;
	char buf[120], p;
	for(i=2;i<123457*2;i++){
		for(it=prime.begin();it!=prime.end();it++)if(i%*it==0)break;
		if(it==prime.end()) prime.push_back(i);
	}
	while(cin>>n,n){
		it = lower_bound(prime.begin(), prime.end(), n+1);
		it2 = lower_bound(prime.begin(), prime.end(), 2*n+1);
		cout << it2-it << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define ll            long long

#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void sb()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
unordered_map<int,int> dp;
vector<vector<int>> graph(100001,vector<int> (0));
int dfs(int source){

int maxr =0;
    
    for(auto child:graph[source]){
        
       if(dp.find(child)==dp.end()){
           maxr = max(maxr,1+dfs(child));
       }
       else
       maxr = max(maxr,1+dp[child]);
      
    }


return dp[source] = maxr;
}
int main()
{
	//sb();
    int n,m;
    cin>>n>>m;
    
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        graph[u].pb(v);
    }
    int ans =0;
   for(int i=1;i<n+1;i++){
   if(dp.find(i)==dp.end())
   ans = max(ans,dfs(i));
   else
   ans = max(ans,dp[i]);
   }
    cout<<ans;




return 0;
}



Measured memory_bytes: 12580
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
    ArrayList<Integer> p = new ArrayList<Integer>();
    for(int i = 0; i<n; i++) {
      int tmp = sc.nextInt();
      p.add(tmp);
    }
    Collections.sort(p);

    int sum = 0;
    for(int i=0; i<k; i++) {
      sum += p.get(i);
    }
		System.out.println(sum);
	}
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int, int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define ar array
//#define endl '\n'
#define FOR(i, s, e) for (int i = s; i < e; ++i)
#define FORL(i, s, e) for (ll i = s; i < e; ++i)
#define RFOR(i, s, e) for (int i = e - 1; i >= s; --i)
#define all(x) x.begin(), x.end()
#define sz(x) (ll) x.size()
#define MOD 1000000007LL
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a, x) memset(a, x, sizeof a);

#ifdef TRACE
#define lol std::cout << "Calling " << __func__ << endl

#else
#define lol
#endif

ll modpow(ll a, ll b, ll m = MOD)
{
	a %= m;
	ll res = 1;
	while (b)
	{
		if (b & 1)
			res = (res * a) % m;
		a = (a * a) % m;
		b >>= 1;
	}
	return res;
}
ll bpow(ll a, ll b)
{
	ll res = 1;
	while (b)
	{
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}
ll modinv(ll a, ll m = MOD) { return modpow(a, m - 2, m); }

void solve(int t)
{
	//	cout << "Case #" << t << ": ";
	ll n,k;
	cin >> n >> k;
	vi A(n+1);
	vl pre(n + 1);
	FOR(i,1,n+1) {
		cin >> A[i];
		pre[i]=-1LL;	
	}
	int pos = 1;
	while(k>0) {
		if(pre[pos]==-1LL){
			pre[pos]=k;
		}
		else{
			ll temp = pre[pos]-k;
			k = (k+temp)%temp;
			FOR(j, 1, n + 1)
			pre[j] = -1LL;
			pre[pos]=k;
			if(k==0LL) break;
		}
		pos = A[pos];
		k--;
	}
	cout << pos << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef IOF
	freopen("alchemy_input.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif
	int t = 1;
	//cin >> t;
	for (int tc = 1; tc <= t; tc++)
		solve(tc);
}


Measured memory_bytes: 5572
// last.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include<iostream>
using namespace std;

int main()
{

	int a;
	int b;
	cin>>a;
	cin>>b;

	int c =b-a-1;

	int sum=0;
	for(int i=1;i<=c;i++){
		sum=sum+i;
	}
	cout<<(sum-a);


	return 0;

}

Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N,Q=map(int,readline().split())
    S=readline().strip()
    l=[0]*Q
    r=[0]*Q
    for i in range(Q):
        l[i],r[i]=map(lambda x:int(x)-1,readline().split())

    sum_ac=[0]*N
    for i in range(N):
        if i==0:
            sum_ac[i]=0
        else:
            if S[i-1]=="A" and S[i]=="C":
                sum_ac[i]=sum_ac[i-1]+1
            else:
                sum_ac[i]=sum_ac[i-1]

    for i in range(Q):
        print(sum_ac[r[i]]-sum_ac[l[i]])

if __name__=="__main__":
    main()

Measured memory_bytes: 14140
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mk make_pair
#define ft first
#define sc second
#define ppb pop_back
#define sz size
#define forn(i,a,n) for(i=a;i<n;i++)
#define M 1000000007
#define inf 2e18


int main() {

ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
    
ll a,b,k;
cin>>a>>b>>k;
ll a1,b1,c1;
a1 = max(0ll,a-k);
c1 = max(0ll, k-a);
b1 = max(0ll, b-c1);
cout<<a1<<" "<<b1<<"\n"; 

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int m=n;
  int sum=0;
  while(m>0){
    sum+=m%10;
    m/=10;
  }
  if(n%sum==0)cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
n=int(input())
a_list=list(map(int,input().split()))
count=0
for i in range(n):
    if i%2==0:
        count+=a_list[i]
    else:
        count-=a_list[i]
print(count,end='')
now=count//2
for i in range(n-1):
    now=a_list[i]-now
    print(' ',end='')
    print(now*2,end='')

            


Measured memory_bytes: 70884
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

func nextInt() int {
	if !sc.Scan() {
		panic("failed scan int")
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()

	max := a + b

	if a-b > max {
		max = a - b
	}
	if a*b > max {
		max = a * b
	}

	fmt.Println(max)
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int p[n];
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }

    int ans = 0;
    rep(i, n-1) {
        if(p[i] == i) {
            swap(p[i], p[i+1]);
            ans++;
        }
    }
    if(p[n-1] == n-1) {
        ans++;
    }

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

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

int main()
{
		char ar[6];
		cin>>ar;
		
		if (ar[2] == ar[3] && ar[4]==ar[5])
		{
			cout<<"Yes"<<endl;
		}
		else
		cout<<"No"<<endl;
	
	
	return 0;
}


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

int main(){
  int n,m;
  cin>>n>>m;
  vector<long long> w(n);
  vector<long long> v(n);
  for(int i=0;i<n;++i){
    cin>>w[i]>>v[i];
  }
  
  int mostV = 1e5+1;
  // 获得这一些 v需要的 最小w
  vector<long long> last(mostV,1e18);
  vector<long long> curr(mostV,1e18);
  
  for(int i=0;i<n;++i){
      last[0] = 0;
      for(int j=mostV;j>0;--j){
      // w[i] + last[j-v[i]] < curr[ j-v[i] ]
      // curr[j-v[i]] = w[i] + last[j-v[i]]
      if(j-v[i]>=0 && w[i] + last[j-v[i]] < curr[ j ]){
        curr[ j ] = w[i] + last[j-v[i]];
      }
    }
    last = curr;
  }
  int result = 0;
  for(int i=0;i<mostV;++i){
    if(curr[i]<=m){
      result = i;
    }
  }
  cout<<result<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 233333,mo=1e9+7;
int n,k,fac[N],ifac[N],res,g[N];
inline int power(int a, int n){
	int res=1;
	while(n){
		if(n&1)res=1LL*res*a%mo;a=1LL*a*a%mo;n>>=1;
	}
	return res;
}
void iniC(int n){
	fac[0]=1;rep(i,1,n)fac[i]=1LL*fac[i-1]*i%mo;
	ifac[n]=power(fac[n],mo-2);
	per(i,n-1,0)ifac[i]=1LL*ifac[i+1]*(i+1)%mo;
}
inline int C(int n, int m){return m>=0&&m<=n?1LL*fac[n]*ifac[m]%mo*ifac[n-m]%mo:0;}
void ini(int n){
	rep(i,1,n)g[i]=C(2*n-i,n)-C(2*n-i,n+1);g[0]=g[1];
//	rep(i,0,n)cerr<<i<<' '<<g[i]<<endl;
}
int main() {
	read(n);read(k);iniC(2*n);
	ini(k-1);
	if(k==1)res=1;
	else if(k==n)res=g[0];
	else{rep(i,n-k,n-1)res=(res+1LL*C(i-1,n-k-1)*g[i-(n-k)])%mo;}
	rep(i,1,n-k-1)res=2LL*res%mo;
	cout<<res;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, n);

  cout << n * n * n << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_M 1000000
#define PRIME_NUM MAX_M
#define SPIRAL_NUM 1003
#define DIR_FOUR 4 // dyとdxのための値
#define DIR_THREE 3 // udyとudxのための値


const int dy[4] = {-1,0,1,0}, dx[4] = {0,1,0,-1}; // 上下左右4方向
const int udy[3] = {1,1,1}, udx[3] = {-1,0,1}; // 下3方向


int *primeNumber(int num){
	int i, j, *ret;
	ret = (int *)malloc(sizeof(int) * (num + 1));
	for(i = 0;i <= num;i++) ret[i] = 1;
	ret[0] = ret[1] = 0;
	for(i = 2;i * i <= num;i++){
		if(ret[i] == 1){
			for(j = 2 * i;j <= num;j+=i){
				ret[j] = 0;
			}
		}
	}
	return ret;
}

int **spiralArray(int arg1,int arg2){ // arg1 は2次元配列をつくるためのもの　arg2 はどの値までスパイラルし続けるか
	int i, j, **ret, x, y, dir;
	ret = (int **)malloc(sizeof(int *) * arg1);
	for(i = 0;i < arg1;i++){
		ret[i] = (int *)malloc(sizeof(int) * arg1);
	}
	for(i = 0;i < arg1;i++){
		for(j = 0;j < arg1;j++){
			ret[i][j] = -1;
		}
	}
	y = arg1 / 2;
	x = arg1 / 2 + 1;
	dir = 0; // dirの向きにまだ数字が設定されていなければdirの方向　そうでなければ(dir + 1) % 4の方向
	ret[y][x - 1] = 1;
	ret[y][x] = 2;

	for(i = 3;i <= arg2;i++){
		if(ret[y + dy[dir]][x + dx[dir]] == -1){
			y += dy[dir]; x += dx[dir];
			ret[y][x] = i;
			dir = (dir + (DIR_FOUR - 1)) % DIR_FOUR;
		}else{
			y += dy[(dir + 1) % DIR_FOUR]; x += dx[(dir + 1) % DIR_FOUR];
			ret[y][x] = i;
		}
	}
	return ret;
}


int main(void){
	int i, j, *pn, **sp, m, n, sx, sy, dp[SPIRAL_NUM][SPIRAL_NUM];
	pn = primeNumber(PRIME_NUM);
	sp = spiralArray(SPIRAL_NUM,PRIME_NUM);
	while(1){
		scanf("%d%d",&m,&n);
		if(m == 0 && n == 0){
			break;
		}

		// スタート地点の探索
		for(i = 0;i < SPIRAL_NUM;i++){
			for(j = 0;j < SPIRAL_NUM;j++){
				if(sp[i][j] == n){
					sy = i;
					sx = j;
				}
			}
		}

		memset(dp,-1,sizeof(dp));
		dp[sy][sx] = 0;
		if(pn[n] == 1){
			dp[sy][sx]++;
		}
		int y, x;
		for(y = 0;y < SPIRAL_NUM;y++){
			for(x = 0;x < SPIRAL_NUM;x++){
				for(i = 0;i < DIR_THREE;i++){
					int ny = y + udy[i], nx = x + udx[i];
					if(ny < 0 || SPIRAL_NUM <= ny || nx < 0 || SPIRAL_NUM <= nx){
						continue;
					}
					if(dp[y][x] != -1 && sp[ny][nx] != -1 && sp[ny][nx] <= m && (dp[ny][nx] == -1 || dp[ny][nx] < dp[y][x] + 1 || (dp[ny][nx] == dp[y][x] && pn[sp[ny][nx]] == 1))){
						if(pn[sp[ny][nx]] == 1){
							dp[ny][nx] = dp[y][x] + 1;
						}else{
							dp[ny][nx] = dp[y][x];
						}
					}
				}
			}
		}

		int ans1 = 0, ans2 = 0;;
		for(i = 0;i < SPIRAL_NUM;i++){
			for(j = 0;j < SPIRAL_NUM;j++){
				if(pn[sp[i][j]] == 1 && (ans1 < dp[i][j] || (ans1 == dp[i][j] && ans2 < sp[i][j]))){
					ans1 = dp[i][j];
					ans2 = sp[i][j];
				}
			}
		}
		if(ans1 == 0){
			printf("0 0\n");
		}else{
			printf("%d %d\n",ans1, ans2);
		}
/*		for(i = 0;i < SPIRAL_NUM;i++){
			for(j = 0;j < SPIRAL_NUM;j++){
				printf("%3d ",dp[i][j]);
			}
			printf("\n");
		}*/
	}
	free(pn);
	free(sp);
	return 0;
}

Measured memory_bytes: 12752
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
using namespace std;

#define MAX_N 100000000
#define INF 100000000000000

int main(){
  int n,m;
  long long l;
  cin >> n >> m >> l;
  vector<pair<int, long long> > adj[n];
  int a,b;
  long long c;
  for(int i=0;i<m;i++){
    cin >> a >> b >> c;
    adj[a-1].push_back(make_pair(b-1,c));
    adj[b-1].push_back(make_pair(a-1,c));
  }
  long long d[n][n];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i == j) d[i][j] = 0;
      else d[i][j] = INF;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<adj[i].size();j++){
      b = adj[i][j].first;
      d[i][b] = adj[i][j].second;
    }
  }

  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }

  long long rd[n][n];

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i == j) rd[i][j] = 0;
      else if(d[i][j] <= l) rd[i][j] = 1;
      else rd[i][j] = INF;
    }
  }

  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        rd[i][j] = min(rd[i][j],rd[i][k]+rd[k][j]);
      }
    }
  }

  int q;
  cin >> q;
  int s[q];
  int t[q];
  for(int i=0;i<q;i++){
    cin >> s[i] >> t[i];
  }
  for(int i=0;i<q;i++){
    if(rd[s[i]-1][t[i]-1] == INF) cout << -1 << endl;
    else cout << rd[s[i]-1][t[i]-1]-1 << endl;
  }

  return 0;
}


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

int main(){
  cout << 100 << ' ' << 100 << endl;
  int a,b,acount = 0,bcount = 0;
  cin >> a >> b;
  for(int i = 1;i <= 100;i++){
    for(int j = 1;j <= 100;j++){
      if(i <= 50){
        if(acount < a-1 && i % 2 == 1 && j % 2 == 1){
          cout << '.';
          acount++;
        }
        else{
          cout << '#';
        }
      }
      else{
        if(bcount < b-1 && i % 2 == 0 && j % 2 == 1){
          cout << '#';
          bcount++;
        }
        else{
          cout << '.';
        }
      }
    }
    cout << ' ' << endl;
  }
}

Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"3
acornistnt
peanutbomb
constraint"# => r#"1"#,
r#"2
oneplustwo
ninemodsix"# => r#"0"#,
r#"5
abaaaaaaaa
oneplustwo
aaaaaaaaba
twoplusone
aaaabaaaaa"# => r#"4"#,
}

fn solve(src: &str) -> String {
    let mut ans:i64 = 0;

    input! {
        source = src,
        n: usize,
        mut s: [chars; n]
    }

    let mut map = std::collections::HashMap::new();

    for i in 0..n {
        s[i].sort();
        let count = map.entry(s[i].clone()).or_insert(0);
        *count += 1;
        ans += *count - 1;
    }

    ans.to_string()
}

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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (1e9 + 7))
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long k;
        cin >> k;

        if (k <= 9) printf("%lld\n", k);
        else {
            vector<long> v = {1, 2, 3, 4, 5, 6, 7, 8, 9};
            set<long> s, aux;
            s.insert(v.begin(), v.end());
            while (v.size() < k) {
                for (auto &y : s) {
                    long x = y * 10;
                    long z = (x % 100) / 10;
                    if (z > 0) v.push_back(x + z - 1);
                    v.push_back(x + z);
                    if (z < 9) v.push_back(x + z + 1);
                    if (z > 0) aux.insert(x + z - 1);
                    aux.insert(x + z);
                    if (z < 9) aux.insert(x + z + 1);
                }
                s = aux;
                aux.clear();
            }
            sort(v.begin(), v.end());
            printf("%lld\n", v[k-1]);
        }
    }
}


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

string S, T; bool used[26][26];

int main() {
	cin >> S >> T;
	for (int i = 0; i < S.size(); i++) used[S[i] - 'a'][T[i] - 'a'] = true;
	for (int i = 0; i < 26; i++) {
		int cnt = 0;
		for (int j = 0; j < 26; j++) { if (used[i][j] == true) cnt++; }
		if (cnt >= 2) { cout << "No" << endl; return 0; }
	}
	for (int i = 0; i < 26; i++) {
		int cnt = 0;
		for (int j = 0; j < 26; j++) { if (used[j][i] == true) cnt++; }
		if (cnt >= 2) { cout << "No" << endl; return 0; }
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 776
#include<stdio.h>
#include <string.h>

int main(void)
{
	int n,i,j,max[9],min[9],temp=0,Max,Min;
	char number[8];

	scanf("%d",&n);
	

	while (n--)
	{
		Max = 0, Min = 0;
		scanf("%s", number);
		for (i = 0; i < 8; i++) {
			max[i] = number[i] - '0';
			min[i] = number[i] - '0';
		}

		for (i = 0; i < 8; i++) {
			for (j = i + 1; j < 8; j++) {
				if (max[i] < max[j]) {
					temp = max[i];
					max[i] = max[j];
					max[j] = temp;
				}
				if (min[i] > min[j]) {
					temp = min[i];
					min[i] = min[j];
					min[j] = temp;
				}
			}
		}
		for (i = 0; i < 8; i++) {
			Max = Max * 10 + max[i];
			Min = Min * 10 + min[i];
		}
		printf("%d\n",Max-Min);
	}

	return 0;
}

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

class Progaram
{
    static void Main(String[] args)
    {
        var n = Int32.Parse(Console.ReadLine());
        var line = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var resl = new Int32[n];
        for (var i = 0; n - 1 > i; i++)
        {
            resl[line[i] - 1]++;
        }
        foreach (var i in resl)
        {
            Console.WriteLine(i);
        }
    }
}

Measured memory_bytes: 43844
from heapq import heappush, heappop
def dijkstra(s,n,dic):
  q = [(0,s)]
  dist = [10**20]*n
  dist[s] = 0
  while q:
    v,p = heappop(q)
    if dist[p]<v:
      continue
    for e,c in dic[p]:
      if dist[e]>dist[p]+c:
        dist[e] = dist[p]+c
        heappush(q,(dist[e],e))
  return dist
N, M, *L = map(int, open(0).read().split())
Els = [[] for i in range(N+1)]
for i in range(2,N+1):
  Els[i].append((i-1,0))
for l,r,c in zip(*[iter(L)]*3):
  Els[l].append((r,c))
  
dist = dijkstra(1,N+1,Els)
if dist[N]==10**20:
  print(-1)
else:
  print(dist[N])

Measured memory_bytes: 49108
#include <stdio.h>

int main(void)
{
    char op;
    int a, b;
    
    scanf("%d %c %d", &a, &op, &b);
    
    while (op != '?') {
        switch (op) {
            case '+':
                printf("%d\n", a + b);
                break;
            case '-':
                printf("%d\n", a - b);
                break;
            case '*':
                printf("%d\n", a * b);
                break;
            case '/':
                printf("%d\n", a / b);
                break;
        }       
        scanf("%d %c %d", &a, &op, &b);
    }   
    
    return 0;
}   

Measured memory_bytes: 2680
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    ll N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;
    vector<ll> L(K), R(K);
    ll cnt = 0;
    for(int i = 0; i < N && cnt < K; i++){
        if (S[i] == 'o'){
            L[cnt++] = i;
            i += C;
        } 
    }
    cnt = K - 1;
    for (int i = N - 1; i >= 0 && cnt >= 0; i--){
        if (S[i] == 'o'){
            R[cnt--] = i;
            i -= C;
        }
    }
    REP(i, K) if (L[i] == R[i]) cout << (L[i] + 1) << endl;

    return 0;
}

Measured memory_bytes: 4996
n, m = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(m)]
visited = [False]*n
counter =0

def v_list(value, vector):
    result = []
    for i in range(len(vector)):
        if value in vector[i]:
            result.append(vector[i][0])
            result.append(vector[i][1])
    while value in result:
        result.remove(value)
    return result


def DFS(x):
    next_x = v_list(x, c)
    all_visited = True
    for i in range(n):
        if not visited[i]:
            all_visited = False

    if all_visited:
        global counter
        counter +=1
        return

    for i in next_x:
        if not visited[i-1]:
            visited[i-1] = True
            DFS(i)
            visited[i-1] = False

visited[0] = True
DFS(1)
print(counter)

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
int a[20000];
char b[20000];
int c[20000];
int d[20000];
int x=0,y=0;
while(y==0){
scanf("%d %c %d\n",&a[x],&b[x],&c[x]);
if(b[x]=='?'){
x=x-1;
break;
}
else if(b[x]=='+'){
d[x]=a[x]+c[x];
x++;
}
else if(b[x]=='-'){
d[x]=a[x]-c[x];
x++;
}
else if(b[x]=='*'){
d[x]=a[x]*c[x];
x++;
}
else if(b[x]=='/'){
d[x]=a[x]/c[x];
x++;
}
}
while(x>=y){
printf("%d\n",d[y]);
y++;
}
return 0;
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int h, w;
	scanf("%d%d", &h, &w);
	auto f = [](int h, int w) {
		ll ans;
		if (h % 3 == 0) ans = 0;
		else ans = h;
		vector<ll> A(3);
		for (int i = 1; i < h; ++i) {
			A[0] = (ll)i * w;
			A[1] = (ll)(w / 2) * (h - i);
			A[2] = (ll)w * (h - i) - A[1];
			sort(A.begin(), A.end());
			ans = min(ans, A[2] - A[0]);
		}
		return ans;
	};
	printf("%lld\n", min(f(h, w), f(w, h)));
}


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

a1 = sorted(a)
a2 = []
count = 1
for i in range(n - 1):
    if a1[i] == a1[i + 1]:
        count += 1
    else:
        a2.append(count)
        count = 1
a2.append(count)
l = sorted(a2)
print(sum(l[:len(l) - k]))

Measured memory_bytes: 32180
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().split()]
D = [-1] * N

for m in range(M):
    s, c = [int(x) for x in input().strip().split()]
    if D[s-1] == -1:
        D[s-1] = c
        continue
    if D[s-1] == c:
        continue
    print(-1)
    exit()

if N > 1:
    if D[0] == -1:
        D[0] = 1
    if D[0] == 0:
        print(-1)
        exit()
    for n in range(1, N):
        if D[n] == -1:
            D[n] = 0
if N == 1:
    if D[0] == -1:
        print(0)
        exit()

ans = ''
for i in range(N):
    ans += str(D[i])

print(int(ans))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=105,M=17,p=998244353,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,ga[1<<(M+1)];
int *g[M+1];
bitset<N> bit[N];
unordered_map<bitset<N>,int> h[N];
void check(int &x,int y){x=(x+y<p) ? (x+y) : (x+y-p);}
int pl(int x,int y){return (x+y<p) ? (x+y) : (x+y-p);}
char ch[N];
void reset(){
	n=100;
	for (int i=0;i<=M;i++) g[i]=ga+(1<<i);
	for (int i=1;i<n;i++)
	for (int j=0;j<i;j++) bit[i][j]=1;
	n=0;
}
int calc(int n,bitset<N> a){
	if (n<=M){
		int t=0;
		for (int i=0;i<n;i++)
		if (a[i]) t+=1<<i;
		return g[n][t];
	}
	if (h[n].count(a)) return h[n][a];
	int ans=calc(n-1,a>>1)*(1+a[0])%p;
	bitset<N> cur,res;
	for (int d=1;d*2<=n;d++){
		cur=a&bit[d];res=a>>d;int l=n-d;
		while (l>=d){
			l-=d;
			cur&=res;res>>=d;
			check(ans,(ll)calc(d,cur)*calc(l,res)%p);
		}
	}
	return h[n][a]=ans;
}
int main(){
	reset();
	g[0][0]=1;
	for (int i=1;i<=M;i++)
	for (int k=0;k<(1<<i);k++){
		check(g[i][k],g[i-1][k>>1]*((k&1)+1)%p);
		for (int d=1;d*2<=i;d++){
			int cur=k&((1<<d)-1),res=k>>d,l=i-d;
			while (l>=d){
				l-=d;
				cur&=res;res>>=d;
				check(g[i][k],(ll)g[d][cur]*g[l][res]%p);
			}
		}
	}
	
	scanf("%s",ch);
	n=strlen(ch);
	
	bitset<N> t;t.reset();
	for (int i=0;i<n;i++) t[i]=(ch[i]=='1');
	printf("%d\n",calc(n,t));
	return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int main(){
    double n,d;
    cin>>n>>d;
    long int a,b,count=0;
    set<pair<long int,long int>> s;
    for(int i=0;i<n;i++){
        double  sum = 0;
        cin>>a>>b;
         sum = ((a*a) + (b*b));
        sum = sqrt(sum);
        
        if(sum <= d){
            count++;
        }
    }
    
   
    cout<<count;
    
    return 0;
}

Measured memory_bytes: 3784
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int x[n]; for (int i = 0; i < n; i++) cin >> x[i];
    int ans = 1<<30;
    for (int a = 0; a <= 100; a++) {
        int sum = 0;
        for (int i = 0; i < n; i++) sum += (a - x[i]) * (a - x[i]);
        ans = min(ans, sum);
    }
    cout << ans << endl;
}


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

static const int MAX = 100;

void bubbleSort(int A[], int N)
{
	int tmp;
	int count = 0;
	for (int i=0; i < N; i++) {
		for (int j=N-1; j > i; j--) {
			if (A[j] < A[j-1]) {
				tmp = A[j];
				A[j] = A[j-1];
				A[j-1] = tmp;
				count++;
			}
		}
	}
	for (int i=0; i < N; i++) {
		if (i != N-1) cout << A[i] << " ";
		else cout << A[i] << endl;
	}
	cout << count << endl;
}

int main()
{
	int N, A[MAX];
	cin >> N;
	for (int i=0; i < N; i++) cin >> A[i];
	bubbleSort(A, N);
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n;
    scanf(" %d", &n);
    vector<int> x(n);
    rep(i,n) scanf(" %d", &x[i]);

    vector<int> sx(x);
    sort(all(sx));

    int a = sx[n/2-1], b = sx[n/2];
    rep(i,n){
        int z = b;
        if(b<=x[i]) z = a;
        printf("%d\n",z);
    }
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    string b = "2019/04/30";
    if(s <= b){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }
    
}


Measured memory_bytes: 256
# coding: utf-8

def test(c1, c2):
    for i in range(2):
        for j in range(3):
            if c1[i][j] != c2[i][j]:
                return("NO")
    return("YES")

if __name__ == "__main__":
    s1 = input()
    s2 = input()
    s = [s1, s2]
    c1 = [[0,0,0],[0, 0, 0]]
    for i in range(2):
        for j in range(3):
            c1[i][j] = s[i][j]

    c2 = [[c1[1][2], c1[1][1], c1[1][0]],[c1[0][2], c1[0][1], c1[0][0]]]

    answer = test(c1, c2)
    print(answer)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
using namespace std;
char s[12];
int main()
{
//	freopen("in.txt","r",stdin);
//	cout<<"Hello world!"<<endl;
    int n,k;
    scanf("%d",&n);
    getchar();
    fgets(s,12,stdin);
    scanf("%d",&k);
    k--;
    for(int i=0;i<n;i++)
    {
        if(s[i]==s[k])
            printf("%c",s[i]);
        else
            printf("*");
    }
	return 0;
}

Measured memory_bytes: 256
def main():
    s = input().strip()
    t = input().strip()
    dp = [[0] * (len(t)+1) for _ in range(len(s)+1)]
    for i in range(1, len(s)+1):
        for j in range(1, len(t)+1):
            if s[i-1] == t[j-1]:
                dp[i][j] = dp[i-1][j-1] + 1
            if dp[i][j] < dp[i-1][j]:
                dp[i][j] = dp[i-1][j]
            if dp[i][j] < dp[i][j-1]:
                dp[i][j] = dp[i][j-1]
    ans = ""
    i = len(s)
    j = len(t)
    while i > 0 and j > 0:
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j-1]:
            j -= 1
        else:
            i -= 1
            j -= 1
            ans = s[i] + ans
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 111836
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r = sc.nextInt();
        int ans;
        if (n >= 10) ans = r;
        else ans = r + 100 * (10 - n);
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
using ll = long long;

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

struct edge {int from, to, cost; };

int h, w, d, a;
int px[90001], py[90001];
int q, l, r;
int res[90001];

void solve(){
    scanf("%d%d%d", &h, &w, &d);
    rep(i, h){
        rep(j, w){
            scanf("%d", &a);
            px[a] = i, py[a] = j;
        }
    }
    for(int i = d+1; i <= h*w; i++){
        res[i]=res[i-d]+abs(px[i]-px[i-d])+abs(py[i]-py[i-d]);
    }
    scanf("%d", &q);
    while(q--){
        scanf("%d%d", &l, &r);
        printf("%d\n", res[r]-res[l]);
    }
}

int main(){
    solve();
    return 0;
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> A(N); REP(i, N) cin >> A[i];

	ll res{-1};

	if (A.front() != 0)
	{
		std::cout << res << std::endl;
		return 0;
	}

	REP(i, N-1)
	{
		if (A[i] == 0 && A[i+1] > 1)
		{
			std::cout << res << std::endl;
			return 0;
		}
	}

	res = 0;

	reverse(ALL(A));
	for (ll i = 0; i < N; )
	{
		ll j = i + 1;
		if (A[i] != 0)
		{
			res += A[i];
			while (j < N && A[j] != 0)
			{
				if (A[j-1] == A[j]+1)
				{
					++j;
				}
				else if (A[j-1] <= A[j])
				{
					res += A[j];
					++j;
				}
				else
				{
					std::cout << -1 << std::endl;
					return 0;
				}
			}
		}
		i = j;
	}

	std::cout << res << std::endl;
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
constexpr ll mod = 1e9+7;

signed main(){
  int h,w,k; cin >> h >> w >> k;

  vi c = {1,2,3,5,8,13,21,34,55};

  vvi dp(h+1,vi(w));
  dp[0][0] = 1;
  rep(hi,h){
    rep(wi,w){
      if(wi-1 >= 0){
	dp[hi+1][wi-1] += (c[max(0ll,wi-2)] * c[max(0ll,w-wi-2)] * dp[hi][wi]) % mod;
	dp[hi+1][wi-1] %= mod;
      }
      
      dp[hi+1][wi] += (c[max(0ll,wi-1)] * c[max(0ll,w-wi-2)] * dp[hi][wi]) % mod;
      dp[hi+1][wi] %= mod;

      if(wi+1 < w){
	dp[hi+1][wi+1] += (c[max(0ll,wi-1)] * c[max(0ll,w-wi-3)] * dp[hi][wi]) % mod;
	dp[hi+1][wi+1] %= mod;
      }
    }
  }
  dump(dp)

  cout << dp[h][k-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 301000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
ll INF = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int main(){
    int N; cin >> N;
    int a,b,c;
    int Adp[100100] = {0},Bdp[100100]={0},Cdp[100100] = {0};
    cin >> a >> b >> c;
    Adp[0] = a; Bdp[0] = b; Cdp[0] = c;
    for(int i = 1; i < N; i++){
        cin >> a >> b >> c;
        Adp[i] = max(Cdp[i-1], Bdp[i-1]) + a;
        Bdp[i] = max(Adp[i-1], Cdp[i-1]) + b;
        Cdp[i] = max(Adp[i-1], Bdp[i-1]) + c;
    }
    cout << max(Adp[N-1], max(Bdp[N-1], Cdp[N-1])) << endl;

}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main()
{
	int n, n1, n2, n3;
	int i = 1;
	cin >> n;
	do{
		cin >> n1 >> n2 >> n3;
		
		if(n1 * n1 + n2 * n2 == n3 * n3){
			cout << "YES" << endl;
		}
		else if(n1 * n1 + n3 * n3 == n2 * n2){
			cout << "YES" << endl;
		}
		else if(n3 * n3 + n2 * n2 == n1 * n1){
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
		i++;
	}while(i <= n);
	
	return 0;
}

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


int main() {
  int n;
  cin >> n;
  vector<ll> a(n+2), b(n+2), c(n+2);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];
  a[n] = 0; b[n] = 0; c[n] = 0;
  a[n+1] = INF; b[n+1] = INF; c[n+1] = INF;
  sort(rng(a));
  sort(rng(b));
  sort(rng(c));
  ll ans = 0;
  vector<ll> y(n+1);
  for(int i = 1; i <= n; i++) {
    int l = 0, r = n+1;
    while(r-l>1) {
      int m = (l+r)/2;
      if(a[m]<b[i]) l = m;
      else r = m;
    }
    y[i] = l;
  }
  y[0] = 0;
  for(int i = 1; i <= n+1; i++) y[i] += y[i-1];
  for(int i = 1; i <= n; i++) {
    int l = 0, r = n+1;
    while(r-l>1) {
      int m = (l+r)/2;
      if(b[m]<c[i]) l = m;
      else r = m;
    }
    ans += y[l];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6416
#include <iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#define INF 1e8
using namespace std;
#define ll long long

#define MAX 100020
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#define INF 1e8
using namespace std;
#define ll long long

#define MAX 100020

long double calc_dist(vector<pair<long double, long double>> vec, int n, vector<int> &v){
    double dist=0;
    for(int i=1;i<n;i++){
        dist+= sqrt(pow((vec[v[i]].second-vec[v[i-1]].second),2) + pow((vec[v[i]].first-vec[v[i-1]].first),2));
    }
    return dist;
}
int main(){
int n;
cin>>n;

double sum=0;
vector<pair<long double,long double>> vec(n);
vector<int> v(n);
for(int i=0;i<n;i++){
    v[i]=i;
    cin>>vec[i].first>>vec[i].second;
}

double count=0;
  do {
      count++;
    sum+=calc_dist(vec,n,v);
  } while ( std::next_permutation(v.begin(),v.end()));

cout<<fixed<<setprecision(6)<<sum/count;

}



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

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i;i<n;i++){
    cin >> v[i];
  }
  int r=0;
  for(int i=1;i<n-1;i++){
    if(v[i]==fmin(v[i],v[i-1]) && v[i]==fmax(v[i],v[i+1])){
      r++;
    }
    else if(v[i]==fmax(v[i],v[i-1]) && v[i]==fmin(v[i],v[i+1])){
      r++;
    }
  }
    cout << r;
            
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 
long long int degit(long long int n){
    long long int i = 0;
    while (n > 0){
        n /= 10;
        i++;
    }
    return i;
}
 
int main() {
    long long n;
    cin >> n;
    long long a = 1; //max
    long long b = 1; //min
    long long int ans = degit(n);
    long long int qans = 0;
    long long i = 1;
 
    do {
        if(n % i == 0){
            b = n /a;
            qans = max(degit(a),degit(b));
            if(qans < ans) ans = qans;
        }
        i++;
        a = i;
    }while (i * i <= n);
 
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
def colormap(rate):
    if 1 <= rate < 400:
        return 0
    elif 400 <= rate < 800:
        return 1
    elif 800 <= rate < 1200:
        return 2
    elif 1200 <= rate < 1600:
        return 3
    elif 1600 <= rate < 2000:
        return 4
    elif 2000 <= rate < 2400:
        return 5
    elif 2400 <= rate < 2800:
        return 6
    elif 2800 <= rate < 3200:
        return 7
    elif 3200 <= rate:
        return -1


def solve():
    N = int(input())
    a = [int(x) for x in input().split()]

    colors = [colormap(x) for x in a]

    import collections
    count = collections.Counter(colors)
    # print(count)

    ncolor = len(count) - (-1 in count)

    nmin = 1 if ncolor == 0 else ncolor
    nmax = ncolor + count[-1]

    print(nmin, nmax)


def main():
    solve()


if __name__ == '__main__':
    main()

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

int main(void){

    set<int> Answer;
    Answer.insert(1);
    Answer.insert(2);
    Answer.insert(3);

    int WA;
    for(int i=0; i<2; i++){
        cin >> WA;
        Answer.erase(WA);
    }

    cout << *Answer.begin() << endl;

    return 0;
}

Measured memory_bytes: 256