akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    int q;
    cin>>s>>q;
    deque<char>dq;
    for(auto x: s)dq.push_back(x);
    bool ok=false;
    while(q-->0){
        int t;
        cin>>t;
        if(t==1)ok=!ok;
        else{
            int l;char ch;
            cin>>l>>ch;
            if(ok)l=3-l;
            if(l==1)dq.push_front(ch);
            else dq.push_back(ch);
        }
    }
    if(ok)reverse(dq.begin(),dq.end());
    while(!dq.empty())cout<<dq.front(),dq.pop_front();
}


Measured memory_bytes: 4012
################### <----------------------  Quicksilver_ ---------------------> ####################
arr=[['1','2','3','4','5','6','7','8','9']]
x=[9]
while sum(x)<100010:
    temp=[]
    for a in arr[-1]:
        z=int(a[-1])
        if z-1>=0:
            temp.append(a+str(z-1))
        temp.append(a+str(z))
        if z+1<10:
            temp.append(a+str(z+1))
    x.append(len(temp))
    arr.append(temp)
glob=[]
for a in arr:
    for b in a:
        glob.append(b)
n=int(input())
print(glob[n-1])


Measured memory_bytes: 18804
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N,X,T;
    cin >> N >> X >> T;
    if(N % X == 0) cout << (N/X) * T << endl;
    else cout << ((N/X)+1)*T << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3648
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		private static long max = long.MaxValue - (long)1e12 * (16 + 1);

		static void Main(string[] args)
		{
			var firstLine = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();
			var h = firstLine[0];
			var w = firstLine[1];

			if(h % 3 == 0 || w % 3 == 0)
			{
				WriteLine(0);
				return;
			}

			var blocks = h * w;
			var oneThirdBlocks = blocks / 3;
			var min = long.MaxValue;

			for(var i = 0; i < 2; i++)
			{
				var firstBlockH = oneThirdBlocks / w != 0 ? oneThirdBlocks / w : 1;
				firstBlockH += i;
				if(firstBlockH > h)
				{
					break;
				}
				var remainBlockH = h - firstBlockH;
				var firstBlocks = firstBlockH * w;
				var remainBlocks = blocks - firstBlocks;

				if(remainBlockH != 1)
				{
					var secondBlockH = remainBlockH / 2;
					var secondBlocks = secondBlockH * w;
					var thirdBlocks = (remainBlockH - secondBlockH) * w;

					min = Min(min, Max(firstBlocks, Max(secondBlocks, thirdBlocks)) - Min(firstBlocks, Min(secondBlocks, thirdBlocks)));
				}
				if(w != 1)
				{
					var secondBlockW = w / 2;
					var secondBlocks = remainBlockH * secondBlockW;
					var thirdBlocks = remainBlockH * (w - secondBlockW);

					min = Min(min, Max(firstBlocks, Max(secondBlocks, thirdBlocks)) - Min(firstBlocks, Min(secondBlocks, thirdBlocks)));
				}
			}

			for(var i = 0; i < 2; i++)
			{
				var firstBlockW = oneThirdBlocks / h != 0 ? oneThirdBlocks / h : 1;
				firstBlockW += i;
				if (firstBlockW > w)
				{
					break;
				}
				var remainBlockW = w - firstBlockW;
				var firstBlocks = firstBlockW * h;
				var remainBlocks = blocks - firstBlocks;

				if (remainBlockW != 1)
				{
					var secondBlockW = remainBlockW / 2;
					var secondBlocks = secondBlockW * h;
					var thirdBlocks = (remainBlockW - secondBlockW) * h;

					min = Min(min, Max(firstBlocks, Max(secondBlocks, thirdBlocks)) - Min(firstBlocks, Min(secondBlocks, thirdBlocks)));
				}
				if (h != 1)
				{
					var secondBlockH = h / 2;
					var secondBlocks = remainBlockW * secondBlockH;
					var thirdBlocks = remainBlockW * (h - secondBlockH);

					min = Min(min, Max(firstBlocks, Max(secondBlocks, thirdBlocks)) - Min(firstBlocks, Min(secondBlocks, thirdBlocks)));
				}
			}

			WriteLine(min);
		}
	}
}


Measured memory_bytes: 13396
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int t = sc.nextInt();
        if(X-t<=0) {
            System.out.println(0);
        }else {
            System.out.println(X-t);
        }
    }
}

Measured memory_bytes: 22868
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    int N;
    cin >> N;
    if (N==1) {
        cout << 1 << endl;
        return 0;
    }
    int a = 1;
    rep(i, 3) a *= N;
    cout << a << endl;
    return 0;
}

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



int main(void){
  string a,b;
  int A,B;
  string c;
  cin >> a >> b;
  cin >> A >> B;
  cin >> c;
  if(a==c){
    cout << A-1<<" " << B <<endl;
  }
  else{
    cout << A << " " <<B-1 << endl;
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  reverse(a,a+n);
  for(int i=0;i<n;i++){
    cout<<a[i];
    if(i==n-1)cout<<endl;
    else cout<<" ";
  }
  return 0;
}

Measured memory_bytes: 3040
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main()
{
  int a,b,c,x,y,q,w,e,ans;
  cin >> a >> b >> c >> x >> y;
  if(x>y){q=x*c*2;
          w=y*c*2+(x-y)*a;
         }
  else {q=y*c*2;
        w=x*c*2+(y-x)*b;
       }
  e=a*x+b*y;
  ans=q;
  if(ans>w)ans=w;
  if(ans>e)ans=e;
  printf("%d",ans);
}

Measured memory_bytes: 256
/*
	@author: cheerioskun
*/
#pragma GCC target("popcnt")
#include "bits/stdc++.h"
#define f first
#define sc second
#define pb push_back
#define MOD 1000000007L
#define inf 0x3f3f3f3f
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long int ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
using namespace std;

double p[3003];
// DP for probability of [Number of coins seen][Number of heads]
double dp[3003][3003];

int main(){
	fast_io
	int N;
	cin>>N;
	for(int i = 0;i < N; ++i){
		cin>>p[i];
	}
	// PUSH DP
	for(int i = 0;i <= N; ++i){
		for(int j = 0;j <= N; ++j){
			dp[i][j] = 0;
		}
	}
	for(int i = 0;i <= N; ++i){
		dp[0][i] = 1;
	}
	for(int i = 0;i < N; ++i){
		for(int j = 0;j <= i; ++j){
			// Comes up tails
			dp[i + 1][j] += dp[i][j] * (1 - p[i]);
			// Comes up heads
			dp[i + 1][j + 1] += dp[i][j] * p[i];
			
		}
		
	}
	double ans = 0;
	for(int i = N/2 + 1; i <= N; ++i){
		ans += dp[N][i];
	}	
	cout<<std::fixed<<std::setprecision(9)<<ans<<endl;
	#ifndef ONLINE_JUDGE
    	cout<<"Time Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}



Measured memory_bytes: 74200
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
ll bit[500005];
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,num,sum,ans;
ll a,b,c,d,e,g,h;
ll x[500005],y[500005],z[500005];
bool dp[10000];
char s[500005];

ll bitsum(ll i){
	ll s = 0;
	while(i>0){
		//p("hoi");
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
void bitadd(ll b,ll x){
	while(b <= n){
		//p("hoi");
		bit[b] += x;
		b += b & -b;
	}
}

int main(){
	cin >> s;
	n = strlen(s);
	for(i=0;i<n;i++){
		x[s[i] - 'a']++;
	}
	for(i=0;i<='z'-'a';i++){
		ans += x[i] * (x[i] - 1) / 2;
	}
	num = n * (n - 1) / 2 + 1;
	p(num - ans);
	return 0;
}

Measured memory_bytes: 29824
import java.util.*;
import java.io.*;
class Main {
    static long MOD = (long)(1e9+7);
    static long[] dp;
    static long recurse(int[] woMask, int mask) {
        int n = woMask.length;
        if(dp[mask]!=-1)
            return dp[mask];
        int idx = Integer.bitCount(mask);
        if(idx==n)
            return 1;
        long ans = 0;
        for(int i = 0; i<n; i++) {
            int bit1 = (woMask[idx]>>i)&1;
            int bit2 = (mask>>i)&1;
            if(bit1==1 && bit2==0)
                ans+=recurse(woMask, mask|(1<<i));
            ans%=MOD;
            if(ans<0)
                ans+=MOD;
        }
        dp[mask] = ans;
        return ans;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] woMask = new int[n];
        for(int i = 0; i<n; i++) {
            int mask = 0;
            for(int j = 0; j<n; j++) {
                if(sc.nextInt()==1)
                    mask|=(1<<j);
            }
            woMask[i] = mask;
        }
        dp = new long[1<<n];
        Arrays.fill(dp, -1);
        System.out.println(recurse(woMask, 0));
    }
}

Measured memory_bytes: 40788
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
int n, a, b, i, j, k, m;

int main() {
	scanf("%d%d", &a, &b);
	if (a >= 1 && a <= 9 && b >= 1 && b <= 9)
		printf("%d\n", a * b);
	else
		printf("-1\n");
}

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

int main(){
  int count=0;
  int N;
  cin>>N;
  vector<int>a(N);
  rep(i,N){
    cin>>a[i];
  }
    rep(i,N){
      while(1){
      if(a[i]%2){
        break;
      }
      a[i]=a[i]/2;
        count++;
    }
  }
  cout<<count;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

#ifndef SIEVE
#define SIEVE
// エラストテネスの篩, o(n)程度
// n以下の素数の数を返す, prime[i]: i番目の素数, is_prime[i]: iが素数であるか
int sieve(int n, int prime[] = nullptr, bool is_prime[] = nullptr){
	bool flag0 = false, flag1 = false;
	if(prime == nullptr){
		flag0 = true; prime = new int[n];
	}
	if(is_prime == nullptr){
		flag1 = true; is_prime = new bool[n + 1];
	}

	int p = 0;
	fill(is_prime, is_prime + n + 1, true);
	is_prime[0] = is_prime[1] = false;

	for(int i = 2; i <= n; i++){
		if(is_prime[i]){
			prime[p++] = i;
			for(int j = 2*i; j <= n; j+=i) is_prime[j] = false;
		}
	}

	if(flag0) delete prime;
	if(flag1) delete is_prime;

	return p;
}
#endif

const int N = (int)1e6;
int prime[N];
bool is_prime[N+1];
int res[N];

int main(void){
    int num = sieve(N, prime, is_prime);

    // for(int i = 0; i < 30; i++) printf("prime[%d] = %d\n", i, prime[i]);
    // for(int i = 1; i < N; i++){
    //     res[i] = res[i-1] + is_prime[i];
    // }

    int n;

    while(scanf("%d", &n) != EOF){
        cout << upper_bound(prime, prime + num, n) -prime << '\n';        
    }

    return 0;
}


Measured memory_bytes: 4420
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
	int N,D,i,ans=1,kanshi=0,temp,flag=0;
	scanf("%d %d", &N,&D);
	i = D + 1;
	while (i+D< N) {
		i = i + D+D+1;
		ans++;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

void solve(){

    string s;
    cin >> s;
    rep(i,s.length()){
        cout << "x";
    }
    cout << endl;
 
}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define int long long
using namespace std;

signed main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if ((a + b) > (c + d)) {
		cout << "Left" << endl;
	} else if ((a + b) < (c + d)) {
		cout << "Right" << endl;
	} else if ((a + b) == (c + d)) {
		cout << "Balanced" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct edge{
  int to, cost;
};
typedef pair<int, int> pii;//cost, vertex
int dx[] = {0, 1, 1, 0, -1, -1};
int dy[2][6] = {{1, 0, -1, -1, -1, 0},
                {1, 1, 0, -1, 0, 1}};

int solve(vector<vector<edge> >& g, int s, int goal, int lx, int ly){
  int n = g.size();
  vector<int> dp(n, 1e9);
  dp[s] = 0;
  int res = -1;
  priority_queue<pii, vector<pii>, greater<pii> > que;
  que.push(pii(0, s));
  while(!que.empty()){
    int c = que.top().first;
    int v = que.top().second;
    que.pop();
    if(v%(lx*ly) == goal){
      res = dp[v];
      break; 
    }
    for (int i = 0; i < g[v].size(); i++) {
      edge e = g[v][i];
      if(dp[e.to] > c + e.cost){
        dp[e.to] = c + e.cost;
        que.push(pii(c + e.cost, e.to));
      }
    }
  }
  return res;
}

int main(int argc, char *argv[]){
  int sx, sy, gx, gy, n;
  cin >> sx >> sy >> gx >> gy >> n;
  int x[n], y[n], lx, ly;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  cin >> lx >> ly;
  sx += lx;
  sy += ly;
  gx += lx;
  gy += ly;
  ly *= 2;
  lx *= 2;
  ly++;lx++;
  int maxi = 6;
  vector<vector<int> > grid(ly, vector<int>(lx, 0));
  vector<vector<edge> >g(maxi*ly*lx, vector<edge>());
  for (int i = 0; i < n; i++) {
    grid[y[i] + ly/2][x[i] + lx/2] = 1;
  }
  for (int t = 0; t < maxi; t++) {
    for (int i = 0; i < ly; i++) {
      for (int j = 0; j < lx; j++) {
        if(grid[i][j] != 0)continue;
        for (int k = 0; k < 6; k++) {
          int nv = (t + 1)*ly*lx +
            (lx*(i + dy[abs(j - lx/2)%2][k]) + (j + dx[k]));
          nv %= maxi*ly*lx;
          if(!(0 <= i + dy[abs(j - lx/2)%2][k] &&
               i + dy[abs(j - lx/2)%2][k] < ly) ||
             !(0 <= j + dx[k] && j + dx[k] < lx))
            continue;

          if(abs(t*(i - ly/2)*(j - lx/2))%6 == k){
            g[t*ly*lx + (lx*i + j)].
              push_back((edge){nv, 0});
          }else{
            g[t*ly*lx + (lx*i + j)].
              push_back((edge){nv, 1});
          }
        }
        g[t*ly*lx + (lx*i + j)].
          push_back((edge){((t + 1)*ly*lx + (lx*i + j))%
                (maxi*ly*lx), 1});
      }
    }
  }
  // for (int t = 0; t < maxi; t++) {
  //   for (int i = 0; i < ly; i++) {
  //     for (int j = 0; j < lx; j++) {
  //       std::cout << t*ly*lx + (lx*i + j) << ":"  << std::endl;
  //       for (int k = 0; k < g[(t*ly*lx) + (lx*i + j)].size(); k++) {
  //         std::cout << g[(t*ly*lx) + (lx*i + j)][k].to << " ";
  //       }
  //       std::cout << std::endl;
  //       std::cout << std::endl;
  //     }
  //   }
  // }
  // std::cout << sy*lx + sx << std::endl;
  // std::cout << gy*lx + gx << std::endl;
  int ans = solve(g, sy*lx + sx, gy*lx + gx, lx, ly);
  if(ans == 1e9){
    std::cout << -1 << std::endl;
  }else{
    std::cout << ans << std::endl;
  }
  return 0;
}

Measured memory_bytes: 26492
n, m = map(int, raw_input().split())
red = [ False for pos in range(n + 1) ]
red[1] = True
count = [ 1 for pos in range(n + 1) ]
count[0] = 0
for i in range(m): 
    x, y = map(int, raw_input().split())
    if red[x]:
        red[y] = True
    count[x] -= 1
    if count[x] == 0:
        red[x] = False
    count[y] += 1
print(red.count(True))


Measured memory_bytes: 23020
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<pll> nums;
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        if(a <= K)
            nums.pb(MP(a, b));
    }
    N = nums.size();
    ll res = 0;
    for(int i = 0; i < N; i++) {
        if(__builtin_popcount(K | nums[i].first) == __builtin_popcount(K)) {
            res += nums[i].second;
        }
    }
    for(int i = 30; i >= 0; i--) {
        if(K & (1 << i)) {
            ll v = 0;
            rep(k, N) {
                bool ok = 1;
                for(int j = 30; j > i; j--) {
                    if(!(K & (1 << j)) && (nums[k].first & (1 << j)))
                        ok = false;
                }
                if((nums[k].first & (1 << i)))
                    ok = false;
                if(ok)
                    v += nums[k].second;
            }
            res = max(v, res);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5356
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int H, W, K;
ll dp[110][20];

int main()
{
    cin >> H >> W >> K;
    dp[0][1] = 1;
    for (int i = 0; i <= H; i++)
    {
        for (int j = 1; j <= W; j++)
        {
            for (int bit = 0; bit < (1 << (W - 1)); bit++)
            {
                bool ok = true;
                for (int k = 0; k < W - 1; k++)
                {
                    if ((bit & (1 << k)) && (bit & (1 << (k + 1))))
                    {
                        ok = false;
                    }
                }
                if (ok)
                {
                    int nj = j;
                    if (bit & (1 << (W - j)))
                    {
                        nj = j - 1;
                    }
                    else if (bit & (1 << (W - j - 1)))
                    {
                        nj = j + 1;
                    }
                    dp[i + 1][nj] += dp[i][j];
                    dp[i + 1][nj] %= MOD;
                }
            }
        }
    }
    cout << dp[H][K] << endl;
}


Measured memory_bytes: 256
N, Q= map(int, input().split())
S = input()
D = []
for i in range(Q):
    l, r = map(int, input().split())
    D.append([l,r])

c =[0]*N
for i in range(N-1):
    if S[i:i+2] == "AC":
        c[i+1]=c[i]+1
    else:
        c[i+1]=c[i]
for l, r in D:
    print(c[r-1]-c[l-1])


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

int main(){
int n;
cin >> n;
vector<int>a(3 * n);
for (int i = 0; i < 3 * n; i++)
{
  cin >> a.at(i);
}
sort(a.begin(), a.end());
reverse(a.begin(), a.end());
ll ans = 0;
int j = 0;
int count = 0;
for (int i = 1; count < n; i += 2)
{
    ans += a[i];
    count++;
}


  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    int res = 1;
    while(b > 0){
        if(b&1) res = m(m(res)*m(a));
        a = m(m(a)*m(a));
        b >>= 1;
    }
    return res;
}
// vector<int> fac; //precompute fac array
// fac.resize(n+1);
// fac[0] = 1; 
// for (int i=1; i<=n; i++)   fac[i] = m(m(fac[i-1])*m(i));
// int modInverse(int n){ 
// return p(n, MOD-2); 
// }  
// int nCrModPFermat(int n, int r){   
//     if(r == 0)  return 1; 
//     return m(m(m(fac[n])*m(modInverse(fac[r])))*m(modInverse(fac[n-r]))); 
// } 
signed main(){
    fast();
    set<int> st;
    for(int i=0, j; i<3; i++){
        cin >> j;
        st.ins(j);
    }
    if(st.size() == 2){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

Measured memory_bytes: 256
void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.split.to!(int[]);
    bool[] colors = new bool[8];
    int red;
    foreach (x; a) {
        if (x < 3200) {
            colors[x/400] = true;
        } else {
            ++red;
        }
    }
    int cmin = colors.count(true).to!int;
    int cmax = cmin + red;
    if (cmin == 0 && red > 0) ++cmin;
    writeln(cmin, " ", cmax);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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;
}

int main(void) {
    int N, M, X;
    cin >> N >> M >> X;

    vector<bool> as(N + 1, false);
    for (int i = 0; i < M; i++) {
        int a;
        cin >> a;
        as[a] = true;
    }

    int l_cnt = 0;
    for (int i = X - 1; i > 0; i--) {
        if (as[i]) {
            l_cnt++;
        }
    }
    int r_cnt = 0;
    for (int i = X + 1; i < N; i++) {
        if (as[i]) {
            r_cnt++;
        }
    }

    // printf("l_cnt: %d, r_cnt: %d\n", l_cnt, r_cnt);
    cout << min(l_cnt, r_cnt) << endl;

    return 0;
}


Measured memory_bytes: 3588
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String str[]=br.readLine().split(" ");
        int a=Integer.parseInt(str[0]);
        int b=Integer.parseInt(str[1]);
        int c=Integer.parseInt(str[2]);
        int k=Integer.parseInt(str[3]);
        int ans=0;
        if(a>=k)
        {
            ans=k;
            k=0;
        }
        if(a<k)
        {
            ans+=a;
            k-=a;
        }
        if(k>0)
        {
            if(b>k)
            k=0;
            else
            k-=b;
        }
        if(k>0)
        ans-=k;
        pw.println(ans);
        pw.flush();
        pw.close();
    }
}

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

#define ipr pair<int, int>
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define rf(i, j, k) for (int i = j; i >= k; i--)
#define ll unsigned long long
#define int long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
#define cnt_ones(x) __builtin_popcountll(x)

#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

const int Maxn = (int)1e5 + 1;
const ld pi = acos(-1);
const int mod = (int)1e9 + 7;
const int inf = (int)1e18;

template <class T>
ostream &operator<<(ostream &out, vector<T> &A) {
    fr(i, 0, (int)A.size()) out << A[i] << " ";
    return out;
}

int32_t main() {
    IOS int Q = 1;
    // cin >> Q;
    while (Q--) {
        int a,b,c,d;    cin>>a>>b>>c>>d;
        cout <<   max ({b*d, a*d, b*c, a*c}) ;
    }
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main{
    private static double calculation(double value){
	double sum = value;
	double[] values = new double[10];
	values[0] = value;
	
	for(int i = 1; i < 10; ++i){
	    if(i%2 == 1){
		values[i] = values[i-1]*2.0;
	    } else {
		values[i] = values[i-1]/3.0;
	    }
	    sum += values[i];
	}
	

	return sum;
    }
    
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	
	while(sc.hasNext()){
	    double value = sc.nextDouble();
	    System.out.printf("%f\n", calculation(value));
	}
    }
}

Measured memory_bytes: 19352
#include<stdio.h>
int main()
{
	long h,n,a[1000000],s=0;
	int i;

	scanf("%d%d",&h,&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=0;i<n;i++)
		s+=a[i];
	if(h-s<=0)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 2688
use whiteread::parse_line;

fn main() {
    let (n, k): (i32, i32) = parse_line().unwrap();
    let v: Vec<i32> = parse_line().unwrap();
    let mut c: i32 = 0;
    
    for i in v {
        if i >= k {
            c = c + 1;
        }
    }

    println!("{:?}", c);
}


Measured memory_bytes: 2836
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	ll fpow(ll base, ll power, ll MOD) {
    ll result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 	
	ll modinv(ll x) {return fpow(x, mod - 2, mod);}
	vll fact(3000211,0);
	vll invfact(3000211,0);
	void ini()
	{
		fact[0]=1;
		fact[1]=1;
		forab(i,1,3000010)
		{
			fact[i]=(fact[i-1]*i)%mod;
		}
		invfact[3000010]=modinv(fact[3000010])%mod;
		for(ll i=3000010;i>0;i--)
		{
			invfact[i-1]=(i*invfact[i])%mod;
			//cout<<invfact[i-1]<<endl;
		}
	}
	ll perm(ll n, ll k)
	{
		return (fact[n]*invfact[n-k])%mod;
	}
	ll comb(ll n,ll k)
	{
		return (perm(n,k)*invfact[k])%mod;
	}
	void solve()
	{
		ini();
		ll k;
		cin>>k;
		string s;
		cin>>s;
		//cout<<invfact[0]<<endl;
		ll n=s.length();
		ll er=n;
		ll ans=0;
		forab(i,n,n+k)
		{
			ans=(ans%mod+(comb(n+k,i)*fpow(25,n+k-i,mod))%mod)%mod;
			
		}
		cout<<ans;
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
		//cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}


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

int main() {
    int N, M;
    cin >> N >> M;
    int count[M+1];
    memset(count,0,sizeof(count));
    for (int i = 1; i <= N; i++) {
        int K;
        cin >> K;
        for (int j = 1; j <= K; j++) {
            int A;
            cin >> A;
            count[A]++;
        }
    }
    int result = 0;
    for (int i = 1; i <= M; i++) {
        if (count[i] == N) {
            result++; 
        }
    }
    cout << result << endl;
    return 0;
}

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

int main() {
  int H, W = 3;
  cin >> H;
  vector<vector<int>> V(H, vector<int>(W));
  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++) cin >> V.at(i).at(j);

  vector<vector<int>> DP(H, vector<int>(W));
  DP.at(0) = V.at(0);
  for (int i = 1; i < H; i++)
    for (int j = 0; j < W; j++) {
      int pre = 0;
      for (int k = 0; k < W; k++) if (k != j) pre = max(pre, DP.at(i - 1).at(k));
      DP.at(i).at(j) = V.at(i).at(j) + pre;
    }

  int ans = 0;
  for (int i = 0; i < W; i++) ans = max(ans, DP.at(H - 1).at(i));
  cout << ans << "\n";
}

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

const int MAX_N = 100;
const int MAX_S = 100;

int main() {
	int N, s[MAX_N], S = 0;

	std::cin >> N;
	for(int i = 0; i < N; ++i) {
		std::cin >> s[i];
		S += s[i];
	}

	bool dp[MAX_N * MAX_S + 1] = {};
	dp[0] = true;
	for(int i = 0; i < N; ++i) {
		for(int j = S; j >= 0; --j) {
			if(j - s[i] >= 0 and dp[j - s[i]]) {
				dp[j] = true;
			}
		}
	}

	int ans = 0;
	for(int i = S; i > 0; --i) {
		if(i % 10 != 0 and dp[i]) {
			ans = i;
			break;
		}
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c;
    int sum=0;
    scanf("%d%d%d",&a,&b,&c);
    sum+=a+b+c;
    if(sum<22)
    {
        printf("win");
    }
    if(sum>=22)
    {
        printf("bust");
    }
    return 0;
}


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

int main() {
  int n;
  cin >>n;
  map<long long int,int> list;
  for (int i=0;i<n;i++) {
    int temp;
    cin >> temp;
    //cout << temp;
    if(list.count(temp)) {
      list.at(temp)++;
    }
    else {
      list[temp]=1;
    }
  }
  //cout<<list.size()<<endl;
  long long int ans=0;
  for (auto p:list) {
    ans+=p.second%2;
    //cout << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005
ll x[MAX_N] = {}, y[MAX_N] = {};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    scanf("%d%d", &n,&q);
    ll ans = (ll)(n-2)*(n-2);
    srep(i,2,n){
        x[i] = n;
        y[i] = n;
    }
    int xx = n;
    int yy = n;
    while(q--){
        int t, z;
        scanf("%d%d", &t,&z);
        if(t == 1){
            if(z < xx){
                ans -= yy - 2;
                srep(i,z,xx) x[i] = yy;
                xx = z;
            }else{
                ans -= x[z] - 2;
            }
        }else{
            if(z < yy){
                ans -= xx - 2;
                srep(i,z,yy) y[i] = xx;
                yy = z;
            }else{
                ans -= y[z] - 2;
            }
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 6916
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    ll N, K;
    cin >> N >> K;
    ll res = K;
    REP(i, 1, N) res *= K-1;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
using namespace std;

typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef long long ll;

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

	ll ans = 0;

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

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3592
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;

int n, a, b, cnt;
pair<int, bool>f[100000], s[100000];
vector<int>g[100000];

int dfsf(int x) {
	lp(g[x].size()) {
		if (!f[g[x][i]].second) {
			f[g[x][i]] = make_pair(f[x].first + 1, true);
			dfsf(g[x][i]);
		}
	}
	return 0;
}

int dfss(int x) {
	lp(g[x].size()) {
		if (!s[g[x][i]].second) {
			s[g[x][i]] = make_pair(s[x].first + 1, true);
			dfss(g[x][i]);
		}
	}
	return 0;
}




int main() {
	cin >> n;
	lp(n-1) {
		cin >> a >> b;
		g[a - 1].push_back(b - 1);
		g[b - 1].push_back(a - 1);
	}
	lp(n)
		f[i].second = s[i].second = false;
	f[0] = s[n - 1] = make_pair(0, true);
	dfsf(0);
	dfss(n-1);
	cnt = 0;
	lp(n) {
		if (f[i].first <= s[i].first)cnt++;
		else cnt--;
	}
	if (cnt > 0)cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
	return 0;
}

Measured memory_bytes: 11904
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = nextInt(scanner);
        int n = nextInt(scanner);
        List<Integer> p = new  ArrayList<>();
        for (int i = 0; i < n; i++) {
            p.add(nextInt(scanner));
        }
        int i = 0;
        if (!p.contains(x)) {
            System.out.println(x);
            return;
        }
        while (true) {
            if (!p.contains(x - i)) {
                System.out.println(x - i);
                return;
            }
            if (!p.contains(x + i)) {
                System.out.println(x + i);
                return;
            }
            i++;
        }
    }

    private static int nextInt(Scanner scanner) {
        return Integer.parseInt(scanner.next());
    }

    private static long nextLong(Scanner scanner) {
        return Long.parseLong(scanner.next());
    }

    private static float nextFloat(Scanner scanner) {
        return Float.parseFloat(scanner.next());
    }

    private static double nextDouble(Scanner scanner) {
        return Double.parseDouble(scanner.next());
    }


}





Measured memory_bytes: 35672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int  main(){
    int n;
    char s;
    cin>>n;
    int x=0;
    int max1=0;
    for(int i=0; i<n; i++){
    cin>>s;
        if(s=='I'){
            x++;
        }
        else{
            x--;
        }
max1=max(max1,x);

    }
    cout<<max1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vll = vector<long long>;
using vpi = vector<pair<int, int>>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)

const char nl = '\n';
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

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

    int n; cin >> n;
    int A = 0, B = 0, C = 0;
    F0R (i, n) {
        int a, b, c; cin >> a >> b >> c;
        int nA = max(B + b, C + c);
        int nB = max(A + a, C + c);
        int nC = max(A + a, B + b);
        A = nA, B = nB, C = nC;
    }
    cout << max(A, max(B, C)) << endl;

    return 0;
}


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

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int n; cin >> n;
	vector<int> a(n);
	REP(i, n) cin >> a[i];

	vector<int> b(n);
	REP(i, n) b[i] = a[i] - i - 1;
	nth_element(b.begin(), b.begin() + b.size()/2, b.end());

	int med = b[b.size()/2];

	ll res = 0;
	REP(i, n) res += abs(b[i] - med);
	cout << res << '\n';
	return 0;
}


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

#define lint long long
#define P pair<int, int>


int main() {
    int N;
    cin >> N;
    
    int A[2][N];
    
    for(int i = 0; i < N; ++i){
        cin >> A[0][i];
    }
    for(int i = 0; i < N; ++i){
        cin >> A[1][i];
    }
    
    int ans = 0;
    
    for(int i = 0; i < N; ++i){
        int sum = 0;
        for(int j = 0; j < N; ++j){
            if(j < i){
                sum += A[0][j];
            } else if(j > i){
                sum += A[1][j];
            } else {
                sum += A[0][j] + A[1][j];
            }
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

fn main() {
    let ss: Vec<u8> = read_line().bytes().collect();
    let mut dp = vec![1i64,0i64,0i64,0i64];
    let m = 1_000_000_007i64;
    for &c in &ss {
        match c {
            b'A' => {
                dp[1] = (dp[1] + dp[0]) % m;
            }
            b'B' => {
                dp[2] = (dp[2] + dp[1]) % m;
            }
            b'C' => {
                dp[3] = (dp[3] + dp[2]) % m;
            }
            b'?' => {
                dp[3] = (3*dp[3] + dp[2]) % m;
                dp[2] = (3*dp[2] + dp[1]) % m;
                dp[1] = (3*dp[1] + dp[0]) % m;
                dp[0] = (3*dp[0]) % m;;
            }
            _ => {
                unreachable!();
            }
        }
    }
    println!("{}", dp[3]);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}

#[allow(dead_code)]
fn tf<T>(cond: bool, t: T, f: T) -> T {
    if cond { t } else { f }
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readA(in.readLine());
		solver.readB(in.readLine());
		solver.readC(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		A = new int[N + 1];
		B = new int[N + 1];
		C = new int[N + 1];
	}

	public void readA(String str) {
		String[] strArr = str.split("\\s+");
		for (int i = 0; i < N; i++)
			A[i + 1] = Integer.parseInt(strArr[i]);
	}

	public void readB(String str) {
		String[] strArr = str.split("\\s+");
		for (int i = 0; i < N; i++)
			B[i + 1] = Integer.parseInt(strArr[i]);
	}

	public void readC(String str) {
		String[] strArr = str.split("\\s+");
		for (int i = 0; i < N - 1; i++)
			C[i + 1] = Integer.parseInt(strArr[i]);
	}

	int[] A;
	int[] B;
	int[] C;

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {
		int ans = 0;
		for (int i = 1; i <= N; i++) {
			ans += B[A[i]];
			if (i >= N)
				continue;
			if (A[i] + 1 == A[i + 1])
				ans += C[A[i]];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21332
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.io.IOException;
import java.util.stream.Collectors;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.stream.Stream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DGridColoring solver = new DGridColoring();
        solver.solve(1, in, out);
        out.close();
    }

    static class DGridColoring {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int h = in.ints(), w = in.ints();
            int n = in.ints();
            int[] a = in.ints(n);
            int[][] c = new int[h][w];
            int offset = 0;
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < a[i]; j++) {
                    int index = offset + j;
                    //System.out.println(index);
                    int y = index / w;
                    if (y % 2 == 0) {
                        c[y][index % w] = i + 1;
                    } else {
                        c[y][w - (index % w) - 1] = i + 1;
                    }
                }
                offset += a[i];
            }
            Arrays.stream(c)
                    .map(x -> IntStream.of(x).mapToObj(Integer::toString).collect(Collectors.joining(" ")))
                    .forEach(out::println);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

        public int[] ints(int length) {
            return IntStream.range(0, length).map(x -> ints()).toArray();
        }

    }
}



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

int main() {
    int n; cin >> n;
    int m; cin >> m;
    int ans = m;
    bool valid = true;
    for(int i = 0; i < n; i++) {
        int in, out; cin >> in >> out;
        m += in;
        m -= out;
        ans = max(ans, m);
        if(m < 0) {
            valid = false;
        }
    }
    cout << (valid ? ans : 0) << endl;
}

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

int main()
{
	string str;
	while(getline(cin, str)){
		if(str[0] == '.' && str.size() == 1)
			break;
		string tmp = "";
		for(unsigned i=0;i<str.size();i++){
			if(str[i] == '(' || str[i] == ')' || str[i] == '[' || str[i] == ']'){
				unsigned a = tmp.size();
				if(a!=0) a--;
				if((tmp[a] == '(' && str[i] == ')' )||(tmp[a] == '[' && str[i] == ']'))
					tmp.erase(a);
				else
					tmp += str[i];
			}
		}
		if(tmp.size()==0)
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
	return 0;
}

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

int main(){
    int i;
    string o, e;
    cin >> o >> e;
    for(i=0; i<o.length()+e.length(); i++){
        if(i%2 == 0){
            cout << o[i/2];
        }else{
            cout << e[i/2];
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct point
{
	int x,y;
}p[90010];
int h,w,m=300,cnt,a[610][610],r[610][610],c[610][610];
long long ans;
int main()
{
	scanf("%d%d",&h,&w);
	for (int i=1;i<=h;i++)
	{
		char str[310];
		scanf("%s",str+1);
		for (int j=1;j<=w;j++)
		{
			if (str[j]=='#')
			{
				int x=i+j-1,y=i-j+m;
				p[cnt++]=(point){x,y};
				a[x][y]=1;
			}
		}
	}
	m*=2;
	for (int i=1;i<=m;i++)
	{
		for (int j=1;j<=m;j++)
		{
			r[i][j]=r[i][j-1]+a[i][j];
			c[i][j]=c[i-1][j]+a[i][j];
		}
	}
	for (int i=0;i<cnt;i++)
	{
		int x=p[i].x;
		int y=p[i].y;
		for (int d=2;d<=m;d+=2)
		{
			if (y+d<=m && a[x][y+d])
			{
				if (x+d<=m)
				{
					ans+=r[x+d][y+d]-r[x+d][y-1];
				}
				if (x-d>0)
				{
					ans+=r[x-d][y+d]-r[x-d][y-1];
				}
			}
			if (x+d<=m && a[x+d][y])
			{
				if (y+d<=m)
				{
					ans+=c[x+d-1][y+d]-c[x][y+d];
				}
				if (y-d>0)
				{
					ans+=c[x+d-1][y-d]-c[x][y-d];
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5248