akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<iomanip>
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<string> vs;
Def inf = sizeof(Def) == sizeof(ll) ? 2e18 : 1e9+10;
// top front right left back bottom
void S(vi &in){
	int tmp=in[1];
	in[1]=in[0];
	in[0]=in[4];
	in[4]=in[5];
	in[5]=tmp;
}

void E(vi &in){
	int tmp=in[2];
	in[2]=in[0];
	in[0]=in[3];
	in[3]=in[5];
	in[5]=tmp;
}

void T(vi &in){
	int tmp=in[1];
	in[1]=in[2];
	in[2]=in[4];
	in[4]=in[3];
	in[3]=tmp;
}
signed main(){
	int n;
	int ri[6][6]={
		{0,3,5,2,4,0},
		{4,0,1,6,0,3},
		{2,6,0,0,1,5},
		{5,1,0,0,6,2},
		{3,0,6,1,0,4},
		{0,4,2,5,3,0}
	};
	while(cin>>n,n){
		vvi he(200,vi(200));
		vvi nu(200,vi(200,-1));
		while(n--){
			int top,front;
			cin>>top>>front;
			top--;front--;
			int right=ri[top][front]-1;
// top front right left back bottom
			vi in={top,front,right,5-right,5-front,5-top};
			int x=100,y=100;
			while(1){
				int ma=-1,to=-1;
				loop(i,1,5){
					if(in[i]>=3){
						bool h=false;
						if(i==1&&he[x+1][y]<he[x][y])h=true;
						if(i==2&&he[x][y+1]<he[x][y])h=true;
						if(i==3&&he[x][y-1]<he[x][y])h=true;
						if(i==4&&he[x-1][y]<he[x][y])h=true;
						
						if(h&&ma<in[i]){
							ma=in[i];
							to=i;
						}
					}
				}
				if(to==1)S(in),x++;
				if(to==2)E(in),y++;
				if(to==3)E(in),E(in),E(in),y--;
				if(to==4)S(in),S(in),S(in),x--;
				if(to==-1)break;
			}
			he[x][y]++;
			nu[x][y]=in[0];
		}
		vi co(6);
		rep(i,200)rep(j,200)if(nu[i][j]+1)
			co[nu[i][j]]++;
		rep(i,6)cout<<co[i]<<" \n"[i==5];
	}
}








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

void solve () {
    int n;
    cin >> n;
    vector<long double> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort (a.begin(), a.end());
    long double ans = a[0];
    for (int i = 1; i < n; i++) {
        ans = (ans + a[i]) / 2;
    }
    cout << ans;
}

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


Measured memory_bytes: 3860
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define all(collection) (collection).begin(), (collection).end()
#define loop(i, times) for(int i = 0; i < times; i++)
#define seloop(i, start_index, end_index) for(int i = start_index; i < end_index; i++)
#define eqseloop(i, start_index, end_index) for(int i = start_index; i <= end_index; i++)

struct Shop
{
	long price_;
	long n_;
	bool operator < (const Shop& s) const
	{
		return (price_ < s.price_);
	}
};

struct BuySum
{
	long num_;
	long price_;
	BuySum()
	{
		num_ = price_ = 0;
	}
};

class Abc121C
{
public:
	void Run(void)
	{
		long n; cin >> n;
		long m; cin >> m;

		shop_collection_.resize(n);
		loop(i, n)
		{
			cin >> shop_collection_[i].price_;
			cin >> shop_collection_[i].n_;
		}

		sort(shop_collection_.begin(), shop_collection_.end());

		BuySum sum;
		for (const auto & elm_shop : shop_collection_)
			Buy(sum, elm_shop, m);

		cout << sum.price_;
	}
	void Buy(BuySum& sum, const Shop& shop, const long m)
	{
		loop(i, shop.n_)
		{
			if (sum.num_ == m)
				return;
			sum.price_ += shop.price_;
			sum.num_++;
		}
	}
private:
	vector<Shop> shop_collection_;
};


int main()
{
	Abc121C abc121c;
	abc121c.Run();
	return 0;
}

Measured memory_bytes: 1792
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

best = 0
for n in range(N):
    c = sum(A1[0:n+1]) + sum(A2[n:N])
    if c > best:
        best = c
print(best)


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


int main(){
    string s, t;
    cin >> s >> t;
    int n = s.size();

    bool flag = false;

    rep(i,n){
        if(s == t){
            cout << "Yes\n";
            return 0;
        }
        s = s.back() + s.substr(0, n-1);
    }
    cout << "No\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>

using namespace std;

#define ll long long
#define MAX 200000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

int a[MAX + 5];

bool ok(int mid, int n, int k) {
    int i, temp;
    for (i = 0; i < n; ++i) {
        temp = (a[i] + mid - 1) / mid - 1;
        k -= temp;
    }
    return k >= 0;
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    int n, k, i;
    int l, h, mid;
    l = 1, h = 0;
    cin >> n >> k;
    for (i = 0; i < n; ++i) {
        cin >> a[i];
        h = max(h, a[i]);
    }
    while (l <= h) {
        mid = (l + h) >> 1;
        if (ok(mid, n, k)) {
            h = mid - 1;
        } else {
            l = mid + 1;
        }
    }
    cout << l;

    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define all(c) begin(c),end(c)
const ll INF = ll(1e16);
const ll mod = ll(1e9 + 7);

const int MAX_E = 2000;
const int MAX_V = 1000;

struct edge { int from, to; ll cost; };

edge es[MAX_E];

ll d[MAX_V];
int V, E;



//s番目の頂点から各頂点への最短距離
void bellman_ford(int s) {
	d[s] = 0;
	int cnt = 0;
	while (cnt<V) {
		bool update = false;
		for (int i = 0; i < E; i++) {
			edge e = es[i];
			if (d[e.from] != INF&&d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		cnt++;
		if (!update)break;
	}
}

int main() {
	cin >> V >> E;
	rep(i, E) {
		int a, b, c;
		cin>>a>>b>>c;
		es[i].from = --a; es[i].to = --b; es[i].cost = -c;
	}

	for (int i = 0; i < V; i++)d[i] = INF;
	bellman_ford(0);
	ll mem = -d[V - 1];
	bellman_ford(0);
	if (mem < -d[V - 1])cout << "inf" << endl;
	else cout << -d[V - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <functional>
using namespace std;
vector<long long> yen(3, 0);


int main() {
	long long a, b, c;
	cin >> yen[0] >> yen[1] >> yen[2];
	sort(yen.begin(), yen.end());
	cout << yen[0] + yen[1];
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var pqr = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(Math.Min(Math.Min(pqr[0] + pqr[1], pqr[0] + pqr[2]), pqr[1] + pqr[2]));
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n-h+1)*(n-w+1) << endl;
    return 0;
}

Measured memory_bytes: 768
from math import *
g = gcd(*map(int,input().split()))
D = {}
n = 2

while n*n<=g:
  if g%n:
    n+=1
  else:
    g//=n
    D[n]=D.get(n,0)+1

if 1<g:
  D[g]=D.get(g,0)+1

print(len(D)+1)

Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

struct Node {
	Node() {
		// empty constructor
		min = 1e9, max = -1;
		sorted = true;
	}
	
	Node(int v) {
		// init
		min = max = v;
		sorted = true;
	}
	
	Node(Node l, Node r) {
		// merge
		min = std::min(l.min, r.min);
		max = std::max(l.max, r.max);
		sorted = l.sorted && r.sorted && l.max <= r.min;
	}

	// atributes
	int min, max;
	bool sorted;
};

template <class i_t, class e_t>
class SegmentTree {
public:
	void init(std::vector<e_t> base) {
		n = base.size();
		tree.resize(2 * n);
		for(int i = 0; i < n; i++) {
			tree[i + n] = i_t(base[i]);
		}
		for(int i = n - 1; i > 0; i--) {
			tree[i] = i_t(tree[i + i], tree[i + i + 1]);
		}
	}
	
	i_t qry(int l, int r) {
		i_t lp, rp;
		for(l += n, r += n; l < r; l /= 2, r /= 2) {
			if(l & 1) lp = i_t(lp, tree[l++]);
			if(r & 1) rp = i_t(tree[--r], rp);
		}
		return i_t(lp, rp);
	}
	
	void upd(int pos, e_t v) {
		pos += n;
		tree[pos] = i_t(v);
		for(pos /= 2; pos > 0; pos /= 2) {
			tree[pos] = i_t(tree[pos + pos], tree[pos + pos + 1]);
		}
	}
	
private:
	int n;
	std::vector<i_t> tree;
};


int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n, k;
	std::cin >> n >> k;
	std::vector<int> a(n);
	for(int i = 0; i < n; i++) {
		std::cin >> a[i];
	}
	long long ans = 0;
	SegmentTree<Node, int> tree;
	tree.init(a);
	ans++;
	bool zero = tree.qry(0, k).sorted;
	for(int i = k; i < n; i++) {
		auto node = tree.qry(i-k+1, i+1);
		auto prv = tree.qry(i-k, i);
		if(node.sorted) {
			if(!zero) {
				zero = true;
				ans++;
			}
		} else if(prv.min != a[i-k] || node.max != a[i]) {
			ans++;
		}
	}
	std::cout << ans << '\n';
}

Measured memory_bytes: 6528
#include <iostream>
using namespace std;
int main()
{
	int d;
	while(cin >> d){
		int sum = 0;
		for(int i=1; i*d<600; i++){
			sum+= (i*d)*(i*d)*d;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 0
Imports System.Text
Imports System.String
Imports System
Imports System.Math

Module Module1

    Sub Main()
        Dim ans As String = ""

        Dim getvaluelength As Integer


        Dim mojiretu As String = Console.ReadLine()

        Dim hen As Decimal = CType(mojiretu, Decimal) / 3





        Console.WriteLine("{0}", hen ^ 3)
        Console.ReadKey()
    End Sub




End Module

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && b != c){
  	cout << "Yes" << endl;
  }
  else if(b == c && c != a){
  	cout << "Yes" << endl;
  }
  else if(c == a && a != b){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        if((x<-100 || 100<x) || (y<-100 || 100<y)){
            System.exit(-1);
        }else if((w<=0 || 100<w) || (h<=0 || 100<h) || (r<=0 || 100<r)){
            System.exit(-1);
        }else if(w<2*r && h<2*r){
            System.out.println("No");
        }else if((r<=x && x<=w-r) && (r<=y && y<=h-r)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 26396
#include <bits/stdc++.h>
#define speed                                                                  \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define oprecision cout.precision(30);
#define ii int
#define ss string
#define ll long long
#define cc char
#define ff float
#define dd double
#define bb bool
#define forn(sz) for (int i = 1; i <= sz; i++)
#define forni(sz, i) for (int i = 1; i <= sz; i++)
#define pb push_back
using namespace std;
ii sz, arr[1000], n, n1;
ii main() {
  speed;
  oprecision;
  /*#ifndef ONLINE_JUDGE
    freopen("outd.txt", "rt", stdin);
  #endif*/
  // code
  cin >> sz;
  forn(sz) {
    cin >> arr[i];
    if (arr[i] != i && n == 0)
      n = i;
    else if (arr[i] != i && n1 == 0)
      n1 = i;
    else if (arr[i] != i && n1 != 0 && n != 0) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  // endl
#ifndef ONLINE_JUDGE
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N,X=map(int, input().split())
A = list(map(int, input().split()))

ans = abs(A[0]-X)
for i in range(1,N):
    tmp = abs(A[i]-X)
    ans = math.gcd(ans,tmp)

print(ans)

Measured memory_bytes: 91056
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;

const ll mod = 1000000007;
const int N = 81;
const int M = 2e6+6;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
const int S = 6400;
int n, m;
int a[N][N];
bitset<N*N*2> dp[N][N];
int main() {
	scanf("%d%d",&n,&m);
	rep(i, 1, n + 1) rep(j, 1, m + 1) scanf("%d",&a[i][j]);
	rep(i, 1, n + 1) rep(j, 1, m + 1) {
		int x; scanf("%d", &x);
		a[i][j] = abs(a[i][j] - x);
	}
	dp[1][1][S+a[1][1]] = dp[1][1][S-a[1][1]] = 1;
	rep(i, 1, n + 1) rep(j, 1, m + 1) {
		if(i==1&&j==1) continue;
		if(i!=1) dp[i][j] |= ((dp[i-1][j] << a[i][j]) | (dp[i-1][j] >> a[i][j]));
		if(j!=1) dp[i][j] |= ((dp[i][j-1] << a[i][j]) | (dp[i][j-1] >> a[i][j]));
	}
	int ret = 1e9;
	rep(i, 0, 2*S) if(dp[n][m][i]) ret = min(ret, abs(i-S));
	printf("%d\n", ret);
    return 0;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll M1,D1,M2,D2;
  cin>>M1>>D1>>M2>>D2;
  if(D2==1) cout<<1<<endl;
  else cout<<0<<endl;
}

Measured memory_bytes: 3596
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#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++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

struct edge{int to; int cost;};
vector<vector<edge>> graph(0);
vector<int> d(0);
const int MAX_dist=1e9;

void init(int n){
    graph.resize(n);
    d.resize(n,MAX_dist);
}

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>> que;
    d[s]=0;
    que.emplace(0,s);
    while(!que.empty()){
        P p=que.top();
        que.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        rep(i,graph[v].size()){
            edge e=graph[v][i];
            if(d[e.to]>d[v]+e.cost){
            d[e.to]=d[v]+e.cost;
            que.emplace(d[e.to],e.to);
            }
        }
    }
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;cin>>n;
    init(n);
    int k,v;
    rep(i,n){
        cin>>k;cin>>k;
        rep(j,k){
            cin>>v;
            graph[i].push_back({v-1,1});
        }
    }
    dijkstra(0);
    rep(i,n){
        cout<<i+1<<" ";
        if(d[i]==MAX_dist) cout<<-1;
        else cout<<d[i];
        cout<<'\n';
    }
}


Measured memory_bytes: 3148
#include <stdio.h>

int main(void){
    int month, date, cnt = 0;
    int i_10 = 2, i_1 = 2;
    scanf("%d %d",&month, &date);

    for(int i = 1; i < month+1; i++){
        for( i_10 = 2; i_10 < 10; i_10++){
            for(i_1 = 2; i_1 < 10; i_1++){
                if((i_10*10 + i_1) <= date){
                    if(i_10 * i_1 == i){
                        cnt++;
                    }
                }
            }
        }
    }

    printf("%d", cnt);
    return 0;
}

Measured memory_bytes: 128
import numpy as np

H, W = map(int, input().split())
temp = [list(input().replace("#","0").replace(".","1")) for i in range(H)]
masu = [[int(temp[i][j]) for j in range(W)] for i in range(H)]

dp = np.zeros((H, W))
if masu[0][0] == 0:
    dp[0][0] = 1

for i in range(0,H):
    for j in range(0,W):
        if i == 0:
            a = 100000
        else:
            if masu[i][j] == 0 and masu[i-1][j] == 1:
                a = dp[i-1][j] + 1
            else:
                a = dp[i-1][j]
        if j == 0:
            b = 100000
        else:
            if masu[i][j] == 0 and masu[i][j-1] == 1:
                b = dp[i][j-1] + 1
            else:
                b = dp[i][j-1]
        if a != 100000 or b != 100000:
            dp[i][j] = min([a, b])
print(int(dp[H-1][W-1]))


Measured memory_bytes: 12664
#include <stdio.h>

long CntDay(int y,int m,int d);

int main(){
 int n,i,Year,Month,Day;
 scanf("%d\n",&n);
 i=1;
 while(i<=n){
  scanf("%d %d %d",&Year,&Month,&Day);
  printf("%ld\n", CntDay(Year,Month,Day));
  i++;
 }
 return 0;
}

long CntDay(int y,int m,int d){
long n,yea,mon,day;
if(y%3==0){
yea=(999-y)/3*590;
} else if(y%3==1){
yea=(999-y)/3*590+395;
} else {
yea=(999-y)/3*590+200;
}
if(y%3==0){
mon=(10-m)*20;
} else {
mon=(10-m)*19+(10-m)/2;
}
if ((y%3==0)||(m%2==1)){
day=1+(20-d);
} else {
day=1+(19-d);
}

n=yea+mon+day;
return n;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v) for (auto&& V : v)
#define all(x) (x).begin(), (x).end()
using lint = long long;
const int INF = 1 << 29;
const double EPS = 1e-9;
using namespace std;

vector<int> eratosthenes(int minimum, int maximum) {
  vector<bool> is_prime(maximum + 1, true);
  vector<int> prime_num;
  is_prime[0] = false;
  is_prime[1] = false;
  for (int i = 2; i <= maximum; ++i) {
    if (is_prime[i]) {
      prime_num.push_back(i);
      for (int check = i * 2; check <= maximum; check += i) is_prime[check] = false;
    }
  }
  prime_num.erase(prime_num.begin(), lower_bound(prime_num.begin(), prime_num.end(), minimum));
  return prime_num;
}

int main(void) {
  int n;
  cin >> n;
  vector<int> primes = eratosthenes(1, 55555);
  vector<int> ans;
  allrep(prime, primes) {
    if (prime % 5 == 1) {
      ans.push_back(prime);
      if (ans.size() == n) break;
    }
  }
  rep(i, n) {
    cout << (i != 0 ? " " : "") << ans[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
# import sys
# input = sys.stdin.readline

def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

n = int(input())
a = lmp()
ans = 0
for i in range(n):
    if i %2 == 0 and a[i] % 2 == 1:
        ans += 1
print(ans)




Measured memory_bytes: 61748
#include <stdio.h>
void buildMaxHeap(void);
void maxHeapify(int );
int left(int );
int right(int );
int heap_size;
int A[500005];
int main() {
    int i;
    scanf("%d",&heap_size);
    for(i=1;i<=heap_size;i++) {
        scanf("%d",&A[i]);
    }
    buildMaxHeap();
    for(i=1;i<=heap_size;i++) {
        printf(" %d",A[i]);
    }
    printf("\n");
    return 0;
}
 
int left(int i) { return 2*i; }
int right(int i) { return 2*i+1; }
 
void buildMaxHeap(void) {
    int i;
    for(i= heap_size/2;i>=1;i--) {
        maxHeapify(i);
    }
}
 
void maxHeapify(int i) {
    int l,r,temp,largest=0;
    l = left(i);
    r = right(i);
    if( l <= heap_size && A[l] > A[i] ) largest = l;
    else largest = i;
    if( r <= heap_size && A[r] > A[largest] ) largest = r;
    if(largest != i) {
        temp = A[i];
        A[i] = A[largest];
        A[largest] = temp;
        maxHeapify(largest);
    }
}

Measured memory_bytes: 2552
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define pie 3.14159265358979323846
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int mod =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
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;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
bool greater_pair(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first!=b.first){
        return a.first>b.first;
    }else{
        return a.second>b.second;
    }
}

int main() {
    ios::sync_with_stdio(false);
    ll N,K;
    cin>>N>>K;
    vector<ll> rui(N+1);
    rui[0]=0;
    REP1(i,N){
        cin>>rui[i];
        rui[i]=rui[i]+rui[i-1];
    }  
    ll ans=0;
    REP(i,N-K+1){
        ans=max(ans,rui[i+K]-rui[i]);
    }
    Sp((double)(ans+K)/2);
    return 0;
}

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

int main(){
    int A,B,K;
    cin>>A>>B>>K;
    if(((B-A)/2)>=K){
        for(int i=0;i<K;i++){
            cout<<A+i<<endl;
        }
        for(int i=0;i<K;i++){
            cout<<B-K+1+i<<endl;
        }
    }else{
        for(int i=A;i<=B;i++){
            cout<<i<<endl;
        }
    }
    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

const int MOD = int(1e9) + 7;

int c[4001][4001], e[4001][4001];
int a, b;

void init() {
    forn(i, 4001) c[0][i] = 0;
    c[0][0] = 1;
    for (int i = 1; i < 4001; ++i) {
        c[i][0] = 1;
        for (int j = 1; j < 4001; ++j) {
            c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
            if (c[i][j] >= MOD) {
                c[i][j] -= MOD;
            }
        }
    }
    forn(i, 4001) {
        e[i][0] = c[i][0];
        for (int j = 1; j < 4001; ++j) {
            e[i][j] = e[i][j - 1] + c[i][j];
            if (e[i][j] >= MOD) {
                e[i][j] -= MOD;
            }
        }
    }
}

int d[2001][2001];

inline void modAdd(int &x, int y) {
    x += y;
    if (x >= MOD) {
        x -= MOD;
    }
}

int main() {
//    freopen("input.txt", "r", stdin);
    init();
    cin >> a >> b;
    int ans = 1;
    forn(i, a) {
        a -= i;
        for (int bc = 0; bc <= b; ++bc) {
            int ac = b - bc;
            if (ac > a) continue;
            int cnt = c[b - 1][bc - 1];
            if (ac == a || bc == b) {
                modAdd(ans, cnt);
                continue;
            }
            modAdd(d[a - ac][b - bc], cnt);
        }
        a += i;
    }
    for (int i = a; i >= 0; --i) for (int j = b; j >= 0; --j) if (d[i][j]) {
        if (i == 0 || j == 0) {
            modAdd(ans, d[i][j]);
            continue;
        }
        modAdd(d[i - 1][j], d[i][j]);
        ans = (ans + (LL)d[i][j] * e[j - 1][min(i, j - 1)]) % MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 140928
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  305
double dp[N][N][N];
ll n,x;
double m,A,B,C,D;
ll a[4];
double dps(ll a,ll b,ll c)
{
    // cout<<a<<" "<<b<<" "<<c<<endl;
    if(a<0||b<0||c<0)
        return 0;
    if(a==0&&b==0&&c==0)
        return 0;
    ll sum=a+b+c;
    if(dp[a][b][c]>=0)
        return dp[a][b][c];
    D=n+(a)*(dps(a-1,b,c))+(b)*(dps(a+1,b-1,c))+(c)*(dps(a,b+1,c-1));
    dp[a][b][c]=D/sum;
    return dp[a][b][c];
}
void solve()
{
    cin>>n;
    m=n;
    rep(i,0,n)
    {
        cin>>x;
        a[x]++;
    }
    // memset(dp,-1,sizeof(dp));
    rep(i,0,N)
    {
        rep(j,0,N)
        {
            rep(k,0,N)
            dp[i][j][k]=-1;
        }
    }
    cout<<setprecision(12)<<dps(a[1],a[2],a[3]);
    // cout<<setprecision(12)<<<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

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

#define MAXN 405


long long as [MAXN];
long long acum [MAXN];
long long dp [MAXN][MAXN];
long long suma(int i, int j){
    if (i==0){
        return acum[j];
    }
    return acum[j]-acum[i-1];
}

long long calc(int i, int f){
    

    if (i==f){
        return dp[i][f]=0;
    }
    if(dp[i][f]!=0){
        return dp[i][f];
    }
    long long maxi = calc(i+1,f);
    for(int j = i+1; j<f; j++){
        maxi = min(maxi, calc(i,j)+calc(j+1,f));
    }
    return dp[i][f] = maxi+suma(i,f);
}

int main(){
    int n;
    cin>>n;
    cin>>as[0];
    acum[0]=as[0];
    for(int i=1; i<n; i++){
        cin>>as[i];
        acum[i] = acum[i-1]+as[i];
    }
    memset(dp, 0, sizeof(dp));
    cout<<calc(0,n-1);
}


Measured memory_bytes: 1536
# coding: utf-8
n = gets().to_i
a = gets.split(' ').map do |e|
  e.to_i
end
b = gets.split(' ').map do |e|
  e.to_i
end

ans = 0
b.each_with_index do |e, i|
  # 左から全力で倒す
  left = [a[i], b[i]].min
  ans += left
  a[i] -= left
  b[i] -= left

  # 残った戦力で右を全力で倒す
  right = [a[i + 1], b[i]].min
  ans += right
  a[i + 1] -= right
end
puts ans



Measured memory_bytes: 19364
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.NoSuchElementException;

public class Main {
	int N,K,L;
	int[] P,Q,R,S;
	int[] uf1,uf2;

	public void init(){
		uf1 = new int[N];
		uf2 = new int[N];
		for(int i = 0;i < N;i++){
			uf1[i] = i;
			uf2[i] = i;
		}
	}

	public void unite1(int x,int y){

		x = root1(x);
		y = root1(y);

		if(x < y){
			uf1[y] = x;
		}else{
			uf1[x] = y;
		}
	}

	public int root1(int x){
		if(uf1[x] == x)return x;
		return uf1[x] = root1(uf1[x]);
	}


	public boolean same1(int x,int y){
		return root1(x) == root1(y);
	}

	public void unite2(int x,int y){

		x = root2(x);
		y = root2(y);

		if(x < y){
			uf2[y] = x;
		}else{
			uf2[x] = y;
		}
	}

	public int root2(int x){
		if(uf2[x] == x)return x;
		return uf2[x] = root2(uf2[x]);
	}


	public boolean same2(int x,int y){
		return root2(x) == root2(y);
	}


	public void solve() {
		N = nextInt();
		K = nextInt();
		L = nextInt();

		P = new int[K];
		Q = new int[K];
		R = new int[L];
		S = new int[L];

		init();

		for(int i = 0;i < K;i++){
			P[i] = nextInt() - 1;
			Q[i] = nextInt() - 1;

			unite1(P[i],Q[i]);
		}

		for(int i = 0;i < L;i++){
			R[i] = nextInt() - 1;
			S[i] = nextInt() - 1;

			unite2(R[i],S[i]);
		}

		HashMap<Long,Integer> map = new HashMap<Long,Integer>();

		for(int i = 0;i < N;i++){
			long key = root1(i) * (long)1e9 + root2(i);
			map.put(key, map.containsKey(key) ? map.get(key) + 1 : 1);
		}

		for(int i = 0;i < N;i++){
			if(i != 0)out.print(" ");
			long key = root1(i) * (long)1e9 + root2(i);

			out.print(map.get(key));
		}

		out.println();

	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), c = sc.nextInt(), k = sc.nextInt();
        int[] T = new int[n];
        for(int i = 0; i < n; i++) T[i] = Integer.parseInt(sc.next());
        Arrays.sort(T);

        int res = 1;
        int min = T[0];
        int cnt = 1;
        for(int i = 1; i < n; i++) {
            cnt++;
            if(cnt > c || T[i] - min > k) {
                cnt = 1;
                res++;
                min = T[i];
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 48980
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

int main() {
	lint K;
	cin >> K;
	lint ans = 0;
	for (lint i = 1; i <= K; i++) {
		for (lint j = 1; j <= K; j++) {
			for (lint k = 1; k <= K; k++) {
				ans += gcd(gcd(i, j), k);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3600
<?php 
fscanf(STDIN, '%d' , $a );
fscanf(STDIN, '%s' , $b );
$num = str_split($b);
$result = 0;
for($i = 0;$i<=$a-3;$i++ ) {
   if($num[$i] == 'A' && $num[$i + 1] == 'B' && $num[$i + 2] == 'C') {
       $result++;
  }
}

echo $result;
?>

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  int dp[n+1][m+1];
  for(int i = 0; i<=n;i++){
    for(int j = 0; j<=m;j++){
      if(i==0 || j==0){
	dp[i][j] = 0;
      }else{
	if(s[i-1]==t[j-1]){
	  dp[i][j] = dp[i-1][j-1]+1;
	}else{
	  dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
	}
      }
    }
  }
  int dx = n, dy=m;
  string ans = "";
  while(dx>0 && dy>0){
    if(s[dx-1]==t[dy-1]){
      ans.push_back(s[dx-1]);
      dx--;
      dy--;
    }else{
      if(dp[dx-1][dy]>dp[dx][dy-1]){
	dx--;
      }else{
	dy--;
      }
    }
  }
  reverse(ans.begin(),ans.end());
  cout<< ans<<'\n';
  return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF 1000000000000000007
typedef long long Int;
typedef pair<Int,Int> P;

Int gcd(Int x, Int y){
	if(y == 0){
		return x;
	}
	return gcd(y, x%y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(Int x){
	bool b = 0;
	if(x == 1) b = 1;
	for(Int i = 2; i * i <= x; i++){
		if(x % i == 0) {b = 1; break;}
	}
	return b;
}

Int n, x, a[100002];

int main(){
	cin >> n >> x;
	Int ans = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(i != 0){
			if(a[i] + a[i-1] > x){
				ans += a[i] + a[i-1] - x;
				a[i] = x - a[i-1];
			}
		}
		else if(a[i] > x){
			ans += a[i] - x;
			a[i] = x;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <list>
#include <cstdlib>

#include <iomanip>


int h, w, sty, stx, goy, gox;

std::vector<std::string> s;
std::vector<std::vector<int>> values;
int value = 0;
constexpr int dx[4] = { 1, -1, 0, 0 };
constexpr int dy[4] = { 0, 0, 1, -1 };
int x, y;
std::list<std::pair<int, int>> next;
std::list<std::pair<int, int>> cur;


void dfs(int vx, int vy)
{
	for (int i = 0; i < 4; i++) {
		x = vx + dx[i];
		y = vy + dy[i];
		if (x < 0 || x >= w || y < 0 || y >= h) {
			continue;
		}
		if (values[y][x] == value) continue;
		if (values[y][x] > value) {
			next.remove({ x, y });
		}
		if (s[y][x] == '#') {
			for (int i = vy - 2; i <= vy + 2; i++) {
				for (int j = vx - 2; j <= vx + 2; j++) {
					if (j < 0 || j >= w || i < 0 || i >= h) {
						continue;
					}
					if (std::abs(i) + std::abs(j) < 2) {
						continue;
					}
					if (s[i][j] == '.' && values[i][j] == -1) {
						values[i][j] = value + 1;
						next.push_back({ j, i });
					}
				}
			}
			continue;
		}
		values[y][x] = value;
		dfs(x, y);
	}
}


int main()
{
	std::cin >> h >> w >> sty >> stx >> goy >> gox;
	stx--; sty--; gox--; goy--;
	s.resize(h);
	for (auto &t : s) {
		std::cin >> t;
	}
	
	values.assign(h, std::vector<int>(w, -1));
	values[sty][stx] = 0;
	cur.push_back({ stx, sty });
	while (!cur.empty()) {
		for (auto [curx, cury] : cur) {
			dfs(curx, cury);
		}
		std::swap(cur, next);
		next.clear();
		value++;
	}
	
	std::cout << values[goy][gox] << std::endl;
	
	return 0;
}


Measured memory_bytes: 8696
#include<cstdio>
#include<algorithm>

using namespace std;

typedef long long ll;

ll h, w;

ll solve(){
	ll res = 1LL << 61, s[3];
	for(int k = 0; k < 2; k++){
		for(int i = 1; i < h; i++){
			s[0] = i * w; s[1] = (h - i) / 2 * w; s[2] = (h - i - (h - i) / 2) * w;
			sort(s, s + 3); res = min(res, s[2] - s[0]);
			s[0] = i * w; s[1] = (h - i) * (w / 2); s[2] = (h - i) * (w - w / 2);
			sort(s, s + 3); res = min(res, s[2] - s[0]);
		}
		swap(h, w);
	}
	return res;
}

int main(){
	scanf("%lld %lld", &h, &w);
	printf("%lld\n", solve());
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2154;
int n,ans,k,pri[10010];
bool mark[10010];
ll a[100010],b[100010];
map<ll,int> mp;
void pre()
{
	for (int i=2;i<=N;i++)
	{
		if (!mark[i])
		{
			pri[k++]=i;
		}
		for (int j=0;j<k;j++)
		{
			int m=i*pri[j];
			if (m>N)
			{
				break;
			}
			mark[m]=true;
			if (i%pri[j]==0)
			{
				break;
			}
		}
	}
}
int main()
{
	pre();
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	{
		ll x;
		scanf("%lld",&x);
		a[i]=b[i]=1;
		for (int j=0;j<k;j++)
		{
			if (x%pri[j])
			{
				continue;
			}
			int cnt=0;
			while (x%pri[j]==0)
			{
				x/=pri[j];
				cnt++;
			}
			cnt%=3;
			if (cnt)
			{
				for (int h=0;h<cnt;h++)
				{
					a[i]*=pri[j];
				}
				for (int h=cnt;h<3;h++)
				{
					b[i]*=pri[j];
				}
			}
			if (pri[j+1]>=x)
			{
				break;
			}
		}
		a[i]*=x;
		ll y=sqrt(x);
		if (y*y==x)
		{
			b[i]*=y;
		}
		else
		{
			b[i]*=x*x;
		}
		mp[a[i]]++;
	}
	if (mp.count(1))
	{
		mp[1]=1;
	}
	for (int i=0;i<n;i++)
	{
		ans+=max(mp[a[i]],mp[b[i]]);
		mp[a[i]]=mp[b[i]]=0;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14336
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<string> a(n,""), b(m,"");
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    for(int i = 0; i < n - m + 1; i++){
        for(int j = 0; j < n - m + 1; j++){
            bool match = true;
            for(int ii = 0; ii < m; ii++){
                for(int jj = 0; jj < m; jj++){
                    if(a[i + ii][j + jj] != b[ii][jj]){
                        match = false;
                    }
                }
            }
            if (match){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int m,a,b;
bool so[100001];
vector <long long> prime;

int main() {
  so[0] = so[1] = 1;
  for(int i=2;i*i<100000;i++) 
    if(so[i] == 0)for(int j=2;j<=100000/i;j++) so[i*j] = 1;
  for(int i=0;i<100000;i++) if(so[i]==0) prime.push_back(i);

  while(1) {

    cin >> m >> a >> b;
    if(m==0 && a==0 && b==0) break;

    int w = 1,h = 1;
    long long maxm=-1;
    for(int i=0;i<prime.size();i++) { // p
      if(prime[i]*prime[i] > m ) break; 
      for(int j=i;j<prime.size();j++){ // q
	if(prime[j] > m)break;
	if(prime[i]*prime[j] > m) continue;
	double pq = (double)prime[i]/prime[j];
	if(1.0*a/b<= pq && pq <= 1 && maxm < prime[i]*prime[j])
	  w = prime[i],h = prime[j],maxm = prime[i]*prime[j];
      }
    }
    cout << w <<" "<<h <<endl;

  }
  return 0;
}

Measured memory_bytes: 1440
#include <iostream>


using namespace std;


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

	if(N <= 2){
		cout << 2 << '\n';
		return 0;
	}

	if(N % 2 == 0)	cout << N << '\n';
	else		cout << 2*N << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
#define inf             1e18
#define mod             1000000007
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}void _p() {cout << "]\n";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=========================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r;








void sol()
{   
    cin>>n>>m;
    
    
    
    cout<< n*(n-1)/2 + m*(m-1)/2 <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 256
// atcoder/abc151/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

  int n, m;
  while (cin >> n >> m) {
    map<int, int> wa;
    set<int> ac;
    for (int i = 0; i < m; ++i) {
      int x;
      string s;
      cin >> x >> s;
      if (s == "WA" && !ac.count(x)) ++wa[x];
      if (s == "AC") ac.insert(x);
    }
    int sum = 0;
    each (i, ac) {
      sum += wa[i];
    }
    cout << ac.size() << ' ' << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
using llong = long long;

pair<llong, llong> island[100005];

int main() {
    llong n, m;
    llong ans = 1;
    llong l, r;

    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> island[i].first >> island[i].second;
    }
    sort(island, island + m);
    l = 0;
    r = n;
    for (int i = 0; i < m; i++) {
        if (r <= island[i].first || l >= island[i].second) {
            ans++;
            l = island[i].first;
            r = island[i].second;
        }
        else {
            l = max(l, island[i].first);
            r = min(r, island[i].second);
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5140
import sys
import math
import itertools

input = sys.stdin.readline


def main():
    n, d = [int(i) for i in input().split()]
    ps = [[int(i) for i in input().split()] for _ in range(n)]
    cnt = 0
    for i, x in itertools.combinations(range(n), 2):
        hige = math.sqrt(sum([(ps[i][j] - ps[x][j]) ** 2 for j in range(d)]))
        if hige % 1 == 0:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
#define ll long long
//#define local

using namespace std;

const int MOD = 1e9+7;
const int inf = 0x3f3f3f3f;
const int maxn = 5005;

int main() {
#ifdef local
    if(freopen("/Users/Andrew/Desktop/data.txt", "r", stdin) == NULL) printf("can't open this file!\n");
#endif
    int a, b;
    scanf("%d%d", &a, &b);
    bool flag = 1;
    for (int i = 1; i <= 3; ++i) {
        if ((a*b*i) % 2 == 1) 
            flag = 0;
    }
    if (flag == 0) printf("Yes\n");
    else printf("No\n");
#ifdef local
    fclose(stdin);
#endif
    return 0;
}


Measured memory_bytes: 128