akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


class UnionFind(n: Int) {
    private val rank = IntArray(n) { 0 }
    private val parent = IntArray(n) { -1 }

    fun find(x: Int): Int {
        if (parent[x] < 0) {
            return x
        }
        parent[x] = find(parent[x])
        return parent[x]
    }

    fun unite(x: Int, y: Int) {
        val x1 = find(x)
        val y1 = find(y)
        if (x1 == y1) {
            return
        }
        if (rank[x1] < rank[y1]) {
            parent[y1] += parent[x1]
            parent[x1] = y1
        } else {
            parent[x1] += parent[y1]
            parent[y1] = x1
            if (rank[x1] == rank[y1]) {
                rank[x1]++
            }
        }
    }

    fun same(x: Int, y: Int): Boolean {
        return find(x) == find(y)
    }

    fun size(x: Int): Int {
        return -parent[find(x)]
    }
}
fun main() {
    val (n, m) = readIntegerList()
    val abs = mutableListOf<List<Int>>()
    val union = UnionFind(n)
    for (i in 0 until m) {
        val (a,b)=readIntegerList()
        union.unite(a-1,b-1)
    }
    var ans=0
     for (i in 0 until n) {
        ans=max(ans,union.size(i))
    }
    println(ans)


}


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

int main(){
    string S;
    cin >> S;
    int N = S.length();
    int C[N]={};
    int move=0;
    int o=0,e=0;
    bool flag = false;
    int index = 0;
    for(int i=0;i<N;i++){
        if(flag){
            if(S[i] == 'R'){
                C[index-1] += o;
                C[index] += e;
                o=1,e=0;
                flag = false;
            }else if(i == S.length()-1){
                if(o==e) o++;
                else e++;
                C[index-1] += o;
                C[index] += e;
            }else{
                if(o==e) o++;
                else e++;
            }
        }else{
            if(S[i] == 'L'){
                C[i-1] += o;
                C[i] += e + 1;
                o=0,e=0;
                flag = true;
                index = i;
            }else{
                if(o==e) o++;
                else e++;
            }
        }
    }
    for(int i=0;i<N;i++) cout << C[i] << " ";

    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    std::string a, b;
    int n;
    std::cin >> a >> b;
    n = std::stoi(a + b);
    if (std::ceil(std::sqrt(n)) == std::floor(std::sqrt(n))) { std::cout << "Yes" << std::endl; }
    else
    {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    char X,Y;
    cin >> X >> Y;

    if(X > Y)
        cout << ">" << endl;
    else if(X == Y)
        cout << "=" << endl;
    else
    {
        cout << "<" << endl;
    }
    
    
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int i = 0; i < m; i++)
    cin >> a.at(i);
  
  for (int i = 0; i < m; i++)
    n -= a.at(i);
  
  if (n < 0)
    cout << -1 << endl;
  else
    cout << n << endl;
  
  return 0;
}

Measured memory_bytes: 3644
import math
class FenwickTree:
    """
    FenwickTree(Binary Indexed Tree)
    total number: n
    queries:
    1. add(i, val): add val to i-th value 
    2. sum(n): sum(bit[0] + ... + bit[n-1])
    complexity: O(log n)

    Self-balancing binary search tree or Segment Tree can do the same, it takes longer to program and complexity also increases.
    Thanks: http://hos.ac/slides/20140319_bit.pdf
    
    used in ARC031 C, indeednow finalB E
    """
    def __init__(self, a_list):
        # 0-indexed
        self.N = len(a_list)
        self.bit = a_list[:]
        for _ in range(N, 1<<(math.ceil(math.log(N, 2)))): self.bit.append(0)
        for i in range(self.N-1):
            self.bit[i | (i+1)] += self.bit[i]

    def add(self, i, val):
        while i < self.N:
            self.bit[i] += val
            i |= i + 1

    def sum(self, n):
        ret = 0
        while n >= 0:
            ret += self.bit[n]
            n = (n & (n + 1)) - 1
        return ret

N, Q = map(int, input().split())
bit = FenwickTree([0]*N)
for _ in range(Q):
    com, x, y = map(int, input().split())
    if com == 0:
        bit.add(x-1, y)
    elif com == 1:
        print(bit.sum(y-1) - bit.sum(x-2))

Measured memory_bytes: 9168
import sys


def main():
    input = sys.stdin.readline

    h, w, k = map(int, input().split())
    s = [input() for _ in range(h)]

    cs = [[0] * (w + 1) for _ in range(h + 1)]
    for i in range(h):
        for j in range(w):
            cs[i +
               1][j +
                  1] = cs[i][j + 1] + cs[i + 1][j] - cs[i][j] + int(s[i][j])

    # print(*cs, sep='\n')
    # print()

    ans = h + w
    for bit in range(1 << (h - 1)):
        border = [0]
        cand = 0
        for i in range(h):
            if (bit >> i) & 1:
                border.append(i + 1)
                cand += 1
        border.append(h)
        if cand >= ans:
            continue
        j0 = 0
        j = 1
        while j <= w:
            # for j in range(1, w + 1):
            for i, bi in enumerate(border[:-1]):
                # print(
                #     j0, j, border[i], border[i + 1], cs[border[i + 1]][j] -
                #     cs[border[i + 1]][j0] - cs[border[i]][j] + cs[border[i]][j0])
                if cs[border[i + 1]][j] - cs[border[
                        i + 1]][j0] - cs[bi][j] + cs[bi][j0] > k:
                    cand += 1
                    j0 = j - 1
                    j -= 1
                    # print(border[i + 1], j, cs[border[i + 1]][j])
                    break
            j += 1
            if cand >= ans:
                break

        # print(border, cand0, cand, cut)
        ans = min(ans, cand)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 45148
from functools import reduce
M, D = map(int, input().split())
#[(4, '22'), ('6', '23'), ('6', '32'), ('8', '24'), ('9', '33'), ('10', '25'), ('12', '26'), ('12', '34'), ('14', '27'), ('15', '35')]

count = 0
for m in range(1, M+1):
    for d in range(12, D+1):
        if '1' in str(d):
            continue
        elif reduce(lambda x, y: x*y, map(int, list(str(d)))) == m:
            count += 1
print(count)

Measured memory_bytes: 3828
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

void main()
{
    auto ip = readln.split.to!(int[]);
    auto A = ip[0];
    auto B = ip[1];
    auto C = ip[2];
    auto X = ip[3];
    auto Y = ip[4];

    writeln(min(
        X * A + Y * B,
        X * 2 * C + max(Y - X, 0) * B,
        max(X - Y, 0) * A + Y * C * 2,
        max(X, Y) * C * 2
    ));
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
using namespace std;

/*
const int MAX_E=2*(100-1);
const int MAX_V=100;
const long long int INF=100000000;
struct edge { int from,to,cost;};
edge es[MAX_E];
//int d[MAX_V];
int V,E;
void shortest_path(int s,int e,vector<int>& d);
int main(){
	int n,k;
	while(cin >> n >> k&&n!=0&&k!=0){
		int V=n;
		int E=2*(n-1);
		vector<int> land(V);
		int l=0;
		for(int i=0; i<E; ++i){
			es[i].cost=-1;
			es[i].from=-1;
			es[i].to=-1;
		}
		for(int i=0; i<k; ++k){
			int m;
			cin >> m;
			if(m==0){
				int a,b;
				cin >> a >> b;
				shortest_path(a,b,land);
				cout << land[b] << "\n";
			} else if(m==1){
				int c,d,e;
				cin >> c >> d >> e;
				es[l].from=c;
				es[l].to=d;
				es[l].cost=e;
				es[l+1].from=d;
				es[l+1].to=c;
				es[l+1].cost=e;
				l+=2;
			}
		}
	}
	return 0;
}

void shortest_path(int s,int e,vector<int>& d){
	cout << "ok1\n";
	for(int i=0; i<V; ++i) {
		cout << "ok\n";
		d[i]=INF;
	}
	d[s]=0;
	while(true){
		cout << "ok2\n";
		bool update=false;
		for(int i=0; i<E; ++i){
			edge e=es[i];
			if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
				update=true;
			}
		}
		if(!update) break;
	}
}
*/
/*
const int INF=100000000;
int main(){
	int n;
	while(cin >> n&&n!=0){
		vector<int> color;
		for(int i=0; i<n; ++i){
			int t;
			cin >> t;
			color.push_back(t);
		}
		int maxDel=INF;
		for(int i=0; i<n; ++i){
			for(int j=1; j<=3; ++j){
				if(color[i]==j) continue;
				int up=i-1;
				int down=i+1;
				int sum=0;
				int c=1;
				int col=j;
				while(1){
					int nCal=-1;
					while(1){
						if(up<0) break;
						if(color[up]!=col){
							nCal=color[up];
							break;
						}
						up--;
						c++;
					}
					while(1){
						if(down>=n) break;
						if(color[down]!=col){
							if(nCal==-1) nCal=color[down];
							break;
						}
						++down;
						++c;
					}
					if(c>=4){
						sum+=c;
					} else{
						break;
					}
					c=0;
					if(nCal==-1){
						break;
					}else{
						col=nCal;
					}
				}
				maxDel=min(maxDel,n-sum);
			}
		}
		cout << maxDel << "\n";
	}
	return 0;
}
*/

int main(){
	int m=10000,n=100000;
	for(int i=0; i<3; ++i){
		int tmp;
		cin >> tmp;
		m=min(m,tmp);
	}
	for(int i=0; i<2; ++i){
		int tmp;
		cin >> tmp;
		n=min(tmp,n);
	}
	cout << m+n-50 << "\n";
	return 0;
}

Measured memory_bytes: 1164
// AOJ 2040 Sort the Panels
// 2018.3.13 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define QMAX 300000
typedef struct { int s; char p; char t; } QUE;
QUE que[QMAX]; int qsize, qmax;

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

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

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

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

void enq(int s, int t, char p)
{
	int i, min;
	QUE qt;

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

#define ABS(a)  ((a)>=0?(a):-(a))
char dist[1<<16][16];

int dijkstra(int n, int nb, int start, int goal)
{
	int i, j, k, m, s, t, p, ns, nt, nw;
	int pi, ij;

	memset(dist, 75, sizeof(dist));
	qsize = 0;
	t = -1, nw = n - nb;
	for (p = 0; p < n; p++) dist[start][p] = 0, enq(start, 0, p);
	while (qsize) {
		s = que[0].s, t = que[0].t, p = que[0].p, deq();
		if (s == goal) break;

		if (dist[s][p] < t) continue;

		for (k = i = 0; k < nb; i++) if (s & (1<<i)) { k++, pi = ABS(p-i);
			for (m = j = 0; m < nw; j++) if (!(s & (1<<j))) { m++;
				ij = ABS(j-i);
				ns = s ^ (1<<i) ^ (1<<j);
				nt = t + pi+ij;
				if (dist[ns][j] > nt) dist[ns][j] = nt, enq(ns, nt, j);
				nt = t + ABS(p-j)+ij;
				if (dist[ns][i] > nt) dist[ns][i] = nt, enq(ns, nt, i);
			}
		}
	}
	return t;
}

int calc(char *s) { int res=0; while (*s > ' ') res = (res<<1)|(*s++ == 'B'); return res; }

int main()
{
	int n, nb, start, goal;
	char buf[20], *p;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		n = atoi(buf);
		fgets(p=buf, 20, stdin); nb = 0; while (*p > ' ') if (*p++ == 'B') nb++;
		start = calc(buf);
		fgets(buf, 20, stdin), goal = calc(buf);
		if (nb > n-nb) {
			nb = n-nb;
			start = ~start & ((1<<n)-1), goal = ~goal & ((1<<n)-1);
		}
		printf("%d\n", dijkstra(n, nb, start, goal));
	}
	return 0;
}


Measured memory_bytes: 5008
import java.util.*;
import java.io.*;
public class Main {
    class Town implements Comparable<Town>{
        int i, v;
        public Town(int i, int v) {
            this.i = i; this.v = v;
        }
        public int compareTo(Town t) {
            return v - t.v;
        }
    }
    class Node {
        Node p = this;
        int sz = 1;
        public Node() {}
        Node find() {
            if(p != this) p = p.find();
            return p;
        }
    }
    boolean Union(Node x, Node y) {
        Node xR = x.find(), yR = y.find();
        if(xR == yR) return false;
        if(xR.sz > yR.sz) {
            yR.p = xR;
            xR.sz += yR.sz;
        } else {
            xR.p = yR;
            yR.sz += xR.sz;
        }
        return true;
    }
    class Edge implements Comparable<Edge> {
        Node u, v;
        int cost;
        public Edge(Node u, Node v, int c) {
            this.u = u; this.v = v; cost = c;
        }
        public int compareTo(Edge e) {
            return cost - e.cost;
        }
    }
    void solve(BufferedReader in) throws Exception {
        int N = toInt(in.readLine());
        Node[] nodes = new Node[N];
        for(int i = 0; i<N; i++) nodes[i] = new Node();
        Town[] t1 = new Town[N], t2 = new Town[N];
        for(int i = 0; i<N; i++) {
            int[] xx = toInts(in.readLine());
            t1[i] = new Town(i, xx[0]);
            t2[i] = new Town(i, xx[1]);
        }
        Arrays.sort(t1);
        Arrays.sort(t2);
        PriorityQueue<Edge> pq = new PriorityQueue<>();
        for(int i = 0; i<N-1; i++) {
            pq.add(new Edge(nodes[t1[i].i], nodes[t1[i+1].i], t1[i+1].v - t1[i].v));
            pq.add(new Edge(nodes[t2[i].i], nodes[t2[i+1].i], t2[i+1].v - t2[i].v));
        }
        long c = 0;
        int p = 1;
        while(p<N) {
            Edge e = pq.poll();
            if(Union(e.u, e.v) ) {
                c += e.cost;
                p++;
            }
        }
        System.out.println(c);
    }
    int toInt(String s) {return Integer.parseInt(s);}
    int[] toInts(String s) {
        String[] a = s.split(" ");
        int[] o = new int[a.length];
        for(int i = 0; i<a.length; i++) o[i] = toInt(a[i]);
        return o;
    }
    void e(Object o) {
        System.err.println(o);
    }
    public static void main(String[] args) throws Exception{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        (new Main()).solve(in);
    }
}


Measured memory_bytes: 62032
str_num_comp::String -> String-> String
str_num_comp x y =  if length x >  length y then "GREATER" else
                    if length x <  length y then "LESS" else same_dig x y
                      where same_dig x y = if (x == []) && (y == []) then "EQUAL" else
                                              let (a,b) = (head x,head y) in
                                              if (read [a]::Int)>(read [b]::Int) then "GREATER" else
                                              if (read [a]::Int)<(read [b]::Int) then "LESS" else same_dig (tail x) (tail y)


main::IO()
main =do
  a<-getLine
  b<-getLine
  putStr (str_num_comp a b)
  putStr "\n"


Measured memory_bytes: 892
N,K = map(int,input().split())
mod = 10**9+7
ans = 0

for i in range(K,N+2):
    mi = ( 0 + i - 1)*i //2
    ma = ( N + ( N - i + 1) )*i //2
    ans += ( ma - mi + 1 ) % mod

print(ans%mod)

Measured memory_bytes: 63568
//Love and Freedom.
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#define ll long long
#define inf 20021225
#define N 410
#define M 40001
using namespace std;
int read()
{
	int s=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return f*s;
}
struct edge{int to,lt,f;}e[M];
int in[N],cnt,s,t,n,m; // clear!
void add(int x,int y,int f)
{
	e[++cnt].to=y; e[cnt].lt=in[x]; in[x]=cnt; e[cnt].f=f;
	e[++cnt].to=x; e[cnt].lt=in[y]; in[y]=cnt; e[cnt].f=0;
}
queue<int> que; int dep[N];
bool bfs()
{
	//printf("GG");
	while(!que.empty())	que.pop();
	memset(dep,0,sizeof(dep)); que.push(s); dep[s]=1;
	while(!que.empty())
	{
		int x=que.front(); que.pop();
		for(int i=in[x];i;i=e[i].lt)	if(!dep[e[i].to] && e[i].f)
		{
			dep[e[i].to]=dep[x]+1,que.push(e[i].to);
			if(e[i].to==t)	return 1;
		}
	}
	return 0;
}
int dfs(int x,int flow)
{
	if(x==t)	return flow;
	int cur=flow;
	for(int i=in[x];i;i=e[i].lt)
	{
		int y=e[i].to; if(dep[y]==dep[x]+1 && e[i].f)
		{
			int tmp=dfs(y,min(cur,e[i].f));// printf("GG");
			cur-=tmp; e[i].f-=tmp; e[i^1].f+=tmp;
			if(!cur)	return flow;
		}
	}
	dep[x]=-1; return flow-cur;
}
vector<int> val[N][N]; int sz[N][N];
void link()
{
	cnt=1; s=N-3; t=s+1;
	memset(in,0,sizeof(in));
	for(int i=1;i<=n;i++)
	{
		add(s,i,1);
		for(int j=1;j<=n;j++)
			if(sz[i][j]<val[i][j].size())	add(i,n+j,1);
	}
	for(int i=1;i<=n;i++)	add(n+i,t,1);
}
int r[N],b[N][N],a[N][N];
void dinic()
{
	//printf("QAQ");
	while(bfs())	dfs(s,inf);
	//printf("QwQ");
	for(int i=1;i<=n;i++)
		for(int j=in[i];j;j=e[j].lt)
		{
			if(e[j].to!=s && e[j^1].f)
			{
				r[i]=e[j].to-n;// printf("%d %d\n",i,r[i]);
				break;
			}
		}
	//printf("QAQ");
}
int main()
{
	n=read(),m=read();
	for(int i=1;i<=n;i++)	for(int j=1;j<=m;j++)
	{
		a[i][j]=read(); int id=(a[i][j]-1)/m+1; val[i][id].push_back(a[i][j]);
		//printf("%d %d\n",i,id);
	}
	//printf("OVO");
	for(int i=1;i<=m;i++)
	{
		link(); dinic();// printf("GG");
		for(int j=1;j<=n;j++)	b[j][i]=val[j][r[j]][sz[j][r[j]]++];
		//printf("QAQ");
	}
	for(int i=1;i<=n;i++,printf("\n"))	for(int j=1;j<=m;j++)
		printf("%d ",b[i][j]),a[j][i]=b[i][j];
	for(int i=1;i<=m;i++)	sort(a[i]+1,a[i]+n+1);
	for(int i=1;i<=n;i++,printf("\n"))	for(int j=1;j<=m;j++)
		printf("%d ",a[j][i]);
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;

  if ((a + b) % 2 == 1) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << (a + b) / 2 << endl;
  }

  return 0;
}


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

#define INF (1<<29)

int m;
int graph[101][101];

void wa(){

  for(int i=1;i<=m;i++){
    for(int j=1;j<=m;j++){
      for(int k=1;k<=m;k++){
	graph[j][k] = min(graph[j][k],graph[j][i]+graph[i][k]);
      }
    }
  }
  
}

int main(){
  int n,a,b,c,d,k;
  
  scanf("%d %d",&m,&n);
    
  fill_n(*graph,101*101,INF);
  for(int i=1;i<=m;i++) graph[i][i]=0;
  
  for(int i=0;i<n;i++){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    graph[a][b]=c;
    graph[b][a]=d;
  }
  
  wa();
  
  scanf("%d,%d,%d,%d",&a,&b,&c,&d);
  printf("%d\n",c-d-graph[a][b]-graph[b][a]);

  return(0);
}



Measured memory_bytes: 2688
/*
ID:greenty2
LANG:C++
TASK:
*/
#include<bits/stdc++.h>
using namespace std;
#define MAX 1005
int n,s[MAX];
int ans;
int book[MAX];
int book2[MAX];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s[i];
	}
	sort(s+1,s+n+1);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans+=s[i];
	}
	if(ans%10)
	{
		cout<<ans<<endl;
		return 0;
	} 
	int t=ans;
	for(int i=1;i<=n;i++)
	{
		if(s[i]%10)
		{
			ans-=s[i];
			break;
		}
	}
	if(ans==t) ans=0;
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
N = int(input())
card = {}
for i in range(N):
    temp = input()
    if temp in card:
        card[temp] += 1
    else:
        card[temp] = 1
M = int(input())
for i in range(M):
    temp = input()
    if temp in card:
        card[temp] -= 1

vals = card.values()
print(str(max(0, max(vals))))

Measured memory_bytes: 3064
ls=[int(s) for s in input().split()]
ls=ls+[int(s) for s in input().split()]
ls=ls+[int(s) for s in input().split()]
N=int(input())
for _ in range(N):
  a=int(input())
  for i in range(9):
    if ls[i]==a:
      ls[i]=0
if ((ls[0]+ls[1]+ls[2])
    *(ls[3]+ls[4]+ls[5])
    *(ls[6]+ls[7]+ls[8])
    *(ls[0]+ls[3]+ls[6])
    *(ls[1]+ls[4]+ls[7])
    *(ls[2]+ls[5]+ls[8])
    *(ls[0]+ls[4]+ls[8])
    *(ls[2]+ls[4]+ls[6]))==0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
n = int(input())
a = [int(x) for x in input().split()]
dp = [0] * n
ans = 0
for i,j in enumerate(a):
    if i + j < n:
        dp[i+j] += 1
    if 0 < i-j:
        ans += dp[i-j]
print(ans) 

Measured memory_bytes: 32200
#include <stdio.h>

#define MAX 2000000
int H,A[MAX+1];

void maxHeapify(int i){
  int l,r,largest,tmp;
  l=2*i;
  r=2*i+1;
  if(l<=H && A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=H && A[r]>A[largest]) largest=r;
  if(largest!=i){
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(largest);
  }
}

int main()
{
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++) scanf("%d",&A[i]);
  for(i=H/2;i>=1;i--) maxHeapify(i);
  for(i=1;i<=H;i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  return 0;
}

	   
    

Measured memory_bytes: 2552
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())
#define MOD 1000000007 
#define mx 100003

long long sum(long long x, long long b){
	if(x == 0)
		return 0;
	return sum(x / b, b) + (x % b);
}
long long n, s;
int main(){
	cin >> n >> s;
	for(int i = 2; i <= 1e6; i++){
		if(sum(n, i) == s){
			cout << i << endl;
			return 0;
		}
	}
	if(s > n){
		cout << -1 << endl;
		return 0;
	}
	if(n == s){
		cout << n + 1 << endl;
		return 0;
	}
	long long selisih = n - s;
	set<long long> faktor;
	for(long long i = 1; i * i<= selisih; i++){
		if(selisih % i == 0){
			faktor.insert(i);
			faktor.insert(selisih / i);
		}
	}
	long long jaw = 1e18;
	for(auto i : faktor){
		if(i <= 1e6)
			continue;
		long long bit = i + 1;
		// debug(bit);
		if((bit - 1) * (n / bit) == selisih){
			assert(sum(n, bit) == s);
			jaw = min(jaw, bit);
		}
	}
	if(jaw == 1e18)
		cout << -1 << endl;
	else cout << jaw << endl;
}


//2.000.002, selisih = bit * (n / bit) - (n / bit);
//(bit - 1) * (n / bit)

// 31415926535
// 1


Measured memory_bytes: 384
(n,m,),*a=$<.map{|z|z.split.map &:to_i}
r=[-1]*-~n
c=r.dup
f=->x{r[x]>0?f[r[x]]:x}
a.map{|u,v|x,y=[f[u],f[v]].sort|[]
m>0&&y&&[r[x]+=r[y],y=!r[y]=x]
y||[c[u]-=1,c[v]-=1]
m-=1}
(1..n).map{|i|p c[i]-r[f[i]]}

Measured memory_bytes: 32508
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

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

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	N, W := nextInt(), nextInt()
	w, v := make([]int, N), make([]int, N)
	for i := 0; i < N; i++ {
		w[i], v[i] = nextInt(), nextInt()
	}

	// dp[i][j][k]: i番目まで見て，j個のモノを使って重さk以下を満たすときの価値の最大値
	dp := make([][][301]int, N+1)
	for i := range dp {
		dp[i] = make([][301]int, N+1)
	}

	for i := 1; i <= N; i++ {
		// 0 <= wi <= 3
		wi, vi := w[i-1]-w[0], v[i-1]
		for j := 1; j <= N; j++ {
			for k := 0; k <= 300; k++ {
				if k >= wi {
					dp[i][j][k] = max(dp[i-1][j][k], dp[i-1][j-1][k-wi]+vi)
				} else {
					dp[i][j][k] = dp[i-1][j][k]
				}
			}
		}
	}

	ans := 0
	for j := 1; j <= N; j++ {
		rem := W - w[0]*j
		if rem >= 0 {
			ans = max(ans, dp[N][j][min(rem, 300)])
		}
	}

	puts(ans)
}


Measured memory_bytes: 25472
#include <bits/stdc++.h>
#include <utility>
using namespace std;
 
int main() {
  int N;
  cin >> N;
 
  map<int,int> m;
  int A[N];
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    m.insert(make_pair(A[i],i+1));
  }
  
  for (auto const& entry: m){
    cout << entry.second << " ";
  }
  
  cout << endl;

  return 0;
}

Measured memory_bytes: 5888
#include <stdio.h>

int main(void)
{
	int i, n, x, y, b, p, sumA, sumB;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%d %d %d %d", &x, &y, &b, &p);
		sumA = x * b + y * p;
		if (b >= 5 && p >= 2){
			printf("%.0f\n", sumA * 0.8);
		}
		else {
			if (b < 5){
				b = 5;
			}
			if (p < 2){
				p = 2;
			}
			
			sumB = x * b + y * p;
			
			if (sumA * 1.0 > sumB * 0.8){
				printf("%.0f\n", sumB * 0.8);
			}
			else {
				printf("%d\n", sumA);
			}
		}
	} 
	
	return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

long long n,x[100005],k,a[100005],b[100005],s,t=LINF;

int main() {
    cin >> n >> k;
    for(int i=1;i<=n;i++){
        cin >> x[i];
        if(x[i]<0) b[i]+=x[i];
        else a[i]+=x[i],s+=x[i];
        a[i]+=a[i-1]; b[i]+=b[i-1];
    }
    for(int i=k;i<=n;i++){
        t=min(t,a[i]-a[i-k]);
        t=min(t,b[i-k]-b[i]);
    }
    cout << s-t;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<cmath>
#include<stdio.h>
#include<string>
using namespace std;

int main() {
	int x;
	cin >> x;
	if (x == 0) {
		cout << 1 << endl;
	}
	else cout << 0 << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <cstring>

using namespace std;

const int MAX_N = 8;
const int dn1 = 12, dn2 = 4;
const int dx1[] = {1, 1, 0, -1, 0, 1, 1, 1, 0, 0, 0, 0};
const int dy1[] = {0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, -1};
const int dz1[] = {0, 0, 0, 0, 1, 1, 0, -1, 0, 1, 1, 1};

const int dx2[] = {1, -1, 1, -1};
const int dy2[] = {1, 1, 1, 1};
const int dz2[] = {1, 1, -1, -1};

int n, m, p;
int board[MAX_N][MAX_N][MAX_N]; // black: 1, white: 2
int num[MAX_N][MAX_N];

int Rec1(int x, int y, int z, int d, int color)
{
    if (x < 0 || x >= n || y < 0 || y >= n || z < 0 || z >= n)
        return 0;
    if (z >= num[x][y] || board[x][y][z] != color)
        return 0;

    if (d >= dn1)
        return Rec1(x - dx1[d - dn1], y - dy1[d - dn1], z - dz1[d - dn1], d, color) + 1;
    else
        return Rec1(x + dx1[d], y + dy1[d], z + dz1[d], d, color) + 1;
}

int Rec2(int x, int y, int z, int d, int color)
{
    if (x < 0 || x >= n || y < 0 || y >= n || z < 0 || z >= n)
        return 0;
    if (z >= num[x][y] || board[x][y][z] != color)
        return 0;

    if (d >= dn2)
        return Rec2(x - dx2[d - dn2], y - dy2[d - dn2], z - dz2[d - dn2], d, color) + 1;
    else
        return Rec2(x + dx2[d], y + dy2[d], z + dz2[d], d, color) + 1;
}

bool Check(int x, int y, int z, int color)
{
    for (int i = 0; i < dn1; ++i)
        if (Rec1(x + dx1[i], y + dy1[i], z + dz1[i], i, color)
            + Rec1(x - dx1[i], y - dy1[i], z - dz1[i], dn1 + i, color) + 1 >= m)
            return true;

    for (int i = 0; i < dn2; ++i)
        if (Rec2(x + dx2[i], y + dy2[i], z + dz2[i], i, color)
            + Rec2(x - dx2[i], y - dy2[i], z - dz2[i], dn2 + i, color) + 1 >= m)
            return true;
    return false;
}

int main()
{
    while (cin >> n >> m >> p, n || m || p) {
        // Init
        vector<pair<int, int> > order(p);
        memset(board, 0, sizeof(board));
        memset(num, 0, sizeof(num));

        // Input
        for (int i = 0; i < p; ++i)
            cin >> order[i].first >> order[i].second;

        // Solve
        bool even = true;
        for (int i = 0; i < p; ++i) {
            int x = order[i].first - 1;
            int y = order[i].second - 1;

            board[x][y][num[x][y]] = ((i % 2 == 0) ? 1 : 2);
            num[x][y]++;
            if (Check(x, y, num[x][y] - 1, board[x][y][num[x][y] - 1])) {
                cout << ((i % 2 == 0) ? "Black" : "White") << " " << i + 1 << endl;
                even = false;
                break;
            }
        }

        if (even)
            cout << "Draw\n";
    }

    return 0;
}

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

int main(){
    int p,q,r;
    cin >> p >> q >> r;
    vector<int> route(3);

    route[0] = p+q;
    route[1] = r+q;
    route[2] = p+r;

    int m = min({route[0],route[1],route[2]});

    cout << m <<endl;
}
    

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

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

    if (counter[0] > 1) {
        cout << 0 << endl;
        return 0;
    }

    counter.erase(0);

    long ans = 1;
    for (auto p: counter) {
        int count = p.second;
        if (count > 2) {
            cout << 0 << endl;
            return 0;
        }
        ans <<= count - 1;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
Q, H, S, D = map(int, input().split())
N = int(input())
Q *= 4
H *= 2
if(N == 1): print(min(Q, H, S))
elif(N == 2): print(min(Q * 2, H * 2, S * 2, D))
else:
    ans = 0
    if(N % 2):
        N = N - 1
        ans += min(N * Q, N * H, N * S, (N // 2) * D)
        ans += min(Q, H, S)
    else:
        ans += min(N * Q, N * H, N * S, (N // 2) * D)
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;

    if(N % K == 0) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}

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

int main(){

  int N,ans=0;
  cin >> N;
  int B[N-1];
  for(int i=0; i<N-1; i++) cin >> B[i];

  ans += B[N-2];
  ans += B[0];
  for(int i=0; i<N-2; i++) ans += min(B[i], B[i+1]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
import numpy as np

def main():
    N,M = map(int,input().split())
    a = list(map(int,input().split()))
    
    l = max(M,max(a)).bit_length()
    a = np.array(a)
    
    base,ans = 0,0
    for i in reversed(range(l)):
        bit = (a>>i)&1
        c = np.count_nonzero(bit==0)
        if c > N//2:
            if base+2**i <= M:
                base += 2**i
                ans += (2**i)*c
            else:
                ans += (2**i)*(N-c)
        else:
            ans += (2**i)*(N-c)
    
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 21552
# C
a,b,c = map(int,input().split())
ans = 'No'
num = c - a - b
if (num > 0):
    num1 = 2 * 2 *  a * b
    num2 = num * num
    if (num1 < num2):
        ans = 'Yes'
print(ans)

Measured memory_bytes: 38384
//
// Created by Md Rashedul Islam on 6/21/2020.
//

#include <bits/stdc++.h>

using namespace std;

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

    //freopen("../in", "r", stdin);

    char c;
    cin >> c;

    if (c >= 'A' && c <= 'Z')
    {
        cout << "A\n";
    } else
    {
        cout << "a\n";
    }
    return 0;
}


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

int N, M, K;

int main() {
	scanf("%d%d%d", &N, &M, &K);
	bool flag = 0;
	for (int n = 0; n <= N; n++) {
		for (int m = 0; m <= M; m++) {
			int val = n * M + N * m - 2 * n * m;
			if (val == K) flag = 1;
		}
	}
	if (flag) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s,t;
    cin>>s>>t;
    int flag=0;
    for (int i=0;i<s.size();i++) {
        if (s[i]!=t[i]) {
            cout<<"No"<<endl;
            flag=1;
            break;
        }
    }
    if (flag==0) {
        cout<<"Yes"<<endl;
    }
}

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

int main(){
    int N;cin>>N;
    map<string,int> dict;
    rep(i,N){
        string s;cin>>s;
        dict[s]++;
    }
    int cnt = 0;
    for(auto it = dict.begin();it != dict.end();it++){
        cnt = max(cnt,it->second);
    }
    for(auto it = dict.begin();it != dict.end();it++){
        if(it->second == cnt){
            cout<<it->first<<endl;
        }
    }
    return 0;
}

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

using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    int sum=0;
    for(int i=0;i<k;i++){
        sum+=v[i];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3624
import fractions
n,m = map(int,input().split())
s = input()
t = input()

lcm = n*m // fractions.gcd(n,m)
ans = -1
ss = lcm // m
ts = lcm // n
j = 0
flg = True
for i in range(0,n,ss):
    if s[i] == t[j] :
        j += ts
        continue
    else:
        flg = False
        break

if flg :
    ans = lcm
print(ans)


Measured memory_bytes: 5432
#pragma optimization_level 3
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, Q;
string S[100000];
int C[100000];
int R[100000][26][26];
int p[256];

class Trie {
public:
  Trie *a[26];
  int ctr;
  bool leaf;

  Trie() {
    for (int i=0; i<26; i++) a[i] = NULL;
    leaf = false;
    ctr = 0;
  }
  void insert(const char *s) {
    if (*s == '\0') {
      leaf = true;
      ctr++;
      return;
    }
    int k = *s - 'a';
    if (a[k] == NULL) {
      a[k] = new Trie();
    }
    a[k]->insert(s+1);
    ctr++;
  }

  int find(const char *s, int x) {
    if (*s == '\0') return leaf;
    int c = leaf;
    int k = *s - 'a';
    for (int i=0; i<26; i++) {
      if (a[i] != NULL) {
        R[x][i][k] += a[i]->ctr;
      }
    }
    if (a[k] == NULL) return c;
    c += a[k]->find(s+1, x);
    return c;
  }
};


signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> S[i];
  cin >> Q;

  Trie trie;
  rep(i, N) trie.insert(S[i].c_str());
  rep(i, N) {
    C[i] = trie.find(S[i].c_str(), i);
  }
  rep(i, Q) {
    int k; cin >> k;
    k--;
    rep(i, 26) {
      char c;
      cin >> c;
      p[c - 'a'] = i;
    }
    int s = C[k];
    rep(i, 26) {
      rep(j, 26) {
        if (p[i] < p[j]) s += R[k][i][j];
      }
    }
    cout << s << "\n";
  }
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a[5];
        for (int j = 0; j < 3; j++) cin >> a[j];
        sort(a, a + 3);

        if ((a[0] * a[0]) + (a[1] * a[1]) == a[2] * a[2]) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}


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

class edge {
public:
	int s, t, w;
	edge(int s, int t, int w) :
			s(s), t(t), w(w) {
	}
	bool operator <(const edge &e) const {
		return w < e.w;
	}
	void print() const {
		cout << s << " " << t << " " << w << endl;
	}
};

class disjointset {
	vector<int> rank, p;
public:
	disjointset(int size) {
		rank.resize(size);
		p.resize(size);
		for (int i = 0; i < size; i++)
			makeset(i);
	}
	void unite(int a, int b) {
		link(findset(a), findset(b));
	}
	bool same(int a, int b) {
		return findset(a) == findset(b);
	}
private:
	void makeset(int x) {
		p[x] = x;
		rank[x] = 0;
	}
	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		} else {
			p[x] = y;
			if (rank[x] == rank[y])
				rank[y]++;
		}
	}
	int findset(int x) {
		if (p[x] == x)
			return x;
		else
			return p[x] = findset(p[x]);
	}
};

#define MAXV 10000
#define MAXE 100000
int v, e;
vector<edge> E;

int kruskal() {
	int ans = 0;
	disjointset DS = disjointset(v);
	for (int i = 0; i < e; i++) {
		if (!DS.same(E[i].s, E[i].t)) {
			DS.unite(E[i].s, E[i].t);
			ans += E[i].w;
		}
	}
	return ans;
}

int main() {
	cin >> v >> e;
	for (int i = 0; i < e; i++) {
		int s, t, w;
		cin >> s >> t >> w;
		E.push_back(edge(s, t, w));
	}
	sort(E.begin(), E.end());
	cout << kruskal() << endl;
	return 0;
}



Measured memory_bytes: 4548
#include<bits/stdc++.h>
using namespace std;
const int M=100001;
int n,q,a,b,c,dd;
struct node{
	int to,cl,val;
};
vector<node>d[M];
int fa[M][18],deep[M];
struct Node{
	int id,x,y,fl;
};
vector<Node>Ask[M];
void dfs(int x,int la){
	fa[x][0]=la;
	deep[x]=deep[la]+1;
	for(int i=0;i<(int)d[x].size();i++){
		int y=d[x][i].to;
		if(y==la)continue;
		dfs(y,x);
	}
}
void Up(int &b,int step){
	for(int i=17;i>=0;i--)if(step&(1<<i))b=fa[b][i];
}
int LCA(int a,int b){
	if(deep[a]>deep[b])swap(a,b);
	Up(b,deep[b]-deep[a]);
	if(a==b)return a;
	for(int i=17;i>=0;i--)if(fa[a][i]!=fa[b][i])a=fa[a][i],b=fa[b][i];
	return fa[a][0];
}
int Ans[M],C[M],sum,cnt[M];
void DFS(int x,int la){
	for(int i=0;i<(int)Ask[x].size();i++){
		Node y=Ask[x][i];
		Ans[y.id]+=(sum-C[y.x]+y.y*cnt[y.x])*y.fl;
	}
	for(int i=0;i<d[x].size();i++){
		node y=d[x][i];
		if(y.to==la)continue;
		sum+=y.val;
		C[y.cl]+=y.val;
		cnt[y.cl]++;
		DFS(y.to,x);
		cnt[y.cl]--;
		C[y.cl]-=y.val;
		sum-=y.val;
	}
}
int main(){
	scanf("%d%d",&n,&q);
	for(int i=1;i<n;i++){
		scanf("%d%d%d%d",&a,&b,&c,&dd);
		d[a].push_back((node)<%b,c,dd%>);
		d[b].push_back((node)<%a,c,dd%>);
	}
	dfs(1,0);
	for(int i=1;i<=17;i++)for(int j=1;j<=n;j++)fa[j][i]=fa[fa[j][i-1]][i-1];
	for(int i=1;i<=q;i++){
		scanf("%d%d%d%d",&a,&b,&c,&dd);
		int lca=LCA(c,dd);
		Ask[c].push_back((Node)<%i,a,b,1%>);
		Ask[dd].push_back((Node)<%i,a,b,1%>);
		Ask[lca].push_back((Node)<%i,a,b,-2%>);
	}
	DFS(1,0);
	for(int i=1;i<=q;i++)printf("%d\n",Ans[i]);
}

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

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int cnt_all = 0;
    int cnt_b = 0;
    rep(i,n) {
        string ans = "No";
        if (s[i] == 'a' && cnt_all < a+b) {
            ans = "Yes";
            cnt_all++;
        }
        if (s[i] == 'b' && cnt_all < a+b && cnt_b < b) {
            ans = "Yes";
            cnt_all++;
            cnt_b++;
        }
        cout << ans << endl;
    }
}

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

int main() {
    int N;
    cin >> N;
    int res=1;
    int cnt=0;
    for (int i=0; i<=N; i+=2) {
        int j=i;
        int c=0;
        while (j>=1) {
            if (j%2==0) {
                j=j/2;
                c++;
            }
            else {
                if (cnt<c) {
                    cnt = c;
                    res = i;
                }
                break;
            }
        }
    }
    cout << res << "\n";
}

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

int main()
{
  int n;
  cin >> n;
  for(int i=0; i<n; i++){
    int a,b,c;
    int temp;
    cin >> a >> b >> c;
    if(a<b){
      temp = a;
      a = b;
      b = temp;
    }
    if(a<c){
      temp = a;
      a = c;
      c = temp;
    }

    if( a*a == b*b + c*c ) cout << "YES" << endl;
    else cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 1152
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

template<typename T>
bool chmax(T &a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T &a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    int n;
    cin >> n;

    int t = n;
    vector< P > v;
    for(int i = 2 ; i * i <= t ; ++i){
        if(t % i == 0){
            int cnt = 0;
            while(t % i == 0){
                t /= i;
                ++cnt;
            }
            v.emplace_back(i, cnt);
        }
    }
    if(t > 1){
        v.emplace_back(t, 1);
    }

    cout << n << ":";
    rep(i, v.size()){
        rep(j, v[i].second){
            cout << " " << v[i].first;
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3212
import java.util.*; 
import java.io.*;

public class Main {
	static int dp[][] = new int[1005][1005]; 
	static char a[][] = new char[1005][1005];
	static int vis[][] = new int[1005][1005]; 
	static int n , m; 
	public static int fun(int i , int j) {
		if(dp[i][j] != -1)
			return dp[i][j]; 
		
		if(i >= n || j >= m) 
			return 0;
		if(a[i][j] == '#') 
			return 0; 
		if(i == n-1 && j == m-1) 
			return 1; 
	     
		return dp[i][j] = (fun(i+1,j) + fun(i , j+1)) % (int) (1e9 + 7); 
	}
	
	public static void solve(InputReader in) {
		 n = in.readInt(); 
		 m = in.readInt(); 
		 
		
		for(int i = 0; i<n; i++) {
			char s[] = in.readString().toCharArray(); 
			for(int j = 0; j<m; j++) {
				a[i][j] = s[j]; 
			}
		}
		
		for(int i = 0; i<1005; i++) {
			for(int j = 0; j<1005; j++) {
				dp[i][j] = -1; 
			}
		}
	    System.out.println(fun(0,0)); 
	}

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		int t = 1; 
		while (t-- > 0)
			solve(in);
	}
}

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

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

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

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

     public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

     public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
     public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
     
     public String next() {
		return readString();
	}
    
     public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 61652
N=int(input())
M=int(input())
target_list=[int(i) for i in input().split(" ")]
vote_list=[[int(i) for i in input().split(" ")] for j in range(M)]
score_list=[0 for i in range(N)]

for i in range(M):
    target=target_list[i]
    vote=vote_list[i]
    for j in range(N):
        if vote[j]==target:
            score_list[j]+=1
        else:
            score_list[target-1]+=1


for i in score_list:
    print(i)

Measured memory_bytes: 7644
#include <bits/stdc++.h>
using namespace std;
int main(){
int X,Y;
  cin>>X>>Y;
  bool nazo=false;
for(int i=0;i<=X;i++){
if(i*2 + (X-i)*4 == Y){
nazo=true;
}
}
  if(nazo){
  cout<<"Yes";
  }
  else{
  cout<<"No";
  }
}

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

int main()
{
  long long int num, k;
  cin >> num >> k;

  vector<long long int> vec(num);
  for(int i=0; i<num; ++i) cin >> vec.at(i);

  // 全ての要素の和
  long long int sum = 0;
  for(int i=0; i<num; ++i) sum += vec.at(i);

  sort(vec.begin(), vec.end());
  long long int sub_sum = 0;
  for(int i=0; i<num-1; ++i) sub_sum += vec.at(i);
                             
  if(num <= k) cout << 0 << endl;
  else if(k==0) cout << sum << endl;
  else{
    sort(vec.begin(), vec.end());
    long long int sub_sum = 0;
    for(int i=0; i<num-k; ++i) sub_sum += vec.at(i);

    cout << sub_sum << endl;
  }
  
}

Measured memory_bytes: 1792
from math import sqrt

x = int(input())
if x == 2:
  print(2)
else:
  if x % 2 == 0:
    x += 1
  while True:
    flag = True
    for mod in range(3, int(sqrt(x))+1, 2):
      if x % mod == 0:
        flag = False
        break
    if flag:
      print(x)
      break
    else:
      x += 2

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

void swap(int *a, int *b) {
  int temp = *a;
  *a = *b;
  *b = temp;
}

int main() {
  int n;  cin >> n;
  
  int card[n];
  for (int i = 0; i < n; i++) 
    cin >> card[i];
  
  sort(card, card + n, greater<int>());
  
  /*
  int max;
  for (int i = 0; i < n; i++) {
    max = i;
    for (int j = i + 1; j < n; j++) {
      if (card[max] < card[j])
        max = j;
    }
    swap(card[i], card[max]);
  }
  */
  
  int alice = 0, bob = 0;
  for (int i = 0; i < n; i += 2) {
    alice += card[i];
    if (i + 1 < n)
      bob += card[i + 1];
  }
  cout << alice - bob << endl;
}


Measured memory_bytes: 256