akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 105, MAXW = 1e5 + 5;
const long long INF = 1e18;
int n, maxWeight, weights[MAXN], values[MAXN];
long long dp[MAXN][MAXW];


long long solve(int i, int curWeight) {
    if (curWeight > maxWeight)
        return -INF;
    if (i >= n)
        return 0;

    if (dp[i][curWeight] != -1)
        return dp[i][curWeight];

    long long take = values[i] + solve(i + 1, curWeight + weights[i]);
    long long leave = solve(i + 1, curWeight);
    return dp[i][curWeight] = max(take, leave);
}
int main() {
    memset(dp, -1, sizeof(dp));

    cin >> n >> maxWeight;
    for (int i = 0; i < n; i++)
        cin >> weights[i] >> values[i];

    cout << solve(0, 0) << '\n';

    return 0;
}

Measured memory_bytes: 85584
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

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

}


ll ketasuu(ll n) {
	ll retval = 1;
	while (n / 10 != 0) {

		n /= 10;
		retval += 1;
	}

	return retval;

}

int main() {
	ll N;

	cin >> N;
	ll num = 0;
	for (int i = 1; i <= ketasuu(N); i++) {
		if (i % 2 == 1) {
			if (i < ketasuu(N))
				num += (int)powl(10.0, i) - (int)powl(10.0, i - 1);
			else
				num += N - (int)powl(10.0, i-1) + 1;
		}


	}

	cout << num << endl;
	return 0;
}

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

template <ll mod> class modint
{
private:
    ll x;

public:
    modint(ll x = 0) : x(x >= 0 ? x % mod : (x % mod) + mod) {}
    modint &operator+=(const modint rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator-=(const modint rhs) {
        if ((x += mod - rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator*=(const modint rhs) {
        (x *= rhs.x) %= mod;
        return *this;
    }
    modint &operator/=(const modint rhs) {
        *this *= rhs.inv();
        return *this;
    }
    modint operator+(const modint rhs) const { return modint(*this) += rhs; }
    modint operator-(const modint rhs) const { return modint(*this) -= rhs; }
    modint operator*(const modint rhs) const { return modint(*this) *= rhs; }
    modint operator/(const modint rhs) const { return modint(*this) /= rhs; }

    modint operator-() const { return modint(-x); }

    modint pow(ll n) const {
        modint e = *this, ret = modint(1);
        while (n) {
            if (n & 1) ret *= e;
            e *= e, n >>= 1;
        }
        return ret;
    }

    modint inv() const { return pow(mod - 2); }

    friend ostream &operator<<(ostream &os, const modint &m) {
        os << m.x;
        return os;
    }

    friend istream &operator>>(istream &is, modint &m) {
        ll in;
        is >> in;
        m = modint(in);
        return is;
    }
};
using mint = modint<1000000007>;

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

    int n, a, b; cin >> n >> a >> b;
    
    mint nca = 1;
    for (int i = 0; i < a; i++) {
        nca *= (mint)(n - i);
    }
    for (int i = a; i > 0; i--) {
        nca /= (mint)i;
    }
    mint ncb = 1;
    for (int i = 0; i < b; i++) {
        ncb *= (mint)(n - i);
    }
    for (int i = b; i > 0; i--) {
        ncb /= (mint)i;
    }

    mint ans = mint(2).pow(n) - nca - ncb - 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<stack>
#include<map>
#include<set>
#include<assert.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define stop char nyaa;cin>>nyaa;

ll dp1[40000], dp2[40000],rdp1[40001],rdp2[40001];
ll cop1[40000], cop2[40000];
const int mn = 40000;
void solve() {
	ll n; int k; cin >> n >> k;
	int v = sqrt(n);
	dp1[1] = 1;
	rep(j, mn) {
		rdp1[j + 1] = (rdp1[j] + dp1[j]) % mod;
		rdp2[j + 1] = (rdp2[j] + dp2[j]) % mod;
	}
	rep(i, k) {
		fill(cop1, cop1 + 40000, 0);
		fill(cop2, cop2 + 40000, 0);
		rep1(j, mn-1) {
			if (j > v)break;
			cop1[j] = rdp2[mn] - rdp2[j];
			int d = n / j;
			if (d >= mn)d = mn - 1;
			cop1[j] += rdp1[d+1];
			cop1[j] = (cop1[j] % mod + mod) % mod;
		}
		rep1(j, mn - 1) {
			int ri = n / j;
			int le = n / (j + 1);
			if (ri < v)ri = v;
			if (le < v)le = v;
			cop2[j] = rdp1[j + 1]*(ri-le)%mod;
		}
		rep(j, mn) {
			dp1[j] = cop1[j];
			rdp1[j + 1] = (rdp1[j] + dp1[j]) % mod;
			dp2[j] = cop2[j];
			rdp2[j + 1] = (rdp2[j] + dp2[j]) % mod;
		}
	}
	ll ans = 0;
	rep(j, mn) {
		ans += dp1[j] + dp2[j]; ans %= mod;
	}
	cout << ans << endl;
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout<<fixed<<setprecision(10);
	solve();
	//stop
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}

signed main() {
	int n, k;
	cin >> n >> k;
	int a[100000];
	for (int i = 0; i < n; i++) cin >> a[i];
	if ((n - 1) % (k - 1) == 0) {
		cout << (n - 1) / (k - 1) << endl;
	}
	else cout << (n - 1) / (k - 1) + 1 << endl;
	endre;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pll pair<ll,ll>
#define vi vector < int >
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define s(x) scanf("%d",&x)
#define sll(x) scanf("%lld",&x)
#define pf(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define flash ios_base::sync_with_stdio(false);cin.tie(0)
#define goog(x) cout << "Case #" << x << ": "
#define MAX5 200005
#define MAX6 2000005
#define MLOG 18
#define limit 1e18
#define mod 1000000007   
void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int power(int x, int y, int p){
    int res = 1;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int v[MAX5];

string noOf(int x){
	int r = 0;
	string t = "";
	while(x){
		r = x % 10;
		t += (r + '0');
		x /= 10;
	}
	reverse(all(t));
	return t;
}
int mat[100][100];

void solve(){
    int d, t, s;
    cin >> d >> t >> s;
    if(d <= s*t) cout << "Yes";
    else cout << "No";
    
} 
signed main(){  
//   freopen("output.txt", "r", stdin);
//   freopen("tt.txt", "w", stdout);
    // flash;
    int t = 1;
    //  cin >> t;  
    for(int tc = 1; tc <= t; tc++){
    // goog(tc);
        solve();
		if(tc != t) cout << endl;
    }
}

Measured memory_bytes: 3624
import java.util.*;
public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int count = 1;
        int ans = 0;
        int temp1 = 0;
        int temp2 = 0;
        for(int i = 0;i < n+1;i++){
            if(i!=n){
                temp2 = sc.nextInt();
                if(temp1 == temp2){
                   count ++;
                }else{
                    ans += count / 2;
                    count = 1;
                }
                temp1 = temp2;
            }else{
                ans += count / 2;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
   long long  int a=0;
   long long  int c=0;
   long long  int b=0;
    cin>>a;
    cin>>b;
    if((b==1 || b==0) && a>1)
    {
        cout<<0;
    }
    else
    {
        c=b;
        a--;
        while(a!=0)
        {
            c=c*(b-1);
            a--;
        }
            cout<<c;
    }
}

Measured memory_bytes: 256
//0048
#include<cstdio>
#include<cmath>
using namespace std;

int main(void)
{
	double d;
	while(scanf("%lf", &d) == 1)
	{
		if(d <= 48.0)
			printf("light fly\n");
		else if( d <= 60.0)
		{
			const char* str[] = {"fly", "bantam", "feather", "light"};
			const int index = ((int)ceil(d)-49)/3;
			printf("%s\n", str[index]);
		}
		else if(d <= 64.00)
			printf("light welter\n");
		else if(d <= 69.00)
			printf("welter\n");
		else if(d <= 75.00)
			printf("light middle\n");
		else if(d <= 81.00)
			printf("middle\n");
		else if(d <= 91.00)
			printf("light heavy\n");
		else
			printf("heavy\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;



int main() {
    string s;
    cin>>s;
    int n=s.size();
    ll res = 0;

    int t=0;
    for (int i = n-1; i >= 0; i--) {
        if(s[i]=='B'){
            res+=t;
        }else{
            t++;
        }
    }

    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 640
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	int n;
	cin>>n;
	int A[n], B[n], C[n];
	for(int i=0;i<n;i++)
	{
		cin>>A[i];
		--A[i];
	}
	for(int i=0;i<n;i++)
		cin>>B[i];
	for(int i=0;i<n-1;i++)
		cin>>C[i];
	int ans = B[A[0]];
	int x = A[0];
	for(int i=1;i<n;i++)
	{
		if(A[i] == x + 1)
			ans += C[A[i]-1];
		ans += B[A[i]];
		x = A[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define forn(i,x,y) for(int i=x;i<y;++i)
#define fornr(i,x,y) for(long long i=x;i>=y;--i)
#define testcase int _t; cin >> _t; while(_t--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 2e5;


int main()
{
	ios_base :: sync_with_stdio(false);
  	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    int n,k;
    cin >> n >> k;
    int arr[n];
    vector<int> dp(n,INT_MAX);
    forn(i,0,n){
    	cin >> arr[i];    	
    }    	
    dp[0] = 0;
	forn(i,1,n){
		forn(j,1,k+1){
			if(i - j < 0)
				break;
			dp[i] = min(dp[i], dp[i-j] + abs(arr[i]-arr[i-j]));
		}
	}
	cout << dp[n-1];  	
  	return 0;
}

 	/* 















 	*/


Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define MAX 100005
using namespace std;

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int n, x, val;

    cin>>n>>x;

    cin>>val;
    int g = abs(val - x);

    for(int i = 2; i <= n; i++){
        cin>>val;
        g = __gcd(g, abs(val - x));
    }

    cout<<g<<endl;

    return 0;
}

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

void b(std::istream& in)
{
    unsigned long long X;
    in >> X;

    unsigned long long year = 0;
    unsigned long long amountOnDeposit = 100;
    while (true)
    {
        ++year;
        amountOnDeposit = static_cast<unsigned long long>(amountOnDeposit * 1.01);
        if (X <= amountOnDeposit)
            break;
    };

    std::cout << year;
}

int main(int, char* [])
{
    b(std::cin);
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
const int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
typedef long long ll;
const int N=100005;
int n,k,val[N],key[N];
using namespace std;

/*struct node
{
	int t,next;
}adj[N<<1];
void add(int s,int t)
{
	adj[++now]=(node){t,head[s]};
	head[s]=now;
}*/
inline int read()
{
	char c;int x;
	while (c=getchar(),c<'0' || c>'9');x=c^'0';
	while (c=getchar(),c>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x;
}
void write(int x)
{
	if (x==0) return;
	write(x/10);
	putchar((x%10)+'0');
}
//void upd(int& x,int y){if (x==-1) x=y;else x=max(x,y);}

int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	scanf ("%d %d",&n,&k);
	int i,j;
	for (i=1;i<=n;i++) scanf ("%d %d",&key[i],&val[i]);
	ll ans=0;
	for (i=29;i>=0;i--)
	{
		ll tmp=0;
		if (!((k>>i)&1)) continue;
		for (j=1;j<=n;j++)
		{
			int a=k>>i,b=key[j]>>i;
			if ((a&b)!=b) continue;
			if ((key[j]>>i)&1) continue;
			tmp+=val[j];
		}
		ans=max(ans,tmp);
	}
	ll tmp=0;
	for (i=1;i<=n;i++)
	if ((k&key[i])==key[i]) tmp+=val[i];
	cout<<max(tmp,ans);
	return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Double r = sc.nextDouble();
		Double pi = Math.PI;
		Double area = r * r * pi;
		Double length = 2 * pi * r;
		System.out.printf("%f %f \n",area,length);
	}
}


Measured memory_bytes: 28360
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
a=-(-A//10)*10
b=-(-B//10)*10
c=-(-C//10)*10
d=-(-D//10)*10
e=-(-E//10)*10
print(a+b+c+d+e-max(a-A,b-B,c-C,d-D,e-E))

Measured memory_bytes: 3064
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

// sum x=0..n-1 (ax+b)/c
int64 get(int64 a, int64 b, int64 c, int64 n) {
  int64 ret = 0;
  ret += b / c * n; b %= c;
  ret += a / c * n * (n - 1) / 2; a %= c;
  if (a * n + b < c) return ret;
  return ret + get(c, (a * n + b) % c, a, (a * n + b) / c);
}

int main() {
  int cas;
  cin >> cas;
  while (cas--) {
    int n, c, a, b;
    cin >> n >> c >> a >> b;
    cout << get(a, b, c, n) << '\n';
  }
  return 0;
}


Measured memory_bytes: 3176
import scala.util.control.Breaks

object Main extends App{
  def main(N:Int,s:List[Int]) {
    var res=1000000000
    for(i<-0 until N-1) {
      res=List(res,s(i+1)-s(i)).min
    }
    println(res)
  }
  val sc = new java.util.Scanner(System.in)
  val b=new Breaks

  b.breakable {
    while (true) {
      val N = sc.nextInt
      if (N == 0) b.break
      val s = List.fill(N)(sc.nextInt)
      main(N, s.sorted)
    }
  }
}

Measured memory_bytes: 69264
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
 
        
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] values = new int[w];
 
  
        for(int i=0;i<values.length;i++){
            values[i] = i+1;
        }
 
        for(int i=0;i<n;i++){
            String str = sc.next();
            String[] ab = str.split(",");
            int a = Integer.parseInt(ab[0])-1;
            int b = Integer.parseInt(ab[1])-1;
 
            int x = values[a];
            values[a] = values[b];
            values[b] = x;
        }
 
        for(int i=0;i<w;i++){
            System.out.println(values[i]);
        }
    }
}
}



Measured memory_bytes: 26100
(let* ((n (read))
       (a (ceiling n 4)))
  (if (not (loop :for j :from a :downto 1
                 :always(loop :for k :from 0 :upto j
                             :never (= n (+ (* 4 k) (* 7 (- j k)))))))
      (princ "Yes")
      (princ "No")))

Measured memory_bytes: 4196
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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



int main(){
	int h,w;
	cin >> h >> w;
	rep(i,0,h){
	    rep(j,0,w){
	        string s;
	        cin >> s;
	        if(s == "snuke")cout << (char)('A'+j)  <<  i+1 <<endl;
	    }
	}
	return  0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int num[3];
  int a, b ,rt;
  
  scanf("%d %d %d",&num[0], &num[1], &num[2]);
  a = num[0] / num[1];
  b = num[0] % num[1];

  if(b == 0)
    rt = a * num[2];
  else
    rt = (a + 1) * num[2];
 
 printf("%d", rt);
    return (0);
}


Measured memory_bytes: 1732
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() { 
   int n; cin >> n;
   vector<ll> t(n); rep(i, n) cin >> t[i];
   ll res = t[0];
   fo(i, 1, n){
       res = res / __gcd(res, t[i]) * t[i];
   }
   cout << res << ln;
}

Measured memory_bytes: 256
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))
bucket={}
for number in A:
    bucket[number]=0
for number in A:
    bucket[number]+= 1
count=0
for key in bucket:
    if bucket[key]%2==1:
        count+=1
    else:
        pass
print(count)

Measured memory_bytes: 16268
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define double long double
using namespace std;
typedef pair<ll, ll>P;
double mypow(double x, ll y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1) * x;
	else return mypow(x, y / 2) * mypow(x, y / 2);
}
signed main() {
	string s;
	cin >> s;
	bool a = true, b = true;
	if ((s[2] - '0') * 10 + (s[3] - '0') > 12 || (s[2] - '0') * 10 + (s[3] - '0') == 0)a = false;
	if ((s[0] - '0') * 10 + (s[1] - '0') > 12 || (s[0] - '0') * 10 + (s[1] - '0') == 0)b = false;
	if (a == true && b == true)puts("AMBIGUOUS");
	else if (a == true && b == false)puts("YYMM");
	else if (a == false && b == true)puts("MMYY");
	else puts("NA");
	ggr
}


Measured memory_bytes: 256
#include <stdio.h>
#include <unistd.h>
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#define BUF_SIZE ((size_t)(16*1024))
char buf[BUF_SIZE];
size_t len;

inline void flush_buf(void){
    write(1, buf, len);
    len = 0;
}

inline void check_buf(size_t n){
    if(unlikely(len+n>=BUF_SIZE)){
        flush_buf();
    }
}

inline void putchar_buf(char c){
    buf[len] = c;
    len++;
}

inline void puts_buf(const char* s){
    size_t i;
    for(i=0; s[i]!='\0'; i++){
        buf[len+i]=s[i];
    }
    buf[len+i]='\n';
    len+=i+1;
}

static inline void print_int(int n){
#define BASE ((int)10)
#define MAX_LEN ((size_t)11)
    static char c[MAX_LEN];
    size_t i=MAX_LEN-1;
    do{
        c[i]=n%BASE+'0';
        n/=BASE;
        i--;
    }while(n>0);
    len+=MAX_LEN-1-i;
    do{
        ++i;
        buf[len+i-MAX_LEN] = c[i];
    }while(i<MAX_LEN-1);
#undef MAX_LEN
#undef BASE
}

static void solve(const int n, const int a, const int b, int mask, const int common){
    const int t = a^b;
    const int d = t&(-t);
    mask ^= d;
    const int aa = a & mask, ab = aa ^ (mask&(-mask));
    if(n==2){
        check_buf(4*7);
        print_int(common|a); putchar_buf(' ');
        print_int(common|ab|(a&d)); putchar_buf(' ');
        print_int(common|ab|(b&d)); putchar_buf(' ');
        print_int(common|b); putchar_buf(' ');
    }else{
        solve(n-1, aa, ab, mask, common|(a&d));
        solve(n-1, ab, b&mask, mask, common|(b&d));
    }
}

int main(void){
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    if(unlikely(__builtin_parity(a)==__builtin_parity(b))){
        puts_buf("NO");
    }else{
        puts_buf("YES");
        if(unlikely(n==1)){
            print_int(a);
            putchar_buf(' ');
            print_int(b);
            putchar_buf('\n');
        }else{
            solve(n, a, b, -1, 0);
        }
    }
    flush_buf();
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  map<string,int> mp;
  for(int i=0;i<N;i++){
    string s;
    cin>>s;
    mp[s]++;
  }
  int mx=0;
  for(auto x:mp){
    mx=max(mx,x.second);
  }
  for(auto t:mp){
    if(mx!=t.second){
      continue;
    }
    else{
      cout<<t.first<<endl;
    }
  }
  return 0;
}
      

Measured memory_bytes: 25216
#include<bits/stdc++.h>
#define pb push_back
#define pair pair<int,int>
#define ll long long
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
const ll hi=1e14;
ll a[101][100001];
int main(){
  int n,w;
  scanf("%d%d",&n,&w);
  for(int i=0;i<=n;i++)
    for(int j=0;j<=100000;j++)
      a[i][j]=hi;
  for(int i=0;i<=n;i++)
    a[i][0]=0;
  for(int i=1;i<=n;i++)
  {
    ll we,va;
    scanf("%lli %lli",&we,&va);
    for(int j=1;j<=100000;j++)
      if(j<va)
        a[i][j]=a[i-1][j];
      else
        a[i][j]=min(a[i-1][j],a[i-1][j-va]+we);
  }
  int ans=0;
  for(int i=100000;i>=1;i--)
  {
    for(int j=1;j<=n;j++)
      if(a[j][i]<=w && a[j][i]!=0){
        ans=i;
        break;
      }
    if(ans!=0)
      break;
  }
  printf("%d",ans);
}

Measured memory_bytes: 79104
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=9e18+1;
const int inf=2e9;
const ll lnf=9e18;

ll C[51][51]; // C[n][k] -> nCk
void comb_table(int N){
  for(int i=0;i<=N;++i){
    for(int j=0;j<=i;++j){
      if(j==0 or j==i) C[i][j]=1ll;
      else C[i][j]=(C[i-1][j-1]+C[i-1][j]);
    }
  }
}

int main(){
  cout << fixed << setprecision(15);
  itn n,a,b; cin >> n >> a >> b;
  comb_table(n);
  vector<ll> v(n);
  rep(i,n) cin >> v[i];
  rsort(v);
  ld mx=0;
  rep(i,a){
    mx+=v[i];
  }
  mx/=a;
  cout << mx << endl;
  ll kagen=v[a-1];
  int cnt1=0;
  int cnt2=0;
  rep(i,n){
    if(v[i]>kagen) cnt1++;
    if(v[i]==kagen) cnt2++;
  }
  //cout << cnt1 << endl;
  //cout << cnt2 << endl;
  if(cnt1){
    cout << C[cnt2][a-cnt1] << endl;
    return 0;
  }
  ll ans=0;
  for(int i=a;i<=b;i++){
    ans+=C[cnt2][i-cnt1];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3912
#include <stdio.h>
#include <string.h>

int main(void){
	int i,l,ans=0;
	char s[100],t[100];
	scanf("%s",s);
	scanf("%s",t);

	l=strlen(s);

	char cp[l*2];

	strcpy(cp,s);
	strcat(cp,s);

	for(i=0;i<l;i++){
		if(strncmp(cp+i,t,l)==0){
			ans=1;
			break;
		}
	}

	if(ans==1){
		printf("Yes");
	}else{
		printf("No");
	}
 
	return 0;
 
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
n = int(input())
A = [int(input()) for i in range(n)]
A.sort()
ans = 0
for i in range(n//2):
    ans += (A[i+1]-A[i])*2*(i+1)
    ans += (A[n-1-i]-A[n-1-i-1])*2*(i+1)
    # print(A[i+1], A[i], 2*(i+1))
    # print(A[n-1-i], A[n-1-i-1], 2*(i+1))
if n % 2 == 1:
    ans -= min(A[n//2]-A[n//2-1], A[n//2+1]-A[n//2])
else:
    ans -= (A[n//2] - A[n//2-1]) * (2 * (n//2) + 1)
print(ans)

Measured memory_bytes: 44508
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

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

int main()
{
    int n, m;
    cin >> n >> m;

    vector<int> x(m);
    rep(i, m)
    {
        cin >> x[i];
    }
    sort(x.begin(), x.end());

    vector<int> dist(m - 1);
    rep(i, m - 1)
    {
        dist[i] = x[i + 1] - x[i];
    }

    sort(dist.begin(), dist.end());

    int result = 0;
    rep(i, max(0, m - n))
    {
        result += dist[i];
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <iostream>
#include <algorithm>
using namespace std;

int H, W, M;
int numh[300005], numw[300005];
map< pair<int, int>, int > m;
vector<int> h, w;

int main()
{
    scanf("%d%d%d", &H, &W, &M);
    for(int i = 1;i <= M;++i)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        m[make_pair(x,y)] = 1;
        ++numh[x];
        ++numw[y];
    }
    int mx = 0, mmx;
    for(int i = 1;i <= H;++i)
        if(mx < numh[i])
            mx = numh[i];
    for(int i = 1;i <= H;++i)
        if(numh[i] == mx)
            h.push_back(i);
    mmx = mx;
    mx = 0;
    for(int i = 1;i <= W;++i)
        if(mx < numw[i])
            mx = numw[i];
    for(int i = 1;i <= W;++i)
        if(numw[i] == mx)
            w.push_back(i);
    int sh = h.size(), sw = w.size(), ans;
    for(int i = 0;i < sh;++i)
    {
        int hh = h[i];
        for(int j = 0;j < sw;++j)
        {
            int ww = w[j];
            if(m[make_pair(hh, ww)] == 0)
            {
                printf("%d\n", mmx + mx);
                return 0;
            }
        }
    }

    printf("%d\n", mmx + mx - 1);

    return 0;
}

Measured memory_bytes: 28456
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int[] c =new int[N];
        int[] t =new int[N];
        
        for(int i=0;i<N;i++){
            c[i]=sc.nextInt();
            t[i]=sc.nextInt();
        }
        int ans = 1001;
        for(int i=0;i<N;i++){
            if(t[i]<=T){
                ans = Math.min(ans,c[i]);
            }
        }
        if(ans<=1000){
            System.out.println(ans);
        }else{
            System.out.println("TLE");
        }
    }
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;

int main(){
  int n;
  cin >> n;
  vector<int> dp(n+1,n);
  dp[0] = 0;
  for(int i=1; i <= n;i++){
    for(int pow6 = 1;pow6<=i;pow6*=6){
      dp[i] = min(dp[i],dp[i-pow6] + 1);
    }
    for(int pow9 = 1;pow9<=i;pow9*=9){
      dp[i] = min(dp[i],dp[i-pow9] + 1);
    }
  }
  cout << dp[n] <<endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
1,2,3個の寿司の皿の残数がi,j,kのときの、全て食べるまでの回数の期待値
*/

ll n,num[3];
double dp[310][310][310];

int main(void){
	cin>>n;
	rep(i,n){
		ll a;
		cin>>a;
		++num[a-1];
	}
	//
	reg(k,0,n)reg(j,0,n)reg(i,0,n){//j,kを取ると下の数が減るのでループはこの順序
		dp[i][j][k]=0;
		if(i+j+k==0)continue;
		dp[i][j][k] += 1.0*n/(i+j+k);//初めて寿司が乗っている皿を取るまでの回数の期待値
		if(i)dp[i][j][k] += dp[i-1][j][k]*i/(i+j+k);//寿司が載ってる皿を取ったら1個の寿司の皿だったとき
		if(j)dp[i][j][k] += dp[i+1][j-1][k]*j/(i+j+k);//2個
		if(k)dp[i][j][k] += dp[i][j+1][k-1]*k/(i+j+k);//3個
	}
	cout<<fixed<<setprecision(15)<<dp[num[0]][num[1]][num[2]]<<endl;
	return 0;
}

Measured memory_bytes: 227584
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define ll              long long
#define dd              double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define vi              vector<int>
#define vll             vector<long long>
#define vdd             vector<double>
#define vpii            vector<pair<int,int>>
#define vpll            vector<pair<long long,long long>>
#define vvi             vector<vector<int>>
#define vvll            vector<vector<long long>>
#define mii             map<int,int>
#define mll             map<long long,long long>
#define umii            unordered_map<int,int>
#define umll            unordered_map<long long,long long>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep2(i,a,b)     for(int i=a;i<b;i++)
#define rev(i,n)        for(int i=n;i>=0;i--)
#define rev2(i,a,b)     for(int i=a;i>=b;i--)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             9e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define wh(x)           int x; cin>>x; while(x--)
#define fio             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl            '\n'
#define all(x)          x.begin(),x.end()
#define d0(x)           cout <<x<<" "
#define d1(x)           cout <<x<<endl
#define d2(x,y)         cout <<x<<" "<<y<<endl
#define d3(x,y,z)       cout <<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w)     cout <<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define read2(x,y)      cin>>x>>y
#define read3(x,y,z)    cin>>x>>y>>z
#define read4(x,y,z,w)  cin>>x>>y>>z>>w
#define read5(x,y,z,w,a)cin>>x>>y>>z>>w>>a
#define sz(a)           (int)a.size()
#define deb(x)          cout <<#x << " is "<<x<<endl;
const ll mod=1e9+7;
const double PI = 3.14159265359;
const ll MOD=998244353;
void i_o()
{
   #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
}

string help(string& t){
  int n=t.length();
  for(char& c:t) if(c=='?') c='D';
  return t;  

}
int main(){
  fio
  i_o();
  string t;
  cin>>t;
  d1(help(t));
  return 0;
}


Measured memory_bytes: 3864
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
using namespace std;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while(A>0 && C>0) {
        C-=B;
        if(C <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        A-=D;
        if( A<= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <complex>
#include <bitset>
 
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
 
using namespace std;

mt19937 rr(random_device{}());

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef double ld;

const int INF = 1e9;
const double PI = acos(-1);

struct Point {
    int x, y;
};

bool operator < (const Point &a, const Point &b) {
    if (a.x != b.x)
        return a.x < b.x;
    return a.y < b.y;
}

int lis(vector<Point> &p) {
    int n = sz(p);
    vector<int> len(n + 1, INF);
    len[0] = -1;

    for (int i = 0; i < n; ++i) {
        int k = lower_bound(len.begin(), len.end(), p[i].y) - len.begin();
        len[k] = p[i].y;
    }
    int ans = 0;
    for (int i = n; i >= 0; --i) {
        if (len[i] != INF)
            return i;
    }
    return -1;
};

int main() {    
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);    
    cout.tie(0);

    Point s, t;
    cin >> s.x >> s.y >> t.x >> t.y;  

    if (t < s) {
        swap(s, t);
    }

    bool f = false;
    if (s.y > t.y) {
        f = true;
        swap(t.y, s.y);
    }

    int n;
    cin >> n;
    vector<Point> p;
    for (int i = 0; i < n; ++i) {
        Point q;
        cin >> q.x >> q.y;
        if (s.x <= q.x && q.x <= t.x && s.y <= q.y && q.y <= t.y) {
            if (!f) {
                p.push_back(q);
            } else {
                p.push_back({q.x, t.y - (q.y - s.y)});
            }
        }
    }

    cout.precision(12);
    cout << fixed;
    double ans = ((double)abs(s.x - t.x) + (double)abs(s.y - t.y)) * 100;

    if (s.x == t.x || s.y == t.y) {
        if (sz(p) > 0) {
            ans += 10 * PI - 20;
        }
        cout << ans << endl;
        return 0;
    }

    sort(all(p));

    int len = lis(p);

    ans -= len * (20 - 5 * PI);
    if (len == min(abs(s.x - t.x), abs(s.y - t.y)) + 1) {
        ans += 5 * PI;
    } 

    cout << ans << endl;


 
    return 0;
}

Measured memory_bytes: 2672
s=[]
for i in input().split():
 n=len(s)-1
 if i=='+':s.append(s[n-1]+s[n]);s.pop(n-1);s.pop(n-1)
 elif i=='-':s.append(s[n-1]-s[n]);s.pop(n-1);s.pop(n-1)
 elif i=='*':s.append(s[n-1]*s[n]);s.pop(n-1);s.pop(n-1)
 else:s.append(int(i))
print(*s)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000



int main(){
	
	int N;
	cin>>N;
	int K = 1<<N;
	vector<int> SS(K);
	multiset<int> S;
	for(int i=0;i<K;i++){
		cin>>SS[i];
		S.insert(SS[i]);
	}
	
	priority_queue<int> A,B;
	
	auto it = S.end();
	it--;
	A.push(*it);
	S.erase(it);
	
	while(S.size()!=0){
		while(A.size()!=0){
			int a = A.top();
			A.pop();
			auto it2 = S.lower_bound(a);
			//cout<<S.size()<<','<<a<<endl;
			if(it2==S.begin()){
				cout<<"No"<<endl;
				return 0;
			}
			it2--;
			B.push(*it2);
			S.erase(it2);
			B.push(a);
		}
		
		swap(A,B);
	}
	
	cout<<"Yes"<<endl;
				
	
	
	return 0;
}

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

int main()
{
    long long int n,m;
    cin>>n>>m;
    if((m/2)<n)
    {
        cout<<m/2;
    }
    else if(m/2==n)
        cout<<n;
    else
    {
        cout<<n+(m-2*n)/4;
    }
    return 0;
}


Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N, M = map(int, input().split())

    res = N * (N-1) // 2 + M * (M-1) // 2
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 64620
N , M , C= map(int,input().split())
B = list(map(int,input().split()))
A = []
for i in range(N):
	A.append(list(map(int,input().split())))
ans = 0
for i in range(N):
	sum = 0
	for j in range(M):
		sum += A[i][j] * B[j]
	if sum > -C:
		ans += 1
	
print(ans)

Measured memory_bytes: 3064
import sys
import numpy as np

c = [list(map(int, input().split())) for ii in range(3)]

a = np.empty(3)
b = np.empty(3)
c_n = np.array(c)

for a1 in range(101):
    a[0] = a1
    # a1 が決まると b1, b2, b3は決まる
    b = c_n[0, :] - a1
    # b1 が決まれば a2, a3 も決まる。
    a[1:] = c_n[1:, 0] - b[0]
    if a.min() < 0 or b.min() < 0:
        # この a1 では満たせない
        continue
    ab = a.reshape(3, 1) + b.reshape(1, 3)
    if np.all(c_n == ab):
        # 一致した
        print("Yes")
        break
else:
    print("No")

Measured memory_bytes: 13056
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int a[n+1];
    int i;
    int rest=1;
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(i=1;i<=n;i++){
        if(a[i]==rest){
            rest++;
        }
    }
    if(rest==1){
        printf("-1\n");
    }else{
        printf("%d\n",n-(rest-1));
    }
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
  public static void main (String[]args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    long n = 1l;
    for(int i = 1; i <= N; i++){
      n = (n * i) % 1000000007;
    }
    System.out.println(n);
  }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
char s[105], t[105];
char a[105], x[105];
int main() {
	scanf("%s", s);
	scanf("%s", t);
	for (int i = 0; i <= strlen(s) - 1; i++) a[i] = s[i];
	for (int i = 0; i <= strlen(t) - 2; i++) x[i] = t[i];
	if (strcmp(a, x) == 0) printf("Yes");
	else printf("No");
	return 0;
}

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

using namespace std;

typedef long long ll;

ll dp[51][51];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, a, b;
	cin >> n >> a >> b;
	vector<ll> v(n);
	map<ll, int> mp;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		mp[v[i]]++;
	}
	sort(v.rbegin(), v.rend());
	vector<ll> sum(n + 1, 0);
	ll ans_sum = 0;
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		sum[i] = sum[i - 1] + v[i - 1];
	}
	ans_sum = sum[a];
	cnt = a;
	for (int i = a + 1; i <= b; i++) {
		if (ans_sum * i < sum[i] * cnt) {
			ans_sum = sum[i];
			cnt = i;
		}
	}

	for (int i = 1; i <= 50; i++) dp[i][0] = 1;
	for (int i = 1; i <= 50; i++) {
		dp[i][i] = 1;
		for (int j = 1; j < i; j++) {
			dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
		}
	}
	int cnt2 = 0;
	for (int i = cnt - 1; i >= 0; i--) {
		if (v[i] != v[cnt - 1]) break;
		cnt2++;
	}
	ll pat = 0;
	cnt2--;
	for (int i = cnt; i <= b; i++) {
		if (ans_sum * i != sum[i] * cnt) break;
		ll tmp = 1;
		if (v[i - 1] == v[cnt - 1]) cnt2++;
		pat += dp[mp[v[cnt - 1]]][cnt2];
	}
	cout << fixed << setprecision(10) << (double)ans_sum / cnt << endl;
	cout << pat << endl;
	return 0;
}

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int main(){
  int n , t , x , y;
  scanf("%d",&n);
  int lastx = 0 , lasty = 0 , lastt = 0;
  rep(i,0,n) {
    scanf("%d%d%d",&t,&x,&y);
    int duration = t - lastt;
    int d = abs(x - lastx) + abs(y - lasty);
    if((d & 1) != (duration & 1) || d > duration) {
      puts("No");
      return 0;
    }
    tie(lastt , lastx , lasty) = tie(t , x , y);
  }
  puts("Yes");
  return 0;
}


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

using namespace std;

const int N = 10000 + 4;;

int n  , r;
int a[111];

int main()
{
    cin>>n;
    for(int i = 0;i<n;i++)
    {
        int t ;
        cin>>t ;
        a[t]++;
    }
    int sol  = 1e9;
    for(int i = 0;i<=100;i++)
    {
        int now = 0;
        for(int j = 0;j<=100;j++)
        {
            now+= a[j] *  pow( j - i , 2);
        }
        sol = min(sol , now);
    }
    cout<<sol;
    return 0;
}



Measured memory_bytes: 256
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break

    ans = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            k = x - (i + j)
            if k >= 1 and k <= n and k > j:
                ans += 1
    print(ans)


Measured memory_bytes: 5596