akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  vi a(n);
  int sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  int ans=sum;
  int suml=0;
  rep(i,n-1){
    suml+=a[i];
    sum-=a[i];  
    ans=min(ans,abs(sum-suml));
  }

  cout<<ans<<endl;



}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
    int K, A, B, count=0;
    scanf("%d%d%d",&K,&A,&B);
    for(int i=A;i<=B;i++){
        if(i%K==0){
            count++;
        }
    }
    if(count!=0)printf("OK\n");
    else printf("NG\n");
return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <cstring>
#define int long long
using namespace std;
int val[100001];
int wt[100001];


int knapsck(int n, int w){
    int dp[2][w+1];
    for (int i=0; i<=n; i++){
        for (int j = 0; j <= w; j++){
            // Base Case ...
            if(i==0 || j == 0){
                dp[i%2][j] = 0ll; 
                continue;
            }
            if(wt[i-1]>j)
                dp[i%2][j] = dp[(i-1+2)%2][j];
            else{
                dp[i%2][j] = max( 
                                dp[ (i-1+2)%2 ][j] , 
                                val[i-1] + dp[ (i-1+2)%2 ][ j - wt[i-1] ] );
            }
        }
    }
    return dp[n%2][w]; 
}

signed main() {
    int n, w;

    cin >> n >> w;
    for (int i=0;i<n; i++)
        cin >> wt[i] >> val[i];
    cout<<knapsck(n, w);
     
    return 0;
}

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

const int mod = 1e9 + 7;
const int N = 2e6 + 50;

inline int inc(int x, int y) { x += y - mod; return x + (x >> 31 & mod); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int fastpow(int x, int p)
{
	int res = 1;
	while (p)
	{
		if (p & 1) res = mul(res, x);
		x = mul(x, x);
		p >>= 1;
	}
	return res;
}
int n, K, fact[N], inv[N], pow26[N], pow25[N];
char s[N];
inline int Comb(int n, int m) { return mul(mul(fact[n], inv[m]), inv[n - m]); }
int main()
{
	scanf("%d%s", &K, s);
	n = strlen(s) + K;
	fact[0] = inv[0] = pow25[0] = pow26[0] = 1;
	for (int i = 1; i <= n; ++i) fact[i] = mul(fact[i - 1], i), pow25[i] = mul(pow25[i - 1], 25), pow26[i] = mul(pow26[i - 1], 26);
	inv[n] = fastpow(fact[n], mod - 2);
	for (int i = n - 1; i >= 0; --i) inv[i] = mul(i + 1, inv[i + 1]);
	int ans = 0;
	K = n - K;
	for (int i = K; i <= n; ++i) ans = inc(ans, mul(pow25[i - K], mul(pow26[n - i], Comb(i - 1, K - 1))));
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 36064
n = int(input())

p = []
l = [True for _ in range(55555 + 1)]#0, 1, 2, ..., 55555
l[0] = False
l[1] = False

for i in range(2, 55555 + 1):
    if l[i]:
        j = i + i
        while j < 55555 + 1:
            l[j] = False
            j += i

ans = []
cnt = 0
for i in range(2, 55555 + 1):
    if l[i]:
        if i % 10 == 1:
            cnt += 1
            ans.append(i)
            if cnt == n:
                break
print(*ans)

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

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

    for(int i=0;i<n;i++)
    {
        sum += a[i];
    }

    if(sum<H)
    {   
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 640
t=[100,101,102,103,104,105]
N=int(input())
for i in t:
        if N%i==0:
                print(1)
                exit()
a,b = divmod(N,100)
c,d = divmod(b,5)
if a >= c+1:
        print(1)
else: print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    ll N, K; cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());

    ll a = 0, b = 0, c = 0;
    rep(i, N) {
        if(A[i] < 0) ++a;
        else if(A[i] == 0) ++b;
        else ++c;
    }

    // 負の場合
    if(K <= a*c) {
        ll ng = -(1e18+1); ll ok = -1;
        auto check = [&](auto mid) {
            ll cnt = 0;
            rep(i, N) {
                if(A[i]>0) {
                    cnt += upper_bound(A.begin(), A.begin()+i, (mid-A[i]+1)/A[i]) - A.begin();
                }
            }
            return cnt>=K;
        };
        while(ok-ng > 1) {
            ll mid = (ok+ng) / 2;
            (check(mid)? ok:ng) = mid;
        }
        cout << ok << endl;
        //cout << check(-2) << endl;
    }
    else if(K > a*c + b*(a+c) + b*(b-1)/2) {
        ll ng = 0; ll ok = 1e18;
        auto check = [&](auto mid) {
            if(mid == 0) return false;
            ll cnt = 0;
            rep(i, N) {
                if(A[i] == 0) cnt += i;
                else if(A[i] < 0) {
                    cnt += (A.begin()+i) - lower_bound(A.begin(), A.begin()+i, mid/A[i]);
                }
                else {
                    cnt += upper_bound(A.begin(), A.begin()+i, mid/A[i]) - A.begin();
                }
            }
            return cnt>=K;
        };
        while(ok-ng > 1) {
            ll mid = (ok+ng) / 2;
            (check(mid)? ok:ng) = mid;
        }
        cout << ok << endl;
    }
    else {
        cout << 0 << endl;
    }

    
    return 0;
}

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

using namespace std;
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
#define debug(_x)		cerr << #_x << '=' << (_x) << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << (_x) << ' ' << #_y << '=' << (_y) << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << (_x) << ' '; cerr << endl;

#define HERE debug(__LINE__);

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;


int32_t main() {
	FAST_IO;
	
	string s, t;
	cin >> s >> t;
	
	t.pop_back();
	if (s == t) {
		cout << "Yes" << endl;
	} else cout << "No" << endl;
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)



int main() {
    string s, t;
    cin >> s >> t;
    
    int cnt = 0;
    rep(i,s.size()) {
        if(s[i] != t[i])
            cnt++;
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 3916
n, m = map(int, input().split())
x = [int(i) for i in input().split()]
if n >= m:
    print(0)
    exit()
x.sort()
dis = [abs(x[i+1] - x[i]) for i in range(m-1)]
dis.sort()
for _ in range(n-1): dis.pop(-1)
print(sum(dis))

Measured memory_bytes: 13840
from collections import Counter

def read():
    return [int(x) for x in input().split()]

N, M = read()

A = []
for _ in range(N):
    A.append(read())

res = N
for _ in range(M - 1):
    count_dict = Counter([a[0] for a in A])
    sport, count = count_dict.most_common(1)[0]
    res = min(res, count)
    for a in A:
        a.remove(sport)

print(res)


Measured memory_bytes: 4592
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    int n; cin >> n;
    string s, t;
    cin >> s >> t;

    /*if(s == t){
        cout << s.size() << endl;
        exit(0);
    }*/
    int ind;
    REP(i, n){
        bool flag = true;
        int j;
        for(j=0; j<n-i; j++){
            if(s[i+j] != t[j]){
                flag = false;
            } 
        }
        if(flag){
            ind = j;
            break;
        }
        else{
            ind = 0;        
        }
    }
    //cout << ind << endl;
    string res = s + t.substr(ind);
    cout << res.size() << endl;
}

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

Measured memory_bytes: 256
import sys

n = int(sys.stdin.readline().rstrip())
ab = map(int, sys.stdin.read().split())
ab = zip(ab, ab)

def main():
    c_a = c_b = 1
    for a, b in ab:
        t_a = (c_a + a - 1) // a
        t_b = (c_b + b - 1) // b
        t = max(t_a, t_b)
        c_a = a * t
        c_b = b * t
    
    ans = c_a + c_b
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N=1010,M=1000010,P=1e9+7;
const int inf=0x3f3f3f3f;
const int INF=0xcfcfcfcf;
const db eps=1e-9,pi=asin(1)*2;
inline ll read();
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
inline int ADD(int a,int b) { return a+b>=P?a+b-P:a+b; }
inline int MINUS(int a,int b) { return a-b<0?a-b+P:a-b; }
#define plus(a,b) a=ADD(a,b)
#define minus(a,b) a=MINUS(a,b)
#define mul(a,b) a=(1ll*a*(b))%P
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)

int n,m;
ll x[N],y[N];
ll d[N];
char s[N];
const char ch[]={'U','R','D','L'};

inline int work(ll &x,ll d)
{
	if(x>=0)
	{
		x-=d;
		return 0;
	}
	else
	{
		x+=d;
		return 2;
	}
}

#ifdef FILE
const int RS=1<<20;
char buf[RS],*p1=buf,*p2=buf;
#define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,RS,stdin),p1==p2)?EOF:*p1++
#endif
inline ll read()
{
	ll s=0;
	bool flag=false;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') flag=true;
	for(;'0'<=ch&&ch<='9';ch=getchar()) s=(s<<3)+(s<<1)+(ch^'0');
	if(flag) return -s;
	return s;
}

int main()
{
#ifdef FILE
	freopen(FILE ".in","r",stdin);
	freopen(FILE ".out","w",stdout);
#endif
	n=read(),m=32;
	for(int i=1;i<=n;i++) x[i]=read(),y[i]=read();
	for(int i=1;i<=m;i++) d[i]=1ll<<m-i;
	for(int i=1;i<n;i++)
	{
		if((x[i]+y[i]&1)!=(x[i+1]+y[i+1]&1))
		{
			printf("-1\n");
			return 0;
		}
	}
	if(x[1]+y[1]&1^1) d[++m]=1;
	printf("%d\n",m);
	for(int i=1;i<=m;i++) printf("%lld ",d[i]);
	putchar('\n');
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(abs(x[i])>abs(y[i])) s[j]=ch[work(x[i],d[j])+1];
			else s[j]=ch[work(y[i],d[j])];
		}
//		reverse(s+1,s+m+1);
		printf("%s\n",s+1);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define mn 100005
#define inf 4444444444444444444
#define mod 1000000009
#define FLN "test"
#define pii pair <int, int>
#define XX first
#define YY second

int n, a, X[55];
int dp[55][6010];

const int nn=2555;

signed main()
{
#ifdef lowie
	freopen(FLN".inp", "r", stdin);
	freopen(FLN".out", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>a;
	for (int i=1; i<=n; i++) 
	{
		cin>>X[i];
		X[i]-=a;
	}
	dp[0][nn]=1;
	for (int i=1; i<=n; i++)
	{
		for (int j=55; j<=5555; j++) dp[i][j]=dp[i-1][j]+dp[i-1][j-X[i]];
	}
	
	cout<<dp[n][nn]-1;
}

// PLEASE REMOVE "cout" AND "cerr" DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Code by low_
// Contact me via mail: dung.totuan01@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie_review/


Measured memory_bytes: 2560
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;		
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b) 
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

int main()
{
	long n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for (long i = 0; i < n; i++)
		cin >> a[i];
	sort(a.begin(), a.end());

	long p = k - 1;
	long q = 1;
	vector<mod> combi(n + 1);
	combi[0] = mod(0);
	combi[1] = mod(1);
	for (long i = 2; i <= n; i++)
	{
		combi[i].val = combi[i - 1].val;
		combi[i] *= p++;
		combi[i] /= q++;
	}
	for (long i = 2; i <= n; i++)
		combi[i] += combi[i - 1];

	mod result(0);
	for (long i = 0; i < n; i++)
	{
		mod now(a[i]);
		now *= n - k - i + 1>= 0 ? combi[n - k - i + 1] : 0;
		result -= now;
		now.val = a[i];
		now *= i - k + 2 >= 0 ? (combi[i - k + 2]) : 0;
		result += now;
	}

	printf("%lld", result.val);

	return 0;
}


Measured memory_bytes: 1792
fun main(args: Array<String>) {
    fun gcd(a: Long, b: Long): Long {
        return if (b > 0) gcd(b, a % b) else a
    }
    val (a, b, c, d) = readLine()!!.split(' ').map(String::toLong)
    var total = b - a + 1
    total -= b / c
    total += (a - 1) / c
    total -= b / d
    total += (a - 1) / d
    total += b / (d * c / gcd(d,c))
    total -= (a - 1) / (d * c / gcd(d,c))

    println(total)
}


Measured memory_bytes: 36428
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//int n=sc.nextInt();
		long x=sc.nextLong();
		long y=sc.nextLong();
		long z=sc.nextLong();
		//long k=sc.nextLong();
		//String s=sc.next();
		//long[] array=new long[n];
		int sum=0,buff,max=0,min=0;
		//int[] array=new int[l];
		//String s="",m="",h="";
		x=x-z;
		while(x>0) {
			x=x-(y+z);
			if(x<0)break;
			sum++;
			//if(x<=0)break;
		}
		//Arrays.sort(array)
		System.out.println(sum);
	}
}

//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));




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

#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  char atual, anterior;
  cin >> n >> anterior;
  //n--;
  int ans = 1;
  while (n--) {
    cin >> atual;
    while ((atual == anterior) && (n)) {
      cin >> atual;
      n--;
    }
    //cout << anterior << " " << atual << ' ' << ans << ende;
    anterior = atual;
    if (n) ans++;
    //if (n < 0) n = 0;
  }
  cout << ans << ende;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
bool CL_intersect(int ax,int ay,int bx,int by,int cx,int cy,int r){
	int acx=cx-ax;
	int acy=cy-ay;
	int bcx=cx-bx;
	int bcy=cy-by;
	int abx=bx-ax;
	int aby=by-ay;
	if(acx*acx+acy*acy>=r*r||bcx*bcx+bcy*bcy>=r*r){
		if(abx*acx+aby*acy<0){
			if(acx*acx+acy*acy<=r*r)return true;
		}else{
			if(abx*acx+aby*acy>abx*abx+aby*aby){
				if(bcx*bcx+bcy*bcy<=r*r)return true;
			}else if(acx*acx+acy*acy-(long long)(abx*acx+aby*acy)*(abx*acx+aby*acy)/(abx*abx+aby*aby)<=r*r)return true;
		}
	}
	return false;
}
bool inclusive(int ax,int ay,int bx,int by,int cx,int cy,int px,int py){
	bool ok1=true;
	bool ok2=true;
	if((bx-ax)*(py-ay)-(px-ax)*(by-ay)<0)ok1=false;
	if((bx-ax)*(py-ay)-(px-ax)*(by-ay)>0)ok2=false;
	if((cx-bx)*(py-by)-(px-bx)*(cy-by)<0)ok1=false;
	if((cx-bx)*(py-by)-(px-bx)*(cy-by)>0)ok2=false;
	if((ax-cx)*(py-cy)-(px-cx)*(ay-cy)<0)ok1=false;
	if((ax-cx)*(py-cy)-(px-cx)*(ay-cy)>0)ok2=false;
	return ok1||ok2;
}
double dist(int ax,int ay,int bx,int by,int px,int py){
	double dx=bx-ax;
	double dy=by-ay;
	double A=dx*dx+dy*dy;
	double B=dx*(ax-px)+dy*(ay-py);
	double t=-B/A;
	if(t<0)t=0;
	if(t>1)t=1;
	double tx=ax+dx*t,ty=ay+dy*t;
	return sqrt((px-tx)*(px-tx)+(py-ty)*(py-ty));
}
int main(){
	int a,b,c,d,e,f,g,h,r;
	while(scanf("%d%d",&a,&b),a||b){
		scanf("%d%d%d%d%d%d%d",&c,&d,&e,&f,&g,&h,&r);
		if((a-g)*(a-g)+(b-h)*(b-h)<=r*r&&(c-g)*(c-g)+(d-h)*(d-h)<=r*r&&(e-g)*(e-g)+(f-h)*(f-h)<=r*r)printf("b\n");
		else if(dist(a,b,c,d,g,h)>(double)r-0.000001&&dist(a,b,e,f,g,h)>(double)r-0.000001&&dist(e,f,c,d,g,h)>(double)r-0.000001&&inclusive(a,b,c,d,e,f,g,h))printf("a\n");
		else if(CL_intersect(a,b,c,d,g,h,r)||CL_intersect(a,b,e,f,g,h,r)||CL_intersect(e,f,c,d,g,h,r))printf("c\n");
		else printf("d\n");
	}
}

Measured memory_bytes: 1016
#define _USE_MATH_DEFINES

#include<cstdio>
#include<cmath>

int main(){
    double r;
    scanf("%lf",&r);

    double area = r * r * M_PI;
    double len = r * 2 * M_PI;

    printf("%f %f\n", area, len);

    return 0;
}


Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);i++)
#define FORE(x,arr) for(auto &x:arr)
#define FOR(i,a,n) for(int i=a;i<(int)(n);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;

ll fact[200001];
ll fact_inv[200001];
ll bin_pow(ll a,ll b,ll mod) {
    if(a==0) return 1;
    a%=mod;
    ll product=1;
    while(b>0) {
        if(b&1) {
            product *= a;
            product %= mod;
        }
        a *= a;
        a %= mod;
        b >>= 1;
    }
    return product%mod;
}
void init_fact(ll max,ll mod) {
    fact[0]=1, fact_inv[0]=1;
    FOR(i,1,max) {
        fact[i]=(fact[i-1]*i)%mod;
        fact_inv[i]=bin_pow(fact[i],mod-2,mod);
    }
}
inline ll nCr_mod(ll n,ll r,ll mod) {
    ll ret = fact[n] * fact_inv[r] % mod*fact_inv[n-r] % mod;
    return ret;
}

int main(int argc, char const *argv[]) {
    const int MOD=1e9+7;
    ll H,W,A,B;
    cin>>H>>W>>A>>B;
    init_fact(H+W,MOD);

    ll ans = 0;
    FOR(x,B,W) {
        // a = (x+H-A-1)C(x)
        // b = (A-1+W-x-1)C(A-1)
        ans += (nCr_mod(x+H-A-1,x,MOD)%MOD*nCr_mod(A+W-x-2,A-1,MOD)%MOD)%MOD;
        ans %= MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]

xyh.sort(key=lambda x: x[2], reverse=True)
ans = [None] * 3
for cx in range(101):
    for cy in range(101):
        x0, y0, h0 = xyh[0]
        top = h0 + abs(x0 - cx) + abs(y0 - cy)
        bl = True
        for x, y, h in xyh[1:]:
            h_calc = max(top - abs(x - cx) - abs(y - cy), 0)
            if h_calc != h:
                bl = False
                break

        if bl:
            ans = [cx, cy, top]

print(*ans)


Measured memory_bytes: 9164
#include <bits/stdc++.h>
#define int long long
#define m_k make_pair
using namespace std;
const int N=2*1e5+100;
int n,a[N],b[N],vi[N],ans;
priority_queue <pair<int,int> > q;
inline int pre(int x){return((x==1)?n:x-1);}
inline int suc(int x){return((x==n)?1:x+1);}
inline bool check(int x){return(b[x]>=b[pre(x)]+b[suc(x)]&&b[x]>a[x]);}
signed main()
{
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for (int i=1;i<=n;i++) scanf("%lld",&b[i]);
	bool bl=1;
	for (int i=1;i<=n;i++) if (b[i]<a[i]) bl=0;
	if (!bl)
	{
		printf("-1\n");
		return 0;
	}
	for (int i=1;i<=n;i++)
	{
		if (check(i))
		{
			vi[i]=1;
			q.push(m_k(i,b[i]));
		}
	}
	bl=1;
	while (!q.empty())
	{
		int x=q.top().first;
		q.pop();
		vi[x]=0;
		int delta=b[x]-a[x];
		delta/=b[pre(x)]+b[suc(x)];
		ans+=delta;
		b[x]-=(b[pre(x)]+b[suc(x)])*delta;
		if (delta==0)
		{
			bl=0;
			break;
		}
		if (check(pre(x)) && !vi[pre(x)]) vi[pre(x)]=1,q.push(m_k(pre(x),b[pre(x)]));
		if (check(suc(x)) && !vi[suc(x)]) vi[suc(x)]=1,q.push(m_k(suc(x),b[suc(x)]));
	}
	if (!bl)
	{
		printf("-1\n");
		return 0;
	}
	for (int i=1;i<=n;i++) if (a[i]!=b[i]) bl=0;
	if (!bl)
	{
		printf("-1\n");
		return 0;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 9940
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                count += 1
print(count)  

Measured memory_bytes: 3060
#https://atcoder.jp/contests/agc008/submissions/15248942
import sys
 
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

X = ini()
if X >= 30:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9184
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! flush {
    () => {
        std::io::stdout().flush().unwrap();
    };
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn uabs(x: usize, y: usize) -> usize {
    if x > y {
        x - y
    } else {
        y - x
    }
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let x: usize = sc.cin::<usize>() - 1;
    let y: usize = sc.cin::<usize>() - 1;
    let mut ks: Vec<usize> = vec![0; n];
    for u in 0..n {
        for v in u + 1..n {
            let d = min!(uabs(u, v), uabs(u, x) + 1 + uabs(v, y));
            ks[d] += 1;
        }
    }
    for &c in ks[1..].iter() {
        put!(c);
    }
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


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

void draw_rect(int w,int h){
    for(int i=0;i<w;i++)
        cout << "#";
    cout << endl;
    for(int i=0;i<h-2;i++){
        cout << "#";
        for(int j=0;j<w-2;j++){
            cout << ".";
        }
        cout << "#" << endl;
    }
    for(int i=0;i<w;i++)
        cout << "#";
    cout << endl;
}

int main(){
    int w,h;
    while(1){
        cin >> h >> w;
        if (w==0 && h==0) break;
        draw_rect(w,h);
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3068
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=200005;
typedef long long ll;
int n,a[N];
int z[N];
bool check(int x){
    for(int i=1;i<=2*n-1;i++){
        z[i]=a[i]>=x;
    }
    for(int i=0;i<n-1;i++){
        int s0=0,s1=0;
        if(z[n-i]==1&&z[n-i-1]==1)
            return 1;
        if(z[n-i]==0&&z[n-i-1]==0)
            return 0;
        if(z[n+i]==1&&z[n+i+1]==1)
            return 1;
        if(z[n+i]==0&&z[n+i+1]==0)
            return 0;
    }
    return z[1];
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=2*n-1;i++)
        scanf("%d",&a[i]);
    int l=1,r=2*n;
    while(l+1<r){
        int mid=(l+r)>>1;
        if(check(mid))
            l=mid;
        else
            r=mid;
    }
    printf("%d\n",l);
}


Measured memory_bytes: 1792
#include <iostream>

#define MOD 1000000007

typedef long long ll;

using namespace std;

ll eleva(ll num, ll elevado){
    ll ans = 0;
    
    if(elevado == 0) return 1;

    if(elevado % 2 == 0){
        
        ans = eleva(num, elevado/2);        
        ans *= ans;
        return ans % MOD;
    }else{

        ans = eleva(num, elevado/2);
        ans = ((ans * ans) % MOD) * num;    
        return ans % MOD;
    }
}

ll subMod(ll x, ll y){

    ll ans = x - y;

    if(ans < 0)
        return ans + MOD;
    else
        return ans % MOD;
}

// n é o total
// k é qntos eu posso escolher
// Combinação de n escolhendo k coisas
// C = (n!) / (n - k)!(k)!
ll comb(ll n, ll k){
    ll ans = 1, deno = 1, res;

    // calculando a parte de cima da função da combinação
    for(ll i = n; i >= (n - k + 1); i--){
        ans = (ans * i) % MOD;
    }

    for(ll i = 1; i <= k; i++){
        deno = (deno * i) % MOD;
    }

    // inversa modular: Um número que vc tem q multiplicar a ele
    // para funcionar como se fosse uma divisão    
    // Por q estamos usando MOD não podemos fazer a divisão ali em cima normalzinha
    // entao vai usar o pequeno teorema d fermat
    // ans * inverso modular do denominador
    
    res = (ans * eleva(deno, MOD - 2)) % MOD;

    return res;
}

int main(){

    ll t, a, b, tot = 0;
    cin >> t >> a >> b;

    tot = eleva(2, t);
    tot = subMod(tot, 1);

    tot = subMod(tot, comb(t, a));
    tot = subMod(tot, comb(t, b));

    cout << tot << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)

	N, M := getInt(), getInt()
	a := make([]int, M)
	for i := 0; i < M; i++ {
		a[i] = getInt()
	}
	sort.Ints(a)
	d := make([]int, 0)
	for i := 1; i < len(a); i++ {
		d = append(d, a[i]-a[i-1])
	}
	sort.Ints(d)
	// out(d, N)
	ans := 0
	for i := 0; i < len(d)-(N-1); i++ {
		ans += d[i]
	}
	out(ans)
}


Measured memory_bytes: 6912
/** 
 *                                                                   
 *   |    |                        ,   .              ,--.,--.,--.,--.
 *   |    |    ,---..    ,,---.    |   |,---..   .      -||  ||  ||  |
 *   |    |    |   | \  / |---'    `---'|   ||   |       ||  ||  ||  |
 *   `    `---'`---'  `'  `---'      |  `---'`---'    `--'`--'`--'`--'
 *                                   `                                
**/
#include <bits/stdc++.h>
using namespace std;

int n, m, x, y;
vector<vector<int>> adj;

int cnt[100005];

int dfs(int node) {
	if (cnt[node] != -1) return cnt[node];

	cnt[node] = 0;
	for (int i = 0; i < adj[node].size(); i++) {
		cnt[node] = max(cnt[node], dfs(adj[node][i]) + 1);
	}

	return cnt[node];
}

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

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	cin >> n >> m;
	adj.resize(n);

	for (int i = 0; i < m; i++) {
		cin >> x >> y; --x; --y;
		adj[x].push_back(y);
	}

	int ans = 0;
	memset(cnt, -1, sizeof(cnt));
	for (int i = 0; i < n; i++) {
		ans = max(ans, dfs(i));
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 7424
#include <map>
    #include <iostream>
    #include <string>
    #include <vector>
    #include <algorithm>
    using namespace std;
     
    typedef long long int ll;
     
    int main() {
        int n; cin >> n;
        int m = 0;
        while(m < n) {
            m+=1000;
        }
        cout << m - n << endl;
     
        return 0;
    }

Measured memory_bytes: 3156
from collections import defaultdict
n,k,l = map(int,input().split())
road = [list(map(int,input().split())) for i in range(k)]
train = [list(map(int,input().split())) for i in range(l)]
rg = [[] for i in range(n+1)]
rv = [0 for i in range(n+1)]
tg = [[] for i in range(n+1)]
tv = [0 for i in range(n+1)]
def connect(road,rg,rv,):
  for a,b in road:
    rg[a].append(b)
    rg[b].append(a)
  cnt = 0
  for i in range(1,n+1):
    if rv[i] == 0:
      cnt += 1
      stack = [i]
      while stack:
        x = stack.pop()
        rv[x] = cnt
        for y in rg[x]:
          if rv[y] == 0:
            stack.append(y)
            rv[y] = cnt
connect(road,rg,rv)
connect(train,tg,tv)
condc = defaultdict(list)
for i in range(1,n+1):
  cr = rv[i]
  ct = tv[i]
  condc[(cr,ct)].append(i)
ans = []
for i in range(1,n+1):
  cr = rv[i]
  ct = tv[i]
  ans.append(len(condc[(cr,ct)]))
print(*ans)

Measured memory_bytes: 144464
n = int(input())
flag = 0
last = 0
for _ in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        flag += 1
        last = d1
    if last != d1:
        flag = 0
    if flag == 3:
        print("Yes")
        exit(0)
print("No")

Measured memory_bytes: 9180
#include<stdio.h>
int main(void)
{
	int a,b;
	int x,z;
	while(scanf("%d%d",&a,&b)!=EOF) {
		x=a+b;
		z=1;
		while(x>=10) {
			x=x/10;
			z=z+1;
		}
		printf("%d\n",z);
	}
	
	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<string.h>
int main()
{
    char N[3];
    int i;
    scanf("%s",&N);
    for(i=0;i<3;i++)
    {
    if(N[i]=='7')
    {
        printf("Yes");
    return 0;
    }
    }
    printf("No");

}

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

int main() {
  int N;
  ll product = 1;
  ll const MAX = 1000000000000000000;
  cin >> N;
  vector<ll> an(N);

  rep(i, N) {
    cin >> an.at(i);
    if (an.at(i) == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  rep(i, N) {
    if(an.at(i) > MAX / product) {
      product = -1;
      break;
    }
    product *= an.at(i);
  }
  cout << product << endl;
}


Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
	par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
  int a;
  cin>>a;
  V<int> b={111,222,333,444,555,666,777,888,999};
  fo(i,9){
    if(a<=b[i]){
      cout<<b[i]<<endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

struct Point {
    int x, y;
    double angle;
    bool operator<(const Point &p) {
        return angle < p.angle;
    }
};

int main() {
    FAST_IO();
    int N; cin >> N;
    vector<Point> v(N);
    rep(i, N) {
        cin >> v[i].x >> v[i].y;
        v[i].angle = atan2(v[i].y, v[i].x);
    }
    sort(all(v));
    ll cx = 0, cy = 0;
    ll ans = 0;
    rep(i, N) {
        cx = cy = 0;
        rep(k, N) {
            int j = (i + k) % N;
            cx += v[j].x;
            cy += v[j].y;
            ans = max(ans, cx * cx + cy * cy);
        }
    }
    cout.precision(12);
    cout << sqrt(ans) << "\n";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

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

  ll ans = 0LL;
  ll cntl = 0LL;
  ll cntr = 0LL;
  ll last_add = 0LL;

  if (S[0] == '<') cntr++;
  else cntl++;

  for (int i = 1; i < S.length(); i++) {
    if ((S[i] == '<') && (S[i-1] == '>')) {
      ans += max(cntl, cntr);
      ans += cntl * (cntl-1) / 2;
      ans += cntr * (cntr-1) / 2;
      cntl = 0LL;
      cntr = 0LL;
    }

    if (S[i] == '<') cntr++;
    else cntl++;
  }

  int lid = S.length()-1;
  if (cntl == 0LL) {
    ans += cntr * (cntr+1) / 2;
  } else if (cntr = 0LL) {
    ans += cntl * (cntl+1) / 2;
  } else {
    ans += max(cntl, cntr);
    ans += cntl * (cntl-1) / 2;
    ans += cntr * (cntr-1) / 2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
string s;
int lens,p,f;
int main(){
	cin>>s;
	lens=s.size();
	p=lens;f=1;
	while(f and p>0){
		if(p-7>=0 and s.substr(p-7,7)=="dreamer")p-=7;
		else if(p-5>=0 and s.substr(p-5,5)=="dream")p-=5;
		else if(p-5>=0 and s.substr(p-5,5)=="erase")p-=5;
		else if(p-6>=0 and s.substr(p-6,6)=="eraser")p-=6;
		else f=0;
	}
	if(f)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;	
}

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

#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define f(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pc __builtin_popcount // counts number of 1's in bin(num)

const double pi = 2*acos(0.0);
//__gcd(n1, n2);
//cout << fixed;
//cout << setprecision(6); //fixes # of dp



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
    cout.tie(0);
	
    int h, n;
    cin >> h >> n;
    int a[n+1], b[n+1], dp[h+1];
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    memset(dp, inf, sizeof(dp));
    dp[0] = 0;
    f(i, 0, n){
        cin >> a[i] >> b[i];
        f(j, 0, h){
            // dp cur = min(cur,
            // index = health lost, val is min consumption 
            dp[min(h, j + a[i])] = min(dp[min(h,j+a[i])], b[i] + dp[j]);            
        }
    }
    cout << dp[h];   
}   








Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  i64 N; cin >> N;
  i64 ans = 0;
  for (i64 i = 1; i*i <= N; ++i) {

    chmax(ans, i*i);
  }

  cout << ans  << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
#define all(x) x.begin(),x.end()
const int inf=0x3f3f3f3f;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll X; cin>>X;
    for(ll i=-5000;i<=5000;i++){
        for(ll j=-5000;j<=5000;j++){
            if(i*i*i*i*i-j*j*j*j*j==X){
                cout<<i<<' '<<j;
                return 0;
            }
        }
    }
    cout<<"wtf";
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define start int t;cin>>t;while(t--)

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
      int k;
      cin>>k;
      int a , b;
      cin>>a>>b;
      string ans = "";
      int tem = b%k;
      tem = b-tem;
      if(b%k==0)
      {
          ans = "OK";
      }else if(tem>=a)
      {
           ans = "OK";
      }else
      {
          ans = "NG";
      }
    
      std::cout << ans << std::endl;
	return 0;
}


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 10001
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define int long long
const double PI = acos(-1);
typedef pair<int, int> P;

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

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

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}
vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i - 1);
            if (i * i != n)
            {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

signed main()
{
    int N, K;
    cin >> N >> K;
    vector<bool> snk(N, false);
    rep(i, K)
    {
        int d;
        cin >> d;
        rep(j, d)
        {
            int A;
            cin >> A;
            A--;
            snk[A] = true;
        }
    }
    int ans = 0;
    rep(i, N)
    {
        if (!snk[i])
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3732
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const int big=1e9+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint tensort(vector<llint>& in){
	//転倒数を計算しながらソートします
	llint ans=0;
	llint i,j,n=in.size(),gen=1;
	vector<llint>iti(n);
	for(gen=1;gen<n;gen*=2){
		llint now=0;
		for(i=0;i<n;i+=gen*2){//i,i+gen
			llint hid=i,mig=i+gen,end=min(n,i+gen+gen);
			if(n<=i+gen){for(j=i;j<n;j++){iti[j]=in[j];}continue;}
			while(now!=end){
				if(mig==end){iti[now]=in[hid];now++;hid++;}//左
				else if(hid==i+gen){iti[now]=in[mig];now++;mig++;}//右
				else if(in[hid]<in[mig]){iti[now]=in[hid];now++;hid++;}//左
				else{ans+=i+gen-hid;iti[now]=in[mig];now++;mig++;}//右
			}
		}
		swap(in,iti);
	}
	return ans;
}
int main(void){
	string str;cin>>str;
	array<llint,26> mzi={0};
	array<llint,26> cou={0};
	char man='!';
	llint n,i,ans=0;n=str.size();
	for(i=0;i<n;i++){mzi[str[i]-'a']++;}
	for(i=0;i<26;i++){
		if(mzi[i]%2==1){
			if(man=='!'){man='a'+i;}
			else{cout<<"-1"<<endl;RE;}//不可能
		}
	}
	string hid;
	string mig;
	//真ん中を超えて動く数を足す
	
	for(i=0;i<n;i++){
		char c=str[i]-'a';
		if(2*cou[c]+1<mzi[c]){ans+=i-(llint)hid.size();hid.pub(c+'a');}
		else{ans+=n/2 +(llint)mig.size()-i;mig.pub(c+'a');}
		cou[c]++;
	}
	reverse(hid.begin(),hid.end());
	ans/=2;
	vector<llint> in(mig.size());
	deque<llint> alf[26];
	if(man!='!'){alf[man-'a'].pub(-1);}
	for(i=0;i<hid.size();i++){
		char c=hid[i]-'a';
		alf[c].pub(i);
	}
	for(i=0;i<mig.size();i++){
		char c=mig[i]-'a';
		in[i]=alf[c].front();
		alf[c].pof();
	}
	ans+=tensort(in);
	cout<<ans<<endl;
	RE;
}

Measured memory_bytes: 3700
#!/usr/bin/env python3
import sys


def solve(n: int, m: int):
    print((n - 1) * (m - 1))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    m = int(next(tokens))  # type: int
    solve(n, m)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int a[10],x,aa,bb;

int main()
{
    for(int i=1; i<=6; i++)
    {
        cin>>x;
        a[x]++;
    }
    for(int i=1; i<=6; i++)
    {
        if(a[i]==1) aa++;
        if(a[i]==2) bb++;

    }

    if(aa==2 && bb==2) cout<<"YES"<<endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
int N, r, ans=0; string c; cin >> N >> c;
REP(i, N){ if(c[i]=='R'){r++;} }
REP(i, r){ if(c[i]=='W'){ans++;} }
cout << ans << "\n";
}

Measured memory_bytes: 3712