akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n){
        cin >> c[i];
        rep(j, m){
            cin >> a[i][j];
        }
    }

    ll ans = 10000000000;
    bool ok = false;
    rep(i, 1<<n){
        vector<int> useC(n, 0);
        rep(j, n) if(i>>j & 1) useC[j] = 1;
        vector<int> xx(m, x);
        ll val = 0;
        rep(j, n){
            if(useC[j] == 1){
                rep(k, m){
                    xx[k] -= a[j][k];
                }
                val += c[j];
            }
        }
        bool okk = true;
        rep(j, m) if(xx[j] > 0) okk =false;
        if (okk){
            ans = min(ans, val);
            ok = true;
        }
    }

    if (ok){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
typedef long long LL;

int p[5][5];

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string a,b;
  int i;
  cin>>a>>b;
  if(a.size()==b.size())
  {
    for(i=0; i<a.size(); i++)
    {
      cout<<a[i]<<b[i];
    }
  }
  else
    if(a.size()>b.size())
    {
      for(i=0; i<b.size(); i++)
      {
        cout<<a[i]<<b[i];
      }
      cout<<a[i];
    }
  else
  {
     for(i=0; i<a.size(); i++)
      {
        cout<<a[i]<<b[i];
      }
      cout<<b[i];
  }
    
}


Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5 {
    class Program {
        //スタートから(x, y)までの最短距離
        static int[,] cost;

        static int H;
        static int W;

        static int[,] s;

        static void Main(string[] args) {
            var S = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            H = S[0];
            W = S[1];
            
            cost = new int[H, W];

            //全ての白マスの数の合計
            int white = 0;
            //解答
            int ans = -1;

            //全ての要素を-1にする
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    cost[i, j] = -1;
                }
            }

            //全ての点の情報を記憶しておく
            s = new int[H, W];
            for (int i = 0; i < H; i++) {
                string X = Console.ReadLine();
                for (int j = 0; j < W; j++) {
                    s[i, j] = X[j];
                    if (X[j] == '.') {
                        white++;  //ここで白マスをカウント
                    }
                }
            }

            //最短距離
            int min_cost = bfs();

            //出力
            if (min_cost == -1) {
                ans = -1;
            } else {
                ans = white - (min_cost + 1);
            }
            Console.WriteLine(ans);
        }

        static int bfs() {
            //移動可能なマスをループで簡単に列挙
            int[] dx = { 0, 1, 0, -1 };
            int[] dy = { 1, 0, -1, 0 };

            //座標をpair(y, x)でもってqueueに入れる
            Queue<Tuple<int, int>> que = new Queue<Tuple<int, int>>();
            //スタートは(0, 0)
            Tuple<int, int> inQueue = Tuple.Create(0, 0);
            que.Enqueue(inQueue);
            cost[0, 0] = 0;

            //キューが空になるまで繰り返す
            while (que.Count != 0) {
                Tuple<int, int> p = que.Peek();
                que.Dequeue();

                //ゴールに到達したらcostを返す
                if (p.Item1 == H - 1 && p.Item2 == W - 1) {
                    return cost[p.Item1, p.Item2];
                }

                //今の地点から、4方向に向かって調査する
                for (int i = 0; i < 4; i++) {
                    //次のx座標とy座標
                    int ny = p.Item1 + dy[i];
                    int nx = p.Item2 + dx[i];

                    //エリア外に行ったら、次のループに入る
                    if (nx < 0 || ny < 0 || nx >= W || ny >= H) {
                        continue;
                    }
                    //壁にぶち当たったら、次のループに入る
                    if (s[ny, nx] == '#') {
                        continue;
                    }
                    //すでに探索済みだったら、次のループに入る
                    if (cost[ny, nx] != -1) {
                        continue;
                    }

                    cost[ny, nx] = cost[p.Item1, p.Item2] + 1;
                    Tuple<int, int> inQ = Tuple.Create(ny, nx);
                    que.Enqueue(inQ);
                }
            }
            return -1;
        }
    }
}

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

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007

int main()
{

    int h, w;
    cin >> h >> w;
    char grid[h][w];
    long long dp[h][w];
    memset(dp, -1, sizeof(dp));
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            cin >> grid[i][j];
            if(grid[i][j] == '#')
                dp[i][j] = 0;
        }
    }
    int pos = 0;
    while(pos < w && dp[0][pos] != 0)
    {
        dp[0][pos] = 1;
        pos++;
    }
    while(pos < w)
    {
        dp[0][pos] = 0;
        pos++;
    }
    pos = 1;
    while(pos < h && dp[pos][0] != 0)
    {
        dp[pos][0] = 1;
        pos++;
    }
    while(pos < h)
    {
        dp[pos][0] = 0;
        pos++;
    }
    for(int i=1; i<h; i++)
    {
        for(int j=1; j<w; j++)
        {
            if(dp[i][j] != 0)
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
        }
    }
    cout << dp[h-1][w-1]%MOD << "\n";
    return 0;
}

Measured memory_bytes: 9088
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

using namespace std;
typedef long long ll;

#define MOD 998244353
#define root 3
    
unsigned int add(const unsigned int x, const unsigned int y){
    return (x + y < MOD) ? x + y : x + y - MOD;
}
    
unsigned int sub(const unsigned int x, const unsigned int y){
    return (x >= y) ? (x - y) : (MOD - y + x);
}
    
unsigned int mul(const unsigned int x, const unsigned int y){
    return (unsigned long long)x * y % MOD;
}
    
unsigned int mod_pow(unsigned int x, unsigned int n){
    unsigned int res = 1;
    while(n > 0){
        if(n & 1){ res = mul(res, x); }
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}
    
unsigned int inverse(const unsigned int x){
    return mod_pow(x, MOD - 2);
}
    
void ntt(vector<int>& a, const bool rev = false){
    unsigned int i, j, k, l, p, q, r, s;
    const unsigned int size = a.size();
    if(size == 1) return;
    vector<int> b(size);
    r = rev ? (MOD - 1 - (MOD - 1) / size) : (MOD - 1) / size;
    s = mod_pow(root, r);
    vector<unsigned int> kp(size / 2 + 1, 1);
    for(i = 0; i < size / 2; ++i) kp[i + 1] = mul(kp[i], s);
    for(i = 1, l = size / 2; i < size; i <<= 1, l >>= 1){
        for(j = 0, r = 0; j < l; ++j, r += i){
            for(k = 0, s = kp[i * j]; k < i; ++k){
                p = a[k + r], q = a[k + r + size / 2];
                b[k + 2 * r] = add(p, q);
                b[k + 2 * r + i] = mul(sub(p, q), s);
            }
        }
        swap(a, b);
    }
    if(rev){
        s = inverse(size);
        for(i = 0; i < size; i++){ a[i] = mul(a[i], s); }
    }
}
    
vector<int> convolute(const vector<int>& a, const vector<int>& b){
    const int size = (int)a.size() + (int)b.size() - 1;
    int t = 1;
    while(t < size){ t <<= 1; }
    vector<int> A(t, 0), B(t, 0);
    for(int i = 0; i < (int)a.size(); i++){ A[i] = a[i]; }
    for(int i = 0; i < (int)b.size(); i++){ B[i] = b[i]; }
    ntt(A), ntt(B);
    for (int i = 0; i < t; i++){ A[i] = mul(A[i], B[i]); }
    ntt(A, true);
    A.resize(size);
    return A;
}

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

    vector<int> u, v;
    int N, M; cin >> N >> M;
    for(int i = 0; i < N; i++){
        int a; cin >> a; u.push_back(a);
    }
    for(int i = 0; i < M; i++){
        int a; cin >> a; v.push_back(a);
    }
    auto w = convolute(u, v);
    for(int i = 0; i < N+M-1; i++) cout << w[i] << ' ';
    cout << endl;
}

Measured memory_bytes: 25228
#include <bits/stdc++.h>
#define int long long
#include <numeric>
using namespace std;

signed main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  int total = 0;
  for( int i = 0; i < N; i++ ){
    cin >> A.at(i);
    total += A.at(i);
  }
  
  int heikin = round((double)total / (double)N);
  
  int ans = 0;
  for( int i = 0; i < N; i++ ){
    ans += ( A.at(i) - heikin )*( A.at(i) - heikin );
  }
  cout << ans << endl;
    
}

Measured memory_bytes: 256
def main():
    H, W = map(int, input().split())
    
    if H % 3 == 0 or W % 3 == 0:
        print(0)
        return

    def c(H, W):
        HW = H * W
        ans = HW
        for i in range(1, H):
            I = i * W
            O = (H - i) // 2 * W
            G = HW - I - O
            ans = min(ans, max(abs(I - O), abs(G - O), abs(G - I)))
    
        for i in range(1, H):
            I = i * W
            O = (H - i) * (W // 2)
            G = HW - I - O
            ans = min(ans, max(abs(I - O), abs(G - O), abs(G - I)))
        return ans
    
    print(min(c(H, W), c(W, H)))

main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

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

	string s;
	switch (d) {
		case 25: s = "Christmas"; break;
		case 24: s = "Christmas Eve"; break;
		case 23: s = "Christmas Eve Eve"; break;
		case 22: s = "Christmas Eve Eve Eve"; break;
		default: break;
	}

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


Measured memory_bytes: 256
Lock = False
key = int(input())
U = []
for i in range(key):
    U.append(input())
attack = int(input())
for i in range(attack):

    T = input()
    found = False
    for k in range(key):
        if T == U[k]:
            found = True
            if Lock == True:
                print("Closed by " + U[k])
                Lock = False
                break
            else:
                print("Opened by " + U[k])
                Lock = True
                break
    if found == False:
        print("Unknown " + T)

Measured memory_bytes: 7684
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e6+10;
int head[maxn],z,kl,id[maxn],val[maxn];
int fa[maxn],sz[maxn],vis[maxn],single,even,odd,fl,tot,col[maxn],indec,n,m,x,y,ans,Q,t;
struct line{int to,next,val;}q[maxn*2];
void pushline(int f,int t){q[++kl].next=head[f];head[f]=kl;q[kl].to=t;}
void dfs(int x,int co)
{
	col[x]=co;tot++;vis[x]=1;
	for(int p=head[x];int v=q[p].to;p=q[p].next)
	{
		if(vis[v]&&col[v]==col[x])fl=1;
		if(vis[v])continue;
		dfs(v,co^1);
	}
}
signed main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)cin>>x>>y,pushline(x,y),pushline(y,x);
	for(int i=1;i<=n;i++)
	{
		if(vis[i])continue;
		fl=0;tot=0;
		dfs(i,0);
		if(tot==1)single++;
		else if(!fl)even++;
		else odd++;
	}
	cout<<2*single*n-single*single+2*odd*(odd+even)-odd*odd+2*even*even;

}

Measured memory_bytes: 18992
#include <iostream>
using namespace std;
int main(void){
  while(true){

      int y=0,n;
      int a[31]={0};
      cin >> n;

      if(n==0)    break;

      a[1]=1;
      a[2]=2;
      a[3]=4;
      for(int i=4;i<31;i++){
          a[i]=a[i-1]+a[i-2]+a[i-3];
      }

      y=(a[n]/10)/365+1;
      cout << y << endl;

  }
}


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

string unbalanced (string s);

int main () {

    string s;
    cin >> s;

    cout << unbalanced(s) << endl;

    return 0;
}

string unbalanced (string s) {

    if (s.size() == 2 && s[0] == s[1]) {
        return "1 2";
    }

    for (int i = 0; i < s.size() - 2; i++) {
        set<char> sc;
        for (int j = 0; j < 3; j++) {
            sc.insert(s[i + j]);
        }
        if (sc.size() < 3) {
            return to_string(i + 1) + " " + to_string(i + 3);
        }
    }

    return "-1 -1";
}

Measured memory_bytes: 512
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        if(n == 1){
        	System.out.println(k);
        }else{
        	System.out.println((int)Math.pow((k -1), (n - 1)) * k);
        }
    }
}

Measured memory_bytes: 35628
li=input()
n=len(li)
child_li=[0]*n



ruiseki=0
for i in range(n-1):
    if li[i]=='R':
        ruiseki+=1
        if li[i+1]=='L':
            child_li[i+1]=ruiseki//2
            child_li[i]=(ruiseki+1)//2
    else:
        ruiseki=0


ruiseki=0
for i in range(n-1, 0, -1):
    if li[i]=='L':
        ruiseki+=1
        if li[i-1]=='R':
            child_li[i-1]+=ruiseki//2
            child_li[i]+=(ruiseki+1)//2
    else:
        ruiseki=0

print(*child_li)

Measured memory_bytes: 6400
n, m = map(int, input().split())
a = []
for i in range(m):
    a.append(list(map(int, input().split())))
a.sort(key=lambda x: x[1])
t = 0
b = 1
for i in range(m):
    if a[i][0] >= b:
        t += 1
        b = a[i][1]
print(t)

Measured memory_bytes: 29068
#include<string>
#include<iostream>
using namespace std;
int main()
{
	int i,m;
	string a,b;
	cin>>a;
	m=-1;
	b="";
	for(i=a.size()-1;i>=0;i--)
	{
		m++;
		if(a[i]=='p')
			b=b+'q';
		if(a[i]=='q')
			b=b+'p';
		if(a[i]=='b')
			b=b+'d';
		if(a[i]=='d')
			b=b+'b';
	}
	if(a==b)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 696
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll D, N; cin >> D >> N;

	if (N == 100) N = 101;

	if (D == 0) {
		cout << N << endl;
	}
	else if (D == 1) {
		cout << N * 100 << endl;
	}
	else if (D == 2) {
		cout << N * 10000 << endl;
	}

	return 0;
}

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

int main()
{
	ios::sync_with_stdio(false);
	int n, v;
	int R[200000] = {0};
	cin >> n;
	
	for (int i = 0; i < n; i++)
	{
		cin >> v;
		R[i] = v;
	}
	
	int minv = R[0];
	int maxv = R[1]-R[0];
	for (int j = 1; j < n; j++)
	{
		if (maxv < (R[j] - minv))
			maxv = (R[j] - minv);
		if (minv > R[j])
			minv = R[j];
	}
	
	cout << maxv << endl;
	
	return 0;
}

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

const int N=101000;

int cnt[N];

int n,k;

int main()
{
	scanf("%d%d",&n,&k);

	for(int i=k-1;i;i--)cnt[i]=i*2>=k?1:cnt[i*2]+1;

	long double ans=0;
	for(int i=1;i<=n;i++)
		ans+=(long double)1.0/(1<<cnt[i]);
	ans/=n;
	printf("%.12Lf\n",ans);

	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(){
  int s,t;
  scanf("%d",&s);
  t=s%100;
  s/=100;
  if(0<s&&s<13){
    if(0<t&&t<13)puts("AMBIGUOUS");
    else puts("MMYY");
  }else{
    if(0<t&&t<13)puts("YYMM");
    else puts("NA");
  }
  return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, K = map(int, input().split())
WD = tuple(tuple(map(int, input().split())) for _ in range(N))

l = 0
r = 2 * 10 ** 18 + 100
while (r - l) > 1:
    pos = (r + l) // 2

    cnt = 0
    for w, d in WD:
        if pos < w:
            continue
        cnt += 1 + (pos - w) // d
    if cnt >= K:
        r = pos
    else:
        l = pos

print(r)

Measured memory_bytes: 54748
#include <string>
#include <iterator>
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;

string GetStr()
{
	string str;
	getline(cin,str);
	return str;
}

vector<int> GetIntVector()
{
	string str;
	getline(cin,str);
	istringstream line( str );

	istream_iterator<int> iit(line);
	istream_iterator<int> iit_eof;

	vector<int> ret;

	for(;iit != iit_eof; iit++){
		ret.push_back(*iit);
	}

	return ret;
}

int counter;

void GoNext(vector<string>& lines,int hh,int hw)
{
	counter++;
	lines[hh][hw] = '#';

	if(hw > 0 && lines[hh][hw-1] != '#')
		GoNext(lines,hh,hw-1);

	if(hw < (int)lines[hh].size() - 1 && lines[hh][hw+1] != '#')
		GoNext(lines,hh,hw+1);

	if(hh > 0 && lines[hh-1][hw] != '#')
		GoNext(lines,hh-1,hw);

	if(hh < (int)lines.size() - 1 && lines[hh+1][hw] != '#')
		GoNext(lines,hh+1,hw);
}

void solve(int w,int h)
{
	vector<string> lines;
	for(int i = 0; i < h; i++){
		lines.push_back(GetStr());
	}

	int humanw,humanh = -1;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(lines[i][j] == '@'){
				humanh = i; humanw = j;
				break;
			}
		}
		if(humanh != -1) break;
	}

	counter = 0;

	GoNext(lines,humanh,humanw);

	cout << counter <<endl;
}

void solve1130()
{
	vector<int> v = GetIntVector();
	while(v[0] != 0 && v[1] != 0){
		solve(v[0],v[1]);
		 v = GetIntVector();
	}
}


int main()
{
	solve1130();

	return 0;
}

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

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

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

    int c[n];
    int t[n];
    for(int i=0; i<n; i++){
        cin >> c[i];
        t[i]=v[i]-c[i];
    }

    int max=-1;
    if(t[0]<0){
        max=0;
    }
    else if(t[0]>=0){
        max=t[0];
    }

    for(int i=1; i<n; i++){
        if(max<max+t[i]){
            max+=t[i];
        }
    }

    cout << max << endl;
    return 0;
}


Measured memory_bytes: 256
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  //cout<<fixed<<setprecision(10);
  ll n,m,ans=0;
  cin>>n>>m;
  vector<ll>v(n,0);
  vector<ll>z(n,1);
  for(ll i=0;i<n;i++){
    cin>>v[i];
  }
  for(ll i=0;i<m;i++){
    ll a,b;
    cin>>a>>b;
    a--;
    b--;

    if(v[a]<=v[b])z[a]=0;
    if(v[b]<=v[a])z[b]=0;
  }
  for(ll i=0;i<n;i++){
    if(z[i])ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long n, k, h[100004], f[100004];
	cin >> n >> k;
	for (long long i = 1; i <= n; i++)
		cin >> h[i];
	f[1] = 0;
	for (long long i = 2; i <= n; i++) {
		long long minn = 0x7f7f7f7f;
		for (long long j = (i - k >= 0)? i - k : 1; j < i; j++) {
			long long tmp = f[j] + abs(h[i] - h[j]);
			if (tmp < minn)
				minn = tmp;
		}
		f[i] = minn;
	}
	cout << f[n] << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    bool ans = true;
    for(int i = 0; i < N; i++){
        if(A.at(i) % 2 == 0){
            if(A.at(i) % 3 != 0 && A.at(i) % 5 != 0){
                ans = false;
            }
        }
    }
    if(ans){
        cout << "APPROVED" << endl;
    }
    else{
        cout << "DENIED" << endl;
    }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class BBishop {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            long n = s.nextLong(), m = s.nextLong();
            if (n == 1 || m == 1) {
                w.println(1);
                return;
            }
            long res = ((n + 1) / 2) * ((m + 1) / 2) + (n - (n + 1) / 2) * (m - (m + 1) / 2);
            w.println(res);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main(){
    long long n;
    cin >> n;
    vector<long long> a(n);
    long long total=0;
    long long ans = 1000000000000;
    long long totalr=0;
    long long temp;
    for(int i=0;i<n;i++){
        cin >> a[i];
        total+=a[i];
    }
    for(int i=0;i<n-1;i++){
        totalr+=a[i];
        total -= a[i];
        temp=abs(total-totalr);
        ans = min(ans,temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
// #define space printf(" ")
#define endl printf("\n")
#define vi vector<int>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define slld(x) scanf("%lld", &(x))
#define plld(x) printf("%lld", (x))
#define plldn(x) printf("%lld\n", (x))
#define sllf(x) scanf("%llf", &(x))
#define pllf(x) printf("%.9llf", (x))
#define pllfn(x) printf("%.9llf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define all(a) (a).begin(), (a).end()
#define foreach(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin);freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp()//true for a before b
{
	bool ans = 0;
	return ans;
}

struct ST_Node
{

	ST_Node()
	{
		return;
	}
	void assign_value_(int val)
	{
		return;
	}
	void merge_nodes_(ST_Node& left, ST_Node& right)
	{
		return;
	}
};

const int N = (1e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;

int cnt[N];

int main()
{
	sws;
	// clock_t clk;
	// clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int n, i, ans = 0, a, j;
	cin >> n;
	fo(i,1,n+1)
	{
		cin >> a;
		if(a > 0)
			cnt[a-1]++;
		cnt[a]++;
		cnt[a+1]++;
	}
	fo(i,0,N)
		ans = max(ans, cnt[i]);
	cout << ans;
	// Code ends here

	// clk = clock() - clk;
	// cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

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

using namespace std;

int main()
{
    int h,w;
    scanf("%d%d",&h,&w);
    char s[h+1][w+1];
    for(int o=1;o<=h;o++) scanf("%s",s[o]+1);
    bool x[h+1][w+1][h+1][w+1];
    for(int a=0;a<=h;a++) for(int b=0;b<=w;b++) for(int c=0;c<=h;c++) for(int d=0;d<=w;d++) x[a][b][c][d]=0;
    for(int o=1;o<=h;o++)
    {
        for(int i=1;i<=w;i++)
        {
            if(s[o][i]=='.') continue;
            x[o][i][o][i]=1;
            for(int j=o-1;j>=1;j--)
            {
                if(s[j][i]=='.') break;
                x[o][i][j][i]=1;
            }
            for(int j=i-1;j>=1;j--)
            {
                if(s[o][j]=='.') break;
                x[o][i][o][j]=1;
            }
            for(int a=1;a<o;a++)
            {
                for(int b=1;b<i;b++)
                {
                    x[o][i][a][b]=(x[o-1][i][a][b]||x[o][i-1][a][b]);
                }
            }
        }
    }
    vector<vector<int>> dp(h+1,vector<int>(w+1,(1<<30)));
    dp[0][1]=dp[1][0]=0;
    for(int o=1;o<=h;o++)
    {
        for(int i=1;i<=w;i++)
        {
            if(s[o][i]=='.')
            {
                dp[o][i]=min(dp[o-1][i],dp[o][i-1]);
                continue;
            }
            for(int a=1;a<=o;a++)
            {
                for(int b=1;b<=i;b++)
                {
                    if(x[o][i][a][b])
                    {
                        dp[o][i]=min(dp[o][i],min(dp[a-1][b],dp[a][b-1])+1);
                    }
                }
            }
        }
    }
    printf("%d\n",dp[h][w]);
    return 0;
}


Measured memory_bytes: 101888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll Dist(const vl& B, const ll& a, const ll& K) {
    return lower_bound(all(B), 2 * K - a) - lower_bound(all(B), K - a) + lower_bound(all(B), 4 * K - a) - lower_bound(all(B), 3 * K - a);
}
int main() {
    init();
    ll N;
    cin >> N;
    vc<ll> A(N), B(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];

    ll mask = 0, ans = 0;
    vl MA(N), MB(N);

    rep(i, 29) {
        mask = (mask << 1)|1;
        rep(j, N) MA[j] = A[j] & mask, MB[j] = B[j] & mask;
        sort(all(MB));
        ll cnt = 0;
        rep(j, N) cnt += Dist(MB, MA[j], 1 << i);
        if (cnt & 1) ans += (1 << i);
    }

    cout << ans << endl;
}

Measured memory_bytes: 9520
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
using namespace std;


int main() {
	
	int a, b, c;
	int count = 0;
	cin >> a >> b >> c;

	for (int i = a; i <= b; i++) {
		if (c % i == 0)count++;
	}

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

	//system("pause");
	return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int l,r;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]=='A')
        {
            l=i;
            break;
        }       
    } 
    for(int i=a.size()-1;i>=0;i--)
    {
        if(a[i]=='Z')
        {
            r=i;
            break;
        }
    }
    cout<<r-l+1<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
// #define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int mod = 998244353;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 300 + 10;

#define int long long
int power(int a, int b, int m = mod){if(b < 0)b += m-1; int r = 1; while(b){if(b&1)r=(r*a)%m; a = (a*a)%m; b>>=1;}return r;}

int n, a[N], s = 0;
int dp[N][N*N];
int dp2[N][N*N];

int solve(int idx, int sum){
   if(idx >= n){
      return (sum >= s-sum);
   }
   int &ans = dp[idx][sum];
   if(~ans)
      return ans;
   ans = 0;
   ans += solve(idx+1, sum+a[idx]);
   ans %= mod;
   ans += 2LL*solve(idx+1, sum)%mod;
   ans %= mod;
   return ans;
}

int solve2(int idx, int sum){
   if(idx >= n){
      return (2*sum == s);
   }
   int &ans = dp2[idx][sum];
   if(~ans)
      return ans;
   ans = 0;
   ans += solve2(idx+1, sum+a[idx]);
   ans %= mod;
   ans += solve2(idx+1, sum);
   ans %= mod;
   return ans;
}

int32_t main(){_

   cin>>n;

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

   int tot = 0;

   memset(dp, -1, sizeof dp);
   int ans1 = solve(0, 0) % mod;

   tot = ans1;

   if(s % 2 == 0){
      memset(dp2, -1, sizeof dp2);   
      int ans2 = solve2(0, 0) % mod;
      tot -= ans2;
      tot %= mod;
   }

   tot = 3*tot;
   tot %= mod;

   tot = power(3, n) - tot + mod;
   tot %= mod;
   cout<<tot;
   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works

Measured memory_bytes: 465792
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,a,b;
  cin>>n>>a>>b;
  if(n*a>b){
    cout<<b<<endl;
  } else if(n*a<b){
    cout<<n*a<<endl;
  } else{
    cout<<b<<endl;
  }
}

Measured memory_bytes: 3628
int main(void)
{
    int i, n, a;
    long sum = 0;
    int M = -1000000, m = 10000000;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &a);
        sum = sum + a;
        if (a >= M)
        {
            M = a;
        }
        if(a <= m)
        {
            m = a;
        }
    }
    printf("%d %d %ld\n", m, M, sum);
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int array[3];
	for(int i=0; i<3; i++) scanf("%d",&array[i]);
	for(int i=2; i>0; i--){
		for(int j=0; j<i; j++){
			if(array[j] > array[j+1]) swap(array[j],array[j+1]);
		}
	}
	printf("%d %d %d\n",array[0],array[1],array[2]);
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N,K;
  cin>>N>>K;
  vector<int>h(N);
  for(int i=0;i<N;i++)cin>>h[i];
  vector<int>dp(N,INT_MAX);
  dp[0]=0;
  for(int i=0;i<N;i++){
    for(int j=1;j<=K;j++){
      if(i+j<N)dp[i+j]=min(dp[i]+abs(h[i+j]-h[i]),dp[i+j]);
    }
  }
  cout<<dp[N-1]<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int k;
	cin>>k;
	string s;
	cin>>s;
	if(k<s.size()){
		for(int i=0; i<k; i++){
			cout<<s[i];
		}
		cout<<"..."<<endl;
	}else{
		cout<<s;
	}
	return 0;
}

Measured memory_bytes: 3136
n = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
c_list = list(map(int,input().split()))

score = 0

for i,a in enumerate(a_list):
    score += b_list[a-1]
    if i != 0:
        if prev + 1 == a:
            score += c_list[prev-1]
    prev = a

print(score)

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

const ll mod = 1000000007;

ll modpow(ll a, ll n){
  ll r = 1; 
  while(n) r = r*((n % 2)? a:1)%mod, a=a*a%mod, n>>=1;
  return r;
}

int main(){
  ll n, k; cin >> n >> k;
  ll sum = 0;
  vector<ll> d(k+1);
  for(int i = k; i > 0; i--){
    d[i] = modpow(k/i, n);
    for(int j = i*2; j <= k; j += i) d[i] -= d[j];
    d[i] = (d[i]%mod+mod)%mod;
    sum += i*d[i];
  }
  cout << sum%mod << endl;
}
      



Measured memory_bytes: 3976
import math

def main():
    S = list(input())

    rl_pos = []
    for i in range(len(S)-1):
        if S[i] == 'R' and S[i+1] == 'L':
            rl_pos.append(i)
    # print(rl_pos)

    # RL
    rl_count = []
    r_count = 0
    l_count = 0
    flag = True
    for si in S:
        if flag and si == 'R':
            r_count += 1
        elif si == 'L':
            flag = False
            l_count += 1
        else:  # 次のカウントへ
            rl_count.append([r_count, l_count])
            r_count = 1
            l_count = 0
            flag = True
    rl_count.append([r_count, l_count])
    # print(rl_pos)
    # print(rl_count)

    ans = [0] * len(S)
    for i in range(len(rl_pos)):
        c = rl_count[i]
        c_r = c[0]
        c_l = c[1]
        p = rl_pos[i]

        if c_r % 2 == 0:
            ans[p] += c_r // 2
            ans[p+1] += c_r // 2
        else:
            ans[p] += c_r // 2 + 1
            ans[p+1] += c_r // 2

        if c_l % 2 == 0:
            ans[p] += c_l // 2
            ans[p+1] += c_l // 2
        else:
            ans[p] += c_l // 2
            ans[p+1] += c_l // 2 + 1


    ans = [str(i) for i in ans]
    print(" ".join(ans))


if __name__ == "__main__":
    main()

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

int main() {
  while(1) {
    int n;
    cin >> n;
    if(n == 0) break;
    int pm[n], pe[n], pj[n];
    double average[n];
    double ave_me[n];
    for(int i = 0; i < n; i++) {
      cin >> pm[i] >> pe[i] >> pj[i];
      average[i] = (pm[i]+pe[i]+pj[i])/3.0;
      ave_me[i] = (pm[i]+pe[i])/2.0;
    }
    char grade[n];
    for(int i = 0; i < n; i++) {
      if(pm[i] == 100 || pe[i] == 100 || pj[i] == 100) {
	grade[i] = 'A';
      } else if(ave_me[i] >= 90) {
	grade[i] = 'A';
      } else if(average[i] >= 80) {
	grade[i] = 'A';
      } else if(average[i] >= 70) {
	grade[i] = 'B';
      } else if(average[i] >= 50 && (pm[i] >= 80 || pe[i] >= 80)) {
	grade[i] = 'B';
      } else {
	grade[i] = 'C';
      }
      cout << grade[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
double pi=3.141592653589793;

const int MOD = 1000000007;

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

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	ll n;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++){
		s[i]+=n;
		if(s[i]>'Z')s[i]-=26;
		//cout<<(int)s[i];
	}
	cout<<s<<endl;
}



Measured memory_bytes: 256
// AOJ 1364: Routing a Marathon Race
// 2018.1.22 bal4u@uu

#include <stdio.h>

#define QMAX 5000
typedef struct { int u, t, p; long long b; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int u, int t, int p, long long b)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].t = t, que[i].u = u, que[i].p = p, que[i].b = b;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

int to[41][41], hi[41]; 
int c[41];
char used[41][41];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int n, m, i, j, k, u, v, p, w, s;
	long long b, b2;

	n = in(), m = in();
	for (i = 1; i <= n; i++) c[i] = in();
	while (m--) {
		i = in(), j = in();
		k = hi[i]++, to[i][k] = j;
		k = hi[j]++, to[j][k] = i;
	}

	qsize = 0;
	b = 1 << 1, m = c[1];
	for (i = 0; i < hi[1]; i++) v = to[1][i], m += c[v], b |= 1LL << v;
	enq(1, m, 0, b);
	while (qsize) {
		u = que[0].u, m = que[0].t, p = que[0].p, b = que[0].b, deq();
		if (u == n) break;

		if (used[p][u]) continue;
		used[p][u] = 1;
		for (i = 0; i < hi[u]; i++) {
			v = to[u][i];
			if (used[u][v]) continue;
			for (s = 0, b2 = b, k = 0; k < hi[v]; k++) {
				w = to[v][k];
				if (!((b2 >> w) & 1)) s += c[w], b2 |= 1LL << w;
			}
			enq(v, m+s, u, b2);
		}
	}
	printf("%d\n", m);
	return 0;
}



Measured memory_bytes: 2080
#include<bits/stdc++.h>
using namespace std;
#define bitCount(num)  __builtin_popcount(num)
#define pb push_back
#define ll long long
#define bye return 0;
#define f(i,a,b) for( long long i=a;i<b;i++)
#define testCases long long t;cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define newLine <<"\n"
#define all(x) (x).begin(), (x).end()
#define vll vector<long long>

int main()
{
    fast
    int n;
    cin>>n;
    vector<int> arr(n,0);
    f(i,0,n)
    cin>>arr[i];
    vector<int> dp(n,INT_MAX);
    dp[0]=0;
    for(int i=0;i<n-1;i++)
    {
      dp[i+1]= min(dp[i+1],abs(arr[i]-arr[i+1])+dp[i]);
      if(i+2<n) dp[i+2]=min(dp[i+2], abs(arr[i]-arr[i+2]) + dp[i]);
    }
    cout<<dp[n-1];
    bye
}

Measured memory_bytes: 3984
# util functions

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

def pd(str)
  p str if $debugFlag
end

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

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

aa = inputs[0][0]
bb = inputs[0][1]

# body
if $debugFlag
  p aa
  p bb
end

ret = 0
if aa > bb
  ret += aa
  aa -= 1
else
  ret += bb
  bb -= 1
end

if aa > bb
  ret += aa
  aa -= 1
else
  ret += bb
  bb -= 1
end

puts ret


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define pb push_back
#define N 900000
#define ar array
typedef long long int ll;
using namespace std;
int main(void){
	fast;
	ll i,ans=0;
	string s,t;
	cin>>s>>t;
	ll n=s.length();
	for(i=0;i<n;i++){
		if(s[i]!=t[i])
		ans++;
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 3884
/*
 Educational Dp Contest Atcoder
 
 */

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define all(x) x.begin(),x.end()

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}

const ll MOD =998244353;
const ll hell=1000000007;
const int INF=1e16;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

const int N=3005;

ldb dp[N][N];

void solve()
{
    
    
    int n;
    cin>>n;
    ldb p[n+1],ans=0;
    for(int i=1;i<=n;i++)
        cin>>p[i];
    dp[0][0]=1;
    for(int j=1;j<=n;j++)
    {
        for(int k=0;k<=n;k++)
        {
            dp[j][k]=(1-p[j])*dp[j-1][k]+(k>=1?(p[j]*dp[j-1][k-1]):0);
        }
    }
    for(int j=1;j<=n;j++)
        if(j>(n-j))
            ans=ans+dp[n][j];
    cout<<setprecision(15);
    cout<<ans<<endl;
    
}

int32_t main()
{
    
    IOS;
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 141184
N , K = map(int,input().split())
P = list(int(i) for i in input().split())

ruisekiwa =[0]
for x in P:
    ruisekiwa.append(ruisekiwa[-1]+x)
maxN =0
maxArg =[0]*2
maxArg[0] = 0
maxArg[1] = 0+K
for x in range(N-(K-1)):
    cal = ruisekiwa[x+K]-ruisekiwa[x]
    if maxN <cal:
        maxN = cal
        maxArg[0]=x
        maxArg[1]=x+K
kitai = 0
p = maxArg[1]-maxArg[0]
for y in range(maxArg[0],maxArg[1]):
    kitai +=  (P[y]+1)/2
    
    
print(kitai)

Measured memory_bytes: 25604
#include <iostream>
using namespace std;
#define MAX 100

int main(){
  int a,b,array[MAX+1];

  while(cin >> a >> b){
    fill(array,array+MAX,0);
    array[--a]++;
    array[--b]++;

    while(true){
      cin >> a >> b;
      if(!a&&!b) break;
      array[--a]++;
      array[--b]++;
    }

    bool flg = false;
    if((array[0]%2==1)&&(array[1]%2==1)) flg = true;
    for(int i = 2 ; i < MAX ; i++){
      if(array[i]%2==1) flg = false;
    }

    if(!flg) cout << "NG" << endl;
    else cout << "OK" << endl;
  }

  return 0;
}

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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    vector<int> A(N+1,INF);
    
    vector<int> B(1,1);
    int tmp = 1;
    while(tmp<=100000) {
        tmp*=6;
        B.push_back(tmp);
    }
    tmp = 1;
    while(tmp<=100000) {
        tmp*=9;
        B.push_back(tmp);
    }
    A[0] = 0;
    rep(i,N+1) {
        if (i==0) continue;
        for(auto b:B) {
            if (i-b>=0) {
                A[i] = min(A[i],A[i-b]+1);
            }
        }
    }
    int ans = A[N];
    cout << ans << endl;
}


Measured memory_bytes: 3688
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[n];
        int[] count = new int[100000];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            count[a[i]]++;
        }
        int max = count[0] + count[1];
        for (int i = 1; i < 99999; i++) {
            if (max < count[i - 1] + count[i] + count[i + 1])
                max = count[i - 1] + count[i] + count[i + 1];
        }
        max = Math.max(max, count[99998] + count[99999]);
        System.out.println(max);
    }
}


Measured memory_bytes: 50592