akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m;
    cin >> n >> m;

    ll left = 0;
    ll right = INF;
    rep(i, m) {
        ll L, R;
        cin >> L >> R;
        chmax(left, L);
        chmin(right, R);
    }

    out(max(0LL, right - left + 1));
    re0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int a, b, c, tmp;

	scanf("%d %d %d", &a, &b, &c);

	if (a > b) {
		tmp = a;
		a = b;
		b = tmp;
	}
	if (b > c) {
		tmp = b;
		b = c;
		c = tmp;
	}
	if (a > b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	printf("%d %d %d\n", a, b, c);

	return(0);
}


Measured memory_bytes: 2068
using System;

namespace ITP1_4_A
{
    class Program
    {
        static void Main()
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);

            Console.WriteLine("{0} {1} {2:f8}", a / b, a % b, (double)a / b);
        }
    }
}

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

struct dt{
    string s;
    int p;
    int idx;
};

bool cmps(const dt &a, const dt &b){
    return a.s < b.s;
}
bool cmpp(const dt &a, const dt &b){
    return a.p > b.p;
}

int main(){
    int n,num;
    int i;
    string tmps;
    int tmpp;
    string tmp, ntmp;
    vector<dt> data;

    cin >> n;
    for(i=0;i<n;i++){
        cin >> tmps >> tmpp;
        data.push_back({tmps,tmpp,i+1});
    }
    cout << endl;
    sort(data.begin(),data.end(),cmps);

    for(i=0;i<n-1;i++){
        tmp = (data.begin()+i)->s;
        num = 0;
        while(tmp == (ntmp = (data.begin()+i+num+1)->s)){
            tmp = ntmp;
            num++; 
        }
        if(num>0) sort((data.begin()+i),data.begin()+i+num+1,cmpp);
        i += num;
    }
    for(i=0;i<n;i++){
        cout << (data.begin()+i)->idx << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), putchar(), scanf()

int
main(int argc, char **argv)
{
	             /* 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18x */
	int line[19] = {6, 7, 8, 9, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
	                    /* 0  1  2  3  4  5  6  7  8  9x */
	int table[10][10] = {{ 0, 9, 9, 9, 9, 9, 9, 9, 9, 9},
	            /* 1x */ { 8, 0,10,10,10,10,10,10,10,10},
	            /* 2x */ { 7, 7, 0,11,11,11,11,11,11,11},
	            /* 3x */ { 6, 6, 6, 0,12,12,12,12,12,12},
	            /* 4x */ { 5, 5, 5, 5, 0,13,13,13,13,13},
	            /* 5x */ { 4, 4, 4, 4, 4, 0,14,14,14,14},
	            /* 6x */ { 0, 0, 0, 0, 0, 0, 0,15,15,15},
	            /* 7x */ { 1, 1, 1, 1, 1, 1, 1, 0,16,16},
	            /* 8x */ { 2, 2, 2, 2, 2, 2, 2, 2, 0,17},
	            /* 9x */ { 3, 3, 3, 3, 3, 3, 3, 3, 3, 0}};

	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; ++i)
	{
		int s, e;
		scanf("%d%d", &s, &e);

		for (int j = table[s][e];; ++j)
		{
			if (s != line[j])
				putchar(' ');

			printf("%d", line[j]);
			if (e == line[j])
				break;
		}

		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 1820
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	long long d, n;
	cin >> d >> n;

	long long k = 1;
	rep(i,d) k*=100;

	if(n == 100){
		cout << n * k + k << endl;
	}else{
		cout << n * k << endl;
	}
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
submits = []
m.times { submits << gets.split }
problems = Array.new(n) { Array.new }
submits.each do |problem, judge|
  problems[problem.to_i - 1] << judge
end
ac = 0
wa = 0
problems.each do |problem|
  current_wa = 0
  problem.each do |judge|
    if judge == "AC"
      wa += current_wa
      ac += 1
      break
    else
      current_wa += 1
    end
  end
end
puts "#{ac} #{wa}"


Measured memory_bytes: 39616
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif




#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()   //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend()//...,3,2,1

using namespace std;


//constant
const int MOD = 1e9+7;
const int INF = 1e18;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};
const double pi = acos(-1);


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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
//*max_element(ALL(vector))
//count(ALL(vector),num) -> n
//memset(obj,value,sizeof(obj));
int n;

int factorial(int n){
    if(n<=0) return 0;
    if(n==1) return 1;
    return factorial(n-1)*n%MOD;
}

void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m; cin >> n >> m;
    
    int factn = factorial(n);
    int factm = factorial(m);
    
    if(n==m){
        cout << factn*factm*2%MOD << endl;
    }else if (abs(n-m)==1){
        cout << factn*factm%MOD << endl;
    }else{
        cout << 0 << endl;
    }
    
    
    
}





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




Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string a,b;
    cin>>a>>b;
    
    if(a==b){
        cout1("=")
    }else if(a>b){
        cout1(">")
    }else{
        cout1("<")
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 1000003
#define INF 1e9
ll dp[100005];
ll visited[100005];
vector <ll> v[100005];
void dfs(int i){
	for(int j = 0; j<v[i].size();j++){
		if(!visited[v[i][j]]){
            visited[v[i][j]]=1;
	     	dfs(v[i][j]);
		}
		dp[i] = max(dp[i], 1 + dp[v[i][j]]);
	}
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,m,i,j,k;
   	cin>>n>>m;
   	for(i=0;i<m;i++){
   		cin>>j>>k;
   		v[j].pb(k);
	}
	memset(dp,0,sizeof(dp));
	for(i=1;i<=n;i++){
		if(!visited[i])
		dfs(i);
	}
	ll  temp =0;
	for(i=1;i<=n;i++)
	temp = max(temp,dp[i]);
	cout<<temp;
 }

Measured memory_bytes: 9344
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000;
int N, x;
int a[MAX_N];

int main() {
  cin >> N >> x;
  rep(i,N) cin >> a[i];

  ll ans = 0;
  for (int i = 0; i < N-1; ++i) { 
    if (a[i] + a[i+1] > x) {
      ll t = (ll)a[i]+a[i+1]-x;
      ans += t;
      if (a[i+1] >= t) {
        a[i+1] -= t;
      } else {
        a[i+1] = 0;
      }
    }
  }

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


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define SORT(x) (sort(x.begin(),x.end()))
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    int N;cin >> N;
    vector<string> V;
    rep(i,N){
        string S;
        cin >> S;
        SORT(S);
        V.push_back(S);
    }
    SORT(V);
    ll cnt=1;
    ll ans=0;
    rep(i,N-1){
        if(V[i+1]==V[i]){
            cnt++;
        }
        else{
            ans+=(cnt*(cnt-1)/2);
            cnt=1;
        }
        if(i==N-2){
            ans+=cnt*(cnt-1)/2;
            cnt=1;
        }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 5876
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#define inf 10000+10
using namespace std;
const int maxn=100+10,maxm=5000+10;
int n,m,S,T,cnt;
int hd[maxn],to[maxm],nxt[maxm],fl[maxm],pos[maxn];
void add(int x,int y,int z){
    to[cnt]=y,fl[cnt]=z,nxt[cnt]=hd[x],hd[x]=cnt++;
    to[cnt]=x,fl[cnt]=0,nxt[cnt]=hd[y],hd[y]=cnt++;
}
bool dfs(){
    memset(pos,-1,sizeof(pos));
    int head=0,tail=0,q[maxn];
    pos[q[0]=S]=0;
    while(head<=tail){
        int v=q[head++];
        for(int i=hd[v];i!=-1;i=nxt[i])
            if(pos[to[i]]==-1&&fl[i])
                pos[q[++tail]=to[i]]=pos[v]+1;
    }
    return pos[T]!=-1;
}
int find(int v,int f){
    if(v==T)
        return f;
    int res=0,t;
    for(int i=hd[v];i!=-1&&f>res;i=nxt[i])
        if(pos[v]+1==pos[to[i]]&&fl[i])
            t=find(to[i],min(f-res,fl[i])),fl[i]-=t,res+=t,fl[i^1]+=t;
    if(!res)
        pos[v]=-1;
    return res;
}
int dinic(){
    int res=0,t;
    while(dfs())
        while(t=find(S,inf))
            res+=t;
    return res;
}
int main(){
    cnt=0;
    memset(hd,-1,sizeof(hd));
    scanf("%d%d",&n,&m);
    for(int i=1,x,y,z;i<=m;i++)
        scanf("%d%d%d",&x,&y,&z),add(x,y,z);
    S=0,T=n-1;
    printf("%d\n",dinic());
    return 0;
}


Measured memory_bytes: 3236
(n, m) = map(int, input().split())

cities = []
for i in range(m):
    (p, y) = map(int, input().split())
    cities.append((p, y))
data = {}
for i, v in enumerate(cities):
    if not v[0] in data:
        data[v[0]] = []
    data[v[0]].append([i, v, ''])

for k, v in data.items():
    v.sort(key=lambda x: x[1][1])
    for i, j in enumerate(v):
        j[2] = "{0:06d}".format(j[1][0]) + "{0:06d}".format(i + 1)

codes = [''] * len(cities)
for k, v in data.items():
    for i in v:
        codes[i[0]] = i[2]

for code in codes:
    print(code)

Measured memory_bytes: 54752
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int a,b; cin >> a >> b ;
    cout << ((a+b < 24)?a+b:a+b-24) << endl; return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n;
    cin >> n;
    vi x(n); rep(i, n) cin >> x[i];
    
    ll ans = 1001001001;
    rep3(p, 1, 100){
        ll tot = 0;
        rep(i, n){
            tot += (x[i]-p) * (x[i]-p);
        }
        ans = min(tot, ans);
    }   
    
    cout << ans << endl;
    return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,cnt[105][30],maxv,ans;
string a,b,c;
int main(){
	cin>>n>>a>>b>>c;
	for(int i=0;i<n;i++)
	{
		maxv=0;
		cnt[i][a[i]-'a']++,cnt[i][b[i]-'a']++,cnt[i][c[i]-'a']++;
		for(int j=0;j<26;j++)
			maxv=max(maxv,cnt[i][j]);
		ans+=(3-maxv);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ALDS1_5_A_ExhaustiveSearch
{
	class Program
	{
		static void Main ( string[] args )
		{
			int arraySize = int.Parse (Console.ReadLine ());
			int[] elementArray = new int[arraySize];
			elementArray = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();

			arraySize = int.Parse (Console.ReadLine ());
			int[] searchArray = new int[arraySize];
			searchArray = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();

			Pattern pattern = new Pattern (elementArray);

			foreach (var item in searchArray)
			{
				bool isCreate = pattern.IsCreate (item);

				if (isCreate)
					Console.WriteLine ("yes");
				else
					Console.WriteLine ("no");
			}

		}
	}

	class Pattern
	{
		public Pattern ( int[] numArray )
		{
			this.NumArray = numArray;
		}

		private int[] NumArray { set; get; }

		public bool IsCreate ( int num, int index = 0 )
		{
			//???????????¶
			if (num == 0)
			{
				return true;
			}
			else if (NumArray.Length <= index)
			{
				return false;
			}

			//?¶??????´?????¨?¶????????????´???
			bool isCreate = IsCreate (num, index + 1) || IsCreate (num - NumArray[index], index + 1);

			return isCreate;
		}
	}
}

Measured memory_bytes: 9388
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXN=1e5+50;
int a[MAXN];
int N, K;
VI e[MAXN];
int ans;

int DFS(int x,bool spe) {
	int d=0;
	for(int u:e[x])
		d=max(d, DFS(u, x==1));
	d++;
	debug("DFS(%d) %d\n",x,d);
	if(spe) return 0;
	if(d==K) ans++, d=0;
	return d;
}

int main() {
	scanf("%d%d",&N,&K);
	for(int i=1;i<=N;i++) {
		scanf("%d",a+i);
		if(i!=1) e[a[i]].PB(i);
	}
	if(a[1]!=1) ans++, a[1]=1;
	DFS(1,1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10752
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READV(K);
    vector<ll> A(N+1,0);
    FORI(i,1,N+1)
    {
        READ(A[i]);
    }
    ll present=1;
    while(K>0)
    {
        if(K%2==1)
        {
            present=A[present];
        }
        K=K/2;
        vector<ll> R(N+1,0);
        FORI(i,1,N+1)
        {
            R[i]=A[A[i]];
        }
        A=R;
    }
    cout<<present<<endl;

//-----------------------------------------------------------------------------------------------------------//


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 6592
import java.util.*;

public class Main {

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

        List<Long> list = new ArrayList<>();
        for(long i=0; i*i*i*i*i >=0; i++) {
            list.add(i*i*i*i*i);
        }
        int n = list.size();
        long[] a = new long[n];
        for(int i=0; i<n; i++) {
            a[i] = list.get(i);
        }

        for(int i=0; i<n; i++) {
            long b5 = a[i]-x;
            if(b5 > 0) {
                int j = Arrays.binarySearch(a, b5);
                if(j >= 0) {
                    int aa = i;
                    int bb = j;
                    System.out.println(aa + " " + bb);
                    return;
                }
            } else {
                int j = Arrays.binarySearch(a, -b5);
                if(j >= 0) {
                    int aa = i;
                    int bb = -j;
                    System.out.println(aa + " " + bb);
                    return;
                }
            }
            b5 = -a[i] - x;
            int j = Arrays.binarySearch(a, -b5);
            if(j >= 0) {
                int aa = -i;
                int bb = -j;
                System.out.println(aa + " " + bb);
                return;
            }
        }

    }



}

Measured memory_bytes: 39212
// Union Find Tree
// 高速にグループ分けをするデータ構造
// * 2つメンバーが所属するグループを同じグループにまとめる
// * 2つのメンバーが同じグループに所属するか判定する
//
// verifyした問題
// B - Union Find
// https://atcoder.jp/contests/atc001/tasks/unionfind_a

#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

// Union Find Tree
class UnionFindTree {
   private:
    vector<int> parent;
    vector<int> rank;
    int root(int x) { return parent[x] == x ? x : parent[x] = root(parent[x]); }
    vector<int> size;  // グループのメンバー数
   public:
    // コンストラクタ n: メンバー数
    UnionFindTree(int n) {
        parent.resize(n);
        iota(parent.begin(), parent.end(), 0);
        rank.assign(n, 0);
        size.assign(n, 1);
    }
    // メンバーxとメンバーyが同じグループに所属しているかどうかを返す
    bool same(int x, int y) { return root(x) == root(y); }
    // メンバーxとメンバーyが所属するグループを合併する
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;

        if (rank[x] < rank[y]) {
            parent[x] = y;
            size[y] += size[x];
        } else {
            parent[y] = x;
            size[x] += size[y];
            if (rank[x] == rank[y]) rank[x]++;
        }
        return true;
    }
    // メンバーxが所属するグループのサイズを返す
    int getGroupSize(int x) { return size[root(x)]; }
};

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n, m;
    cin >> n >> m;

    UnionFindTree uft(n);

    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        uft.unite(x - 1, y - 1);
    }

    int ans = 0;

    for (int i = 0; i < n; i++) {
        ans = max(uft.getGroupSize(i), ans);
    }

    cout << ans << endl;
}


Measured memory_bytes: 7952
import math

def dfs(i, sum, count, remain, d, g, pc):
    global ans
    if i == d:
        if sum < g:
            q = max(remain)
            n = min(pc[q][0] - 1, math.ceil((g - sum) / (100 * (q + 1))))
            #n = min(pc[q][0], -(-(g - sum) // ((q + 1) * 100)))
            count += n
            sum += 100 * (q + 1) * n
        if sum >= g:
            ans = min(ans, count)
    else:
        dfs(i + 1, sum, count, remain, d, g, pc)
        dfs(i + 1, sum + (i + 1) * 100 * pc[i][0] + pc[i][1], count + pc[i][0], remain - {i}, d, g, pc)

def main2():
    global ans
    ans = float("inf")
    d, g = map(int, input().split())
    pc = [list(map(int, input().split())) for _ in range(d)]
    dfs(0, 0, 0, set(range(d)), d, g, pc)
    print(ans)

if __name__ == '__main__':
    main2()

Measured memory_bytes: 41456
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int long x;
    cin >> x;
    cout << bitset<32>(x) << endl;
    //反転
    cout << bitset<32>(~x) << endl;
    //左シフト
    cout << bitset<32>(x*2) << endl;
    //右シフト
    cout << bitset<32>(x/2) << endl;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define maxn (int)(2*(1e5))
using namespace std;
int n,k,l;
int id1[maxn],sz1;
int id2[maxn],sz2;
map<pair<int,int>,int> d;
vector<int> m1[maxn],m2[maxn];
bool v[maxn];
void dfs1(int a) {
	v[a]=1;
	id1[a]=sz1;
	for (int i=0;i<m1[a].size();i++) {
		int b=m1[a][i];
		if (!v[b])
			dfs1(b);
	}
}
void dfs2(int a) {
	v[a]=1;
	id2[a]=sz2;
	for (int i=0;i<m2[a].size();i++) {
		int b=m2[a][i];
		if (!v[b])
			dfs2(b);
	}
}
int main() {
	scanf("%d %d %d",&n,&k,&l);
	int a,b;
	for (int i=1;i<=k;i++) {
		scanf("%d %d",&a,&b);
		m1[a].push_back(b);
		m1[b].push_back(a);
	}
	for (int i=1;i<=l;i++) {
		scanf("%d %d",&a,&b);
		m2[a].push_back(b);
		m2[b].push_back(a);
	}
	memset(v,0,sizeof(v));
	memset(id1,0,sizeof(id1));
	sz1=0;
	for (int i=1;i<=n;i++)
		if (!v[i]) {
			sz1++;
			dfs1(i);
		}
	memset(v,0,sizeof(v));
	memset(id2,0,sizeof(id2));
	sz2=0;
	for (int i=1;i<=n;i++)
		if (!v[i]) {
			sz2++;
			dfs2(i);
		}
	for (int i=1;i<=n;i++)
		d[make_pair(id1[i],id2[i])]++;
	for (int i=1;i<=n;i++)
		printf("%d ",d[make_pair(id1[i],id2[i])]);
	printf("\n");
	return 0;
}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

int n,m;
pii dp[100000];//(red,sum);

int main(){
  cin >> n >> m;
  REP(i,n){
    dp[i] = pii(0,1);
  }
  dp[0] = pii(1,1);
  REP(i,m){
    int x,y;
    cin >> x >> y;
    x--;y--;
    if(dp[x].first == 1){
      dp[y] = pii(1,dp[y].second+1);
      dp[x].second--;
      if(dp[x].second==0){
        dp[x].first = 0;
      }
    }else{
      dp[y].second++;
      dp[x].second--;
    }
  }
  int cnt = 0;
  REP(i,n){
    if(dp[i].first==1) cnt++;
  }
  cout <<cnt <<endl;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] h = new int[n];
    for(int i=0; i<n; i++){
      h[i] = sc.nextInt();
    }
    Arrays.sort(h);
    int[] wa = new int[n-k+1];
    for(int i=0; i<=n-k; i++) {
      wa[i] = h[i+k-1] - h[i];
    }
    int ans = 2_000_000_000;
    for(int i=0; i<=n-k; i++) {
      ans = Math.min(ans, wa[i]);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 50196
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <algorithm>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;
typedef pair<llint, P> E;

struct edge{
	llint to, cost;
	edge(int a, int b){
		to = a, cost = b;
	}
};

struct UnionFind{
	int size;
	vector<int> parent;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};

int n, m;
vector<E> g[100005];
vector<edge> G[300005];
UnionFind uf(1000005);
vector<llint> comp;
llint dist[300005];

void dijkstra()
{
	for(int i = 1; i <= n+m; i++) dist[i] = inf;
	dist[1] = 0;
	
	priority_queue< P, vector<P>, greater<P> > Q;
	Q.push( make_pair(0, 1) );
	
	int v, d;
	while(Q.size()){
		d = Q.top().first;
		v = Q.top().second;
		Q.pop();
		if(dist[v] < d) continue;
		for(int i = 0; i < G[v].size(); i++){
			if(dist[G[v][i].to] > d + G[v][i].cost){
				dist[G[v][i].to] = d + G[v][i].cost;
				Q.push( make_pair(dist[G[v][i].to], G[v][i].to) );
			}
		}
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	int u, v, c;
	for(int i = 1; i <= m; i++){
		cin >> u >> v >> c;
		g[u].push_back(E(c, P(v, i)));
		g[v].push_back(E(c, P(u, i)));
	}
	int id = 1;
	for(int i = 1; i <= n; i++){
		sort(g[i].begin(), g[i].end());
		for(int j = 1; j < g[i].size(); j++){
			if(g[i][j-1].first == g[i][j].first){
				uf.unite(g[i][j-1].second.second, g[i][j].second.second);
			}
		}
	}
	
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < g[i].size(); j++){
			comp.push_back(uf.root(g[i][j].second.second));
		}
	}
	sort(comp.begin(), comp.end());
	comp.erase(unique(comp.begin(), comp.end()), comp.end());
	
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < g[i].size(); j++){
			int id = g[i][j].second.second;
			id = uf.root(id);
			id = lower_bound(comp.begin(), comp.end(), id) - comp.begin() + 1 + n;
			G[i].push_back(edge(id, 1));
			G[id].push_back(edge(i, 1));
		}
	}
	
	dijkstra();
	
	if(dist[n] > inf/2) cout << -1 << endl;
	else cout << dist[n]/2 << endl;
	
	return 0;
}

Measured memory_bytes: 56048
import sys
readline = sys.stdin.readline
from math import factorial
MOD = 10 ** 9 + 7

def main():
    N, K = map(int, readline().rstrip().split())
    f1 = factorial(N-K+1)
    f2 = factorial(K-1)
    f3 = 1
    for i in range(1, K+1):
        if N - K + 1 - i < 0:
            print(0)
            continue
        ans = f2 // (f3 * factorial(K-i))
        f3 *= i
        ans *= f1 // (f3 * factorial(N-K+1-i))
        print(ans % MOD)


if __name__ == '__main__':
    main()

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

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

	int ans = 0;
	for (int i = 1; ; i++) {
		if (y * i + z * (i + 1) <= x)ans = max(ans, i);
		else break;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int n, a[100];
string str;
signed main(){
	while(1){
		scanf("%lld", &n);
		if(n == 0)break;
		cin >> str;
		fill(a, a+100, 0);
		int tmp = 0;
		rep(i,100){
			int t = i%n;
			if(str[i] == 'M')a[t]++;
			if(str[i] == 'S'){tmp += a[t]+1;a[t] = 0;}
			if(str[i] == 'L'){a[t] += tmp+1;tmp = 0;}
		}
		sort(a, a+n);
		rep(i,n)printf("%lld ", a[i]);
		printf("%lld\n", tmp);
	}
	return 0;
}








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


int main(){
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  for(auto& a : A){
    cin >> a;
  }
  vector<int> B(N);
  B[0] = A[0] + K - A[N-1];
  for(int ii=1; ii<N; ii++){
    B[ii] = A[ii] - A[ii-1];
  }
  sort(B.begin(), B.end());
  cout << K - B[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

int N, A;
int x[111];
ll coudp[111][111][5555];

int main() 
{
	int W, H,N;
	cin >> W>> H>>N;
	vector<int> x(N);
	vector<int> y(N);
	vector<int> n(N);
	for (int i = 0; i < N; i++)
	{
		cin >> x[i] >> y[i] >> n[i];
	}
	int w = 0;
	int h = 0;
	for (int i = 0; i < N; i++)
	{
		if (n[i] == 1)
		{
			if (w <= x[i]&&x[i]<=W)
			{	
				w = x[i];

			}
		}
		if (n[i] == 2)
		{
			if (W >= x[i])
			{
				W = x[i];

			}
		}
		if (n[i] == 3)
		{
			if (h <= y[i] && y[i] <= H)
			{
				h = y[i];

			}
		}
		if (n[i] == 4)
		{
			if (H >= y[i])
			{
				H = y[i];

			}
		}

	}
	int ans = (W - w) * (H - h);
	if (ans <= 0)
	{
		ans = 0;
	}
	cout << ans << endl;

	return 0;
	
}

Measured memory_bytes: 256
S=str(input())
l=int(S[0]+S[1])
r=int(S[2]+S[3])
if l<=12 and l>0 and r<=12 and r>0:
  print('AMBIGUOUS')
elif l<=12 and l>0:
  print('MMYY')
elif r<=12 and r>0:
  print('YYMM')
else:
  print('NA')

Measured memory_bytes: 3064
#include <cstdio>

int a,d,n;
bool num[1000000];

int prime(){
	num[0] = false;
	num[1] = false;
	for(int i = 2; i < 1000000; i++) num[i] = true;
	for(int i = 2; i < 1000; i++){
		if(!num[i]) continue;
		for(int j = 2*i; j < 1000000; j += i) num[j] = false;
	}
}

int main(){
	prime();
	while(scanf("%d%d%d", &a, &d, &n),a||d||n){
		int cnt = 0;
		for(int i = 0;;i++){
			if(num[a+d*i]) cnt++;
			if(cnt == n){
				printf("%d\n", a+d*i);
				break;
			}
		}
	}
}

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

using namespace std;

#define REP(i,n) for(int i = 0;i < n;i++)
	
int main()
{
	int x,y,s;
	while(cin >> x >> y >> s,x|y|s)
	{
		int ans = 0;
		for(int i = 1;i < s;i++)
		{
			for(int j = 1;j < s ;j++)
			{
				int a = i*(100 + x)/100;
				int b = j*(100 + x)/100;
				if(a + b != s)continue;
				a = i*(100 + y)/100;
				b = j*(100 + y)/100;
				ans = max(ans , a+b);
			}
		}
		cout << ans << endl;
		
	}
	
	return 0;
	
}

Measured memory_bytes: 3020
#include <stdio.h>
int main(void){
	int n,m,l[100000],r[100000],i,b=0,c=1000000;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++){
      scanf("%d %d",&l[i],&r[i]);
	  if(b<l[i])b=l[i];
      if(c>r[i])c=r[i];
    }
    if(c-b>=0)printf("%d",c-b+1);
    else printf("0");
	return 0;
}


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

typedef long long ll;
typedef long double ld;

#define deb(x) cerr << #x << ":" << x << "\n"

int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1;
    // cin >> t;
    for (int tc = 1; tc <= t; tc++)
    {
        ll i, j, k = 0;
        ll n;
        cin >> n;
        vector<ll> v(n);
        for (i = 0; i < n; i++)
            cin >> v[i];
        j = v[0];
        k = 1;
        for (i = 0; i < n; i++)
        {

            if (v[i] < j)
            {
                k++;
            }
            j = min(j, v[i]);
        }
        cout << k << "\n";
    }
    return 0;
}

Measured memory_bytes: 1792
from bisect import bisect_left, bisect_right

def int_raw():
	return int(raw_input())
 
def words_raw():
	return raw_input().split()
 
def ints_raw():
	return map(int, words_raw())

INF = 10 ** 11

def dist_to_left(a, x):
	i = bisect_right(a, x)
	return x - a[i-1] if i else INF

def dist_to_right(a, x):
	i = bisect_left(a, x)
	return a[i] - x if i != len(a) else INF

def cost(shrines, temples, query):
	best = INF
	shrine_left = dist_to_left(shrines, query)
	shrine_right = dist_to_right(shrines, query)
	temple_left = dist_to_left(temples, query)
	temple_right = dist_to_right(temples, query)

	# Both left
	if best > max(shrine_left, temple_left):
		best = max(shrine_left, temple_left)

	# Both right
	if best > max(shrine_right, temple_right):
		best = max(shrine_right, temple_right)

	# Different_directions
	shrine_closest = min(shrine_left, shrine_right)
	temple_closest = min(temple_left, temple_right)
	dist = min(shrine_closest, temple_closest) + shrine_closest + temple_closest
	if best > min(shrine_closest, temple_closest) + shrine_closest + temple_closest:
		best = min(shrine_closest, temple_closest) + shrine_closest + temple_closest

	return best

A, B, Q = ints_raw()
shrines = [int_raw() for _ in range(A)]
temples = [int_raw() for _ in range(B)]
queries = [int_raw() for _ in range(Q)]
for query in queries:
	print cost(shrines, temples, query)	



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

int main() {
    int n;
    cin >> n;
    
    vector<int> h(n);
    for(int i  = 0; i < n; i++) cin >> h.at(i);
    
    int ref = h.at(0);
    
    int ans = 1;
    for(int i = 1; i < n; i++) {
        if (h.at(i) >= ref) {
            ans++;
            ref = h.at(i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a,b,c,tmp;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    
    if(b<a){
    tmp=a;
    a=b;
    b=tmp;
    }

    if(c<b){
    tmp=b;
    b=c;
    c=tmp;
    }
    
    if(b<a){
    tmp=a;
    a=b;
    b=tmp;
    }
    
    printf("%d %d %d\n",a,b,c);
    
    return 0;
}



Measured memory_bytes: 2044
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = s.length();
    if (n <= k){
        cout << s;
    }
    else {
        cout << s.substr(0,k) << "...";
    }


    return 0;
}

Measured memory_bytes: 3656
def getStart(field):
    search_field = field[1:]
    for y in range(len(search_field)):
        for x in range(len(search_field[0])):
            if search_field[y][x] == "S":
                return x,y+1


def bfs(field,start_x,start_y,goal_N):
    direction = [[-1,0],[1,0],[0,-1],[0,1]]
    gotten_cheese = 1
    distance = 0
    que = []
    que.append([start_x,start_y,gotten_cheese,distance])
    INF = 1
    min_path = [[INF for j in range(field[0][1])] for i in range(field[0][0])]
    while len(que) != 0:
        current = que.pop(0)
        for d in direction:
            nx = current[0] + d[0]
            ny = current[1] + d[1]
            if 0 <= nx < field[0][1] and 1 <= ny < field[0][0]+1 and field[ny][nx] != "X" and min_path[ny-1][nx] == INF:
                if field[ny][nx] == current[2]:
                    if field[ny][nx] == goal_N:
                        print(current[3]+1)
                        return
                    else:
                        que = []
                        que.append([nx,ny,current[2]+1,current[3]+1])
                        min_path = [[INF for j in range(field[0][1])] for i in range(field[0][0])]
                        break
                else:
                    que.append([nx,ny,current[2],current[3]+1])
                    min_path[ny-1][nx] = 0


def main(field):
    sx,sy = getStart(field)
    bfs(field,sx,sy,field[0][2])

matrix = []
while True:
    row = input().rstrip().split()
    if len(row) == 3:
        re_row = []
        for i in row:
            re_row.append(int(i))
        matrix.append(re_row)
    else:
        re_row = []
        for char in row[0]:
            if char.isdigit():
                re_row.append(int(char))
            else:
                re_row.append(char)
        matrix.append(re_row)
    if len(matrix) == int(matrix[0][0]) + 1:
        main(matrix)
        break

Measured memory_bytes: 34196
use std::io::*;
use std::str::FromStr;
use std::collections::BTreeMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    if &s == "ARC" {
        println!("ABC");
    } else {
        println!("ARC");
    }
}


Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    string s[50];
    int c[26];
    for(int i=0;i<26;i++)c[i]=50;
    int cnt[26];
    for(int i=0;i<26;i++)cnt[i]=0;
    for(int i=0;i<n;i++){
        cin>>s[i];
        for(int j=0;j<s[i].size();j++)cnt[(int)(s[i][j]-97)]++;
        for(int i=0;i<26;i++){
            c[i]=min(cnt[i],c[i]);
            cnt[i]=0;
        }
    }
    for(int i=0;i<26;i++){
        for(int j=0;j<c[i];j++)cout<<(char)(i+97);
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
def count_(n):
    cnt = 0
    k = 1
    while(n-k >= 0):
        n = n - k
        k = k + 1
        cnt = cnt + 1
    return cnt

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

if __name__ == '__main__':
    n = int(input())

    s_li = (factorization(n))
    
    if s_li[0][0] == 1:
        print(0)
    else:
        ans = 0
        for s_ in s_li:
            ans = ans + count_(s_[1])
        print(ans)

Measured memory_bytes: 9488
package main

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

func main() {
	var N int
	fmt.Scan(&N)
	b := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := range b {
		sc.Scan()
		b[i], _ = strconv.Atoi(sc.Text())
		b[i]-- // 0-indexed
	}
	var found bool
	ans := make([]int, 0)
	for len(b) > 0 {
		found = false
		for i := len(b) - 1; i >= 0; i-- { // 最後に挿入した数字を追跡する
			if b[i] == i { // これを満たす数が複数ある場合は一番右側の数を採用する
				found = true
				ans = append(ans, b[i])
				b = append(b[0:i], b[i+1:]...)
				break
			}
		}
		if !found {
			fmt.Println(-1)
			return
		}
	}
	for i := len(ans) - 1; i >= 0; i-- {
		fmt.Println(ans[i] + 1) // 0-indexedなので1足す
	}
}


Measured memory_bytes: 640
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;

void main() {
  string str = readln.chomp;

  // array.lengthの返り値の型はulongなので
  // intに代入しようとすると(dmd64 v2.070.1では)CEになる
  int p = str.length.to!int;

  while (p > 0) {
    if (str[(p - 7)..p] == "dreamer") {
      p -= 7;
    }
    else if (str[(p - 6)..p] == "eraser") {
      p -= 6;
    }
    else if (str[(p - 5)..p] == "erase") {
      p -= 5;
    }
    else if (str[(p - 5)..p] == "dream") {
      p -= 5;
    }
    else {
      p = -1;
    }
  }

  if (p == 0) {
    writeln("YES");
  }
  else {
    writeln("NO");
  }

  return;
}

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

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

Measured memory_bytes: 256
fn main() {
    loop {
        let reader = std::io::stdin();
        let mut line = String::new();
        let _r = reader.read_line(&mut line);
        let vec: Vec<&str> = line.split_whitespace().collect();
        let mut v = vec[0];
        if v == "#" {
            break;
        } else {
            let mut a: i64 = vec[1].parse().unwrap();
            let b: i64 = vec[2].parse().unwrap();
            let c: i64 = vec[3].parse().unwrap();
            if 31 < a {
                v = "?";
                a = a - 30;
            } else if 31 == a && 5 <= b {
                v = "?";
                a = a - 30;
            }
            println!("{} {} {} {}", v, a, b, c);
        }
    }
}



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

int main() {
	long n,a,b,i,j,k,ans,cur,res;
	cin >> n;
	cur=100;
	for(i=0; i<1e9; i++){
		cur=floor(cur*1.01);
		if(cur>=n){
			cout << i+1 << endl; return 0;
		}
	}
	cout << cur << endl;
	return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
        long long int t=0,b[1000000]={0};
        string c;
        set<string>s;
       long long int n,m,o=0,l,d=0,i,j,p=0,k,f;
       double pie=3.141592653589793238;
    long long int MOD=1000000007;
    cin>>n;
    for(i=0;i<n;i++)
    {
        p=s.size();
        cin>>c;
        s.insert(c);
        if(s.size()>p)
        p++;
    }
    cout<<p;
 return 0;
}

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

int main(){
   string s; cin>>s;
   int cnt=0;
   int tmp=s[0];
   for(int i=1;i<s.length();i++){
      if(s[i]==s[i-1]){
         if(s[i]=='0') s[i]='1';
         else s[i]='0';
         cnt++;
      }
   }
   cout<<cnt<<endl;
   return 0;
}

Measured memory_bytes: 512