akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ll arr[1001];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    for(int i=2;i<=n;i++){
        int k=i;
        while((k&1)==0){
            k>>=1;
            arr[2]+=1;
        }
        for(int j=3;j<=sqrt(k);j++){
            while((k%j)==0){
                arr[j]+=1;
                k/=j;
            }
        }
        if(k>1){
            arr[k]+=1;
        }
    }
    ll ans=1;
    for(int i=2;i<=n;i++){
        if(arr[i]>0){
            arr[i]+=1;
            ans*=arr[i];
            ans=ans%1000000007;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

struct Node {
  int a;
  int b;
  Node *child;
  Node(int _a, int _b) : a(_a), b(_b) {
    child = nullptr;
  }
  Node(int _a, int _b, Node *_child) : a(_a), b(_b), child(_child) {
  }
};

ll n, m;
vector<ll> a, b;
vector<ll> c;
vector<vector<ll>> dp;

signed main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  a.resize(m);
  b.resize(m);
  c.resize(m);
  dp.resize(m+1, vector<ll>((1<<n), inf));
  REP(i, m) {
    cin >> a[i] >> b[i];
    int x = 0;
    REP(j, b[i]) {
      int y = 0;
      cin >> y;
      y--;
      x |= 1<<y;
    }
    c[i] = x;
  }
  REP(i, m) {
    dp[i+1][c[i]] = min(dp[i+1][c[i]], a[i]);
    REP(j, (1<<n)) {
      dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
      dp[i+1][c[i]|j] = min({dp[i+1][c[i]|j] , dp[i][j] + a[i], dp[i][c[i]|j]});
    }
  }
  // REP(j, n+1){
  // REP(i, 1<<n) cout << dp[j][i] << " ";cout << endl;
  // }
  ll ans = dp[m][(1<<n) - 1];
  if(ans==inf) ans = -1;
  cout << ans << endl;
  // REP(i, m) cout << c[i] << " ";cout << endl;  
  return 0;
}

Measured memory_bytes: 32384
#include <bits/stdc++.h>
int main(int argc, char const *argv[])
{
    unsigned N;
    scanf("%d", &N);
    int paper;
    if (N % 2 == 0) paper = N / 2;
    else paper = (N / 2) + 1;
    printf("%d\n", paper);
    return 0;
}


Measured memory_bytes: 256
X, N = map(int, input().split(' '))
diff, rst = -1, 0
if N == 0:
    print(X)
else:
    P_ls = list(map(int, input().split(' ')))
    for i in range(101, -1, -1):
        if i not in P_ls:
            if diff == -1:
                diff = abs(X - i)
                rst = i
            else:
                diff = min(diff, abs(X - i))
                if diff == abs(X - i):
                    rst = i
    print(rst)

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

#define ff first
#define endl "\n"
#define ss second
using namespace std;
#define maxn 2000006
#define pb push_back
#define ll long long
#define lll __int128
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fr(i,x,n) for(ll i=x;i>=n;i--)
inline ll min(ll a, ll b, ll c) { return min(min(a, b), c);}
inline ll max(ll a, ll b, ll c) { return max(max(a, b), c);}
inline void fastio(){ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);}

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



int main(){
	fastio();

	int n,m; cin>>n>>m;
	if(m<n) cout<<"No";
	else cout<<"Yes";


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,m;
    cin >> n >> m;
    cout << (1900*m+100*(n-m))*pow(2,m) << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func search(in [9]byte) int {
	for i := 0; i < 9; i++ {
		if in[i] == byte(0) {
			return i
		}
	}
	panic("not found 0")
}

func up(in [9]byte) (bool, [9]byte) {
	pos := search(in)
	if pos > 2 {
		in[pos], in[pos-3] = in[pos-3], in[pos]
	} else {
		return false, in
	}
	return true, in
}

func down(in [9]byte) (bool, [9]byte) {
	pos := search(in)
	if pos < 6 {
		in[pos], in[pos+3] = in[pos+3], in[pos]
	} else {
		return false, in
	}
	return true, in
}

func left(in [9]byte) (bool, [9]byte) {
	pos := search(in)
	if pos != 0 && pos != 3 && pos != 6 {
		in[pos], in[pos-1] = in[pos-1], in[pos]
	} else {
		return false, in
	}
	return true, in

}
func right(in [9]byte) (bool, [9]byte) {
	pos := search(in)
	if pos != 2 && pos != 5 && pos != 8 {
		in[pos], in[pos+1] = in[pos+1], in[pos]
	} else {
		return false, in
	}
	return true, in
}

func next() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

var goal = [9]byte{1, 2, 3, 4, 5, 6, 7, 8, 0}

type item struct {
	d *[9]byte
	c int
}

var queue = []item{}
var closed = map[[9]byte]bool{}

func bfs() int {
	for {
		top := queue[0]
		queue = queue[1:]

		if *top.d == goal {
			return top.c
		}
		closed[*top.d] = true

		ok, ur := up(*top.d)
		ok2, _ := closed[ur]
		if ok && !ok2 {
			queue = append(queue, item{&ur, top.c + 1})
		}
		ok, dr := down(*top.d)
		ok2, _ = closed[dr]
		if ok && !ok2 {
			queue = append(queue, item{&dr, top.c + 1})
		}
		ok, lr := left(*top.d)
		ok2, _ = closed[lr]
		if ok && !ok2 {
			queue = append(queue, item{&lr, top.c + 1})
		}
		ok, rr := right(*top.d)
		ok2, _ = closed[rr]
		if ok && !ok2 {
			queue = append(queue, item{&rr, top.c + 1})
		}
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	var state [9]byte
	for i := 0; i < 9; i++ {
		state[i] = byte(next())
	}
	queue = append(queue, item{&state, 0})
	cost := bfs()
	fmt.Println(cost)
}


Measured memory_bytes: 23500
import itertools


def strjoin(numbers, options):
    return numbers[0] + ''.join([options[i] + numbers[i + 1] for i in range(len(options))])


def main(s):
    if len(s) == 1:
        return int(s)
    numbers = list(s)
    options = [['', '+']] * (len(numbers) - 1)
    products = itertools.product(*options)
    n_sum = 0
    for p in products:
        n_sum += sum(map(int, strjoin(numbers, p).split('+')))
    return n_sum


if __name__ == '__main__':
    S = input()
    print(main(S))


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

#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define for1(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define clr(x) memset((x), 0, sizeof((x)));
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long i64;
typedef unsigned long long ull;

template<class T>
bool remin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool remax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}

ll gcd(ll a, ll b) {
    a = abs(a);
    b = abs(b);
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

typedef ll ptdata;

struct pt {
    ptdata x, y;

    pt() {}

    pt(ptdata x, ptdata y) : x(x), y(y) {}

    inline pt operator-(const pt &r) const {
        return pt(x - r.x, y - r.y);
    }

    inline pt operator+(const pt &r) const {
        return pt(x + r.x, y + r.y);
    }

    inline pt operator*(const ld &r) const {
        return pt(x * r, y * r);
    }

    inline ptdata sqlen() const {
        return abs(x * x + y * y);
    }

    inline bool operator<(const pt &r) const {
        if (x != r.x) return x < r.x;
        return y < r.y;
    }

    inline bool operator==(const pt &r) const {
        return x == r.x && y == r.y;
    }
};

ostream &operator<<(ostream &os, const pt &p) {
    return os << "(" << p.x << "," << p.y << ")";
}

inline ptdata cross(const pt &l, const pt &r) {
    return l.x * r.y - l.y * r.x;
}

inline ptdata dot(const pt &l, const pt &r) {
    return l.x * r.x + l.y * r.y;
}


ll pwmod(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

template<typename T>
inline T sqr(T x) {
    return x * x;
}



void solve() {
    string s;
    cin >> s;
    int cnt = 0;
    int ans = 0;
    forn(i, s.length()) {
        if (s[i] == 'S') {
            ++cnt;
        } else {
            if (cnt) {
                cnt--;
            } else {
                ++ans;
            }
        }
    }
    cout << ans + cnt << "\n";
}

void prepare() {

}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    prepare();

    int t = 1;
    //t = nxt();
    forn(i, t) {
        solve();
    }

    //cerr << "Time " << clock() / (double) CLOCKS_PER_SEC << endl;
    return 0;
}


Measured memory_bytes: 848
#include <iostream>
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <queue>
#include <bits/stdc++.h>
#include <stack>
#include <vector>
#include <list>

using namespace std;

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

  vector<vector<vector<long> > > V (51,vector<vector<long> >(51,vector<long>(2551)));
  //値50が50個あればMAX値2500
  int x[50];
  for(int i = 0; i < N; i++)
    cin >> x[i];
  V[0][0][0] = 1;
  for(int i = 0; i < N; i++){
    for(int j = 0; j <=i; j++){
      for(int k = 0; k < 2500; k++){
        V[i+1][j][k] += V[i][j][k];           //数字を次に送る
        V[i+1][j+1][k+x[i]] += V[i][j][k];    //今の数字と次の数字を足す
        //if(V[i][j][k])
        //cout << " i = " << i << " j = " << j << " k = " << k << endl;
      }
    }
  }

  long long ans = 0;
  for(int i = 1; i <= N; i++)
    ans += V[N][i][i*A];

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 53376
#include<stdio.h>
int main()
{
    int K,X,i,j;
    scanf("%d %d",&K,&X);
    int count=X;
    int result=X;
    int num=X-K+1;
    if(K>1)
    {
    printf("%d ",num);
    }
    for(i=1;i<(K-1);i=i+1)
    {
        num=num+1;
        printf("%d ",num);
    }
    printf("%d ",count);
    for(j=1;j<K;j=j+1)
    {
        result=result+1;
        printf("%d ",result);
    }

}


Measured memory_bytes: 128
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		for (int i = 1; i < n; i++) {
			a[i] += a[i - 1]; 
		}

		Map<Long, Long> map = new HashMap<Long, Long>();
		map.put(0L, 1L);
		for (int i = 0; i < n; i++) {
			long b = a[i] % m;
			if (map.containsKey(b)) {
				map.put(b, map.get(b) + 1L);
			} else {
				map.put(b, 1L);
			}
		}

		long ans = 0;
		for (long b : map.keySet()) {
			long c = map.get(b);
			ans += c * (c - 1) / 2;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 60380
n = int(input())
a_l = list(map(int,input().split()))

flag = True
count = 0
while flag:
    # print(a_l)
    for i in range(n):
        if a_l[i]%2 == 0:
            a_l[i] //= 2
        else:
            flag = False
            break
    else:
        count += 1

print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int n;
    cin >> n;
    vi a(n);
    vi b(n);
    vi c(n-1);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    int m = 0;
    for(int i=0; i<n; i++){
        cin >> b.at(i);
        m += b.at(i);
    }
    for(int i=0; i<n-1; i++){
        cin >> c.at(i);
    }
    for(int i=0; i<n-1; i++){
        if(a.at(i+1) - a.at(i) == 1){
            m += c.at(a.at(i) - 1);
        }
    }
    cout << m << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int main(void){
	int n;
	char s[10010];
	scanf("%d",&n);
	scanf("%s",s);
	int len=strlen(s),t=0;
	for(int i=0;i<len;i++){
		if(s[i]+n>'Z') t=n-26;
		else t=n;
		s[i]=s[i]+t;
	}
	printf("%s",s);
	return 0;
}

Measured memory_bytes: 256
import math
a,b,x=(int(x) for x in input().split())

S = x/a
if S >= a*b/2:
    h = 2 * (a * b - S) / a
    print(math.degrees(math.atan2(h, a)))
else:
    w = 2 * S / b
    print(math.degrees(math.atan2(b, w)))

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

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

	if (A > B) {
		if ((A > C) && (C > B)) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else if (B > A) {
		if ((B > C) && (C > A)) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
	return 0;
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	 cin>>a[i];
	int val=0;
	for(int i=0;i<n;i++)
	 val=val^a[i];
	for(int i=0;i<n;i++)
	 {
	 	int b=a[i]^val;
	 	cout<<b<<" ";
	 }
	return 0;
}

Measured memory_bytes: 4340
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define hell 998244353
#define hell1 1000000006
#define pb push_back
#define x first
#define y second
#define MAXL 100005
#define pll pair<ll,ll>
#define pii pair<int,int>
#define L LLONG_MAX
#define all(v) (v).begin(),(v).end()
#define tcFile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;
//vector<int>prime(15000005,0);
ll mM(ll a,ll b,ll p=hell){ll res = 0;if(a>=p)a %= p;while(b){if (b & 1ll)res = (res + a);if(res>=p) res%= p;a = (2 * a); if(a>=p)a%=p;b >>= 1ll;}return res;}
ll fpow(ll x,ll y,ll p=hell){if(x>=p)x=x%p;ll res=1;while(y){if(y&1ll)res*=x;if(res<0)res+=p;if(res>=p)res%=p;y=y>>1ll;x*=x;if(x<0)x+=p;if(x>=p)x%=p;}return res;}
ll inv(ll n,ll p=hell){return fpow(n,p-2,p);}
ll modmul(ll x,ll y,ll p = hell){if(x<0)x+=p;if(x>=p)x%=p;if(y<0)y+=p;if(y>=p)y%=p;return (x*y)%p;}
ll modadd(ll x,ll y,ll p = hell){if(x<0)x+=p;if(x>=p)x%=p;if(y<0)y+=p;if(y>=p)y%=p;ll temp=x+y;if(temp>=p)temp%=p;return temp;}
/*void sieve(){
    prime[0] = -1;
    prime[1] = 0;
    for(int i=2;i<=15000000;i++)
        if(!prime[i])
            for(int j=i;j<=15000000;j+=i)
            	if(!prime[j])
            		prime[j] = i;
}*/
int main(){
	ios
	int t = 1,tc = 0;
	//cin >> t;
	while(t--){
		ll n, w;
		cin >> n >> w;
		vector<pll>a(n+1);
		ll v = 0;
		for (int i = 1; i <= n; i++) {
			cin >> a[i].x >> a[i].y;
			v += a[i].y;
		}
		vector<vector<ll>>dp(n+2, vector<ll>(v+1, 1e13));
		for (int j = 0; j <= n; j++)
			dp[j][0] = 0;
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= v; j++) {
				dp[i][j] = dp[i-1][j];
				if (a[i].y <= j) {
					ll temp = dp[i-1][j - a[i].y];
					if (temp < 1e13)
						dp[i][j] = min(dp[i][j], temp + a[i].x);
				}
			}
		ll ans = 0;
		for (int i = v; i >= 0; i--)
			if (dp[n][i] <= w) {
				ans = i;
				break;
			}
		cout << ans << "\n";
	}
}


Measured memory_bytes: 83820
#include <bits/stdc++.h>
using namespace std;
int main(){
 
 char b;
  cin >> b;
  
  if(b=='A') cout << 'T' << endl;
  else if(b=='C') cout << 'G' << endl;
  else if(b=='G') cout << 'C' << endl;
  else  cout << 'A' << endl;
 
  
  
}

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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/
const ll mod=1e9+7;
const ll INF=1e18;
/*****************************************************************************/

using namespace std;

int n,q,b,c,num,i,j;
int a[100003];
ll ans;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >>n;
	while (n--) {
		scanf("%d",&num);
		a[num]++;
	}
	for (i=1;i<=100000;i++) {
		ans+=i*a[i];
	}
	cin >>q;
	while (q--) {
		scanf ("%d%d",&b,&c);
		ans+=a[b]*(c-b);
		a[c]+=a[b];
		a[b]=0;
		cout <<ans <<endl;
	}
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 4148
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
int main()
{
    int x,a,b;
    while(~scanf("%d%d%d",&x,&a,&b))
    {
        if(abs(x-a)<abs(x-b))
            printf("A\n");
        else
            printf("B\n");
    }
}



Measured memory_bytes: 256
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

H, W = map(int, input().split())
if H >= 2 and W >= 2:
    ans = math.ceil(H / 2) * math.ceil(W / 2) + (H // 2) * (W // 2)
else:
    ans = 1
print(ans)


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;

int main() {
    cin >> n;
    li v = 0;
    rin{
        v += (i + 1) * (n - i);
    }
    li e = 0;
    rep(i, n - 1) {
        li a, b;
        cin >> a >> b;
        if (a > b)swap(a, b);
        e += a * (n - b + 1);
    }
    cout << v - e << endl;

    return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main()
{
    int q; cin>>q;
    priority_queue<ll> que1;
    priority_queue<ll, vector<ll>, greater<ll>> que2;
    ll s1=0, s2=0, sb=0;
    for(int i=0; i<q; i++){
        int t; cin>>t;
        if(t==1){
            ll a, b; cin>>a>>b;
            sb+=b;
            if(que1.empty()){
                que1.push(a); s1+=a;
                continue;
            }
            ll am=que1.top();
            if(am<a) que2.push(a), s2+=a;
            else que1.push(a), s1+=a;
            if(que1.size()<que2.size()){
                while(que1.size()<que2.size()){
                    ll x=que2.top(); que2.pop();
                    que1.push(x);
                    s1+=x, s2-=x;
                }
            }else if(que1.size()>que2.size()+1){
                while(que1.size()>que2.size()+1){
                    ll x=que1.top(); que1.pop();
                    que2.push(x);
                    s1-=x, s2+=x;
                }
            }
        }else{
            ll a=que1.top();
            cout<<a<<" "<<a*((ll)que1.size()-(ll)que2.size())-s1+s2+sb<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3828
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()) {
			int R = sc.nextInt(), G = sc.nextInt(), B = sc.nextInt(), N = sc.nextInt();
			int ans = 0;
			for(int r = 0; r <= N; r++) {
				for(int g = 0; g <= N; g++) {
					if((N - R * r - G * g) % B == 0 && (N - R * r - G * g) >= 0) {
						ans++;
					}
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}



int main()
{
	IOS;
	int n;
	cin>>n;
	string s[n];
	map<string,long long>m;
	rep(i,0,n)
	{
		cin>>s[i];
		sort(s[i].begin(),s[i].end());
		m[s[i]]++;
	}
	ll ans=0;
	for(auto it=m.begin();it!=m.end();it++)
	{
		ans=ans+((it->ss)*((it->ss)-1))/2;
	}
	cout<<ans;
}



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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<bool> v = vector<bool>(55556, true);

	cout << 11;
	N--;
	for (int ii = 2; ii < 55556; ii++) {
		if (N == 0)break;
		if (v[ii]) {
			for (int jj = ii + ii; jj < 55556; jj += ii) {
				v[jj] = false;
			}
			if (ii <= 11) continue;
			if (ii % 5 == 1) {
				cout << " " << ii;
				N--;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5+10;
int pow10[maxN],a[maxN],sum[maxN],tong[maxN];
int main()
{
    string s;
    cin>>s;
    int N=s.size();
    pow10[0]=1;
    for(int i=1;i<=N;i++)pow10[i]=pow10[i-1]*10%2019;
    for(int i=0;i<N;i++)a[i+1]=(s[i]-'0')*pow10[N-i-1]%2019;
    int ans=0;
    for(int i=1;i<=N;i++)
    {
        sum[i]=(sum[i-1]+a[i])%2019;
        if(sum[i]==0)ans++;
        ans+=tong[sum[i]];
        tong[sum[i]]++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6072
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+100;
vector<int> A;
int main()
{
    int n;
    while(cin>>n)
    {
        int x;
        for(int i=0;i<n;i++)
        {
            cin>>x;
            int s=A.size();
            if(!s||x<=A[s-1])
                A.push_back(x);
            else
            {
                for(int k=0;k<s;k++)
                    if(x>A[k])
                    {
                        A[k]=x;
                        break;
                    }
            }
        }
        cout<<A.size()<<endl;
    }
}

Measured memory_bytes: 892
INF = float("inf") #const
MOD = 10**9+7 #const
MAX = 510000 #const

import fractions
import itertools

def main():
    s = input()
    n = len(s) - 1 #隙間の数
    ans = 0

    for i in range(2**n):
        op = ["-"] * n
        for j in range(n):
            if (i>>j)&1:
                op[j] = "+"
            tmp = ""
            for a,b in zip(s,op+[""]):
                tmp += a + b
            if eval(tmp) == 7:
                print(tmp + "=7")
                return


if __name__ == "__main__":
    main()


Measured memory_bytes: 5052
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main()
	{
		int N = GetInt();
		int[,] abc = new int[3, N];
		for(int i = 0; i < N; i++)
			for(int j = 0; j < 3; j++)
				abc[j, i] = GetInt();

		int[,] dp = new int[3, N + 1];
		for(int i = 0; i < N; i++)
		{
			for(int j = 0; j < 3; j++)
			{
				for(int k = 0; k < 3; k++)
				{
					if(k == j)
						continue;

					dp[k, i + 1] = Math.Max(dp[k, i + 1], dp[j, i] + abc[k, i]);
				}
			}
		}

		Console.WriteLine(Math.Max(dp[0, N], Math.Max(dp[1, N], dp[2, N])));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 17344
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
int x(int n) {
	int f = 0;
	while (n % 2 == 0) {
		n /= 2;
		f++;
	}
	return f;
}
int main() {
	int n, ans = 0, A[10101];
	cin >> n;
	rep(i, n) {
		cin >> A[i];
	}
	rep(i, n) {
		if (A[i] % 2 == 1)
			continue;
		else
			ans += x(A[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
    int n;
    int m;
    int a[101];
    int s[101]={};
    int b;
    cin>>n;
    cin>>m;

   for(int i=1; i<m+1; i++){
	  cin>>a[i];
   }
   for(int i=1; i<m+1; i++){
	   for(int j=1; j<n+1; j++){
		   cin>>b;
		   if(a[i]==b){
			   //??£?§£?????£??????j???
		   	   s[j]+=1;
		   }else{
			   //?????£?§£?????????????????????a[i]??????????????????
			   s[a[i]]+=1;
		   }
	   }
   }

   for(int j=1; j<n+1; j++){
	   cout<<s[j]<<endl;
   }
}

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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

LL M[110][110];

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    LL h, w;
    cin >> h >> w;

    for(LL i = 1; i <= h; i++){
        for(LL j = 1; j <= w; j++){
            char ch;
            cin >> ch;

            if(ch == '*')
                M[i][j] = 1;
        }
    }


    for(LL i = 1; i <= 2 * h; i++){
        for(LL j = 1; j <= w; j++){
            if(M[(i + 1) / 2][j])
                cout << '*';
            else
                cout << '.';
        }
        cout << '\n';
    }
    return 0;
}




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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N, K;
    cin >> N >> K;
    vector<ll> A(N), F(N);
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> F[i];

    sort(A.begin(), A.end());
    sort(F.begin(), F.end());

    ll lb = -1;
    ll ub = 1000000000000+1;
    vector<ll> C(N);

    while(ub-lb>1){
    	ll md = (ub+lb)/2;
    	REP(i, N){
    		C[N-1-i] = md/F[i];
    	}
    	ll cnt = 0;
    	REP(i, N){
    		cnt += max(0ll, A[i]-C[i]);
    	}
    	//cout << C << endl;
    	//cout << A << endl;
    	//dump(cnt)
    	if(cnt<=K){
    		ub = md;
    	}else{
    		lb = md;
    	}
    }
    cout << ub << endl;
    return 0;
}

Measured memory_bytes: 4992
#include<cstdio>
int main()
{
	char c=getchar();
	printf("%c",c);
	while(1)
	{
		c=getchar();c=getchar();
		if(c>'z'||c<'a') break;
		printf("%c",c);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
  
ll c=INT_MAX;
void calcCost(vector<int>res,ll ind,vector< vector<int> >mat,vector<int>cost,ll x)
{
    if(ind==mat.size())
    {
        ll *level=new ll[mat[0].size()];
        for(int i=0;i<mat[0].size();i++)
        {
            level[i]=0;
        }
        for(int i=0;i<res.size();i++)
        {
            for(int j=0;j<mat[res[i]].size();j++)
            {
                level[j]+=mat[res[i]][j];
            }
        }
        for(int i=0;i<mat[0].size();i++)
        {
            if(level[i]<x)
            {
                return;
            }
        }
        ll sum=0;
        for(int i=0;i<res.size();i++)
        {
            sum+=cost[res[i]];
        }
        if(sum<c)
        {
            c=sum;
        }
        return;
    }
    
    res.push_back(ind);
    calcCost(res,ind+1,mat,cost,x);
    res.pop_back();
    calcCost(res,ind+1,mat,cost,x);
}
int main() 
{
    ll n,m,x;
    cin>>n>>m>>x;
    ll len;
    vector<int>cost;
    vector< vector<int> >algo;
    for(int i=0;i<n;i++)
    {
        cin>>len;
        cost.push_back(len);
        vector<int>v;
        ll a;

        for(int j=0;j<m;j++)
        {
            cin>>a;
            v.push_back(a);
        }
        algo.push_back(v);
    }    
    vector<int>empty;
    calcCost(empty,0,algo,cost,x);
    if(c!=INT_MAX)
    {
        cout<<c<<endl;
    }
    else 
    {
        cout<<-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 4016
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

int main() {
    lint n, k;
    cin >> n >> k;
    vector<lint> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    if (k >= n) {
        cout << 0 << endl;
        return 0;
    } else {
        sort(h.begin(), h.end());
        lint ans = 0;
        for (int i = 0; i < n - k; i++) {
            ans += h[i];
        }
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 1792
#include <stdio.h>

#define WHITE 0
#define BLACK 2
#define GRAY 1
#define INF 1000000
int color[100];
int M[100][100];
int d[100];
int p[100];
int n;
void prim(){
  int u,minv,total;
  int i;
  
for(i=0;i<n;i++){
  color[i] = WHITE;
  d[i] = INF;
  p[i] =- 1;
 }
d[0] = 0;
while(1){
  minv = INF;
  u = -1;
  for(i=0;i<n;i++){
    if(minv > d[i] && color[i] != BLACK){
      u = i;
      minv = d[i];
    }
  }
  if(u == -1) break;
  color[u] = BLACK;
  for(i=0;i<n;i++){
    if(color[i] != BLACK && M[u][i] != INF){
      if(d[i] > M[u][i]){
        d[i] = M[u][i];
        p[i] = u;
        color[i] = GRAY;
      }
    }
  }
 }
total = 0;
for(i=0;i<n;i++){
  if(p[i] != -1)
    total += M[i][p[i]];
 }
printf("%d\n",total);
}

int main(int argc, char const *argv[]) {
  int i,j,s;
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    for(j=0;j<n;j++){
      scanf("%d",&s);
      M[i][j]=(s == -1)? INF:s;
    }
  }
  prim();
  return 0;
}


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

using namespace std;
#define ll long long int

int main()
{
   ll t;
   t = 1;	
  // cin t;
   while(t--){
    ll n;
    cin >> n;
    ll x = 1;
    ll total = 0;
    int l = 0;
    vector< ll > p;
    while(total < n)
    {
        x *= 26;
        total += x;
        p.push_back(x);
        l++;
    }
    string ans = "";
    int size = p.size() - 1;
    size --;
    total -= x;
    n = n - total;
    n--;
    for(int i = 0 ; i < l - 1 ; i ++)
    {
        
        int x = n / p[size];
        n = n % p[size --];
        ans += (char)('a' + x);
    }
    ans += (char)('a' + n);
    cout << ans << endl;




   }
}


Measured memory_bytes: 3584
#encoding=utf-8

import sys

printf = sys.stdout.write

taro = 0
hanako = 0

x = input()
for i in range(x):
    word = map(str, raw_input().split())
    if word[0] > word[1]:
        taro += 3
    elif word[0] < word[1]:
        hanako += 3
    else:
        taro += 1
        hanako += 1

print str(taro) + " " + str(hanako)

Measured memory_bytes: 6444
from collections import deque

n=int(input())
a=[]
for i in range(n):
    A=int(input())
    a.append(A)
l=deque([a[0]])
for i in range(1,n):
    if l[0]>=a[i]:
        l.appendleft(a[i])
    elif l[-1]<a[i]:
        l[-1]=a[i]
    else:
        p=0
        q=len(l)-1
        while q-p!=1:
            if l[(p+q)//2]>=a[i]:
                q=(p+q)//2
            else:
                p=(p+q)//2
        l[p]=a[i]
print(len(l))

Measured memory_bytes: 8060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
using namespace std;



int main() {
	int n;
	cin >> n;
	int a[100];
	int count=0;
	for (int i = 0; i < n;i++)cin >> a[i];
	for (int i = 0;i < n;i++) {
		int minj = i;
		for (int j = i;j < n;j++) {
			if (a[j] < a[minj]) minj = j;
		}
		if (a[i] != a[minj]) {
			swap(a[i], a[minj]);
			count++;
		}
	}
	for (int i = 0;i < n;i++) {
		cout << a[i];
		if (i < n - 1)cout << " ";
		else cout << endl;
	}
	cout << count << endl;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int main(){int k,a,b,c,ta,tb,tc,i,ok=0,t1,t2,t3;
int m[10];
m[0]=1;
for(i=1;i<10;i++)m[i]=2*m[i-1];
cin>>a>>b>>c>>k;
for(ta=0;ta<=k;ta++){
    for(tb=0;ta+tb<=k;tb++){
        tc=k-ta-tb;
        t1=a,t2=b,t3=c;
        t1*=m[ta];
        t2*=m[tb];
        t3*=m[tc];
        if(t3>t2&&t2>t1)ok=1;
    }
}
if(ok){cout<<"Yes";}
else{cout<<"No";}
    return 0;}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;

char need(char a,char b,char s){
    if (a==b){
        if (s=='o'){
            return 'S';
        }
        else{
            return 'W';
        }
    }
    else {
        if (s=='o'){
            return 'W';
        }
        else{
            return 'S';
        }
    }
}

string check(char a,char b,ll N,string S){
    vector<char> ans(N);
    ans[0] = a;
    ans[1] = b;
    repf(i, 2, N)
    {
        ans[i] = need(ans[i - 2], ans[i - 1], S[i - 1]);
    }
    if (ans[0]==need(ans[N-2],ans[N-1],S[N-1]) && ans[1]==need(ans[N-1],ans[0],S[0])){
        string ansS = "";
        rep(i, N)
        {
            ansS += ans[i];
        }
        return ansS;
    }
    return "-1";
}

int main(){
    ll N;
    string S;
    cin >> N >> S;
    vector<char> ans(N);
    string ansS;
    ansS = check('S', 'S', N, S);
    if (ansS != "-1")
    {
        cout << ansS << endl;
        return 0;
    }
    ansS = check('S', 'W', N, S);
    if (ansS != "-1")
    {
        cout << ansS << endl;
        return 0;
    }
    ansS = check('W', 'S', N, S);
    if (ansS != "-1")
    {
        cout << ansS << endl;
        return 0;
    }
    ansS = check('W', 'W', N, S);
    if (ansS != "-1")
    {
        cout << ansS<<endl;
        return 0;
    }
    cout << -1 << endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

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

    int ans = 0;
    rep(i, a + 1) rep(j, b + 1) rep(k, c + 1) {
        int sum = i*500 + j*100 + k*50;
        if (sum == x) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <limits.h>
#include <math.h>



int main(int argc, char *argv[])
{
    int r, g, b, n;
    int x, y, z;
    long long ans;

    scanf("%d %d %d %d", &r, &g, &b, &n);

    ans = 0;

    for (x = 0; x * r <= n; x++) {
        for (y = 0; x * r + y * g <= n; y++) {
            if ((n - (x * r + y * g)) % b == 0) {
                ans++;
            }
        }
    }

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

    return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s;

int main() {
	cin >> s;
		
	cout << count(ALL(s), '1') << endl;
	
	return 0;
}


Measured memory_bytes: 256
#import <bits/stdc++.h>
using namespace std;
 
long long n;
vector<char> v;
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	n--;
	v.push_back('a'+(n%26));
	n /= 26;
	while(n > 0) {
		v.push_back('a'+(n+25)%26);
		if(!(n%26)) n--;
		n /= 26;
	}
	
	for(int i = v.size()-1; i > -1; i--) cout << v[i];
	cout << endl;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define MP make_pair
#define mod 1000000007
#define int long long
signed main(){
    map<int,int> mp,mark;
    int N,ans=0;
    cin>>N;
    int arr[N];
    for(int i=0;i<N;i++){
        cin>>arr[i];
        mp[arr[i]]++;
    }
    
    sort(arr,arr+N);
    int mx = *(max_element(arr,arr+N));
    for(int i=0;i<N;i++){
        int  p = arr[i];
        if(!mark[p]){
            for (int j=2*p; j<=mx; j += p) 
                mark[j] = 1; 
        }
    }
    for(int i=0;i<N;i++){
        if(!mark[arr[i]] && mp[arr[i]]==1){
            ans++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 76768
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int N, X, m[110], sum = 0, an = 0;
	scanf("%d%d", &N, &X);
	for (int i = 0; i < N; i++) {
		scanf("%d", &m[i]);
		sum += m[i];
		an++;
	}
	sort(m, m + N);
	X -= sum;
	an += X / m[0];
	printf("%d", an);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pi(n,m) n.insert(n.begin(),m);
#define ee(n) n.erase(n.end()-1)
#define eb(n) n.erase(n.begin())
#define check(n) reverse(all(n));rep(z,0,n.size())cout<<n[z];co("");reverse(all(n));
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

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

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

using namespace std;

typedef long long ll;

#define MOD 998244353
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}




ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}

ll pow(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }

return ans;
}


/*const int N=200000;

ll fac[N+1];
ll inv[N+1];
ll p=998244353;

ll c(ll a, ll b,ll m)
{
  if(a<b)return 0;
  return (fac[a]*inv[b]%m)*(inv[a-b])%m;
}

void fill()
{
inv[0]=1;
fac[0]=1;

for(int i=1;i<=N;i++)
{
  fac[i]=fac[i-1]*i%p;
  inv[i]=powM(fac[i],p-2,p);
}

}
*/
//ld dp[2001][2001];

//ll dp[3001][3001];  // dp[i][j] ways to make sum i using j numbers.


int main()
{  fast

ll h1,m1,h2,m2,k;cin>>h1>>m1>>h2>>m2>>k;
ll a=0;

if(h2<h1)h2+=24;

if(m1>=m2)
  {
    a+=60+m2-m1;
    h2--;
}
else a+=m2-m1;

a+=60*(h2-h1);

cout<<max(a-k,0LL)<<"\n";


 return 0;

}


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

using namespace std;

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

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

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

int N;
ll A[100100];

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> A[i];
    }

    sort(A, A+N);

    vector<ll> v;
    for(int i=0;i+1<N;++i){
        if(A[i] == A[i+1]){
            v.emplace_back(A[i]);
            i += 1;
        }
    }

    ll res = 0ll;
    if(v.size() >= 2){
        res = v[v.size()-1] * v[v.size()-2];
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 1660