akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = INT32_MAX;
const long long int Mod = 1000000007;
const long long int mod = 100000;//10^5
using ll = long long int; //long long int は64bit
using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using pii = pair<int,int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
//       cin.tie(0);ios::sync_with_stdio(false);
void cinit(){cin.tie(0);ios::sync_with_stdio(false);}
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////

string s;


int main(){
	cin>>s;bool key =false;
	rep(i,1){
		rep(k,7)for(int j =i+k+1;j<s.size();j++){
			if(j<=s.size()){
				//cout<<s.substr(i,k+1)+s.substr(j,7-k-1)<<endl;
				if(s.substr(i,k+1)+s.substr(j,s.size()-j)=="keyence"){
					cout<<"YES"<<endl;
					key  = true;
					return 0;
				}
			}
		}
	}
	if(!key){
		rep(i,s.size()){
			if(s.substr(i)=="keyence"){
				cout<<"YES"<<endl;
					key  = true;
					return 0;
			}
		}
	}
	if(!key)cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<=8&&b<=8){
		printf("Yay!\n");
	}
	else{
		printf(":(\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <chrono>
#include <random>
#include <stack>
#include <ctime>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

const static int N = 50;
int main() {
    int h, w;
    cin >> h >> w;
    char s[N][N];
    rep(i, h) {
        rep(j, w) {
            cin >> s[i][j];
        }
    }

    if (h == 1 && w ==1 ) {
        cout << "No" << endl;
        return 0;
    }
    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '#') {
                if ((i - 1 >= 0 && s[i - 1][j] == '#') || (j - 1 >= 0 && s[i][j - 1] == '#') ||
                    (i + 1 < h && s[i + 1][j] == '#') || (j + 1 < w && s[i][j + 1] == '#')) {
                    continue;
                } else {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    long long int x,y;
    scanf("%lld %lld", &x, &y);
    int i=0;
    while(1){
        if(x>y){
            break;
        }
        x*=2;
        i++;
    }
    printf("%d\n", i);
    return 0;
}


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

int main () {
  string a;
  cin >> a;
  
  string s;
  int ans=0;
  
  for (int tmp = 0; tmp < (1 << 3); tmp++) {
    s=a[0];
    ans +=a[0]-'0';
    
    for (int i = 0; i < 3; i++) {
      if (tmp & (1<<i)) {
        s+='+';
        s+=a[i+1];
        ans += a[i+1]-'0';        
      }else{
        s+='-';
        s+=a[i+1];
        ans -= a[i+1]-'0';  
      }
    }
    if(ans==7){
      break;
    }
    ans=0;
  }
  cout << s << "=7"<< endl;
  return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <utility>
using namespace std;

typedef struct{
	char c;
	int v;
}cards;

int main(){
	int n;
	cards x[36], y[36], z[36];
	int count=0;
	
	scanf(" %d", &n);
	for(int i=0; i<n; ++i){
		scanf(" %c %d", &x[i].c, &x[i].v);
		y[i]=x[i];
		z[i]=x[i];
	}
	
	//bubble sort	
	bool flag=true;
	while(flag){
		flag=false;
		for(int i=n-1; i>0; --i){
			if(y[i].v<y[i-1].v){
				swap(y[i], y[i-1]);
				flag=true;
			}	
		}
	}
	
	//selection sort	
	for(int i=0; i<n; ++i){
		int minj=i;
		for(int j=i; j<n; ++j){
			if(z[j].v<z[minj].v) minj=j;		
		}	
		
		if(i!=minj) swap(z[i], z[minj]);
	}

	
	for(int i=0; i<n; ++i){
		if(i>0) printf(" ");
		printf("%c%d", y[i].c, y[i].v);
	}
	printf("\n");
	
	printf("Stable\n");
	
	for(int i=0; i<n; ++i){
		if(i>0) printf(" ");
		printf("%c%d", z[i].c, z[i].v);
	}
		printf("\n");
	
	bool f2=true;
	for(int i=0; i<n; ++i) if(y[i].c!= z[i].c) f2=false;
	
	if(f2) printf("Stable\n");
	else printf("Not stable\n");
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;


#define INF 1e+9 //初期化注意
#define MAX_V 100000 //頂点数の最大値

struct edge {
	int to;
	int cost;
	//edge e ={to, cost}
};

// <最短距離, 頂点の番号>
using P = pair<int, int>;

int V;// 頂点の数
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
	//sからiへの最短距離をd[i]に保存 i=e.to
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V, INF);
	d[s] = 0;//初期位置へのコストは0

	que.push(P(0, s));
	//queはmake_pair(cost,to)?

	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;//v=e.to	from s to v
		//すでにこの経路よりいい経路が見つかっているなら無視
		if (d[v] < p.first) continue;
		

		for (int i = 0; i < G[v].size(); ++i) {
			edge e = G[v][i];
			// i 番目の v と v'を結ぶ辺　G=<e.to, e.cost>
			//e.to=v'
	                //e.cost means v to v' costs e.cost
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				//from s to v'> from s to v + from v to v'
				//vを経由したほうがコストが低いなら経由する
				que.push(P(d[e.to], e.to));
			}
		}
	}
}


void solve()
{
	int n;
	int x,y;
	cin>>n>>x>>y;
	V=n;
	int E=n-1;
	for (int i = 0; i < E; ++i) {
		int a=i, b=i+1,c=1;
		//the route a to b costs c
		edge e = { b, c };
		G[a].push_back(e);
		e={a,c};
		G[b].push_back(e);
		//有向グラフの場合であり、無向グラフなら e{a,c}も必要
	}
	x--; y--;
	edge e={y,1};
	G[x].push_back(e);
	e={x,1};
	G[y].push_back(e);
	vector<int>dis(n);
	rep(i,n){
		dijkstra(i);
		FOR(j,i+1,n){
			dis[d[j]]++;
		}
	}
	FOR(i,1,n){
		cout<<dis[i]<<endl;
	}
	//dijkstra(int s); nからの最短距離を計算
	//d[i]はsからiまでの最短距離が保存される the path from s to i costs d[i]
}
	


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}


Measured memory_bytes: 2688
#include <iostream>

using namespace std;

int main(void){
  int i,j,k,l;
  int a,b,c;
  int sum;
  int judge;
  
  while(cin>>a>>b>>c){
    sum=0;
    judge=0;
    sum+=a+b;
    for(i=1;i<11;i++){
      if(sum+i<=20&&i!=c&&i!=a&&i!=b){
	judge++;
      }
    }
    if((double)judge/7.0>=0.5){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
  return(0);
}

Measured memory_bytes: 1152
N = gets.to_i
z = [nil]

N.times do
  z << gets.split.map(&:to_i)
end

def dist(z1, z2)
  Math.sqrt((z1[0] - z2[0])**2 + (z1[1] - z2[1])**2)
end

sum = 0.0

[*1..N].permutation(N) do |i|
  i.inject { |j, k| sum += dist(z[j], z[k]); k }
end

puts sum / [*1..N].inject(:*)

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main()
{
    int A, B, K;
    cin >> A >> B >> K;

    int cnt = 0;

    FORR(i, min(A, B), 1)
    {
        if (A % i == 0 && B % i == 0)
        {
            cnt++;
            if (cnt == K)
            {
                cout << i << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long int n, k; cin >> n >> k;
	if(k==0){
		cout << n*n << endl;
		return 0;
	}
	long long int c = 0;
	for(long long int i=k+1;i<=n;i++){
		if(n%i<k){
			c += (n/i)*(i-k);
		}
		if(n%i>=k){
			c += (n/i)*(i-k)+n%i-k+1;
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstdlib>
#include <map>

using namespace std;


struct UFNode
{
    UFNode *parent;
    int rank;
    UFNode(){
        parent=this;
        rank=0;
    }
};

typedef pair<UFNode*, UFNode*> P;

UFNode* find(UFNode *n)
{
    if(n->parent==n) return n;
    else return n->parent=find(n->parent);
}

void unite(UFNode *a,UFNode *b)
{
    UFNode *x=find(a),*y=find(b);
    if(x==y) return;
    if(x->rank < y->rank) x->parent=y;
    else{
        y->parent=x;
        if(x->rank == y->rank) x->rank++;
    }
}

int main(){
    int N, K, L;
    scanf("%d%d%d", &N, &K, &L);
    vector<UFNode*> road(N), rail(N);
    for (int i=0; i<N; i++) {
        road[i] = new UFNode();
        rail[i] = new UFNode();
    }
    int p, q;
    for (int i = 0; i < K; i++) {
        scanf("%d%d", &p, &q);
        unite(road[p - 1], road[q - 1]);
    }
    for (int i = 0; i < L; i++) {
        scanf("%d%d", &p, &q);
        unite(rail[p - 1], rail[q - 1]);
    }
    map<P, int> num;
    for (int i = 0; i < N; i++) {
        P p(find(road[i]), find(rail[i]));
        if (num.find(p) == num.end())
            num[p] = 1;
        else
            num[p]++;
    }
    for (int i = 0; i < N; i++) {
        P p(find(road[i]), find(rail[i]));
        if (i < N - 1)
            printf("%d ", num[p]);
        else
            printf("%d", num[p]);
    }
    printf("\n");
}


Measured memory_bytes: 27136
#include <iostream>
#include <algorithm>
using namespace std;
int head, tail;
const int num = 100005;
typedef struct pp {
	char name[11];
	int t;
} p;
p s[num];
void enqueue(p a) {
	s[tail] = a;
	tail = (1 + tail) % num;
}
p dequeue() {
	p b = s[head];
	head = (1 + head) % num;
	return b;
}

int main() {
	int n, q, i, sum = 0;
	cin >> n;
	cin >> q;
	for (i = 0; i < n; i++) {
		cin >> s[i].name >> s[i].t;
	}
	head = 0;
	tail = n;
	while (head != tail) {
		p c = dequeue();
		int j = min(q, c.t);
		c.t -= j;
		sum += j;
		if (c.t > 0) 
			enqueue(c);
		else cout << c.name <<' '<< sum << endl;
	}
	return 0;
}

Measured memory_bytes: 4600
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    s=readline().strip()
    x,y=map(int,readline().split())
    n=len(s)

    now_x={0}
    now_y={0}
    i=0
    first=True
    flag="x"
    cnt=0
    while i<n:
        if s[i]=="F":
            cnt+=1
            i+=1
            if i==n:
                nex=set()
                if flag=="x":
                    l=len(now_x)
                else:
                    l=len(now_y)
                for _ in range(l):
                    if flag=="x":
                        now=now_x.pop()
                    else:
                        now=now_y.pop()
                    nex.add(now+cnt)
                    if first==False:
                        nex.add(now-cnt)
                if flag=="x":
                    now_x=nex
                    flag="y"
                else:
                    now_y=nex
                    flag="x"
        else:
            nex=set()
            if flag=="x":
                l=len(now_x)
            else:
                l=len(now_y)
            for _ in range(l):
                if flag=="x":
                    now=now_x.pop()
                else:
                    now=now_y.pop()
                nex.add(now+cnt)
                if first==False:
                    nex.add(now-cnt)
            if flag=="x":
                now_x=nex
                flag="y"
            else:
                now_y=nex
                flag="x"
            if first:
                first=False
            i+=1
            cnt=0

    if x in now_x and y in now_y:
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()

Measured memory_bytes: 3688
import java.util.Scanner;

public class Main {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  int tmp,case_num = 1;
  while((tmp = sc.nextInt()) != 0){
   System.out.printf("Case %d: %d\n",case_num++, tmp);
  }
 }
}


Measured memory_bytes: 65108
N = int(input())
D = list(map(int, input().split(" ")))
mod = 998244353

count = [0 for i in range(N)]
for i in range(N):
    count[D[i]] += 1
max_dist = max(D)
ans = count[0]

for i in range(1, max_dist + 1):
    ans *= (count[i - 1] ** count[i]) % mod
    ans %= mod

if count[0] > 1 or D[0] != 0:
    ans = 0

print(ans % 998244353)

Measured memory_bytes: 55532
#include<bits/stdc++.h>
using namespace std;
int main(){
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     string a;
     int b,c;
     cin>>a;
     b=a.size();
     if(a[b-1]!='s') cout<<a<<'s'<<endl;
     else if(a[b-1]=='s') cout<<a<<"es"<<endl;
     return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include <algorithm>
#include<cstdio>
#include<string>
#include<math.h>
#include<vector>
#include <queue>
#include <bits/stdc++.h>
using namespace std;
typedef vector<vector<char>> field_t;
typedef long long ll;
typedef pair<int, int> point_t;

int main()
{
	ll N,K,tmp,i;
    cin >> N;
	K=0;
	for(i=1;i<=N;i++){
		if(i%3!=0&&i%5!=0){
			K+=i;
		}
			
	}
	cout <<K<< endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
    int n;ll k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i=0;i<n;i++){
        cin >> a.at(i);
    }
    vector<int> s;
    vector<int> ord(n+1,-1);
    int c = 1; 
    int l=0;
    {
        int v = 1;
        while(ord[v]== -1){
            ord[v] = s.size();
            s.push_back(v);
            v = a[v-1];
        }
        c = s.size() -ord[v];
        l = ord[v];
    }
    if(k < l) 
        cout << s[k] << endl;
    else {
        k -= l;
        k %= c;
        cout << s[l+k] << endl;
    }
    return 0;
}

Measured memory_bytes: 5888
import sys,collections
sys.setrecursionlimit(1000000)
N = int(sys.stdin.readline())
#sdw = [[src1 dist1 d1][src1 dist1 d1]...]# vect source1 -> distance1 distances
INF = float("inf")

stw = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N-1)) # multi line with multi param

G = [{} for _ in range(N)]

for s,t,w in stw:
    G[s][t] = w
    G[t][s] = w
#print(G)
distance = [0]*N
ret = 0

def dfs(c,w,visited):
    if c in visited:
        return
    distance[c] = w
    visited.add(c)
    for to,dw in G[c].items():
        dfs(to,w+dw,visited)

dfs(0,0,set())
#print(distance)
i = distance.index(max(distance))
dfs(i,0,set())
#print(distance)

print(max(distance))



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

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU 

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

struct Edge {
public:
	int from, to;
	Edge() {}
	Edge(int _from, int _to) {
		from = _from;
		to = _to;
	}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
bool b;

vi indeg;//各頂点の入次数を管理。
vb visited;//各頂点の訪問状態を管理

void bfsForTSort(int s, Graph G, vi &out) {
	queue<int> Q;
	Q.push(s);
	visited[s] = true;
	while (!Q.empty()) {
		int u = Q.front(); Q.pop();
		out.push_back(u);
		int cnt = 0;
		for (Edge e : G[u]) {
			indeg[e.to]--;
			if (indeg[e.to] == 0 && !visited[e.to]) {
				visited[e.to] = true;
				Q.push(e.to);
				cnt++;
			}
		}
		if (cnt >= 2) {
			b = true;
		}
	}
}


vi topologicalSort(Graph G) {
	vi ret;//返り値
	indeg = vi(SZ(G), 0);
	visited = vb(SZ(G), false);
	REP(i, SZ(G)) {
		for (Edge e : G[i]) {
			indeg[e.to]++;
		}
	}
	int cnt = 0;
	REP(i, SZ(G)) {
		if (indeg[i] == 0)cnt++;
	}
	if (cnt != 1)b = true;
	
	REP(u, SZ(G)) {
		if (indeg[u] == 0 && !visited[u]) {
			bfsForTSort(u, G, ret);
		}
	}
	return ret;
}




int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	Graph G(N);
	b = false;
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(Edge(a, b));
	}
	vi v = topologicalSort(G);
	REP(i, N) {
		cout << v[i] + 1 << endl;
	}

	G.push_back(Edges());
	REP(i, N) {
		if (SZ(G[i]) == 0)G[i].push_back(Edge(i, N));
	}
	
	cout << ((b) ? 1 : 0) << endl;
	PAU;
	return 0;
}




Measured memory_bytes: 6208
#include <iostream>

using namespace std;

int main() {
	int n, m;

	cin >> n >> m;

	int a[n][m];
	int b[m];

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

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

	int c[n] = { 0 };

	for(int i = 0;i < n;i++) {
		for(int j = 0;j < m;j++) {
			c[i] += a[i][j] * b[j];
		}
	}

	for(int i = 0;i < n;i++) {
		cout << c[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
 
 
 
 
int main() {
    int n;
    cin>>n;
    ll h[n];
    rep(i,n){
        cin>>h[i];
    }
    int maxi=0;
    int count=0;

    rep(i,n){

        for(int j=i;j<n;j++){
            if(h[j]>=h[j+1]){
                count++;
            }else{
                i=j;
                break;
            }
        }
        if(count>=maxi){
            maxi=count;
        }
        count=0;
    }
    cout<<maxi<<endl;
}


Measured memory_bytes: 1024
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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; }
int n, x;
vector<int> m;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> x;
    m.resize(n);
    rep(i,n)cin>>m[i];
    sort(ALL(m));
    int sum=0;
    rep(i,n)sum+=m[i];
    int ans=n;
    x-=sum;
    ans+=x/m[0];
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
using namespace std;
int main(){
    vector<char> v;
    vector<char> v1;
    int t;
    int k=0;
    cin >> t;
    char c[t];
    cin >> c;
    for(int i=0;i<t; ++i){
           v.push_back(c[i]);    
    }
    v1.push_back(v[0]);
      //a
      //aabbc
    for(int i=1; i<v.size(); ++i){
        if(v1[k]!=v[i]){
            v1.push_back(v[i]);
            k++;
        }
    }
    
   cout << v1.size() <<"\n";
    
    return 0;
    
}

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

using namespace std;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    long long int a;
    cin>>a;
    long long int b;
    bool f=true;
    while(f){
        b=sqrt(a);
        if(b*b==a)f=false;
        else a--;
    }
    cout<<a<<"\n";
}

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

using std::swap;

const int N=2e5+10;

struct Edge{ int to,next; }way[N<<1];

int n,num[N],tot,In[N],app[N],val[N],val1[N],val2[N];
bool cir[N],vis[N];

void Build(int a,int b) { way[++tot]=(Edge){b,num[a]}; num[a]=tot; }

void Init() {
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&In[i]);
}

void Dfs(int x,int fa) {
	for (int i=num[x];i;i=way[i].next) {
		int v=way[i].to;
		Dfs(v,x);
	}
	for (int i=num[x];i;i=way[i].next) {
		int v=way[i].to;
		app[val[v]]++;
	}
	int cnt=fa?1:2;
	for (int i=0;cnt;++i) if (!app[i]) {
		if (cnt==2) val2[x]=i;
		else val[x]=val1[x]=i; 
		cnt--;
	}
	for (int i=num[x];i;i=way[i].next) {
		int v=way[i].to;
		app[val[v]]--;
	}
}

void Solve() {
	int rt=1; while (!vis[rt]) vis[rt]=1,rt=In[rt];
	while (!cir[rt]) cir[rt]=1,rt=In[rt];
	for (int i=1;i<=n;++i) if (!cir[i]) Build(In[i],i);
	for (int i=1;i<=n;++i) if (cir[i]) Dfs(i,0);
	for (int i=1;i<=n;++i) if (cir[i]) {
		for (int j=1;j<=n;++j) if (cir[j]) {
			val[j]=-1;
			if (val2[j]<val1[j]) swap(val1[j],val2[j]);
		}
		val[i]=val1[i]; 
		int x=In[i],pre=i;
		do{
			if (val[pre]==val1[x]) val[x]=val2[x];
			else val[x]=val1[x];
			pre=x; x=In[x];
		}while (x!=In[i]);
		if (val1[i]==val[i]) { printf("POSSIBLE\n"); return ; }
		
		for (int j=1;j<=n;++j) if (cir[j]) val[j]=-1;
		val[i]=val2[i]; x=In[i],pre=i;
		do{
			if (val[pre]==val1[x]) val[x]=val2[x];
			else val[x]=val1[x];
			pre=x; x=In[x];
		}while (x!=In[i]);
		if (val2[i]==val[i]) { printf("POSSIBLE\n"); return ; }
		else { printf("IMPOSSIBLE\n"); return ; }
		break;
	}
}

int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 8320
#include <algorithm>
#include <iostream>
#include <vector>

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

constexpr ll INF {1000000000000000001};

int main() {
  ll n, k;
  std::cin >> n >> k;
  std::vector<ll> A(n);
  rep(i, n) std::cin >> A[i];
  std::sort(A.begin(), A.end());
  ll left = -INF, right = INF;
  for (ll mid = (left+right)/2;left+1<right;mid = (left+right)/2) {
    bool ok = [&]{
      ll total = 0;
      rep(i, n) {
        if (A[i] < 0) {
          ll l = -1, r = n;
          for (ll c = (l+r)/2;l+1<r;c = (l+r)/2) {
            if (A[c]*A[i] < mid) {
              r = c;
            } else {
              l = c;
            }
          }
          total += n-r;
        } else {
          ll l = -1, r = n;
          for (ll c = (l+r)/2;l+1<r;c = (l+r)/2) {
            if (A[c]*A[i] < mid) {
              l = c;
            } else {
              r = c;
            }
          }
          total += r;
        }
        if (A[i]*A[i] < mid) --total;
      }
      total /= 2;
      return total<k;
    }();
    if (ok) {
      left = mid;
    } else {
      right = mid;
    }
  }
  std::cout << left << '\n';
}


Measured memory_bytes: 1792
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      int cnt = 0;
      for(int i = 0;i < n;i++){
        a[i]=sc.nextInt();
        if(a[i]%2==1)cnt++;
      }
      if(cnt%2==0)System.out.println("YES");
      else System.out.println("NO");
    }
}

Measured memory_bytes: 51948
import java.util.Scanner;
public class Main{
	public static void main(String[]args){
		Scanner sc =new Scanner(System.in);
		int Su[] ={0,6000,4000,3000,2000};
		int Ke[] ={0,0,0,0};
		for(int i = 0; i < 4; i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			Ke[i] = Su[a] * b;
		}
		for(int n = 0; n < 4; n++){
			System.out.println(Ke[n]);
		}
	}
}

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

int main(void)
{
    int n,m,X,Y,x[100],y[100],i,j,aright,bleft;

    scanf("%d %d %d %d",&n,&m,&X,&Y);
    for ( i = 0; i < n; i++)
    {
        scanf("%d",x+i);
    }
    for ( j = 0; j < m; j++)
    {
        scanf("%d",y+j);
    }

    aright=X;
    for ( i = 0; i < n; i++)
    {
        if(aright<x[i]) aright=x[i];
    }

    bleft=Y;
    for ( j = 0; j < m; j++)
    {
        if(bleft>y[j]) bleft=y[j];
    }

    if(aright<bleft) printf("No War");
    else printf("War");

    return 0;
}

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

#define pi 3.141592654
#define fix(n) cout << fixed << setprecision(n)

#define rep(i,a,b) for(int i=a;i<b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)

#define ll  long long
#define ull unsigned long long

#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define vi      vector<int>
#define pii     pair<int,int>
#define piii    pair<pair<int,int>,int>
#define all(v)  v.begin(), v.end()

int mod = 998244353;
const int N = 5005;

// gcd
ll gcd(ll a , ll b)
{
    if ( b == 0)
    return a;
    return gcd( b, a % b);
}
bool check(string a, string b)
{
	int l = a.length();
	for ( int i = 0; i < l ; i++)
	{
		if ( a[i] == '?')
			continue;
		if ( a[i] != b[i])
			return false;
	}
		return true;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string s, t;
	cin >> s >> t;
	vector<string> v;
	int l = s.length();
	int tl = t.length();
	for ( int  i = 0; i <= l - tl; i++)
	{
		string a = "";
		for ( int j = 0; j < tl; j++ )
			a += s[i+j];
		if ( check(a,t))
		{
			string ans = "";
			for ( int j = 0; j  < i; j++)
			{
				if ( s[j] == '?')
					ans += 'a';
				else
					ans += s[j];
			}
			for ( int j = 0; j < t.length(); j++)
				ans += t[j];
			for ( int j = i + t.length(); j < l; j++)
			{
				if ( s[j] == '?')
					ans += 'a';
				else
					ans += s[j];
			}
			v.pb(ans);
		}
	}
	if ( v.size() == 0)
	{
		cout << "UNRESTORABLE";
		return 0;
	}
	sort(all(v));
	cout << v[0] << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
int main(){
    int N,M;
    std::cin>>N>>M;
    std::vector<std::vector<int> > graph(N,std::vector<int>(0));
    std::vector<int>guide(N,-1);
    for(int i=0;i<M;++i){
        int A,B;
        std::cin>>A>>B;
        graph[A-1].push_back(B-1);
        graph[B-1].push_back(A-1);
    }
    guide[0]=0;
    std::queue<int> q;
    q.push(0);
    while(!q.empty()){
        int searchNum=q.front();
        q.pop();
        for(int i=0;i<graph[searchNum].size();++i){
            int adjustNum=graph[searchNum][i];
            if(guide[adjustNum]==-1){
                guide[adjustNum]=searchNum;
                q.push(adjustNum);
            }
        }
    }
    std::cout<<"Yes"<<std::endl;
    for(int i=1;i<N;++i){
        std::cout<<guide[i]+1<<std::endl;
    }
}

Measured memory_bytes: 10224
cnt = [0] * 11000

n = int(input())

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            value = x*x + y*y + z*z + x*y + y*z + z*x
            if value <= n:
                cnt[value] += 1

for i in range(1, n+1):
    print(cnt[i])


Measured memory_bytes: 9272
#include <stdio.h>

int main(){

  int h,w,n,a[20000],c[200][200];

  scanf("%d%d",&h,&w);
  scanf("%d",&n);
  int i,j;
  for(i=0;i<n;i++)scanf("%d",&a[i]);

  int k=0,cou=0;
  
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(cou==0){
	c[i][j]=k+1;
	a[k]--;
	if(a[k]==0)k++;
      }else{
	c[i][w-1-j]=k+1;
	a[k]--;
	if(a[k]==0)k++;
      }
    }
    if(cou>0)cou=0;
    else cou=1;
  }


  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(j!=w-1)printf("%d ",c[i][j]);
      else printf("%d\n",c[i][j]);
    }
  }

  return 0;
}


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

#define EPS (1e-7)
#define INF (99999999999L)
#define PI (acos(-1))

#define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

int main() {
  ll a, b, c, k; cin >> a >> b >> c >> k;
  if (a < b) swap(a, b);
  if (a < c) swap(a, c);
  cout << a*pow(2,k) + b + c << endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
    
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[][] A = new int[2][N];
        for (int i = 0; i < N; i++) {
            A[0][i] = scanner.nextInt();
        }
        for (int i = 0; i < N; i++) {
            A[1][i] = scanner.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int score = 0;
            for (int j = 0; j < N; j++) {
                if(j<i) score += A[0][j];
                else if(i==j) score += A[0][j] + A[1][j];
                else if(i<j) score += A[1][j];
            }
            ans = Math.max(ans,score);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 1000 + 10;
int arr[MAXN];
bool a[MAXN];
bool b[MAXN];
int x[MAXN], y[MAXN];
unsigned long long int n, k;
int main(){
cin >> n >> k;
for(int i = 1; i <= n; i++){
	cin >> arr[i];
}

int cnt = 1, sum = 0, co = 0;
while(1){
	if(a[cnt] == true){
		break;
	}	
	a[cnt] = true;
	x[co] = cnt;
	co++;
	cnt = arr[cnt];	
	sum++;
}
int cnt2 = cnt, len = 0, z = cnt, co2 = 0;
while(1){
	if(b[cnt2] == true){
		break;
	}	
	b[cnt2] = true;
	y[co2] = cnt2;
	co2++;
	cnt2 = arr[cnt2];
	len++;	
}

if(sum - len >= k){
	cout << x[k];
	return 0;
}
if(sum != len){
	int v = sum - len;
k = k - v;
int mod = k % len;
cout << y[mod];
}else{
	int mod = k % sum;
	cout << x[mod];
}

return 0;
}
//7 2
//2 3 4 5 6 7 4


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

map <string, int> dic;

string lowerword(string w){
    for (int i=0; i<(int)w.size(); i++)
        w[i] = tolower(w[i]);
    return w;
}

int main(void){

	string w1, w2;
	int l=0, m=0, tmp;

	while (true){
		string s;
		cin>>s;
		if (cin.eof()) break;
		s=lowerword(s);
		dic[s]++;

		tmp = dic[s];
		if (tmp>m){
			m = tmp;
			w1 = s;
		}
		tmp = s.size();
		if (tmp>l){
			l = tmp;
			w2 = s;
		}
	}
	cout<<w1<<" "<<w2<<endl;
	return 0;
}

Measured memory_bytes: 1196
#define rep(i,n) for (int i=0;i<n;i++)
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const long long INF = 1LL<<60;

int main(){
  
  int N;
  cin >> N;
  
  vector<int> a(N);
  rep(i,N)
    cin >> a.at(i);
  
  vector<vector<long>> dp(N+1,vector<long>(N+1));
  
  rep(i,N)
    dp.at(i).at(i)=0;
  
  for(int len=1;len<=N;len++){
    for(int i=0;len+i<=N;i++){
      int j=len+i;
      
      if((N-len)%2==0){
        dp.at(i).at(j)=max(dp.at(i).at(j-1)+a.at(j-1),dp.at(i+1).at(j)+a.at(i));
      }else{
        dp.at(i).at(j)=min(dp.at(i).at(j-1)-a.at(j-1),dp.at(i+1).at(j)-a.at(i));
      }
      
      
     
      
      
    }
    
    
  }
  
  
   cout << dp.at(0).at(N) << endl;
 
  
}

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

typedef pair<int, int> pii;
const int N = 55;

int n, maxi, x[N], y[N];
map<pii, int> cnt;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> x[i] >> y[i];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if(i != j)
				cnt[pii(x[i] - x[j], y[i] - y[j])]++;
	for (auto p: cnt)
		maxi = max(maxi, p.second);
	cout << n - maxi;
	return 0;
}

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

int main() {
  string s;
  cin >> s;

  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {

    int i;
    Scanner sc = new Scanner( System.in );
    String str = sc.next();

    String[] stringArray = {"Sunny", "Cloudy", "Rainy"};
    
    for ( i = 0; i < stringArray.length; i ++ ) {
      if (str.equals(stringArray[i])) {
        break;
      }
    }

    System.out.println(stringArray[( i + 1 ) % stringArray.length]);
  }
}

Measured memory_bytes: 21588
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn solve(
    u: usize,
    tmp: u32,
    check: &mut Vec<bool>,
    ans: &mut Vec<u32>,
    neighbors: &Vec<Vec<usize>>,
    count: &Vec<u32>,
) {
    if check[u] {
        return;
    }
    check[u] = true;
    let tmp = tmp + count[u];
    ans[u] = tmp;
    for v in &neighbors[u] {
        solve(*v, tmp, check, ans, neighbors, count);
    }
}

fn main() {
    let nq: Vec<usize> = read_vec();
    let n = nq[0];
    let q = nq[1];
    let abm: Vec<Vec<usize>> = read_vec2(n - 1);
    let pxm: Vec<Vec<u32>> = read_vec2(q);
    let mut count: Vec<u32> = vec![0; n];
    let mut check: Vec<bool> = vec![false; n];
    for px in pxm {
        count[(px[0] - 1) as usize] += px[1];
    }
    let mut ans: Vec<u32> = vec![0; n];
    let mut neighbors: Vec<Vec<usize>> = vec![vec![]; n];
    for ab in abm {
        neighbors[ab[0] - 1].push(ab[1] - 1);
        neighbors[ab[1] - 1].push(ab[0] - 1);
    }
    solve(0, 0, &mut check, &mut ans, &neighbors, &count);
    for i in 0..ans.len() {
        print!("{}", ans[i]);
        if i < ans.len() - 1 {
            print!(" ");
        } else {
            println!("");
        }
    }
}


Measured memory_bytes: 32860
import numpy as np
from numba import jit, i8


@jit(i8[:](i8, i8, i8[:]), nopython=True)
def myfunc(n, k, A):
    for _ in range(k):
        l = np.zeros((n + 1,), dtype=np.int64)
        for i, a in enumerate(A[:-1]):
            l[max(0, i - a)] += 1
            l[min(n, i + a + 1)] -= 1
        A = np.cumsum(l)
        if np.all(A[:-1] == n):
            break
    return A


def main():
    n, k = map(int, input().split())
    A = np.array(list(map(int, input().split())), dtype=np.int64)
    A = np.append(A, 0)
    print(*myfunc(n, k, A)[:-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 137172
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vvi vector<vector<int> >
#define vb vector<bool>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define pii pair<int,int>
#define mii map<int,int>
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mkp make_pair
#define input(a,b,n) for(i=b;i<n;i++){cin>>a[i];}
#define print(a) for(i=0;i<a.size();i++){cout<<a[i]<<" ";}cout<<endl;
#define trace(a); cout<<"a="<<a<<endl;
#define trace(a,b); cout<<"a="<<a<<" b="<<b<<endl;
#define fast; ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int inf=0x3f3f3f3f3f3f3f3f;
int power(int a, int b){
    int res = 1;
    while(b!=0){
        if(b&1){
            res *= a; 
        }
        a = (a * a);
        b = (b / 2);
    }
    return res;
}
int32_t main()
{
	fast;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
    	int x;
    	cin>>x;
    	double x1=x;
    	int p=100;
    	int t=0;
    	while(p<x1)
    	{
    		p=p+0.01*p;
    		
    		t++;
    	}
    	cout<<t<<endl;
	}
    return 0;
}


Measured memory_bytes: 3656
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<set>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<stack>
#include<tuple>
#include<utility>
typedef long long ll;
#define rep0(i,n) for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n) for(ll i=1; i<=n; i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using namespace std;

int main(){
  int n,m;  cin >> n >> m;
  vi s(n);
  rep0(i,m){ //スイッチの番号
    int k;  cin >> k;
    rep0(j,k){ //スイッチの個数
      int a;  cin >> a;  a--;
      s[a] |= 1 << i;
    }
  }
  int x,p = 0;
  rep0(i,m){ //答えの点灯の仕方
    cin >> x;
    p |= x << i;
  }

  int ans = 0;
  for(int S = 0; S < (1 << n); S++){ //全ての01のパターン
    int t = 0;
    rep0(i,n){
      if(S >> i & 1){ //何ビット目が立っているか
        t ^= s[i]; //XOR演算子
      }
    }
    if(p == t){
      ans++;
    }
  }
  cout << ans;
}


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

typedef long long ll;

int main() {
    string s;
    int sum =0;
    cin>>s;
    int len = s.length();

    for ( int i =0; i<len; i++ )
        sum = sum + (int)s[i] - (int)'0';
    
    if (sum%9==0)
        cout<<"Yes";
    else
    {
        
        cout<<"No";
    }
    
}

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


int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    int ans=0;
    
    sort(a.begin(),a.end());
    
    rep(i,k)ans+=a[i];
    
    cout<<ans;
    
    
    }

Measured memory_bytes: 3576
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] arges) throws ParseException {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] kz = line.split(" ");
		int v1 = Integer.parseInt(kz[0]);
		int v2 = Integer.parseInt(kz[1]);
		List<Integer> vlist = new ArrayList<Integer>();
		List<Integer> v3list = new ArrayList<Integer>();
		List<Integer> kouyaku = new ArrayList<Integer>();
		if (v1 < v2) {
			int v3 = v2 % v1;
			if (v1 >= v3) {

				for (int i = 1; i <= v3; i++) {
					if (v3 % i == 0) {
						v3list.add(i);
					}
					if (v1 % i == 0) {
						vlist.add(i);
					}
				}
			} else {
				for (int i = 1; i <= v1; i++) {
					if (v3 % i == 0) {
						v3list.add(i);
					}
					if (v1 % i == 0) {
						vlist.add(i);
					}
				}

			}

		} else if (v1 > v2) {
			int v3 = v1 % v2;
			if (v3 >= v2) {

				for (int i = 1; i <= v2; i++) {
					if (v2 % i == 0) {
						vlist.add(i);
					}
					if (v3 % i == 0) {
						v3list.add(i);
					}

				}
			} else {

				for (int i = 1; i <= v3; i++) {
					if (v3 % i == 0) {
						v3list.add(i);
					}
					if (v2 % i == 0) {
						vlist.add(i);
					}
				}
			}
		} else {
			kouyaku.add(v1);
		}

		for (int integer : vlist) {
			for (int in : v3list) {
				if (integer == in) {
					kouyaku.add(in);
					break;

				} else if (integer < in) {
					break;
				}
			}
		}
		System.out.println(java.util.Collections.max(kouyaku));

	}
}

Measured memory_bytes: 28236
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

ll calc(vector<ll>& time)
{
  ll res = INF;
  for (ll i = 0; i < 24; ++i) {
    if (time.at(i) > 1) {
      return 0;
    }
    if (time.at(i) == 1) {
      for (ll j = 1; j <= 12; ++j) {
        if (time.at((i + j) % 24) == 1) {
          res = min(res, j);
          break;
        }
        ll temp = i - j;
        if (temp < 0) {
          temp += 24;
        }
        if (time.at(temp) == 1) {
          res = min(res, j);
          break;
        }
      }
    }
  }
  return res;
}

int main()
{
  ll N;
  cin >> N;
  vector<ll> D(N);
  vector<ll> time(24, 0);
  time.at(0) = 1;
  for (ll i = 0; i < N; ++i) {
    cin >> D.at(i);
    time.at(D.at(i)) += 1;
  }

  ll ans = 0;
  for (ll i = 0; i < (1 << 11); ++i) {
    vector<ll> temp = time;
    for (ll j = 0; j < 11; ++j) {
      if (i & (1 << j)) {
        if (temp.at(j + 1) >= 1) {
          temp.at(j + 1) -= 1;
          temp.at(23 - j) += 1;
        }
      }
    }
    ans = max(ans, calc(temp));
  }
  cout << ans << endl;
}


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

using namespace std;

int _sum(int n)
{
    int sum = 0;
    while (n > 0)
    {
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

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

    int min = 10000000000000;
    for (int a = 1; a < N; ++a)
    {
        int b = N - a;
        int c = _sum(a) + _sum(b);
        min = std::min(min, c);
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    Int N;
    cin >> N ;

    cout << 180*(N-2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a.at(i);
    int64_t res = 0;
    rep(i,n){
        while(a.at(i)%2==0){
            res++;
            a.at(i)/=2;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
import bisect
from collections import Counter
def solve():
  n = int(input())
  a = sorted(list(int(i) for i in input().split()))
  c = Counter(a)
  val = list(c.values())
  val.sort()
  ans = [0]*(n+1)
  t = len(val)
  for i in range(1,n+1):
    place = bisect.bisect_left(val,i)
    ans[i] = ans[i-1]+t-place
  for i in range(1,n+1):
    ok = 0
    ng = n+1
    while ng-ok > 1:
      mid = (ok+ng)//2
      if ans[mid] >= i*mid:
        ok = mid
      else:
        ng = mid
    print(ok)
  
solve()


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> void chmax(T& a,const T& b){if(a < b) a = b;}
template<typename T> void chmin(T& a,const T& b){if(b < a) a = b;}
typedef long long ll;

int N;

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

	cin >> N;
	vector<ll> A(N);
	FOR(i,0,N){
		cin >> A [i];
	}

	ll ans = 0,mx = 0;
	FOR(i,0,N){
		if(i == 0){
			ans += A [i] - 1;
			A [i] = 1;
		}
		else if(A [i] > mx + 1){
			ans += (A [i] - 1) / (mx + 1);
			A [i] = mx;
		}
		chmax(mx,A [i]);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
x, y = map(int, input().split())

if y % 2 != 0:
    print("No")
else:
    a = 2 * x - 1/2 * y
    b = y * 1/2  - x

    if a >= 0 and b >= 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 9172
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <limits>
#include <utility>
#include <algorithm>
#include <tuple>
#include <limits>

typedef long long ll;

int main(int argc, char *argv[])
{
    ll n, m, k;
    std::vector<ll> a, b;

    // 入力
    std::cin >> n >> m >> k;

    a.resize(n);
    b.resize(m);

    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
        std::cin >> b[i];
    }

    // pre
    std::vector<ll> aSum(n + 1), bSum(m + 1);

    aSum[0] = 0;
    bSum[0] = 0;

    for (int i = 0; i < n; i++) {
        aSum[i + 1] = aSum[i] + a[i];
    }
    for (int i = 0; i < m; i++) {
        bSum[i + 1] = bSum[i] + b[i];
    }

    int aPtr, bPtr;
    for (aPtr = 0; aPtr < n; aPtr++) {
        if (aSum[aPtr + 1] > k) {break;}
    }
    for (bPtr = 0; bPtr < m; bPtr++) {
        if (aSum[aPtr] + bSum[bPtr + 1] > k) {break;}
    }

    // solve
    int max = aPtr + bPtr;
    for (; aPtr >= 0; aPtr--) {
        for (; bPtr < m; bPtr++) {
            if (aSum[aPtr] + bSum[bPtr + 1] > k) {break;}
        }
        max = std::max(max, aPtr + bPtr);
    }

    std::cout << max << std::endl;

    return 0;
}


Measured memory_bytes: 9596