akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_10C
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var input = Console.ReadLine();
                var n = int.Parse(input);

                if (n == 0)
                {
                    break;
                }

                input = Console.ReadLine();
                var arrayOfS = input.Split(' ').Select(_ => int.Parse(_));


                var averageOfS = arrayOfS.Aggregate(0.0, (acc, s) => acc + s / (double)n);
                var dOfS = arrayOfS.Aggregate(0.0, (acc, s) => acc + (s - averageOfS) * (s - averageOfS));
                var standardDeviation = Math.Sqrt(dOfS / n);



                /*
                var arrayOfS = new int[words.Length];
                var averageOfS = 0.0;
                for (var i = 0; i < n; ++i)
                {
                    arrayOfS[i] = int.Parse(words[i]);
                    averageOfS += arrayOfS[i] / (double)arrayOfS.Length;
                }

                var dOfS = 0.0;
                for (var i = 0; i < n; ++i)
                {
                    dOfS += (arrayOfS[i] - averageOfS) * (arrayOfS[i] - averageOfS);
                }
                var standardDeviation = Math.Sqrt(dOfS / arrayOfS.Length);
                 * */

                Console.WriteLine(standardDeviation);

            }
        }
    }
}

Measured memory_bytes: 6004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=2e5+10;
ll K,Cnt,N,M,CstA[MAXN],CstB[MAXN],CurA,CurB=0;
inline void pre(){
    cin>>N>>M>>K;
    for(int i=1;i<=N;i++)
        cin>>CstA[i],CstA[i]+=CstA[i-1];
    for(int i=1;i<=M;i++)
        cin>>CstB[i],CstB[i]+=CstB[i-1];
    CurA=N;
}
int main(){
    pre();
    while(CurB<=M){
        while(CstA[CurA]+CstB[CurB]>K)
            CurA--;
        Cnt=max(Cnt,CurA+CurB);
        CurB++;
    }
    cout<<Cnt;
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, n) for(int i = (n)-1; i >= 0; --i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s<<'[';for(size_t i=0;i<v.size();++i){s << v[i];if(i < v.size()-1) s << ", ";}s<<']';return s;
}
struct __f{
    __f(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    }
};

int main(){

    int n;
    scanf("%d", &n);
    vector<int> a(n);

    rep(i, n) scanf("%d", &a[i]);
    

    int ans = INF;
    for(int x = -100; x <= 100; ++x){
        int tmp = 0;
        rep(i, n)  tmp += (a[i]-x)*(a[i]-x);
        chmin(ans, tmp); 
    }
    ppp(ans);
    return 0;
}


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

int main(){

    int n,tem,tar; cin>>n>>tem>>tar;

    vector<int> high(n);

    for(int i=0; i<n; i++){

        cin>>high[i];
    }

    double mi =  10000;

    int ans = 0;

    for(int i=0; i<n; i++){

        double ave = tem - high[i] * 0.006;
        
        if( mi > abs(tar -  ave) ){

            mi = abs(tar - ave);

            ans = i + 1;
        }
    }

    cout<<ans<<endl;

    return 0;


}

Measured memory_bytes: 256
N, M = map(int, input().split())
P = [0]*M
Y = [0]*M
T = [0]*M
d = {}
for i in range(M):
    P[i], Y[i] = map(int, input().split())
    if not P[i] in d.keys():
        d[P[i]] = []
    d[P[i]].append([Y[i],i])
for k in d:
    d[k].sort(key=lambda x:x[0])
    for i in range(len(d[k])):
        T[d[k][i][1]] = i+1
for i in range(M):
    print('%06d' % P[i] + '%06d' % T[i])


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

int main() {
  int D;
  cin >> D;
  
  for (int i = 0; i < D; i++) {
    int ans = (i >= 26) ? (i % 26) : i;
    cout << ans + 1 << endl;
  }
}

Measured memory_bytes: 3672
ActualTiming=[]
Timecost=[]
for i in range(5):
	A=int(input())
	ActualTiming.append(A)
for i in range(5):
	X=0
	while X<ActualTiming[i]:
		X=X+10
	Timecost.append(X)
M=max(Timecost[j]-ActualTiming[j] for j in range(5))
print(sum(Timecost)-M)

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int n, k;
  cin >> n >> k;
  
  int x;
  int ans = 0;
  for(int i=0; i<n; i++) {
    cin >> x;
    if(x<=k-x) ans += x*2;
    else ans += (k-x)*2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map(String::toLong)
    val ab = mutableListOf<Pair<Long, Long>>()
    for (i in 0 until n.toInt()) {
        val (a, b) = readLine()!!.split(" ").map(String::toLong)
        ab.add(Pair(a, b))
    }
    ab.sortBy { it.first }

    var bSum = 0L
    for (i in 0 until n.toInt()) {
        bSum += ab[i].second
        if (bSum >= k) {
            println(ab[i].first)
            return
        }
    }
}


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

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    for(int i=0; i<N; i++) scanf(" %d", &P[i]);

    vector<bool> up(N, false);
    int count = 0;
    bool flag = false;
    for(int i=1; i<N; i++){
        if(P[i-1] < P[i]) count++;
        else count = 0;
        if(count >= K-1 && i-K+1>=0){
            // if(!flag) flag = true;
            // else ans--;
            up[i-K+1] = true;
        }
    }

    int ans = N-K+1;
    // for(int i=1; i+K-1<N; i++){
    //     if(P[i-1] < P[i] && P[i+K-2] < P[i+K-1]) ans--;
    // }
    set<int> st;
    vector<int> m(N), M(N);
    for(int i=0; i<K; i++) st.insert(P[i]);
    // for(auto& s: st) cout << s << " "; cout << endl;
    for(int i=0; i+K-1<N; i++){
        m[i] = *st.begin();
        st.erase(P[i]);
        if(i+K<N) st.insert(P[i+K]);
        // for(auto& s: st) cout << s << " "; cout << endl;
    }

    st.clear();
    for(int i=0; i<K; i++) st.insert(P[N-1-i]);
    // for(auto& s: st) cout << s << " "; cout << endl;
    for(int i=N-1; i>=K-1; i--){
        M[i] = *st.rbegin();
        st.erase(P[i]);
        if(i-K>=0) st.insert(P[i-K]);
        // for(auto& s: st) cout << s << " "; cout << endl;
    }

    bool f0 = false;
    for(int i=0; i+K-1<N; i++){
        if(up[i]){
            if(!f0) f0 = true;
            else ans--;
        }
        else if(i+K<N && m[i] == P[i] && M[i+K] == P[i+K]) ans--;
    }
    // for(auto& num: m) cout << num << " "; cout << endl;
    // for(auto& num: M) cout << num << " "; cout << endl;
    // for(int i=0; i+K-1<N; i++) cout << up[i] << endl;
    cout << ans << endl;
}

Measured memory_bytes: 12032
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

const int N=2e5+5,Mo=1e9+7;

int n,m,k,f[N],s[N];
char st[N];

int main() {
	scanf("%d%d",&n,&m);
	scanf("%s",st+1);
	k=1;for(;k<m&&st[k+1]==st[1];k++);
	if (k==m) {
		f[0]=s[0]=1;
		fo(i,1,n) {
			if (i>=2) f[i]=s[i-2];
			s[i]=(s[i-1]+f[i])%Mo;
		}
		int ans=1;
		fo(i,2,n) (ans+=(ll)i*f[n-i]%Mo)%=Mo;
		printf("%d\n",ans);
		return 0;
	}
	if (n&1) {puts("0");return 0;}
	int lim=k+1,now=0;
	for(k++;k<=m;k++) {
		if (st[k]==st[1]) now++;
		else {
			if (now&1) lim=min(lim,now);
			now=0;
		}
	}
	n>>=1;lim=(lim+1)>>1;
	f[0]=s[0]=1;
	fo(i,1,n) {
		f[i]=s[i-1];
		if (i-lim-1>=0) (f[i]+=Mo-s[i-lim-1])%=Mo;
		s[i]=(s[i-1]+f[i])%Mo;
	}
	int ans=0;
	fo(i,1,lim) (ans+=(ll)(i<<1)*f[n-i]%Mo)%=Mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1920
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

nn = inputs[0][0]
kk = inputs[0][1]

# body
if $debugFlag
end

puts nn-kk+1


Measured memory_bytes: 1788
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define mem(dp,a) memset(dp,a,sizeof dp);
#define all(a) a.begin(),a.end()
#define sall(a) sort(all(a))
#define X first
#define Y second
typedef int ll;
typedef pair<ll,ll> pp;

#define debug(x) cout << #x << " :: "<< x <<"\n";
#define debug2(x,y) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\n";
#define debug3(x,y,z) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\t" << #z << " :: " << z << "\n";
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree< pp , null_type,less< pp >, rb_tree_tag,tree_order_statistics_node_update>

ll power(ll b, ll exp){
    ll res = 1;
    while(exp > 0){
        if(exp % 2){
            res = 1LL * res * b % mod;
        }
        b = 1LL * b * b % mod;
        exp /= 2;
    }
    return res;
}

const ll N=1e6+1;
set<ll> p[N];
ll arr[N];

int main()
{
    boost
    ll n;
    for(ll i=1;i<N;i++)    {
        arr[i]=i;
    }
    for(ll i=2;i<N;i++)    {
        for(ll j=i;j<N;j+=i)    {
            while( (arr[j]%i)==0 )  {
                p[j].insert(i);
                arr[j]/=i;
            }
        }
    }
    cin >> n;
    vector<ll> a(n);
    map<ll,ll> ma;
    ll sc=0,g=a[0];
    for(ll i=0;i<n;i++) {
        cin >> a[i];
        for(auto num:p[a[i]])   {
            ma[num]++;
        }
        g=__gcd(g,a[i]);
    }
    bool pc=true;
    for(ll i=0;i<n;i++) {
        bool flag=true;
        for(auto num:p[a[i]])   {
            ma[num]--;
            if( ma[num]!=0 )    {
                flag=false;
                pc=false;
                break;
            }
        }
        if( !flag ) {
            break;
        }
    }
    if( pc )    {
        cout << "pairwise coprime";
        return 0;
    }
    if( g==1 )    {
        cout << "setwise coprime";
        return 0;
    }
    cout << "not coprime";
    return 0;
}


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

const int MAX = 10000;
const int INF = 1e9 + 7;

int n;
vector<pair<int, int> > adj[MAX];

void dijkstra()
{
  int d[MAX], color[MAX];
  priority_queue<pair<int, int> > pq;

  fill(d, d + MAX, INF);
  fill(color, color + MAX, 0);

  d[0] = 0;
  pq.push(make_pair(0, 0));
  color[0] = 1;

  while (!pq.empty()) {
    pair<int, int> f = pq.top();
    pq.pop();
    int u = f.second;
    color[u] = 2;

    if (d[u] < f.first * (-1)) continue;
    for (int j = 0; j < adj[u].size(); j++) {
      int v = adj[u][j].first;
      if (color[v] == 2) continue;
      if (d[v] > d[u] + adj[u][j].second) {
        d[v] = d[u] + adj[u][j].second;
        pq.push(make_pair(d[v] * (-1), v));
        color[v] = 1;
      }
    }
  }
  
  for (int i = 0; i < n; i++) {
    cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl;
  }
}

signed main()
{
  int u, k, c, v;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> v >> c;
      adj[u].push_back(make_pair(v, c));
    }
  }

  dijkstra();

  return (0);
}

Measured memory_bytes: 8056
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <math.h> // sqrt()
#include <iomanip>
#define rep(i , n) for (int i = 1; i <= (int)(n); i++)
#define repz(i , n) for (int i = 0; i < (int) n; i++)
#define repi(i , r, n) for (int i = r; i <= (int)(n); i++)
#define repd(i , r, n) for (int i = r; i >= (int)(n); i--)
 
 
using namespace std;
 
 
int main(){
    int n, m , a, b;
    cin >> n >> m;
    int amount[n+1];
    rep( i , n) amount[i] = 1;
    bool red[n+1];
    red[1] = 1;
    rep(i , m){
        cin >> a >> b;
        amount[a]--;
        amount[b]++;
        if ( red[a]) red[b] = 1;
        if ( amount[a] == 0) red[a] = 0;
        
        
    }
    int ans = 0;
    rep( i , n){
        if ( red[i] ) ans++;
    }
    
    cout << ans << endl;
    
    
}

Measured memory_bytes: 4064
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) ;
#define MOD 1000000007
#define int long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define ff first
#define ss second
#define INF (1LL<<61)

using namespace std;

int n ;
double p[3010];
double dp[3010][3010];

double solve(int i , int x) {

	if (x == 0)return 1;

	if (i == 0)return 0;

	if (dp[i][x] > -0.9)return dp[i][x];

	return dp[i][x] =  p[i] * solve(i - 1 , x - 1) + (1 - p[i]) * solve(i - 1 , x);

}

int32_t main() {

	fastio
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt","w", stdout);
// #endif

	memset(dp , -1, sizeof(dp));
	cin >> n;
	for (int i = 1 ; i <= n  ; i++)cin >> p[i];

	cout << fixed << setprecision(10) << solve( n , (n + 1) / 2) << '\n';

	return 0;
}


Measured memory_bytes: 74816
#include <iostream>
#include<bits/stdc++.h>
#include <vector>

using namespace std;

int main()
{
  
  string str;
  getline(cin,str);
  
  if(str[2]==str[3] && str[4]==str[5]){
  	
  	cout << "Yes";
  	
  }
  else{
  	cout << "No";
  }
}


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

int main() {
  int a=0,b=0,c=0,d=0,e=0;
  
  for(int i=1;i<=10000;i++){
  cin >> a;
    if(a==0){
      break;
    }
  cout << "Case" << ' ' << i << ": " << a << endl;
  }
  return 0;
}



Measured memory_bytes: 2996
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cstdlib>

using namespace std;

#define DEBUG 0

int parseInt2(int *now,string data){
	int nextPosition = data.find("]",*now);

	int returnNum = atoi(data.substr(*now,nextPosition-*now).c_str());
	if(DEBUG)cout<<"parseInt"<< atoi(data.substr(*now,nextPosition-*now).c_str())<<endl;
	if(DEBUG)cout<<"now="<<*now<<endl;
	if(DEBUG)cout<<"nextPosition="<<nextPosition<<endl;
	*now = nextPosition+1;
	return returnNum;
}


int main(){

	int n;
	cin>>n;
	int ans=0;

	for(int i=0;i<n;i++){

		string data;

		cin>>data;

		string nextData;
		nextData="";
		ans=0;
		int first=0;

		while(1){
			if(data.find_last_of("[")==0 && data.find_first_of("]")==data.size()-1){
				break;
			}
			for(int j=0;j<data.size();j++){
				if(data.at(j)==']'){
					nextData+="]";
				}else if(data.at(j)=='['&& data.at(j+1)=='['){
					nextData+="[";
				}else{
					j++;
					priority_queue<int, vector<int> , greater<int> > q;
					while(1){
						q.push(parseInt2(&j,data));
						if(data.at(j)==']'){
							break;
						}
						j++;
					}
					int pushNum=0;
					int nowSize = q.size();
					for(int k=0;k<nowSize/2+1;k++){
						if(first==0){
							if(DEBUG)cout<<"q.top()/2+1="<<q.top()/2+1<<endl;
							pushNum += q.top()/2+1;
							ans += q.top()/2+1;
							q.pop();
						}
						else{
							if(DEBUG)cout<<"q.top()="<<q.top()<<endl;
							pushNum += q.top();
							ans += q.top();
							q.pop();
						}
					}
					if(DEBUG)cout<<"pushNum="<<pushNum<<endl;
					nextData+=to_string(pushNum);
					j--;
				}
			}
			if(DEBUG)	cout<<"nextData =" <<nextData<<endl;
			data = nextData;
			nextData="";
			first++;
		}
		if(DEBUG)cout<<"ans0="<<data.substr(1,data.size()-2)<<endl;
		cout<<data.substr(1,data.size()-2)<<endl;
		if(DEBUG)cout<<endl;
	}


	return 0;


}

Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll k, a, b;
    cin >> k >> a >> b;


    if(k <= a){
        cout << k + 1 << endl;
        return 0;
    }else{
        if(b - a > 2){
            ll sum = (k - (a - 1)) / 2 * (b - a) + a;
            if((k - (a - 1)) % 2 == 1){
                sum++;
            }
            cout << sum << endl;
            return 0;
        }else{
            cout << k + 1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

	int n,x,t;
	int sum = 0;
	
	if (scanf("%d %d %d",&n,&x,&t) == 3)
	{
		sum = n / x;
		if (n % x > 0) sum += 1;
		sum *= t;
		printf("%d\n",sum);

	}
	
    
    return 0;

}


Measured memory_bytes: 1708
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE InstanceSigs #-}

import Control.Monad
import Data.List

inputChar :: String -> Char -> String
inputChar [] 'B' = []
inputChar s 'B' = init s
inputChar s c = s ++ [c]

main :: IO ()
main = do
    s <- getLine
    putStrLn $ foldl inputChar [] s

Measured memory_bytes: 380
#include<stdio.h>
#define MAX 10000
#define NIL -1
#define t 1

struct Node
{
  int p, q, r;
};

struct Node T[MAX];

int n,D[MAX],H[MAX];

int getdepth(int u){
  int d1=0;
  while(t){
    u = T[u].p;
    if(u == NIL){
      break;
    }
    d1++;
  }
  return d1;
}

int getsibling(int u)
{
  if(T[u].p == NIL) {
    return NIL;
  }
  if(T[T[u].p].q != u && T[T[u].p].q != NIL) {
    return T[T[u].p].q;
  }
  if(T[T[u].p].r != u && T[T[u].p].r != NIL){
    return T[T[u].p].r;
  }

  return NIL;
}

void print(int u)
{
  int d2=0;

  printf("node %d: parent = %d, sibling = %d,",u,T[u].p,getsibling(u));
  if( T[u].q != NIL ){
    d2++;
  }
  if( T[u].r != NIL ) {
    d2++;
  }
  printf(" degree = %d, depth = %d, height = %d, ", d2,D[u],H[u]);

  if( T[u].p == NIL ){
    printf("root");
    printf("\n");
  }
  else if( T[u].q == NIL && T[u].r == NIL){
    printf("leaf");
    printf("\n");
  }
  else{
    printf("internal node");
    printf("\n");
  }
}

int main()
{
  int i,v,q,r,p,C;

  scanf("%d", &n);
  for(i=0; i<n; i++){
    T[i].p = NIL;
  }

  for(i=0; i<n; i++){
    scanf("%d%d%d",&v,&q,&r);
    T[v].q = q;
    T[v].r = r;

    if(q != NIL){
      T[q].p = v;
    }
    if(r != NIL){
      T[r].p = v;
    }
  }

  for (i=0; i<n; i++){
    D[i] = getdepth(i);
    H[i] = 0;
  }

  for (i=0; i<n; i++){
    if(T[i].q == NIL && T[i].r == NIL){
      H[i] = 0;
      p = T[i].p;
      C = 1;

      while(t){
        if(p == NIL){
          break;
        }
        if(H[p] < C){
          H[p] = C;
        }
        C++;
        p = T[p].p;
      }
    }
  }

  for (i=0; i<n; i++){
    print(i);
  }

  return 0;
}


Measured memory_bytes: 2104
S_A = list(input())
S_B = list(input())
S_C = list(input())
flg = 'a'

while (len(S_A) > 0) or (len(S_B) > 0) or (len(S_C) > 0):
    if flg == 'a' and len(S_A) > 0:
        flg = S_A[0]
        S_A.remove(S_A[0])
    elif flg == 'b' and len(S_B) > 0:
        flg = S_B[0]
        S_B.remove(S_B[0])
    elif flg == 'c' and len(S_C) > 0:
        flg = S_C[0]
        S_C.remove(S_C[0])
    else:
        break

print(flg.upper())

Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
const ll BetsuMOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	string s;
	cin >> s;
	int n = s.size();
	deque<char> dq;
	rep(i, n) {
		dq.push_back(s[i]);
	}
	int ans = 0;
	while (!dq.empty()) {
		if (dq.size() == 1) break;
		if (dq.front() == dq.back()) {
			dq.pop_front();
			dq.pop_back();
		}
		else if (dq.front() == 'x' && dq.back() != 'x' || dq.back() == 'x' && dq.front() != 'x') {
			ans++;
			if (dq.front() == 'x') dq.pop_front();
			else dq.pop_back();
		}
		else {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using Pii = pair<int, int>;
using Vi = vector<int>;
using St = string;
using Ch = char;

const double pi = 3.1415926535;

void Main()
{
	int k;
	int seven = 7;
	cin >> k;
	rep(i, k) {
		seven %= k;
		if (seven == 0) {
			cout << i + 1 << endl;
			return;
		} else {
			seven = 10 * seven + 7; 
		}
	}
	cout << -1 << endl;
}

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

Measured memory_bytes: 3620
N = gets.to_i
num = gets.strip.split.map(&:to_i)
new = num.select {|n| n%2 == 0}
sum = 0
m = new.size
(0..m-1).each do |i|
  if new[i]%3 == 0 or new[i]%5 == 0 then
    sum += 1
  end
end
if sum == m then
  puts "APPROVED"
else
  puts "DENIED"
end

Measured memory_bytes: 14332
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <functional>
#include <set>
#include <numeric>
#include <queue>
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
#define PI 3.14159265358979323846264338327950

vector<int> to[100005];

int main() {
	ll N, X, T, num, ans=0;

	cin >> N >> X >> T;
	num = (N + X - 1) / X;
	ans = num*T;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5960
n,t = map(int,input().split())
ct = []
for i in range(n):
    ct.append(list(map(int,input().split())))
c = []
for i in ct:
    if i[1] <= t:
        c.append(i[0])
c == set(c)
if c == []:
    print('TLE')
else:
    print(min(c))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = (1<<18) + 20;
ll arr[maxn], n, k;
ll p[maxn];

ll cnt[maxn];

bool valid() {
    for(int i=1;i<=(1<<(n+1));i++) {
        if(arr[i] > maxn) return false;
        cnt[arr[i]]++;
    }

    for(int i=0;i<(1<<(n));i++) {
        if(cnt[i] != 2) return false;
    }
    return true;
}

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

    if(n == 0) {
        if(k == 0) {
            cout<<"0 0\n";
        }
        else {
            cout<<"-1\n";
        }
        return 0;
    }
    if(n == 1) {
        if(k == 0) {
            cout<<"0 0 1 1\n";
        }
        else {
            cout<<"-1\n";
        }
        return 0;
    }

    if(k >= (1<<n)) {
        cout<<"-1\n";
        return 0;
    }

    for(int i=0;i<(1<<n);i++) {
        if(i != k) {
            cout<<i<<" ";
        }
    } cout<<k<<" ";

    for(int i=(1<<n)-1;i>=0;i--) {
        if(i != k) {
            cout<<i<<" ";
        }
    } cout<<k<<"\n";

    return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    vector<char> u(N);
    for (int i=0; i<N; ++i) cin >> x[i] >> y[i] >> u[i];

    int ans = INF;
    for (int i=0; i<4; ++i) {
        // calc
        // 'U' and 'D'
        vector<pair<int, int>> us;
        vector<set<int>> v(200001);
        for (int j=0; j<N; ++j) {
            if (u[j] == 'D') v[x[j]].insert(y[j]);
            else if (u[j] == 'U') us.emplace_back(x[j], y[j]);
        }
        for (auto p : us) {
            auto iter = v[p.first].lower_bound(p.second);
            if (iter != v[p.first].end()) chmin(ans, (*iter - p.second) * 5);
        }
        // 'U' and 'R'
        vector<pair<int, int>> rs;
        vector<set<int>> vv(400001);
        for (int j=0; j<N; ++j) {
            if (u[j] == 'U') vv[x[j] + y[j]].insert(x[j]);
            else if (u[j] == 'R') rs.emplace_back(x[j], y[j]);
        }
        for (auto p : rs) {
            int add = p.first + p.second;
            auto iter = vv[add].lower_bound(p.first);
            if (iter != vv[add].end()) chmin(ans, (*iter - p.first) * 10);
        }
        // rotate
        for (int j=0; j<N; ++j) {
            y[j] *= -1;
            swap(x[j], y[j]);
            x[j] += 200000;
            if (u[j] == 'U') u[j] = 'L';
            else if (u[j] == 'L') u[j] ='D';
            else if (u[j] == 'D') u[j] = 'R';
            else u[j] = 'U';
        }
    }
    if (ans == INF) cout << "SAFE" << '\n';
    else cout << ans << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 44252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

public class Main {

    private static final int VIDEO_TAPE_TIME = 7200;

    public static void main(String[] args) {

        List<String> inputDataList = new LinkedList<String>();
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        // 入力データをリストにセット
        String inputData = null;
        try {
            while ((inputData = in.readLine()) != null) {
                inputDataList.add(inputData);
            }
        } catch (IOException e) {
            e.printStackTrace();
            return;
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
                return;
            }
        }

        for (String input : inputDataList) {
            if (!remainingTime(input)) {
                break;
            }
        }
    }

    private static boolean remainingTime(String inputTime) {
        String[] inputTimeArray = inputTime.split("\\s");
        int inputHour = Integer.parseInt(inputTimeArray[0]);
        int inputMinute = Integer.parseInt(inputTimeArray[1]);
        int inputSecond = Integer.parseInt(inputTimeArray[2]);

        // 入力値のどの値が負の数でも不整合なデータとなるため、
        // 負の数が入った時点で終了とみなす。
        if (inputHour < 0 || inputMinute < 0 || inputSecond < 0) {
            return false;
        }

        int useTime = (inputHour * 60 + inputMinute) * 60 + inputSecond;

        int notUseTime = VIDEO_TAPE_TIME - useTime;

        // 標準録画の残量表示
        printremainingTime(notUseTime);

        // 3倍録画の残量表示
        printremainingTime(notUseTime * 3);

        return true;
    }

    private static void printremainingTime(int notUseTime) {
        int second = notUseTime % 60;
        int minute = notUseTime / 60 % 60;
        int hour = notUseTime / 3600;

        StringBuilder input = new StringBuilder();

        input.append(0).append(hour).append(":");

        if (minute < 10) {
            input.append(0);
        }

        input.append(minute).append(":");

        if (second < 10) {
            input.append(0);
        }

        input.append(second);

        System.out.println(input.toString());
    }

}

Measured memory_bytes: 16920
N, T, E = map(int, input().split())
x = [int(x) for x in input().split()]
Time = list(range(T-E,T+E+1,1))

time = []
for i in range(N):
    t = []
    for j in range(len(Time)):
        if Time[j]%x[i]==0:
            t.append(1)
    if 1 in t:
        time.append(1)
    else:
        time.append(0)

if sum(time)==0:
    print(-1)
else:
    index = time.index(1)
    print(index+1)


Measured memory_bytes: 5624
import java.util.Scanner;
public class Main {

    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	// 入力
    	int n = sc.nextInt();
    	String ans = "No";

    	for(int i = 1; i <=  9; i++){
    		for(int k = 1; k <= 9; k++){
    			if (n == i * k){
    				ans = "Yes";
    				break;
    			}
    		}
    	}


    	// 出力
    	System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#!/usr/bin/env python3

# from numba import njit

# from collections import Counter
# from itertools import accumulate
# import numpy as np
# from heapq import heappop,heappush
# from bisect import bisect_left

# @njit
def solve(n,l):
  l = sorted(l,key=lambda x: x[1])
  consumedTime = 0
  flag = True
  for i in range(n):
    if not flag:
      break
    consumedTime += l[i][0]
    if consumedTime > l[i][1]:
      flag = False
  return flag



def main():
  N = int(input())
  # N,M = map(int,input().split())
  l = [tuple(map(int,input().split())) for _ in range(N)]
  print("Yes" if solve(N,l) else "No")
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 39036
#include<bits/stdc++.h>
using ll= long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (ll)1e9 //10^9:∞
#define LLINF (ll)1e12
#define MOD (ll)(1e9+7) //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	ll N;
	cin>>N;
	cout<<N*(N-1)/2<<endl;;

	
		return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

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

bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int fiv(int n){
  if(n==0){
    return 0;
  }
  else if(n==1){
    return 1;
  }
  return fiv(n-1)+fiv(n-2);
}
ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}
int main(){
  int n,m;
  cin>>n>>m;
  vvi s(10,vi(11));
  
  rep(i,m){
    
    cin >>s[i][0];
    for(int j=1; j<=s[i][0];j++){
      
      cin>>s[i][j];
    }
  }
  vi p(m);
 
  rep(i,m){
    cin >> p[i];
  }
  int ans=0;
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    
    bitset<11> light(tmp);
     
    bool res =true;
    rep(i,m){
      int c =0;
      for(int j=1; j <= s[i][0] ; j++){
        
        if(light.test(s[i][j]-1)){
          c ++;
        }
      }//onのスイッチの数
      if(c%2 != p[i]) res=false;
    }
    
    if(res) ans++;
  }
  cout <<ans <<endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n,h,hm=0; cin >> n;
  int ans=0;
  REP(i,n) {
    cin >> h;
    if (hm <= h) ans++;
    chmax(hm,h);
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n,k; cin>>n>>k;
  vector<ll> a(n);
  rep(i,n) cin >>a[i];
  map<ll,ll> mp;
  mp[0]++;
  ll key=0;
  ll time=0;
  ll loop=0;
  vector<ll> vec;
  vector<ll> vec0;
  vec0.push_back(0);
  rep(i,2*n+10){
    mp[a[key]-1]++;
    if(mp[a[key]-1]==1){
    time++;
    vec0.push_back(a[key]);
    }
    if(mp[a[key]-1]==2) {
    loop++;
    vec.push_back(a[key]);
    }
    key=a[key]-1;
  }
  if(k>time&&(k-time)%loop!=0)cout <<vec[(k-time)%loop-1]<<endl;
  else if(k>time&&(k-time)%loop==0)cout <<vec[loop-1]<<endl;
  else cout <<vec0[k]<<endl;
}

Measured memory_bytes: 20716
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<complex>
#include<numeric>
#include<bitset>
#define INF 1001001001
#define EPS 0.000001

using namespace std;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int,int> pint;

int memo[1000000];

int main(){
	int i,j;
	for(i=2;i<1000000;i++) memo[i]=1;
	for(i=2;i<1000;i++){
		if(memo[i]==1){
			for(j=i;i*j<1000000;j++) memo[i*j]=0;
		}
	}
	for(i=1;i<1000000;i++) memo[i]+=memo[i-1];
	int n;
	while(cin >> n) cout << memo[n] << endl;
	return 0;
}

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

int main(){
    long long N, K, Q;
    cin >> N >> K >> Q;

    vector<int> A(Q);

    for(int i=0; i<Q; i++){
        cin >> A.at(i);
    }

    vector<int> R(N,K-Q);

    for(int i = 0; i < Q; i++){
        R.at(A.at(i)-1) ++;
    }

    for(int i = 0; i < N; i++){
        if(R.at(i) < 1)cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

Measured memory_bytes: 1408
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

tt = inputs[1][0]
aa = inputs[1][1]
lst = inputs[2]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
  p tt
  p aa
  p lst
end

ans = nil
idx = nil
lst.size.times do |i|
  x = (tt - 0.006*lst[i] - aa).abs
  if ans == nil
    ans = x
    idx = i
  elsif x < ans
    ans = x
    idx = i
  end
end
puts idx+1


Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        Dice dice = new Dice(str);
        int n = Integer.parseInt(br.readLine());
        StringBuilder sb = new StringBuilder();
        String str2[];
        int i,j=0;
        while(n-->0){
            str2 = br.readLine().split(" ");
            for(i=0;i<6;i++){
                if(dice.getStr(i).equals(str2[0])) break;
            }
            switch(i){
                case 0:
                    break;
                case 1:
                    dice.moveN();
                    break;
                case 2:
                    dice.moveW();
                    break;
                case 3:
                    dice.moveE();
                    break;
                case 4:
                    dice.moveS();
                    break;
                case 5:
                    dice.moveN();
                    dice.moveN();
                    break;
            }
            for(i=1;i<5;i++){
                if(dice.getStr(i).equals(str2[1])) break;
            }
            switch(i){
                case 1:
                    j = 2;
                    break;
                case 2:
                    j = 4;
                    break;
                case 3:
                    j = 1;
                    break;
                case 4:
                    j = 3;
                    break;
                default:
                    break;
            }    
            sb.append(dice.getStr(j)).append("\n");
        }
        System.out.print(sb);
    }
}
 
class Dice{
    private String str[];//0=???,1=???,2=???,3=???,4=??????,5=???
    private String tmp;
     
    Dice(String str) {
        this.str = new String[6];
        this.str = str.split(" ");
    }
     
    public String getStr(int n){
        return this.str[n];
    }
     
    void moveW(){
        tmp = this.str[0];
        this.str[0] = this.str[2];
        this.str[2] = this.str[5];
        this.str[5] = this.str[3];
        this.str[3] = tmp;
    }
     
    void moveE(){
        tmp = this.str[0];
        this.str[0] = this.str[3];
        this.str[3] = this.str[5];
        this.str[5] = this.str[2];
        this.str[2] = tmp;
    }
     
    void moveS(){
        tmp = this.str[0];
        this.str[0] = this.str[4];
        this.str[4] = this.str[5];
        this.str[5] = this.str[1];
        this.str[1] = tmp;
    }
     
    void moveN(){
        tmp = this.str[0];
        this.str[0] = this.str[1];
        this.str[1] = this.str[5];
        this.str[5] = this.str[4];
        this.str[4] = tmp;
    }
}


Measured memory_bytes: 24216
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(l,k,h) for(int l = k; l <= h; ++l)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;


int main() {
    int n;
    cin >> n;
    int ans = -n,a;
    rep(i,n) {
        cin >> a;
        ans += a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(N, K - Q);
  for(int i = 0; i < Q; i++){
    int x;
    cin >> x;
    A[x - 1]++;
  }
  for(int i = 0; i < N; i++) {
    if( A[i] > 0 ){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

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

using namespace std;

int main(){
	vector<int> cards;
	vector<int> shuffuleCards;
	vector<int> ::iterator cardsIterator;
	vector<int> ::iterator shuffuleIterator;
	int n,r,p,c;

	while(cin >> n >> r, n && r){
		cards.clear(); //?????????
		// ?????????????±±??????
		for (int i = 0; i < n; ++i){
			cards.push_back(i+1);
		}
		// ?????£?????????
		while(cin >> p >> c, r--){
			cardsIterator = cards.end();
			cardsIterator -= p + (c - 1);
			while(c--){
				cards.push_back(*cardsIterator);
				cards.erase(cardsIterator);
			}
			if (r == 0){
				break;
			}
		}
		// ???????????????????????¨???
		cout << cards.back() << endl;
	}
}

Measured memory_bytes: 1220
def main():
    S = input()[::-1]
    ans = 0
    mods = [0] * 2019
    mods[0] = 1
    current = 0
    x = 1
    for s in S:
        current = (current + x * int(s)) % 2019
        ans += mods[current % 2019]
        mods[current % 2019] += 1
        x = x * 10 % 2019
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 68516
use std::io::*;
use std::str::FromStr;

fn main() {
    let m: usize = read();
    let d: usize = read();
    
    let mut ans = 0;
    for i in 2..10 {
        for j in 2..10 {
            if i * 10 + j <= d && i * j <= m {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
    fastio();
    int n;cin>>n;
    int dp[n+1][3]={};
    int a,b,c;
    for(int i=1;i<=n;i++)
    {
        cin>>a>>b>>c;
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
    return 0;
}    

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
#define guard(x) if( not ( x ) ) continue;
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename T>
struct Maybe {
   T x;
   bool valid;
   Maybe() : valid(false) {}
   Maybe(T x_) : x(x_), valid(true) {}
   operator T() const {
      assert( valid );
      return x;
   }
};

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      std::string ss; scan(ss);
      Int xs[4];
      for(Int i = 0; i < 4; ++i) {
         xs[i] = ss[i] - '0';
      }
      if( xs[0] + xs[1] + xs[2] + xs[3] == 7 ) {
         printf("%ld+%ld+%ld+%ld=7\n", xs[0], xs[1], xs[2], xs[3]);
         return;
      }
      if( xs[0] + xs[1] + xs[2] - xs[3] == 7 ) {
         printf("%ld+%ld+%ld-%ld=7\n", xs[0], xs[1], xs[2], xs[3]);
         return;
      }
      if( xs[0] + xs[1] - xs[2] + xs[3] == 7 ) {
         printf("%ld+%ld-%ld+%ld=7\n", xs[0], xs[1], xs[2], xs[3]);
         return;
      }
      if( xs[0] + xs[1] - xs[2] - xs[3] == 7 ) {
         printf("%ld+%ld-%ld-%ld=7\n", xs[0], xs[1], xs[2], xs[3]);
         return;
      }
      if( xs[0] - xs[1] + xs[2] + xs[3] == 7 ) {
         printf("%ld-%ld+%ld+%ld=7\n", xs[0], xs[1], xs[2], xs[3]);
         return;
      }
      if( xs[0] - xs[1] + xs[2] - xs[3] == 7 ) {
         printf("%ld-%ld+%ld-%ld=7\n", xs[0], xs[1], xs[2], xs[3]);
         return;
      }
      if( xs[0] - xs[1] - xs[2] + xs[3] == 7 ) {
         printf("%ld-%ld-%ld+%ld=7\n", xs[0], xs[1], xs[2], xs[3]);
         return;
      }
      if( xs[0] - xs[1] - xs[2] - xs[3] == 7 ) {
         printf("%ld-%ld-%ld-%ld=7\n", xs[0], xs[1], xs[2], xs[3]);
         return;
      }
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 256