akhauriyash/Code-Regression huggingface dataset:
#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>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
vector<int> G[200000];
int distan[200000];
void dist(int v,int f,int c){
	distan[v] = c;
	for(int i=0;i<G[v].size();i++){
		int t = G[v][i];
		if(t != f){
			dist(t,v,c+1);
		}
	}
}
void Calc(){
	int N = rei();
	for(int i=0;i<N-1;i++){
		int f = rei()-1;
		int t = rei()-1;
		G[f].push_back(t);
		G[t].push_back(f);
	}
	dist(0,-1,0);
	int maxd = 0;
	for(int i=0;i<N;i++){
		if(distan[maxd] < distan[i]){
			maxd = i;
		}
	}
	dist(maxd,-1,0);
	int diam = 0;
	for(int i=0;i<N;i++){
		diam = max(diam,distan[i]);
	}
	if(diam % 3 == 1){
		cout << "Second" << endl;
	}
	else{
		cout << "First" << endl;
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 24448
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
main(){
    int W,A,B;
    cin >> W >> A >> B;
    if(min(A,B)+W>=max(A,B))cout << 0 << endl;
    else cout << max(A,B)-min(A,B)-W << endl;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n,m,k;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m;
    int ans=0;
    int outlet=1;
    while(outlet<m){
        outlet+=(n-1);
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////
/*
4 4
4 0 0 0
*/

vector<pair<LL,int> > make(LL K) {
	vector<pair<LL, int>> ans;
	LL bit = 1;
	for (int i = 0; K; ++i) {
		if (K & bit) {
			K ^= bit;
			ans.push_back(pair<LL, int>(K, i));
		}
		bit <<= 1;
	}
	return ans;
}
void solve() {
	LL N, K;
	cin >> N >> K;
	vector<int> B(60);
	vector<LL> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		LL ter = A[i];
		for (int j = 0; j < 60; ++j) {
			B[j] += (ter & 1);
			ter /= 2;
		}
	}

	vector<LL> ans;
	ans.push_back(K);

	vector<pair<LL,int>> X = make(K);
	int len = X.size();
	LL base = (LL)1 << 59;
	for(int x=0;x<len;++x){
		LL now = X[x].first;
		base = (LL)1 << max(0, X[x].second - 1);

		for (int i = X[x].second-1; i >= 0; --i) {
			LL bit1 = B[i];
			LL bit0 = N - B[i];
			LL H = N / 2;
			if (bit0 > H) {
				now += base;
			}
			base >>= 1;
		}
		ans.push_back(now);
	}
	LL ans2 = 0;
	for(int a=0;a<ans.size();++a){
		LL res = 0;
		for (int i = 0; i < N; ++i) {
			res += (ans[a] ^ A[i]);
		}
		chmax(ans2, res);
	}
	cout << ans2 << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 1024
/***
**     Author: Khairul Anam Mubin
**     Bangladesh University of Business and Technology,
**     Dept. of CSE.
***/

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <string>
#include <sstream>
#include <iterator>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>

#define pb       push_back
#define Sqr(n)   (n*n)
#define Sort(v)  sort(v.begin(),v.end())
#define Mxe(v)   *max_element(v.begin(),v.end())
#define Mne(v)   *min_element(v.begin(),v.end())
#define Fill0(a) memset(a,0,sizeof(a))
#define Fin      freopen("input.txt","r",stdin)
#define Fout     freopen("output.txt","w",stdout)

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
const double pi = acos(-1.0);

template <typename T> T Abs(T a) {if(a<0)return -a;else return a;}
template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T Pow(T B,T P){ if(P==0) return 1; if(P&1) return B*Pow(B,P-1);  else return Sqr(Pow(B,P/2));}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template <typename T> T exgcd(T a,T b,T &x,T &y) {if(a<0){T d=exgcd(-a,b,x,y);x=-x;return d;}   if(b<0){T d=exgcd(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=exgcd(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}

char uplowch(char ch){if(ch >= 'A' &&  ch <= 'Z') ch += 32; return ch;}
char lowupch(char ch){if(ch >= 'a' &&  ch <= 'z') ch -= 32; return ch;}
bool isalpha(char ch){if((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) return true; return false;}
int strtoint(string str){stringstream ss(str);int x = 0;ss >> x ;return x ;}
string intostr(int x){stringstream ss; ss << x; string str = ss.str(); return str;}
vector<string> linetostr(string str){string s; vector <string> v ;istringstream is(str); while(is >> s)v.pb(s);return v;}

#define MOD 1000000007
#define MAX -1000000007
#define MIN 1e9 + 7

//int dx[] = {0,0,-1,1,-1,-1,1,1};
//int dy[] = {1,-1,0,0,-1,1,-1,1};

//Code starts from here......

int main() {
    string str ;
    int n ;
    while(cin >> str >> n){
        int len = str.size() ;
        for(int i = 0 ; i < len ; i+= n)
            if(i < len)
                cout << str[i];
        cout << "\n";
    }

    return 0;
}

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

// find the modular inverse using extended Euclidean algorithm
long long modinv(long long a, long long mod) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long q = a / b;
        a -= q * b;
        swap(a, b);
        u -= q * v;
        swap(u, v);
    }
    u %= mod;
    if (u < 0) {
        u += mod;
    }
    return u;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int K;
    cin >> K;
    string S;
    cin >> S;
    long long mod = 1E9 + 7;
    int L = S.length();
    long long cur = 1;
    long long C = 1;
    for (int i = 0; i < K; ++i) {
        C = (((C * (L + i)) % mod) * modinv(i + 1, mod) % mod) * 25 % mod;
        cur = (cur * 26 + C) % mod;
    }
    cout << cur << '\n';
    return 0;
}

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

int N, A, B, C;
vector<int> l;

int dfs(int, int, int, int);
int main(){
	cin >> N >> A >> B >> C;

	l.resize(N);
	for(int i = 0; i < N; ++i){
		cin >> l[i];
	}

	cout << dfs(0, 0, 0, 0) << endl;

	return 0;
}
	
int dfs(int n, int a, int b, int c){
	if(n == N){
		if(min({a, b, c}) > 0){
			return abs(a-A)+abs(b-B)+abs(c-C) - 30;
		}else{
			return 10000000; // INF
		}
	}
	int p1 = dfs(n+1, a+l[n], b, c) + 10;
	int p2 = dfs(n+1, a, b+l[n], c) + 10;
	int p3 = dfs(n+1, a, b, c+l[n]) + 10;
	int p4 = dfs(n+1, a, b, c);

	return min({p1, p2, p3, p4});
}



Measured memory_bytes: 256
n = int(input())
l = []
s = 0
for i in range(1,n+1):
    if i%15==0:
        continue
    elif i%3==0:
        continue
    elif i%5==0:
        continue
    else:
        l.append(i)
        
for i in l:
    s += i
    
print(s)

Measured memory_bytes: 29960
def examA():
    N = I()

    ans = 0
    print(ans)
    return

def examB():
    N, M = LI()
    A = LI()
    S = sum(A)
    if N>=S:
        ans = N-S
    else:
        ans = -1
    print(ans)
    return

def examC():
    N = I()
    A = LI()
    ans = [0]*N
    for i in range(N-2,-1,-1):
        ans[A[i]-1] +=1
    for v in ans:
        print(v)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 102080
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;
// use std::cmp::max;
// use std::cmp::min;


fn main() {
    input! {
        N: i64,
    }

    let a = N / 100;
    // let b = N / 10;
    let c = N % 10;
    let ans = if a == c { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 2128
#include<bits/stdc++.h>
#define maxn 100010
#define pii pair<long long,long long>
using namespace std;
long long a[maxn];
map<long long,int>mp;
set<pii>s;
vector<int>e[maxn];
int ans[maxn][2],dp[maxn],d[maxn],vis[maxn];
long long sz[maxn],w[maxn];
priority_queue<pii>pq;
void dfs(int x)
{
    if(vis[x])return;
    vis[x]=1;
    sz[x]=1;
    for(int i=0;i<e[x].size();i++)
    {
        int k=e[x][i];
        if(vis[k])continue;
        dfs(k);
        sz[x]+=sz[k];
        w[x]+=w[k]+sz[k];
    }
}
int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        mp[a[i]]=i;
        s.insert({a[i],i});
    }
    for(int i=1;i<=n;i++)dp[i]=1;
    int f=0,cnt=0,x;
    for(int i=1;i<n;i++)
    {
        pii tmp=*(--s.end());
        s.erase(tmp);
        int y=tmp.second;
        if(!mp.count(a[y]-n+dp[y]*2)){f=1;break;}
        int u=mp[a[y]-n+dp[y]*2];
        e[u].push_back(y);
        e[y].push_back(u);
        ans[cnt][0]=u;
        ans[cnt][1]=y;
        dp[u]+=dp[y];
        cnt++;
        x=u;
    }
    x=s.begin()->second;
    dfs(x);
    for(int i=1;i<=n;i++)if(!vis[i])f=1;
    if(w[x]!=a[x])f=1;
    if(f)
    {
        cout<<-1<<endl;
        exit(0);
    }
    for(int i=0;i<cnt;i++)cout<<ans[i][0]<<" "<<ans[i][1]<<endl;
return 0;
}


Measured memory_bytes: 22912
#include<stdio.h>

typedef struct{

  int key;
  int p;
  int l;
  int r;
}Node;


int main(){

  int n,i,k;

  scanf("%d",&n);

  Node N[n+1];


 for(i=0;i<=n;i++){

   N[i].key = N[i].p = N[i].l = N[i].r = -1;
   
 }
  for(i=1;i<=n;i++){

    scanf("%d",&k);

    N[i].key = k;

    if(i != 1){

      N[i].p = i/2;
    }

      if((2*i) <= n) N[i].l = 2*i;

      if(((2*i)+1) <= n) N[i].r = 2*i+1;
    
    

  }

 for(i=1;i<=n;i++){
   printf("node %d: ",i);
   printf("key = %d, ",N[i].key);
   if(N[i].p!=-1)
     printf("parent key = %d, ",N[N[i].p].key);
   if(N[i].l!=-1)
     printf("left key = %d, ",N[N[i].l].key);
    if(N[i].r!=-1)
     printf("right key = %d, ",N[N[i].r].key);
   
   printf("\n");
 }
 return 0;
}



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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll c[3][3],a,b,C,d;
    rep(i,3){
        rep(j,3)cin >> c[i][j];
    }
    a = c[0][0]+c[1][1]+c[2][2];
    b = c[2][0]+c[1][1]+c[0][2];
    C = c[0][1]+c[1][0]+c[2][2];
    d = c[0][0]+c[1][2]+c[2][1];
    if(a==b && b==C && C==d && d==a)
    cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  int N;
  cin >> N;
  string S;
  map<string, int> res;
  rep(i, N){
    cin >> S;
    res[S]++;
  }
  cout << res.size() << endl;
}

Measured memory_bytes: 19180
h, w = map(int, input().split())
S = [input() for _ in range(h)]

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

flag = True
for i in range(h):
    for j in range(w):
        if S[i][j] == ".":
            continue

        check = False
        for nx, ny in zip(dx, dy):
            nx += i
            ny += j

            if 0 <= nx < h and 0 <= ny < w:
                if S[nx][ny] == "#":
                    check = True

        if not check:
            flag = False
            break

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
n,a,b=map(int,input().split())
num = 0
all = 0

def sum(x):
  total = 0
  while x>0:
    num = x%10
    total +=num
    num=0
    x = int(x/10)
  
  return total
    
for i in range(1,n+1):
  if sum(i)>=a and sum(i)<=b:
    all +=i
  
print(all)


Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define dupl(s) s.erase(unique(s.begin(), s.end()), s.end());//重複取り除き
#include <bits/stdc++.h>
using namespace std;
int sum(vector<int> s){return accumulate(s.begin(),s.end(),0);}
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    double n;
    int k;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1; i <= n; i++){
      int score = i;
      int cnt = 0;
      while(score < k){
        score *= 2;
        cnt++;
      }
      ans += (1/n) * pow(0.5,cnt);
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 4104
from operator import itemgetter


n, m = map(int, input().split())
p = [0] * m
y = [0] * m

d = {}

for i in range(m):
    p[i], y[i] = map(int, input().split())

    if not p[i] in d:
        d[p[i]] = []

    d[p[i]].append([y[i], i])

for v in d.values():
    v.sort(key=itemgetter(0))

ans = [None] * m

for k, v in d.items():
    for i, vv in enumerate(v):
        ans[vv[1]] = str(k).zfill(6) + str(i + 1).zfill(6)

print("\n".join(ans))


Measured memory_bytes: 51504
#include<bits/stdc++.h>
#define int long long int
#define db double
#define ull unsigned long long
#define vii vector <int>
#define pii pair <int, int>
#define fi first
#define se second
#define rep(i,a,n)		for(int i=a;i<n;i++)
#define endl '\n'
#define mem(a,b) memset(a, b, sizeof a)
#define mkp make_pair
#define pb push_back
#define mod 1000000007LL
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
using namespace std;
db pi=3.1415926535;
db eps=0.000001;
 
void print(vector <int> &arr){
	for(int i=0;i<arr.size();i++)
		cout<<arr[i]<<" ";
	
	cout<<endl;
}
int ncr(int n, int r)
{
    r=min(r,n-r);
    int A[r],i,j,B[r];
    iota(A,A+r,n-r+1);  //initializing A starting from n-r+1 to n
    iota(B,B+r,1);      //initializing B starting from 1 to r

    int g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    int ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}


int32_t main(){
/////////////////////////////////////////////////////////////////////
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
//	std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//    std::cout.precision(5);
	int t=1;
	//cin>>t;
	while(t--){
	int n,k;
	cin>>n>>k;
	if(n==k){
		cout<<0<<endl;
		
	}
	else if(n<k){
		cout<<min(n,k-n)<<endl;
		
	}
	else if(n>k && n%k==0){
		cout<<0<<endl;
		
	}
	else{
		
		int a=n/k;
		a++;
		if(k*a-n>=0)
		cout<<min(k*(a)-n,n%k)<<endl;
		else cout<<n%k<<endl;
		
		
	}
	}
	return 0;
	}

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

#define STRING(str) #str
#define ll long long

template <typename T >
void print_vec_1d(vector<T> x, string name) {
	cout << name << endl;
	cout << "[ ";
	for (int i=0;i<x.size();i++) {
		cout << x[i];
		if (i != x.size()-1) cout << ", ";
		else cout << " ]" << endl;
	}
}

int main() {
	string S;
	cin >> S;
	int N = S.size();
	vector<int> sa = suffix_array(S);
	vector<int> la = lcp_array(S, sa);

	ll ans = (ll)N*(N+1)/2;
	for (auto val : la) {
		ans -= val;
	}
	cout << ans << endl;
}

Measured memory_bytes: 15640
from sys import stdin

def main():
    N, K = map(int, input().split())
    H = list(map(int, stdin.read().splitlines()))

    H.sort()
    ans = float('inf')
    for i in range(N - K + 1):
        j = i + K - 1
        ans = min(ans, H[j] - H[i])
    print(ans)

input = lambda: stdin.readline()
main()


Measured memory_bytes: 14056
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int A, B;

int main() {
    cin >> A >> B;
    cout << max(0, A-B*2) << endl;
}

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

using namespace std;

const int N = 1e5;

int readInt ()
{
    bool minus = false;
    int 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;
}
main() {
    int a = readInt(), b = readInt();
    cout << max(max(a + b, a - b), a * b);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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;}

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

int main(){
    int A,B;
    cin>>A>>B;
    if(A>=10||B>=10){
        cout<<-1<<endl;
    }else cout<<A*B<<endl;
    return 0;
}

//a=97,z=122

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

#define rep(i, n) for (int i = 0; i < (n); i++)
int gcd(int a, int b){ return (a%b ? gcd(b,a%b) : b); }

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n){
        cin >> a[i];
    }

    int g = a[0];
    for(int i = 1;i<n;i++){
        g = gcd(g,a[i]);
    }

    cout << g;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>> maze(h,vector<char>(w));
    rep(i,h){
        rep(j,w){
            cin>>maze.at(i).at(j);
        }
    }
    int dp[h][w];
    dp[0][0]=0;
    if(maze.at(0).at(0)=='#') dp[0][0]=1;
    else dp[0][0]=0;
    rep(i,h-1){
        if(maze.at(i).at(0)=='.' && maze.at(i+1).at(0)=='#') dp[i+1][0]=dp[i][0]+1;
        else dp[i+1][0]=dp[i][0];
    }
    rep(j,w-1){
        if(maze.at(0).at(j)=='.' && maze.at(0).at(j+1)=='#') dp[0][j+1]=dp[0][j]+1;
        else dp[0][j+1]=dp[0][j];
    }
    rep(i,h-1){
        rep(j,w-1){
            int a=dp[i+1][j];
            int b=dp[i][j+1];
            if(maze.at(i+1).at(j)=='.' && maze.at(i+1).at(j+1)=='#') a++;
            if(maze.at(i).at(j+1)=='.' && maze.at(i+1).at(j+1)=='#') b++;
            dp[i+1][j+1]=min(a,b);
        }
    }
    cout<<dp[h-1][w-1];
}


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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

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

	vector<bool> row(h*w),col(h*w);
	rep(i,h){
		int a; scanf("%d",&a); a--;
		if(row[a]) return puts("0"),0;
		row[a]=true;
	}
	rep(j,w){
		int b; scanf("%d",&b); b--;
		if(col[b]) return puts("0"),0;
		col[b]=true;
	}

	mint ans=1;
	int cnt1=0,cnt2=0;
	rep(t,h*w){
		int num=h*w-t-1;
		if(row[num] && col[num]){
			cnt1++;
			cnt2++;
		}
		else if(row[num]){
			ans*=cnt2;
			cnt1++;
		}
		else if(col[num]){
			ans*=cnt1;
			cnt2++;
		}
		else{
			if(cnt1*cnt2<t) return puts("0"),0;
			ans*=cnt1*cnt2-t;
		}
	}
	printf("%d\n",ans.to_int());

	return 0;
}


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

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

  int ans;
  if (n >= 10) {
    ans = r;
  } else {
    ans = r + 100 * (10 - n);
  }

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

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N; cin >> N;
  vector<vector<int>> g(N);
  vector<pair<int, int>> edges;
  rep(i, N - 1) {
    int a, b; cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
    edges.emplace_back(a, b);
  }
  int K = 0;
  rep(i, N) {
    K = max(K, (int)g[i].size());
  }
  cout << K << endl;
  queue<pair<int, int>> q;
  q.emplace(0, -1);
  vector<bool> vis(N);
  vis[0] = 1;
  map<pair<int, int>, int> edge_to_color;
  while(!q.empty()) {
    auto t = q.front(); q.pop();
    int curr, skip_color; tie(curr, skip_color) = t;
    int color = 1;
    rep(i, g[curr].size()) {
      auto next = g[curr][i];
      if (vis[next]) { continue; }
      vis[next] = 1;

      if (color == skip_color) { color++; }
      edge_to_color[make_pair(curr, next)] = color;

      q.emplace(next, color);

      color++;
    }
  }
  rep(i, N - 1) {
    if (edge_to_color.find(edges[i]) != edge_to_color.end()) {
      cout << edge_to_color[edges[i]] << "\n";
    }
    else {
      cout << edge_to_color[make_pair(edges[i].second, edges[i].first)] << "\n";
    }
  }
}


Measured memory_bytes: 13044
import java.util.*;
import java.math.*;

public class Main {

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

    for (int i = 0; i < s.length(); i++) {
      System.out.print("x");
    }
    System.out.println();
  }

}


Measured memory_bytes: 23892
#include <iostream>

using namespace std;

int f[100][10];
int p[100][10];

int n;

int num[100002][31];
int main(){
	int n, c;
	cin >> n >> c;
	
	for(int i = 0;i <= 100000;i++){
		for(int j = 0;j < 30;j++){
			num[i][j] = 0;
		}
	}
	
	for(int i = 0;i < n;i++){
		int s, t, c;
		cin >> s >> t >> c;
		
		num[s][c] += 1;
		num[t][c] -= 1;
	}
	
	int res = 0, now = 0;
	for(int i = 0;i <= 100000;i++){
		int p = 0, n = 0;
		for(int j = 0;j <= c;j++){
			//cout << num[i][j] << " ";
			if(num[i][j] == 1) p++;
			else if(num[i][j] == -1) n++;
		}
		
		int need = now + p;
		res = max(res, need);
		
		now = now + p - n;
		
		//cout << ":" << p << "," << n << "," << now << endl;
	}
	cout << res << endl;
	
	return 0;
}

/*
int calc(int x){
	int num[100];
	for(int i = 0;i < n;i++){
		num[i] = 0;
	}
	
	for(int i = 0;i < 10;i++){
		if((x&(1<<i)) != 0){
			for(int j = 0;j < n;j++){
				if(f[j][i]){
					num[j]++;
				}
			}
		}
	}
	
	int ret = 0;
	for(int i = 0;i < n;i++){
		ret += p[i][num[i]];
	}
	
	return ret;
}

int main(){
	cin >> n;
	
	for(int i = 0;i < n;i++){
		for(int j = 0;j < 10;j++){
			cin >> f[i][j];
		}
	}
	for(int i = 0;i < n;i++){
		for(int j = 0;j < 11;j++){
			cin >> p[i][j];
		}
	}
	
	int res = -1100000000;
	for(int i = 1;i < (1<<10);i++){
		res = max(res, calc(i));
	}
	cout << res << endl;
	
	return 0;
}
*/

Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;
const int MAX = 510000;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){   
    ll n,m;
    cin >> n >> m;
    COMinit();
    if(abs(n-m)==0){
        cout << (2 * ((fac[n] * fac[m]) % MOD))%MOD << endl;
    }else if(abs(n-m) == 1){
        cout << ((fac[n] * fac[m]) % MOD)%MOD << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 12160
import sys
input = sys.stdin.readline

n = int(input())
l = list(map(int, input().split()))
ans = 0
cnt = 0
for i in range(1, n):
	if l[i] > l[i-1]:
		cnt = 0
	else:
		cnt += 1
	ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 59632
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 座標の最大値 */
	private static final int MAX = 100;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] x = new int[n], y = new int[n], h = new int[n];
			IntStream.range(0, n).forEach(i -> {
				x[i] = scanner.nextInt();
				y[i] = scanner.nextInt();
				h[i] = scanner.nextInt();
			});
			for (int i = 0; i <= MAX; i++) {
				for (int j = 0; j <= MAX; j++) {
					int ch = check(n, x, y, h, i, j);
					if (ch > 0) {
						System.out.println(i + " " + j + " " + ch);
						return;
					}
				}
			}
		}
	}

	/**
	 * 指定されたcx,cyでHを計算する
	 * 
	 * @param n  座標数
	 * @param x  X座標の一覧
	 * @param y  Y座標の一覧
	 * @param h  hの一覧
	 * @param cx
	 * @param cy
	 * @return 指定されたcx,cyで計算したH、計算できない場合は−1
	 */
	private static int check(int n, int[] x, int[] y, int[] h, int cx, int cy) {
		int ch = -1;
		for (int i = 0; i < n; i++) {
			if (h[i] > 0) {
				ch = Math.abs(x[i] - cx) + Math.abs(y[i] - cy) + h[i];
				break;
			}
		}
		for (int i = 0; i < n; i++) {
			if (h[i] != Math.max(ch - Math.abs(x[i] - cx) - Math.abs(y[i] - cy), 0)) {
				return -1;
			}
		}
		return ch;
	}
}


Measured memory_bytes: 39912
N,K=map(int,input().split())
A=list(map(int,input().split()))

N=N-K
if N==0:
    print(1)
else:
    i=1
    while(N-(K-1)>0):
        i+=1
        N=N-(K-1)
    if N!=0:
        i+=1
    print(i)

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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

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

void init(){
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const int N = 1e6+5;
bool arr[N];

int main()
{
	init();
	ll a, b;
	int ans = 1;
	cin >> a >> b;
	a = __gcd(a, b);
	if(a % 2 == 0){
		++ans;
		while(a % 2 == 0)
			a /= 2;
	}
	b = sqrt(a);
	b = min(1000000LL, b+1);
	for (ll i = 3; i < b; i += 2) {
		if(!arr[i]){
			if(a % i == 0){
				++ans;
				while(a % i == 0)
					a /= i;
			}
			for (ll j = i * i; j < b; j += 2*i) {
		    	arr[j] = 1;
		    }
		}
	}
	if(a > 1)
		++ans;
	cout << ans;
	return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <strings.h>

int
main(int argc, char *argv[])
{
    int H, W, A, B;
    char mat[1001][1001];
    int i, j;
    int p, on;

    scanf("%d%d%d%d", &H, &W, &A, &B);
    bzero(mat, sizeof(mat));

    for (i=0; i<H; i++) {
        for (j=0; j<W; j++) {
                if ((j<A && i<B) || (j>=A && i>=B)) {
                    mat[i][j] = '1';
                }
                else {
                    mat[i][j] = '0';
                }
        }
    }

    for (i=0; i<H; i++) {
        printf("%s\n", mat[i]);
    }
    
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define INF 2e9
#define ll long long


struct union_find{

    vector<int> par, r;

    //union find初期化
    union_find(int n){
        par.resize(n);  //vectorのサイズを変更する
        r.resize(n);
        for(int i=0; i<n; i++){
            par[i] = i;
            r[i] = 0;
        }
    }

    //union find 木の根を求める
    int find(int x){
        if(par[x] == x){
            return x;
        }
        else{
            return par[x] = find(par[x]);
        }
    }

    //union find xとyの属する集合を結合
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y){
            return;
        }
        if(r[x] < r[y]){
            par[x] = y;
        }
        else{
            par[y] = x;
            if(r[x] == r[y]){
                r[x]++;
            }
        }
    }

    //union find xとyが同じ集合に属するか否か
    bool same(int x, int y){
        return find(x) == find(y);
    }
};
    
int main(){

    int n, k, l;
    cin>>n>>k>>l;

    union_find road(n), train(n);

    for(int i=0; i<k; i++){
        int a, b;
        cin>>a>>b;
        a--, b--;
        if(!road.same(a, b)){
            road.unite(a, b);
        }
    }

    for(int i=0; i<l; i++){
        int a, b;
        cin>>a>>b;
        a--, b--;
        if(!train.same(a, b)){
            train.unite(a, b);
        }
    }

    vector<pair<int, int> > com(n);
    map<pair<int, int>, int> s;

    for(int i=0; i<n; i++){
        com[i].first = road.find(i);
        com[i].second = train.find(i);
        s[com[i]]++;
    }

    for(int i=0; i<n; i++){
        cout<<s[com[i]]<<" ";
    }

    cout<<endl;


    return 0;
}

Measured memory_bytes: 16640
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000001;
const long long LINF = 1e18;
const int MAX = 510000;

int main() {
	string s;
	cin >> s;
	int i = 0;
	int cnt = 0;
	while (i < s.size()-1) {
		if (s[i] != s[i + 1]) {
			cnt++;
			i++;
		}
		else {
			i += 3;
			if (i > s.size()) {
				cnt += 1;
			}
			else {
				cnt += 2;


			}
		}
		
	}
	if (i == s.size() - 1)cnt++;
	cout << cnt << endl;
		return 0;
}

Measured memory_bytes: 3760
# Author: cr4zjh0bp
# Created: Sun 15 Mar 2020 06:17:23 PM UTC
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

s = ns()
n = len(s)

p = ""
c = ""
ans = 0
i = 0
for i in range(n):
    c = c + s[i]
    if p != c:
        p = c
        c = ""
        ans += 1

print(ans)

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long a, long long b, long long c){
    lint res = min(a+b, a+c);
    res = min(res, a+c);
    res = min(res, b+c);
    cout << res << endl;

}

int main(){

    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    solve(a, b, c);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#define LL long long
#define dob complex<double>
#define Abs(a) ((a) < 0 ? (-(a)) : (a))
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Swap(a, b) ((a) ^= (b), (b) ^= (a), (a) ^= (b))
#define writeln(x) (write(x), putchar('\n'))
#define lowbit(x) ((x)&(-(x)))
using namespace std;
const int N = 100000;
const int yzd = 1e9+7;
void read(int &x) {
    char ch; bool flag = 0;
    for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == '-')) || 1); ch = getchar());
    for (x = 0; isdigit(ch); x = (x<<1)+(x<<3)+ch-48, ch = getchar());
    x *= 1-2*flag;
}
void print(int x) {if (x > 9) print(x/10); putchar(x%10+48); }
void write(int x) {if (x < 0) putchar('-'); print(Abs(x)); }
 
int n, m, s, t, u, v, c;
struct tt {int to, next, cost; }edge[(N<<2)+5];
int path[N+5], top;
int ans1[N+5], ans2[N+5], vis[N+5], in[N+5];
LL dist1[N+5], dist2[N+5];
queue<int>Q;
vector<int>to[N+5];
 
void add(int u, int v, int c) {
    edge[++top].to = v, edge[top].cost = c, edge[top].next = path[u], path[u] = top;
}
void SPFA(int s, LL *dist) {
    dist[s] = 0; Q.push(s); vis[s] = 1;
    while (!Q.empty()) {
    int u = Q.front(); Q.pop(); vis[u] = 0;
    for (int i = path[u]; i; i = edge[i].next)
        if (dist[edge[i].to] > dist[u]+edge[i].cost) {
        dist[edge[i].to] = dist[u]+edge[i].cost;
        if (!vis[edge[i].to]) {
            vis[edge[i].to] = 1; Q.push(edge[i].to);
        }
        }
    }
}
void topsort(int s, LL *dist, int *ans) {
    for (int u = 1; u <= n; u++) {
    to[u].clear();
    for (int i = path[u]; i; i = edge[i].next)
        if (dist[edge[i].to] == dist[u]+edge[i].cost) to[u].push_back(edge[i].to), ++in[edge[i].to];
    }
    ans[s] = 1; Q.push(s);
    while (!Q.empty()) {
    int u = Q.front(), size = to[u].size(); Q.pop();
    for (int i = 0; i < size; i++) {
        if (--in[to[u][i]] == 0) Q.push(to[u][i]); (ans[to[u][i]] += ans[u]) %= yzd;
    }
    }
}
void work() {
    read(n), read(m), read(s), read(t);
    for (int i = 1; i <= m; i++) {
    read(u), read(v), read(c); add(u, v, c); add(v, u, c);
    }
    memset(dist1, 127/3, sizeof(dist1));
    SPFA(s, dist1); topsort(s, dist1, ans1);
    memset(dist2, 127/3, sizeof(dist2));
    SPFA(t, dist2); topsort(t, dist2, ans2);
    int ans = 1ll*ans1[t]*ans1[t]%yzd;
    for (int u = 1; u <= n; u++) {
    if (dist1[u] == dist2[u] && dist2[u]*2 == dist1[t]) (ans -= 1ll*ans1[u]*ans1[u]%yzd*ans2[u]%yzd*ans2[u]%yzd) %= yzd;
    for (int i = path[u]; i; i = edge[i].next)
        if (dist1[u]+edge[i].cost+dist2[edge[i].to] == dist1[t] && dist1[u]*2 < dist1[t] && dist2[edge[i].to]*2 < dist1[t])
        (ans -= 1ll*ans1[u]*ans1[u]%yzd*ans2[edge[i].to]%yzd*ans2[edge[i].to]%yzd) %= yzd;
    }
    writeln((ans+yzd)%yzd);
}
int main() {
    work();
    return 0;
}

Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define of(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
const ll mod=1e9+7;
int main()
{
  IOS
  ll x;
  cin>>x;
  ll f=0;
  for(ll i=0;i>=-4000;i--)
  {
    ll p=x+(ll)pow(i,5);
    if(p>=0)
    {
      for(ll j=0;j<=4000;j++)
      {
        ll q=(ll)pow(j,5);
        if(q==p)
        {
          cout<<j<<" "<<i;
          f=1;
          break;
        }
      }
      if(f)
        break;
    }
    else
    {
      for(ll j=0;j>=-4000;j--)
      {
        ll q=(ll)pow(j,5);
        if(q==p)
        {
          cout<<j<<" "<<i;
          f=1;
          break;
        }
      }
      if(f)
        break;
    }
  }
  if(f==0)
  {
    for(ll i=0;i<=4000;i++)
  {
    ll p=x+(ll)pow(i,5);
    if(p>=0)
    {
      for(ll j=0;j<=4000;j++)
      {
        ll q=(ll)pow(j,5);
        if(q==p)
        {
          cout<<j<<" "<<i;
          f=1;
          break;
        }
      }
      if(f)
        break;
    }
    else
    {
      for(ll j=0;j>=-4000;j--)
      {
        ll q=(ll)pow(j,5);
        if(q==p)
        {
          cout<<j<<" "<<i;
          f=1;
          break;
        }
      }
      if(f)
        break;
    }
  }
  }
  return 0;
}


Measured memory_bytes: 4212
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	ss := strings.Split(sc.Text(), " ")

	nl := []float64{}
	for _, i := range ss {
		m, _ := strconv.ParseFloat(i, 64)
		nl = append(nl, m)
	}

	res := math.MaxFloat64
	for i := -100; i <= 100; i++ {
		r := 0.0
		for _, x := range nl {
			r += math.Pow(x - float64(i), 2)
		}
		if res > r {
			res = r
		}
	}
	fmt.Println(int(res))
}


Measured memory_bytes: 1860
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(ll i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define UB upper_bound
#define LB lower_bound
const int NUM = 2e5 + 5;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        string s,t; cin >> s >> t;
        int ans = 0;
        FOR(i,0,s.size()){
            if(s[i] != t[i]) ++ans;
        }
        cout << ans;
    }   
}

Measured memory_bytes: 3792
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	string s;
	while(cin>>N>>s) {
		ll bs = 0;
		REP(i, N) if(s[i]=='#') bs++;
		ll ans = INF;
		minUpdate(ans, N-bs);
		ll lbs = 0;
		REP(i, N) {
			if(s[i]=='#') lbs++;
			ll lans = lbs+(N-bs-(i+1-lbs));
			minUpdate(ans, lans);
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

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

using namespace std;

int main() {
	int h, w;
	cin >> h >> w;

	vector<string>s(h);

	rep(i, h)
		cin >> s[i];

	rep(i, w + 2)
		cout << "#";
	cout << endl;

	rep(i, h)
		cout << "#" << s[i] << "#" << endl;
	
	rep(i, w + 2)
		cout << "#";
	cout << endl;
	
	return 0;
}


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

public class Main {

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

	    int N = Integer.parseInt(scanner.next());
	    int K = Integer.parseInt(scanner.next());

	    int[] P = new int[N];

	    for (int i = 0; i < N; i++) {
	        P[i] = Integer.parseInt(scanner.next());
	    }

	    Arrays.sort(P);

	    int result = 0;
	    for (int i = 0; i < K; i++) {
	        result += P[i];
	    }

	    System.out.println(result);
	}

}

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

#ifdef DEBUG
#include "../include/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    int N;
    cin >> N;

    double sum = 0;

    double x;
    string u;
    for (int i=0; i<N; ++i) {
        cin >> x >> u;
        if (u == "JPY") {
            sum += x;
        } else {
            sum += x * 380000;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from itertools import permutations

N, C = map(int,input().split())
D = []
for _ in range(C):
    D.append(list(map(int,input().split())))
c = []
for _ in range(N):
    c.append(list(map(int,input().split())))

P = [defaultdict(int) for _ in range(3)]
for i in range(N):
    for j in range(N):
        P[(i+j)%3][c[i][j]-1] += 1

ans = float('inf')
for L in permutations([i for i in range(C)], 3):
    cnt = 0
    for i in range(3):
        for j in range(C):
            cnt += P[i][j] * D[j][L[i]]
    ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 43868
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
#define ll long long

int main(void){
    int n;
    int ct = 2;
    cin >> n;
    while(1){
        if(n==ct*(ct-1)/2)break;
        else if(n<ct*(ct-1)/2){cN;return 0;}
        ct++;
    }
    cY;
    cout << ct << endl;
    int a = 1;
    int b = 0;
    rep(i,ct){
        cout << ct-1 << " ";
        rep(j,ct-i-1){
            cout << a << " ";
            a++;
        }
        int c = b;
        rep(j,i){
            cout << c << " ";
            c += ct-j-2;
        }
        b++;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1408