akhauriyash/Code-Regression huggingface dataset:
/*
Dont BLUNDER
*/

// #pragma GCC optimize("O3")
// //#pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;


 */
//#define d long double
#define int long long
#define pii pair<int,int>
#define pb push_back
#define endl '\n'
#define pi acos(-1)

#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod1 = 998244353;
int const mod = 1000000007;
#define bitcount(x)       __builtin_popcountll(x)
#define l first
#define r second
const int inf = LLONG_MAX;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// * Using PBDS *
/*typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
               os; */



int modexp(int x, int n) {
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
	}
	else {
		return (modexp((x * x) % mod, n / 2) % mod);
	}
}

int modinv(int n)
{
	return modexp(n, mod - 2);
}

int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}
bool comp(pair<int, pii> a, pair<int, pii> b) {
	if (a.first == b.first) {
		return a.second.first < b.second.first;
	}
	return a.first < b.first;

}
int spf[1000001];
void ini() {
	for (int i = 2; i <= 1000000; i++) {
		if (spf[i] != i)
			continue;
		for (int j = i; j <= 1000000; j += i) {
			spf[j] = min(spf[j], i);
		}
	}

}



signed main()
{
	haha
// #ifndef ONLINE_JUDGE

// 	freopen("inp.txt", "r", stdin);

// 	freopen("out1.txt", "w", stdout);
// #endif
	map<int, int> m;
	for (int i = 1; i <= 1000000; i++)
		spf[i] = i;
	ini();
	int n;
	cin >> n;
	int arr[n];
	int f = 0;

	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		int x = arr[i];
		while (x != 1) {
			if (f == 1)
				break;
			int y = spf[x];
			//cout << y << endl;

			if (m.find(y) != m.end())
			{
				f = 1;
				break;
			}
			while (x % y == 0)
				x /= y;
			m[y]++;
			//x /= y;

		}

	}
	if (f == 0) {
		cout << "pairwise coprime";
	}
	else {
		int z = arr[0];
		for (int i = 1; i < n; i++) {
			z = gcd(z, arr[i]);

		}
		if (z == 1)
			cout << "setwise coprime";
		else
			cout << "not coprime";

	}
















}

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

using namespace std;

int len;
long ans;
char s[10];

void dfs(long sum, long cnt, int k);

int main(void){
    cin >> s;
    len=strlen(s);
    dfs(0,0,0);
    printf("%ld\n",ans);
    return 0;
}

void dfs(long sum, long cnt, int k){
	if(k==len){
		ans+=sum+cnt;
		return;
	}
    // +を挿入した場合
	if(cnt!=0)
        dfs(sum+cnt,s[k]-'0',k+1);
    // +を挿入しない場合
	dfs(sum,cnt*10+s[k]-'0',k+1);
}


Measured memory_bytes: 3764
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int a[5];
int n1=0,n2=0;
cin>>a[1]>>a[2]>>a[3];
for(int i=1;i<=3;i++)
{
	if(a[i]==5)
	n1++;
	if(a[i]==7)
	n2++;
}
if(n1==2&&n2==1)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}


Measured memory_bytes: 256
// 2011/07/15 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
	string ans[10000];

	for(int i=0; i<10000; i++)
		if((i+1)%15==0)
			ans[i] = "FizzBuzz";
		else if((i+1)%3==0)
			ans[i] = "Fizz";
		else if((i+1)%5==0)
			ans[i] = "Buzz";
		else{
			ostringstream ost;
			ost << i+1;
			ans[i] = ost.str();
		}

	while(true){
		int m, n;
		cin >> m >> n;
		if(m==0&&n==0)
			break;

		int ply[1000];
		for(int i=0; i<m; i++)
			ply[i] = i+1;

		int p = 0;
		for(int i=0; i<n; i++){
			string s;
			cin >> s;

			if(m==1)
				continue;

			if(s==ans[i])
				p = (p+1)%m;
			else{
				for(int j=p; j<m-1; j++)
					ply[j] = ply[j+1];
				m--;
				if(p==m)
					p = 0;
			}
		}

		for(int i=0; i<m; i++){
			cout << ply[i];
			if(i==m-1)
				cout << endl;
			else
				cout << ' ';
		}
	}

	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

struct edge{ll to, cost;};

vector<ll> Djikstra(ll n, vector<vector<edge>> G, ll start){
    //小さい順に取り出す
    priority_queue<pll, vector<pll>, greater<pll>> que;

    vector<ll> min_dist(n+1);
    fill(ALL(min_dist), LINF); 

    min_dist[start] = 0;
    //firstは距離、secondは頂点番号
    que.push(make_pair(0, start));

    while(!que.empty()){
        pll top = que.top();
        que.pop();

        ll v = top.second;

        //既により短い経路があるのなら更新しない
        if(min_dist[v] < top.first)continue;

        rep(i, G[v].size()){
            edge e = G[v][i];
            //最短慶経路を更新できる場合、更新し格納
            if(min_dist[e.to] > min_dist[v] + e.cost){
                min_dist[e.to] = min_dist[v] + e.cost;
                que.push(make_pair(min_dist[e.to], e.to));
            }
        }
    }

    return min_dist;
}

int main(){
    ll v, e, r;
    cin >> v >> e >> r;

    vector<vector<edge>> g(v);

    rep(i, e){
        ll s, t, c;
        cin >> s >> t >> c;

        g[s].push_back(edge({t, c}));
    }

    vector<ll> ans = Djikstra(v, g, r);

    rep(i, v){
        if(ans[i] >= INF)cout << "INF\n";
        else cout << ans[i] << endl;
    }
}


Measured memory_bytes: 30824
n = int(input())
tests = []
for i in range(n):
    a = int(input())
    xys = [ list(map(int, input().split())) for j in range(a) ]
    tests.append(xys)

patterns = []
def dfs(N, li):
    if len(li) == N:
        patterns.append(li)
        return
    for i in range(2):
        new = li[::]
        new.append(i)
        dfs(N, new)
dfs(n, [])
ans = 0
for pattern in patterns:
    contradict = False
    for i in range(len(pattern)):
        if pattern[i] == 0:
            continue
        test = tests[i]
        for xy in test:
            x = xy[0]-1
            y = xy[1]
            if pattern[x] != y:
                contradict = True
                break
        if contradict:
            break
    if contradict:
        continue
    ans = max(ans, sum(pattern))
print(ans)

Measured memory_bytes: 12532
import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Main {
	static int time = 0;

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_6_A-in9.txt"));

		int n = scan.nextInt();

		int[][] v = new int[n + 1][n];
		int[] d = new int[n + 1];

		for (int i = 0; i < n; i++) {
			int u = scan.nextInt();
			int k = scan.nextInt();
			d[u] = -1;
			for (int j = 0; j < k; j++)
				v[u][j] = scan.nextInt();
		}

		d[1] = 0;
		list = new int[n + 1];
		list[0] = 1;

		Bsearch(v, d);

		for (int i = 1; i <= n; i++) {
			System.out.println(i + " " + d[i]);
		}

		scan.close();
		System.exit(0);
	}

	static int[] list;
	static int pp = 0, pn = 1;

	private static void Bsearch(int[][] v, int[] d) {
		for (; pp < pn; pp++) {
			int fr = list[pp];
			for (int i = 0; i < v[fr].length; i++) {
				int to = v[fr][i];
				if (d[to] == -1) {
					d[to] = d[fr] + 1;
					list[pn++] = to;
				}
			}
		}
	}

}



Measured memory_bytes: 28432
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	cin >> K;
	vector<int>v(K);
	for (auto &i : v)cin >> i;
	vector<int>box;
	vector<int>used(M + 1, 0);
	int num = 0;
	reverse(v.begin(), v.end());
	for (auto i : v) {
		if (used[i])continue;
		used[i] = 1;
		box.push_back(i);
	}
	//reverse(box.begin(), box.end());
	num = box.back();
	bool st = true;
	//for (auto i : box)cout << i << endl;
	for (int i = 0; i < box.size(); i++) {
		if (box[i] != i + 1)st = false;
	}

	reverse(v.begin(), v.end());
	if (st) {
		cout << "Yes\n";
		return 0;
	}
	vector<set<int>>place(M + 1);
	for (int i = 0; i < v.size(); i++) {
		place[v[i]].insert(-i);
	}
	place[box.back()].insert(box.size() - 1);
	for (int i = (int)box.size() - 2; i >= 0; i--) {
		if (box[i] < box[i + 1]) {
			place[box[i]].insert(i);
		}
		else break;
	}
	for (int i = 0; i < N; i++) {
		int p = -MOD;
		for (auto j : box) {
			//cout << i << " " << j << " " << p << endl;
			auto it = place[j].lower_bound(p);
			if (it == place[j].end()) {
				cout << "No\n";
				return 0;
			}
			p = *it;
			if (*it <= 0)place[j].erase(it);
		}
	}
	cout << "Yes\n";
}

Measured memory_bytes: 15480
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long ksm(long long u,long long v){
	long long o=1;
	while(v){
		if(v&1)
			o=o*u%mo;
		u=u*u%mo;
		v>>=1;
	}
	return o;
}
int n,k,i,sum;
bool a[200005],flag;
char s[200005];
int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
   	n=read();k=read();
   	scanf("%s",s);
   	for(i=0;i<n;i++)
   		if(s[i]=='A')
   			a[i]=0;
   		else
   			a[i]=1;
   	while(k--){
		if((a[sum]^flag)==0)
			a[sum]^=1;
		else{
			sum++;
			flag^=1;
			sum=(sum>=n?sum-n:sum);
		}
	}
	for(i=sum;i<n;i++)
		if((a[i]^flag)==0)
			putchar('A');
		else
			putchar('B');
	for(i=0;i<sum;i++)
		if((a[i]^flag)==0)
			putchar('A');
		else
			putchar('B');
	cout<<endl;
    return 0;
}

Measured memory_bytes: 768
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] arr = new long[n];
		long total = 0;
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			total += arr[i];
		}
		long a = 0;
		long min = Long.MAX_VALUE;
		for (int i = 0; i < n - 1; i++) {
			a += arr[i];
			min = Math.min(min, Math.abs(total - 2 * a));
		}
		System.out.println(min);
		
	}
}


Measured memory_bytes: 82264
N = int(input())
a = list(map(int, input().split()))

p1, p2, p4 = (0, 0, 0)
for ai in a:
	if ai % 4 == 0:
		p4 += 1
	elif ai % 2 == 0:
		p2 += 1
	else:
		p1 += 1
		
ans = 'Yes'
if p4 + 1 < p1 or (p4 + 1 == p1 and p2 != 0):
	ans = 'No'

print(ans)

Measured memory_bytes: 14252
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<map>

using namespace std;

bool odd[100001] = { 0, };
vector<int> graph[100001];
bool visited[100001] = { 0, };
map<pair<int, int>, int> list;
map<pair<int, int>, int>::iterator it, ret;

bool dfs(int cur, int parent)
{
	bool phase, rval;
	int i;
	int next;

	phase = odd[cur];

	for (i = 0; i < graph[cur].size(); i++)
	{
		next = graph[cur][i];

		if (visited[next])
		{
			continue;
		}

		if (next == parent)
		{
			continue;
		}

		visited[next] = true;

		rval = dfs(next, cur);

		phase = phase && !rval || !phase&&rval;
	}

	if (phase && parent)
	{
		ret = list.find(make_pair(cur, parent));

		if (ret == list.end())
		{
			ret = list.find(make_pair(parent, cur));

			ret->second = !ret->second;
		}

		else
		{
			ret->second = !ret->second;
		}
	}

	return phase;
}

int main()
{
	int n, m;
	int i, j;
	int u, v;
	bool tot = false;

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

	for (i = 0; i < m; i++)
	{
		scanf("%d %d", &u, &v);

		odd[u] = !odd[u];

		list[make_pair(u, v)] = 0;

		graph[u].push_back(v);
		graph[v].push_back(u);
	}

	for (i = 1; i <= n; i++)
	{
		tot = tot && !odd[i] || !tot&&odd[i];
	}

	if (tot)
	{
		printf("-1\n");

		return 0;
	}

	visited[1] = true;

	dfs(1, 0);

	for (it = list.begin(); it != list.end(); it++)
	{
		if (!it->second)
		{
			printf("%d %d\n", it->first.first, it->first.second);
		}

		else
		{
			printf("%d %d\n", it->first.second, it->first.first);
		}
	}

	return 0;
}

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

int main(){
	
	int a, b, c, d, e, f;
	double x, y;
	
	while(~scanf("%d %d %d %d %d %d\n", &a, &b, &c, &d, &e, &f)){
		y = (double)(a*f-c*d)/(double)(a*e-b*d);
		x = ((double)c-(double)b*y)/(double)a;
		
		printf("%.3f %.3f\n",x,y);
	}
	
	return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import sys


def solve(N: int, A):
    d = [[0] * N for i in range(2)]
    d[1][N-1] = A[1][N-1]
    d[0][N-1] = A[0][N-1] + d[1][N-1]
    for i in range(2, N+1):
        d[1][N-i] = d[1][N-i+1] + A[1][N-i]
        d[0][N-i] = A[0][N-i] + max(d[1][N-i], d[0][N-i+1])
    print(d[0][0])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [[int(next(tokens)) for _ in range(N)] for _ in range(2)]
    solve(N, A)

if __name__ == '__main__':
    main()


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

int main(){
	int h,w;
	cin>>h>>w;
	vector<vector<int> > a(h,vector<int>(w,0) );
	int res = 1e9;
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)cin>>a[i][j];
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
		{
			int s = 0;
			for(int k=0;k<h;k++)
				for(int l=0;l<w;l++) s+= a[k][l] * min(abs(i-k),abs(j-l) );
		      	res = min(res,s); 	
		}
	cout<<res<<endl;

}



Measured memory_bytes: 3160
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define int long long
bool ac[100010];
signed main(){
    int N, M;
    cin >> N >> M;
    int p[M];string S[M];

    int wrong = 0;
    int wcnt[N +1] = {0};

    for(int i = 0; i < M;i++){
        cin >> p[i] >> S[i];
        if(S[i] == "AC" && ac[p[i]] == false){wrong += wcnt[p[i]];ac[p[i]] = true;}
        else if(S[i] == "WA" && ac[p[i]] == false){wcnt[p[i]]++;}
    }
    int ans = 0;
    for(int i = 1;i <= N;i++){
        if(ac[i] == true)ans++;
    }
    
    cout << ans << " " << wrong;
}

Measured memory_bytes: 7424
n,k = map(int, input().split())
x = list(map(int, input().split()))
ans = float("inf")
for i in range(0,n-k+1):
    if (x[i]<=0 and x[i+k-1]<=0):
        ans = min(ans, -x[i])
    elif (x[i]>=0 and x[i+k-1]>=0):
        ans = min(ans, x[i+k-1])
    else:
        ans = min (ans, x[i+k-1]-x[i]+(min(abs(x[i+k-1]),abs(x[i]))))
print(ans)

Measured memory_bytes: 14252
#include <iostream>
using namespace std;
char a[2001][2001];
int n, m;
int main() {
	for(int i=0;i<=2000;i++){
		for(int j=0;j<=2000;j++){
			a[i][j]='#';
		}
	}
	cin >> n >> m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin >> a[i][j];
		}
	}
	for(int i=0;i<=n+1;i++){
		for(int j=0;j<=m+1;j++){
			cout << a[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define f(a, n) for (int a=0; a<n; a++)
#define F(a, n) for (int a=1; a<=n; a++)
using namespace std;
typedef long long LL;

long long A[100005], sum, cnt, n;
int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(0);
	cin>>n;
	f(i, n) cin>>A[i];
	sort(A, A+n);
	f(i, n){
		if (sum*2<A[i]) cnt = i;
		sum+=A[i];
	}
	cout<<n-cnt<<endl;
}


Measured memory_bytes: 1152
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  int n,k;
  cin >> n >> k;
  int now = 1;
  rep(i,0,n){
    now = min( now + now , now + k);
  }

  P(now);
  ret 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int N, a[22][22], memo[22][2222222];


int dfs(int i, int b)
{
  if (i == N) {
    assert(b == 0);
    
    return 1;
  }

  if (memo[i][b] >= 0)
    return memo[i][b];

  int c = 0;

  for (int j = 0; j < N; j ++)
    if (b & (1 << j))
      if (a[i][j])
        (c += dfs(i + 1, b & ~(1 << j))) %= MOD;

  return memo[i][b] = c;
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::cin >> N;

  for (int i = 0; i < N; i ++)
    for (int j = 0; j < N; j ++)
      std::cin >> a[i][j];

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

  std::cout << dfs(0, (1 << N) - 1) << std::endl;

  return 0;
}


Measured memory_bytes: 191360
#include<iostream>
using namespace std;
long long int aa[100000];
int main() {
	int n;
	cin >> n;

	int i;

	for (i = 0; i < n; i++) {
		cin >> aa[i];
	}
	long long int  a, b, c;
	a = 0;
	b = 0;
	c = 0;
	int counta = 0;
	int countb = 0;
	int countc = 0;

		for (i = 0; i < n; i++) {
			if (counta == 0) {
				counta++;
				a = aa[i];
			}
			else {
				if (aa[i] == a) {
					counta++;
				}
				else {
					if (countb == 0) {
						countb++;
						b = aa[i];
					}
					else {
						if (aa[i] == b) {
							countb++;
						}
						else {
							if (countc == 0) {
								countc++;
								c = aa[i];
							}
							else {
								if (aa[i] == c) {
									countc++;
								}
								else {
									cout << "No";
									return 0;
								}
							}
						}
					}
				}
			}
		}
		if ((counta == countb) && (countb == countc)) {
			if (a == (b ^ c)) {
				cout << "Yes";
			}
			else {
				cout << "No";
			}
			return 0;
		}
		else if ((counta == n) && (a == 0)) {
			cout << "Yes";
		}
		else if ((counta == 2 * countb) && (b == 0) && (countc == 0)) {
			cout << "Yes";
		}
		else if ((2 * counta == countb) && (a == 0) && (countc == 0)) {
			cout << "Yes";
		}
		else {
			cout << "No";
			return 0;
		}
	
}

Measured memory_bytes: 1024
#include <stdio.h>
#define N 10000
#define Q 500

int main(){
  int n, q, i, j, count = 0, a[N], b[Q];

  scanf("%d", &n);
  for(i = 0;i < n;i++){
    scanf("%d", &a[i]);
  }
  scanf("%d", &q);
  for(i = 0;i < q;i++){
    scanf("%d", &b[i]);
  }
  for(i = 0;i < q;i++){
    for(j = 0;j < n;j++){
      if(b[i] == a[j]){
	count++;
	break;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
 
using namespace std;
long long n,m;
string st[50+10];
int a[50+10][50+10];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>st[i];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(st[i][j]=='#')
			a[i][j+1]=-1;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]==-1)
			{
				cout<<"#";continue;
			}
			cout<<abs(a[i-1][j-1]+a[i-1][j]+a[i-1][j+1]+a[i][j-1]+a[i][j+1]+a[i+1][j+1]+a[i+1][j]+a[i+1][j-1]);
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
from collections import deque

K = int(input())

d = [-1, 0, 1]

lun = deque([1,2,3,4,5,6,7,8,9])
cnt = 9
while cnt < K:
    a = lun.popleft()
    b = str(a)[-1]
    if b not in ('0', '9'):
        lun.append(int(str(a) + str(int(b) - 1)))
        lun.append(int(str(a) + b))
        lun.append(int(str(a) + str(int(b) + 1)))
        cnt += 3
    elif b == '0':
        lun.append(int(str(a) + b))
        lun.append(int(str(a) + str(int(b) + 1)))
        cnt += 2
    elif b == '9':
        lun.append(int(str(a) + str(int(b) - 1)))
        lun.append(int(str(a) + b))
        cnt += 2

print(lun[K-cnt-1])

Measured memory_bytes: 5944
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long
int ans = 0;
ll N;

int digit(ll N) {
  int res = 0;
  while(N > 0) {
    res++;
    N /= 10;
  }
  return res;
}

bool all_used(int n) {
  bool ret[3];
  ret[0] = ret[1] = ret[2] = false;
  while(n > 0) {
    switch(n%10) {
    case 3:
      ret[0] = true;
      break;
    case 5:
      ret[1] = true;
      break;
    case 7:
      ret[2] = true;
      break;
    }
    n /= 10;
  }
  return ret[0] && ret[1] && ret[2];
}

void work(int tmp, int n) {
  if(tmp <= N) {
    if(all_used(tmp)) {
      ans++;
    }
    if(n <= 0)
      return;
    work(tmp*10+3, n-1);
    work(tmp*10+5, n-1);
    work(tmp*10+7, n-1);
  }
}

int main(){
  cin >> N;
  int d = digit(N);
  work(3, d-1);
  work(5, d-1);
  work(7, d-1);

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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

		int X=sc.nextInt();
		int Y=sc.nextInt();
		int Z=sc.nextInt();
		int K=sc.nextInt();

		List<Long> A=new ArrayList<>();
		List<Long> B=new ArrayList<>();
		List<Long> C=new ArrayList<>();

		for(int i=0;i<X;i++) A.add(sc.nextLong());
		for(int i=0;i<Y;i++) B.add(sc.nextLong());
		for(int i=0;i<Z;i++) C.add(sc.nextLong());


		Collections.sort(A, Collections.reverseOrder());
		Collections.sort(B, Collections.reverseOrder());
		Collections.sort(C, Collections.reverseOrder());

		List<Long> ABC=new ArrayList<>();

		for(int a=0;a<X;a++) {
			for(int b=0;b<Y;b++) {
				if( (a+1)*(b+1)>K) break;
				for(int c=0;c<Z;c++) {
					if( (a+1)*(b+1)*(c+1) >K) break;
					ABC.add(A.get(a)+B.get(b)+C.get(c));
				}
			}
		}

		Collections.sort(ABC, Collections.reverseOrder());

		for(int i=0;i<K;i++) System.out.println(ABC.get(i));

		sc.close();

	}

}


Measured memory_bytes: 34072
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
#define vi vector<ll>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vt vector<tuple<ll, ll, ll>>
using namespace std;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
map<ll, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	string s;
	cin >> s;
	set<char> st;
	REP(i, s.size())
	{
		if(st.count(s[i]))
		{
			cout << "no" << endl;
			return 0;
		}
		else st.insert(s[i]);
	}
	cout << "yes" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner scan =new Scanner(System.in);
        
        
        while(scan.hasNext())
        {
            int n = scan.nextInt();
            int m = scan.nextInt();
            
            //終了条件
            if(n+m==0)
                break;
            
            int[] nFlg = new int[n];
            
            int total = n;
            int tmp=0,i=0;
            
            for(i=0;i<n;i++)
                nFlg[i]=0;
            
            while(total!=1)
            {
                for(i=0;i<m;i++)
                {
                    if(tmp+i>=n)
                    {
                        tmp=i*(-1);
                    }
                    
                    if(nFlg[tmp+i]==1)
                    {
                        i--;
                        tmp++;
                    }

                }
                nFlg[tmp+i-1]=1;
                tmp+=i;
                total--;
            }
            
            for(i=0;i<n;i++)
            {
                if(nFlg[i]==0)
                {
                   i++;
                   System.out.println(i);
                }
            }
        }
    }
}

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

#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0;i<N;i++) cin >> A[i];
    map<int,int> mp;
    int sum = 0;
    for (int i=0;i<N;i++){
        sum += A[i];
        mp[A[i]]++;
    }
    int Q;
    cin >> Q;
    for (int i=0;i<Q;i++){
        int b, c;
        cin >> b >> c;
        int p = mp[b];
        mp[b]-=p;
        mp[c]+=p;
        sum += (c-b)*p;
        cout << sum << "\n";
    }
}

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

int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i = 0 ; i < N ; i++){
    cin >> a[i];
  }
  sort(a,a + N);
  int id = 0;
  double min_diff = 1e9;
  for(int i = 0 ; i < N - 1 ; i++){
    if(min_diff > fabs(((double)a[i] - a[N-1]/2.0))){
      min_diff = fabs(((double)a[i] - a[N-1]/2.0));
      id = i;
    }
  }
  cout << a[N-1] << ' ' << a[id] << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const int day = 60*60*24;

int main() {
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    
    while (1) {
        int n;
        cin >> n;
        if (n == 0) return 0;
        vi a(day+1);
        rep(i, n) {
            int h1, m1, s1, h2, m2, s2;
            scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
            int s = h1*60*60 + m1*60 + s1;
            int e = h2*60*60 + m2*60 + s2;
            a[s]++;
            a[e]--;
        }
        rep(i, day) a[i+1] += a[i];
        cout << *max_element(a.begin(), a.end()) << endl; 
    }
}


Measured memory_bytes: 3464
fun main(args: Array<String>) {
    val (N, Q) = listOfInt()
    val S = next()
    val T = Array(N + 1) { 0 }
    for (n in 0 until S.length) {
        T[n + 1] = T[n] + (if ((n + 1 < N) && S[n] == 'A' && S[n + 1] == 'C') 1 else 0)
    }
    repeat(Q) {
        val (l, r) = listOfInt(-1)
        println(T[r] - T[l])
    }
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }

Measured memory_bytes: 67656
import java.util.Scanner;
import java.util.Arrays;

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

int n=scan.nextInt();
int k=scan.nextInt();
long[] h=new long[n];
 int i=0;
  for(i=0;i<n;i++){
    h[i]=scan.nextLong();
  }
Arrays.sort(h);
long sum=0;
for(i=0;i<n-k;i++){
  sum=sum+h[i];
}

    System.out.println(sum);

}
}


Measured memory_bytes: 89300
from operator import itemgetter
N = int(input())
e = {}
for i in range(N):
    c,p = input().split()
    if c in e.keys():
        e[c].append((int(p),i))
    else:
        e[c] = [(int(p),i)]

for k,v in sorted(e.items()):
    for p,q in sorted(v,key=itemgetter(0),reverse=True):
        print(q+1)


Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//


ll n;
ll ans;
void dfs(ll num) {
    if (n < num) return;
    int cnt7, cnt5, cnt3;
    cnt7 = cnt5 = cnt3 = 0;
    int tmp = num;
    while(tmp > 0) {
        if (tmp % 10 == 7) ++cnt7;
        else if (tmp % 10 == 5) ++ cnt5;
        else ++cnt3;
        tmp /= 10;
    }
    bool ok = true;
    if (cnt7 == 0 || cnt5 == 0 || cnt3 == 0) ok = false;
    if (ok) ++ans;
    num *= 10;
    dfs(num + 7);
    dfs(num + 5);
    dfs(num + 3);
}





int main() {
    cin >> n;
    ans = 0;
    dfs(0);
    out(ans);

    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back

const int P = 1e9+7;

using namespace std;

int n, h, w;
pii p[3030];
int dp[3030], f[202020], inv[101010];

int add(int a, int b){
	a += b;
	if(a>=P) return a-P;
	return a;
}
int sbt(int a, int b){
	a -= b;
	if(a<0) return a+P;
	return a;
}
int mul(int a, int b){
	ll ab = (ll)a*b;
	int c = ab/P;
	ll cP = (ll)c*P;
	return ab-cP;
}

int pow(int a, int b){
	if(b==0) return 1;
	if(b&1) return mul(a, pow(a, b-1));
	return pow(mul(a, a), b/2);
}

int abCb(int a, int b){
	return mul(f[a+b], mul(inv[a], inv[b]));
}

int main(){


	cin >> h >> w >> n;
	for(int i=1; i<=n; i++) cin >> p[i].F >> p[i].S;
	p[n+1] = {h, w};
	sort(p, p+n+2);

	f[0] = 1;
	for(int i=1; i<=h+w; i++) f[i] = mul(f[i-1], i);
	for(int i=0; i<=max(h, w); i++) inv[i] = pow(f[i], P-2);

	dp[0] = 1;

	for(int i=1; i<n+2; i++){
		dp[i] = abCb(p[i].F-1, p[i].S-1);
		for(int j=1; j<i; j++){
			if(p[j].S <= p[i].S){
				int pth = mul(dp[j], abCb(p[i].F-p[j].F, p[i].S-p[j].S));
				dp[i] = sbt(dp[i], pth);
			}
		}
	}

	cout << dp[n+1] << endl;

	return 0;
}


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

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

#include <random>

int main() {
    ll n;
    cin >> n;
    vector<ll> x, y, h;
    for (int i = 0; i < n; ++i) {
        ll xx, yy, hh;
        scanf("%lld%lld%lld", &xx, &yy, &hh);
        x.emplace_back(xx);
        y.emplace_back(yy);
        h.emplace_back(hh);
    }
    for(int i = 0; i < 101; i++) {
        for (int j = 0; j < 101; j++) {
            vector<int> v;
            for (int k = 0; k < n; k++) {
                int dist = abs(i - x[k]) + abs(j - y[k]);
                v.emplace_back(h[k] + dist);
            }
            for (auto &item : v) {
                bool p = true;
                for (int k = 0; k < n; k++) {
                    int dist = abs(i - x[k]) + abs(j - y[k]);
                    if (max(item - dist, 0) != h[k]) p = false;
                }
                if (p) {
                    cout << i << " " << j << " " << item << "\n";
                    return 0;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,p = [int(i) for i in input().split()]
s = input()
ans = 0

if p == 2 or p == 5:
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i + 1
    print(ans)
    exit()

else:
  chk = [0]*p
  chk[0] = 1
  m = 0
  for i in range(n)[::-1]:
    m = (int(s[i])*pow(10,n-1-i,p)+m)%p
    chk[m] += 1
  for i in chk:
    ans += i*(i-1)/2
  print(int(ans))

Measured memory_bytes: 41196
import java.io.*;


public class Main {
	
	
    public static void main(String[] args) {
       
    	try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
          
            String str;
           
            
            while((str = br.readLine()) != null)
            {
            	for(int i = str.length()-1; i>=0; i--)
            	{
            	System.out.print(str.charAt(i));
            	}
            	System.out.println();
            }
    	}catch (Exception e) {
            e.printStackTrace();
        }
       
    }
    
   
}

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

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
//~ #define int long long
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 100005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,mx,vis[li],dp[li];
int cev;
string s;
vector<int> v[li];

inline int dfs(int node){
	int cevv=0;
	vis[node]=1;
	if(~dp[node])return dp[node];
	for(int i=0;i<(int)v[node].size();i++){
		int go=v[node][i];
		cevv=max(cevv,dfs(go)+1);
	}
	return dp[node]=cevv;
}

main(void){
	memset(dp,-1,sizeof(dp));
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		v[x].pb(y);
	}
	FOR{
		if(vis[i]==0)mx=max(mx,dfs(i));
	}
	printf("%d\n",mx);
	return 0;
}


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

using namespace std;

int main(void)
{
    long N;
    char *str;
    string s_str;
    char tmp;
    long result = 0;
    std::unordered_map<std::string, int> mp;

    cin >> N;
    for(int k=0;k<N;k++)
    {
        str = new char[10];
        cin >> str;
        for(int i=1;i<10;i++)
        {
            for(int j=0;j<9;j++)
            {
                if(str[i] < str[j])
                {
                    tmp = str[i];
                    str[i] = str[j];
                    str[j] = tmp;
                }
            }
        }
        s_str = string(str,10);
        delete(str);
        auto itr = mp.find(s_str);
        if(itr == mp.end())
        {
            mp[s_str] = 1;
        }
        else
        {
            result += mp[s_str];
            mp[s_str] = mp[s_str] + 1;
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int ans = (N-M)*100 + M*1900;
    int x = 1;
    while ( M > 0) {
        x *= 2;
        M--;
    }
    cout << ans * x << endl;

    return 0;
}


Measured memory_bytes: 256
# 高橋くんは N種類の料理が食べ放題のビュッフェに行き、全種類の料理 (料理 1, 料理 2, …, 料理 N) を 1度ずつ食べました。
# 高橋くんが i (1≤i≤N) 番目に食べた料理は料理 Ai でした。
# 高橋くんは、料理 i (1≤i≤N) を食べると満足度Bi を得ます。

# また、料理 i(1≤i≤N−1) を食べた直後に料理 i+1 を食べると満足度 Ci を追加で得ます。
# 高橋くんが得た満足度の合計を求めてください。
N=gets.to_i
A= gets.split.map(&:to_i)
B= gets.split.map(&:to_i)
C= gets.split.map(&:to_i)
feel=0
for i in 0..N-1 do
  if ((A[i]+1)==A[i+1]) then
    feel=feel+C[A[i]-1]
  end
  feel=feel+B[A[i]-1]
end
puts (feel)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;

int main(){

    int s;
    cin >> s;

    int count = 1;

    function<int(int)> collatz = [=](int n) -> int{
        if(n % 2 == 0){
            return n / 2;
        }else return n * 3 + 1;
    };

    while(s != 1 && s != 2 && s != 4){
        s = collatz(s);
        count++;
    }

    cout << count + 3 << endl;



    return 0;
}

Measured memory_bytes: 256
open System.Linq.Expressions

/// 境界はIn
type InOut =
    | In
    | OutLeft
    | OutRight

// 最短候補は高々2つなので距離をマッピングしていく
let n, x, y = stdin.ReadLine().Split() |> fun arr -> int arr.[0], (int arr.[1]) - 1, (int arr.[2]) - 1

/// aからの距離マップ(距離、個数) (a < n-1)
let distanceMap (a:int) =

    let inOut a =
        if a < x then
            OutLeft
        elif a > y then
            OutRight
        else 
            In

    let length a b =
        match (inOut a, inOut b) with
        | In, In -> min (b - a) (y - b + a - x + 1)
        | In, OutRight  -> min (b - a) (b - y + a - x + 1)
        | OutLeft, In -> min (b - a) (y - b + x - a + 1)
        | OutLeft, OutRight -> b- y + x - a + 1
        | OutLeft, OutLeft | OutRight, OutRight -> b - a

    [a + 1 .. n - 1]
    |> Seq.map (fun b -> length a b)
    |> Seq.countBy (fun x -> x)

let tmp =
    [0..n-2]
    |> Seq.map distanceMap
    |> Seq.collect (fun x -> x)

let result = Array.zeroCreate<int> n

for (length, count) in tmp do
    result.[length] <- result.[length] + count

result.[1..n-1]
|> Seq.iter (stdout.WriteLine)


Measured memory_bytes: 37116
import math

li=list(map(int,input().split()))
max_=max(li[0],li[1])

a=[0 for i in range(max_+1)]
b=[0 for i in range(max_+1)]

for i in range(2,li[0]+1):
  while(li[0]%i==0 and li[0]!=1):
    li[0]//=i
    a[i]+=1
for i in range(2,li[1]+1):
  while(li[1]%i==0 and li[1]!=1):
    li[1]//=i
    b[i]+=1

result=1
for i in range(1,max_+1):
  max_num=max(a[i],b[i])
  result*=i**max_num
print(result)

Measured memory_bytes: 4760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

int main()
{
  ll N, x; cin >> N >> x;
  vector<ll> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }

  ll ans = 0;
  for (int i = 0; i < N-1; ++i) {
    if (a[i]+a[i+1] > x) {
      ll need = a[i]+a[i+1]-x;

      if (a[i+1] >= need) a[i+1] -= need;
      else a[i+1] = 0;

      ans += need;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    int cnt = 1;
    for (int i = 0; i < n-1; i++) {
        if (s[i] != s[i+1]) {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 9596
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 10;
char buf[maxn], str[maxn * 5][10];
int idx[maxn * 5], k;
bool cmp(int l, int r) {
	return strcmp(str[l], str[r]) < 0;
}
int main() {
	scanf("%s", buf);
	int len = strlen(buf);
	scanf("%d", &k);
	int scnt = 0;
	for (int L = 1; L <= k; ++L) {
		for (int i = 0; i + L <= len; ++i) {
			for (int j = 0; j < L; ++j)
				str[scnt][j] = buf[i + j];
			str[scnt][L] = 0;
			++scnt;
		}
	}
	for (int i = 0; i < scnt; ++i)
		idx[i] = i;
	sort(idx, idx + scnt, cmp);
	int id = 0;
	while (k > 1 && id < scnt) {
		while (id + 1 < scnt && strcmp(str[idx[id]], str[idx[id + 1]]) == 0)
			++id;
		--k;
		++id;
	}
	printf("%s\n", str[idx[id]]);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
vector<long long int>v,v1;
long long int a[2000000], b[2000000];
int main()
{
    IO;
    long long int j, n, m, k=0, l=0, i;
    cin>>n;
    for(i=2; i*i<=n; i++){
        if(n%i==0){
            v.push_back(i);
            if(i!=n/i) v.push_back(n/i);
        }
    }
    v.push_back(n);
    k=n-1;
    for(i=2; i*i<=k; i++){
        if(k%i==0){
            l++;
            if(n/i!=i)l++;
        }
    }
    if(k!=1)l++;
    for(i=0; i<v.size(); i++){
        k=n;
        while(k%v[i]==0)k/=v[i];
        if(k%v[i]==1)l++;
    }
    cout<<l<<endl;
    return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	vector<int>v;
	for (int i = 0; i < n; i++)
	{
		int z;
		scanf("%d", &z);
		v.push_back(z);
	}
	int beg = 0, end = 1000000000;
	for (;;)
	{
		if (beg == end)break;
		int med = (beg + end) / 2;
		ll s = 0;
		for (int i = 0; i < n; i++)s += max(0LL, ((ll)v[i] - (ll)med*(ll)b + (a - b - 1)) / (a - b));
		if (s > med)beg = med + 1;
		else end = med;
	}
	printf("%d\n", beg);
}

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

int main() {
	int N, i, count;
	cin >> N;
	count = 0;

	vector<int> d(N+1);

	for (i = 0; i < N; i++) {
		cin >> d.at(i);
	}
	sort(d.begin(), d.end());
	reverse(d.begin(), d.end());

	for (i = 0; i < N; i++) {
		if (d.at(i) > d.at(i + 1)) {
			count += 1;
		}
	}

	cout << count << endl;

}

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

int main(){
  int count=0;
  string S;
  vector<int>ACGT(20);
  cin>>S;
  rep(i,S.size()){
    if(S[i]=='A' or S[i]=='C' or S[i]=='G' or S[i]=='T'){
      ACGT[i]=1;
    }
  }

  rep(i,S.size()){
    int tmp=0;
      for(int j=i;j<S.size();j++){
        if(ACGT[j]){
        tmp++;
        }
        else break;
      }
      count=max(count,tmp);
  }
  cout<<count;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns, OverloadedStrings #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Int
import Data.Foldable
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import Data.ByteString.Internal (accursedUnutterablePerformIO)
import qualified Data.Set as S
import System.IO.Unsafe
import Debug.Trace

unew :: VUM.Unbox a => Int -> VUM.IOVector a
unew !n = accursedUnutterablePerformIO $ VUM.unsafeNew n

uread :: VUM.Unbox a => Int -> VUM.IOVector a -> a
uread !i !v = accursedUnutterablePerformIO $ VUM.unsafeRead v i

uwrite :: VUM.Unbox a => Int -> a -> VUM.IOVector a -> VUM.IOVector a
uwrite !i !a !v =
  accursedUnutterablePerformIO $ VUM.unsafeWrite v i a >> return v

uthaw :: VUM.Unbox a => VU.Vector a -> VUM.IOVector a
uthaw !v = accursedUnutterablePerformIO $ VU.unsafeThaw v

ufreeze :: VUM.Unbox a => VUM.IOVector a -> VU.Vector a
ufreeze !v = accursedUnutterablePerformIO $ VU.unsafeFreeze v

uset :: VUM.Unbox a => a -> VUM.IOVector a -> VUM.IOVector a
uset !a !v = accursedUnutterablePerformIO $ VUM.set v a >> return v

solve :: B.ByteString -> B.ByteString -> B.ByteString
solve !s !t = walk
 where
  toIndex !i !j = j * succ (B.length s) + i

  ifoldlB' :: (a -> Int -> Char -> a) -> a -> B.ByteString -> a
  ifoldlB' !f !x !bs = snd $ B.foldl'
    ( \(!i, !acc) !ch ->
      let i'   = i + 1
          acc' = f acc i ch
      in  i' `seq` acc' `seq` (i', acc')
    )
    (0, x)
    bs

  dp :: VU.Vector Int16
  dp = ufreeze $ ifoldlB'
    ( \(!dp) !i !si -> ifoldlB'
      ( \(!dp) !j !tj -> uwrite
        (toIndex (i + 1) (j + 1))
        ( if si == tj
          then uread (toIndex i j) dp + 1
          else max (uread (toIndex (i + 1) j) dp) (uread (toIndex i (j + 1)) dp)
        )
        dp
      )
      dp
      t
    )
    (uset 0 (unew $ succ (B.length s) * succ (B.length t)))
    s

  walk =
    fst
      $ B.unfoldrN (fromIntegral $ dp VU.! toIndex (B.length s) (B.length t))
                   (\(x:xs) -> Just $ (,) (B.index s x) xs)
      $ fst
      $ fix
          ( \(!f) (!acc, (!i, !j)) -> if i == 0 || j == 0
            then (acc, (i, j))
            else if s `B.index` (i - 1) == t `B.index` (j - 1)
              then f ((i - 1) : acc, (i - 1, j - 1))
              else if dp VU.! toIndex (i - 1) j < dp VU.! toIndex i (j - 1)
                then f (acc, (i, j - 1))
                else f (acc, (i - 1, j))
          )
          ([], (B.length s, B.length t))

main = do
  s <- B.getLine
  t <- B.getLine
  B.putStrLn $ solve s t


Measured memory_bytes: 19452
#include <bits/stdc++.h> 
using namespace std;
 
int a, b;
 
int gcd(int x, int y) {
    if (x < y) {
        swap(x, y);
    }
    if (x % y == 0) {
        return y;
    }
    return gcd(x % y, y);
}
 
int main() {
    cin >> a >> b;
    cout << gcd(a, b) << endl;
    return 0;
}

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

using namespace std;
#define int int64_t
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define gsort(x) sort((x).begin(), (x).end(), greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

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

   int a, b;
   cin >> a >> b;
   if (a >= b)
   {
      rep(i, a)
      {
         cout << b;
      }
      cout << '\n';
   }
   else
   {
      rep(i, b)
      {
         cout << a;
      }
      cout << '\n';
   }
}

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

int main(){
  int n;
  cin >>n;
  int tf=0,af=0,bf=0,a,b,t;
  for(int i=0;i<n;i++){
    cin >>t>>a>>b;
    if(abs(a+b-t)%2 == 1){
      cout << "No" <<endl;
      return 0;
    }
    if(abs(a-af)+abs(b-bf) > t-tf){
      cout << "No" <<endl;
      return 0;
    }
    af=a;
    bf=b;
    tf=t;
  }
  cout << "Yes" << endl;
}



Measured memory_bytes: 256