akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

bool isPalindrome(int x){
  string s = to_string(x);
  int n=s.length();
  bool ret=true;
  repeat(i,(n+1)/2){
    ret &= s[i]==s[n-1-i];
  }
  return ret;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;cin>>N;
  string S;cin>>S;
  int ans = 0;
  repeat(i,N-1){
    int X=0,Y=0;
    repeat(j,N){
      if(j<i+1) X |= 1<<(S[j]-'a');
      else Y |= 1<<(S[j]-'a');
    }
    ans = max(ans,__builtin_popcount(X&Y));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[3*N];
		for(int i = 0; i < 3*N; i++)
			 a[i] = sc.nextInt();
		 
		quickSort(a);
		
		long sum = 0;
		for(int i = 0; i < N; i++)
			sum += a[3*N-1-(2*i+1)];
		
		System.out.println(sum);
	}
	
	static void quickSort(int[] a, int left, int right){
		if(left >= right){
			return;
		}
		int pl = left, pr = right, tmp;
		int p = a[(pl+pr)/2];
		while(pl <= pr) {
			while(a[pl] < p) { pl++; }
			while(a[pr] > p) { pr--; }
			if (pl <= pr){
				tmp = a[pl]; a[pl++] = a[pr]; a[pr--] = tmp;
			}
        }
        quickSort(a, left, pr);
        quickSort(a, pl, right);
	}
	
	static void quickSort(int[] a){
		quickSort(a, 0, a.length-1);
	}
}

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

signed main(void)
{
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	cout << (ll)(h2 - h1) * 60 + (m2 - m1) - k << endl;
	return 0;
}


Measured memory_bytes: 3624
#ifdef ONLINE_JUDGE

#include "bits/stdc++.h"
using namespace std;

#define ui unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double

#define all(v) v.begin(), v.end()

#define speed ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const ld PI = 3.1415926535897932384626;
ll MOD = 1000000007;
const ld EPS = 1e-9;
const int N = 3e5 + 7;

inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ui setBits(ui v) { ui c; for(c = 0 ; v; ++c) v &= (v - 1); return c; }
inline bool isPowerOfTwo(ui v) { return (v && !(v & (v - 1))); }
ll power(ll base, ull exp, ll mod = MOD) { 
	ll res = 1; base %= mod; 
	while(exp) { 
		if(exp & 1) res = (res * base)%mod; 
		exp >>= 1; base = (base * base)%mod; 
	} 
	return res; 
}
ll modInv(ll a, ll mod = MOD) { 
	if(mod == 1) return 0; 
	ll x = 1, y = 0, m = mod; 
	while(a > 1) { 
		ll q = a/m, t = m; m = a%m; a = t; t = y; y = x - q * y; x = t; 
	} 
	if(x < 0) x += mod; 
	return x; 
}
inline ui iabs(int x) { ui y = x; return (y > 0) ? y : -y; }
inline ll add(ll a, ll b, ll mod = MOD) { ll res = (a%mod + b%mod)%mod; return res; }
inline ll sub(ll a, ll b, ll mod = MOD) { ll res = (a%mod - b%mod + mod)%mod; return res; }
inline ll mult(ll a, ll b, ll mod = MOD) { ll res = (a%mod * b%mod)%mod; return res; }
inline ll div(ll a, ll b, ll mod = MOD) { ll res = (a%mod * modInv(b, mod))%mod; return res; }

#else

#include "custom.h"
using namespace std;

#endif

void openf() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	
}

int main() {
	speed;
	openf();
	ll n, ans;
	cin >> n;
	vector<ll> arr(n);
	unordered_map<ll, ll> umap; 
	for(int i = 0 ; i < n ; ++i) {
		cin >> arr[i];
		++umap[arr[i]];
	}
	if(n%2) {
		int nele = 0;
		bool sol = true;
		for(auto v : umap) {
			if(v.second == 1) {
				++nele;
			}
			else if(v.second != 2) {
				sol = false;
				break;
			}
		}
		ans = (sol && nele == 1 && umap[0] == 1) ? power(2, n/2) : 0;
	}
	else {
		bool sol = true;
		for(auto v : umap) {
			if(v.second != 2) {
				sol = false;
				break;
			}
		}
		ans = (sol && !umap[0]) ? power(2, n/2) : 0;
	}
	cout << ans << endl;
	return 0;
}  

Measured memory_bytes: 7444
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int jiecheng(int x)
{
int ans=1;
for(int i=1;i<=x;i++)ans*=i;
return ans;
} 
int main()
{
	int sum=0;
	int a;
	cin>>a>>sum;
	if(a>0)cout<<"Positive";               
    else if(sum>=0)cout<<"Zero";           
    else if((a&1)^(sum&1))cout<<"Positive";  
    else cout<<"Negative";
	return 0;
}


	



Measured memory_bytes: 256
#include <iostream>
#define NIL -1

using namespace std;

struct node{
  int l,r,p,d;
};

int x = 0;

node tree[30];

void depth(int u,int d){
  tree[u].d = d;

  if(tree[u].l != NIL) depth(tree[u].l,d + 1);
  if(tree[u].r != NIL) depth(tree[u].r,d + 1);
}

int height(int u,int h){
  //cout << "h = " << h << endl;
  if(tree[u].r != NIL) height(tree[u].r,h + 1);
  if(tree[u].l != NIL) height(tree[u].l,h + 1);

  if(h > x) {
    x = h;
    return h;
  }
  else return x;
}

int sibling(int u){
  int p;
  if(tree[u].p == NIL) return -1;
  p = tree[u].p;
  //cout << "r = " << tree[p].r << endl;
  //cout << "l = " << tree[p].l << endl;
  if(tree[p].l == u && tree[p].r != NIL) return tree[p].r;
  else if(tree[p].r == u && tree[p].l != NIL) return tree[p].l;
  else return -1;
}

int degree(int u){
  if(tree[u].l != NIL && tree[u].r != NIL) return 2;
  else if((tree[u].l != NIL && tree[u].r == NIL) || (tree[u].r != NIL && tree[u].l == NIL)) return 1;
  else return 0;
}

void classify(int u){
  if(tree[u].p == NIL) cout << "root" << endl;
  else if(tree[u].r == NIL && tree[u].l == NIL) cout << "leaf" << endl;
  else cout << "internal node" << endl;
}
void pri(int u){

  cout << "node " << u << ": " << "parent = " << tree[u].p;
  cout << ", sibling = " << sibling(u) << ", degree = " << degree(u);
  cout << ", depth = " << tree[u].d << ", height = " << height(u,0) << ", ";
  classify(u);
  x = 0;
}
int main(){

  int n,v,p,r,l;

  cin >> n;

  for(int i = 0;i < 30;i++) tree[i].p = tree[i].l = tree[i].r = NIL;

  for(int i = 0; i < n;i++){
    cin >> v;
    cin >> tree[v].l >> tree[v].r;
    r = tree[v].r;
    l = tree[v].l;
    //cout << "r = " << r << endl;
    //cout << "l = " << l << endl;
    tree[r].p = tree[l].p = v;
  }

  for(int i = 0;i < n;i++) if(tree[i].p == NIL) p = i;
  depth(p,0);
  for(int i = 0;i < n;i++) pri(i);
}

Measured memory_bytes: 3096
# -*- coding: utf-8 -*-

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    a, b, n = input_to_int_map()

    if n < b:
        return (a * n) // b

    if n < b * 2:
        return ((a * ((b * 2) - 1)) // b) - a

    return 0


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 9084
object Main extends App {

  import scala.io.StdIn._
  solve
  def solve: Unit = {
    val n = readLine.trim.toInt
    if (n != 0){
      val buildings = Array.tabulate(n){_ ⇒
        val Array(b, x, y) = readLine.trim.split(' ').map(_.toInt)
        new Building(b, Coordinate(x, y))
      }.sortBy(_.id)
      val memo = Array.tabulate(n){_ ⇒ Array.tabulate(n){_ ⇒new Route(-1, Double.MaxValue)}}
      val networks = calNetwork(buildings)
      for (from ← networks.indices){
        memo(from)(from).distance = 0
        for (to ← networks(from)){
          memo(from)(to) = new Route(to, buildings(from).distance(buildings(to)))
          memo(to)(from) = new Route(from, buildings(to).distance(buildings(from)))
        }
      }
      for (a ← 0 until n){
        for (i ← 0 until n){
          for (j ← 0 until n){
            if (memo(i)(j).distance - memo(i)(a).distance > memo(a)(j).distance) {
              memo(i)(j) = new Route(memo(i)(a).from, memo(i)(a).distance + memo(a)(j).distance)
            }
          }
        }
      }
      for (_ ← 0 until readLine.trim.toInt){
        val Array(s, g) = readLine.trim.split(' ').map(_.toInt - 1)
        var stack = g::Nil
        while (memo(stack.head)(s).from != -1){
          stack ::= memo(stack.head)(s).from
        }
        println (if (stack.head == s) stack.map(_ + 1).mkString(" ") else "NA")
      }
      solve
    }
  }
  class Route(var from: Int, var distance: Double)
  def calNetwork(buildings: Array[Building]): Array[List[Int]] = {
    val res = Array.tabulate(buildings.length){_ ⇒ Nil: List[Int]}
    for (i ← buildings.indices){
      for (j ← buildings.indices){
        if (i != j && buildings(i).canJumpTo(buildings(j))) {
          res(i) ::= j
        }
      }
    }
    res
  }
  case class Coordinate(x: Int, y: Int) {
    def - (that: Coordinate): Coordinate = Coordinate(this.x - that.x, this.y - that.y)
  }
  class Building(val id: Int, val position: Coordinate)
  {
    def canJumpTo(that: Building): Boolean = (this.position - that.position).let(it ⇒ it.x * it.x + it.y * it.y <= 50 * 50)
    def distance(that: Building): Double = (this.position - that.position).let(it ⇒ math.sqrt(it.x * it.x + it.y * it.y))
  }
  implicit class ScopeFunc[T](val value:T){
    def let[A](func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 47696
function Main(input){
var A = input.split(" ")[0];
A = parseInt(A,10);
var P = input.split(" ")[1];
P = parseInt(P,10);

var p = A * 3 + P;
var pie = p / 2;
pie = Math.floor(pie);
console.log(pie);




    
}





Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <stack>
using namespace std;
int main(){
	stack<char> st;
	string str;
	cin >> str;
	for(int i=0;i<str.size();i++){
		char letter = str[i];
		if(letter=='T'){
			if(!st.empty()){
				if(st.top()=='S'){
					st.pop();
				}else{
					st.push(letter);
				}
			}else{
				st.push(letter);
			}
		}else if(letter=='S'){
			st.push(letter);
		}
	}
	cout << st.size();
	return 0;
}


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

int H, W, N;
vector<int> a;
int B[111][111];

signed main() {
   //  入力
   cin >> H >> W >> N;
   a.resize(N);
   for (int i = 0; i < N; i++) {
      cin >> a[i];
   }

   // 使う配列を用意しておく
   vector<int> v;
   for (int i = 0; i < a.size(); i++) {
      for (int j = 0; j < a[i]; j++) {
         v.push_back(i+1);
      }
   }
   sort(v.begin(), v.end());

   int cnt = 0;
   for (int yi = 0; yi < H; yi++) {
      // 偶数なら右へ、奇数なら左へ進む
      if (yi % 2 == 0) {
         for (int xi = 0; xi < W; xi++) {
            B[yi][xi] = v[cnt];
            cnt++;
         }
      } else {
         for (int xi = W-1; xi >= 0; xi--) {
            B[yi][xi] = v[cnt];
            cnt++;
         }
      }
   }

   for (int i = 0; i < H; i++) {
      for (int j = 0; j < W-1; j++) {
         cout << B[i][j] << " ";
      }
      cout << B[i][W-1] << endl;
   }

   return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}

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


/////////////////////////////////////////////////////////////////////////////////////

int main(){
    int n,m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    int point[13];
    bool ok[13];

    for (int i = 0;i < n;i++){
        cin >> c[i];
        for (int j = 0;j < m;j++){
            cin >> a[i][j];
        }
    }
    bool solve = true;
    bool can = false;
    ll ans = 1e9;
    int cnt;
    for (int bit = 0;bit < (1 << n);bit++){
        memset(ok, false, sizeof(ok));
        memset(point, 0, sizeof(point));
        ll pay = 0;
        solve = true;
        for (int i = 0;i < n;i++){
            if (bit & (1 << i)){
                pay += c[i];
                for (int j = 0;j < m;j++){
                    point[j] += a[i][j];
                    if (point[j] >= x){
                        ok[j] = true;
                    }
                }
            }
        }   
        for (int i = 0;i < m;i++){
            if (ok[i] == false){
                solve = false;
                break;
            }
        }

        if (solve){
            can = true;
            ans = min(ans, pay);
        }
    }

    if (can == false){
        cout << -1 << endl;
    }
    else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 3592
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
using namespace std;
#define U(v) \
cerr << #v << ": " << (v) << endl

int main() {
    long long N, X;
    cin >> N >> X;
    long long sm = N;
    long long a = X, b = N - X;
    while (a != b) {
        if (a > b)
            swap(a, b);
        if (a == 1) {
            sm += (b - 1) * 2;
            b = 1;
        } else {
            sm += b / a * a * 2;
            b %= a;
            if (b == 0) {
                cout << sm - a << endl;
                return 0;
            }
        }
    }
    sm += a;
    cout << sm << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "A"
string s;
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    cin>>s;
    if(s.find("YAKI")==0) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{
#ifdef RAHUL
    freopen("input.txt","r",stdin);
#endif

string s;
cin>>s;
if (s.length()>4)
{
    /* code */
    cout<<"No"<<"\n";
}
else{

    std::map<char,int> rohan;

    for (int i = 0; i < s.length(); ++i)
    {
        /* code */
        rohan[s[i]]++;
    }
bool make =0;

    for (int i = 0; i < s.length(); ++i)
    {
        /* code */
        if (rohan[s[i]]!=2)
        {
            /* code */
            make=1;
            break;
        }
    }
    if (make==1)
    {
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n";
using namespace std;
typedef long long int ll;
int main()
{
    
    ll T,D,ct=0;
    cin>>T>>D;
    while(T--)
    {
        ll  p,q;
        cin>>p>>q;
        
        double v= sqrt(p*p+q*q);
        if(v<=D)ct++;
    }
    cout<<ct<<endl;
    return 0;
}


Measured memory_bytes: 3676
import sys
import math
import bisect

def main():
    n = int(input())
    A = list(map(int, input().split()))
    ans = 1000
    for i in range(1, n):
        if A[i-1] <= 1000 and A[i] > A[i-1]:
            r = ans % A[i-1]
            ans = ans // A[i-1] * A[i] + r
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9188
N,  M = [int(i) for i in input().split()]
cities = {}
for i in range(N):
    cities[i+1] = 0
for i in range(M):
    for c in [int(i) for i in input().split()]:
        cities[c] += 1
for key, val in sorted(cities.items()):
    print(val)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n, k;
	cin >> n >> k;
	long long int ans = (long long int)pow(n / k, 3);
	if(k % 2 == 0){
		ans += (long long int)pow(n / k + ((n % k >= k / 2) ? 1 : 0), 3);
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  int  n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int cnt = 0;
  rep(i,n){
    while(a[i] % 2 == 0){
      a[i]/= 2;
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<string>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
//#include<chrono>
//#include<time.h>
//#include<windows.h>
using namespace std;
 
//#define int ll
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
//static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
struct edge {int /*from,*/to,cost;};

main(){
    string s;
    cin >> s;
    string ans;
    REP(i,LEN(s)){
        if(!isdigit(s[i])&&!ans.empty()) ans.erase(LEN(ans)-1,1);
        else if(isdigit(s[i])) ans += s[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

int N, M, X, Y;
vector<int> xv, yv;
int xmax = INT_MIN, ymin = INT_MAX;

int main() {
	cin >> N >> M >> X >> Y;
	xv.resize(N);
	yv.resize(M);
	for (int n = 0; n < N; n++) {
		int x;
		cin >> x;
		xmax = max(xmax, x);
	}
	xmax = max(X, xmax);
	for (int m = 0; m < M; m++) {
		int y;
		cin >> y;
		ymin = min(ymin, y);
	}
	ymin = min(ymin, Y);
	if (xmax < ymin)cout << "No War" << endl;
	else cout << "War" << endl;
	return 0;
}


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

int main() {
  int n,r;
  cin>>n>>r;
  if(n>=10){
  cout<<r<<endl;
  }else{
  cout<<r+100*(10-n)<<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));
		while (true) {
			String str = br.readLine();
			String[] x_y = str.split(" ", 0);
			int x = Integer.parseInt(x_y[0]);
			int y = Integer.parseInt(x_y[1]);
			if (x == 0 && y == 0) {
				break;
			}
			if (x <= y) {
				System.out.println(x + " " + y);
			} else {
				System.out.println(y + " " + x);
			}
		}
	}
}

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

int main(){
    int mod=1000000007;
    long long n,w,ans=0;
    scanf("%lld %lld",&n,&w);
    long long dp[n+1][1000*n+1];
    for (int i=0;i<=n;i++) for (int j=0;j<=1000*n;j++) dp[i][j]=mod;
    for (int i=1;i<=n;i++) {
        long long a,b;
        scanf("%lld %lld",&a,&b);
        dp[i][b]=min(dp[i][b],a);
        for (int j=1;j<=1000*n-b;j++) {
            if (dp[i-1][j]<w) {
                dp[i][j]=min(dp[i][j],dp[i-1][j]);
                dp[i][j+b]=min(dp[i][j+b], dp[i-1][j]+a);
            }
        }
    }
    for (int i=0;i<=n;i++) for (long long j=0;j<=1000*n;j++) {
        if (dp[i][j]<=w) {
            ans=max(ans,j);
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll>a(n+1),b(m+1);
    a[0]=0,b[0]=0;
    rep(0,i,n){
        cin>>a[i+1];
        a[i+1]=a[i]+a[i+1];
    }
    rep(0,i,m){
        cin>>b[i+1];
        b[i+1]=b[i]+b[i+1];
    }
    ll ans=0;
    rep(0,i,n+1){
        if(k-a[i]<0)continue;
        auto itr=upper_bound(b.begin(),b.end(),k-a[i]);
        ans=max(ans,itr-b.begin()-1+i);
    }
    cout<<ans;
}


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

int max( int*, int);

int main(){
    int time;
    int* in;
    int* out;
    int* hide;
    int i;
    
    scanf("%d", &time);
    in = malloc(sizeof(int) * time);
    out = malloc(sizeof(int) * time);
    hide = malloc(sizeof(int) * (time + 1));
    scanf("%d", &hide[0]);
   for(i = 0; i <= time;i++){
        scanf("%d%d", &in[i], &out[i]);
    }
    
    for(i = 0; i < time; i++){
        hide[i + 1] = hide[i] + in[i] - out[i];
        if(hide[i + 1] < 0){
            printf("0\n");
            goto end;
        }
    }
    
    printf("%d\n", max(hide, time + 1));
end:
    return 0;
}

int max(int* data, int num)
{
    int i;
    int max = 0x80000000;
    for(i = 0; i < num; i++){
        if(data[i] > max){
            max = data[i];
        }
    }
    
    return max;
}


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

int main(void){
    int N, K;
    cin >> N >> K;
    vector<int> len(N);
    for(int i = 0; i < N; i++)
        cin >> len[i];

    sort(len.begin(), len.end(), greater<int>() );
    int sum = 0;
    for(int i = 0; i < K; i++)
        sum += len[i];

    cout << sum << endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n=5,arr[6],i,s;
    for(i=1;i<=n;i++)
    {
        cin>>arr[i];
        if(arr[i]==0)
            s=i;
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3424
#include <iostream>

void draw(int h, int w){
    int i, j;
    for(i = 0; i < h; i++){
        for(j = 0; j < w; j++) putchar(((i+j) & 1) ? '.' : '#');
        putchar('\n');
    }
}

int main(void){
    while(true){
        int h, w; scanf("%d%d", &h, &w);
        if(h == 0 and w == 0) break;
        draw(h, w); putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 3140
#include <stdio.h>

int main(void)
{
	long int n;
	int k;
	int i;

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

	for (i = 0; n > 0; i++)
	{
		n /= k;
	}

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

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, a[110];
bool flag[2020];

signed main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    for(int i = 0; i < (1 << N); i++){
        int sum = 0;
        for(int j = 0; j < N; j++){
            if(i & (1 << j)){
                sum += a[j];
            }
        }
        if(sum < 2010){
            flag[sum] = true;
        }
    }
    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int b;
        cin >> b;
        cout << ((flag[b]) ? "yes" : "no") << endl;
    }


    return 0;
}

/*

*/


Measured memory_bytes: 3096
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

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

fn has_8divisors(n: u8) -> bool {
    n % 2 == 1 && (1..n+1).filter(|x| n % x == 0).count() == 8
}

fn main() {
    input!{
        n: u8,
    }
    let ans = (1..n+1).filter(|&x| has_8divisors(x)).count();
    println!("{}", ans);

}


Measured memory_bytes: 2124
#include<bits/stdc++.h>
#define   endl   '\n'
#define   ll long long 
using namespace std;
 
int main() {
  char s[200010];
  cin >> s;
  ll sum  = 0;
  for (int i = 0; i < strlen(s); i++) {
  	sum += s[i]-'0';
  } 
  sum%9 == 0 ? cout << "Yes" : cout << "No";
  return 0;
}

Measured memory_bytes: 3816
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
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; }
void say(bool yes){cout<<(yes?"YES":"NO")<<endl;};

int main(){

    ll N;
    cin >> N;
    ll ans = 0;
    for(ll i = 1; i * i <= N; i++)chmax(ans, i * i);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100],dp[500][500];

int main(){
  ll ans = 0;
  cin >> n;
  ll vec[n];
  rep(i,0,n){
    cin >> m;
    vec[i] = m;
  }
  sort(vec,vec+n);
  rep(i,0,n){
    m = 0;
    int j = i;
    while(1){
      // cout << vec[i] << " " << vec[j] << endl;
      if(vec[i] != vec[j]){
        break;
      }
      m++;
      j++;
    }
    // cout << "!" << endl;
    if(vec[i] < m)ans += m-vec[i];
    else if(vec[i] > m)ans += m;
    i = j-1;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,j,k,ans=-1e9-1;
  cin>>n;
  vector<vector<int>> f(n,vector<int>(10)),p(n,vector<int>(11));
  for(i=0;i<n;i++) for(j=0;j<10;j++) cin>>f.at(i).at(j);
  for(i=0;i<n;i++) for(j=0;j<11;j++) cin>>p.at(i).at(j);
  for(i=1;i<(1<<10);i++){
    bitset<10> b(i);
    vector<int> c(n);
    int x=0;
    for(j=0;j<10;j++) if(b.test(j)) for(k=0;k<n;k++) c.at(k)+=f.at(k).at(j);
    for(k=0;k<n;k++) x+=p.at(k).at(c.at(k));
    ans=max(ans,x);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3580
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#endif

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

int const maxn = 1e5 + 5;

ll t[maxn];
ll cur[maxn];

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, k; cin >> n >> k;
	vector<ll>a(n);
	for (ll i = 0; i < n; i++)cin >> a[i];
	
	cur[k] = 1;

	for (ll i = 0; i < n; i++) {
		ll x = a[i];
		for (int y = 0; y < k + 1; y++) {
			ll kek = cur[y];
			ll l = max(0LL, y - x);
			ll r = y;
			(t[r] += kek)%=mod;
			if (l) {
				t[l - 1] -= kek;
				t[l - 1] %= mod;
				if (t[l - 1] < 0) t[l - 1] += mod;
			}
		}
		ll c = 0;
		fill_n(cur, maxn, 0);
		for (ll j = k + 1; j >= 0; j--) {
			c += t[j];
			c %= mod; if (c < 0) c += mod;
			cur[j] = c;
		}
		fill_n(t, maxn, 0);
	}

	cout << cur[0] << endl;

	return 0;
}

/*
5
2 6 15 5 10

4
2 6 15 5

*/

Measured memory_bytes: 1792
from math import gcd
from collections import Counter
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

MOD = 10**9+7

def main():
    N,*ab = map(int, read().split())

    ab_zero = 0
    ratio = []
    for a, b in zip(*[iter(ab)]*2):
        if a == 0 and b == 0:
            ab_zero += 1
        else:
            if b < 0:
                a, b = -a, -b
            if b == 0:
                a = 1
            g = gcd(a, b)
            a //= g
            b //= g
            ratio.append((a, b))
    ab_zero %= MOD
    
    s = Counter(ratio)

    bad = 1
    for k, v in s.items():
        if v == 0:
            continue
        a, b = k
        if (-b, a) in s:
            bad *= (pow(2, v, MOD) + pow(2, s[(-b, a)], MOD) -1) % MOD
            bad %= MOD            
            s[(-b, a)] = 0
        elif (b, -a) in s:
            bad *= (pow(2, v, MOD) + pow(2, s[(b, -a)], MOD) -1) % MOD
            bad %= MOD            
            s[(b, -a)] = 0
        else:
            bad *= pow(2, v, MOD)
            bad %= MOD            
        s[k] = 0

    ans = (bad + ab_zero -1) % MOD
    print(ans)
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 72812
using System;
using System.Text;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace sandbox
{
    class Program
    {
        static void Main(string[] args)
        {
            var consoleReader = new ConsoleReader(Console.In);
            var N = consoleReader.Int;
            var M = consoleReader.Int;
            var works = consoleReader.Repeat(N).Select(cr => new PartTimeWork { days = cr.Int, pay = cr.Int })
                .Where(w => w.days <= M)
                .OrderBy(w => w.days)
                .ToArray();

            var remaining = new SortedList<int, int>(Comparer<int>.Create((p1, p2) => p2 - p1));
            long pay = 0;
            var i = 0;

            for (int d = 1; d <= M; d++)
            {
                while (i < works.Length && works[i].days <= d)
                {
                    var p = works[i++].pay;
                    if (remaining.ContainsKey(p))
                        ++remaining[p];
                    else
                        remaining.Add(p, 1);
                }

                if (remaining.Count > 0)
                {
                    var first = remaining.First();
                    pay += first.Key;
                    if (first.Value > 1)
                        --remaining[first.Key];
                    else
                        remaining.RemoveAt(0);
                }
            }

            Console.WriteLine(pay);
        }
        struct PartTimeWork
        {
            public override string ToString() => $"days:{days}, pay:{pay}";
            public int days;
            public int pay;
        }
    }

    class ConsoleReader
    {
        private Queue<string> queue = new Queue<string>();
        private TextReader textReader;
        public ConsoleReader(TextReader tr) { textReader = tr; }
        public int Int => int.Parse(String);
        public long Long => long.Parse(String);
        public double Double => double.Parse(String);
        public string String
        {
            get
            {
                if (queue.Count > 0) return queue.Dequeue();
                var line = textReader.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 1; i < line.Length; i++) queue.Enqueue(line[i]);
                return line[0];
            }
        }
        public class RepeatReader
        {
            ConsoleReader cr; int count;
            public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; }
            public IEnumerable<T> Select<T>(Func<ConsoleReader, T> func) { for (int i = 0; i < count; i++) yield return func(cr); }
            public IEnumerable<string> String { get { for (int i = 0; i < count; i++) yield return cr.String; } }
            public IEnumerable<int> Int { get { for (int i = 0; i < count; i++) yield return cr.Int; } }
            public IEnumerable<double> Double { get { for (int i = 0; i < count; i++) yield return cr.Double; } }
        }
        public RepeatReader Repeat(int count) => new RepeatReader(this, count);
    }
}


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

typedef pair<int, int> Pii;

void readint(int N, vector<int> &a);
void readdouble(int N, vector<double> &a);
void readindex(int N, vector<int> &a);



signed main(){

    int H, W, D;
    cin >> H >> W >> D;
    vector<vector<int>> A(H, vector<int>(W));
    REP(i, H){
        readindex(W, A[i]);
    }
    int Q;
    cin >> Q;
    vector<int> L(Q), R(Q);
    REP(i, Q){
        cin >> L[i] >> R[i];
        L[i]--;
        R[i]--;
    }

    vector<Pii> coor(H * W);
    REP(i, H){
        REP(j, W){
            coor[A[i][j]] = Pii(i, j);
        }
    }

    vector<int> cons(H * W, 0);

    FOR(i, D, H * W){
        int tmp = llabs(coor[i].first - coor[i - D].first) + llabs(coor[i].second - coor[i - D].second);
        cons[i] = cons[i - D] + tmp; 
    }

    REP(i, Q){
        int ans = cons[R[i]] - cons[L[i]];
        cout << ans;
        if(i != Q - 1) cout << endl;
    }
    
    return 0;
}








void readint(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readdouble(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}
void readindex(int N, vector<int> &a){
    REP(i, N){
        cin >> a[i];
        a[i]--; 
    }
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n, m; std::cin >> n >> m;
  vi dp(n);
  vvi to(n), from(n);
  vector<bool> isStart(n, true);
  rep(i, m) {
    int x, y; std::cin >> x >> y;
    --x, --y;
    to[x].pb(y);
    from[y].pb(x);
    isStart[y] = false;
  }
  vi sp;
  rep(i, n) if(isStart[i]) sp.pb(i);
  vi que;
  vi remain(n); rep(i, n) remain[i] = from[i].size();
  rep(i, sp.size()) {
    que.pb(sp[i]);
    rep(j, que.size()) {
      for (auto &v : from[que[j]]) {
        chmax(dp[que[j]], dp[v]+1);
      }
      for (auto &v : to[que[j]]) {
        remain[v]--;
        if (remain[v] == 0) que.pb(v);
      }
    }
    que.clear();
  }
  int ans = 0;
  rep(i, n) chmax(ans, dp[i]);
  std::cout << ans << "\n";
}


Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int h,w,k; cin >> h >> w >> k;
	vector<string> s(h);
	rep(i,h) cin >> s[i];
	vi rn(h,0);
	rep(i,h)rep(j,w){
		if(s[i][j]=='#')rn[i]++;
	}
	int st = 0;
	rep(i,h){
		if(rn[i]==0) st++; else break;
	}
	int cnt = 1;
	vvi a(h,vi(w));
	rep2(i,st,h){
		if(rn[i]==0){
			rep(j,w) a[i][j] = a[i-1][j];
			continue;
		}
		int cntj = 0;
		rep(j,w){
			if(s[i][j]=='#'&&cntj<rn[i]){
				if(cntj>0||j==0&&i!=st)cnt++;
				cntj++;
			}else if(j==0&&i!=st) cnt++;
			a[i][j] = cnt;
		}
	}
	rep(i,st)rep(j,w) a[i][j] = a[st][j];
	rep(i,h){
		rep(j,w) cout << a[i][j] << " ";
		cout << endl;
	}
}


Measured memory_bytes: 1280
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()
A = getList()

numlist = [0] * N
list_zero = 3
ans = 1

for i in range(N):
    if A[i] == 0:
        ans *= list_zero
        list_zero -= 1
        numlist[0] += 1
    else:
        ans *= numlist[A[i] - 1]
        numlist[A[i] - 1] -= 1
        numlist[A[i]] += 1
    ans %= mod
print(ans % mod)

Measured memory_bytes: 75044
#include<iostream>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;

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

    map<int,ll> cnt;
    for(int i = 0; i < n; i++){
        int cp = a[i];
        for(int j = 2; j*j <= cp; j++){
            if(cp%j)    continue;
            cnt[j] += a[i];
            while(cp%j == 0)    cp /= j;
        }
        if(cp != 1) cnt[cp] += a[i];
    }

    ll ans = 0;
    for(auto p : cnt)   ans = max(ans, p.second);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3148
(defun solve (xs &optional (x 0) (ans 0))
  (cond
    ((null xs) ans)
    ((equal (first xs) #\D) (solve (rest xs) (1- x) (max ans (1- x))))
    (t                      (solve (rest xs) (1+ x) (max ans (1+ x))))))


(let ((n (read))
      (xs (concatenate 'list (read-line))))
     (princ (solve xs)))

Measured memory_bytes: 13540
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()){
        	int a = scan.nextInt()*4+scan.nextInt()*2+scan.nextInt();
        	System.out.println((a==1||a==6)?"Open":"Close");
        }
    }
}

Measured memory_bytes: 17164
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main() {
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	for(int i=1;i<=5;i++){
		if(a!=i&&b!=i&&c!=i&&d!=i&&e!=i)cout<<i;
	}
	return 0;
}

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

using namespace std;

int func(int x) {
  int res = 0;
  for (int i = 1; i <= x; i++) {
    if (x % i == 0) res++;
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 2 == 0) continue;
    if (func(i) == 8) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

int main(){
    char str[1001];

    while(1){
        scanf("%s", str);
        if (str[0] == '0' )break;
        int sum = 0;
        for ( int i = 0; i < strlen(str); i++){
            sum += (str[i] - '0');
        }

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

    }
        return 0;

}

Measured memory_bytes: 2684