akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <cassert>
#include <fstream>
#include <algorithm>
#include <list>
#include <random>
#include <ctime>
#include <cmath>
#include <random>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define mmin(a, b) a = min(a, (b))
#define mmax(a, b) a = max(a, (b))
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ALL(a) a.begin(),a.end()
#define sqr(x) (x) * (x)
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define cint const int &
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;

const double PI = 2 * acos(0.0);


template<class T>
void show(const vector<T> &a) {
    for (T x : a)
        cout << x << " ";
    cout << endl;
}

const ll oo = 1e18;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    vl a(n);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i - 1];
        a[i - 1] = -a[i - 1] + i;
    }
    sort(ALL(a));
    ll ans = oo;
    ll backs = 0;
    ll forws = accumulate(ALL(a), 0LL);
    fori (i, n) {
        forws -= a[i];
        ll b = a[i];
        ll cur = -backs + b * i + forws - b * (n - i - 1);
        mmin(ans, cur);
        backs += a[i];
    }
    cout << ans;
}



Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
int ctoi(char a) {
	return (int)a - '0';
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n;
int a[200000];
int b[200000];
int c[200000];
signed main() {
	cin >> n;
	n++;
	for (int i = 0; i < 200000; i++)
		b[i] = -1;
	int x, y;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (b[a[i]] >= 0) 
			x = b[a[i]], y = i;
		b[a[i]] = i;
	}
	c[0] = 1;
	for (int i = 1; i < 200000; i++)
		c[i] = c[i - 1] * i%Mod;
	int k = y - x + 1;
	int r, t;
	for (int i = 1; i <= n; i++) {
		r = c[n] * mod_pow(c[i], Mod - 2, Mod) % Mod*
			mod_pow(c[n - i], Mod - 2, Mod) % Mod;
		if (n - k >= i - 1)
			t = c[n - k] * mod_pow(c[i - 1], Mod - 2, Mod) % Mod*
			mod_pow(c[n - k - i + 1], Mod - 2, Mod) % Mod;
		else t = 0;
		cout << ((r - t) % Mod + Mod) % Mod << endl;
	}
	getchar(); getchar();
}

Measured memory_bytes: 5248
#include <iostream>

int main()
{
	int n, x;
	while (std::cin >> n >> x) {
		int nSum = 0;
		if (n == 0 && x == 0) {
			break;
		}
		else {
			for (int i = 1;i < n;i++) {
				for (int j = i + 1;j < x - 1;j++) {
					int k = x - j - i;
					if (k > j&&k <= n) {
						nSum += 1;
					}
					else {
						nSum += 0;
					}
				}
			}
		}
		std::cout << nSum << std::endl;
	}
    return 0;
}

Measured memory_bytes: 3084
def main():
    max_score = int(input())
    answer = []
    i = 1
    while i * i + i - 2 * max_score < 0:
        i += 1
    if i * i + i - 2 * max_score == 0:
        answer = [j for j in range(1, i + 1)]
    else:
        while max_score >= 0:
            answer.append(i)
            max_score -= i
            i -= 1
        answer.pop(-1)
        if i + max_score + 1 > 0:
            answer.append(i + max_score + 1)
    for a in answer:
        print(a)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3572
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <utility>
using namespace std;
const int INF=0x3f3f3f3f;
typedef long long LL;
struct edge{
    int to,cap,cost,rev;
    edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
};
const int MAX_V=10010;
int V,dist[MAX_V],prevv[MAX_V],preve[MAX_V];
vector<edge> G[MAX_V];
void add_edge(int from,int to,int cap,int cost){
    G[from].push_back(edge(to,cap,cost,G[to].size()));
    G[to].push_back(edge(from,0,-cost,G[from].size()-1));
}
int min_cost_flow(int s,int t,int f){
    int res=0;
    while(f>0){
        fill(dist,dist+V,INF);
        dist[s]=0;
        bool update=1;
        while(update){
            update=0;
            for(int v=0;v<V;v++){
                if(dist[v]==INF)continue;
                for(int i=0;i<G[v].size();i++){
                    edge &e=G[v][i];
                    if(e.cap>0&&dist[e.to]>dist[v]+e.cost){
                        dist[e.to]=dist[v]+e.cost;
                        prevv[e.to]=v;
                        preve[e.to]=i;
                        update=1;
                    }
                }
            }
        }
        if(dist[t]==INF)return -1;
        int d=f;
        for(int v=t;v!=s;v=prevv[v]){
            d=min(d,G[prevv[v]][preve[v]].cap);
        }f-=d;
        res+=d*dist[t];
        for(int v=t;v!=s;v=prevv[v]){
            edge &e=G[prevv[v]][preve[v]];
            e.cap-=d;
            G[v][e.rev].cap+=d; 
        }
    }return res;
}
void clear(){for(int i=0;i<=V;i++)G[i].clear();}
const int MAX_N=10010;
int M,N,K,w[MAX_N],lst[MAX_N],a[MAX_N];
int solve(){
    for(int i=1;i<=N;i++)scanf("%d",&w[i]);
    for(int i=1;i<=K;i++)scanf("%d",&a[i]);
    int cnt=unique(a+1,a+K+1)-(a+1);
    int res=0;
    memset(lst,0,sizeof(lst));
    V=cnt+1; clear();
    for(int i=1;i<=cnt;i++){
        res+=w[a[i]];
        if(lst[a[i]])add_edge(lst[a[i]],i-1,1,-w[a[i]]);
        lst[a[i]]=i;
    }for(int i=1;i<cnt;i++)add_edge(i,i+1,INF,0);
    printf("%d\n",res+min_cost_flow(1,cnt,M-1));
}
int main(){
    while(~scanf("%d%d%d",&M,&N,&K))solve();
    return 0;
}

Measured memory_bytes: 4036
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>

int main() {
	int m, f, r;
	char rank[5][2] = {"A", "B", "C", "D", "F"};
	int flug;
	while (1) {
		scanf("%d%d%d", &m, &f, &r);
		if (m + f + r == -3)break;
		if (m + f >= 80) flug = 0;
		else if (m + f >= 65) flug = 1;
		else if (m + f >= 50) flug = 2;
		else if (m + f >= 30 && r >= 50) flug = 2;
		else if (m + f >= 30 && r <= 50) flug = 3;
		else flug = 4;
                if(m==-1||f==-1) flug = 4;
		printf("%s\n", rank[flug]);
	}
	return 0;
}

Measured memory_bytes: 2696
#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else
#define DMP(...) ((void)0)
#endif

#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <numeric>
#include <algorithm>
#include <bitset>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	int N;
	cin >> N;

	vector<pair<int, int>> AB(N);
	for (int i = 0; i < N; i++) cin >> AB[i].first >> AB[i].second;

	vector<pair<int, int>> add(N);
	for (int i = 0; i < N; i++) {
		const auto& [a, b] = AB[i];
		add[i] = { a + b, i };
	}
	sort(add.begin(), add.end(), greater<>());

	lint ans = 0;
	for (int i = 0; i < N; i++) {
		const auto& [_, idx] = add[i];
		const auto& [a, b] = AB[idx];
		if (i & 1) ans -= b;
		else ans += a;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 4780
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();

		log(N * N *N);
	}

	private static void log(int str) {
		System.out.println(str);
	}
}



Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(snip_i, n) cin >> a.at(snip_i);
	int ans = 0;
	rep(i, n-1){
		int now = i+1;
		if(now == a.at(i)){
			ans++;
			swap(a.at(i), a.at(i+1));
		}
	}
	if(a.at(n-1) == n) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,s=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            s+=a[i]*a[j];
        }
    }
    cout<<s<<endl;
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define v vector<ll>
#define vv vector<v>
#define MAX 15000001
#define p pair<int,int>
#define speed ios::sync_with_stdio(false); cin.tie(0) ; cout.tie(0)

vector<int> prime(105,1);
int highpow[105];

void preprocess()
{
	for(int i=2;i<105;i++)
	{
		if(prime[i])
		{
			for(int j=2;i*j<105;j++)
			{
				prime[i*j]=0;
			}
		}
	}
}



int main()
{
	int n;
	cin>>n;
	preprocess();
	for(int i=2;i<105;i++)
	{
		if(prime[i])
		{
			int s=0;
			int t=n;
			while(t)
			{
				s+=t/i;
				t/=i;
			}
			highpow[i]=s;
		}
	}
/*	for(int i=2;i<11;i++)
	{
		if(prime[i])
		{
			cout<<i<<" "<<highpow[i]<<endl;
		}
	}*/
	int n4=0,n2=0,n24=0,n14=0,n74=0;
	for(int i=2;i<=n;i++)
	{
		if(highpow[i]>=4)
			n4++;
		if(highpow[i]>=2)
			n2++;
		if(highpow[i]>=24)
			n24++;
		if(highpow[i]>=14)
			n14++;
		if(highpow[i]>=74)
			n74++;
	}
	ll ans=0;
	ans+=((n4*(n4-1))/2)*(n2-2);
	ans+=n24*(n2-1);
	ans+=n14*(n4-1);
	ans+=n74;
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
using namespace std;

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

	int cnt = 0;
	for (int i = 0; i < s.length() / 2; i++) {
		if (s[i] != s[s.length() - i - 1]) {
			cnt++;
		}
	}

	cout << cnt << endl;
}

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

int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;

  // "AC" の登場回数をカウントする
  vector<int> c(N, 0);
  for (int i = 0; i < N; i++) {
    string result = S.substr(i, 2);
    if (result == "AC") {
      c.at(i + 1)++;
    }
  }

  // 累積和にする
  vector<int> s(N + 1, 0);
  for (int i = 0; i < N; i++) {
    s.at(i + 1) = s.at(i) + c.at(i);
  }

  // for (int i = 0; i < N + 1; i++) {
  //   cout << i << " " << s.at(i) << endl;
  // }

  for (int i = 0; i < Q; i++) {
    int left, right;
    cin >> left >> right;
    // cin >> left >> right;
    cout << s.at(right) - s.at(left) << endl;
  }
  return 0;
}

Measured memory_bytes: 4288
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
const int maxN = 3e5+10;
long long int fact[maxN]={0};
long long int power(long long int a,long long int b){
	if(a==1||b==0){
		return 1;
	}
	long long int ans = 1;
	while(b){
		if(b&1){
			ans = (ans%mod)*(a%mod)%mod;
		}
		b/=2;
		a=((a%mod)*(a%mod))%mod;
	}
	return ans;
}
void init(){
	fact[0]=fact[1]=1;
	for(int i=2;i<maxN;i++){
		fact[i]=(fact[i-1]%mod)*(i%mod)%mod;
	}
}
long long int modInverse(long long int n){
	return power(n,mod-2);
}
long long int nCr(long long int n,long long int r){
	return (((fact[n]%mod)*(modInverse(fact[n-r]%mod))%mod)%mod)*(modInverse(fact[r]%mod))%mod;
}
int main(){
	init();
	long long int h,w,a,b;
	cin>>h>>w>>a>>b;
	//let L[k] be the number of ways from (0,0) to (k,b-1)
	//R[k] be the number of ways from (k,b) to (h-1,w-1)
	//ans will be sigma L[k]*R[k]
	
	long long int  ans = 0;
	for(long long int k=0;k<=h-a-1;k++){
		ans += (nCr(k+b-1,b-1))*(nCr(h-1-k+w-b-1,w-b-1))%mod;
		ans%=mod;
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 5920
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.rbegin(),a.rend());
  ll ans = 0;
  rep(i,(n+1)/2) ans += 2*a[i];
  ans-=a[0];
  if(n&1) ans-=a[(n-1)/2];
  cout << ans << endl;
}

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

using ll = long long;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

const ll INF = (ll)1e11;

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int a[2];
    cin >> a[0] >> a[1];
    
    if (a[0] > a[1]) {
        cout << a[0] * 2 - 1 << endl;
    } else if (a[0] < a[1]) {
        cout << a[1] * 2 - 1 << endl;
    } else {
        cout << a[0] * 2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

type SortName [][]int

func (x SortName) Len() int           { return len(x) }
func (x SortName) Less(i, j int) bool { return x[i][1] < x[j][1] }
func (x SortName) Swap(i, j int)      { x[i], x[j] = x[j], x[i] }

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

func main() {
	sc.Split(bufio.ScanWords)
	x := stringLineScan()
	n, _ := strconv.Atoi(x)
	ab := make([][]int, n)
	for i := 0; i < n; i++ {
		c := make([]int, 2)
		for j := 0; j < 2; j++ {
			c[j], _ = strconv.Atoi(stringLineScan())
		}
		ab[i] = c
	}
	sort.Sort(SortName(ab))
	t := 0
	f := true
	for i := 0; i < n; i++ {
		t += ab[i][0]
		if t > ab[i][1] {
			f = false
			break
		}
	}
	if f {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 10368
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	r := make([][]bool, n)
	for i := 0; i < n; i++ {
		r[i] = make([]bool, n)
	}
	var a, b int
	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b)
		a--
		b--
		r[a][b], r[b][a] = true, true
	}

	res := solve(n, r)
	fmt.Println(res)
}

func solve(n int, r [][]bool) int {
	visited := make([]bool, n)

	var dfs func(a int) int
	dfs = func(a int) int {
		ok := true
		for _, v := range visited {
			if !v {
				ok = false
				break
			}
		}
		if ok {
			return 1
		}

		c := 0
		for b := 0; b < n; b++ {
			if r[a][b] && !visited[b] {
				visited[b] = true
				c += dfs(b)
				visited[b] = false
			}
		}

		return c
	}

	visited[0] = true
	return dfs(0)
}

func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}


Measured memory_bytes: 512
N = int(input())
A = [int(x) for x in input().split()]
if sum(A) % (N * (N + 1) // 2) != 0:
    print("NO")
    quit()
res = sum(A) // (N * (N + 1) // 2)
cnt = 0
for i in range(N):
    d = A[i] - A[(i+1)%N]
    if d + res < 0 or (d + res) % N != 0:
        print("NO")
        quit()
    cnt += (d + res) // N
print("YES" if cnt == res else "NO")


Measured memory_bytes: 14260
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int N;
int M;
int A;
int B;
int C;
int dp[5000];
int main(){
  int Lj4PdHRW, i;
  int res;
  rd(N);
  for(i=(1);i<(1<<N);i++){
    dp[i] = 1073709056;
  }
  int KL2GvlyY = rd_int();
  for(Lj4PdHRW=(0);Lj4PdHRW<(KL2GvlyY);Lj4PdHRW++){
    int Q5VJL1cS;
    rd(A);
    C = 0;
    int e98WHCEY = rd_int();
    for(Q5VJL1cS=(0);Q5VJL1cS<(e98WHCEY);Q5VJL1cS++){
      C |= (1<<(rd_int()-1));
    }
    for(i=(0);i<(1<<N);i++){
      chmin(dp[i|C], dp[i] + A);
    }
  }
  res = dp[(1<<N)-1];
  if(res == 1073709056){
    res = -1;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190928-1

// --- original code ---
// int N, M, A, B, C;
// int dp[5000];
// {
//   int res;
//   rd(N);
//   rep(i,1,1<<N) dp[i] = int_inf;
//   REP(rd_int()){
//     rd(A);
//     C = 0;
//     REP(rd_int()) C |= (1<<(rd_int()-1));
//     rep(i,1<<N) dp[i|C] <?= dp[i] + A;
//   }
//   res = dp[(1<<N)-1];
//   if(res == int_inf) res = -1;
//   wt(res);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int vacations(vector<int> a,vector<int> b,vector<int> c)
{
  int N=a.size();
  int dp0=a[N-1],dp1=b[N-1],dp2=c[N-1];
  for(int i=N-2;i>=0;i--)
  {
    int t0=a[i]+max(dp1,dp2);
    int t1=b[i]+max(dp0,dp2);
    int t2=c[i]+max(dp0,dp1);
    dp0=t0;
    dp1=t1;
    dp2=t2;
  }
  return max(dp0,max(dp1,dp2));
}
int main()
{
  int N;
  cin>>N;
  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(N);
  for(int i=0;i<N;i++)
    cin>>a[i]>>b[i]>>c[i];
  cout<<vacations(a,b,c);
  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

void solve(){
    string l;
    cin>>l;
    ll dp1=1;
    ll dp0=0;
    for(auto c:l){
        if(c=='1'){
            dp0=(dp0*3+dp1)%MOD;
            dp1=dp1*2%MOD;
        }else{
            dp0=dp0*3%MOD;
        }
    }
    cout<<(dp0+dp1)%MOD<<endl;

}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 512
N=int(input())
l=list(map(int,input().split()))

idxs = [i for i in range(N,0,-1)]
box=[0 for _ in range(N)]

for idx in idxs:
    div = [(i+1)*idx for i in range(N//idx)]
    sum_=sum([box[c-1] for c in div])
    if sum_ % 2 != l[idx-1]:
        box[idx-1] = 1
    
print(sum(box))
for i, v in enumerate(box):
    if v==1:
        print(i+1, end=' ')

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

const int nm = 500;
int n, c[nm - 1], s[nm - 1], f[nm - 1];

int main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}
	for (int i = 0, t; i < n; i++) {
		t = 0;
		for (int j = i; j < n - 1; j++) {
			t = max(s[j], (t + f[j] - 1) / f[j] * f[j]);
			t += c[j];
		}
		cout << t << endl;
	}
}


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

namespace My
{
template <typename ArrayT>
static void DumpArray(const ArrayT &arr, int len = 0,
                      int upper = std::numeric_limits<int>::max())
{
#if defined(HOME)
	if (len == 0) {
		for (auto it = std::begin(arr); it != std::end(arr); ++it) {
			cerr << *it << " ";
		}
	} else {
		for (int i = 0; i < len; i++) {
			if (arr[i] <= upper) {
				cerr << arr[i] << " ";
			} else {
				cerr << "x ";
			}
		}
	}
	cerr << endl;
#endif
}
template <typename T>
static void DumpGrid(const vector<vector<T>> &grid)
{
#if defined(HOME)
	REP (i, grid.size()) {
		REP (j, grid[i].size()) {
			cerr << grid[i][j] << " ";
		}
		cerr << endl;
	}
#endif
}
template <class ArrayT, typename T>
static void InitArray(ArrayT &arr, T initValue)
{
	for (auto &v : arr) {
		v = initValue;
	}
}
template <typename T>
static bool ReplaceIfSmaller(T &target, T value)
{
	if (value < target) {
		target = value;
		return true;
	} else {
		return false;
	}
}
template <typename T>
static bool ReplaceIfBigger(T &target, T value)
{
	if (target < value) {
		target = value;
		return true;
	} else {
		return false;
	}
}

#define INF 1LL << 60

using Edge = pair<ll, ll>;
using Graph = vector<vector<Edge>>; 

class Solver
{
  public:
	Solver() {}

	ll V, E, r;
	// 隣接リスト Graph[from頂点] = {to頂点, to頂点への距離}
	Graph G;
	// dist[行き先頂点] = start地点からの最短距離
	vector<ll> dist;

	// シンプルにダイクストラを適用するだけの問題
	void dijkstra()
	{
		// {距離, 頂点} のpairで格納 ※Graphの要素Edge(pair)とは異なる点に注意！
		// 距離が最も小さいものを取り出すのでGreaterを指定している ※降順ソートして、後ろから取り出すイメージ
		priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> que;
		//距離0の頂点rを入れる
		que.emplace(0, r);

		while (!que.empty()) {
			// キューの先頭を取り出す
			auto p = que.top();
			que.pop();
			ll curDist = p.first;  //取り出した距離
			ll curNode = p.second; //取り出した頂点

			//(optional)取り出した距離が、今現在わかっている頂点の距離より長い時スルーする
			// if (dist[curNode] < curDist) continue;

			// 行ける頂点にすべてについて距離を更新
			for (auto&& next : G[curNode]) {
				ll nextNode = next.first;     //辺の行き先
				ll nextWeight = next.second;  //辺の重み

				// 距離を小さくできたときだけキューに追加
				if (ReplaceIfSmaller(dist[nextNode], dist[curNode] + nextWeight)){
					que.emplace(dist[nextNode], nextNode);
				}
			}
		}
	}
	void Solve(istream &cin, ostream &cout)
	{
		cin >> V >> E >> r;
		G.resize(V);

		for (int i = 0; i < E; i++) {
			int s, t, d;
			cin >> s >> t >> d;
			G[s].emplace_back(t, d);
		}

		dist.resize(V, INF);
		dist[r] = 0;
		dijkstra();

		for (ll x : dist) {
			if (x == INF) {
				cout << "INF" << endl;
			} else {
				cout << x << endl;
			}
		}
	}
};
} // namespace My

#if !defined(BOOST_TEST_MODULE)
#if !defined(GTEST_INCLUDE_GTEST_GTEST_H_)
int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);

	My::Solver solver;
	solver.Solve(std::cin, std::cout);

	return 0;
}
#endif
#endif



Measured memory_bytes: 19440
#include <bits/stdc++.h>
using namespace std;
int n;
string x;
int main() {
    cin >> n;
    vector<int> s(4);
    for(int i = 0;i<n;i++){
        cin >> x;
        if(x == "AC"){
            s.at(0)++;
        }else if(x == "WA"){
            s.at(1)++;
        }else if(x=="TLE"){
            s.at(2)++;
        }else if(x=="RE"){
            s.at(3)++;
        }
    }
    cout << "AC " << "x " << s.at(0) << endl;
    cout << "WA " << "x " << s.at(1) << endl;    
    cout << "TLE " << "x " << s.at(2) << endl;
    cout << "RE " << "x " << s.at(3) << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef double db;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
const int N=3e5+5,M=6e5+5,mo=998244353;
int n,st,x[N],le,ri,lst,i;
ll y[N],ans;
int main()
{
	scanf("%d %d",&n,&st);
	fo(i,1,n) scanf("%d %lld",x+i,y+i);
	ans=0;
	le=1;ri=n;
	lst=2;
	while (x[le]<st&&st<x[ri])
	{
		if (y[le]>=y[ri])
		{
			if (lst!=-1) ans+=x[ri]-x[le];
			lst=-1;
			y[le]+=y[ri];
			ri--;
		}else
		{
			if (lst!=1) ans+=x[ri]-x[le];
			lst=1;
			y[ri]+=y[le];
			le++;
		}
	}
	ans+=max(abs(x[le]-st),abs(x[ri]-st));
	printf("%lld\n",ans);
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(){
  int n;
  scanf("%d",&n);
  if(n%2!=0 || n<2 || n>100000){
    return 0;
  }

  int d[n];
  int i,j;
  int tmp;

  for(i=0;i<n;i++){
    scanf("%d",&d[i]);
    if(d[i]<1 || d[i]>100000){
      return 0;
    }
  }
   qsort(d, sizeof(d) / sizeof(int), sizeof(int), asc);
  int a = d[n/2] -d[n/2-1];

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

  return 0;
}


Measured memory_bytes: 892
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;


int main(){

	char buf[8];
	int cups[] ={0,1,2};
	while(~scanf("%s,%s",buf)){
		swap(cups[buf[0]-'A'],cups[buf[2]-'A']);		
	}

	for(int i=0;i<3;i++){
		if(cups[i] == 0){
			printf("%c\n",i+'A');
		}
	}
	
}

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

typedef long long ll;

int main(){
	int n;
	cin>>n;
	vector<int>a(n);
	set<int>s;
	for(int i=0;i<n;i++){
		cin>>a[i];
		s.insert(a[i]);
	}
	if(s.size()==n){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	cout<<endl;
}

Measured memory_bytes: 10368
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      m: usize
   }
   let mut t = (n - m) * 100 + m * 1900;
   for _ in 0..m {
      t *= 2;
   }
   println!("{}", t);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm> 
#include <cstdio>

struct Node{
	int index,val;
	bool operator<(Node n){
		return this->val>n.val;
	}
	bool operator>(Node n){
		return this->val<n.val;
	}
	Node(){
		this->index=0;
	}
};

class Min_heap{
	private:
		Node **n;//?????????????????????
		int N;//????°????index
		void swap(int a_index, int b_index){
			Node *temp=n[b_index];
			n[b_index]=n[a_index];
			n[a_index]=temp;
			n[a_index]->index=a_index;
			n[b_index]->index=b_index;
		}
	public:
		Min_heap(int size){
			this->n = new Node*[size+1];
			std::fill_n(n,size+1,(Node*)NULL);
			this->N = 0;
		}
		void clear(){
			for(int i=0;i<N;i++){
				n[i]->index=0;
				n[i]=NULL;
			}
		}
		bool isEmpty(){
			return N==0;
		}
		void push(Node& e){
			int i=++N;
			n[i]=&e;
			e.index=i;
			while(i>1){
				if(*n[i/2]>*n[i]){
					swap(i/2,i);
					i=i/2;
				}else{
					break;
				}
			}
		}
		void remove(Node& a){
			int index = a.index;
			swap(index,N);
			n[N]->index=0;
			n[N--]=NULL;
			int i=index;
			while(i<N){
				if(i*2+1<=N){
					if(*n[i*2]<*n[i*2+1]){
						if(*n[i]>*n[i*2]){
							swap(i,i*2);
							i=i*2;
							continue;
						}
					}else{
						if(*n[i]>*n[i*2+1]){
							swap(i,i*2+1);
							i=i*2+1;
							continue;
						}
					}
				}else if(i*2<=N){
					if(*n[i]>*n[i*2]){
						swap(i,i*2);
						i=i*2;
						continue;
					}
				}
				break;
			}
		}
		Node* pop(){
			Node *p=n[1];
			remove(*n[1]);
			return p;
		}
};

int main(void){
	char str[10];
	Min_heap que = Min_heap(2000000);
	Node *V = new Node[2000000];
	int i=0;
	while(std::scanf("%s",str),str[2]!='d'){
		if(str[0]=='i'){
			int k;
			std::scanf("%d",&k);
			V[i].val=k;
			que.push(V[i]);
		}else{
			std::printf("%d\n",que.pop()->val);
		}
		i++;
	}

	return 0;
}

Measured memory_bytes: 32448
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

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

    private static void solve(Scanner in) {
        int N = in.nextInt(), M = in.nextInt();
        char[][] A = new char[N][N], B = new char[M][M];
        for (int i = 0; i < N; i++) {
            A[i] = in.next().toCharArray();
        }
        for (int j = 0; j < M; j++) {
            B[j] = in.next().toCharArray();
        }
        for (int h = 0; h < N - M + 1; h++) {
            for (int w = 0; w < N - M + 1; w++) {
                boolean ok = true;
                for (int i = 0; i < M; i++) {
                    for (int j = 0; j < M; j++) {
                        ok &= A[h + i][w + j] == B[i][j];
                    }
                }
                if (ok) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}

class Scanner implements Closeable {
    private final InputStream stream;
    private final byte[] buf = new byte[1024];
    private int cur;
    private int num;

    Scanner(InputStream stream) {
        this.stream = stream;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    int nextInt() {
        return (int) nextLong();
    }

    long nextLong() {
        int c = read();
        while (isdel(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long l = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            l *= 10;
            l += c - '0';
            c = read();
        } while (!isdel(c));
        return l * sgn;
    }

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

    String next() {
        int c = read();
        while (isdel(c))
            c = read();
        StringBuilder s = new StringBuilder();
        do {
            s.appendCodePoint(c);
            c = read();
        } while (!isdel(c));
        return s.toString();
    }

    private int read() {
        if (num == -1)
            throw new InputMismatchException();
        if (cur >= num) {
            cur = 0;
            try {
                num = stream.read(buf);
            } catch (Exception e) {
                throw new InputMismatchException();
            }
            if (num <= 0)
                return -1;
        }
        return buf[cur++];
    }

    private boolean isdel(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    @Override
    public void close() {
        try {
            stream.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

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

int main() {
  ll n,k;
  cin>>n>>k;
  ll p[n];
  ll res=0;
  ll max_res=0;
  for(int i=0;i<n;i++){
    cin>>p[i];
    res+=p[i];
    if(i>=k-1){
      max_res=max(max_res,res);
      res-=p[i-k+1];
    }
  }
  ll r=(max_res+k)/2;
  if ((max_res+k)%2==0)  cout<<r<<endl;
  else cout<<r<<".5"<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <stack>
#include <utility>
#include <functional>

int main(void)
{
  std::string c;
  std::stack<int> stack;
  auto next = [&stack]() -> std::pair<int, int> {
    int lhs = stack.top();
    stack.pop();
    int rhs = stack.top();
    stack.pop();
    return std::make_pair(lhs, rhs);
  };
  while(std::cin >> c){
    if (c == "+"){
      auto v = next();
      stack.push(v.first + v.second);
    } else if (c=="-"){
      auto v = next();
      stack.push(v.second - v.first);
    } else if (c=="*"){
      auto v = next();
      stack.push(v.first * v.second);
    } else {
      stack.push(std::stoi(c));
    }
  }
  std::cout << stack.top() << std::endl;
  return 0;
}



Measured memory_bytes: 3204
#include<iostream>
#include<cstdio>
#include<cstring>
#define REP(i,e,s) for(register int i=e; i<=s; i++)
#define DREP(i,e,s) for(register int i=e; i>=s; i--)
#define DE(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG(a) DE("DEBUG: %d\n",a)
#define file(a)	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
using namespace std;

int read() {
	int x=0,f=1,ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXM=2e5+10;

int a[MAXM];

int main() {
	int n=read();
	
	printf("%.2lf\n",3.14*n*2);
	return 0;
}



Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<pair<int,pair<int,int>>> t(n);
  int m=0;
  for(int i=0;i<n;i++){
    int x,y,z;cin >> x >> y >> z;
    m=max(m,y);
    x--,y--;
    t[i]=make_pair(z,make_pair(x,y));
  }
  vector<int> c(m+1);
  sort(t.begin(),t.end());
  c[t[0].second.first]++;
  c[t[0].second.second+1]--;
  for(int i=1;i<n;i++){
    if(t[i-1].first==t[i].first&&t[i-1].second.second==t[i].second.first){
      c[t[i].second.first+1]++;
      c[t[i].second.second+1]--;
    }
    else{
      c[t[i].second.first]++;
      c[t[i].second.second+1]--;
    }
  }
  int ans=0;
  int sum=0;
  for(int i=0;i<c.size();i++){
    sum+=c[i];
    ans=max(ans,sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int x,k,d;
    cin>>x>>k>>d;
    if(x>0)
    {
        int f=(x/d);
        if(f>=k)
        {
            cout<<abs(x-(k*d));
            return 0;
        }
        k-=f;
        if(k&1)
        cout<<abs(x-(f*d)-d);
        else
        cout<<abs(x-(f*d));
    }
    else
    {
        int f=(x/d);
        if(abs(f)>=k)
        {
            cout<<abs(x+(k*d));
            return 0;
        }
        k+=f;
        if(k&1)
        cout<<abs(x-(f*d)+d);
        else
        cout<<abs(x-(f*d));
    }
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e3+10;
int a[N],st[N],f[N][1<<13];
int main()
{
    int n,m,b;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>a[i]>>b;
        int t,c=0;
        for(int j=1;j<=b;j++)
        {
            cin>>t;
            t--;
            c|=1<<t;
        }
        st[i]=c;
    }
    memset(f,0x3f,sizeof f);
    f[0][0]=0;
    for(int i=1;i<=m;i++)
    for(int j=0;j<=(1<<13)-1;j++)
    {
        f[i][j]=min(f[i][j],f[i-1][j]);
        f[i][j|st[i]]=min(f[i][j|st[i]],f[i-1][j]+a[i]);
    }
    if(f[m][(1<<n)-1]==0x3f3f3f3f)  cout<<-1;
    else    cout<<f[m][(1<<n)-1];
}

Measured memory_bytes: 35960
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
#define mod 1000000007
long long exp(long long taban, long long us) {
    long long carpan = taban;
    long long temp = us;
    long long res = 1;
    while(temp > 0){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (((a*b)%mod)*(exp(ebob(a,b), (ll)mod-2))) % mod;
}
/*int level[100005];
int parent[100005][20];
vector<vector<int>> vec(100005);
void fonk(int cur, int dont){
	level[cur] = level[dont] + 1;
	parent[cur][0] = dont;
	for(int i = 1; i < 20; i++){
		parent[cur][i] = parent[parent[cur][i - 1]][i-1];
	}
	for(int i = 0; i < vec[cur].size(); i++){
		if(vec[cur][i] != dont) fonk(vec[cur][i], cur);
	}
}

int lca(int n1, int n2){
	int ans = -1;
	if(level[n2] > level[n1]){
		swap(n1, n2);
	}
	while(level[n1] > level[n2]){
		for(int i = 0; i < 20; i++){
			if(level[parent[n1][i]] >= level[n2]){
				n1 = parent[n1][i];
			}else break;
		}
	}
	if(n1 == n2) return n1;
	while(parent[n1][0] != parent[n2][0]){
		int tmp1, tmp2;
		for(int i = 0; i < 20; i++){
			if(parent[n1][i] != parent[n2][i]){
				tmp1 = parent[n1][i];
				tmp2 = parent[n2][i];
			}else break;
		}
		n1 = tmp1, n2 = tmp2;
	}
	return parent[n1][0];
}

int dist(int n1, int n2){
	return level[n1] + level[n2] - 2*level[lca(n1, n2)];
}*/
ll fonk(vector<ll>& vec, ll k){
	int n = vec.size();
	ll res = 0;
	for(int i = 0; i < n - 1; i++){
		if(vec[i] == 0){
			if(k >= 0) res += n - i - 1;
			continue;
		}
		bool check = vec[i] < 0;
		int l = i+1, r = n - 1;
		int mid;
		while(l < r){
			mid = (l+r) / 2;
			if(vec[i] * vec[mid] > k){
				check ? l = mid + 1 : r = mid;
			}else if(vec[i] * vec[mid] <= k){
				check ? r = mid : l = mid + 1;
			}
		}
		//cout<<k<< " "<<l<< " "<<i<<endl;
		if(vec[i] * vec[l] > k){
			if(check) l++;
			else l--;
		}
		if(vec[i] * vec[l] <= k) res += check ? n - l : l - i;
	}
	//cout<<k<<res<<endl;
	return res;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll n, k; cin>>n>>k;
	vector<ll> vec(n);
	for(auto &x: vec) cin>>x;
	sort(vec.begin(), vec.end());
	ll l = -1e18, r = 1e18;
	ll res = 0;
	while(l < r){
		//cout<<"asd";
		ll mid = (l+r) / 2;
		if(fonk(vec, mid) < k){
			l = mid + 1;
		}else if(fonk(vec, mid) >= k){
			//res = mid;
			r = mid;
			//cout<<res<<endl;
		}
		if(l + 1 == r){
			//cout<<l<< " "<<r<<endl;
			//cout<<fonk(vec, l)<< " "<<fonk(vec, r)<<endl;
			if(fonk(vec, l) == k){
				res = l;
			}else if(fonk(vec, r) >= k){
				l = r;
				res = l;
			}
			break;
		}else if(l == r) res = l;
		//cout<<l<< " "<<r<<endl;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 1792
import sys

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

    d = {}
    cnt=0

    for i in range(N):
        key=input()
        if key not in d:
            cnt+=1
            d[key] = 0

    print(cnt)

if __name__ =='__main__': 
    main()

Measured memory_bytes: 35276
#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 a,b,c;
  cin >>a >>b >>c;
  int sum = a+b+c;
  int M = max(a,max(b,c));
  int dis = 3*M - sum;
  int cnt = 0, modsum = sum;
  for(int i = 0;;i++){
    if(modsum%3==0 && modsum-sum>=dis) {
      break;
    }
    modsum += 2;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		long ans = 0;
		
		if(K==0) System.out.println(N*N);
		else{
			for(long i=K+1;i<=N;++i){
				long max = N/i;
				ans += (i-K)*max;
				if(N-max*i>=K) ans += N-max*i-K+1;
			}
			System.out.println(ans);
		}
		return;
	}
}

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

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int main() {
    double r;
    cin >> r;
    double ans = r * 2 * 3.141592;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <set>
#include <string>
using namespace std;

int main() {
	char S[101010];
	cin >> S;

	bool app[26] = { false };
	for (int i = 0; S[i] != '\0'; ++i) {
		app[S[i] - 'a'] = true;
	}
	for (int i = 0; i < 26; ++i) {
		if (!app[i]) {
			cout << char(i + 'a') << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;

}

Measured memory_bytes: 384
let a, b, c, d = Scanf.sscanf (read_line()) "%d %d %d %d" (fun a b c d -> a,b,c,d
)
let rec loop a c =
  if c - b <= 0 then "Yes" else
  if a - d <= 0 then "No" else
  loop (a-d) (c-b)

let _ = loop a c |> print_endline

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

using namespace std;
using ll=long long;

void solve() {
    int n; ll K;
    cin >> n >> K;
    vector<pair<int, int>> a(n);
    for (auto& p: a) {
        cin >> p.first >> p.second;
    }
    sort(a.begin(), a.end());
    vector<ll> sum(n+1);
    sum[0] = 0;
    for (int i = 1; i <= n; i++) {
        sum[i] = sum[i-1] + a[i-1].second;
    }
    
    int i = lower_bound(sum.begin(), sum.end(), K) - sum.begin();
    cout << a[i-1].first;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
using namespace std;

int main() {
	long long  n;
	cin >> n;
	double k = sqrt(1. * n);
	long long m = k/1;
	for (long long i = m; i >= 1; i--) {
		if (n % i == 0) {
			n/=i;
			break;
		}
	}
	
	int j = 0;
	while (n > 0) {
		n /= 10;
		j++;
	}
	cout << j << endl;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> input(N);
    vector<int> tmp(N);
    rep0(i,N){
        cin >> input[i];
        tmp[i] = input[i];
    }
    sort(input.begin(),input.end());
    int diff = 0;
    rep0(i,N){
        if(input[i]!=tmp[i]){
            diff++;
        }
    }
    if(diff<=2){
        cout << "YES";
    }else{
        cout << "NO";
    }
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



int main(){
    int n;
    cin >> n;
    int ans = 1;
    while(ans <= n) ans *= 2;
    ans /= 2;
    cout << ans << endl;
}

Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        string[] vs = (Console.ReadLine().Split(' '));
        int X = Convert.ToInt32(vs[0]);
        int Y = Convert.ToInt32(vs[1]);
        bool a = false;

        for (int i = 0; i <= X; i++)
        {
            if (2*(i)+4*(X-i)==Y)
            {
                a = true;
            }
        }

        if (a == true)
        {
            Console.WriteLine("Yes");
        }
        else
            Console.WriteLine("No");
    }
}


Measured memory_bytes: 17936
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int x = parseInt(sc.next());
		int y = parseInt(sc.next());
		int z = parseInt(sc.next());
		sc.close();
		out.printf("%d %d %d%n", z, x, y);
	}
}


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

using namespace std;

int uf[100001];
int parent[100001];
vector <int> adj[100001];
int indegree[100001];
int n,m,a,b;

int find(int x)
{
	if(uf[x] < 0)
	{
		return x;
	}
	return uf[x] = find(uf[x]);
}

bool merge(int x,int y)
{
	x = find(x);
	y = find(y);
	if(x==y)
	{
		return false;
	}
	uf[y] = x;
	return true;
}
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	memset(uf,-1,sizeof(uf));
	cin >> n >> m;
	for(int i=0;i<n+m-1;i++)
	{
		cin >> a >> b;
		adj[a].push_back(b);
		indegree[b]++;
	}

	queue <int> que;
	for(int i=1;i<=n;i++)
	{
		if(indegree[i]==0)
		{
			que.push(i);
		}
	}

	while(!que.empty())
	{
		int now = que.front();
		que.pop();

		for(auto next : adj[now])
		{
			indegree[next]--;
			if(indegree[next]==0)
			{
				if(merge(now,next))
				{
					parent[next] = now;
				}				
				que.push(next);
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		cout << parent[i] << '\n';
	}
	return 0;	
}

Measured memory_bytes: 10272