akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n){
        int info[4][3][10] = {0};
        rep(i,n){
            int a, b, c, d;
            cin >> a >> b >> c >> d;
            a--; b--; c--;
            info[a][b][c] += d;
        }
        rep(i,4){
            rep(j,3){
                rep(k,10){
                    cout << ' ' << info[i][j][k];
                }
                cout << endl;
            }
            if(i != 3){
                rep(l,20) cout << '#';
                cout << endl;
            }
        }
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;
#define max(a, b) ((a) > (b) ? (a) : (b))

int main(void){
	int n,m;
	cin>>n>>m;
	int s[n],t[m];
	rep(i,n)cin>>s[i];
	rep(i,m)cin>>t[i];

	ll dp[n+1][m+1];
	rep(i,n+1)dp[i][0]=1;
	rep(i,m+1)dp[0][i]=1;
	rep(i,n){
		int ii=i+1;
		rep(j,m){
			int jj=j+1;
			if(s[i]==t[j])dp[ii][jj]=(dp[ii][j]+dp[i][jj])%MAX;
			else dp[ii][jj]=((dp[ii][j]+dp[i][jj])%MAX+MAX-dp[i][j])%MAX;
		}
	}

	cout<<dp[n][m]<<endl;
	return 0;
}


Measured memory_bytes: 31488
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
int dp[55][55];
int dx[4] = {1,-1,0,0}, dy[4] = {0,0,1,-1};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	int white = 0;
	rep(i,h){
		cin >> s[i];
		rep(j,w){
			if(s[i][j] == '.') ++white;
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	queue<P> que;
	que.push(P(0, 0));
	while(!que.empty()){
		P cur = que.front();
		que.pop();
		rep(i,4){
			int ny = cur.first + dy[i];
			int nx = cur.second + dx[i];
			if(ny < 0 || h <= ny) continue;
			if(nx < 0 || w <= nx) continue;
			if(s[ny][nx] == '#') continue;
			if(dp[ny][nx] <= dp[cur.first][cur.second]+1) continue;
			dp[ny][nx] = dp[cur.first][cur.second] + 1;
			que.push(P(ny, nx));
		}
	}
	if(dp[h-1][w-1] == INF){
		cout << -1 << endl;
		return 0;
	}
	int ans = white - dp[h-1][w-1] - 1;
	chmax(ans, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

int main() {
    int h, w, k, x1, y1, x2, y2;
    cin >> h >> w >> k >> x1 >> y1 >> x2 >> y2;

    vector<vector<bool>> c(h + 2, vector<bool>(w + 2, false));
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;

        for (int j = 0; j < w; j++) {
            c[i + 1][j + 1] = (s[j] == '.');
        }
    }

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

    long long inf = 1LL << 61;

    vector<vector<vector<long long>>> dp(h + 2, vector<vector<long long>>(w + 2, vector<long long>(4, inf)));
    priority_queue<tuple<long long, int, int, int>,
            vector<tuple<long long, int, int, int>>,
            greater<tuple<long long, int, int, int>>> que;
    for (int i = 0; i < 4; i++) {
        dp[x1][y1][i] = 0;
        que.push(make_tuple(0, x1, y1, i));
    }

    while (!que.empty()) {
        tuple<long long, int, int, int> q = que.top();
        que.pop();

        int x = get<1>(q);
        int y = get<2>(q);
        int d = get<3>(q);

        for (int i = 0; i < 4; i++) {
            if (i == d && c[x + dx[i]][y + dy[i]] && dp[x + dx[i]][y + dy[i]][i] > dp[x][y][d] + 1) {
                dp[x + dx[i]][y + dy[i]][i] = dp[x][y][d] + 1;
                que.push(make_tuple(dp[x + dx[i]][y + dy[i]][i], x + dx[i], y + dy[i], i));
            } else if (i != d && dp[x][y][i] > ((dp[x][y][d] + k - 1) / k) * k) {
                dp[x][y][i] = ((dp[x][y][d] + k - 1) / k) * k;
                que.push(make_tuple(dp[x][y][i], x, y, i));
            }
        }
    }

    long long r = *min_element(dp[x2][y2].begin(), dp[x2][y2].end());
    cout << (r < inf ? (r + k - 1) / k : -1) << endl;
}


Measured memory_bytes: 284920
package main

import (
        "fmt"
)

func solution(n int, a []int) int {
        all, bad := 1, 1
        for i := 0; i < n; i++ {
                all *= 3
                if a[i]%2 == 0 {
                        bad *= 2
                }
        }
        return all - bad
}

func main() {
        var n int
        fmt.Scan(&n)
        a := make([]int, n)
        for i := range a {
                fmt.Scan(&a[i])
        }
        fmt.Println(solution(n, a))
}

Measured memory_bytes: 1772
import java.util.*;

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

        long[] num = new long[26];
        for(int i=0; i<s.length(); i++){
            num[s.charAt(i) - 'a']++;
        }
        long ans = 1 + (long)(s.length()) * (long)((s.length() - 1)) / 2;
        for(int i=0; i<26; i++){
            ans -= num[i] * (num[i] - 1) / 2;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 26740
from collections import defaultdict


def resolve():
    n, k = list(map(int, input().split()))
    a = list(map(int, input().split()))
    d = defaultdict(int)
    for ai in a:
        d[ai] += 1

    if len(d) <= k:
        print("0")
    else:
        dd = sorted(d.values())
        ans = sum([v for v in dd[:len(d) - k]])
        print(ans)


if __name__ == "__main__":
    resolve()


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

namespace abc147_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int value = input.Length;
            int hug = 0;  //hug回数の初期値
            string[] a = new string[value];
            for (int i = 0; i < value; ++i)
            {
                a[i] = input.Substring(i, 1);
            }
            for(int i = 0; i < (value / 2); ++i)
            {
                if (a[i] != a[value - (i+1)])
                {
                    hug++;
                }
            }
            Console.WriteLine(hug);
        }
    }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
constexpr LL kInf = 1e18;
typedef pair<int, int> P;

int H, W;
int Ch, Cw;
int Dh, Dw;
vector<string> S;
vector<vector<LL>> C;

int main() {
  cin >> H >> W;
  cin >> Ch >> Cw; --Ch, --Cw;
  cin >> Dh >> Dw; --Dh, --Dw;
  S.resize(H);
  C.resize(H, vector<LL>(W, kInf));
  for(int i = 0; i < H; ++i) cin >> S[i];

  deque<P> que;
  que.push_front({Ch, Cw});
  C[Ch][Cw] = 0;
  while (!que.empty()) {
    auto [r, c] = que.front(); que.pop_front();
    LL dist = C[r][c];
    vector<pair<int, int>> ds = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
    for (auto [dr, dc] : ds) {
      int nr = r + dr, nc = c + dc;
      if (nr < 0 || H <= nr || nc < 0 || W <= nc) continue;
      if (S[nr][nc] != '#') {
        if (C[nr][nc] > dist) {
          C[nr][nc] = dist;
          que.push_front({nr, nc});
        }
      }
    }

    for (int y = r - 2; y <= r + 2; ++y) {
      for (int x = c - 2; x <= c + 2; ++x) {
        if (y < 0 || H <= y || x < 0 || W <= x) continue;
        if (S[y][x] != '#') {
          if (C[y][x] > dist + 1LL) {
            C[y][x] = dist + 1LL;
            que.push_back({y, x});
          }
        }
      }
    }
  }

  if (C[Dh][Dw] == kInf) cout << -1 << endl;
  else                  cout << C[Dh][Dw] << endl;


}


Measured memory_bytes: 13472
while True:
    n=int(input())
    if n==0:
        break
    else:
        sum=0
        sum+=(1000-n)//500
        sum+=(1000-n)%500//100
        sum+=(1000-n)%500%100//50
        sum+=(1000-n)%500%100%50//10
        sum+=(1000-n)%500%100%50%10//5
        sum+=(1000-n)%500%100%50%10%5//1
        print(sum)


Measured memory_bytes: 5584
using System;
using System.IO;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
   
namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] sortArray = new int[n];
            int cnt = 0;
            for(int i = 0;i < n; ++i)
            {
                sortArray[i] = int.Parse(Console.ReadLine());
            }
            int m = 1;
            ArrayList G = new ArrayList();
            while(n > m)
            {
                G.Add(m);
                if ((3 * m + 1) > n) break;
                m = 3 * m + 1;
            }
            if(G.Count == 0)
            {
                G.Add(1);
            }
            Console.WriteLine(G.Count);
            for(int i = G.Count - 1;i >= 0; --i)
            {
                cnt += InsertionSort(sortArray, n, (int)G[i]);
                if (i != 0)
                {
                    Console.Write(G[i] + " ");
                }
                else
                {
                    Console.Write(G[i] + "\n");
                }
            }
            Console.WriteLine(cnt);
            for(int i = 0;i < n; ++i)
            {
                Console.WriteLine(sortArray[i]);
            }
        }
        
        public static int InsertionSort(int[] a,int n,int g)
        {
            int cnt = 0;
            for(int i = 0; i < n; ++i)
            {
                int v = a[i];
                int j = i - g;
                while( j >= 0 && a[j] > v)
                {
                    a[j + g] = a[j];
                    j = j - g;
                    ++cnt;
                }
                a[j + g] = v;
            }
            return cnt;
        }
    }
}

Measured memory_bytes: 16508
#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[i];
}
int cnt = 0;
int minA = 0;
for(int i=n-1;i>=0;i--){
	if(a[i]<=a[i-1]){
		cnt++;
	} else {
		minA = max(minA,cnt);
		cnt=0;
	}
}
cout<<minA<<endl;
return 0;
}


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

int main() {
  const double PI = acos(-1.0);
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double alpha = (H * 60 + M) / 720 * (PI * 2);
  double beta = M /60 * (PI * 2);
  double theta = alpha - beta;
  double res = sqrt(A*A + B*B - 2.0 * A * B * cos(theta));
  cout <<  fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 4128
#include<iostream>
#include<vector>
using namespace std;
int main() {
	vector<int> line;
	int time;
	int code;
	cin >> time;
	for (int i = 0; i < time; ++i) {
		cin >> code;
		line.push_back(code);
	}
	int time2;
	cin >> time2;
	int place1;
	int place2, place3;
	int answer=0;
	for (int i = 0; i < time2; ++i) {
		cin >> code;
		place2 = 0;
		place3 = time;
		while (place2 < place3) {
			place1 = (place2 + place3) / 2;
			if (line[place1] == code) {
				++answer;
				break;
			}
			else if (code < line[place1])place3 = place1;
			else place2 = place1 + 1;
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 1672
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
        cout << "Bad" << endl; 
        return 0;
    }
    cout << "Good";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    char ch;
    char abc[27]="abcdefghijklmnopqrstuvwxyz";
    int counter[26]={};
    while(cin >> ch){
        if(isupper(ch)) ch=tolower(ch);
        int num = ch - 'a';
        counter[num]++; 
    }
    for(int i=0;i<26;i++){
        cout << abc[i] <<" : "<<counter[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3076
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class DBrickBreak {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vc<int> A(N);
        for(auto& a : A) in>>a;
        int nxt = 1;
        REP(i, N){
            if(A[i]==nxt) ++nxt;
        }
        if(nxt==1) out<<"-1\n";
        else out<<N-nxt+1<<'\n';
    }
};


int main() {
	DBrickBreak solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int A, B;

long long gcd(int a, int b) {
    long long temp;
    while (a % b != 0) {
        temp = b;
        b = a % b;
        a = temp;
    }

    return b;
}
int main() {
    cin >> A >> B;


    cout << (long long)A * B / gcd(A, B) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int main(){
  int a,b,x;
  cin  >> a >> b >> x;
  if(a<=x && x<=a+b){cout << "YES" << endl;}else{cout << "NO" << endl;}
}

Measured memory_bytes: 3620
a,b,c,d,e,f=map(int,input().split())
water=[]
salt=[]
for i in range(30):
  for j in range(30):
    x=a*100*i+b*100*j
    if x<=f:
      water.append(x)
for i in range(1501):
  for j in range(1501):
    x=c*i+d*j
    if x<=f:
      salt.append(x)
water=list(set(water))
salt=list(set(salt))
stack=0
ans_sol=min(a*100,b*100)
ans_sal=0
for i in water:
  for j in salt:
    if 1<=i+j<=f and j*100<=i*e:
      if j/(i+j)>stack:
        stack=j/(i+j)
        ans_sol=i+j
        ans_sal=j
print(ans_sol,ans_sal)

Measured memory_bytes: 12436
#include <iostream>
using namespace std;
int sum(int n){
	int s = 0;
	while(n){
		s+= n%10;
		n/=10;
	}
	return s;
}
int main(){
	int n,min = 100000;
	cin>>n;
	for(int i = n-1,j = 1;i>0;i--,j++){
		int suma = sum(j) +sum(i); 
		if(suma<min) min = suma;
	}
	cout<<min<<endl;
}

Measured memory_bytes: 256
N = int(input())
money = []
for i in range(N):
    money.append(input().split())

B2Y = 380000.0

otoshidama = 0

for item in money:
    if item[1] == 'JPY':
        otoshidama += float(item[0])
    else:
        otoshidama += float(item[0])*B2Y

print(otoshidama)


Measured memory_bytes: 3060
n=int(input())
a=list(map(int,input().split()))
res=1
for i in range(n//2):
    res=(res*2)%(10**9+7)
from collections import defaultdict
data=defaultdict(int)
for i in a:
    data[i]+=1
ans=0
if n%2==0:
    for i in range(n//2):
        if data[2*i+1]!=2:
            ans=1
            break
elif n%2==1:
    for i in range(n//2):
        if data[2*i+2]!=2:
            ans=1
            break
if ans==1:print(0)
elif ans==0:print(res)

Measured memory_bytes: 14692
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-19 20:13:54
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template <class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '(' << p.first << ", " << p.second << ')'; }
template <class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { int flag = 0; for (auto e : vec) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { int flag = 0; for (auto e : st) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { int flag = 0; for (auto e : mp) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { for (T& e : vec) is >> e; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  map<int, int> mp;

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

  for (int i = 1; i <= n; ++i) {
    cout << mp[i] << '\n';
  }

  return 0;
}

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

using namespace std;
#define ll long long

const int N = 5005, P = 1000000007;
int n, a, b, f[N], ff[N], g[N][2];
int Pow(ll x, int y){
	int ans=1;
	for(; y; y>>=1, x=x*x%P) if(y&1) ans=ans*x%P;
	return ans;
}
int main() {
	scanf("%d%d%d", &n, &a, &b);
	if(a>b) swap(a, b);
	f[1]=1;
	for(int i=1; i<b; ++i){
		(f[i+1]+=f[i])%=P;
		for(int j=a+1; i+j<=b; ++j) (f[i+j]+=f[i])%=P, (ff[i+j-1]+=f[i])%=P;
	}
	g[0][0]=g[0][1]=1;
	for(int i=0; i<n; ++i){
		(g[i][1]+=ff[i])%=P;
		for(int j=1; j<a && i+j<=n; ++j) (g[i+j][0]+=g[i][1])%=P;
		for(int j=1; j<b && i+j<=n; ++j) g[i+j][1]=(g[i+j][1]+(ll)g[i][0]*f[j])%P;
		g[n][1]=(g[n][1]+(ll)g[i][0]*ff[n-i])%P;
	}
	printf("%lld\n", ((ll)Pow(2, n)-g[n][0]-g[n][1]+P+P)%P);
	return 0;
}

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

bool bitSearch(int A[], int n, int key) {
  for (int bit = 0; bit < (1<<n); bit ++ ) {
    vector<int> S;
    for (int i = 0; i < n; i ++) {
      if (bit & (1 << i)) {
        S.push_back(A[i]);
      }
    }

    int sum = 0;
    vector<int>::iterator itr;
    for (itr = S.begin(); itr < S.end(); itr++) {
      sum += *itr;
    }
    if (sum == key) return true;
  }
  return false;
}

// int solve (int i, int m) {
//   if (m == 0) return 1;
//   if (i >= n) return 0;
//   int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
//   return res;
// }

int main() {
  int n; cin >> n;
  int A[n];
  // for (int i = 0; i < n; i++) cin >> A[i];
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);

  set<int> st;
  for (int bit = 0; bit < (1<<n); bit ++ ) {
    vector<int> S;
    for (int i = 0; i < n; i ++) {
      if (bit & (1 << i)) {
        S.push_back(A[i]);
      }
    }

    int sum = 0;
    vector<int>::iterator itr;
    for (itr = S.begin(); itr < S.end(); itr++) {
      sum += *itr;
    }
    st.insert(sum);
  }

  int q;cin>>q;
  for(int i = 0; i < q; i ++) {
    // int key;cin>>key;
    int key;scanf("%d", &key);

    if (st.find(key) != st.end()) cout << "yes" << endl;
    else cout << "no" << endl;
    // if ( solve(0, key)) cout << "yes" << endl;
    // else cout << "no" << endl;
    // if(bitSearch(A, n, key)) cout << "yes" << endl;
    // else cout << "no" << endl;
  }

}


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


using namespace std;

const int INF = 1e9;

int main () {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
  
    long long N, K; cin >> N >> K;
    long long ans = 1;
    ans *= K;
    for (int i = 1; i < N; ++i)
        ans *= (K-1);
    cout << ans << '\n';

    return 0;
}



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

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

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

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

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

  
  ll a,b,c;
  cin >> a >> b >> c;

  cout << min(a+b, min(b+c, c+a)) << endl;
  
}


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

int main(){
    string s;
    cin >> s;
    rep(0,s.length()){
        if(s[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
// C - Scc Puzzle
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	ll s,c; cin>>s>>c;
	ll ans = 0;

	if(s*2<=c){
		ans += s;
		c -= s*2;
		s = 0;
	}

	ll c2 = c/2;
	if(s>=c2){
		ans += c2;
		s -= c2;
		c -= c2*2;
	}

	ans += c/4;

	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    for(int i = 0; i < m; ++i) {
        if(a[i]*4*m < sum) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 100100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n,x,y;
    cin >> n >> x >> y;
    vector<vector<ll>> graph(n);
    graph[0].push_back(1);
    for (ll i=1;i<n-1;i++){
        graph[i].push_back(i-1);
        graph[i].push_back(i+1);
    }
    graph[n-1].push_back(n-2);
    graph[x-1].push_back(y-1);
    graph[y-1].push_back(x-1);
    ll visited[n];
    ll ans[n];
    fill(ans,ans+n,0);
    for (ll i=0;i<n;i++){
        fill(visited,visited+n,n+1);
        visited[i]=0;
        queue<ll> que;
        que.push(i);
        while(!que.empty()){
            ll a=que.front();
            que.pop();
            for (ll j=0;j<graph[a].size();j++){
                if (visited[graph[a][j]]>visited[a]+1){
                    visited[graph[a][j]]=visited[a]+1;
                    que.push(graph[a][j]);
                }
            }
        }
        for (ll j=0;j<n;j++){
            ans[visited[j]]=ans[visited[j]]+1;
        }
    }
    for (ll i=1;i<n;i++){
        cout << ans[i]/2 << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int N, C, K, base = 0, count = 1, T[100000];
	cin >> N >> C >> K;
	for (int i = 0; i < N; i++) cin >> T[i];
	sort(T, T+N);
	for (int i = 0; i < N; i++) {
		if (T[base] + K < T[i]||i-base+1>C) {
			base = i;
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (int) 1e9+7
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define vi vector<int>
ll xpow(ll a, ll b)
{
	if (b == 0)
		return 1;
	if (b % 2 == 0)
	{
		ll k = xpow(a, b / 2);
		return k * k;
	}
	if (b % 2 != 0)
		return a * xpow(a, b - 1);
}
int main()
{

#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out1.txt", "w", stdout);
#endif
	fio;
	ll n;
	cin >> n;
	map<ll, ll> m;
	ll sum = 0;
	for (ll i = 0; i < n; i++) {
		ll x;
		cin >> x;
		m[x]++;
		sum += x;
	}
	ll q;
	cin >> q;
	while (q--) {
		ll b, c;
		cin >> b >> c;
		ll cnt_b = m[b];
		sum = sum - cnt_b * b + cnt_b * c;
		m[b] = 0;
		m[c] += cnt_b;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 9556
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> mp(h);
	for (int i = 0; i < h; i++) {
		cin >> mp[i];
	}

	vector<string> mp2;

	for (int i = 0; i < h; i++) {
		bool hh = false;
		for (int j = 0; j < w; j++) {
			if (mp[i][j] != '.') {
				hh = true;
			}
		}
		if (hh) {
			mp2.push_back(mp[i]);
		}
	}

	vector<string> mp3;

	for (int i = 0; i < w; i++) {
		string s = "";
		bool hh = false;
		for (int j = 0; j < mp2.size(); j++) {
			if (mp2[j][i] != '.') {
				hh = true;
			}
			s += mp2[j][i];
		}
		if (hh) {
			mp3.push_back(s);
		}
	}

	vector<string> mp4;
	for (int i = 0; i < mp3[0].size(); i++) {
		string s = "";
		for (int j = 0; j < mp3.size(); j++) {
			s += mp3[j][i];
		}
		mp4.push_back(s);
	}

	for (int i = 0; i < mp4.size(); i++) {
		cout << mp4[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 384
"use strict"
const  Main= (input)=> {
  const Array= input.split(" ")
  const A = parseInt(Array[0],10)
  const B = parseInt(Array[1],10)
  let result=0
  for(let i=A; i<=B ;i++){
    const ketaArray =i.toString().split("")
     if(ketaArray.join("") == ketaArray.reverse().join("")) result ++;
}
console.log(result);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 13344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define max(a,b) ((a>b)? (a):(b))
int main()
{
  int n,m;
  cin>>n>>m;
  int i=1;
  vector<int> div;
  vector<int> ans;
  while(i<=sqrt(m)){
    if(m%i==0) {
      div.push_back(i);
      div.push_back(m/i);
    }
    i++;
  }
  sort(div.begin(),div.end());
  for(auto &e:div){
    if(m/e>=n){
      ans.push_back(e);
    }
  }
  reverse(ans.begin(),ans.end());
  cout<<ans[0];
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  int n;cin>>n;
  int s[n+10];
  int sum=0;int mi=1e5;
  rep(i,0,n){
    cin>>s[i];
    if(s[i]%10!=0)mi=min(mi,s[i]);
    sum+=s[i];
  }
  if(sum%10!=0)out(sum);
  else out(max(0,sum-mi));


  return 0;
}


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

const long long MAXN = 2000 + 10, inf = 1e18;

long long n, x;
long long ans;
long long shift;
long long a[MAXN], b[MAXN];

int main() {
	cin >> n;

	n *= 2;
	
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);

	for (int i = 0; i < n; i += 2)
		ans += a[i];

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        string S = sc.Next();
        int n = S.Length;
        for (int i = 0; i < n/2; i++)
        {
            if (S[i] != S[n - i - 1])
            {
                Console.WriteLine("No");
                return;
            }
        }

        for (int i = 0; i < n / 2 / 2; i++)
        {
            if (S[i] != S[n / 2 - 1 - i])
            {
                Console.WriteLine("No");
                return;
            }
        }

        Console.WriteLine("Yes");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, M, V, P;
    cin >> N >> M >> V >> P;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    sort(all(A));

    vector<ll> sumA(N + 1);
    rep(i, N) sumA[i + 1] = sumA[i] + A[i];

    int low = -1, high = N - 1;
    while (high - low > 1) {
        int mid = (low + high) / 2;

        bool ok = false;
        int iPth = N - 1 - P + 1;
        ll Vrest = max(0, V - (P - 1) - mid - 1);
        ll Amidmax = A[mid] + M;
        int Ntgt = N - (P - 1) - mid - 1;
        ll margin = Amidmax * Ntgt - (sumA[iPth + 1] - sumA[mid + 1]);

        if (mid > N - 1 - P) ok = true;
        else if (Amidmax < A[iPth]) ok = false;
        else if (Vrest == 0) ok = true;
        else if (margin < Vrest * M) ok = false;
        else {
            //rep(i, mid + 1, mid + 1 + Vrest) {
            //    ll r = Vrest * M - Amidmax * (iPth - i + 1) - (sumA[iPth + 1] - sumA[i]) - 
            //    if ()
            //}
            ok = true;
        }

        if (ok) high = mid;
        else low = mid;
    }
    write(N - high);
}

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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> dp(n + 1, vector<int>(3, 0));  // dp[i][0~2]0:a, 1:b, 2:c
  for (int i = 1; i <= n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    dp[i][0] = max(dp[i - 1][1] + a, dp[i - 1][2] + a);
    dp[i][1] = max(dp[i - 1][2] + b, dp[i - 1][0] + b);
    dp[i][2] = max(dp[i - 1][0] + c, dp[i - 1][1] + c);
  }
  cout << max({dp[n][0], dp[n][1], dp[n][2]});
  return 0;
}

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

int main() {
  string s,t;
  cin>>s>>t;
  int n=s.size(),m=t.size();
  sort(s.begin(),s.end()); 
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  int a[100]={},b[100]={};
  bool ana=true;
  bool yeah=false;
  
  
  for(int i=0;i<min(n,m);i++){
    a[i]=s[i]; b[i]=t[i];
    if(a[i]<b[i]){
      yeah=true;
      break;
    }
    if(a[i]>b[i]){
      ana=false;
      break;
    }
  }
  if(ana==true && yeah==false)
    if(n>=m)
      ana=false;
  if(ana || yeah)
    cout<<"Yes";
  else cout<<"No";

}

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

typedef struct{
    string name;
    int Anum;
    int Pnum;
}DATA;

int main(void){
    std::ios_base::sync_with_stdio();

    DATA dt[10];

    for(int i=0;i<9;i++){
        cin>>dt[i].name>>dt[i].Anum>>dt[i].Pnum;
    }
    for(int i=0;i<9;i++){
        cout<<dt[i].name<<" ";
        cout<<dt[i].Anum+dt[i].Pnum<<" ";
        cout<<dt[i].Anum*200+dt[i].Pnum*300<<endl;
    }
    return 0;
}

Measured memory_bytes: 3120
from collections import defaultdict, deque

N, M = map(int, input().split())
edges = defaultdict(list)

for _ in range(M):
    u, v = map(int, input().split())
    edges[u - 1].append((v - 1, 1))
    edges[v - 1].append((u - 1, 1))

checked = [None] * N
checked[0] = 0

que = deque([0])

while que:
    u = que.popleft()
    for v, w in edges[u]:
        if checked[v] is not None:
            continue
        if edges[v] != []:
            que.append(v)
        checked[v] = u

print('Yes')
for i in range(N - 1):
    print(checked[i + 1] + 1)


Measured memory_bytes: 67016
#include <stdio.h>

int min(int a,int b)
{
    return a>b?b:a;
}

int main()
{
    int n;
    scanf("%d",&n);
    int b[100];
    for(int i=0;i<n-1;i++) scanf("%d",&b[i]);

    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(i==0) ans+=b[i];
        else if(i==n-1) ans+=b[i-1];
        else
        {
            ans+=min(b[i],b[i-1]);
        }
        
    }
    printf("%d\n",ans);
}

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

using namespace std;

int main(){
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	vector<string>s;
	map<string,int> cnt;
	string som;
	while(n--){cin>>som;s.push_back(som);}
 	for (string c: s){
        if(c=="AC" ||c=="WA"||c=="RE"||c=="TLE")
		cnt[c]++;

    }
	   cout<<"AC"<<" x "<<cnt["AC"]<<endl;
	    cout<<"WA"<<" x "<<cnt["WA"]<<endl;
		 cout<<"TLE"<<" x "<<cnt["TLE"]<<endl;
		  cout<<"RE"<<" x "<<cnt["RE"]<<endl;

}

Measured memory_bytes: 7436
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <queue>

using namespace std;

int r,c;
char field[30][30];

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

int main(){

  while(cin>>r>>c&&!(r==0&&c==0)){
    bool passed[30][30][30][30];
    memset(passed,0,sizeof(passed));
    // 0:ツ右,1:ツ可コ,2:ツ債カ,3:ツ湘」
    for(int i = 0; i < r; i++)
      for(int j = 0; j < c; j++)
	cin>>field[i][j];
    // ツ債カツ湘」ツつゥツづァツ開ツ始
    int sx=0;
    int sy=0;
    bool isLoop=true;
    queue<pair<pair<int,int>,pair<int,int> > > *prv
      =new queue<pair<pair<int,int>,pair<int,int> > >();
    queue<pair<pair<int,int>,pair<int,int> > > *nxt
      =new queue<pair<pair<int,int>,pair<int,int > > >();
    prv->push(make_pair(make_pair(sy,sx),make_pair(0,0)));
    while(prv->size()){
      while(prv->size()){
	pair<pair<int,int>,pair<int,int> > p=prv->front();prv->pop();
	int y=(p.first.first+r)%r;
	int x=(p.first.second+c)%c;
	int mem=p.second.first;
	int angle=p.second.second;
	if(passed[y][x][mem][angle])
	  continue;
	passed[y][x][mem][angle]=true;
	if(field[y][x]=='@'){
	  isLoop=false;
	  break;
	}
	else if(field[y][x]=='<'){
	  angle=2;
	  nxt->push(make_pair(make_pair(y+dy[angle],x+dx[angle]),make_pair(mem,angle)));
	}
	else if(field[y][x]=='>'){
	  angle=0;
	  nxt->push(make_pair(make_pair(y+dy[angle],x+dx[angle]),make_pair(mem,angle)));
	}
	else if(field[y][x]=='^'){
	  angle=3;
	  nxt->push(make_pair(make_pair(y+dy[angle],x+dx[angle]),make_pair(mem,angle)));
	}
	else if(field[y][x]=='v'){
	  angle=1;
	  nxt->push(make_pair(make_pair(y+dy[angle],x+dx[angle]),make_pair(mem,angle)));
	}
	else if(field[y][x]=='_'){
	  if(mem==0)
	    angle=0;
	  else
	    angle=2;
	  nxt->push(make_pair(make_pair(y+dy[angle],x+dx[angle]),make_pair(mem,angle)));
	}
	else if(field[y][x]=='|'){
	  if(mem==0)
	    angle=1;
	  else
	    angle=3;
	  nxt->push(make_pair(make_pair(y+dy[angle],x+dx[angle]),make_pair(mem,angle)));
	}
	else if(field[y][x]=='?'){
	  for(int i = 0; i < 4; i++){
	    nxt->push(make_pair(make_pair(y+dy[i],x+dx[i]),make_pair(mem,i)));
	  }
	}
	else if(field[y][x]>='0'&&field[y][x]<='9'){
	  mem=field[y][x]-'0';
	  nxt->push(make_pair(make_pair(y+dy[angle],x+dx[angle]),make_pair(mem,angle)));
	}
	else if(field[y][x]=='+'){
	  mem=(mem+1)%16;
	  nxt->push(make_pair(make_pair(y+dy[angle],x+dx[angle]),make_pair(mem,angle)));
	}
	else if(field[y][x]=='-'){
	  mem=(mem-1+16)%16;
	  nxt->push(make_pair(make_pair(y+dy[angle],x+dx[angle]),make_pair(mem,angle)));
	}
	else{
	  nxt->push(make_pair(make_pair(y+dy[angle],x+dx[angle]),make_pair(mem,angle)));
	}
      }
      if(!isLoop)
	break;
      swap(prv,nxt);
    }
    if(isLoop){
      cout<<"NO"<<endl;
    }
    else
      cout<<"YES"<<endl;
    delete prv,nxt;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    vector<ll> p(n);
    for(i=0;i<n;i++){
        cin >> p[i];
    }
    ll cnt = 0;
    for(i=1;i<n-1;i++){
        if(p[i]!=min({p[i-1],p[i],p[i+1]}) && p[i]!=max({p[i-1],p[i],p[i+1]})){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    char S[4];
    char T[4];

    scanf( "%s", S );
    scanf( "%s", T );

    int count = 0;
    if ( S[0] == T[0] ) count ++;
    if ( S[1] == T[1] ) count ++;
    if ( S[2] == T[2] ) count ++;

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

    return 0;
}


Measured memory_bytes: 764
n = int(input())
a = list(map(int,input().split()))
mod = 1000000007
ans = 1
l = []
for i in range(n):
  if a[i] == 0:
    l.append(0)
    ans = ans*(4-len(l))%mod
  else:
    id = -1
    count = 0
    for j in range(len(l)):
      if l[j] == a[i] - 1:
        count += 1
        id = j
    if id == -1:
      ans = 0
      break
    ans = (ans*count)%mod
    l[id] = a[i]
  if ans == 0:
    break
print(ans%mod)

Measured memory_bytes: 14396
#include <iostream>
int main(){
  int H,N;
  int A[100000];
  std::cin>>H >>N;
  for (int i=0;i<N;i++){
    std::cin>>A[i];
  }
  for (int i=0;i<N;i++){
    H=H-A[i];
  }
  if (H>0){
    std::cout<<"No";
  }
  else{
    std::cout<<"Yes";
  }
  return 0;
}
    


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    int n,a;cin>>n>>a;
    n%=500;
    if(n<=a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

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

 if(n>99 && n<106){
    cout<<1<<endl;
  }
  else if(n>199 && n<211){
    cout<<1<<endl;
  }
  else if(n>299 && n<316){
    cout<<1<<endl;
  }
    else if(n>399 && n<421){
    cout<<1<<endl;
  }
    else if(n>499 && n<526){
    cout<<1<<endl;
  }
    else if(n>599 && n<631){
    cout<<1<<endl;
  }
    else if(n>699 && n<736){
    cout<<1<<endl;
  }
    else if(n>799 && n<841){
    cout<<1<<endl;
  }
    else if(n>899 && n<946){
    cout<<1<<endl;
  }
    else if(n>999 && n<1051){
    cout<<1<<endl;
  }
    else if(n>1099 && n<1156){
    cout<<1<<endl;
  }
    else if(n>1199 && n<1261){
    cout<<1<<endl;
  }
    else if(n>1299 && n<1366){
    cout<<1<<endl;
  }
    else if(n>1399 && n<1471){
    cout<<1<<endl;
  }
    else if(n>1499 && n<1576){
    cout<<1<<endl;
  }
    else if(n>1599 && n<1681){
    cout<<1<<endl;
  }
    else if(n>1699 && n<1786){
    cout<<1<<endl;
  }
    else if(n>1799 && n<1891){
    cout<<1<<endl;
  }
    else if(n>1899 && n<1996){
    cout<<1<<endl;
  }
    else if(n>1999){
    cout<<1<<endl;
  }
    else{
    cout<<0<<endl;
  }
  
  return(0);
  


}

Measured memory_bytes: 256
from collections import Counter
def main():
    n=int(input())
    a=list(map(int,input().split(' ')))
    a_count = Counter(a)
    odd = 0
    even = 0
    for value in a_count.values():
        if value%2 ==0:
            even +=1
        else:
            odd += 1
    if even %2 ==0:
        print(odd+even)
    else:
        print(odd+even-1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 18656
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int mp[21][21];
int w,h;
int ans;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

void dfs(int n,int x,int y,int c[21][21])
{
	if(n == 11)return;
	REP(i,4)
	{
		int tx = x,ty = y;
		while(tx + dx[i] >= 0 && tx + dx[i] < w  &&
		ty + dy[i] >= 0 && ty + dy[i] < h &&
		c[ty+dy[i]][tx+dx[i]] == 0 || c[ty+dy[i]][tx+dx[i]] == 2)
		{
			tx += dx[i];
			ty += dy[i];
		}
		if(!(tx + dx[i] >= 0 && tx + dx[i] < w  &&
		ty + dy[i] >= 0 && ty + dy[i] < h) ||
		(( x == tx && y == ty) && c[ty+dy[i]][tx+dx[i]] == 1))continue;
		tx += dx[i];
		ty += dy[i];
		if(c[ty][tx] == 3)
		{
		//	cout << "!!!" << n << ' ' << ty << ' ' << tx << endl;
			ans = min(ans,n);
		}
		if(c[ty][tx] == 1)
		{
		//	cout << n << ' ' << ty << ' ' << tx << endl;
			c[ty][tx] = 0;
		//	SHOW2d(c,h,w);
			dfs(n+1,tx-dx[i],ty-dy[i],c);
			c[ty][tx] = 1;
		}
	}
}
		
		
				
				

int main()
{
	while(cin >> w >> h,w|h)
	{
		int sx,sy;
		ans = 100;
		REP(i,h)
		{
			REP(j,w)
			{
				cin >> mp[i][j];
				if(mp[i][j] == 2)
				{
					sx = j,sy = i;
				}
			}
		}
		//cout << sx << ' ' << sy << endl;
		dfs(1,sx,sy,mp);
		
		if(ans != 100)
		{
			cout << ans << endl;
		}
		else
		{
			cout << -1 << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3100
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl

typedef pair<int, int> P;
typedef long long ll;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> v(3);
    REP(i,3) cin>>v[i];
    sort(all(v));
    print(v[0]*v[1]/2);
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc072c()
}

fun abc072c() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map { it.toInt() }
        .sorted()

    var left = 0
    var right = 0
    val answer = aList.map { a ->
        while (left < n && aList[left] < a - 1) left++
        while (right < n && aList[right] <= a + 1) right++
        right - left
    }.max()

    println(answer)
}


Measured memory_bytes: 54444
def primes(n):
    candidate = list(range(2, n+1))
    prime = []
    limit = n**0.5 + 1
    while True:
        p = candidate[0] 
        if limit <= p:
            prime.extend(candidate)
            break
        prime.append(p)

        candidate = [i for i in candidate if i % p != 0]
    return prime
L=primes(100000)
R=set([i for i in L if (i+1)//2 in L])
Q=int(input())
for i in range(Q):
  a,b=map(int,input().split())
  print(len([i for i in R if i>=a and i<=b]))

Measured memory_bytes: 81160