akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int lis(vector<int> v){
    int n = sz(v);
    vector<int> dp(n, inf);
    for(auto &e: v){
        *lower_bound(all(dp), e) = e;
    }
    return lower_bound(all(dp), inf)-dp.begin();
}

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    if(sx > tx) swap(sx, tx), swap(sy, ty);
    int flag = 1;
    if(sy > ty) sy *= -1, ty *= -1, flag *= -1;
    int dx = tx-sx, dy = ty-sy;
    int N;
    cin >> N;
    map<int, int> mp;
    rep(i, N){
        int x, y;
        cin >> x >> y;
        y *= flag;
        if(sx <= x && x <= tx && sy <= y && y <= ty) mp[x] = y;
    }
    vector<int> v;
    for(auto &e: mp) v.pb(e.second);
    int n = lis(v);
    ld pi = acos(-1);
    ld ans = 100*(ld)(dx+dy)+(5*pi-20)*(ld)n;
    if(n == min(dx, dy)+1) ans += 5*pi;
    cout << sp(15) << ans << endl;
}

Measured memory_bytes: 12152
import sys

sys.setrecursionlimit(10 ** 7)

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

X, N = map(int, input().split())

if N == 0:
    print(X)
    exit()

P = list(map(int, input().split()))

DIFF = 200
ans = 200

for p in range(0, 102):
    if p in P:
        continue

    d = abs(X - p)

    if d == DIFF:
        ans = min(p, ans)
    elif d < DIFF:
        DIFF = d
        ans = p

print(ans)


Measured memory_bytes: 9156
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

string s;
void solve(){
  unsigned long long a, b, x; cin >> a >> b >> x;
  if(a == 0) cout << b / x + 1<< endl;
  else cout << b / x - (a - 1) / x << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
using namespace atcoder;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
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;}
ll ceilll(ll a, ll b) {return (a + b-1) / b;} // if(a%b == 0) (a/b) + 1
ll get_digit(ll a) {ll digit = 0; while(a != 0){a /= 10; digit++;} return digit;} // a != 0
template<typename T> void vecdbg(vector<T>& v){ rep(i, v.size()){cout << v[i] << " ";} br;}
template<typename T> void vecvecdbg(vector<vector<T>>& v){ rep(i, v.size()){rep(j, v[i].size()){cout << v[i][j] << " ";} br;}}

// 0 false, 1 true 
// string number to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp
// global vector -> 0 initialization

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll k; cin >> k;
    rep(i, k){
        cout << "ACL";
    }
    cout << endl;
}

Measured memory_bytes: 3632
N = int(input())
A = list(map(int, input().split()))

ans_even = 0
ans_odd = 0

sum = 0

for index, i in enumerate(A):
  sum += i

  if index % 2 == 0:
    if sum <= 0:
      ans_even += abs(sum - 1)
      sum = 1
  else:
    if sum >= 0:
      ans_even += abs(sum + 1)
      sum = -1

sum = 0
for index, i in enumerate(A):
  sum += i
  
  if index % 2 == 0:
    if sum >= 0:
      ans_odd += abs(sum + 1)
      sum = -1
  else:
    if sum <= 0:
      ans_odd += abs(sum - 1)
      sum = 1
      
print(min(ans_even, ans_odd))

Measured memory_bytes: 14468
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(){
    long long N;
    long long ans=0;
    cin >> N;

    for(long long i=1;i<=N;i++){
        int y=N/i;
        for(long long j=1;j<=y;j++){
            ans+=j*i;
        }    
    }

    cout<<ans;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int a[N],b[N],c[N];
int main()
{
    int n,ans=0;scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]),b[i]=a[i];
    sort(b+1,b+n+1);
    for(int i=1;i<=n;i++)a[i]=lower_bound(b+1,b+n+1,a[i])-b;
    for(int i=1;i<=n;i++)c[a[i]]=i;
    for(int i=1;i<=n;i++)if(abs(c[i]-i)%2)ans++;
    cout<<ans/2<<endl;
}


Measured memory_bytes: 8832
#include<iostream>
#include<vector>
#include<queue>

#define MAX 10

using namespace std;

struct Point{
	int i, j;
	Point():i(0),j(0){}
	Point(int i,int j):i(i),j(j){}
};
struct Node{
	Node(){}
	vector< pair< int, vector< Point > > > vId;
	/* »ÌêÉ éXvN[Ìzñ(øÊÍÍÜÞ) < id, Ìm[hÊuÌzñ > */
};

int n;
Node E[MAX+4][MAX+4];

bool DFS(int id, Node * p){
	int index = -1;

	for(unsigned int i = 0; i < p->vId.size(); ++i){
		if( id == p->vId[i].first ){
			index = i;
			break;
		}
	}
	if( index < 0 )
		return false;

	for(unsigned int i = 0; i < p->vId[index].second.size(); ++i){
		int ei = p->vId[index].second[i].i;
		int ej = p->vId[index].second[i].j;
		Node * nextPoint = &E[ei][ej];

		if( id+1 >= n )
			return true;
		else
			if( DFS( id+1, nextPoint ) )
				return true;
	}
	return false;
}
void ResetMap(){
	for(int i = 0; i < sizeof(E)/sizeof(*E); ++i){
		for(int j = 0; j < sizeof(*E)/sizeof(**E); ++j){
			E[i][j].vId.clear();
		}
	}
}

inline bool inRange(int min, int t, int max){ return (min <= t && t < max); }

void SetEdges(){
	const int di[] = { 0, 1, 2,2,2,1,0,-1,-2,-2,-2,-1};
	const int dj[] = {-2,-2,-1,0,1,2,2, 2, 1, 0,-1,-2};

	for(int i = 2; i < MAX+2; ++i){
		for(int j = 2; j < MAX+2; ++j){
			for(unsigned int m = 0; m < E[i][j].vId.size(); ++m){
				int id = E[i][j].vId[m].first;
				
				for(int k = 0; k < sizeof(di)/sizeof(*di); ++k){
					int ti = i+di[k];
					int tj = j+dj[k];

					if( !(inRange(2, ti, MAX+2) && inRange(2, tj, MAX+2)) )
						continue;
					
					for(unsigned int l = 0; l < E[ti][tj].vId.size(); ++l)
						if( E[ti][tj].vId[l].first == id + 1)
							E[i][j].vId[m].second.push_back( Point(ti, tj) );
				}
			}
		}
	}
}
void SetSprinclar(int id, int i, int j){
	const int di[] = {0, 0, 1,1,1,0,-1,-1,-1};
	const int dj[] = {0,-1,-1,0,1,1, 1, 0,-1};
	vector<Point> tmp;
	for(int m = 0; m < sizeof(di)/sizeof(*di); ++m)
		E[i+di[m]][j+dj[m]].vId.push_back( make_pair(id,tmp) );
}
int main(void){
	while( true ){
		int x, y, px, py;
		vector<Point> tmp;

		cin >> px >> py;
		if( px == 0 && py == 0 ) break;

		ResetMap();

		E[py+2][px+2].vId.push_back( make_pair(0, tmp) );
		
		cin >> n;
		for(int i = 1; i <= n; ++i){
			cin >> x >> y;
			SetSprinclar( i, y+2, x+2 ); 
		}
		SetEdges();
		
		cout << ( DFS(0, &E[py+2][px+2] ) ? "OK\n" : "NA\n" );
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]){
        int N=sc.nextInt(),K=sc.nextInt(),x=0,res=0;
        for(int i=0;i<N;i++){
            x=sc.nextInt();
            res+=(Math.min(x,K-x))*2;
        }
        System.out.println(res);
    }
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    vector<Int> res;
    string s;
    while (cin >> s and s != "0") {
        reverse(all(s));
        Int n = s.size();
        vector<Int> a(n);
        Int add = 1;
        for (Int i = 0; i < n; i++) {
            a[i] = (s[i] - '0') * add % 11;
            add = add * 10 % 11;
        }
        for (int i = 0; i < n - 1; i++) {
            a[i + 1] += a[i];
            a[i + 1] %= 11;
        }
        Int cnt = 0;
        map<Int, Int> mp;
        mp[0]++;
        for (Int i = 0; i < n; i++) {
            if (s[i] != '0')  {
                cnt += mp[a[i]];
            }
            mp[a[i]]++;
        }
        res.push_back(cnt);
    }
    for (Int i = 0; i < (Int)res.size(); i++) {
        dump(res[i]);
    }
    return 0;
}



Measured memory_bytes: 3904
n,m = map(int,input().split())
input_lines = [[int(j)-1 for j in input().split()]for i in range(m)]

map_list = [[0 for i in range(n)] for i in range(n)]

for line in input_lines:
    map_list[line[0]][line[1]]+=1
    map_list[line[1]][line[0]]+=1

for li in map_list:
    print(sum(li))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
using vi=vector<int>;
#define PB push_back
#define ALL(x) x.begin(),x.end()
int read(){
	int i;
	scanf("%d",&i);
	return i;
}
int Ask(int a,int b){
	cout<<"? "<<a<<" "<<b<<endl;
	string ans;cin>>ans;
	return ans=="Y";
}
int Find(vi idx){
	int s=idx.size();
	if(s<=2)return idx[0];
	vi w;
	for(int i=0;i+1<s;i+=2)
		if(Ask(idx[i],idx[i+1]))w.PB(idx[i+1]);
	if(w.empty())return idx[s-1];
	if(s%2==1&&(s/2)%2==0)w.PB(idx[s-1]);
	return Find(w);
}

int main(){
	int a=read(),b=read(),n=a+b;
	if(a<=b){
		cout<<"Impossible"<<endl;
		return 0;
	}
	vi idx(n);REP(i,n)idx[i]=i;
	int h=Find(idx);
	string ans;
	REP(i,n)ans+='0'+Ask(h,i);
	cout<<"! "<<ans<<endl;
}


Measured memory_bytes: 844
# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import statistics
import string


def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

N = intinput()
print(math.ceil(N/2))

Measured memory_bytes: 5252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) (x.begin(), x.end())

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b;
    cin >> a >> b;
    cout << (a >= b ? 10 : 0) << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int r = 0, w = 0;
  int ans = 0;
  rep(i, n) {
    if (s[i] == 'R') ++r;
  }
  ans = r;

  rep(i, n) {
    if (s[i] == 'R')
      --r;
    else
      ++w;
    int now = max(r, w);
    ans = min(ans, now);
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

int main()
{
    string s, t;

    while (cin >> s >> t) {
        int dp[(int) s.size() + 1][(int) t.size() + 1];

        memset(dp, 0, sizeof dp);

        for (int i = 1; i <= (int) s.size(); i++) {
            for (int j = 1; j <= (int) t.size(); j++) {
                if (s[i - 1] == t[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
                dp[i][j] = max(dp[i][j], max(dp[i - 1][j], dp[i][j - 1]));

            }
        }

//        for (int i = 0; i < (int) s.size(); i++) {
//            for (int j = 0; j < (int) t.size(); j++) {
//                cout << dp[i][j] << " ";
//            }
//            cout << endl;
//        }

        int i = (int) s.size(), j = (int) t.size();

        string ans = "";

        while (dp[i][j] != 0) {
            if (dp[i - 1][j] == dp[i][j] || dp[i][j - 1] == dp[i][j]) {
                if (dp[i - 1][j] == dp[i][j - 1]) {
                    i = i - 1;
                    j = j;
                }
                else if (dp[i - 1][j] == dp[i][j]) {
                    i = i - 1;
                    j = j;
                }
                else {
                    i = i;
                    j = j - 1;
                }
            }
            else {
                ans += s[i - 1];
                i = i - 1;
                j = j - 1;
            }
        }

        reverse(ans.begin(), ans.end());
        cout << ans << endl;
    }

    return 0;
}


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

int keta(int x){
	if(10>x)return 10;
	return 100;
}

int main(){
while(1){
	vector<int> ans;
	int n,k,a[10+2];
	scanf("%d%d",&n,&k);
if(n==0&&k==0)break;
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	if(k==2){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(j!=i){
					int c=a[i]*keta(a[j])+a[j];
					vector<int>::iterator ite;
					ite=find(ans.begin(),ans.end(),c);
					if(ite==ans.end())ans.push_back(c);
				}
			}
		}
	}
	if(k==3){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(j!=i){
					for(int x=0;x<n;x++){
						if(x!=i&&x!=j){
							int c=(a[i]*keta(a[j])+a[j])*keta(a[x])+a[x];
							vector<int>::iterator ite;
							ite=find(ans.begin(),ans.end(),c);
							if(ite==ans.end())ans.push_back(c);
						}
					}
				}
			}
		}
	}
	if(k==4){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(j!=i){
					for(int x=0;x<n;x++){
						if(x!=i&&x!=j){
							for(int y=0;y<n;y++){
								if(y!=i&&y!=j&&y!=x){
									int c=((a[i]*keta(a[j])+a[j])*keta(a[x])+a[x])*keta(a[y])+a[y];
									vector<int>::iterator ite;
									ite=find(ans.begin(),ans.end(),c);
									if(ite==ans.end())ans.push_back(c);
								}
							}
						}
					}
				}
			}
		}
	}
	printf("%d\n",ans.size());
}
}

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

int main(){
    int L;
    cin >> L;
    ll A[L];
    rep(i, L) cin >> A[i];
    ll l_0[L+1], l_1[L+1], l_2[L+1];
    l_0[0] = l_2[0] = l_1[0] = 0;
    rep2(i, 1, L){
        l_0[i] = l_0[i-1] + A[i-1];
        if(A[i-1] != 0) l_2[i] = min(l_0[i-1], l_2[i-1]) + A[i-1]%2;
        else l_2[i] = min(l_0[i-1], l_2[i-1]) + 2;
        l_1[i] = min({l_0[i-1], l_2[i-1], l_1[i-1]}) + (A[i-1]+1)%2;
    }
    ll r_0[L+1], r_2[L+1];
    r_0[L] = r_2[L] = 0;
    rep3(i, L-1, 0){
        r_0[i] = r_0[i+1] + A[i];
        if(A[i] != 0) r_2[i] = min(r_0[i+1], r_2[i+1]) + A[i]%2;
        else r_2[i] = min(r_0[i+1], r_2[i+1]) + 2;
    }
    ll ans = INF;
    //iからスタートしてiより左の地点でゴールする場合
    rep(i, L+1){
        //cout << l_0[i] << ' ' << l_2[i] << ' ' << l_1[i] << ' ';
        //cout << r_0[i] << ' ' << r_2[i] << endl;
        ll tmp = min({l_0[i], l_2[i], l_1[i]}) + min(r_0[i], r_2[i]);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9728
#include<bits/stdc++.h>
#define int long long
#define p 1000000007
using namespace std;
int n;
int qpow(int x,int y){
	int ret=1;
	while(y){if(y&1)ret=ret*x%p;x=x*x%p;y>>=1;}
	return ret;
}
signed main(){
	scanf("%lld",&n);
	printf("%lld",((qpow(10,n)%p-qpow(9,n)%p*2%p+qpow(8,n)%p)%p+p)%p);
	return 0;
}

Measured memory_bytes: 3820
#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;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 
ll a[200005];
int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> k >> n;
	for(i=0;i<n;i++)
		cin >> a[i];

	ll mn=a[n-1]-a[0];
	for(i=1;i<n;i++)
	{
		mn=min(mn,k-a[i]+a[i-1]);
	}
	cout<<mn<<endl;
}

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

int main() {
	vector<int> dishes(5);
	int rest_min = 1000;
	int sum = 0;
	for (int i = 1; i <= 5; i++) {
		cin >> dishes[i];
		if (dishes[i] % 10 != 0) {
			if (rest_min > dishes[i]%10)rest_min = dishes[i]%10;
			dishes[i] += 10 - (dishes[i] % 10);
		}
		sum += dishes[i];
	}

	if (rest_min > 10)cout << sum << endl;
	else cout << sum -( 10 - rest_min) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define eps 1e-8
//#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const ll mod = 998244353;
long double PI = acosl(-1);
const ll infl = 3e18+10;
const int inf = 1e9+10;
const int nmax = 2e5+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

void NA(){
    cout<<"NO";
    exit(0);
}

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

    int n,m,a,b;
    cin>>n>>m>>a>>b;
    vector<vector<char> >g(n, vector<char>(m, '.') );

    if(n%2){
        for(int j=0; j<m-1; j+=2){
            if(a>0){
                g[n-1][j] = '<';
                g[n-1][j+1] = '>';
                a--;
            }
            else break;
        }
    }
    if(m%2){
        for(int i=0; i<n-1; i+=2){
            if(b>0){
                g[i][m-1] = '^';
                g[i+1][m-1] = 'v';
                b--;
            }
            else break;
        }
    }

    for(int i=0; i<n-1; i+=2){
        for(int j=0; j<m-1; j+=2){
            if(n%2 and m%2 and i==n-3 and j==m-3) break;
            if(a>1){
                a-=2;
                g[i][j] = g[i+1][j] = '<';
                g[i][j+1] = g[i+1][j+1] = '>';
            }
            else if(b>1){
                b-=2;
                g[i][j] = g[i][j+1] = '^';
                g[i+1][j] = g[i+1][j+1] = 'v';
            }
            else if(a>0){
                a--;
                g[i][j] = '<';
                g[i][j+1] = '>';
            }
            else if(b>0){
                b--;
                g[i][j] = '^';
                g[i+1][j] = 'v';
            }
        }
    }

    if(n%2 and m%2){
        int i = n-3, j = m-3;
        if(a>0 and b>0){
            a--, b--;
            g[i][j] = g[i+2][j+1] = '<';
            g[i][j+1] = g[i+2][j+2] = '>';
            g[i+1][j] = '^', g[i+2][j] = 'v';
        }
        else if(a>0){
            a--;
            g[i][j] = '<', g[i][j+1] = '>';
            if(a>0){
                a--;
                g[i+1][j] = '<', g[i+1][j+1] = '>';
            }
        }
        else if(b>0){
            b--;
            g[i][j] = '^', g[i+1][j] = 'v';
            if(b>0){
                b--;
                g[i][j+1] = '^', g[i+1][j+1] = 'v';
            }
        }
    }

    if(a>0 or b>0) NA();
    cout<<"YES\n";
    for(auto z : g){
        for(char ch : z)
            cout<<ch;
        cout<<"\n";
    }
}
/*
*/


Measured memory_bytes: 2304
N,x = map(int, input().split())
A = sorted(map(int, input().split()))

S = 0
c = 0

for i in range(N):
  S += A[i]
  
if S < x:
  print(N-1)
else:
  for i in range(N):
    b = x - A[i]
    if b > 0:
      c += 1
      x -= A[i]
    elif b == 0:
      c += 1  
      break
    else:
      break
  print(c)


Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
using ll = long long;
const ll INF = 100100100100;
 
int main(){
  int n; cin >> n;
  vector<ll> a(n);
  vector<vector<ll>> dp(n, vector<ll>(3, -INF));
  rep(i, n) cin >> a[i];
  dp[0][0] = a[0]; dp[1][0] = a[1];
  if(n>=3){
    dp[2][0] = dp[0][0] + a[2];
    dp[2][1] = a[2];
  }
  
  for(int i=3; i<n; i++){
    dp[i][0] = dp[i-2][0] + a[i];
    dp[i][1] = max( dp[i-3][0] + a[i], dp[i-2][1] +a[i]);
    dp[i][2] = max( dp[i-3][1] + a[i], dp[i-2][2] +a[i]);
    }
  
  ll ans;
  if(n%2==0) ans = max( dp[n-2][0], max( dp[n-1][0], dp[n-1][1]));
  else{
  ans = max( dp[n-3][0], max( dp[n-2][0], max( dp[n-2][1], max(dp[n-1][1], dp[n-1][2])))); 
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 22024
import java.util.Scanner;

class P{
	int x;
	int y;
	int d;
	P(int x,int y,int d){
		this.x=x;
		this.y=y;
		this.d=d;
	}
}

public class Main {
	
	int n,m;
	char map[][];
	int mx[]={-1,0,1,0};
    int my[]={0,-1,0,1};
	
	public static void main(String[] args) {
		// TODO ティツ?ェテ・ツ仰陛ァツ板淌ヲツ按静」ツ?陛」ツつ古」ツ?淌」ツδ。テ」ツつステ」ツδε」ツδ嘉」ツδサテ」ツつケテ」ツつソテ」ツδ?
		new Main().run();
	}
	void run(){
		Scanner sc=new Scanner(System.in);
		while(true){
			n=sc.nextInt();//x
			m=sc.nextInt();//y
			if(n+m==0) break;
			map=new char[m][n];
			for(int i=0;i<m;i++){
				map[i]=sc.next().toCharArray();
			}
			int sx=-1,sy=-1;
			for(int i=0;i<m;i++){
				for(int j=0; j<n; j++){
					if(map[i][j]=='&'){
						sx=j;
						sy=i;
					}
				}
			}
//			int ans=bfs(new P(sx, sy, 0));
			int ans=dijkstra(sx,sy);
			System.out.println(ans);
		}
	}
	int dijkstra(int sx,int sy){
		int y,x,ans;
		ans=2<<15;
		boolean use[][]=new boolean[m][n];
		int cost[][]=new int[m][n];
		for(int a=0; a<m; a++){
			for(int b=0; b<n; b++){
				use[a][b]=false;
				cost[a][b]=2<<15;
			}
		}
		cost[sy][sx]=0;
		while(true){
			x=y=-1;
			//テ」ツ?セテ」ツ??、ツスツソテ」ツ?」テ」ツ?ヲテ」ツ?ェテ」ツ??」ツつ?」ツ?、テ」ツ?ァテ」ツ??
			for(int a=0; a<m; a++){
				for(int b=0; b<n; b++){
					if(!use[a][b] && 
							(x==-1 || cost[a][b]<cost[y][x])){
						y=a;x=b;
					}
				}
			}

			if(x==-1) break;
			//System.out.println(y+" "+x);
			use[y][x]=true;

			//テ、ツサツ甘・ツ崢榲」ツ?ョテァツァツサテ・ツ仰陛」ツ?ッ4テヲツ鳴ケテ・ツ青?
			//テ」ツ?敕」ツつ古」ツ?ォテ」ツ?づ」ツつ湘」ツ?崚」ツ?ヲテ」ツ?ョテ」ツつオテ」ツつ、テ」ツつウテ」ツδュテ」ツ?ョテァツ崢ョテ」ツ?ョテ・ツ、ツ嘉・ツ個姪」ツ?ォテ」ツ?づ」ツつ湘」ツ?崚」ツ?ヲティツィツ暗ァツョツ?
			for(int i=0;i<4;i++){
				//テァツァツサテ・ツ仰陛」ツ?ァテ」ツ?催」ツつ凝」ツ?凝」ツ?ゥテ」ツ??」ツ?凝」ツ?ョテ」ツδ?」ツつァテ」ツδε」ツつッ テ・ツ」ツ?」ツδ?」ツつァテ」ツδε」ツつッ
				if(y+my[i]<0 || x+mx[i]<0 || m<=y+my[i] || n<=x+mx[i]){
					if(map[y][x]=='#'){
						ans=Math.min(ans,cost[y][x]+1);
					}
					else{
						ans=Math.min(ans,cost[y][x]);
					}
					continue;
				}
				if(map[y][x]=='#' && map[y+my[i]][x+mx[i]]=='.'){
					cost[y+my[i]][x+mx[i]]=Math.min(cost[y+my[i]][x+mx[i]], cost[y][x]+1);
				}
				else{
					cost[y+my[i]][x+mx[i]]=cost[y][x];
				}
			}
		}
		
		return ans;
	}
//	int bfs(P sp){
//		Queue<P> q=new LinkedList<P>();
//		q.offer(sp);//テ」ツつケテ」ツつソテ」ツδシテ」ツδ暗」ツ?ョsテ」ツつ津」ツつュテ」ツδ・テ」ツδシテ」ツ?ォテ」ツ??」ツつ古」ツ?ヲテ」ツ??
//	
//		while(!q.isEmpty()){//テ」ツつュテ」ツδ・テ」ツδシテ」ツ?古ァツゥツコテ」ツ?ォテ」ツ?ェテ」ツつ凝」ツ?セテ」ツ?ァテ」ツつ?」ツつ?
//			P now=q.poll();//テ」ツつュテ」ツδ・テ」ツδシテ」ツ?ョテ・ツ?暗ゥツ?ュテ」ツつ津・ツ渉姪」ツつ甘・ツ?コテ」ツ??
//			int nx=now.x;
//			int ny=now.y;
//			if(nx < 0 || n <= nx || ny < 0 || m <= ny){
//				return now.d;
//			}
//			map[nx][ny]='@';
//			//テ」ツ?禿」ツ?禿」ツ?凝」ツつ嘉ゥツ?キテァツァツサテ・ツ?暗」ツつ津」ツつュテ」ツδ・テ」ツδシテ」ツ?ォテ・ツ?・テ」ツつ古」ツ?ヲテ」ツ??」ツ??
//			for(int i=0; i<4; i++){
//				if(nx+mx[i] < 0 || n <= nx+mx[i] || ny+my[i] < 0 || m <= ny+my[i]){
//					return now.d;
//				}
//				if(map[ny+my[i]][nx+mx[i]]=='@'){
//					continue;
//				}
//				if(map[ny][nx]!=map[ny+my[i]][nx+mx[i]]){
//					q.offer(new P(nx+mx[i],ny+my[i],now.d+1));
//				}
//				else{
//					q.offer(new P(nx+mx[i],ny+my[i],now.d));
//				}
//			}
//		}
//		return -1;
//	}
}

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

namespace AtCoder_ABC089_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            int y = 700;

            for (int i = 0; i < 3; ++i)
            {
                if (s[i] == 'o')
                {
                    y += 100;
                }
            }
            Console.WriteLine(y);
        }
    }
}


Measured memory_bytes: 11092
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

signed main() {
   tezz
   
    string s;
    cin >> s;
    int n=s.length();
    string ss="";
    string sss="";
    for(int i=0; i<n; i++){
        if(i%2==0)ss+='1';
        else ss+='0';
        
        if(i%2==1)sss+='1';
        else sss+='0';
    }
    int a1=0;
    int a2=0;
    for(int i=0; i<n; i++){
        if(s[i]!=ss[i])a1++;
        if(s[i]!=sss[i])a2++;
    }
    cout << min(a1,a2);
    
   return 0;
}


Measured memory_bytes: 720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String A = "Three";
		for(int i = 0;i < N;i++) {
			String S = sc.next();
			if(S.equals("Y")) {
				A = "Four";
				break;
			}
		}
		System.out.println(A);
	}

}

Measured memory_bytes: 21844
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int maxn=200020;

int num[maxn],st[maxn];

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&num[i]);
            st[i]=num[i];
        }
        sort(num+1,num+1+n);


        int mid=n/2;
        for(int i=1;i<=n;i++)
        {
            int p=lower_bound(num+1,num+1+n,st[i])-num;
            if(p+p<=n)
                printf("%d\n",num[mid+1]);
            else
                printf("%d\n",num[mid]);
        }
    }
    return 0;
}


Measured memory_bytes: 3712
/*
                IftekharMd.Shishir
                Dept. of Information and Communication Engineering
                University of Rajshahi
*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

#define ll  long long
#define ull  unsigned long long
#define ld  long double
#define f(i,n)  for(i=0;i<n;i++)
#define F(i,n)  for(i=n-1;i>=0;i--)
#define fa(i,a,b)  for(i=a;i<=b;i++)
#define Fa(i,a,b)  for(i=a;i>=b;i--)
#define printArray(i,a,n)  f(i,n)cout<<a[i]<<" "; cout<<endl;
#define printSet(a)  for(auto setData:a) cout<<setData<<" ";cout<<endl;
#define printMap(a)  for(auto mapData:a) cout<<mapData.first<<" "<<mapData.second<<endl;
#define printVector(a)  for(auto vectorData:a)cout<<vectorData<<" ";cout<<endl;
#define printLinkedList()  temp=head;while(temp){cout<<temp->data<<" ";temp=temp->post;} cout<<endl;

#define pb(x)  push_back(x)
#define all(a)  a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()

#define bs  binary_search
#define lb  lower_bound
#define ub  upper_bound
#define mp  make_pair
#define TxtIO  freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define TxtTest freopen("C:/Users/Iftekhar/Documents/what/input.txt", "r", stdin);
#define FastIO  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
#define TestCase  ll t;cin>>t;while(t--)
#define points(x)  fixed<<setprecision(x)
#define scd(a,x,y)  a/__gcd(x,y);
#define nl  cout<<endl;
#define done  return 0

const ld PI= 3.14159265358979323846264338327950288;  //2*acos(0.0);
const long long MOD= 1000000007;
const long long MAX = 32000;

// stringstream demo(str);  demo >> x;
// stringstream demo;  demo << x;  name=demo.str();

using namespace __gnu_pbds;
using namespace std;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main()
{
        FastIO;
        //TxtTest;
        ll n;
        cin>>n;
        ll k = n/1.08;
        if(floor(k*1.08)==n){
                cout<< k <<endl;
                done;
        }
        else if(floor((k+1)*1.08)==n) {
                cout<< k+1 <<endl;
                done;
        }
        cout<< ":(" <<endl;
        done;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{
	int i;
	int H, W;
	
	scanf("%d %d", &H, &W);
	char s[H][W+1];
	
	for (i = 0; i < H; i++)
		scanf("%s", s[i]);
	
	for (i = 0; i < H; i++)
	{
		printf("%s\n", s[i]);
		printf("%s\n", s[i]);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
  int i,j,n,s=0,t,a;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    t=0;
    j=i;
    while(j%2==0){
      j/=2;
      t++;
    }
    if(t>=s){
      a=i;
      s=t;
    }
  }

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

  return 0;
}



Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	k := nextInt()
	hl := make([]int, n)

	for i := 0; i < n; i++ {
		hl[i] = nextInt()
	}
	sort.Ints(hl)

	dh := make([]int, n-1)
	for i := 0; i < n-1; i++ {
		dh[i] = hl[i+1] - hl[i]
	}

	// はじめの累積和を事前計算
	runsum := 0
	for i := 0; i < k-1; i++ {
		runsum += dh[i]
	}
	minrun := runsum

	// 累積和
	for i := 1; i < n-k+1; i++ {
		runsum = runsum - dh[i-1] + dh[i+k-2]
		minrun = min(minrun, runsum)
	}

	fmt.Println(minrun)
}
func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 5224
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <list>
#include <stack>
#include <algorithm>
#include <math.h>

using namespace std;

#define dump(x) cout << (x) << endl;
typedef long long Int;

Int mod = 1e9+7;
Int MOD = 998244353;

Int C[51][51];

void comb_table(Int n) {
    for (Int i = 0; i <= n; i++) {
        for (Int j = 0; j <= i; j++) {
            if (j == 0 || j == i) {
                C[i][j] = 1;
            }
            else {
                C[i][j] = (C[i-1][j-1] + C[i-1][j]);
            }
        }
    }
}

int main() {
    Int N, A, B;
    cin >> N >> A >> B;
    map<Int, Int> mp;
    for (Int i = 0; i < N; i++) {
        Int tmp;
        cin >> tmp;
        mp[tmp]++;
    }
    comb_table(N);
    Int cnt = 0;
    double sum = 0;
    for (auto itr = mp.rbegin(); itr != mp.rend(); itr++) {
        cnt += itr->second;
        if (cnt >= A) {
            Int x = A-cnt+itr->second;
            sum += (A-cnt+itr->second) * itr->first;
            Int c = C[itr->second][x];
            if (cnt == itr->second) {
                for (Int i = 1; i < B-A+1; i++) {
                    c += C[itr->second][x+i];
                }
            }
            printf("%.12lf\n", sum/A);
            dump(c);
            break;
        }
        else {
            sum += itr->first * itr->second;
        }
    }
    return 0;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
const ll min_v = -10000000000;
 
int p[5050];
int c[5050];
ll rui[5050];
int visited[5050];
 
ll ss(int j, int k)
{
  ll mx = min_v;
  for( int i=0;i<j;i++){
    for(int kk=0; kk<k; kk++){
      int l = i + kk + 1;
      ll v;
      if( l > j ){
        v = rui[l-j] + rui[j] - rui[i];
      } else {
        v = rui[l] - rui[i];
      }
      if( v > mx ) mx = v;
    }
  }
  return mx;
}
 
int main()
{
  int n,k;    cin >> n >> k;
  
  for(int i=0;i<n;i++){
    cin >> p[i];
    p[i]--;
  }
  for(int i=0;i<n;i++){
    cin >> c[i];
  }
  
  for(int i=0;i<5050;i++){ rui[i] = visited[i] = 0; }
  
  int st = 0; ll mx = min_v;
  
  while( st < n ){
    while( st < n && visited[st] != 0 ){ st++; }
    if( st >= n ){ break; }
    
    int i = st, j = 0;
    rui[0] = 0;
    while( visited[i] == 0 ){
      visited[i] = 1;
      int n_i = p[i];
      rui[1+j] = rui[j] + c[n_i];
      i = n_i;
      j++;
    }
    
    ll v = min_v;
    if( rui[j] > 0 ){
      int m1 = k % j;
      int m2 = (k - m1)/j;
      ll v1 = min_v;
      if( m1 > 0 ) v1 = ss(j,m1) + m2 * rui[j] ;
      ll v2 = min_v;
      if( m2 > 0 ) v2 = ss(j,j) + rui[j] * ( m2 - 1 );
      v = max(v1,v2);
    } else {
      int m1 = ( k >= j ? j : k );
      v = ss(j,m1);
    }
    if( v > mx ) mx = v;
  }
  
  cout << mx << endl;
  
  return 0;
  
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

bool ok[101];
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;cin >>n >> k;
  rep(i,k){
    ll d;cin >> d;
    rep(j,d){
      ll a;cin >> a;
      a--;
      ok[a] = true;
    }
  }
  ll ans = 0;
  rep(i,n){
    if(!ok[i])ans++;
  }
  cout << ans << endl;
}

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

int main()
{
    int N, M;
    cin >> N >> M;
    int sum = 0;
    vector<int> A(M);
    rep(i, 0, M)
    {
        cin >> A[i];
        sum += A[i];
    }
    if (sum > N)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << N - sum << endl;
    }
}


Measured memory_bytes: 3624
#include <stdio.h>
 
#define NMAX 1000
#define WMAX 10000


int mincost(short *, int, int);



int main(){
  
  int i, j;
  int n;
  int d;
  int wtemp, wmin=WMAX;
  int cost=0;
  short w[NMAX], s[NMAX], l[NMAX];
  char c[WMAX+1]={0};
  char flag[NMAX]={0};
  
  
  scanf("%d",&n);
  
  for (i = 0; i < n; i++) {
    
    scanf("%d",&w[i]);
    
    if (wmin > w[i]) wmin = w[i];
    c[w[i]]++;
    
  }
  
  j = 0;
  
  
  for (i = 0; i <= WMAX; i++) {
    
    if(c[i]) {
      
      s[j] = i;
      j++;
      
    }
  }
  
  for (i = 0; i < n; i++) {
    if( flag[i] == 0 ) {
      
      d = 0;
      flag[i]++;
      l[d] = w[i];
      d++;
      wtemp = w[i];
      while (1) {
	j = 0;
	while (s[j] != wtemp) {
	  j++;
	}
	if(j == i) break;
	flag[j]++;
	l[d] = w[j];
	d++;
	wtemp = w[j];
      }
      cost += mincost(l, d, wmin);
    }
  }
  
  printf("%d\n",cost);
  
  return 0;
}

int mincost(short *l, int d, int wmin)
{
  int i;
  int c1 = 0, c2;
  int lmin = WMAX, imin;
  
  for (i = 0; i < d; i++) {
    c1 += l[i];
    if(lmin > l[i]) {
      lmin = l[i];
    }
  }
  
  c2 = c1;
  c1 += (d - 2)*lmin;
  c2 += lmin + (d + 1)*wmin;
  
  if (c1 < c2) return c1;
  else return c2;
  
}

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




int main()
{
    int N,M;

    cin >> N >> M;

    int p[M];
    string S[M];
    int AC_bit[N];
    int WA_bit[N];

    for(int i=0;i<M;i++){
        cin >> p[i] >> S[i];
    }

    for(int i=0;i<N;i++){
        AC_bit[i] = 0;
        WA_bit[i] = 0;
    }


    for(int i=0;i<M;i++){

        if(S[i]=="AC"){
            AC_bit[p[i]-1] = 1;
        }else{
            if(AC_bit[p[i]-1]==0){
                WA_bit[p[i]-1] = WA_bit[p[i]-1] + 1;
            }
        }

    }

    for(int i=0;i<N;i++){
        if(AC_bit[i]==0){
            WA_bit[i] = 0;
        }
    }


    int AC_num=0;
    int WA_num=0;

    for(int i=0;i<N;i++){
        AC_num += AC_bit[i];
        WA_num += WA_bit[i];
    }


    cout << AC_num << " " << WA_num << endl;

    return 0;


}

Measured memory_bytes: 7040
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

int main(){
    int N;
    ll in, med_left, med_right;
    vector<ll> x, x_sorted;

    cin >> N;
    //input
    for(int i=0; i<N; i++){
        cin >> in;
        x.push_back(in);
    }

    x_sorted = x;
    sort(x_sorted.begin(), x_sorted.end());
    med_left = x_sorted[N/2-1];
    med_right = x_sorted[N/2];

    for(int i=0; i<N; i++){
        if(x[i]<=med_left){
            cout << med_right << "\n";
        }else{
            cout << med_left << "\n";
        }
    }
    return 0;
    
}

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

int main() {
    string str, op, p;
    int q, a, b;
    cin >> str >> q;

    for (int i = 0; i < q; i++)
    {
        cin >> op;
        if (op == "replace") {
            cin >> a >> b >> p;
            for (int j = a; j <= b; j++)
            {
                str[j] = p[j - a];
            }
        } else if (op == "reverse") {
            cin >> a >> b;
            string tmp = str;
            for (int j = 0; j <= b - a; j++)
            {
                str[a + j] = tmp[b - j];
            }
        } else if (op == "print") {
            cin >> a >> b;
            cout << str.substr(a, b - a + 1) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3216
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){

			long N = scan.nextLong();

			long goukei = 0;
			for(long i = 1;i<=N;i++) {
				long s = N/i;

				goukei +=i*s*(s+1)/2;

			}

			System.out.println(goukei);





		}
	}


}


Measured memory_bytes: 36228
//abc153
#include <stdio.h>
int main(int argc, char const *argv[]) {
    int H,N;
    int A[100000];
    int sum=0;
    scanf("%d %d\n",&H,&N );
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    for (int i = 0; i < N; i++) {
        sum = sum + A[i];
    }
    //printf("%d %d\n",H,sum );
    if (sum>=H) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


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

using namespace std;

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

  int N,M; cin>>N>>M;
  string S; cin>>S;

  set<int> mass;
  for (int i = 0; i <= N; i++)
    if (S[i] == '0')
      mass.insert(i);

  vector<int> most_left;
  most_left.push_back(N);
  int p = N;
  while (p > 0) {
    auto ml = *mass.lower_bound(p - M);
//    cerr << ml << endl;
    if (ml == p) {
      cout << -1 << endl;
      return 0;
    }
    most_left.push_back(ml);
    p = ml;
  }
  for (int i = most_left.size()-2; i >= 0; i--) {
    auto d = most_left[i] - most_left[i+1];
    cout << d << ' ';
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 5832
#include <iostream>
#include <set>
using namespace std;
int main(){
	int N,K;
  	set<int> st;
  	
  	cin >> N >> K;
  	for(int i=0;i<K;i++){
      	int d = 0;
      	cin >> d;
    	for(int j=0;j<d;j++){
          	int temp;
          	cin >> temp;
          	st.insert(temp);
        }
    }
  	cout << N - st.size() <<"\n";
  	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
#include <complex>
#include <cassert>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define deb(a) cerr<< #a << "= " << (a)<<"\n";

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef complex<double> base;
typedef vector<int> vi;
typedef pair<int,int> pii;

template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream; }
ll fpow(ll x, ll p, ll m){ll r=1; for (;p;p>>=1){ if (p&1) r=r*x%m; x=x*x%m; } return r;}
int gcd(int a, int b){ if (!b) return a; return gcd(b,a%b);}
ll gcd(ll a, ll b){ if (!b) return a; return gcd(b,a%b);}

ll N,M;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> M;

    ll t=100*(N-M)+1900*M;
    t*=(1<<M);
    cout << t << "\n";
	return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    vector<vector<ll>> c(3, vector<ll>(3, 0));
    for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 3; ++j){
            cin >> c.at(i).at(j);
        }
    }

    for(ll a1 = 0; a1 <= 100; ++a1){
        for(ll a2 = 0; a2 <= 100; ++a2){
            for(ll a3 = 0; a3 <= 100; ++a3){
                if(a1 != 0 && a2 != 0 && a3 != 0){ continue; }
                const ll b1 = c.at(0).at(0) - a1;
                const ll b2 = c.at(0).at(1) - a1;
                const ll b3 = c.at(0).at(2) - a1;
                if(b1 == c.at(1).at(0) - a2 &&
                   b2 == c.at(1).at(1) - a2 &&
                   b3 == c.at(1).at(2) - a2 &&
                   b1 == c.at(2).at(0) - a3 &&
                   b2 == c.at(2).at(1) - a3 &&
                   b3 == c.at(2).at(2) - a3){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b,c,d;
map<ll,ll>mp;
ll solve(ll x){
	if(!x) return 0;
	if(mp.find(x) != mp.end()) return mp[x];
	ll j = (x + 2) / 3 *3, j2 = x / 3 *3;
	mp[x] = min((__int128)d*x,(__int128)5000000000000000000);
	mp[x] = min(mp[x],solve(j/3) + d*abs(j - x) + b),mp[x] = min(mp[x],solve(j2/3) + d*abs(x - j2) + b*(j2 > 0));
	j = (x + 4) / 5 * 5,j2 = x / 5 * 5;
	mp[x] = min(mp[x],solve(j/5) + d*abs(j - x) + c),mp[x] = min(mp[x],solve(j2 / 5) + d*abs(x - j2) + c*(j2 > 0));
	j = (x + 1) / 2 * 2,j2 = x/2 * 2;
	mp[x] = min(mp[x],solve(j/2) + d*abs(j - x) + a ),mp[x] = min(mp[x],solve(j2 / 2) + d*abs(x - j2) + a*(j2 > 0));
	
	return mp[x];
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t;
	cin>>t;
	while(t--){
		cin>>n>>a>>b>>c>>d;
		mp.clear();
		printf("%lld\n",solve(n));
	}
	return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PA pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e16+7;
const ll MOD=1e9+7;




int main(){
	ll A , B;
	cin >> A >> B;
	A--;
	//B++;
	if(B%2==0){
		if(B%4)B++;
	}else{
		if((B-1)%4==0)B=1;
		else B=0;
	}

	if(A%2==0){
		if(A%4)A++;
	}else{
		if((A-1)%4==0)A=1;
		else A=0;
	}
	A^=B;
	cout << A << endl;
}

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

//最大公約数の計算(ユークリッドの互除法)
long long int gcd(long long int a, long long int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

//エラトステネスの篩
vector<bool> eratosthenes_sieve(int n) {
    vector<bool> res(n + 1, true);
    res[0] = res[1] = false;
    for (int i = 2; i <= n; i++) {
        if (res[i]) {
            for (int j = i; i * j <= n; j++) res[i * j] = false;
        }
    }
    return res;
}

int n;
vector<lint> a;

int m = 1000000;

bool isPairwise() {
    vector<vector<int>> pfs(m + 1);
    for (int i = 2; i <= m; i++) {
        if (pfs[i].size() == 0) {
            for (int j = 1; i * j <= m; j++) {
                pfs[i * j].push_back(i);
            }
        }
    }
    vector<bool> used(m + 1, false);
    for (int i = 0; i < n; i++) {
        for (auto e : pfs[a[i]]) {
            if (used[e]) {
                return false;
            } else {
                used[e] = true;
            }
        }
    }
    return true;
}

bool isSetwise() {
    lint res = 0;
    for (int i = 0; i < n; i++) {
        res = gcd(res, a[i]);
    }
    return res == 1;
}

int main() {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    if (isPairwise()) {
        cout << "pairwise coprime" << endl;
    } else if (isSetwise()) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }
}

Measured memory_bytes: 66752
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int A,B,C;
	cin >> A >> B >> C;
	int ans = 0;
	while(!(A==B && B==C)){
		if(A%2 == 1 || B%2 == 1 || C%2 == 1){
			cout << ans << endl;
			return 0;
		}
		int x = A/2;
		int y = B/2;
		int z = C/2;
		A = y + z;
		B = z + x;
		C = x + y;
		ans++;
	}
	cout << (A%2 == 0 ? -1 : ans) << endl;

	return 0;
}

Measured memory_bytes: 256