akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    int n;
    while(cin>>n, n){
        int a, b; cin>>a>>b;
        vector<int> p(n);
        for(int i=0; i<n; i++) cin>>p[i];

        int gmin=1e9;
        int ans;
        for(int i=0; i+1<n; i++){
            if(a-1<=i && i<=b-1){
                if(p[i+1]-p[i]<=gmin){
                    gmin=p[i+1]-p[i];
                    ans=i+1;
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3100
N,A,B=map(int,input().split())
S=input()
for i in range(N):
	if S[i]=="a":
		if (A+B)>0:
			print("Yes")
			A-=1
		else:
			print("No")
	if S[i]=="b":
		if (A+B)>0 and B>0:
			print("Yes")
			B-=1
		else:
			print("No")
	if S[i]=="c":
		print("No")


Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  V<> d(m); for (int i = 0; i < m; i++) cin >> d[i];
  V<> dp(n + 1, 1e9);
  dp[0] = 0;
  for (int i = 0; i < m; i++) {
    for (int j = d[i]; j < n + 1; j++) dp[j] = min(dp[j], dp[j - d[i]] + 1);
  }
  cout << dp[n] << '\n';
}


Measured memory_bytes: 3232
from collections import*
I=9**9
(h,w),(s,t),(f,g)=eval('map(int,input().split()),'*3)
m,d=zip(*eval('(input(),[I]*w),'*h))
q=deque([(s-1,t-1,1)])
while q:
 y,x,c=q.popleft()
 if d[y][x]>c:
  d[y][x]=c
  for i in range(y-2,y+3):
   for j in range(x-2,x+3):h>i>-1<j<w<I==d[i][j]!=m[i][j]>'#'!=(abs(y-i)+abs(x-j)<2!=q.appendleft((i,j,c))or q.append((i,j,c+1)))
print(d[f-1][g-1]%I-1)

Measured memory_bytes: 185496
#include<stdio.h>

int main()
{
    int N,K,i,j,temp,c=0;
    int ara[1001];

    scanf("%d %d",&N,&K);

    for(i=0;i<N;i++){
        scanf("%d",&ara[i]);
    }

    for(i=0;i<N;i++){
        for(j=0;j<N-1-i;j++){
            if(ara[j]>ara[j+1]){
                temp = ara[j];
                ara[j] = ara[j+1];
                ara[j+1] = temp;
            }
        }
    }

    for(i=0;i<K;i++){
        c = c + ara[i];
    }
    printf("%d\n",c);

    return 0;
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int mod = 1e9 + 7;
const int maxn = 50;

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

int mul(int a, int b){
	return (ll)a * b % mod;
}

struct Mat{
	int a[maxn][maxn];
	int n;

	Mat(int n){
		int i,j;
		this->n = n;
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				a[i][j] = 0;
			}
		}
	}
	
	Mat operator*(const Mat &b) const {
		int i,j,k;
		Mat c(n);
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				for(k=0;k<n;k++){
					add(c.a[i][j], mul(a[i][k], b.a[k][j]));
				}
			}
		}
		return c;
	}
};

int main(){
	int n;
	ll k;
	scanf("%d %lld",&n,&k);
	int a[55][55];
	int i,j;
	Mat ans(n), ind(n), temp(n);
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			scanf("%d",&a[i][j]);
			temp.a[i][j] = a[i][j];
		}
	}

	for(i=0;i<n;i++){
		ans.a[i][i] = 1;
	}

	while(k) {
		if(k%2){
			ans = ans * temp;
		}
		temp = temp*temp;
		k /= 2;
	}
	int jawab = 0;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			add(jawab, ans.a[i][j]);
			// printf("ans[%d][%d]: %d\n",i,j,ans.a[i][j]);
		}
	}
	printf("%d\n",jawab);
	// naive dp

	// int dp[55][55];

	// for(i=0;i<n;i++){
	// 	dp[i][0] = 1;
	// }

	// for(i=0;i<k;i++){
	// 	for(j=0;j<n;j++){
	// 		for(int m=0;m<n;m++){
	// 			if(a[j][m]){
	// 				add(dp[m][i+1], dp[j][i]);
	// 			}
	// 		}
	// 	}
	// }

	// int ans = 0;
	// for(i=0;i<n;i++){
	// 	add(ans, dp[i][k]);
	// }

	// printf("%d\n",ans);
	return 0;
};

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
	string S;
	cin >> S;
	map<char, int> counter;
	rep(i, S.size())
	{
		counter[S[i]]++;
	}

	int w = counter['W'];
	int e = counter['E'];
	int n = counter['N'];
	int s = counter['S'];

	bool judge1 = false;
	if (w == 0 && e == 0)
	{
		judge1 = true;
	}
	else if (w > 0 && e > 0)
	{
		judge1 = true;
	}

	bool judge2 = false;
	if (n == 0 && s == 0)
	{
		judge2 = true;
	}
	else if (n > 0 && s > 0)
	{
		judge2 = true;
	}

	if (judge1 && judge2)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define sz size()
#define mk make_pair
#define clr clear()
#define B begin()
#define E end()
#define EM empty()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define all(cont) cont.begin(),cont.end()
#define pb push_back
string en="\n";
string t="hello";
#define sqr(a) ((a) * (a))
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    string a,b;
    while(cin>>a>>b)
    {
        bool f=0;
        if(a.sz>b.sz) cout<<"GREATER"<<en;
        else if(a.sz<b.sz) cout<<"LESS"<<en;
        else
        {
            rep(i,a.sz)
            {
                if(a.at(i)>b.at(i))
                {
                    f=1;
                    cout<<"GREATER"<<en;
                    break;
                }
                else if(a.at(i)<b.at(i))
                {
                    f=1;
                    cout<<"LESS"<<en;
                    break;
                }
                else continue;
            }
            if(!f) cout<<"EQUAL"<<en;
        }
    }
}



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

typedef long long int ll;

#define endl '\n'

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


    ll w,h,x,y;

    cin>>w>>h>>x>>y;
    cout<<fixed<<setprecision(10);

    ll c = 0;

    if(w%2 == 0)
    {
        if(x==(w/2))
        {
            c=0;
        }
    }
    if(h%2 == 0)
    {
        if(y==(h/2))
        {
            c = 0;
        }
    }

    if(x==0 and y==0)
        c = 0;

    if(x==w and y==h)
        c = 0;

    if( ((w*1.0)/h) ==  ((x*1.0)/h) )
        c = 0;

    if( (-(w*1.0)/h) == (((x*1.0)-w)/h ))
        c = 0;

    if(h%2 == 0 and w%2==0)
    {

        if(x==(w/2) and y==(h/2))
            c = 1;

    }




    cout<<(w*h*1.0)/2<<" "<<c<<endl;


}


Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
count =0
for i in range(n-1):
    if i + 1 == p[i]:
        c = p[i]
        p[i] = p[i+1]
        p[i+1] = c
        count += 1
if n == p[n-1]:
    c = p[n-1]
    p[n-1] = p[n-2]
    p[n-2] = c
    count += 1
print(count)

Measured memory_bytes: 13880
#include<stdio.h>
#include<stdlib.h>
#define MAX(x, y) (((x) > (y)) ? (x) : (y))

int main() {

	unsigned short *A, *B;

	int n, i;
	scanf("%d", &n);

	A = (unsigned short*)malloc(sizeof(short) * n + 1);
	B = (unsigned short*)malloc(sizeof(short) * n + 1);

	int max = (1<<30)*-1;
	for (i = 0; i < n; i++) {
		scanf("%hu", &A[i+1]);
		max = MAX(max, A[i]);
	}

	int C[max+1] = {0};

	for (i = 0; i < n; i++) C[A[i+1]]++;
	for (i = 1; i <= max; i++) C[i] += C[i-1];

	for (i = n; i >= 1; i--) {
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}

	printf("%d", B[1]);
	for (i = 2; i <= n; i++) {
		printf(" %d", B[i]);
	}
	printf("\n");

	free(A);
	free(B);
	return 0;
}


Measured memory_bytes: 10260
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){

  int n;cin>>n;
  vector<int>p(n+1);
  int cnt=0;
  for(int i=1;i<=n;i++)cin>>p[i];
  for(int i=1;i<n;i++){
    if(p[i]==i){
      swap(p[i],p[i+1]);
      cnt++;
    }
  }
  if(p[n]==n)cnt++;
  cout<<cnt;
  return 0;
}

Measured memory_bytes: 640
base_num = input("")
base_line = input("")
term = base_line.split(' ')

last_num = int(base_num)-1
list_num = list()
for n in term:
    list_num.append(int(n))

list_num.reverse()

for i,r in enumerate(list_num):
    print('{}'.format(r),end='')
    if i != last_num:
        print(' ',end='')

print()



Measured memory_bytes: 5620
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
#include<numeric>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
#define P pair<ll,ll>
ll mod = 1000000007;
P p[200005];
int n, m, c[1005], i, j, k, l, a[1005], b[1005];
vector<int> dp(5000, mod);




int main() {
	cin >> n >> m;
	for (i = 1; i < m + 1; i++) {
		cin >> a[i] >> b[i];
		rep(j, b[i]) {
			cin >> k;
			c[i] += 1 << (k - 1);
		}
	}
	dp[0] = 0;
	for (i = 1; i < m + 1; i++) {
		l = c[i];
		rep(j, 1 << n)	dp[j | l] = min(dp[j | l], dp[j] + a[i]);
	}
	if (dp[(1 << n) - 1] == mod)cout << -1;
	else	cout << dp[(1 << n)-1];
	return 0;
	
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

int main()
{
    long long n;
    std::cin >> n;

    std::string s;
    std::cin >> s;

    std::vector<long long> num_w(n, 0);
    std::vector<long long> num_e(n, 0);

    num_w[0] = s[0] == 'W';
    for (int i = 1; i < n; i++) {
        num_w[i] = num_w[i - 1] + (s[i] == 'W' ? 1 : 0);
    }

    num_e[n - 1] = s[n - 1] == 'E';
    for (int i = n - 2; i >= 0; i--) {
        num_e[i] = num_e[i + 1] + (s[i] == 'E' ? 1 : 0);
    }

    long long min = std::min(num_w[n - 2], num_e[1]);
    for (int i = 1; i < n - 1; i++) {
        min = std::min(min, num_w[i - 1] + num_e[i + 1]);
    }

    std::cout << min << std::endl;
}


Measured memory_bytes: 5380
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

char conv(int n) {
  return 'a' + n;
}

int main()
{
  ll n;
  cin >> n;
  string s = "";
  while(n) {
    n--;
    int r = n % 26;
    s += r + 'a';
    n = n / 26;
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3656
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pll >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 

const ll mod = 1e9+7;
const ll inf=1e18+1e17;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}

const ll N =1e5 + 6;
void solve(){

	ll val=100;
	ll x;
	cin>>x;
	int count=0;
	while ( val<x){
		val=(val+val/100);
		count++;
	}
	cout<<count<<'\n';

}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// #ifndef ONLINE_JUDGE
	// 	freopen ("INPUT.txt" , "r" , stdin);
	// 	freopen ("OUTPUT.txt", "w" , stdout);
	// #endif	
    ll t=1;
	//cin>>t;
    for (ll i=1;i<=t;i++){
    //	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}

Measured memory_bytes: 3636
/* * * * * * * * * * * **
*                      *
*	   saurabh8522	   *
*	  I will handle	   *
*		   IT.		   *
*                      *
* * * * * * * * * * * **/
#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ld long double
#define zero(a) memset((a),0,sizeof((a)))
#define one(a) memset((a),1,sizeof((a)))
#define minus(a) memset((a),-1,sizeof((a)))
#define all(g) g.begin(),g.end()
#define ppb pop_back
using namespace std;
typedef long long int ll;
#define MOD 1000000007
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll numdigit(ll n){return floor(log10(n)) + 1;}
bool isPowerTwo (ll x) { return x && (!(x&(x-1))); } 
int  main(){
	FastRead;
	ll t=1;
	// cin>>t;
	while(t--){
		ll n;
		cin>>n;
		ll arr[n][n];
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cin>>arr[i][j];
			}
		}
		ll pre[1<<n];
		zero(pre);
		for(int i=0;i<(1<<n);i++){
			for(int j=0;j<n;j++){
				for(int k=j+1;k<n;k++){
					if((i&(1<<j))&&((i&(1<<k)))){
						// cout<<i<<" "<<j<<" "<<k<<endl;
						pre[i]+=arr[j][k];
					}
				}
			}
		}
		ll dp[1<<n];
		zero(dp);
		for(int i=0;i<(1<<n);i++){
			dp[i]=pre[i];
			for(int s=i;s>0;s=(s-1)&i){
				dp[i]=max(dp[i],dp[i^s]+pre[s]);
			}
		}
		cout<<dp[(1<<n)-1]<<endl;
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;
const int MOD = 1000000007;
struct edge{
    int from;
    int to;
    int cost;
};
signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    vector <edge> edges(m);
    vector <vector<int>> g(105,vector <int>());
    vector <vector<int>> d(105,vector <int>(105, INF));
    vector <vector<bool>> cone(1010,vector <bool>(1010));
    rep(i,m){
        int a,b,c; cin>>a>>b>>c;
        a--; b--;
        edges[i] = {a,b,c};
        d[a][b] = d[b][a] = c;
        cone[b][a]=cone[a][b]=true;
    }
    rep(i,n) d[i][i] = 0;
    vector <vector<bool>> path(1010,vector <bool>(1005));
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(d[i][j] >= d[i][k] + d[k][j]){
                    d[i][j]=d[i][k]+d[k][j];
                }
            }
        }
    }
    int ans = 0;
    rep(k,m){
        bool ok = false;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(d[i][j] == d[i][edges[k].from] + edges[k].cost + d[edges[k].to][j]) ok = true;
            }
        }
        if(!ok) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 768
n = int(input())
t, a = map(int,input().split())
h = list(map(int, input().split()))

def T(x):
  return t - x*0.006

lis = []
for i in range(n):
  lis.append(abs(a-T(h[i])))
print(1+lis.index(min(lis)))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ll long long
#define X first
#define Y second
#define pb push_back
#define E Maxke_pair
#define pii pair<int, int>
#define ls rt << 1
#define rs rt << 1 | 1
#define sz(x) (int)(x).sze()
#define ALL(x) (x).insgin(), (x).end()
#define vi vector<int>
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int mod = 1e9 + 7;
const int INF = 1e9 + 7;
const int N = 110;
const int M = 2e6 + 10; 
int m,n,a[N][N],b[N][N]; 
bool vis[N][N];
int main()
{
	m = read();
	n = read();
	rep(i, 1, m)
		rep(j, 1, n)
			a[i][j] = read();
	rep(i, 1, m)
		rep(j, 1, n)
			rep(x, 0, 100)
				rep(y, 0, 100)
					b[x][y] = max(b[x][y], a[i][j] - i * x - j * y);
	rep(i, 1, m)
		rep(j, 1, n)
			rep(x, 0, 100)
				rep(y, 0, 100)
					if (b[x][y] == a[i][j] - i * x - j * y) vis[i][j] = 1;

	rep(i, 1, m)
		rep(j, 1, n)
			if(!vis[i][j]) 
			{
				puts("Impossible");
				return 0;
			}
	puts("Possible");
	printf("202 %d\n", 200 + 101 * 101);
	rep(i, 1, 100) printf("%d %d X\n", i, i + 1);
	rep(i, 102, 201) printf("%d %d Y\n",i + 1, i);
	rep(i, 0, 100)
		rep(j, 0, 100) 
			printf("%d %d %d\n", i + 1, j + 102, b[i][j]);
	puts("1 102");
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
 
int main (void) {
  int a, b, t;
  int n;
  
  do {
    scanf("%d %d %d", &a, &b, &t);
  } while(!(0<=a && a<=20 && 0<=b && b<=20 && 0<=t && t<=20)); {
    scanf("%d %d %d", &a, &b, &t);
  }
  n = t / a;
  printf("%d\n", b * n);
  
  return 0;
}

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

int main(){
    int n; 
    cin >> n;
    vector<int> data(n);
    int i, j, k;
    for(i = 0; i < n; i++){
        cin >> data.at(i);
    }
    int ans = 1000000;
    int sum = 0;
    for(i = 0; i < 101; i++){
        for(j = 0; j < n; j++){
            sum += (data.at(j)-i)*(data.at(j)-i);
        }
        if(sum < ans){
            ans = sum;
        }
        sum = 0;
    }
    cout << ans << endl;
    return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

int main() {
    vector<int> res;
    while (true) {
        double a, b;
        int x;
        cin >> a >> b >> x;
        if (a == 0) break;
        int ma = -1;
        for (int i = 1; i < x - 1; i++) {
            for (int j = i; j < x; j++) {
                int p = (double)i * (100.0 + a) / (100.0);
                int q = (double)j * (100.0 + a) / (100.0);
                if (p + q == x) {
                    int pp = (double)i * (100.0 + b) / (100.0);
                    int qq = (double)j * (100.0 + b) / (100.0);
                    ma = max(ma, pp + qq);
                }
            }
        }        
        res.push_back(ma);
    }
    for (int i = 0; i < (int)res.size(); i++) {
        dump(res[i]);
    }
    return 0;
}



Measured memory_bytes: 3224
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

const double EPS=(1e-10);
typedef long long ll;
typedef pair<int,int> pii;
bool EQ(double a,double b){
  return abs((a)-(b))<EPS;
}
void fast_stream(){
	std::ios_base::sync_with_stdio(0);
}

int dp[5001][5001][4];
int sa[5001];
int sb[5001];
int A,B;

int calc(){
    for(int posa=A;posa>=0;posa--){
        for(int posb=B;posb>=0;posb--){
            for(int fg=3;fg>=0;fg--){
                int res=0;
                if(posa==A||posb==B)res=0;
                else{
                    // mem
                    if(fg==0){
                        // ÂÃªÂvÂÂµÂÂ½ÂÃÂÃÂÃÂÃÂÂ¸ÂÃÂÃ¦ÂÃÂÃÂÂ¨ÂÂ­
                        if(sa[posa]==sb[posb])res=max(res,dp[posa+1][posb+1][2]+1);
                        // ÂÂ ÂÃ±ÂÃÂÃÂRÂÃ°ÂÃÂÃÂÃ©
                        res=max(res,dp[posa+1][posb][fg]);
                        // ÂuÂÂÂ[ÂmÂÃÂRÂÃ°ÂÃÂÃÂÃÂÂ©ÂÂ©ÂÃ©
                        res=max(res,dp[posa][posb][fg+1]);
                    }
                    else if(fg==1){
                        // 1ÂÂÂuÂÂÂ[ÂmÂÃÂRÂÃ°ÂÃÂÃÂÃ©
                        res=max(res,dp[posa][posb+1][fg]);
                        // ÂÂ ÂÃ±ÂÃÂÃÂRÂÃ°ÂÃÂÃÂÃ©
                        res=max(res,dp[posa+1][posb][fg]);
                        // ÂÃÂÃÂÃÂÂ¢
                        res=max(res,dp[posa][posb][fg+1]);
                    }
                    else if(fg==2){
                        // ÂÃªÂvÂÂµÂÂ½ÂÃÂÃÂÃÂÃÂÂ¸ÂÃÂÃ¦ÂÃÂÃÂÂ¨ÂÂ­
                        if(sa[posa]==sb[posb])res=max(res,dp[posa+1][posb+1][fg]+1);
                        // ÂÂ ÂÃ±ÂÃÂÃÂRÂÃ°ÂÃÂÃÂÃ©
                        res=max(res,dp[posa+1][posb][fg]);
                        // modeÂÃ°ÂÃÂÂ¦ÂÃ©ÂÂ¾ÂÂ¯
                        res=max(res,dp[posa][posb][fg+1]);
                    }
                    // ÂuÂÂÂ[ÂmÂÃÂRÂÂ©ÂÃ§ÂcÂÃ¨ÂÃ°ÂÂ·ÂÃÂÃÂÃÂÃÂÃ©
                    else{
                        res=max(res,dp[posa][B][fg]);
                    }
                }
                dp[posa][posb][fg]=res;
            }
        }
    }
    return dp[0][0][0];
}
void solve(){
    cin>>A>>B;
    for(int i=0;i<A;i++)cin>>sa[i];
    for(int i=0;i<B;i++)cin>>sb[i];
    int res=calc();
    cout<<res<<endl;
}
int main(){

    solve();

    return 0;
}

Measured memory_bytes: 0
import math

n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
ansp = 0
ansq = 0
for i in range(n):
    ansp += (p[i]-1)*(math.factorial(n-i-1))
    #print((p[i]-n-1))
    #print(ansp)
    for j in range(i+1,n):
        if p[j] > p[i]:
            p[j] -= 1
for i in range(n):
    ansq += (q[i]-1)*(math.factorial(n-i-1))
    for j in range(i+1,n):
        if q[j] > q[i]:
            q[j] -= 1

print(abs(ansp-ansq))

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<algorithm>


using namespace std;
int n;
int a[100];
int main(){
  cin>>n;
  for(int i = 0;i<n;i++){
    cin>>a[i];
  }
  int ans = 111111111;
  for(int i = -100;i<=100;i++){
    int tmp = 0;
    for(int p = 0;p<n;p++){
      tmp += (a[p]-i)*(a[p]-i);
    }
    ans = min(ans,tmp);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    private static final PrintStream so = System.out;
    private static final Scanner     sc = new Scanner(System.in);

    public static void main(String[] args) {
         int n = sc.nextInt();
         int[] a = new int[n*2];
         for (int i = 0 ; i < n*2; i++) {
             a[i] = sc.nextInt();
         }
         
         
         Arrays.sort(a);
         int sum = 0;
         for (int i = 0; i < n*2; i += 2) {
             sum += a[i];
         }
         so.println(sum);
    }
}


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

int main(){
  int num,a[4]={};
  char c;
  string s,b[4]={"A","B","AB","O"};

  while(cin>>num>>c>>s){
    for(int i=0;i<4;i++)
      if(s==b[i]) 
	a[i]++;
  }
  for(int i=0;i<4;i++)
    cout<<a[i]<<endl;
 return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    int n, k;
    cin >> n >> k;

    cout << n - k + 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int a,b,c,d;
	int ans=0;
	cin >>a>>b>>c>>d;
	if(a+b >c+d){
	cout<<"Left"<<endl;
	}else if(a+b==c+d){
		cout<<"Balanced"<<endl;
	}else{
		cout<<"Right"<<endl;
	}
	}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int n,p[1000000];
main(){
	for(int i=0;i<1000000;++i)p[i]=1;
	p[0]=0;
	p[1]=0;
	for(int i=2;i<1000000,i*i<1000000;++i){
		for(int j=2;j<1000000;++j){
			if(p[i]==0)break;
			if(j%i==0 && i!=j)p[j]=0;
		}
	}
	while(cin>>n){
		int sum=0;
		for(int i=0;i<=n;++i)if(p[i]==1)++sum;
		cout<<sum<<endl;
	}
}

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

using namespace std;
using ll = long long;

ll f(ll n) {
  if ((n + 1) % 2 == 0)
    return ((n + 1) / 2) % 2;
  else
    return f(n + 1) ^ (n + 1);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll A, B;
  cin >> A >> B;
  cout << (f(A - 1) ^ f(B)) << '\n';
  return 0;
}


Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
  int A,B;
  cin >> A >> B;
  if(A%2==1&&B%2==1) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  ll a,b,c;
  while(input(a,b,c)) {
    ll t = c-a-b;
    if (t < 0) puts("No");
    else {
      puts(4*a*b < t*t ? "Yes" : "No");
    }
  }
}


Measured memory_bytes: 256
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

int a[1 << 17],b[1 << 17];

char ask(int x)
{
    cout << x << endl;
    string s;
    cin >> s;
    return s[0];
}

char tmp[1 << 17];

int32_t main(){_
    //freopen("input","r",stdin);
    int n;
    cin >> n;
    string s,ss;
    int l = 0;
    int r = n - 1;
    tmp[l] = ask(l);
    tmp[r] = ask(r);
    if(tmp[l] == 'V') rc(l << endl);
    if(tmp[r] == 'V') rc(r << endl);
    while(l < r)
    {
        if(tmp[l] == 'V') rc(l << endl);
        if(tmp[r] == 'V') rc(r << endl);
        int mid = l + r >> 1;
        tmp[mid] = ask(mid);
        if(tmp[mid] == 'V') rc(mid << endl);
        if((tmp[mid] == tmp[l]) && ((mid - l) % 2 != 0) || ((tmp[mid] != tmp[l]) && ((mid - l) % 2 == 0)))
        {
            r = mid;
        }
        else l = mid;
    }
    rc(l << endl);
}

Measured memory_bytes: 852
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
ll h, w, n;
vector<ll>x, y;
struct A {
	ll x1, y1, x2, y2;
};
struct P {
	ll x, y;
};
vector<A>v;
bool a[3000][3000];
int main() {
	while (cin >> w >> h&&w != 0 && h != 0) {
		cin >> n;
		x.clear();
		y.clear();
		v.clear();
		x.push_back(0);
		y.push_back(0);
		x.push_back(h);
		y.push_back(w);
		for (int i = 0; i < n; i++) {
			ll x1, x2, y1, y2;
			cin >> y1 >> x1 >> y2 >> x2;
			x.push_back(x1);
			x.push_back(x2);
			y.push_back(y1);
			y.push_back(y2);
			v.push_back(A{ x1,y1,x2,y2 });
		}
		sort(x.begin(), x.end());
		sort(y.begin(), y.end());
		for (ll i = 0; i < x.size()-1; i++) {
			for (ll j = 0; j < y.size()-1; j++)
				a[i][j] = true;
		}
		for (int z = 0; z < n; z++) {
			int p, q, r, s;
			p = lower_bound(x.begin(), x.end(), v[z].x1) - x.begin();
			q = lower_bound(y.begin(), y.end(), v[z].y1) - y.begin();
			r = upper_bound(x.begin(), x.end(), v[z].x2) - x.begin()-1;
			s = upper_bound(y.begin(), y.end(), v[z].y2) - y.begin()-1;
			for (ll i = p; i < r; i++) {
				for (ll j = q; j < s; j++)
					a[i][j] = false;
			}
		}
		int sum = 0;
		for (int i = 0; i < x.size()-1; i++) {
			for (int j = 0; j < y.size()-1; j++) {
				if (a[i][j]) {
					sum++;
					queue<P>p;
					p.push(P{ i,j });
					a[i][j] = false;
					while (!p.empty()) {
						P t = p.front(); p.pop();
						if (t.x + 1 < x.size()-1 && a[t.x + 1][t.y]) {
							a[t.x + 1][t.y] = false;
							p.push(P{ t.x + 1,t.y });
						}
						if (t.x - 1 >= 0 && a[t.x - 1][t.y]) {
							a[t.x - 1][t.y] = false;
							p.push(P{ t.x - 1,t.y });
						}
						if (t.y + 1 < y.size()-1 && a[t.x][t.y + 1]) {
							a[t.x][t.y + 1] = false;
							p.push(P{ t.x,t.y + 1 });
						}
						if (t.y - 1 >= 0 && a[t.x][t.y - 1]) {
							a[t.x][t.y - 1] = false;
							p.push(P{ t.x,t.y - 1 });
						}
					}
				}
			}
		}
		cout << sum << endl;
	}
}

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

using namespace std;
typedef long long LL;

int main(){
  string N;
  cin >> N;
  int A[5];
  rep(i,4) A[i]=N[i]-'0';
  rep(bit,8){
    int sum=A[0];
    rep(i,3){
      if(bit&(1<<i)) sum+=A[i+1];
      else sum-=A[i+1];
    }
    if(sum==7){
      string M;
      rep(i,3){
        if(bit&(1<<i)) M.push_back('+');
        else M.push_back('-');
      }
      M.push_back('=');
      rep(i,4) cout << A[i] << M[i];
      cout << 7 << endl;
      return 0;
    }
  }

  return 0;
}


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

#define INTFY (1 << 30)

int A[2000000],N = 0;

void maxheapify(int i,int H) {
  int l,r,largest;
  l = 2 * i;
  r = 2 * i + 1;
  if(l <= H && A[l] > A[i]) {
    largest = l;
  }else {
    largest = i;
  }

  if(r <= H && A[r] > A[largest]) {
    largest = r;
  }

  if(largest != i) {
    swap(A[i],A[largest]);
    maxheapify(largest,H);
  }
}

void heapIncreaseKey(int i,int key) {
  if(A[i] > key)  return;
  A[i] = key;
  while(i > 1 && A[i] > A[i /2]) {
    swap(A[i],A[i / 2]);
    i /= 2;
  }
}

void insert(int key) {
 N++;
 A[N] = -INTFY;
 heapIncreaseKey(N,key);
}



int heapExtractMax(int A[]) {
  if(N < 1) return -INTFY;
  int max = A[1];
  A[1] = A[N];
  N--;
  maxheapify(1,N);

  return max;
}



int main() {

string S;
while(1) {
  cin >> S;
  if(S == "insert") {
    int k;
    cin >> k;
    insert(k);
  }else if(S == "extract") {
    int ans = heapExtractMax(A);
    cout << ans << endl;
  }else break;
}

}


Measured memory_bytes: 7112
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)

#define eb emplace_back
#define pb pop_back
#define mp make_pair
#define fi first
#define se second
#define sz(xs) ((int)(xs).size())
#define all(xs) xs.begin(),xs.end()
#define lla(xs) xs.rbegin(),xs.rend()
#define sortup(xs) sort(all(xs))
#define sortdown(xs) sort(lla(xs))
#define reverse(xs) reverse(all(xs))
template<class C>void mini(C &a,C b){a=min(a,b);}
template<class C>void maxi(C &a,C b){a=max(a,b);}
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__)
#define out(...) _cout(__VA_ARGS__)
void _cin(){}template<class Head,class...Tail>void _cin(Head&&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
void _cout(){}template<class Head,class...Tail>void _cout(Head&&head,Tail&&...tail){cout<<head<<endl;_cout(forward<Tail>(tail)...);}
template<class Type>void _cinvec(Type t,int n){}template<class Type,class Head,class...Tail>void _cinvec(Type t,int n,Head&&head,Tail&&...tail){rep(n){cin>>t;head.eb(t);}_cinvec(t,n,forward<Tail>(tail)...);}

#define VI vector<int>
#define VD vector<double>
#define VS vector<string>
#define VVI vector<VI>
#define VVD vector<VD>
#define VVS vector<VS>

#define int int64_t
// #define double long double

// map,文字列処理


signed main(){
  in(int,x,y,z,k);
  VI a(x);fou(i,0,x)cin>>a[i];
  VI b(y);fou(i,0,y)cin>>b[i];
  VI c(z);fou(i,0,z)cin>>c[i];
  sortdown(a);
  sortdown(b);
  sortdown(c);
  VI ab(x*y);
  fou(i,0,x){
    fou(j,0,y){
      ab[i*y+j]=a[i]+b[j];
    }
  }
  sortdown(ab);
  rep(x*y-k) ab.pb();
  VI abc(min(x*y,k)*z);
  fou(i,0,min(x*y,k)){
    fou(j,0,z){
      abc[i*y+j]=ab[i]+c[j];
    }
  }
  sortdown(abc);
  fou(i,0,k)out(abc[i]);
}

Measured memory_bytes: 31616
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


# nが素数か判定する
def is_prime(n):
    if n == 1:
        return False
    for k in range(2, int(pow(n, 0.5)) + 1):
        if n % k == 0:
            return False
    return True


def resolve():
    n = int(input())
    primes = []
    for i in range(1, 55556):
        if i % 5 == 1 and is_prime(i):
            primes.append(i)
            if len(primes) == n:
                break
    print(*primes)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9316
#include <stdio.h>

int main()
{
    char k[1000];
    int sum, i;

    while(1)
    {
        scanf("%s", k);
        if(k[0] == '0') break;
        for(i = 0, sum = 0; k[i] != '\0'; i++)
        {
            sum += (k[i] - '0');
        }
        printf("%d\n", sum);
    }

    return 0;
}

Measured memory_bytes: 536
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
double pi = 3.1415926535;

void solve(){
	long double a , b, h, m;
	cin >> a >> b >> h >> m;
	long double hour_angle = 0.5 * (h * 60 + m);
	long double minute_angle = 6.0 * m;
	long double angle = abs(hour_angle - minute_angle);
	//angle = min(360 - angle, angle);
	//angle = 0.0174533 * angle;
	long double ans = (a * a) + (b * b)- ((2 * a * b ) * cos(angle * pi/ 180));
	ans = sqrt(ans);
	printf("%0.10Lf\n", ans);
}

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
}


Measured memory_bytes: 4176
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
 
int main(){
    string s;
    cin >> s;
    
    if(s[0]=='7' || s[1]=='7' || s[2]=='7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3572
#include <stdio.h>

int main(void)
{
  int a,b,c;
  int s;
  int i;


  s=0;

  scanf("%d %d %d",&a,&b,&c);

  
  for(i = a ; i <= b ; i++)
    {
      
       if( c%i == 0 )
	{
	  s++;
	}
    }

  printf("%d\n",s);
  
  return 0;
}

	  



Measured memory_bytes: 2084
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    int A[N][M];
    REP(int,i,0,N){
        cin >> C.at(i);
        REP(int,j,0,M) cin >> A[i][j];
    }
    int ans = INT_MAX;
    for ( int tmp = 0; tmp < ( 1 << N ); tmp++ ){
        bitset<12> s(tmp);
        vector<int> Score(M);
        int Money = 0;
        REP(int,i,0,M) Score.at(i) = 0;
        REP(int,i,0,N){
            if ( s.test(i) ){
                REP(int,j,0,M) Score.at(j) += A[i][j];
                Money += C.at(i);
            }
        }
        bool Flag = true;
        REP(int,i,0,M){
            if ( Score.at(i) < X ) Flag = false;
        }
        if ( Flag ) ans = min(ans,Money);
    }
    if ( ans == INT_MAX ) ans = -1;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double 

int f(int x, int d) {
	return x/d;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int l, r, d;
	cin>>l>>r>>d;
	int w = f(r, d);
	if(l != 1)
		w-=f(l-1, d);
	cout<<w;
}


Measured memory_bytes: 3540
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A__Placing_Marbles
{
    class Program
    {
        static void Main(string[] args)
        {
            long a = long.Parse(ReadLine());
            long[] n = new long[a];
            long sum = 0;
           
            for (int i=0;i<a; i++) {
                n[i] = i + 1;
                if (n[i] % 3 == 0 || n[i] % 5 == 0)
                {
                    n[i] = 0;
                }
                
            }
            for (int j = 0; j < a; j++) {
                sum += n[j];
            }
            WriteLine("{0}",sum);
        }
    }
}


Measured memory_bytes: 35036
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int K, T;
  cin >> K >> T;
  int a[T];
  for(int i = 0; i < T; i++) cin >> a[i];

  int mx = *max_element(a, a + T);
  int rest = K - mx;

  cout << max(0, mx - rest - 1) << endl;
  return 0;

}


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

int main() {
	char a,b,c,d;
	scanf("%c %c %c %c", &a, &b, &c, &d);
	if ((a==b)||(b==c)||(c==d)) {
		printf("Bad\n");
	}else{
		printf("Good\n");
	}
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main() {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)


def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ca, cb = [], []
    for i in range(n):
        if b[i] - a[i] > 0:
            ca.append(b[i] - a[i])
        elif b[i] - a[i] < 0:
            cb.append(-b[i] + a[i])

    if len(ca) == n:
        print(0)
        exit()

    cb = sorted(cb, reverse=True)
    ans = 0
    casum = sum(ca)
    for i in range(len(cb)):
        if casum <= 0:
            break
        casum -= cb[i]
        ans += 1

    if casum > 0:
        print(-1)
        exit()

    print(ans + len(ca))


if __name__ == '__main__':
    main()


Measured memory_bytes: 75952
"A Frog"
N = int(input())  # N個の足場
HHH = list(map(int, input().split()))  # 足場の高さ, N個, 最初は足場1にいる

dp = [1e7]*N

# dp配列の初期化
dp[0] = 0
dp[1] = abs(HHH[1]-HHH[0])

for i in range(2, len(HHH)):
    # 1段前から来るパターン, 2段前から来るパターン
    dp[i] = min(dp[i-1] + abs(HHH[i]-HHH[i-1]), dp[i-2] + abs(HHH[i]-HHH[i-2]))

print(dp[-1])


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

using namespace std;
#define BUF (100005)
#define ll long long 
#define INF (1000000005)
int n,m;
int used[BUF];
int cnt;
ll ans;
ll cost[BUF];

vector<int> v[BUF];

ll m1cost;
int m1node;
ll m2cost;

ll treec1[BUF];
ll treen1[BUF];

vector<ll> cost2;

void dfs(int node){
	used[node]=1;
	if(m1cost>cost[node]){
		m1cost=cost[node];
		m1node = node;
	}
	for(auto x: v[node]){
		if(used[x]==0) dfs(x);
	}

	return;
}

int main(void){
	cin >> n >> m;
	for(int i=0;i<n;i++) cin >> cost[i];
	for(int i=1;i<=m;i++){
		int x,y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}

	for(int i=0;i<n;i++){
		if(used[i]==0){
			m1cost=INF;
			dfs(i);
			treec1[cnt]=m1cost;
			treen1[cnt]=m1node;
			cnt++;
		}
	}

	if(cnt==1){
		cout << "0\n";
		return 0;
	}

	for(int i=0;i<cnt;i++){
		ans+=treec1[i];
	}

	for(int i=0;i<cnt;i++){
		cost[treen1[i]]=INF;
	}
	sort(cost,cost+n);
	for(int i=0;i<cnt-2;i++){
		if(cost[i]==INF){
			cout << "Impossible\n";
			return 0;
		}
		ans+=cost[i];
	}
	
	cout << ans << "\n";
	return 0;
}


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

int main(){
  string S;
  cin >> S;
  
  for (int tmp = 0; tmp < (1 << 3); tmp++){
    bitset<3> s(tmp);
    int sum = S.at(0) - '0';
    for (int i = 0; i < 3; i++){
      if(s.test(i)){
        sum += S.at(i+1) - '0';
      } else {
        sum -= S.at(i+1) - '0';
      }
    }
    if (sum == 7){
      cout << S.at(0);
      for (int i = 0; i < 3; i++){
        if(s.test(i)){
          cout << "+";
        } else {
          cout << "-";
        }
        cout << S.at(i+1);
      }
      cout << "=7";
      break;
    }
  }
  
}

Measured memory_bytes: 256