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

int main() {
  string num;
  cin >> num;
  if (num.at(0) == num.at(1) && num.at(1) == num.at(2)) {
    cout << "Yes" << endl;
  }
  else if (num.at(1) == num.at(2) && num.at(2) == num.at(3)) {
    cout << "Yes" << endl;
  } 
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
using namespace std;

//ABC128 B
int main() {
	int N;
	cin >> N;
	// map<string, int> dict;
	vector<pair<string, pair<int, int>>> vec;
	string city;
	int point;
	for (int i=0; i<N; i++) {
		cin >> city >> point;
		// dict[city] = make_pair(point, i);
		vec.push_back(make_pair(city, make_pair(-point, i+1)));
	}
	sort(vec.begin(), vec.end());
	for (int i=0; i<N; i++) {
		cout << vec[i].second.second << endl;
	}
}

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

typedef long long ll;
using namespace std;

int main(){
	int a[5];
	for(int i=0;i < 5;i++)cin >> a[i];
	int k;
	cin >> k;
	if(a[4]-a[0] > k ){
		cout << ":(";
	}else{
		cout << "Yay!";
	}
	return 0;
}

Measured memory_bytes: 384
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    int A, B, C;  cin >> A >> B >> C;

    int ans = 0;
    if (A+B >= C-1) {
        ans += C;
        ans += B;
    } else {
        ans += A + B + 1;
        ans += B;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int x[100] = {};

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

    sort(x,x+n,greater<int>());

    int a = 0,b = 0;

    for(int i = 0; i < n; ++i){
        if(i % 2 == 0){
            a += x[i];
        }else{
            b += x[i];
        }
    }

    cout << a - b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

#define INF 100000000001

typedef long long ll;

ll n, s;

ll f(ll x, ll k){
	ll ret = 0;
	while(x){
		ret += (x % k);
		x /= k;
	}
	return ret;
}

int main(){
	std::cin >> n >> s;
	
	if(n == s){
		std::cout << n + 1 << std::endl;
		return 0;
	}
	
	if(s > n){
		std::cout << -1 << std::endl;
		return 0;
	}
	
	for(ll i = 2; i * i <= n; ++i){
		if(f(n, i) == s){
			std::cout << i << std::endl;
			return 0;			
		}
	}
	
	ll ans = INF;
	for(ll p = 1; p * p <= n; ++p){
		ll b = (n - s) / p + 1;
		if(b == 1)continue;
		if(f(n, b) == s)ans = std::min(ans, b);
	}
	
	if(ans != INF){
		std::cout << ans << std::endl;
		return 0;
	}
	
	std::cout << -1 << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	string s;
	int a, b, c, d;
	cin >> s;
	a = s[0] - '0';
	b = s[1] - '0';
	c = s[2] - '0';
	d = s[3] - '0';
	REP(i, 8) {
		int sum = a;
		bool s1 = i & 4, s2 = i & 2, s3 = i & 1;
		sum += b * (s1 ? 1 : -1);
		sum += c * (s2 ? 1 : -1);
		sum += d * (s3 ? 1 : -1);
		if (sum == 7) {
			cout << a
				<< (s1 ? '+' : '-') << b
				<< (s2 ? '+' : '-') << c
				<< (s3 ? '+' : '-') << d
				<< "=7" << endl;
			return 0;
		}
	}
	return 0;
}
 

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

int main(){
    int N, K;
    string S;
    cin >> N >> K >> S;
    int score = 0;
    for (int i = 0; i < N-1; ++i) {
        if (S[i] == S[i+1]) score++;
    }
    int ans = min(score + 2*K, N-1);
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>

int main()
{
	long N, A, B;
	std::cin >> N >> A >> B;
	long sum;
	if (N % (A + B) < A) {
		sum += N % (A + B);
	}
	else {
		sum += A;
	}
	N /= A + B;
	sum += N * A;
	std::cout << sum;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define heap_min priority_queue<int,vector<int>,greater<int>>
#define heap_max priority_queue<int>
#define precision(x) cout << setprecision(x) << fixed;
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i] << " "; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
map<int,int>mp;
void cal(int n)
{
    for(int i = 1 ; i<= (int)sqrt(n)+1 ; i++ ){
      for(int j = 1 ; j<=(int)sqrt(n)+1 ; j++){
        for(int k = 1 ; k<=(int)sqrt(n)+1; k++){
          int res = (i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i);
          if(res>n){
          	break;
		  }
          mp[res]++;
        }
      }
    }
}
int32_t main()
{
   fast;
   
   int n;
   cin >> n;
   cal(n);
   for(int i =1 ; i<=n ; i++){
   	cout << mp[i] << "\n";
   }
}


Measured memory_bytes: 4172
fn main() {
        let (dist, k): (i32, i32) = {
            let a: i32 = read();
            let (_, _, _): (i32, i32, i32) = (read(), read(), read());
            let e: i32 = read();
     
            (e - a, read())
        };
     
        if dist <= k {
            println!("Yay!");
        } else {
            println!(":(");
        }
    }
    
    fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n, a[100]; a[0]=2;
    cin >> n;
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    for(int i = 1; i < 100; i++) {
        a[i] = a[i-1] * 2;
    }
    for(int i = 0; i < 100; i++) {
        if(n < a[i+1] && n >= a[i]) {
            cout << a[i];
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int x,y;
    cin >> x >> y;
    string s[x];
    for (int i=0;i<x;i++){
        cin >> s[i];
    }
    for (int i=0;i<x;i++){
        cout << s[i] << endl;
        cout << s[i] << endl;
    }
    return 0;
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    string s;
    cin>>s;
    if(s=="SUN") cout<<7;
    else if(s=="MON") cout<<6;
    else if(s=="TUE") cout<<5;
    else if(s=="WED") cout<<4;
    else if(s=="THU") cout<<3;
    else if(s=="FRI") cout<<2;
    else if(s=="SAT") cout<<1;
    return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    int n = 1001;
    rep(i,n){
        int s = i*0.1;
        int t = i*0.08;
        if(a == t && b == s){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char a,b,c,d,e,f;
int main()
{
	cin>>a>>b>>c>>d>>e>>f;
	if ((a==f) && (b==e) && (c==d)) cout<<"YES";
	    else cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN=100000+5;
int n,a,b,c,dp[MAXN][3];

int main(){
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a>>b>>c;
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int n;
int x[10000][2];
int V[1 << 16];
vector<pii> comp;
int sz;
vector<int> edge[1 << 16];
vector<int> redge[1 << 16];
int init(int i, int s, int e) {
    if (s == e) return V[i] = ~comp[s].se + n;
    V[i] = sz++;
    int m = (s + e) / 2;
    int L = init(i << 1, s, m);
    int R = init(i << 1 | 1, m + 1, e);
    edge[V[i]].push_back(L);
    edge[V[i]].push_back(R);
    return V[i];
}

void add_edge(int i, int s, int e, int x, int y, int v) {
    if (e < x || y < s) return;
    if (x <= s && e <= y) {
        edge[v + n].push_back(V[i]);
        return;
    }
    int m = (s + e) / 2;
    add_edge(i << 1, s, m, x, y, v);
    add_edge(i << 1 | 1, m + 1, e, x, y, v);
}

int vis[1 << 16];
int scc[1 << 16];
vector<int> st;
void dfs1(int x) {
    vis[x] = 1;
    for (int i : redge[x]) {
        if (vis[i]) continue;
        dfs1(i);
    }
    st.push_back(x);
}

void dfs2(int x, int c) {
    scc[x] = c;
    for (int i : edge[x]) {
        if (scc[i]) continue;
        dfs2(i, c);
    }
}

int check(int d) {
    st.clear();
    for (int i = 0; i < (1 << 16); ++i) edge[i].clear(), redge[i].clear(), vis[i] = scc[i] = 0;
    sz = n + n;
    init(1, 0, n + n - 1);
    for (int i = 0, j = 0, k = 0; i < n + n; ++i) {
        while (comp[j].fs <= comp[i].fs - d) ++j;
        while (k + 1 < n + n && comp[k + 1].fs < comp[i].fs + d) ++k;
        add_edge(1, 0, n + n - 1, j, i - 1, comp[i].se);
        add_edge(1, 0, n + n - 1, i + 1, k, comp[i].se);
    }
    for (int i = 0; i < sz; ++i) {
        for (int j : edge[i]) {
            redge[j].push_back(i);
        }
    }
    for (int i = 0; i < sz; ++i) {
        if (vis[i]) continue;
        dfs1(i);
    }
    int ord = 0;
    for (int i = sz; i--; ) {
        if (scc[st[i]]) continue;
        dfs2(st[i], ++ord);
    }
    for (int i = 0; i < n; ++i) {
        if (scc[i + n] == scc[~i + n]) return 0;
    }
    return 1;
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x[i][0] >> x[i][1];
        comp.emplace_back(x[i][0], i);
        comp.emplace_back(x[i][1], ~i);
    }
    sort(comp.begin(), comp.end());
    int s = 0, e = 1e9;
    while (s < e) {
        int m = (s + e + 1) / 2;
        if (check(m)) s = m;
        else e = m - 1;
    }
    printf("%d\n", s);
    return 0;
}

Measured memory_bytes: 19068
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <memory.h>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;





int i,j;
int nn,mm;
double l[100];
double a[100];
double b[100];
double core[100][100];

int s[100];
double maxx=0.0;
void print(int N)
{
     double num=0.0;
for(int ii=1;ii<=N;ii++)
{
 for(int jj=1;jj<=N;jj++)
{
 //printf("ii=%d jj=%d\n",s[ii],s[jj]);
 num+=core[s[ii]][s[jj]];
}
//printf("\n");
}
 if(num>maxx){maxx=num;}
}
void zuhe(int a,int n,int M,int N)
{
if(n<=N)
{
int i;
for(int ii=a;ii<=M-N+n;ii++)
{
s[n]=ii;
if(n==N)
print(N);
else
zuhe(a+1,n+1,M,N);
a++;
}
}
}



int main()
{
scanf("%d%d",&nn,&mm);
if(mm==1){printf("0.00000000000000000000\n");return 0;}
for(i=1;i<=nn;i++)
{
    scanf("%lf%lf%lf",&l[i],&a[i],&b[i]);
}
int topp=0;

for(i=1;i<=nn;i++)
{
               // printf("%.20f\n",(l[i]*l[i]+a[i]*a[i]+b[i]*b[i]));
}

for(i=1;i<=nn;i++)
{
    for(j=1;j<=nn;j++)
    {
       
       core[i][j]=((l[i]-l[j])*(l[i]-l[j])+(a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j]));
       //printf("%.2f ",core[i][j]);
       
    }
    //printf("\n");
}
zuhe(1,1,nn,mm);
printf("%.20f\n",maxx/2);

//system("pause");
    return 0;
}

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


int main() {
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i <= (n - 1) / 4 ; i++){
        if(s[i] != s[(n - 1) / 2 - 1 - i]){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i = (n + 3) / 2  - 1; i <= (n + 1) * 3 / 4 - 1; i++){
        if(s[i] != s[n - 1 - i]){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i = 0 ; i <= n / 2 ; i++){
        if(s[i] != s[n - 1 - i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
use std::collections::BinaryHeap;
use std::cmp::Ordering;

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

const INF: usize = 1_000_000_000;

fn main() {
    let hw = readn::<usize>(" ");
    let h = hw[0];
    let _w = hw[1];
    let c = (0..10).map(|_| readn::<usize>(" ")).collect::<Vec<Vec<usize>>>();
    let mut count = vec![0; 10];
    for _ in 0..h {
        let av = readn::<isize>(" ");
        for &a in av.iter() {
            if a >= 0 {
                count[a as usize] += 1;
            }
        }
    }

    let mut dist = vec![INF; 10];
    let mut que = BinaryHeap::new();
    dist[1] = 0;
    que.push(Rev((0, 1)));
    while let Some(Rev((d, i))) = que.pop() {
        if dist[i] != d {
            continue;
        }
        for j in 0..10 {
            if j == i {
                continue;
            }
            if dist[j] > dist[i] + c[j][i] {
                dist[j] = dist[i] + c[j][i];
                que.push(Rev((dist[j], j)));
            }
        }
    }

    let mut ans = 0;
    for i in 0..10 {
        ans += dist[i] * count[i];
    }

    println!("{}", ans);
}

Measured memory_bytes: 4352
sx,sy,tx,ty=map(int,input().split())
ans=""
width=tx-sx
length=ty-sy
A,B,C,D="U"*length,"R"*width,"D"*length,"L"*width
for i in range(2):
    if i==0:ans +=A+B+C+D
    else:ans +="L"+A+"UR"+B+"DR"+C+"DL"+D+"U"
print(ans)

Measured memory_bytes: 3060
// #pragma GCC optimize(3)
#include "bits/stdc++.h"
using namespace std;
#ifdef __attribute__
#define fast __attribute__((optimize(3), target("no-ieee-fp,arch=corei7")))
#define inline fast inline
#else
#define fast
#endif
namespace io
{
	// #define USE_FREAD_IO
#ifdef USE_FREAD_IO
#define BUF_SIZE 5000010
	char buf[BUF_SIZE]; int cur = BUF_SIZE; FILE *in = stdin;
	inline char gnc()
	{
		if (cur == BUF_SIZE) { fread(buf, BUF_SIZE, 1, in); cur = 0; }
		return buf[cur++];
	}
#else
	inline char gnc()
	{
		return (char)getchar();
	}
#endif
	template<typename T>
	inline void gi(T &dx)
	{
		dx = 0;
		int yc = gnc();
		bool nega = false;
		while (yc < '0' || yc > '9') { nega = (yc == '-' ? true : nega); yc = gnc(); }
		while (yc >= '0' && yc <= '9') { dx = (T)(dx * 10 + yc - '0'); yc = gnc(); }
		if (nega) { dx = -dx; }
	}
	void gc(char &a)
	{
		do a = gnc(); while (!isgraph(a));
	}
	void gss(char *c)
	{
		*c = gnc();
		while (!isgraph(*c)) *c = gnc();
		while (isgraph(*c)) *++c = gnc();
		*c = 0;
	}
#if __cplusplus >= 201103l || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103l)
	template<typename T, typename ...Args> inline void gi(T &a, Args &...args)
	{ gi(a); gi(args...); }
#else
	template<typename t1, typename t2> inline void gi(t1 &a, t2 &b) { gi(a); gi(b); }
	template<typename t1, typename t2, typename t3> inline void gi(t1 &a, t2 &b, t3 &c) { gi(a); gi(b); gi(c); }
	template<typename t1, typename t2, typename t3, typename t4> inline void gi(t1 &a, t2 &b, t3 &c, t4 &d) { gi(a); gi(b); gi(c); gi(d); }
	template<typename t1, typename t2, typename t3, typename t4, typename t5> inline void gi(t1 &a, t2 &b, t3 &c, t4 &d, t5 &e) { gi(a); gi(b); gi(c); gi(d); gi(e); }
#endif
}
using namespace io;
int a[233][233];
int z[23333];
int h, w, n;
void next(int &x, int &y)
{
	if ((y & 1) && x == w) {
		++y;
	} else if (!(y & 1) && x == 1) {
		++y;
	} else if (y & 1) {
		++x;
	} else {
		--x;
	}
}
int main()
{
	gi(h, w, n);
	for (int i = 1; i <= n; ++i) gi(z[i]);
	int x = 1, y = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= z[i]; ++j) {
			a[x][y] = i;
			// cerr << x << " " << y << endl;
			next(x, y);
		}
	}
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			printf("%d ", a[j][i]);
		}
		putchar('\n');
	}
	return 0;
}





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

const int M=2e5+5;
int isp[M];

int main()
{
	int n;
	cin>>n;
	int i=2;
	for(;;i++)
	{
		if(isp[i]) continue;
		if(i>=n) break;
		for(int j=i+i;j<M;j+=i)
			isp[j]=1;
	}
	cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

int main(){
    long long n, k;
    std::cin >> n >> k;

    long long ans = 0;
    if(0 == k % 2){
        ans += std::pow(n / k, 3);
        ans += std::pow((n + k / 2) / k, 3);
    }else{
        ans = std::pow(n / k, 3);
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
ans = 0
while True:
  f = True
  c = 0
  for i in range(n):
    if A[i] % 2 == 0:
      A[i] //= 2
      c += 1
  ans += c
  if c == 0:
    break
print(ans)


Measured memory_bytes: 4152
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  150
#define tmod             998244353
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<ll> &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
//bool P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n);

bool check(ll n)
{
    ll ld = n%10; n = n/10;
    while(n>0)
    {
        if(abs(ld-n%10)>1) return false;
        ld = n%10; n /= 10;
    }
    return true;
}

int main()
{
fast;
ll q=1,t;
//cin >> q;
ll i ,j;
while(q--)
{
    ll n,m,k,l,r,a,b,c=0,g,counter=0,u,v,d,e,p,x,y,flag=1;
    //n=m=i=j=l=r=a=t=b=c=u=v=w=p=x=y=0;
    cin >> n;
    vector<ll> Dn_1,D;
    map<ll,ll> M;
    for(i=2;i*i<=n-1;i++)
    {
        if((n-1)%i==0) {Dn_1.pb(i);  M[i]++;
        if(i*i != n-1)    {Dn_1.pb((n-1)/i); M[(n-1)/i]++;}}
    }
    for(i=2;i*i<=n;i++)
    {
        if((n)%i==0)
            D.pb(i);
        if(i*i!=n) D.pb((n)/i);
    }
    if(n-1>1) Dn_1.pb(n-1);
    ll ans = Dn_1.size(); //cout << ans << " ";
    for(auto it:D)
    {
        m = n;
        while(m%it==0) m/=it;
        if(m%it==1 and M.find(it)==M.end())
        {
            //cout << it << "  " ;
            ans++;
        }
    }
    cout << (ans+1);
}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%tmod;}
    else{return (b*((temp*temp)%tmod))%tmod;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}
/*
void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}

*/


Measured memory_bytes: 10224
#include <stdio.h>


int main() {
	int a, num;
	scanf("%d %d", &a, &num);
	if (a >= 13) {
		printf("%d\n", num);
	}
	else if (12 >= a && a >= 6) {
		printf("%d\n", num / 2);
	}
	else {
		printf("%d\n", 0);
	}
	
}

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

signed main(void)
{
	int a, b, c, d;
	int aoki, taka;
	cin >> a >> b >> c >> d;
	aoki = c / b;
	if (c % b != 0)
		aoki++;
	taka = a / d;
	if (a % d != 0)
		taka++;
	if (taka >= aoki)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3620
unittest
{
	assert( [ "3", "-10 5 -4" ].solve == 19 );
	assert( [ "5", "10 -4 -8 -11 3" ].solve == 30 );
	assert( [ "11", "-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000" ].solve == 10000000000 );
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	
	auto ans = 0L;
	auto c = 0L;
	auto m = long.max;
	foreach( a; as )
	{
		auto aa = a.abs;
		ans += aa;
		c += ( a < 0 );
		m = min( m, aa );
	}
	if( c % 2 ) ans -= m * 2;
	return ans;
}


Measured memory_bytes: 7424
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int n, t;

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

	int max_diff = 0;
	int min_a = a[0];
	int count = 0;

	for (int i = 1; i < n; i++) {
		min_a = min(min_a, a[i]);
		int diff = a[i] - min_a;
		if (diff > max_diff) {
			max_diff = diff;
			count = 1;
		} else if (diff == max_diff) {
			count++;
		}

	}

	cout << count << endl;
	return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define NIL -2000000001
#define MAX 2000000000000

int main() {
  int n;
  scanf("%d", &n);
  bool a[n+1];
  a[0] = true;
  for (int i=1; i<=n; i++) {
    if (i-7<0) {
      if (i == 4) {
        a[i]= true;
      } else {
        a[i] = false;
      }
      continue;
    }
    if (a[i-4] || a[i-7]) {
      a[i] = true;
    } else {
      a[i] = false;
    }
  }
  if (a[n]) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


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

int W;
int H;
int x;
int y;
int r;

void input() {
    cin >> W;
    cin >> H;
    cin >> x;
    cin >> y;
    cin >> r;
}

int main() {
    input();

    if((x + r) <= W && (x - r) >= 0 &&
    (y + r) <= H && (y - r) >= 0){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#include<string.h>
#include<cstring>
#define pb push_back
#define FAST ios::sync_with_stdio(0);cin.tie(),cout.tie();
typedef long long ll;
//const long double pi = acos(-1.0);
//const int mod = 1e9+7;
using namespace std;
int main()
{
    //FAST
    double n,m;
    scanf("%lf %lf",&n,&m);
    double a[(int)n],sum=0,p=4*m;
    for(int i=0;i<n;i++)
    {
      scanf("%lf",&a[i]);
      sum+=a[i];
    }
    double mx=sum/(double)p,kk=0;
    for(int i=0;i<n;i++)
    {
      if(a[i]>=mx)
        kk++;
    }
    if(kk>=m)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 17.11.2019 00:57:03       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {                                                                                                    
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  long long ans = (long long) 9e18;
  for (int rot = 0; rot < 2; rot++) {
    for (int i = 1; i < h; i++) {
      long long s1 = (long long) i * w;
      long long s2 = (long long) (h - i) * (w / 2);
      long long s3 = (long long) (h - i) * ((w + 1) / 2);
      ans = min(ans, max(max(s1, s2), s3) - min(min(s1, s2), s3));
    }
    long long w1 = w / 3;
    long long w2 = (w + 1) / 3;
    long long w3 = (w + 2) / 3;
    ans = min(ans, (w3 - w1) * h);
    swap(h, w);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String C = sc.next();
		int RCount[] = new int[N];
		for(int i = 0 ; i < N ; ++i){
			int r = C.charAt(i) == 'R' ? 1 : 0;
			RCount[i] = r;
			if(i > 0){
				RCount[i] += RCount[i - 1];
			}
		}
		int ret = RCount[N - 1]; // 全てWにする場合
		ret = Math.min(ret, N - RCount[N - 1]); // 全てRにする場合		
		// RRRR...WWW
		for(int i = 0 ; i < N - 1; ++i){
			int leftR = RCount[i];
			int leftW = (i + 1) - leftR;
			int rightR = RCount[N - 1] - RCount[i];
			int rightW = (N - i - 1) - rightR;
			int swap = Math.min(leftW, rightR);
			leftW -= swap;
			rightR -= swap;
			int op = leftW + rightR + swap;
//			System.out.println(leftR+" "+leftW+" "+rightR+" "+rightW+" "+swap+ " " + op);
			ret = Math.min(ret, op);
		}
		System.out.println(ret);
	}
}


Measured memory_bytes: 41276
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */

#include <bits/stdc++.h>
//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class ERemOfSumIsNum {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n, k;
        in >> n >> k;
        vector<int> A(n);
        for (int &x: A) {
            in >> x;
        }
        unordered_map<int, int> counter;
        counter[0] = 1;
        long long res = 0;
        vector<int> added(n + 1);
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            if (i >= k) {
                --counter[added[i - k]];
            }
            sum = (sum + A[i - 1]) % k;
            int val = (sum - i % k + k) % k;
            added[i] = val;
            res += counter[val]++;
        }
        out << res << "\n";
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    ERemOfSumIsNum solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 10056
#pragma comment(linker, "/stack:200000000")
        #pragma GCC optimize ("Ofast")
        #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
        #include <iostream>
        #include <iomanip>
        #include <sstream>
        #include <cstring>
        #include <vector>
        #include <deque>
        #include <queue>
        #include <set>
        #include <map>
        #include <valarray>
        #include <iterator>
        #include <functional>
        #include <limits>
        #include <algorithm>
        #include <numeric>
        #include <cmath>
        #include <cassert>
        #include <unordered_map>
        #include <unordered_set>
        #include <stack>
        using namespace std;
        #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
         #define trace(x) cerr << #x << ": " << x << " " << endl;
     
        typedef int64_t ll;
     
        #define endl '\n'
        #define int ll
        ll mod=1e9+7;
        ll mod1=1e9+5;
        ll power(ll a,ll b)
        {
            if(b==0) return 1;
            else if(b%2==0)
                return power((((a%mod)*(a%mod))%mod),b/2)%mod;
            else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
        }
        int n,t;
        int dp[3001][3001];
        pair<int,int> a[3001];
        int solve(int i,int j)
        {
            if(i==n)
                return 0;
            if(j>t)
                return 0;
            int &res=dp[i][j];
            if(res!=-1)
                return res;
            res=0;
            res=solve(i+1,j);
                res=max(res,a[i].second+solve(i+1,j+a[i].first));
            return res;


        }
     int32_t main()
        {
            IOS
        
        cin>>n>>t;
        memset(dp,-1,sizeof(dp));
        for(int i=0;i<n;++i)
        {
            cin>>a[i].first>>a[i].second;
        }
        sort(a,a+n);
        cout<<solve(0,1);


        


        }

Measured memory_bytes: 70784
#include<iostream>

using namespace std;

int main() {
	int X, Y;
	int turu, kame;
	bool flag = false;

	cin >> X >> Y;

	for (int i = 0; i <= 100; i++) {
		turu = i;
		kame = X - i;
		if (turu * 2 + kame * 4 == Y && kame >= 0) {
			flag = true;
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
using namespace std;


int main()
{
    vector<int> i(3);
    cin >> i[0] >> i[1] >> i[2];
    cout << i[0] + i[1] + i[2] - *max_element(i.begin(), i.end()) << endl;
}

Measured memory_bytes: 256
<?PHP
$single_line_input = fgets(STDIN);
// 取得した入力値を半角スペースで分解します
$array = explode(" ", $single_line_input);
//複数の変数に値を一括代入する
list($item_num, $weight_upper) = $array;

for ($i = 0; $i < $item_num; ++$i) {
    fscanf(STDIN, "%d %d ", $x, $y);
    $weight[$i] = $x;
    $value[$i] = $y;
}

$dp = [];
foreach (range(0, $item_num - 1) as $item_index) {
    $i_value = $value[$item_index];
    $i_weight = $weight[$item_index];
    foreach (range(1, $weight_upper) as $weight_index) {
        $current_value = $dp[$item_index - 1][$weight_index] ?? 0;
        if ($weight[$item_index] <= $weight_index) {
            $new_value = ($dp[$item_index - 1][$weight_index - $weight[$item_index]] + $i_value);
            $dp[$item_index][$weight_index] = $current_value >= $new_value ? $current_value : $new_value;
        } else {
            $dp[$item_index][$weight_index] = $current_value;
        };
    }
}
echo $dp[(int)$item_num - 1][(int)$weight_upper];


Measured memory_bytes: 420332
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k =sc.nextInt();
		int h[] =new int[n];
		for(int i=0;i<n;i++){
			h[i]=sc.nextInt();
		}
		int dp[]= new int[n];
		for (int i = 0; i < n; i++) {
		    dp[i]=Integer.MAX_VALUE;
		}
		dp[0]=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<=i+k;j++){
                if(j<n){
                    dp[j]=Math.min(dp[j],dp[i]+Math.abs(h[j]-h[i]));
                }
            }
        }
      System.out.println(dp[n-1]);
    }
}

Measured memory_bytes: 50824
a = gets.chomp.split.map(&:to_i)
b = []
a[0].times{b << gets.chomp.split.map(&:to_i)}
incr,ans,path = 0,[],[]
for t in 0...a[0]
  case t%2
  when 0
    for y in 0...a[1]
      path << [t,y]
    end
  when 1
    for y in (0...a[1]).to_a.reverse
      path << [t,y]
    end
  end
end
for n in 0...path.size-1
  unless b[path[n][0]][path[n][1]].even?
    ans << [path[n][0]+1,path[n][1]+1,path[n+1][0]+1,path[n+1][1]+1]
    b[path[n][0]][path[n][1]] -= 1
    b[path[n+1][0]][path[n+1][1]] += 1
    incr += 1
  end
end
puts incr,ans.map{|a|a.join(" ")}

Measured memory_bytes: 73084
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;

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


const int BIG_NUM = 1e8;

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

	vector<vector<int>> g(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}

	vector<int> root(n,-1);
	root[0] = 0;
	
	queue<int> q;
	q.push(0);

	while (!q.empty()) {
		int v = q.front();
		q.pop();

		for (int u : g[v]) {
			if (root[u] >= 0) {
				continue;
			}

			root[u] = v;
			q.push(u);
		}
		
	}

	cout << "Yes" << endl;
	for (int i = 1; i < n; i++) {
		cout << root[i] + 1 << endl;
	}


}

Measured memory_bytes: 10176
import sys


def main():
    n, m = map(int, input().split())
    g = [[] for i in range(n)]
    lines = sys.stdin.read().splitlines()
    for i in range(m):
        l, r, d = map(int, lines[i].split())
        g[l - 1].append((r - 1, d))
        g[r - 1].append((l - 1, -d))
    dis = [0] * n
    visited = [False] * n
    for i in range(n):
        if visited[i]:
            continue
        stack = list([i])
        visited[i] = True
        while len(stack):
            v = stack[-1]
            stack.pop()
            for u, d in g[v]:
                if not visited[u]:
                    dis[u] = dis[v] + d
                    stack.append(u)
                    visited[u] = True
    for v in range(n):
        for u, d in g[v]:
            if dis[v] + d != dis[u]:
                print('No')
                return
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 124660
def main():
  import fractions
  import math

  a,b = map(int,input().split())
  g = fractions.gcd(a,b)
  
  d = [1]
  num = 2

  while num**2 <= g:
    #print("num",num)
    if g%num == 0:
      d.append(num)
    while g%num == 0 and g>1:
      g = g//num
      #print(g)
    num += 1
  
  print(len(d) + (g > 1))

if __name__ == "__main__":
  main()



Measured memory_bytes: 5048
import numpy as np

def main():
    n = int(input())
    value_list = list(map(int, input().split()))
    cost_list = list(map(int, input().split()))

    ans = 0

    value_list = np.array(value_list)
    cost_list = np.array(cost_list)

    value_list -= cost_list

    for i in range(n):
        if value_list[i] > 0:
            ans += value_list[i]

    print(ans)

if __name__ == '__main__':
    main()

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

int main(void){
    char hon[10];
    scanf("%s",&hon);
    for(int i=0;i<=3;i++){
        if(hon[i+1]=='\0'){
            if(strncmp("3",&hon[i],1)==0){
                printf("bon");
                return 0;
            }else if(strncmp("0",&hon[i],1)==0||strncmp("1",&hon[i],1)==0||strncmp("6",&hon[i],1)==0||strncmp("8",&hon[i],1)==0){
                printf("pon");
                return 0;
            }else{
                printf("hon");
                return 0;
            }
        }
    }
}

Measured memory_bytes: 1728
s = input()
s_reverse = s[::-1]

arr = ['dream', 'dreamer', 'erase', 'eraser']
arr_reversed = list(map(lambda item: item[::-1], arr))
able = True
t = ""
while s_reverse != t and able:
    for i in range(len(arr_reversed)):
        item = arr_reversed[i]
        if s_reverse[len(t): len(t) + len(item)] == item:
            t += item
            break
        elif i == len(arr_reversed) - 1:
            able = False

print("YES" if s_reverse == t else "NO")

Measured memory_bytes: 135688
#include<iostream>
using namespace std;
int main(){
int n,i,j;
  cin >> n;
  for(i=1;i<=9;i++){
    for(j=1;j<=9;j++){
      if(i*j==n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
} 

Measured memory_bytes: 3608
function Main(input) {
	input = input.split("\n");
	input2 = input[1].split(" ");

  	var a = input[0].split("");
	var b = input2[0].split("");
  	var count = 0;
  
  	a.forEach((item, i) => {
      if(a[i] !== b[i]) {
        count++;
      }
    });
  
	//出力
	console.log('%d',count);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 35544
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;

int main(){
    string s;
    cin >> s;
    for(int i=1;i<(int)s.length();i++){
        if(s[i]==s[i-1]){
            printf("%d %d\n",i,i+1);
            exit(0);
        }
        if(i+1<(int)s.length()&&s[i-1]==s[i+1]){
            printf("%d %d\n",i,i+2);
            exit(0);
        }
    }
    printf("-1 -1");
}


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

int main(){
    int w,h,n;
    cin>>w>>h>>n;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> A(n);
    for(int i=0;i<n;i++){
        cin>>x.at(i);
        cin>>y.at(i);
        cin>>A.at(i);
    }
    int x1=0,x2=w,y1=0,y2=h;
    for(int i=0;i<n;i++){
        if(A.at(i)==1){
          if(x1<x.at(i)) x1=x.at(i);
        }
        else if(A.at(i)==2){
          if(x2>x.at(i)) x2=x.at(i);
        }
        else if(A.at(i)==3){
          if(y1<y.at(i)) y1=y.at(i);    
        }
        else if(A.at(i)==4){
          if(y2>y.at(i)) y2=y.at(i);
        }
    }
    int S=(x2-x1)*(y2-y1);
    if(x2-x1<0||y2-y1<0) cout<<0<<endl;
    else cout<<S<<endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a=list(map(int,input().split()))
a_sum=sum(a)
a_sort=sorted(a,reverse=True)
for i in range(m):
  if a_sort[i]<(a_sum)/4/m:
    print("No")
    break
else:
  print("Yes")

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

// limit
#define mod1 22439423LL
#define mod2 42342432LL
#define mod3 56454765LL
#define mod4 66867574LL
#define oo 1000000007LL
#define OO 1000000000000000007LL
#define maxN 1000009

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftosqrt(i, x, y) for(int i = (x); i*i <= (y); ++i)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define debug cout << "*" << endl;
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front
// structure
#define ii pair<int, int>
#define iii pair<ii, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define matrix vector<vi>

// get value
#define FF first
#define SS second

// data type
#define ll long long
#define ull unsigned long long

// function
#define lb lower_bound
#define ub upper_bound

// const value
#define pi 3.14159265358979323846264338327950288419716939937510

using namespace std;

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T min(T a, T b, T c, T d) {
    return min(a, min(b, min(c, d)));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

template <class T>
T max(T a, T b, T c, T d) {
    return max(a, max(b, max(c, d)));
}

bool cmp(const ii& a, const ii& b) {return (a.FF > b.FF || (a.FF == b.FF && a.SS >= b.SS));}
ll GCD(ll a, ll b) {return (a%b) ? GCD(b, a%b) : b;}

const string namePro = "tmp";

ll a[maxN];
ll f[maxN];

int main() {
    int n;
    scanf("%d", &n);

    fto (i, 1, n) scanf("%lld", &a[i]);
    fto (i, 1, n) f[i] = f[i-1]+a[i];

    ll ans = OO;
    fto (i, 1, n-1) {
        ans = min(ans, (ll)abs(f[n]-2LL*f[i]));
    }

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

Measured memory_bytes: 5888
def cross(v1,v2):
	return v1.real*v2.imag-v1.imag*v2.real

def isOnSegment(p1,p2,p):
	return abs(p1-p)+abs(p2-p)-abs(p1-p2)<=1e-8

def isIntersection(p1,p2,p3,p4):
	if cross(p2-p1,p4-p3)==0:
		return any(isOnSegment(q1,q2,q3)for q1,q2,q3 in ((p1,p2,p3),(p1,p2,p4),(p3,p4,p1),(p3,p4,p2)))
	return cross(p2-p1,p3-p1)*cross(p2-p1,p4-p1)<=1e-8>=cross(p4-p3,p1-p3)*cross(p4-p3,p2-p3)

import sys
input = sys.stdin.buffer.readline
ans=[]
for _ in range(int(input())):
	m=map(int,input().split())
	ans.append(int(isIntersection(*[complex(x,y)for x,y in zip(*[iter(m)]*2)])))
print("\n".join(map(str,ans)))


Measured memory_bytes: 5644
import java.util.Scanner;

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

    String a = sc.next();

    if (Character.isLowerCase(a.toCharArray()[0])) {
      System.out.println("a");
    } else {
      System.out.println("A");
    }
  }
}


Measured memory_bytes: 35724
# coding: utf-8
import re
import math
import fractions
import random
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
#import numpy as np
mod=int(10**9+7)
inf=int(10**20)
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def comb(n,r):return math.factorial(n)//math.factorial(n-r)//math.factorial(r)
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
 

 
#main
n,m=map(int,input().split())
#A=list(map(int,input().split()))

print(math.ceil(n/m))

Measured memory_bytes: 65772
#include<iostream>
#include<algorithm>
using namespace std;
main(){
	int a,b,c;
	int oo=0;
	cin>>a>>b>>c;
	if(b<c){
	oo+=(2*b);
	c-=b;
   if(a<c)
	oo+=(a+1);
	else oo+=c;
	}
   else if(b==c)oo=2*c;
   else oo=c+b;
	cout<<oo;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;


int main(){
    int n,d,x;
    cin>>n>>d>>x;
    int sum=n+x;
    int D=d-1;
    rep(i,0,n){
        int a; cin>>a;
        sum+=D/a;
    }
    cout<<sum<<endl;
}

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

using namespace std;

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, n) for(int i=0; i<(n); i++)
#define all(a)  begin(a),end(a)
#define pb push_back
#define mp make_pair

typedef long long int ll;
typedef long long unsigned int llu;


/*---------------------------------------------------------------------------------*/


int main(){
   int a,b,c;
   scanf("%d %d %d",&a,&b,&c);
   if(a==b)printf("%d",c);
   if(a==c)printf("%d",b);
   if(c==b)printf("%d",a);
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var k = vals[0];
        var a = vals[1];
        var b = vals[2];
        var biscuit = 1L;
        if (a + 2 >= b || a + 2 > k + 1)
        {
            biscuit += k;
        }
        else
        {
            k -= a - 1;
            biscuit += a - 1;
            biscuit += (b - a) * (k / 2) + k % 2;
        }

        Console.WriteLine(biscuit);
    }
}

Measured memory_bytes: 13396
#include <cstdio>
#include <string.h>

int main() {

    int eachalphabetnum[26];

    for (int i = 0;i<26;i++) {
            eachalphabetnum[i] = 0;
        }

    char s[1200];

    while (scanf("%s", s) != EOF) {

        

        for(int i = 0; s[i] != '\0'; i++) {

            char c = s[i];

            if (c >= 65 && c <= 90) {
                eachalphabetnum[c-65]++;
            } else if (c >= 97 && c <= 122) {
                eachalphabetnum[c-97]++;
            }

        }
    }   

    for (int i = 0; i<26;i++) {
        char d = i + 97;
        std::printf("%c : %d\n",d,eachalphabetnum[i]);
    }


}


Measured memory_bytes: 2740
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	vector<ll> nums(n); fore(e, nums) cin >> e;
	ll sm = 0;
	forl(i, 0, n) {
		forl(j, i+1, n) {
			sm += nums[i]*nums[j];
		}
	}
	println(sm);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,k;
const int maxn=105;
int arr[maxn];
const int inf=1e5+5;
int dp[inf];
void solve(){
    memset(dp,0,sizeof(dp));
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>arr[i];
    for(int i=1;i<=k;i++){
        for(int j=0;j<n;j++){
            if(arr[j]<=i && dp[i-arr[j]]==0){
                dp[i]=1;
            }
        }
    }
    if(dp[k]){
        cout<<"First"<<endl;
    }
    else {
        cout<<"Second"<<endl;
    }
    }
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    solve();
    return 0;
    }


Measured memory_bytes: 640