akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#define SF scanf
#define PF printf
#define MAXN 100010
#define INF 0x3FFFFFFF
using namespace std;
typedef long long ll;
int a[MAXN],p[MAXN];
ll n;
struct node *NIL;
struct node{
    node *ch[2],*fa;
    int val,sum,num;
    bool Dir(){
        return this==fa->ch[1];
    }
    void setchild(node *x,int d){
        ch[d]=x;
        if(x!=NIL)
            x->fa=this;
    }
    void pushup(){
        //pushdown();
        //if(x->ch[0]!=NIL)x->ch[0]->pushdown();
        //if(x->ch[1]!=NIL)x->ch[1]->pushdown();
        sum=ch[0]->sum+ch[1]->sum+num;
    }
}tree[MAXN],*root,*ncnt;
node * Newnode(node *x,int val){
    x->ch[0]=x->ch[1]=x->fa=NIL;
    x->val=val;
    x->sum=x->num=1;
    return x;
}
void Rotate(node *x){
    node *y=x->fa;
    //y->pushdown(),x->pushdown();
    int d=x->Dir();
    if(y==root)
        root=x,x->fa=NIL;
    else
        y->fa->setchild(x,y->Dir());
    y->setchild(x->ch[!d],d);
    x->setchild(y,!d);
    y->pushup();
}
void Splay(node *x,node *rt){
    //x->pushdown();
    while(x->fa!=rt){
        node *y=x->fa;
        if(y->fa==rt){
            Rotate(x);
            break;
        }
        if(x->Dir()==y->Dir())
            Rotate(y);
        else
            Rotate(x);
        Rotate(x);
    }
    x->pushup();
}
void Ins(node *&root,int val){
    if(root==NIL){
        root=Newnode(++ncnt,val);
        return ;
    }
    node *y=root;
    int d;
    while(1){
        y->sum++;
        if(y->val==val){
            y->num++;
            Splay(y,NIL);
            return ;
        }
        d=(y->val)<val;
        if(y->ch[d]==NIL)
            break;
        y=y->ch[d];
    }
    y->setchild(Newnode(++ncnt,val),d);
    Splay(y->ch[d],NIL);
}
node *find(node *x,int val){
    if(x->val==val)
        return x;
    return find(x->ch[(x->val)<val],val);
}
ll check(int x){
	ncnt=root=NIL;
	for(int i=1;i<=n;i++)
		p[i]=0;
	for(int i=1;i<=n;i++)
		p[i]=p[i-1]+(a[i]>x)*2;
	ll res=0;
	Ins(root,0);
	for(int i=1;i<=n;i++){
		Ins(root,i-p[i]);
		node *x=find(root,i-p[i]);
		Splay(x,NIL);
		res+=x->ch[0]->sum;
	}
	return res;
}
int main(){
    NIL=&tree[0];
    NIL->ch[0]=NIL->ch[1]=NIL->fa=NIL;
    root=ncnt=NIL;
	SF("%lld",&n);
	for(int i=1;i<=n;i++)
		SF("%d",&a[i]);
	int l=1,r=INF,ans=INF;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid)<(n*(n+1ll)/4ll+1ll))
			l=mid+1;
		else{
			ans=mid;
			r=mid-1;
		}
	}
	PF("%d",ans);
}

Measured memory_bytes: 4864
#include "bits/stdc++.h"
using namespace std;
void solve(){
    string s, t;
    cin >> s, cin >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if(s < t)
    cout << "Yes" << endl;
    else 
    cout << "No" << endl;
}
int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <assert.h>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;


int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll a, b;
    cin >> a >> b;
    ll c = a + b;
    if (c & 1) {
        cout << "IMPOSSIBLE";
    } else {
        cout << c / 2;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//g++ yarudake.cpp -std=c++17 -I .
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, mod, x;
    cin >> n >> x >> mod;
    ll sum = x;
    ll y = x;
    map<ll, ll> m;
    vector<ll> sumv;
    m[x] = 1;
    sumv.push_back(0);
    sumv.push_back(x);
    if (n == 1)
        return cout << x << "\n", 0;
    for (int i = 1; i < n; i++)
    {
        ll z = (x * x) % mod;
        sum += z;
        x = z;
        //cout<<z<<"\n";
        sumv.push_back(sum);
        if (z == 0)
        {
            return cout << sum << "\n", 0;
        }
        //cout << z << "\n";
        //cout<<sum<<"\n";
        if (m[z] != 0)
        {
            ll temp = m[z];
            ll sumt = sumv[m[z]];
            ll va = sum - sumt;
            ll d = i - m[z]+1;
            ll ans = sum + (va * ((n - i-1) / d));
            //ans%=mod;
            ll temp2 = (n - i-1) % d;
            ans += sumv[m[z] + temp2]-sumv[m[z]];
            //cout << sumv[m[z] + temp2] - sumv[m[z]] << "\n";
            cout << ans << "\n";
            //cout << va << " " << d << " " << i << " " << (n - i-1) % d << " " << (n-i-1)/d<< "\n";
            return 0;
        }
        m[z] = i + 1;
    }
    cout << sum << "\n";
}

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

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

int main()
{
  int n, m, x;
  cin >> n >> m >> x;
  int c[n], a[n][m];
  rep(i, n)
  {
    cin >> c[i];
    rep(j, m)
    {
      cin >> a[i][j];
    }
  }
  int ans = 10000000;
  for (int bit = 0; bit < (1 << n); ++bit)
  {
    vector<int> S;
    int A[m] = {0};

    for (int i = 0; i < n; ++i)
    {
      if (bit & (1 << i))
      { // 列挙に i が含まれるか
        S.push_back(i);
      }
    }
    rep(j, S.size())
    {
      rep(k, m)
      {
        A[k] += a[S[j]][k];
      }
    }
    bool flag = true;
    rep(i, m)
    {
      if (A[i] < x)
      {
        flag = false;
      }
    }
    if (flag)
    {
      int sum = 0;
      rep(i, S.size())
      {
        sum += c[S[i]];
      }
     // cout<<"ans=="<<ans<<endl;
      ans = min(ans, sum);
    }
  }
  if (ans == 10000000)
  {
    cout << -1 << endl;
  }
  else
  {
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
int main(){
	int a,b,c,d,e;
	scanf("%d %d",&a,&b);
	c=a+b;
	d=a-b;
	e=a*b;
	if (c>=d&&c>=e)
	{
		printf("%d\n",c);
	}else if (d>=c&&d>=e)
	{
		printf("%d\n",d);
	}else if (e>=c&&e>=d)
	{
		printf("%d\n",e);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define db(x) cout << (x) << '\n';
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<double,ll> pdi;
typedef pair<string,ll> psi;
typedef pair<ll,string> pls;
typedef pair<ll,pii> pip;
typedef pair<pii,pii> ppp;

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

    int n,m;
    cin >> n >> m;
    for(int i=0;i<m;i++)
{
    int a;
    cin >> a;
    n-=a;
}
    n=max(n,-1);
    db(n)
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstring>
#include <vector>
#include <map>
#include <list>
#include <unordered_map>
#include <set>
#include <queue>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int maxn = 10001;
int a[maxn],b[maxn];
#define long double double
int main()
{
    int n;
    cin>>n;
    for(int i = 0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
    double fac = 0.0;
    double den = 1;
    for(int i = 1;i<=n;i++)
    {
        den *= i;
    }
    vector<int> nums;
    for(int i = 0;i<n;i++)
    {
        nums.push_back(i);
    }
    do {
        for(int i = 1;i<n;i++) 
        {
            double xx = a[nums[i]] - a[nums[i-1]];
            double yy = b[nums[i]] - b[nums[i-1]];
            fac += sqrt(xx*xx+yy*yy);
        }
    }
    while(next_permutation(nums.begin(),nums.end()));
    cout.precision(8);
    cout<<fixed<<fac/den<<endl;
    return 0;
    
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc1 = new Scanner(System.in);
        int n = sc1.nextInt();
        int x = sc1.nextInt();
        int y = sc1.nextInt();
        
        int max = x > y ? y : x;
        int min = x + y - n > 0 ? x + y - n : 0;
        System.out.println(max + " " + min);
    }
}


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

#define mod 1000000007
#define maxn 100005

int n;

int main()
{
    //freopen("monotonic.in", "r", stdin);
    //freopen("monotonic.out", "w", stdout);
    cin >> n;
    bool ok = 0;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i > 0)
            continue;
        if (i < 10 && n / i < 10)
            ok = 1;
    }
    if (ok)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    char s[201] = {};
    char p[101] = {};
    int i=0,j=0;
    int cs1 = 0, cp = 0,count=0,cs2 = 0; /*cs = s'count */

    scanf("%s", s);
    scanf("%s", p);

    while(s[i++])
        cs1++;
    i = 0;
    cs2 = cs1;
    while(p[i++])
        cp++;
    i = 0;
    while(p[i]){
        s[cs1] = s[i];
        cs1++;
        i++;
    }

    for(j=0;j<cs1-cp;j++){
        for(i=0;i<cp;i++){
            if(s[j+i] == p[i]){
                count++;
            }
        }
        if(count == cp){
            printf("Yes\n");
            break;
        }
        count = 0;
    }
    if(count != cp) printf("No\n");
    return(0);
}

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

#define MAXN 123456
#define INF 0x3f3f3f3f

int n;

int h[MAXN], memo[MAXN];

int solve(int ind){
    if(memo[ind]!=-1) return memo[ind];
    if(ind>n-1) return INF;
    if(ind==n-1) return 0;

    return memo[ind] = min(solve(ind+1)+abs(h[ind]-h[ind+1]), solve(ind+2)+abs(h[ind]-h[ind+2]));
}

int main(){
    cin >> n;

    memset(memo, -1, sizeof memo);

    for(int i=0;i<n;i++)
        cin >> h[i];

    cout << solve(0) << endl;
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int dp[400][400];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  cin >> n;

  vector<int> s(n), l(n), p(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> l[i] >> p[i];
  }
  
  int m;
  cin >> m;

  vector<int> w(m);
  for (int i = 0; i < m; i++) {
    cin >> w[i];
  }

  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 393; j++) {
      dp[i + 1][j] = dp[i][j];
      if (j - s[i] >= 0) {
        for (int k = max(0, j - l[i]); k <= j - s[i]; k++) if (dp[i + 1][k] >= 0) {
          dp[i + 1][j] = max(dp[i + 1][j], dp[i + 1][k] + p[i]);
        }
      }
    }
  }

  vector<int> ans;
  for (int i = 0; i < m; i++) {
    if (dp[n][w[i]] < 0) {
      cout << -1 << endl;
      return 0;
    }
    ans.emplace_back(dp[n][w[i]]);
  }
  for (auto &i : ans) {
    cout << i << endl;
  }

  return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> vec){ return (ll)vec.size(); }
ll sz(string s){ return (ll)s.size(); }

int main(){
    
    ll d,t,s;
    cin >> d >> t >> s;
    if(s*t >= d){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    return 0;
}




Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            decimal iA = decimal.Parse(sS[0]);
            decimal iB = decimal.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            decimal iOut = Math.Truncate(iA * iB);

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


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

int n;
ll a[111];
char linha[100100];

int main(){
	while(scanf("%s", linha)!=EOF){
		int tam = strlen(linha), beg, end, tem=false;
		for(int i=0; i<tam-1; i++){
			if(linha[i]==linha[i+1]){
				tem = true;
				beg = i+1;
				end = i+2;
			}
		}
		for(int i=2; i<tam; i++){
			if(linha[i]==linha[i-2]){
				tem = true;
				beg = i-1;
				end = i+1;
			}
		}
		if(tem){
			printf("%d %d\n", beg, end);
		}
		else{
			printf("-1 -1\n");
		}
	}
	return 0;
}


Measured memory_bytes: 384
# ABC138D - Ki
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)


def dfs(v: int, p: int) -> None:
    x = cnt[v]
    for u in T[v]:
        if u != p:  # p: parent -> skip
            cnt[u] += x  # cumulative sum
            dfs(u, v)


def main():
    # Ai (A[i][0]) may be not a parent of Bi (A[i][1])
    global T, cnt
    N, Q = tuple(map(int, input().rstrip().split()))  # vertices and queues
    E = tuple(tuple(map(int, input().rstrip().split())) for _ in range(N - 1))
    P = tuple(tuple(map(int, input().rstrip().split())) for _ in range(Q))
    T = [[] for _ in range(N + 1)]  # tree, N+1: 1-idx
    for a, b in E:
        T[a] += [b]
        T[b] += [a]
    cnt = [0] * (N + 1)
    for p, x in P:
        cnt[p] += x  # increase vertex p by x
    dfs(1, -1)
    print(*cnt[1:])


if __name__ == "__main__":
    main()

Measured memory_bytes: 265792
ticket = input()


for i in range(1 << 3):
    s = ticket[0]
    for j in range(3):
        if (i>>j) & 1:
            s += '+' + ticket[j+1]
        else:
            s += '-' + ticket[j+1]
    if eval(s) == 7:
        print(s+'=7')
        exit()


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

using ll = long long;

int main() {
    string s, ans = "";
    cin >> s;
    rep(i, s.size()) {
        if (s[i] == 'B') {
            if (ans.size() > 0) ans.pop_back();
        } else {
            ans.push_back(s[i]);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include "iostream"
using namespace std;

int main(){
	int target;
	while(cin >> target){
		int count = 0;
		for(int i = 0; i < 10; i++){
			for(int j = 0; j < 10; j++){
				for(int k = 0; k < 10; k++){
					for(int l = 0; l < 10; l++){
						if( i + j + k + l == target) count ++;
					}
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

h = int(input())
w = int(input())
n = int(input())

a = 0
c = 0

if h > w:
    m = h
else:
    m = w
    
while a < n:
    a += m
    c += 1
    
print(c)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;


int main(){
    string t;
    cin >> t;

    map<string, int> s{};
    s["SUN"] = 7;
    s["MON"] = 6;
    s["TUE"] = 5;
    s["WED"] = 4;
    s["THU"] = 3;
    s["FRI"] = 2;
    s["SAT"] = 1;

    cout << s[t] << endl;
}

Measured memory_bytes: 384
/**
     *    author:  shashank_hire
    **/
#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define ld long double
#define MOD 1000000007

ll f(ll n, unordered_map<ll, ll> &fact)
{
    if(fact[n])
        return fact[n];
    if(n<=1)
        return fact[n] = 0;
    return fact[n] = n*(n-1)/2;
}
// main function
int main()
{
    ll n, i, sum=0;
    cin>>n;
    vector<ll> a(n);
    unordered_map<ll, ll> cnt, fact;
    for(i=0;i<n;i++)
        {
            cin>>a[i];
            cnt[a[i]]++;
        }
    for(auto x: cnt)
        sum += (fact[x.second] = f(x.second, fact));
    for(i=0;i<n;i++)
        cout<<sum - fact[cnt[a[i]]] + f(cnt[a[i]]-1, fact)<<"\n";    
	return 0;
}

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

using namespace std;

int main(){
    int n,a,max=0,min=0;
    long int sum=0;
    cin >> n;

    for(int i=0;i<n;i++){
        cin >> a;
        if(i==0){
            max=a;
            min=a;
            sum=a;
            continue;
        }
        if(max<a){
            max = a;
        }
        if(min>a){
            min = a;
        }
        sum = sum + a;
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3104
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]
inf = 10**9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf
    no_merge = dfs(cur+1, a, b, c)
    merge_a = dfs(cur+1, a+L[cur], b, c) + 10
    merge_b = dfs(cur+1, a, b+L[cur], c) + 10
    merge_c = dfs(cur+1, a, b, c+L[cur]) + 10
    return min(no_merge, merge_a, merge_b, merge_c)

print(dfs(0, 0, 0, 0))

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

int main() {
    int64_t A,B,N;
    cin >> A >> B >> N;
    int64_t max_x;
    if(N%B == 0){
        max_x = N-1;
    }else if(N/B == 0){
        max_x = N;
    }else{
        max_x = (N/B)*B-1; 
    }
    cout << (A*max_x)/B - (max_x/B)*A << endl;
    //cout << max_x << endl;
}


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

int main() {
  int N;
  cin >> N;
  int a;
  cin >> a;
  int b = a;
  int ans = a;
  for (int i = 0; i < N-2; i++) {
      cin >> b;
      ans += min(a, b);
      a=b;
  }
  ans += b;
  cout << ans << endl;
}

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

int d[11];
int f[10];

bool check(int x) {
	while (x) {
		if (f[x % 10]) return false;
		x /= 10;
	}
	return true;
}
	
int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= k; i++) {
		cin >> d[i];
		f[d[i]] = 1;
	}
	while (1) {
		if (check(n)) {
			cout << n;
			return 0;
		}
		n ++;
	}
}

Measured memory_bytes: 256
/*
 
श्रीगुरु चरन सरोज रज
निजमनु मुकुरु सुधारि
बरनउँ रघुबर बिमल जसु
जो दायकु फल चारि
बुद्धिहीन तनु जानिके, सुमिरौं पवन-कुमार
बल बुधि बिद्या देहु मोहिं, हरहु कलेस बिकार 
 
*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD (ll)1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    ll arr[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    ll l = 0;
    ll mini = arr[0];
    ll maxi = -1;
    for (ll i = 1; i < n; i++)
    {
        if (arr[i] > mini)
        {
            maxi = max(maxi, i - l - 1);
            l = i;
            mini = arr[i];
        }
        else
        {
            mini = arr[i];
        }
    }
    maxi = max(maxi, n - l - 1);
    cout << maxi << endl;
}

Measured memory_bytes: 1024
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())
print(arr[k - 1 ])


Measured memory_bytes: 2940
import java.io.*;

public class Main {
    private static int[] goal;
    private static int inputNum = 0;
    private static int[] bamboo;
    private static int[] bPattern;


    private static void increaseBambooPattern(int figure){
        if(figure >= bPattern.length) {

        }else  if(bPattern[figure] >= 3){
            bPattern[figure] = 0;
            increaseBambooPattern(figure+1);
        }else{
            bPattern[figure] += 1;
        }
    }

    private static int calcUsedMP(int[] lengthSum){
        int answer = 0;
        for(int i=1; i<4; i++) {
            answer += Math.abs(goal[i-1] - lengthSum[i]);
        }
        return answer;
    }

    private static int calcAnswer(){
        int[] lengthSum = new int[4];
        int[] mergeNum = new int[4];
        for(int i=0; i<bamboo.length; i++){
            lengthSum[bPattern[i]] += bamboo[i];
            mergeNum[bPattern[i]] ++;
        }

        int mergeMP = 0;
        for(int i=1; i<4; i++){
            if (mergeNum[i] == 0) {
                 return Integer.MAX_VALUE;
            } else if (mergeNum[i] > 1) {
                mergeMP += 10 * (mergeNum[i] - 1);
            }
        }
        return mergeMP + calcUsedMP(lengthSum);
    }

    private static int solveBambooPattern(){
        int answer = Integer.MAX_VALUE;
        bPattern = new int[bamboo.length];
        int loopMax = (int)Math.pow(4, bamboo.length);
        for(int i=0; i<loopMax; i++){
            answer = Math.min(answer, calcAnswer());
            increaseBambooPattern(0);
        }

        return answer;

    }

    private static int solver() {

        return solveBambooPattern();

    }


    public static void main(String[] args) {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);

        goal = new int[3];
        try {
            String[] inputArray = br.readLine().split(" ");
            inputNum = Integer.parseInt(inputArray[0]);
            goal[0] = Integer.parseInt(inputArray[1]);
            goal[1] = Integer.parseInt(inputArray[2]);
            goal[2] = Integer.parseInt(inputArray[3]);
        } catch (Exception e) {
            e.printStackTrace();
        }

        bamboo = new int[inputNum];
        for (int i = 0; i < inputNum; i++) {
            try {
                bamboo[i] = Integer.parseInt(br.readLine());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        System.out.println(solver());

    }
}

Measured memory_bytes: 26068
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e10;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 




////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

signed main(){
  int a,b;cin>>a>>b;
  repd(i,1,4){
    if(a == i || b == i)continue;
    else{
      cout << i << endl;return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N;
  while (cin >> N, N) {
    string s;
    cin >> s;
    int a[10] = {};
    int ba = 0;
    int curr = 0;
    for (int i = 0; i < 100; i++) {
      if (s[i] == 'M') {
        a[curr]++;
      } else if (s[i] == 'S') {
        ba += a[curr] + 1;
        a[curr] = 0;
      } else {
        a[curr] += ba + 1;
        ba = 0;
      }
      curr = (curr + 1) % N;
    }
    sort(a, a + N);
    for (int i = 0; i < N; i++) {
      cout << a[i] << " ";
    }
    cout << ba << endl;
  }

  return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
#define all(a)  (a).begin(), (a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i = 0; i < n; i++)
#define repR(i,n) for(int i = n-1; i >= 0; i--)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define PB push_back
#define MP make_pair
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


int main() {
    ll n;
    string s;
    cin >> n >> s;

    int cnt = 0, sum[n];
    rep(i,n){
        if(s[i] == 'W') cnt++;
        sum[i] = cnt;
    }
    int ans = n;
    rep(i,n){
        int num = 0;
        if(i) num += sum[i-1];
        if(i!=n-1) num += n-1-i - (sum[n-1]-sum[i]);
        ans = min(ans,num);
    }
    cout << ans << endl;
    return 0;
}

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

if N==0:
    print(0)
elif N==1 and A==B:
    print(1)
elif N==1 and A!=B:
    print(0)
elif A>B:
    print(0)
elif N>=2:
    mx = B*(N-1)+A
    mn = A*(N-1)+B
    print(mx-mn+1)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main() {
	int x, y, z;
	int s, ans;
	scanf("%d %d %d", &x, &y, &z);
	ans = min(x*y, z);

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


	return 0;
}


Measured memory_bytes: 128
from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations
# from itertools import combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    N,M=map(int,input().split())
    A=list(map(int,input().split()))
    A = [-a for a in A]  # プライオリティキューで最大値を取り出す処理を実施するために正負反転
    heapify(A)  # プライオリティキューに変換

    for i in range(M):
        M=heappop(A)
        M=M/2
        heappush(A,M)
    print(sum([int(-a) for a in A]))  # 最後にまた正負反転






resolve()

Measured memory_bytes: 95360
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;

int n,t,tmpmin,tmpd,ai,ret;

int main(){
    I(n); I(t);
    I(tmpmin);
    REP(i,n-1){
        I(ai);
        int d = ai-tmpmin;
        if (d > tmpd){
            tmpd = d;
            ret = 1;
        } else if (d == tmpd){
            ret++;
        }
        tmpmin = min(tmpmin,ai);
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;	//・・・①
import java.util.Arrays;
public class Main {
  public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);	//・・・②
        // System.out.println("何か入力してください。");
        int N = scanner.nextInt();	//・・・③
        // System.out.println("入力した文字列は " + string + " です。");
        int K = scanner.nextInt();
        // int int3 = scanner.nextInt();
        int[] p = new int[N];
        // ArrayList<Integer> foo = new ArrayList<>();

        for(int i=0; i<N; i++){
            p[i] = scanner.nextInt();
            
        }
        Arrays.sort(p);
        int sum=0;
        for(int j=0;j<K;j++){
            sum += p[j];
        }
        System.out.println(sum);

        
  }
}

Measured memory_bytes: 38504
n=int(input())
a = list(map(int, input().split()))
cnt4=0
cnt_odd=0
cnt_even=0
ans="Yes"
for i in a:
    if i%4==0:
        cnt4+=1
    elif i%2==0:
        cnt_even+=1


if cnt4 >= n // 2:
    print('Yes')
elif n - cnt4*2 <= cnt_even:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14252
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

struct lit{
	char c;
	bool _not;
	lit(char c,bool _not):c(c),_not(_not){}
};

bool clause(string &exp,int &p){
	//<clause> ::= <literal>"&"<literal>"&"<literal>
	//<literal> ::= <variable> | "~"<variable>
	//<variable> ::= [a-z]|[A-z]
	vector<lit> literals;
	REP(i,3){
		bool _not=false;
		if(exp[p]=='~'){
			_not=true;
			p++;
		}
		assert(isalpha(exp[p]));
		literals.push_back(lit(exp[p],_not));
		p++;
		if(i!=2){
			assert(exp[p]=='&');
			p++;
		}
	}
	REP(i,3){
		FOR(j,i+1,3){
			if(literals[i].c==literals[j].c&&literals[i]._not!=literals[j]._not){
				return false;
			}
		}
	}
	return true;
}

bool expression(string &exp,int &p){
	//<expression> ::= "("<clause>")" | "("<clause>")|("<expression>")"
	while(1){
		assert(exp[p]=='(');
		p++;
		if(clause(exp,p)){
			return true;
		}
		assert(exp[p]==')');
		p++;
		if(p>=exp.size()||exp[p]!='|'){
			break;
		}
		p++;
	}
	return false;
}

int main(){
	string exp;
	while(cin>>exp,exp!="#"){
		int p=0;
		cout<<(expression(exp,p)?"yes":"no")<<endl;
	}
}

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

int main() {
  int N;
  cin >> N;
  N *= 2;
  vector<int> L(N);
  for (int& l : L) cin >> l;
  sort(L.begin(), L.end());
  int ans = 0;
  for (int i = 0; i < N; i += 2) {
    ans += L[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0

#define putb push_back
#define f first
#define s second

//logx(a^n)=loga(a^n)/logx(a)
//logx(a*b)=logx(a)+logx(b)
//logx(y)=log(y)/log(x)

#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define putf push_front
#define gainb pop_back

#define gainf pop_front
#define len(x) (ll)x.size()

// 1/b%mod=b^(m-2)%mod
// (a>>x)&1==0

typedef double db;
typedef long long ll;

const ll ary=1e5+5;
const ll mod=1e9+7;
const ll inf=1e18;

using namespace std;
using namespace __gnu_pbds;
string s;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>s;
	if(s=="SUN"){
		cout<<7;
	}
	else if(s=="MON"){
		cout<<6;
	}
	else if(s=="TUE"){
		cout<<5;
	}
	else if(s=="WED"){
		cout<<4;
	}
	else if(s=="THU"){
		cout<<3;
	}
	else if(s=="FRI"){
		cout<<2;
	}
	else{
		cout<<1;
	}
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
typedef long long ll;
const int mod=1e9+7;
#define lol(i,n) for(int i=0;i<n;i++)

using namespace std;
int h,w,x,y;
int main() {
    cin >>h>>w>>x>>y;
    if((h*w)%2==1&&(x+y)%2==1)cout << "No"<< endl;
    else cout <<"Yes"<< endl;
}



Measured memory_bytes: 3124
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int N, K, X, Y;
    cin >> N;
    cin >> K;
    cin >> X;
    cin >> Y;
    int ans = 0;
    for (int i=0; i<min(K,N); i++) ans += X;
    for (int i=K; i<N; i++)ans += Y;

    cout << ans << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    int n;
    cin >> n;
    vector<int>vec;
    vector<int>vec2;
    for(int i =0; i<n; i++){
        int a;
        cin >> a;
        vec.push_back(a);
        vec2.push_back(a);
    }
    int mx = *max_element(vec.begin(),vec.end());
    sort(vec2.begin(),vec2.end());
    for(int i=0; i<vec.size(); i++){
        if(vec[i]!=mx){
            cout << mx <<endl;
        }else{
            cout << vec2[n-2] <<endl;
        }
    }      
}

Measured memory_bytes: 5136
S=input()
chk = S[0]
cnt =1
cnt_list=[]
ans = 0
for i in S[1:]:
    if chk==i:
        cnt += 1
    else:
        ans += cnt*(cnt-1)//2
        cnt_list.append(cnt)
        cnt = 1
        chk = i
cnt_list.append(cnt)
ans += cnt*(cnt-1)//2
if S[0]=="<":
    for i,j in zip(cnt_list[::2],cnt_list[1::2]):
        ans += max(i,j)
    if len(cnt_list)%2!=0:
        ans += cnt_list[-1]
else:
    ans += cnt_list[0]
    for i,j in zip(cnt_list[1::2],cnt_list[2::2]):
        ans += max(i,j)
    if len(cnt_list)%2==0:
        ans += cnt_list[-1]
print(ans)

Measured memory_bytes: 7568
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

r = 10**9+7
n = inp[0]
dp = na(2,0)
ans = 0
m8 = 1
m9 = 0
n.times do |i|
  ans *= 10
  ans += m9 * 2
  m9 = m9 * 9 + m8
  m8 *= 8

  m9  %= r
  m8  %= r
  ans %= r
end
p ans

Measured memory_bytes: 14400
#include<bits/stdc++.h>
using namespace std;
int n,cnt;
int book[200010];
char out[200010];
void dfs(int now,int pre){
	if(now==n){
		cout<<out<<endl;
		return;
	}
	for(int i=0;i<=cnt;++i){
		if(book[i]==0)++cnt;
		++book[i];
		out[now]=i+'a';
		dfs(now+1,i);
		--book[i];
		if(book[i]==0)--cnt;
	}
}
int main(){
	cin>>n;
	out[n]='\0';
	dfs(0,0);
	return 0;
}

Measured memory_bytes: 1536
import cmath
import sys

INF=10**18
MOD=10**9+7
MAX=10**5+7



def main():
  A,B,M=map(int, input().split())
  a=list(map(int, input().split()))
  b=list(map(int, input().split()))
  
  ans=min(a)+min(b)
  for i in range(M):
    x,y,c=map(int, input().split())
    x-=1
    y-=1
    ans=min(ans, a[x]+b[y]-c)
  
  print(ans)
  
  
if __name__=='__main__':
    main()

Measured memory_bytes: 65724
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	printf("%lld",(n-a)%b);
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var x1, y1, x2, y2 int
	fmt.Scan(&x1, &y1, &x2, &y2)

	moveX := x2 - x1
	moveY := y2 - y1

	fmt.Println(x2-moveY, y2+moveX, x1-moveY, y1+moveX)
}


Measured memory_bytes: 512
// Original macro is in https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> String {
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// for adhoc read (ex. https://atcoder.jp/contests/abc112/tasks/abc112_a)
#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    input!{x_1:i32,y_1:i32,x_2:i32,y_2:i32}
    // A(x_1, y_1), B(x_2, y_2), C(x_3, y_3), D(x_4, y_4), 
    // -> C = r(-90°)*(A-B) + B
    // -> D = r(90°)*(B-A) + A
    let x_3 = y_1 - y_2 + x_2;
    let y_3 = (-1)*x_1 + x_2 + y_2;
    let x_4 = x_1 + y_1 - y_2;
    let y_4 = (-1)*x_1 + x_2 + y_1;
    println!("{} {} {} {}", x_3, y_3, x_4, y_4);
}

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

int n,q,a,b,p[200010],p0,x,c[200010],now;

int main(){
    cin>>n>>q;
    vector<vector<int>> g(n+1);
    for(int i=1;i<n;i++){
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        cin>>p0>>x;
        p[p0]+=x;
    }
    queue<int> que;
    que.push(1);
    c[1]=1;
    while(que.size()){
        now=que.front();
        que.pop();
        for(int j=0;j<g[now].size();j++){
            if(c[g[now][j]]!=1){
                c[g[now][j]]=1;
                que.push(g[now][j]);
                p[g[now][j]]+=p[now];
            }
        }
    }
    cout<<p[1];
    for(int i=2;i<=n;i++)cout<<' '<<p[i];
    cout<<endl;
}

Measured memory_bytes: 16372
#include <iostream>

using namespace std;

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

    int64_t count = 0;
    if (K <= A)
        count = K;
    else if (K <= A + B)
        count = A;
    else
    {
        int64_t res = K - A - B;
        count = A - res;
    }
    cout << count;
}

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

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	long long predmet, tezina;
	int n,w;
	cin >> n >> w;
	vector<long long> dp(w+1,0);
	for (int i = 0; i < n; i++)
	{
		cin >> tezina >> predmet;
		for (int j = w; j >= tezina; j--)
			dp[j] = max(dp[j - tezina] + predmet, dp[j]);
	}
	cout << dp[w];
}


Measured memory_bytes: 1024
while True:
    h, w = map(int, raw_input().split())
    if h == 0 and w == 0:
        break
    else:
        result = list()
        for i in range(h):
            temp = list()
            if i % 2 == 0:
                even, odd = '#', '.'
            else:
                even, odd = '.', '#'
            for j in range(w):
                if j % 2 == 0:
                    temp.append(even)
                else:
                    temp.append(odd)
            result.append(temp)
        for i in result:
            print("".join(j for j in i))
        print("")

Measured memory_bytes: 6444
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    int e = sc.nextInt();
    int k = sc.nextInt();

    if(b-a <= k && c-a <= k && d-a <= k && e-a <= k && c-b <= k && d-b <= k && e-b <= k && d-c <= k && e-c <= k && e-d <= k ) {
      System.out.println("Yay!");
    } else {
      System.out.println(":(");
    }
    
  }

}


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

int main(void){
    long long x;
    cin >> x;
    
    long long tmp, seki;
    long long max_t = 1;
    for(long long i = 2; i <= 100; i++){
        tmp = i;
        seki = tmp;
        for(long long j = 1; ; j++){
            seki *= tmp;
            if(seki > x) break;
            max_t = max(seki, max_t);
        }
    }

    cout << max_t << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    scanf("%d",&k);
    for(int i=0;i<32;i++)
    {
       printf("%d\n",a[k-1]);
       return 0;
    }

}


Measured memory_bytes: 128
n, k = map(int, input().split())

remain = (n-1)*(n-2)//2 - k
if remain < 0:
    print(-1)
    exit()

m = n-1 + remain
print(m)
for i in range(1, n):
    print(1, i+1)

for i in range(1, n):
    for j in range(i+1, n):
        if remain > 0:
            print(i+1, j+1)
            remain -= 1
        else:
            exit()

Measured memory_bytes: 3608
N = int(input())
nums = list(map(int,input().split()))

total = 0
sums = []
tmp = 0

for i in range(1, N):
    tmp += nums[N-i]
    sums.append(tmp)

for i in range(N-1):
    a = nums[i]
    b = sums[N-(i+2)]
    total += a*sums[N-(i+2)]

print(total % (1000000000+7))


Measured memory_bytes: 31532
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;

ll a[200010];
ll x[200010];
ll y[200010];

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

  for ( int i = 0; i < N; i++ ) {
    cin >> a[i];
  }
  x[0] = a[0];
  for ( int i = 1; i < N; i++ ) {
    x[i] = x[i-1] + a[i];
  }
  y[N-1] = a[N-1];
  for ( int i = N-2; i >= 0; i-- ) {
    y[i] =  a[i] + y[i+1];
  }
  /*
  for ( int i = 0; i < N; i++ ) {
    cout << x[i] << " ";
  }
  cout << endl;

  for ( int i = 0; i < N; i++ ) {
    cout << y[i] << " ";
  }
  cout << endl;  
  */

  ll ans = 1e18;
  for ( int i = 0; i < N-1; i++ ) {
    ans = min(abs(x[i]-y[i+1]),ans);
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
N = int(input())
s = input().split()
A = []
for i in range(N):
    A.append(int(s[i]))
sum = 0
while True:
    flg = True
    for i in range(len(A)):
        if A[i] % 2 == 1:
            flg = False
            break
        else:
            A[i] = A[i] / 2
    if flg:
        sum += 1
    else:
        break
print(sum)


Measured memory_bytes: 3060
#include "iostream"
#include "algorithm"
#include "string"
#include "set"
#include "vector"
#include "climits"
#include "queue"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W;

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

	cin >> W >> H;
	while(W){
	cin >> N;
	vector<vector<long long int>>v(H, vector<long long int>(W));
	v[0][0] = 1;
	for (int i = 0; i < N; i++) {
		cin >> M >> K;
		M--;
		K--;
		v[K][M] = -1;
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (v[i][j] == -1) {
				v[i][j] = 0;
				continue;
			}
			if (!i && !j) {
				continue;
			}
			if (!i) {
				v[i][j] = v[i][j - 1];
				continue;
			}
			if (!j) {
				v[i][j] = v[i - 1][j];
				continue;
			}
			v[i][j] = v[i - 1][j] + v[i][j - 1];
		}
	}
	cout << v[H - 1][W - 1] << endl;
	cin>>W>>H;
	}
	return 0;
}


Measured memory_bytes: 3116
l = sorted(list(map(int,input().split())))

a = abs(l[0]-l[1])%2
b = abs(l[1]-l[2])%2
c = abs(l[0]-l[2])%2

if a==0:
    if b==0:
        ans = (l[2]-l[0] + l[2]-l[1]) /2
    else:
        ans = 1 + (l[2]-(l[0]+1) + l[2]-(l[1]+1))/2
else:
    if b==0:
        ans = 1 + ((l[2]+1)-l[0] + (l[2]+1)-(l[1]+1))/2
    else:
        ans = 1 + ((l[2]+1)-(l[0]+1) + (l[2]+1)-l[1])/2
print(int(ans))

Measured memory_bytes: 9256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<v<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<62;
const ll MOD=1000000007;

ll N,Q,K;
vector<ll> a(100007,0);
vector<ll> b(100007,0);
vector<ll> c(100007,0);
vector<ll> x(100007,0);
vector<ll> y(100007,0);
vector<ll> d(100007,INF);
vector<vector<P>> G(100007, vector<P>(0));


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll H;
    cin >> H;
    ll W;
    cin >> W;
    ll N;
    cin >> N;
    vector<ll> a(N,0);
    for(ll i=0;i<N;++i)cin>>a[i];
    vector<vector<ll>> ans(H, vector<ll>(W, 0));
    vector<ll> wait(0);
    for(ll i=0;i<N;++i){
        for(ll j=0;j<a[i];++j)wait.emplace_back(i+1);
    }
    ll index=0;
    for(ll i=0;i<H;++i){
        if(i%2){
            for(ll j=0;j<W;++j){ans[i][j]=wait[index];index++;}
        }
        else {
            for(ll j=W-1;j>=0;--j){ans[i][j]=wait[index];index++;}
        }
    }
    for(ll i=0;i<H;++i){
        for(ll j=0;j<W;++j)cout<<ans[i][j]<<" ";cout<<endl;
    }

    
    return 0;
}


Measured memory_bytes: 7680