akhauriyash/Code-Regression huggingface dataset:
def main():
    h,w = map(int,input().split())
    a = []
    for i in range(h):
        a.append(list(map(int,input().split())))
    n = []
    for i in range(h):
        for j in range(w):
            if a[i][j]%2==1:
                flg=0
                if i<h-1:
                    if a[i+1][j]%2==1:
                        a[i+1][j]+=1
                        a[i][j]-=1
                        n.append([i+1,j+1,i+2,j+1])
                        flg=1
                elif 0<i:
                    if a[i-1][j]%2==1:
                        a[i-1][j]+=1
                        a[i][j]-=1
                        n.append([i+1,j+1,i,j+1])
                        flg=1
                elif j<w-1:
                    if a[i][j+1]%2==1:
                        a[i][j+1]+=1
                        a[i][j]-=1
                        n.append([i+1,j+1,i+1,j+2])
                        flg=1
                elif 0<j:
                    if a[i][j-1]%2==1:
                        a[i][j-1]+=1
                        a[i][j]-=1
                        n.append([i+1,j+1,i+1,j])
                        flg=1
                if flg==0:
                    if i<h-1:
                        a[i+1][j]+=1
                        a[i][j]-=1
                        n.append([i+1,j+1,i+2,j+1])
                    elif j<w-1:
                        a[i][j+1]+=1
                        a[i][j]-=1
                        n.append([i+1,j+1,i+1,j+2])
                    elif i>0:
                        a[i-1][j]+=1
                        a[i][j]-=1
                        n.append([i+1,j+1,i,j+1])
                    elif j>0:
                        a[i][j-1]+=1
                        a[i][j]-=1
                        n.append([i+1,j+1,i+1,j])
    print(len(n))
    for i in range(len(n)):
        print(' '.join(list(map(str,n[i]))))

if __name__ == "__main__":
    main()


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

int main() {
  int n;
  cin >> n;
  vector<int> cnt(n + 1);
  for (int i = 2; i <= n; ++i) {
    int p = i;
    for (int j = 2; j * j <= p; ++j) {
      while (p % j == 0) {
        ++cnt[j];
        p /= j;
      }
    }
    if (p > 1) {
      ++cnt[p];
    }
  }
  vector<int> dp(76);
  dp[1] = 1;
  for (int i = 0; i <= n; ++i) {
    vector<int> next(76);
    for (int j = 0; j <= cnt[i]; ++j) {
      for (int k = 1; (j + 1) * k < 76; ++k) {
        next[(j + 1) * k] += dp[k];
      }
    }
    dp = next;
  }
  cout << dp[75] << endl;
  return 0;
}


Measured memory_bytes: 3632
package main

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

var (
	BufferSize = 10*10*10*10*10 + 10
)

func scanStr(sc *bufio.Scanner) string {
	if !sc.Scan() {
		panic(nil)
	}

	return sc.Text()
}

func scanInt(sc *bufio.Scanner) int {
	if !sc.Scan() {
		panic(nil)
	}

	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func check() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, BufferSize)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)
	v := make([]int, n, n)
	c := make([]int, n, n)

	for i := 0; i < n; i++ {
		v[i] = scanInt(sc)
	}
	for i := 0; i < n; i++ {
		c[i] = scanInt(sc)
	}

	sum := 0
	for i := 0; i < n; i++ {
		diff := v[i] - c[i]
		if diff > 0 {
			sum += diff
		}
	}

	fmt.Printf("%d\n", sum)

}

func main() {
	check()
}


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

int main()
{
	int a1,a2,a3,b1,b2,b3;
	int x[4][4];
	
	for(int i=1; i<=3; i++){
		for(int j=1; j<=3; j++){
			cin>>x[i][j];
		}
	}
	
	a1=0;
	b1=x[1][1]-a1;
	b2=x[1][2]-a1;
	b3=x[1][3]-a1;
	
	a2=x[2][1]-b1;
	a3=x[3][1]-b1;
	
	if(a2+b2==x[2][2] && a2+b3==x[2][3] && \
	   a3+b2==x[3][2] && a3+b3==x[3][3]){
		 cout<<"Yes"<<endl;
		 return 0;
	}
	
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int L, M, N;
	int i;
	int save;
	int result;
	int flag;
	
	while (scanf("%d", &L)){
		if (L == 0) break;
		
		save = result = flag = 0;
		for (i = 1; i <= 12; i++){
			scanf("%d%d", &M, &N);
			save += M - N;
			
			if (save < L){
				result++;
			}
			else if (save >= L && flag == 0){
				flag = 1;
				result++;
			}
		}
		if (save >= L){
			printf("%d\n", result);
		}
		else {
			printf("NA\n");
		}
	}
	return (0);
}

Measured memory_bytes: 612
/*
      author : nishi5451
      created: 10.08.2020 23:47:28
*/

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


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

Measured memory_bytes: 3612
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

from heapq import heappush, heappop

import __pypy__


def main():
    n, m = map(int, input().split())
    a, b = [0] * n, [0] * n
    for i in range(n):
        a[i], b[i] = map(int, input().split())
    order = sorted(range(n), key=lambda x: a[x])

    heap = []

    cnt = 0
    i, j = 0, 1
    while i < n and j <= m:
        while i < n and a[order[i]] <= j:
            heappush(heap, -b[order[i]])
            i += 1
        if heap:
            cnt -= heappop(heap)
        j += 1

    while j <= m:
        if heap:
            cnt -= heappop(heap)
        j += 1

    print(cnt)


# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


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

int main(){
    int n,m;
    typedef tuple<vector<char>,vector<char>,int> T;
    while(1){
        cin >> n >> m;
        if(n == 0 && m == 0)break;
        vector<char> cup;
        vector<char> beforecup;
        cup.resize(n);
        bool flag = true;
        rep(i,3){
            int n1;
            cin >> n1;
            rep(j,n1){
                int n2;
                cin >> n2;
                n2--;
                cup[n2] = i;
            }
        }//入力ここまで
        queue<T> que;
        que.push(T(cup,cup,0));
        while(que.size()!=0){
            T state = que.front();
            cup = get<0>(state);
            beforecup = get<1>(state);
            int movecount = get<2>(state);
            que.pop();
            int bigger[2];
            int maxcount = 0;
            bool tray[3] ={true,true,true};
            if(n == count(cup.begin(),cup.end(),0) ||n == count(cup.begin(),cup.end(),2)){
                cout << movecount << endl;
                flag = false;
                break;
            }
            rep(i,n){
                int i2 = n-i-1;
                rep(j,3){
                    if(tray[j] == true && cup[i2] == j){
                        tray[j] = false;
                        bigger[maxcount] = i2;
                        maxcount++;
                        break;
                    }
                }
                if(maxcount == 2)break;
            }
            movecount++;
            if(movecount > m) break;
            if(cup[bigger[0]]-1 >= 0){
                cup[bigger[0]]--;
                if(cup != beforecup) que.push(T(cup,get<0>(state),movecount));
                cup[bigger[0]]++;
            }
            if(cup[bigger[0]]+1 <= 2){
                cup[bigger[0]]++;
                if(cup != beforecup) que.push(T(cup,get<0>(state),movecount));
                cup[bigger[0]]--;
            }
            if(maxcount >= 2){
                if(cup[bigger[1]]-1 >= 0 && cup[bigger[1]]-1 != cup[bigger[0]]){
                    cup[bigger[1]]--;
                    if(cup != beforecup) que.push(T(cup,get<0>(state),movecount));
                    cup[bigger[1]]++;
                }
                else if(cup[bigger[1]]+1 <= 2 && cup[bigger[1]]+1 != cup[bigger[0]]){
                    cup[bigger[1]]++;
                    if(cup != beforecup) que.push(T(cup,get<0>(state),movecount));
                    cup[bigger[1]]--;
                }
            }
        }
        if(flag) cout << "-1" << endl;
    }
    return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int maxn = 1e5+10;
int a[maxn];
int main(void){
 int h,n;
 cin >> h >> n;
 ll sum = 0;
 for(int i = 0; i < n; i++){
     cin >> a[i];
     sum += a[i];
 }
 if(sum>=h)
     cout<<"Yes"<<endl;
 else
     cout<<"No"<<endl;
 return 0;

}

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

using namespace std;

int main(){
        string res;
        int sx, sy, gx, gy;
        cin>>sx>>sy>>gx>>gy;
        int lenx=abs(sx-gx);
        int leny=abs(sy-gy);
        for(int i=0;i<lenx;i++){
                res+='R';
        }
        for(int i=0;i<leny;i++){
                res+='U';
        }
        for(int i=0;i<lenx;i++){
                res+='L';
        }
        for(int i=0;i<leny;i++){
                res+='D';
        }
        res+='D';
        for(int i=0;i<lenx+1;i++){
                res+='R';
        }
        for(int i=0;i<leny+1;i++){
                res+='U';
        }
        res+='L';
        res+='U';
        for(int i=0;i<lenx+1;i++){
                res+='L';
        }
        for(int i=0;i<leny+1;i++){
                res+='D';
        }
        res+='R';
        cout<<res<<endl;
        return 0;
}


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

#define REP(i,a,b) for(int i=a,i##_end_=b;i<=i##_end_;++i)
#define DREP(i,a,b) for(int i=a,i##_end_=b;i>=i##_end_;--i)
#define debug(x) cout<<#x<<"="<<x<<" "
#define fi first
#define se second
#define mk make_pair
#define pb push_back
typedef long long ll;

using namespace std;

void File(){
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
}

template<typename T>void read(T &_){
	_=0; T f=1; char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())_=(_<<1)+(_<<3)+(c^'0');
	_*=f;
}

ll a,b,c;

int main(){
	//File();
	read(a),read(b),read(c);
	if(a+b>=c)printf("%lld\n",b+c);
	else printf("%lld\n",b*2+a+1);
	return 0;
}


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

int main(){
	int n,q,x;
	cin>>n;
	vector<int> A;
	for(int i=0;i<n;i++){
		cin>>q;
		switch(q){
			case 0:
				cin>>x;
				A.push_back(x);
				break;
			case 1:
				cin>>x;
				cout<<A[x]<<endl;
				break;
			case 2:
				A.pop_back();
		}
	}
	return 0;
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s =sc.next();
		String ans="";
		for(int i=0;i<s.length();i++) {
			ans+="x";
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 23892
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		// スペース区切りの整数の入力
		int m = sc.nextInt();
      int a[] = new int[n];
      Map<Integer, Integer> map = new HashMap<>();
      int b=0;
      Integer c[] = new Integer[m];
      for(int i=0;i<n;i++){
        a[i] = sc.nextInt();
	   }
      Arrays.sort(a);
       for(int j=0;j<m;j++){
        b = sc.nextInt();
        c[j] = sc.nextInt();
        if(map.containsKey(c[j])){
          map.put(c[j], map.get(c[j])+b);
        }else{
          map.put(c[j],b);
        }
	   }
      Arrays.sort(c, Collections.reverseOrder());
      int k = 0;
      int kk = 0;
      int before = 0;
      for(Integer max:c){
        for(kk=0;max!=before&&k<n && kk<map.get(max)&&max>a[k];kk++){
          a[k]=max;
          k++;
        }
        before = max;
      }
      long sum =0;
      for(int ap:a){
        sum+=ap;
      }
      System.out.println(sum);
    }
}

Measured memory_bytes: 99328
#include <bits/stdc++.h>
using namespace std;
typedef pair<string, int> P;

int main(void) {
  int N;
  cin >> N;
  vector<P> v(N);
  for (int i = 0; i < N; i++) {
    string s;
    int t;
    cin >> s >> t;
    v[i] = P(s, t);
  }
  string X;
  cin >> X;
  int ans = 0;
  bool flag = false;
  for (int i = 0; i < N; i++) {
    if (flag) ans += v[i].second;
    if (v[i].first == X) flag = true;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
x = list(map(int, input().split()))

if N == 1:
	print(abs(x[0]))
else:
	a = x[0]
	for i in range(N - 1):
		b = x[i + 1]
		a, b = sorted([a, b])
		while True:
			if b % a == 0:
				break
			else:
				a, b = b % a, a
	print(abs(a))

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

#define MaxN 200005
#define INF 2140000000
#define MOD 1000000007

using namespace std;

int d[MaxN],c,To[MaxN],Next[26];
char S[MaxN],Ch[MaxN];
int main()
{
    cin.getline(S+1,MaxN);
    int N=strlen(S+1);
    for(int i=0;i<26;i++)
        Next[i]=MaxN-1;
    for(int i=N;i>0;i--)
    {
        Next[S[i]-'a']=i;
        d[i]=INF;
        for(int j=0;j<26;j++)
        {
            if(Next[j]!=N&&d[i]>1+d[Next[j]+1])
                d[i]=1+d[Next[j]+1],c=j;
        }
        To[i]=Next[c]+1;
        Ch[i]=c+'a';
    }
    int p=1;
    while(p<=N)
    {
        cout<<Ch[p];
        p=To[p];
    }
    return 0;
}


Measured memory_bytes: 2176
import math
import sys
input = sys.stdin.readline
X = [int(_) for _ in range(2500)]
r, d, x = map(int, input().split())
X[2000] = x
for i in range(2001, 2011):
    X[i] = r * X[i - 1] - d
[print(X[i]) for i in range(2001,2011)]

Measured memory_bytes: 9220
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);
    
    double PI = acos(-1);

    int r;
    cin >> r;
    double res = 2.0 * PI * r;

    cout << res << "\n";


    return 0;
}

Measured memory_bytes: 3804
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 入力
		int h = sc.nextInt();// 縦のマス数
		int w = sc.nextInt();// 横のマス数

		String[] temp = new String[h];
		for(int i = 0; i < h; i++){
			temp[i] = sc.next();
		}

		String[][] s = new String[h][w];
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				s[i] = temp[i].split("");
			}
		}

		// 判定
		String[][] o = new String[h][w];
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(s[i][j].equals("#")){
					o[i][j] = "#";
				}else{
					int cnt = 0;
					if(i != h - 1 && s[i + 1][j].equals("#")) cnt++; // 下
					if(i != 0 && s[i - 1][j].equals("#")) cnt++;  // 上
					if(j != w - 1 && s[i][j + 1].equals("#")) cnt++;  // 右
					if(j != 0 && s[i][j - 1].equals("#")) cnt++;  // 左
					if(i != 0 && j != w - 1 && s[i - 1][j + 1].equals("#")) cnt++;  // 右上
					if(i != 0 && j != 0 && s[i - 1][j - 1].equals("#")) cnt++;  // 左上
					if(i != h - 1 && j != w - 1 && s[i + 1][j + 1].equals("#")) cnt++;  // 右下
					if(i != h - 1 && j != 0 && s[i + 1][j - 1].equals("#")) cnt++;  // 左下
					o[i][j] = String.valueOf(cnt);
				}
			}
		}
		// 出力
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				System.out.print(o[i][j]);
				if(j == w - 1) System.out.println();
			}
		}
	}
}




Measured memory_bytes: 35564
#include<bits/stdc++.h>
using namespace std;
const int N=110;
int nn,n,m,c,now=1,tot,cnt;
int ans[N][N];
int main(){
	scanf("%d%d",&n,&m);
	scanf("%d%d",&nn,&tot);
	bool flag=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cnt++;
			if(cnt>tot) scanf("%d",&tot),cnt=1,now++;
			if(flag) ans[i][j]=now;
			else ans[i][m-j+1]=now;
		}
		flag=!flag;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++) cout<<ans[i][j]<<" ";
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)n;i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1001001001; const long long INFLL=1001001001001001001ll;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
    #ifdef int
        cerr<<"\x1b[7m"<<"'int' is defined as 'long long' !!!!"<<"\x1b[m"<<endl;
    #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(12)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int n;
    cin>>n;
    vi t(n);
    cin>>t;
    int sum=accumulate(ALL(t),0);
    int m;
    cin>>m;
    REP(i,m) {
        int p,x;
        cin>>p>>x;
        p--;
        cout<<sum-t[p]+x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool prime(int n){
	for(int i=2;i<sqrt(n);i++){
		if(n%i==0){
			return false;
		}
	}
	return true;
}
int main(){
	int n;
	cin>>n;
	while(!prime(n)){
		n++;
	}
	cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define maxn 25 
#define maxm 33000
#define maxk 100000
#define int long long
#define mod 1000000007
#define bi bitset<5>
int n, m, Map[maxn][maxn], g[maxn][maxm];
int CNST, f[maxn][maxm], dp[maxk], bits[maxk], a[maxk];

int read()
{
	int x = 0, k = 1;
	char c; c = getchar();
	while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * k;
}

void Up(int &x, int y) { x = (x + y) % mod; }
void Pre()
{
	bits[0] = 1; for(int i = 1; i < maxm; i ++) bits[i] = (bits[i - 1] << 1) % mod; 
	CNST = bits[n];
	for(int i = 1; i <= n; i ++)
		for(int j = 1, t = j, cnt = 1; j < CNST; j ++, t = j, cnt = 1)
			while(t) {
				if(t & 1) {
					Up(f[i][j], Map[i][cnt]);
					Up(g[i][j], Map[cnt][i]); // f : i - > j, g : j - >i
				}
				t >>= 1; cnt ++;
			}
}

signed main()
{
	n = read(), m = read();
	for(int i = 1; i <= m; i ++) {
		int x = read(), y = read();
		Map[x][y] = 1;
	}
	Pre(); dp[0] = 1;
	for(int s = 0; s < CNST; s ++)
	{
		if((s & 1) != ((s >> 1) & 1)) continue;
		for(int S = s; S; S = (s & (S - 1)))
		{
			int T = s ^ S; // S = 0;
			if((S & 1) != ((S >> 1) & 1)) continue;
			if((T & 1) != ((T >> 1) & 1)) continue;
			int tot = 0, cnt = 1, t = T;
			while(t) {
				if(t & 1) a[++ tot] = cnt;
				t >>= 1; cnt ++;
			}
			int ret = dp[T];
			for(int i = 1; i <= tot; i ++)
				ret = ret * (bits[f[a[i]][S]] - 1) % mod * bits[g[a[i]][S]] % mod;
			Up(dp[s], ret);
		}
	//	cout << (bi) s << " " << dp[s] << endl;
	}
	printf("%lld\n", (((bits[m] - dp[CNST - 1]) % mod) + mod) % mod);
	return 0;
}

Measured memory_bytes: 13056
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 5e5+1;
 
typedef long long ll;
typedef long double ld;

ll n, m, k;
ll res[3001][3001][4];
ll res1[3001][3001];

ll dfs(ll i,ll j,ll cur)
{
    if(i == n || j == m || cur == 3)
        return 0;
    if(res[i][j][cur] != -1)
        return res[i][j][cur];
    ll &ans = res[i][j][cur];
    ans = 0;
    if(res1[i][j] == 0)
        ans = max({ans,dfs(i+1,j,0), dfs(i,j+1,cur)});
    else
        ans = max({ans,res1[i][j] + dfs(i+1,j,0),res1[i][j] + dfs(i,j+1,cur+1),dfs(i,j+1,cur),dfs(i+1,j,0)});
    return ans;
}
void test_case()
{
	cin >> n >> m >> k;
    memset(res,-1,sizeof(res));
    for(int i = 0; i < k; i++)
    {
        int x, y, z;
        cin >> x >> y >> z;
        res1[x-1][y-1] = z;
    }
    cout << dfs(0,0,0);

}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}


Measured memory_bytes: 356056
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

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

int main()
{
    int x,y;
    cin>> x >> y;
    string ans="No";
    for(int a=0;a<=x;a++){
        int b=x-a;
        if(4*a+2*b==y){
            ans="Yes";
            break;
        }
    }
    cout<< ans <<endl;
    return 0;
}

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

#define ED return 0;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) long(pow(x,y))
const long long int mod = 1000000007;
unsigned long long int gcd(unsigned long long int a, unsigned long long int b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<pair<int, int>> vec (N);
    for(int i = 0;i < N;i++){
        vec.at(i).first = 0;
        vec.at(i).second = i;
    }
    for(int i = 0;i < N;i++){
        int dummy;
        cin >> dummy;
        vec.at(dummy-1).first++;
    }
    SORT(vec)
    REV(vec)
    for(int i = 0;i < K;i++){
        N -= vec.at(i).first;
        if(N == 0){
            cout << 0 << endl;
            ED
        }
    }
    cout << N << endl;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define int long long  
#define mod 1000000007
#define am 998244353
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){ 
  int c=max(a,b)-min(a,b);
  return c;
}
int gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for(int i=3;i<=sqrtNum;i+=2){
    if(num%i==0){
      return false;
    }
  }
}
int lcm(int a,int b){//最小公倍数
    return (a*b)/gcd(a,b);
}	    
signed main(){
// __builtin_ctz(N);      Nを２で何回割り切れるかを返す
//(n+1)*n/2;              １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    priority_queue<int> a;
    int b;
    string c;
    while(true){
	cin>>c;
	if(c=="end") break;
	if(c=="insert"){
	    cin>>b;
	    a.push(b);
	}
	else{
	    cout<<a.top()<<"\n";
	    a.pop();
	}
    }
}



Measured memory_bytes: 11228
#C
n,m,x = list(map(int,input().split()))
c = [0 for i in range(n)]
a = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
    buf = list(map(int,input().split()))
    c[i] = buf[0]
    for j in range(m):
        a[i][j] = buf[j+1]

cmin = 10**8
csum = 0
asum = [0 for i in range(m)]
for i in range(2**n):
    csum = 0
    for k in range(m):
        asum[k] = 0
    for j in range(n):
        if (i>>j)&1:
            csum+=c[j]
            for k in range(m):
                asum[k] += a[j][k]
    b = True
    for k in range(m):
        if asum[k]<x:
            b = False
            break
    if b:
        cmin = min(cmin,csum)

if cmin==10**8:
    print(-1)
else:
    print(cmin)

Measured memory_bytes: 9272
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
// #include <prettyprint.hpp>
using namespace std;
typedef long long llong;
static const int max_n = 1010;
static const int max_e = 2010;
static const llong max_cost = 2000000000000000;
static const string negative_cicle = "inf";
// vector<vector<llong>> matrix(max_n, vector<llong>(max_n, 0));
// vector<vector<llong>> adj_matrix(max_n, vector<llong>(max_n, max_cost));
struct Edge{
    int from;
    int to;
    llong cost;
};
// vector<vector<pair<llong, int>>> adj_list(max_n);
vector<llong> distance_table(max_n, max_cost);
vector<bool> negative_table(max_n, false);
vector<Edge> edge_list(max_e);
// vector<pair<llong, int>> points_sort_y;

int V, E, S;


void bellman_ford(int st){

    bool updated = true;
    // bool has_negative = false;
    llong update_num = 0;
    distance_table[st] = 0;

    for(int k=0;k<V;k++){
        updated = false;
        // printf("update %lld times\n", update_num);
        for(int i=0;i<E;i++){
            Edge edge = edge_list[i];
            if(distance_table[edge.from]!=max_cost && distance_table[edge.to]>distance_table[edge.from]+edge.cost){
                distance_table[edge.to] = distance_table[edge.from]+edge.cost;
                updated = true;
            }
        }
        if(!updated){
            break;
        }
    }
    // return has_negative;

}

void bellman_ford_negative_loop(int st){

    bool updated = true;
    // bool has_negative = false;
    llong update_num = 0;
    // distance_table[st] = 0;

    for(int k=0;k<V;k++){
        updated = false;
        // printf("update %lld times\n", update_num);
        for(int i=0;i<E;i++){
            Edge edge = edge_list[i];
            if(distance_table[edge.from]==max_cost){
                continue;
            }
            if(distance_table[edge.to]>distance_table[edge.from]+edge.cost){
                distance_table[edge.to] = distance_table[edge.from]+edge.cost;
                negative_table[edge.to] = true;
                updated = true;
            }
            if(negative_table[edge.from]){
                negative_table[edge.to] = true;
            }

        }
        if(!updated){
            break;
        }
    }
    // return has_negative;

}

int main(){
    int u, v;
    // bool updated = false;
    llong cost;
    bool has_negative = false;
    // printf("ok3\n");

    S = 0;
    scanf("%d %d", &V, &E);
    // printf("ok2\n");

    for(int i=0;i<E;i++){
        scanf("%d %d %lld", &u, &v, &cost);
        Edge edge = {u-1, v-1, -cost};
        edge_list[i] = edge;
        // points_sort_y.insert(make_pair(v, i));
    }


    // printf("ok1\n");

    // has_negative = bellman_ford(S);
    bellman_ford(S);
    llong ans = distance_table[V-1];
    bellman_ford_negative_loop(S);
    // fill(distance_table.begin(), distance_table.begin()+V);
    if(negative_table[V-1]){
        cout << negative_cicle << "\n";
    }else{
        printf("%lld\n",-ans);

    }



    return 0;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Prac
{
    public struct Cards
    {
        public int n ;
        public string suit;
        public Cards(String suit, int n)
        {
            this.suit = suit;
            this.n = n;
        }
        public override String ToString()
        {
            return suit + " " + n.ToString();
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var cards = new Dictionary<Cards,bool>();
            for (var i = 0; i < 52; i++)
            {
                switch (i / 13)
                {
                    case 0:
                        cards.Add(new Cards("S", i+1), false);
                        break;
                    case 1:
                        cards.Add(new Cards("H", (i%13)+1), false);
                        break;
                    case 2:
                        cards.Add(new Cards("C", (i % 13) + 1), false);
                        break;
                    case 3:
                        cards.Add(new Cards("D", (i % 13) + 1), false);
                        break;
                }
            }
            var temp = new string[2];
            for (var i = 0; i < n; i++)
            {
                temp = Console.ReadLine().Split(' ');
                cards[new Cards(temp[0], int.Parse(temp[1]))] = true;
            }
            foreach (var c in cards)
            {
                if (c.Value == false)
                {
                    Console.WriteLine(c.Key.ToString());
                }
            }


        }
    }
}

Measured memory_bytes: 5888
#include<stdio.h>

struct node{
	int key;
	struct node *next;
	struct node *prev;
};

typedef struct node * NodePointer;
NodePointer finditem(int);
void listprint(void);
NodePointer make_1node(int,NodePointer);
void deleteFirst(void);
void deleteLast(void);
void deleteNode(NodePointer);
NodePointer head;

int main(void){
	int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
    if ( com[6] == 'F' ) deleteFirst();
    else if ( com[6] == 'L' ) deleteLast();
      } else {
    delete(key); nd++; 
      }
      size--;
    }
  }
   
  listprint();
  return 0;
}

NodePointer finditem(int key){
  NodePointer x;
  x = head->next;
  while(x != head && x->key != key){
    x = x->next;
  }
  return x;
}

void insert(int key){
  NodePointer y;
  y = malloc(sizeof(struct node));
  y->key = key;
  y->next = head->next;
  head->next->prev = y;
  head->next = y;
  y->prev = head;
   
}

void listprint(){
  NodePointer cur = head->next;
  int isf = 1;
  while(1){
    if ( cur == head ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}
 
void deleteFirst(){
  NodePointer t = head->next;
  if ( t == head ) return;
  deleteNode(t);
}
 
void deleteLast(){
  NodePointer t = head->prev;
  if ( t == head ) return;
  deleteNode(t);
}
 
void delete(int key){
  NodePointer k;
  k=finditem(key);
  if(k == head) return;
   
  deleteNode(k);
   
}
void init(){
  head = malloc(sizeof(struct node));
  head->next = head;
  head->prev = head;
}

Measured memory_bytes: 31788
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int n;
    string s;
    cin >> n >> s;
    for(int i=0; i<s.size(); i++){
        int a = int(s[i]) + n;
        if(a > 90) a -= 26;
        s[i] = (char)a;
    }

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
/* https://atcoder.jp/contests/abc094/tasks/arc095_a */

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

std::vector<int> solve(const int N, std::vector<int> &X)
{
  std::vector<int> B(N);
  int idx_median = N/2 - 1;

  std::vector<int> idx_sorted(N);

  std::iota(idx_sorted.begin(), idx_sorted.end(), 0);
  std::sort(idx_sorted.begin(), idx_sorted.end(), [&](int a, int b) { return X.at(a) < X.at(b); });

  for (int i = 0; i < N; ++i) {
    int idx = i <= idx_median ? idx_median + 1 : idx_median;
    B.at(idx_sorted.at(i)) = X.at(idx_sorted.at(idx));
  }

  return B;
}

int main(int argc, char *argv[])
{
  // Input
  int N;

  std::cin >> N;

  std::vector<int> X(N);

  for (auto &e: X)
    std::cin >> e;

  // Output
  std::vector<int> B = solve(N, X);

  for (auto e: B)
    std::cout << e << std::endl;

  return 0;
}


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

using ll = long long ;

int n;
ll f[100010];
int a,b;

int main()
{
    ios::sync_with_stdio(false);
	
	cin>>n>>a>>b;
	for (int i=1;i<=n;i++) cin>>f[i];
	ll l=1;
	ll r=0x7fffffff;
	
	while (l<r)
	{
		ll mid=(l+r) >> 1;
		ll check=0;
		for (int i=1;i<=n;i++) if ((f[i]-mid*b) > 0) check+=((f[i]-mid*b+a-b-1)/(a-b));
		if (check<=mid) r=mid;else l=mid+1;
	}
	
	cout<<l;
}

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

int compare(const void *a, const void *b)
{
    return *((char *)a) - *((char *)b);
}

void reverse(char *str, int l)
{
    int i;
    char t;

    for (i = 0; i < l / 2; ++i) {
        t = str[i];
        str[i] = str[l - i - 1];
        str[l - i - 1] = t;
    }
}

int get_next_term(int a, int l)
{
    char buf[13];
    int max, min;

    sprintf(buf, "%d000000", a);
    buf[l] = '\0';

    qsort(buf, l, sizeof(char), compare);
    min = atoi(buf);

    reverse(buf, l);
    max = atoi(buf);

    return max - min;
}

int main(void)
{
    for (;;) {
        int a[21], l;
        int i, j, ans_i, ans_j;

        scanf("%d %d", &a[0], &l);
        if (a[0] == 0 && l == 0)
            break;

        for (i = 1;; ++i) {
            int f;

            a[i] = get_next_term(a[i - 1], l);

            f = 0;
            for (j = 0; j < i; ++j) {
                if (a[i] == a[j]) {
                    ans_i = i;
                    ans_j = j;
                    f = 1;
                    break;
                }
            }
            if (f)
                break;
        }

        printf("%d %d %d\n", ans_j, a[ans_j], ans_i - ans_j);
    }

    return 0;
}

Measured memory_bytes: 620
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	w := getNextInt(scanner)
	ww := make([]int, n)
	vv := make([]int, n)

	for i := 0; i < n; i++ {
		ww[i] = getNextInt(scanner)
		vv[i] = getNextInt(scanner)
	}

	var dp [101][301]int

	for i := 0; i < n; i++ {
		for wi := n; wi > 0; wi-- {
			for wwi := 300; wwi >= 0; wwi-- {
				if wi*ww[0]+wwi > w {
					continue
				}
				if wwi-ww[i]+ww[0] < 0 {
					continue
				}
				if dp[wi][wwi] < vv[i]+dp[wi-1][wwi-ww[i]+ww[0]] {
					dp[wi][wwi] = vv[i] + dp[wi-1][wwi-ww[i]+ww[0]]
				}
			}
		}
	}

	ans := 0
	for wi := 1; wi <= n; wi++ {
		for wwi := 0; wwi <= 300; wwi++ {
			if ans < dp[wi][wwi] {
				ans = dp[wi][wwi]
			}
		}
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}


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

#ifndef ONLINE_JUDGE
#define debarr(a,x,y)cerr<<#a<<":";for(int i=x;i<=y;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define deb(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S, class T>ostream &operator<<(ostream &os, const pair<S, T> &p) {return os << "(" << p.first << "," << p.second << ")";}
template<class T>ostream &operator<<(ostream &os, const vector<T> &p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class T>ostream &operator<<(ostream &os, const set<T>&p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class T>ostream &operator<<(ostream &os, const multiset<T>&p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class S, class T>ostream &operator<<(ostream &os, const map<S, T>&p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class T>void dbs(string str, T t) {cerr << str << ":" << t << "\n";}
template<class T, class...S>void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << ":" << t << ","; dbs(str.substr(idx + 1), s...);}
#else
#define deb(...){}
#define debarr(a,x,y){}
#define debmat(mat,row,col){}
#endif
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define pr(x) {cout << x << "\n"; return;}

#define int              long long
#define ll               long long
#define ld               long double
#define fi               first
#define se               second
#define mp               make_pair
#define pb               push_back
#define sz(x)            (int)x.size()
#define all(x)           x.begin(),x.end()
#define ini(x,y)         memset(x,y,sizeof(x))
#define rep(i,n)         for(int i=0;i<n;i++)
#define re(i,n)          for(int i=1;i<=n;i++)
#define fr(i,a,b)        for(int i=a;i<=b;i++)
#define fb(i,a,b)        for(int i=a;i>=b;i--)
typedef pair<int, int>   pii;
typedef vector<int>      vi;
typedef vector<pii>      vii;
typedef map<int, int>    mii;
typedef set<int>         si;
const int N = 1e3 + 10;

void solve()
{
	int h, w; cin >> h >> w;
	int k; cin >> k;
	set<int> m[h+1];
	vi row(h+1,0),col(w+1,0);
	vi v1,v2;
	rep(i,k)
	{
	    int x,y; cin>>x>>y;
	    m[x].insert(y);
	    row[x]++;
	    col[y]++;
	}
	int mx1=*max_element(all(row));
	int mx2=*max_element(all(col));
	if(mx1==w||mx2==h)
	{
	    cout<<(mx1+mx2-1)<<endl;
	    return;
	}
	for(int i=1;i<=w;i++)
	{
	    if(col[i]==mx2) v1.pb(i);
	}
	for(int i=1;i<=h;i++)
	{
	    if(row[i]==mx1) v2.pb(i);
	}
	int f=0;
	for(auto u:v2)
    {
        for(auto v:v1)
        {
        if(m[u].find(v)==m[u].end()) 
        {
            f=1;
            break;
        }
        }
    }
	cout << mx1+mx2-1+f << endl;
}
signed main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) solve();
	return 0;
}

Measured memory_bytes: 44392
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

use std::io::*;
use std::str::FromStr;

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

#[allow(dead_code)]
fn readu() -> usize {
    read::<usize>()
}

#[allow(dead_code)]
fn readi() -> i32 {
    read::<i32>()
}

fn main() {
    input! {
        s: i64,
    }
    let m: i64 = 1_000_000_000;
    let a = 1_000_000_000;
    let b: i64 = 1;
    let c = {
        if s % m > 0 {
            m - s % m
        } else {
            0
        }
    };
    let d = (s + c) / a;
    // println!("{}", a * d - b * c);
    println!("{} {} {} {} {} {}", 0, 0, a, b, c, d);
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void) {

  long a,b,c,k,count = 0;
  scanf("%ld %ld %ld %ld", &a, &b, &c, &k);
  while (b <= a) {
    count++;
    b *= 2;
  }
  while (c <= b) {
    count++;
    c *= 2;
  }
  if (count <= k) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 1616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

int main() {
  ll n;
  string s;
  cin >> n >> s;
  ll x=0;
  ll ans=0;
  for(ll i=0;i<n;i++) {
    if(s[i]=='I') {
      x++;
      ans=max(x,ans);
    }
    else {
      x--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) {
        cin >> a[i];
    }
    if(n % 2 == 0){
        ll dp[n][2];
        fill(dp[0], dp[n], -LINF);
        dp[0][0] = a[0];
        dp[1][1] = a[1];
        for (int i = 0; i < n; i++) {
            rep(j, 2) {
                if (i - 2 >= 0) dp[i][j] = max(dp[i][j], dp[i - 2][j] + a[i]);
            }
            if (i - 3 >= 0) dp[i][1] = max(dp[i][1], dp[i - 3][0] + a[i]);
        }
        cout << max(dp[n - 1][1], dp[n - 2][0]) << endl;
    }else{
        ll dp[n][3];
        fill(dp[0], dp[n], -LINF);
        dp[0][0] = a[0];
        dp[1][1] = a[1];
        dp[2][2] = a[2];
        for (int i = 0; i < n; i++) {
            rep(j, 3) {
                if (i - 2 >= 0) dp[i][j] = max(dp[i][j], dp[i - 2][j] + a[i]);
            }
            if (i - 3 >= 0) dp[i][1] = max(dp[i][1], dp[i - 3][0] + a[i]);
            if (i - 3 >= 0) dp[i][2] = max(dp[i][2], dp[i - 3][1] + a[i]);
            if (i - 4 >= 0) dp[i][2] = max(dp[i][2], dp[i - 4][0] + a[i]);
        }
        cout << max({dp[n - 1][2], dp[n - 2][1], dp[n - 3][0]}) << endl;
    }
    return 0;
}

Measured memory_bytes: 9844
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
	
  		int[] p=new int[n];
		for(int c=0;c<n;c++){
    		p[c]=sc.nextInt();
    	}
  		int[] p1=new int[n+1];
  		p1[0]=0;
  		for(int d=0;d<n;d++){
        	p1[d+1]=p1[d]+p[d];
        }
  		double max=0;
  		double kari=0;
  		
  		for(int d=k;d<n+1;d++){
          	kari=p1[d]-p1[d-k];
        	if(max<kari){
            	max=kari;
            }
        }
    
 	 double ans=(max+k)/2;
    	System.out.println(ans);
    }
}

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


bool isso(long long int a) {
	if (a == 1 || a == 0)return false;
	for (long long int i = 2; i*i <= a; ++i) {
		if ((a%i)) {
		}
		else {
			return false;
		}
	}
	return true;
}
int main() {
	while (1) {
		int n; cin >> n;
		int a = 0;
		if (!n)break;
		for (int i = n + 1; i <= 2 * n; ++i) {
			if (isso(i))a++;
		}
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <cmath>
#include <vector>
#include <iostream>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> v(N + 2);
  for(int i = 1; i <= N; ++i) {
    cin >> v[i];
  }
  int ans = 0;
  for(int i = 0; i <= N; ++i) {
    ans += abs(v[i] - v[i + 1]);
  }
  cout << ans / 2 << endl;
  return 0;
}

Measured memory_bytes: 888