akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    set<ll> N;
    rep(i, 0, 3){
        ll tmp;
        cin >> tmp;
        N.insert(tmp);
    }

    cout << (N.size() == 2 ? "Yes" : "No") << endl;

    return 0;
}


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
	double d;
	cin >> d;
	double ans=d;
	for(int x=0;x*x<=d*d;++x){
		double y=sqrt(d*d-x*x);
		ans=max(ans,x+y);
		if(x>=1&&y<1.0){
			ans=max(ans,x+1.0);
		}
	}
	ans=max(ans,2*sqrt(d*d/2));

	cout.precision(15);
	cout << fixed << ans << endl;
	return 0;
}

Measured memory_bytes: 1288
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
using namespace std;
#define ul unsigned long long

#define rup(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rdn(i, a, b) for(int (i) = (a); (i) > (b); (i)--)


int main() {
	ul x, a, b;
	cin >> x>>a>>b;

	if (a >= b) {
		cout << "delicious";
	}
	else {
		if (b - a <= x) {
			cout << "safe";
		}
		else {
			cout << "dangerous";
		}

	}
	return 0;
}





Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main() {
 
    long long int ain[50],bin[50];
    long long int a,b,c,d,e,gcm,lcd;
    int loop=50;
    
    for(int i = 0;i<50;i++) {
    	ain[i]=0;
    	bin[i]=0;
        cin >> ain[i] >> bin[i];
        /*if (ain[i]==null) {
        	loop = i;
        	break;
        }*/
    }
    for (int i = 0;i <= loop;i++) {
    a = ain[i];
    b = bin[i];
    if (a==0&&b==0) break;
    if (a < b) {
        c  = a;
        a  = b;
        b = c;
        c=0;
    }
 
    c=a;
    d=b;
 
    for(;;) {
        if(d==0) {
            gcm = c;
            lcd = (a * b) / gcm;
            break;
        }
        e = c % d;
        c = d;
        d = e;
    }
 
    cout << gcm << " " << lcd << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1152
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n,m = gets.chomp.split.map(&:to_i)
edges = Array.new()
m.times do
  a,b = gets.chomp.split.map(&:to_i)
  edges[a] ||= []
  edges[b] ||= []
  edges[a].push b
  edges[b].push a
end

ans = Array.new(n+1)
visited = Set.new([1])
q = [1]
until q.empty?
  node = q.shift
  edges[node].each do |nnode|
    next if visited.include? nnode
    visited.add nnode
    ans[nnode] = node
    q.push nnode
  end
end

puts 'Yes'
ans.shift
ans.shift
ans.each do |line|
  puts line
end

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

int main(void)
{
  int summer_vacation_days, homework_num;
  
  cin >> summer_vacation_days >> homework_num;
  
  int homework_day;
  int total_homework_day = 0;
  for(int i = 0; i < homework_num; i++)
  {
    cin >> homework_day;
    total_homework_day += homework_day;
  }
  
  if (total_homework_day > summer_vacation_days)
  {
    //宿題を終わらせることができません
    cout << -1 << endl;
  }
  else
  {
    //夏休みに遊べる日数
    cout << (summer_vacation_days - total_homework_day) << endl;
  }
 
  return 0;
}


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

#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0);
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define pii pair<int,int>
#define UMP(x,y) unordered_map<x,y>
#define MP(x,y) map<x,y>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define inf 1e18
#define endl "\n"
#define coutd(n) cout << fixed << setprecision(n)
#define watch(x) cout<<#x<<" = "<<x<<endl;
typedef double db;
typedef long double ld;	
const int mod = 1000000007;

using namespace std;

int32_t main(){
    fast
    	
    //int t;
	//cin>>t;
	//rep(_,0,t){
		string str;
      	cin>>str;
      	if(str == "ABC")
          	str="ARC";
     	else
          	str ="ABC";
     	cout<<str;
	//}
	
    return 0;
}

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



int main() {
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);

  if(x/d>k) x=x-k*d;
  else{
    ll e = x/d;
    k -= e;
    x -= e*d;
    if(k%2==1) x -= d;
  }
  cout << abs(x) << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
using namespace std;
typedef long long ll;

vector<pair<int, int>> to[100010];
bool visited[100010];
ll dist[100010];
ll gcd(ll a, ll b)
{
   if (b == 0)
   {
       return a;
   }
    return gcd(b, a%b);
}
void dfs(int now, ll d) {
  visited[now] = true;
  dist[now] = d;
  for (auto p : to[now]) {
    if (visited[p.first]) continue;
    dfs(p.first, d + p.second);
  }
}
vector<int>ans(10005,0);
void f(ll n){
    for (ll x = 1; x*x<n;x++){
        for (ll y = 1; y*y<n;y++){
            for (ll z = 1; z*z<n;z++){
                ll v = (x*x)+(y*y)+(z*z)+(x*y)+(y*z)+(z*x);
                if(v<10005) ans[v]++;
            }
        }
    }
}

int main() {
    int n;
    cin >> n;
    if(30 <= n) cout << "Yes" << endl;
    else cout << "No" << endl;
   
    return 0;
}


Measured memory_bytes: 6012
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 
int mod = 1e9+7;
ll dp[100005][2];
int main() {
  string s; cin >> s;
  int n = s.length();
  dp[0][1] = 1;
  rep(i,n) {
    // trasition from less than
    (dp[i+1][0] += (dp[i][0]*3)%mod)%=mod;
    // transition from equal
      if (s[i] == '1') {
        // a + b = 0
        (dp[i+1][0] += dp[i][1]) %= mod; 
        // a + b = 1
        (dp[i+1][1] += (dp[i][1] * 2) % mod) %= mod;
      } else {
        // a + b = 0
        (dp[i+1][1] += dp[i][1]) %= mod;
      }
  }
  cout << (dp[n][0]+dp[n][1]) % mod << endl;
  return 0;
}

Measured memory_bytes: 2048
N = int(input())
A = list(map(int,input().split()))
x = [0 for _ in range(N)]
for i in range(1,N):
  if A[i] < A[i-1] + x[i-1]:
    x[i] = A[i-1] + x[i-1] - A[i]
print(sum(x))


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

using namespace std;

int main(void)
{
    int x;
    cin >>x;

    long long happy = (x / 500) * 1000;

    x %= 500;

    happy += ( x / 5 ) * 5;

    printf("%lld\n", happy);

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int r=sc.nextInt();
	    int c=sc.nextInt();
	    int data[][]=new int[101][101];
	    for(int i=0;i<r;i++){
	        for(int j=0;j<c;j++){
	            data[i][j]=sc.nextInt();
	            data[i][c]+=data[i][j];
	            data[r][j]+=data[i][j];
	        }
	        data[r][c]+=data[i][c];
	    }
	    for(int i=0;i<=r;i++){
	        for(int j=0;j<c;j++){
	            System.out.print(data[i][j]);
	            System.out.print(" ");
	        }
	        System.out.println(data[i][c]);
	    }
	    sc.close();
	}
}




Measured memory_bytes: 45328
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip>
#include<map>
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
//fixed<< setprecision(2)
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll a,b,c,k;
    while (cin >> a>>b>>c>>k)
    {
        ll ans=0;
        if(k>=a)ans+=a;
        else {
            ans+=k;
        }
        k-=a;
        if(k<=0){cout<<ans<<'\n';continue;}
        if(k>b);
        else {
            ;
        }
        k-=b;
        if(k<=0){cout<<ans<<'\n';continue;}
        if(k<=0){cout<<ans<<'\n';continue;}
        if(k>c)ans+=-1*c;
        else {
            ans+=-1*k;
        }
        k-=c;
        if(k<=0){cout<<ans<<'\n';continue;}
    }
}

Measured memory_bytes: 3184
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    int i = 1;
    while (++i <= n)
    {
        int x = i;
        if (x % 3 == 0)
        {
            cout << " " << i;
        }
        else
        {
            while (true)
            {
                if (x % 10 == 3)
                {
                    cout << " " << i;
                    break;
                }
                x /= 10;
                if (x == 0)
                    break;
            }
        }
    }
    cout << endl;
}



Measured memory_bytes: 3172
def main():
    A = [int(i) for i in input().split()]
    A.sort()
    B = [A[2]-A[1], A[2]-A[0]]
    ans = 0
    if B[0] % 2 == B[1] % 2:
        ans = (B[0]+B[1])//2
    else:
        ans = 0--(B[0]+B[1])//2 + 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

const int INF = (1<<29);
const int INFF = 0x7fffffff;
const ll LINF = (1ll<<60);
const ll LINFF = 0x7fffffffffffffff;
const double PI = 3.14159265359;

#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define prec(x) cout << fixed << setprecision(x)
#define sz(x) (int)x.size()
#define ilog2(x) 31-__builtin_clz(x)

#define hash sodnf9843bsd
#define pqueue priority_queue
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define len length
#define endl '\n'

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll a, ll b){return uniform_int_distribution<ll>(a, b)(rng);}


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

	int k;cin>>k;
	int a, b;cin>>a>>b;

	int x = b/k;
	if (x*k >= a) cout << "OK" << endl;
	else cout << "NG" << endl;

	return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll sum = 0;
  rep(i,n) sum += ( a[i] - 1LL );
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
import copy
h, w, k = map(int, input().split())
mas_global = [[] for _ in range(h)]
for i in range(h):
    mas_global[i] = list(input())

# a, bはh, wからどれを選ぶかの情報2進数
def calc_black_cnt(a, b):
    mas = copy.deepcopy(mas_global)
    i = 0
    while 1<<i <= a:
        if a & 1<<i != 0:
            mas[i] = ['r' for _ in range(w)]
        i += 1
    j = 0
    while 1<<j <= b:
        if b & 1<<j != 0:
            for ii in range(h):
                mas[ii][j] = 'r'
        j += 1
    res = 0
    for i in range(h):
        res += mas[i].count('#')
    return res

ans = 0
for i in range(2**h):
    for j in range(2**w):
        cnt = calc_black_cnt(i, j)
        if cnt == k:
            ans += 1
print(ans)
# calc_black_cnt(0, 4)

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

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

    string S;
    std::cin >> S;

    for(int i=0;i<(1<<3);++i){
        int v = S[0] - '0';
       
        for(int j=1;j<4;++j){
            if(i >> (j - 1) & 1){
                v += S[j] - '0';
            }else{
                v -= S[j] - '0';
            }
        }
        
        if(v == 7){
            std::cout << S[0];

            for(int j=1;j<4;++j){
                std::cout << "-+"[i >> (j - 1) & 1];
                std::cout << S[j];
            }

            std::cout << "=7" << std::endl;
            
            return 0;
        }
    }
}


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

int main(){
	// sengen
	int n;
	string s;
	// nyuryoku
	cin >> s;
	n = s.size() - 1;
	// keisan
	if(s[n] == 's'){
		cout << s + "es" << endl;
	}else{
		cout << s + 's' << endl;
	}
	// syutsuryoku
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x,y,z;
  x=c-a;
  if(x<0){
    x=-x;
  }
  y=c-b;
  if(y<0){
    y=-y;
  }
  z=b-a;
  if(z<0){
    z=-z;
  }
  if(x<=d||y<=d&&z<=d){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}

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

int main(){
    int n;
    std::cin >> n;

    std::vector<int> v(n), c(n);
    for(int i = 0; i < n; ++i){
        std::cin >> v.at(i);
    }
    for(int i = 0; i < n; ++i){
        std::cin >> c.at(i);
    }

    int val;
    int ans = 0;
    for(int i = 0; i < n; ++i){
        val = v.at(i) - c.at(i);
        if(0 < val){
            ans += val;
        }
    }
    
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    t = [0] * (n + 1)
    x = [0] * (n + 1)
    y = [0] * (n + 1)
    for i in range(1, n + 1):
        t[i], x[i], y[i] = map(int, input().split())
    for i in range(n):
        diff = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
        time = t[i + 1] - t[i]
        if diff % 2 != time % 2 or diff > time:
            print("No")
            return
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 11636
#include<stdio.h>

int main(){
  int n, Adj[100][100],i,j,u,k,b;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      Adj[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&b,&k);
    for(j=0;j<k;j++){
      scanf("%d",&u);
      Adj[b-1][u-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j!=0)printf(" ");
      printf("%d",Adj[i][j]);
    }
    printf("\n");
  }
 
  return 0;
}
  

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef vector<ll> Vec;
typedef vector<pair<ll, ll>> Pair;
#define rep(i, n) for(ll i=0;i<n;i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//static const ll MOD = 1000000007;
//static const ll INF = 100000000;
//#define PI 3.14159265359


int main() {
    // input
    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    // process
    ll ans = 0;
    if (K >= A) {
        ans += A;
        K -= A;
    } else {
        ans += K;
        K = 0;
    }
    if (K >= B) {
        K -= B;
    } else {
        K = 0;
    }
    if (K >= C) {
        ans -= C;
        K -= C;
    } else {
        ans -= K;
        K = 0;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+2;
set<ll>s;
ll a[]= {3,5,7};
void go(ll val,ll n)
{
    ll r=val,x=0,y=0,z=0;
    while(r!=0)
    {
        if(r%10==3)
        {
            x=1;
        }
        else if(r%10==5)
        {
            y=1;
        }
        else if(r%10==7)
        {
            z=1;
        }
        r/=10;
    }
    if(x==1 && y==1 && z==1)
    {
        s.insert(val);
    }
    for(int i=0; i<3; i++)
    {
        r=val*10+a[i];
        if(r<=n)
        {
            go(r,n);
        }
    }
    return;
}
int main()
{
    ft
    ll t,i,j,k,n,m,l=0,r;
    cin>>n;
    go(0,n);
    cout<<(int)s.size()<<"\n";
    return 0;
}



Measured memory_bytes: 1536
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int i,l,t,b,r=0;
    char s[131072];
    scanf("%s",s);
    l = strlen(s);
    t = 0;b = l-1;
    while(t<b){
        if(s[t]=='x'){
            if(s[b] == 'x'){t++;b--;}
            else{r++;t++;}
        }
        else if(s[b]=='x'){
            r++;b--;
        }
        else{
            if(s[t]==s[b]){t++;b--;}
            else{printf("-1\n");return 0;}
        }
    }
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
    ans=min(a,k);
    k-=a;
    if(k<=0){
        cout<<ans<<"\n";
        return 0;
    }
    k-=b;
    if (k <= 0)
    {
        cout << ans << "\n";
        return 0;
    }
    ans-=k;
    cout<<ans<<"\n";
}


Measured memory_bytes: 3652
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <random>
#include <unordered_set>
#include <set>
using namespace std;
typedef long long ll;



int main(){
	ll ans=0,now=0,N;
	string s;
	cin >> N >> s;
	for(auto c:s){
		if(c=='I'){
			now++;
		}else{
			now--;
		}
		ans = max(ans,now);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  cin >> n;
  vector<P> a(n);
  rep(i, n) {
    ll x, l;
    cin >> x >> l;
    a[i] = P(x + l, x - l);
  }
  sort(all(a));
  int ans = 0;
  ll nr = -1e18;
  rep(i, n) {
    ll r = a[i].first;
    ll l = a[i].second;
    if(l >= nr) {
      ans++;
      nr = r;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=(int)(6e5+50)<<2;

/*
int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int gcd(int a,int b){ return !b?a:gcd(b,a%b); }
*/

struct P { ll x, y; } ; 
typedef P V; 
V operator-(const P& a, const P& b){ return (V){a.x-b.x,a.y-b.y}; }
ll det(P a, P b) { return a.x*b.y-b.x*a.y; } 

P s[N]; 
int n, tp; 
ll a[N], b[N], c[N]; 
ll ans; 
int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("d.in", "r", stdin); 
#endif
	read(n); 
	rep(i, 1, n) read(a[i]); 
	rep(i, 1, n) read(b[i]); 
	ll* p = max_element(a+1, a+n+1); 
	rotate(a+1, p, a+n+1); 
	rotate(b+1, b+(p-a), b+n+1); 
	++n, a[n] = a[1], b[n] = b[1];
	rep(p, 2, n-1) c[p+1] = 2*c[p]+2*b[p]-c[p-1];
	rep(i, 1, n) {
		P v=(P){i,a[i]-c[i]};
		while(tp>=2 && det(s[tp-1]-s[tp-2],v-s[tp-2])>=0) --tp;
		s[tp++] = v;
	}
	lop(i, 1, tp){
		ll dx = s[i].x-s[i-1].x;
		ans += (dx+1) * s[i-1].y + (dx-1)*s[i].y;
	}
	lop(i, 1, n) ans += 2 * c[i]; 
	printf("%.12f\n", (double)ans/(n-1)/2); 
	return 0; 
}


Measured memory_bytes: 11408
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
  int A,B;
  cin >> A >> B;
  int cnt = 0;
  int sum = 1;
  while(sum < B){
    cnt++;
    sum += A-1;
  }
   cout << cnt <<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n % 2 == 0) {
			System.out.println(n);
		} else {
			System.out.println(n * 2);
		}
	}
}


Measured memory_bytes: 23636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

class Class_
{
	void Test()
	{
		var NM = A_Int_();

		//
		var n = new string[NM[0]];
		for (int i = 0; i < NM[0]; i++)
		{
			n[i] = S_String_();
		}

		//
		var m = new string[NM[1]];
		for (int i = 0; i < NM[1]; i++)
		{
			m[i] = S_String_();
		}

		for (int i = 0; i < NM[0] - NM[1]+1; i++)
		{
			for (int j = 0; j < NM[0] - NM[1] + 1; j++)
			{
				// [i,j]

				bool f = true;

				// [ii,jj]
				for (int ii = 0; ii < NM[1] ; ii++)
				{
					for (int jj = 0; jj < NM[1]; jj++)
					{
						if (n[i+ii][j+jj] != m[ii][jj])
						{
							f = false;
						}
					}
				}

				// hit
				if (f) {
					Console.WriteLine("Yes");
					return;
				}

				// [i,j]end
				Debug.WriteLine(""+i+ " " + j);
			}
		}
		
		Console.WriteLine("No");

	}

	static void Main(string[] args)
  {
    new Class_().Test();
  }

  #region

  string S_String_()
  {
    return Console.ReadLine();
  }

	//
	string[] A_String_()
  {
    return Console.ReadLine().Split();
  }

  int[] A_Int_(int n)
  {
    var x = new int[n];
    for (var i = 0; i < n; i++)
    {
      x[i] = int.Parse(Console.ReadLine());
    }
    return x;
  }

	//
	int[] A_Int_()
  {
    var ss = Console.ReadLine().Split();

    var x = new int[ss.Length];
    for (var i = 0; i < ss.Length; i++)
      x[i] = int.Parse(ss[i]);

    return x;
  }
  #endregion
}
	

Measured memory_bytes: 2648
#include <bits/stdc++.h>
using namespace std;
    
int main() {
	int N, S = 0;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H.at(i);
	}

	bool ishigher;
	for (int i = 0; i < N; ++i){
		ishigher = true;
		for (int j = 0; j < i; ++j) {
			if (H.at(j) > H.at(i)) {
				ishigher = false;
			}
		}
		if (ishigher) {
			S++;
		}
	}

	cout << S << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
  long long k;
  int i;
  scanf("%lld", &k);
  long long ans[55];
  long long sho = k/50;
  long long amari = k%50;
  for (i = 0; i < 50; i++) {
    ans[i] = 49+sho;
  }
  for (i = 0; i < amari; i++) {
    ans[i] = ans[i]+51-amari;
  }
  for (i = amari; i < 50; i++) {
    ans[i] = ans[i]-amari;
  }
  printf("50\n");
  for (i = 0; i < 50; i++) {
    printf("%lld ", ans[i]);
  }
  return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
  ll k, a, b;
  cin >> k >> a >> b;

  ll ans = 1;
  if (a + 2 > b) {
    ans += k;
  } else {
    k -= a - 1;
    ans += a - 1;
    ans += (b - a) * (k / 2) + k % 2;
  }

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

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans=0,n,k;
    cin>>n>>k;
    vector<ll> hp;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        hp.push_back(a);
    }
    sort(hp.rbegin(),hp.rend());

    for(int i=k;i<n;i++){
        ans+=hp[i];
    }

    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 2420
#include <stdio.h>
int main() {
	int n, x;
	scanf("%d", &n);
	int p[4], d;
	p[0] = 0; p[1] = 0; p[2] = 0;
	int ans = 0;
	char s[20];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 20; j++)s[j] = '0';
		d = 0;
		scanf("%s", s);
		while (s[d] != '0')d++;
		d--;
		for (int j = 0; j < d - 1; j++) {
			if (s[j] == 'A' && s[j + 1] == 'B')ans++;
		}
		if (s[0] == 'B' && s[d - 1] == 'A')p[0]++;
		if (s[0] == 'B' && s[d - 1] != 'A')p[1]++;
		if (s[0] != 'B' && s[d - 1] == 'A')p[2]++;
		if (s[0] != 'B' && s[d - 1] != 'A')p[3]++;
	}
	if (p[1] != 0 && p[2] != 0) {
		ans += p[0];
		x = p[1];
		if (p[2] < p[1])x = p[2];
		ans += x;
		printf("%d\n", ans);
		return 0;
	}
	if (p[1] + p[2] == 0) {
		ans += p[0] - 1;
		if (p[0] == 0)ans++;
		printf("%d\n", ans);
		return 0;
	}
	ans += p[0];
	printf("%d\n", ans);
}

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

template<int MAX>
struct Combination {
    vector<long long> _inv, _fac, _ifac;
    const long long MOD;
    Combination(long long mod) : _inv(MAX+1), _fac(MAX+1), _ifac(MAX+1), MOD(mod) { init(); }
    void init() { init_inv(), init_fac(); }

    void init_inv() {
        _inv[0] = 0;
        for (int i = 1; i <= MAX; i++) {
            if (i == 1) _inv[i] = 1;
            else {
                _inv[i] = (MOD - (MOD / i) * _inv[MOD % i]) % MOD;
                if (_inv[i] < 0) _inv[i] += MOD;
            }
        }
    }
    void init_fac() {
        _fac[0] = _ifac[0] = 1;
        for (int i = 1; i <= MAX; i++) {
            _fac[i] = _fac[i-1] * i % MOD;
            _ifac[i] = _ifac[i-1] * _inv[i] % MOD;
        }
    }

    long long modpow(long long n, long long r) {
        n %= MOD, r %= (MOD-1);
        if (!n) return 0;
        long long ret = 1; long long tmp = n;
        while (r != 0) {
            if (r % 2) ret *= tmp;
            tmp *= tmp; tmp %= MOD; ret %= MOD;
            r /= 2;
        }
        return ret;
    }
    long long invb(int i) const { return (i <= MAX) ? _inv[i] : this->modpow(i, MOD-2); }
    long long inv(int i) const { return _inv[i]; }
    long long fac(int i) const { return _fac[i]; }
    long long ifac(int i) const { return _ifac[i]; }

    long long operator()(int n, int r) const {
        if (n < r) return 0;
        return fac(n) * ifac(r) % MOD * ifac(n-r) % MOD;
    }
};

constexpr int mod = 1000000007;
constexpr int MAX = 2000010;
Combination<MAX> C(mod);

int main() {
    int K; string S; 
    cin >> K >> S;
    const int N = S.size();
    long long Ans = 0;
    for (int i = N; i <= N + K; i++) {
        Ans += C(i-1, N-1) * C.modpow(25, i-N) % mod * C.modpow(26, N+K-i) % mod;
    }
    cout << Ans % mod << "\n";
    return 0;
}

Measured memory_bytes: 52156
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){

	string str;
	int table[200];

	table[0]=0;
	table['I']=1;
	table['V']=5;
	table['X']=10;
	table['L']=50;
	table['C']=100;
	table['D']=500;
	table['M']=1000;

	while(cin>>str){
		reverse(str.begin(),str.end());
		int prv=0;
		int sum=0;
		for(int i = 0; i < str.size(); i++){
			if(prv>table[str[i]]){
				sum-=table[str[i]];
			}
			else{
				sum+=table[str[i]];
			}
			prv=table[str[i]];
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
void Main(){
    ll n;cin>>n;
    vector<int> a(3);
    For(i,0,3) cin>>a[i];
    vector<string> s(n+1);
    For(i,0,n) {
        cin>>s[i];
    }
    s[n]="AB";
    string ans="Yes";
    vector<char> play(n);
    vector<int> ch(2),nextch(2);
    For(i,0,n){
        For(j,0,2) {
            ch[j]=s[i][j]-'A';
            //cout<<ch[j]<<" ";
        }

        if(a[ch[0]]==0 && a[ch[1]]==0){
            ans="No";
            break;
        }
        else if(a[ch[1]]==0){
            play[i]=s[i][1];
            a[ch[0]]--;
            a[ch[1]]++;
        }
        else if(a[ch[0]]==0){
            play[i]=s[i][0];
            a[ch[0]]++;
            a[ch[1]]--;
        }
        else if(a[ch[0]]>1){
            play[i]=s[i][1];
            a[ch[0]]--;
            a[ch[1]]++;
        }
        else if(a[ch[1]]>1){
            play[i]=s[i][0];
            a[ch[0]]++;
            a[ch[1]]--;
        }
        else{
            For(j,0,2) nextch[j]=s[i+1][j]-'A';
            int playnum=0;
            if(ch[0]==nextch[0]){
                playnum=0;
            }
            else if(ch[1]==nextch[1]){
                playnum=1;
            }
            else if(ch[0]==nextch[1]){
                playnum=0;
            }
            else playnum=1;
            play[i]=s[i][playnum];
            a[ch[playnum]]++;
            a[ch[1-playnum]]--;
        }
        //cout << a[0] << " " << a[1] << " " << a[2] << endl;
    }
    cout << ans << endl;
    if(ans=="Yes"){
        For(i,0,n){
            cout << play[i] << endl;
        }
    }
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 6428
n = int(input())
b = list(map(int, input().split())) 

a = []
for i in range(n):
    if i==0:
        a.append(b[0])
    elif i==n-1:
        a.append(b[-1])
    else:
        a.append(min(b[i-1], b[i]))

print(sum(a))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) x.size()
using namespace std;
typedef long long ll;
int main(void) {
    string s; cin >> s;
    int state = 0;
    int cnt = 0;
    int cur = 0;
    vector<int> ans(sz(s));
    rep(i, sz(s)) {
        if(state == 0){
            if(s[i]=='R') cnt++;
            else{
                ans[i-1]+=cnt-cnt/2; ans[i]+=cnt/2;
                state = 1; cnt = 1; cur = i;
            }
        }else{
            if(s[i]=='L') cnt++;
            else{
                ans[cur-1]+=cnt/2; ans[cur]+=cnt-cnt/2;
                state = 0; cnt = 1;
            }
            if(i==sz(s)-1){
                ans[cur-1]+=cnt/2; ans[cur]+=cnt-cnt/2;
            }
        }
    }
    if(s[sz(s)-2]=='R') ans[sz(s)-1] += 1;
    rep(i, sz(s)) {
        cout << ans[i] << endl;
    }
}





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

int main() {
    long long n, p;
    cin >> n >> p;
    vector<bool> is_prime(1010101, true);
    is_prime[0] = is_prime[1] = false;
    for (int i=2; i<(int)is_prime.size(); ++i) {
        if (!is_prime[i]) continue;
        for (int j=i*2; j<(int)is_prime.size(); j += i) is_prime[j] = false;
    }
    long long ans = 1;
    if (n == 1) {
        cout << p << endl;
        return 0;
    }
    for (int i=2; i<(int)is_prime.size(); ++i) {
        if (!is_prime[i]) continue;
        int cnt = 0;
        while (p % i == 0) {
            p /= i;
            cnt++;
            if (cnt >= n) {
                ans *= i;
                cnt -= n;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int sum = 0;
		
		for (int i = 0; i < 2; i++) {
			if(A < B) {
				sum += B;
				B -= 1;
			} else {
				sum += A;
				A -= 1;
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
#define int long long
//BEGIN CUT HERE
struct BiMatch{
  int n;
  vector<vector<int> > G;
  vector<int> match,used;
  
  BiMatch(){}
  BiMatch(int sz):n(sz),G(sz),match(sz),used(sz){}
  
  void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
  }

  bool dfs(int v){
    used[v]=true;
    for(int i=0;i<(int)G[v].size();i++){
      int u=G[v][i],w=match[u];
      if(w<0||(!used[w]&&dfs(w))){
	match[v]=u;
	match[u]=v;
	return true;
      }
    }
    return false;
  }

  int build(){
    int res=0;
    fill(match.begin(),match.end(),-1);
    for(int v=0;v<n;v++){
      if(match[v]<0){
	fill(used.begin(),used.end(),0);
	if(dfs(v)){
	  res++;
	}
      }
    }
    return res;
  }
};
//END CUT HERE

signed main(){
  int X,Y,E;
  cin>>X>>Y>>E;
  BiMatch bm(X+Y);
  for(int i=0;i<E;i++){
    int x,y;
    cin>>x>>y;
    bm.add_edge(x,X+y);
  }
  cout<<bm.build()<<endl;
  return 0;
}
/*
  verified on 2017/06/29
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_7_A&lang=jp
*/

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

int main() {
  long long n, a, b;
  cin >> n >> a >> b;
  if (a > b) cout << 0 << endl;
  else if (n == 1 && a != b) cout << 0 << endl;
  else if (n == 1 && a == b) cout << 1 << endl;
  else cout << (b - a) * (n - 2) + 1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String S = scanner.next();
		String[] splitArray = S.split("");
		int count = 0;
		for (int j = 0; j < 3; j++) {
			if (splitArray[j].equals(splitArray[j + 1])) {
				count += 1;
			}
		}
		if (count == 0) {
			System.out.println("Good");
		} else {
			System.out.println("Bad");
		}

	}
}

Measured memory_bytes: 21460
N = int(input())

ret = 0


def solve(seven=False, five=False, three=False, num=0):
    global ret
    if num <= N:
        if seven and five and three:
            ret += 1
        solve(True, five, three, num * 10 + 7)
        solve(seven, True, three, num * 10 + 5)
        solve(seven, five, True, num * 10 + 3)
    else:
        return


solve()
print(ret)


Measured memory_bytes: 2940
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;
const int n_max = 1299710;
int prime[n_max];
int main(){
	
	for(int i = 0;i < n_max;i++){
		prime[i] = true;
	}
	
	for(int i = 2;i < sqrt(n_max);i++){
		if(prime[i]){
			for(int j = 0; i * (j + 2) < n_max;j++){
				prime[i*(j+2)] = false;
			}
		}
	}
	
	vector<int> ans;
	while(true){
		int n;
		cin >> n;
		if(n == 0) break;
		if(prime[n]){
			ans.push_back(0);
		}else{
			int pl=0,pr=0;
			for(int i = 1;i < n_max;i++){
				if(prime[n+i] && pr == 0){
					pr = n+i;
				}
				if(prime[n-i] && pl == 0){
					pl = n-i;
				}
				if(pr != 0 && pl != 0){
					ans.push_back(pr - pl);
					break;
				}
			}
		}
	}
	
	for(int i = 0;i < ans.size();i++){
		cout << ans[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 8128
class UnionFind:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n
 
    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            # 経路の圧縮
            self.table[x] = self._root(self.table[x])
            return self.table[x]
 
    def find(self, x, y):
        return self._root(x) == self._root(y)
 
    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2
 
 
if __name__ == '__main__':
    ans = 0
    n,m = map(int,input().split())
    s = list(map(int,input().split()))
    uf = UnionFind(n+1)
    for i in range(m):
        a,b = map(int,input().split())
        uf.union(a-1,b-1)
    for i in range(n):
        if uf.find(s[i]-1,i):
            ans += 1
        elif s[i]-1  == i :
            ans += 1
print(ans)

Measured memory_bytes: 13812
# -*- coding: utf-8 -*-
def two_pointers(ary, l, r, split, ary_func, comb_func, comp_func):
    '''
    This function is supposed to be repeatedly called so that 'split' keeps
    renewing, under an assumption that 'split' increases monotonously.
    ('l' and 'r' just specify the region to be searched in 'ary')
    '''

    left = ary_func(ary, l, split)
    right = ary_func(ary, split, r)
    val = comb_func(left, right)

    for i in range(split + 1, r):
        tmp_left = ary_func(ary, l, i)
        tmp_right = ary_func(ary, i, r)
        tmp_val = comb_func(tmp_left, tmp_right)

        if comp_func(val, tmp_val):
            return i - 1, val, left, right
        else:
            left = tmp_left
            right = tmp_right
            val = tmp_val

    else:
        return r - 1, val, left, right


if __name__ == '__main__':
    from operator import add
    from itertools import accumulate

    n = int(input())
    a = [int(_) for _ in input().split()]
    cul_ary = [0] + list(accumulate(a, add))

    l_split = 1
    r_split = 3
    griefs = []
    for i in range(2, n - 1):
        # left
        l_split, l_diff, p, q = two_pointers(cul_ary,
                                             0,
                                             i,
                                             l_split,
                                             lambda ary, l, r: ary[r] - ary[l],
                                             lambda left, right: abs(left - right),
                                             lambda val1, val2: True if val1 < val2 else False)

        # right
        r_split, r_diff, r, s = two_pointers(cul_ary,
                                             i,
                                             n,
                                             r_split,
                                             lambda ary, l, r: ary[r] - ary[l],
                                             lambda left, right: abs(left - right),
                                             lambda val1, val2: True if val1 < val2 else False)

        griefs.append(max(p, q, r, s) - min(p, q, r, s))

    print(min(griefs))


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

int main() {
	// your code goes here
	long long int d,t,s;
	cin>>d>>t>>s;
	if(d <= t*s){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i,n) for (long long i=0;i<(n);i++)
#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define RREP(i,n) for(long long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl
#define dump(x)  cerr << #x << " => " << (x) << endl
#define dumpP(p) cerr << "( " << p.first << " , " << p.second << " )" << ends
#define SORT(c) sort((c).begin(),(c).end())
#define MIN(vec) *min_element(vec.begin(), vec.end())
#define MAX(vec) *max_element(vec.begin(), vec.end())
#define UNIQ(vec) vec.erase(unique(vec.begin(), vec.end()),vec.end()) //ソートの必要あり
#define IN(n,m)  (!(m.find(n) == m.end()))
#define ENUM(m) for (auto itr = m.begin(); itr != m.end(); ++itr)
#define dump_MAP(m) for(auto itr = m.begin(); itr != m.end(); ++itr) { cerr << itr->first << " --> "  << itr->second << endl; }
#define FINDL(vec,x) (lower_bound(vec.begin(),vec.end(),x) - vec.begin())
#define FINDU(vec,x) (upper_bound(vec.begin(),vec.end(),x) - vec.begin())
#define ROUND(N) setprecision(N)
#define ROUND_PRINT(N,val) cout << fixed;cout << setprecision(N) << val << endl
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define INARR(h,w,x,y) (0 <= y && y < h && 0 <= x && x < w)
#define EQ(a,b) (abs(a - b) < 1e-10)
#define ZETA(b,k,n) REP(b,n) REP(k,1<<n) if ((k & (1 << b)))
using namespace std;
constexpr int dx[4] = {0,1,0,-1};
constexpr int dy[4] = {1,0,-1,0};
constexpr long double pi = M_PI;
constexpr double eps = 1e-10;
constexpr long mod = 1000000007;
constexpr short shINF = 32767;
constexpr long loINF = 2147483647;
constexpr long long llINF = 9223372036854775807;
typedef long long LL;
typedef vector<long> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<LL,LL> pr;
typedef vector<bool> VB;
typedef vector<pr> VP;
struct Order {
	bool operator() (pr const& a,pr const& b) const {
		return a.first > b.first || ((a.first == b.first) && (a.second > b.second));
	}
};

VI merge(VI &A,VI &B) {
	VI cp(A.begin(),A.end());
	REP(i,B.size()) cp.push_back(B[i]);
	sort((cp).begin(),(cp).end(),greater<long>());
	return vector<long>(cp.begin(),cp.begin()+min(2,(int)cp.size()));
}

int main(void) {
	int N;
	cin >> N;
	VI A(1<<N);
	REP(i,1<<N) cin >> A[i];
	VVI dp(1<<N,VI(2,0));
	REP(i,1<<N) dp[i] = {A[i]};	
	ZETA(b,k,N) {
		dp[k] = merge(dp[k],dp[k ^ (1 << b)]);
	}
	long ans = 0;
	FOR(i,1,1<<N) {
		ans = max(ans,dp[i][0]+dp[i][1]);
		cout << ans << endl;
	}
	//dump2d_arr(dp);
}



Measured memory_bytes: 19456
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  int sum = 0;
  for(int i = 0; i < 3; i++){
    if (a.at(i) == '1') {
      sum += 1;
    }  
  }
  cout << sum << endl;
}


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

  int main()
 {
     int a,b,c;
     cin>>a>>b>>c;
     if(b-a==c-b)
    {
         cout<<"YES"<<endl;
     }
     else
     {
         cout<<"NO"<<endl;
     }
     return 0;
 }

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

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


Measured memory_bytes: 256