akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define push_back emplace_back
#define int long long
typedef pair<int, int> pii; 
typedef vector<pii> vii;
typedef vector<int> vi;
#define ss second
#define ff first
#define pii pair<int, int>
#define max3(a, b, c) max(a, max(b, c))
#define TEST ll t; cin >> t;while (t--)
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define pq priority_queue<int>
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}

void fastio()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int32_t main() {
	fastio();
	long double n,d;
	cin>>n>>d;
	int counter=0;
	for(int i=0;i<n;i++)
	{
		
		long double p,q;
		cin>>p>>q;
		long double di=sqrt(p*p + q*q);
		if(di<=d)
		counter++;
	}cout<<counter<<endl;
	return 0;
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int N,M;
  cin>>N>>M;
  vector<int>arr(M);
  ll sum=0;
  for(int i=0; i<M; i++)
  {
    cin>>arr[i];
    sum+=arr[i];
  }
  ll ans=N-sum;
  if(ans>=0)
   cout<<ans;
  else
    cout<<"-1";
  return 0;
}
    

Measured memory_bytes: 3628
import std.stdio;
import std.string;
import std.conv;

void main()
{
    int n = readln.chomp.to!(int);
    long[] a = readln.chomp.split.to!(long[]);

    int ans = 0;
    for (int i = 0; i < a.length; i++) {
        while (true) {
            if (!(a[i] & 1)) {
                ans += 1;
                a[i] /= 2;
            }
            else {
                break;
            }
        }
    }

    writeln(ans);
}

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

int main() {

	int N, K;
	cin >> N >> K;

	string S;
	cin >> S;

	if (S[K - 1] == 'A') {
		S[K - 1] = 'a';
	}
	else if (S[K - 1] == 'B') {
		S[K - 1] = 'b';

	}else {
		S[K - 1] = 'c';
	}

	cout << S << endl;

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;



int main(){
double R;
    cin >> R;
 cout << fixed << setprecision(20);
 cout<<2*R*3.141592653589793238<<endl;
return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (a + b > c + d) {
    cout << "Left" << endl;
  }else if(a + b < c + d){
  	cout << "Right" << endl;
  }else{
  	cout << "Balanced" << endl;
  }
}

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

using namespace std;

const int P = 998244353;

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

	int n;
	cin >> n;

	string s;
	cin >> s;

	long long ans = 1;
	vector<long long> cnt(9);

	for(char c : s) {
		if(c == 'R') {
			long long x = cnt[5] + cnt[6];
			long long y = cnt[1] + cnt[2];
			if(x > 0) {
				ans = ans * x % P;
				if(cnt[5] > 0) {
					cnt[5] -= 1;
				} else {
					cnt[6] -= 1;
				}
			} else if(y > 0) {
				ans = ans * y % P;
				if(cnt[1] > 0) {
					cnt[1] -= 1;
					cnt[4] += 1;
				} else {
					cnt[2] -= 1;
					cnt[8] += 1;
				}
			} else {
				cnt[0] += 1;
			}
		}
		if(c == 'G') {
			long long x = cnt[7] + cnt[8];
			long long y = cnt[0] + cnt[2];
			if(x > 0) {
				ans = ans * x % P;
				if(cnt[7] > 0) {
					cnt[7] -= 1;
				} else {
					cnt[8] -= 1;
				}
			} else if(y > 0) {
				ans = ans * y % P;
				if(cnt[0] > 0) {
					cnt[0] -= 1;
					cnt[3] += 1;
				} else {
					cnt[2] -= 1;
					cnt[6] += 1;
				}
			} else {
				cnt[1] += 1;
			}
		}
		if(c == 'B') {
			long long x = cnt[3] + cnt[4];
			long long y = cnt[0] + cnt[1];
			if(x > 0) {
				ans = ans * x % P;
				if(cnt[3] > 0) {
					cnt[3] -= 1;
				} else {
					cnt[4] -= 1;
				}
			} else if(y > 0) {
				ans = ans * y % P;
				if(cnt[0] > 0) {
					cnt[0] -= 1;
					cnt[7] += 1;
				} else {
					cnt[1] -= 1;
					cnt[5] += 1;
				}
			} else {
				cnt[2] += 1;
			}
		}
	}

	for(int i = 1; i <= n; ++i) {
		ans = ans * i % P;
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		int count = 0;
		int max = 0;
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		for(int i = 0; i < n-1; i++) {
			if( h[i] >= h[i+1]) {
				count++;
			}else if(count  != 0 &&  h[i] < h[i+1]) {
				max = Math.max(max, count);
				count = 0;
			}
		}
		max = Math.max(max, count);
		System.out.println(max);
		sc.close();

	}

}

Measured memory_bytes: 49488
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int x = rint;
	foreach(i; 0 .. 10000){
		int r = x - 100 * i;
		if(r >= 0 && r <= i * 5){
			"1".writeln;
			return;
		}
	}
	"0".writeln;
	return;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,p;
    cin>>n>>p;
    ll ans=1;
    for(ll i=2;i*i<=p;i++){
        ll cnt=0;
        if(p%i==0){
            while(p%i==0){
                p/=i;
                cnt++;
            }
            cnt/=n;
            rep(j,cnt) ans*=i;
        }
        
    }
    if(p!=1){
            rep(j,1/n) ans*=p;
        }
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

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

    vector<int> u(m), v(m), a(m), b(m);
    for (int i = 0; i < m; i++) {
        cin >> u[i] >> v[i] >> a[i] >> b[i];
        u[i]--;
        v[i]--;
    }

    vector<int> c(n), d(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i] >> d[i];
    }

    int s_max = *max_element(a.begin(), a.end()) * (n - 1);
    vector<vector<pair<int, long long>>> graph(n * (s_max + 1), vector<pair<int, long long>>(0));
    for (int i = 0; i < m; i++) {
        for (int j = u[i] * (s_max + 1) + a[i]; j < (u[i] + 1) * (s_max + 1); j++) {
            graph[j].push_back(make_pair(v[i] * (s_max + 1) + j - u[i] * (s_max + 1) - a[i], b[i]));
        }
        for (int j = v[i] * (s_max + 1) + a[i]; j < (v[i] + 1) * (s_max + 1); j++) {
            graph[j].push_back(make_pair(u[i] * (s_max + 1) + j - v[i] * (s_max + 1) - a[i], b[i]));
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = i * (s_max + 1); j < (i + 1) * (s_max + 1); j++) {
            graph[j].push_back(make_pair(min(j + c[i], (i + 1) * (s_max + 1) - 1), d[i]));
        }
    }

    vector<long long> dist(n * (s_max + 1), 1LL << 61);
    dist[min(s, s_max)] = 0;

    priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> que;
    que.push(make_pair(0, min(s, s_max)));
    while (!que.empty()) {
        int q = que.top().second;
        que.pop();

        for (int i = 0; i < static_cast<int>(graph[q].size()); i++) {
            if (dist[graph[q][i].first] > dist[q] + graph[q][i].second) {
                dist[graph[q][i].first] = dist[q] + graph[q][i].second;
                que.push(make_pair(dist[graph[q][i].first], graph[q][i].first));
            }
        }
    }

    for (int i = 1; i < n; i++) {
        cout << *min_element(dist.begin() + i * (s_max + 1), dist.begin() + (i + 1) * (s_max + 1)) << endl;
    }
}


Measured memory_bytes: 23404
#include <iostream>
 
using namespace std;
 
const long long MAX = 1e9;
 
int main() {
	long long s; cin >> s;
	long long x = (MAX - s % MAX) % MAX; //abs(MAX*y-x*1)==s となればよい,
	long long y = (s + x) / MAX;
	cout << "0 0 " << MAX << " 1 " << x << " " << y << endl;
 
	return 0;
}

Measured memory_bytes: 256
N = int(input())
arr = list(map(int, input().split()))
ans = [0]*N
for i in range(N):
    target = N-1-i
    tmp = 0
    for k in range(target,N,target+1):
        tmp += ans[k]
    if tmp % 2 == arr[target]:
        ans[target] = 0
    else:
        ans[target] = 1
ans2 = []
for i in range(N):
    if ans[i] == 1:
        ans2.append(i+1)
print(len(ans2))
print(*ans2)

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

using namespace std;

typedef long long ll;

#define eps 1e-9
#define all(a)   a.begin(),a.end()
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define sz size()
#define rd(inp) scanf("%lld",&inp)
#define rd2(inp1, inp2) scanf("%lld %lld",&inp1, &inp2)
#define rl(inp) scanf("%d",&inp)
#define pf(out) printf("%lld\n", out);

const long long linf = 1e18+5;
const int mod = (int) 1e9 + 7;
const int inf = 1e9;

ll read(){
	bool minus = false;
	ll result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus){
		return -result;
	}
	else{
		return result;
	}
}

ll fpow(ll base,ll power){
	ll result = 1;
	while (power > 0){
		if (power%2 == 1) result=(result*base);
  		base = (base*base);
  		power /= 2;
  	}
	return result;
}

int main(){
	int a, b;
	cin >> a >> b;
	a += b;
	if ( a > 23 ){
		a %= 24;
	}
	cout << a << "\n";
	return 0;	
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int M=1e9+7;
    int H,W;
    cin>>H>>W;
    char a[H][W];
    for (int i=0;i<H;i++)
        for (int j=0;j<W;j++)
            cin>>a[i][j];
    long long int dp[H][W];
    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            if(i==0 and j==0)   
                dp[i][j]=1;
            else if(i==0){
                if(a[i][j]=='.') dp[i][j]=dp[i][j-1];
                else dp[i][j]=0;
            }
            else if(j==0){
                if(a[i][j]=='.') dp[i][j]=dp[i-1][j];
                else dp[i][j]=0;
            }
            else{
                if(a[i][j]=='.') dp[i][j]=dp[i][j-1]+dp[i-1][j];
                else dp[i][j]=0;
            }
            dp[i][j]%=M;
        }
    }
    cout<<dp[H-1][W-1]<<"\n";
	return 0;
}

Measured memory_bytes: 9088
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) 
{
	cout << *it << " = " << a;
	nl;
	err(++it, args...);
}
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
void solveforthiscase(const int & test)
{//deb(test);
int q;
cin>>n>>q;
vector<pair<ll,pll>> vp(n);
for(int i=0;i<n;i++)
{
    cin>>vp[i].se.fi>>vp[i].se.se>>vp[i].fi;
    
}
set<ll> s;
map<ll,ll> ind;
for(int i=0;i<q;i++)
{
    cin>>temp;
    ind[temp]=i;
    s.insert(temp);
}
sor(vp);
ll ans[2*100000+1]={0};
//memset(ans,-1,q+1);
for(auto x:vp)
{
    if(s.empty())
    break;
    //if(x.fi>=x.se.se)
    //continue;
    ll mintime;
    ll maxtime;
     mintime=x.se.fi-x.fi;
     maxtime=x.se.se-x.fi-1;
    auto it1=s.lower_bound(mintime);
    auto it2=s.upper_bound(maxtime);
    vll tempe;
    for(auto it=it1;it!=it2;it++)
    {
    ans[ind[*it]]=x.fi;
    tempe.pb(*it);
    }
    for(auto x:tempe)
    {
        s.erase(x);
    }
    tempe.clear();
    // for(auto x:s)
    // {
    //     cout<<x<<' ';
    // }
    // nl;
}
for(int i=0;i<q;i++)
{
    cout<<(ans[i]?ans[i]:-1);
    nl;
}
return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 30604
#include<bits/stdc++.h>
using namespace std;
int h,w,a[15],b[15];
char s[15][15];
string ss[15];
void dfs1(int x,bool f)
{
	if(x==w)
	{
		cout<<"YES"<<endl;
		exit(0);
	}
	else if(b[x]!=-1)
	{
		dfs1(x+1,f);
	}
	else
	{
		int i,j;
		for(int i=x+1;i<w;i++)
		{
			if(b[i]!=-1)
			{
				continue;
			}
			for(j=0;j<h;j++)
			{
				if(s[j][x]!=s[a[j]][i])
				{
					break;
				}
			}
			if(j==h)
			{
				b[x]=i;
				b[i]=x;
				dfs1(x+1,f);
				b[x]=b[i]=-1;
			}
		}
		if(!f)
		{
			for(j=0;j<h;j++)
			{
				if(s[j][x]!=s[a[j]][x])
				{
					break;
				}
			}
			if(j==h)
			{
				b[x]=x;
				dfs1(x+1,true);
				b[x]=-1;
			}
		}
	}
}
void dfs2(int x,bool f)
{
	if(x==h)
	{
		dfs1(0,w%2==0);
	}
	else if(a[x]!=-1)
	{
		dfs2(x+1,f);
	}
	else
	{
		int i;
		for(i=x+1;i<h;i++)
		{
			if(a[i]!=-1)
			{
				continue;
			}
			if(ss[x]!=ss[i])
			{
				continue;
			}
			a[x]=i;
			a[i]=x;
			dfs2(x+1,f);
			a[x]=a[i]=-1;
		}
		if(!f)
		{
			a[x]=x;
			dfs2(x+1,true);
			a[x]=-1;
		}
	}
}
int main()
{
	cin>>h>>w;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin>>s[i][j];
		}
	}
	for(int i=0;i<h;i++)
	{
		ss[i]=(string)s[i];
		sort(ss[i].begin(),ss[i].end());
	}
	memset(a,-1,sizeof(a));
	memset(b,-1,sizeof(b));
	dfs2(0,h%2==0);
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) (x).begin(), (x).end()
const int inf = 1e9;
const long long INF=1e15;
#define endl '\n'
#define rep(i, n) for(int i=0;i<(n);++i)
#define repp(i, a, b) for(int i=(a);i<=(b);++i)
#define pb push_back
#define eb emplace_back
#define fastio ios::sync_with_stdio(false);cin.tie(0); //cout.tie(0);

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;


void solve() {
	int n, m;cin>>n>>m;
	int sum = 0;
	vi a(n);rep(i,n)cin>>a[i],sum+=a[i];
	int ok = 0; rep(i,n)if(a[i]*4*m>=(sum))ok++;
	if(ok>=m) cout << "Yes";else cout << "No";
}
int main() {
	fastio;
	solve();
}

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

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

int cnt = 0; 
 for (int i = 0; i < s.size(); i++) {
   if (s[i] == '1') {
     cnt++;
   }
 }

 cout << cnt << endl;
}


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

s = []
t = []
for _ in range(n):
    tmps, tmpt = map(str, input().split())
    s.append(tmps), t.append(int(tmpt))

x = input()

ans_li = []
count = False
for i in range(n):
    if count:
        ans_li.append(t[i])

    if s[i] == x:
        count = True

print(sum(ans_li))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x, y, a ,b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> ad(a);
    vector<int> bd(b);
    vector<int> cd(c);\
    vector<int> kq(x+y+c);

    for(int i = 0; i < a; i++)
        cin >> ad[i];
    for(int i = 0; i < b; i++)
        cin >> bd[i];
    for(int i = 0; i < c; i++)
        cin >> cd[i];
    sort(ad.rbegin(), ad.rend());
    sort(bd.rbegin(), bd.rend());
    for(int i = 0; i < x; i++)
        kq.push_back(ad[i]);
    for(int i = 0; i < y; i++)
        kq.push_back(bd[i]);
    for(int i = 0; i < c; i++)
        kq.push_back(cd[i]);
    sort(kq.rbegin(), kq.rend());

    long long sum = 0;
    for(int i = 0; i < x+y; i++)
    {
        sum+=kq[i];
    }
    cout << sum;



    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define INF 1000000007
int main()
{
     ll n,a,b;
     cin>>n>>a>>b;
     if(abs(a-b)>=0 && abs(a-b)%2==0)
        cout<<(abs(a-b))/2ll<<endl;
     else if(a==b)
     cout<<0;
     else
     {
         if(a>b)
            swap(a,b);
            ll d=a;
            ll w=b;
         ll g=a;
         b-=a;
         a=1ll;
         g+=((abs(b-a)))/2ll;
         ll f=n-w+1;
         d+=n-w+1;
         w=n;
         f+=((abs(w-d)))/2ll;
         cout<<min(f,g);
     }
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n, x; cin >>n>>x;
  vector<ll> X(n);
  rep(i,n) cin >>X[i];
  ll ans=abs(x-X[0]);
  rep(i,n)ans=__gcd(ans,abs(x-X[i]));
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
int main(){
    int a,b,k,now,ko=0;
    cin>>a>>b>>k;
    for(now=min(a,b);now>=1;now--){
        if(a%now==0&&b%now==0){
            ko++;
            if(ko==k) break;
        }
    }
    cout<<now << endl;
    return 0;
}

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

int main(){

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

    int max = *max_element(v.begin(), v.end());
    int sum = accumulate(v.begin(), v.end(), 0);

    if( (3 * max - sum) % 2 == 0){
        cout << (3 * max - sum) / 2 << endl;
    }
    else{
        cout << (3 * (max + 1) - sum) / 2 << endl;
    }

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
char s[1000010];
int a[1000010];
int main()
{
/*	for(int i=0;i<=20;++i)
	{
		C[i][0]=1;
		for(int j=1;j<=i;++j)C[i][j]=C[i-1][j]^C[i-1][j-1];
		for(int j=0;j<=i;++j)printf("%d",C[i][j]);printf("\n");
	}*/
	scanf("%d",&n);--n;
	scanf("%s",s);
	for(int i=0;i<=n-1;++i)
		if(s[i]<s[i+1])a[i]=s[i+1]-s[i];
		else a[i]=s[i]-s[i+1];
	--n;
	int ans=0;
	for(int i=0;i<=n;++i)if((i&n)==i)ans^=a[i]&1;
	if(ans&1)return printf("1"),0;
	for(int i=0;i<=n;++i)if(a[i]==1)return printf("0"),0;
	ans=0;
	for(int i=0;i<=n;++i)if((i&n)==i)ans^=a[i]==2;
	if(ans==0)printf("0");
	else printf("2");
	return 0;
}


Measured memory_bytes: 4992
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Policy;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var c = int.Parse(spl[1]);
        var k = int.Parse(spl[2]);

        var tt = new int[n];
        for(int i=0; i<n; i++) {
            tt[i] = int.Parse(input.ReadLine());
        }

        Array.Sort(tt);

        var bus = 0;
        var men = 0;
        var first = -1;

        for(int i=0; i<n; i++) {
            var t = tt[i];

            if(men > 0) {
                if(t > first + k) {
                    bus++;
                    men = 0;
                }
            }

            if(men == 0) {
                first = t;
            }

            men++;
            if(men == c) {
                bus++;
                men = 0;
            }
        }

        if(men > 0) bus++;

        return bus;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        if(n == 0) return ret;
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 31880
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int x = scan.nextInt();
		int y = scan.nextInt();


		int sa = y - (x * 2);
		int kame = sa /2;
		int turu = x -kame;
		if( (sa%2==0) && kame >= 0&& turu >= 0) {
			System.out.println("Yes");
		} else{
			System.out.println("No");
		}

	}

}

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

int main(){
  int H,A;
  cin >> H >> A;
  if(H%A == 0) cout << H/A <<endl;
  else cout << abs(H/A)+ 1 <<endl;
  return 0;
}

Measured memory_bytes: 256
<?php
// Your code here!
$s = strrev(trim(fgets(STDIN)));//入力を反対向きに取得
$array = ["dream","dreamer","erase","eraser"];
foreach($array as $k => $v){//arrayの中身を一つづつ反対向きに直している
    $array[$k] = strrev($v);
}
// var_dump($array);

$can = true;
for($i=0; $i<strlen($s);){
    $can2 = false;
    foreach($array as $v){
        if(strpos($s,$v,$i) === $i){
            $can2 = true;
            $i += strlen($v);
        }
    }
    if(! $can2){
        $can = false;
        break;
    }
}
echo $can ? 'YES' : 'NO';

?>


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


int main() {
    int N; cin >> N;
    vector<int> V(N);
    for(int i=0;i<N;i++){
        cin >> V.at(i);
    }

    for(int i=0;i<N;i++){
        V.at(i)/=400;
    }

    vector<int> Clr(9,0);
    for(int i=0;i<N;i++){
        int x=V.at(i);
        if(x<8){
            Clr.at(x)++;      
        }
        else{
            Clr.at(8)++;
        }
    }
    int min=0;
    for(int j=0;j<8;j++){
        int y=Clr.at(j);
        if(y>0){
            min++;
        }
    }
    int Max=0;
    Max = min + Clr.at(8);

    if(min==0){
        min=1;
    }


    cout << min;
    cout << " " << Max << endl;
}

Measured memory_bytes: 256
import itertools

N = int(input())
L = list(map(int,input().split()))
cnt = 0

def judge(arg1,arg2,arg3):
    if arg1 == arg2 or arg1 == arg3 or arg3 == arg2:
        return 0
    elif arg1 + arg2 > arg3 and arg2 + arg3 > arg1 and arg1 + arg3 > arg2:
        return 1
    else:
        return 0
# for i in range(N):
#     for j in range(N):
#         for k in range(N):
#             if i == j or j == k or i == k:
#                 pass
#             elif L[i] + L[j] >= L[k] or L[j] + L[k] >= L[i] or L[i] + L[k] >= L[j]:
#                 cnt += 1

for pairs in itertools.combinations(L,3):
    if judge(*pairs):
        cnt += 1

print(cnt)

Measured memory_bytes: 9212
S = input().strip()
count=1
a=[]
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        count=count+1
    else:
        a.append(count)
        count=1
    
if S[len(S)-1]!=S[len(S)-2]:
    a.append(1)
else:
    a.append(count)
sa=0
for i in range(len(a)-1):
    if S[0]=='<':
        if i%2==0:
            sa=sa+min(a[i],a[i+1])
    else:
        if i%2==1:
            sa=sa+min(a[i],a[i+1])
wa=0
for i in range(len(a)):
    wa=wa+((a[i]+1)*a[i]/2)
print(int(wa-sa))

Measured memory_bytes: 6300
#include<bits/stdc++.h>
using namespace std;
bool ans[1024][1024];
void merge(int x1,int y1,int x2,int y2){
	if(x1==x2 || y1==y2) return;
	int x=(x1+x2)/2,y=(y1+y2)/2;
	ans[x][y]=0;
	merge(x1,y1,x-1,y-1);
	merge(x1,y+1,x-1,y2);
	merge(x+1,y1,x2,y-1);
	merge(x+1,y+1,x2,y2);
}
int main(){
	int H,W,n;
	cin>>H>>W>>n;
	cout<<min(ceil(1.0*n/H),ceil(1.0*n/W));
	return 0;
}

Measured memory_bytes: 3780
<?php
//error_reporting(0);
$N = (int)trim(fgets(STDIN));
//list($N,$M) = explode(" ",trim(fgets(STDIN)));
$a = array_map('intval',explode(" ",trim(fgets(STDIN))));

$x = array_count_values($a);
$res=array();
$tot=0;
foreach($x as $k=>$v) {
  $res[$k]=nCr($v,2);
  $tot+=$res[$k];
}

for($i=0;$i<$N;$i++) {
  printf("%d\n",$tot-$res[$a[$i]]+nCr($x[$a[$i]]-1,2));
}

function nCr(int $n,int $r)
{
    if ($r > $n) {
        return 0;
    }
    if ($n - $r < $r) {
        return nCr($n, $n - $r);
    }
    $return = 1;
    for ($i = 0; $i < $r; $i++) {
        $return *= ($n - $i) / ($i + 1);
    }
    return $return;
}


Measured memory_bytes: 29808
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

a, b = MAP()
ans1 = ''
ans2 = ''
for i in range(b):
    ans1 += str(a)
for i in range(a):
    ans2 += str(b)
print(min(ans1, ans2))

Measured memory_bytes: 60012
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //ArrayList<Integer> list;
        List<Integer> list = new ArrayList<>();
        int a = sc.nextInt();
        int b = sc.nextInt();
        //int c = sc.nextInt();
        if(a*b % 2 == 1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> s(H, vector<char>(W));
  int memo = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> s.at(i).at(j);
      if (s.at(i).at(j) == '.') {
        memo++;
      }
    }
  }
  vector<vector<int>> M(H, vector<int>(W, 0));
  queue<int> X;
  queue<int> Y;
  X.push(0);
  Y.push(0);
  vector<int> vx = {1, -1, 0, 0}, vy = {0, 0, 1, -1};
  s.at(0).at(0) = '#';
  while (X.size() > 0) {
    for (int i = 0; i < 4; i++) {
      if ((X.front() + vx.at(i)) >= 0 && (Y.front() + vy.at(i)) >= 0 
          && (X.front() + vx.at(i)) < H && (Y.front() + vy.at(i)) < W
          && s.at(X.front() + vx.at(i)).at(Y.front() + vy.at(i)) == '.' 
          && M.at(X.front() + vx.at(i)).at(Y.front() + vy.at(i)) == 0) {
            X.push(X.front() + vx.at(i));
            Y.push(Y.front() + vy.at(i));
            M.at(X.front() + vx.at(i)).at(Y.front() + vy.at(i)) = M.at(X.front()).at(Y.front()) + 1;
      }
    }
    X.pop();
    Y.pop();
  }
  if (M.at(H - 1).at(W - 1) != 0) {
    cout << memo - (M.at(H - 1).at(W - 1) + 1) << endl;
  }
  else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>

#define INF 1 << 29

using namespace std;


typedef int Weight; 

struct Edge{
    int src;
    int dst;
    Weight weight;

    Edge(int src, int dst, Weight weight):
        src(src), dst(dst), weight(weight){ }
};

struct Node{
    int index;
    Weight cost;
    int prev;

    Node(int index, Weight cost, int prev) :
        index(index), cost(cost), prev(prev){ }
};

bool operator <(const Node &a, const Node &b){
    if(a.cost == b.cost){
        return a.index > b.index;
    }else{
        return a.cost > b.cost;
    }
}

void dijkstra(int s, vector<Weight> &costs, vector<int> &prev, vector<vector<Edge> > &edges){
    int n=costs.size();
    priority_queue<Node> q;

    costs.assign(n,INF);
    prev.assign(n,-1);
    costs[s] = 0;
    q.push(Node(s,0,-2));

    while(!q.empty()){
        Node fix = q.top(); 
        q.pop();
        if(prev[fix.index] != -1) continue;
       
        costs[fix.index] = fix.cost;
        prev[fix.index] = fix.prev;

        for(int i=0;i<edges[fix.index].size();i++){ //foreach edge from fixed
            if(costs[edges[fix.index][i].dst] > costs[fix.index] + edges[fix.index][i].weight){
                q.push(Node(edges[fix.index][i].dst, edges[fix.index][i].weight + costs[fix.index], fix.index));
            }
        }
    }
}

int main(){
    int n,k,req,a,b,c;


    while(cin >> n >> k){
        if((n|k) == 0) break;
        vector<Weight> costs(n);
        vector<int> prev(n);
        vector<vector<Edge> > edges(n);

        for(int i=0;i<k;i++){
            cin >> req;
            if(req){
                cin >> a >> b >> c;
                bool isexist = false;
                for(int j=0;j<edges[a-1].size();j++){
                    if(edges[a-1][j].dst == b-1 && edges[a-1][j].weight > c){
                        edges[a-1][j].weight = c;
                        isexist = true;
                    }
                }
                if(!isexist){
                    edges[a-1].push_back(Edge(a-1,b-1,c));
                }

                isexist = false;
                for(int j=0;j<edges[b-1].size();j++){
                    if(edges[b-1][j].dst == a-1 && edges[b-1][j].weight > c){
                        edges[b-1][j].weight = c;
                        isexist = true;
                    }
                }
                if(!isexist){
                    edges[b-1].push_back(Edge(b-1,a-1,c));
                }
            }else{
                cin >> a >> b;
                dijkstra(a-1,costs,prev,edges);
                if(costs[b-1] == INF){
                    cout << -1 << endl;
                }else{
                    cout << costs[b-1] << endl;
                }
            }
        }
    }
}

Measured memory_bytes: 968
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a) for(int i=0;i<a;i++)
#define ender {return 0;}
#define tosasuretu(a) (a*(a+1)/2)
inline ll kaizyo(ll);
ll gcd(ll, ll);
ll combination(ll, ll);
int main() {
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b)*h / 2 << endl;
	return 0;
}


inline ll kaizyo(ll x) {
	long ans = 1;
	for (int z = 0; z < x; z++) {
		ans *= (x - z);
	}
	return ans;
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input!{
        source = src,
        xn: [usize; 5]
    }


    for (i, x) in xn.iter().enumerate() {
        if *x == 0 {
            return (i+1).to_string();
        }
    }
    return 0.to_string();
}


Measured memory_bytes: 2108
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll INF = 1e16;

ll n, mod;
vvl G;
vl dp1;  // dp1[v] : 頂点vを根とする下方向の部分木の塗り方の数
vl dp2;  // dp2[v] : 頂点vを根とする上方向の部分木の塗り方の数
vl ans;  // ans[v] : 頂点vを黒で塗るときの塗り方の数

void dfs1(ll v, ll p = -1) {
    // 行きの処理はこのへんに書く
    ll x = 1;
    for(ll to : G[v]) {
        if(to == p) {
            continue;
        }
        dfs1(to, v);
        // 帰りの処理はこのへんに書く
        x = x * dp1[to] % mod;
    }
    dp1[v] = x + 1;
}

void dfs2(ll v, ll p = -1) {
    // 行きの処理はこのへんに書く
    if(p == -1) {
        dp2[v] = 1;
    }
    vl ruiL(G[v].size(), 1);
    rep(i, G[v].size()) {
        ll to = G[v][i];
        if(i-1 >= 0) {
            ruiL[i] = ruiL[i-1];
        }
        if(to == p) {
            continue;
        }
        ruiL[i] = dp1[to] * ruiL[i] % mod;
    }
    vl ruiR(G[v].size(), 1);
    for(ll i = G[v].size()-1; i >= 0; i--) {
        ll to = G[v][i];
        if(i+1 < G[v].size()) {
            ruiR[i] = ruiR[i+1];
        }
        if(to == p) {
            continue;
        }
        ruiR[i] = dp1[to] * ruiR[i] % mod;
    }
    rep(i, G[v].size()) {
        ll to = G[v][i];
        if(to == p) {
            continue;
        }
        ll x = 1;
        if(i-1 >= 0) {
            x = x * ruiL[i-1] % mod;
        }
        if(i+1 < G[v].size()) {
            x = x * ruiR[i+1] % mod;
        }
        dp2[to] = (x * dp2[v] + 1) % mod;
        dfs2(to, v);
    }
}

void dfs3(ll v, ll p = -1) {
    // 行きの処理はこのへんに書く
    ans[v] = dp2[v];
    for(ll to : G[v]) {
        if(to == p) {
            continue;
        }
        ans[v] = ans[v] * dp1[to] % mod;
        dfs3(to, v);
        // 帰りの処理はこのへんに書く
    }
}

int main() {
    
    cin >> n >> mod;    
    
    G.resize(n);
    rep(i, n-1) {
        ll x, y;
        cin >> x >> y;
        x--;  y--;
        G[x].pb(y);
        G[y].pb(x);
    }

    dp1.resize(n);
    dp2.resize(n);
    ans.resize(n);
    const ll root = 0;
    dfs1(root);
    dfs2(root);
    dfs3(root);

    rep(v, n) {
        out(ans[v]);
    }

    re0;
}

Measured memory_bytes: 21344
#include <iostream>
#include <string>
#include <stack>
using namespace std;
const int MAX_N = 2048;
int N, M;
char a[MAX_N][MAX_N];
int ne[MAX_N][MAX_N], spom[MAX_N];
string s;
stack < pair <int, int> > st;
int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
	cin >> N >> M;
	for(int i = 1; i <= N; ++ i)
    {
        cin >> s;
        for(int j = 0; j < M; ++ j)   a[i][j + 1] = s[j];
    }
    int ans = max(N, M);
    for(int i = 1; i < N; ++ i)
    {
        for(int j = 1; j < M; ++ j)
        {
            int brb = 0;
            for(int k = 0; k < 2; ++ k)
            {
                for(int p = 0; p < 2; ++ p)
                {
                    if(a[i + k][j + p] == '#')   ++ brb;
                }
            }
            if(brb % 2)   ne[i][j] = 0;
            else   ne[i][j] = 1;
        }
    }
    for(int i = 2; i < N; ++ i)
    {
        for(int j = 1; j < M; ++ j)
        {
            if(ne[i][j] == 0)   continue;
            ne[i][j] += ne[i - 1][j];
        }
    }
    for(int i = 1; i < N; ++ i)
    {
        for(int j = 1; j < M; ++ j)
        {
            if(ne[i][j] == 0)
            {
                while(!st.empty())   st.pop();
                continue;
            }
            pair <int, int> curr = {ne[i][j], 1};
            while(!st.empty() && (st.top().first >= curr.first))
            {
                curr.second += st.top().second;
                st.pop();
            }
            spom[j] = curr.second;
            st.push(curr);
        }
        while(!st.empty())   st.pop();
        for(int j = M - 1; j >= 1; -- j)
        {
            if(ne[i][j] == 0)
            {
                while(!st.empty())   st.pop();
                continue;
            }
            pair <int, int> curr = {ne[i][j], 1};
            while(!st.empty() && (st.top().first >= curr.first))
            {
                curr.second += st.top().second;
                st.pop();
            }
            int curans = (spom[j] + curr.second) * (curr.first + 1);
            if(curans > ans)   ans = curans;
            st.push(curr);
        }
        while(!st.empty())   st.pop();
    }
    cout << ans << "\n";
	return 0;
}


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

long long N, M, P[114514], A, B, C, D, E, i;

int main(){
  scanf("%lld%lld%lld", &N, &M, &A);
  for(i = 1; i < M; ++i){
    scanf("%lld", &B);
    --P[max(A, B)];
    ++P[min(A, B)];
    swap(A, B);
  }
  A = 0;
  B = *P;
  for(i = 1; i < N; ++i){
    B += P[i];
    scanf("%lld%lld%lld", &C, &D, &E);
    //cout << B << endl;
    A += min(B * C, B * D + E);
  }
  cout << A << endl;
  return 0;
}

Measured memory_bytes: 4012
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {

	int A, B, C, K;
	cin >> A >> B >> C >> K;
	vector<int> ABC = { A, B, C };

	cout << *max_element(ABC.begin(), ABC.end()) * ll(pow(2, K)) + A + B + C - *max_element(ABC.begin(), ABC.end());
	return 0;
}

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

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

  bool ac = false;
  for (int i = 0; i < s.size() - 1; ++i) {
    string sub = s.substr(i, 2);
    if (sub == "AC")
      ac = true;
  }

  if (ac)
    puts("Yes");
  else
    puts("No");
}

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

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

int main()
{
    int n ;
    cin >> n ;
    call( n ) ;
    return 0 ;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using Graphi = vector<vi>;
using Graphe = vector<vector<edge> >;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
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; }

Graphi G;
vi w;
vl flow_ans;
void dfs(int v,int p = -1, ll flow = 0){
    ll flow_now = flow + w.at(v);
    flow_ans.at(v) = flow_now;

    for(auto nv : G.at(v)){
        if(nv == p) continue;
        dfs(nv,v,flow_now);
    }
}

int main(){

    int n,q; cin >> n >> q;
    G.resize(n);
    rep(i,n-1){
        int a,b; cin >> a >> b;
        a--;b--;
        G.at(a).push_back(b);
        G.at(b).push_back(a);
    }
    w.assign(n,0);
    flow_ans.assign(n,0);
    rep(i,q){
        int q,x; cin >> q >> x;
        q--;
        w.at(q) += x;
    }
    dfs(0);
    rep(i,n) cout << flow_ans.at(i) << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 25088
n=int(input())
t=(1,2,3,4,5,6,7,8,9,10,12,14,16,18,15,21,24,27,20,28,32,36,25,30,35,40,45,42,48,54,49,56,63,64,72,81)
if n in t:
  print("Yes")
else:
  print("No")

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

using namespace std;

int main()
{
    string s;
    int K;
    vector<string> substrings;

    cin >> s >> K;
    for(int i = 0; i < s.size(); ++i) {
        for(int j = 1; j <= 5; ++j) {
            substrings.push_back(s.substr(i, j));
        }
    }
    sort(substrings.begin(), substrings.end());
    substrings.erase(unique(substrings.begin(), substrings.end()), substrings.end());
//    for(auto hoge : substrings) cout << hoge << endl;
    cout << substrings[K - 1] << endl;
    return 0;
}


Measured memory_bytes: 1660
import math
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    xy = [tuple(map(int, input().split())) for _ in range(n)]
    dis = [[None for _ in range(n)] for _ in range(n)]
    sum_v = 0
    p = 1
    for i in range(n):
        p *= i + 1
        for j in range(n):
            if i == j or dis[i][j] is not None:
                continue
            d = math.sqrt((xy[i][0] - xy[j][0]) ** 2 + (xy[i][1] - xy[j][1]) ** 2)
            dis[i][j] = d
            dis[j][i] = d
            sum_v += d
    print(sum_v * 2 / n)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
program ABC178C
    implicit none
    integer(8)::N,i,m=10**9+7,ans=0,c10,c8,c9
    read*,N
    if(N==1)then
        print'(i0)',ans
    else
        c10=1
        c8=1
        c9=1
        do i=1,N
            c10=c10*10
            c10=mod(c10,m)

            c9=c9*9
            c9=mod(c9,m)

            c8=c8*8
            c8=mod(c8,m)
        end do
        ans=mod(c10-2*c9+c8,m)
        if(ans<0)ans=ans+m
        print'(i0)',ans
    end if
end program ABC178C

Measured memory_bytes: 2920
#include <iostream>
#include<algorithm>

using namespace std;
#define ll long long

int main() {
	int n, a[200000], m;
	ll ans = 0;
	cin >> n;
	m = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] < 0) {
			a[i] = -a[i];
			m++;
		}
	}
	if (m % 2 == 0) {
		for (int i = 0; i < n; i++) {
			ans += a[i];
		}
	}
	else {
		sort(a, a + n);
		for (int i = 1; i < n; i++) {
			ans += a[i];
		}
		ans -= a[0];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640