akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<utility>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#define maxn 1010
#define INF 0x3f3f3f3f
#define LL long long
#define ULL unsigned long long
#define E 1e-8
#define mod 1000000007
#define P pair<int,int>
using namespace std;

int main()
{
    int n;
    int cnt_5=0,cnt_7=0;
    for(int i=1;i<=3;++i){
        scanf("%d",&n);
        if(n==5)cnt_5++;
        else{
            cnt_7++;
        }

    }
    if(cnt_5==2&&cnt_7==1)
            printf("YES\n");
        else{
            printf("NO\n");
        }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
char R[105][99]={0};
int N;
bool ch(int l)
{
	map<string,bool>T;
	for(int i=0;i<N;i++)
	{
		char b[99]={0};
		for(int j=0;j<l;j++)b[j]=R[i][j];
		if(T[string(b)])return 0;
		T[string(b)]=1;
	}
	return 1;
}

int main()
{
	int res,q;
	for(;scanf("%d",&N),N;)
	{
		res=99,q=0;
		memset(R,0,sizeof(R));
		for(int i=0;i<N;i++)
		{
			char X[99];
			scanf("%s",X);
			q=max(q,(int)strlen(X));
			R[i][0]=X[0];
			for(int j=0,p=1;j<strlen(X)-1;j++)
				if(strchr("aiueo",X[j])!=NULL)
					R[i][p++]=X[j+1];
		}
		int c;
		for(c=1;c<=q;c++)
			if(ch(c))
			{
				printf("%d\n",c);
				break;
			}
		if(c>q)
			puts("-1");
	}
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(3, 0));
    for (vector<int> &i : a)
    {
        for (int &x : i)
        {
            cin >> x;
        }
    }
    vector<vector<int>> dp(n + 1, vector<int>(3, 0));
    for (int i = 1; i < n + 1; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            int k = (j + 1) % 3, r = (j + 2) % 3;
            dp[i][j] = max(dp[i - 1][k], dp[i - 1][r]) + a[i - 1][j];
        }
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
    return 0;
}

Measured memory_bytes: 11136
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
e = [set() for _ in range(N + 1)]
reve = [[] for _ in range(N + 1)]
for _ in range(M):
  u, v, c = map(int, input().split())
  e[u].add((v, -c))
  reve[v].append(u)

vis = [0] * (N + 1)
def revdfs(x):
  global vis
  if x == 1: return True
  res = 0
  for y in reve[x]:
    if vis[y]: continue
    vis[y] = 1
    res |= revdfs(y)
  return res
def dfs(x):
  global vis
  if x == N: return True
  res = 0
  for y, _ in e[x]:
    if vis[y]: continue
    vis[y] = 1
    res |= dfs(y)
  return res
banned = [0] * (N + 1)
for x in range(1, N + 1):
  vis = [0] * (N + 1)
  banned[x] |= revdfs(x) ^ 1
  vis = [0] * (N + 1)
  banned[x] |= dfs(x) ^ 1

for x in range(1, N + 1):
  t = list(e[x])
  for y, d in t:
    if banned[x] | banned[y]: e[x].discard((y, d))
#print(banned)
INF = 10**18
dist = [INF] * (N + 1)
dist[1] = 0
update = 1
for _ in range(N + 1):
    update = 0
    for v, x in enumerate(e):
        for t, cost in x:
            if dist[v] != INF and dist[v] + cost < dist[t]:
                dist[t] = dist[v] + cost
                update = 1
    if not update:
        break
else:
  print("inf")
  exit(0)
print(-dist[N])

Measured memory_bytes: 124992
#include <iostream>

using namespace std;

int main(){
    int n, num1, num2;
    int max = -999999999;
    cin >> n;
    cin >> num1;
    for(int i=1;i<n;i++){
        cin >> num2;
        if(num2-num1>max) max = num2-num1;
        if(num1>num2) num1 = num2;
    }
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long a,b,n,x;
    cin>>a>>b>>n;
    if (n/b==0)
    {
    	x=n;
	}
	else
	{
		x=b-1;
	}
	cout<<(a*x)/b-a*(x/b)<<endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <queue>
#include <utility>
#include <map>
using namespace std;

typedef long long lint;
typedef unsigned long long ulint;

int main(){
    lint N;
    cin >> N;
    ulint X=0,E=0;
    for(lint i=0;i<N;i++){
        ulint A;
        cin >> A;
        X^=A;
        E|=(A^(A-1))+1;
    }

    lint cnt=0;
    for(int i=31;i>=0;i--){
        if(X&(1<<i)){
            if((E&(1<<(i+1)))==0){
                cout << "-1" << endl;
                return 0;
            }
            cnt++;
            X^=(1<<(i+1))-1;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
// Vicfred
// https://atcoder.jp/contests/abc175/tasks/abc175_d
// math
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    long N, K;
    readf("%s %s", &N, &K);
    readln;

    long[] P = readln.split.map!(to!long).array;
    long[] C = readln.split.map!(to!long).array;

    for(int i = 0; i < N; i++)
        P[i] -= 1;

    long ans = long.min;

    for(long i = 0; i < N; i++) {
        long p = i;

        long sum = 0;
        long cycles = 0;

        while(true) {
            cycles += 1;
            sum += C[p];
            p = P[p];
            if(p == i) break;
        }

        long count = 0;
        long path = 0;
        while(true) {
            count += 1;
            path += C[p];

            if(count > K) break;
            long num = (K - count)/cycles;
            long score = path + max(0, sum)*num;
            ans = max(ans, score);

            p = P[p];
            if(p == i) break;
        }
    }

    ans.writeln;
}



Measured memory_bytes: 3176
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 1000000

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n,a[100010];
    cin>>n;
    for(int i=0;i<n;i++){
	cin>>a[i+1];
    }
    a[0]=0,a[n+1]=0;
    ll ans=0;
    for(int i=0;i<=n;i++){
	ans+=abs(a[i+1]-a[i]);
    }
    for(int i=1;i<=n;i++){
	ll res=ans-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]);
	cout<<res<<endl;
    }
}




Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main()
{
	//freopen("one.in","r",stdin);
	//freopen("one.out","w",stdout);
	int x,y,a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	x=a+b;
	y=c+d;
	if(x>y)
		printf("Left");
	else if(y>x)
		printf("Right");
	else
		printf("Balanced");
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}


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

int main() {
    int A,  B, C;
    cin >> A >> B >> C;
    int answer;
    if(A==B){
        if(A==C){
            answer = false;
        } else {
            answer = true;
        }
    }
    else if(A==C){
        if(A==B){
            answer = false;
        } else {
            answer = true;
        }
    }
    else if(C==B){
        if(A==C){
            answer = false;
        } else {
            answer = true;
        }
    }
    else{
        answer = false;
    }
    if(answer){
        cout << "Yes";
    } else{
        cout << "No";
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define MAX INT_MAX
#define MIN INT_MIN
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
set <int> s;
bool ar[100001];
void seive() {
	ar[0] = ar[1] = true;

	for(int p=2; p*p<=100001; p++) {
		if(ar[p] == false) {
			for(int i=p*p;i<=100001;i+=p)
				ar[i] = true ;
		}
	}

	for(int p=2;p<=100001;p++) {
		if(ar[p] == false)
			s.insert(p);
	}
}
void solve() {
	int n, k;
	cin >> n >> k;
	vector <int> v(n);
	vector <double> pre(n);
	vector <double> temp;
	for(int i=0;i<n;i++) {
		cin >> v[i];
		pre[i] = ((v[i]*(v[i]+1))/2.0)/double(v[i]);
		// cout << pre[i] << " ";
	}
	// cout << endl;
	double sum = 0.0;
	for(int i=0;i<k;i++)
		sum += pre[i];
	temp.pb(sum);
	// for(double x : temp)
	// 	cout << x << " ";
	// cout << endl;
	int c = 0;
	double cursum = sum;
	for(int i=k;i<n;i++) {
		double x =  cursum - pre[c] + pre[i];
		temp.pb(x);
		cursum = x;
		c++;
	}
	// for(double x : temp)
	// 	cout << x << " ";
	// cout << endl;

	double x = *max_element(temp.begin(), temp.end());
	cout << setprecision(10) << x << endl;
    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}

Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int As;
int Bs;
char A[52];
char B[52];
char res[102];
int main(){
  int i, k=0;
  As = rd(A);
  Bs = rd(B);
  for(i=0;i<As;i++){
    res[k++] = A[i];
    if(i<Bs){
      res[k++] = B[i];
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int As, Bs;
// char A[52], B[52];
// 
// char res[102];
// 
// {
//   int i, k = 0;
//   rd(A@As, B@Bs);
//   rep(i,As){
//     res[k++] = A[i];
//     if(i<Bs) res[k++] = B[i];
//   }
//   wt(res);
// }


Measured memory_bytes: 256
from collections import Counter
n = int(input())

cnt_list = []
for i in range(n):
    cnt_list.append(Counter(input()))

ans = ""

for code in range(ord("a"), ord("a")+27):
    target = chr(code)
    repeat = min([x[target] for x in cnt_list])
    ans += target*repeat

print(ans)

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

using ll = long long;
#define pq priority_queue
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int ans[500];
int a, b, c, N;
int r[1000], x[1000], y[1000], z[1000];

void init() {
   for (int i = 0; i < 500; i++) ans[i] = 2;
}

int main() {
   while (cin >> a >> b >> c, a) {
      init();
      cin >> N;
      for (int i = 0; i < N; i++) {
         cin >> x[i] >> y[i] >> z[i] >> r[i];
         if (r[i] == 1) ans[x[i]] = 1, ans[y[i]] = 1, ans[z[i]] = 1;
      }
      
      for (int i = 0; i < N; i++) {
         if (r[i] == 1) continue;
         if (ans[x[i]] == 1 && ans[y[i]] == 1) ans[z[i]] = 0;
         if (ans[y[i]] == 1 && ans[z[i]] == 1) ans[x[i]] = 0;
         if (ans[z[i]] == 1 && ans[x[i]] == 1) ans[y[i]] = 0;
      }

      for (int i = 1; i <= a+b+c; i++) {
         cout << ans[i] << endl;
      }
   }

   return 0;
}


Measured memory_bytes: 3084
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    n=int(readline())
    #ss=readline().rstrip()
    #yn(1)
    if n <= 599:
        print(8)
        return
    if n <= 799:
        print(7)
        return
    if n <= 999:
        print(6)
        return
    if n <= 1199:
        print(5)
        return
    if n <= 1399:
        print(4)
        return
    if n <= 1599:
        print(3)
        return
    if n <= 1799:
        print(2)
        return
    if n <= 1999:
        print(1)
        return
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16200
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-8-25 20:45:21
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, K;
ll x[100010];
vector<ll> V[2];

int main()
{
  cin >> N >> K;
  for (auto i = 0; i < N; i++)
  {
    cin >> x[i];
  }
  for (auto i = 0; i < N; i++)
  {
    if (x[i] == 0)
    {
      K--;
    }
    else if (x[i] > 0)
    {
      V[0].push_back(x[i]);
    }
    else
    {
      V[1].push_back(-1 * x[i]);
    }
  }
  if (K <= 0)
  {
    cout << 0 << endl;
    return 0;
  }
  sort(V[1].begin(), V[1].end());
  ll ans = 100000000000000;
  for (auto i = 0; i < 2; i++)
  {
    if ((int)V[i].size() >= K)
    {
      ans = min(ans, V[i][K - 1]);
    }
  }
  for (auto k = 1; k <= K - 1; k++)
  {
    int l = K - k;
    if ((int)V[0].size() >= k && (int)V[1].size() >= l)
    {
      //cerr << "V[0][" << k - 1 << "] = " << V[0][k - 1] << endl;
      //cerr << "V[1][" << l - 1 << "] = " << V[0][l - 1] << endl;
      ans = min(ans, V[0][k - 1] + 2 * V[1][l - 1]);
      ans = min(ans, 2 * V[0][k - 1] + V[1][l - 1]);
    }
  }
  cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  vector<int> c(n);
  rep(i, n) cin >> c[i];
  int result = INT_MIN;
  for (int bit = 0; bit < (1 << n); bit++) {
    vector<int> s;
    for (int i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        s.push_back(i);
      }
    }
    int sumX = 0;
    int sumY = 0;
    rep(i, s.size()) {
      sumX += v[s[i]];
      sumY += c[s[i]];
    }
    result = max(result, sumX - sumY);
  }
  cout << result << endl;

  return 0;
}


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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    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;
    }
}

long long 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;
}


int main(){
    ll n,k;
    cin >> n >> k;
    COMinit();
    for(ll i=1;i<=k;i++){
        ll res=1;
        res=res*COM(n-k+1,i)%MOD;
        res=res*COM(k-1,i-1)%MOD;
        cout << res << endl;
    }
}


Measured memory_bytes: 15584
#include <iostream>
#include <vector>
#include <set>

using namespace std;

unsigned int xor32(){
    static unsigned int y = 2463534242;
    y = y ^ (y << 13); y = y ^ (y >> 17);
    return y = y ^ (y << 5);
}

int main(){
    int D; cin >> D;
    vector<int> c(26, 0);
    for(auto& t : c) cin >> t;
    vector s(D, vector(26, 0));
    for(auto& v : s){
        for(auto& t : v) cin >> t;
    }
    vector<int> last(26, 0);
    vector<set<int>> days(26);
    for(int i=0;i<26;i++){
        days[i].insert(0);
        days[i].insert(D+1);
    }
    vector<int> select(D+1, -1);
    long long score = 0;
    for(int i=1;i<=D;i++){
        int t = -1;
        long long best = 0;
        for(int j=0;j<26;j++){
            long long cur = s[i-1][j];
            for(int k=0;k<26;k++){
                if(j==k) continue;
                cur -= c[k] * (i - last[k]);
            }
            if(t == -1 || best < cur){
                t = j;
                best = cur;
            }
        }
        days[t].insert(i);
        select[i] = t;
        last[t] = i;
        score += best;
    }
    for(int i=0;i<3000000;i++){
        int d = xor32()%D + 1;
        int q = xor32()%26;
        long long sub = 0;
        sub -= s[d-1][select[d]];
        sub += s[d-1][q];
        auto it = days[select[d]].find(d);
        --it;
        auto pre = *it;
        ++it; ++it;
        auto next = *it;
        sub += ((d-pre)*(d-pre-1)/2 + (next-d)*(next-d-1)/2) * c[select[d]];
        sub -= (next-pre)*(next-pre-1)/2 * c[select[d]];
        it = days[q].lower_bound(d);
        next = *it;
        --it;
        pre = *it;
        sub -= ((d-pre)*(d-pre-1)/2 + (next-d)*(next-d-1)/2) * c[q];
        sub += (next-pre)*(next-pre-1)/2 * c[q];
        if(sub > 0){
            days[select[d]].erase(d);
            days[q].insert(d);
            select[d] = q;
            score += sub;
        }
    }
    for(int i=1;i<=D;i++) cout << select[i]+1 << endl;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
const int maxn=1010;
int w,l;
char s[maxn];
int main(){
    scanf("%s",s);l=strlen(s);
    scanf("%d",&w);
    for(register int i=0;i<l;i+=w) putchar(s[i]);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int main() {
    int a, b, k; cin >> a >> b >> k;
    int cnt = 0;
    for (int i = min(a, b); i >= 1; --i) {
        if (a % i == 0 && b % i == 0) {cnt++;/* cout << i << endl;*/}
        if (cnt == k) {cout << i << endl; break;}
    }
}








Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    H = il()

    dp = [0]*N
    for n in range(1, N):
        if H[n] <= H[n-1]:
            dp[n] = dp[n-1] + 1
        else:
            dp[n]
    print(max(dp))


if __name__ == '__main__':
    main()


Measured memory_bytes: 13772
#include <bits/stdc++.h>
  using namespace std;
 
int main(){
  int N;
  cin>>N;
  vector<int> V(N);
  for(int i=0;i<N;i++){
    cin>>V.at(i);
  }
  vector<int> C(N);
  for(int i=0;i<N;i++){
    cin>>C.at(i);
  }
  int P=0;
  for(int i=0;i<N;i++){
    if(V.at(i)>C.at(i)){
      P+=V.at(i)-C.at(i);
    }
  }
  cout<<P<<endl;
}

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

using i64 = long long;
const int INF = 1001001001;

template <class T, class U>
bool chmax(T &a, const U &b) {
  return a < b ? a = b, 1 : 0;
}
template <class T, class U>
bool chmin(T &a, const U &b) {
  return a > b ? a = b, 1 : 0;
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> keys(M);
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    int s = 0;
    for (int j = 0; j < b; ++j) {
      int c;
      cin >> c;
      s |= 1 << (c - 1);
    }
    keys[i] = {a, s};
  }

  static int dp[1 << 12];
  fill(dp, dp + (1 << 12), INF);
  dp[0] = 0;
  for (int i = 0; i < (1 << N); ++i) {
    for (int j = 0; j < M; ++j) {
      chmin(dp[i | keys[j].second], dp[i] + keys[j].first);
    }
  }
  int ans = dp[(1 << N) - 1];
  if (ans == INF) ans = -1;
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <assert.h>
#include <memory>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

const vector<unsigned int> primepool={4294967291, 4294967279, 4294967231, 4294967197};

class RobinKarpMersenne {
public:
	static const uint64_t mod = (1ull<<61) - 1;
	uint64_t modmul(uint64_t a, uint64_t b){
		uint64_t l1 = (uint32_t)a, h1 = a>>32, l2 = (uint32_t)b, h2 = b>>32;
		uint64_t l = l1*l2, m = l1*h2 + l2*h1, h = h1*h2;
		uint64_t ret = (l&mod) + (l>>61) + (h << 3) + (m >> 29) + (m << 35 >> 3) + 1;
		ret = (ret & mod) + (ret>>61);
		ret = (ret & mod) + (ret>>61);
		return ret-1;
	}
	uint64_t modpow(uint64_t a, uint64_t n) {
		uint64_t ret = 1; uint64_t p = a; while (n) { if (n & 1) ret = modmul(ret, p); p = modmul(p, p); n >>= 1; } return ret;
	}
	uint64_t b,binv;
	vector<uint64_t> bpow;
	//vector<uint64_t> invbpow;
	void init(int n, uint64_t base) {
		b=base;
		bpow.reserve(n);
		uint64_t x=1;
		bpow.PB(x);
		for (int i=1;i<n;i++) {
			x=modmul(x,b);
			bpow.PB(x);
		}
		/*
		binv=modpow(b,mod-2);
		x=1;
		invbpow.PB(x);
		for (int i=1;i<n;i++) {
			x=modmul(x,invb);
			invbpow.PB(x);
		}*/
	}
	uint64_t addc(uint64_t hash, uint64_t c, int pos) {
		hash+=modmul(c,bpow[pos]); if (hash>=mod) hash -= mod;
		return hash;
	}
};
uint32_t rd() {
  uint32_t ret;
  asm volatile("rdrand %0" :"=a"(ret) ::"cc");
  return ret;
}

RobinKarpMersenne rk;
map<pair<uint64_t,uint64_t>, int> h;
int main(){	
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; string inp; cin>>n>>inp;
	string s[2]; s[0]=inp.substr(0,n); s[1]=inp.substr(n,n); reverse(s[1].begin(),s[1].end());
  seed_seq seq{
      (uint64_t) chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count(),
      (uint64_t) __builtin_ia32_rdtsc(),
      (uint64_t) rd()
  };
  mt19937 rng(seq);
  uint64_t base = uniform_int_distribution<uint64_t>(31, rk.mod-31)(rng);
  rk.init(n,base);
  for (int z=0;z<(1<<n);z++) {
  	pair<uint64_t,uint64_t> hash=MP(0,0);
  	int zeros=0,ones=0;
  	for (int x=0;x<n;x++) {
  		if (0==(z&(1<<x))) hash.fst=rk.addc(hash.fst, s[0][x], zeros++);
  		else hash.snd=rk.addc(hash.snd,s[0][x],ones++);
  	}
  	hash.fst^= ((uint64_t)zeros)<<61;
  	++h[hash];
  }
  ll final=0;
  for (int z=0;z<(1<<n);z++) {
  	pair<uint64_t,uint64_t> hash=MP(0,0);
  	int zeros=0,ones=0;
  	for (int x=0;x<n;x++) {
  		if (0==(z&(1<<x))) hash.fst=rk.addc(hash.fst, s[1][x], zeros++);
  		else hash.snd=rk.addc(hash.snd,s[1][x],ones++);
  	}
  	hash.fst^= ((uint64_t)zeros)<<61;
  	auto it=h.find(hash);
  	if (it!=h.end()) final+=(it->snd);
  }
  printf("%lld\n",final);
}



Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define rep(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define For(i, a, n) for (ll (i) = (a); (i) < (n); (i)++)
#define prl(x) cout << (x) << endl
#define pr(x) cout << (x)
#define all(v) (v).begin(), (v).end()

int main(void){
    const size_t MB=160*160+10;
    typedef bitset<MB> bts;
    const ll M = 80 * 160 + 3;
    ll h,w,v;cin>>h>>w;vector<vl> vs(w,vl(h));
    rep(y,h)rep(x,w)cin>>vs[x][y];
    rep(y,h)rep(x,w){cin>>v;vs[x][y]-=v;vs[x][y]=abs(vs[x][y]);}
    vector<vector<bts>> dp(w,vector<bts>(h,0));bts b1=1,bM=b1<<M;
    auto ud = [&](bts p,ll v)->bts{return p<<v|p>>v;};
    dp[0][0]=ud(bM,vs[0][0]);
    rep(x,w)rep(y,h){
        ll v=vs[x][y];
        if (!x&&!y) continue;
        if(x)dp[x][y]|=ud(dp[x-1][y],v);
        if(y)dp[x][y]|=ud(dp[x][y-1],v);
    }
    rep(v,M)if(dp[w-1][h-1][M+v]){prl(v);return 0;}
    return 0;
}

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

using namespace std;

int main(void) {
    string s, t;
    int flag = 0;
    cin >> s >> t;
    for(int i = 0; i < (int)(s.length()); i++){
        if(s[i] == t[i]){
        }
        else{
            cout << "No" << endl;
            flag = 1;
            break;
        }
    }
    if(flag == 0){
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
using System;

namespace abc130A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            if (A < B)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(10);
            }
        }
    }
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
#define repi(i,a,b) for(lint i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v); reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

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

    string s;cin>>s;
    tsort(s);
    lint l=s.length()-1;
    rep(i,l){
        if(s[i]==s[i+1]){
            co("no");
            return 0;
        }
    }
    co("yes");
}

Measured memory_bytes: 256
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
// }}}

LL a,b;

void input() {
    scanf("%lld %lld", &a, &b);
}

LL gcd(LL a, LL b) {
    if(b==0) return a;
    return gcd(b, a%b);
}

void solve() {
    int g = gcd(a,b);
    printf("%lld\n", (a*b)/g);
}

int main( int argc, char *argv[] ) {
    input(); solve();
    return 0;
}

Measured memory_bytes: 256
n,wgt=map(int,input().split())
a=[]
v=[]
for i in range(n):
    x,y=map(int,input().split())
    a.append(x)
    v.append(y)

dp=[[0 for x in range(wgt+1)] for x in range(n+1)]

for i in range(n+1):
    for j in range(wgt+1):
        if i==0 or j==0:
            dp[i][j]=0
        elif a[i-1]<=j:
            dp[i][j]=max(v[i-1]+dp[i-1][j-a[i-1]],dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]

print(dp[n][wgt])

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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define f(i,a,b) for(ll i=a;i<b;i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define en '\n'

int main()
{
	IOS;
	int t=1;
//	cin>>t;
	while(t--)
	{
        int n,m,a,b;
        cin>>n>>m;
        vector<pair<int,int> > v;
        f(i,0,m)
        {
            cin>>a>>b;
            v.pb({a,b});
        }
        sort(all(v));
        int c=0;
        int l=v[0].F,r=v[0].S;
        f(i,1,m)
        {
            a=v[i].F;
            b=v[i].S;
            if(a<r){
            l=max(l,a);
            r=min(r,b);
            }
            else
            {
                c++;
                l=a;
                r=b;
            }

        }
        c++;
        cout<<c;
	}
}


Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long int ll;
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a+b==c || a+c==b || b+c==a)printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 256
from collections import Counter


def main():
    n = int(input())
    a = list(map(int, input().split()))
    d_a = Counter(a)
    q = int(input())
    answer = sum(a)
    for _ in range(q):
        b, c = map(int, input().split())
        if b in d_a:
            answer += (c - b) * d_a[b]
            if c in d_a:
                d_a[c] += d_a[b]
            else:
                d_a[c] = d_a[b]
            d_a[b] = 0
        print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 21392
N, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
MOD = 10 ** 9 + 7
# pypyで通す
def prepare(n, MOD):
 
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return factorials, invs

def comb(n ,k, mod, fac, finv):
    '''
    二項係数の計算

    Parameters
    n : int
        元集合
    k : int
        元集合から選択する数
    mod : int
        あまり
    fac : list
        階乗のリスト
    finv : list
        逆元のリスト
    
    Returns
    c : int
        nCkの組み合わせの数
    '''
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

fac, rfac = prepare(N, MOD)
#print(count)
# 最大値の数え上げ
maxnum = 0
minnum = 0
for i in range(N-K+1):
    counter = comb(N-i-1, K-1, MOD, fac, rfac)
    maxnum += counter * A[i] % MOD
    minnum += counter * A[len(A) - 1 - i] % MOD

print((maxnum - minnum) % MOD)


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

int main()
{
	int n, a, b, x = 0;
	cin >> a >> b;
	n = 200000;
	for (int i = 1; i <= n; i++)
	{
		if (2*i/25 == a && i/10 == b)
		{
			cout << i;
			return 0;
		}
	}
	cout << -1;
	return 0;
}

Measured memory_bytes: 256
#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>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
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(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int k, a, b;
  cin >> k >> a >> b;
  if(a%k == 0) {
    cout << "OK" << endl;
    return 0;
  }
  else {
    if(a/k != b/k) cout << "OK" << endl;
    else cout << "NG" << endl; 
  }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}

int main(){;
	while(1){
		string s;
		cin>>s;
		if(s=="#") break;
		reverse(s.begin(),s.end());
		ll x=0,y=1,t=2;
		int i=0;
		if(s[0]=='t') x=90,i=4;
		else i=5;
		for(;i<s.size();){
			if(s[i]=='t'){
				ll X=90,Y=t;
				ll x_=x*Y+y*X,y_=y*Y;
				x=x_,y=y_;
				ll g=gcd(x,y);
				x/=g,y/=g;
				i+=4;
			}
			else{
				ll X=90,Y=t;
				ll x_=x*Y-y*X,y_=y*Y;
				x=x_,y=y_;
				ll g=gcd(x,y);
				x/=g,y/=g;
				i+=5;
			}
			t*=2;
		}
		if(y==1) cout<<x<<endl;
		else cout<<x<<'/'<<y<<endl;
	}
}


Measured memory_bytes: 3160
import java.util.Scanner;

class Main
{
  public static void main(String[] args)
  {
    int Max=-1000000,min=1000000,n,temp;
    long sum=0;
    Scanner in=new Scanner(System.in);
	
	n=in.nextInt();
	for(int i=0;i<n;i++)
	{
		temp=in.nextInt();
		if(temp>Max)
			Max=temp;
		if(temp<min)
			min=temp;
		sum+=temp;		
	}
	System.out.println(min + " " + Max + " " + sum);
    
  }

}

Measured memory_bytes: 41780
#include <iostream>
#include <algorithm>
using namespace std;
#define maxn 200010
#define ll long long

int n,len[maxn],t[maxn];
string s[maxn];
struct node{
	int t[26];
	node *son[26];
	node(){for(int i=0;i<26;i++)t[i]=0,son[i]=NULL;}
}*root=new node();
void insert(string &S,int &l){
	for(int i=0;i<l;i++)t[S[i]-'a']++;
	node *now=root;
	for(int i=l-1;i>=0;i--){
		for(int j=0;j<26;j++)if(t[j])now->t[j]++;
		if(!now->son[S[i]-'a'])now->son[S[i]-'a']=new node();
		now=now->son[S[i]-'a'];t[S[i]-'a']--;
	}
}
ll ans=0;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s[i];len[i]=s[i].length();
		insert(s[i],len[i]);
	}
	for(int i=1;i<=n;i++){
		node *now=root;
		for(int j=len[i]-1;j>=1;j--)now=now->son[s[i][j]-'a'];
		ans+=now->t[s[i][0]-'a']-1;
	}
	cout<<ans;
}

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

using namespace std;

typedef long long int LL;


int main()
{
    vector<int> v, vec;

    int a, t, cnt = 0;

    cin>>t;

    for(int i = 0; i < t; i++)
    {
        cin>>a;

        v.push_back(a);
        vec.push_back(a);
    }

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

    for(int i = 0; i < t; i++)
    {
        if(v[i] != vec[i])
            cnt++;
    }

    if(cnt < 3)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	//cout << fixed << setprecision(10);
	string s,t; cin>>s>>t;
	int n=s.size();
	int m=t.size();
	rep(i,0,s.size()){
		string u;
		rep(j,0,m){
			u.push_back(s[(i+j)%n]);
		}
		if(t==u){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;


	return 0;
}


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

long long make5pow(long long A) {
    long long ans = 1;
    for (int i = 0; i < 5; ++i) {
        ans *= A;
    }
    return ans;
}

int main() {
    long long X;
    cin >> X;

    for (long long A = -200; A <= 200; ++A) {
        for (long long B = -200; B<= 200; ++B) {
            long long result = make5pow(A) - make5pow(B);
            if (result == X) {
                cout << A << " " << B << endl;
                return 0;
            }
        }
    }
}

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

int main() {
  long long n, m;
  cin>>n>>m;
  if (n == 1 && m == 1) {
    cout<<1<<endl;
  } else if (n == 1) {
    cout<<m - 2<<endl;
  } else if (m == 1) {
    cout<<n - 2<<endl;
  } else {
    cout<<(n - 2) * (m - 2)<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	double a,b,h,m,r;
	cin>>a>>b>>h>>m;
	h+=m/60;
	h/=12;
	m/=60;
	if(h>=0.5&&m>=0.5)
	{
		h-=0.5;
		m-=0.5;
		r=h-m;
		if(r<0)
		r=-r;
		
	}
	else
	if(h>0.5&&m<0.5)
	{
		h-=0.5;
		r=h-m;
		if(r<0)
		r=-r;
		r=0.5-r;
	}
	else
	if(h<0.5&&m>0.5)
	{
		m-=0.5;
		r=h-m;
		if(r<0)
		r=-r;
		r=0.5-r;
	}
	else
	{
		r=h-m;
		if(r<0)
		r=-r;
	}
	
	
	
	
//	cout<<h<<m<<endl;
//	if(h>m&&((h<0.5&&m<0.5)||(h>0.5&&m>=0.5)))
//	{
//		r=h-m;
//		
//	}
//	else
//	if(h<=m&&((h<0.5&&m<=0.5)||(h>0.5&&m>0.5)))
//	{
//		r=m-h;
//	}
//	else
//	if(h>m&&(h>0.5&&m<=0.5))
//	{
//		r=m+(1-h);
//	}
//	else
//	if(h<m&&(h<0.5&&m>=0.5))
//	{
//		r=h+(1-m);
//	}

	
	printf("%.20lf\n",sqrt(a*a+b*b-2*a*b*cos(r*acos(-1)*2)));
}

Measured memory_bytes: 4288
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int x,y;
	scanf("%d%d",&x,&y);
	printf("%d\n",(x+y+1)/2);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
deque<int> q;
int n;
 int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i) 
	{
		int x;
		scanf("%d",&x);
		if (i&1) q.push_back(x);
		else q.push_front(x);
	}
	if (n&1) 
		for (int i=q.size()-1;i>=0;--i) printf("%d ",q[i]);
	else 
		for (int i=0;i<q.size();++i) printf("%d ",q[i]);
}

Measured memory_bytes: 2944
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  string S;
  cin >> S;

  ll s = 0; // summ

  vector<char> chars(3);
  chars[0] = 'B';
  chars[1] = 'G';
  chars[2] = 'R';

  do {
    ll now = 0;
    ll r = 0;
    char a = chars[0];
    char b = chars[1];
    char c = chars[2];

    // cout << "a:" << a << endl;
    // cout << "b:" << b << endl;
    // cout << "c:" << c << endl;

    rep(i, n) {
      if (S[i] == a) {
        ++r;
      } else if (S[i] == b) {
        now += r;
      } else { // s[i] == c
        s += now;
      }
    }
  } while (next_permutation(all(chars)));

  // cout << "s: " << s << endl;

  // Here, all sum is calculated
  for (int m = 1; m < n; ++m) {
    // Here, we try all cas
    rep(i, n) {
      ll j = i + m;
      ll k = j + m;
      if (j >= n || k >= n) { break; }
      // Check (i,j,k)
      if (S[i] != S[j] && S[j] != S[k] && S[i] != S[k]) { // valid
        --s;
      }
    }
  }

  cout << s << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define P pair<int,int>
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
long long dp[51][51][2501] = {};
int main() {
	int n, A;
	cin >> n >> A;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	dp[0][0][0] = 1;
	for (int j = 0; j < n; j++) {
		for (int k = 0; k < n; k++) {
			for (int s = 0; s < n * A; s++) {
				if (!dp[j][k][s]) {
					continue;
				}
				dp[j + 1][k][s] += dp[j][k][s];
				dp[j + 1][k + 1][s + a[j]] += dp[j][k][s];
			}
		}
	}
	long long ans = 0;
	for (int k = 1; k <= n; k++) {
		ans += dp[n][k][k * A];
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    double sum = 0;
    int a_n;
    for (int n = 0; n < N; n++) {
        cin >> a_n;
        sum += (double)1 / a_n;
    }

    cout << 1 / sum << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(abs(a-b)<abs(a-c)){
		cout<<"A"<<endl;
	}
	else cout<<"B"<<endl;
	return 0;
}

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

using namespace std;

const int INF = 100000000;
bool valid(int x, int l){
    return 0 <= x && x < l;
}
void update(int& x, int y){
    if(x < y) x = y;
}

int main(){
    int H, W;
    while(cin >> H >> W && H > 0){
        string grid[55];
        REP(y, H) cin >> grid[y];

        map< int, vector<pair<int, int>> > jewels;
        REP(y, H) REP(x, W) if(isupper(grid[y][x])) {
            jewels[ grid[y][x] ].push_back(make_pair(x, y));
        }

        static int dp[55][55][55][55] = {};
        memset(dp, -1, sizeof(dp));

        function<int(int, int, int, int)> dfs = [&](int sx, int sy, int gx, int gy){
            if(!valid(sx, W) || !valid(sy, H)) return -INF;
            if(sx > gx || sy > gy) return -INF; // ???
            if(grid[sy][sx] == '#') return -INF;

            if(sx == gx && sy == gy) return 0;

            int& res = dp[sx][sy][gx][gy];
            if(res != -1) {
                return res;
            }
            res = -INF;

            update(res, dfs(sx + 1, sy, gx, gy));
            update(res, dfs(sx, sy + 1, gx, gy));

            if(islower(grid[sy][sx])){
                char c = grid[sy][sx] - 'a' + 'A';
                for(auto p : jewels[c]){
                    int ngx = p.first;
                    int ngy = p.second;
                    if(sx == ngx && sy + 1 == ngy){
                        update(res, 1 + dfs(ngx, ngy, gx, gy));
                    }else if(sy == ngy && sx + 1 == ngx){
                        update(res, 1 + dfs(ngx, ngy, gx, gy));
                    }else if(sx <= ngx && sy <= ngy && ngx <= gx && ngy <= gy){
                        update(res, 1 + dfs(sx + 1, sy, ngx - 1, ngy) + dfs(ngx, ngy, gx, gy));
                        update(res, 1 + dfs(sx + 1, sy, ngx, ngy - 1) + dfs(ngx, ngy, gx, gy));
                        update(res, 1 + dfs(sx, sy + 1, ngx - 1, ngy) + dfs(ngx, ngy, gx, gy));
                        update(res, 1 + dfs(sx, sy + 1, ngx, ngy - 1) + dfs(ngx, ngy, gx, gy));
                    }
                }
            }
            return res;
        };

        int res = dfs(0, 0, W - 1, H - 1);
        if(res < 0) res = -1;
        cout << res << endl;
    }
    return 0;
}

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

using namespace std;
#define ll long long

ll INF = 1e9 + 7;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    string str;
    cin>>str;

    int i=0, j = n-1;
    int swaps = 0;

    while(i <j)
    {
        if(str[i] == 'R')
            i++;
        else if( str[j] == 'W')
            j--;
        else
        {
            swaps++;
            i++;
            j--;
        }
    }

    cout<<swaps<<endl;

    return 0;
}


Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

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

    for (int i = 0; i < s.length(); i++)
    {
        s[i] = 'x';
    }

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
N, K, S = list(map(int, input().split()))

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

for i in range(2, 10**6):
    if gcd(S, i) == 1:
        break

ans = []
ans.extend([S for _ in range(K)])
ans.extend([i for _ in range(N-K)])

ans_str = ""
for j in range(len(ans)):
    ans_str += str(ans[j])
    ans_str += " "
ans_str = ans_str[:len(ans_str) - 1]
print(ans_str)

Measured memory_bytes: 6996