akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
typedef long long ll;
ll dp[100001];
int main(void){
    int n,w;
    cin>>n>>w;
    for(int i=0;i<n;i++){
        ll g,v;
        cin>>g>>v;
        for(int j=w;j>=g;j--){
            dp[j]=max(dp[j],dp[j-g]+v);
        }
    }
    cout<<dp[w]<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define rep2(i,x,n) for(int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vvl = vector<vl>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k; 
ll INF = 10000000000000000;



int main(){
    string S,T;
    cin >>S>>T;
    int n =T.size();
    T = T.substr(0,n-1);
    if(S==T) cout <<"Yes"<<endl;
    else cout <<"No"<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef pair<int,int> P;
struct edge {
	int to,cap,cost,rev;
	edge(int a,int b,int c,int d) : to(a),cap(b),cost(c),rev(d){}
};
const int MAX_V=101,INF=2e8,inf=1e6;
int V;			//??£??\!!
vector<edge> G[MAX_V];
int h[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];
void add_edge(int from, int to, int cap, int cost){
	edge e1=edge(to,cap,cost,G[to].size()),e2=edge(from,0,-cost,G[from].size());
//	printf("%d->%d   cap=%d   cost=%d\n",from,to,cap,cost);
	G[from].push_back(e1);
	G[to].push_back(e2);
}
void add_edge_lbub(int from,int to,int lb,int ub,int cost){
	add_edge(from,to,ub-lb,cost);
	add_edge(from,to,lb,cost-inf);
}
int min_cost_flow(int s, int t){
	int res=0;
	fill(h,h+V,INF);
	h[0]=0;
	rep(v,V){
		for(edge& e:G[v]) if(e.cap!=0) chmin(h[e.to],h[v]+e.cost);
	}
//	rep(v,V) printf("h[%d]=%d\n",v,h[v]);
	int f=INF;
	while(h[t]<0){
		priority_queue< P,vector<P>,greater<P> > que;
		fill(dist,dist+V,INF);
		dist[s]=0;
		que.push(P(0,s));
		while(!que.empty()){
			P p=que.top();
			que.pop();
			int v=p.second;
			if(dist[v]<p.first) continue;
			for(int i=0;i<G[v].size();i++){
				edge &e=G[v][i];
				if(e.cap>0 && dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
					dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
					prevv[e.to]=v;
					preve[e.to]=i;
					que.push(P(dist[e.to],e.to));
				}
			}
		}
		if(dist[t]==INF) return -1;
		for(int v=0;v<V;v++) h[v]+=dist[v];
		int d=f;
		for(int v=t;v!=s;v=prevv[v]){
			d=min(d,G[prevv[v]][preve[v]].cap);
		}
		f-=d;
		res+=d*h[t];
		for(int v=t;v!=s;v=prevv[v]){
			edge &e=G[prevv[v]][preve[v]];
			e.cap-=d;
			G[v][e.rev].cap+=d;
		}
	}
	return res;
}
vector<P> GG[100];
int main(){
	int N,M;
	cin>>N>>M;
	rep(i,M){
		int x,y,s;
		cin>>x>>y>>s;
		add_edge_lbub(x,y,1,INF,-s);
		GG[x].pb(P(y,s));
	}
	int S=0,T=N;
	V=N+1;
	int D=0;
	{
		int d[101]={};
		rep(i,N){
			for(P e:GG[i]){
				chmax(d[e.fs],d[i]+e.sc);
			}
		}
		D=d[N-1];
	}
//	show(D);
	add_edge(N-1,N,INF,D);
	cout<<min_cost_flow(S,T)+M*inf<<endl;
}

Measured memory_bytes: 1344
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N, M, Q;
    cin >> N >> M >> Q;
    int a[Q], b[Q], c[Q], d[Q];
    rep(i, Q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }
    vector<vector<int>> v[N];
    rep(i, M){
        vector<int> a;
        a.pb(i);
        v[1].pb(a);
    }
    rep2(i, 1, N-2){
        rep(j, v[i].size()){
            int sum = 0;
            for(auto &e: v[i][j]) sum += e;
            rep(k, M-sum){
                vector<int> memo = v[i][j];
                memo.pb(k);
                v[i+1].pb(memo);
            }
        }
    }
    int ans = 0;
    rep(i, v[N-1].size()){
        int A[N], sum = 0;
        A[0] = 0;
        rep(j, N-1) A[j+1] = A[j]+v[N-1][i][j];
        rep(k, Q){
            if((A[b[k]]-A[a[k]]) == c[k]) sum += d[k];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9672
while True:
    try:
        m = int(raw_input())
        a = sorted([list(map(int, raw_input().split())) for i in xrange(m)])
        dax = [a[i][0]-a[0][0] for i in xrange(m)]
        n = int(raw_input())
        b = sorted([list(map(int, raw_input().split())) for i in xrange(n)])
        bx = [b[i][0] for i in xrange(n)]
        for i in xrange(n-m+1):
            for j in xrange(m):
                if bx[i]+dax[j] not in bx:
                    break
            else:
                print b[i][0]-a[0][0],b[i][1]-a[0][1]
                break
    except:
        break

Measured memory_bytes: 4484
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
   	ll n,k;
  	cin>>n>>k;
  	ll ans=0;
  	ll vall,valh,store;
  	for(ll i=k;i<=n+1;i++)
  	{
    	valh= i*n;
      	valh -= (i*(i-1))/2;
      	vall = (i*(i-1))/2;
 	    store= (valh-vall)+1 ;
     	store%= MOD;
      	ans+=store;
      	ans%=MOD;
  	}
  cout<<ans;
   return 0;
}
    



Measured memory_bytes: 3632
var
	n,a,b,c,d,c1,c1m,c2,c2m,dif:longint;
begin
	Readln(n, a, b, c, d);
	dif := abs(b - a);
	c1 := ((dif + ((n + 1) mod 2) * c) div (c * 2)) * 2 - ((n + 1) mod 2);
	c2 := c1 + 2;
	c1m := ((n - 1) + c1) div 2;
	c2m := (n - 2) - c1m;
	if (((n - 1) * c <= dif) and (dif <= (n - 1) * d)) or 
		((c1 <= (n - 1)) and (dif <= c1 * c + c1m * (d - c))) or
		((c2 <= (n - 1)) and (c2 * c - c2m * (d - c) <= dif)) then
		Writeln('YES')
	else
		Writeln('NO');
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(x) for(auto it=(x).begin();it!=(x).end();it++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
//#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

string s[12];
void dfs(int y,int x){
    s[y][x]='0';
    rep(i,0,4){
        int ny=y+dy[i],nx=x+dx[i];
        if(0<=ny && 0<=nx && ny<12 && nx<12 && s[ny][nx]=='1'){
            dfs(ny,nx);
        }
    }
    return;
}

int main(){
    while(cin>>s[0]){
        int ans=0;
        rep(i,1,12)cin>>s[i];
        rep(i,0,12){
            rep(j,0,12){
                if(s[i][j]=='1'){
                    ans++;
                    dfs(i,j);
                }
            }
        }
        cout<<ans<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3076
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long MOD = 1000000007;

        public void Run()
        {
            var line = Input.ReadIntArray();
            int A = line[0];
            int P = line[1];

            P += 3 * A;
            Console.WriteLine(P / 2);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;


int main(){
  vector<string> s{"dream", "dreamer", "erase", "eraser"};
  for(int i=0; i<4; i++){
    reverse(s[i].begin(),s[i].end());
  }
  string S;
  cin >> S;
  reverse(S.begin(),S.end());
  bool ok = true;
  for(int i=0; i<(int)S.size();){
    bool can = false;
    for(int j=0; j<4; j++){
      int n;
      n = s[j].size();
      if(S.substr(i,n) == s[j]){
        can = true;
        i += n;
      }
    }
    if(!can){
      ok = false;
      break;
    }
  }
  if(ok){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 512
L, R = map(int, input().split())
div = 2019
min_mod = div - 1
flag = False

for i in range(L, R):
  for j in range(i+1, R+1):
    mod = (i * j) % div
    if mod == 0:
      min_mod = mod
      flag = True
    elif mod < min_mod:
      min_mod = mod
    if flag:
      break
  if flag:
    break
    
print(min_mod)

Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<vector>
#include<map>
using namespace std;
#define NIL -2000000001
#define MAX 200000
#define M 1000000007

long long h,w,k;
long long dp[101][8]; // DPテーブル

long long hiki(long long i) {
  if (i == 0) return 1;
  if (i == 1) return 1;
  if (i == 2) return 2;
  if (i == 3) return 3;
  if (i == 4) return 5;
  if (i == 5) return 8;
  if (i == 6) return 13;
  if (i == 7) return 21;
  return 0;
}

void solve() {
  dp[0][0] = 1;
  for (long long j = 1; j < w; j++) {
    dp[0][j] = 0;
  }
  for (long long i = 0; i < h; i++) {
    for (long long j = 0; j < w; j++) {
      dp[i+1][j] = dp[i][j]*hiki(j)*hiki(w-(j+1)) % M;
      if (j-1 >= 0) {
        dp[i+1][j] = (dp[i+1][j]+dp[i][j-1]*hiki(j-1)*hiki(w-(j+1))) % M;
      } else {

      }
      if (j+1 < w) {
        dp[i+1][j] = (dp[i+1][j]+dp[i][j+1]*hiki(j)*hiki(w-(j+2))) % M;
      }
    }
  }

}

int main() {
  scanf("%lld %lld %lld", &h, &w, &k);
  solve();

  printf("%lld\n", dp[h][k-1]);

  return 0;
}


Measured memory_bytes: 888
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,m,q; cin>>n>>m>>q;
    vector<vector<int>> rail(n,vector<int>(n,0));
    rep(i,m){
        int l,r; cin>>l>>r;
        rail[l-1][r-1]++;
    }
    if(n>1){
        rep(i,n-1) rail[i][i+1]+=rail[i][i]+rail[i+1][i+1];
    }
    for(int i=2;i<n;i++){
        rep(j,n-i){
            rail[j][j+i]+=rail[j][j+i-1]+rail[j+1][j+i]-rail[j+1][j+i-1];
        }
    }
    rep(i,q){
        int a,b; cin>>a>>b;
        cout<<rail[a-1][b-1]<<endl;
    }
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll H, W;
    ll kore[53][53];
    int ba[53][53];
    MEMSET(kore, 0);
    MEMSET(ba, 0);
    cin>>H>>W;
    rep1(i,H){
        string S;
        cin>>S;
        rep1(j, W){
            if(S[j-1]=='#'){
                ba[i][j]=1;
                kore[i+1][j+1]++;
                kore[i+1][j-1]++;
                kore[i-1][j-1]++;
                kore[i-1][j+1]++;
                kore[i+1][j]++;
                kore[i-1][j]++;
                kore[i][j-1]++;
                kore[i][j+1]++;
            }
        }
    }
    rep1(i, H){
        rep1(j,W){
            if(ba[i][j]==0) cout<<kore[i][j];
            else cout<<"#";
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
using namespace std;
const int INF = 1e9;
typedef long long lint;
const lint LINF = 1e18;
const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}
 
int main(){
	int N; cin >> N;
    vector<long long> a(N);
    long long ans = 0;
    rep(i,N){
        cin >> a[i];
        ans += a[i] - 1;
    }
    cout << ans << endl;
}


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

int main() {
	int n, g, k;
	cin >> n;
	g = n / 2;
	k = (n + 1) / 2;
	cout << g * k << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  int n = (int) s.size();
  vector<vector<int>> v(26);
  for (int i = 0; i < n; i++) v[s[i] - 'a'].push_back(i);
  for (int i = 0; i < 26; i++) v[i].push_back(n);
  vector<int> dp(n + 1);
  dp[n] = 1;
  for (int i = n - 1; i >= 0; i--) {
    int mi = 1 << 30;
    for (int j = 0; j < 26; j++) {
      auto it = upper_bound(v[j].begin(), v[j].end(), i);
      mi = min(mi, dp[*it]);
    }
    dp[i] = mi + 1;
  }
  string ans;
  int cur = -1;
  while (cur < n) {
    int len = 1 << 30;
    char ch;
    int nxt;
    for (int i = 0; i < 26; i++) {
      auto it = upper_bound(v[i].begin(), v[i].end(), cur);
      if (dp[*it] < len) {
        len = dp[*it];
        nxt = *it;
        ch = i + 'a';
      }
    }
    cur = nxt;
    ans += ch;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    ll a;
    cin>>a;
    string s;
    string t;
    vector<string> k(2*a);
    cin>>s>>t;
    rep(i,a){
        k[2*i]=s[i];
        k[2*i+1]=t[i];
    }
    rep(i,2*a){
      cout<<k[i];
    }
}

Measured memory_bytes: 3512
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
#define INF 2147483647
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;



int main(){
	
	int n,a[222222];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]-=i+1;
	}
	sort(a,a+n);
	int num;
	if(n%2==0)num=a[n/2-1];
	else num=a[n/2];
		
	ll ans=0;
	for(int i=0;i<n;i++){
		ans+=abs(a[i]-num);
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ld Calc_Dist (ld X1, ld Y1, ld X2, ld Y2){
  ld ans = (X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2);
  ans = sqrtl(ans);
  return ans;
}

int main(){
  const ld EPS = 1e-8;
  int N, K; cin >> N >> K;

  ld X[N], Y[N], C[N];
  for (int i = 0; i < N; i++){
    cin >> X[i] >> Y[i] >> C[i];
  }

  ld L = 0, R = 1e10;
  while (R - L > EPS){
    ld now = (L + R) / 2;

    vector <pair<ld, ld>> Cand;


    for (int i = 0; i < N; i++){
      Cand.push_back(make_pair(X[i], Y[i]));
      for (int j = i + 1; j < N; j++){
        ld Ri = now / C[i], Rj = now / C[j];
        ld Dist = Calc_Dist(X[i], Y[i], X[j], Y[j]);

        if (Dist < abs(Ri - Rj) - EPS) continue;
        if (Dist > Ri + Rj + EPS) continue;

        double theta = atan((Y[j] - Y[i]) / (X[j] - X[i]));
        
        if (X[j] - X[i] <= 0) theta += PI;
        else if (Y[j] - Y[i] <= 0) theta += 2 * PI;

        double phi = acos((Ri * Ri + Dist * Dist - Rj * Rj) / (2 * Ri * Dist));

        double Xnow = X[i] + Ri * cos(theta + phi);
        double Ynow = Y[i] + Ri * sin(theta + phi);
        Cand.push_back(make_pair(Xnow, Ynow));

        Xnow = X[i] + Ri * cos(theta - phi);
        Ynow = Y[i] + Ri * sin(theta - phi);
        Cand.push_back(make_pair(Xnow, Ynow));
      }
    }
    
    bool flag = false;
    for (int i = 0; i < Cand.size(); i++){
      int cnt = 0;
      ld X_now = Cand[i].first, Y_now = Cand[i].second;

      for (int j = 0; j < N; j++){
        ld Dist = Calc_Dist(X_now, Y_now, X[j], Y[j]);
        if (Dist <= now / C[j] + EPS) cnt++;
      }
      if (cnt >= K) flag = true;
    }
    
    if (flag == true) R = now;
    else L = now;
  }
  cout << setprecision(16) << (L + R) / 2 << endl;

  return 0;
}


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

namespace AtCoderBeginner
{
    class Program
    {
        static void Main(string[] args)
        {
            //O >= E
            string O, E;
            string psw = null;

            O = Console.ReadLine();
            E = Console.ReadLine();
            
            for(int i = 0; i < E.Length; i++)
            {
                psw += O[i];
                psw += E[i];
            }

            if(O.Length != E.Length)
            {
                psw += O[O.Length - 1];
            }

            Console.WriteLine(psw);
        }
    }
}


Measured memory_bytes: 11092
n, k, c = map(int, input().split())
s = input()
sub = []
key = -1
for i in range(n):
  if s[i] == "o" and (key == -1 or key+c+1 <= i):
    sub.append(i+1)
    key = i
  if len(sub) == k:
    break

sub2 = []
key = -1
for i in range(n-1, -1, -1):
  if s[i] == "o" and (key == -1 or key-c-1 >= i):
    sub2.append(i+1)
    key = i
  if len(sub2) == k:
    break

sub2.reverse()
ans = []
for i in range(k):
  if sub[i] == sub2[i]:
    ans.append(sub[i])

for value in ans:
  print(value)

Measured memory_bytes: 22284
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

typedef long long ll;

constexpr ll MAX_N = 2000;

ll N;
bitset<MAX_N * MAX_N> b;

int main(void) {
    cin >> N;
    ll sum = 0;
    b[0] = 1;
    for (ll i = 0; i < N; i++) {
        ll a;
        cin >> a;
        sum += a;
        b |= (b << a);
    }

    for (ll i = (sum + 1) / 2; i <= sum; i++) {
        if (b[i]) {
            cout << i << endl;
            return 0;
        }
    }
}



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

int main() {
  int K;
  string S;
  cin >> K >> S;

  if (S.size() <= K){
    cout << S << endl;
  }else{
    for(int i=0; i<K; i++){
      cout << S.at(i) ;
    }
    cout << "..." <<endl;
  }
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<map>
#include<functional>
using namespace std;

const int dev = 1e9+7;
typedef unsigned long long ull;

int main(){
    ull N, x;
    cin >> N >> x;
    vector<ull> a(N);
    for (int i=0;i<N;i++){
        cin >> a[i];
    }

    ull S = 0;
    ull tmp;
    for (int i=0;i<N-1;i++){
        if(a[i] + a[i+1] > x) {
            if((a[i] + a[i+1] - x) <= a[i+1]){
                tmp = a[i] + a[i+1] - x;
                a[i+1] -= tmp;
                S += tmp;
            }else{
                S += a[i+1];
                a[i+1] = 0;
                tmp = a[i] - x;
                a[i] -= tmp;
                S += tmp;
            }
        }
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int k; cin >> k;
    cout << (k/2) * ((k-1)/2 + 1) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
int n,a[100005];long long ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    for(int i=1;i<=n;i++){
        if((a[i]&1)&&(a[i+1]&1)) a[i]--,a[i+1]--,ans++;
        if(a[i]%2!=0&&a[i+1]>0&&a[i+1]%2==0) a[i]--,a[i+1]--,ans++;
        ans+=a[i]/2;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 512
///////////////////////////////////////////// Template /////////////////////////////////////////////
#![allow(non_snake_case, unused_imports)]
use std::io::Write;
use std::collections::*;
use template::*;

#[macro_use]
pub mod template {
	macro_rules! debug {
	    ($($v: expr),*) => {
	    	$(let _ = write!(std::io::stderr(), "{} = {:?} ", stringify!($v), $v);)*
	        let _ = writeln!(std::io::stderr(), "@ {}:{}", file!(), line!());
	    }
	}
	macro_rules! mat {
		($e:expr) => { $e };
		($e:expr; $d:expr $(; $ds:expr)*) => { vec![mat![$e $(; $ds)*]; $d] };
	}
	pub trait FromLn {
		fn fromln(s: &str) -> Self;
	}	
	pub fn readln<T: FromLn>() -> T {
		let mut buf = String::new();
		let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
		T::fromln(buf.trim())
	}
	pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
		let mut vs = vec![];
		for _ in 0..n { vs.push(readln()); }
		vs
	}
	macro_rules! fromln_primitives {
		($($t:ty),*) => { $(
			impl FromLn for $t {
				fn fromln(s: &str) -> $t {
					s.parse().unwrap()
				}
			}
		)* }
	}
	fromln_primitives!(String, bool, f32, f64, isize, i8, i16, i32, i64, usize, u8, u16, u32, u64);
	impl<T> FromLn for Vec<T> where T: FromLn {
		fn fromln(s: &str) -> Vec<T> {
			s.split_whitespace().map(T::fromln).collect()
		}
	}
	impl FromLn for Vec<char> {
		fn fromln(s: &str) -> Vec<char> {
			s.chars().collect()
		}
	}
	macro_rules! fromln_tuple {
		($($t:ident: $i:expr),*; $n:expr) => {
			impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
				fn fromln(s: &str) -> ($($t),*) {
					let ss = s.split_whitespace().collect::<Vec<_>>();
					assert_eq!(ss.len(), $n);
					($($t::fromln(ss[$i])),*)
				}
			}
		}
	}
	fromln_tuple!(A:0, B:1; 2);
	fromln_tuple!(A:0, B:1, C:2; 3);
	fromln_tuple!(A:0, B:1, C:2, D:3; 4);
	pub trait SetMin {
		fn setmin(&mut self, v: Self) -> bool;
	}
	impl<T> SetMin for T where T: PartialOrd {
		fn setmin(&mut self, v: T) -> bool {
			*self > v && { * self = v; true }
		}
	}
	pub trait SetMax {
		fn setmax(&mut self, v: Self) -> bool;
	}
	impl<T> SetMax for T where T: PartialOrd {
		fn setmax(&mut self, v: T) -> bool {
			*self < v && { * self = v; true }
		}
	}
}
fn main() {
	let _ = writeln!(std::io::stderr(), "----- {} -----", file!());
	let _ = std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}
////////////////////////////////////////////////////////////////////////////////////////////////////

fn run() {
	let s: String = readln();
	println!("{}", s.rfind('Z').unwrap() - s.find('A').unwrap() + 1);
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int MX = 100 * 1000 + 7;
const int INF = 1000 * 1000 * 1000 + 7;
vector<pair<int, int> > g[MX];
int dist[MX];
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            g[i].emplace_back((10 * i + j) % n, j);
        }
    }
    for (int j = 1; j < 10; j++) {
        g[n].emplace_back(j % n, j);
    }
    for (int i = 0; i <= n; i++) {
        dist[i] = INF;
    }
    dist[n] = 0;
    set<pair<int, int> > heap;
    for (int i = 0; i <= n; i++) {
        heap.emplace(dist[i], i);
    }
    while (!heap.empty()) {
        int v = (*heap.begin()).second;
        heap.erase(heap.begin());
        for (auto to : g[v]) {
            if (dist[to.first] > dist[v] + to.second) {
                heap.erase({dist[to.first], to.first});
                dist[to.first] = dist[v] + to.second;
                heap.emplace(dist[to.first], to.first);
            }
        }
    }
    printf("%d\n", dist[0]);
}



Measured memory_bytes: 21760
h,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(h)]
ans=[]
for i in range(h):
  for j in range(w-1):
    if a[i][j]%2==1:
      a[i][j]-=1
      a[i][j+1]+=1
      ans.append('%d %d %d %d'%(i+1,j+1,i+1,j+2))
for i in range(h-1):
  if a[i][w-1]%2==1:
    a[i][w-1]-=1
    a[i+1][w-1]+=1
    ans.append('%d %d %d %d'%(i+1,w,i+2,w))
print(len(ans))
for i in ans:
  print(i)

Measured memory_bytes: 16408
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  long long n,k,i,j,res=0;
  cin >> n;
  k=(long long)sqrt(n);
  for(i=1;i<=k;i++){
    if(n%i!=0) continue;
    j=n/i-1;
    if(j>i) res+=j;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

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

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

  if(a > b){
    int t;
    t = a;
    a = b;
    b = t;
  }

  if(b > c){
    int t;
    t = b;
    b = c;
    c = t;
  }

  if(a > b){
    int t;
    t = a;
    a = b;
    b = t;
  }
 
  printf("%d %d %d\n", a, b, c);

  /*
  if(a < b && a < c){
    if(b < c){
      printf("%d %d %d\n",a,b,c);
    }
    else{
      printf("%d %d %d\n",a,c,b);
    }
  }

  if(b < a && b < c){
    if(a < c){
      printf("%d %d %d\n",b,a,c);
    }
    else{
      printf("%d %d %d\n",b,c,a);
    }
  }

  if(c < a && c < b){
    if(a < b){
      printf("%d %d %d\n",c,a,b);
    }
    else{
      printf("%d %d %d\n",c,b,a);
    }
  }
  */

  return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
inline ll read(){
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,k;
int main(){
	n=read(),k=read();
	printf("%d\n",n-k+1);
	return 0;
}




Measured memory_bytes: 3700
#include <limits>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <vector>

using namespace std;

template<class F>
void times_do(size_t n, F func)
{
    for(size_t i = 0; i < n; ++i) func();
}

template<class T>
T read()
{
    T value;
    std::cin >> value;
    return value;
}

template<class T>
vector<T> reads(size_t n)
{
    vector<T> a;
    a.reserve(n);
    times_do(n, [&](){
        a.push_back(read<T>());
    });
    return a;
}

template<class T>
vector<vector<T>> reads(size_t n, size_t m)
{
    vector<vector<T>> a;
    a.reserve(n);
    times_do(n, [&](){
        a.push_back(reads<T>(m));
    });
    return a;
}

static int distance_map[50][50];

using field_t = vector<vector<char>>;

int search(const field_t& field, int s, int x, int y, int w, int h)
{
    if(x == w-1 && y == h-1)
        return s;
    
    distance_map[x][y] = s;

    int dx[] = {1, 0, -1, 0};
    int dy[] = {0, 1, 0, -1};
    int min_d = INT32_MAX;
    for(int i = 0; i < 4; ++i)
    {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(0 <= nx && nx < w && 0 <= ny && ny < h)
        {
            if(field[ny][nx] != '#')
            {
                if(distance_map[nx][ny] > s + 1)
                    min_d = min(min_d, search(field, s + 1, nx, ny, w, h));
            }
        }
    }

    return min_d;
}

void reset()
{
    for(auto& row : distance_map)
        for(auto& cell : row)
            cell = INT32_MAX;
}

int count_floor(const field_t& field, int w, int h)
{
    int c = 0;
    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j)
            if(field[i][j] == '.')
                c++;
    return c;
}

int main()
{
    const size_t h = read<size_t>();
    const size_t w = read<size_t>();
    auto s = reads<char>(h, w);
    
    reset();
    
    const auto d = search(s, 0, 0, 0, w, h);
    
    if(d == INT32_MAX)
    {
        cout << "-1\n";
        return 0;
    }

    cout << (count_floor(s, w, h) - d - 1) << '\n';

    return 0;
}


Measured memory_bytes: 512
import sys
N, Y = map(int, input().split())

for m in range(N+1):
    for g in range(N-m+1):
        s = N - m - g
        if Y == 10000*m + 5000*g + 1000*s:
            print(m, g, s)
            sys.exit()

print(-1, -1, -1)

Measured memory_bytes: 40684
#include<bits/stdc++.h>
using namespace std;
const int q=1000000007;
int n,m,t,f[4010][2010],p;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k;
	scanf("%d%d%d",&n,&m,&t);
    if(!n || !m)
      p=1;
	f[0][0]=1;
	for(i=1;i*(t-1)<=n+m-1;i++)
	  for(j=0;j<=(i-1)*(t-1);j++)
	    for(k=0;k<=t-1;k++)
	      if(j+k<=n && i*(t-1)+1-j-k<=m)
	        {
             f[i][j+k]=(f[i][j+k]+f[i-1][j])%q;
             if(k && (n-j-k)%(t-1)==0)
               p=(p+f[i-1][j])%q;
            }
    printf("%d\n",p);
	return 0;
}


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

int main() {
  int64_t n, k;
  cin >> n >> k;
  
  n -= (n / k) * k;
  //cout << "result: " << n << endl;
  
  int64_t num = n - k;  
  if (num < 0) {
    num *= -1;
    if (num >= n) {
      cout << n << endl;
    }
    else {
      cout << num << endl;
    }
  }
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        BigInteger x[] = new BigInteger[N];
        BigInteger y[] = new BigInteger[N];
        for (int i=0; i<N; i++) {
            x[i] = new BigInteger(sc.next());
            y[i] = new BigInteger(sc.next());
        }
        sc.close();

        double sum = 0.0;
        for (int i=0; i<N; i++) {
            for (int j=0; j<N; j++) {
                if (j==i)
                    continue;
                sum += Math.pow(Math.pow(x[i].intValue()-x[j].intValue(), 2)+Math.pow(y[i].intValue()-y[j].intValue(),2), 0.5);
            }
        }
        System.out.println(sum/N);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define REP0(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REP1(i,n) for((i)=1;(i)<=(int)(n);(i)++)
#define ll long long
using namespace std;

int i,j,k;
const ll MOD = 1000000000 + 7;

int main(){
    int n,w,ans,l;
    ans=0;
    l=1;
    cin>>n>>w;
    while(true){
        if(l>=w){
            break;
        }
        else{
            l+=n-1;
            ans++;
        }
    }


    

    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

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

	int n;
	cin >> n;
	vector<int> a( n );
	for( auto& v: a ) { cin >> v; }

	int q;
	cin >> q;
	while( q-- > 0 ) {
		int k;
		cin >> k;
		auto p = equal_range( a.begin(), a.end(), k );
		cout << p.first - a.begin() << ' ' << p.second - a.begin() << '\n';
	}

	return 0;
}



Measured memory_bytes: 3360
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
int q, x, y, f[107], sum;
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int dfs(int a, int b, int d)
{
	if (a * f[d - 1] + b * (d > 1 ? f[d - 2] : 0) > x || a * f[d] + b * f[d - 1] > y)
		return 0;
	if (d == 1)
	{
		if (x >= a + b)sum = (sum + (x - b) / a % mod) % mod;
		sum = (sum + (y - b) / a % mod) % mod;
		return 1;
	}
	int i = 1 + (b == 0);
	while (1)
	{
		if (!dfs(b + i * a, a, d - 1))return i > 1;
		i++;
	}
}
signed main()
{
	q = read();
	f[0] = f[1] = 1;
	for (int i = 2; i <= 88; i++)
		f[i] = f[i - 1] + f[i - 2];
	for (int lp = 1; lp <= q; lp++)
	{
		x = read();
		y = read();
		if (x > y)swap(x, y);
		if (x == 1) { printf("1 %lld\n", y % mod); continue; }
		int res = 0;
		while (x >= f[res] && y >= f[res + 1])
			res++;
		res--;
		sum = 0;
		dfs(1, 0, res);
		printf("%lld %lld\n", res, sum);
	}
	return 0;
}

Measured memory_bytes: 3968
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
typedef pair<int, P> PP;
struct edge { int u, v, cost; };

int a[35][35];
int dp[35][35][901];
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };

signed main() {
	int h, w; cin >> h >> w;
	rep(i, h)rep(j, w)cin >> a[i][j];
	rep(i, h)rep(j, w)rep(k,w*h+1)dp[i][j][k] = 1145141919;
	dp[0][0][0] = 0;

	rep(k, h*w) {
		rep(i, h) {
			rep(j, w) {
				rep(l, 4) {
					int ni = i + dx[l], nj = j + dy[l];
					if (0 <= ni&&ni < h && 0 <= nj&&nj < w) {
						dp[ni][nj][k + 1] = min(dp[ni][nj][k + 1], dp[i][j][k] + (2 * k + 1)*(a[ni][nj]));
					}
				}
			}
		}
	}
	int ans = 1145141919;
	rep(i, h*w+1)ans = min(ans, dp[h - 1][w - 1][i]);

	cout << ans << endl;
}



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

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795

ll f(ll a)
{
  ll cnt=0,i;
  if (a==2)return 1;
  for(i=2;i*i<a;i++)
  {
if(a%i==0)cnt+=2;
  }
  if(i*i==a)cnt++;
  return cnt;
}

//vl a(1001);

ll powM(ll a,ll b, ll m)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans%m;
}
 vector<ll>fac(200001),invf(200001);

ll c(ll n,ll r,ll p){
return ((fac[n]*invf[r]%p)*(invf[n-r]))%p;
}
int main()
{
  ll n,m,k;
  cin>>n>>m>>k;
  ll p=998244353;
 
fac[0]=1;
invf[0]=1;

for(int i=1;i<=n;i++)
{
     fac[i]=fac[i-1]*i%p;
     invf[i]=powM(fac[i],p-2,p);
}
ll total=0;
//cout<<c(5,4,p)<<"\n";
for(int i=0;i<=k;i++)
{
ll a=c(n-1,i,p);
ll b=powM(m-1,n-1-i,p);
ll temp=((a*b)%p*m)%p;
total=(total+temp)%p;

}

cout<<total<<"\n";

  return 0;
}



Measured memory_bytes: 6292
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long ll;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

int main() {

    vector<int> a(3);
    REP(i,3) cin >> a[i];

    int t = 0;
    REP(i,a.size()) {
        t *= 10;
        t += a[i];
    }

    if(t % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) begin(c), end(c)
#define ok() puts(ok?"Yes":"No");
template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

ll N;
int main() {
  cin >> N;
  int mod = 1e9 + 7;
  ll a = 1;
  ll b = 1;
  ll c = 1;
  rep(i,N) {
    (a*=10) %= mod;
    (b*=9) %= mod;
    (c*=8) %= mod;
  }
  ll ans = (a  + c - (b*2%mod)) % mod;
  if (ans < 0) ans += mod;
  printf("%lld\n", ans);
  return 0;
}

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

int main()
{
	int W = 0, H = 0, x = 0, y = 0, r = 0;

	cin >> W >> H >> x >> y >> r;

	if(((x >= r && x <= W - r) && y >= r) && y <= H - r)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

    return 0;
}

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

template <int MOD_> struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");
 
private:
	using ll = long long;
 
	int v;
 
	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}
 
public:
 
	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }
 
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }
 
	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
 
	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}
 
	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}
 
	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<int(1e9) + 7>;

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

	int N[2]; cin >> N[0] >> N[1];
	num prod = 1;
	for (int z = 0; z < 2; z++) {
		num sum = 0;
		int prv = 0;
		for (int i = 0; i < N[z]; i++) {
			int v; cin >> v;
			if (i) {
				sum += num(v - prv) * i * (N[z] - i);
			}
			prv = v;
		}
		prod *= sum;
	}

	cout << prod << '\n';

	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

struct Doubling {
    int sz, n;
    vector<vector<int>> table;
    Doubling(int n, long long ma = 1LL << 62) : sz(0), n(n) {
        while ((1LL << sz) < ma) ++sz;    // 64 - __builtin_clzll(ma)
        table.assign(sz, vector<int>(n, -1));
    }
    void set_next(int i, int x) { table[0][i] = x; }
    void build() {
        for (int k = 0; k < sz - 1; k++) for (int i = 0; i < n; i++) {
            if (~table[k][i]) table[k + 1][i] = table[k][table[k][i]];
        }
    }
    int query(int i, long long t) {
        for (int k = sz - 1; k >= 0; k--) {
            if (t >> k & 1) i = table[k][i];
        }
        return i;
    }
    long long lower_bound(int s, int t) {
        if (s == t) return 0;
        if (s > t) swap(s, t);
        long long ret = 1;
        for (int k = sz - 1; k >= 0; k--) {
            if (table[k][s] < t) ret += 1LL << k, s = table[k][s];
        }
        return ret;
    }
};

int main() {
    int n; cin >> n;
    vector<int> x(n);
    for (int &xi: x) cin >> xi;
    int l; cin >> l;
    Doubling dbl(n);
    int nxt = 0;
    for (int i = 0; i < n; i++) {
        while (nxt + 1 < n && x[nxt + 1] - x[i] <= l) nxt++;
        dbl.set_next(i, nxt);
    }
    dbl.build();
    int q; cin >> q;
    while (q--) {
        int a, b; cin >> a >> b; a--, b--;
        cout << dbl.lower_bound(a, b) << endl;
    }
    return 0;
}

Measured memory_bytes: 25464
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
pair<int,int> V[55];
map<int,int> X,Y;
int invX[55],invY[55];
int N,K;
long long rez=1LL<<62;
int S[55][55];
int main()
{
    cin>>N>>K;
    for(int i=1;i<=N;i++)
    {
        cin>>V[i].first>>V[i].second;
        X[V[i].first]=1;
        Y[V[i].second]=1;
    }
    int nr=0;
    for(auto &it:X)
    {
        it.second=++nr;
        invX[it.second]=it.first;
    }
    N=nr;
    nr=0;
    for(auto &it:Y)
    {
        it.second=++nr;
        invY[it.second]=it.first;
    }
    int M=nr;
    for(int i=1;i<=N;i++)
    {
        int x=X[V[i].first],y=Y[V[i].second];
        S[x][y]++;
    }
    for(int i=1;i<=N;i++)
    {
        for(int j=1;j<=M;j++)
        {
            S[i][j]+=S[i-1][j]+S[i][j-1]-S[i-1][j-1];
        }
    }
    for(int i=1;i<=N;i++)
    {
        for(int j=1;j<=M;j++)
        {
            for(int k=i;k<=N;k++)
            {
                for(int l=j;l<=M;l++)
                {
                    if(S[k][l]-S[k][j-1]-S[i-1][l]+S[i-1][j-1]>=K)
                    {
                        rez=min(rez,1LL*abs(invX[k]-invX[i])*abs(invY[l]-invY[j]));
                    }
                }
            }
        }
    }
    cout<<rez;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define rALL(x) x.rbegin(), x.rend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n, W;    cin >> n >> W;
    vector<ll> w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];
    vector<vector<ll>> dp(n+1, vector<ll>(n*1000+1, LINF));
    dp[0][0] = 0;
    rep(i, n){
        for(ll j=0; j<=n*1000; j++){
            dp[i+1][j] = dp[i][j];
            if(v[i]<=j) dp[i+1][j] = min(dp[i][j-v[i]]+w[i], dp[i+1][j]);
        }
    }
    ll res=0;
    rep(i, n*1000+1) if(dp[n][i]<=W){
        res = i;
        //cout << i << ' ' << dp[n][i] << endl;
    }
    cout << res << endl;

}


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

int main(){
  int N, M;
  scanf("%d %d", &N, &M);
  long int *H; 
  int *D;
  H = (long int *)malloc(sizeof(long int) * N);
  D = (int *)malloc(sizeof(int) * N);
  for(int i = 0; i < N; i++){
    scanf("%ld", &H[i]);
    D[i] = 0;
  }
  int A, B;
  for(int i = 0; i < M; i++){
    scanf("%d %d", &A, &B);
    if(H[A - 1] > H[B - 1]) {
      if(D[A - 1] == 0) D[A - 1] = 1;
      D[B - 1] = -1;
    }
    else if(H[A - 1] < H[B - 1]) {
      D[A - 1] = -1;
      if(D[B - 1] == 0) D[B - 1] = 1;
    }
    else {
      D[A - 1] = -1;
      D[B - 1] = -1;
    }
  }
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(D[i] != -1) ans++;
  }
  printf("%d", ans);
  free(H);
  free(D);
  return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

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

const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int N, L, T;
int X[112345], W[112345];
int ans[112345];

int endP(int idx) {
	if (W[idx] == 1) return ((ll)X[idx] + T) % L;
	else return ( ( (ll)X[idx] - T ) % L + L) % L;
}

int main() {
	cin >> N >> L >> T;
	REP(i, N) scanf("%d %d", X + i, W + i);
	
	vector<pii> e(N); // T秒後の各位置
	REP(i, N) e[i] = pii(endP(i), -W[i]);
	sort(ALL(e));
	
	ll idx = 0;
	FOR(i, 1, N) {
		ll t = 1e11;
		
		if (W[0] == 1 && W[i] == 2) t = X[i] - X[0];
		if (W[0] == 2 && W[i] == 1) t = X[0] + L - X[i];
		
		if (2 * T >= t) idx += (2 * T - t) / L + 1;
		idx %= N;
	}
	
	if (W[0] == 2) idx = (-idx + N) % N;
	
	int st = lower_bound(ALL(e), pii(endP(0), -INF)) - e.begin();
	
	if (st + 1 < N && e[st].fi == e[st + 1].fi) {
		if (W[0] == 1) st++;
	}
	
	REP(i, N) ans[(idx + i) % N] = e[(i + st) % N].fi;
	REP(i, N) printf("%d\n", ans[i]);
	
	return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>

int main(void){
	int n;	//input
	int p_ptn;	// pattern

	while(1){
		scanf("%d", &n);
		if((n>=1)&&(n<=9)){ break; }
			else { puts("Prease input another number."); }
	}

	p_ptn = n*n*n;

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

	return 0;
}


Measured memory_bytes: 128