akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/
int64_t M =  1000000007;
int main(){
  string s;
  cin >> s;
  int64_t n = s.size();
  vector<vector<int64_t>> DP(n+1,vector<int64_t>(13));
  DP[0][0]=1;
  rep(i,n){
    if(s[i] == '?'){
      rep(j,13){
        rep(k,10){
          DP[i+1][((j*10)+k)%13] = (DP[i+1][((j*10)+k)%13] + DP[i][j])%M;
        }
      }
    }else{
      int g = s[i]-'0';
      rep(j,13){
        DP[i+1][((j*10)+g)%13] = DP[i][j];
      }
    }
  }
  /*rep(i,n+1){
    rep(j,13){
      printf("%4d",DP[i][j]);
    }
    cout << endl;
  }*/
  cout << DP[n][5] << endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i, n)cin>>a[i];

  vector<ll>results;
  rep(i, n){
//cout<<a[i]<<endl;
//    if(i==0){ results.push_back(a[i]); continue; }

    auto it = lower_bound(results.begin(), results.end(), a[i]);
    if( it==results.end() ){
      if(results.size()>0 && a[i]>results[results.size()-1])results[results.size()-1]=a[i];
      else results.insert(results.begin(), a[i]);
    }else{
//cout<<*it<<':';
      if(it==results.begin()){ results.insert(results.begin(), a[i]);
      }else{
        it--;
        *it = a[i];
      }
//cout<<*it<<'*'<<endl;
    }

//cout<<results.size()<<':';rep(i, results.size())cout<<results[i]<<' ';cout<<endl;

  }
  cout<<results.size()<<endl;

  return 0;
}

Measured memory_bytes: 2168
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine();
            if (int.Parse(a) == 0)
            {
                Console.WriteLine("1");
            }
            else
            {
                Console.WriteLine("0");
            }
        }
    }
}

Measured memory_bytes: 27540
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans=0;
    REP(i,n){
        int l,r;
        cin  >> l >> r;
        ans+=r-l+1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const ll MOD = 1e9 + 7;


ll kaijo(int x){
    ll ans = 1;
    while(x > 0){
        ans *= x--;
        ans %= MOD; 
    }
    return ans;
}

int main(){
    int N,M;
    cin >> N >> M;
    int diff = abs(N-M);
    ll ans;
    if(diff >= 2){
        ans = 0;
    }else if(diff == 1){
       ans = (kaijo(N)*kaijo(M)) % MOD ;
    }else{
       ans = (2 * kaijo(N)*kaijo(M)) % MOD ;
    }

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


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;
ll A, B, N; 

ll f(ll x){
	ll a = A*x / B;
	ll b = A * (x / B);
	return a - b;

}

int main(void){

	cin >> A >> B >> N;
	ll x = min(N, B-1);

	cout << f(x) << endl;

	return 0;

}


Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 8;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rnr(i, a, b) for(int i = int(a); i >= int(b); i--)
#define rep(i, b) rng(i, 0, b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    string s; cin >> s;
    int ans = 0;
    if(s == "RRR") {
        ans = 3;
    } else if (s == "RRS" || s == "SRR") {
        ans = 2;
    }else {
        for(char c: s) {
            if(c == 'R') ans = 1;
        }
    }
    cout << ans << endl;
}


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

// int main() {
//     int n;
//     cin >> n;
//     vector<tuple<string, int, int>> a;
//     for(int i = 1; i <= n; i++){
//         string S;
//         int P;
//         cin >> S >> P;
//         P = -P;
//         a.push_back(tie(S, P, i));
//     }
//     sort(a.begin(), a.end());
//     for(int i = 0; i < n; i++){
//         cout << get<2>(a[i]) << endl;
//     }
// }

int main(){
    vector<tuple<string, int, int>> res;
    int n, p;
    string s;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> s >> p;
        res.push_back(make_tuple(s,-p,i+1));
    }
    sort(res.begin(), res.end());
    for(auto v: res){
        cout << get<2>(v) << endl;
    }
}

Measured memory_bytes: 256
/*
                        --------------- Shuvo 's code-_______
                        /''''''''''(______O] ----------____  \______/]_
     __...---'"""\_ --''        Metropolitan university     ___________@ -> ->  -> - --  - -- - ---- ->>
 |'''                   ._   _______________=---------"""""""
 |                ..--''|   l L |_l   |
 |          ..--''      .  /-___j '   '
 |    ..--''           /  ,       '   '
 |--''                /           `    \
                      L__'         \    -
                                    -    '-.
                                     '.    /
                                       '-./
*/

///   ------------ Bismillah hirrahman nirrahim ----------   ///

#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define sc(n) scanf("%I64d", &n);
#define pr(n) printf("%I64d\n", n);
#define prr(n, m) printf("%I64d %I64d\n", n, m);
#define prrr(n, m, p) printf("%I64d %I64d %I64d\n", n, m, p);
#define lp(i,s,n) for(long long  i = s; i<n; i++)
#define pl(n) for(long long i=n-1; i>=0; i--)
#define  ars(arr,s,e) sort(arr+s,arr+n);
#define pb push_back
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)

long long int mx = 1e18;
long long int mn = -1e18;
using namespace std;
ll a[10];

vector < ll > v;
set < ll > st[100010];

ll gcd(ll a,ll b){
    ll tmp;
    while(b){
        tmp=b;
        b=a%tmp;
        a=tmp;
    }
    return a;
}


int main()
{
    FastRead;
    ll p,q,r,s,t,i, j,ii, x, jj, n, ans, sum, cnt = 0, st,tc = 0, len ;
    string str;

    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    ans  = a[2] - a[0];

    cout << ans << endl;

}



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

typedef long long ll;

ll n,a,b;
ll h[100005];
ll ans;

bool chk(ll x){
    ll res=0;
    for(ll i=1;i<=n;i++){
        if(x*b<0)continue;
        ll cur=h[i]-x*b;
        if(cur<=0)continue;
        res+=(cur+(a-b)-1)/(a-b);
    }
    return res<=x;
}

int main(){

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

    cin>>n>>a>>b;
    for(ll i=1;i<=n;i++){
        cin>>h[i];
    }
    ll l=0,r=1e18;
    while(l<=r){
        ll m=(l+r)/2;
        if(chk(m)){
            ans=m;
            r=m-1;
        }else{
            l=m+1;
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

#define ll long long
using namespace std;

int main()
{
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	ll now = 0;
	ll ret = 0;
	for (ll i = 45; i >= 0; i--)
	{
		ll count = 0;
		for (ll j = 0; j < n; j++)
		{
			if ((1LL << i & a[j]) > 0)count++;
		}
		if (count < n - count && now + (1LL << i) <= k)
		{
			now += 1LL << i;
			ret += (1LL << i) * (n - count);
		}
		else
			ret += (1LL << i) * count;
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 1024
/*  CREATED BY
    STREAM_CIPHER
    7-aug-2020
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define debug1(a) cout<<#a<<"="<<(a)<<"\n"
#define debug2(a,b) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<"\n"
#define debug3(a,b,c) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<","<<#c<<"="<<(c)<<"\n"
#define fix_precision(n) cout << fixed << setprecision(n)
#define all(a) a.begin(),a.end()
const double pi=acos(-1.0);
int inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int mx=5*1000000;
int n,m;
vector<int>g[mx];
vector<int>topo_order;
bool vis[mx];
void dfs(int start)
{
    vis[start]=1;
    for(auto i:g[start])
        if(!vis[i])
            dfs(i);
    topo_order.push_back(start);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    #endif
        cin>>n>>m;
        for(int i=0;i<m;i++)
        {
            int u,v;
            cin>>u>>v;
            u--,v--;
            g[u].push_back(v);
        }
        for(int i=0;i<n;i++)
            if(!vis[i])
                dfs(i);
        reverse(all(topo_order));
        int dp[n+9]={0};
        memset(dp,0,sizeof dp);
        int ans=0;
        for(auto i:topo_order)
            for(auto j:g[i])
                dp[j]=max(dp[i]+1,dp[j]),ans=max(ans,dp[j]);
        cout<<ans<<endl;
}

Measured memory_bytes: 126704
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;


set<string> ans;
int N;

int main() {
	mp::cpp_dec_float_100 a, b, c;
	cin >> a >> b >> c;
	mp::cpp_dec_float_100 A,B,C;
	A = mp::sqrt(a);
	B = mp::sqrt(b);
	C = mp::sqrt(c);
	if (A + B < C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b;
	if(a==0||b==0)cout<<"Zero";
	if(a>0&&b>0)cout<<"Positive";
	if(a>0&&b<0)cout<<"Zero";
	if(a<0&&b>0)cout<<"Zero";
	c=b-a;
	if(a<0&&b<0){
	if(c%2==0)cout<<"Negative";
	else cout<<"Positive";
	}
} 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#define INF 1<<28
#define F first
#define S second
using namespace std;

int sx, sy, gx, gy;
typedef pair < int, int > P;
vector < P > p[5];
int memo[5][5][1111];
int a, b;

int solve(int k, int t, int q){

  if(k == 4) return abs(p[t][q].F-gx) + abs(p[t][q].S-gy);
  if(memo[k][t][q]) return memo[k][t][q];

  int ans = INF, d = (t+1)%5, s;
  for(int i=0;i<p[d].size();i++){
    if(!k) s = abs(sx-p[d][i].F) + abs(sy-p[d][i].S);
    else s = abs(p[t][q].F-p[d][i].F) + abs(p[t][q].S-p[d][i].S);
    ans = min(ans, solve(k+1, d, i) + s);
  }

  return memo[k][t][q] = ans;
}

int main(){

  int w,h;
  char c;

  while(true){
    cin >> w >> h;
    if(!w && !h) break;

    for(int i=0;i<5;i++) p[i].clear();
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> c;
	if(c == 'S') sx = j, sy = i;
	if(c == 'G') gx = j, gy = i;
	else if(c != '.') p[c-'1'].push_back(P(j,i));
      }
    }
    
    b = INF;
    for(int i=0;i<5;i++){
      memset(memo, 0, sizeof(memo));
      if(b > solve(0,i,0)) a = i, b = solve(0,i,0);
    }

    if(b == INF) cout << "NA\n";
    else cout << a+1 << " " << b << endl;

  }
}

Measured memory_bytes: 1372
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, ans=0;
	cin>>n;
	char ch;
	vector<int> r, w;
	for(int i=0;i<n;i++){
		cin>>ch;
		if(ch=='W')
			w.push_back(i);
		else r.push_back(i);
	}
	reverse(w.begin(),w.end());
	while(w.size() && r.size() && w.back()<r.back()){
		ans++;
		w.pop_back();
		r.pop_back();
	}
	cout<<ans;
}


Measured memory_bytes: 4584
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) {
		String str;
		double d = 0;
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			str = br.readLine();
			d = Double.parseDouble((str));
		} catch(Exception e) {
			
		}
		int i = (int)Math.pow(d, 3.0);
		System.out.println(i);
	}
}

Measured memory_bytes: 16924
#include <iostream>
using namespace std;
 
int main() {
	int A, B, C;
	cin>>A>>B>>C;
	if(A==B && B==C){
		cout<<"No";
	}else if(A==B || A==C || B==C){
		cout<<"Yes";
	}else {
		cout<<"No";
	}
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
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(){
	while(1){
		int t,h;
		cin >> t >> h;
		if(t==0&&h==0) break;
		vector<int> td;
		vector<int> hd;
		int tsum = 0;
		int hsum = 0;
		REP(i,t){
			int tmp;
			cin >> tmp;
			td.pb(tmp);
			tsum += tmp;
		}
		REP(i,h){
			int tmp;
			cin >> tmp;
			hd.pb(tmp);
			hsum += tmp;
		}
		int ansx = 114514;
		int ansy = 114514;
		REP(i,t){
			REP(j,h){
				if(tsum-td[i]+hd[j]==hsum-hd[j]+td[i]){
					if((ansx+ansy)>(i+j)){
						ansx = i;
						ansy = j;
						i = t;
						j = h;
					}
				}
			}
		}
		if(ansx == 114514) cout << -1 << endl;
		else cout << td[ansx] << " " << hd[ansy] << endl;

	}
}

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

int main() {
  int l, r, d;cin>>l>>r>>d;
  int sum = 0;
  for(int i = l; i < r+1; i++) {
    if (i % d == 0) sum++;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

pair<double,double> solve(double a,double b,double c,double d,double e,double f)
{
	return mp((c*e-b*f)/(a*e-b*d),(a*f-c*d)/(a*e-b*d));
}

int main()
{
	int n;
	cin>>n;
	rep(i,n){
		vector<double> x(3),y(3);
		rep(j,3)
			cin>>x[j]>>y[j];
		double x0=x[0],y0=y[0];
		rep(j,3){
			x[j]-=x0;
			y[j]-=y0;
		}
		pair<double,double> res=solve(
			2*x[1],2*y[1],x[1]*x[1]+y[1]*y[1],
			2*x[2],2*y[2],x[2]*x[2]+y[2]*y[2]);
		printf("%.3f %.3f %.3f\n",res.first+x0,res.second+y0,hypot(res.first,res.second));
	}
	
	return 0;
}

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

int main() {
	int a[3];
	int x = 0, y = 0, z = 0;
	while (1) {
		rep(i, 3)cin >> a[i];
		sort(a, a + 3);
		if (a[0] + a[1] <= a[2])break;
		if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2])x++;
		else if (a[0] * a[0] + a[1] * a[1] > a[2] * a[2])y++;
		else z++;
	}
	cout << x + y + z << ' ' << x << ' ' << y << ' ' << z << endl;
	return 0;
}

Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
ll h, w; 
ll dp[402][200][200];
bool can(pair<ll, ll> po){return (0 <= po.first && po.first < h && 0 <= po.second && po.second < w ? true : false);}
int main(){
	cin >> h >> w;
	ll a[h][w];
	for(ll i = 0; i < h; i++)for(ll j = 0; j < w; j++)cin >> a[i][j];
	dp[0][0][0] = a[0][0];
	for(ll count = 0; count < h + w - 2; count++){
		for(ll i = 0; i < h; i++){
			for(ll j = 0; j < h; j++){
				auto po = pair<ll, ll>(i, count - i), yo = pair<ll, ll>(j, count - j);
				if(!can(po) || !can(yo)) continue;
				ll dh[] = {1, 0}, dw[] = {0, 1};
				for(ll p = 0; p < 2; p++){
					for(ll y = 0; y < 2; y++){
						auto nextpo = po, nextyo = yo;
						nextpo.first += dh[p];
						nextpo.second += dw[p];
						nextyo.first += dh[y];
						nextyo.second += dw[y];
						if(!can(nextpo) || !can(nextyo)) continue;
						dp[count + 1][nextpo.first][nextyo.first] = max(dp[count + 1][nextpo.first][nextyo.first], dp[count][po.first][yo.first] + a[nextpo.first][nextpo.second] + a[nextyo.first][nextyo.second] - (nextpo == nextyo ? a[nextpo.first][nextpo.second] : 0));
					}
				}
			}
		}
	}
	cout << dp[h + w - 2][h - 1][h - 1] << endl;
	return 0;
}

Measured memory_bytes: 123520
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>

using ll = long long;

int main() {
    int N;
    std::cin >> N;
    int sum = 0;
    int n = N;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }

    if (N % sum == 0) {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }
    return 0;
}


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

int s[1000], d[1000], y[1000], a, b, n, m, h, k;
P p[100000];
int main() {
	while (scanf("%d%d%d%d", &n, &m, &h, &k), n) {
		rep(i, n)scanf("%d", &s[i]);
		rep(i, m)scanf("%d%d", &a, &b), p[i] = { b,a };
		sort(p, p + m); iota(d, d + n, 0);
		rep(i, m) {
			swap(d[p[i].t - 1], d[p[i].t]);
			p[i] = { d[p[i].t - 1],d[p[i].t] };
			if (p[i].first > p[i].t)swap(p[i].first, p[i].t);
		}
		rep(i, n)y[d[i]] = s[i];
		int M = accumulate(y, y + k, 0); int S = M;
		rep(i, m)if (p[i].first < k&&p[i].second >= k)M = min(M, S + y[p[i].second] - y[p[i].first]);
		printf("%d\n", M);
	}
}

Measured memory_bytes: 3956
N = int(input())
way = [[] for _ in range(N+1)]
depth = [float("inf")]*(N+1)
for _ in range(N - 1):
    a,b,c = map(int, input().split())
    way[a].append((b, c))
    way[b].append((a, c))

Q, K = map(int, input().split())
xy = [list(map(int,input().split())) for _ in range(Q)]

stack = []
stack.append((K, 0))

while stack:
    now, d = stack.pop()
    depth[now] = d
    for i, j in way[now]:
        if depth[i] < d+j:
            continue
        stack.append((i, d+j))

for x,y in xy:
    print(depth[x] + depth[y])

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;

    ll d = min(8*Q, min(4*H, min(2*S, D)));
    ll s = min(4*Q, min(2*H, S));

    ll ans = (N/2) * d + (N%2) * s;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
V = np.array([int(i) for i in (input()).split(" ")])
C = np.array([int(i) for i in (input()).split(" ")])
 
YmX = V-C

MaxYmX = np.sum(YmX[np.where(YmX > 0)])

print(MaxYmX)


Measured memory_bytes: 12496
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 n, l;
  vector<string> s;
  cin >> n >> l;
  read_n(s, n);
  sort(begin(s), end(s));
  for (auto&& t : s) cout << t;
  cout << '\n';
  return 0;
}


Measured memory_bytes: 256
[<EntryPoint>]
let main argv =
    let s = stdin.ReadLine().Split() |> Array.map (fun x -> (x |> int |> (+) 11) % 13)
    if s.[0] > s.[1] then "Alice" else if s.[0] < s.[1] then "Bob" else "Draw"
    |> stdout.WriteLine
    0

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

vector<int> to[200005];
vector<int>  ans;
void dfs(int v, int p=-1){
	for (int u: to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u,v);
	}
}

int main() {
	int n, q;;
	cin >> n >>  q;
	rep(i, n-1) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		to[a].push_back(b);
		to[b].push_back(a);

	}
	ans.resize(n);
	rep(i, q) {
		int p, x;
		cin >> p >> x;
		--p;
		ans[p] += x;
	}
	dfs(0);
	rep(i, n) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 23424
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <iterator>

using ll = long long;
using namespace std;
#define modmod 1000000007

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


int main(){
    int N;
    cin >> N;
    ll T[N];
    ll A[N];
    for(int i = 0; i < N; i++){
        cin >> T[i] >> A[i];
    }
    ll nt = T[0];
    ll na = A[0];
    if(N==1){
        cout << nt+na << endl;
        return 0;
    }

    ll n;

    for(int i = 1; i < N; i++){
        //n = max(ceil((double)nt/T[i]),ceil((double)na/A[i]));
        int64_t tmp_taka=nt/T[i];
        int64_t tmp_aoi=na/A[i];
        if(nt%T[i]!=0){
            tmp_taka++;
        }
        if(na%A[i]!=0){
            tmp_aoi++;
        }
        int64_t n=max(tmp_taka,tmp_aoi);
        nt = n*T[i];
        na = n*A[i];
    }

    cout << nt + na << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <string>
#include <cstdlib>
using namespace std;

int main()
{
    stack<int> x;
    string s;
    while (cin >> s)
    {
        if (s == "*")
        {
            int a = x.top();
            x.pop();
            int b = x.top();
            x.pop();
            x.push(b * a);
        }
        else if (s == "+")
        {
            int a = x.top();
            x.pop();
            int b = x.top();
            x.pop();
            x.push(b + a);
        }
        else if (s == "-")
        {
            int a = x.top();
            x.pop();
            int b = x.top();
            x.pop();
            x.push(b - a);
        }
        else
        {
            int n = atoi(s.c_str());
            x.push(n);
        }
        //        cout << x.top() << endl;
    }
    cout << x.top() << endl;
    return 0;
}



Measured memory_bytes: 3172
#include <algorithm>
#include <iostream>
#define rep(S, L) for (int i = S; i < L; ++i)
using namespace std;

int main() {
  int a[3];
  rep(0, 3) { cin >> a[i]; }
  sort(a, a + 3, greater<int>());
  int ans = abs(a[1] - a[0]) + abs(a[2] - a[1]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define EPS 1e-10
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
using namespace std;

struct Point {
    double x,y;
    Point(){}
    Point(double x, double y) : x(x),y(y){}
    Point operator+(Point p) {return Point(x+p.x, y+p.y);}
    Point operator-(Point p) {return Point(x-p.x, y-p.y);}
    Point operator*(double k) {return Point(x*k,y*k);}
    Point operator/(double k) {return Point(x/k,y/k);}
    double norm(){return x*x+y*y;}
    double abs(){sqrt(norm());}
    bool operator == (const Point &p) const {return equals(x,p.x)&&equals(y,p.y);}
};

typedef Point P;

struct Segment {
    P p1,p2;
    Segment(){}
    Segment(P p1, P p2): p1(p1),p2(p2){}
};
// 内積
double dot(P a, P b) {return a.x*b.x+a.y*b.y;}

// 射影
P project(Segment s, P p) {
    P base = s.p2-s.p1;
    double r = dot(p-s.p1,base)/base.norm();
    return s.p1+base*r;
}

// 反射
P reflect(Segment s, P p) {
    return p+((project(s,p)-p)*2.0);
}

int main() {
    double x1,x2,y1,y2;
    cin>>x1>>y1>>x2>>y2;
    Point p1(x1,y1); Point p2(x2,y2);
    Segment s(p1,p2);
    int q; cin>>q;
    rep(i,q) {
        double x0,y0;
        cin>>x0>>y0;
        P p0(x0,y0);
        P ans = reflect(s,p0);
        cout << fixed << setprecision(12);
        cout << ans.x << " " << ans.y << endl;
    }
}


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

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

    vector<int64_t> x(n), l(n);
    for(int i = 0; i < n; i++) cin >> x[i] >> l[i];

    vector< pair<int64_t, int64_t> > reach(n);
    for(int i = 0; i < n; i++) {
        reach[i].first = x[i] - l[i];
        reach[i].second = x[i] + l[i];
    }
    sort(reach.begin(), reach.end());

    vector<bool> left(n, false);
    left[0] = true;
    int tmp = 0;
    for(int i = 1; i < n; i++) {
        if(reach[tmp].second <= reach[i].first) {
            left[i] = true;
            tmp = i;
        } else if(reach[tmp].second >= reach[i].second) {
            left[tmp] = false;
            left[i] = true;
            tmp = i;
        }
    }

    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(left[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<set>
#include<string>
#include<vector>
#include<queue>

using namespace std;

/*
//1
int main(){
	int d, c;
	cin >> d >> c;

	cout << d*c << endl;

	return 0;
}
*/

/*
//2
int main(){
	int c1, c5, c10,c50,c100, c500;
	cin >> c1 >>  c5 >> c10 >> c50 >> c100 >> c500;
	int x = c1 + c5*5 + c10*10 + c50*50 + c100*100 + c500*500;
	if(x>=1000) cout << 1 << endl;
	else cout << 0 << endl;

	return 0;
}*/



//3
/*
int main(){
	int N;
	cin >> N;
	for(int i=0; i<N; i++){
		int k, p;
		cin >> k >> p;
		int x = k%p;
		if(x == 0) x = p;
		cout << x << endl;

	}

	return 0;
}
*/


/*
//4
int main(){
	int N, M;
	int times[300];
	cin >> N;
	for(int i=0; i<N; i++){
		int h, m;
		cin >> h >> m;
		times[i] = 60*h + m;
	}
	cin >> M;
	for(int i=0; i<M; i++){
		int h, m;
		cin >> h >> m;
		times[N+i] = 60*h + m;
	}
	sort(times, times+N+M);

	int n = -1;
	for(int i=0; i< N+M; i++){
		if(times[i] == n) continue;
		int h, m;
		h = times[i]/60;
		m = times[i]%60;
		
		if(m < 10){
			if(n == -1) cout << h << ":0" << m;
			else cout << " " << h << ":0" << m;
		}
		else{
			if(n == -1) cout << h << ":" << m;
			else cout << " " << h << ":" << m;
		}

		n = times[i];
	}
	cout << endl;

	return 0;
}
*/

//=====


//5
int main(){
	int N,M,p;
	cin >> N >> M >> p;
	int left = -1;
	int right = N;
	int mini,ma;
	vector<int> all;
	vector<int> migi;
	vector<int> hidari;
	for(int i=0; i<M; i++){
		int tmp;
		cin >> tmp;
		all.push_back(tmp);
		if(tmp < p){
			migi.push_back(N-p+tmp);
			hidari.push_back(p-tmp);
		}
		else{
			migi.push_back(tmp-p);
			hidari.push_back(p+N-tmp);
		}
	}
	sort(all.begin(), all.end());
	sort(migi.begin(), migi.end());
	sort(hidari.begin(), hidari.end());

	int ans = min(hidari.back(),migi.back());
	for(int i=0; i<M-1; i++){
		ans = min(ans, 2*hidari[i]+migi[M-i-2]);
		ans = min(ans, 2*migi[i]+hidari[M-i-2]);
	}
	
	cout << ans*100 << endl;

	return 0;
}


/*
//6
int main(){


	return 0;
}
*/

/*
//7
int main(){


	return 0;
}
*/

/*
//8
int main(){


	return 0;
}
*/

/*
//9
int main(){


	return 0;
}
*/

/*
//10
int main(){


	return 0;
}
*/


Measured memory_bytes: 3256
#include <iostream>
#include <string>

std::string O, E;

int main() {
  std::cin >> O >> E;
  for (int i=0; i<E.size(); ++i) {
    std::cout << O[i] << E[i];
  }
  if (O.size() - E.size() == 1) std::cout << O.back();
  std::cout << '\n';
  return 0;
}


Measured memory_bytes: 256
def examD():
    K = I()
    N = 50
    A = [i for i in range(N)]
    for i in range(N):
        A[-1-i] +=((K-i+49)//N)
    print(N); print(" ".join(map(str,A)))

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;

//cin.tie(0);
//ios::sync_with_stdio(false);

ll dp[2010][2]={};//iより先からとれる

signed main(){
    ll n,x,y;cin>>n>>x>>y;

    vector<ll> a(n);
    rep(i,n)cin>>a[i];

    for(int i=n-1;0<=i;i--)
    {
        dp[i][0]=(i ? abs(a[i-1]-a[n-1]):abs(y-a[n-1]));
        for(int j=i+1;j < n;j++)
        {   
            dp[i][0]=max(dp[j][1],dp[i][0]);
        }

        
        dp[i][1]=(i ? abs(a[i-1]-a[n-1]):abs(x-a[n-1]));
        for(int j=i+1;j < n;j++)
        {
            dp[i][1]=min(dp[j][0],dp[i][1]);
        }
        //cout<<dp[i][0]<<":"<<dp[i][1]<<endl;
    }

    cout<<dp[0][0]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1009;
int n, P[N];
pair < string , int > A[N];
bool CMP(int i, int j)
{
    return (A[i] < A[j]);
}
int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> A[i].first >> A[i].second;
        P[i] = i; A[i].second *= -1;
    }
    sort(P + 1, P + n + 1, CMP);
    for (int i = 1; i <= n; i++)
        printf("%d\n", P[i]);
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
it = lambda: list(map(int, input().strip().split()))
INF = float('inf')

def solve():
    X, N = it()
    arr = it()
    res = [False] * 102
    for i in range(N):
        res[arr[i]] = True
    
    i = X
    j = X
    while i >= 0 and j <= 101:
        if not res[i]:
            return i
        elif not res[j]:
            return j
        i -= 1
        j += 1

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

Measured memory_bytes: 9468
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
 
int main(){
	int N=1407;
	int K=38;
	printf("%d %d\n",N,K);
	for(int i=0;i<K;i++){
		printf("%d",N);
		for(int j=0;j<K-1;j++){
			printf(" %d",1+i*(K-1)+j);
		}
		printf("\n");
	}
	for(int j=0;j<K-1;j++){
		for(int k=0;k<K-1;k++){
			printf("%d",(K-1)*(K-1)+j+1);
			for(int l=0;l<K-1;l++){
				printf(" %d",(k+l*j)%(K-1)+1+(K-1)*l);
			}
			printf("\n");
		}
	}
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    A = LI()
    A.sort()
    MAX = A[-1]+1
    All = [0 for i in range(MAX)]

    setA = set(A)
    for i in A:
        k = i
        All[k] += 1
        k += i
        if All[i] == 2:
            continue
        while k < MAX and i in setA:
            All[k] += 1
            k += i

    ans = 0
    for i in range(1, MAX):
        if All[i] == 1 and i in setA:
            ans += 1

    print(ans)

    # oj t -c "pypy3 main.py"
    # acc s main.py -- --guess-python-interpreter pypy
main()


Measured memory_bytes: 194364
#include <stdio.h>

int main()
{
    long long H;
    long N;
    short tmp;
    
    scanf("%lld %ld", &H, &N);
    
    while(N>0)
    {
        scanf("%hd ", &tmp);
        H = H - tmp;
        N--;
    }
    
    if(H > 0)
    {
        printf("No");
    }
    else
    {
        printf("Yes");
    }

    return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  char C;
  cin >> C;
  cout << char(C+1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

ll h, w;
vector<string> a;

ll dp[1100][1100];

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

int main() {
    cin >> h >> w;
    a.resize(h);
    for(int i = 0; i < h; i++) cin >> a[i];

    dp[0][0] = 1;
    
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(i+1 < h && a[i+1][j] == '.') add(dp[i+1][j], dp[i][j]);
            if(j+1 < w && a[i][j+1] == '.') add(dp[i][j+1], dp[i][j]); 
        }
    }

    cout << dp[h-1][w-1] << endl;
}

Measured memory_bytes: 10368
n = int(input())
a = list(map(int, input().split()))

b = [0]*n
ans = []
for i in range(n)[::-1]:
    tmp = 0
    for j in range(n//(i+1)):
        tmp += b[(i+1)*(j+1)-1]
    if tmp%2 != a[i]:
        b[i] += 1
        ans.append(i+1)

print(sum(b))
print(*ans)

Measured memory_bytes: 67164
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			int x=in.nextInt();
			int y=in.nextInt();
			if((x|y)==0)
				return;
			int c=y-x;
			System.out.println(c%500/100+" "+c%1000/500+" "+c/1000);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define N 200006
using namespace std;
int n,m,x,y,t,a[N],s[N];long long sum,v[N];
inline int read()
{
	int x=0,c=getchar(),f=1LL;while(c<'0'||c>'9')f=(c=='-'?-f:f),c=getchar();
	while(c>='0'&&c<='9')x=(x<<1LL)+(x<<3)+c-48,c=getchar();return f>0?x:-x;
}
void print(long long x)
{
	if(x>9)print(x/10);putchar(x%10+48);
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=2;i<=n;i++){
		if(a[i-1]<a[i]){
			sum+=a[i]-a[i-1];
			if(a[i-1]+1<a[i])s[a[i-1]+2]++,s[a[i]+1]--,v[a[i]+1]-=a[i]-a[i-1]-1;
		}else{
			sum+=m-a[i-1]+a[i];
			if(a[i-1]+1<m)s[a[i-1]+2]++,s[m+1]--,s[1]++,s[a[i]+1]--,v[0]+=m-a[i-1]-1,v[a[i]+1]-=m-a[i-1]+a[i]-1;
			if(a[i-1]+1==m)s[1]++,s[a[i]+1]--,v[a[i]+1]-=m-a[i-1]+a[i]-1;
			if(a[i-1]==m&&1<a[i])s[2]++,s[a[i]+1]--,v[a[i]+1]-=m-a[i-1]+a[i]-1;
		}
	}
	long long ans=0;
	for(int i=1;i<=m;i++){
		s[i]+=s[i-1];v[i]+=v[i-1]+s[i];if(v[i]>ans)ans=v[i];
	}
	printf("%lld\n",sum-ans);
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(void) {
	int H, W;
	H = 0;
	W = 0;
	
	for (;;) {
		cin >> H >> W;
				if (W == 0 && H == 0) {
			break;
		}
				W = W + 1;
				H = H + 3;
		for (int j = 3; j < H; j++) {
			for (int i = 1; i < W; i++) {
				if (j % 2 == 1) {
					if (i == 1) {
						cout << '#';
					}
					else if (i % 2 == 1) {
						cout << '#';
					}
					if (i % 2 == 0) {
						cout << '.';
					}
				}
				else{
					if (i == 1) {
						cout << '.';
					}
					else if (i % 2 == 1) {
						cout << '.';
					}
					if (i % 2 == 0) {
						cout << '#';
					}
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3100
#!/usr/bin/env python3
#ABC93 B

a,b,k = list(map(int,input().split()))

ans = []
for i in range(k):
    if a+i <= b:
        ans.append(a+i)
for i in range(k):
    if b-(k-i)+1 >= a:
        ans.append(b-(k-i)+1)
ans = list(set(ans))
ans.sort()
for i in range(len(ans)):
    print(ans[i])


Measured memory_bytes: 38384
#include <bits/stdc++.h>
    using namespace std;
    #define el "\n"
    #define ll long long
    #define ull unsigned long long int
    #define pb push_back
    #define mp make_pair
    #define X first
    #define Y second
    #define M 1000000007
    #define all(v) v.begin(), v.end()
    long long pow(long long int a,long long int b,long long int MOD)
    {
        long long x=1,y=a; 
        while(b > 0)
        {
            if(b%2 == 1)
            {
                x=(x*y);
                if(x>MOD) x%=MOD;
            }
            y = (y*y);
            if(y>MOD) y%=MOD; 
            b /= 2;
        }
        return x;
    }
    long long modInverse(long long int n, long long int MOD)
    {
        return pow(n,MOD-2,MOD);
    }
   ll nCrModPFermat(ll n, ll r, ll p) 
{ 
   
   if (r==0) 
      return 1; 
    ll fac[n+1]={0}; 
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = (fac[i-1]*i)%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 
    int main() {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      ll n,k;
      cin>>n>>k;
      ll ans1=0,ans2=0,ans=0;
      for(int i=1;i<=k;i++){
          if(n-k+1>=i)
          ans1=nCrModPFermat(n-k+1, i, M);
          else ans1=0;
          ans2=nCrModPFermat(k-1,i-1,M);
          ans=ans1*ans2;
          ans%=M; 
          cout<<ans<<el;
      }
      return 0;
    }


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;

double a,b,C;
int main(){
	cin >> a >> b >> C;
	double S = a/2*b*sin(C/180*M_PI);
	double c = sqrt(a*a+b*b-2*a*b*cos(C/180*M_PI));
	double L = (a+b+c);
	double h = 2*S/a;
	printf("%.6f\n",S);
	printf("%.6f\n",L);
	printf("%.6f\n",h);
}


Measured memory_bytes: 3476
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<algorithm>
using namespace std;
vector<int>G[100010];
int dis[100010];
int par[100010];
bool f[100010];
vector<int>dia;
int n;
void dfs(int x,int p)
{
	for(int i=0;i<G[x].size();i++)
	{
		int y=G[x][i];
		if(y==p)continue;
		dis[y]=dis[x]+1;
		par[y]=x;
		dfs(y,x);
	}
}
vector<int>a,b;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	dfs(1,0);
	int u=0,v=0;
	for(int i=1;i<=n;i++)
	{
		if(!u || dis[i]>dis[u])u=i;
	}
	dis[u]=0;
	par[u]=0;
	dfs(u,0);
	for(int i=1;i<=n;i++)
	{
		if(!v || dis[i]>dis[v])v=i;
	}
	while(v)
	{
		f[v]=true;
		dia.push_back(v);
		v=par[v];
	}
	int lt=1;
	for(int i=0;i<dia.size();i++)
	{
		int cur=dia[i];
		int nw=lt+1;
		for(int j=0;j<G[cur].size();j++)
		{
			int nxt=G[cur][j];
			if(f[nxt])continue;
			if(G[nxt].size()>1)
			{
				printf("-1");
				return 0;
			}
			a.push_back(nw++);
		}
		a.push_back(lt);
		lt=nw;
	}
	reverse(dia.begin(),dia.end());
	lt=1;
	for(int i=0;i<dia.size();i++)
	{
		int cur=dia[i];
		int nw=lt+1;
		for(int j=0;j<G[cur].size();j++)
		{
			int nxt=G[cur][j];
			if(f[nxt])continue;
			b.push_back(nw++);
		}
		b.push_back(lt);
		lt=nw;
	}
	for(int i=0;i<n;i++)
	{
		if(a[i]<b[i])break;
		if(a[i]>b[i])
		{
			a=b;break;
		}
	}
	for(int i=0;i<n;i++)printf("%d ",a[i]);
	return 0;
} 

Measured memory_bytes: 14712
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int A, B;
   cin >> A >> B;
   string S;
   cin >> S;
   bool flg = true;
   for (int i = 0; i < S.size(); i++) {
      if (i == A) {
         if (S[i] != '-') flg = false;
      }
      if (i != A) {
         if (S[i] == '-') flg = false;
      }
   }
   if (flg) cout << "Yes" << endl;
   else cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 256
// The moment you think of giving up you have already lost the battle
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define Mod 1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}
const ll N=1e7+5;
ll  dp[N+1]={0};
int main()
{
    ll n,m,K;
    cin>>n>>m>>K;
    ll A[n],B[m];
    ll i,j;
    ll pr[n+1],sf[m+1];
    pr[0]=0;
    sf[0]=0;
    for(i=0;i<n;i++)
    {
        cin>>A[i];
    }
    for(i=0;i<m;i++)
    {
        cin>>B[i];
    }
    ll ans=0;
    for(i=1;i<=n;i++)
    {
        pr[i]=pr[i-1]+A[i-1];
        if(pr[i]<=K)
            ans=max(ans,i);

    }
    for(i=1;i<=m;i++)
    {
        sf[i]=sf[i-1]+B[i-1];
        if(sf[i]<=K)
            ans=max(ans,i);
    }

    for(i=1;i<=m;i++)
    {
        ll d=K-sf[i];
        if(d<0)
        {
            break;
        }
        else if(d==0)
        {
            ans=max(ans,i);
            break;
        }
        else
        {
            ll lo=1,hi=n;
            ll ind=-1,mid;
            while(lo<=hi)
            {
                mid=(lo+hi)/2;
                if(pr[mid]<=d)
                {
                    ind=mid;
                    lo=mid+1;
                }
                else
                {
                    hi=mid-1;
                }
            }
            if(ind!=-1)
            {
                ans=max(ans,i+ind);
            }
        }
    }
    cout<<ans;



}


Measured memory_bytes: 9768
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next(), m = next();
  var g = xArray("[]",n);
  for(var i = 0; i < m; i++){
    var a = next()-1, b = next()-1;
    g[a].push(b);
    g[b].push(a);
  }
  var q = next();
  var r = nextm(q,3);
  var dp = xArray(-1,n,11);
  for(var i = q; i--;){
    var x = [r[i][0]-1,r[i][1]],id=0;
    while(x.length > id){
      var v = x[id], d = x[id+1];
      id += 2;
      if(dp[v][d] >= i)continue;
      for(var j = d; j >= 0; j--){
        if(dp[v][j] < i)dp[v][j] = i;
      }
      if(d-- === 0)continue;
      for(var j = 0; j < g[v].length; j++){
        var V = g[v][j];
        if(dp[V][d] < i)x.push(V,d);
      }
    }
  }
  var ans = Array(n);
  for(var i = 0; i < n; i++)ans[i] = dp[i][0] < 0 ? 0 : r[dp[i][0]][2];
  return ans.join("\n");
}

Measured memory_bytes: 123176
import sys
input = sys.stdin.readline

X, Y, Z, K = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

a.sort(reverse=True)
b.sort(reverse=True)

ablst = [m + n for n in b for m in a]

ablst.sort(reverse=True)

c.sort(reverse=True)

abclst = [m + n for n in c[:K] for m in ablst[:K]]

abclst.sort(reverse=True)

print(*abclst[:K], sep='\n')


Measured memory_bytes: 207536