akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static String U = "U";
	static String D = "D";
	static String L = "L";
	static String R = "R";

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int sx = in.nextInt();
			int sy = in.nextInt();
			int tx = in.nextInt();
			int ty = in.nextInt();
			int dw = tx - sx;
			int dh = ty - sy;

			// solve
			StringBuffer sb = new StringBuffer();
			sb.append(L);
			for (int i = 0; i < dh+1; i++) {
				sb.append(U);
			}
			for (int i = 0; i < dw+1; i++) {
				sb.append(R);
			}
			for (int i = 0; i < dh+1; i++) {
				sb.append(D);
			}
			for (int i = 0; i < dw; i++) {
				sb.append(L);
			}
			for (int i = 0; i < dh; i++) {
				sb.append(U);
			}
			for (int i = 0; i < dw+1; i++) {
				sb.append(R);
			}
			for (int i = 0; i < dh+1; i++) {
				sb.append(D);
			}
			for (int i = 0; i < dw+1; i++) {
				sb.append(L);
			}
			sb.append(U);

			out.println(sb.toString());

		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

int main(void) {

	int n;

	std::cin >> n;

	bool flag = false;

	for (size_t i = 0; i <= n / 4; i++) {
		for (int j = 0; i * 4 + j * 7 <= n; j++) {
			if (i * 4 + j * 7 == n) {
				flag = true;
			}
		}
	}

	if (flag) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(){
	using namespace std;
	int h,w;
	cin >> h >> w;
	char grid[h][w];
	for(int a = 0;a < h;a++){
		for(int b = 0;b < w;b++){
			cin >> grid[a][b];
		}
	}
	int dp[h][w];
	for(int a = h-1;a >= 0;a--){
		for(int b = w-1;b >= 0;b--){
			if (a == h-1&&b == w-1) dp[a][b] = 1;
			else if (grid[a][b] == '#'){
				dp[a][b] = 0;
			}
			else{
				dp[a][b] = 0;
				if (b != w-1) dp[a][b] += dp[a][b+1];
				if (a != h-1) dp[a][b] += dp[a+1][b];
				dp[a][b] = dp[a][b]%1000000007;
				//dp[a][b] = dp[a][b+1]+dp[a+1][b];
			}
			//cout << dp[a][b] << ' ';
		}
		//cout << '\n';
	}
	cout << dp[0][0];
}


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

int	main()
{
	int	N, W;
	cin >> N >> W;
	int	v[100];
	int	w[100];
	for (int i = 0; i < N; ++i)
		cin >> v[i] >> w[i];
	int	val[10001];
	for (int i = 0; i <= W; ++i)
		val[i] = 0;
	int	v_i, val_j, val_k, k;
	int	max_val = 0;
	for (int i = 0; i < N; ++i) {
		v_i = v[i];
		for (int j = 0; j <= W; ++j) {
			val_j = val[j];
			k = j + w[i];
			if (k > W) continue;
			val_k = val_j + v_i;
			if (val[k] < val_k) {
				val[k] = val_k;
				if (max_val < val_k)
					max_val = val_k;
			}
		}
	}
	cout << max_val << endl;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 1; i < (n); ++i)

using namespace std;

void solve(int N, vector<int> v) {
  sort(v.begin(), v.end());
  float ans = v[0];
  rep(i, N)
    ans = (ans + v[i]) / 2.0;
  cout << ans << endl;
}

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

  int N;
  cin >> N;
  vector<int> v(N);
  for(int i = 0 ; i < N ; i++){
    cin >> v[i];
  }
  solve(N, move(v));
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;

int main() {
  int n, k;
  cin >> n >> k;
  VI snuke(n);
  rep(i, k) {
    int d;
    cin >> d;
    rep(j, d) {
      int a;
      cin >> a;
      a--;
      snuke.at(a) += 1;
    }
  }
  int cnt = 0;
  rep(i, n) {
    if (snuke.at(i) == 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> A(N);
    rep (i, N) {
        cin >> A[i];
    }

    bool flag = true;
    A[0]--;
    rep (i, N-1) {
        if (A[i+1] > A[i]) {
            A[i+1]--;
        } else if (A[i+1] == A[i]) {
            ;
        } else {
            flag = false;
        }
    }

    if (flag) {
        Yes;
    } else {
        No;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
using namespace std;
 main()
{
  int x;
  cin>>x;
  for(int i =1; i; i++){
        int cur = 100;
        for(int j =1; j<=i; j++){
            cur+=(cur/100);
        }
  if(cur >=x)return cout<<i<<endl,0;

  }

	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<int(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=2000005;
char s[N]; int n,ans;

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	rep(i,1,n){
		if(s[i]=='?') s[i]='D';
	}
	puts(s+1);
	return 0;
}

Measured memory_bytes: 3876
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    string s, t;
    cin >> s >> t;

    vector<vector<int>> place(27);

    for(int i = 0; i < s.size(); i++){
        int ichar = s[i] - 'a';
        place[ichar].push_back(i + 1);
    }
    for(int i = 0; i < 26; i++){
        if(place[i].size() > 0){
            place[i].push_back((int)1e9);
        }
    }

    ll ans = 0;
    int index = 0;

    for(int i = 0; i < t.size(); i++){
        int ichar = t[i] - 'a';
        if(place[ichar].size() == 0){
            cout << -1 << endl;
            return 0;
        }


        auto next = upper_bound(place[ichar].begin(), place[ichar].end(), index) - place[ichar].begin();

        if(place[ichar][next] == (int)1e9){
            ans += s.size() - index;//残りすべて足す
            ans += place[ichar][0];//始めに戻って、一番最初に登場する場所まで移動
            index = place[ichar][0];
        } else {
            ans += place[ichar][next] - index;
            //cout << place[ichar][next] << " " << index << endl;
            index = place[ichar][next];
        }
        //cout << ans << endl;
    }

    cout << ans << endl;
}

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

int main() {
    int a=0, b=0,n,m;

    cin >> n >> m;
    vector<int> vec(n,0);

    for(int i = 0; i < m; i ++){
        cin >> a >> b;
        vec.at(a-1) ++;
        vec.at(b-1) ++;
    }

    for(int i = 0;i < n; i ++){
        cout << vec.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    string s,t;cin>>s>>t;
    ll n=sz(s);
    rep(i,n){
        if(s[i]!=t[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3588
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, x = map(int, input().split())
  As = list(map(int, input().split()))
  cost = 0
  for i in range(n):
    if As[i] > x:
      cost += As[i] - x
      As[i] = x
  for i in range(1, n):
    if As[i] + As[i-1] > x:
      cost += (As[i] + As[i-1] - x)
      As[i] -= (As[i] + As[i-1] - x)
  print(cost)

if __name__=='__main__':
  main()



Measured memory_bytes: 14132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
int main()	{
	int a; 
	cin>>a;
	cout<<a+a*a+a*a*a; 
	return 0;
}

Measured memory_bytes: 3576
N = int(input())
S = [input() for _ in range(N)]

# ABC-081-Cの類題！
# 方針：各文字列の出現回数を数え、出現回数が最大なる文字列を昇順に出力する
 
# 各単語の出現回数を数える（辞書型を用いる！！）
dic = {}
for i in range(N):
  s = S[i]
  if s not in dic: dic[s] = 1
  else: dic[s] += 1

max_count = max(dic.values()) # 最大の出現回数
 
# 出現回数が最も多い単語を集計する
l = [key for key in dic.keys() if dic[key] == max_count]
 
# 昇順にソートして出力
for i in sorted(l):
  print(i)

Measured memory_bytes: 38444
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> a(n+1);
  int i, j;
  vector<bool> b(n+1,false);
  for(i = 1; i <= n; i++)cin >> a.at(i);
  bool check;
  for(i = n; i >= 1; i--)
  {
    check = false;
    for(j = i*2; j <= n; j += i)
    {
      if(b.at(j) && !check)check = true;
      else if(b.at(j) && check) check = false;
    }
    if(a.at(i) == 1)
    {
      if(check)b.at(i) = false;
      else b.at(i) = true;
    }
    else
    {
      if(check)b.at(i) = true;
      else b.at(i) = false;
    }
  }
  int count = 0;
  for(i = 1; i <= n; i++)
  {
    if(b.at(i))count++;
  }
  cout << count << endl;
  count = 0;
  for(i = 1; i<= n; i++)
  {
    if(b.at(i) && count == 0)
    {
      cout << i;
      count++;
    }
    else if(b.at(i) && count != 0)cout << " " << i; 

  }
  cout << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod =  1000000007;
ll maxn = 1000000000;
 
//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------
 
int main(){
   int x,n;
   cin>>x>>n;
   if(x<n)cout<<0<<endl;
   else cout<<10<<endl;
}
   



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<int>> G(H, vector<int> (W, inINF));
    char c;

    queue<iint> q;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> c;
            if(c == '#'){
                G[i][j] = 0;
                q.push(make_pair(i, j));
            }
        }
    }

    int v, w;
    vector<int> x(4), y(4);
    x[0] = 1;
    x[1] = -1;
    x[2] = 0;
    x[3] = 0;
    y[0] = 0;
    y[1] = 0;
    y[2] = 1;
    y[3] = -1;
    while(!q.empty()){
        v = q.front().first;
        w = q.front().second;
        q.pop();
        for (int i = 0; i < 4; i++) {
            if(v+x[i] < H && v+x[i] >= 0 && w+y[i] < W && w+y[i] >= 0 && G[v+x[i]][w+y[i]] == inINF){
                G[v+x[i]][w+y[i]] = G[v][w] + 1;
                q.push(make_pair(v+x[i], w+y[i]));
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            ans = max(ans, G[i][j]);
        }
    }

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



}

Measured memory_bytes: 15148
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, t, a;
    cin >> n >> t >> a;

    vector<int> H(n);

    for (int i = 0; i < n; i++) {
        cin >> H[i];
    }

    double diff = 1000.0;
    int ans = 0;

    for (int i = 0; i < n; i++) {
        double d = abs(a - (t - H[i] * 0.006));
        if (d < diff) {
            ans = i;
            diff = d;
        }
    }

    cout << ans + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ld double
#define ll long long
#define all(x) x.begin(),x.end()
const int mod=998244353;
#define fi first
#define se second
#define sync  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf (ll)1e16

const ld pi=(4.0*atan(1));

ll po(ll x,ll y,ll md=mod){
    ll res=1;
    x%=md;
    
    while(y>0){
        if (y&1){
            res=(res*x)%md;
        }
        
        y>>=1;
        x=(x*x)%md;
    }
    return res;
}

vector<vector<vector<ll>>> dp;

ll n,m,k;
ll rec(ll curr,ll last,ll rem){
    if (rem>k){
        return 0;
    }
    if (curr==n){
        if (rem<=k){
            return dp[curr][last][rem]=1;
        }
    }
    if (dp[curr][last][rem]!=-1){
        return dp[curr][last][rem];
    }
    
    ll ans=0;
    for (ll i=1;i<=m;i++){
        if (last==i){
            ans+=rec(curr+1,last,rem+1);
            ans%=mod;
        }
        else
        ans+=rec(curr+1,i,rem),ans%=mod;
    }
    return dp[curr][last][rem]=ans;
}
vector<ll> nCm;
void xC(ll x){
    nCm.resize(x+1,1);
    int ptr=(x/2-((x&1)^1));
    for (ll i=1;i<=(x/2);i++){
        nCm[i]=(nCm[i-1]*(x-i+1))%mod*(po(i,mod-2));
        nCm[i]%=mod;
    }
    for (ll i=(x/2+1);i<=x;i++){
        nCm[i]=nCm[ptr];
        ptr--;
    }
}

void solve(){
   cin>>n>>m>>k;
   //dp.resize(n+1,vector<vector<ll>>(m+1,vector<ll>(k+1,-1)));
   //ll wys=rec(1,0,0);
   
   xC(n-1);
   
   /*for (ll i=0;i<=n-1;i++){
       cout<<nCm[i]<<" ";
   }cout<<endl;*/
   
   ll wys=0;
   for (ll kk=0;kk<=k;kk++){
       wys+=((m%mod*(nCm[kk]))%mod*(po(m-1,n-1-kk)))%mod;
       wys%=mod;
   }
   cout<<wys<<"\n";
}

int main() {
    
    sync
    ll tt=1;
    //cin>>tt;
    cout<<fixed<<setprecision(12);
    for (ll tc=1;tc<=tt;tc++){
       solve();
    }
    
	return 0;
}

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

int main() {
	int a=0, b=0, count=0;
	cin >> a >> b;
 	for(int i=a;i<= b;i++){
		int digit[2] = {};
      	digit[0] = (i - i%10000)/10000; //5
      	digit[1] = (i%10000 - ((i%10000)%1000))/1000;//4
      	if(digit[1]*10+digit[0] == i%100)count++;
	}
  	cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define INF INT_MAX
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int n,m,d[1000];
int main(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   int ans=0,a,c;
   cin>>n>>m>>c;
   FOR(i,m) cin>>d[i];
   FOR(y,n){
     int sum=c;
     FOR(x,m){
       cin>>a;
       sum+=a*d[x];
     }
     if(sum>0){
       ans++;
     }
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{

    int[] cnt;
    int n,m,kk;
    int INF = Integer.MAX_VALUE;

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            n = sc.nextInt();
            m = sc.nextInt();
            kk = sc.nextInt();
            if(n==0 && m==0 && kk==0) break;

            double mn = Math.pow(m,n);

            int[][] dp = new int[2][(int)mn+1];

            for(int i=1; i<=m; i++) dp[0][i] = 1;
            for(int i=0; i<n-1; i++){
                for(int k=1; k<=m; k++){
                    for(int j=0; j+k<=(int)mn; j++){
                        dp[(i+1)%2][j+k] += dp[i%2][j];
                    }
                }
                Arrays.fill(dp[i%2], 0);
            }

            double ans = 0.0;
            for(int i=1; i<=(int)mn; i++){
                if(dp[(n-1)%2][i]==0) continue;
                ans += ((double)dp[(n-1)%2][i]/mn) * Math.max(1, i-kk);
            }

            System.out.println(ans);
        }
    }

    public static void main(String[] args){
        new Main().solve();

    }
}

Measured memory_bytes: 91012
N=int(input())
A=list(map(int,input().split()))
B=[None]*N

for i in range(N):
    B[i]=A[i]-i-1

B.sort()

Left=0
Right=sum(B)-B[0]*N
ANS=Left+Right
#print(B)
#print(Left,Right)

for i in range(1,N):
    Left=Left+(B[i]-B[i-1])*i
    Right=Right-(B[i]-B[i-1])*(N-i)
    #print(Left,Right)

    if ANS>Left+Right:
        ANS=Left+Right

print(ANS)



Measured memory_bytes: 92372
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <regex>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
using namespace std;
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;
}

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

    string s;
    cin >> s;

    string ans = s;

    vector<string> akiba = {"AKIHABARA", "AKIHBAR",  "AKIHABR",  "AKIHBR",
                            "AKIHABRA",  "AKIHBARA", "AKIHBARA", "KIHABARA",
                            "KIHABAR",   "KIHABR",   "KIHBR",    "KIHBRA",
                            "KIHABRA",   "KIHBARA",  "KIHBAR",   "AKIHABAR"};

    REP(i, akiba.size()) {
        if (s == akiba[i]) {
            std::cout << "YES" << std::endl;
            return 0;
        }
    }

    std::cout << "NO" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)  	
typedef long long ll;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f;
const int maxn = 1e6 + 5;
const double pi = acos(-1.0);
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }
ll read()     //输入外挂
{
    ll res = 0, ch, flag = 0;
    if ((ch = getchar()) == '-')
        flag = 1;
    else if (ch >= '0' && ch <= '9')
        res = ch - '0';
    while ((ch = getchar()) >= '0' && ch <= '9')
        res = res * 10 + ch - '0';
    return flag ? -res : res;
}

int main() {
    ll n, m;
    cin >> n>>m;
    if (n % m != 0) cout << (n / m) + 1 << endl;
    else cout << n / m << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
  // D
  int N;
  int a[51];
  cin >> N;
  REP(i, N) {
    cin >> a[i];
  }

  int max_idx = -1;
  int min_idx = -1;
  int max = -1000000-1;
  int min = 1000000+1;

  REP(i, N) {
    if(max < a[i]) {
      max = a[i];
      max_idx = i;
    }
    if (min > a[i]) {
      min = a[i];
      min_idx = i;
    }
  }

  int sum = 0;
  int sum_idx = -1;
  if (abs(max) >= abs(min) ){
    sum = max;
    sum_idx = max_idx;
  } else {
    sum = min;
    sum_idx = min_idx;
  }

  cout << 2*N-1 << endl;
  REP(i, N) {
    a[i] += sum;
    cout << sum_idx+1 << " " << i+1 << endl;
  }

  if (a[0] >= 0) {
    REP(i, N-1) {
      cout << i+1 << " " << i+2 << endl;
    }
  } else {
    for(int i=N-1 ; i > 0; i--) {
      cout << i+1 << " " << i << endl;
    }
  }
  return 0;
}

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

using namespace std;

int n,a,b;

int main()
{
    cin >> n >> a >> b;
    if (b-a==1) cout << "Borys";
    else
    {
        if ((b-a)%2==0) cout << "Alice";
        else cout << "Borys";
    }
}


Measured memory_bytes: 764
S = input()
c1 = c2 = 0

N = len(S)
c1 = N - (len([s for s in S[0::2] if s == "0"]) + len([s for s in S[1::2] if s == "1"]))
c2 = N - (len([s for s in S[0::2] if s == "1"]) + len([s for s in S[1::2] if s == "0"]))

print(min(c1, c2))


Measured memory_bytes: 3636
class Node
  attr_accessor :priority, :key, :left, :right
  def initialize(key, pri)
    @key = key
    @priority = pri
  end
end

def find(node, key)
  return node if node.nil? || node.key == key
  if key < node.key
    find(node.left, key)
  else
    find(node.right, key)
  end
end
def in_order(node, arr = [])
  return if node.nil?
  in_order(node.left, arr)
  arr << node.key
  in_order(node.right, arr)
  arr
end

def pre_order(node, arr = [])
  return if node.nil?
  arr << node.key
  pre_order(node.left, arr)
  pre_order(node.right, arr)
  arr
end
def rightRotate(t)
    s = t.left
    t.left = s.right
    s.right = t
    return s #root of the subtree
end
def leftRotate(t)
    s = t.right
    t.right = s.left
    s.left = t
    return s # root of the subtre
end
def insert(t,key, priority)    # 再帰的に探索
  if t == nil
    return Node.new(key, priority)               # 葉に到達したら新しい節点を生成して返す
  end
  if key == t.key
    return t                                 # 重複したkeyは無視
  end

  if key < t.key                             # 左の子へ移動
    t.left = insert(t.left, key, priority)   # 左の子へのポインタを更新
    if t.priority < t.left.priority          # 左の子の方が優先度が高い場合右回転
      t = rightRotate(t)
    end
  else                                       # 右の子へ移動
    t.right = insert(t.right, key, priority) # 右の子へのポインタを更新
    if t.priority < t.right.priority         # 右の子の方が優先度が高い場合左回転
      t = leftRotate(t)
    end
  end

  return t
end

def delete(t, key)
    if t == nil
        return nil
    end
    if key < t.key                                # 削除対象を検索
        t.left = delete(t.left, key)
    elsif key > t.key
        t.right = delete(t.right, key)
    else
        return _delete(t, key)
    end
    return t
end

def _delete(t, key) # 削除対象の節点の場合
    if t.left == nil && t.right == nil           # 葉の場合
        return nil
    elsif t.left == nil                        # 右の子のみを持つ場合左回転
        t = leftRotate(t)
    elsif t.right == nil                       # 左の子のみを持つ場合右回転
        t = rightRotate(t)
    else                                       # 左の子と右の子を両方持つ場合
        if t.left.priority > t.right.priority  # 優先度が高い方を持ち上げる
            t = rightRotate(t)
        else
            t = leftRotate(t)
        end
    end
    return delete(t, key)
end

node = nil
$n=gets.to_i
$n.times{|i|
  cmd, key, priority = gets.split
  case cmd
  when 'insert'
    node = insert(node, key.to_i, priority.to_i)
  when 'find'
    puts find(node, key.to_i) ? 'yes' : 'no'
  when 'delete'
    node = delete(node, key.to_i)
  when 'print'
    puts "\s" + in_order(node).join("\s")
    puts "\s" + pre_order(node).join("\s")
  end
}


Measured memory_bytes: 33604
#include<iostream>
#include<cstdio>

using namespace std;
const int N = 1e5 + 10; 

int n, k, q, ans;
int a[N], f[N];

int main(){
	scanf("%d%d%d", &n, &k, &q);
	for(int i=1; i<=q; ++i){
		scanf("%d", &a[i]);
		f[a[i]]++;
		ans++;
	}
	for(int i=1; i<=n; ++i){
		if((ans - f[i]) >= k)
		  cout << "No" << endl;
		else 
		  cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int H = sc.nextInt();
        int W = sc.nextInt();
        int ans = (N - H + 1) * (N - W + 1);

        System.out.println(ans);

        sc.close();
    }
}


Measured memory_bytes: 22100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    cin >> a >> b >> c >> d;
    
    while(1){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD=1000000007;
using Graph = vector<vector<int>>;

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}


ull gcd(ull a, ull b) {
    while (a % b != 0) {
        ull tmp = b;
        b = a % b;
        a = tmp;
    }
    return b;
}

ull lcm(ull a, ull b) {
    if (a == b) return b;
    ull g = gcd(a, b);
    return (a / g) * b;
}

int main() {
    int n;
    //cout << lcm(12, 24) << endl;
    cin >> n;
    ull ans = 1;
    for (int i = 0; i < n; i++) {
        ull t;
        cin >> t;
        ans = lcm(ans, t);
        //cout <<"   "<< ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef double DB;

#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define R(i,n) for(int i=0;i<(n);++i)
#define fill(a,b) memset(a,b,sizeof(a))

const int maxn = 1e5 + 10;
int nxt[maxn][22],x[maxn];
int n,l,q;

int main()
{
	//freopen("test.txt","r",stdin);
	scanf("%d",&n);
	R(i,n) scanf("%d",x+i);
	scanf("%d",&l);
	F(i,1,n)
	{
		int it = upper_bound(x,x+n,x[i-1]+l) - x;
		nxt[i][0] = it;
		if(x[i-1] + l > x[n-1]) nxt[i][0] = n+1;
	}
	nxt[n+1][0] = n+1;
	F(j,1,20)
	{
		nxt[n+1][j] = n+1;
		F(i,1,n)
		{
			nxt[i][j] = nxt[nxt[i][j-1]][j-1];
		}
	}
	scanf("%d",&q);
	while(q--)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		if(a > b) swap(a,b);
		int i = 20,ans = 0;
		while(i >= 0)
		{
			if(nxt[a][i] <= b)
			{
				a = nxt[a][i];
				ans += 1<<i;
			}
			if(a == b) break;
			--i;
		}
		if(a != b) ans++ ;
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 9856
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[]) {

  int num;
  int *line;
  int i,j,minj;
  int temp,count=0;

  scanf("%d",&num);

  line = (int *)malloc( num * sizeof(int) );

  for( i = 0 ; i < num ; i++ ){
    scanf("%d",&line[i]);
  }

  for( i = 0 ; i < num ; i++ ){

    minj = i;

    for( j = i ; j < num ; j++ ){

      if( line[j] < line[minj] ){
        minj = j;
      }

    }

    if( i != minj ){

    temp = line[i];
    line[i] = line[minj];
    line[minj] = temp;
    count++;

    }

  }



  for( i = 0 ; i < num-1 ; i++ )
    printf("%d ",line[i]);

  printf("%d\n%d\n",line[num-1],count);

  free(line);

  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N,M;cin>>N>>M;
    vector<vector<int>> graph(N);
    REP(i,M){
        int a,b; cin>>a>>b;
        a--;b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    REP(i,N) cout<<graph[i].size()<<endl;
}


Measured memory_bytes: 256
n,a,b=map(int,input().split())
l=list(input())
PASS=0
B=0
for i in l:
    if i=="a":
        if PASS<a+b:
            print("Yes")
            PASS+=1
        else:print("No")
    elif i=="b":
        if PASS<a+b and B<=b-1:
            print("Yes")
            PASS+=1
            B+=1
        else:print("No")
    else:print("No")

Measured memory_bytes: 4708
N = int(input())
dic = {}

for _ in range(N):
  inp = input()
  if inp not in dic:
    dic[inp] = 1
  else:
    dic[inp] = dic[inp] + 1

num = max(dic.values())
ans = []
for i in dic:
  if dic[i] == num:
    ans.append(i)
    
ans.sort()
for i in ans:
  print(i)
  

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

int main()
{
	int a[3];

	cin >> a[0] >> a[1] >> a[2];

	int g = count(a, a + 3, 5), s = count(a, a + 3, 7);

	if (g == 2 && s == 1) cout << "YES" << endl;
	else cout << "NO" << endl;

	return (0);
}


Measured memory_bytes: 256
// A - Irreversible operation
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t, v, x, y;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> s;
  vlli d(200010, 0), e(s.size() + 1, 0);
  rep(j, 0, s.size())
  {
    y = s[j];
    if (y == "W")
    {
      d[j]++;
    }
    e[j + 1] = e[j] + d[j];
  }
  a = MAX(e);
  rep(i, 1, s.size())
  {
    x = s[i - 1];
    if (x == "B")
    {
      ans += a - e[i];
    }
  }
  // cout << d << endl;
  // cout << e << endl;
  cout << ans << endl;
  // cout << "s: " << s << endl;
}

Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <map>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
int mod = 1e9 + 7;

int main()
{
	int N, K;
	cin >> N >> K;
	int ans = 0;
	rep(i, N)
	{
		int tmp;
		cin >> tmp;
		if (tmp >= K)ans++;
	}
	co(ans);
}

Measured memory_bytes: 256
/*input
198 1.10

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll a;
  cin >> a;
  string str;
  cin >> str;
  int n = str.size();
  vector<ll> vec;
  int pos = -1;
  ll rem = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (str[i] == '.') {
      pos = i;
      continue;
    }
    ll x = a * (str[i] - '0') + rem;
    vec.pb(x % 10);
    rem = x / 10;
  }
  if (rem)
    vec.pb(rem);
  reverse(all(vec));
  int ind = 0;
  while (ind <= pos) {
    vec.pop_back();
    ind++;
  }
  for (auto it : vec) {
    cout << it;
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3640
#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 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;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n,c=0;
bool flag=false;

void solve(){
    cin >> n;
    int n_=n;
    while (n_>1){
        if (n_%2==1) flag=true;
        n_/=2;
        c+=1;
    }
    if (!flag) {
        cout << "No" << endl;
        return;
    }
    vector<P> ans;
    ans.push_back(P(3,n+1));
    for(int i=2;i<n;i+=2){
        ans.push_back(P(i,i+1));
        ans.push_back(P(1,i));
        ans.push_back(P(i+n+1,1));
        ans.push_back(P(i+n,i+n+1));
    }
    if (n%2==0) {
        ans.push_back(P(n,1<<c));
        int a=n^(1<<c);
        ans.push_back(P(2*n,a+n+1));
        //cout << a << endl;
    }

    cout << "Yes" << endl;
    rep(i,ans.size()) cout << ans[i].first << " " << ans[i].second << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 4080
//自称高知能系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 tmp;
    int n, a, b;
    cin >> n >> a >> b;

    cout << min(n*a , b) << endl;
}

Measured memory_bytes: 256
import java.io.*;
class Main{
	public static void main (String[] args)throws IOException{
		int x, sum=0, i;
		
		BufferedReader d =new BufferedReader(new InputStreamReader(System.in));
		x = Integer.parseInt(d.readLine());
		sum =x;
		
		for(i=1; i<3; i++){
			sum *= x;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 17024
import heapq


def main():
    N, M = map(int, input().split())
    A_i = list(map(lambda x: -int(x), input().split()))
    heapq.heapify(A_i)
    for i in range(M):
        m = -heapq.heappop(A_i)
        m = m//2
        heapq.heappush(A_i, -m)
    print(-sum(A_i))


main()


Measured memory_bytes: 14180
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

n,m = readints()
x = readints()
modx = [i%m for i in x]

a = [0]*(10**5+1)
b = [0]*m
for i in range(n):
    a[x[i]]+=1
    b[modx[i]]+=1

ans = b[0]//2
b[0] = 0
y = m//2
if m%2==0:
    ans += b[m//2]//2
    b[m//2] = 0
else:
    y += 1
for i in range(1,y):
    c = min(b[i],b[m-i])
    b[i] -= c
    b[m-i] -= c
    ans += c
for i in range(10**5+1):
    if b[i%m]>1 and a[i]>1:
        c = min(b[i%m],a[i])//2
        ans += c
        b[i%m] -= c*2

print(ans)


Measured memory_bytes: 82300
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int W,H,N;
  	cin>>W>>H>>N;
  	bool black[W][H];
  	int barea=0;
  	rep(i,W){
     	rep(j,H){
         	black[i][j]=false; 
        }
    }
  
  	rep(i,N){
      	int x,y,a;
      	cin>>x>>y>>a;
      	
     	if(a==1){
        	rep(j,W){
             	rep(k,H){
                   if(j<x) black[j][k] = true;
                }
            }
        }
      
      	if(a==2){
        	rep(j,W){
             	rep(k,H){
                   if(j>=x) black[j][k] = true;
                }
            }
        }
      
        if(a==3){
        	rep(j,W){
             	rep(k,H){
                   if(k<y) black[j][k] =true;
                }
            }
        }
      
      	if(a==4){
        	rep(j,W){
             	rep(k,H){
                   if(k>=y) black[j][k] =true;
                }
            }
        }
      
    }	
  	
  	rep(i,W){
     	rep(j,H){
         	 barea+=black[i][j];
        }
    }
  	
  	cout<<W*H-barea<<endl;
  
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  char op;
  while(1){
    cin>>a>>op>>b;
    if(op=='?')break;
    if(op=='+'){
      c=a+b;
      cout<<c<<"\n";
    }else if(op=='-'){
      c=a-b;
      cout<<c<<"\n";
    }else if(op=='*'){
      c=a*b;
      cout<<c<<"\n";
    }else if(op=='/'){
      c=a/b;
      cout<<c<<"\n";
    }
}
  return 0;
}

Measured memory_bytes: 1164
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int man = 2e5+10;
#define IOS ios::sync_with_stdio(0)
template<typename T>T gcd(T a, T b) {return b==0?a:gcd(b, a%b);}
template<typename T>T exgcd(T a,T b,T &g,T &x,T &y){if(!b){g = a,x = 1,y = 0;}else {exgcd(b,a%b,g,y,x);y -= x*(a/b);}}
#ifndef ONLINE_JUDGE
#define debug(fmt, ...) {printf("debug ");printf(fmt,##__VA_ARGS__);puts("");}
#else
#define debug(fmt, ...)
#endif
typedef long long ll;
const ll mod = 1e9+7;
int lef[man][2],rig[man][2];
int pos[man];
int x[man];
int n;
int te[man*4];

void pushup(int rt){
    te[rt] = max(te[rt<<1] , te[rt<<1|1]);
}

void build(int l,int r,int rt){
    if(l==r){
        te[rt] = x[l]; 
        return;
    }
    int m = l+r>>1;
    build(l,m,rt<<1);
    build(m+1,r,rt<<1|1);
    pushup(rt);
}

int query(int l,int r,int L,int R,int rt){
    if(L<=l&&R>=r){
        return te[rt];
    }
    int ans = -1;
    int m = l+r>>1;
    if(L<=m)ans = max(ans,query(l,m,L,R,rt<<1));
    if(R>m)ans = max(ans,query(m+1,r,L,R,rt<<1|1));
    return ans;
    //pushup(rt);
}

void solve1(int id){
    int l = 1,r = id;
    int ans = 0;
    while(l<=r){
        int mid = l+r>>1;
        if(query(1,n,mid,id,1)>x[id]){
            ans = mid;
            l = mid + 1;
        }else r = mid - 1;
    }
    lef[id][0] = ans;
    if(ans==0){
        lef[id][1] = 0;
        return;
    }
    l = 1,r = ans-1;
    int tp = ans-1;
    ans = 0;
    while(l<=r){
        int mid = l+r>>1;
        if(query(1,n,mid,tp,1)>x[id]){
            ans = mid;
            l = mid + 1;
        }else r = mid - 1;
    } 
    lef[id][1] = ans;
}

void solve2(int id){
    int l = id,r = n;
    int ans = n+1;
    while(l<=r){
        int mid = l+r>>1;
        if(query(1,n,id,mid,1)>x[id]){
            ans = mid;
            r = mid - 1;
        }else l = mid + 1;
    }
    rig[id][0] = ans;
    if(ans==n+1){
        rig[id][1] = ans;
        return;
    }
    l = ans + 1,r = n;
    int tp = ans + 1;
    ans = n+1;
    while(l<=r){
        int mid = l+r>>1;
        if(query(1,n,tp,mid,1)>x[id]){
            ans = mid;
            r = mid - 1;
        }else l = mid + 1;
    }
    rig[id][1] = ans;
}

int main() {
    #ifndef ONLINE_JUDGE
        //freopen("in.txt", "r", stdin);
        //freopen("out.txt","w",stdout);
    #endif
    scanf("%d",&n);
    for(int i = 1;i <= n;i++){
        scanf("%d",x+i);
        pos[x[i]] = i;
    }
    build(1,n,1);
    for(int i = 1;i <= n;i++){
        solve1(i);
        solve2(i);
    }
    // for(int i = 1;i <= n;i++){
    //     printf("%d: %d %d %d %d\n",i,lef[i][0],lef[i][1],rig[i][0],rig[i][1]);
    // }
    ll ans = 0;
    for(int i = 1;i <= n;i++){
        int lpos1 = lef[pos[i]][0];
        int lpos2 = lef[pos[i]][1];
        int rpos1 = rig[pos[i]][0];
        int rpos2 = rig[pos[i]][1];
       // printf("%d %d %d %d\n",lpos1,lpos2,rpos1,rpos2);
        if(lpos1)ans += 1ll*(lpos1 - lpos2)*(rpos1 - pos[i])*i;
       // printf("%lld\n",ans);
        if(rpos1<=n)ans += 1ll*(pos[i]-lpos1)*(rpos2-rpos1)*i;
       // printf("%lld\n",ans);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 6144