akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define repU(i,s,t) for(int i = (s); i <= (t); ++i)
#define repD(i,t,s) for(int i = (t); i >= (s); --i)
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) (((a)^(b)) & 1 ^ 1)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = 1e9 + 7;

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}

int main(){
	string s;
	cin>>s;
	if(s.size() == 26){
		int i = 25;
		char m = s[25];
		while(i > 0 && s[i - 1] > s[i]) --i;
		if(!i) cout<<-1<<endl;
		else{
			int j = i;
			while(j < 25 && s[j + 1] > s[i - 1]) ++j;
			rep(k,i - 1) cout<<s[k];
			cout<<s[j]<<endl;
		}
	}
	else{
		bool b[26] = {};
		for(char c : s) b[c - 'a'] = 1;
		int i = 0;
		while(b[i]) ++i;
		cout<< s + (char)(i + 'a')<<endl;
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int n,i,cnt,p[20];
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&p[i]);
	cnt=0;
	for(i=1;i<n-1;i++)	{
		if((p[i-1]<p[i] && p[i]<p[i+1]) ||
			(p[i-1]>p[i] && p[i]>p[i+1]))	cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    vector<int> Rs(1);

    if (S[0] == '1')
        Rs[0] = 0;
    else
        Rs.push_back(0);

    int before = (int)S[0];

    rep(i, N) {
        int s = (int)S[i];
        if (s != before) {
            Rs.push_back(0);
        }
        Rs[Rs.size() - 1]++;
        before = s;
    }
    if (S.back() == '0') Rs.push_back(0);

    vector<int> sums(Rs.size() + 1, 0);
    rep(i, Rs.size()) sums[i + 1] = sums[i] + Rs[i];

    int mx = 0;
    for (int i = 2 * K + 1; i < sums.size(); i += 2) {
        mx = max(mx, sums[i] - sums[i - 2 * K - 1]);
    }
    if (2 * K + 1 >= sums.size()) {
        mx = sums[sums.size() - 1];
    }

    cout << mx << endl;
}

Measured memory_bytes: 1272
#include <stdio.h>

int stair(int x) {

  if(x==1) return 1;

  else if(x==2) return 2;

  else if(x==3) return 4;

  else return stair(x-1)+stair(x-2)+stair(x-3);

}

int main(void) {

  int n;

  int step;
  int day,year;


  while(1) {

    scanf("%d",&n);

    if(n==0) break;

    step=stair(n);

    if(step%10==0) day=step/10;

    else day=step/10+1;

    if(day%365==0) year=day/365;

    else year=day/365+1;

    printf("%d\n",year);

  }

  return 0;

}

Measured memory_bytes: 756
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
const int INF = 0x7fffffff;

int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}
struct Edge{
  int parent;
  int depth;
  vector<int> nodes;
};

int getDepth(int id,vector<Edge>* edges){

  int depth=0;
  int parent;
  while(id != -1){
    id = edges->at(id).parent;
    depth++;
  }
  return depth;
}

int main(){
  long ii,jj,kk;
  vector<int> a;
  int n;
  cin >> n;
  vector<Edge> edges;
  edges.resize(n);

  for(ii=0;ii<n;ii++){
    edges[ii].parent = -1;
    edges[ii].depth =  0;
  }
  
  int id,k;
  int tmp,child,parent;
  for(ii=0;ii<n;ii++){
    cin >> id >> k;
    edges[id].nodes.resize(k);

    //子供の分、回す
    for(jj=0;jj<k;jj++){
      //子供
      cin >> edges[id].nodes[jj] ;
      //tmp = edges[edges[id].nodes[jj]].parent;
      //親の設定
      edges[edges[id].nodes[jj]].parent = id;
      //深さの設定
      edges[edges[id].nodes[jj]].depth = edges[id].depth + 1;
    }
    
    //自分が親
    //if(edges[id].parent == -1){
    //  for(jj=0;jj<edges[id].nodes.size();jj++){
    //    for(kk=0;kk<edges[edges[id].
    //  }
    //}    
  }
  int depth;
  for(ii=0;ii<n;ii++){
    depth = getDepth(edges[ii].parent,&edges);
    cout << "node " << ii << ": parent = " << edges[ii].parent << ", depth = " << depth << ", ";

    if(edges[ii].parent == -1){
      cout << "root,";
    }
    else if(edges[ii].nodes.size() == 0){
      cout << "leaf,";
    }
    else{
      cout << "internal node,";
    }

    cout << " [";

    for(jj=0;jj<edges[ii].nodes.size();jj++){
      cout << edges[ii].nodes[jj] ;

      if(jj != edges[ii].nodes.size() -1){
        cout << ", ";
      }
    }
    
    cout << "]" << endl;
      
  }
  
  return 0;
}



Measured memory_bytes: 6404
#include <stdio.h>

int main(void){
	int H;
	int W = 301;
	do {
		if (W <= 300) {
			for (int h = 1; h <= H; h++) {
				for (int w = 1; w <= W; w++) {
					if (h == 1 || h == H || w == 1 || w == W) {
						printf("#");
					} else {
						printf(".");
					}
					
				}
				printf("\n");
			}
			printf("\n");
		}
		scanf("%d %d", &H, &W);
	} while (H > 0 && W > 0);
	
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


bool check(string s){
  ll n=s.size();
  bool flag = true;
  for(ll i=0; i<n/2; i++){
    if(s[i]!=s[n-1-i])
      flag=false;
  }

  return flag;
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s;
  cin>>s;

  ll n=s.size();
  ll ans = check(s);
  if(!check(s.substr(0,n/2)))
    ans=false;


  if(!check(s.substr((n+3)/2-1)))
    ans=false;


  if(ans)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}



Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};

int N;

int main()
{
  while(cin >>N,N){
  N =1000-N;
  int ans = 0;
  int c[6] ={500,100,50,10,5,1};
  for(int i =0;i < 6;i++){
   while(N/c[i]){
      ans++;
      N -=c[i];
    }
  }
  cout <<ans<<endl;
  }
  return 0;
}

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

int main () {
  string S;
  cin >> S;
  const int num = S.size();

  string T;

  for (int64_t tmp = 0; tmp < (1 << 3); tmp++) {

    bitset<3> b(tmp);

    int sum = S.at(0)-'0';
    T = "";
    for (int i = 0; i < 3; i++) {

      if(b.test(0)){
        sum += S.at(i+1)-'0';
		T += "+";
      }else{
        sum -= S.at(i+1)-'0';
      	T += "-";
      }
      b = b >> 1;
      
    }

    if(sum == 7)
      break;
  }
  

  
  for (int i = 0; i < 3; i++) {
   cout << S.at(i) << T.at(i); 
  }
  cout << S.at(3) << "=7" << endl; 

  

}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }

int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < (int)N; ++i) cin >> A[i] >> B[i];

  vector<vector<ll>> dp(N + 1, vector<ll>(2e4 + 1, 1e15));
  dp[0][0] = 0;

  for (int i = 0; i < (int)N; ++i) for (int j = 0; j < (int)2e4 + 1; ++j) {
    chmin(dp[i + 1][j], dp[i][j]);
    if (j - A[i] >= 0) chmin(dp[i + 1][j], dp[i + 1][j - A[i]] + B[i]);
  }

  ll ans = 1e15;
  for (int h = H; h <= 2e4; ++h) chmin(ans, dp[N][h]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 160640
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int min(int x,int y){
    if(x<y)return x;
    return y;
}
int cost(int h[],int i,int j){
    if(h[i]-h[j]>0)return h[i]-h[j];
    return h[j]-h[i];
}
int main()
{
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++)cin>>h[i];
    int result[n];
    result[0]=0;
    result[1]=h[1]-h[0];
    if(result[1]<0)result[1]=-result[1];
    for(int i=2;i<n;i++){
        result[i]=min(result[i-1]+cost(h,i-1,i),result[i-2]+cost(h,i-2,i));
    }
    cout<<result[n-1]<<"\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define print(x) cout << (x) << '\n'
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(__null);
    
    string s; cin >> s;
 
    int m = 10000;
 
    for (int i = 0; i < (int) s.size() - 2; ++i) {
        int temp = (int) stoi(s.substr(i, 3));
        int tt = abs(temp - 753);
        m = min(m, tt);
    }
    print(m);
 
    return 0;
}

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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << (abs(a - c) <= d || (abs(c - b) <= d && abs(b - a) <= d) ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int h, w;
	cin >> h >> w;

	vector<string> v(h);
	rep(i, h) cin >> v[i];

	char grid[h+2][w+2];
	rep(i, h+2) rep(j, w+2) grid[i][j] = '.';

	rep(i, h) rep(j, w) grid[i+1][j+1] = v[i][j];

	vector<string> ans(h);

	rep(i, h) rep(j, w){
		if(grid[i+1][j+1] == '#'){
			ans[i].push_back('#');
		}else{
			int cnt = 0;
			for(int k = -1; k <= 1; k++){
				for(int l = -1; l <= 1; l++){
					if(k == 0 && l == 0) continue;
					if(grid[i+k+1][j+l+1] == '#') cnt++;
				}
			}
			ans[i].push_back('0' + cnt);
		}
	}

	rep(i, h) cout << ans[i] << endl;

}


Measured memory_bytes: 256
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));

		int n = Integer.parseInt(br.readLine());

		int a[] = new int[n];
		int b[] = new int[n];
		int c[] = new int[n - 1];

		String str[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(str[i]);
		}

		str = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(str[i]);
		}

		str = br.readLine().split(" ");
		for (int i = 0; i < n - 1; i++) {
			c[i] = Integer.parseInt(str[i]);
		}

		int ans = b[a[0] - 1];
		for (int i = 1; i < n; i++) {
			ans += b[a[i] - 1];

			if (a[i - 1] + 1 == a[i]) {
				ans += c[a[i - 1] - 1];
			}
		}

		System.out.println(ans);
	}
}

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

using namespace std;

const int maxn = 110;
const int maxk = 100010;

int n, k;
int a[maxn];
int dp[maxk];

int main(){
	cin >> n >> k;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}

	dp[0] = 1;
	for (int i = 1; i <= k; i++){
		dp[i] = 1;
		for (int j = 0; j < n; j++){
			if (a[j] <= i && dp[i-a[j]] == 1){
				dp[i] = 0;
			}
		}
	}
	if (dp[k] == 0){
		cout << "First" << endl;
	}
	else {
		cout << "Second" << endl;
	}
	return 0;
}


Measured memory_bytes: 640
x,n=map(int,input().split())

if n==0:
    print(x)
else:
    p=list(map(int,input().split()))

    num=[1]*102
    count=1

    for i in p:
        num[i]=0   
    if num[x]==1:
        print(x)
    else:
        while True:
            if x-count>-1:
                if num[x-count]==1:
                    print(x-count)
                    break
            if x+count<103:
                if num[x+count]==1:
                    print(x+count)
                    break    
            count+=1

Measured memory_bytes: 9212
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
#define MOD (LL)(1e9+7)

string S, T;
int main(){
	cin >> S >> T;
	vector<int> p[26];
	for(int i=0; i<S.size(); i++){
		p[S[i]-'a'].PB(i);
	}
	LL idx = -1;
	LL ans = 0;
	for(int i=0; i<T.size() && ans<T.size()+5; i++){
		if(upper_bound(p[T[i]-'a'].begin(), p[T[i]-'a'].end(), idx) == p[T[i]-'a'].end()){
			i--;
			ans++;
			idx = -1;
		}
		else{
			idx = *upper_bound(p[T[i]-'a'].begin(), p[T[i]-'a'].end(), idx);
		}
		//cout << ans << " " << idx << endl;
	}

	if(ans > T.size()) cout << -1 << endl;
	else cout << ans*S.size()+idx+1 << endl;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
int main() 
{ 
	SPEED
    int n, heros_left, temp;
    cin >> n;
    int arr[n+1];
    int brr[n];
    ll ans = 0;
    for (int i = 0; i < n+1; ++i)
        cin >> arr[i];
    for (int i = 0; i < n; ++i)
        cin >> brr[i];
    for (int i = 0; i < n; ++i)
    {
        if (arr[i]<=brr[i])
        {
            heros_left = brr[i] - arr[i];
            ans += arr[i];
            ans += min(heros_left, arr[i+1]);
            arr[i+1] = arr[i+1] - min(heros_left, arr[i+1]);
        }
        else
        {
            ans += brr[i];
        }
    }
    cout << ans;
    return 0;      
} 

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
int n,i,A[1000000],tmp,k,cnt=0,j,m=0,h=1;

// InsersionSort
void insersionSort(int A[], int n, int g){
  for(i=g;i<=n-1;i++){
    tmp=A[i];
    k=i-g;
    while(k>=0&&A[k]>tmp){
      A[k+g]=A[k];
      k=k-g;
      cnt++;
    }
    A[k+g]=tmp;
  }
}

// ShellSort
void shellSort(int A[], int n){
  int *G=(int *)malloc(sizeof(int)*n);
  while(h<=n){
    G[m]=h;
    h=h*3+1;
    m++;
  }
  for(j=m-1;j>=0;j--){
    insersionSort(A, n, G[j]);
  }
  printf("%d\n",m);
  for(i=m-1;i>=0;i--){
    if(i<m-1)printf(" ");
    printf("%d",G[i]);
  }
  free(G);
}

int main(){
  scanf("%d", &n);
  for(i=0;i<=n-1;i++)scanf("%d",&A[i]);
  shellSort(A, n);
  printf("\n");
  printf("%d\n",cnt);
  for(i=0;i<=n-1;i++)printf("%d\n",A[i]);
  return 0;
}

Measured memory_bytes: 4508
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;

const int INF = 1001001001;

int main() {
  int n, m, l;
  cin >> n >> m >> l;
  vector<vector<int>> dist(n, vector<int>(n,INF));
  rep(i,n) dist[i][i] = 0;
  rep(i,m) {
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    dist[a][b] = dist[b][a] = c;
  }
  rep(k,n)rep(i,n)rep(j,n) chmin(dist[i][j], dist[i][k]+dist[k][j]);
  vector<vector<int>> dist2(n, vector<int>(n,INF));
  rep(i,n)rep(j,n) {
    if (dist[i][j] <= l) dist2[i][j] = 1;
  }
  rep(k,n)rep(i,n)rep(j,n) chmin(dist2[i][j], dist2[i][k]+dist2[k][j]);
  int q;
  cin >> q;
  rep(qi,q) {
    int s, t;
    cin >> s >> t;
    --s; --t;
    int ans = dist2[s][t]-1;
    if (dist2[s][t] == INF) ans = -1;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

vector<int> a;
vector<int> b;
vector<int> c;
int dp[100001][4];

int solve(int n, int prev){
	if(dp[n][prev] > -1){
		return dp[n][prev];
	}
	if(n == 0){
		int maximum = INT_MIN;
		if(1 != prev){
			maximum = max(a[n], maximum);
		}
		if(2 != prev){
			maximum = max(b[n], maximum);
		}
		if(3 != prev){
			maximum = max(c[n], maximum);
		}
		return dp[n][prev] = maximum;
	}
	else{
		int maximum = INT_MIN;
		if(prev != 1){
			maximum = max(solve(n-1, 1) + a[n], maximum);
		}
		if(prev != 2){
			maximum = max(solve(n-1, 2) + b[n], maximum);
		}
		if(prev != 3){
			maximum = max(solve(n-1, 3) + c[n], maximum);
		}
		return dp[n][prev] = maximum;
	}
}
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int n;
  	cin >> n;
  	a.resize(n);
  	b.resize(n);
  	c.resize(n);
  	for(int i = 0; i < n; i++){
  		int ai, bi, ci;
  		cin >> ai >> bi >> ci;
  		a[i] = ai;
  		b[i] = bi;
  		c[i] = ci;
  	}
  	reverse(a.begin(), a.end());
  	reverse(b.begin(), b.end());
  	reverse(c.begin(), c.end());
  	for(int i = 0; i < 100001; i++){
  		for(int j = 0; j < 4; j++){
  			dp[i][j] = -1;
  		}
  	}
  	cout << solve(n-1, 0) << endl;

	return 0;
}


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

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


Measured memory_bytes: 256
using System;

namespace ABC106_D___AtCoder_Express_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var NMQ = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NMQ[0]; var M = NMQ[1]; var Q = NMQ[2];
            var connection = new int[N + 1, N + 1];
            for (int i = 0; i < M; i++)
            {
                var LR = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                connection[LR[0], LR[1]]++;
            }
            var accum = new int[N + 1, N + 1];
            for (int l = 0; l < N; l++)
            {
                for (int r = 0; r < N; r++)
                {
                    accum[l + 1, r + 1] = accum[l + 1, r] + accum[l, r + 1] - accum[l, r] + connection[l + 1, r + 1];
                }
            }

            for (int i = 0; i < Q; i++)
            {
                var pq = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                var p = pq[0]; var q = pq[1];
                var result = accum[q, q] - accum[p - 1, q] - accum[q, p - 1] + accum[p - 1, p - 1];
                Console.WriteLine(result);
            }
        }
    }
}


Measured memory_bytes: 17548
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  string s;
  cin>>a>>b>>s;
  int len = a+b+1;
  for (int i = 0; i < len; i++) {
    if(i==a){
      if(s[i]!='-'){
        cout<<"No";
        return 0;
      }
    }
    else{
      if(s[i]=='-'){
        cout<<"No";
        return 0;
      }
    }
  }
  cout<<"Yes";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define simplify ios_base::sync_with_stdio(0);cin.tie(0);
#define int long long
#define endl "\n"
using namespace std;

const int mod=998244353;
const int N=2e5+5;

int fact[N];
int invFact[N];

int inverseMod(int x,int mod);
void precompute(){
    fact[0]=fact[1]=1;

    for(int i=2;i<N;i++){
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
    }
    invFact[N-1]=inverseMod(fact[N-1],mod);

    for(int i=N-2;i>=0;i--){
        invFact[i]=invFact[i+1]*(i+1);
        invFact[i]%=mod;
    }
}
int NCR(int n,int r){

    if(r>n)return 0;
    int num=fact[n];
    num*=invFact[r];
    num%=mod;
    num*=invFact[n-r];
    num%=mod;
    return num;
}



int power(int x,int n,int mod){
//(x^n)%mod
    int result=1;
    while(n){
        if(n%2)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return result;
}

int inverseMod(int x,int mod){

return power(x,mod-2,mod);
}




int32_t main(){

    simplify
    int n,m,k;
    cin>>n>>m>>k;
    precompute();
    int ans=0;
    int other;
    for(int i=0;i<=k;i++){
        other=m*power(m-1,n-1-i,mod);
        other%=mod;
        other=other*NCR(n-1,i);
        other%=mod;
        ans+=other;
        ans%=mod;
    }
    cout<<ans;




    
    return 0;
}








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

int main(void)
{
	char A[100] = { 0 };
	char B[100] = { 0 };
	char C[100] = { 0 };
	int i;
	int count_a = 0;
	int count_b = 0;
	int count_c = 0;
	int turn = 0;
	int n_a = 0;
	int n_b = 0;
	int n_c = 0;

	scanf("%s\n%s\n%s", A, B, C);
	n_a = strlen(A);
	n_b = strlen(B);
	n_c = strlen(C);

	for (i = 0;i < 300;i++)
	{
		if (turn == 0 && (n_a != count_a))
		{
			turn = A[count_a] - 'a';
			count_a = count_a + 1;
		}
		else if (turn == 0 && (n_a == count_a))
		{
			printf("A");
			break;
		}
		else if (turn == 1 && (n_b != count_b))
		{
			turn = B[count_b] - 'a';
			count_b = count_b + 1;
		}
		else if (turn == 1 && (n_b == count_b))
		{
			printf("B");
			break;
		}
		else if (turn == 2 && (n_c != count_c))
		{
			turn = C[count_c] - 'a';
			count_c = count_c + 1;
		}
		else if (turn == 2 && (n_c == count_c))
		{
			printf("C");
			break;
		}
	}

}

Measured memory_bytes: 1660
//
// Created by sark2 on 22-10-2019.
//

#include "bits/stdc++.h"

using namespace std;
#define PB push_back
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define CASES int t;cin>>t;while(t--)
#define MP make_pair

using ll = long long;
using ld = long double;

ll mod = 1e9 + 7;

unsigned int n;
int m;

const int INF = 1e5+10;

int main() {
    IOS

    cin>>n>>m;

    vector<int>dp((1<<n), INF);

    for(int i = 0; i < m; i++){
        int a, b;
        cin>>a>>b;
        unsigned int x = 0;
        for(int j = 0; j < b; j++){
            int r; cin>>r;
            x ^= (1<<(r-1));
        }
        dp[x] = min(dp[x], a);
    }


    for(int i = 0; i < (1<<n)-2; i++){
        for(int j = i+1; j < (1<<n)-1; j++){
            dp[(i|j)] = min(dp[(i|j)], dp[i] + dp[j]);
        }
    }

    cout<<(dp[(1<<n)-1] == INF ? -1 : dp[(1<<n)-1]);






}


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

#define INF 1e9
using namespace std;

int main() {

    string S; cin >> S;

    int a;
    a = (S[0] - '0') * 10 + S[1] - '0';

    int b;
    b = (S[2] - '0') * 10 + S[3] - '0';

    if (1 <= a && a <= 12 && 1 <= b && b <= 12) {
        cout << "AMBIGUOUS" << endl;
        return 0;
    }

    if (1 <= a && a <= 12) {
        cout << "MMYY" << endl;
        return 0;
    }

    if (1 <= b && b <= 12) {
        cout << "YYMM" << endl;
        return 0;
    }

    cout << "NA" << endl;
}

Measured memory_bytes: 256
N = int(input())
H = list(int(x) for x in input().split())
max = H[0]
ans = True

for i in range(N):
    if max < H[i]:
        max = H[i]
    elif max - 2 >= H[i]:
        ans = False
        break

if ans:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14396
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;


void sieve(vector<bool>& IsPrime,ll max){
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない
    for(ll i=2; i*i<=max; ++i){ // 0からsqrt(max)まで調べる
        // cout<<"a"<<endl;
        // cout<<i<<endl;
        if(IsPrime[i]){
         // iが素数ならば
            for(ll j=2; i*j<=max; ++j){
                 // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
            }
        }
    }
    // cout<<"aa"<<endl;
}

ll ipow(ll a, ll b){
    ll res = 1;
    while(b >= 1){
        if(b % 2 == 1)res*=a;
        b/=2;
        a*=a;
    }
    return res;
}

ll f(vector<int>& primes, ll pi, vector<int>& pnums, ll curint, ll curf, ll N){
    if(pi == primes.size()){
        return curint * curf;
    }
    if(curint * primes[pi] > N){
        return f(primes,primes.size(),pnums,curint,curf,N);
    }
    ll res = 0;
    for(ll i = 0; ipow(primes[pi],i)*curint<=N;i++){
        pnums[pi] = i;
        res += f(primes,pi+1,pnums,curint * ipow(primes[pi],i),curf * (i+1),N);
    }
    return res;
}


int main(){
    int N;cin>>N;
    vector<bool> IsPrime(N+1,true);
    sieve(IsPrime, N);
    vector<int> primes;
    // cout<<N<<endl;
    // cout<<IsPrime.size()
    for(int i = 2;i < N+1;i++){
        if(IsPrime[i]){
            // cout<<i<<endl;
            primes.push_back(i);
        }
    }
    vector<int> pnums(primes.size(),0);
    // cout<<primes.size()<<endl;
    // cout<<"a"<<endl;
    cout<<f(primes,0,pnums,1,1,N)<<endl;
    // cout<<primes.size()<<endl;

}

Measured memory_bytes: 71980
package main

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

type stack struct {
	data []int
}

func (s *stack) push(v int) {
	s.data = append(s.data, v)
}
func (s *stack) top(v *int) bool {
	if len(s.data) == 0 {
		return false
	}
	*v = s.data[len(s.data)-1]
	return true
}
func (s *stack) pop(v *int) bool {
	if len(s.data) == 0 {
		return false
	}
	*v = s.data[len(s.data)-1]
	s.data = s.data[:len(s.data)-1]
	return true

}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	q := nextInt(sc)
	ans := make([]int, 0)
	stacks := make([]stack, n)
	for i := 0; i < q; i++ {
		op := nextInt(sc)
		t := nextInt(sc)
		if op == 0 {
			x := nextInt(sc)
			stacks[t].push(x)
		} else if op == 1 {
			var v int
			if stacks[t].top(&v) {
				ans = append(ans, v)
			}
		} else {
			var v int
			stacks[t].pop(&v)
		}
	}
	wtr := bufio.NewWriter(os.Stdout)
	for i := 0; i < len(ans); i++ {
		fmt.Fprintf(wtr, "%d\n", ans[i])
	}
	wtr.Flush()
}



Measured memory_bytes: 8840
def calc(x):
    if x == 0:
        return 0
    cnt = 0
    for i in range(25):
        if x >> i & 1:
            cnt += 1
    return 1 + calc(x % cnt)

N = int(input())
X = list(map(int, input().rstrip()))
count = sum(X)
mod1 = [0] * N
mod2 = [0] * N
sum1 = sum2 = 0
for i, d in enumerate(X):
    if count > 1:
        mod1[i] = pow(2, N - i - 1, count-1)
    mod2[i] = pow(2, N - i - 1, count+1)
    if d:
        if count > 1:
            sum1 = (sum1 + mod1[i]) % (count - 1)
        sum2 = (sum2 + mod2[i]) % (count + 1)
for i, d in enumerate(X):
    ans = 0
    if d:
        if count > 1:
            ans = 1 + calc((sum1 - mod1[i]) % (count - 1))
    else:
        ans = 1 + calc((sum2 + mod2[i]) % (count + 1))
    print(ans)

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

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

    ll sum=0;
    for (int i=1;i<=n;i++) {
        if ( i%3 != 0 && i%5 != 0 ) {
            sum += i;
        }
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3624
c11 ,c12, c13 = map(int,input().split())
c21 ,c22, c23 = map(int,input().split())
c31 ,c32, c33 = map(int,input().split())

if c11 - c12 == c21 -c22 == c31-c32 and c12 - c13 == c22 -c23 == c32-c33 and c11 - c21 == c12 -c22 == c13-c23 and c21 - c31 == c22 -c32 == c23-c33 :
    print('Yes')
else :
    print('No')

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

vector<int> calc_divisor(int n) {
  vector<int> res;
  for (int i = 1; i*i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      int j = n / i;
      if (j != i) res.push_back(j);
    }
  }
  sort(res.begin(), res.end(), greater<int>());
  return res;
}

int main() {
  int N, M; cin >> N >> M;
  vector<int> div = calc_divisor(M);
  for (int i = 0; i < div.size(); i++) {
    if (div.at(i) <= (double)M / (double)N) {
      cout << div.at(i) << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <limits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)

void read_problem(int& a, int& b, int& c)
{
    scanf("%d %d %d", &a, &b, &c);
}

int main()
{
    int a, b, c;
    read_problem(a, b, c);

    vector<int> v{a, b, c};
    sort(v.begin(), v.end());

    printf("%d\n", v[0] + v[1]);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define printarray(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl;
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long

using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;

int fastexpo(int b, int exp){
    if(exp == 0) return 1;
    if(exp == 1) return b;
    int ans = (fastexpo(b,exp/2) % MOD);
    ans *= ans;
    ans %= MOD;
    if(exp % 2 == 1){
        ans *= b;
    }
    ans %= MOD;
    return ans;
}

int dp[105][MAXN];



signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
	int n, m;
	cin>>n>>m;
	pair<int, int> a[n+2];
	for(int i= 0;i<n;i++){
		cin>>a[i+1].fr>>a[i+1].sc;
	}
	memset(dp, 0, sizeof(dp));
	for(int i =1;i<=n;i++){
		for(int j = 1;j<=m;j++){
			if(a[i].fr <= j){
				dp[i][j] = max(dp[i][j], a[i].sc + dp[i-1][j-a[i].fr]);
				dp[i][j] = max(dp[i][j], dp[i-1][j]);
			} else {
				dp[i][j] = max(dp[i][j], dp[i-1][j]);
			}
		}
	}
	cout<<dp[n][m]<<endl;
    return 0;
}





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

ll n, k, ans = 1;
int main() {
    scanf("%lld%lld", &n, &k);
    if(n == 1) { printf("%lld\n", k); return 0; }
    for(ll i = 2; i * i <= k; ++i) {
        if(k % i == 0) {
            ll cnt = 0, km;
            while(k % i == 0) k /= i, cnt++;
            km = cnt / n;
            rep(j, km) ans *= i;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    ll res = 0;
    // k-;
    string z = "";
    rep(i, 0, t.size())
    {
        // cout << i;ss
        if (i < k)
        {
            if (t[i] == 'r')
                z += "p",
                res += p;
            else if (t[i] == 'p')
                z += "s",
                res += s;
            else 
                z += "r",
                res += r;
        }
        else 
        {
            if (t[i] == 'r' && z[i-k] != 'p')
                z += "p",
                res += p;
            else if (t[i] == 'p' && z[i-k] != 's')
                z += "s",
                res += s;
            else if (t[i] == 's' && z[i-k] != 'r')
                z += "r",
                res += r;
            else 
                z += "*";
        }
    }
    cout << res;    
    return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
string char_to_str(char c){string tem(1,c);return tem;}

typedef pair<int, int> ii;
#define S second
#define F first
// string to integer atoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output


int main(){

	int a, p;
	cin>>a>>p;

	cout<<((3*a) + p)/2;	

	return 0;
}

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

int main() {
    int n, p, maximum = 0, sum = 0;
    cin >> n;
    rep(i, n) {
        cin >> p;
        sum += p;
        maximum = max(maximum, p);
    }
    int ans = sum - maximum / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>

using namespace std;

int main() {
	int n, m; cin >> n >> m;
	vector<pair<int, int> > ab(n);
	for (int i = 0; i < n; ++i) {
		int a, b; cin >> a >> b;
		ab[i].first = a, ab[i].second = -b;
	}
	sort(ab.begin(), ab.end());
	long long ans = 0;
	priority_queue<int> pq;
	int tmp = 1;
	int i = 0;
	while (tmp <= m) {
		while (i < n && ab[i].first == tmp) pq.push(-ab[i].second), i++;
		if (!pq.empty()) ans += pq.top(), pq.pop();
		tmp++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
const int maxn=200005;
using namespace std;
int a[maxn],b[maxn];
int main()
{
    int n,i,x=-1,res,ans;
   scanf("%d",&n);
   for(i = 1;i<=n;i++)
    scanf("%d",&a[i]);
   sort(a+1,a+n+1);
   for(i = 1;i<n;i++)
   {
       int c=a[n]-a[i];
       int d=a[n]-(a[n]-a[i]);
       res=min(c,d);
       if(x<res) ans=i,x=res;
   }
   printf("%d %d\n",a[n],a[ans]);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  //枚数の宣言
  int N = 0;
  cin >> N;
  //カードに書いている数値の枠を作る
  vector<int> vec(N);
  for(int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  //枠の中身を大きいもの順にする
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  //ボブとアリスの枠に数値を足していく
  int Bob = 0;
  int Alice = 0;
 for (int i = 0; i < N; i++) {
   if ((i + 1) % 2 == 1) { 
     Alice += vec.at(i);
   }
   else {
     Bob += vec.at(i);
   }
 }
  cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; i++) a[i] = sc.nextInt();
		for(int i = 0; i < n; i++) {
			if(i != 0) System.out.print(" ");
			System.out.print(a[n - i - 1]);
		}
		System.out.println();
	}
}



Measured memory_bytes: 26528
#include <iostream>
#include <fstream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define foreach(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define len(a) ((int) (a).size())

#ifdef CUTEBMAING
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

using namespace std;

typedef long long int64;
typedef long double ld;
typedef unsigned long long lint;

const int inf = (1 << 30) - 1;
const int64 linf = (1ll << 62) - 1;
const int N = 1e6 + 100;

int n, q;
int a[N], b[N], c[N];
int parent[N];

inline int findSet(int v) {
    if (parent[v] != v) {
        return parent[v] = findSet(parent[v]);
    }
    return v;
}

int main() {
#ifdef XCODE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n >> q;
    for (int i = 0; i < q; i++) {
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
    }
    for (int i = 0; i < n; i++) {
        parent[i] = i;
    }
    set<tuple<int, int, int, int>> st;
    for (int i = 0; i < q; i++) {
        st.insert(make_tuple(c[i], a[i], b[i], 0));
    }
    int64 ans = 0;
    while (len(st) > 0) {
        int c, u, v, cnt; tie(c, u, v, cnt) = *st.begin();
        st.erase(st.begin());
        if (findSet(u) == findSet(v)) {
            if (cnt >= 2) {
                continue;
            } else {
                st.insert(make_tuple(c + 1, v, (u + 1) % n, cnt + 1));
                continue;
            }
        }
        ans += c;
        parent[findSet(u)] = findSet(v);
        st.insert(make_tuple(c + 1, v, (u + 1) % n, 0));
    }
    for (int i = 0; i < n; i++) {
        assert(findSet(0) == findSet(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 17792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		for(int i = 0 ; i < n ; i++) {
			int a = sc.nextInt();
			if((i + 1) % 2 == 1) {
				if(a % 2 == 1)
					count++;
			}

		}
		System.out.println(count);

	}
}



Measured memory_bytes: 35664
Main(myin());
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//不明値:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
function myconv(i,no){switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}
function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  input.shift();
  var list = new Array(N);
  for(var i = 0; i < N; i++){
    list[i] = temple();
  }
  for(var i = 0; i < N-1; i++){
    var tmp = myconv(input[i],4);
    list[tmp[0]-1]["children"][tmp[1]-1] = tmp[2] % 2;
    list[tmp[1]-1]["children"][tmp[0]-1] = tmp[2] % 2;
  }
  var que = [];
  list[0]["accessed"] = true;
  que.push(list[0]);
  while(que.length > 0){
     var tmpObj = que.shift();
    var children = Array.from(Object.keys(tmpObj["children"])); 
    for(var i = 0; i < children.length; i++){
       if(list[children[i]]["accessed"]){continue;}
       if(tmpObj["children"][children[i]] % 2 == 0){
          list[children[i]]["color"] = tmpObj["color"];
       }else{
         if(tmpObj["color"] == 1){
            list[children[i]]["color"] = 0
         }else{
           list[children[i]]["color"] = 1;
         }
       }
       list[children[i]]["accessed"] = true;
       que.push(list[children[i]]);
     }
  }
  var output = new Array(N);
  for(var i = 0; i < N; i++){
    output[i] = list[i]["color"];
  }
  myout(output.join("\n"));
}

function temple(){
  var obj = {};
  obj["children"] = {};
  obj["color"] = 0;
  obj["accessed"] = false;
  return obj;
}


Measured memory_bytes: 85484
#include<stdio.h>//----0138 
int main(void)
{
	int i,j,num[24+1],temp01;
	float time[24+1],temp02;
	for(i=0;i<24;i++) {
		scanf("%d %f",&num[i],&time[i]);
	}
	for(i=0;i<8-1;i++) {
		for(j=i+1;j<8;j++) {
			if(time[i]>time[j]) {
				temp01=num[i];
				num[i]=num[j];
				num[j]=temp01;
				temp02=time[i];
				time[i]=time[j];
				time[j]=temp02;
			}
		}
	}
	for(i=8;i<16-1;i++) {
		for(j=i+1;j<16;j++) {
			if(time[i]>time[j]) {
				temp01=num[i];
				num[i]=num[j];
				num[j]=temp01;
				temp02=time[i];
				time[i]=time[j];
				time[j]=temp02;
			}
		}
	}
	for(i=16;i<24-1;i++) {
		for(j=i+1;j<24;j++) {
			if(time[i]>time[j]) {
				temp01=num[i];
				num[i]=num[j];
				num[j]=temp01;
				temp02=time[i];
				time[i]=time[j];
				time[j]=temp02;
			}
		}
	}
	for(i=0;i<2;i++) {
		printf("%d %.2f\n",num[i],time[i]);
		time[i]=100.00;
	}
	for(i=8;i<10;i++) {
		printf("%d %.2f\n",num[i],time[i]);
		time[i]=100.00;
	}
	for(i=16;i<18;i++) {
		printf("%d %.2f\n",num[i],time[i]);
		time[i]=100.00;
	}
	for(i=0;i<24-1;i++) {
		for(j=i+1;j<24;j++) {
			if(time[i]>time[j]) {
				temp01=num[i];
				num[i]=num[j];
				num[j]=temp01;
				temp02=time[i];
				time[i]=time[j];
				time[j]=temp02;
			}
		}
	}
	for(i=0;i<2;i++) {
		printf("%d %.2f\n",num[i],time[i]);
	}
	return 0;
}

Measured memory_bytes: 648
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
#define fi first
#define sc second
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef pair<ll,ll> P;

ll H,W,D,Q,A[400][400],L[100000],R[100000];
P p[100000];
ll d[100000];


int main(){
    cin >> H >> W;
    cin >> D;
    REP(i,H) {
        REP(j,W) {
            cin >> A[i][j];
        }
    }
    cin >> Q;
    REP(i,Q) {
        cin >> L[i] >> R[i];
    }

    REP(i,H) {
        REP(j,W) {
            p[A[i][j]] = P(i,j);
        }
    }

    
    FOR(i,1,min(D + 1,H * W + 1)) {
        d[i] = 0;

        ll dis = 0;

        for(ll j = 1;j * D + i <= H * W;j++) {
            dis += abs(p[j * D + i].fi - p[(j - 1) * D + i].fi) + abs(p[j * D + i].sc - p[(j - 1) * D + i].sc);
            d[j * D + i] = dis;
        }
    }

    REP(i,Q) {
        cout << d[R[i]] - d[L[i]] << endl;
    }

    return 0;
}




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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1)/b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

int nmax=200000; // 2*(10^5)
vvec g(nmax);

vec c(nmax,-1);

int n,m;
int gg=0,f=0;
int ans=0;
bool fl=false;
void dfs(int v,int p,int cl){
    if(c[v]==-1){
        c[v]=cl;
        if(cl==0) gg++;
        else f++;
        for(int next:g[v]){
            dfs(next,v,(cl+1)%2);
        }
    }
    else{
        if(c[v]!=cl){
            cout<<n*(n-1)/2-m<<endl;
            exit(0);
        }
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    cin>>n>>m;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs(0,-1,0);
    cout<<gg*f-m<<endl;
}

Measured memory_bytes: 10624
import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


enum LIM = 10^^5;

int N;
long[] A;

void main() {
  auto isnp = new bool[LIM];
  foreach (p; 2 .. LIM) {
    if (!isnp[p]) {
      for (int n = 2 * p; n < LIM; n += p) {
        isnp[n] = true;
      }
    }
  }
  
  try {
    for (; ; ) {
      N = readInt();
      A = new long[N + 1];
      foreach_reverse (i; 0 .. N + 1) {
        A[i] = readLong();
      }
      
      long[] ans;
      
      long g;
      foreach (i; 0 .. N + 1) {
        g = gcd(g, abs(A[i]));
      }
      long gg = g;
      for (long p = 2; p * p <= gg; ++p) {
        if (gg % p == 0) {
          ans ~= p;
          do {
            gg /= p;
          } while (gg % p == 0);
        }
      }
      if (gg > 1) {
        ans ~= gg;
      }
      
      foreach (p; 2 .. N + 1) {
        if (!isnp[p]) {
          auto a = A.dup;
          a[] %= p;
          foreach_reverse (i; p .. N + 1) {
            a[i - p + 1] += a[i];
            a[i - p + 1] %= p;
          }
          if (a[0 .. p].all!"a == 0") {
            ans ~= p;
          }
        }
      }
      
      ans = ans.sort().uniq.array;
      foreach (p; ans) {
        writeln(p);
      }
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 4860
//                        Bismillahir Rahmanir Rahim
//ALGO:
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define FILL(a, x) memset(a, x, sizeof(a))
#define ll long long
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF INT_MAX
#define mx 1000010
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<pair<int, int>, null_type,less<pair<int, int> >, rb_tree_tag,tree_order_statistics_node_update>
*/
const double Pi=acos(-1);
using namespace std;
int debug=01;
ll dp[100010][3], a[100010][3];
int n;
ll solve(int i, int x){
    if(i>n) return 0;
    if(~dp[i][x]) return dp[i][x];
    ll ret=0;
    for(int j=0; j<3; j++) if(j!=x) ret=max(ret, solve(i+1, j)+a[i][j]);
    return dp[i][x]=ret;
}
int main() {
    cin>>n;
    FILL(dp, -1);
    for(int i=1; i<=n; i++) for(int j=0; j<3; j++) cin>>a[i][j];
    cout<<max(solve(1, 0), max(solve(1, 1), solve(1, 2)));
}



Measured memory_bytes: 9984