akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
  string S;
  cin >> S;
  int price = 700;
  for(int i=0; i<3; i++){
    if(S.at(i) == 'o'){
      price += 100;
    }
  }
  cout << price << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int n,A,B,C;
vi l;

int f(int i,int a,int b,int c,int t){
    if(i==n){
        int r;
        r=abs(A-a)+abs(B-b)+abs(C-c)+t-30;
        if(!a||!b||!c||r<0)r=inf;
        return r;
    }
    return min({f(i+1,a,b,c,t),f(i+1,a+l[i],b,c,t+10),f(i+1,a,b+l[i],c,t+10),f(i+1,a,b,c+l[i],t+10)});
}

void run(){
    cin>>n>>A>>B>>C;
    l.resize(n);
    rep(i,n)cin>>l[i];
    cout<<f(0,0,0,0,0)<<endl;
}

Measured memory_bytes: 256
import kotlin.math.*
import java.util.*

const val MOD = 1_000_000_007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main(args: Array<String>) {
  val (n, m) = readIs()
  val ab = Array(n + 1) { mutableSetOf<Int>() }
  repeat(m) {
    val (a, b) = readIs()
    ab[a].add(b)
    ab[b].add(a)
  }
  val d = IntArray(n + 1) { -1 }
  val q = ArrayDeque<Int>()
  d[1] = 0
  q.add(1)
  while (q.isNotEmpty()) {
    val node = q.remove()
    for (cur in ab[node]) {
      if (d[cur] != -1) continue
      d[cur] = node
      q.add(cur)
    }
  }
  println("Yes")
  for (i in 2..n) {
    println(d[i])
  }
}


Measured memory_bytes: 101324
#include <bits/stdc++.h>
using namespace std;
#define MAX 100000
#define NIL -1

struct Node{int parent, left, right;};
vector<Node> T(MAX);
vector<int> D(MAX);


int getDepth(int u){
    int d = 0;
    while(T.at(u).parent != NIL){
        u = T.at(u).parent;
        d++;
    }
    return d;
}

void setDepth(int u, int p){
    D.at(u) = p;
    if(T.at(u).right != NIL) setDepth(T.at(u).right, p);
    if(T.at(u).left != NIL)  setDepth(T.at(u).left, p + 1);
}

void printChildren(int u){
    int c = T.at(u).left;
    while(c != NIL){
        cout << c;
        c = T.at(c).right;
    }
}

void print(int u){
    cout << "node " << u << ": ";
    cout << "parent = " << T.at(u).parent << ", ";
    cout << "depth = " << D.at(u) << ", ";

    if(T.at(u).parent == NIL) cout << "root, ";
    else if(T.at(u).left == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";
    for(int i = 0, c = T.at(u).left; c != NIL; i++, c = T.at(c).right){
        if(i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

int main(){
    int n,v,d,c,l,r;
    cin >> n;
    for(int i = 0;i<n;i++) T.at(i).parent = T.at(i).left = T.at(i).right = NIL;

    for(int i = 0;i<n;i++){
        cin >> v >> d;
        for(int j = 0;j<d;j++){
            cin >> c;
            if(j == 0) T.at(v).left = c;
            else T.at(l).right = c;
            l = c;
            T.at(c).parent = v;
        }
    }
    for(int i = 0;i<n;i++){
        if(T.at(i).parent == NIL) r = i; 
    }

    setDepth(r,0);
    for(int i = 0;i<n;i++) print(i);

    return 0;
}




Measured memory_bytes: 9068
from math import gcd

gcd_results = {}

def three_gcd(a, b, c):
    if a == 1 or b == 1 or c == 1:
        return 1

    if a == b == c:
        return a
    k = sorted([a, b, c])
    key = k[0] * 1000000 + k[1] * 1000 + k[2]
    if key not in gcd_results:
        res = gcd(gcd(a, b), c)
        gcd_results[key] = res
        return res
    else:
        return gcd_results[key]

K = int(input())

a = range(1, K + 1)
b = range(1, K + 1)
c = range(1, K + 1)

result = 0
for ia in a:
    for ib in b:
        for ic in c:
            result += three_gcd(ia, ib, ic)

print(result)

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

int main() {
    int x, y;
    cin >> x >> y;

    bool ok = false;
    for(int i = 0; i <= x; i++){
        int turu = 2 * i;
        int kame = 4 * (x - i);
        if(turu + kame == y)ok = true;
    }

    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>

using namespace std;

int main() {
	vector<int> v1;
	vector<int> v2;
	int h;
	int w;
	bool IsInput = true;

	while (IsInput) {
		cin >> h >> w;
		if (h == 0 && w == 0) {
			break;
		}
		v1.push_back(h);
		v2.push_back(w);
	}
	
	bool IsSharp = true;

	for(int i = 0; i < v1.size();i++){
		for (int j = 0; j < v1[i];j++) {
			if (j % 2) {
				IsSharp = false;
			}
			else {
				IsSharp = true;
			}
			for (int k = 0; k < v2[i]; k++) {
				if (IsSharp) {
					cout << "#";
				}
				else {
					cout << ".";
				}
				IsSharp = !IsSharp;
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef struct {
    int x, y;
    VVI b;
    int count;
} Move;

int gx, gy;
const int INF = 1<<29;
int dirs[] = { 1, 0, -1, 0, 1 };
VVI B;

int dfs(int crr_x, int crr_y, int count)
{
    if (count >= 10) return INF;
    int ans = INF;
    loop (4, i) {
        int x = crr_x+dirs[i], y = crr_y+dirs[i+1];
        if (B[x][y] != 0) continue;
        while (B[x][y] == 0) {
            if (x == gx && y == gy) return count + 1;
            x += dirs[i];
            y += dirs[i+1];
        }
        if (B[x][y] == 2) continue;
        B[x][y] = 0;
        ans = min(ans, dfs(x-dirs[i], y-dirs[i+1], count+1));
        B[x][y] = 1;
    }
    return ans;
}

int main()
{
    while (1) {
        int w, h; cin >> w >> h;
        if (!w) break;
        int sx, sy;
        B = VVI(w+2, VI(h+2));
        loop (h+2, y) {
            B[0][y] = 2;
            B[w+1][y] = 2;
        }
        loop (w+2, x) {
            B[x][0] = 2;
            B[x][h+1] = 2;
        }
        loop (h, y) loop (w, x) {
            int v; cin >> v;
            if (v == 2) sx = x+1, sy = y+1;
            if (v == 3) gx = x+1, gy = y+1;
            B[x+1][y+1] = (v == 1);
        }

        int ans = dfs(sx, sy, 0);
        if (ans == INF) ans = -1;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <climits>
#include <iomanip>
 
using namespace std;

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
 	
 	vector<char> alph(26, false);

 	string s;
 	cin >> s;

 	for (int i = 0; i < (int) s.size(); ++i) {
 		alph[s[i] - 'a'] = true;
 	}

 	string answer = "None";

 	for (int i = 0; i < (int) alph.size(); ++i) {
 		if (!alph[i]) {
 			answer.clear();
 			answer.push_back((char)(i + 'a'));
 			break;
 		}
 	}

 	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
    int a,b,c; cin>>a>>b>>c;
    long long cnt=0;
    while(!(a%2||b%2||c%2)){
        cnt++;
        int tmpa=a,tmpb=b,tmpc=c;
        a=(tmpb+tmpc)/2;
        b=(tmpc+tmpa)/2;
        c=(tmpa+tmpb)/2;
        if(a==b&&b==c){
            cnt=-1; break;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cnt = dif = 0
for i in range(n+1):
    cnt += min(dif,a[i])
    if i!=n:
        a[i] -= min(dif,a[i])
        cnt += min(a[i],b[i])
        dif = max(0,b[i]-a[i])
print(cnt)

Measured memory_bytes: 18468
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;

int eras,query;
struct Eras
{
  string name;
  int start,end,eraend;
  Eras(string _name,int p,int _end)
  {
    name=_name;
    end=_end;
    eraend=p;
    start=end-p+1;
  }
};

int main(int argc,char const* argv[])
{
  while(1)
    {
      cin >> eras >> query;
      if(!eras) break;
      vector<Eras> e;
      e.clear();
      for(int i=0;i<eras;i++)
	{
	  string s;
	  int a,b;
	  cin >> s >> a >> b;
	  e.push_back(Eras(s,a,b));
	}
      for(int i=0;i<query;i++)
	{
	  int ques;
	  bool ok=false;
	  cin >> ques;
	  for(int i=0;i<eras;i++)
	    {
	      if(e[i].start <= ques && ques<=e[i].end)
		{
		  cout << e[i].name << ' ' << (e[i].eraend-(e[i].end-ques)) << endl;
		  ok=true;
		  break;
		} 
	    }
	  if(!ok) cout << "Unknown" << endl;
	}
    }
  return 0;
}



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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);

int main()
{
	IOS;
    cout.precision(30);
    int n; cin >> n; vector <ll> A(n,0);
    for (int i=0;i<n;i++)
    {
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    cout << A[n/2]-A[(n-1)/2];
    return 0;
}



Measured memory_bytes: 1024
n = int(input())
ans = [0] * (60000 + 1)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            ans[i ** 2 + j ** 2 + k** 2 + i * j + j* k + k* i] += 1
for i in range(n):
    print(ans[i + 1])

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

int Isprime(int a){
	if(a == 1)
		return 0;
	int q = sqrt(a);
	for(int i = 2; i <= q; i++){
		if(a%i == 0)
			return 0;
	}
	return 1;
}

int main(){
	int n, t, cnt = 0;
	cin>>n; 
	while(n--){
		cin>>t;
		if(Isprime(t))	cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3096
# Template 1.0
import sys, re
from decimal import *
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, floor, trunc, log
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

x = input()

if(x[-1]=='s'):
    print(str(x) + str('es'))
else:
    print(x+str('s'))


Measured memory_bytes: 71040
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int D;
int c[26];
int s[365][26];
int last[26] = {};  // 各コンテストを最後に開催した日
int t[365] = { 0 };  // 各日に開催するコンテスト
int M;
vector<int> d;
vector<int> q;
vector<int> ds[26];  // 各コンテストの開催日

void Setds() {
    rep(i, D) {
        ds[t[i] - 1].push_back(i+1);
    }
}

int CalcScore() {
    int res = 0;
    int last_[26] = { 0 };
    rep(i, D) {
        res += s[i][t[i] - 1];
        last_[t[i] - 1] = i + 1;
        rep(j, 26) {
            res -= c[j] * (i+1 - last_[j]);
        }
    }
    return res;
}

int Disatisfaction(int c, int pre, int d, int post) {
    return c * ((post - pre)* (post - pre - 1) - (d - pre) * (d - pre - 1) - (post - d) * (post - d - 1)) / 2;
}

int Disatisfaction2(int c, int pre, int d, int post) {
    return c * (- (post - pre) * (post - pre - 1) + (d - pre) * (d - pre - 1) + (post - d) * (post - d - 1)) / 2;
}

void Query(int d, int q) {
    t[d - 1] = q;
}

//int Query(int d, int q) {
//    int res = 0;
//    int old = t[d - 1];  // 前回値保存
//    t[d - 1] = q;  // 入れ替え
//
//    // 満足度上昇分
//    res -= s[d - 1][old - 1];
//    res += s[d - 1][q - 1];
//
//    // oldについて満足度減少分
//    int pre = 0;
//    int post = D + 1;
//    for (int i = 1; i < ds[old-1].size(); i++) {
//        if (ds[old - 1][i] == d) {
//            pre = ds[old - 1][i - 1];
//            if (i != ds[old - 1].size() - 1) {
//                post = ds[old - 1][i+1];
//            }
//        }
//    }
//    res -= Disatisfaction(c[old - 1], pre, d, post);
//
//    // qについて満足度減少分
//    pre = 0;
//    post = D + 1;
//    for (int i = 1; i < ds[q - 1].size(); i++) {
//        if (ds[q - 1][i] == d) {
//            pre = ds[q - 1][i - 1];
//            if (i != ds[q - 1].size() - 1) {
//                post = ds[q - 1][i + 1];
//            }
//        }
//    }
//    res -= Disatisfaction2(c[q - 1], pre, d, post);
//    return res;
//}

int main()
{
    cin >> D;
    rep(i, 26) cin >> c[i];
    rep(i, D) rep(j, 26) cin >> s[i][j];
    rep(i, D) cin >> t[i];
    cin >> M;
    d.resize(M);
    q.resize(M);
    rep(i, M) cin >> d[i] >> q[i];

    int score = 0;
    rep(i, M) {
        Query(d[i], q[i]);
        score = CalcScore();
        cout << score << endl;
    }
    return 0;
}


Measured memory_bytes: 4004
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto& e : A) cin >> e;
  sort(begin(A), end(A));
  vector<bool> table(A.back() + 1, true), looked(A.back() + 1, false);
  for (const auto& e : A)
    if (table[e]) {
    	if (looked[e]) {
    		table[e] = false;
    		continue;
    	}
    	looked[e] = true;
      for (int i = 2; i * e <= A.back(); ++i)
 	      table[i * e] = false;
    }
  int ans = 0;
  for (const auto& e : A) if (table[e]) ++ans;
  cout << ans << '\n';
}


Measured memory_bytes: 4268
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();

		if (a+b < x) {
			System.out.println("NO");
		} else if (a>x) {
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}

	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
const int INF = 1e9;
int h,w;
int ch,cw;
int th,tw;
char s[N][N];
int dist[N][N];
int dh[] = {-1, 1, 0, 0};
int dw[] = {0, 0, -1, 1};
bool valid(int a, int b) {
	return a >= 0 and a < h and b >= 0 and b < w and s[a][b] != '#';
}
int main() {
	scanf("%d %d", &h, &w);
	scanf("%d %d", &ch, &cw);
	scanf("%d %d", &th, &tw);
	ch--, cw--, th--, tw--;
	for(int i = 0; i < h; ++i) {
		scanf("%s", s[i]);
		for(int j = 0; j < w; ++j)
			dist[i][j] = INF;
	}
	priority_queue< tuple<int, int, int> > pq;
	pq.emplace(0, ch, cw);
	dist[ch][cw] = 0;
	while(!pq.empty()) {
		auto front = pq.top();
		pq.pop();
		int ph = get<1>(front);
		int pw = get<2>(front);
		int d = -(get<0>(front));
		if(d > dist[ph][pw])
			continue;
		for(int i = 0; i < 4; ++i) {
			int nxt_h = ph + dh[i];
			int nxt_w = pw + dw[i];
			if(valid(nxt_h, nxt_w) and dist[ph][pw] < dist[nxt_h][nxt_w]) {
				dist[nxt_h][nxt_w] = dist[ph][pw];
				pq.emplace(-dist[nxt_h][nxt_w], nxt_h, nxt_w);
			}
		}
		for(int i = -2; i <= 2; ++i) {
			for(int j = -2; j <= 2; ++j) {
				int nxt_h = ph + i;
				int nxt_w = pw + j;
				if(valid(nxt_h, nxt_w) and dist[ph][pw] + 1 < dist[nxt_h][nxt_w]) {
					dist[nxt_h][nxt_w] = dist[ph][pw] + 1;
					pq.emplace(-dist[nxt_h][nxt_w], nxt_h, nxt_w);
				}
			}
		}
	}
	if(dist[th][tw] == INF) puts("-1");
	else printf("%d\n", dist[th][tw]);
	return 0;
}



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

using namespace std;

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

  int n;
  string s, t;
  cin >> n >> s >> t;
  for (int i = 0; i < n; ++i) {
    cout << s[i] << t[i];
  }

  return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf-8');
 
let inputString = '';
let currentLine = 0;
 
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
 
process.stdin.on('end', _ => {
    inputString = inputString.split(/\n/);
    main();    
});
 
function readLine() {
    return inputString[currentLine++];
}

const mod = Math.pow(10, 9) + 7
function main() {
  const n = Number(readLine())
  let tens = 1
  let nines = 2
  let eights = 1
  for (let _ = 0; _ < n; _++) {
    tens = (tens * 10) % mod
    nines = (nines * 9) % mod
    eights = (eights * 8) % mod
  }
  const total = tens - nines + eights
  console.log(total >= 0 ? total % mod : total + mod)
}

Measured memory_bytes: 33512
#include<stdio.h>
#define MAX 200
 
int main(){
  int n, u, k, v, a[MAX][MAX], i, j;
   
  scanf("%d", &n);
   
  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      a[i][j]=0;
    }
  }
   
  for(i = 1; i <= n; i++){
    scanf("%d%d", &u, &k);
 
    for(j = 1; j <= k; j++){
      scanf("%d", &v);
      a[i][v] = 1;
    }
  }
   
  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      if (j == n) printf("%d", a[i][j]);
      else printf("%d ", a[i][j]);
    }
    printf("\n");

  }
   
  return 0;
}

Measured memory_bytes: 1812
#include<bits/stdc++.h>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
//lower_bound like o_set.find_by_order(val) strictly less then val
//upper_bound like o_set.order_of_key(MAX)– o_set.order_of_key(val)
//if u need multiset elements then use second parameter as time and think 
//typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define se second
#define fi first
#define pai acos(-1)
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x,s) for(i=x;i>=s;i--)
#define fit(itr,s) for(itr=s.begin();itr!=s.end();itr++)
#define W while
#define pp pair<ll,ll>
#define ppi pair<int,int>
#define vl vector<ll>
#define vll vector<pp >
#define vi vector<int>
#define vii vector<ppi>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#define boost  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const int MAX=2e5+5;
const ll MM=1e16;
const ll mod=998244353;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

ll expo(ll x,ll n,ll M=mod)
{
    ll ans=1;
    while(n>0)
    {
        if(n&1){ans=(ans*x)%M;}
                x=(x*x)%M;
                n>>=1;
    }
    return ans;
}

void solve()
{
    ll n,m,i,j,k;
    cin>>n;
    map<string,ll> mp;
    mp["AC"]=0;
    mp["WA"]=0;
    mp["TLE"]=0;
    mp["RE"]=0;
    W(n--)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC"<<" "<<"x "<<mp["AC"]<<endl;
    cout<<"WA"<<" "<<"x "<<mp["WA"]<<endl;
    cout<<"TLE"<<" "<<"x "<<mp["TLE"]<<endl;
    cout<<"RE"<<" "<<"x "<<mp["RE"]<<endl;
}

int main()
{
  boost;
  ll t=1;
// cin>>t;
  while(t--)
  {
      solve();
  }
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n,m,k,a,c=0;
	vector<int> s;
	cin>>n>>m;
	for(int i=0;i<m;i++)s.push_back(0);
	for(int i=0;i<n;i++){
		cin>>k;
		for(int j=0;j<k;j++){
			cin>>a;
			s.at(a-1)++;
		}
	}
	for(int i=0;i<m;i++){
		if(s.at(i)==n){
			c++;
		}
	}
	cout<<c<<endl;
	return 0;
}
 

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

int main() {
    int64_t n, k;
    cin >> n >> k;
    vector<pair<int64_t, int64_t>> x(n), y(n), xy(n);
    for (int i = 0; i < n; i++) {
        x[i].second = y[i].second = i;
        cin >> x[i].first >> y[i].first;
        xy[i].first = x[i].first, xy[i].second = y[i].first;
    }
    sort(begin(x), end(x));
    sort(begin(y), end(y));

    int64_t ans = INT64_MAX;
    for (int xi = 0; xi+1 < n; xi++) {
        for (int xj = xi+1; xj < n; xj++) {              
            for (int yi = 0; yi+1 < n; yi++) {
                for (int yj = yi+1; yj < n; yj++) {
                    int64_t left = x[xi].first, right = x[xj].first;
                    int64_t bottom = y[yi].first, top = y[yj].first;
                    vector<int64_t> use { x[xi].second, x[xj].second, y[yi].second, y[yj].second };
                    if (any_of(begin(use), end(use), [&](auto a) {
                        return xy[a].first < left || right < xy[a].first || xy[a].second < bottom || top < xy[a].second;
                    })) continue;

                    int c = 0;
                    for (int m = 0; m < n; m++) {
                        if (left <= xy[m].first && xy[m].first <= right && bottom <= xy[m].second && xy[m].second <= top) c++;
                    }
                    if (c >= k) ans = min(ans, (top - bottom) * (right - left));
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] values = new int[w];
        for (int i = 0; i < w; i++) {
            values[i] = i + 1;
        }

        for (int i = 0; i < n; i++) {
            String str = sc.next();
            String[] ab = str.split(",");
            int a = Integer.parseInt(ab[0]) - 1;
            int b = Integer.parseInt(ab[1]) - 1;
            int tmp;
            tmp = values[a];
            values[a] = values[b];
            values[b] = tmp;
        }

        for (int i=0; i<w;i++){
            System.out.println(values[i]);
        }
    }
}

Measured memory_bytes: 26168
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
const ll inf=1e14;
ll dp[105][105][105]={0};
int main(){
  ll n,w;
  cin>>n>>w;
  ll w1,v1;
  cin>>w1>>v1;
  for(int i=0;i<105;i++){
    for(int j=0;j<105;j++){
      for(int k=0;k<105;k++) dp[i][j][k]=0;
    }
  }
  dp[0][0][0]=0;
  dp[1][0][0]=0;
  dp[1][1][0]=v1;
  for(ll i=1;i<n;i++){
    for(ll j=0;j<105;j++){
      for(ll k=0;k<105;k++) dp[i+1][j][k]=dp[i][j][k];
    }
    ll wn,vn;
    cin>>wn>>vn;
    for(ll j=0;j<104;j++){
      for(ll k=0;k<105;k++){
        if(k+wn-w1<105){
          dp[i+1][j+1][k+wn-w1]=max(dp[i+1][j+1][k+wn-w1],dp[i][j][k]+vn);
        }
      }
    }
  }
  ll ans=0;
  for(int i=0;i<105;i++){
    ll w2=w-i*w1;
    if(w2>=0){ for(int k=0;k<=min(w2,(ll)104);k++) ans=max(ans,dp[n][i][k]);}
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 9344
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX_N 10000

int n;
int a[MAX_N];

void solve() {
    int _max = -1000000, _min = 1000000;
    long long _sum = 0;
    for(int i = 0; i < n; i++) {
        _max = max(a[i], _max);
        _min = min(a[i], _min);
        _sum += a[i];
    }

    cout << _min << " " << _max << " " << _sum << endl;


}

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


Measured memory_bytes: 3108
import java.math.*;
import java.util.*;

public class Main {
    static boolean isGood(int n, int l[]) {
        int tmp = String.valueOf(n).length();
        int div = (int) Math.pow(10, tmp - 1);
        boolean tmp2 = true;

        r: for (int i = 0; i < tmp; i++) {
            int t = n / div;
            for (int ln : l) {
                if (ln == t) {
                    tmp2 = false;
                    break r;
                }
            }
            n -= t * div;
            div /= 10;
            
        }
        return tmp2;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int d[] = new int[k];
        for (int i = 0; i < k; i++)
            d[i] = sc.nextInt();
        int ans = n;
        if (isGood(ans, d)) {
        } else {
            while (!isGood(ans, d)) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 24528
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> v(n),e(1e5+1),o(1e5+1);
	pair<int,int> even[2],odd[2];
	even[0]={0,0};
	even[1]={0,0};
	odd[0] ={0,0};
	odd[1] ={0,0};
	rep(i,n){
		cin >> v[i];
		if(i%2==0)e[v[i]]++;
		else o[v[i]]++;
	}
	rep(i,1e5+1){
		if(e[i]>even[0].second){
			even[1] = even[0];
			even[0] = {i,e[i]};
		}else if(e[i]>even[1].second){
			even[1] = {i,e[i]};
		}
		if(o[i]>odd[0].second){
			odd[1] = odd[0];
			odd[0] = {i,o[i]};
		}else if(o[i]>odd[1].second){
			odd[1] = {i,o[i]};
		}
	}
	int ans = 1e9;
	if(even[0].first == odd[0].first){
		ans = min(ans,n - (even[0].second + odd[1].second) );
		ans = min(ans,n - (even[1].second + odd[0].second) );
	}else{
		ans = n - (even[0].second + odd[0].second);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
int s1[10][10];
int vis[10];
int judge[10][10];
int n,m;
int sum,all;
void dfs(int num)
{
    int a,b;
    if(sum==n)
    {
        all++;
        return;
    }
    for(a=1;a<=n;a++)
    {
        if(s1[num][a]==1&&vis[a]==0)
        {
            vis[a]=1;sum++;
            dfs(a);
            vis[a]=0;sum--;
        }
    }
    return;
}
int main()
{
    int a,b,x,y;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        sum=0;all=0;
        memset(s1,0,sizeof(s1));
        memset(vis,0,sizeof(vis));
        for(a=1;a<=m;a++)
        {
            scanf("%d%d",&x,&y);
            s1[x][y]=s1[y][x]=1;
        }
        vis[1]=1;sum++;
        dfs(1);
        printf("%d\n",all);
    }
    return 0;
}


Measured memory_bytes: 128
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define which(flag,msg1,msg2) cout<<((flag)? msg1:msg2);

#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
map<char,int> 
count_same_elements(const vector<char>& v){map<char,int>cmap; for_each(v.begin(),v.end(),[&cmap](int x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A> bool
all_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]<1){flag=false;}; }return flag;}
template<class A> bool
any_of(const vector<A>& v){bool flag=false;rep(i,v.size()){ if(v[i]>0){flag=true; break;}; }return flag;}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class T>
void scan_vector(long long size,vector<T>& vector){
    vector.resize(size);
    for(long long i=0;i<size;++i){
        cin>>vector[i];
    }
}

ll n,x;
string s,t;
void input(){
    cin>>n;
}
void src(){
    bool f=false;
    do{
        if(n%4==0){f=true;break;}
        n-=7;
    }while(n>=0);
    Yes(f);
}   

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.size();
    int e = 0, o = 0;
    vector<int> ans(n);
    for(int i = 0; i < n; i++){
        swap(e, o);
        if(s[i] == 'R'){
            e++;
        }else{
            ans[i - 1] += o;
            ans[i] += e;
            e = o = 0;
        }
        printde(ans);
    }
    for(int i = n - 1; i >= 0; i--){
        swap(e, o);
        if(s[i] == 'L'){
            e++;
        }else{
            ans[i + 1] += o;
            ans[i] += e;
            e = o = 0;
        }
        printde(ans);
    }
    for(int i = 0; i < n; i++){
        cout << ans[i] << ' ';
    }
}


Measured memory_bytes: 1104
import java.util.*;
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int Q = sc.nextInt();
		int[][] A = new int[N][N];
		for(int i = 0; i < M; i++)
			A[sc.nextInt()-1][sc.nextInt()-1]++;
		int[][] S = new int[N+1][N+1];
		for(int i = 0; i < N; i++)
			for(int j = 0; j < N; j++)
				S[i+1][j+1] = S[i][j+1] + S[i+1][j] - S[i][j] + A[i][j];
		for(int i = 0; i < Q; i++) {
			int p = sc.nextInt()-1;
			int q = sc.nextInt();
			System.out.println(S[q][q]+S[p][p]-S[p][q]-S[q][p]);
		}
	}
 
}

Measured memory_bytes: 164568
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << ((n%2==0)?n:n*2) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
int cnt[200000][26];
int main() {
	string A;
	cin >> A;
	int N = A.size();
	for (int i = 0; i < N; i++) {
		cnt[i][A[i] - 'a']++;
	}
	for (int i = 1; i < N; i++) {
		for (int j = 0; j < 26; j++) cnt[i][j] += cnt[i - 1][j];
	}
	LL ans = 1;
	for (int i = 0; i < N; i++) {
		ans += (N - 1 - i) - (cnt[N - 1][A[i] - 'a'] - cnt[i][A[i] - 'a']);
	}
	cout << ans << endl;
}

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

int main() {
  int A,B,C;
  int ans = 0;
  cin >> A >> B >> C;
  
  while(A%2 == 0 && B%2 == 0 && C%2 == 0){
    ans += 1;
    int a =A,b=B,c=C;
    A = b/2 + c/2;
    B = a/2 + c/2;
    C = a/2 + b/2;
    if(A == B && A == C){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
def max_heapify(a, i):
    h = len(a)
    l = 2 * i
    r = 2 * i + 1
    if l <= h and a[l - 1] > a[i - 1]:
        largest = l
    else:
        largest = i
    if r <= h and a[r - 1] > a[largest - 1]:
        largest = r

    if largest != i:
        tmp = a[i - 1]
        a[i - 1] = a[largest - 1]
        a[largest - 1] = tmp
        max_heapify(a, largest)


def build_max_heap(a):
    h = len(a)
    for i in range(h // 2, 0, -1):
        max_heapify(a, i)


def print_list_split_whitespace(a):
    s = ""
    for x in a:
        s += " " + str(x)
    print(s)


h = int(input())
heap = [int(x) for x in input().split()]

build_max_heap(heap)

print_list_split_whitespace(heap)


Measured memory_bytes: 63972
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    LL a,b,c;
    cin >> a >> b >> c;
    if(a + b >= c) {
        cout << "No" << endl;
        return 0;
    }
    cout << ((c-a-b)*(c-a-b) - 4*a*b > 0? "Yes":"No") << endl;
    return 0;
}

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

static int *
read_arr(FILE *f, int size) {
  int *arr;
  int *tmp_arr;
  int n;

  arr = (int *) malloc(sizeof(int) * size);
  if (arr == NULL) return NULL;

  tmp_arr = arr;
  while (1) {
    n = fscanf(f, "%d", tmp_arr++);
    if (errno != 0) perror("fscanf");
    if (n == EOF) break;
  }

  return arr;
}

static void
print_arr(int *arr, int size) {
  int i;

  for (i = 0; i < size; ++i) {
    if (i > 0) fprintf(stdout, " ");
    fprintf(stdout, "%d", arr[i]);
  }
  fprintf(stdout, "\n");
}

// Selection sort
static int
sort(int *a, int n) {
  int cnt, min, i, j, v;

  cnt = 0;
  for (i = 0; i < n; ++i) {
    min = i;
    for (j = i; j < n; ++j) {
      if (a[j] < a[min]) min = j;
    }
    if (i != min) {
      v = a[i];
      a[i] = a[min];
      a[min] = v;
      ++cnt;
    }
  }

  return cnt;
}

int
main(int argc, char **argv) {
  int *arr;
  int n, ret, cnt;

  ret = fscanf(stdin, "%d", &n);
  if (errno != 0) perror("fscanf");
  if (ret < 1) exit(1);

  arr = read_arr(stdin, n);
  if (arr == NULL) exit(1);

  cnt = sort(arr, n);
  print_arr(arr, n);
  fprintf(stdout, "%d\n", cnt);

  free(arr);
  arr = NULL;
  exit(0);
}


Measured memory_bytes: 2104
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAXN = 300;
const int MOD = 998244353;

inline int add(int x, int y) {x += y; return x >= MOD ? x - MOD : x;}
inline int sub(int x, int y) {x -= y; return x < 0 ? x + MOD : x;}
inline int mul(int x, int y) {return (int)(1LL * x * y % MOD);}

int pow_mod(int b, int p) {
	int ret = 1;
	for(int i=p;i;i>>=1,b=mul(b,b))
		if( i & 1 ) ret = mul(ret, b);
	return ret;
}

int a[MAXN + 5], s, m, K;
int dp[2][MAXN + 5][MAXN + 5];
int solve() {
	int t = 0; dp[0][0][0] = 1;
	for(int i=m;i>=1;i--) {
		for(int k=0;k<=s;k++)
			for(int j=0;j<=s;j++)
				dp[1][k][j] = dp[0][k][j], dp[0][k][j] = 0;
		
		for(int k=0;k<=s;k++) {
			dp[0][k][t] = dp[1][k][t];
			for(int j=s-1;j>=0;j--)
				dp[0][k][j] = add(dp[0][k][j + 1], dp[1][k][j]);
		}
		
		for(int k=0;k<=s;k++)
			for(int j=0;j<=s;j++)
				for(int l=1;l<=a[i];l++)
					dp[0][k+l][j+l] = add(dp[0][k+l][j+l], dp[1][k][j]);
		
		t += a[i];
	}
	
	int lim = min(K, s), ans = 0;
	for(int i=0;i<=lim;i++)
		ans = add(ans, dp[0][i][0]);
	return ans;
}

char S[MAXN + 5]; int n;
int main() {
	scanf("%s%d", S, &K), n = strlen(S);
	
	int cnt = 0;
	for(int i=0;i<n;i++) {
		if( S[i] == '0' )
			a[++m] = cnt, cnt = 0;
		else cnt++, s++;
	}
	a[++m] = cnt, printf("%d\n", solve());
}


Measured memory_bytes: 2416
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	x := scanInt()
	y := scanInt()
	z := scanInt()
	x,y = y,x
	x,z = z,x
	fmt.Fprintln(wr, x,y,z)
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
vpint G[111111];
int sz[111111];

pint ei;
int eiid;
int ans[111111];

int S[111111];
void dfs(int v,int p,int id){
    sz[v]=1;
    for(auto &e:G[v]){
        if(e.fi==p)continue;
        dfs(e.fi,v,e.se);
        sz[v]+=sz[e.fi];
    }

    if(p!=-1){
        if(sz[v]*2==N){
            ei={v,p};
            eiid=id;
        }
        else{
            int tmp=S[v]-S[p];
            tmp/=(N-sz[v]-sz[v]);
            ans[id]=tmp;
        }
    }
}

int dfs2(int v,int p,int d){
    int ret=d;
    for(auto &e:G[v]){
        if(e.fi==p)continue;
        ret+=dfs2(e.fi,v,d+ans[e.se]);
    }
    return ret;
}

signed main(){
    cin>>N;
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb({b,i});
        G[b].pb({a,i});
    }
    rep(i,N)scanf("%lld",&S[i]);

    ei={-1,-1};
    dfs(0,-1,-1);

    if(ei!=pint(-1,-1)){
        int tmp=dfs2(ei.fi,-1,0);
        tmp=S[ei.fi]-tmp;
        tmp/=N/2;

        ans[eiid]=tmp;
    }

    rep(i,N-1)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 15232
N,M = map(int,input().split())

A = [list(map(int,input().split())) for _ in range(N)]

T = [[1,1,1],[1,1,-1],[1,-1,1],[-1,1,1],[1,-1,-1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]

num = 0
for t in T:
    B = []
    for a in A:
        B.append(a[0]*t[0]+a[1]*t[1]+a[2]*t[2])
    num_ = 0
    for k in range(M):
        num_ += B.pop(B.index(max(B)))
    num = max(num,num_)
print(num)

Measured memory_bytes: 3316
n=int(input())
x=0
a=[int(x) for x in input().split()]
for i in range(len(a)):
    if(a[i]%2==0):
        if(a[i]%3==0 or a[i]%5==0):pass
        else:
            x=1
            print("DENIED")
            break
if x==0:print("APPROVED")

Measured memory_bytes: 3060
import fileinput


class Vector2D:
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def dot(self, vec2d):
        return (self.x * vec2d.y) - (self.y * vec2d.x)


for line in fileinput.input():
    x1, y1, x2, y2, x3, y3, xp, yp = [float(r) for r in line.split()]
    v1To2 = Vector2D(x2 - x1, y2 - y1)
    v2To3 = Vector2D(x3 - x2, y3 - y2)
    v3To1 = Vector2D(x1 - x3, y1 - y3)
    v1ToP = Vector2D(xp - x1, yp - y1)
    v2ToP = Vector2D(xp - x2, yp - y2)
    v3ToP = Vector2D(xp - x3, yp - y3)

    if (v1To2.dot(v1ToP) < 0 and v2To3.dot(v2ToP) < 0 and v3To1.dot(v3ToP) < 0) or (v1To2.dot(v1ToP) > 0 and v2To3.dot(v2ToP) > 0 and v3To1.dot(v3ToP) > 0):
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 7416
#include <stdio.h>
#include <math.h>
 
int isprime(int x){
  if(x==2) return 1;
  if(x<2||x%2==0) return 0;
  int i;
  for(i=3;i<=sqrt(x);i+=2)
    if(x%i==0)
      return 0;
  return 1;  
}
 
int main(void){
 
  int n,x,i,num=0;
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&x);
    if(isprime(x))num++;
  }
   
  printf("%d\n",num);
 
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD = 1000000007;
#define INF (1e9)
#define print(x) cout << x << endl;

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;
    return 0;
}


Measured memory_bytes: 256
/*
मनस्वी म्रियते कामं कार्पण्यं न तु गच्छति ।
अपि निर्वाणमायाति नानलो याति शीतताम् ॥
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define p2d(v) for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v) for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v) for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
#define test3(x,y,z) cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define test4(w,x,y,z) cout << #w " = " << w << " " << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    string s;
    cin>>s;

    if(s[0] == s[1] && s[0] == s[2])
    {
        cout<<"No";
    }
    else cout<<"Yes";
        
        












    return 0;
}


Measured memory_bytes: 3596
if __name__ == '__main__':
    S = list(input())

    answer = 0
    for i in range(2**(len(S)-1)):

        operators = (list(format(i, '0' + str(len(S)-1) + 'b').replace('1', '+').replace('0', ' ')))

        state = S[0]
        for j in range(len(S)-1):
            state += operators[j] + S[j+1]
        state = state.replace(' ', '')

        answer += eval(state)

    print(answer)

Measured memory_bytes: 3064