akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        cout << n << " ";  
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
 //  freopen("input.txt","r",stdin);
    long long int n1,m1,t;
 //   cin>>t;
   t=1;
    while(t--)
    {
   long long int i,j;
 //long long int b[1000000];
 //set<long long int >s;
       long long int f=1,p=0,z,o=0;
       double pie=3.141592653589793238;
    long long int c=0,n,m,l=0,r=0,k,min1=10000000000000,max2=-100;
 cin>>n;
 long long int a[n],b[n];
 for(i=0;i<n;i++)
 {
 cin>>a[i];
 b[i]=a[i];
}
 sort(a,a+n);
 p=a[n/2];
 l=a[n/2-1];
 if(p==l)
 {
 	for(i=0;i<n;i++)
 	cout<<p<<"\n";
 }
 else
 {
 	for(i=0;i<n;i++)
 	
 	if(b[i]<=l)
 	cout<<p<<"\n";
 	else if(b[i]>=p)
 	cout<<l<<"\n";
 }

 //cout<<min1;
 }
 
 //vector<pair<long long int,long long int>>v;
 
    
 return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    ll h, n;
    cin >> h >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    vector<vector<ll>> dp(n, vector<ll>(h + 10001, 1e9));
    for (int i = 0; i < n; ++i) {
        dp[i][0] = 0;
    }
    for (int j = 1; j <= h + 10000; ++j) {
        dp[0][j] = ((j + a[0] - 1) / a[0]) * b[0];
        for (int i = 1; i < n; ++i) {
            dp[i][j] = dp[i - 1][j];
            if (a[i] <= j) {
                dp[i][j] = min(min(dp[i][j], dp[i - 1][j - a[i]] + b[i]), dp[i][j - a[i]] + b[i]);
            }
        }
    }
    ll ans = 1e9;
    for (int j = h; j <= h + 10000; ++j) {
        ans = min(ans, dp[n - 1][j]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 160512
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")
MOD = 1000000007


def main():
    N, K = map(int, input().split())

    ans = 0
    sum_min = sum([i for i in range(K)])
    sum_max = sum([i for i in range(N-K+1, N+1)])
    l = K - 1
    r = N - K + 1
    while l <= N:
        ans += sum_max - sum_min + 1
        ans %= MOD
        l += 1
        r -= 1
        sum_min += l
        sum_max += r
    
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 99816
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void D();

int main()
{
	D();
	fflush(stdout);
	return 0;
}

static void D()
{
	int N, K;
	get(N, K);

	std::vector<LLONG> hi(N);
	for (int i = 0; i < N; i++) {
		get(hi[i]);
	}

	std::sort(hi.begin(), hi.end());
	LLONG ans = 0;
	for (int i = 0; i < N - K; i++) {
		ans += hi[i];
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
int dp[N],h[N],n,k;
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++) scanf("%d",&h[i]);
	memset(dp,0x3f,sizeof(dp));
	dp[1]=0;
	for (int i=2;i<=n;i++){
		for (int j=i-1;j>=i-k && j;j--)
			dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
	} 
	printf("%d\n",dp[n]);
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A,B,X,num;
        A=sc.nextInt();
        B=sc.nextInt();
        X=sc.nextInt();
        num=X-A;
        if(num<0) System.out.println("NO");
        else if(num>B) System.out.println("NO");
        else System.out.println("YES");

    }
}


Measured memory_bytes: 23252
/*
	written by Pankaj Kumar.
	country:-INDIA
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef set<pair<int,int>> spi;
typedef set<pair<ll,ll>> spl;
typedef vector<pair<int,int>> vpi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vpl;
typedef vector<string> vs;
typedef map<int,int>m;
typedef set<string> ss;
typedef set<int> si;
typedef set<ll> sl;
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
// define values.
#define mod 1000000007;
#define phi 1.618
/* Bit-Stuff */
#define get_set_bits(a) (__builtin_popcount(a))
#define get_set_bitsll(a) ( __builtin_popcountll(a))
#define get_trail_zero(a) (__builtin_ctz(a))
#define get_lead_zero(a) (__builtin_clz(a))
#define get_parity(a) (__builtin_parity(a))
/*  Abbrevations  */
#define ff first
#define ss second
#define mp make_pair
#define line cout<<endl;
#define pb push_back
// function
ll power(ll x,ll y)
{
	ll res=1;
	while(y>0)
	{
		if(y%2==1)res*=x;
		y/=2; x*=x;
	}
	return res;
}
/* ascii value 
A=65,Z=90,a=97,z=122
*/
/*  ---------------------------------MAIN-------------------------------------------*/

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

Measured memory_bytes: 3580
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
  static void Main(string[] args)
  {
    int a = int.Parse(Console.ReadLine());
    string rtn="NO";
    if(a==7 || a==5 || a==3){
      rtn="YES";
    }
    
    Console.WriteLine(rtn);
  }
}

Measured memory_bytes: 11092
n, k = map(int, input().split())
n = n % k
if abs(n - k) > abs(k - n):
    if n > abs(k - n):
        print(abs (k - n))
    else:
        print(n)  
else:
    if n > abs(n - k):
        print(abs (n - k))
    else:
        print(n)   


Measured memory_bytes: 2940
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 55;
const ll mm = 1e+18;
void solve()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    rep0(i,n) cin>>a[i];
    repp(i,k,n){
        if(a[i]>a[i-k]) cout<<"Yes\n";
        else cout<<"No\n";
    }
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // freopen("sp.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 5224
S = list(input())
N = len(S)

# n文字まで見て最後が1文字か2文字化
dp_1 = [0] * N
dp_2 = [0] * N
dp_1[0] = 1
dp_2[1] = 1
if S[0] != S[1]:
    dp_1[1] = 2


for i, s in enumerate(S[2:], 2):
    # dp_1
    # 2 -> 1
    tmp = dp_2[i - 1] + 1
    # 1 -> 1
    if S[i - 1] != S[i]:
        tmp = max(tmp, dp_1[i - 1] + 1)
    dp_1[i] = tmp

    # dp_2
    # 1->2
    tmp = dp_1[i - 2] + 1
    # 2->2
    if S[i - 3 : i - 1] != S[i - 1 : i + 1]:
        tmp = max(tmp, dp_2[i - 2] + 1)
    dp_2[i] = tmp

print(max(dp_1[-1], dp_2[-1]))


Measured memory_bytes: 22064
#include<bits/stdc++.h>
#define ll   long long int  
#define pb push_back
const int M=1e9 + 7;
using namespace std;
int N=1000000+1;
void dfs(vector<int>* g,int st,bool* visited,vector<int>* ts)
{
	visited[st]=true;
	for(int i=0;i<g[st].size();i++)
	{
		if(visited[g[st][i]]==false)
		{
			dfs(g,g[st][i],visited,ts);
		}
	}
	ts->pb(st);
}
int logestPath(vector<int>* g,vector<int>* ts,int n,int m)
{
	int* dp=new int[n+1];
	for(int i=0;i<=n;i++)
	{
		dp[i]=0;
	}
	int tss=ts->size();
	dp[ts->at(tss-1)]=0;
//	for(int i=0;i<tss;i++)
//	{
//		cout<<ts->at(i)<<" ";
//	}
//	cout<<endl;
	for(int i=tss-1;i>=0;i--)
	{
		int curVertex=ts->at(i);
		//cout<<curVertex<<" ";
		for(int j=0;j<g[curVertex].size();j++)
		{
			dp[curVertex]=max(dp[curVertex],1+dp[g[curVertex][j]]);
		}
		//cout<<curVertex<<" "<<dp[curVertex]<<" ";
	}
	//cout<<endl;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,dp[i]);
	}
	return ans;
}
int main() {
   
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m;cin>>n>>m;
    vector<int>* g=new vector<int>[n+1];
    for(int i=1;i<=m;i++)
    {
    	int u,v;cin>>u>>v;
    	g[u].pb(v);
	}
	bool* visited=new bool[n+1]();
	//memset(visited,0,n+1);
	vector<int>* ts=new vector<int>();
	int ans=0;
	//cout<<"BREAKING POINT-1"<<endl;
	for(int i=1;i<=n;i++)
	{
		if(visited[i]==false){
			//ts=new vector<int>();
			dfs(g,i,visited,ts);
			
		}
	}
	reverse(ts->begin(),ts->end());
	ans=max(ans,logestPath(g,ts,n,m));
	cout<<ans<<endl;
	return 0;
}
 
 
 
 
 

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 1005;

int n;

int main() {

	FAST;

	intt x;
	cin >> x;
	double k = 100.0;
	for (int i = 1; ; i ++) {
		k *= 1.01;
		k = 1.0 * (intt)(k);
		if (k >= x) {
			cout << i << '\n';
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3636
// Date: 2020-03-07

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int main() {
    string s; cin >> s;
    int f = 0;
    if(s[0] != s[1] || s[1] != s[2]) f = 1;
    puts(f ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}


int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

//#############################
const int MAXN = 1000005;

ll fact[MAXN], inv[MAXN];
const ll MOD = (1e9+7);

ll mult(ll a, ll b) {
    return ((a%MOD) * (b%MOD)) % MOD;
}

ll sum(ll a, ll b) {
    return ((a%MOD) + (b%MOD) + MOD) % MOD;
}

ll my_pow (ll a, ll e) {
    if (e == 0) 
        return 1;
    else if (e % 2 == 0) {
        ll r = my_pow(a, e/2);
        return mult(r, r);
    }
    else
    {
        return mult(my_pow(a, e-1), a);
    }
}

ll mod_inv(ll a) {
    return my_pow(a, MOD-2);
}

ll comb(ll n, ll k){
    if (k > n)
        return 0;
    return mult(fact[n], mod_inv(mult(fact[n-k], fact[k])));
}

int main() {
    ll n,k;
    vector<ll> a;
    cin >> n >> k;

    ll x;
    for (int i = 0; i < n; i++) 
        cin >> x, a.pb(x);

    fact[0] = fact[1] = 1;
    for (int i = 2; i < n; i++)
        fact[i] = mult(i, fact[i-1]);

    ll ans = 0;
    sort(a.begin(), a.end());
    for (int i = 0; i < a.size(); i++) {
        ans = sum(ans, comb(n-i-1, k-1)*(-1)*a[i]);
    }
    reverse(a.begin(), a.end());
    for (int i = 0; i < a.size(); i++) {
        ans = sum(ans, comb(n-i-1, k-1)*a[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5236
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



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

	int n, m;
	cin >> n >> m;
	vector<int> d; // mの約数

	for(int i = 1; i * i <= m; i++) {
		if(m % i == 0) {
			d.push_back(i);
			d.push_back(m / i);
		}
	}

	int ans = 0;
	rep(i, d.size()) {
		if(m >= d[i] * n) {
			chmax(ans, d[i]);
		}
	}

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

Measured memory_bytes: 256
n = int(input())
c = input()

w = []
r = []
for i in range(n):
  if c[i] == 'W':
    w.append(i+1)
  else:
    r.append(i+1)

w_len = len(w)
r_len = len(r)
if w_len == 0 or r_len == 0:
  print(0)
  exit(0)

if w_len < r_len:
  search = w_len
else:
  search = r_len

w_min = w[0]
r_max = r[r_len-1]

if r_max < w_min:
  print(0)
  exit(0)

count = 0
for i in range(search):
  tmp = w[i]
  w[i] = r[r_len-i-1]
  r[r_len-i-1] = tmp
  count += 1
  
  if w_len > count and (r_len-count-1) >= 0:
    w_min = w[count]
    r_max = r[r_len - count - 1]
  else:
    w_min = w[w_len-1]
    r_max = r[0]
    
  if r_max < w_min:
    print(count)
    exit(0)
print(count)

Measured memory_bytes: 17384
N,M,X=map(int,input().split())
lst=[0]*N
for i in range(N):
  lst[i]=list(map(int,input().split()))
x=-1
def ad(l1,l2):
  n=len(l1)
  return [l1[i]+l2[i] for i in range(n)]
for i in range(2**N):
  l0=[0]*(M+1)
  for j in range(N):
    if (i//(2**j))%2:
      l0=ad(l0,lst[j])
  if sum([j>=X for j in l0[1:]])==M:
    if l0[0]<=x or x==-1:
      x=l0[0]
print(x)

Measured memory_bytes: 69016
using System;
class buffet{
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    String[] number = Console.ReadLine().Split(' ');
    String[] basepoint = Console.ReadLine().Split(' ');
    String[] bonuspoint = Console.ReadLine().Split(' ');
    int satisfaction=0;
    for(int i=0; i<n-1; i++){
      if(int.Parse(number[i]) == (int.Parse(number[i+1])-1)){
        satisfaction += int.Parse(basepoint[int.Parse(number[i])-1]);
        satisfaction += int.Parse(bonuspoint[int.Parse(number[i])-1]);
      }
      else{
        satisfaction += int.Parse(basepoint[int.Parse(number[i])-1]);
      }
    }
    satisfaction += int.Parse(basepoint[int.Parse(number[n-1])-1]);
    Console.WriteLine(satisfaction);
  }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>

#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

/*---------------------------------------------------*/

int n,m[4]={10,50,100,500};
int num[4];
bool en=false;
int main(){
  int sum=0;
  while(cin>>n){
    sum=0;
    if(n==0)break;
    
    if(!en)en=true;
    else cout<<endl;
    
    rep(i,4){
      cin>>num[i];
      sum+=num[i]*m[i];
    }
    sum-=n;
    rrep(i,3){
      num[i]-=min(num[i],sum/m[i]);
      sum%=m[i];
    }
    rep(i,4)if(num[i]!=0)cout<<m[i]<<" "<<num[i]<<endl;
  }
  
  return 0;
}

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

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> v;
    bool h2 = false;
    if(s[0] == '2')
        h2 = true;
    for(int i = 1; i < n; i++) {
        if(s[i] == '2')
            h2 = true;
        v.push_back(abs(s[i] - s[i - 1]));
    }
    int k = n - 2, ans = 0;
    if(!h2) {
        for(auto &x : v) {
            x /= 2;
        }
    }
    else {
        for(auto &x : v) {
            if(x == 2)
                x = 0;
        }
    }
    for(int i = 0; i <= k; i++) {
        //cout << ((k - i) & i);
        ans ^= (v[i] & (((k - i) & i) == 0));
    }
    //cout << endl;
    cout << (h2 ? ans : 2*ans) << '\n';
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x, y, ans = -1;
    cin >> x >> y;
    for(int i = 10; i < 1009; i++) {
        if((i*8)/100 == x && i/10 == y) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	xs := make([]int, n)
	for i := range xs {
		fmt.Scan(&xs[i])
	}

	ys := make([]int, n)
	copy(ys, xs)
	sort.Ints(ys)
	mid1 := ys[len(ys)/2-1]
	mid2 := ys[len(ys)/2]

	for _, x := range xs {
		if x <= mid1 {
			fmt.Println(mid2)
		} else {
			fmt.Println(mid1)
		}
	}
}


Measured memory_bytes: 8576
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
using namespace std;

using int64 = long long;

const int MAX_N = 200000;

int N;
int64 L;

int64 result = 0;

string s[MAX_N];
vector<int64> heights;

int64 calc_grundy(int64 x) {
    if (x == 0) return 0;

    int64 res = 1;
    while (x % 2 == 0) {
        x /= 2;
        res *= 2;
    }
    return res;
}

string prefix = "";

void dfs(int64 dep, int lb, int ub) {
    int num = ub - lb;
    if (num == 0) {
        // result ^= calc_grundy(L + 1 - dep);
        heights.push_back(L + 1 - dep);
        return;
    } else if (num == 1 and prefix == s[lb]) return;
    /*
    } else if (num == 1) {
        int64 h = L - dep + 1;
        int64 sh = L - s[lb].size() + 1;

        // cerr << "h: " << h << " sh: " << sh << endl;

        for (int64 x = sh; x < h; x++) {
            result ^= calc_grundy(x);
            // heights.push_back(x);
        }
        return;
    }
    */
    prefix.push_back('1');
    int b = lower_bound(s + lb, s + ub, prefix) - s;
    prefix.pop_back();

    prefix.push_back('0');
    dfs(dep + 1, lb, b);
    prefix.pop_back();

    prefix.push_back('1');
    dfs(dep + 1, b, ub);
    prefix.pop_back();
}

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

    for (int i = 0; i < N; i++) {
        cin >> s[i];
    }
    sort(s, s + N);

    dfs(0, 0, N);

    for (auto h : heights) {
        // cerr << " == " << h << endl;
        result ^= calc_grundy(h);
    }

    if (result) cout << "Alice" << endl;
    else cout << "Bob" << endl;

    return 0;
}

Measured memory_bytes: 14200
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    int minX = 1000;
    for (int i = 0; i < S.size() - 2; i++)
    {
        int X = (S[i] - '0') * 100 + (S[i + 1] - '0') * 10 + (S[i + 2] - '0');
        minX = min(minX, abs(753 - X));
    }
    cout << minX << endl;
}

Measured memory_bytes: 256
def main():
    N, K, C = list(map(int, input().split(' ')))
    S = input()
    R, L = [0 for _ in range(K)], [0 for _ in range(K)]
    # calc first dates
    index, cnt = 0, 0
    while cnt < K and index <= N - 1:
        if S[index] == 'o':
            R[cnt] = index
            index += C + 1
            cnt += 1
        else:
            index += 1
    # calc last dates
    S = S[::-1]
    index, cnt = 0, 0
    while cnt < K and index <= N - 1:
        if S[index] == 'o':
            L[K - 1 - cnt] = N - 1 - index
            index += C + 1
            cnt += 1
        else:
            index += 1
    ans = [R[k] + 1 for k in range(K) if R[k] == L[k]]
    if len(ans) == 0:
        print('')
    else:
        for a in ans:
            print(a)


if __name__ == '__main__':
    main()

Measured memory_bytes: 33108
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	
	ll n ;
	cin>> n ;
	ll arr[n];
	for(ll i=0,a;i<n ;i++){
		cin>> a;
		arr[a]=i+1;
	}
	for(ll i=1;i<=n;i++)cout<<arr[i]<<" ";

	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){

    int N;cin>>N;
    vector<ll> A(N+1),B(N);
    for(int i=0;i<N+1;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        cin>>B[i];
    }
    
    ll ans=0;
    
    for(int i=0;i<N;i++){
        if(A[i]>=B[i]){
            ans+=B[i];
        }else{
            B[i]-=A[i];
            ans+=A[i];
            if(A[i+1]>=B[i]){
                A[i+1]-=B[i];
                ans+=B[i];
            }else{
                ans+=A[i+1];
                A[i+1]=0;
            }
        }
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 1792
import sys

#+++++
		
def main():
	n = int(input())
	ll=[int(input()) for _ in range(n)]
	
	mm = sorted(ll)
	#print(ll)
	ma=mm[-1]
	mb=mm[-2]
	
	for i in ll:
		pp = ma if i != ma else mb
		print(pp)
		
	
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 14112
n = int(input())
s = input()

ans = s
n_left, n_right = 0, 0
for ss in s:
    if ss == '(':
        n_left += 1
    else:
        if n_left > 0:
            n_left -= 1
        else:
            ans = '('+ans
if n_left > 0:
    for _ in range(n_left): ans += ')'

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	vector<int> a(n);
	int answer = inf;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		int cnt = 0;
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			++cnt;
		}
		answer = min(answer, cnt);
	}
	cout << answer << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>

const std::vector<std::vector<int>>
    dxs{{-1, -1, -1, 0, 0, 0, 1},
        {-1, 0, 0, 0, 1, 1, 1}},
    dys{{-1, 0, 1, -1, 0, 1, 0},
        {0, -1, 0, 1, -1, 0, 1}};

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

void solve() {
    int h, w;
    std::cin >> h >> w;

    auto grid = vec(h + 2, vec(w + 2, 0));
    for (int j = 1; j <= w; ++j) {
        for (int i = 1; i <= h; ++i) {
            std::cin >> grid[i][j];
        }
    }

    std::queue<std::pair<int, int>> que;
    que.emplace(0, 0);
    auto visited = vec(h + 2, vec(w + 2, false));
    visited[0][0] = true;

    int ans = 0;
    while (!que.empty()) {
        int x, y;
        std::tie(x, y) = que.front();
        que.pop();

        for (int i = 0; i < 7; ++i) {
            int nx = x + dxs[y % 2][i],
                ny = y + dys[y % 2][i];

            if (nx < 0 || nx > h + 1 ||
                ny < 0 || ny > w + 1 ||
                visited[nx][ny]) continue;

            if (grid[nx][ny] == 1) {
                ++ans;
                continue;
            }

            visited[nx][ny] = true;
            que.emplace(nx, ny);
        }
    }

    std::cout << ans << "\n";
}

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

    solve();

    return 0;
}



Measured memory_bytes: 3240
#include<iostream>
#include<algorithm>
using namespace std;
int dist[301][301], p[17], q[17], dp[1 << 16][17], n, m, a, b, c, d, e, f;
int main() {
	while (true) {
		cin >> n >> m >> a >> b >> c; if (n + m + a + b + c == 0)break;
		for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++)dist[i][j] = 999999999; }
		for (int i = 1; i <= n; i++) dp[i][i] = 0;
		for (int i = 0; i < m; i++) { cin >> d >> e >> f; dist[d][e] = f; dist[e][d] = f; }
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				for (int k = 1; k <= n; k++)dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
			}
		}
		for (int i = 0; i < (1 << a); i++) { for (int j = 0; j <= a; j++)dp[i][j] = 999999999; }
		for (int i = 0; i < a; i++)cin >> p[i] >> q[i]; dp[0][a] = 0; p[a] = b;
		for (int i = 0; i < (1 << a); i++) {
			for (int j = 0; j <= a; j++) {
				if (dp[i][j] == 999999999)continue;
				int bit[16]; for (int k = 0; k < a; k++)bit[k] = (i / (1 << k)) % 2;
				for (int k = 0; k < a; k++) {
					if (bit[k] == 1)continue;
					dp[i + (1 << k)][k] = min(dp[i + (1 << k)][k], dp[i][j] + dist[p[j]][p[k]] + q[k]);
				}
			}
		}
		int maxn = 0;
		for (int i = 0; i < (1 << a); i++) {
			for (int j = 0; j < a; j++) {
				int G = 0; for (int k = 0; k < a; k++) G += (i / (1 << k)) % 2;
				if (dp[i][j] + dist[p[j]][p[a]] > c)continue;
				maxn = max(maxn, G);
			}
		}
		cout << maxn << endl;
	}
	return 0;
}

Measured memory_bytes: 7716
#include<stdio.h>

int search(int n, int i, int arr[], int target){
    int res;
    if(target==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    res = search(n, i+1, arr, target-arr[i]) || search(n, i+1, arr, target);
    return res;
}

int main(){
    int num, i, q, target;
    scanf("%d", &num);
    int int_list[num];
    for(i=0; i<num; i++){
        scanf("%d", &int_list[i]);
    }
    scanf("%d", &q);
    for(i=0; i<q; i++){
        scanf("%d", &target);
        if(search(num, 0, int_list, target)){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1820
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <climits>
using namespace std;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % int(powl(10,9) + 7);
    }

    return f;
}

int main(){
    long int k,s;
    cin >> k >> s;

    int count = 0;

    for(int x = 0;x <= k; ++x){
        for(int y = 0; y <= k; ++y){
            int z = s - x- y;
            if(z >= 0 && z <= k)
                count++;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <iterator>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=1e5+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0;i*4<=n;i++){
        if((n-(i*4))%7==0){
        cout<<"Yes";
        return 0;
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, A, B, C, D = read_int()
S = read_str()

def solve():
    can_reach = not ('##' in S[A:C] or '##' in S[B:D])
    is_comma_suc3 = '...' in S[B - 2 : D + 1]
    if C < D:
        return "Yes" if can_reach else "No"
    else:
        return "Yes" if is_comma_suc3 and can_reach else "No"

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,unroll-all-loops")
// #pragma GCC option("arch=native","tune=native")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")

#include <bits/stdc++.h>
using namespace std;

#define f(_i, _n) for (auto _i = 0; _i < _n; _i++)
#define F(_i, _k, _n) for (auto _i = _k; _i < _n; _i++)
#define re return
#define pb push_back
#define all(_v) _v.begin(), _v.end()
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; }
#define fi first
#define se second

typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;

int p[100500];

int start = 0;

int ask(int pos) {
  pos += start;
  cout << pos << endl;
  string res;
  cin >> res;
  if (res[0] == 'V') {
    exit(0);
  }
  int a = 0;
  if (res[0] == 'F') {
    a = 1;
  }
  p[pos] = a;
  return p[start] == p[pos];
}

int main() {
  int n;
  cin >> n;
  int big = 1 << 30;
  ask(0);
  while (big > 0) {
    if (big < n) {
      if (ask(big)) {
        start += big;
        n -= big;
      }
    }
    big /= 2;
  }
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//



//----------//

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    vector<int> rv(n);
    rep(i, n){
        cin >> v[i];
        rv[i] = v[i];
    }
    reverse(ALL(rv));

    int ans = 0;
    rep(p, min(n, k)+1){
        //print("");
        rep(i, p + 1){
            priority_queue<int, vector<int>, greater<int> > q;
            int tmp = 0;
            int l = i;
            int r = p - i;
            //print(l, r);
            rep(j, l){
                tmp += v[j];
                if(v[j] < 0){
                    q.push(v[j]);
                }
            }
            rep(j, r){
                tmp += rv[j];
                if(rv[j] < 0){
                    q.push(rv[j]);
                }
            }
            rep(j, k - p){
                if(q.empty()) break;
                int qtmp = q.top(); q.pop();
                //print(tmp, qtmp);
                tmp += -qtmp;
            }
            ans = max(ans, tmp);
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10,mod=998244353,inf=0x3f3f3f3f;
int n,m,k,t;
int main()
{
    int i,j;
    int res=1000;
    scanf("%d",&n);
    for(i=1;i<n;i++)
    {
        int x=i,y=n-i;
        int ret=0;
        while(x)ret+=x%10,x/=10;
        while(y)ret+=y%10,y/=10;
        if(ret<res)res=ret;
    }
    printf("%d\n",res);
    return 0;
}


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

using namespace std;
typedef pair<int,int> pii;

const int MAXN = 110;
const int INF = 1000000010;

int n, m;

int dp[MAXN][MAXN];

vector< pair<pii,int> > edges;

int main()
{
	scanf("%d %d",&n,&m);

	for(int i = 1 ; i <= n ; i++)
		for(int j = 1 ; j <= n ; j++)
			dp[i][j] = INF;

	for(int i = 1 ; i <= n ; i++)
		dp[i][i] = 0;

	for(int i = 1 ; i <= m ; i++)
	{
		int U, V, W;
		scanf("%d %d %d",&U,&V,&W);

		dp[U][V] = dp[V][U] = W;

		edges.push_back( { {U , V} , W } ); 
	}

	for(int k = 1 ; k <= n ; k++)
		for(int U = 1 ; U <= n ; U++)
			for(int V = 1 ; V <= n ; V++)
				dp[U][V] = min( dp[U][V] , dp[U][k] + dp[k][V] );

	int ans = 0;

	for(int i = 0 ; i < m ; i++)
	{
		int U = edges[i].first.first;
		int V = edges[i].first.second;
		int W = edges[i].second;

		bool noShortestPath = false;

		for(int s = 1 ; s <= n ; s++)
		{
			for(int t = 1 ; t <= n ; t++)
			{
				int dist = dp[s][U] + W + dp[V][t];

				noShortestPath = noShortestPath || ( dist == dp[s][t] );
			}
		}

		if( !noShortestPath ) ans++;
	}

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

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

int main(){
  int N;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
  }
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  int sum=0;
  for(int i=0;i<N;i++){
    sum+=p.at(i);
  }
  sum-=p.at(0)/2;
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;

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;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  FOR(i,n-m+1,n+1){
    ans*=i;
    ans/=(i-n+m);
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 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() {
    // 前処理
    COMinit();
	ll n,k;
  	ci(n>>k)
    FOR(i,1,k+1){
      ll ans=1;
      ans*=COM(n-k+1,i);
      ans*=COM(k-1,i-1);
      ans%=1000000007;
   co(ans)
}
}


Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll fastpow(ll a,ll n){
	if(n<0)return 0;
	ll res=1;
	a%=MOD;
	while(n){
		if(n&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		n>>=1;
	}
	return res%MOD;
}
ll inv(ll a)
{
	return a == 1l ? 1l : (ll)(MOD - MOD / a) * inv(MOD % a) % MOD;
}
ll C(ll n, ll m)
{
	if (m < 0)return 0;
	if (n < m)return 0;
	if (m > n - m)m = n - m;
	ll up = 1, down = 1;
	for (ll i = 0; i < m; i++)
	{
		up = up * (n - i) % MOD;
		down = down * (i + 1) % MOD;
	}
	return up * inv(down) % MOD;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n,a,b,ans=0;
	cin>>n>>a>>b;
	ans=fastpow(2,n)-1;
	ans=ans-C(n,a)-C(n,b);
	cout<<(ans+MOD+MOD)%MOD<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int h;
    int w;
    while(1)  {
        scanf("%d%d", &h, &w);
        if(h == 0 && w == 0) break;
        int i,j;
        for(i = 0; i < h; i++){
            for(j = 0; j < w; j++){
                printf("#");
                }
                printf("\n");
                }
                printf("\n");
                }
                return 0;
                }


Measured memory_bytes: 2052
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits.h>
#include <climits>
#include <map>
#include <unordered_map>
#include <cmath>
#include <set>
#include <unordered_set>
#include <iterator>
#include <deque>
#include <assert.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ull min(ull x, ull y){ if (x<y) return x; return y;}
ull max(ull x, ull y){ if (x<y) return y; return x;}
ll min(ll x, ll y){ if (x<y) return x; return y;}
ll max(ll x, ll y){ if (x<y) return y; return x;}
double min(double x, double y){ if (x<y) return x; return y;}
double max(double x, double y){ if (x<y) return y; return x;}
ull gcd(ull x, ull y){
    if (!x) return y;
    if (!y) return x;
    if (x>y) swap(x,y);
    return gcd(x, y%x);
}
ull inv(ull a, ull c){ // a,c are coprime and a<c
    if (a==1){
        return 1;
    }
    return ((c-(c/a))*inv(c%a,c))%c;
}


int main(){
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int s, w;
    cin>>s>>w;
    if (w>=s){
        cout<<"unsafe\n";
    }
    else{
        cout<<"safe\n";
    }
    

    return 0;
}





Measured memory_bytes: 3048
#include <stdio.h>
#include <string.h>

int main() {
	
	char S[200];
	char B[200];
	int N=0, K=0;
	N=strlen(S);
	scanf("%d %d", &N, &K);
	scanf("%s", S);
	S[K-1]=S[K-1]+('a'-'A');
	printf("%s\n", S);
	
	return 0;
}

Measured memory_bytes: 128
N = int(input())
K = int(input())
x = input().split()
ans = 0
for i in range(0,N):
	if int(x[i]) > (K-int(x[i])):
		ans += (K-int(x[i]))*2
	else:
		 ans += int(x[i])*2
print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;

signed main(){
  int n,m;
  cin>>n>>m;
  vector<int> a(n);
  vector<int> b(m);
  map<int,int> am;
  map<int,int> bm;
  for(int i=0;i<n;i++){
    cin>>a[i];
    am[a[i]]++;
  }
  for(int i=0;i<m;i++){
    cin>>b[i];
    bm[b[i]]++;
  }
  sort(a.begin(),a.end(),greater<int>());
  sort(b.begin(),b.end(),greater<int>());

  bool f=true;
  for(int i=0;i<n-1;i++)if(a[i]==a[i+1])f=false;
  for(int i=0;i<m-1;i++)if(b[i]==b[i+1])f=false;
  if(!f){
    cout<<0<<endl;
    return 0;
  }

  int ans=1;
  int ac=0;
  int bc=0;
  for(int i=n*m;i>0;i--){
    if(am.count(i)&&bm.count(i)){
      ans*=1;
    }else if(am.count(i)){
      (ans*=bc)%=mod;
    }else if(bm.count(i)){
      (ans*=ac)%=mod;
    }else{
      (ans*=((ac*bc)-(n*m-i)))%=mod;
    }
    if(ac!=n&&a[ac]==i)ac++;
    if(bc!=m&&b[bc]==i)bc++;
  }
  cout<<ans%mod<<endl;
}


Measured memory_bytes: 512
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int n, q; readV(n, q);
  int[] s, t, x; readC(n, s, t, x);
  int[] d; readC(q, d);

  struct A { int q, t, x; }
  A[] a;

  foreach (i; 0..n) {
    a ~= A(0, s[i]-x[i], x[i]);
    a ~= A(1, t[i]-x[i], x[i]);
  }
  foreach (i; 0..q)
    a ~= A(2, d[i], 0);

  a.sort!"a.t == b.t ? a.q < b.q : a.t < b.t";
  auto p = redBlackTree!(true, int)();

  foreach (ai; a)
    switch (ai.q) {
    case 0: p.insert(ai.x); break;
    case 1: p.removeKey(ai.x); break;
    case 2: writeln(p.empty ? -1 : p.front); break;
    default: assert(0);
    }
}


Measured memory_bytes: 20988
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

ll dp[(1<<21)+1];
vector<int> a[21];
int n;

ll memo(ll female){
  if(dp[female]>=0) return dp[female];
  if(female==(1ll<<n)-1) return dp[female]=1;

  int male=0;
  for(int i=0;(1ll<<i)<=female;i++){
    if((1ll<<i)&female) male++;
  }
  ll res=0;
  for(int i=0;i<a[male].size();i++){
    int u=a[male][i];
    if((1ll<<u)&female) continue;

    res=(res+memo(female|(1ll<<u)))%MOD;
  }

  return dp[female]=res;
}

int main(){
  cin>>n;

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int x;
      cin>>x;
      if(x>0) a[i].push_back(j);
    }
  }

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

  cout<<memo(0ll)<<endl;

  return 0;
}


Measured memory_bytes: 16640
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;

typedef long long int ll;

int main(){
    int N;
    cin >> N;
    vector<int> D(N);
    for(int i=0; i<N; i++){
        cin >> D[i];
        }
    int Count=0;
    for(int i=0; i<N; i++){
        for(int k=0; k<N; k++){
            if(i!=k){
                Count += D[i] * D[k];
                }

            }
        }

    cout << Count/2;


}

Measured memory_bytes: 256