akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2505;
struct Edge {
	int v,w;
	int next;
}e[10005];
int head[maxn],ecnt;
void add(int u,int v,int w) {
	e[ecnt].v = v;
	e[ecnt].w = w;
	e[ecnt].next = head[u];
	head[u] = ecnt;
	ecnt ++;
}
int cnt[maxn];
int dis[maxn];
bool inq[maxn];
int n,m,p;
vector <int> g2[maxn];
bool avail[maxn];
void bfs(int s) {
	queue <int> q;
	q.push(s);
	avail[s] = true;
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		for (auto v:g2[u]) {
			if (!avail[v]) {
				q.push(v);
				avail[v] = true;
			}
		}
	}
}
bool spfa(int s) {
	memset(dis,0x3f,sizeof(int)*(n+1));
	memset(cnt,0,sizeof(int)*(n+1));
	queue <int> q;
	dis[s] = 0;
	q.push(s);
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		cnt[u] ++;
		if (cnt[u] > n) return false; 
		inq[u] = false;
		for (int i=head[u];~i;i=e[i].next) {
			int v = e[i].v;
			if (!avail[v]) continue;
			if (dis[u] + e[i].w < dis[v]) {
				dis[v] = dis[u] + e[i].w;
				if (!inq[v]) {
					q.push(v);
					inq[v] = true;
				}
			}
		}
	}
	return true;
}
int main() {
	memset(head,-1,sizeof(head));
	ecnt = 0;
	scanf("%d%d%d",&n,&m,&p);
	for (int i=0;i<m;i++) {
		int u,v,c;
		scanf("%d%d%d",&u,&v,&c);
		add(u,v,-c+p);
		g2[v].push_back(u);
	}
	bfs(n);
	if (spfa(1)) printf("%d\n",max(-dis[n],0));
	else printf("-1\n");
	return 0;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	string s;
	llong w;

	cin >> s >> w;
	for(int i = 0; i < (int)s.size(); i += w)
		cout << s[i];
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

template <typename T> T mod_pow(T n, T r, T m) {
	T ret = 1;
	T tmp = n;
	
	while(r != 0) {
		if(r % 2) {
			ret *= tmp;
		}
		tmp *= tmp;
		tmp %= m;
		ret %= m;
		r /= 2;
	}
	return ret;
}

template <typename T> T mod_inv (T a, T m) {
	return mod_pow(a, m - 2, m);
}

template <typename T> T mod_div (T a, T b, T m) {
	return a * mod_inv(b, m) % m;
}

int main() {
	ull mod = pow(10, 9) + 7;
	uint X, Y;
	cin >> X >> Y;
	
	if((2 * Y - X) % 3 != 0) {
		cout << 0;
		return 0;
	} else if((2 * X - Y) % 3 != 0) {
		cout << 0;
		return 0;
	}
	
	ull K = (2 * Y - X) / 3;
	ull L = (2 * X - Y) / 3;
	
	//cout << K << " " << L << endl;
	
	ull comb = 1;
	ull N = L + K;
	for(uint i=1; i<=min(K, L); i++) {
		comb = mod_div(comb * (N - i + 1) % mod, (ull)i, mod);
	}
	
	cout << comb;
	
	return 0;
}


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

int main(){
  int n; cin>>n;
  map<int,int> mp;
  int max_ans=0, min_ans=0;
  rep(i,n){
    int a; cin>>a;
    if(1<=a&&a<400){
      mp[1]=1;
    }
    if(400<=a&&a<800){
      mp[2]=1;
    }
    if(800<=a&&a<1200){
      mp[3]=1;
    }
    if(1200<=a&&a<1600){
      mp[4]=1;
    }
    if(1600<=a&&a<2000){
      mp[5]=1;
    }
    if(2000<=a&&a<2400){
      mp[6]=1;
    }
    if(2400<=a&&a<2800){
      mp[7]=1;
    }
    if(2800<=a&&a<3200){
      mp[8]=1;
    }
    if(3200<=a){
      max_ans++;
    }
  }
  for(auto x : mp){
      min_ans+=x.second;
  }
  if(min_ans==0){
    min_ans=1;
  }
  
  for(auto x : mp){
    max_ans+=x.second;
  }
  cout<<min_ans<<" "<<max_ans<<endl;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ope operator
#define re register
#define il inline
using namespace std;
int T,n,m,k,q,a[100010];
int gcd(int x,int y){
	return y?gcd(y,x%y):x;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int cur=0,o_cnt,e_cnt,pos;
	bool flag;
	while(true){
		o_cnt=e_cnt=flag=0,pos=-1;
		for(int i=1;i<=n;i++){
			if(a[i]%2==0) o_cnt++;
			else pos=i,e_cnt++;
			if(a[i]==1) flag=true;
		}
		if(flag) return puts((o_cnt&1)^cur?"First":"Second"),0;
		if(o_cnt&1) return puts(cur?"Second":"First"),0;
		if(e_cnt>1&&!(o_cnt&1)) return puts(cur?"First":"Second"),0;
		cur^=1;
		a[pos]--;
		int g=a[1];
		for(int i=2;i<=n;i++) g=gcd(a[i],g);
		for(int i=1;i<=n;i++) a[i]/=g;
	}
}

Measured memory_bytes: 640
Imports System

Module Program
    Sub Main(args As String())
        Dim s As String = Console.ReadLine()
        Dim a As DateTime = DateTime.Parse(s)
        Dim b As DateTime = DateTime.Parse("2019/04/30")
        If a > b Then
            Console.WriteLine("TBD")
        Else
            Console.WriteLine("Heisei")
        End If

    End Sub
End Module



Measured memory_bytes: 13660
import java.util.Scanner;

public class Main {

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

        int ans;
        if (n < 3) {
            ans = 0;
        } else if (n % 2 == 0) {
            ans = n / 2 - 1;
        } else {
            ans = n / 2;
        }
        System.out.println(ans);

        sc.close();
    }

}


Measured memory_bytes: 23892
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
using namespace std;

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	for (int i = sx; i < tx;i++) cout << "R";
	for (int i = sy; i < ty; i++) cout << "U";
	for (int i = sx; i < tx;i++) cout << "L";
	for (int i = sy; i <= ty; i++) cout << "D";
	for (int i = sx; i <= tx;i++) cout << "R";
	for (int i = sy; i <= ty; i++) cout << "U";
	cout << "LU";
	for (int i = sx; i <= tx;i++) cout << "L";
	for (int i = sy; i <= ty; i++) cout << "D";
	cout << "R" << endl;
}
	      

Measured memory_bytes: 256
from bisect import bisect_right
N = int(input())
A = [int(input()) for _ in range(N)]

# 頭にappendは遅いため、逆にする
arr = []
l = 0
for a in A:
  a = -a
  idx = bisect_right(arr, a)
  if idx == l:
    arr.append(a)
    l += 1
  else:
    arr[idx] = a

print(l)

Measured memory_bytes: 11036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
const int mod = 1000000007;
struct mint {
ll x;
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 {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
struct combination {
vector<mint> fact, ifact;
combination(int n):fact(n+1),ifact(n+1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n) return 0;
return fact[n]*ifact[k]*ifact[n-k];
}
mint p(int n, int k) {
return fact[n]*ifact[n-k];
}
};
int main(){
    ll n,m;cin>>n>>m;
    mint ans=0;
    combination c(1000100);
    rep(i,n+1){
        mint now=c(n,i);
        now*=c.p(m,n);
        now*=c.p(m-i,n-i);
        if(i&1)now=-now;
        ans+=now;
    }
    cout<<ans.x<<endl;
    return 0;
}

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

int main() {
  int N, A;
  int B;
  
  cin >> N >> A;
  
  B = N / 500;
  
  if (A < 500) {
    if ((N - (B * 500)) <= A) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else {
    cout << "Yes" << endl;
  }

}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        long x = sc.nextLong();
        long k = sc.nextLong();
        long d = sc.nextLong();

        long absX = Math.abs(x);

        long tmpMove = absX / d;
        long tmpMulti = k * d;

        if (k <= tmpMove) {
            if (0 < x) System.out.println(x - tmpMulti);
            else System.out.println(Math.abs(x + tmpMulti));
        } else {
            if (0 < x) {
                x -= d * tmpMove;
                long res = Math.abs(x);
                k -= tmpMove;
                if (k % 2 == 0) {
                    System.out.println(res);
                } else {
                    System.out.println(Math.min(Math.abs(x - d), Math.abs(x + d)));
                }
            } else {
                x += d * tmpMove;
                long res = Math.abs(x);
                k -= tmpMove;
                if (k % 2 == 0) {
                    System.out.println(res);
                } else {
                    System.out.println(Math.min(Math.abs(x - d), Math.abs(x + d)));
                }
            }
        }


    }


}



Measured memory_bytes: 35904
import numpy as np
N , M = map(int,input().split())
A_B = []
for i in range(N):
	A_B.append(list(map(int,input().split())))
A_B = np.array(A_B).T

arg_A_B = np.argsort(A_B[0])

sort_A_B = A_B[:,arg_A_B]

money = 0
i = 0
while M > 0:
	money += sort_A_B[0][i] * sort_A_B[1][i]
	M -= sort_A_B[1][i]
	i += 1
print(money + M * sort_A_B[0][i - 1])
	

Measured memory_bytes: 37828
#AGC003A

s=raw_input()
l=[s[i] for i in xrange(len(s))]
if l.count('N')==0 and l.count('S')>0:
 print "No"
elif l.count('N')>0 and l.count('S')==0:
 print "No"
elif l.count('E')==0 and l.count('W')>0:
 print "No"
elif l.count('E')>0 and l.count('W')==0:
 print "No"
else:
 print "Yes"


Measured memory_bytes: 2568
from itertools import combinations

n = int(input())
S = [input() for _ in range(n)]
initials = ('M', 'A', 'R', 'C', 'H')
d = {}
for s in S:
  if s[0] in initials:
    d[s[0]] = d.get(s[0], 0) + 1

print(sum(d[x] * d[y] * d[z] for x, y, z in combinations(d.keys(), 3)))

Measured memory_bytes: 16236
from collections import deque

S = deque(input())
Q = int(input())
flg = True
for _ in range(Q):
    query = input()
    if query[0] == "1":
        flg = not flg
    else:
        _,F,C = query.split()
        if (F == "1" and flg) or (F == "2" and not flg):
            S.appendleft(C)
        else:
            S.append(C)
if not flg:
    S.reverse()

print(''.join(S))


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

int main() {
  long long a,b,c;
  cin >> a;
 double s = pow (a,0.5);
  for (int i=1;i<s+1;i++){
    if(a%i==0)
    b=i; c=a/b;
  }
  cout << b+c-2<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int g[1024][1024];
int main(){
  int h, w; cin >> h >> w;
  vector<tuple<int,int,int,int>> ans;
  for(int i = 0; i < h; i++){
  	for(int j = 0; j < w; j++){
    	cin >> g[i][j];
    }
  }
  for(int i = 0; i < h - 1; i++){
  	for(int j = 0; j < w; j++){
    	if(g[i][j]&1){
        	ans.push_back(make_tuple(i + 1, j + 1, i + 2, j + 1));
          	g[i + 1][j]++;
        }
    }
  }
  for(int j = 0; j < w - 1; j++){
  	if(g[h - 1][j]&1){
      	ans.push_back(make_tuple(h, j + 1, h, j + 2));
    	g[h - 1][j + 1]++;
    }
  }
  cout << ans.size() << endl;
  for(auto it : ans){
    int x, y, z, a; tie(x, y, z, a) = it;
    cout << x << " " << y << " " << z << " " << a << endl;
  }
  return 0;
}


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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> mii;
typedef map<ll,int> mli;

///*********************************** C o n s t ***********************************///

int const N=1e6+3;
const double PI = acos(-1);

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

///ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
///bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0n%(i+2)==0)return false;}return true;}

///************************************************ C o d e ************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n,s=0,i,q,x,y;
    cin>>n;
    ll a[n];
    mli m;
    forn(i,n) cin>>a[i],s+=a[i],m[a[i]]++;
    cin>>q;
    while(q--){
        cin>>x>>y;
        s-=m[x]*x;
        s+=m[x]*y;
        cout<<s el;
        m[y]+=m[x];
        m[x]=0;
    }
}

main()
{
///    test
///    while(1)
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 10132
import sys

sys.setrecursionlimit(10 ** 6)

def main():
    n, k = map(int, input().split())
    s = input()
    a = []
    pre = s[0]
    cnt = 0
    for c in s:
        if pre == c:
            cnt += 1
        else:
            a.append(cnt)
            cnt = 1
        pre = c
    a.append(cnt)
    # print(a)
    if len(a) <= 2 * k + 1:
        print(n - 1)
    else:
        a = [sum(a[:2 * k + 1])] + a[2 * k + 1:]
        # print(a)
        print(sum(x - 1 for x in a))

main()


Measured memory_bytes: 5364
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string alp = "abcdefghijklmnopqrstuvwxyz";
int main(){
    string s;
    long long n,a = 1;
    cin >> n;
    while(n>=a){
        n -= a;
        a *= 26;
    }
    a /= 26;
    while(a){
        int c = n/a;
        s.push_back(alp[c]);
        n -= c*a;
        a /= 26;
    }
    cout << s << endl;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

map<char, int> strans;
map<char, int> ttrans;
map<char, int> mtrans;

int main(void)
{
    strans['U'] = 0;
    strans['D'] = 1;
    strans['L'] = 2;
    strans['R'] = 3;

    ttrans['U'] = 1;
    ttrans['D'] = 0;
    ttrans['L'] = 3;
    ttrans['R'] = 2;

    int h,w,n;
    cin >>h >>w >>n;
    int sr, sc;
    cin >>sr >>sc;
    vector<int> rem;
    string s,t;
    cin >>s >>t;

    // sの操作で取り除きたい、　tの操作で阻止したい
    // 阻止できるならYES
    vector<vector<int> > dp(4, vector<int>(n+1, 0));
    dp[0][0] = sr-1;
    dp[1][0] = h-sr;
    dp[2][0] = sc-1;
    dp[3][0] = w-sc;
    mtrans['U'] = h-1;
    mtrans['D'] = h-1;
    mtrans['L'] = w-1;
    mtrans['R'] = w-1;

    bool isNo = false;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 4; j++){
            dp[j][i+1] = dp[j][i];
        }
        //printf("DDD %d %d\n", i, dp[3][i+1]);
        dp[strans[s[i]]][i+1]--;

        //printf("dc %d\n", strans[s[i]]);
        //printf("DDS %d %d\n", i, dp[3][i+1]);
        if(dp[strans[s[i]]][i+1] < 0){
            isNo = true;
            //printf("NNNN %d %c\n", i, s[i]);
        }
        dp[ttrans[t[i]]][i+1]++;
        if(dp[ttrans[t[i]]][i+1] > mtrans[t[i]]){
            dp[ttrans[t[i]]][i+1] = mtrans[t[i]];
        }
        //printf("XXX %d %c %d\n", i, t[i], ttrans[t[i]]);
        //printf("inc %d\n", ttrans[t[i]]);
        //printf("DDT %d %d\n", i, dp[3][i+1]);
    }

    if(isNo){
        printf("NO\n");
    }else{
        printf("YES\n");
    }
    return 0;
}

Measured memory_bytes: 4616
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    int now = 0;
    rep(i,n) {
        if(s[i] == 'I') {
            now++;
            ans = max(ans,now);
        } else {
            now--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 4;
int a[N];
map <int, int> cnt;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		cnt[a[i]]++;
	}

	sort(a + 1, a + 1 + n);
	int ans = 0;
	for(int i = n; i >= 1; i--)
	{
		if(cnt[a[i]] == 0)
			continue;
		cnt[a[i]]--;
		for(int j = 30; j >= 0; j--)
		{
			if((1 << j) < a[i])
				break;
			if(cnt[(1 << j) - a[i]] > 0)
			{
				ans++;
				cnt[(1 << j) - a[i]]--;
			}
		}
	}
	cout << ans;
}

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



int main()
{
    string s,t;
    cin>>s>>t;
    int count=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
        {
            count++;
        }
    }
    cout<<count<<endl;

}


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

void inputVector(int n, vector<int>& va) {
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		va.push_back(a);
	}
}

int bubbleSort(int n, vector<int>& va) {
	int countSort = 0;
	bool existRev = true;
	while (existRev) {
		existRev = false;
		for (int i = n - 1; i > 0; i--) {
			if (va.at(i - 1) > va.at(i)) {
				int x = va.at(i);
				va.at(i) = va.at(i - 1);
				va.at(i - 1) = x;
				countSort++;
				existRev = true;
			}
		}
	}
	return countSort;
}

void outputVector(int n, vector<int>& va, int countSort) {
	for_each(va.cbegin(), va.cend() - 1, [](int x) {
		cout << x << " ";
	});
	cout << va.at(n - 1) << "\n";
	cout << countSort << "\n";
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<int> va;
	inputVector(n, va);

	int countSort = bubbleSort(n, va);

	outputVector(n, va, countSort);
	return 0;
}


Measured memory_bytes: 3212
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		DecimalFormat df = new DecimalFormat("0.000");
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i=0;i<n;i++) {
			Vector2 ra = new Vector2(sc.nextDouble(),sc.nextDouble());
			Vector2 rb = new Vector2(sc.nextDouble(),sc.nextDouble());
			Vector2 rc = new Vector2(sc.nextDouble(),sc.nextDouble());
			Vector2 rm = ra.add(rb).divide(2);
			Vector2 dmo = ra.subtract(rb).rotate90();
			Vector2 rn = ra.add(rc).divide(2);
			Vector2 dno = ra.subtract(rc).rotate90();
			Vector2 ro = Vector2.intersect(rm, dmo, rn, dno);
			double radius = ro.subtract(ra).norm();
			System.out.println(df.format(ro.x) + " " + df.format(ro.y) + " " + df.format(radius));
		}
	}

}
class Vector2 {
	public double x;
	public double y;
	public Vector2(double x,double y) {
		this.x = x;
		this.y = y;
	}
	public double dot(Vector2 v) {
		return this.x*v.x+this.y*v.y;
	}
	public double cross(Vector2 v) {
		return this.x*v.y-this.y*v.x;
	}
	public double norm() {
		return Math.sqrt(this.x*this.x+this.y*this.y);
	}
	public Vector2 add(Vector2 v) {
		return new Vector2(x+v.x,y+v.y);
	}
	public Vector2 subtract(Vector2 v) {
		return new Vector2(x-v.x,y-v.y);
	}
	public Vector2 multiply(double k) {
		return new Vector2(x*k,y*k);
	}
	public Vector2 divide(double k) {
		return new Vector2(x/k,y/k);
	}
	public Vector2 rotate90() {
		return new Vector2(-y,x);
	}
	public static Vector2 intersect(Vector2 r1,Vector2 d1,Vector2 r2,Vector2 d2) {
		return r1.add(d1.multiply(-d2.cross(r2.subtract(r1)) / d1.cross(d2)));
	}
	public String toString() {
		return "(" + this.x + "," + this.y + ")";
	}
}

Measured memory_bytes: 20760
/* 
    Author : Jeff Ahn
    Sun 21 Jun 2020 03:32:55 PM PDT 
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define endl '\n'

signed main() {
  fastio;
  int n;
  cin >> n;
  vector<char>c(27, 'a');
  for (int i = 0; i < 26; i++) {
    c[i+1] += i;
  }
  c[0] = 'z';
  string res = "";
  while (n) {
    int co = n % 26;
    res += c[co];
    if (co == 0) {
      n -= 26;
    }
    n /= 26;
  }
  reverse(res.begin(), res.end());
  cout << res << endl;

}


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

typedef long long ll;
//loop
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//STL
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

void Main() {
    string c;
    cin >> c;
    if (c == "a" || c == "e" || c == "i" || c == "o" || c == "u") {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	Main();
	return 0;
}


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

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define maxn 100005
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define ROF(i,a,b) for(i=a ; i>=b ; i--)
#define DBG pf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
// #define off 1000000
#define sq(x) ((x)*(x))

using namespace __gnu_pbds;
using namespace std ;

template <class T>  inline void smax(T &x,T y){ x = max((x), (y)); }
template <class T>  inline void smin(T &x,T y){ x = min((x), (y)); }

// typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

char s[200005] ;

int dp[(1<<26)+2] , a[200005] ;

int main()
{
    for(int i=0 ; i<(1<<26) ; i++) dp[i] = 2000000 ;

  //  printf("done!\n") ;

    int i , j , k , l , m , n ;

    scanf("%s",s) ;

    dp[0] = 0 ; a[0] = 0 ;
    int mask = 0 ;

    for(i=0 ; s[i]!='\0' ; i++)
    {
    //    printf("%d\n",i) ;
        k = s[i]-'a' ;

        mask = mask^(1<<k) ;
        a[i] = dp[mask] + 1 ;

        for(j=0 ; j<26 ; j++)
        {
            a[i] = min( a[i] , dp[ mask^(1<<j) ] + 1 ) ;
        }
        dp[mask] = min(dp[mask],a[i]) ;
    }

    printf("%d\n",a[i-1]) ;

    return 0 ;
}


Measured memory_bytes: 263552
n,k = map(int,input().split())
A = [int(a) -1 for a in input().split()]

now = 0
if k <= n:
  for i in range(k):
    now = A[now]
  print(now+1)
  
else:
  V = [-1]*n
  V[0] = 0
  for i in range(1,n):
    now = A[now] 
    if V[now] >= 0:
      break
    V[now] = i 
      
  for j in range( (k-i)%(i-V[now])):
    now = A[now]
    
  print(now+1)

Measured memory_bytes: 32192
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
int main(){
ll a,b,c,k;
cin >>a>>b>>c>>k;
if(k%2==0){
if(abs(a-b)>1000000000000000000)
cout<<"Unfair";
else
cout<<a-b;
}
else{
if(abs(b-a)>1000000000000000000)
cout<<"Unfair";
else
cout<<b-a;
}
return 0;
}

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

using namespace std;

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

	vector<int> p(n, 0), q(n, 0);

	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> q[i];
	}

	auto r = p;
	int idx = 0;
	int ans = 0;
	sort(r.begin(), r.end());
	do {
		if (r == p) {
			ans += idx;
		}
		if (r == q) {
			ans -= idx;
		}

		idx++;
	} while (next_permutation(r.begin(), r.end()));

	ans = abs(ans);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <iomanip>
#include <random>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using std::cin;
using std::cerr;
using std::cout;
using std::endl;
using std::make_pair;
using std::pair;
using std::stack;
using std::string;
using std::unordered_map;
using std::unordered_set;
using std::vector;
using std::lower_bound;
using std::upper_bound;

int main(int argc, char* argv[]) {
  long x;
  cin >> x;
  cout << x / 500 * 1000 + (x % 500 / 5) * 5;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//define
#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define str string
//vectordefine
#define vint vector<int>
#define vvint vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vool vector<bool>
#define vtr vector<str>
#define vvtr vector<vector<str>>
//queuedefine
#define qint queue<int>
#define qtr queue<string>
#define qc queue<char>
//pairdefine
#define pint pair<int,int>
#define pic pair<int,char>
#define pci pair<char,int>
#define pis pair<int,str>
#define psi pair<str,int>
#define pcc pair<char,char>
#define pss pair<str,str>
#define mp make_pair
//mapdefine
#define mint map<int,int>
#define mic map<int,char>
#define mci map<char,int>
#define mis map<int,str>
#define msi map<str,int>
#define pb() push_back()
#define all(x) x.begin(),x.end()
#define elif else if
//function
str shizuku(char,char);
//UnionFind
struct UnionFind{
  vint par;
  UnionFind(int N):par(N){
    rep(0,N)par[i]=i;
  }
  int root(int x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
  }
  void unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry)return;
    par[rx]=ry;
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
};
//binary_search

//main
signed main(){
    int N=0,M,X,count=0,count2=0;
    double d,D;
    int alph='A'-'a';
    char op,Ch;
    str S,T;
    cin>>N;
    vint a(N);
    rep(0,N)cin>>a[i];
    sort(all(a));
    reverse(all(a));
    rep(0,N){
      if(a[i]==a[i+1]&&count==0){
        count=a[i];
        a[i]=0;
        a[i+1]=0;
      }
      if(a[i]!=0&&a[i]==a[i+1]&&count2==0){
        count2=a[i];
      }
    }
    cout<<count*count2<<endl;
}


Measured memory_bytes: 1024
s = input()
l_strk_count = 1
r_strk_count = 1
ans = 0
pre_s = "a"
for i in s:
    
    if pre_s == "<" and i == "<":
        l_strk_count += 1
    elif pre_s == ">" and i == ">":
        r_strk_count += 1

    # if s != pre_s and l_strk_count =! 0 and r_strk_count == 0:
    #     ans += l_strk_count * (l_strk_count + 1) // 2
    if i == "<" and pre_s == ">":
        ans += (max(l_strk_count,r_strk_count) ** 2 + max(l_strk_count,r_strk_count))//2 + (min(l_strk_count,r_strk_count) ** 2 - min(l_strk_count,r_strk_count))//2
        l_strk_count = 1
        r_strk_count = 1
    pre_s = i
if pre_s == ">":
    ans += (max(l_strk_count,r_strk_count) ** 2 + max(l_strk_count,r_strk_count))//2 + (min(l_strk_count,r_strk_count) ** 2 - min(l_strk_count,r_strk_count))//2
else:
    ans += (l_strk_count**2 + l_strk_count) // 2
print(ans)

Measured memory_bytes: 4212
#include<cstdio>
#include<algorithm>
using namespace std;const int N=110;bool book1[N];bool book2[N];
char mde[N][N];int n;int m;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%s",mde[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)book1[i]|=(mde[i][j]=='#'),book2[j]|=(mde[i][j]=='#');
	for(int i=1;i<=n;i++)
		{
			if(book1[i]==false)continue;
			for(int j=1;j<=m;j++)if(book2[j])printf("%c",mde[i][j]);printf("\n");
		}return 0;
	
}

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

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    int sum_1 = n*a;
    int sum_2 = b;
    cout << min(sum_1,sum_2) << endl;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include<iomanip>
 
using namespace std;

const int N = 1e5 + 5;
vector<int> graph[N];
vector<int> path;
vector<int> path2;
bool mark[N];
bool check = true;
int n, m;

void dfs1(int v)
{
	if (!check)
	{
		return;
	}
	mark[v] = true;
	path.push_back(v);
	for (int i = 0; i < graph[v].size(); i++)
	{
		int u = graph[v][i];
		if (!mark[u])
		{
			dfs1(u);
		}
	}
	check = false;
}

void dfs2(int v)
{
	mark[v] = true;
	if (!check)
	{
		return;
	}
	path2.push_back(v);
	for (int i = 0; i < graph[v].size(); i++)
	{
		int u = graph[v][i];
		if (!mark[u])
		{
			dfs2(u);
		}
	}
	check = false;
}

int main() 
{
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v;
		graph[u - 1].push_back(v - 1);
		graph[v - 1].push_back(u - 1);
	}
	mark[0] = true;
	int cnt = 0;
	for (int i = 0; i < graph[0].size(); i++)
	{
		int u = graph[0][i];
		if (!mark[u] && cnt == 1)
		{
			check = true;
			dfs2(u);
			cnt++;
		}
		if (!mark[u] && cnt == 0)
		{
			check = true;
			dfs1(u);
			cnt++;
		}
		if (cnt == 2)
		{
			break;
		}
	}
	cout << path.size() + path2.size() + 1 << endl;
	reverse(path2.begin(), path2.end());
	for (int i = 0; i < path2.size(); i++)
	{
		cout << path2[i] + 1 << " ";
	}
	cout << 1 << " ";
	for (int i = 0; i < path.size(); i++)
	{
		cout << path[i] + 1 << " ";
	}


}

 

Measured memory_bytes: 9720
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int a[3]; cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    cout << a[0]+a[1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double PI = atan(1)*4;

int main(){
    double A, B, H, M; cin >> A >> B >> H >> M;
    double angle1 = 2*PI*(H/12+M/720);
    double angle2 = 2*PI*M/60;
    double x1 = A*sin(angle1), y1 = A*cos(angle1);
    double x2 = B*sin(angle2), y2 = B*cos(angle2);
    double dis = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
    cout << setprecision(13) << dis << endl;
    return  0;
}


Measured memory_bytes: 4128
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

int main() {
	int N, K, l[50];
	cin >> N >> K;
	for (int i = 0; i < N; i++)cin >> l[i];
	sort(l, l + N, greater<int>());
	int res = 0;
	for (int i = 0; i < K; i++)res += l[i];
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
// Written by newbiechd
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>

// Delete the debugging information!
#define debug(x) std::cerr << #x << " = " << x << std::endl;

const int BUFFER_SIZE = 1 << 25 | 1;
struct InputOutputStream {
  char ibuf[BUFFER_SIZE], obuf[BUFFER_SIZE], *s, *oh;
  InputOutputStream() : s(ibuf), oh(obuf) {
    ibuf[fread(ibuf, 1, BUFFER_SIZE, stdin)] = '\0';
  }
  ~InputOutputStream() { fwrite(obuf, 1, oh - obuf, stdout); }
  template <typename T>
  inline InputOutputStream &operator>>(T &x) {
    while (!isdigit(*s)) ++s;
    for (x = 0; isdigit(*s); ++s)
      x = x * 10 + (*s ^ '0');
    return *this;
  }
  template <typename T>
  inline InputOutputStream &operator<<(T x) {
    static char buf[23];
    register char *top = buf;
    if (x) {
      for (T t; x; )
        t = x / 10, *top++ = x - t * 10 + 48, x = t;
      while (top != buf)
        *oh++ = *--top;
    }
    else
      *oh++ = '0';
    *oh++ = '\n';
    return *this;
  }
}IO;

template <typename lhs, typename rhs>
inline lhs min(const lhs &x, const rhs &y) { return x < y ? x : y; }
template <typename lhs, typename rhs>
inline lhs max(const lhs &x, const rhs &y) { return x > y ? x : y; }

const int MAXN = 500003;
int n, k, p[MAXN], q[MAXN];

const int MAXT = 2000003;
#define mid ((l + r) >> 1)
#define lSon (k << 1)
#define rSon (k << 1 | 1)
struct SegmentTree {
  int mx[MAXT];
  void modify(int k, int l, int r, int x, int v) {
    mx[k] = max(mx[k], v);
    if (l == r)
      return ;
    x <= mid ? modify(lSon, l, mid, x, v) : modify(rSon, mid + 1, r, x, v);
  }
  int query(int k, int l, int r, int x, int y) {
    if (x <= l && r <= y)
      return mx[k];
    int o = 0;
    if (x <= mid)
      o = max(o, query(lSon, l, mid, x, y));
    if (mid < y)
      o = max(o, query(rSon, mid + 1, r, x, y));
    return o;
  }
}tree;
#undef mid
#undef lSon
#undef rSon

std::vector<int> g[MAXN];
int deg[MAXN];

std::priority_queue<int> que;

int main() {
  IO >> n >> k, --k; // k = k - 1
  for (int i = 1; i <= n; ++i)
    IO >> p[i], q[p[i]] = i;
  for (int i = 1; i <= n; ++i) {
    int temp = tree.query(1, 1, n, q[i] - k, q[i]);
    if (temp)
      g[q[i]].push_back(q[temp]), ++deg[q[temp]];
    temp = tree.query(1, 1, n, q[i], q[i] + k);
    if (temp)
      g[q[i]].push_back(q[temp]), ++deg[q[temp]];
    tree.modify(1, 1, n, q[i], i);
  }
  
  static int ans[MAXN], cnt = 0;
  for (int i = 1; i <= n; ++i)
    if (!deg[i])
      que.push(i);
  while (!que.empty()) {
    int x = que.top();
    que.pop(), ans[++cnt] = x;
    for (int y : g[x])
      if (--deg[y] == 0)
        que.push(y);
  }
  std::reverse(ans + 1, ans + n + 1);
  for (int i = 1; i <= n; ++i)
    p[ans[i]] = i;
  for (int i = 1; i <= n; ++i)
    IO << p[i];
  return 0;
}


Measured memory_bytes: 56704
n, ma, mb = map(int, input().split())
r = [0] * n
c = [0] * n
for i in range(n):
  a, b, c[i] = map(int, input().split())
  r[i] = a * mb - b * ma
dp = [[10 ** 9] * 4001 for i in range(n + 1)]
for i in range(n):
  for j in range(4001):
    dp[i+1][j] = min(dp[i+1][j], dp[i][j])
    if j == 2000:
      dp[i+1][j+r[i]] = min(dp[i+1][j+r[i]], c[i])
    if 0 <= j + r[i] <= 4000:
      dp[i+1][j+r[i]] = min(dp[i+1][j+r[i]], dp[i][j] + c[i])
if dp[n][2000] < 10 ** 9:
  print(dp[n][2000])
else:
  print(-1)


Measured memory_bytes: 4592
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int[] X = nextIntArray(sc, N);

		sc.close();

		long ans = Long.MAX_VALUE;

		for (int p = 1; p <= 100; p++) {
			long s = 0;
			for (int i = 0; i < N; i++) {
				s += Math.pow(p - X[i], 2);
			}
			ans = Math.min(ans, s);
		}
		out.println(ans);
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<stack>
using namespace std;
int N, M;
vector<int> line;
vector<vector<int> > nextgo;
vector<char> used;
int getnum(int place) {
	if (used[place]) {
		return 0;
	}
	stack<int> places;
	places.push(place);
	map<int,int> dic;
	used[place] = true;
	dic[place] = line[place];
	while (!places.empty()) {
		int d = places.top();
		places.pop();
		for (int i = 0; i < nextgo[d].size(); ++i) {
			int np = nextgo[d][i];
			if (used[np] == false) {
				used[np] = true;
				dic[np] = line[np];
				places.push(np);
			}
		}
	}
	int res = 0;
	for (map<int,int>::iterator itr = dic.begin(); itr != dic.end(); ++itr) {
		map<int,int>::iterator fi = dic.find(itr->second);
		if (fi != dic.end()) {
			++res;
		}
	}
	return res;
}
int main() {
	cin >> N >> M;
	line.resize(N + 1);
	nextgo.resize(N + 1);
	used.resize(N + 1, false);
	for (int i = 1; i <= N; ++i) {
		cin >> line[i];
	}
	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		nextgo[a].push_back(b);
		nextgo[b].push_back(a);
	}
	int ans = 0;
	for (int i = 1; i <= N; ++i) {
		ans += getnum(i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10880
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        string input1 = Console.ReadLine(); // "red blue";
        string input2 = Console.ReadLine(); // "5 5";
        string input3 = Console.ReadLine(); // "blue";

        var S = input1.Split(' ')[0];
        var T = input1.Split(' ')[1];
        var A = int.Parse(input2.Split(' ')[0]);
        var B = int.Parse(input2.Split(' ')[1]);
        var U = input3;

        Dictionary<string, int> counts = new Dictionary<string, int>();
        counts.Add(S, A);
        counts.Add(T, B);

        counts[U]--;

        Console.WriteLine($"{counts[S]} {counts[T]}");
    }
}

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



int main()
{
while(1){
	char r[10]; char a[10];
	int h=0,v=0,i,j;

	cin >> r;
	cin >> a;
if(r[0]=='0'&&r[1]=='\0')break;
	for(i=0;i<4;i++){
		if(r[i]==a[i])h=h+1;
	for(j=0;j<4;j++){
		if(r[i]==a[j])v=v+1;
		if(r[i]==a[i]&&r[i]==a[j])v=v-1;
		
		}
	}
cout<<h<<" "<<v<<endl;

}
return 0;

}

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

int main() {
    int n, k;
    cin>>n>>k;
    int arr[n];
    for(int i=0; i<n; i++) cin>>arr[i];
    
    long long int dp[n];
    for(int y=1; y<n; y++){
        dp[y]=1000000001;
    }
    
    dp[0]=0;

    if(n>k+1){
    for(int i=1; i<k; i++){
        dp[i]=abs(arr[i]-arr[0]);
    }

    
    for(int j=k; j<n; j++){
        for(int t=k; t>0; t--){
            dp[j]=min(dp[j], dp[j-t]+abs(arr[j]-arr[j-t]));
        }
    }
    
    cout<<dp[n-1];
    }
    else cout<<abs(arr[n-1]-arr[0]);
    return 0;
}



Measured memory_bytes: 1408
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  a,b,c,x,y=LI()

  l=[]
  l.append(a*x+b*y)
  l.append(c*x*2+b*max(0,y-x))
  l.append(c*y*2+a*max(0,x-y))
  l.append(c*max(x,y)*2)
  return min(l)

print(main())


Measured memory_bytes: 5420
A,V=map(int, input().split())
B,W=map(int, input().split())
T=int(input())
if W>=V:
  print('NO')
else:
  v=V-W
  d=abs(A-B)
  if d>v*T:
    print('NO')
  else:
    print('YES')
    

Measured memory_bytes: 9176
#include <stdio.h>

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

    int sum = a + b;

    if (sum > b) {
        printf("Positive");
    } else if (sum >= a) {
        printf("Zero");
    } else {
        if (sum & 1) {
            printf("Positive");
        } else {
            printf("Negative");
        }
    }
}

Measured memory_bytes: 1712
def main():
    s = int(input())
    dp = [0] * 3 + [1] * 3 + [0 for _ in range(s)]

    for i in range(6, s+1):
        dp[i] = dp[i-1] + dp[i-3]

    print(dp[s] % (10**9+7))


if __name__ == '__main__':
    main()


Measured memory_bytes: 63820
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int a,b;cin>>a>>b;
    for(int i=0;i<=10000;i++){
        if(floor(i*0.08)==a&&floor(i*0.1)==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define MAX 10005
#define MOD 1000000007
#define fo(a, b) for (int i = a; i < b; i++)
#define foi(a, b) for (int i = a; i <= b; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


int main () {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	int n; cin >> n;
	int arr1[n], arr2[n], pref1[n], pref2[n];
	fo(0, n) cin >> arr1[i];
	fo(0, n) cin >> arr2[i];

	pref1[0]=arr1[0]; pref2[0]=arr2[0];
	fo(1, n) {
		pref1[i]=pref1[i-1]+arr1[i];
		pref2[i]=pref2[i-1]+arr2[i];
	}

	int ans = arr1[0]+pref2[n-1];

	for (int i = 1; i < n; i += 1) {
		ans = max(ans, pref1[i]+pref2[n-1]-pref2[i-1]);
	}

	cout << ans;
	return 0;
}

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

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

  if (A * N == B) {
    cout << B << endl;
  }

  else if (A * N > B) {
    cout << B << endl;
  }
    else   {
    cout << A * N << endl;
  }
  
}


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

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// class
// ------------------------------------------------
class Combi
{
  public:
    Combi();
    long long Combination(long long n, long long k);
    long long nPk_modp(long long n, long long k, long long p);
  private:
    vector<vector<long long>> memo;
    long long n_num;
    long long k_num;
    void Resize(long long n, long long k);
};

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {

  ll n,m;
  cin >> n >> m;

  ll mo = 1000000007;

  ll ans;
  if(abs(n - m) > 1)
  {
    ans = 0;
  }
  else
  {
    Combi com;
    ans = ((com.nPk_modp(n,1,mo) % mo ) * com.nPk_modp(m,1,mo)) % mo;
    if(n == m)
      ans = (ans * 2) % mo;
  }

  cout << ans << endl;
  


  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Combi::Combi(){
  n_num = -1;
  k_num = -1;
};
ll Combi::Combination(ll n, ll k)
{
  Resize(n,k);

  ll ret;
  if(memo[n][k] != 0)
  {
    ret = memo[n][k];
  }
  else if(n == k || k == 0)
  {
    memo[n][k] = 1;
    ret = 1;
  }
  else
  {
    ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
    memo[n][k] = ret;
  }
  return ret;
}

void Combi::Resize(ll n, ll k)
{
  if(n_num <= n || k_num <= k)
  {
    n_num = (n + 1) * 2;
    k_num = (k + 1) * 2;
    memo.resize(n_num);
    for(auto itr = memo.begin(); itr != memo.end(); ++itr)
    {
      itr->resize(k_num);
    }
  }
}

long long Combi::nPk_modp(long long n, long long k, long long p)
{
  ll ans = 1;
  for(long long i = k; i <= n; i++)
  {
    ans = (ans * i) % p;
  }

  return ans;
};

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    vector<int> minv(n);
    minv.back() = INF;
    for(int i = n - 2; i >= 0; i--)
    {
        minv[i] = min(minv[i + 1], v[i + 1]);
    }
    bool ok = true;
    for(int i = 0; i < n; i++)
    {
        if(v[i] - 1 > minv[i]) ok = false;
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

	

Measured memory_bytes: 1024
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    MOD = 1000000007
    N, *AB = map(int, read().split())
    G = [[] for _ in range(N)]
    for a, b in zip(AB[::2], AB[1::2]):
        G[a - 1].append(b - 1)
        G[b - 1].append(a - 1)

    stack = deque([0])
    order = []
    prev = [0] * N
    prev[0] = -1
    while stack:
        v = stack.pop()
        order.append(v)
        for nv in G[v]:
            if nv != prev[v]:
                stack.append(nv)
                prev[nv] = v

    pow2 = [0] * (N + 1)
    pow2[0] = 1
    for i in range(N):
        pow2[i + 1] = pow2[i] * 2 % MOD

    nodes = [1] * N
    numer = 0

    for v in reversed(order):
        if prev[v] != -1:
            nodes[prev[v]] += nodes[v]
        numer = (numer + pow2[N - 1] - 1 - (pow2[N - nodes[v]] - 1)) % MOD
        for nv in G[v]:
            if nv != prev[v]:
                numer = (numer - (pow2[nodes[nv]] - 1)) % MOD

    denom = pow2[N]
    ans = (numer * pow(denom, MOD - 2, MOD)) % MOD
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 75384