akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// 049 c
int main()
{
    string s;
    cin >> s;

    vector<string> divide = {"dream", "dreamer", "erase", "eraser"};

    reverse(s.begin(), s.end());
    for (int i=0; i<4; i++) reverse(divide.at(i).begin(), divide.at(i).end());

    bool can = true;
    for (int i=0; i<s.size();) {
        bool can2 = false;
        for (int j=0; j<4; j++) {
            string d = divide.at(j);
            if (s.substr(i, d.size()) == d) {
                can2 = true;
                i += d.size();
            }
        }
        if (!can2) {
            can = false;
            break;
        }
    }
    if (can) cout << "YES" << endl;
    else cout << "NO" <<endl;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;
 
int main(){
   int k; cin >> k;
   vector<ll> a(k);
   rep(i,k) cin >> a[i];
   ll mn=2; ll ma=2;
   if(a[k-1]>2){
       cout << -1 << endl;
       return 0;
   }
   for(int i=k-1; i>=0; i--){
       //mn=a[i]*((mn-1)/a[i]+1);
       ma=((ma/a[i])+1)*a[i]-1;
       mn=((mn-1)/a[i]+1)*a[i];
       //ma=(ma/a[i])*a[i]+a[i]-1;
       //cout << ma << endl;
       //cout << mn << ' ' << ma << endl;
       if(mn>ma){
           cout << -1 << endl;
           return 0;
       }
   }
 
   cout << mn << ' ' << ma << endl;
return 0;
}

Measured memory_bytes: 4020
from sys import stdin
A = int(stdin.readline().rstrip())
B = int(stdin.readline().rstrip())
C = int(stdin.readline().rstrip())
X = int(stdin.readline().rstrip())
cnt = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            # print(500 * a + 100 * b + 50 * c)
            if 500 * a + 100 * b + 50 * c == X:
                cnt += 1
print(cnt)

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)

	w := b + c
	if w-a <= 0 {
		fmt.Print(0)
		return
	}

	fmt.Print(w - a)
}


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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] row = new int[N];
    for (int i=0; i<N; i++) row[i] = sc.nextInt();
    int distance = 0;
    Arrays.sort(row);
    for (int i=1; i<N; i++) {
      distance += row[i] - row[i-1];
    }
    System.out.print(distance);
  }
}

Measured memory_bytes: 22740
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
// #define MOD ll(1e9) + 7
#define ll long long
const double PI = atan(1.0) * 4;
// const int N = 1e5 + 5 ;
// const ll INF = (int)1e9 ;
const int dx[4] = { -1, 0, 1, 0} ;
const int dy[4] = {0, -1, 0, 1} ;
// const ll INF = (ll)2e18 + 50;
const ll INF = 1e9 ;
const ll MOD = 1e9 + 7 ;


ll power(ll a , ll e) {
	ll res = 1LL ;
	while (e > 0) {
		if (e % 2 == 1) res = res * a % MOD ;
		a =  a * a % MOD ;
		e /= 2 ;
	}
	return res ;
}
vector<int> complement(const vector<int> &vec) {
	int n = vec.size() ;
	vector<bool> occur(n + 1 , true) ;
	vector<int> ans ;
	for (int i = 0 ; i < (int)vec.size() ; i++) {
		occur[vec[i]] = false ;
	}
	for (int i = 1 ; i <= n ; i++) {
		if (occur[i]) ans.push_back(i) ;
	}
	return ans ;
}

ll intlog(double base, double x) {
	return (ll)(log(x) / log(base));
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t ;
	// cin >> t;
	// while (t--) {
	ll n ;
	cin >> n ;
	ll prod = 1 ;
	int len ;
	for (len = 1 ; ; len++) {
		prod *= 26 ;
		if (prod >= n) break ;
		n -= prod ;
	}
	--n ;
	// cout << len << "\n";
	string res ;
	for (int i = 0 ; i < len ; i++) {
		res += (char)('a' + n % 26) ;
		n /= 26 ;
	}
	reverse(res.begin(), res.end()) ;
	cout << res << "\n";



	// }

	return 0;
}


Measured memory_bytes: 3640
import java.util.*;

public class Main {
	
	public static void main(String args[]){
		
		Scanner sc= new Scanner(System.in);
		long n= sc.nextLong();
	
		int count=0;
		
		//String str="";
		
		int ans =count(0,count,n);
		
		
		
		System.out.println(ans);
	}
	
	public static int count(long n,  int count, long limit){
		if(limit<357)return 0;
		
		String str = String.valueOf(n);
			
			if(10*n+3>limit)return count;
			if(str.indexOf('5')!=-1 &&str.indexOf('7')!=-1)count++;
			count=count(10*n+3,count, limit);
			
			if(10*n+5>limit)return count;
			if(str.indexOf('3')!=-1 &&str.indexOf('7')!=-1)count++;
			count=count(10*n+5,count, limit);
			
			if(10*n+7>limit)return count;
			if(str.indexOf('5')!=-1 &&str.indexOf('3')!=-1)count++;
			count=count(10*n+7,count, limit);
			
		return count;
	}
	
	

}




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

const int mod = 1e9+7;
long long int fac[1000001],inv[1000001];

long long int mypow(long long int a,long long int b){
	a%=mod;
	long long int res=1;
	while(b){
		if(b&1)	res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}

long long int Choose(long long int a,long long int b){
	return fac[a]*inv[b]%mod*inv[a-b]%mod;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m,k;
	fac[0]=1;
	for(int i=1;i<=1000000;i++)
		fac[i]=fac[i-1]*i%mod;
	for(int i=0;i<=1000000;i++)
		inv[i]=mypow(fac[i],mod-2);
	cin>>n>>m>>k;
	if(m>k)	swap(m,k);
	long long int ans=0;
	long long int tmp=1;
	for(int i=0;i<=k+m;i++){
		ans=(ans+Choose(n-1+i,n-1)*tmp%mod*mypow(3,k+m-i))%mod;
		if(i<m)
			tmp=tmp*2%mod;
		else if(i<k)
			tmp=(tmp*2-Choose(i,i-m)+mod)%mod;
		else{
			tmp=(tmp*2-Choose(i,i-m)+mod)%mod;
			tmp=(tmp-Choose(i,k)+mod)%mod;	
		}
	}
	cout<<ans<<endl;
}


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

int main()
{
    int n,odd=0,even=0,i;
    cin>>n;
    for(i=0;i<n;i++)
    {
       long long a;
       cin>>a;
       if((a&1)==1)
            even++;
        else
            odd++;
    }
    if(even%2==0)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
ll mod=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll mini=0,maxi=n,ans=0;
    for(ll i=1;i<=n+1;i++)
    {
        //cout<<mini<<" "<<maxi<<"\n";
        if(i>=k){
            ans=(ans+(maxi-mini+1))%mod;
        }
            mini+=(i);
            maxi+=(n-i);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <vector>

using namespace std;

const int INF = 1000000005;
const int MAX_N = 200005;

int a[MAX_N], ans[MAX_N];
vector<int> G[MAX_N];

void dfs(int u, int p, vector<int>& dp){
    int pos = lower_bound(dp.begin(), dp.end(), a[u]) - dp.begin();
    int pre_val = dp[pos];
    dp[pos] = a[u];
    ans[u] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
    for(int v : G[u]){
        if(v != p){
            dfs(v, u, dp);
        }
    }
    dp[pos] = pre_val;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    int u, v;
    for(int i = 0; i < n - 1; ++i){
        cin >> u >> v;
        --u, --v;
        G[u].push_back(v), G[v].push_back(u);
    }
    vector<int> dp(n, INF);
    dfs(0, -1, dp);
    for(int i = 0; i < n; ++i){
        cout << ans[i] << "\n";
    }
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    
    int cnt = 0;
    rep(i, 0, n)
    {
        int h;
        cin >> h;
        if (k <= h) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque

N, D, A, *XH = map(int, open(0).read().split())

ans = 0
Q = deque()
damage = 0
for x, h in sorted(zip(*[iter(XH)] * 2)):

    while Q and Q[0][0] < x:
        v, d = Q.popleft()
        damage -= d

    h -= damage
    if h <= 0:
        continue

    n = -(-h // A)

    damage += A * n
    ans += n

    Q.append((x + 2 * D, A * n))

print(ans)

Measured memory_bytes: 50448
#include<iostream>
#include<algorithm>
using namespace std;
int n,q,r,l;
long long s,t,a[200010],d[200010],x;

int main(){

	cin>>n>>q>>s>>t;
	for(int i=0;i<=n;i++)cin>>a[i];
	long long cnt=0;
	for(int i=0;i<n;i++){
		d[i]=a[i+1]-a[i];
		if(d[i]<0)cnt-=t*d[i];
		if(d[i]>0)cnt-=s*d[i];
	}
	while(q--){
		cin>>l>>r>>x;l--;
		if(d[l]<0)cnt+=t*d[l];
		if(d[l]>0)cnt+=s*d[l];
		d[l]+=x;
		if(d[l]<0)cnt-=t*d[l];
		if(d[l]>0)cnt-=s*d[l];

		if(r<n){
		if(d[r]<0)cnt+=t*d[r];
		if(d[r]>0)cnt+=s*d[r];
		d[r]-=x;
		if(d[r]<0)cnt-=t*d[r];
		if(d[r]>0)cnt-=s*d[r];
		}

		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 6224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=3005,INF=1<<30;
vector<int> G[MAX];
int color[MAX];
bool ok=true;

void DFS(int u,int p){
    for(int to:G[u]){
        if(to==p) continue;
        if(color[to]==0){
            color[to]=3-color[u];
            DFS(to,u);
        }else if(color[to]==color[u]) ok=false;
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,M;cin>>N>>M;
        if(N+M==0) break;
        memset(color,0,sizeof(color));
        ok=true;
        for(int i=0;i<N;i++) G[i].clear();
        
        for(int i=0;i<M;i++){
            int a,b;cin>>a>>b;
            a--;b--;
            G[a].push_back(b);
            G[b].push_back(a);
        }
        
        color[0]=1;
        DFS(0,-1);
        
        if(!ok) cout<<0<<endl;
        else{
            int cnt1=0,cnt2=0;
            for(int i=0;i<N;i++){
                if(color[i]==1) cnt1++;
                else cnt2++;
            }
            
            if(cnt1%2) swap(cnt1,cnt2);
            
            if(cnt2%2==0&&cnt1!=cnt2){
                cout<<2<<endl;
                if(cnt1>cnt2) swap(cnt1,cnt2);
                cout<<cnt1/2<<endl;
                cout<<cnt2/2<<endl;
            }else if(cnt1%2==0){
                cout<<1<<endl;
                cout<<cnt1/2<<endl;
            }else cout<<0<<endl;
            
        }
    }
}




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

int main() {
  long n, a, b;
  cin >>n >>a >>b;
  
  long ans=0, tmp=0;
  
  ans=(n/(a+b))*a;
  tmp=(n/(a+b))*(a+b);
  if((n-tmp)>a){
    ans+=a;
  }else{
    ans+=n-tmp;
  }
  cout <<ans <<endl;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

bool b[8][8];

bool isin(int n){
  return n>=0 && n<8;
}

void put_queen(int x, int y){
  b[y][x]=true;
  rep(i, 8)b[i][x]=true;
  rep(i, 8)b[y][i]=true;

  rep(i, 16){
    if( !(isin(y+i-8) && isin(x+i-8)) )continue;
    b[y+i-8][x+i-8] = true;
  }

  rep(i, 16){
    if( !(isin(y-i+8) && isin(x+i-8)) )continue;
    b[y-i+8][x+i-8] = true;
  }
}

int main(){
  int n;cin>>n;
  vector<int> x(n), y(n);
  rep(i, n)cin>>y[i]>>x[i];

  vector<int> q;
  rep(i, 8)q.push_back(i);

  do {
    rep(i, 8)rep(j, 8)b[i][j]=false;
    
    bool f = true;
    rep(i, 8){
      if(b[i][q[i]]){f=false; break;}

      put_queen(q[i], i);
    }

    if(!f)continue;

    int initial_q_c=0;
    rep(i, n){
      rep(j, 8){
        if(j==y[i] && q[j]==x[i])initial_q_c++;
      }
    }

    if(initial_q_c==n)break;

  }while(next_permutation(q.begin(), q.end()));

  map<pi, bool> m;
  rep(i, 8) m[make_pair(i, q[i])] = true;

  rep(i, 8){
    rep(j, 8){
      if(m[make_pair(i, j)])cout<<'Q';
      else cout<<'.';
    }
    cout<<endl;
  }

  // rep(i, 8)cout<<q[i]<<' ';cout<<endl;

  return 0;
}

/*

# # # Q # . . #
Q # # # # # # #
. # # # Q # # .
# . # # # # # Q
. # . # # Q # #
. . Q # # # # #
# # # # # # Q #
# Q . # # # # #

*/



Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
string s;
string myans;
void dfs(int total, string ans, int i) {
    if (i >= 4) {
        if (total == 7) {
            myans = ans;
        }
        return;
    }
    int t1 = total + (s[i] - '0');
    string s1 = ans + '+' + s[i];
    dfs(t1, s1, i + 1);
    int t2 = total - (s[i] - '0');
    string s2 = ans + '-' + s[i];
    dfs(t2, s2, i + 1);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    s += '0';
    string t; t += s[0];
    dfs(s[0] - '0', t, 1);
    cout << myans << "=7";
    return 0;
}


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

using namespace std;

const int MaxN = 200005;

struct SegmentTree
{
    vector<int> IT;
    vector<int> Low, High;
    void InitTree(int x, int Left, int Right)
    {
        Low[x] = Left;
        High[x] = Right;
        if (Left == Right)
        {
            IT[x] = 0;
            return;
        }
        int Mid = (Left + Right) / 2;
        InitTree(x * 2, Left, Mid);
        InitTree(x * 2 + 1, Mid + 1, Right);
        IT[x]=max(IT[x*2],IT[x*2+1]);
    }
    void Update(int x, int Left, int Right, int Val)
    {
        if (Low[x] > Right || High[x] < Left)
        {
            return;
        }
        if (Low[x] >= Left && High[x] <= Right)
        {
            IT[x] = Val;
            return;
        }
        Update(x * 2, Left, Right, Val);
        Update(x * 2 + 1, Left, Right, Val);
        IT[x]=max(IT[x*2],IT[x*2+1]);
    }
    int Get(int x, int Left, int Right)
    {
        if (Low[x] > Right || High[x] < Left)
        {
            return 0;
        }
        if (Low[x] >= Left && High[x] <= Right)
        {
            return IT[x];
        }
        return max(Get(x * 2, Left, Right), Get(x * 2 + 1, Left, Right));
    }
    void Init(int n)
    {
        IT.resize(4 * n + 5);
        Low.resize(4 * n + 5);
        High.resize(4 * n + 5);
        InitTree(1, 0, n+1);
    }
};

int n, m;
int a[MaxN], ans[MaxN];
vector<int> Adj[MaxN];
map<int, int> mp;
SegmentTree SMT;

void DFS(int u, int p)
{
    int oldVal = SMT.Get(1, a[u], a[u]);
    SMT.Update(1, a[u],a[u], SMT.Get(1, 0, a[u]-1) +1);
    ans[u] = SMT.IT[1];
    for (auto v : Adj[u])
    {
        if (v != p)
        {
            DFS(v, u);
        }
    }
    SMT.Update(1, a[u], a[u], oldVal);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        mp[a[i]] = 0;
    }
    m = 0;
    for (auto &x : mp)
    {
        m++;
        x.second = m;
    }
    for (int i = 1; i <= n; i++)
    {
        a[i] = mp[a[i]];
    }
    int u, v;
    for (int i = 1; i < n; i++)
    {
        cin >> u >> v;
        Adj[u].push_back(v);
        Adj[v].push_back(u);
    }
    SMT.Init(m);
    DFS(1, -1);
    for (int i = 1; i <= n; i++)
    {
        cout << ans[i] << '\n';
    }
    return 0;
}

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

using vi = vector<int>;


int main(){
  int M1, D1, M2, D2;
  cin >> M1 >> D1 >> M2 >> D2;
  
  if(D2 == 1){
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
a, b = gets.chomp.split.map(&:to_i)

a_str = a.to_s
b_index = b - 1
b_index.times do
        a_str += a.to_s
end

b_str = b.to_s
a_index  = a - 1
a_index.times do
        b_str += b.to_s
end

puts a_str <= b_str ? a_str : b_str

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


const ll inf=1e15+7;
struct max_flow {
    struct edge { ll to, cap, rev; };
    ll V;
    vector<vector<edge>> G;
    vector<ll> itr, level;

    max_flow(ll V) : V(V) { G.assign(V,vector<edge>()); }

    void add_edge(ll from, ll to, ll cap) {
        G[from].push_back((edge) {to, cap, (ll) G[to].size()});
        G[to].push_back((edge) {from, 0, (ll) G[from].size()-1});
    }

    void bfs(ll s) {
        level.assign(V,-1);
        queue<ll> q;
        level[s] = 0; q.push(s);
        while (!q.empty()) {
            ll v = q.front(); q.pop();
            for(auto &e: G[v]){
                if (e.cap > 0 and level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    q.push(e.to);
                }
            }
        }
    }

    ll dfs(ll v, ll t, ll f) {
        if (v == t) return f;
        for (ll& i = itr[v]; i < (ll) G[v].size(); ++i) {
            edge& e = G[v][i];
            if (e.cap > 0 and level[v] < level[e.to]) {
                ll d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    ll run(ll s, ll t) {
        ll ret = 0, f;
        while (bfs(s), level[t] >= 0) {
            itr.assign(V,0);
            while ((f = dfs(s, t, inf)) > 0) ret += f;
        }
        return ret;
    }
};

int main(){
  ll n;cin>>n;
  ll ans=0;
  max_flow m(n+2);
  rep(i,n){
    ll c;cin>>c;
    if(c<0){
      m.add_edge(i+1,n+1,-c);
      m.add_edge(0,i+1,0);
    }
    else{
      ans+=c;
      m.add_edge(0,i+1,c);
      m.add_edge(i+1,n+1,0);
    }
  }
  rep(i,1,n+1){
    for(ll j=2*i;j<=n;j+=i)m.add_edge(j,i,inf);
  }
  cout<<ans-m.run(0,n+1)<<endl;
}

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

using namespace std;

int main(void)
{
  int n,biggest=0,second=0,biggestnum;cin>>n;
  for(int i=1;i<=n;i++){
    int ele;cin>>ele;
    if(ele>second){
      if(ele>biggest){ biggest=ele; biggestnum=i; }
      else { second=ele; }
    }
  }
  for(int i=1;i<=n;i++){
    if(i!=biggestnum) cout<<biggest<<endl;
    else cout<<second<<endl;
  }
  return 0;
}
      

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

int main() {
  int N, op;
  vector<int> A(4);
  cin >> N;
  A.at(0) = N / 1000;
  A.at(1) = (N % 1000) / 100;
  A.at(2) = (N % 100) /  10;
  A.at(3) = N % 10;
  for (int tmp = 0; tmp < (1<<3); tmp++) {
    bitset<3> s(tmp);
    int x = A.at(0);
    for (int i = 1; i < 4; i++) {
      if (s.test(i - 1)) {
        x += A.at(i);
      }else{
        x -= A.at(i);
      }
    }
    if (x == 7) {
      op = tmp;
    }
  }
  bitset<3> t(op);
  cout << A.at(0);
  for (int i = 1; i < 4; i++) {
    if (t.test(i - 1)) {
      cout << '+';
    }else{
      cout << '-';
    }
    cout << A.at(i);
  }
  cout << "=7";
}

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

using namespace std;

long long cmax(long long a, long long b) { return ((a > b) ? a : b); }

int main() {
 	long long a, b, c, d;
  	cin >> a >> b >> c >> d;
  
  	long long mx = LLONG_MIN;
  	mx = cmax(mx, b * d);
  	mx = cmax(mx, b * c);
  	mx = cmax(mx, a * d);
  	mx = cmax(mx, a * c);
  
  	cout << mx << endl;
}

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

int main() {
    int year = 0;
    int month = 0;
    int day = 0;
    char chr;
    vector<char> y(4);
    vector<char> m(2);
    vector<char> d(2);
    for (int i = 0; i < 4; i++) {
        cin >> y.at(i);
    }
    cin >> chr;
    for (int i = 0; i < 2; i++) {
        cin >> m.at(i);
    }
    cin >> chr;
    for (int i = 0; i < 2; i++) {
        cin >> d.at(i);
    }
    year += (y.at(0) - '0') * 1000;
    year += (y.at(1) - '0') * 100;
    year += (y.at(2) - '0') * 10;
    year += (y.at(3) - '0');

    month += (m.at(0) - '0') * 10;
    month += (m.at(1) - '0');

    day += (d.at(0) - '0') * 10;
    day += (d.at(1) - '0'); 

    if (year >= 2020) {
        cout << "TBD" << endl;
    }
    else if (month >= 5) {
        cout << "TBD" << endl;
    }
    else if (day == 31) {
        cout << "TBD" << endl;
    }  
    else {
        cout << "Heisei" << endl;
    }
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=[ i //2 for i in list(map(int,input().split()))]
def f(x):
  c=0
  while(x%2==0):
    x//=2
    c+=1
  return c
def gcd(a,b):
  if b==0:
    return a
  return gcd(b,a%b)
def lcm(a,b):
  return a//gcd(a,b)*b

t=f(a[0])
for i in range(len(a)):
  if t!=f(a[i]):
    print(0)
    exit(0)
  a[i]//=2**t
m//=2**t
l=1
for i in a:
  l=lcm(l,i)
  if l>m:
    print(0)
    exit(0)
m//=l
print((m+1)//2)

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

int  main()
{
	string s; cin >> s;
	int n = 0;
	rep(i, s.size())
	{
		if (s[i] == '+') n++;
		else n--;
	}
	cout << n << endl;
	return (0);
}

Measured memory_bytes: 256
String = str(input())

result = {}
for char in String:
    try:
        result[char] += 1
    except KeyError:
        result[char] = 1

result = list(map(lambda x: x % 2, list(result.values())))
if result == [0] * len(result):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
S = input()
if 0< int(S[0:2]) < 13: #月の可能性
    if 0 < int(S[2:5]) < 13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
    
elif 0< int(S[2:5]) < 13: #月の可能性
    print("YYMM")
    
else:
    print("NA")

    

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,i,x,cnt1=0,cnt2=0,m=10000000000000000;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x;
		cnt1+=x*x;
		cnt2+=x;
	}
	for(i=1;i<=100;i++){
		m=min(m,cnt1+n*i*i-2*i*cnt2);
	}
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD =(int)(1e9)+7;
int main()
{
    long long H,W;
    cin >> H >> W;
    long long ans = (long long)(1e11);
    long long s1,s2,s3;
    for(int i=1;i<H;i++){
        s1=i*W;
        long long k=W/2;
        s2=(H-i)*k;
        s3=(H-i)*(W-k);
        ans=min(ans,max({abs(s1-s2),abs(s2-s3),abs(s3-s1)}));

        if(H-i>=2){
            k=(H-i)/2;
            s2=W*k;
            s3=H*W-s1-s2;
            ans=min(ans,max({abs(s1-s2),abs(s2-s3),abs(s3-s1)}));
        }
    }
    for(int i=1;i<W;i++){
        s1=i*H;
        long long k=H/2;
        s2=(W-i)*k;
        s3=(W-i)*(H-k);
        ans=min(ans,max({abs(s1-s2),abs(s2-s3),abs(s3-s1)}));
        if((W-i)>=2){
            k=(W-i)/2;
            s2=k*H;
            s3=H*W-s1-s2;
            ans=min(ans,max({abs(s1-s2),abs(s2-s3),abs(s3-s1)}));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())

Alist = []
Blist = []

for i in range(1, 1251) :
  Alist.append(int(i * 0.08))
for i in range(1, 1001) :
  Blist.append(int(i * 0.1))

canA = [i + 1 for i, x in enumerate(Alist) if x == A]
canB = [i + 1 for i, x in enumerate(Blist) if x == B]

can = set(canA) & set(canB)

if len(can) == 0 :
  print(-1)
else :
  print(min(can))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 200005;
const LL MOD = 998244353;

int N, h[MAXN], a[MAXN];
LL dp[MAXN];
set<int> mque;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> h[i];
	for (int i = 1; i <= N; i++) cin >> a[h[i]];
	
	mque.insert(0);
	for (int i = 1; i <= N; i++) {
		auto it = mque.upper_bound(h[i]);
		dp[h[i]] = dp[*prev(it)] + a[h[i]];
		while (it != mque.end() && dp[h[i]] >= dp[*it]) it = mque.erase(it);
		mque.insert(h[i]);
	}
	
	cout << dp[*mque.rbegin()] << "\n";
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  string s;
  int last;
  int mn;
};

vector<ST> v1, v2;

int main(){
  int N;
  cin >> N;

  int sum = 0;
  rep(i,N){
    ST st;
    cin >> st.s;
    int mn = 0;
    int now = 0;
    rep(j,st.s.size()){
      if(st.s[j] == ')') now--;
      else now++;
      mn = min(mn, now);
    }
    st.last = now;
    st.mn = mn;

    if(st.last >= 0){
      v1.push_back(st);
    }
    else {
      v2.push_back(st);
    }
    sum += st.last;
  }

  if(sum != 0){
    cout << "No" << endl;
    return 0;
  }

  sort(ALLOF(v1), [](const ST& a, const ST& b){
    return a.mn > b.mn;
  });
  sort(ALLOF(v2), [](const ST& a, const ST& b){
    return a.last - a.mn > b.last - b.mn;
  });

  int now = 0;
  int mn = 0;
  rep(i,v1.size()){
    mn = min(mn, now + v1[i].mn);
    now += v1[i].last;
  }
  rep(i,v2.size()){
    mn = min(mn, now + v2[i].mn);
    now += v2[i].last;
  }
    
  if(mn >= 0 && now == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 42516
#include<iostream>

const int q[3] = { 200, 300, 500 };
const int p[3] = { 380, 550, 850 };
const int b[3] = { 5, 4, 3 };
const double r[3] = { 0.8, 0.85, 0.88 };

int calc( int i, int n )
{
	return n / b[i] * b[i] * p[i] * r[i] + n % b[i] * p[i];
}

int main()
{
	int n;
	while( std::cin >> n, n )
	{
		int ans = 1 << 30;

		for( int a = 0; a <= 25; ++a )
		{
			for( int b = 0; b <= 16; ++b )
			{
				for( int c = 0; c <= 10; ++c )
				{
					int price = calc( 0, a ) + calc( 1, b ) + calc( 2, c );
					int w = a * q[0] + b * q[1] + c * q[2];

					if( w == n )
						ans = std::min( ans, price );
				}
			}
		}

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

	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
long long f(long long a,long long b){
	if(a<b) swap(a,b);
	while(b){
		long long t=a%b;
		a = b;
		b = t;
	}
	return a;
}
int main(){
	long long a,b;
	cin>>a>>b;
	long long lcd = f(a,b);
	long long ret = 0;
	for(long long i=2; i*i<=lcd; i++){
		if(lcd%i==0){
			ret++;
			while(lcd%i==0) lcd/=i;
		}
	}
	if(lcd!=1) ret+=2;
	else ret++;
	cout<<ret;
}

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

int main(int argc, char const *argv[])
{
	int n, h, w; cin >> n >> h >> w;
	cout << (n - h + 1) * (n - w + 1) << 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++) \
    ;

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  int a, b;
  cin >> a >> b;
  int tmp = a * b;
  if (tmp * 1 % 2 == 1 || tmp * 2 % 2 == 1 || tmp * 3 % 2 == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main() {
	ll n;
	cin>>n;
	ll h[n][3];
	for(ll i=0;i<n;i++)
	{
	    cin>>h[i][0]>>h[i][1]>>h[i][2];
	}
	ll c[n][3];
	c[0][0]=h[0][0];c[0][1]=h[0][1];c[0][2]=h[0][2];
	for(ll i=1;i<n;i++)
	{
	    for(ll j=0;j<3;j++)
	    {
	        j==0?c[i][j]=h[i][j]+max(c[i-1][1],c[i-1][2]):0;
	         j==1?c[i][j]=h[i][j]+max(c[i-1][0],c[i-1][2]):0;
	          j==2?c[i][j]=h[i][j]+max(c[i-1][1],c[i-1][0]):0;
	    }
	    
	}
	cout<<max(max(c[n-1][0],c[n-1][1]),c[n-1][2]);
	return 0;
}

Measured memory_bytes: 4992
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = scan.nextInt();
        }
        int max = 0;
        for(int i = 0; i < n; i++){
            if(max <= a[i]){
                max = a[i];
            }
        }
        int max2 = 0;
        int c = 0;
        for(int i = 0; i < n; i++){
            if(max2 < a[i] && a[i] != max){
                max2 = a[i];
            }
            if(a[i] == max){
                c++;
            }
        }
        for(int i = 0; i < n; i++){
            if(a[i] == max && c < 2){
                System.out.println(max2);
            }else{
                System.out.println(max);
            }
        }
    }
}

Measured memory_bytes: 87124
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n + 1);
    for(int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
    }
    int s, t;
    cin >> s >> t;
    int constexpr INF = 1e9;
    vector<vector<int>> dist(n + 1, vector<int>(3, INF));
    dist[s][0] = 0;
    queue<pair<int, int>> q;
    q.push({s, 0});
    while(q.empty() == false) {
        pair<int, int> t = q.front();
        q.pop();
        for(int v : g[t.fi]) {
            int y = (t.se + 1) % 3;
            if(dist[t.fi][t.se] + 1 < dist[v][y]) {
                dist[v][y] = dist[t.fi][t.se] + 1;
                q.push({v, y});
            }
        }
    }
    cout << (dist[t][0] == INF ? -1 : dist[t][0] / 3) << '\n';
}

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

long long gcd(long long a, long long b) {
    if(a%b == 0) {
       return b;
    } else {
        return gcd(b, a%b);
    }
}

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

    long long ans = 0;
    long long n = gcd(c, d);

    b = b - (b/c) - (b/d) + b/(c*d/n);
    a = (a-1) - (a-1)/c - (a-1)/d + (a-1)/(c*d/n);

    ans = b-a;


    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
char a, b;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b;
  cout << (a==b ? 'H' : 'D') << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  int A,B,C;

  scanf("%d%d%d", &A, &B, &C);

  if( A+B == C ||
      A+C == B ||
      B+C == A )
    printf("Yes\n");
  else
    printf("No\n");
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

ll modpow(ll a, ll t, ll p) {
    ll ret = 1LL;
    while(t){
        if(t & 1LL){
            ret *= a;
            ret %= p;
        }
        a *= a;
        a %= p;
        t >>= 1;
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n; ll p;
    cin >> n >> p;
    string s;
    cin >> s;

    if(p == 2 || p == 5) {
        ll ans = 0;
        for(int i=0;i<n;++i) {
            int num = int(s[i] - '0');
            if(num % p == 0) {
                ans += ll(i+1);
            }
        }
        cout << ans << endl;
        return 0;
    }

    vector<ll> mod_a(n+1, 0), mod_b(n+2, 0);
    for(int i=1;i<=n;++i) {
        int num = int(s[i-1] - '0');
        mod_a[i] = (mod_a[i-1] + num * modpow(10LL, n-i, p)) % p;
    }

    // for(int i=n;i>=1;--i) {
    //     int num = int(s[i-1] - '0');
    //     mod_b[i] = (num * pow10 + mod_b[i+1]) % p;
    //     pow10 *= 10LL;
    //     pow10 %= p;
    // }

    // pow10 = 1;
    // vector<ll> pow10_inv(n+1);
    // for(int i=0;i<=n;++i) {
    //     pow10_inv[i] = modpow(pow10, p-2);
    // }

    vector<ll> cnt(p, 0);
    ll ans = 0LL;
    for(int i=1;i<=n;++i) {
        // cerr << mod_a[i] << " ";
        ++cnt[mod_a[i-1]];
        ans += cnt[mod_a[i]];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3732
from sys import stdin

list_N = [int(x) for x in stdin.readline().rstrip().split()]
list_V = [int(x) for x in stdin.readline().rstrip().split()]
list_C = [int(x) for x in stdin.readline().rstrip().split()]

XsubY=0
for i in range(0, list_N[0]):
    sub = list_V[i] - list_C[i]
    if(sub>0):
        XsubY += sub

print(XsubY)

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    result()
}

private fun result() {
    readLine()?.split(" ")?.let {
        var summerDay = it[0].toInt()
        val homeworkCount = it[1].toInt()
        val quote = readLine()?.split(" ")?.map { it.toInt() }?: emptyList()
        quote.forEach {
            summerDay -= it
        }
        if (summerDay < 0) {
            println("-1")
        } else {
            println(summerDay)
        }
    }
}

Measured memory_bytes: 39288
N = int(input())
T, A = map(int, input().split())
H = input().split()

ans = 0
min_diff = 2**32
for i, h in enumerate(H):
  d = abs((T-int(h)*0.006)-A)
  if min_diff > d:
    min_diff = d
    ans = i+1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n, t;
    cin >> n >> t;
    vector<vector<int>> ab(n, std::vector<int>(2));
    for (int i = 0; i < n; i++) {
        cin >> ab[i][0] >> ab[i][1];
    }
    sort(ab.begin(), ab.end());
    vector<int> dp(t + 1, 0);
    for (int i = 0; i < n; i++) {
        for (int j = t - 1; j >= 0; j--) {
            if (j == 0) {
                if (ab[i][0] < t) {
                    chmax(dp[ab[i][0]], ab[i][1]);
                } else {
                    chmax(dp[t], ab[i][1]);
                }
            } else if (dp[j] > 0 && (j + ab[i][0] < t)) {
                chmax(dp[j + ab[i][0]], dp[j] + ab[i][1]);
            } else if (dp[j] > 0) {
                chmax(dp[t], dp[j] + ab[i][1]);
            }
        }
    }
    int max = 0;
    for (int i = 0; i <= t; i++) {
        chmax(max, dp[i]);
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    
    //変数：１匹目のトンボの頭の位置 「 x1 」と２匹目のトンボの頭の位置 「 x2 」と置く

    int x1, x2;
   
    //入力：１匹目のトンボの頭の位置 「 x1 」と２匹目のトンボの頭の位置 「 x2 」を入力
    cin >> x1 >> x2;
    
    //出力：両トンボ間の距離は必ず正の数だから絶対値を使用 ➡  abs(式  or  変数)
    cout << abs(x1 - x2) << endl;
    
    return 0;
}


Measured memory_bytes: 3064
<?php
$Arraylength = trim(fgets(STDIN));
$stdins = explode(" ",trim(fgets(STDIN)));

bubbleSort($stdins,$Arraylength);

function bubbleSort($Array, $N){ 
    $count = 0;
    for ($i=0; $i<$N; ++$i){
        for ($j=$N-1; $j>$i; --$j){
            if ($Array[$j] < $Array[$j-1]){
                 $tmp = $Array[$j];
                 $Array[$j] = $Array[$j-1];
                 $Array[$j-1] = $tmp;
                 $count++;
            }
        }
    }
    echo implode(" ",$Array) . PHP_EOL;
    echo $count . PHP_EOL;
}


Measured memory_bytes: 9320
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int N, M;
vector<vector<P>> G(100001); // first  : 行先
								 // second : 距離
int Query[200001][3]; // [0] : L
					  // [1] : R
					  // [2] : D 

void input() {
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; i++) {
		scanf("%d%d%d", &Query[i][0], &Query[i][1], &Query[i][2]);
		G[Query[i][0]].push_back(P(Query[i][1], Query[i][2]));
		G[Query[i][1]].push_back(P(Query[i][0], -Query[i][2]));
	}

	// 確認
	/*
	for (int i = 1; i <= N; i++) {
		for (auto u : G[i]) {
			cout << i << "→" << u.first << "(" << u.second << ")   : ";
		}
		cout << endl;
	}
	*/
}

int pos[100001];
bool isfound[100001];

void dfs(int c, int d) { // c : 現在位置
						 // d : ここに至るまでの距離
	isfound[c] = true;
	pos[c] = d;

	for (P u : G[c]) {
		if (!isfound[u.first]) dfs(u.first, d + u.second);
	}
}

void solve() {
	for (int i = 1; i <= N; i++) isfound[i] = false;

	for (int i = 1; i <= N; i++) {
		if (!isfound[i]) dfs(i, 0);
	}

	// 確認
	bool flag = true;
	for (int i = 0; i < M && flag; i++) {
		if (pos[Query[i][1]] - pos[Query[i][0]] != Query[i][2]) {
			flag = false;

			// cout << i << "番目がダメでした" << endl;
		}
	}

	// for (int i = 1; i <= N; i++) cout << pos[i] << " ";

	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

	input();
	solve();

	return 0;
}

Measured memory_bytes: 13568
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const int MOD = 1000000007;
int main() {
    int N;
    cin >> N;
    int count = 0;
    rep(i, 1, N + 1) {
        int yaku = 0;
        rep(r, 1, N + 1) {
            if(i % r == 0) {
                yaku++;
            }
        }
        if(i % 2 == 1 && yaku == 8) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  vector<pair<int, int>> m(N);
  for(int i=0;i<N;i++){
    cin >> m[i].first;
    m[i].second=i+1;
  }
  sort(m.begin(),m.end());
  for(int i=0;i<N;i++){
    cout << m[i].second << endl;
  }
}


Measured memory_bytes: 1664
function main(input) {
    var array = input.split(' ')
    var a = parseInt(array[0],10)
    var b = parseInt(array[1],10)
    if ((a*b) % 2===0){
        console.log('Even')
    }else {
        console.log('Odd')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, nc, ans = 0, cnt = 0, t = 26;
  cin >> n;

  while (n >= t) n -= t, cnt++, t *= 26;

  if (n == 0) {
    rep(i, cnt) cout << 'z';
    cout << endl;
    return 0;
  }
  if (n == 1) {
    rep(i, cnt + 1) cout << 'a';
    cout << endl;
    return 0;
  }

  n--;
  rep(i, cnt + 1) {
    ll x = (ll)pow(26, cnt - i);
    ll y = n / x;
    cout << (char)('a' + y);
    n -= y * x;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 4028
import sys
def main():
    input = sys.stdin.readline
    N = int(input())
    E = [[] for _ in range(N)]
    for i in range(N-1):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        E[a].append((b,i))
        E[b].append((a,i))
    
    def dfs(s, g):
        par = [(-1,-1)] * N
        par[s] = (s,-1)
        stack = [s]
        while stack:
            v = stack.pop()
            for to, i in E[v]:
                if par[to][0] >= 0: continue
                par[to] = (v, i)
                if to == g: break
                stack.append(to)
        r = 0
        v = g
        while v != s:
            v, i = par[v]
            r |= 1 << i
        return r
    
    M = int(input())
    path = [0] * M
    for i in range(M):
        u, v = map(int, input().split())
        u, v = u-1, v-1
        path[i] = dfs(u, v)

    def calc(s): return 1<<(N-1-popcount(s))

    i_ans = 0
    for p in range(1, 1<<M):
        is_odd = 0
        s = 0
        for i in range(M):
            if p&1:
                s |= path[i]
                is_odd ^= 1
            p >>= 1
        if is_odd: i_ans += calc(s)
        else: i_ans -= calc(s)

    print((1<<(N-1)) - i_ans)

def popcount(x):
    x = (x & 0x5555555555555555) + (x >> 1 & 0x5555555555555555)
    x = (x & 0x3333333333333333) + (x >> 2 & 0x3333333333333333)
    x = x + (x >> 4) & 0x0f0f0f0f0f0f0f0f
    x += x >> 8
    x += x >> 16
    x += x >> 32
    return x & 0x7f

if __name__ == '__main__':
    main()

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

int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a, a + N);
  reverse(a, a + N);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0)
      ans += a[i];
    else
      ans -= a[i];
  }
  cout << ans << endl;
}

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

const int N = 3005;
const int mod = 1e9 + 7;
const int two = 5e8 + 4;

void add(int& x,int y) {
	x += y; if (x >= mod) x -= mod;
}

int mul(int x,int y) {
	return (long long) x * y % mod;
}

int n, q;
int a[N];
int f[N][N];
int nf[N][N];

int main() {
	scanf("%d %d", &n, &q);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			f[i][j] = (a[i] > a[j]);
		}
	}
	for (int it = 1; it <= q; ++it) {
		int x, y; 
		scanf("%d %d", &x, &y);
		if (x > y) swap(x, y);
		nf[x][y] = nf[y][x] = mul(two, f[x][y] + f[y][x]);
		for (int i = 1; i <= n; ++i) if (i != x && i != y) {
			nf[i][x] = nf[i][y] = mul(two, f[i][x] + f[i][y]);
			nf[x][i] = nf[y][i] = mul(two, f[x][i] + f[y][i]);
		}
		for (int i = 1; i <= n; ++i) {
			f[i][x] = nf[i][x];
			f[x][i] = nf[x][i];
			f[i][y] = nf[i][y];
			f[y][i] = nf[y][i];
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			add(ans, f[i][j]);
		}
	}
	for (int i = 1; i <= q; ++i) {
		ans = mul(ans, 2);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 70784
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for c in range(0, C+1):
    for b in range(0, B+1):
        for a in range(0, A+1):
            if c*50 + b*100 + a*500 == X:
                cnt += 1

print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, D;
  cin >> N >> D;
  if(N%(2*D+1)==0) cout << N/(2*D+1)<< endl;
  else cout << N/(2*D+1)+1 << endl;
}

Measured memory_bytes: 256
//abc056_b.cpp
//Sat Oct 27 20:37:21 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int w,a,b;
	cin >> w >> a >> b;

	if (a+w<=b){
		cout << b-a-w << endl;
	}else if (b+w <= a){
		cout << a-b-w << endl;
	}else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 768
n,m,x=map(int,input().split())
a=[]
for _ in range(n):
  s=list(map(int,input().split()))
  a.append(s)
  
ans=[]
check=0
for q in range(2**n):
  nedan=[0]*m
  sum1=0
  for i in range(n):
    if ((q>>i) &1):
      sum1+=a[i][0]
      for p in range(m):
        nedan[p]+=a[i][p+1]
  
  t=min(nedan)
  if t>=x  :
    ans.append(sum1)
    check+=1
    
if check==0:
  print(-1)
  
else:
  print(min(ans))

Measured memory_bytes: 9064