akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

const int N = 10000;
int main()
{
	int n, q;
	cin >> n >> q;
	
	vector<int> A[N];
	
	while (q--)
	{
		int cmd, t;
		cin >> cmd >> t;
		if (cmd == 0)
		{
			int x;
			cin >> x;
			A[t].push_back(x);
		}
		else if (cmd == 1)
		{
//			for (auto x : A[t])
//			{
//				if (x != *A[t].begin())
//					cout << " ";
//				cout << x;				
//			}
			
			for (vector<int>::iterator it = A[t].begin(); it!= A[t].end(); it++)
			{
				if (it != A[t].begin())
					cout << " ";
				cout << *it;
			}
			cout << endl;

		}
		else
		{
			A[t].clear();

		}
		
	}
	
}


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

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	string s,t;
	cin >> s >> t;
	// sの末尾x文字とtの先頭x文字が一致するとする
	for(int x=N;x>=0;x--){
		bool ok = 1;
		for(int j=0;j<x;j++){
			if(t[j]==s[N-x+j])continue;
			else {
				ok = 0;
				break;
			}
		}
		if(ok){
			cout << 2*N - x << endl;
			return 0;
		}
	}
}

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

int main(){
    int x, a, b;
    cin >> x >> a >> b;

    if(a >= b) cout <<"delicious"<< endl;
    else if(a+x >= b) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    
    return 0;
}

Measured memory_bytes: 256
/*input

*/
#include "bits/stdc++.h"
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int a, b;
	cin >> a >> b;
	cout << (a^b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int s, t;
long long a[2], b[2];

bool inf() {
    long long dist1 = s*a[0] + t*a[1];
    long long dist2 = s*b[0] + t*b[1];
    return (dist1 == dist2);
}

bool f(long long time) {
    long long ta = (s*a[0]+t*a[1]), ao = (s*b[0]+t*b[1]);
    long long sta = ta * (time-1), sao = ao * (time-1);
    long long mta = sta + s * a[0], mao = sao + s * b[0];
    long long fta = ta * time, fao = ao * time;
    if (mta <= mao && fta >= fao) return true;
    if (mta >= mao && fta <= fao) return true;
    return false;
}

long long fin(long long time) {
    long long ta = (s*a[0]+t*a[1]), ao = (s*b[0]+t*b[1]);
    long long sta = ta * (time-1), sao = ao * (time-1);
    long long mta = sta + s * a[0], mao = sao + s * b[0];
    long long fta = ta * time, fao = ao * time;
    if (mta == mao) return 1LL;
    if (mta > mao && fta < fao) return 2LL;
    return 0LL;
}

signed main() {
    cin >> s >> t >> a[0] >> a[1] >> b[0] >> b[1];
    if (inf()) { printf("infinity\n"); return 0; }
    if (a[0]<b[0]&&a[1]<b[1]) { printf("0\n"); return 0; }
    if (a[0]>b[0]&&a[1]>b[1]) { printf("0\n"); return 0; }
    if (b[0] > a[0]) { swap(a[0], b[0]); swap(a[1], b[1]); }
    
    long long ok = 0, ng = 1e18;
    while (abs(ok-ng) > 1) {
        long long mid = (ok + ng) / 2;
        if (f(mid)) ok = mid;
        else ng = mid;
    }
    
    long long ans;
    if (ok == 1) ans = 1;
    else ans = (ok-2)*2 + 1 + fin(ok);
    ans = max(0LL, ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
   int N;
   scanf("%d",&N);
   char S[N];
   scanf("%s",S);
   int count = 0;
   for(int i = 0; i < N; i++) {
      if (S[i] =='A'&&S[i+1]=='B'&&S[i+2]=='C') {
         count++;
      }
   }
   
   printf("%d\n", count);
   
   return 0;
}
  

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

int main(){

    int room[4][3][10];

    for(int x=0; x<4; x++){
        for(int y=0; y<3; y++){
            for(int z=0; z<10; z++){
                room[x][y][z] = 0;
            }
        }
    }

    int n; cin >> n;
    int a, b, c, d;

    for(int i=0; i<n; i++){
        cin >> a >> b >> c >> d;
        a--; b--; c--; 
        room[a][b][c] += d;
    }

    for(int x=0; x<4; x++){
        for(int y=0; y<3; y++){
            for(int z=0; z<10; z++){
                if(z==9) cout << " " << room[x][y][z] << endl;
                else cout << " " << room[x][y][z];
            }
        }
        if(x==3) break;
        else cout << "####################" << endl;
    }

    return 0;
}


Measured memory_bytes: 3096
import collections

N = int(input())
S = []

for i in range(N):
  s = input()
  ss = [i for i in s]
  ss.sort()
  s = ''.join(ss)
  S.append(s)
  
c = collections.Counter(S)
ans = 0

for b in c:
  ans += c[b] * (c[b] - 1) // 2
  
print(ans)

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

int32_t main() {
	int n; cin>>n;
	vector<pair<int,int> > A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i].first;
		A[i].second = i;
	}
	sort(A.rbegin(), A.rend());
	for (int i = 0; i < n; i++)
		if (A[0].second == i)
			cout << A[1].first << endl;
		else
			cout << A[0].first << endl;
}


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

char s[5010],S[10010],mi,ans[5010],nw[5010],ss[5010];
int n,k,len;

int main()
{
	scanf("%d%d%s",&n,&k,s),mi='z';
	for (int i=0; i<n; i++) mi=min(mi,s[i]),ss[i]=s[i];
	if (k>15)
	{
		for (int i=0; i<n; i++) putchar(mi);
		return 0;
	}
	for (int i=0; i<n; i++) ans[i]='z';
	if (k==1)
	{
		for (int j=0; j<n; j++) S[j]=s[j];
		for (int j=n; j<(n<<1); j++) S[j]=s[(n<<1)-j-1];
		for (int j=0; j<=n; j++)
		{
			for (int k=j; k<j+n; k++) nw[k-j]=S[k];
			for (int k=0; k<n; k++) 
			{
				if (nw[k]<ans[k])
				{
					for (int l=0; l<n; l++) ans[l]=nw[l];
					break;
				} else
				if (nw[k]>ans[k]) break;
			}
		}
		return puts(ans),0;
	}
	for (int i=0; i<n; i++) if (s[i]==mi)
	{
		len=0;
		for (int j=0; j<n; j++) S[j]=s[j];
		for (int j=n; j<(n<<1); j++) S[j]=s[(n<<1)-j-1];
		for (int j=n-i; j<=(n<<1)-i-1; j++) s[j-n+i]=S[j];
		for (int j=n-1; j>=0; j--) if (s[j]==mi) len++; else break;
		for (int l=2; l<k; l++)
		{
			for (int j=0; j<n; j++) S[j]=s[j];
			for (int j=n; j<(n<<1); j++) S[j]=s[(n<<1)-j-1];
			for (int j=len; j<=n+len-1; j++) s[j-len]=S[j];
			len<<=1,len=min(len,n);
		}
		for (int j=0; j<n; j++) S[j]=s[j];
		for (int j=n; j<(n<<1); j++) S[j]=s[(n<<1)-j-1];
		for (int j=n-len; j<2*n-len; j++) nw[j-n+len]=S[j];
		for (int k=0; k<n; k++) 
		{
			if (nw[k]<ans[k])
			{
				for (int l=0; l<n; l++) ans[l]=nw[l];
				break;
			} else
			if (nw[k]>ans[k]) break;
		}
		for (int j=0; j<n; j++) s[j]=ss[j];
	}
	puts(ans);
	return 0;
}

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

int main(){
	int A ,B;
	cin >>A >> B;
	if (A>B && B!=1 || A<B && A==1)
		cout << "Alice";
	else if (B>A && A!=1 ||B<A && B==1)
		cout << "Bob";
	else 
		cout << "Draw";
	return 0;
}

Measured memory_bytes: 256
n, m, x = map(int, input().split())

a = [[0] * m for j in range(n)]
c = [0] * n

ans = 10**10

for i in range(n):
    arr = list(map(int, input().split()))
    c[i] = arr[0]
    a[i] = arr[1:]

# bit全探索
import itertools
for bit in itertools.product([0,1], repeat=n):
    arr = [0] * m
    cost = 0
    for i in range(n):
        if bit[i] == 1:
            for k in range(len(a[i])):
                arr[k] += a[i][k]
            cost += c[i]

    NG = False
    for i in range(len(arr)):
        if arr[i] < x:
            NG = True
            
    if NG:
        pass
    else:
        ans = min(ans,cost)

if ans != 10**10:
    print(ans)
else:
    print(-1)


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

public class Main {
	FastScanner in;
	PrintWriter out;

	void solve() {
		int n = in.nextInt();
		int m = in.nextInt();
		int q = in.nextInt();
		int[] a = new int[q];
		for (int i = 0; i < q; i++) {
			a[i] = in.nextInt() - 1;
		}
		int[] pos = new int[m];
		Arrays.fill(pos, -1);
		int nowPos = 0;
		int[] vals = new int[m];
		int[] num = new int[m + 1];
		num[0] = n;
		for (int i = q - 1; i >= 0; i--) {
			int id = a[i];
			if (pos[id] == -1) {
				vals[nowPos] = id;
				pos[id] = nowPos;
				nowPos++;
			}
			if (num[pos[id]] > 0) {
				num[pos[id]]--;
				num[pos[id] + 1]++;
			}
		}
		for (int i = 0; i < m; i++) {
			if (num[i] !=0) {
				boolean[] all = new boolean[m];
				Arrays.fill(all, true);
				for (int j = 0; j < m; j++) {
					if (pos[j] != -1 && pos[j] < i) {
						all[j] = false;
					}
				}
				int it = 0;
				boolean ok = true;
				for (int j = i; j < nowPos; j++) {
					while (!all[it]) {
						it++;
					}
					if (it != vals[j]) {
						ok = false;
						break;
					}
					it++;
				}
				out.println(ok ? "Yes" : "No");
				return;
			}
		}
		out.println("Yes");
	}

	void run() {
		try {
			in = new FastScanner(new File("object.in"));
			out = new PrintWriter(new File("object.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
				new Main().runIO();
			}
		}, "1", 1 << 26).start();
	}
}

Measured memory_bytes: 24344
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
#include <atcoder/all>
using namespace std; using namespace atcoder;
using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
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; }
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q, T;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vll flag, D; vector<vpll> path; vs S;
int main() {
	ll BIG = 1000000000;
	cin >> N >> K;
	vll A(N, vl(N));
	mcf_graph<ll, ll> G(2 * N + 2);
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			cin >> A[i][j];
			G.add_edge(i, N + j, 1, BIG - A[i][j]);
		}
	}
	ll s = 2 * N, t = 2 * N + 1;
	G.add_edge(s, t, N * K, BIG);
	for (i = 0; i < N; i++) {
		G.add_edge(s, i, K, 0);
		G.add_edge(N + i, t, K, 0);
	}
	auto res = G.flow(s, t, N * K);
	cout << 1LL * N * K * BIG - res.second << endl;
	vs S(N, string(N, '.'));
	auto edges = G.edges();
	for (auto e : edges) {
		if (e.from == s || e.to == t || e.flow == 0) continue;
		S[e.from][e.to - N] = 'X';
	}
	for (i = 0; i < N; i++) {
		co(S[i]);
	}
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAX = 1000 + 10;
char in[MAX][MAX];
int dis[MAX][MAX];

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

int main() {
  int H, W;
  scanf("%d%d", &H, &W);
  for (int i = 0; i < H; i++)
    scanf("%s", in[i + 1] + 1);

  memset(dis, -1, sizeof(dis));

  queue<PII> que;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (in[i][j] == '#') {
        dis[i][j] = 0;
        que.push(MP(i, j));
      }
    }
  }

  while (!que.empty()) {
    PII t = que.front();
    que.pop();
    for (int k = 0; k < 4; k++) {
      int nx = t.F + dx[k];
      int ny = t.S + dy[k];
      if (in[nx][ny] != '.' && in[nx][ny] != '#')
        continue;
      if (dis[nx][ny] == -1) {
        dis[nx][ny] = dis[t.F][t.S] + 1;
        que.push(MP(nx, ny));
      }
    }
  }

  int ans = 0;
  for (int i = 1; i <= H; i++)
    for (int j = 1; j <= W; j++)
      ans = max(ans, dis[i][j]);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 13456
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
int n;
int k,a[maxn],b[maxn];
ll ans,res;
int main(){
    read(n),read(k);
    for (int i=1;i<=n;i++){
        read(a[i]),read(b[i]);
        if ((a[i]&k)==a[i]) ans+=b[i];
    }
    for (int i=0;i<=30;i++){
        int mask=1<<i;
        if (k&mask){
            int tmp=(k^mask)|(mask-1);
            res=0;
            for (int j=1;j<=n;j++){
                if ((a[j]&tmp)==a[j]) res+=b[j];
            }
            ans=max(ans,res);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x,n;
	cin>>x>>n;
	set<int> s;
	for(int i = 0;i<n;i++)
	{
		int a;
		cin>>a;
		s.insert(a);
	}
	int i = 0;
	while(1)
	{
		if((x-i) >= 0)
		{
			if(!s.count(x-i))
			{
				cout<<(x-i);
				break;
			}
		}
		if((x+i) <= 101)
		{
			if(!s.count(x+i))
			{
				cout<<(x+i);
				break;
			}
		}
		i++;
	}
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
using namespace std;

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

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

typedef pair<int, int> P;


bool isValid(vector<vector<int>> &isHonest) {
    for (int col = 0; col < isHonest.size(); col++) {
        bool findOne = false, findZero = false;
        for (int row = 0; row < isHonest.size(); row++) {
            if (isHonest[row][col] == 1)  {
                if (findZero) {
                    return false;
                }
                findOne = true;
            } else if (isHonest[row][col] == 0) {
                if (findOne) {
                    return false;
                }
                findZero = true;
            }
        }
    }
    return true;
}

int main() {
    int N;
    cin >> N;
    vector<P> A[N];
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        for (int j = 0; j < a; j++) {
            int x, y;
            cin >> x >> y;
            x--;
            A[i].emplace_back(P(x, y));
        }
    }

    int res = 0;
    for (int i = 0; i < (1 << N); i++) {
        vector<vector<int>> isHonest(N, vector<int>(N, -1));
        vector<int> temp(N, -1);

        for (int j = 0; j < N; j++) {
            if ((i >> j) & 1) {
                temp[j] = 1;
                isHonest[j][j] = 1;
                for (int k = 0; k < A[j].size(); k++) {
                    P p = A[j][k];
                    isHonest[j][p.first] = p.second;
                }
            } else {
                isHonest[j][j] = 0;
                temp[j] = 0;
            }
        }

        int cnt = 0;
        if (isValid(isHonest)) {
            for (int j = 0; j < N; j++) {
                if (temp[j]) cnt++;
            }
        }

        res = max(res, cnt);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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

const ll mod = 1e9+7;





int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll>a(n);
    vector<ll>one(60),zero(60);
    rep(i,n){
        cin >> a[i];
        rep(j,60){
            if(1 & a[i]>>j)one[j]++;
            else zero[j]++;
        }
    }

    ll ans = 0;
    ll res = 1;
    rep(j,60){
        ll mul = one[j]*zero[j]%mod;
        
        ans = (ans + res*mul%mod)%mod;
        res = res*2%mod;
    }

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 5568
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 200000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
vector<int> v[200005];
bool use[200005];
int n,k;
inline void dfs(int x,int nu){
//	cout<<x<<" "<<nu<<endl;
	if(x==k&&nu==2){
		cout<<"POSSIBLE"<<endl;
		exit(0);
	}
	if(nu==2) return;
	if(use[x]) return;
	use[x]=1;
	for(int i=0;i<v[x].size();i++) dfs(v[x][i],nu+1);
	use[x]=0;
}
int main(){
	ios_base::sync_with_stdio(false);
	int i,j,x,y;
	cin>>k>>n;
	k--;
	for(i=0;i<n;i++){
		cin>>x>>y;
		x--,y--;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(0,0);
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}



Measured memory_bytes: 12144
n,d = map(int,input().split())
point = [list(map(int,input().split())) for _ in range(n)]
count = 0
for i in range(n-1):
  for j in range(i+1,n):
    dis = 0
    for k in range(0,d):
      dis += pow(point[i][k]-point[j][k],2)
    dis = dis**0.5
    if int(dis)==dis: count += 1
print(count)

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;

int n, k;

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

  scan(n); scan(k);
  string s;
  scan(s);

  vint a;
  vint cnt;

  vint a0, a1;
  int j=0;
  int a0num=0, a1num=0;
  REP(i, n){
    if(s[i]=='0') a0num++;
    else          a1num++;
    if(i!=n-1 && s[i]=='0' && s[i+1]=='1'){
      a0.pb(a0num);
      a1.pb(a1num);
      j++;
      a0num=0;
      a1num=0;
    }
    if(i==n-1){
      a0.pb(a0num);
      a1.pb(a1num);
      if(s[i-1]=='0'){
        a0.pb(0);
        a1.pb(0);
        j++;
      }
    }
  }
  j=j-k+1;
  vint sum;
  int sumnum=0;
  REP(i, j){
    for(int m=i; m<i+k; m++)  sumnum+=a0[m]+a1[m];
    sumnum+=a1[i+k];
    sum.pb(sumnum);
    sumnum=0;
  }

  int res;
  if(j<=0)  res = n;
  else      res = *max_element( ALL(sum) );
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1228
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Set<Integer> set = new HashSet<>();
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                set.add(i*j);
            }
        }

        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        System.out.println(set.contains(n)?"Yes":"No");
    }
}


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

int main()
{
	int t;
	t = 1;
	while (t--)
	{
		int n;
		cin >> n;

		int v[n + 1][3];

		v[0][0] = v[0][1] = v[0][2] = 0;

		for (int i = 1; i <= n; i++)
			for (int j = 0; j < 3; j++)
				cin >> v[i][j];


		int dp[n + 1][3] ;
		dp[0][0] = dp[0][1] = dp[0][2] = 0;

		for (int i = 1; i <= n; i++)
		{
			dp[i][0] = v[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
			dp[i][1] = v[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
			dp[i][2] = v[i][2] + max(dp[i - 1][0], dp[i - 1][1]);

			//cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << endl;

		}

		cout << max(max(dp[n][0], dp[n][1]), dp[n][2]) << endl;


	}
	return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int N;
  string S;
  cin >> N;
  cin >> S;
  int ans = 0;
  REP(i,S.size()-2) {
    if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
import sys

n = int(sys.stdin.readline().strip())
str_list = []

common_char = set()

for i in range(n):
    line = sys.stdin.readline().strip()
    str_list.append(list(line))

    char_set = set(line)
    if len(common_char) == 0:
        common_char = char_set
    else:
        common_char = common_char.intersection(char_set)

#print(str_list)
#print(common_char)

ans_str_list = []
for c in common_char:
    min_num = 50
    for sl in str_list:
        min_num = min( min_num, sl.count(c) )
    
    for i in range(min_num):
        ans_str_list.append(c)

ans_str_list.sort()
ans = "".join(ans_str_list)

print(ans)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        long [] nValues = new long[n + 1];
        nValues[0] = 2;
        nValues[1] = 1;
        for (int i = 2; i <= n; i++) {
            nValues[i] = nValues[i-1] + nValues[i-2];
        }
        System.out.println(nValues[n]);

    }
}


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

#define loop(i,n) for(int i=1;i<=n;i++)
int dp[2][5002];
int a[5002];
int b[5002];

int main(){
  int A,B;
  cin>>A>>B;
  loop(i,A)cin>>a[i];
  loop(j,B)cin>>b[j];
  int m=0;
  loop(i,A)loop(j,B){
    dp[i&1][j]=dp[i&1^1][j];
    if(a[i]==b[j]){
      dp[i&1][j]=dp[i&1^1][j-1]+1;
    }
    m=max(m,dp[i&1][j]);
  }
  cout<<m<<endl;
  return 0;
}

Measured memory_bytes: 3152
#include<stdio.h>

int N[1000000],n;

int binarySearch(int key){
  int left=0,right=n;
  int mid;
  while(left<right){
    mid=((left+right)/2);
    if(key==N[mid])return 1;
    if(key>N[mid])left=mid+1;
    else if(key<N[mid])right=mid;
}
  return 0;
}

int main(){
  int i,j,k,sum=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&N[i]);
  }
  scanf("%d",&j);
  for(i=0;i<j;i++){
    scanf("%d",&k);
    if(binarySearch(k))sum++;
  }
  printf("%d\n",sum);
  
  return 0;
}



Measured memory_bytes: 2108
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;

map<int, int> mp;

const int mod = 1e9 + 7;

int qpow(int a, int n){
    int res = 1;
    while(n > 0){
        if(n & 1)
            res = 1LL * res * a % mod;
        a = 1LL * a * a % mod; 
        n >>= 1;
    }
    return res;
}

void add(int &a, int b){
    a += b;
    if(a >= mod)
        a -= mod;
}

void sub(int &a, int b){
    a -= b;
    if(a < 0)
        a += mod;
}

int k;

int Dp(int n){
    if(mp.count(n))
        return mp[n];
    int res = qpow(k, (n + 1) / 2);
    for(int i = 2;1LL * i * i <= n;i++){
        if(n % i == 0){
            sub(res, Dp(i));
            if(i != n / i){
                sub(res, Dp(n / i));
            }
        }
    }
    sub(res, Dp(1));
    return mp[n] = res;
}

int main(){
    int n;
    cin >> n >> k;
    mp[1] = k;
    int res = 0;
    for(int i = 1;1LL * i * i <= n;i++){
        if(n % i == 0){
            if(i & 1){
                add(res, 1LL * Dp(i) * i % mod);
            }else{
                add(res, 1LL * Dp(i) * i / 2 % mod);
            }
            if(i != n / i){
                if((n / i) & 1){
                    add(res, 1LL * Dp(n / i) * n / i % mod);
                }else{
                    add(res, 1LL * Dp(n / i) * (n / i / 2) % mod);
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}


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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	cin>>n>>m>>k;
	ll b[m];
	rep(i,0,m) cin>>b[i];
	rep(i,0,n)
	{
		ll a[m];
		rep(j,0,m) cin>>a[j];
		rep(j,0,m) cnt+=a[j]*b[j];
		if(cnt+k>0) ans++;
		cnt=0;
	}	
	
	ret(ans)
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long tint;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend() 
#define NACHO ios::sync_with_stdio(0); cin.tie(NULL);

const int INF = 1111122222;
const int MOD = 1e9+7;

int main(){
	int h, a; cin >> h >> a;
	cout << h/a+(h % a != 0) << "\n";
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: Vec<i32> = (0..3).map(|_| read()).collect();

    let mut ans = -1;
    for i in 0..3 {
        for j in 0..3 {
            if i == j { continue; }
            for k in 0..3 {
                if i == k { continue; }
                if j == k { continue; }
                let cost = (a[j] - a[i]).abs() + (a[k] - a[j]).abs();
                if ans < 0 || cost < ans {
                    ans = cost;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}


int main() {
  int x,y;
  cin>>x>>y;
  vector<int>a={1,3,5,7,8,10,12},
  b={4,6,9,11},c={2};
  int X=0,Y=0;
  for(int i=0;i<7;i++){
    if(x==a[i]){X=1;}
    if(y==a[i]){Y=1;}
  }
  for(int i=0;i<4;i++){
    if(x==b[i]){X=2;}
    if(y==b[i]){Y=2;}
  }
    if(x==2){X=3;}
    if(y==2){Y=3;}
  
  if(X==Y){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a[101][101], b[101][101];
    long c[101][101]={{0}};
    int n, m, l, i, j, k;
    
    scanf("%d%d%d", &n, &m, &l);
    
    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }
    
    for(i=0; i<m; i++)
    {
        for(j=0; j<l; j++)
        {
            scanf("%d", &b[i][j]);
        }
    }
    
    for(i=0; i<n; i++)
    {
        for(k=0; k<m; k++)
        {
            for(j=0; j<l; j++)
            {
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    
    for(i=0; i<n; i++)
    {
        for(j=0; j<l; j++)
        {
            printf("%ld", c[i][j]);
            
            if(l-1 == j)
            {
                printf("\n");
            }
            else
            {
                printf(" ");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 772
using System; 
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq; 
using E = System.Linq.Enumerable; 


class Program {
    static void Main(string[] args) {
        
        var NM = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var N = NM[0];
        var M = NM[1];
        
        if(N != 2 && M !=2){
          Console.WriteLine("Yes");
        }else{          Console.WriteLine("No");
       }
        
        
     }
     
}
     
     
                   
public class PriorityQueue<T> : IEnumerable<T> { private readonly List<T> _data = new List<T>(); private readonly IComparer<T> _comparer; private readonly bool _isDescending; public PriorityQueue(IComparer<T> comparer, bool isDescending = true) { _comparer = comparer; _isDescending = isDescending; } public PriorityQueue(Comparison<T> comparison, bool isDescending = true) : this(Comparer<T>.Create(comparison), isDescending) { } public PriorityQueue(bool isDescending = true) : this(Comparer<T>.Default, isDescending) { } public void Enqueue(T item) { _data.Add(item); var childIndex = _data.Count - 1; while (childIndex > 0) { var parentIndex = (childIndex - 1) / 2; if (Compare(_data[childIndex], _data[parentIndex]) >= 0) break; Swap(childIndex, parentIndex); childIndex = parentIndex; } } public T Dequeue() { var lastIndex = _data.Count - 1; var firstItem = _data[0]; _data[0] = _data[lastIndex]; _data.RemoveAt(lastIndex--); var parentIndex = 0; while (true) { var childIndex = parentIndex * 2 + 1; if (childIndex > lastIndex) break; var rightChild = childIndex + 1; if (rightChild <= lastIndex && Compare(_data[rightChild], _data[childIndex]) < 0) childIndex = rightChild; if (Compare(_data[parentIndex], _data[childIndex]) <= 0) break; Swap(parentIndex, childIndex); parentIndex = childIndex; } return firstItem; } public T Peek() { return _data[0]; } private void Swap(int a, int b) { var tmp = _data[a]; _data[a] = _data[b]; _data[b] = tmp; } private int Compare(T a, T b) { return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b); } public int Count => _data.Count; public IEnumerator<T> GetEnumerator() { return _data.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); }


Measured memory_bytes: 13268
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    double a,b,c,d=0,e=0,x=0,y=0,z=0;
    string s;
    cin>>a>>s;
    if(a<3200){cout<<"red";return 0;}
    else{cout<<s;}
    return 0;
}


Measured memory_bytes: 3728
(N, K, Q) = map(int, list(input().split()))

points = []
for x in range(N):
    points.append(K-Q)

for y in range(Q):
    ansed = int(input()) - 1
    points[ansed] += 1

for point in points:
    if point > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 7848
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

using Graph = vector<vector<ll>>;

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

#define MAX_N 2010

const long long INF = 1LL << 60;

//境界値に注意！！！
int main() {
    ll n,k,ans=1;
    cin >> n >> k;
    for (ll i=0;i<n;++i){
        ans=min(2*ans,ans+k);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int a, b; cin >> a >> b;
    int res = 0;
    for(int i = a; i <= b; i++){
        string str = to_string(i);
        if(str[0] == str[4] && str[1] == str[3]) res++;
    }
    cout << res << endl;
    return 0;
}

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

int main() {
  int A,B;
  cin >> A >> B;
  if (A > 8) {
    cout << ":(" << endl;
  }else if(B > 8) {
    cout << ":(" << endl;
  }else {
    cout << "Yay!" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cassert>
#include <ctime>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
using namespace std;

#define N 310000
int n, m, cnt[N][2], zhan[N], in[N], len, s[N];
char S[N];
vector <int> ve[N];

int main() {
	scanf("%d%d", &n, &m);
	scanf("%s", S + 1);
	for (int i = 1; i <= n; i++) {
		s[i] = (S[i] == 'B');
	}
	for (int i = 1; i <= m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		ve[a].push_back(b);
		ve[b].push_back(a);
		cnt[a][s[b]]++;
		if (a != b) {
			cnt[b][s[a]]++;
		}
	}
	for (int i = 1; i <= n; i++)
		if (cnt[i][0] == 0 || cnt[i][1] == 0) {
			in[i] = true;
			zhan[++len] = i;
		}
	for (int i = 1; i <= len; i++) {
		for (int j = 0; j < (int) ve[zhan[i]].size(); j++) {
			cnt[ve[zhan[i]][j]][s[zhan[i]]]--;
			if (!in[ve[zhan[i]][j]] && !cnt[ve[zhan[i]][j]][s[zhan[i]]]) {
				in[ve[zhan[i]][j]] = true;
				zhan[++len] = ve[zhan[i]][j];
			}
		}
	}
	if (len < n) {
		printf("Yes\n");
	}else {
		printf("No\n");
	}
}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
 
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> vec(M);
    for(int i=0; i<N; i++){
        int K;
        cin >> K;
        for(int j=0; j<K; j++){
            int A;
            cin >> A;
            vec.at(A-1) += 1;
        }
    }
    int count=0;
    for(int i=0; i<M; i++){
        if(vec.at(i)==N){
            count++;
        }
    }
    cout << count << endl;
}

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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    int N;
    int W[100];
    int ans = 100000000;

    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> W[i];
    }
    for(int T = 0; T < N - 1; T++) {
        int S1 = 0, S2 = 0;
        for(int i = 0; i <= T; i++) {
            S1 += W[i];
        }
        for(int i = T + 1; i < N; i++) {
            S2 += W[i];
        }
        ans = min(ans, abs(S1 - S2));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int P(int m,int k,int w[],int n);

int main(){
  int n,k,i,j,m,r,l,s=0,b,f;
  int w[100000];

  scanf("%d%d",&n,&k);

  for(i=0;i<n;i++){
    scanf("%d",&w[i]);
    s=w[i]+s;
  }

  l=0;
  r=s;
  while(r-l>1){
    m=(l+r)/2;
    f=P(m,k,w,n);
    if(f>=n)r=m;
    else l=m;
  }

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

  return 0;
}

int P(int m,int k,int w[],int n){
  int i=0,j;
  for(j=0;j<k;j++){
    int s=0;
    while(s+w[i]<=m){
      s=w[i]+s;
      i++;
      if(i==n) return n;
    }
  }
  return i;
}
    

  



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

using namespace std;

int main(int argc, char *argv[]) {
    int n;
    cin >> n;
    
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        char c1 = s1[i];
        char c2 = s2[i];
        char c3 = s3[i];

        if (c1 == c2 && c2 == c3 && c3 == c1) {
            ans += 0;
        } else if (c1 != c2 && c2 != c3 && c3 != c1) {
            ans += 2;
        } else if (c1 == c2 || c2 == c3 || c3 == c1) {
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
const int M=1000001;
vector<int>a[M];
bool vis[M];
int gcd(int a,int b){return a?gcd(b%a,a):b;}

main()
{
    cin>>N;
    for(int i=2;i<M;++i)for(int j=i;j<M;j+=i)a[j].push_back(i);
    int g=0;
    bool ok=true;
    for(int i=0;i<N;++i){
        int A;cin>>A;
        g=gcd(g,A);
        for(int j:a[A]){
            ok&=!vis[j];
            vis[j]=true;
        }
    }
    cout<<(ok?"pairwise coprime":g==1?"setwise coprime":"not coprime")<<endl;
}

Measured memory_bytes: 114976
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int cup[ ] = { 1, 0, 0 };
  char a, b;
  int i;

  while ( scanf ( " %c,%c", &a, &b ) == 2 )
  {
    int tmp = cup[ a - 'A' ];
    cup[ a - 'A' ] = cup[ b - 'A' ];
    cup[ b - 'A' ] = tmp;
  }

  for ( i = 0; !cup[ i ]; ++i );
  printf ( "%c\n", i + 'A' );

  return ( 0 );
}

Measured memory_bytes: 0
using System;


namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
            double x,y;
            String s = Console.ReadLine();
            double r = double.Parse(s);

            x = 2 * 3.141592653589 * r;
            y = 3.141592653589 * r * r;

            Console.WriteLine(y.ToString("F6") + " " + x.ToString("F6"));
        }
    }
}

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

string tolower(string a) {
  rep(i,a.size()) {
    if ('A' <= a[i] && a[i] <= 'Z') {
      a[i] = a[i] - 'A' + 'a';
    }
  }

  return a;
}

int main() {
  string W, T;
  cin >> W;
  cin >> T;

  int c=0;
  W = tolower(W);
  while(T != "END_OF_TEXT") {
    if (W == tolower(T)) ++c;
    cin >> T;
  }
  cout << c << endl;

  return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(int i =a ;i <= b;i++)
using namespace std;
 
int main(int argc, char const *argv[])
{
	//ifstream cin("input.txt");
	cout.sync_with_stdio(false);
	cin.tie(0);
	int n;
	string s;
	unordered_map <string,int> count;
	cin>>n;
	count["WA"] = 0;
	count["AC"] = 0;
	count["TLE"] = 0;
	count["RE"] = 0;
	rep(i, 0, n-1)
	{
		cin>>s;
		count[s] ++;
	}
 
	cout<<"AC x "<<count["AC"]<<"\n";
	cout<<"WA x "<<count["WA"]<<"\n";
	cout<<"TLE x "<<count["TLE"]<<"\n";
	cout<<"RE x "<<count["RE"]<<"\n";
		
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int n;
int w[110];
set<string> a;
set<string>::iterator it;
set<char> b,c;
string s;
int main() {
	cin>>n;
	char ch;
	cin>>s;
	a.insert(s);
	ch = s[s.size()-1];
	for(int i=2;i<=n;i++) {
		cin>>s;
		it = a.find(s);
		if(it!=a.end() || ch!=s[0]) {
			cout<<"No";
			return 0; 
		}
		a.insert(s);
		ch = s[s.size()-1];
	}
	cout<<"Yes";
	return 0;
} 

Measured memory_bytes: 256
N=int(input())
A=[]
B=[]
for i in range(N):
    a,b=map(int, input().split())
    A.append(a+b)
    B.append(a-b)
x=max(A)-min(A)
y=max(B)-min(B)
ans=max(x,y)
print(ans)


Measured memory_bytes: 24944
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    ll n;
    cin>>n;
    int cnt=0;
    n--;
    deque<char> q;
    while(n>=0){
        q.push_front((char)'a'+(n%26));
        n/=26;
        n--;
    }
    while(!q.empty()){
        cout<<q.front();
        q.pop_front();
    }
    cout<<endl;
}


Measured memory_bytes: 3632
import itertools
import math
import sys
input = sys.stdin.readline
abcde = [int(input()) for _ in range(5)]

min_time = 2**24
for perm in itertools.permutations(abcde):
  time = 0
  for x in perm[0:-1]:
    time = math.ceil((time + x) / 10) * 10
  time += perm[-1]
  min_time = min(time, min_time)

print(min_time)


Measured memory_bytes: 3444
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True


def main():
    a = I()

    print(a + a ** 2 + a ** 3)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68120