akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

vector<pll> edge[2][100000];

void dijkstra(int st, int a, ll d[]){
    d[st] = 0;
    priority_queue<pli, vector<pli>, greater<pli> > que;
    d[st] = 0;
    que.push(pli(0, st));
    while(!que.empty()){
        pli p = que.top();
        int v = p.second;
        que.pop();
        if(d[v] < p.first) continue;
        for(auto &e: edge[a][v]){
            int u = e.first;
            if(d[u] > d[v] + e.second){
                d[u] = d[v] + e.second;
                que.push(pli(d[u], u));
            }
        }
    }
}

int main(){
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--, t--;
    rep(i, m){
        int u, v;
        ll a, b;
        cin >> u >> v >> a >> b;
        u--, v--;
        edge[0][u].pb(pil(v, a)), edge[0][v].pb(pil(u, a));
        edge[1][u].pb(pil(v, b)), edge[1][v].pb(pil(u, b));
    }
    ll d1[n], d2[n];
    fill_n(d1, n, INF), fill_n(d2, n, INF);
    dijkstra(s, 0, d1);
    dijkstra(t, 1, d2);
    ll ans[n];
    ans[n-1] = d1[n-1] + d2[n-1];
    rep3(i, n-2, 0){
        ans[i] = min(ans[i+1], d1[i] + d2[i]);
    }
    ll x = 1e15;
    rep(i, n){
        cout << x - ans[i] << endl;
    }
}

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

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,res=0;
    cin >> n;
    vi p(n);
    rep(i,n) cin >> p.at(i);
    sort(p.begin(), p.end(), greater<>());
    res += p.at(0)/2;
    for(int i=1; i<n; i++){
        res+=p.at(i);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
// In the name of Allah
// #Isart
// yedoone bashe, mashti bashe ...

#include<bits/stdc++.h>

#define pii pair<int, int>
#define pb push_back
#define F first
#define S second
#define ll long long
#define ld long double

using namespace std;

const int MAXN = 1e5 + 10;
ll a[MAXN];
ll ps[MAXN];

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	int n, ans = 0;
	cin >> n;
	for(int i = 0; i < n; i ++) cin >> a[i];
	sort(a, a + n);
	for(int i = 0; i < n; i ++){
		ps[i] = a[i];
		if(i > 0) ps[i] += ps[i - 1];
		if(ps[i] * 2 < a[i + 1])
			ans = 0;		
		else ans ++;
	}	
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 1792
n = int(input())
count = 0
p = list(map(int,input().split()))
for i in range(1,n-1):
    if min(p[i-1],p[i],p[i+1]) != p[i] and max(p[i-1],p[i],p[i+1]) != p[i]:
        count += 1
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  vector<int> b(n);
  int cnt = 0;
  for(int i = n-1;i >= 0;i -= 2){
    b[cnt++] = i;
  }
  for(int i = (n%2);i < n;i += 2)b[cnt++] = i;
  rep(i,n)cout<<a[b[i]]<<" \n"[i == n-1];
  return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    ll N, T;
    cin >> N >> T;
    VL t(N);
    rep(i,N) cin >> t[i];
    ll ans = T;
    rep(i,N-1){
        ans += min(t[i+1]-t[i], T);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4748
n, m, x = map(int,input().split())

aList = list(map(int,input().split()))

pList = []
s = aList.pop(0)
for i in range(n+1):
  if i == s:
    pList.append(1)
    if not(len(aList) == 0):
      s = aList.pop(0)
  else:
    pList.append(0)

resultS = 0
resultG = 0
for i in range(0,x+1):
  resultS += pList[i]
for i in range(x,n+1):
  resultG += pList[i]

if resultS<= resultG:
  print(resultS)
else:
  print(resultG)
  

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

#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FOR(i, 1, n+1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;
const int MAX_N = 1e5;

ll N;
ll data[MAX_N*4];

bool asc(const P &a, const P &b){
	if(a.fs == b.fs) return a.sc > b.sc;
	else return a.fs < b.fs;
}

void init(){
  rep(i, MAX_N*4) data[i] = LINF;
}

void update(int i, int x){
  i += N-1;
  data[i] = x;
  while(i > 0){
    i = (i-1)/2;
    data[i] = min(data[i*2+1], data[i*2+2]);
  }
}

ll rmq(ll a, ll b, ll k, ll l, ll r){
  if(r <= a || b <= l) return LINF;
  if(a <= l && r <= b) return data[k];
  else{
    ll vl = rmq(a, b, k*2+1, l, (l+r)/2);
    ll vr = rmq(a, b, k*2+2, (l+r)/2, r);
    return min(vl, vr);
  }
}

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

	N = 1;
	while(N < n) N <<= 1;
	init();

	vector<P> r(n);
	rep(i, n) cin >> r[i].fs >> r[i].sc;

	sort(all(r));

	rep(i, n) update(i, r[i].sc);

	ll ans = 0;
	repn(i, n-1){
		ans = max(ans, max(0LL, rmq(0, i, 0, 0, N)-r[i-1].fs+1)+max(0LL, rmq(i, n, 0, 0, N)-r[n-1].fs+1));
	}

	rep(i, n){
		ans = max(ans, r[i].sc-r[i].fs+1+max(0LL, rmq(0, n, 0, 0, N)-r[n-1].fs+1));
	}

	co(ans);

	return 0;
}


Measured memory_bytes: 4992
using System;
using System.Linq;

namespace _2881
{
	class Program
	{
		static void Main(string[] args)
		{
			while (true)
			{
				string s = Console.ReadLine();
				if (s == "#") break;
				s = s.Substring(7, s.Length - 7);
				int[] x = s.Split().Select(int.Parse).ToArray();
				if (x[0] < 31) Console.WriteLine("HEISEI " + s);
				else
				{
					if (x[0] == 31)
					{
						if (x[1] < 5) Console.WriteLine("HEISEI " + s);
						else
						{
							x[0] -= 30;
							Console.WriteLine("? " + string.Join(" ", x));
						}
					}
					else
					{
						x[0] -= 30;
						Console.WriteLine("? " + string.Join(" ", x));
					}
				}
			}
		}
	}
}


Measured memory_bytes: 16336
#include<bits/stdc++.h>
#define rep(i,n) for(long long int i=0;i<n;i++)
#define lli long long int
#define ll long long 
#define dd double
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define limit 1000000000000000000
const double pi=3.14159265358;
const double pie=2*acos(0.0);
	
using namespace std;
lli power(lli a,lli b)
{
	lli res=1;
	while(b>0)
	{
		if(b%2!=0)
		{
			b--;
			res=(res%mod*a%mod)%mod;
		}
		else
		{
			a=(a%mod*a%mod)%mod;
			b/=2;
		}
	}
	return res%mod;
}
bool sortinrev(const pair<lli,lli> &a,  
               const pair<lli,lli> &b) 
{ 
       return (a.first > b.first); 
}

int main() {
	fast
	lli n;
	cin>>n;
	lli ar[n+1];
	for(int i=1;i<=n;i++)cin>>ar[i];
	lli res=0;
	for(int i=1;i<=n;i++)res=res^ar[i];
	for(int i=1;i<=n;i++)
	{
		cout<<(res^ar[i])<<" ";
	}
	cout<<endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    int input;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }

    sort(a.begin(),a.begin() + N);

    cout << a[N - 1] - a[0];

    return 0;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

void solve() {
    i64 n, h, w;
    cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,k;
ll val[5005];
vector<int> node[5005];
int dis[5005];
ll cost[5005];
int vis[5005];
int par[5005];
ll res=-1e18;
ll pubg=0;
ll op;
void another(int x,int mov)
{
    if(mov<=0)
    {
        return;
    }
    op += val[x];
    //cout<<op<<" op "<<endl;
    res=max(res,op);
    for(int i=0; i<node[x].size(); i++)
    {
        int y=node[x][i];
        another(y,mov-1);
    }
    return;
}
void dfs(int x,ll sum,ll mov,int lev,int p)
{
    if(lev!=0)
    {
        res=max(res,sum);
    }
    if(mov<=0)
    {
        return ;
    }
    dis[x]=lev;
    par[x]=p;
    cost[x]=sum;
    for(int i=0; i<node[x].size(); i++)
    {
        int y=node[x][i];
        if(vis[y]==0)
        {
            vis[y]=1;
            dfs(y,sum+val[y],mov-1,lev+1,x);
        }
        else
        {
            ll d=abs(dis[x]-dis[y]);
            //cout<<d<<" "<<cost[x]-cost[y]<<" cost "<<x<<" "<<y<<endl;
            mov--;
            ll req=mov/(d+1LL);
            op=sum+(req*((cost[x]-cost[y])+val[y]));
            //cout<<op<<" op "<<endl;
            res=max(res,op);
            another(y,1+(mov%(d+1)));
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>k;
    for(int i=1; i<=n; i++)
    {
        int x;
        cin>>x;
        node[i].push_back(x);
    }
    for(int i=1; i<=n; i++)
    {
        ll x;
        cin>>x;
        val[i]=x;
        res=max(res,x);
    }
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            dis[j]=0;
            vis[j]=0;
            par[j]=-1;
        }
        dfs(i,0,k,0,-1);
        //cout<<i<<" "<<res<<endl;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 4612
N,Y=map(int,input().split())
flag=False

for i in range(0,N+1):
  if flag==False:
    for j in range(0,N-i+1):
      P=10000*i+5000*j+1000*(N-i-j)
      if Y==P:
        print(i,j,N-i-j)
        flag=True
        break
      
if flag==False:
  print(-1,-1,-1)

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

const int mod = 1e9 + 7;
const long long INF = 1LL<<60;
using ll = long long;
using P = pair<int,int>;

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; }

int main(){
    int n;
    cin >> n;
    
    int ans = n * n * n;
    cout << ans << endl;
}

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


using namespace std;

int main(){

	int a,b,c,k;

	scanf("%d %d %d",&a,&b,&c);
	scanf("%d",&k);
	int mayor = max(a,max(b,c));

	printf("%d\n",(mayor<<k)+((a+b+c)-mayor));


	return 0;
}


Measured memory_bytes: 256
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def main():
    s = str(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    l = len(s)
    ans = 0
    for i in range(l-1):
        if s[i] != s[i+1]:
            ans += 1
    print(ans)

main()


Measured memory_bytes: 9236
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    for(auto& val: arr)
        cin >> val;
    ll acc = 0, ans = 0;
    unordered_map<ll, int> dp;
    dp[0] = 1;
    for(int val: arr) {
        acc += val;
        ans += dp[acc];
        dp[acc] += 1;
    }
    cout << ans << endl;
    return 0;
}




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

inline int sq(const int x) { return x * x; };

int main() {
    vector<int> s(3, 0);
    while(true) {
        vector<int> in(3);
        for(int i = 0; i < 3; i++) cin >> in[i];
        sort(in.begin(), in.end());
        if(in[0] + in[1] <= in[2]) break;
        int left = sq(in[2]);
        int right = sq(in[0]) + sq(in[1]);
        if(left == right) s[1]++;
        else if(left < right) s[0]++;
        else s[2]++;
    }
    cout << accumulate(s.begin(), s.end(), 0) << ' ' << s[1] << ' ' << s[0] << ' ' << s[2] << endl;
}

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

int main() {
    long long int X,K,D;
    cin >> X >> K >> D;
    long long int toMinCount,minV;
    if(abs(X)%D <= D - abs(X)%D) {
        minV = abs(X)%D;
        toMinCount = abs(X)/D;
    }else{
        minV = D - abs(X)%D;
        toMinCount = abs(X)/D + 1;
    }
    if(K<=toMinCount) {
        cout << abs(X) - K*D << endl; 
    }else{
        long long int rest = K-toMinCount;
        cout <<  (rest%2==1 ? min(abs(minV - D), abs(D - minV)) : minV) << endl;
    }
}

Measured memory_bytes: 3584
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
    int n,count=0;
    cin>>n;
    int arr[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(arr[i]!=i)
        {
            count++;
        }
    }
    if(count<=2)
    {
        cout<<"YES"<<endl;
    }
    else
        cout<<"NO"<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    int l, r;
    cin >> l >> r;
    if (r - l >= 2020) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 1e9;
    for (int i = l; i <= r; i++) {
        for (int j = i + 1; j <= r; j++) {
            ans = min(ans, (int) (1ll * i * j % 2019));
        }
    }
    cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class A, int N, class T>
void fillArray(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

ll a, b, n;
void solve() {
    cin >> a >> b >> n;
    ll x = min(n, (n / b) * b + b - 1);
    ll ans = (a * x) / b - a * (x / b);
    ll x2 = min(n, (n / b - 1) * b + b - 1);
    if (x2 > 0) maxs(ans, (a * x2) / b - a * (x2 / b));
    cout << max(0LL, ans) << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
int ball[10];
bool dfs(int n,int b,int c) {
	if(n==10) {
		return true;
	}
	bool res=false;
	if(b<ball[n]) {
		res|=dfs(n+1,ball[n],c);
	}
	if(c<ball[n]) {
		res|=dfs(n+1,b,ball[n]);
	}
	return res;
}
int main() {
	int N;
	scanf("%d",&N);
	for(int i=0;i<N;i++) {
		for(int j=0;j<10;j++) {
			scanf("%d",&ball[j]);
		}
		printf("%s\n",dfs(0,0,0)?"YES":"NO");
	}
}

Measured memory_bytes: 1008
n = int(input())
st = []
for i in range(n):
  s, t = input().split()
  st.append((s,t))
x = input()

ans = 0
f = False
for a in st:
  if f:
    ans += int(a[1])
    continue
  if a[0] == x:
    f = True
print(ans)

Measured memory_bytes: 3064
N,K = map(int,input().split())
V = list(map(int,input().split()))

cum = [0]
rcum = [0]

for i in range(N):
    cum.append(cum[-1]+V[i])
    rcum.append(rcum[-1]+V[-1-i])

ans = 0

for i in range(N+1):
    for j in range(N+1):

        if i+j > min(N,K):
            continue

        value = cum[i]+rcum[j]
        neg = []

        for ii in range(i):
            if V[ii] < 0:
                neg.append(V[ii])

        for jj in range(j):
            if V[-1-jj] < 0:
                neg.append(V[-1-jj])

        neg.sort()

        value -= sum(neg[:min(K-i-j,len(neg))])

        ans = max(ans,value)

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans=0;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++)
		cin >> a[i];
	sort(a,a+n);
	if(n%2 == 0)
		ans=a[n/2]-a[n/2-1];
	else
		ans=0;
	cout << ans;
	return 0; 
}

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

int main(){
 	long a,b,c;
  	string s;
	cin >> a >> b >> c >> s;
  	char k = s[s.size()-1];
  	
  	cout << ((k-'0')%2==0 ? a-b:-a+b) << endl;
}


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

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
typedef pair<int,int> p;
typedef pair<double,double> dop;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;


signed main()
{
int n,m;
std::cin >> n >> m;
if(abs(n - m) >= 2){
    std::cout << 0 << std::endl;
} else if(abs(n - m) == 0){
    int sum = 2;
    for(int i = 1; i <= n; i++){
        sum = (sum * i) % INT_DMAX;
    }
    for(int i = 1; i <= m; i++){
        sum = (sum * i) % INT_DMAX;
    }  
    std::cout << sum << std::endl;
} else {
    int sum = 1;
    for(int i = 1; i <= n; i++){
        sum = (sum * i) % INT_DMAX;
    }
    for(int i = 1; i <= m; i++){
        sum = (sum * i) % INT_DMAX;
    }  
    std::cout << sum << std::endl; 
}
return 0;
}

Measured memory_bytes: 256
@OptIn(ExperimentalStdlibApi::class)
fun main() {
    var (n, k) = readLine()!!.split(" ").map(String::toLong)
    val array = readLine()!!.split(" ").map { it.toInt() - 1 }.toIntArray()

    var set = mutableSetOf(0)
    var a = set.last()
    do {
        a = array[a]
    } while (set.add(a))

    val list = mutableListOf<Int>()

    var w = 0
    while (w != a) {
        list.add(w)
        w = array[w]
    }

    val cList = mutableListOf(a)
    w = array[w]
    while (w != a) {
        cList.add(w)
        w = array[w]
    }


    if (k < list.size) {
        println(list[k.toInt()] + 1)
    } else {
        println(cList[((k - list.size) % cList.size).toInt()] + 1)
    }
}





Measured memory_bytes: 84088
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        For i As Integer = N To 1 Step -1
            If Judge(i) Then
                WriteLine(i)
                Exit For
            End If
        Next
    End Sub

    Function Judge(N As Integer) As Boolean
        Do While N Mod 2 = 0 AndAlso N <> 0
            N \= 2
        Loop
        If N = 1 Then Return True
        Return False
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 21968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
//#define endl "/n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

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


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define mx 100005
set<int> adj[mx];
int arr[mx];
int main()
{	
	ios_base::sync_with_stdio(0);
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
    int n,m,a,b;
    cin>>n>>m;
    for(int i=1; i<=n; i++) cin>>arr[i];
    for(int i=1; i<=m; i++){
    	cin>>a>>b;
    	adj[a].insert(b);
    	adj[b].insert(a);
    }
    int ans = 0;
    for(int i=1; i<=n ;i++){
    	int cnt = 0;
		for(auto v:adj[i])
			cnt+=(arr[i]>arr[v]);
		ans+=(cnt==adj[i].size());
	}
    cout<<ans<<endl;
}

Measured memory_bytes: 18084
import java.util.*;
public class Main  {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      String t = sc.next();

      /*for (int i = 0; i < t.length(); i++) {
         if (t.charAt(i) = "?" && t.charAt(i+1) = "D") {
            String t1 = t.substring(i, t.length()).replaceFirst("?", "P");
            String t2 = t.substring(0, i);
            t = "";
            t = t1 + t2;
         }
      }*/
      
      System.out.println(t.replace("?", "D"));
      
      }
      
}


Measured memory_bytes: 41136
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		if(a>=10||b>=10) {
			System.out.println(-1);
		}
		else {
			System.out.println(a*b);
		}
	}
}

Measured memory_bytes: 35800
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<ll> xs(n), ys(n), zs(n);
    for(int i = 0; i < n; i++){
        cin >> xs[i] >> ys[i] >> zs[i];
    }
    ll ans = 0;
    for(int i = 0; i < 8; i++){
        vector<ll> cs;
        for(int j = 0; j < n; j++){
            ll cand =
                (i & 1 ? -xs[j] : xs[j]) +
                (i & 2 ? -ys[j] : ys[j]) +
                (i & 4 ? -zs[j] : zs[j]);
                // (i & 1 ? (xs[j] < 0 ? -xs[j] : 0) : (xs[j] > 0 ? xs[j] : 0)) +
                // (i & 2 ? (ys[j] < 0 ? -ys[j] : 0) : (ys[j] > 0 ? ys[j] : 0)) +
                // (i & 4 ? (zs[j] < 0 ? -zs[j] : 0) : (zs[j] > 0 ? zs[j] : 0));
            cs.push_back(cand);
        }
        sort(cs.rbegin(), cs.rend());
        prints(cs);
        ans = max(ans, accumulate(cs.begin(), cs.begin() + m, 0ll));
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int a, b, k;
    scanf("%d %d %d", &a, &b, &k);
    int max_value = min(a, b);
    for (int i = max_value; i >= 1; --i) {
        if ((a % i == 0) && (b % i == 0)) {
            --k;
        }
        if (k == 0) {
            printf("%d\n", i);
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[510][510],n,dx[4]={1,0,-1,0},dy[4]={0,1,0,-1},res;
bool g[510][510];
void qwq(int x,int y){
	for(int i=0;i<4;i++){
		int nx=x+dx[i],ny=y+dy[i];
		if(nx>n||nx<1||ny>n||ny<1)continue;
		if(f[nx][ny]<=f[x][y]+g[x][y])continue;
		f[nx][ny]=f[x][y]+g[x][y],
		qwq(nx,ny);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)f[i][j]=min(min(i-1,n-i),min(j-1,n-j)),g[i][j]=true;
	for(int i=1,x,y;i<=n*n;i++){
		scanf("%d",&x);
		y=(x-1)%n+1,x=(x-1)/n+1;
//		printf("%d %d\n",x,y);
		res+=f[x][y];
		g[x][y]=false;
		qwq(x,y);
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 20300
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int userCount = sc.nextInt();

        int free = 0;
        Set<Integer> colors = new HashSet<>();
        for (int i = 0; i < userCount; i++) {
            int rate = sc.nextInt() / 400;
            if (7 < rate) {
                free++;
            } else {
                colors.add(rate);
            }
        }
        int hold  = colors.size();
        System.out.println((hold == 0 ? 1 : hold) + " " + (hold + free));
    }
}

Measured memory_bytes: 21844
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        APlacingMarbles solver = new APlacingMarbles();
        solver.solve(1, in, out);
        out.close();
    }

    static class APlacingMarbles {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            int ans = 0;
            for (int i = 0; i < 3; i++) {
                if (s.charAt(i) == '1') {
                    ans++;
                }
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 21716
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    N, M = input(int, int)
    yesno(N == M)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 3316
#include <iostream> 
#include <vector>
#include <algorithm>
using namespace std; 
int main() {
	int m;
	int nmin;
	int nmax;
	while (cin >> m >> nmin >> nmax, m != 0) {
		vector <int> vec(m);
		for (int i = 0; i < m; i++) {
			cin >> vec.at(i);
		}
		int cnt = 0;
		for (int j = nmin-1; j <= nmax-1; j++) {
			cnt = max(cnt, vec.at(j) - vec.at(j+1));
		}
		for (int k = nmax-1; k >= nmin-1; k--) {
			if (cnt == vec.at(k) - vec.at(k+1)) {
				cout << k + 1 << endl;
				break;
			}
			else {
				continue;
			}
		}
	}
}


Measured memory_bytes: 3088
package main

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

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	h := make([]int, n)
	for i := range h {
		sc.Scan()
		h[i], _ = strconv.Atoi(sc.Text())
	}

	sort.Ints(h)
	min := 1000000000
	for i := 0; i+k-1 < n; i++ {
		if v := h[i+k-1] - h[i]; v < min {
			min = v
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 3072
S = input().rstrip()

def check_YYMM(str:S):
    MM = int(S[2:])
    if 0 < MM and MM < 13:
        return True
    else:
        return False
    
def check_MMYY(str:S):
    MM = int(S[:2])
    if 0 < MM and MM < 13:
        return True
    else:
        return False

is_YYMM = check_YYMM(S)
is_MMYY = check_MMYY(S)

if is_YYMM and is_MMYY:
    print('AMBIGUOUS')
elif is_YYMM:
    print('YYMM')
elif is_MMYY:
    print('MMYY')
else:
    print('NA')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#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 showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n, x;
    cin >> n >> x;
    vector<ll> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}

    ll ans = 0;
    if (a[0] > x) {ans += a[0]-x; a[0] = x;}
    ll sum = a[0];
    for (int i = 1; i < n; i++)
    {
        sum += a[i];
        if (sum > x) {
            ans += sum-x;
            a[i] -= sum-x;
            sum -= sum-x;
        }
        sum -= a[i-1];
    }
    
    cout << ans << endl;

}


Measured memory_bytes: 1400
#include<stdio.h>
int gcd(int,int);
  int main()
{
  int a,b;
  scanf("%d %d",&a,&b);
  printf("%d\n",gcd(a,b));

  return 0;
}
int gcd(a,b)
{
  int r;
  while(b>0)
    {
      r=a%b;
      a=b;
      b=r;
    }
      return a;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int L,R;
  cin>>L>>R;
  int res = INF;
  for (int i = L; i <= R; i++)
  {
    for (int j = i+1; j <= R; j++)
    {
      res = min(res,(i*j)%2019);
      // DEBUG(i,j,res);
      if(res == 0)
      {
        cout<<0<<endl;
        return;
      }
    }
    
  }
  cout<<res<<endl;
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 256
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=1e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    ll A;
  	cin>>A;
  	string ans;
    while(A){
        ans+=(A%26?char('a'+A%26-1):'z');
        A=(A-1)/26;
    }
    reverse(all(ans));
  	cout<<ans;
    return 0;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  string s;cin>>s;
  string s1=s.substr(0,2);
  string s2=s.substr(2,2);
  if("01"<=s1&&s1<="12"&&"01"<=s2&&s2<="12"){
    puts("AMBIGUOUS");
  }else if ("01"<=s1&&s1<="12"){
    puts("MMYY");
  }else if ("01"<=s2&&s2<="12"){
    puts("YYMM");
  }else{
    puts("NA");
  }

  
  return 0;
}


Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		
		int a, b, c, d, n = Integer.valueOf(reader.readLine());
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		
		for(int i = 0; i < n; i++) map.put(i + 1, 0);
			
		for(int i = 0; i < n * (n - 1) / 2; i++){
			string = reader.readLine();
			a = Integer.valueOf(string.split(" ")[0]);
			b = Integer.valueOf(string.split(" ")[1]);
			c = Integer.valueOf(string.split(" ")[2]);
			d = Integer.valueOf(string.split(" ")[3]);
			
			if(c == d){
				map.put(a, map.get(a) + 1);
				map.put(b, map.get(b) + 1);
			}else if(c > d){
				map.put(a, map.get(a) + 3);
			}else{
				map.put(b, map.get(b) + 3);
			}
		}
		ArrayList<Map.Entry<Integer, Integer>> entries = new ArrayList<Map.Entry<Integer, Integer>>(map.entrySet());
		Collections.sort(entries, new Comparator<Map.Entry<Integer, Integer>>() {
	 
			@Override
			public int compare(
					Entry<Integer, Integer> entry1, Entry<Integer, Integer> entry2) {
				return ((Integer)entry2.getValue()).compareTo((Integer)entry1.getValue());
				}
			});
	    
		int res[] = new int[n];
		int hoge = 0, hogehoge = 0;
	    for(int i = 0; i < n; i++){
	    	if(hoge != entries.get(i).getValue()){
	    		hoge = entries.get(i).getValue();
	    		hogehoge = i + 1;
	    		res[entries.get(i).getKey() - 1] = hogehoge;
	    	}else{
	    		res[entries.get(i).getKey() - 1] = hogehoge;
	    	}
	    }
	    
	    for(int var : res) System.out.println(var);
	}
}

Measured memory_bytes: 38596
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
using namespace std;
typedef long long ll;

int main(){
  int n; cin >> n;
  vector<double> v(n);

  for (int i = 0; i < n; i++){
    cin >> v[i];
  }
  
  sort(v.begin(), v.end());
  
  double res = v[0];
  
  for (int i = 1; i < n; i++){
    res = (res + v[i]) / 2;
  }
  
  cout << res;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

	int i;
	long power = 1;


	for( i = 1; i <= N; i++ ){
		power = ( power * i ) % ( 1000000007 );
	}

	std::cout << power << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <cstdlib> //絶対値 abs()
using namespace std;


int main(){
	int n;
	cin >> n;
	vector<int> r(n);

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

	int ans = r[1]-r[0];
	int rmin = r[0];

	for(int i=1; i<n; i++){
		if(rmin <= r[i]){
			if(r[i]-rmin > ans){
				ans = r[i]-rmin;
			}
		}
		
		else{
			rmin = r[i];
		}
	}

	cout << ans << endl;

}


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

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

    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = max(a*c, max(b*d, max(b*c, a*d)));
    cout << ans;

    return 0;
}   

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

ll solve(){
    int n;
    cin>>n;
    int ptr[n] ;
    vector<int> dp(n,INT_MAX);
    for(int i=0;i<n;i++) cin>>ptr[i];
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j : {i+1, i+2}){
            if(j<n) dp[j]= min(dp[j] , dp[i] + abs(ptr[i] - ptr[j]));
        }
    }
    return dp[n-1];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        cout<<solve()<<endl;
    }
}

/*
4
10 30 40 20
*/

Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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; }


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

    ll N, M; cin >> N >> M;
    ll ans = 1;
    if (N > 2 && M > 2) ans = (N - 2) * (M - 2);
    else if (N == 2 || M == 2) ans = 0;
    else {
        if (N > 2) ans = (N - 2);
        if (M > 2) ans = (M - 2);
    }
    COUT(ans);
}

Measured memory_bytes: 256
s = int(input())
l = [s]
a = 0
cnt = 1

for i in range(1000000):
    if s%2 == 1:
        a = s*3 + 1
        for j in range(cnt):
            if a == l[j]:
                print(i + 2)
                exit()
        l.append(a)
        s = a
        a = 0
        cnt += 1
    else:
        a = int(s/2)
        for j in range(cnt):
            if a == l[j]:
                print(i + 2)
                exit()
        l.append(a)
        s = a
        a = 0
        cnt += 1

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll nax=3005;
ll dp[nax][nax];
int main(){
    ll n;cin>>n;
    ll a[3005];
    for(ll i=0;i<n;i++)cin>>a[i];

  //  ll dp[3005][3005];

    for(ll L=n-1;L>=0;L--){
       for(ll R=L;R<n;R++){
            if(L==R){
                dp[L][R]=a[L];
            }
            else{
                dp[L][R]=max(a[L]-dp[L+1][R],a[R]-dp[L][R-1]);
            }
        }
    }
    //cout<<"sahil";
    cout<<dp[0][n-1];
}

Measured memory_bytes: 70016
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun May  3 21:16:32 JST 2020
 **/

std::string a = "ABC", b = "ARC";
signed main() {
    std::string s;
    std::cin >> s;
    std::cout << (s == a ? b : a) << std::endl;
}


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

const long long Inf = 1LL << 60;

#define rep(i,n) for(int i = 0;i < (int)(n);i++)

template <class T> bool chmin(T&a,T b);

int main()
{
    int N;cin >> N;
    long long dp[100000],list[100000];
    rep(i,N)
    {
        cin >> list[i];
        dp[i] = Inf;
        if(dp[0] != 0)
            dp[0] = 0;
        chmin(dp[i],dp[i - 1] + abs(list[i] - list[i - 1]));
        if(i > 1)
        {
            chmin(dp[i],dp[i - 2] + abs(list[i] - list[i - 2]));
        }
    }
    cout << dp[N - 1] << endl;
}

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

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    long long int n, i, max=0, cnt=0;
    scanf("%lld", &n);
    long long int a[n];
    for(i=0; i<n; i++)
    {
        scanf("%lld", &a[i]);
    }
    max=a[0];
    for(i=1; i<n; i++)
    {
        if(max>a[i])
        {
            cnt=cnt+max-a[i];
            a[i]=a[i]+max-a[i];
        }
        else if(max<a[i])
        {
            cnt=cnt+0;
            max=a[i];
        }
    }
    printf("%lld\n", cnt);
    return 0;
}


Measured memory_bytes: 3268