akhauriyash/Code-Regression huggingface dataset:
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define EPS 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f3f3f3f3f
#define MEM(a, b) memset(a, b, sizeof(a))
#define PPER(i, n, m) for (int i = n; i >= m; i--)
#define REPP(i, n, m) for (int i = n; i <= m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define PER(i, n, m) for (int i = n; i > m; i--)
#define SA(n) scanf("%d", &(n))
#define SLLA(n) scanf("%lld", &(n))
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define DE(val) cout << #val << ": " << val << endl;
 
const int dx44[6] = {0, -1, -1, 1, 1};
const int dy44[6] = {0, -1, 1, -1, 1};
const int dx4[6] = {0, 0, 1,-1};
const int dy4[6] = {1, -1, 0,0};
const int dx8[9] = {0, -1, 0, 1, 0, 1, 1, -1, -1};
const int dy8[9] = {0, 0, 1, 0, -1, 1, -1, 1, -1};
const int dx82[9] = {0, -1, -1, 1, 1, 2, 2, -2, -2};
const int dy82[9] = {0, 2, -2, 2, -2, 1, -1, 1, -1};

void update(ll& x,ll v){
    if(x==-1)x=v;
    else if(x>v)x=v;
}
 
ll po(ll a, ll b, ll mod)
{
    ll res = 1;
    a %= mod;
    for (; b; b >>= 1)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
    {
        return b;
    }
    else
    {
        return gcd(b % a, a);
    }
}
void extgcd(ll a, ll b, ll &d, ll &x, ll &y)
{
    if (!b)
    {
        d = a;
        x = 1;
    }
    else
    {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}
ll inverse(ll a, ll n)
{
    ll d, x, y;
    extgcd(a, n, d, x, y);
    return d == 1 ? (x + n) % n : -1;
}
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const int maxn = 5e5 + 15;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
/*************************************************************************/


void solve() {
    int n;
    SA(n);
    printf("%d", (n+1)/2 );
}

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

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

// https://atcoder.jp/contests/abc085/tasks/abc085_b
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		int[] numbers = new int[n];
		for(int i=0;i<n;i++) {
			numbers[i] = scanner .nextInt();
		}

		scanner.close();

		Arrays.sort(numbers);

		int sum = 1;
		int number1 = numbers[0];
		for(int i=1;i<n;i++) {
			if(number1!=numbers[i]) {
				sum++;
				number1 = numbers[i];
			}
		}
		System.out.println(sum);

	}

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,K,sum=0;
cin>>N>>K;
int l[N];
for(int i=0;i<N;i++){
    cin>>l[i];
}
sort(l,l+N);
reverse(l,l+N);
for(int i=0;i<K;i++){
    sum+=l[i];
}
cout<<sum;
return 0;
}


Measured memory_bytes: 256
main=do
 [xx,yy,n]<-map read.words<$>getLine
 s<-map(map read.words).lines<$>getContents
 print$f 0 xx 0 yy s
f x xx y yy[]=(max(xx-x)0)*(max(yy-y)0)
f x xx y yy([a,b,c]:s)=f(max x(if c==1 then a else x))(min xx(if c==2 then a else xx))(max y(if c==3 then b else y))(min yy(if c==4 then b else yy))s


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

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 500005;

vector<int> adj[N];

int32_t main()
{





    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;

    s[k-1] = tolower(s[k-1]);

    cout << s;











    return 0;
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int main(){
	int n,m,x,y;cin>>n>>m>>x>>y;
	vector<int> xs(n),ys(m);
	rep(i,n)cin>>xs[i];
	rep(i,m)cin>>ys[i];
	sort(xs.begin(),xs.end());
	sort(ys.begin(),ys.end());
	if(xs[n-1]<ys[0]&&xs[n-1]<y&&x<y&&x<ys[0])cout<<"No ";
	cout<<"War"<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> ii;
typedef pair<long long, pair<int, int>> iii;
typedef pair<ii, ii> iiii;

const double PI = acos(-1.0), EPS = 1e-6;
const int N = 200005, M = 100005, mod = 998244353 , mxLog = 20;

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(6), cout << fixed;

    int n;
    long long k;
    cin >> n >> k;
    vector<long long> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }

    vector<int> ones(64);
    for (int i = 0; i < n; ++i) {
        long long tmp = v[i];
        int j = 0;
        while (tmp) {
            ones[j] += (tmp & 1);
            tmp >>= 1;
            ++j;
        }
    }

    int most = 63;
    while (most >= 0) {
        if (k & (1LL << most))
            break;
        --most;
    }

    long long x = 0;
    bool f = false;
    for (int i = most; ~i; --i) {
        if (f) {
            if (n - ones[i] > ones[i]) {
                x |= (1LL << i);
            }
        } else {
            if ((1LL << i) & k) {
                if (n - ones[i] > ones[i]) {
                    x |= (1LL << i);
                } else {
                    f = true;
                }
            }
        }
    }


    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += (v[i] ^ x);
    }

    cout << ans << '\n';


    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
const ll mod=1e9+7;

struct stats{
    ll w,s,v;
};

const int N=1e3+1, M=1e4+2;
vector<stats> a(N);
ll dp[N][M],n;

ll go(ll pos, ll left){
    if(pos==n) return 0;
    if(dp[pos][left]!=-1)
        return dp[pos][left];
    ll ans;
    if(left==M-1)
        ans=max(go(pos+1,left),a[pos].v+go(pos+1,a[pos].s));
    else{
        ans=go(pos+1,left);
        if(left>=a[pos].w)
            ans=max(ans,a[pos].v+go(pos+1,min(left-a[pos].w,a[pos].s)));
    }
    return dp[pos][left]=ans;
}

bool comp(stats a, stats b){
    return (a.s+a.w)>(b.s+b.w);
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();

    cin>>n;
    for(ll i=0;i<n;i++)
        cin>>a[i].w>>a[i].s>>a[i].v;
    sort(a.begin(),a.end(),comp);
    //for(ll i=0;i<n;i++)
    //    cout<<a[i].w<<" "<<a[i].s<<" "<<a[i].v<<"\n";
    memset(dp,-1,sizeof(dp));
    cout<<go(0,M-1);



    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}


Measured memory_bytes: 82068
import datetime
while True:
    ymd  = map(str, raw_input().split())
    if (ymd[0] == '-1'):
        break
    d1 = ":".join(ymd[:3])
    d2 = ":".join(ymd[3:])
    t1 = datetime.datetime.strptime(d1, "%Y:%m:%d")
    t2 = datetime.datetime.strptime(d2, "%Y:%m:%d")
    print (t2 - t1).days
    
    

Measured memory_bytes: 5084
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

int main() {
  int k, a, b;
  scanf("%d %d %d", &k, &a, &b);

  lint result = 1 + k;

  if (1 + k >= a && b > a + 2) {
    int op_count = (k - (a - 1)) / 2;
    result = max(result,
                 1 + (lint)op_count * (b - a) + (k - 2 * op_count));
  }

  printf("%lld\n", result);

  return 0;
}


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

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int H,W,i,j;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0){break;}
        for(i=1;i<=H;i++){
            for(j=1;j<=W;j++){
                if(i%2!=0){
                    if(j%2!=0){printf("#");}
                    else{printf(".");}
                }
                else{
                    if(j%2!=0){printf(".");}
                    else{printf("#");}
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}



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

long long GCD(long long  a, long long b){
	if (a%b == 0){
		return b;
	}
	else {
		return GCD(b, a%b);
	}
}

long long LCM(long long a, long long b){
	return (a*b) / GCD(a,b);
}


int main(){
	long long A, B, C, D,a,l,b,c,d,l2;

	cin >> A >> B >> C >> D;

	a = B - B / C - B / D;
	
	l = LCM(C, D);

	b = B / l;

	a += b;

	A--;

	c = A - A / C - A / D;

	l2 = LCM(C, D);

	d = A / l2;

	c += d;

	cout << a - c << endl;

	return 0;
}

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

int solvegcd(int x, int y) {
	if (x == -1 && y == -1)return -1;
	if (x == -1 && y != -1)return y;
	if (x != -1 && y == -1)return x;
	if (x < y)swap(x, y);
	if (x%y == 0)return y;
	return solvegcd(y, x%y);
}

class SegmentTree {
public:
	int n;	// 木の要素数
	vector<int> num;

	SegmentTree(int x, vector<int> v) {
		n = pow(2, ceil(log2(x)) + 1) - 1;
		num.resize(n);
		for (int i = 0; i < (n + 1) / 2; i++) {
			if (i < x) { num[i + (n + 1) / 2 - 1] = v[i]; }
			else num[i + (n + 1) / 2 - 1] = -1;
		}
		solve(0);

	}

	int solve(int i) {
		int a = 2 * i + 1;
		int b = a + 1;
		if (num[a] == 0 && num[b] == 0) return num[i] = solvegcd(num[a] = solve(a), num[b] = solve(b));
		if (num[a] == -1 && num[b] == -1) return num[i] = -1;
		if (num[a] == -1 && num[b] != -1) return num[i] = num[b];
		if (num[a] != -1 && num[b] == -1) return num[i] = num[a];
		return num[i] = solvegcd(num[a], num[b]);

	}

	int length() {
		return n;
	}

	int queryto(int x) {
		x++;
		int s = (n - 1) / 2;	// start of lowest tier
		int ans = -1;
		while (x != 0) {
			if (x % 2 == 1) {
				ans = solvegcd(ans, num[s + x - 1]);
			}
			s /= 2;
			x /= 2;
		}

		return ans;
	}

	int queryfrom(int x) {
		int s = n - 1;	// end of lowest tier
		x = (n + 1) / 2 - x;
		int ans = -1;
		while (x != 0) {
			if (x % 2 == 1) {
				ans = solvegcd(ans, num[s - x + 1]);
			}
			s = (s - 1) / 2;
			x /= 2;
		}

		return ans;
	}
};

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

		int* front = new int[n];
		int* back = new int[n];
		int* gcds = new int[n];

		front[0] = a[0];
		back[n - 1] = a[n - 1];

		for (int i = 1; i < n; i++) {
			front[i] = solvegcd(a[i], front[i - 1]);
		}
		for (int j = n - 2; j >= 0; j--) {
			back[j] = solvegcd(a[j], back[j + 1]);
		}
		for (int i = 1; i < n - 1; i++) {
			gcds[i] = solvegcd(front[i - 1], back[i + 1]);
		}

		gcds[0] = back[1];
		gcds[n - 1] = front[n - 2];

		for (int i = 0; i < n + 1; i++) {
			if (ans < gcds[i])ans = gcds[i];
		}
		cout << ans << endl;
	}
	else {
		SegmentTree s(n, a);

		int ans = 0;
		int temp = 0;

		ans = s.queryfrom(1);
		//cout << ans << endl;
		for (int i = 1; i < n - 1; i++) {
			temp = solvegcd(s.queryto(i - 1), s.queryfrom(i + 1));
			//cout << temp << endl;
			if (temp > ans)ans = temp;
		}
		temp = s.queryto(n - 1);
		//cout << temp << endl;
		if (temp > ans)ans = temp;

		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2048
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
 
 //dp[i][j][m]: Nを上から見た時に
 //i-1桁目まで考慮し，非0がj個ある個数
 //mはフラグ (i-1桁目まで考慮したときに既にNより小さい数になることが確定しているか否か)
 // i-1までの桁がNと一致⇒m=0,  i-1までの桁を考慮した時点でNより小さい数になることが確定⇒m=1
 	int dp[101][4][2];
int main(){
	string s;
	cin >> s;
	int K;
	cin >> K;
	int N = s.size();

	dp[0][0][0] = 1;//まだ1桁も考慮してない時点ではNと一致しているといえるので1個
	for(int i=0; i<N; i++){
	for(int j=0; j<=3; j++){
	for(int m=0; m<=1; m++){
				
		int nd = s[i] - '0';
		for(int num=0; num<=9; num++){
			int ni = i+1, nj = j, nm = m;
			if(num!=0) nj++;
			if(nj>K) continue;
			if(m==0 && num>nd) continue;
			if(m==0 && num<nd) nm=1;
			dp[ni][nj][nm] += dp[i][j][m];
		}
	}
	}
	}
	// cout << " dp[N-1][K][0]: " << dp[N-1][K][0] << " dp[N-1][K][1]: " << dp[N-1][K][1] << endl;
	// cout << " dp[N-1][K-1][0]: " << dp[N-1][K-1][0] << " dp[N-1][K-1][1]: " << dp[N-1][K-1][1] << endl;
	
	// cout << " dp[N][K][0]: " << dp[N][K][0] << " dp[N][K][1]: " << dp[N][K][1] << endl;
	int ans = dp[N][K][0] + dp[N][K][1];
	cout << ans << endl;
	return 0;



}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define MAX_V 1000
#define INF 1e9
using namespace std;

typedef pair<int,int> P; //first??????????????¢???second??????????????????

//(???????????????????????????????????????)
struct edge{int to, cap, cost, rev;};

int V;                          //????????°
vector<edge> G[MAX_V];          //??°???????????£??\???????????¨???
int h[MAX_V];                   //??????????????£???
int dist[MAX_V];                //???????????¢
int prevv[MAX_V], preve[MAX_V]; //??´??????????????¨???

//from??????to??????????????????cap????????????cost???????????°????????????????????????
void add_edge(int from, int to, int cap, int cost){
  G[from].push_back((edge){to, cap, cost, G[to].size()});
  G[to].push_back((edge){from, 0 ,-cost, G[from].size()-1});
}

//s??????t????????????f???????°??????¨???????±??????????
int min_cost_flow(int s, int t, int f){
  int res = 0;
  fill(h, h+V, 0); //h????????????
  while(f > 0){
    //??????????????????????????¨??????h?????´??°?????????
    priority_queue <P, vector<P>, greater<P> > que;
    fill(dist,dist+V,INF);
    dist[s] = 0;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      int v= p.second;
      if(dist[v] < p.first) continue;
      for(int i=0; i<G[v].size() ;i++){
	edge &e = G[v][i];
	if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
	  dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
	  prevv[e.to] = v;
	  preve[e.to] = i;
	  que.push(P(dist[e.to],e.to));
	}
      }
    }
    if(dist[t]==INF) return -1; //????????\???????????????
    for(int v=0; v<V ;v++) h[v] += dist[v];
    
    //s???t????????????????????£?????????????????????
    int d = f;
    for(int v=t; v!=s ;v=prevv[v]) 
      d= min(d, G[prevv[v]][preve[v]].cap);
    
    f -= d;
    res += d * h[t];
    for(int v=t; v!=s; v=prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}

int main(){
  int E,F;
  cin>>V>>E>>F;

  for(int i=0;i<E;i++){
    int u,v,c,d;
    cin>>u>>v>>c>>d;
    add_edge(u,v,c,d);
  }
  cout <<min_cost_flow(0,V-1,F)<<endl;  
}

Measured memory_bytes: 3196
N=int(input())
ans=[0]*(N+1)
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            num=x*y+y*z+z*x+x*x+y*y+z*z
            if num>N:
                break
            ans[num]+=1
for i in range(N):
    print(ans[i+1])

Measured memory_bytes: 9312
#include<stdio.h>
#define MAX 100000

typedef struct{
  int count;
  char pict;
  int number;
}num;

int partition(num *, int, int);
void quicksort(num *,int ,int);

 main()
{
  int flag=0,n,i,r,p;/*q??????????????¢??°??§??????????????????*/
  num A[MAX];
  char dd;
  scanf("%d%c",&n,&dd);
  for(i=0;i<n;i++)
    {
      scanf("%c%d%c",&A[i].pict,&A[i].number,&dd);
      A[i].count = i;  /*???????????\????????????*/
 
    }
  r = n-1;
  p = 0;

  quicksort(A,p,r);

  for(i=0;i<n-1;i++)
    {
      if(A[i].number == A[i+1].number && A[i].count > A[i+1].count && flag==0)
	{
	  printf("Not stable\n");
	  flag = 1;
	}
      if(flag == 0 && i== n-2){
	printf("Stable\n");
      }
    }

  for(i=0;i<n;i++)
    {
      printf("%c %d\n",A[i].pict,A[i].number);
    }

  return 0;
}

int partition(num *a,int p, int r)/*partition????????????????????????????????????*/
{
  int i,j; /*??????????§??????????????????¨exchange*/
  int x;
  num ex;
  x = a[r].number;
  i = p-1;

  for(j=p;j<r;j++)
    {
      if(a[j].number<=x)
	{

	  i = i+1;
	  ex = a[i];
	  a[i] = a[j];
	  a[j] =  ex;
	}
    }
  ex = a[i+1];
  a[i+1] = a[r];
  a[r] = ex;

  return i+1;
}

void quicksort(num *a,int p, int r)
{
  int q;

  if(p<r)
    {
      q = partition(a,p,r);
      quicksort(a,p,q-1);
      quicksort(a,q+1,r);

    }

  return ;
}

Measured memory_bytes: 1780
N,A,B=map(int,input().split())
if (B-A)%2 == 0:
  print((B-A)//2)
else:
  ans=min((B-1),(N-A))
  if (B-1)<=(N-A):
    A2=1
    B2=B-(A-1)-1
    _ans=A-1+1
    _ans+=(B2-A2)//2
  else:
    B2=N
    A2=A+(N-B)+1
    _ans=N-B+1
    _ans+=(B2-A2)//2
  ans=min(ans,_ans)
  print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int ask(int y1, int x1, int y2, int x2)
{
	printf("? %d %d %d %d\n", y1, x1, y2 - 1, x2 - 1);
	fflush(stdout);
	int a;
	scanf("%d", &a);
	return a;
}

int score(int q)
{
	if (q > 2500) return 0;
	if (q >= 930) return max((int)(1e-8 + 125 - 3.2 * sqrt(q - 920)), 40);
	if (q >= 880) return (int)(1e-8 + 288 - 22 * sqrt(q - 870));
	return min(2860 - 3 * q, 300);
}

int H, W, N, K;
int C[50][50];

void solve(int y1, int x1, int y2, int x2, int cnt)
{
	if (y2 - y1 == 1 && x2 - x1 == 1) {
		C[y1][x1] = cnt;
		return;
	}
	if (cnt == 0) return;
	if ((y2 - y1) * (x2 - x1) == cnt) {
		for (int i = y1; i < y2; ++i) {
			for (int j = x1; j < x2; ++j) {
				C[i][j] = 1;
			}
		}
		return;
	}

	if (x2 - x1 == 1) {
		int ym = (y2 + y1) / 2;
		int a = ask(y1, x1, ym, x2);
		solve(y1, x1, ym, x2, a);
		solve(ym, x1, y2, x2, cnt - a);
	} else {
		int xm = (x2 + x1) / 2;
		int a = ask(y1, x1, y2, xm);
		solve(y1, x1, y2, xm, a);
		solve(y1, xm, y2, x2, cnt - a);
	}
}

int main()
{
	scanf("%d%d%d%d", &H, &W, &N, &K);
	solve(0, 0, H, W, N);

	int ret = 0;
	int pw = 1;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			ret += C[i][j] * pw;
			ret %= K;
			pw = pw * 2 % K;
		}
	}
	printf("! %d\n", ret);
	return 0;
}


Measured memory_bytes: 596
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "tet"
using namespace std;
const ll N = 2e5 + 9;
const ll inf = 1e18;
typedef pair<ll,ll> LL;
vector<ll> res;
ll n;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>n;
    ll i = 2,p = n;
    while(i <= sqrt(p)){
        if (n%i == 0){
            ll cnt = 0;
            while(n%i == 0){
                cnt++;
                n /= i;
            }
            res.push_back(cnt);
        }
        i++;
    }
    if (n > 1) res.push_back(1);
    ll ans = 0;
    for (auto i : res){
        //cout<<i<<" ";
        ll r = sqrt(2*i);
        if (r*(r + 1) > 2*i) ans += r - 1;
        else ans += r;
    }
    cout<<ans;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  int a,b;
  vector<int> vec(N);
  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 <stdio.h>

int	main(void)
{
  	char	s[6];
  	int		num;
  
  	num = scanf("%s", s);
 	if (num != 1)
      	return (0);
  
  	if (s[2] == s[3] && s[4] == s[5])
      	printf("Yes");
  	else
      	printf("No");
  
  	return (0);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>

using namespace std;

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

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

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

#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))32
const ll MOD = 1000000007ll;

int main() {
	int w, a, b;
	cin >> w >> a >> b;
	
	int ans = INF;
	
	if (a + w <= b) chmin(ans, b - (a + w));
	if (a >= b + w) chmin(ans, a - (b + w));
	if (a <= b && a + w >= b) ans = 0;
	if (a <= b + w && a + w >= b + w) ans = 0;
	
	cout << ans << endl;
	
	return 0;
}

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

int main()
{
	std::string S;
	std::cin >> S;
	S = ">" + S + "<";
	std::vector<int> ans(S.size() - 1);
	for (int i{}; i < (int)ans.size(); i++)
	{
		if (S[i] != '>' || S[i + 1] != '<') continue;
		for (int j{i - 1}; j >= 0 && S[j + 1] == '>'; j--)
			ans[j] = std::max(ans[j], ans[j + 1] + 1);
		for (int j{i + 1}; j < (int)ans.size() && S[j] == '<'; j++)
			ans[j] = std::max(ans[j], ans[j - 1] + 1);
	}
	int64_t sum{};
	for (auto& e: ans) sum += e;
	printf("%lld\n", sum);

	return 0;
}

Measured memory_bytes: 2840
#include<iostream>
using namespace std;
int main(){
  unsigned int x,y;

  scanf("%x", &x);
  scanf("%x", &y);


  if(x<y)
    cout << "<" << endl;
  else if(x>y)
    cout << ">" << endl;
  else
    cout << "=" << endl;

  return 0;
}


Measured memory_bytes: 256
//Totka hai dosto
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll

int32_t main()
{
	int n;
	cin>>n;
	int a[n];
	for(auto &i:a)cin>>i;
	int f=0;
	
	for(int i=0;i<n;i++)
	{
		if(i&1)
		f-=a[i];
		else f+=a[i];
	}
	
	cout<<f<<" ";
	
	int cur=f/2;
	for(int i=0;i<n-1;i++)
	{
		cout<<2*(a[i]-cur)<<" ";
		cur=a[i]-cur;
	}
	
}

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

#define ll  long long  int
using namespace std;


int  main()
{

  #ifndef ONLINE_JUDGE
freopen("fi.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#else
// online submission
 
#endif
int n;
int d;
cin>>n>>d;
int ctr=0;

while(n--)
{

double p,q;
cin>>p>>q;
    double x=sqrt(p*p+q*q);
    if(x<=d)
    {
        ctr++;
    }
}
cout<<ctr<<endl;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(N), B(M);
  bool ok = true;
  map<int, int> mpA, mpB;
  vector<ll> cntA(N*M+1), cntB(N*M+1);
  rep(i, N) {
    cin >> A[i];
    if(mpA.count(A[i])) ok = false;
    mpA[A[i]] = i;
    cntA[A[i]]++;
  }
  rep(i, M) {
    cin >> B[i];
    if(mpB.count(B[i])) ok = false;
    mpB[B[i]] = i;
    cntB[B[i]]++;
  }
  rrep(i, N*M) {
    cntA[i] += cntA[i+1];
    cntB[i] += cntB[i+1];
  }
  if(!ok) cout << 0 << endl;
  else {
    ll ans = 1;
    RREP(i, N*M, 1) {
      if(mpA.count(i) && mpB.count(i)) {
        ans *= 1;
      } else if(mpA.count(i)) {
        (ans *= cntB[i]) %= mod;
      } else if(mpB.count(i)) {
        (ans *= cntA[i]) %= mod;
      } else {
        (ans *= max((cntA[i]*cntB[i])-(N*M-i), 0LL)) %= mod;
      }
      // cout << i << ' ' << ans << endl;
    }
    cout << ans << endl;
  }
  return 0;
}


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

namespace ABC_C
{
    class C089
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            List<char> list = new List<char>();
            List<char> march = new List<char>{ 'M', 'A', 'R', 'C', 'H' };
            for (int i = 0; i < N; i++)
            {
                char c = Console.ReadLine()[0];
                if (march.Contains(c)) list.Add(c);
            }

            Dictionary<char, int> dic = list.ToLookup(x => x).ToDictionary(x => x.Key, x => x.Count());
            int[] cnt = dic.Values.ToArray();

            long count = 0;
            if (dic.Count <= 2)
            {
                count = 0;
            }
            else if (dic.Count == 3)
            {
                count = (long)cnt[0] * cnt[1] * cnt[2];
            }
            else if (dic.Count == 4)
            {
                count += (long)cnt[0] * cnt[1] * cnt[2];
                count += (long)cnt[1] * cnt[2] * cnt[3];
                count += (long)cnt[2] * cnt[3] * cnt[0];
                count += (long)cnt[3] * cnt[0] * cnt[1];
            }
            else
            {
                for(int i = 0; i < 5; i++)
                {
                    for(int j = i + 1; j < 5; j++)
                    {
                        for(int k = j + 1; k < 5; k++)
                        {
                            count += (long)cnt[i] * cnt[j] * cnt[k];
                        }
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 16224
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,h[1000]={},s[10]={},ans=0;
  string a;
  cin>>n>>a;
  for(int i=0;i<a.size();i+=2)h[(int)a[i]]++;
  for(int i=0;i<1000;i++)s[h[i]]++;
  for(int i=1;i<10;i++){
    if(s[i]){
      if(i==1)ans+=2*s[i]-1;
      else if(s[i]==1)ans+=3;
      else if(s[i]>=2)ans+=7+(s[i]-2)*2;
    ans++;
    }
  }
  cout<<ans-1<<endl;
  return 0;
}

Measured memory_bytes: 3192
import std.stdio : readln, writeln, writefln;
import std.string : chomp;
import std.array : array, split;
import std.conv  : to;
import std.range.primitives;
import std.range : enumerate, iota, repeat, retro, assumeSorted;
import std.algorithm.searching  : all, any, canFind, count, countUntil;
import std.algorithm.comparison : max, min, clamp;
import std.algorithm.iteration  : each, group, filter, map, reduce, permutations, sum, uniq;
import std.algorithm.sorting    : sort;
import std.algorithm.mutation   : reverse, swap;

void main() {
    int n;
    scan(n);
    iota(n).map!(i => readln.chomp.to!int).array.sort().uniq().count.writeln;
}




void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.array : split;
    import std.conv  : to;
    import std.range.primitives;

    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
   int n;
   cin>>n;
   int a[n+1],b[n];
   rep(i,n+1){
       cin>>a[i];
   }
   rep(i,n){
       cin>>b[i];
   }
   int ans=0;
   rep(i,n){
       if(a[i]+a[i+1]>b[i]){
           if(b[i]>=a[i]){
           a[i+1]=a[i+1]-(b[i]-a[i]);
           }
           ans+=b[i];
       }
       else{
           ans+=a[i]+a[i+1];
           a[i+1]=0;
       }
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

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

vector<int> zalgorithm(string s){
    int n=s.length();
    vector<int> ret(n);
    ret[0]=n;
    int i=1,j=0;

    while(i<n){
        while(i+j<n && s[j]==s[i+j]){j++;}
        ret[i]=j;
        if(j==0){
            i++;
            continue;
        }
        int k=1;
        while(i+k<n && k+ret[k]<j){
            ret[i+k]=ret[k];
            k++;
        }
        i+=k;
        j-=k;
    }
    return ret;
} 

int main(void){
    int N;
    string S;
    cin>>N>>S;

    int ans=0;
    for(int i=0;i<N;i++){
        string Si=S.substr(i);
        vector<int> v;
        v=zalgorithm(Si);
        for(int j=0;j<Si.length();j++){
            int len=min(v[j],j);
            if(ans<len){ans=len;}
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << '\n'
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n, k;
    cin >> n >> k;
    int keta = 0;
    while ((k>>keta)>0) {
        keta++;
    }
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    ll ans = 0;
    rep(i, keta) {
        if ((k>>i&1)==0) continue;
        ll score = 0;
        rep(j, n) {
            bool ok = true;
            if ((a[j]>>i&1)==1) ok = false;
            rep(l, 30) {
                if (l<=i) continue;
                if ((k>>l&1)==0 && (a[j]>>l&1)==1) ok = false;
            }
            if (ok) score += b[j];
        }
        chmax(ans, score);
    }
    ll res = 0;
    rep(j, n) {
        bool ok = true;
        rep(l, 30) {
            if ((k>>l&1)==0 && (a[j]>>l&1)==1) ok = false;
        }
        if (ok) res += b[j];
    }
    chmax(ans, res);
    
    pr(ans);
    return 0;
}


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

int main() {
    /* 入力受け取り */
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];

    /* しゃくとり法 */
    int res = 0;
    int right = 0;
    for (int left = 0; left < n; ++left) {
        while (right < n-1 && a[right]>= a[right+1]) {
            ++right;
        }
        res = max(res, right - left);
				if (left == right) ++right;
    }
    cout << res << endl;
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s          second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep0(a,n)  for(int i=0;i<n;i++)cin>>a[i]
#define si(x)       cin>>x
#define sii(x,y)    cin>>x>>y
#define siii(x,y,z) cin>>x>>y>>z
#define ahell   998244353
#define hell 1000000007
#define N1 100001
#define fl 1.0000000000
//#define mod 998244353
#define cntbit(a) __builtin_popcountll(a)
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

main()
{
  ios

//si(test);
int test=1,i,j,k,l;
int n,m;
//si(test);
//sieve();
while(test--)
{
  // sii(n,k);
 int a,b,c,d;
 sii(a,b);
 sii(c,d);
 k=max(a*c,max(b*d,max(a*d,b*c)));
 cout<<k;

 }
}


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++)

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

    ll N;
    cin >> N;

    vector<string> S(N);
    rep (i, N) {
        cin >> S[i];
    }

    vector<ll> count(26, INF);
    rep (i, N) {
        vector<ll> tmp(26, 0);
        rep (j, S[i].size()) {
            tmp[S[i][j] - 'a']++;
        }
        rep (j, 26) {
            count[j] = min(count[j], tmp[j]);
        }
    }

    string ans = "";
    rep (i, 26) {
        rep (j, count[i]) {
            ans += i+'a';
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{   int n;
    cin>>n;
    LL s=1;
    for(int i=0;i<n;i++){
        LL x;
        cin>>x;
        s=x/__gcd(x,s)*s;
    }
    cout<<s<<endl;


    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>


using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;



int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    ll s = 0;
    ll A[N];
    REP(i, N) {
        ll a; cin >> a;
        s += a;
        A[i] = s;
    }

    ll ans = INF;
    REP(i, N-1) {
        ans = min(abs(s - 2 * A[i]), ans);
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int coin[] = {10, 50, 100, 500};

int main(void){
  int pay;
  int flg = false;
  while(cin >> pay, pay){
    if(flg) cout << endl;
    flg = true;
    int noc[4];
    int noc_org[4];
    for(int i=0; i < 4; i++){
      int t;
      cin >> t;
      noc[i] = t;
      noc_org[i] = t;
    }
    int charge = (coin[0]*noc[0]+coin[1]*noc[1]+coin[2]*noc[2]+coin[3]*noc[3]) - pay;
    int use[4];
    for(int i=3; i >= 0; i--){
      use[i] = charge / coin[i];
      while(charge >= coin[i]){
        charge -= coin[i];
      }
    }
    for(int i=0; i < 4; i++){
      int out = ((noc_org[i] - use[i] < 0) ? 0 : noc_org[i] - use[i]);
      if(out == 0) continue;
      cout << coin[i] << " " << out << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
fun main(args: Array<String>) {
    val (n, m) = readIntList()
    val x = readLongList().sorted()

    if (n > m) {
        println(0)
        return
    }

    val xx = MutableList(m - 1) { 0L }
    for (i in 0 until x.size - 1) {
        xx[i] = x[i + 1] - x[i]
    }
    val sorted = xx.sorted().reversed()

    var ans = x.last() - x.first()
    for (i in 0 until n-1) {
        ans -= sorted[i]
    }
    println(ans)
}

// read
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 59796
import sys


def main():
    inp = [int(line)  for line in sys.stdin.readlines()]
    k = inp.pop(len(inp) - 1)
    #sys.stdin.readline()
    #line = sys.stdin.readline()

    if max(inp) - min(inp) > k:
        print(":(")
    else:
        print("Yay!")

if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

char s[105];

int main(){
	cin >> s+1;
	bool b = 1;
	int k = strlen(s+1);
	for(int i=1; i<=k; ++i){
		if(i % 2 == 1){
			if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')
			  continue;
			else {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')
			  continue;
			else {
				cout << "No" <<endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a, b, c, d;
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		d = sc.nextInt();
		
		sc.close();
		
		int time = Math.min(d,  b);
		time -= Math.max(a, c);
		
		if(time < 0)time = 0;
		System.out.println(time);
		
	}

}


Measured memory_bytes: 22612
class comb():
  F = [1, 1]
  Fi = [1, 1]
  I = [0, 1]
  def __init__(self, num, mod):
    self.MOD = mod
    for i in range(2, N + 1):
      self.F.append((self.F[-1] * i) % mod)
      self.I.append(mod - self.I[mod % i] * (mod // i) % mod)
      self.Fi.append(self.Fi[-1] * self.I[i] % mod)
  def com(self, n, k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return self.F[n] * (self.Fi[k] * self.Fi[n - k] % self.MOD) % self.MOD

N, A, B, K = list(map(int, input().split()))
MOD = 998244353
com = comb(N, MOD)

if A > B:
  A, B = (B, A)
Rk = min(N, K // A)

Ans = 0
for i in range(Rk + 1):
  R = i
  if (K - (A * R)) % B != 0:
    continue
  C = (K - (A * R)) // B
  if C > N:
    continue
  Rc = com.com(N, R)
  Cc = com.com(N, C)
  Ans += (Rc * Cc) % MOD

print(Ans % MOD)

Measured memory_bytes: 100208
from itertools import permutations
a = list(permutations(range(5)))
time = [int(input()) for _ in range(5)]
ans = 10000
for l in a:
  t = 0
  for i in range(5):
    t += time[l[i]] + (10 - t % 10)*(t % 10 != 0)
  ans = min(ans,t)
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong();
		long k  = n;
		int countn = 1;
		while(k >= 10) {
			k = k /10;
			countn++;
		}
		int min = countn ;

		for( long i = 1; i < n; i++) {
		 int dig = 1;
		 long j = n / i;
		 
		 if(i > j)  break;
		 
		 if(n % i == 0) {
			 long jj = j;
			while(jj >= 10) {
				dig++;
				jj = jj /10;
			}
			min = Math.min(dig, min);
		}
	}
		System.out.println(min);

	}
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
int n,b,syz,waki[200010];
long long sum=0;
int a[200010];
int main()
{
	cin>>n;
	syz=n;
	for(int i=1;i<=n;i++){scanf("%d",&waki[i]);waki[i]-=i;a[i]=waki[i];};
	sort(a+1,a+1+n);
	b=a[n/2+1];
	for(int i=1;i<=n;i++) sum+=abs(waki[i]-b);
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1792
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))

def cumsum(a):
    """l[i] = sum(a[:i]) なるlを返す
    sum(a[i:j]) == l[j+1] - l[i]
    """
    c = 0
    l = [None] * (len(a)+1)
    for i,num in enumerate(a):
        l[i] = c
        c += num
    l[-1] = c
    return l
s = cumsum(a)

dp = [[None]*n for _ in range(n+1)] # i
for j in range(n):
    dp[1][j] = 0
for i in range(2,n+1):
    for j in range(n-i+1):
        dp[i][j] = min(dp[k][j]+dp[i-k][j+k] for k in range(1,i)) + s[j+i] - s[j]
print(dp[n][0])

Measured memory_bytes: 76872
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}


int main() {
	int n, m, c;
	int b[20];

	scanf("%d%d%d", &n, &m, &c);
	REP(i, m) {
		scanf("%d", &b[i]);
	}

	int ans = 0;
	REP(i, n) {
		int a;
		int sum = 0;
		REP(j, m) {
			scanf("%d", &a);
			sum += a*b[j];
		}
		sum += c;
		if (sum > 0)ans++;
	}
	PRINTD(ans);
}

Measured memory_bytes: 128
import java.util.*;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        String N = sc.next();
        int x = 1; 
        
        for(int i=0; i<3; i++){
            if(N.charAt(i)==N.charAt(i+1)){
                x += 1;
            }
        }
        if(x>=3 && N.charAt(1)==N.charAt(2)){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(double &x){
  scanf("%lf",&x);
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned x){
  int s=0;
  char f[10];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned long long x){
  int s=0;
  char f[21];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(double x){
  printf("%.15f",x);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
inline void wt_L(string &x){
  int i=0;
  for(i=0;x[i]!='\0';i++){
    putchar_unlocked(x[i]);
  }
}
template<class T> inline T pow2_L(T a){
  return a*a;
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int N;
double X[50];
double Y[50];
double dist[50];
int main(){
  int e98WHCEY;
  int i;
  int j;
  int k;
  double cx = 0;
  double cy = 0;
  double mv = 1;
  double r = 0.999;
  double res = 1e150;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(X[Lj4PdHRW]);
      rd(Y[Lj4PdHRW]);
    }
  }
  for(e98WHCEY=(0);e98WHCEY<(100000);e98WHCEY++){
    for(i=(0);i<(N);i++){
      dist[i] =pow2_L((X[i]-cx))+pow2_L((Y[i]-cy));
    }
    {
      int WYIGIcGE;
      double t_ynMSdg;
      if(N==0){
        t_ynMSdg = 0;
      }
      else{
        t_ynMSdg = dist[0];
        for(WYIGIcGE=(1);WYIGIcGE<(N);WYIGIcGE++){
          t_ynMSdg = max_L(t_ynMSdg, dist[WYIGIcGE]);
        }
      }
      chmin(res, t_ynMSdg);
    }
    {
      int a2conNHc;
      int hCmBdyQB = 0;
      double V9aVTaxx;
      double APIVbQlN;
      int YREPHmFM;
      for(a2conNHc=(0);a2conNHc<(((N)-1)+1);a2conNHc++){
        APIVbQlN = dist[a2conNHc];
        if(hCmBdyQB==0 || V9aVTaxx<APIVbQlN){
          V9aVTaxx = APIVbQlN;
          hCmBdyQB = 1;
          YREPHmFM = a2conNHc;
        }
      }
      k =YREPHmFM;
    }
    cx += mv * (X[k] - cx);
    cy += mv * (Y[k] - cy);
    mv *= r;
  }
  wt_L(sqrt(res));
  wt_L('\n');
  return 0;
}
// F


Measured memory_bytes: 256