akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long N,W,i,j;
long long w[110],v[110],s[110][100010];
int main(void){
    
    cin >> N >> W;
    
    for(i=1;i<=N;i++){
        cin >> w[i] >> v[i];
    }
    
    for(j=0;j<=W;j++){
        s[0][j]=0;
    }
    
    for(i=1;i<=N;i++){
        for(j=1;j<=W;j++){
            if(j>=w[i]){
                s[i][j]=max(s[i-1][j],s[i-1][j-w[i]]+v[i]);
            }
            else{
                s[i][j]=s[i-1][j];
            }
        }
    }
    
    cout << s[N][W] << endl;
}


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

int main(){
  int s[2000],n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  bool odd=false;
  for(int i=0;i<n;i++){
    if(s[i]%2==0&&s[i]%3!=0&&s[i]%5!=0){
      odd=true;
    
    }
  }
  if(odd) cout<<"DENIED";
  else{
    cout<<"APPROVED"<<endl;
  }
}



Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;

int main()
{
    long double a,b,h,m;
    cin >> a >> b >> h >> m;

    long double kakuH, kakuM;
    kakuH = h * 30.0 + (m / 2.0);
    kakuM = m * 6.0;
    long double PI = 3.141592653589793238462643;

    double xh, yh, xm, ym;

    double  radianH = kakuH * PI / 180;
    yh = sin(radianH) * a;
    xh = cos(radianH) * a;

    double  radianM = kakuM * PI / 180;
    ym = sin(radianM) * b;
    xm = cos(radianM) * b;

    double c = sqrt((xm - xh) * (xm - xh) + (ym - yh) * (ym - yh));


    //long double kaku = abs(kakuH - kakuM);
    /*if (kaku > 180) {
        kaku -= 180;
    }

    kaku = kaku * PI / 180.0;

    long double c2 = (a * a) + (b * b)- (2.0 * a * b * cos(kaku));

    long double c = sqrt(c2);*/

    printf("%.20f", c);

    return 0;
}

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

using namespace std;

const int N = 1e6+6,M=1e9+7,OO=0x3f3f3f3f;

int n,m,k,dots;
string s;

int main(){
    cin>>s;
    if(s=="Sunny")
        printf("Cloudy");
    else if(s=="Cloudy")
        printf("Rainy");
    else
        printf("Sunny");
    return 0;
}


Measured memory_bytes: 256
using System;
public class Hello{
    public static void Main(){
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        string[] s = new string[N];
        for(int i = 0;i < N;i++){
            s[i] = Console.ReadLine();
        }
        for(int i = 0;i < N;i++){
            Console.WriteLine(s[i]);
            Console.WriteLine(s[i]);
        }
    }
}


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

int main(){
  int N, X, L, D=0;
  cin >>N >>X;

  int ans=1;
  for(int i=0;i<N;i++){
    cin >>L;
    D += L;
    if(D>X) break;
    ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;

typedef long long int ll;
typedef pair<ll,ll> pp;
typedef long double ld;
typedef vector<pp> vpl;
//typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 

 
const ll N = 1000004;
const ll mod = 998244353;
const long long int inf = 10000000000;

#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   
 
const ld pi = 3.14159265359;

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

 
void fastIO(void);
void decimal(int);
inline ll modmulti(ll, ll);
inline ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);




int main(){
	fastIO();
	ll h1,s1,h2,s2;
	cin>>h1>>s1>>h2>>s2;
	ll t1,t2;
	t1 = h1/s2;
	t2 = h2/s1;
	if(h1%s2!=0) t1++;
	if(h2%s1!=0) t2++;
	if(t1>=t2) cout<<"Yes\n";
	else cout<<"No\n";
}
	


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
inline ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
inline ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}

Measured memory_bytes: 3616
import bisect
two_ruijo_list = [2**i for i in range(18)]
N,K = map(int,input().split())
if K <= N:
    mi = K
    ans = (N-K+1)/N
else:
    mi = N+1
    ans = 0
#mi = min(N+1,K)
for i in range(1,mi):
    d = bisect.bisect_left([two_ruijo_list[j]*i for j in range(18)], K)
    ans += 0.5**d /N
print(ans)

Measured memory_bytes: 3060
#include <array>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

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

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

enum { LU, RU, LD, RD, NUM};
int h, w;

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

typedef pair<int, int> point;
#define X first
#define Y second

inline bool out(int x, int y) {
	return x < 0 || y < 0 || x >= w || y >= h;
}

void dfs(const point &current, vector<string> &picture, array<point, NUM> &corner) {
	picture[current.Y][current.X] = ' ';

	if(current.Y < corner[LU].Y) {
		corner[LU] = corner[RU] = current;
	}
	else if(current.Y == corner[LU].Y) {
		chmin(corner[LU], current);
		chmax(corner[RU], current);
	}

	if(current.Y > corner[LD].Y) {
		corner[LD] = corner[RD] = current;
	}
	else if(current.Y == corner[LD].Y) {
		chmin(corner[LD], current);
		chmax(corner[RD], current);
	}

	rep(d, 8) {
		const int nx = current.X + dx[d];
		const int ny = current.Y + dy[d];

		if(!out(nx, ny) && picture[ny][nx] == '*') {
			dfs(point(nx, ny), picture, corner);
		}
	}
}

int area(int x, int y, vector<string> &picture) {
	array<point, NUM> corner{{point(w, h), point(0, h), point(w, 0), point(0, 0)}};
	dfs(point(x, y), picture, corner);
	const int tw = corner[RU].X - corner[LU].X + corner[RD].X - corner[LD].X + 2;
	const int ty = corner[LD].Y - corner[LU].Y + 1;
	return tw * ty / 2;
}

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

	bool first = true;
	const string bar(10, '-');
	while(cin >> h && h) {
		cin.ignore();

		if(first) first = false;
		else cout << bar << endl;

		vector<string> picture(h);
		w = 0;
		for(auto &e : picture) {
			getline(cin, e);
			chmax<int>(w, e.size());
		}

		for(auto &e : picture) e = (e + string(w, ' ')).substr(0, w);

		map<int, int> trapezoids;
		rep(y, h) {
			rep(x, w) {
				if(picture[y][x] == '*') {
					++trapezoids[area(x, y, picture)];
				}
			}
		}

		for(const auto &e : trapezoids) {
			cout << e.first << ' ' << e.second << endl;
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1268
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
const int mod = 998344253;
typedef struct DLL_Node{
	int key;
	struct DLL_Node *prev, *next;
}Node;
Node *nil;
int H, W, Ch, Cw, Dh, Dw, d[1111][1111];
char s[1111][1111];
void push_front(int x){
	Node *z = (Node*)malloc(sizeof(Node));
	(*z).key=x;
	(*(*nil).next).prev = z;
	(*z).next = (*nil).next;
	(*nil).next = z;
	(*z).prev = nil;
	return;
}
void push_back(int x){
	Node *z = (Node*)malloc(sizeof(Node));
	(*z).key=x;
	(*(*nil).prev).next = z;
	(*z).prev = (*nil).prev;
	(*nil).prev = z;
	(*z).next = nil;
	return;
}
int front(){
	Node *t = (*nil).next;
	(*nil).next = (*(*nil).next).next;
	(*(*nil).next).prev = nil;
	int res = (*t).key;
	free(t);
	return res;
}
int main(){
	nil = (Node*)malloc(sizeof(Node));
	(*nil).next=(*nil).prev=nil;
	scanf("%d%d%d%d%d%d", &H, &W, &Ch, &Cw, &Dh, &Dw);
	Ch--; Cw--; Dh--; Dw--;
	for(int i=0; i<H; i++){
		scanf("%s", s[i]);
		for(int j=0; j<W; j++)d[i][j] = mod-1;
	}
	push_front(Ch * 10000 + Cw);
	d[Ch][Cw] = 0;
	while((*nil).next != nil){
		int tmp = front();
		int x = tmp/10000, y = tmp%10000;
		for(int i=-2; i<3; i++){
			for(int j=-2; j<3; j++){
				int nx = x+i, ny = y+j;
				if(0<=nx&&nx<H && 0<=ny&&ny<W && s[nx][ny]=='.'){
					int c = (abs(i)+abs(j)>1);
					int dis = d[x][y] + c;
					if(dis < d[nx][ny]){
						d[nx][ny] = dis;
						if(c){
							push_back(nx*10000 + ny);
						}else {
							push_front(nx*10000 + ny);
						}
					}
				}
			}
		}
	}
	printf("%d\n", (d[Dh][Dw]+1)%mod-1);
	//for(int i=0; i<H; i++){for(int j=0; j<W; j++)printf("%d", (d[i][j]+1)%mod-1);puts("");}
	return 0;
}

Measured memory_bytes: 7468
/*
ID: skipian1
PROB: 
LANG: C++11
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF = 2000000000
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define X first
#define Y second
ll MOD = 1e9+7;


int main() {
  ll n, k;
  cin >> n >> k;
  int arr[n];
  ll inv[n];
  ll ord[n];
  for (ll i = 0; i < n; i++) cin >> arr[i];
  for (ll i = 0; i < n; i++) {
    inv[i] = 0;
    ord[i] = 0;
    for (ll j = 0; j < n; j++) {
      if (arr[j] < arr[i]) {
	ord[i]++;
	if (j > i) inv[i]++;
      }
    }
  }
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    ans += inv[i]*k;
    ans %= MOD;
    ll num = k*(k-1)/2;
    num %= MOD;
    num *= ord[i];
    num %= MOD;
    ans += num;
    ans %= MOD;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    public static void Main()
    {
        int A = NextInt();
        int B = NextInt();
        if (B % A == 0) Console.WriteLine(A+B);
        else Console.WriteLine(B-A);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

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

// clang-format off
#define forn(i, x, y) for(int i = x; i < y; i++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)
// clang-format on

using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;

const long long MOD = 1000000007;

void dfs(VVI &tree, VVLL &dp, int u, int prev)
{
  for (auto v : tree[u])
  {
    if (v != prev)
    {
      dfs(tree, dp, v, u);
      dp[u][0] *= (dp[v][0] + dp[v][1]) % MOD;
      dp[u][0] %= MOD;
      dp[u][1] *= dp[v][0];
      dp[u][1] %= MOD;
    }
  }
}

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

  VVI tree(N + 1, VI());
  int x, y;
  forn(i, 0, N - 1)
  {
    cin >> x >> y;
    tree[x].push_back(y);
    tree[y].push_back(x);
  }

  VVLL dp(N + 1, VLL(2, 1));
  dfs(tree, dp, 1, -1);
  cout << (dp[1][0] + dp[1][1]) % MOD << endl;

  return 0;
}


Measured memory_bytes: 22360
#include <iostream>

int main(void){
    int H, W, x, y, r;
    scanf("%d%d%d%d%d", &H, &W, &x, &y, &r);
    puts((0 <= x - r and x + r <= H and 0 <= y - r and y + r <= W) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <string>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_utility.hpp>
#include <utility>
#include <boost/foreach.hpp>
#include <cmath>

int x1, x2, x3, x4, x5;

int main() {
  std::cin >> x1 >> x2 >> x3 >> x4 >> x5;

  if (x1 == 0) {
    std::cout << "1" << std::endl;
  }
  else if (x2 == 0) {
    std::cout << "2" << std::endl;
  }
  else if (x3 == 0) {
    std::cout << "3" << std::endl;
  }
  else if (x4 == 0) {
    std::cout << "4" << std::endl;
  }
  else if (x5 == 0) {
    std::cout << "5" << std::endl;
  }

  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<P, int> node;
typedef pair<P, node> PP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int h,w,k;
int sx,sy,gx,gy;
priority_queue<PP,vector<PP>,greater<PP>> que;

void solve(){
    cin >> h >> w >> k;
    cin >> sy >> sx >> gy >> gx;sx--;sy--;gx--;gy--;
    vector<string> S(h);
    rep(i,h){
        cin >> S[i];
    }
    vector<vector<vector<P>>> d(h,vector<vector<P>>(w,vector<P>(4,P(mod,0)))); 
    rep(i,4) {
        que.push(PP(P(1,0),node(P(sy,sx),i)));
        //d[sy][sx][i]=P(1,0);
    }
    while(!que.empty()){
        PP s=que.top();que.pop();
        int nx=s.second.first.second,ny=s.second.first.first,dir=s.second.second,num=s.first.first,cnt=s.first.second;
        //cout << ny << " " << nx << " " << dir << " " << num << " " << cnt << endl;
        //cout << "a" << endl;
        if(d[ny][nx][dir]<=P(num,cnt)) continue;
        d[ny][nx][dir]=P(num,cnt);
        rep(i,4){
            //cout << ny+dy[i] << " " << nx+dx[i] << " " << i << endl;
            if(ny+dy[i]<0 || ny+dy[i]>h-1 || nx+dx[i]<0 || nx+dx[i]>w-1) continue;
            if(S[ny+dy[i]][nx+dx[i]]=='@') continue;
            int nex_num,nex_cnt;
            if(dir==i && cnt<k){
                nex_num=num;nex_cnt=cnt+1;
            }
            else {
                nex_num=num+1;nex_cnt=1;
            }
            que.push(PP(P(nex_num,nex_cnt),node(P(ny+dy[i],nx+dx[i]),i)));
        }
    }
    //cout << "n" << endl;
    int ans=mod;
    rep(i,4) ans=min(ans,d[gy][gx][i].first);
    //cout << ans << endl;
    // rep(i,h){
    //     rep(j,w){
    //         rep(dir,4) cout << i << " " << j << " " << dir << " " << d[i][j][dir].first << " " << d[i][j][dir].second << endl;
    //     }
    // }
    if(ans<mod)cout << ans << endl;
    else cout << -1 << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 144916
#include<iostream>
using namespace std;
int main(){
	int A1;
	int A2;
	int A3;
	cin >> A1 >> A2 >> A3;
	int sum=0;
	sum=A1+A2+A3;
	if(sum>21){
		cout << "bust" << endl;
	} else {
		cout << "win" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main(void){
    int a,b;cin>>a>>b;
    int c=0;
    for(int i=a;i<=b;i++){
        string s=to_string(i);
        string t=to_string(i);
        reverse(t.begin(), t.end());
        if(s==t)c++;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
from collections import deque
sa = deque(input())
sb = deque(input())
sc = deque(input())

now = sa.popleft()
while True:
    if now == "a":
        if sa:
            now = sa.popleft()
        else:
            print("A")
            exit()
    elif now == "b":
        if sb:
            now = sb.popleft()
        else:
            print("B")
            exit()
    elif now == "c":
        if sc:
            now = sc.popleft()
        else:
            print("C")
            exit()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int a[100010],b[100010];
//map<int,set<int>> mp;
set<pair<int,int>> mp;
long long ans[10];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int h,w,n;
	cin>>h>>w>>n;
	for(int i=0;i<n;i++)
		cin>>a[i]>>b[i];
	for(int i=0;i<n;i++)
		mp.insert({a[i],b[i]});
	vector<pair<int,int>> ps;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
			for(int k=0;k<3;k++)
				ps.push_back({a[i]+j,b[i]+k});
	}
	sort(ps.begin(), ps.end());
	ps.resize(unique(ps.begin(), ps.end())-ps.begin());
	for(auto p:ps)
	{
		int x=p.first, y=p.second;
		if(x>h||y>w||x-2<1||y-2<1)continue;
		int cnt=0;
		for(int j=0;j<3;j++)
			for(int k=0;k<3;k++)
				if(mp.count({x-j,y-k}))
					cnt++;
		ans[cnt]++;
	}
	ans[0]=(long long)(h-2)*(w-2);
	for(int i=1;i<10;i++)
		ans[0]-=ans[i];
	for(int i=0;i<10;i++)
		cout<<ans[i]<<'\n';
}

Measured memory_bytes: 14064
# https://beta.atcoder.jp/contests/arc098/tasks/arc098_a
# C - Attention

# C_Attention.py

N = int(input())
S = input()

e = [0 for i in range(N)]
w = [0 for i in range(N)]

# 累積和を求める
for i in range(N):
    # そこからE側の人で、Wを向くべきなのにEを向いている人
    if i > 0:
        w[i] += w[i-1]
    if i < N-1:
        if S[i] == "W":
            w[i+1] += 1
    # そこからW側の人で、Eを向くべきなのにWを向いている人
    if i > 0:
        e[N-1-i] += e[N-1-(i-1)]
    if i < N-1:
        if S[N-1-i] == "E":
            e[N-1-(i+1)] += 1

min = 10 ** 6
for i in range(N):
    total = e[i] + w[i]
    if total < min:
        min = total
print(min)


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

bool judge(int n)
{
    if (n == 0) {
        return true;
    } else if (n < 0) {
        return false;
    }
    return judge(n - 4) || judge(n - 7);
}

int main()
{
    int n;
    cin >> n;
    if (judge(n)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

#define si(n) scanf("%d",&n)
#define MAX 100005
#define ll long long

int arr[MAX],k;

int main()
{
    //freopen("input.txt","r",stdin);
    int i,j;
    si(k);
    for(i=1;i<=k;i++)si(arr[i]);
    if(arr[k]>2)return printf("-1\n"),0;
    ll lft=arr[k],rht=arr[k]*2-1;
    for(i=k-1;i>=1;i--){
        //cout<<i<<' '<<lft<<' '<<rht<<endl;
        ll x=lft/arr[i];
        if(x==0 || lft%arr[i])x++;
        if(arr[i]*x<lft || arr[i]*x>rht)return printf("-1\n"),0;
        lft=arr[i]*x;

        x=rht/arr[i];
        if(!x ||arr[i]*x<lft || arr[i]*x>rht)return printf("-1\n"),0;
        rht=arr[i]*x+arr[i]-1;
    }
    printf("%lld %lld\n",lft,rht);
}



Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long H=sc.nextLong();
		long W=sc.nextLong();
		
		if(H%3==0||W%3==0) {
			System.out.println(0);
			return;
		}
		long S[]= {0,0,0};
		long d=H*W;
		
		for(long i=1;i<H;i++) {
			S[0]=W/2*i;
			S[1]=(W-W/2)*i;
			S[2]=W*(H-i);
			Arrays.sort(S);
			d=Math.min(d, S[2]-S[0]);
		}
		for(long i=1;i<W;i++) {
			S[0]=H/2*i;
			S[1]=(H-H/2)*i;
			S[2]=H*(W-i);
			Arrays.sort(S);
			d=Math.min(d, S[2]-S[0]);
		}
		d=Math.min(d, H);
		d=Math.min(d, W);
		
		System.out.println(d);
	}
}


Measured memory_bytes: 25172
word = gets.chomp.split("")
leng = word.length
nu = gets.to_i
word_s = word.sort
ans = []

if nu == 1
  print word_s[0]
  exit
end
if leng == 2
  ans[0] = word_s[0]
  if word_s[0] == word[0]
    ans[1] = word.join
    ans[2] = word[1]
  else
    ans[1] = word[1]
    ans[2] = word.join
  end
  print ans[nu - 1]
  exit
end

inst = ""
count = 0
count2 = 1
count3 = 1

while count2 < leng
  if word_s[count3] == word_s[count3 - 1]
    word_s.delete_at(count3)
  else
    count3 += 1
  end
  count2 += 1
end


for i in 0..leng - 1
  if word[i] == word_s[0] || word[i] == word_s[1] || word[i] == word_s[2]
    while (count <= 4) && (i + count < leng)
      inst += word[i + count]
      ans.push(inst)
      count += 1
    end
  end
  inst = ""
  count = 0
end

ans_s = ans.sort
leng2 = ans.length
count2 = 1
count3 = 1

while count2 < leng2
  if ans_s[count3] == ans_s[count3 - 1]
    ans_s.delete_at(count3)
  else
    count3 += 1
  end
  count2 += 1
end

print ans_s[nu - 1]


Measured memory_bytes: 3656
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall


n = int(input())
s = list()
for i in range(n):
    s.append([int(x) for x in list(input())])
s=np.array(s)
d=floyd_warshall(csr_matrix(s))
c=d[:, np.argmax(d) % n]
for i in range(n):
    for j in range(i+1, n):
        if (s[i, j] == 1) and abs(c[i] - c[j]) != 1:
            print(-1)
            exit()
r=int(np.amax(d)+1)
print(r)


Measured memory_bytes: 16588
n=int(input())
s=list(input())
d={}
ans=0
for x in range(n-2):
  if s[x] not in d:
    d[s[x]]=0
    for y in range(x+1,n-1):
      if (s[x]+s[y]) not in d:
        d[(s[x]+s[y])]=0
        for z in range(y+1,n):
          if (s[x]+s[y]+s[z]) not in d:
            d[(s[x]+s[y]+s[z])]=0
            ans+=1
    
print(ans)   

Measured memory_bytes: 75296
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,m,n) for(int i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;


int main(){
  int n;cin>>n;
  string s,t;
  cin >> s >> t;
  rep(i,n)cout << s[i] << t[i];

  return 0;
}


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

using namespace std;

int main()
{
    char a;
    unsigned int t = 0, c1 = 0, c2 = 0;
    while((a = getchar()) != '\n')
    {
        if(t % 2 == 0)
        {
            if(a == '0')
                c1++;
            else
                c2++;
        }
        else if (t % 2 == 1)
        {
            if(a == '0')
                c2++;
            else
                c1++;
        }
        t++;
    }
    cout << min(c1, c2);
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }
    sort(all(data));

    int sum = 0;
    rep(i, n-1) sum += data[i];

    if (sum > data.back()) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections import Counter
from itertools import accumulate
from collections import defaultdict
INF = float("inf")


def solve(N: int, A: "List[int]"):
    c = Counter(A)
    d = Counter(c.values())
    d = tuple(accumulate([d[i] for i in range(N, -1, -1)]))[::-1]
    S = [0]*(N+1)
    for i in range(1, N+1):
        S[i] = S[i-1] + d[i]

    def isOK(y):
        return S[y] < K*y

    def binary_search(x):
        ng = -1
        ok = len(x)+1

        while abs(ok - ng) > 1:
            mid = (ok + ng)//2
            if isOK(mid):
                ok = mid
            else:
                ng = mid
        return ng, ok

    for K in range(1, N+1):
        ng, ok = binary_search(range(N))
        print(ng)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 123676
#include <iostream>
#include <vector>
#define INF 1e18
#define F first
#define S second
using namespace std;

vector<vector<pair<long long,long long>>>dp;

pair<long long,long long> dp_func(long long arr[], int i, int j)
{
    
    if(i==j)
        return {0ll,(long long)arr[i]};
    
    if(dp[i][j].F!=INF)
        return dp[i][j];
    
    pair<long long,long long> ans={INF, INF};
    
    for(int it=i;it<j;it++)
    {
        pair<long long,long long>x = dp_func(arr, i,it);
        pair<long long,long long>y = dp_func(arr,it+1,j);
        if(x.F+y.F+x.S+y.S<=ans.F)
            ans={x.F+y.F+x.S+y.S, x.S+y.S};
    }
    return dp[i][j]=ans;
    
}

int main() {
	
	int n;
	cin>>n;
	long long arr[n];
	for(int i=0;i<n;i++)
    	cin>>arr[i];
	
	dp.assign(n,vector<pair<long long,long long>>(n,{INF,INF}));
	
// 	pair<long long,long long>x=;
	
	cout<<dp_func(arr,0,n-1).F;
	
	return 0;
}

Measured memory_bytes: 5836
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int A,B,C,D;

int main(){
    cin>>A>>B>>C>>D;
    if(A<C){
        if(B<=C){
            out(0);
        }
        else{
            out(min(D,B)-C);
        }
    }
    else{
        if(D<=A){
            out(0);
        }
        else{
            out(min(B,D)-A);
        }
    }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

const int MAXN = 300000 + 10;
int Ans[MAXN];

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

	if (K % 2 == 0) {
		cout << K / 2;
		for (int i = 0; i < N - 1; i++) cout << " " << K;
		cout << endl;
	}
	else {
		
		int x = (K + 1) / 2;
		int d = N / 2;
		for (int i = 0; i < N; i++) Ans[i] = x;
		int j = N - 1;
		for (int i = 0; i < d; i++) {
			while (Ans[j] == 0) {
				j--;
			}

			if (Ans[j] == 1) {
				Ans[j] = 0;
				j--;
				continue;
			}

			Ans[j]--;

			for (int k = j + 1; k < N; k++) Ans[k] = K;
			j = N - 1;
		}
		printf("%d", Ans[0]);
		for (int i = 1; i < N; i++) {
			if (Ans[i] == 0)
				break;
			printf(" %d", Ans[i]);
		}
		printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1010;
char s[110];
int main()
{
    int n , m;
    while (~scanf("%d%d", &n, &m)){
        scanf("%s", s);
        bool flag = true;
        for (int i=0; i<n; i++){
            if (!isdigit(s[i])) {
                flag = false;
                break;
            }
        }
        if (s[n] != '-')  flag = false;
        for (int i=n+1; i<n+m+1; i++){
            if (!isdigit(s[i])) {
                flag = false;
                break;
            }
        }
        if (flag)  puts("Yes");
        else  puts("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define ll long long
#define fm_t  ll t;cin>>t;while(t--)
#define fr(i,a,b) for( ll i=a;i<b;i++)
#define fr1(i,n,a) for( ll i=n-1;i>=a;i--)
#define sz(x) (ll)(x).size()
#define all(v)  (v).begin(), (v).end()
#define Sort(x) sort(x.begin(),x.end())
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
const ll mod = 998244353;
#define Mod 1000000007

#define inf 1e18
#define ld long double
#define pll pair<ll, ll> 
#define vi vector<int>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vvi vector< vector<int> >
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<ll, ll>, ll >
#define pi pair<ll, ll>
#define ppi pair<pair<ll, ll>, ll>
#define ump unordered_map<ll,ll>
#define pri priority_queue< pair<ll,ll> , vector< pair<ll,ll> >, greater< pair<ll,ll> > >
void ingraph(vl graph[], ll m){ll x, y;fr(i,0,m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}

#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)

//setprecision(10)
//greater<int>()
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}


ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll modinv(ll a){
    return modpower(a,mod-2);
}   
     
int main()
{
      
  fast;
  ll n,k;
  cin>>n>>k;
  ll h[n+5];
  fr(i,0,n)
    cin>>h[i];
    fr(i,n,n+5)
    h[i]=0;
  ll dp[n+5];
  for(ll i=0;i<n+5;i++)
  {
    dp[i]=inf;
   // dp[i][1]=inf;
  }
  dp[0]=0;

  for(ll i=0;i<n;i++)
  {
    for(ll j=1;j<=k;j++)
    {
      if(i+j<n)
      {
        dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
      }
    }
    
  }
  cout<<dp[n-1]<<endl;


    
//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
return 0;
}

Measured memory_bytes: 5200
s = input()
N = len(s)
s_num = [int(i) for i in s]
for i in range(2**(N-1)):
    x = []
    value = s_num[0]
    for j in range(N-1):
        if (i >> j) & 1:
            x.append('+')
            value += s_num[j+1]
        else:
            x.append('-')
            value -= s_num[j+1]
    if value == 7:
        fomula = ''
        for k in range(N-1):
            fomula += s[k]
            fomula += x[k]
        fomula += s[N-1]
        fomula += '=7'
        print(fomula)
        break

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

using namespace std;

const int maxn = 100010;

int n, c, k, ans = 0, last = 0;
int t[maxn];

int main() {
	scanf("%d%d%d", &n, &c, &k);
	for (int i = 1; i <= n; i++) scanf("%d", &t[i]);
	sort(t+1, t+n+1);
	for (int i = 1; i <= n; i++) {
		if (!last) {
			last = i;
			++ ans;
		} else {
			if (i-last >= c || t[i] - t[last] > k) {
				last = i;
				++ ans;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
import sys
from numba import njit, i8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8, i8, i8, i8), cache=True)
def floor_sum(n, m, a, b):
    ans = 0
    while True:
        if a >= m:
            ans += (n - 1) * n * (a // m) // 2
            a %= m
        if b >= m:
            ans += n * (b // m)
            b //= m
        y_max = (a * n + b) // m
        x_max = y_max * m - b
        if not y_max:
            return ans
        ans += (n - (x_max + a - 1) // a) * y_max
        n, m, a, b = y_max, a, m, (a - x_max) % a

T = int(readline())
m = map(int, read().split())
for n, m, a, b in zip(m, m, m, m):
    print(floor_sum(n, m, a, b))

Measured memory_bytes: 124280
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
const int M = 100010;
typedef long long int ll;

int cost[N],val[N];
ll dp[N][M];
int n,m;

ll solve(int i,int w)
{
	if(i > n || w < 0) return 0;
	if(dp[i][w] != -1) return dp[i][w];

	ll ncol = solve(i+1,w);

	if(w - cost[i] >= 0)
	{
		ll col = solve(i+1,w-cost[i]) + val[i];
		return dp[i][w] = max(ncol,col);
	}

	return dp[i][w] = ncol;
}
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	for(int i=0;i<N;++i)
		for(int j=0;j<M;++j)
			dp[i][j] = -1;

	cin>>n>>m;
	for(int i=1;i<=n;++i)
		cin>>cost[i]>>val[i];
	
 	cout<<solve(1,m)<<"\n";
}

Measured memory_bytes: 86272
#include <map>
#include <queue>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

int n,a[100010],v[10] = {-1,-1,-1};
map<int,int> Mp;
int main() {
	read(n);
	for(int i=0;i<n;i++){
		read(a[i]);
	}
	sort(a,a+n);
	for(int i=0;i<n;i++){
		Mp[a[i]]+=1;
		for(int j=0;j<3;j++){
			if(v[j] == -1){
				v[j] = a[i];
				break;
			}
			if(v[j] == a[i])break;
		}
	}
	//cout<<v[0]<<v[1]<<v[2]<<endl;
	if(v[0] == 0){
		if(Mp[v[0]] == n || (n%3 == 0 && Mp[v[0]]== n/3 && Mp[v[1]] == 2*n/3)){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	for(int i=0;i<3;i++){
		if(Mp[v[i]]!=n/3){
			cout<<"No"<<endl;
			return 0;
		}
	}
	if((v[0]^v[1])!=v[2]){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 4224
from collections import deque
S=input()
N=len(S)
i=0
flag=1
ans=[]
buf=""
while i<N:
    if (i+9<N)and((S[i]=="d")and(S[i+1]=="r")and(S[i+2]=="e")and(S[i+3]=="a")and(S[i+4]=="m")and(S[i+5]=="e")and(S[i+6]=="r")and(S[i+7]=="a")and(S[i+8]=="s")and(S[i+9]=="e")):
        if i+10==N:
            break
        elif (S[i+10]=="d")or(S[i+10]=="e"):
            i=i+10
        elif (S[i+10]=="r"):
            i=i+5
        else:
            flag=0
            break
    elif (i+6<N)and((S[i]=="d")and(S[i+1]=="r")and(S[i+2]=="e")and(S[i+3]=="a")and(S[i+4]=="m")and(S[i+5]=="e")and(S[i+6]=="r")):
        if i+7==N:
            break
        elif (S[i+7]=="d")or(S[i+7]=="e"):
            i=i+7
        else:
            flag=0
            break
    elif (i+4<N)and((S[i]=="d")and(S[i+1]=="r")and(S[i+2]=="e")and(S[i+3]=="a")and(S[i+4]=="m")):
        if i+5==N:
            break
        elif (S[i+5]=="d"):
            i=i+5
        else:
            flag=0
            break
    elif (i+5<N)and((S[i]=="e")and(S[i+1]=="r")and(S[i+2]=="a")and(S[i+3]=="s")and(S[i+4]=="e")and(S[i+5]=="r")):
        if i+6==N:
            break
        elif (S[i+6]=="e")or(S[i+6]=="d"):
            i=i+6
        else:
            flag=0
            break
    elif (i+4<N)and((S[i]=="e")and(S[i+1]=="r")and(S[i+2]=="a")and(S[i+3]=="s")and(S[i+4]=="e")):
        if i+5==N:
            break
        elif (S[i+5]=="e")or(S[i+5]=="d"):
            i=i+5
        else:
            flag=0
            break
    else:
        flag=0
        break
    #print(i)
    #input()
if flag==1:
    print("YES")
else:
    print("NO")







Measured memory_bytes: 42736
H,W = map(int, input().split())
a = [[int(i) for i in input().split()] for _ in range(H)]

move = []
for i in range(H):
    if i % 2 == 0:
        for j in range(W):
            if a[i][j] % 2 == 1:
                if j == W - 1 and i < H - 1:
                    move.append((i+1,j+1,i+2,j+1))
                    a[i][j] -= 1; a[i+1][j] += 1
                elif j < W - 1:
                    move.append((i+1,j+1,i+1,j+2))
                    a[i][j] -= 1; a[i][j+1] += 1
    else:
        for j in range(W-1, -1, -1):
            if a[i][j] % 2 == 1:
                if j == 0 and i < H - 1:
                    move.append((i+1,j+1,i+2,j+1))
                    a[i][j] -= 1; a[i+1][j] += 1
                elif j > 0:
                    move.append((i+1,j+1,i+1,j))
                    a[i][j] -= 1; a[i][j-1] += 1

print(len(move))
for ans in move:
    print(*ans, sep=" ")

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

int a;
int ans;

int main(){
  a=0;
  int b,B;
  int A;
  cin>>A;
  for(int i=0;i<A;i++){
    cin>>b>>B;
    if(a<b){
      ans=b+B;
      a=b;
     }
   }
cout<<ans<<endl;
}


Measured memory_bytes: 256
def vec(ap):
    input_line = input()
    x = input_line.split()
    query = [int(s) for s in x]
    if query[0] == 0:
        ap.append(query[1])
    elif query[0] == 1:
        ap_out = ap[query[1]]
        print(ap_out)
    elif query[0] == 2:
        del ap[-1]
    x = []
    s = []
    input_line = 0
    return ap

x = []
ap = []
input_num = int(input())
for a in range(input_num):
    vec(ap)


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

mod = 10**9+7
n = int(input())
A = tuple(tuple(map(int, input().split())) for _ in range(n))
dp = [[-1]*(1<<n) for _ in range(n+1)]
def f(i, k):
  if i == n:
    return 1
  if dp[i][k] != -1:
    return dp[i][k]
  res = 0
  for j in range(n):
    if A[i][j] and ((k>>j)&1):
      res += f(i+1, k^(1<<j))
      res %= mod
  dp[i][k] = res
  return res
ans = f(0, (1<<n)-1)
print(ans)

Measured memory_bytes: 436200
main :: IO ()
main =
  getLine >>=
    putStrLn
    . (\xs -> judge (xs!!0) (xs!!1) (xs!!2) (xs!!3) (xs!!4))
    . map (read :: String -> Int) . words

judge w h x y r =
  if x - r >= 0 && y - r >= 0 && x + r <= w && y + r <= h
    then "Yes"
    else "No"



Measured memory_bytes: 3636
a,b,c=map(int,input().split())
k=int(input())
x='No'
for i in range(k+1):
  A=a*2**i
  for j in range(k-i+1):
    B=b*2**j
    C=c*2**(k-i-j)
    if A<B<C:
      x='Yes'
print(x)

Measured memory_bytes: 9176
#include<cstdio>
#include<cstring>

using namespace std;

int main() {
    while (true) {
        char x[1001];
        scanf("%s", x);
        if (x[0] == '0') break;
        int s = 0;
        for (int i = 0; i < strlen(x); i++) {
            s += x[i] - '0';
        }
        printf("%d\n", s);
    }
    return 0;
}


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

#define int long long

#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second

using vint = vector<int>;
using pint = pair<int, int>;
using vpint = vector<pint>;

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

template <class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>& p) {
    ost << "{" << p.first << "," << p.second << "}";
    return ost;
}

template <class T>
ostream& operator<<(ostream& ost, const vector<T>& v) {
    ost << "{";
    for (int i = 0; i < v.size(); i++) {
        if (i) ost << ",";
        ost << v[i];
    }
    ost << "}";
    return ost;
}

inline int topbit(unsigned long long x) {
    return x ? 63 - __builtin_clzll(x) : -1;
}

inline int popcount(unsigned long long x) {
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x) {
    return __builtin_parity(x);
}

signed main() {
    int N;
    cin >> N;
    vint A(N);
    rep(i, N) cin >> A[i];

    int ans = 0;
    for (int i = 1; i < N; i++) {
        int tmp = max(0ll, A[i - 1] - A[i]);
        A[i] += tmp;
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4744
#include <stdio.h>
#define Nmax 10000
#define Qmax 500

int  LinerSearch(int );
int S[Nmax],n;

int main(){
  int q,i;
  int T[Qmax];
  int sum=0;
  int ans;

  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0 ; i<q ; i++){
    scanf("%d",&T[i]);
  }
  
  for(i=0 ; i<q ; i++){
    ans = LinerSearch(T[i]);
    if(ans == T[i]) sum++;
  }

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

  return 0;
}

int LinerSearch(int key){
  int i;

  for(i=0 ; i<n ; i++){
    if (S[i] == key) return S[i];
  }

  return S[i];
}

Measured memory_bytes: 636
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int n, c[20], v[20];
	cin >> n;
	REP(i,n) cin >> v[i];
	REP(i, n ) cin >> c[i];
	REP(i,n){
		if(v[i] > c[i]) ans += v[i] - c[i];
	}
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

struct BIT{
    int n;
    VL bit;

    BIT(){}
    BIT(int x){
        n = x;
        bit.resize(x+1);
    }

    void init(int x){
        n = x;
        bit.resize(x+1);
    }

    void add(int i, ll x){
        i++;
        while (i <= n){
            bit[i] += x;
            i += i & -i;
        }
    }

    // [0, i]
    ll sum(int i){
        i++;
        ll ret = 0;
        while (i > 0){
            ret += bit[i];
            i -= i & -i;
        }
        return ret;
    }

    // [l, r)
    ll sum(int l, int r){
        if (l >= r) return 0;
        return sum(r-1) - sum(l-1);
    }
};

int main(void){
    int n, m;
    cin >> m >> n;
    vector<pair<int, P> > a(m);
    REP(i,m){
        scanf("%d %d", &a[i].second.first, &a[i].second.second);
        a[i].first = a[i].second.second - a[i].second.first + 1;
    }
    sort(ALL(a));

    BIT bit;
    bit.init(n+1);
    int j = 0;
    REP(i,n){
        int d = i + 1;
        while (j < m && a[j].first < d){
            bit.add(a[j].second.first,1);
            bit.add(a[j].second.second+1,-1);
            j++;
        }
        int ans = m - j;
        for (int k = d; k <= n; k += d){
            ans += bit.sum(k);
        }
        printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 5248
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 998244353;
const ll MAX = 2000001;

ll mod(ll a){
  if(a % MOD < 0) return MOD + (a % MOD);
  return a % MOD;
}

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


int main(){
  ll n,h; cin >> n >> h; ll cnt = 0;
  
  vvl table(n,vl(2));
  
  rep(i,n) cin >> table[i][0] >> table[i][1];
  
  vl bn(n);
  
  rep(i,n) bn[i] = table[i][1];
  
  sort(all(bn));
  reverse(all(bn));
  
  ll maxcut = 0;
  
  rep(i,n){
    maxcut = max(maxcut,table[i][0]);
  }
  
  rep(i,n){
    if(bn[i] > maxcut){
      cnt++;
      h -= bn[i];
      
      if(h <= 0){
        cout << cnt << endl;
        return 0;
      }
    }
  }
  
  
  cnt += (h+maxcut-1)/maxcut;
  
  cout << cnt << endl;
  
  
}

Measured memory_bytes: 12716
#include <iostream>

using namespace std;




int main() {
	int N, K;
	cin >> N >> K;
	// i = 0
	long long count = N / K;
	count = count * count * count;
/*
	int last = N % K;
	if (last == 0) {
		last = K;
	}
*/
	for (long long i = 1; i < K; i++) {
		if ((i * 2) % K != 0) {
			continue;
		}

		long long num = N / K;
		if (N % K >= i) {
			num++;
		}
		num = num * num * num;
		count += num;
	}
	cout << count << endl;



	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // 標準入力からデータを読み込む準備
        Scanner sc = new Scanner(System.in);
        // 2つの文字の固まりを整数値と想定して読み込む 
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a<b)System.out.println("a < b"); 
        else if(a==b)System.out.println("a == b");
        else System.out.println("a > b");
    } 
}


Measured memory_bytes: 26120
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> as(n), bs(n);
    set<int> st;
    for(int i = 0; i < n; i++){
        cin >> as[i] >> bs[i];
    }
    for(int i = 1; i <= m; i++){
        st.insert(i);
    }
    vector<int> is(n);
    iota(is.begin(), is.end(), 0);
    sort(is.begin(), is.end(), [&](int i, int j){ return bs[i] > bs[j]; });
    printde(as, bs);
    printde(is);
    int ans = 0;
    for(auto& i : is){
        int a = as[i], b = bs[i];
        auto ite = st.lower_bound(a);
        if(ite == st.end()){ continue; }
        ans += b;
        st.erase(ite);
        printde(st);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 6144
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<map>
using namespace std;
map<int,int> p;
int main()
{
    int i,j,k,flag=1,n,m,x;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&x);
        p[x]++;
    }
    scanf("%d",&m);
    for(i=0;i<m;i++)
    {
        scanf("%d",&x);
        if(p[x])
        {
            p[x]--;
        }
        else
        flag=0;
    }
    if(flag)
    printf("YES\n");
    else
    printf("NO\n");
    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int A[10001], cnt;
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> A[i];
        int temp = A[i];
        while(temp % 2 == 0)
            temp /= 2, cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 256
# *-* coding=utf-8 *-*


nn = int(input())
n = []
for i in range(nn):
    n.append(int(input()))
a = ia = b = ib = c = 0
for i in n:
    if a<i: a = i; ia = c
    elif b<i: b = i; ib = c
    c += 1
for i in range(len(n)):
    if i == ia: print(b)
    else: print(a)


Measured memory_bytes: 12532
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
#define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;
ll dp[100005][13];

signed main(void) {
	ll N;
	cin >> N;
	
	ll ans = 0;
	rep(i, N) {
		ans += i;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256