akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int A,B,C,D,F;
double E;
double concentration(int a,int b,int c,int d){
  return 100.0*(d*D+c*C)/(100*a*A+100*b*B+c*C+d*D);
 }

int main(){
  cin>>A>>B>>C>>D>>E>>F;
  int water,sugar;
  water=B;
  sugar=0;
  double con;
  con=0.0;
  E=100.0*E/(100.0+E);
  for(int a=0;a*A*100<=F;a++){
    for(int b=0;a*A*100+b*B*100<=F;b++){
      for(int c=0;concentration(a,b,c,0)<=E&&a*A*100+b*B*100+c*C<=F;c++){
        for(int d=0;concentration(a,b,c,d)<=E&&A*a*100+b*B*100+c*C+d*D<=F;d++){
          if(con<=concentration(a,b,c,d)){
            water=100*(a*A+b*B)+c*C+d*D;
            sugar=c*C+d*D;
            con=concentration(a,b,c,d);
          }
        }
      }
    }
  }
  cout<<water<<' '<<sugar<<endl;
}     

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

ll binpow(ll a, ll b, ll mod = 2e18){
	ll ans = 1;
	while(b){
		if(b&1) ans*=a;
		a*=a;
		ans%=mod;
		a%=mod;
		b/=2;
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, k;cin>>n>>k;
	ll mod = 1e9 + 7;
	ll ans = 0;
	ll gc[k+1] = {0};
	for(int i = k; i > 0; --i){
		gc[i] = binpow(k/i, n, mod);
		for(int j = i + i; j <=k; j += i){
			gc[i] -= gc[j];
			gc[i] += mod;
			gc[i]%=mod;
		}
	}
	for(int i = 1; i<=k; ++i){
		ans += i*gc[i];
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}



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

int main() {
	int n,r=0;
	cin>>n;
	if(n%10==7)
		r=1;
	n/=10;
	if(n%10==7)
		r=1;
	if(n/10==7)
		r=1;
	if(r)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

const int INF = 1e9;
const int MAXC = 80;

int main(){
	int h,w;
	cin >> h >> w;
	vector<vector<int>> a(h,vector<int>(w));
	vector<vector<int>> b(h,vector<int>(w));
	
	rep(i,h){
		rep(j,w) cin >> a[i][j];
	}
	rep(i,h){
		rep(j,w) cin >> b[i][j];
	}
	
	vector<vector<int>> c(h,vector<int>(w));
	rep(i,h) rep(j,w) c[i][j] = abs(a[i][j] - b[i][j]);
	
	int MAX = MAXC*(h+w);
	bool dp[h][w][MAX];
	rep(i,h) rep(j,w) rep(k,MAX) dp[i][j][k] = false;
	dp[0][0][c[0][0]] = true;
	
	
	rep(i,h){
		rep(j,w){
			rep(k,MAX){
				int n = c[i][j];
				if(i-1 >= 0 && abs(k-n) < MAX) dp[i][j][abs(k-n)] |= dp[i-1][j][k];
				if(j-1 >= 0 && abs(k-n) < MAX) dp[i][j][abs(k-n)] |= dp[i][j-1][k];
				if(i-1 >= 0 && k+n < MAX) dp[i][j][k+n] |= dp[i-1][j][k];
				if(j-1 >= 0 && k+n < MAX) dp[i][j][k+n] |= dp[i][j-1][k];
			}
		}
	}
	
	rep(k,MAX){
		if(dp[h-1][w-1][k]){
			cout << k << endl;
			return 0;
		}
	}

}


Measured memory_bytes: 80384
x, k, d = map(int, input().split())
x = abs(x)

if x - k * d >= 0:
    print(x - k * d)
else:
    div = x // d
    if div % 2 == k % 2:
        print(x - d * div)
    else:
        print(abs(x - d * (div + 1)))



Measured memory_bytes: 61936
#include<bits/stdc++.h>
using namespace std;
 
const int N=200005;
const int mod=1000000007;
typedef long long ll;
 
 
char s[N];
 
int main()
{
    scanf("%s",s+1);
    int len=strlen(s+1);
    ll tmp=0,ans=0;
    for(int i=len; i>0; i--)
    {
        if(s[i-1]=='B' && s[i]=='C')
        {
            tmp++;
            i--;
        }
        else if(s[i]=='A') ans+=tmp;
        else tmp=0;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 384
N, M = map(int, input().split())

flag = 0
x = [1000] * N
for m in range(M):
  s, c = map(int, input().split())
  if (x[s-1] != 1000) & (x[s-1] != c):
    #print("{} {}".format(s,c))
    flag = 1
    pass
    if (s == 1) & (c == 0) & (N != 1):
      pass
    else:
      x[s-1] = x[s-1] if x[s-1] < c else c
  else:
    x[s-1] = c
#print(x)
    
ans = 0
for n in range(N):
  if x[n] != 1000:
    ans += 10**(N-n-1) * x[n]
  elif n==0:
    ans += 10**(N-n-1) * 1
#print(ans)

if (N == 1) & (M == 0) & (flag == 0):
  print(0)
elif (N == 1) & (M > 0) & (flag == 0):
  print(ans)
elif (ans >= 10**(N-1)) & (flag == 0):
  print(ans)
else:
  print(-1)


Measured memory_bytes: 38384
#include <iostream>

using namespace std;

int main(void){
  int high,wide,x,y,radius,xmax,xmin,ymax,ymin;

  cin >>wide>>high>>x>>y>>radius;

  xmax = wide - (x + radius);
  xmin = x - radius;
  ymax = high - (y + radius);
  ymin = y - radius;

  if((xmax >= 0) && (xmin >= 0)){
    if((ymax >= 0) && (ymin >= 0)){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3136
from itertools import product

def solve(a, b, c, d):
    for ops in product('+-', repeat=3):
        op = a + ops[0] + b + ops[1] + c + ops[2] + d
        if eval(op) == 7:
            return op + '=7'


if __name__ == '__main__':
    a, b, c, d = input()
    print(solve(a, b, c, d))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#include <math.h>


using namespace std;

int main(){

    int N, D;
    cin >> N >> D;
    
    // int型の2次元配列(3×4要素の)の宣言
    vector<vector<int> > X(N, vector<int>(D));
    
    // 入力 (2重ループを用いる)
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            cin >> X.at(i).at(j);
        }
    }
    
    int count = 0;
    
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            
            int distans = 0;
            for (int k = 0; k < D; k++) {
                distans += (X.at(i).at(k) - X.at(j).at(k))*(X.at(i).at(k) - X.at(j).at(k));
            }
            
            double sqd = sqrt(distans);
            
            int dis = int(sqd);
            
            
            
            if (dis*dis == distans) {
                count += 1;
            }
            
        }
    }
    
    
    cout << count << endl;
    
    return 0;
    
}


Measured memory_bytes: 256
#D
from collections import deque

N,M = map(int,input().split())
V = [[] for _ in range(N)]

for _ in range(M):
    a,b = map(int,input().split())
    V[a-1].append(b-1)
    V[b-1].append(a-1)
    

visited = [-1]*N
visited[0] = 0
mae = [-1]*N
mae[0] = 0

D = deque()
for v in V[0]:
    visited[v] = 1
    mae[v] = 1
    D.append(v)

while D:
    d = D.popleft()
    Vd = V[d]
    
    for v in Vd:
        if visited[v] == -1:
            visited[v] = visited[d]+1
            mae[v] = d+1
            D.append(v)
        

print("Yes")
for i in range(1,N):
    print(mae[i])
    



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

#define swap(type,a,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(int i=0;i<n;i++)
#define forS(i,start,n) for(int i=start;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}
#define DOUBLE fixed << setprecision(15)

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

bool cmp(vi,vi);
int main(){
    int n,m,cnt=0;
    string s;

    int ptr=0;
    int a,b,c;
    cin >>n>>a>>b>>c;
    vi l(n);
    vector<vector<vi>> ret(pow(4,n),vector<vi>(4,vi(2,0)));
    forN(i,n){
        cin >> l[i];
    }
    cnt = 65536;
    forN(i,pow(4,n)){
        int sp=i;
        forN(j,n){
            ret[i][sp&3][0]+=l[j];
            ret[i][sp&3][1]+=10;
            sp>>=2;
        }
        int res1 = abs(a - ret[i][0][0]) + (ret[i][0][1] -10);
        int res2 = abs(b - ret[i][1][0]) + (ret[i][1][1] -10);
        int res3 = abs(c - ret[i][2][0]) + (ret[i][2][1] -10);
        int tmp = res1+res2+res3;
        if(ret[i][0][0]==0||ret[i][1][0]==0||ret[i][2][0]==0){}else{
            cnt=min(tmp,cnt);
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 20628
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int X;
  cin >> X;
  if(X < 400){
    cout << 8 << "\n";
    return 0;
  }
  X -= 400;
  X /= 200;
  cout << 8 - X << "\n";
  return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;
public class Main {	
	public static void main(String[] args) {
		Scanner frog = new Scanner(System.in);
		String S = frog.next();
		int i = S.length();
		for(int x = 0;x<i;x++) {
			System.out.print('x');
		}
	}   
	}
    

Measured memory_bytes: 23124
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int X, Y, Z, N, M, S, T; cin >> X >> Y >> Z >> N >> M >> S >> T;
    S--; T--;
    vector<int> A(N), B(N), C(M), D(M);
    vector<int> dist(N + M + X + Y + Z, INF);
    dist[S] = 0;
    vector< vector< pair<int, int> > > G(N + M + X + Y + Z);
    for(int i=0; i<N; i++) {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;

        // サンド
        G[i].emplace_back(N + M + A[i], 0);
        G[ N + M + A[i] ].emplace_back(i, 1);

        // カツ
        G[i].emplace_back(N + M + X + B[i], 0);
        G[ N + M + X + B[i] ].emplace_back(i, 1);
    }
    for(int i=0; i<M; i++) {
        cin >> C[i] >> D[i];
        C[i]--; D[i]--;

        // カツ
        G[N+i].emplace_back(N + M + X + C[i], 0);
        G[ N + M + X + C[i] ].emplace_back(N+i, 1);

        // カレー
        G[N+i].emplace_back(N + M + X + Y + D[i], 0);
        G[ N + M + X + Y + D[i] ].emplace_back(N+i, 1);
    }

    queue< pair<int, int> > que;
    dist[S] = 0;
    que.emplace(S, 0);
    while(que.size()) {
        int cur, c; tie(cur, c) = que.front(); que.pop();
        if(c > dist[cur]) continue;
        for(auto e : G[cur]) {
            int to, cost; tie(to, cost) = e;
            if(dist[to] > c + cost) {
                dist[to] = c + cost;
                que.emplace(to, dist[to]);
            }
        }
    }

    int ans = dist[N+T];
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}



Measured memory_bytes: 32260
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int N,M;
    cin >> N >> M;
    // スペース区切りの整数の入力
    int p[M];

    int sum = 0;
    for (int i = 0; i < M; i++){
        cin >> p[i];
    }
    for (int i = 0; i < M; i++){
        sum += p[i];
    }
    
    
    if (sum <= N){
        cout << N-sum << endl;
    }
    else{
        cout << -1 << endl;
    }
    
    return 0;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    int x = 0;
    if(A > B){
        cout << A + (A - 1) << endl;
    }
    else if(A < B){
        cout << B + (B - 1) << endl;
    }
    else {
        cout << A + B << endl;
    }
}

Measured memory_bytes: 256
#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 rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int x,y,a,b,c;cin>>x>>y>>a>>b>>c;
    vector<ll> P(a),Q(b),r(c),pq(x+y);
    rep(i,a) cin>>P[i];
    rep(i,b) cin>>Q[i];
    rep(i,c) cin>>r[i];
    sort(P.rbegin(),P.rend());
    sort(Q.rbegin(),Q.rend());
    rep(i,x)pq[i]=P[i];
    rep(i,y)pq[i+x]=Q[i];
    sort(r.rbegin(),r.rend());
    sort(pq.begin(),pq.end());
    priority_queue<ll> que;
    rep(i,x+y)que.push(pq[i]);
    rep(i,c){
        auto itr=lower_bound(pq.begin(),pq.end(),r[i]);
        int k=itr-pq.begin();
        if(k==0)break;
        que.push(r[i]);
    }
    ll res=0;
    rep(i,x+y){
        ll ren=que.top();que.pop();
        //cout<<ren<<endl;
        res+=ren;
    }
    cout<<res<<endl;
}


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

int main(){
  int N;
  cin>>N;
  int C[N],S[N],F[N];
  for(int i=1;i<N;i++){
    cin>>C[i]>>S[i]>>F[i];
  }
  for(int i=1;i<=N;i++){
    int t=0;
    for(int j=i;j<N;j++){
      if(t<S[j]) t=S[j];//最初の電車に間に合うか
      else if(t%F[j]==0);//ちょうど出発するのでロスなし
      else t=t-(t%F[j])+F[j];//次の出発時間
      t+=C[j];
    }
    cout<<t<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
const int maxn = 1e5+10;
struct Item {
    int from, to, d;
};
Item step[maxn];
vector<int> F[maxn], T[maxn];
bool use[maxn];
int a[maxn];
LL ans[maxn], aans;
int cnt, n, m;
int main () {
    scanf ("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf ("%d", &a[i]);
        --a[i];
    }
    for (int i = 1; i <= n-1; i++) {
        step[i].from = a[i]; step[i].to = a[i+1]; step[i].d = (a[i+1]+m-a[i])%m;
        F[step[i].from].push_back (i);
        T[step[i].to].push_back (i);
    }
    for (int i = 1; i <= n-1; i++) {
        if (1+step[i].to <= step[i].d) {
            ans[0] += 1+step[i].to;
            cnt++;
            use[i] = true;
        }
        else {
            ans[0] += step[i].d;
            use[i] = false;
        }
    }
    //printf ("%lld ", ans[0]);
    aans = ans[0];
    for (int x = 1; x < m; x++) {
        ans[x] = ans[x-1];
        for (int i = 0; i < T[x-1].size(); i++) {
            int u = T[x-1][i];
            //printf ("back:%d\n", u);
            use[u] = false;
            ans[x] += step[u].d-1;
            --cnt;
        }
        ans[x] -= cnt;
        for (int i = 0; i < F[x-1].size(); i++) {

            int u = F[x-1][i];
            //printf ("get:%d\n", u);
            use[u] = true;
            ++cnt;
        }
        //printf ("%lld ", ans[x]);
        aans = min (ans[x], aans);
    }
    //printf ("\n");
    printf ("%lld\n", aans);
}


Measured memory_bytes: 12032
def main():
    num = int(input())
    data_list = [int(input()) for i in range(num)]
    data_list.sort()


    if num % 2 == 1:
        hikukazu = 0
        for i in range(num // 2 + 1):
            hikukazu += 2 * data_list[i]
        hikukazu -= data_list[num // 2] + data_list[num // 2 - 1]

        tasukazu = 0
        for i in range(num // 2 + 1, num):
            tasukazu += 2 * data_list[i]
    else:
        hikukazu = 0
        for i in range(num // 2):
            hikukazu += 2 * data_list[i]
        hikukazu -= data_list[num // 2 - 1]

        tasukazu = 0
        for i in range(num // 2, num):
            tasukazu += 2 * data_list[i]
        tasukazu -= data_list[num // 2]

    a = tasukazu - hikukazu

    if num % 2 == 1:
        hikukazu = 0
        for i in range(num // 2):
            hikukazu += 2 * data_list[i]

        tasukazu = 0
        for i in range(num // 2, num):
            tasukazu += 2 * data_list[i]
        tasukazu -= data_list[num // 2] + data_list[num // 2 + 1]
    else:
        hikukazu = 0
        for i in range(num // 2):
            hikukazu += 2 * data_list[i]
        hikukazu -= data_list[num // 2 - 1]

        tasukazu = 0
        for i in range(num // 2, num):
            tasukazu += 2 * data_list[i]
        tasukazu -= data_list[num // 2]

    b = tasukazu - hikukazu

    # print(a, b)
    print(max(a, b))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll k,s;
	cin >> k >> s;
	ll ans = 0;
	FOR(i,0,k+1){
		FOR(j,0,k+1){
			ll p = s-i-j;
			if(p>=0&&p<=k)ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import static java.lang.Double.parseDouble;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	private static final long MOD = 1000000007;
	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	void solve() throws Exception {
		int x1 = nextInt();
		int y1 = nextInt();
		int x2 = nextInt();
		int y2 = nextInt();
		int[] p4 = solution(x1, y1, x2, y2);
		int[] p3 = solution(p4[0], p4[1], x1, y1);
//		Helper.tr(freq);
		out.println(p3[0] + " " + p3[1] + " " + p4[0] + " " + p4[1]);
	}

	private int[] solution(int x1, int y1, int x2, int y2) {
		x2 -= x1;
		y2 -= y1;

		int x4 = -y2;
		int y4 = x2;

		return new int[] { x4 + x1, y4 + y1};
	}

	private long f(long cnt) {
		if (cnt <= 0)
			return 0;
		return cnt * cnt * cnt;
	}

	private int[][] nextInts(int r, int c) throws IOException {
		int[] a[];
		a = new int[r][c];
		for (int i = 0; i < r; i++)
			for (int j = 0; j < c; j++)
				a[i][j] = nextInt();
		return a;
	}

	private int[] nextTuple(int n) throws IOException {
		int[] a;
		a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	private int[] nextInts(int n) throws IOException {
		return nextTuple(n);
	}

	static int nextInt() throws IOException {
		return parseInt(next());
	}

	static long nextLong() throws IOException {
		return parseLong(next());
	}

	static double nextDouble() throws IOException {
		return parseDouble(next());
	}

	static String next() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	public static void main(String[] args) {
		new Thread(null, null, "Main", 0x4000000) {
			public void run() {
				try {
					in = new BufferedReader(new InputStreamReader(System.in));
					out = new PrintWriter(new OutputStreamWriter(System.out));
					new Main().solve();
					in.close();
					out.close();
				} catch (Throwable e) {
					e.printStackTrace();
					exit(1);
				}
			}
		}.start();
	}
}


Measured memory_bytes: 24276
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace2(a,b) cerr <<"a is " << a << " b is " << b << el;
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    ll n , k ;
    cin >> n >> k ;
    vl x , y , sx , sy ;
    forn(i , 1 , n ) {
       ll xx , yy ;
       cin >> xx >> yy ;
       x.pb(xx);
       y.pb(yy);
    }
    sx = x ;
    sy = y ;
    sort(all(sx)) ;
    sort(all(sy)) ;
    ll fiz = sx[n-1] - sx[0] ;
    ll ziz = sy[n-1] - sy[0] ;
    ll ans = ziz * fiz ;
    forn(xi , 0 , n-1){
       forn(xj,xi+1,n-1){
          forn(yi,0,n-1){
             forn(yj,yi+1,n-1){
                ll foo = 0 ;
                ll lx = sx[xi] , rx = sx[xj] ;
                ll by = sy[yi] , uy = sy[yj] ;
                forn(i,0,n-1){
                   if(x[i]>=lx and x[i]<=rx and by<=y[i] and uy>=y[i]) ++foo;
                }
                if(foo>=k) ans = min(ans, (rx-lx)*(uy-by));
             }
          }
       }
    }
    cout << ans << el ;
    ro ;
}


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

int main() {
    int n; cin >> n;
    vector<int> p(n, 0);
    rep(i,n) cin >> p.at(i);

    int cnt=0;
    for(int i=1; i<n-1; i++){
        if(p.at(i-1)<p.at(i)&&p.at(i)<p.at(i+1)) cnt++;
        else if(p.at(i-1)>p.at(i)&&p.at(i)>p.at(i+1)) cnt++;
    }

    cout << cnt << endl;
}


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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);

    int N, M, C;
    cin >> N >> M >> C;

    vi B(M);
    vvi A(N, vi(M));
    rep(i, M)cin >> B[i];
    rep(i, N)rep(j, M)cin >> A[i][j];

    int ans = 0;
    rep(i, N){
        int s = C;
        rep(j, M){
            s+=A[i][j]*B[j];
        }
        if(s>0)ans+=1;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    multiset<ll> st;
    st.insert(-1);
    st.insert(1e9+7);
    for(int i = 0; i < n; i++){
        auto itr = st.lower_bound(a[i]);
        itr--;
        if((*itr)==-1){
            st.insert(a[i]);
        }else{
            st.erase(itr);
            st.insert(a[i]);
        }
    }

    cout << st.size()-2 << endl;
    return 0;

}


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

signed main() {
    int a, b;
    cin >> a >> b;
    if(a >= 13) {
        cout << b << "\n";
    } else if(a > 5) {
        cout << b / 2 << "\n";
    } else {
        cout << "0\n";
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include <math.h>
int main(void){
    int i,j,N;
    double dist;
    double xa[100],ya[100],ra[100],xb[100],yb[100],rb[100];
    scanf("%d",&N);
    for(i = 0;i < N;i++){
        scanf("%lf",&xa[i]);
        scanf("%lf",&ya[i]);
        scanf("%lf",&ra[i]);
        scanf("%lf",&xb[i]);
        scanf("%lf",&yb[i]);
        scanf("%lf",&rb[i]);
    }
    for(j = 0;j < N;j++){
        dist = sqrt((xa[j] - xb[j]) * (xa[j] - xb[j]) + (ya[j] - yb[j]) * (ya[j] - yb[j]));
        if(dist < ra[j] - rb[j]){
            printf("2\n");
        }
        else if(dist < rb[j] - ra[j]){
            printf("-2\n");
        }
        else if(dist > rb[j] + ra[j]){
            printf("0\n");
        }
        else{
            printf("1\n");
        }
    }
    return 0;
}

Measured memory_bytes: 624
N = int(input())
p = list(map(int,input().split()))
num = 0

for i in range(N-2):
  pThree = [p[i],p[i+1],p[i+2]]
  pn = sorted(pThree)
  if pn[1] == p[i+1]:
    num += 1
  
print(num)

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    int A,B,res;
    char op;
    scanf("%d %c %d",&A,&op,&B);
    switch(op)
    {
        case'+':res=A+B;
        printf("%d\n",res);
        break;

        case'-':res=A-B;
        printf("%d\n",res);
        break;
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;

int main(){
    ll n,m;
    cin >> n;
    ll d[n];
    for(ll i=0;i<n;i++) cin >> d[i];
    cin >> m;
    ll t[m];
    for(ll i=0;i<m;i++) cin >> t[i];
    sort(d,d+n);
    sort(t,t+m);
    ll i=0,j=0;
    while(j<m){
        if(d[i] > t[j]){
            cout << "NO" << endl;
            return 0;
        }
        else if(d[i] == t[j]){
          i++;
          j++;
        }
      	else i++;
    }
    if(j == m) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 3328
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

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

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

const int INF = 1001001001;

pii gcd(int a, int b)
{
	if(b == 0)
		return pii(a, 0);
	pii ret = gcd(b, a%b);
	ret.second++;
	return ret;
}

int main()
{
	int a, b;
	while(scanf("%d%d", &a, &b), a){
		if(a < b)
			swap(a, b);
		pii ret = gcd(a, b);
		printf("%d %d\n", ret.first, ret.second);
	}
}

Measured memory_bytes: 1028
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

#include <chrono>

using namespace std;
int main()
{
	string S;
	cin >> S;
	size_t string_size = S.size();
	int absolute = abs(753 - stoi((S.substr(0, 3))));
	for (int i = 1; i < string_size; i++)
	{
		int temp = abs(753 - stoi((S.substr(i, 3))));

			if (temp < absolute)
		{
			absolute = temp;
		}
	}
	cout << absolute;
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  QS_
//
//  Created by ptyuan on 2018/10/30.
//  Copyright © 2018 YY. All rights reserved.
//

#include <iostream>
#include <cstdio>
using namespace std;
struct Element {
    char c;
    long number;
};

void swap(Element &a, Element &b) {
    Element temp = a;
    a = b;
    b = temp;
}


int partition(Element *A, int p, int r) {
    Element x = A[r];
    int i = p - 1;
    for (int j = p; j <= r - 1; j++) {
        if (A[j].number <= x.number) {
            i++;
            Element temp = A[j];
            A[j] = A[i];
            A[i] = temp;
        }
    }
    A[r] = A[i + 1];
    A[i + 1] = x;
    return i + 1;
}


void qs(Element *A, int left, int right) {
    if (left < right) {
        int mid = partition(A, left, right);
        qs(A, left, mid - 1);
        qs(A, mid + 1, right);
    }
}

const long kMaxValue = 10000000000;
const int kMax = 1000000;


Element L[kMax / 2 + 2];
Element R[kMax / 2 + 2];
int cmpCount = 0;

void _merge(Element *A, int n, int left, int mid, int right) {
    int n1 = mid - left;
    for (int i = 0; i < n1; i++) {
        L[i] = A[left + i];
    }
    
    int n2 = right - mid;
    for (int i = 0; i < n2; i++) {
        R[i] = A[mid + i];
    }
    Element temp;
    temp.number = kMaxValue;
    L[n1] = temp;
    R[n2] = temp;
    int l1 = 0;
    int l2 = 0;
    for (int k = left; k < right; k++) {
        ++cmpCount;
        if (L[l1].number <= R[l2].number) {
            A[k] = L[l1++];
        } else {
            A[k] = R[l2++];
        }
    }
}

void mergeSort(Element *A, int n, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        _merge(A, n, left, mid, right);
    }
}

bool isStable(Element *e1, Element *e2, int n) {
    for (int i = 0; i < n; i++) {
        if (e1[i].c != e2[i].c) {
            return false;
        }
    }
    return true;
}


int main(int argc, const char * argv[]) {
    Element A[100000];
    Element B[100000];
    int n = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        Element temp;
        scanf(" %c", &temp.c);
        scanf("%ld", &temp.number);
        A[i] = temp;
        B[i] = temp;
    }
    qs(A, 0, n - 1);
    mergeSort(B, n, 0, n);
    if (isStable(A, B, n)) {
        printf("Stable");
    } else {
        printf("Not stable");
    }
    printf("\n");
    for (int i = 0; i < n; i++) {
        Element temp = A[i];
        printf("%c %ld\n", temp.c, temp.number);
    }
    
    return 0;
}




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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> q;
    int a;
    REP(i, n) {
        cin >> a;
        q.emplace(a);
    }

    REP(i, m) {
        int x = q.top(); q.pop();
        x /= 2;
        q.emplace(x);
    }

    ll ans = 0;
    REP(i, n) {
        ans += (ll)q.top(); q.pop();
    }
    cout << ans << endl;
}

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

int main(){
  int N,M;
  cin >> N >> M;

  if(N == M){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 764
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define pb         push_back
#define mp         make_pair
#define ll         long long
#define PI         acos(-1.0)
#define ALL(A)     ((A).begin(), (A).end())
#define vsort(v)   sort(v.begin(),v.end())
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(){
    int N, M;
    cin >> N >> M;cin.ignore();
    vector<string> A, B;
    FOR(i, 0, N){
        string s;
        getline(cin, s);
        A.pb(s);
    }
    FOR(i, 0, M){
        string s;
        getline(cin, s);
        B.pb(s);
    }

    FOR(i, 0, N-M+1){
        FOR(j, 0, N-M+1){
            int check = 0;
            FOR(k, 0, M){
                FOR(l, 0, M){
                    if(B[k][l]==A[i+k][j+l]) check++;
                }
            }
            if(check == M*M){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
#define ld long double
const int mod=1e9 + 7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};
 
const int INF = (int)1e9 + 7;
const int M = (int)1e9 + 7;
 


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

 
 string g;
 cin>>g;

 if(g=="SUN")
 {
   cout<<7;
 }
 else if(g=="MON")
 cout<<6;
 else if(g=="TUE")cout<<5;
 else if(g=="WED")cout<<4;
 else if(g=="THU")cout<<3;
 else if(g=="FRI")cout<<2;
 else cout<<1;


}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)


int main(){
  int ans[1000000]={};
  int sum[1000]={0};

  rep(i,1,1000){
    sum[i] = sum[i-1]+i;
  }

  rep(i,0,999){
    rep(j,i+2,1001){
      ans[ sum[j]-sum[i] ]++;
    }
  }
  int n;
  while(cin >> n){
    if(n==0)break;
    cout << ans[n] << endl;
  }

}

Measured memory_bytes: 7024
#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[5][5];
    int n;
    int b;
    int i, j, k;
    bool card[5][5];
    bool ans = false;
    
    for(i=0; i<3; i++){
        for(j=0; j<3; j++){
            card[i][j] = false;
        }
    }
    
    for(i=0; i<3; i++){
        for(j=0; j<3; j++){
            cin >> a[i][j];
        }
    }
    
    cin >> n;
    
    for(k=0; k<n; k++){
        cin >> b;
        for(i=0; i<3; i++){
            for(j=0; j<3; j++){
                if(a[i][j] == b){
                    card[i][j] = true;
                }
            }
        }
    }
    
    for(i=0; i<3; i++){
        if(card[i][0] && card[i][1] && card[i][2]) ans = true;
        if(card[0][i] && card[1][i] && card[2][i]) ans = true;
    }
    if(card[0][0] && card[1][1] && card[2][2]) ans = true;
    if(card[2][0] && card[1][1] && card[0][2]) ans = true;
    
    if(ans) cout << "Yes" << endl;
    else    cout << "No" << endl;
    return 0;
}




Measured memory_bytes: 256
#include <cstddef>
#include <cstdint>
#include <type_traits>
#include <vector>

namespace null_null {

using int64 = std::int_fast64_t;
using usize = std::size_t;

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename T, typename V>
inline void chmin(T &a, V b) {
  if (a > b) a = b;
}
template <typename T, typename V>
inline void chmax(T &a, V b) {
  if (a < b) a = b;
}

} // namespace null_null

#include <algorithm>
#include <iostream>
#include <string>
#include <utility>

namespace null_null {

void main_() {
  std::string s;
  std::cin >> s;
  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3] || s[3] == s[4]) {
    std::cout << "Bad" << std::endl;
  } else {
    std::cout << "Good" << std::endl;
  }
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int L  = sc.nextInt();
        int R  = sc.nextInt();
        int d  = sc.nextInt();
        
        int count = 0;
        
        for(int i=L; i<=R; i++){
            if(i%d ==0){
                count++;
            }
        }
        
        System.out.println(count);
        
        
        
    }
}

Measured memory_bytes: 35704
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

#define fst first
#define snd second

typedef long long llint;
typedef pair<int, int> pii;

const int B = 27397, MOD = 1e9 + 7;
const int B1 = 33941, MOD1 = 1e9 + 9;

string o, e;

int main(void) {
  cin >> o >> e;
  for (int i = 0; i < e.size(); ++i)
    cout << o[i] << e[i];
  if (o.size() != e.size())
    cout << o[o.size() - 1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k;
long long ans,a[101010],sum[101010],youzhen[101010],zuozhen[101010];
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		sum[i]=sum[i-1]+a[i];
	}
	for(int i=1;i<=n;i++)
	{
		zuozhen[i]=zuozhen[i-1]+max(a[i],0ll);
	}
	for(int i=n;i>=1;i--)
	{
		youzhen[i]=youzhen[i+1]+max(a[i],0ll);
	}
	for(int i=0;i<=n-k;i++)
	{
		ans=max(ans,zuozhen[i]+youzhen[i+k+1]+max(sum[i+k]-sum[i],0ll));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define DEBUG(debug_x) cerr <<#debug_x<<": "<<debug_x<<endl;
#define DEBUG2(debug_x, debug_y) cerr <<#debug_x<<":"<<debug_x<<" "<<#debug_y<<":"<<debug_y<<endl;
#define DEBUG3(debug_x, debug_y, debug_z) cerr <<#debug_x<<":"<<debug_x<<" "<<#debug_y<<":"<<debug_y<<" "<<#debug_z<<":"<<debug_z<<endl;
#define DEBUGVC(debug_x) cerr <<#debug_x<<": "; for(auto a:debug_x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(debug_x) cerr <<#debug_x<<":"<<endl; for(auto a:debug_x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (200005)
#define INF (1LL << 60)
const int MOD = (int)1e9;
typedef pair<int,int> Pii;
typedef pair<double,double> Pdd;

// 約数の列挙O(√n)
vector<int> divisor(int n){
    vector<int> res;
    for(int i=1; i*i<=n; i++){
        if(n%i==0){
            res.push_back(i);
            // n の約数が i の時、n/i も n の約数になる
            if(i!=n/i) res.push_back(n/i);
        }
    }
    return res;
}
 
signed main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin >> a[i];

    map<int,int> mp;
    vector<int> ans;
    for(int i=N; i>=1; i--){
        if(mp[i]%2!=a[i-1]){
            vector<int> div = divisor(i);
            for(auto x: div){
                mp[x]++;
            }
            ans.push_back(i);
        }
    }

    cout << ans.size() << endl;
    if(ans.size()==0) return 0;
    for(auto x: ans){
        printf("%lld ", x);
    }
    puts("");

}

Measured memory_bytes: 16116
#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        s: usize
    }

    let mut v1 = vec![s; k];
    let mut v2 = vec![max((s + 1) % 1_000_000_000, 1); n - k];
    v1.append(&mut v2);

    print!("{}", v1[0]);
    for v in v1.into_iter().skip(1) {
        print!(" {}", v);
    }
    println!("");
}



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

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<int> L(M), R(M);
  vector<vector<int>> D(N,vector<int>(N));
  rep(i, 0, M) {
    cin >> L[i] >> R[i];
    L[i]--, R[i]--;
  }
  rep(i, 0, M) D[L[i]][R[i] - L[i]]++;
  rep(i, 0, N) rep(j, 0, N-1) D[i][j + 1] += D[i][j];
  vector<int> p(Q), q(Q);
  rep(i, 0, Q) {
    cin >> p[i] >> q[i];
    p[i]--, q[i]--;
  }
  rep(i, 0, Q) {
    int res = 0;
    int len = q[i] - p[i];
    rep(j, 0, len + 1) res += D[p[i] + j][len - j];
    cout << res << endl;
  }
  return 0;
}


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

using namespace std;

int main() {
	cin.sync_with_stdio(false);

	int N;
	string S;
	cin >> N >> S;
	int x_b=0, x_a=0;
	int x_max=x_b;
	for (int i = 0;i < S.length();i++) {
		if (S[i] == 'I') {
			x_a = x_b + 1;
		}else if(S[i] == 'D') {
			x_a = x_b - 1;
		}
		x_max = max(x_max, x_a);
		x_b = x_a;
	}
	cout << x_max << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int, int>pii;
typedef pair<int, pii>pi3;
ll mod = 1000000007;
int m[100][100];
bool flag[100][100];
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
	int n, a;
	cin >> n;
	cout << n / 3 << endl;
	//printf((n % 500 <= a) ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#include <stdio.h>
int n,i,j,x,a[10][10],list[1000][3],size;

void push(int x,int y,int s){list[size][0]=i;list[size][1]=j;list[size][2]=s;size++;}

int check(int x,int y,int s){
	int d;
	if(s<3 && (x<1 || x>9 || y<1 || y>9)) return 0;
	if(s==3 && (x<2 || x>8 || y<2 || y>8)) return 0;
	d=a[x][y];
	if(a[x-1][y]<d)d=a[x-1][y];
	if(a[x+1][y]<d)d=a[x+1][y];
	if(a[x][y-1]<d)d=a[x][y-1];
	if(a[x][y+1]<d)d=a[x][y+1];
	if(s==1 || d==0)return d;
	if(a[x-1][y-1]<d)d=a[x-1][y-1];
	if(a[x+1][y+1]<d)d=a[x+1][y+1];
	if(a[x+1][y-1]<d)d=a[x+1][y-1];
	if(a[x-1][y+1]<d)d=a[x-1][y+1];
	if(s==2 || d==0)return d;
	if(a[x-2][y]<d)d=a[x-2][y];
	if(a[x+2][y]<d)d=a[x+2][y];
	if(a[x][y-2]<d)d=a[x][y-2];
	if(a[x][y+2]<d)d=a[x][y+2];
	return d;
}

void draw(int x,int y,int s,int d){
	if(size==3 && (x<2 || x>8 || y<2 || y>8)) return;
	a[x][y]+=d;
	a[x-1][y]+=d;
	a[x+1][y]+=d;
	a[x][y-1]+=d;
	a[x][y+1]+=d;
	if(s==1)return;
	a[x-1][y-1]+=d;
	a[x+1][y+1]+=d;
	a[x+1][y-1]+=d;
	a[x-1][y+1]+=d;
	if(s==2)return;
	a[x-2][y]+=d;
	a[x+2][y]+=d;
	a[x][y-2]+=d;
	a[x][y+2]+=d;
}

int search(int nn,int from){
	int i,x,y,s;
	for(i=from;i>=0;i--){
		x=list[i][0];y=list[i][1];s=list[i][2];
		if(a[x][y]==0 && a[x+1][y]>0)return 0;
		if(x<8){
			if(s<3 && a[x+2][y]>0)return 0;
			//if(y==1 && a[x+2][y-1]>0)return 0;
		}
		//if(y==1 && s<2 && a[x+1][y-1]>0)return 0;
		//if(y==8 && s<2 && a[x+1][y+1])return 0;
		if(check(x,y,s)>0){
			draw(x,y,s,-1);
			if(s==1 && a[x+1][y+1]>0 && check(x-1,y+1,3)==0){draw(x,y,s,+1);return 0;}
			if(nn>1){
				if(search(nn-1,i-1)>0){printf("%d %d %d\n",y,x,s);return 1;}
			}else{
				int p,q;
				for(p=0;p<10;p++)for(q=0;q<10;q++){{if(a[p][q]!=0)goto miss;}}
				printf("%d %d %d\n",y,x,s);return 1;miss:;
			}
			draw(x,y,s,+1);
		}
	}
	return 0;
}

int main(void){
	scanf("%d",&n);size=0;
	for(i=0;i<10;i++){for(j=0;j<10;j++){scanf("%d",&a[i][j]);}}
	for(i=1;i<9;i++){
		for(j=1;j<9;j++){
			x=check(i,j,1); if(x==0)continue; else for(;x>0;x--)push(i,j,1);
			x=check(i,j,2); if(x==0)continue; else for(;x>0;x--)push(i,j,2);
			x=check(i,j,3); if(x==0)continue; else for(;x>0;x--)push(i,j,3);
		}
	}
	//for(i=0;i<size;i++)printf("%d %d %d\n",list[i][0],list[i][1],list[i][2]);
	search(n,size-1);
	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD =998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////



int main() {
	ll A, B, C;
	cin >> A >> B >> C;

	if (A == B && B == C) { cout << "Yes"; }
	else { cout << "No"; }
	system("PAUSE");
}


Measured memory_bytes: 504
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>*/
#include <bits/stdc++.h>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

string s; 

int test(char x) {
    int ret = 0;
    while (1) {
        string s1;
        bool f = 1;
        F0R(i,s.length()) if (s[i] != x) {
            f = 0;
            break;
        }
        if (f == 1) return ret;
        
        ret ++;
        F0R(i,s.length()-1) {
            if (s[i] == x || s[i+1] == x) s1 += x;
            else s1 += 'A';
        }
        s = s1;
    }
}

int main() {
    cin >> s;
    int ans = MOD;
    F0R(i,26) {
        string t = s;
        ans = min(ans,test('a'+i));
        s = t;
    }
    cout << ans;
}

Measured memory_bytes: 256
N,Y=map(int,input().split())
Y=Y/1000
c=0
for a in range(int(Y//10)+1):
  for b in range(int((Y - 10*a)//5)+1):
    if a*10+b*5+(N-a-b)*1==Y:
      print(a,b,N-a-b)
      c=1
      break
  if c==1:
    break
if c==0:
  print(-1,-1,-1)

Measured memory_bytes: 3064