akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

struct MaxHeap{
    int h [2000000];
    int lastPos; //index of last element=number of elements
    
    MaxHeap(){ 
        lastPos=0;
    } 
    
    bool isLeaf(int pos){ 
        if (pos>(lastPos/2) && pos <=lastPos){
            return true;
        } else {
            return false;
        }
    }

    void siftDown(int pos) {
        bool isHeap=false;
        int lc, rc, temp;
        while (!isLeaf(pos) && isHeap==false){
            lc = 2*pos, rc= 2*pos+1; //lc=leftChild, rc=rightChild
            if (rc <=lastPos){ //if it has a right son
                if (h[rc]>h[lc]){
                    lc=rc; //rc is greater than lc
                }
            }
            if (h[pos]>=h[lc]){
                isHeap=true;
            } else {
                temp=h[pos];
                h[pos]=h[lc];
                h[lc]=temp;
                pos=lc; //moving down
            }
        }
    }
    
    //increases the number of elements and insert the new key k at the end of the array, then compare with 
    //the parent's value, if the k's value is less than of its parent it's a heap, if not swap k and its father,
    //keep comparing until k is in its right position
    void insert(int k) {
        int currPos, temp;
        lastPos++;
        currPos=lastPos;
        h[currPos] = k; 
        while (currPos>1 && h[currPos]>h[currPos/2]){ //currPos/2=parent's position
            temp=h[currPos];
            h[currPos]=h[currPos/2];
            h[currPos/2]=temp;
            currPos=currPos/2;
        }
    }
    int removeMax() {
        int root=h[1], temp; //root=max value
        temp=h[1];
        h[1]=h[lastPos];
        h[lastPos]=temp;
        lastPos--;
        siftDown(1);
        return root;
    }
};

int main(){
    string op;
    int k, removed;
    MaxHeap heap;
    while(cin>>op && op.compare("end")!=0){
        if(op[0]=='i'){ //insert
            cin>>k;
            heap.insert(k);
        } else { //extract
            removed=heap.removeMax();
            cout<<removed<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6960
INF_MAX = 2 ** 31 - 1


class Segment_tree():
    def __init__(self, N):
        self.N = 1
        while self.N < N:
            # 完全二分木にするために2のべき乗にする
            self.N *= 2

        self.dat = []
        for i in range(2 * self.N - 1):
            # indexが0を頂点とするsegment_treeを作る
            self.dat.append(INF_MAX)

    def update(self, k, x):
        k += self.N - 1
        # 指定しているkにsegmenttreeのindexを合わせる
        self.dat[k] = x
        while k > 0:
            # datの下から更新して行く
            k = int((k - 1) / 2)
            self.dat[k] = min(self.dat[k * 2 + 1], self.dat[k * 2 + 2])

    def find(self, a, b, k, l, r):
        if r < a or b < l:
            # a,bが区間に存在しないとき
            return INF_MAX
        if a <= l and r <= b:
            # 区間a,bがl,rを完全に含んでいるとき
            return self.dat[k]
        else:
            mid = int((l + r) / 2)
            # 左の子と右の子にいく
            vl = Segment_tree.find(self, a, b, k * 2 + 1, l, mid)
            vr = Segment_tree.find(self, a, b, k * 2 + 2, mid + 1, r)
            return min(vl, vr)


def main():
    N, Q = map(int, input().split())
    segment_tree = Segment_tree(N)
    for i in range(Q):
        command, a, b = map(int, input().split())
        if command == 0:
            Segment_tree.update(segment_tree, a, b)
        else:
            if a > b:
                a, b = b, a
            min_number = Segment_tree.find(segment_tree, a, b, 0, 0, segment_tree.N - 1)
            print(min_number)


if __name__ == "__main__":
    main()



Measured memory_bytes: 8812
#include <stdio.h>

int main(void){
  int a, b, k;
  scanf("%d%d%d", &a, &b, &k);
  int i;
  for(i = a; i <= b; i++){
    if(i < a + k || b - k < i){
      printf("%d\n", i);
    }
  }
  return 0;
}

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

int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k<=a) cout << k << endl;
    else if(a<k && k<=a+b) cout << a << endl;
    else if(a+b<k && k<=a+b+c) cout << a-(k-a-b) << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s, t;
	cin >> s >> t;

	vector<Int> S(26,-1);//Sの置換表
	vector<Int> T(26,-1);//Tの置換表
	vector<Int> D(26, -1);//重複確認用

	Int len = s.size();

	//同じ文字は異なる文字に変換されない
	Int flag = 0;
	for (Int i = 0; i < len; i++) {
		if (S[s[i]-'a'] == -1) {
			S[s[i] - 'a'] = t[i] - 'a';
			continue;
		}
		else if (S[s[i] - 'a'] != t[i] - 'a') {
			flag = 1;
			break;
		}
	}

	/*
	for (Int i = 0; i < len; i++) {
		if (T[t[i] - 'a'] == -1) {
			T[t[i] - 'a'] = s[i] - 'a';
			continue;
		}
		else if (T[t[i] - 'a'] != s[i] - 'a') {
			flag = 1;
			break;
		}
	}
	*/

	//違う文字から、同じ文字に変換されないかチェック
	for (Int i = 0; i < 26; i++) {
		if ((S[i] != -1) && (D[S[i]] == -1)) {
			D[S[i]] = 1;
			continue;
		}

		if ((S[i] != -1) && (D[S[i]] == 1)) {
			flag = 1;
			break;
		}
	}


	cout << (flag ? "No" : "Yes") << endl;

}

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

long long dp[110][100010];

int main(){
	int n, m;
	int v[110], w[110];
	
	cin >> n >> m;
	
	for(int i=1; i<=n; i++)
		cin >> w[i] >> v[i];
		
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			dp[i][j] = dp[i-1][j];
			if(w[i] <= j)
				dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]);
		}
	}
	
	cout << dp[n][m] << '\n';
}

Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    int p[n];
    for(int i=0;i<n;i++)cin >> p[i];
    sort(p,p+n);
    int ans=0;
    for(int i=0;i<k;i++)ans += p[i];
    cout << ans << endl;
}

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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

/**
 *  約数を列挙する
 */
template<typename T>
std::vector<T> divisor(T n, bool sort = true) {
    std::vector<T> ret;
    for(T i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    if(sort) std::sort(ret.begin(), ret.end());
    return ret;
}

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

    ll N;
    std::cin >> N;

    auto div = divisor(N);
    ll   ans = LINF;
    REP(i, div.size()) {
        REP(j, div.size()) {
            if(N == div[i] * div[j]) {
                chmin(ans, (ll)(div[i] + div[j] - 2));
            }
        }
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void){
  int a[3];
  for(int i=0;i<3;i++){
    scanf("%d",&a[i]);
  }
  int num=(a[0]*100)+(a[1]*10)+a[2];
  if(num%4==0){
    printf("YES");
  }else{
    printf("NO");
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 128
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
aa = inl()
a = []
for i in range(n):
    x = []
    for j in range(20):
        x.append((aa[i]>>j)&1)
    a.append(x)
if DBG:
    for i,z in enumerate(a):
        printn(aa[i])
        printn(' ')
        printn(i)
        print(z)
    print("- a -")
cnt = n
c = [a[0][j] for j in range(20)]
s = 1
for i in range(1,n):
    ok = True
    for j in range(20):
        if c[j]==1 and a[i][j]==1:
            ok = False
            break
    #ddprint("i {} ok {} c {} s {} cnt {}".format(i,ok,c,s,cnt))
    if ok:
        cnt += s
        s += 1
        for j in range(20):
            c[j] += a[i][j]
    else:
        for j in range(20):
            c[j] += a[i][j]
        #cnt += s*(s-1)//2
        s += 1
        #ddprint("mid s {} c {}".format(s,c))
        while s>1:
            if max(c)<=1:
                break
            for j in range(20):
                c[j] -= a[i-s+1][j]
            s -= 1
            #ddprint("mid2 s {} c {}".format(s,c))
        cnt += s-1
print(cnt)


Measured memory_bytes: 129400
import sys
from collections import Counter
 
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60

def prime_factorize(x):
    a = []
    while x % 2 == 0:
        a.append(2)
        x //= 2
    f = 3
    while f * f <= x:
        if x % f == 0:
            a.append(f)
            x //= f
        else:
            f += 2
    if x != 1:
        a.append(x)
    return a

def main():
    N = int(readline())
    a = Counter(prime_factorize(N))
 
    ans = 0
    for power in a.values():
        ans += int(((1 + 8 * power) ** 0.5 - 1) / 2)
 
    print(ans)
    return
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 9732
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 10e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//



signed main()
{
  ios();
  int a[3];
  rep(i,3)cin >> a[i];
  sort(a,a+3);
  cout << abs(a[2] - a[1]) + abs(a[1]-a[0]) << endl;
  
}


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

int a[3], b;

int main() {

	cin >> a[0] >> a[1] >> a[2];
	b = a[2];
	sort(a, a + 3);

	if (a[1] == b)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
template<typename T = int>
T in() {T a; cin >> a; return a;}
/***** MAIN *****/
signed main() {
  int n, h, w;
  cin >> n >> h >> w;
  int ans = 0;
  REP(i,n) {
    int a, b;
    cin >> a >> b;
    if(a >= h && b >= w) ++ans;
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
N,M=map(int, input().split())

prob=[0]*N
prob[0]=1
num=[1]*N
num[0]=1

for i in range(M):
    x,y=map(int, input().split())
    if prob[x-1]==1:
        prob[y-1]=1
    num[x-1]-=1
    num[y-1]+=1
    if num[x-1]==0:
        prob[x-1]=0
print(sum(prob))

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

int main() {
    int n;
    cin >> n;
    int a, b, c, d;
    a = n / 1000;
    b = n / 100 - a * 10;
    c = n / 10 - a * 100 - b * 10;
    d = n - a * 1000 - b * 100 - c * 10;
    
    if (a == b && b == c && c == d) {
        cout << "Yes" << endl;
    }
    else if (a == b && b == c) {
        cout << "Yes" << endl;
    }
    else if (b == c && c == d) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005



int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);

        string a,b;
        cin >> a >> b;
        int n=a.size();
        int m=b.size();
        if(m!=(n+1)){
            cout << "No";
            return 0;
        }
        int i;
        for( i=0; i<n; i++){
            if(a[i]!=b[i]){
                cout << "No";
                return 0;
            }
        }
        cout << "Yes" << '\n';

        

}

Measured memory_bytes: 3648
/**
*    created: 09.07.2020 22:19:15
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n; cin >> n;
    int x = 800 * n;
    int y = 200 * (n / 15);
    cout << x - y << endl;
    return 0;
}

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

dp = [i for i in range(101010)]

#dp[i] = i円払うのに必要な最小値
#6ˆn円,0<=i<=Nにおいて、dp[i+6ˆn] = min(dp[i+6ˆn] ,dp[i]+1)  


t = 7
while True:
    for i in range(101010):
        if 6**t+(i+1) < 101010:
            dp[6**t+(i)] = min(dp[6**t+(i)], dp[i] + 1) 
    t -= 1
    if t == 0:
        break


t = 7
while True:
    for i in range(101010):
        if 9**t+(i+1) < 101010:
            dp[9**t+(i)] = min(dp[9**t+(i)], dp[i] + 1)
    t -= 1
    if t == 0:
        break

i = 0
while i+1 < 101010:
    dp[i+1] = min(dp[i+1],dp[i]+1)
    i += 1

#print(dp)
print(dp[n])

Measured memory_bytes: 7064
#include <stdio.h>
#include <stdlib.h>
int strcmp( const void *p, const void *q ) {
   		 return *(int*)p - *(int*)q;}
int main(){
  int n,a[100];
  scanf("%d",&n);
  for(int i=0;i<n;i++)scanf("%d",&a[i]);
  qsort(a,n,sizeof(int),strcmp);
  printf("%d",a[n-1]-a[0]);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        string s;
        getline(cin, s);
        if(s == "")
            return 0;
    
        int n = s.size();
        for(;;){
            bool bl=false;
            for(int i=0; i<n; ++i){
               if('a' <= s[i] && s[i] <= 'z'){
                   if(s[i] == 'z')
                           s[i] = 'a';
                   else
                           ++ s[i];
               }
           }
           istringstream iss(s);
           string s1;
           while(iss >> s1){
               if(s1 == "the" || s1 == "this" || s1 == "that"){
                       cout << s << endl;
                       bl=true;
                       break;
               }
            }
           if(bl) break;
         }      
    }
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int modulo(int x,int N){
    return (x % N + N) %N;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    int a[n];
    for(int i=0;i<n;++i) cin>>a[i];
    int ans=0;
    reverse(a,a+n);
    for(int i=0;i<n;++i)
    {
        bool check=true;
        for(int j=i+1;j<n;++j)
        {
            if(a[i]>=a[j])
            {
                check = true;
            }
            else {check=false; break;}
        }
        if(check) ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextStr() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRuneAt(s string, i int) rune {
	rs := []rune(s)
	return rs[i]
}

func main() {
	sc.Split(bufio.ScanWords)
	a, _ := strconv.Atoi(nextStr())
	b, _ := strconv.Atoi(nextStr())

	var sum int
	if a > b {
		sum += a
		a--
	} else {
		sum += b
		b--
	}

	if a > b {
		sum += a
	} else {
		sum += b
	}

	fmt.Print(sum)
}


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

int main() {
  int n,p;
  cin >>n >>p;
  int sum;
  bool odd=false;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    sum +=a;
    if(a%2!=0){
      odd=true;
    }
  }  
  long ans=1;
  for(int i=1;i<=n-1;i++){
    ans*=2;
  }
  if(odd){
    cout << ans;
  }
  else{
    cout << (p%2==0?ans*2:0);
  }
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
A.append(0)
S = 0
for i in range(n+2):
    S += abs(A[i]-A[i-1])
for i in range(1,n+1):
    print(S-abs(A[i]-A[i+1])-abs(A[i]-A[i-1])+abs(A[i-1]-A[i+1]))

Measured memory_bytes: 14040
#include<bits/stdc++.h>
#include<cmath>
#include<string>
using namespace std;
int main(){
  long long X;
  vector<long> A(3);
  cin>>A.at(0)>>A.at(1)>>A.at(2);
  sort(A.begin(),A.end());
  if(A.at(1)%2==0||A.at(2)%2==0||A.at(0)%2==0) X=0;
  else X=A.at(0)*A.at(1);
  cout <<X<< endl;
}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (N, K) = readLine()!!.split(" ").map { it.toInt() }
    val V = readLine()!!.split(" ").map { it.toInt() }.toMutableList()

    var max = 0
    (0..Math.min(N, K)).forEach {L ->
        (0..Math.min(N, K)).forEach { R ->
            if (L +R <= Math.min(N, K)) {
                val popped = mutableListOf<Int>()
                if (L > 0) {
                    V.slice(0..(L-1)).forEach {
                        popped.add(it)
                    }
                }
                if (R > 0) {
                    V.slice((N-R)..(N-1)).forEach {
                        popped.add(it)
                    }
                }

                popped.sort()
                val timesPossibleToReturn = K - (L+R)
                var sum = popped.sum()
                if (timesPossibleToReturn > 0) {
                    popped.take(timesPossibleToReturn).filter { it < 0 }.forEach {
                        sum -= it
                    }
                }

                max = Math.max(sum, max)
            }
        }
    }
    println(max)
}

Measured memory_bytes: 42608
//Keep Working Hard
  // I__Like__Food  

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;
  const double PI = 3.1415926535898;


int32_t main()
{








    set<string> s;


    int n;
    cin >> n;

    for(int i = 0; i < n; i++)
    {
    	string ss;
    	cin >>ss;
    	s.insert(ss);
    }

    cout << s.size();



    return 0;
}


Measured memory_bytes: 19224
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        int m = scn.nextInt();
        int[] a = new int[n];
        int[] pena = new int[n];
        int clear = 0;
        int total = 0;
        for(int i = 0; i < m; i++){
            int pm = scn.nextInt()-1;
            String sm = scn.next();
            if(a[pm] == 1){
                
            }else if(sm.equals("AC")){
                clear++;
                a[pm]=1;
            }else{
                pena[pm]++;
            }
        }
        int penalty = 0;
        for(int i = 0; i < n; i++){
            if(a[i] == 1){
                penalty += pena[i];
            }
        }
        System.out.println(clear+" "+penalty);
        
    }
}


Measured memory_bytes: 66148
#include <iostream>

const int MOD = 998244353;
const int N = 3004;

int n, x;
int calc[N];
int cnk[N][N];

signed main()
{
    std::cin >> n >> x;
    calc[0] = 1;
    for (int i = 0; i <= n; i++)
    {
        cnk[i][0] = 1, cnk[i][i] = 1;
        for (int j = 1; j < i; j++)
        {
            cnk[i][j] = (cnk[i - 1][j - 1] + cnk[i - 1][j] >= MOD) ? cnk[i - 1][j - 1] + cnk[i - 1][j] - MOD : cnk[i - 1][j - 1] + cnk[i - 1][j];
        }
    }
    for (int len = 1; len <= n; len++)
    {
        for (int summ = len; summ <= 2 * len; summ++)
        {
            if (summ < x)
            {
                if (summ - len >= 0) calc[len] = calc[len] + cnk[len][summ - len];
                if (calc[len] >= MOD) calc[len] -= MOD;
            }
            else
            {
                if (summ <= x || (summ - x + 1) % 2 == 1)
                {
                    continue;
                }
                int L = (summ - x + 1) / 2;
                int summa = summ - 4 * L;
                int dlina = len - 2 * L;
                if (summa != 2 * dlina)
                {
                    if (summa - dlina >= 0) calc[len] = calc[len] + cnk[dlina][summa - dlina];
                    if (calc[len] >= MOD) calc[len] -= MOD;
                }
            }
        }
        if (2 * len >= x && x % 2 == 1) calc[len]++;
    }
    int ans = 0;
    for (int i = 0; i <= n; i++)
    {
        ans = (ans + 1ll * calc[i] * cnk[n][i]) % MOD;
    }
    std::cout << ans;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 34176
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N;
	static int[] B;
	static boolean[][] g;
	static boolean[] used;
	static HashMap<Long, Integer> memo;
	static long[] mask;

	public static void main(String[] args) {
		while (true) {
			N = sc.nextInt();
			if (N == 0) break;
			Country[] cs = new Country[N];
			used = new boolean[N];
			B = new int[N];
			for (int i = 0; i < N; ++i) {
				cs[i] = new Country();
				B[i] = cs[i].b;
			}
			used[0] = true;
			g = new boolean[N][N];
			for (int i = 0; i < N; ++i) {
				for (String o : cs[i].c) {
					for (int j = 0; j < N; ++j) {
						if (o.equals(cs[j].a)) {
							g[i][j] = true;
							if (i == 0) used[j] = true;
							break;
						}
					}
				}
			}
			int ans = B[0];
			for (int i = 0; i < N; ++i) {
				if (!used[i]) ans += solve(i);
			}
			System.out.println(ans);
		}
	}

	static int solve(int cur) {
		int pos = 0;
		ArrayList<Integer> list = new ArrayList<Integer>();
		list.add(cur);
		used[cur] = true;
		while (pos < list.size()) {
			int c = list.get(pos++);
			for (int i = 0; i < N; ++i) {
				if (g[c][i] && !used[i]) {
					used[i] = true;
					list.add(i);
				}
			}
		}
		mask = new long[list.size()];
		for (int i = 0; i < list.size(); ++i) {
			for (int j = 0; j < list.size(); ++j) {
				if (g[list.get(i)][list.get(j)]) {
					mask[i] |= 1L << list.get(j);
				}
			}
			mask[i] |= 1L << list.get(i);
		}
		memo = new HashMap<Long, Integer>();
		return dfs(0, list, 0);
	}

	static int dfs(int pos, ArrayList<Integer> list, long st) {
		if (pos == list.size()) return 0;
		if (pos > 15 && memo.containsKey(((long) pos << 50) | st)) {
			return memo.get(((long) pos << 50) | st);
		}
		int cur = list.get(pos);

		// not use cur
		int ret = dfs(pos + 1, list, st | (1L << cur));

		// use cur
		if ((st & (1L << cur)) == 0) {
			int sum = B[cur];
			sum += dfs(pos + 1, list, st | mask[pos]);
			ret = Math.max(ret, sum);
		}

		if (pos > 15) {
			memo.put(((long) pos << 50) | st, ret);
		}
		return ret;
	}

	static class Country {
		String a;
		int b;
		String[] c;

		Country() {
			a = sc.next();
			b = sc.nextInt();
			int cc = sc.nextInt();
			c = new String[cc];
			for (int i = 0; i < cc; ++i) {
				c[i] = sc.next();
			}
		}
	}
}

Measured memory_bytes: 61720
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int n,m;
    cin >> n >> m;
    int X,Y;
    cin >> X >> Y;
    vector <int> x(n);
    vector <int> y(m);
    rep(i,0,n) {
        cin >> x[i];
    }
    rep(i,0,m) {
        cin >> y[i];
    }
    rep(i,X+1,Y+1) {
        bool flag = true;
        rep (j,0,n) {
            if (x[j] >= i) {
                flag = false;
            }
        }
        rep (j,0,m) {
            if (y[j] < i) {
                flag = false;
            }
        }
        if (flag) {
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
}

Measured memory_bytes: 3024
S=input()
flug=True
nagasa=len(S)
for i in range(nagasa):
    for k in range(1,nagasa-i):
        if S[i:i+1]==S[i+k:i+k+1]:
            flug=False
            break
if flug==True:
    print("yes")
else:
    print("no")

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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 17;

char str[MAXN];
int f[MAXN][2];

int main()
{
	scanf("%s", str + 1); int l = strlen(str + 1);
	f[0][1] = 0;
	f[0][0] = -0x3f3f3f3f;
	FOR(i, 1, l) {
		f[i][1] = f[i - 1][1] + str[i] - '0';
		f[i][0] = f[i - 1][0] + 9;
		if (str[i] != '0') chkmax(f[i][0], f[i - 1][1] + str[i] - '0' - 1);
	}
	printf("%d\n", Max(f[l][0], f[l][1]));
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  
  vector<int> a(n,0);
  
  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  
  int min = 101;
  int max = 0;
  
  for(int i = 0; i < n; i++)
  {
    if(a[i]>max)
    {
      max = a[i];
    }
    
    if(a[i]<min)
    {
      min = a[i];
    }
  }
  
  int ans = 1000000;
  
  for(int j = min; j <= max; j++)
  {
    int sum = 0;
    for(int i = 0; i < n; i++)
    {
      sum += (a[i] - j)*(a[i] - j);
    }
    
    if(sum < ans)
    {
      ans = sum;
    }
  }

  cout << ans;
  
  return 0;
}

Measured memory_bytes: 256
N=int(input())
T=[list(map(int,input().split())) for _ in range(N)]

T.sort(key=lambda x:x[0])
T.sort(key=lambda x:x[1])

sum=0
for i in range(N):
  sum+=T[i][0]
  if sum>T[i][1]:
    print('No')
    break
else:
  print('Yes')

Measured memory_bytes: 53608
#include<bits/stdc++.h>
using namespace std;
bool comp(int a,int b){
   return a<b;
}
int main(){
    char arr[4];
    char arr2[4];
    cin>>arr;
    cin>>arr2;
    int c=0;
    for(int i=0;i<3;i++){
        if(arr[i]==arr2[i])c++;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
# coding: utf-8

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

#（↓）累積和を別のリストに格納する必要はなく、
# modmという変数を1つ用意して、modmにその時点での
# 累積和のmod mを格納すればよい
modm = 0

#（↓）{x:y}:Aの各要素を順に処理していくとき、
# mod mがxである要素が現時点までにy個見つかっていることを表す
dic = {0:1}

cnt = 0
for a in A:
    modm = (modm+a) %m
    cnt += dic.get(modm,0)
    dic[modm] = dic.get(modm,0) + 1
#（↑）c[b]では、bをキーとする要素が見つからなかった場合
# エラーが発生してしまう。
#（↑）c.get(b,default)なら、bをキーとする要素が見つからなかった場合
# デフォルト値を返してくれる。

print(cnt)

Measured memory_bytes: 14252
#include<stdio.h>

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

if(a < b){
    printf("a < b");
}else if(a > b){
    printf("a > b");
}else if(a == b){
    printf("a == b");
}
printf("\n");
return 0;
}

Measured memory_bytes: 584
import java.util.*;

import static java.lang.System.*;

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

        long[] A = new long[N + 2];
        for (int i = 1; i <= N; i++) {
            A[i] = sc.nextLong();
        }
        A[N + 1] = 0;

        long sum = 0;
        for (int i = 0; i <= N; i++) {
            sum += Math.abs(A[i] - A[i + 1]);
        }

        for (int i = 1; i <= N; i++) {
            long diffCost = Math.abs(A[i - 1] - A[i + 1]) - Math.abs(A[i - 1] - A[i]) - Math.abs(A[i] - A[i + 1]);
            out.println(sum + diffCost);
        }
    }
}

Measured memory_bytes: 65664
H, W = gets.chomp.split.map(&:to_i)
cells = []
H.times do
  cells << gets.chomp.split.map(&:to_i)
end

ans = []
H.times do |h|
  W.times do |w|
    if cells[h][w] % 2 == 1
      if w < W - 1
        ans << "#{h + 1} #{w + 1} #{h + 1} #{w + 2}"
        cells[h][w] -= 1
        cells[h][w + 1] += 1
      elsif h < H - 1
        ans << "#{h + 1} #{w + 1} #{h + 2} #{w + 1}"
        cells[h][w] -= 1
        cells[h + 1][w] += 1
      end
    end
  end
end

puts ans.length
ans.each do |item|
  puts item
end

Measured memory_bytes: 18044
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll ;
long long gcd(long long aaa,long long bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}
int main (){ 
    
    int A,B,ans=0;
    cin >> A >> B;
    ans = A + B;
    ans = max(ans,A - B);
    ans = max(ans,A * B);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
l = [0]*n
c = 0
for i in range(n-1):
  if s[i+1] == "E":
    c += 1
    if s[i] == "E":
      l[i+1] = l[i] - 1
    else:
      l[i+1] = l[i]
  else:
    if s[i] == "W":
      l[i+1] = l[i] + 1
    else:
      l[i+1] = l[i]
ans = min(l) + c
print(ans)

Measured memory_bytes: 15244
void main() {
	auto ip = readAs!(int[]), N = ip[0], K = ip[1];
	if(N%K==0) writeln(0);
	else writeln(1);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i], a[i]--;
    vector<int> idx(n);
    rep(i, n) idx[a[i]] = i;

    multiset<int> st;
    rep(i, 2) {
        st.insert(-1);
        st.insert(n);
    }
    ll ans = 0;
    rrep(i, n) {
        int now = idx[i];
        st.insert(now);
        vector<int> l(2), r(2);
        auto it = st.lower_bound(now);
        rep(j, 2) {
            ++it;
            r[j] = *it;
        }
        it = st.lower_bound(now);
        rep(j, 2) {
            --it;
            l[j] = *it;
        }
        ans += (1LL * (l[0] - l[1]) * (r[0] - now) + 1LL * (now - l[0]) * (r[1] - r[0])) * (i+1);
    }
    cout << ans << endl;
}


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

using namespace std;



vector<int> GaussJordanMod2(vector<vector<int> > a){
	int n=a.size();
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			if(a[j][i]){
				a[i].swap(a[j]);
				break;
			}
		}
		for(int j=0;j<n;j++){
			if(i==j||a[j][i]==0)continue;
			for(int k=i;k<n+1;k++){
				a[j][k] = (a[j][k]-a[i][k]+2)%2;
			}
		}
	}
	vector<int> res(n);
	for(int i=0;i<n;i++)res[i]=a[i][n];
	return res;
}


int main(){
	int dy[]={0,1,0,-1,0};
	int dx[]={0,0,1,0,-1};
	int n;
	cin>>n;
	while(n--){
		vector<vector<int> > a(100,vector<int>(101,0));
		for(int i=0;i<100;i++){
			int y=i/10,x=i%10;
			for(int j=0;j<5;j++){
				int ny=y+dy[j],nx=x+dx[j];
				if(0<=ny&&ny<10&&0<=nx&&nx<10){
					a[ny*10+nx][i]=1;
				}
			}
		}
		for(int i=0;i<100;i++){
			int c;
			cin>>c;
			a[i][100]=c;
		}
		vector<int> ans(GaussJordanMod2(a));
		for(int i=0;i<10;i++){
			cout<<ans[i*10];
			for(int j=1;j<10;j++){
				cout<<' '<<ans[i*10+j];
			}
			cout<<endl;
		}
	}
	return 0;
}

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

typedef long long ll;
const int maxn=4e5+10,maxm=4e5+10,mod=1e9+7;
int n,m,s,t,a[maxm],b[maxm],d[maxm];
ll ans,res,mindis;
bool xxx[maxm];
struct graph1{
	int ecnt,ebeg[maxn],eto[maxm],enxt[maxm],ew[maxm];
	ll dis[maxn];
	bool inq[maxn];
	void ae(int u,int v,int w){
		++ecnt;
		enxt[ecnt]=ebeg[u];
		ebeg[u]=ecnt;
		eto[ecnt]=v;
		ew[ecnt]=w;
	}
	void spfa(int s){
		for(int i=1;i<=n;++i)
			dis[i]=1e18;
		dis[s]=0;
		queue<int> q;
		q.push(s);
		while(!q.empty()){
			int pos=q.front();q.pop();
			for(int i=ebeg[pos],v;i;i=enxt[i])
				if(dis[v=eto[i]]>dis[pos]+ew[i]){
					dis[v]=dis[pos]+ew[i];
					if(!inq[v]){
						inq[v]=true;
						q.push(v);
					}
				}
			inq[pos]=false;
		}
	}
}g1,g2;
struct graph2{
	int ecnt,ebeg[maxn],eto[maxm],enxt[maxm],ew[maxm];
	ll dp[maxn];int deg[maxn];
	void ae(int u,int v,int w){
		++ecnt;
		enxt[ecnt]=ebeg[u];
		ebeg[u]=ecnt;
		eto[ecnt]=v;
		ew[ecnt]=w;
		++deg[v];
	}
	void top(int s){
		queue<int> q;
		dp[s]=1;
		q.push(s);
		while(!q.empty()){
			int pos=q.front();q.pop();
			for(int i=ebeg[pos],v;i;i=enxt[i]){
				v=eto[i];
				dp[v]=(dp[v]+dp[pos])%mod;
				--deg[v];
				if(!deg[v])
					q.push(v);
			}
		}
	}
}g3,g4;

int main(){
	cin>>n>>m>>s>>t;
	for(int i=1;i<=m;++i){
		scanf("%d%d%d",&a[i],&b[i],&d[i]);
		g1.ae(a[i],b[i],d[i]);
		g1.ae(b[i],a[i],d[i]);
		g2.ae(a[i],b[i],d[i]);
		g2.ae(b[i],a[i],d[i]);
	}
	g1.spfa(s);g2.spfa(t);
//	for(int i=1;i<=n;++i)
//		cout<<g1.dis[i]<<' '<<g2.dis[i]<<endl;
	mindis=g1.dis[t];
//	cout<<mindis<<endl;
	for(int i=1;i<=m;++i){
		if(g1.dis[a[i]]+d[i]+g2.dis[b[i]]==mindis)
			g3.ae(a[i],b[i],d[i]),g4.ae(b[i],a[i],d[i]),xxx[i]=true;
		else if(g1.dis[b[i]]+d[i]+g2.dis[a[i]]==mindis){
			swap(a[i],b[i]);
			g3.ae(a[i],b[i],d[i]),g4.ae(b[i],a[i],d[i]),xxx[i]=true;
		}
	}
	g3.top(s);g4.top(t);
	ans=g3.dp[t]*g3.dp[t]%mod;
	for(int i=1;i<=n;++i)
		if(g1.dis[i]*2==mindis)
			res=(res+g3.dp[i]*g4.dp[i]%mod*g3.dp[i]%mod*g4.dp[i])%mod;
	for(int i=1;i<=m;++i)
		if(xxx[i]&&g1.dis[a[i]]*2<mindis&&g2.dis[b[i]]*2<mindis)
			res=(res+g3.dp[a[i]]*g4.dp[b[i]]%mod*g3.dp[a[i]]%mod*g4.dp[b[i]])%mod;
	printf("%lld\n",(ans-res+mod)%mod);
	return 0;
}

Measured memory_bytes: 42928
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int A = sc.nextInt();
			int B = sc.nextInt();
			int C = sc.nextInt();
			int X = sc.nextInt();
			int[] Y = new int[N];
			for (int i = 0; i < N; ++i) {
				Y[i] = sc.nextInt();
			}
			int p = 0;
			for (int i = 0; i <= 10000; ++i) {
				if (X == Y[p]) {
					++p;
					if (p == N) {
						System.out.println(i);
						break;
					}
				}
				X = (A * X + B) % C;
			}
			if (p < N) System.out.println(-1);
		}
	}

}

Measured memory_bytes: 31788
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;

int main(){
  int h,w;
  cin>>h>>w;
  int datah,dataw;
  cin>>datah>>dataw;
  cout<<(h-datah)*(w-dataw)<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <math.h>
#include <vector>
 
#define MOD 1000000007
typedef long long ll;
 
using namespace std;

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

	ll a;
	cin >> a;
	cout << (a + (a*a) + (a*a*a)) << '\n';

	return 0;
}

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

int main() {
  int K,N;
  cin >> K >> N;
  
  vector<int>vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  
  vector<int>bet(N);
  bet.at(0) = vec.at(0) + K - vec.at(N-1);
  for(int i=1;i<N;i++){
    bet.at(i) = vec.at(i) - vec.at(i-1);
  }
  
  int sum = 0;
  for(int i=0;i<N;i++){
    sum += bet.at(i);
  }
  
  int max = 0;
  for(int i=0;i<N;i++){
    if(max < bet.at(i)){
      max = bet.at(i);
    }
    else{
      continue;
    }
  }
  
  cout << sum - max << endl;

}

        

Measured memory_bytes: 1792
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;

int main(){
    int k, t; cin >> k>> t;
    int max_a = 0;
    for(int i=0; i<t; i++){
        int a; cin >> a;
        max_a = max(max_a, a);
    }
    if(k % 2 == 0){
        if(max_a <= k / 2){
            cout << 0 << endl;
        }
        else{
            cout << (max_a - k / 2) * 2 - 1 << endl;
        }
    }
    else{
        if(max_a <= k / 2 + 1){
            cout << 0 << endl;
        }
        else{
            cout << (max_a - k / 2) * 2 << endl;
        }
    }
    return 0;
}

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

typedef long long ll;

int main() {
    ll A, B, V, W, T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;

    ll a, b, c, d;
    a = A - T*V;
    b = A + T*V;
    c = B - T*W;
    d = B + T*W;
    if (a <= c && b >= d) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3636
package main

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

func main() {
	N := nextInt()
	count := map[int64]int64{}

	sum := int64(0)
	for i := 0; i < N; i++ {
		a := nextInt64()
		n, ok := count[a]

		sum += a
		if !ok {
			count[a] = 1
		} else {
			count[a] = n + 1
		}
	}

	Q := nextInt()
	for i := 0; i < Q; i++ {
		b := nextInt64()
		c := nextInt64()

		n, ok := count[b]

		if !ok {
			n = 0
		}
		count[b] = 0

		m, ok := count[c]

		if !ok {
			m = 0
		}
		count[c] = n + m

		sum = sum - b*n + c*(n)
		fmt.Println(sum)
	}
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}

func debug(args ...interface{}) {
	fmt.Fprintln(os.Stderr, args)
}


Measured memory_bytes: 9812
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=51;
const int INF =(1<<30);
struct Node {
	int x,y;
}s[maxn],c[maxn];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d%d",&s[i].x,&s[i].y);
	for(int i=1;i<=m;i++) scanf("%d%d",&c[i].x,&c[i].y);
	for(int i=1;i<=n;i++) {
		int minn=INF,ans=1;
		for(int j=1;j<=m;j++) {
			if(abs(s[i].x-c[j].x)+abs(s[i].y-c[j].y)<minn)
				minn=abs(s[i].x-c[j].x)+abs(s[i].y-c[j].y),ans=j;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

ll n,dp[100010][15],mod=7+1e9,pot[100010];
bool use[100010][15];
string s;

ll fn( ll pos , ll r ){
    if( pos>=n ){
        if(r==5) return 1LL;
        return 0LL;
    }
    if( use[pos][r] ) return dp[pos][r];
    use[pos][r] = true;

    if( s[pos]!='?' ) return dp[pos][r] = fn( pos+1 , (r+ (((s[pos]-'0')*pot[n-pos-1])%13) )%13 );

    ll myAns = 0;
    for(ll i=0; i<10; i++){
        ll var = i*pot[n-pos-1];
        var%=13;
        myAns = ( myAns + fn(pos+1,(r+ var )%13) )%mod;
    }
    return dp[pos][r] = myAns;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> s;
    n = s.size();
    pot[0] = 1;
    for(ll i=1; i<=n; i++) pot[i] = (pot[i-1]*10LL)%13;
    cout << fn( 0 , 0 );

    return 0;
}


Measured memory_bytes: 20688