akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
    
void printIt(int hw[][110], int h, int w){
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cout<<hw[i][j]<<" ";
            //if(j!=w-1) cout<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
}

 int main()
 {
     int h,w,n;
     int a[200000],hw[110][110];
     cin>>h>>w>>n;
     for(int i=0;i<n;i++) cin>>a[i];
     
     int k = 0, put = 0;
     int toggle = 0;
         
     for(int i=0; i<h && put < a[k] && k < n; i++){
         if(toggle == 0)
         for(int j=0; j<w; j++){
             hw[i][j] = k+1;
             put++;
             if(put == a[k]){
                 put = 0;
                k++;
             }
         }
         else
         for(int j=w-1; j>=0; j--){
             hw[i][j] = k+1;
             put++;
             if(put == a[k]){
                 put = 0;
                k++;
             }
         }
         if(put < a[k])
            toggle = 1-toggle;
        else{
            put = 0;
            k++;
        }
     }
     printIt(hw,h,w);
     return 0;
}

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

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;



void chmax(ll &a,ll b) {
	if (a < b)a = b;
}


int main() {
	vector<vector<ll>>dist(205, vector<ll>(205, 0));
	rep(i, 0, 205)rep(j, 0, 205)dist[i][j] = inf;

	int n, m, r;
	cin >> n >> m >> r;
	vector<int>v(r);
	rep(i,0,r) {
		int x;
		cin >> x;
		x--;
		v[i] = x;
	}

	rep(i, 0, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		dist[a][b] = c;
		dist[b][a] = c;
	}


	rep(k, 0, n) {
		rep(i, 0, n) {
			rep(j, 0, n) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}

	sort(v.begin(), v.end());
	vector<ll>ans;
	do {
		int temp = 0;
		rep(i, 1, r) {
			temp += dist[v[i-1]][v[i]];
		}
		ans.push_back(temp);
	} while (next_permutation(v.begin(), v.end()));

	sort(ans.begin(),ans.end());
	cout << ans[0] << endl;

	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 998244353;

vector<int> fac(300001); //n!(mod M)
vector<int> ifac(300001); //k!^{M-2} (mod M)

long long fpow(long long a,long long n){
  long long ret=1;
  if(n==1) return a;
  if(n%2==0) {
      ret = fpow(a*a%mod, n/2) %mod ;
  }else {
      ret = (a%mod)*fpow(a*a%mod, n/2) %mod;
  }
  return ret %mod;
}
int comb(int a, int b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    int tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}

signed main(){
    int n;
    cin >> n;
    vector<int> h(n);
    vector<int> dp(n);
    rep(i, n) cin >> h[i];
    if(n==1) {
        cout << 1 << endl;
        return 0;
    }
    if(n==2) {
        cout << abs(h[0]-h[1]) << endl;
        return 0;
    }
    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);

    FOR(i,2, n) {
        dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
    }

    //for(auto d: dp) cout << d << endl;
    cout << dp[n-1] << endl;

    return 0;
}



Measured memory_bytes: 6528
/*
 * MinMaxAndSum.cpp
 *
 *  Created on: 2014/07/21
 *      Author: WanWan1985
 */
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {

	long int n;
	cin >> n;

	vector<long int> vecValue;
	vecValue.reserve(n);
	for (long int i = 0; i < n; i++) {
		long int x;
		cin >> x;
		vecValue.push_back(x);
	}

	long long int iResult = 0;
	for (long int i = 0; i < vecValue.size(); i++) {
		iResult += vecValue.at(i);
	}

	cout << *min_element(vecValue.begin(), vecValue.end()) << " "
		 << *max_element(vecValue.begin(), vecValue.end()) << " "
		 << iResult << endl;


	return 0;
}

Measured memory_bytes: 1280
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from math import pi, sqrt, cos
    input = sys.stdin.readline

    A, B, H, M = map(int, input().split())

    ta = pi * 2 * (H + M / 60) / 12
    tb = pi * 2 * M / 60
    t = abs(ta-tb)

    print(sqrt(A*A + B*B - 2 * A * B * cos(t)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; 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 ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.length();
    bool ans = true;
    REP(i,n) {
        if((i%2==0 && s[i]=='L') || (i%2==1 && s[i]=='R')) {
            ans = false;
            break;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
#include<iomanip>
#include<map>
#include<fstream>
#include<queue>
#include<set>
#include<deque>

using namespace std;

int main()
{
	int n;
	double sum = 0;
	cin >> n;
	double a;
	char b[4];
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (b[0] == 'J')
			sum += a;
		else
			sum += 380000 * a;
	}
	cout << sum << endl;
}

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

int main(){
    long N,ans=0,cnt=0;
    cin>>N;
    vector<string> s(N);
    for(int i=0;i<N;i++){
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
    }
    sort(s.begin(),s.end());
    for(int i=1;i<N;i++){
        if(s[i-1]==s[i]){
            cnt+=1;
            ans+=cnt;
        }
        else{
            cnt=0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7296
import java.io.*;
import java.util.*;
import java.lang.*;

class Main {
    public static void main(String [] args){
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        
        double cr = deg2rad(c);
        
        System.out.println((a * b * Math.sin(cr)) / 2);
        System.out.println(a + b + Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(cr)));
        System.out.println(b * Math.sin(cr));
    }
    
    public static double deg2rad(double deg){
        return (deg / 360) * 2 * Math.PI;
    }
}


Measured memory_bytes: 26080
#include <iostream>


int main() {
    long N, K;

    std::cin >> N >> K;

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

    long answer = 0;
    long cur = 0;

    for (int i = 60; i >= 0; i--) {
        long val = 1LL << i;
        if (val > K && val > maxval) continue;
        // std::cout << "K = " << K << ", maxval = " << maxval << ", val = " << val << std::endl;

        int zeros = 0;
        for (int i = 0; i < N; i++) {
            if ((val & A[i]) == 0) {
                zeros++;
            }
        }
        int ones = N - zeros;

        if (cur + val <= K) {
            if (zeros > ones) {
                answer += zeros * val;
                cur += val;
            } else {
                answer += ones * val;
            }
        } else {
            answer += ones * val;
        }
    }

    std::cout << answer << std::endl;
}


Measured memory_bytes: 1024
open System
let R T = stdin.ReadLine()|> T
let RS T = stdin.ReadLine().Split()|>Array.map T
let R2 T U = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U)
let R3 T U V = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V)
let R4 T U V W = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W)
let R5 T U V W X = RS string|>fun c-> (c.[0]|>T),(c.[1]|>U),(c.[2]|>V),(c.[3]|>W),(c.[4]|>X)
[<EntryPoint>]
let main argv =
    let H,W,K=R3 int int int
    let map = [|for i in [1..H] do yield (R string)|]
    let bit x i = ((x>>>i)&&&1)<>0
    let mutable ans = 0
    for a in [0..(1<<<H)-1] do
        for b in [0..(1<<<W)-1] do
            if ([0..H-1]|>Seq.sumBy(fun c -> if (bit a c) then 0 else ([0..W-1]|>Seq.sumBy(fun d -> if ((bit b d)||(map.[c].[d]='.')) then 0 else 1))))=K then
                ans <- ans+1
    printfn "%d" ans
    0

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

int main() {
    int H, W;
    cin >> H >> W;
    int Cy, Cx, Dy, Dx;
    cin >> Cy >> Cx >> Dy >> Dx;
    vector<string> S(H);
    for (int i = 0; i < H; i++) cin >> S[i];
    queue<pair<int, int>> Q;
    Q.push(make_pair(Cy - 1, Cx - 1));
    queue<pair<int, int>> warp_Q;
    int ey, ex;
    vector<vector<bool>> mark(H, vector<bool>(W));
    mark[Cy - 1][Cx - 1] = true;
    int dy[4] = {0, 1, 0, -1},
        dx[4] = {1, 0, -1, 0};
    bool flag = false, flag2 = false;
    int warp_count = 0;
    while(1) {
        while(!Q.empty()) {
            ey = Q.front().first;
            ex = Q.front().second;
            Q.pop();
            warp_Q.push(make_pair(ey, ex));
            for (int i = 0; i < 4; i++) {
                if(ey + dy[i] < 0 || ey + dy[i] >= H || ex + dx[i] < 0 || ex + dx[i] >= W) {
                    continue;
                }
                if (S[ey + dy[i]][ex + dx[i]] == '#') {
                    continue;
                }
                if (mark[ey + dy[i]][ex + dx[i]]) {
                    continue;
                }
                if (ey + dy[i] == Dy - 1 && ex + dx[i] == Dx - 1) {
                    flag = true;
                    break;
                }
                mark[ey + dy[i]][ex + dx[i]] = true;
                Q.push(make_pair(ey + dy[i], ex + dx[i]));
            }
            if (flag) break;
        }
        if (flag) break;
        if (warp_Q.empty()) {
            flag = true;
            flag2 = true;
            break;
        }
        warp_count++;
        while(!warp_Q.empty()) {
            ey = warp_Q.front().first;
            ex = warp_Q.front().second;
            warp_Q.pop();
            for (int i = ey - 2; i <= ey + 2; i++) {
                for (int j = ex - 2; j <= ex + 2; j++) {
                    if (i < 0 || i >= H || j < 0 || j >= W) {
                        continue;
                    }
                    if (S[i][j] == '#') {
                        continue;
                    }
                    if (mark[i][j]) {
                        continue;
                    }
                    if (i == Dy - 1 && j == Dx - 1) {
                        flag = true;
                        break;
                    }
                    mark[i][j] = true;
                    Q.push(make_pair(i, j));
                }
                if (flag) break;
            }
            if (flag) break;
        }
        if (flag) break;
    }
    if (flag2) cout << -1 << endl;
    else cout << warp_count << endl;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for (int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

int dp[4096][4096];

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

    string s1, s2;

    while (cin >> s1 >> s2)
    {
        memset(dp, 0, sizeof(dp));

        int ans = 0;

        REP(i, s1.size())
        {
            REP(j, s2.size())
            {
                if (s1[i] == s2[j])
                {
                    dp[i + 1][j + 1] = dp[i][j] + 1;
                    ans = max(dp[i + 1][j + 1], ans);

                }
                else
                {
                    dp[i + 1][j + 1] = 0;
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 68724
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000
struct C
{
	char suit;
	int value;
};
struct C L[MAX/2+2],R[MAX/2+2];
void merge(struct C A[],int n,int left,int mid,int right)
{
	int i,j,k;
	int n1=mid-left;
	int n2=right-mid;
	for(i=0;i<n1;i++)L[i]=A[left+i];
	for(i=0;i<n2;i++)R[i]=A[mid+i];
	L[n1].value=R[n2].value=SENTINEL;
	i=j=0;
	for(k=left;k<right;k++)
	{
		if(L[i].value<=R[j].value)
		A[k]=L[i++];
		else 
		A[k]=R[j++];
	}
}
void mergeSort(struct C A[],int n,int left,int right)
{
     int mid;
	if(left+1<right)
	{
		mid=(left+right)/2;
		mergeSort(A,n,left,mid);
		mergeSort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}
int partition(struct C A[],int n,int p,int r)
{
	int i,j;
    struct C t,x;
    x=A[r];
    i=p-1;
    for(j=p;j<r;j++)
    {
    	if(A[j].value<=x.value)
        {
        	i++;
        	t=A[i];A[i]=A[j];A[j]=t;
        }
	}
	t=A[i+1];A[i+1]=A[r];A[r]=t;
	return i+1;
}
void quickSort(struct C A[],int n,int p,int r)
{
	int q;
	if(p<r)
	{
		q=partition(A,n,p,r);
		quickSort(A,n,p,q-1);
		quickSort(A,n,q+1,r);
	}
}
int main()
{
	int i,n,v;
	struct C A[MAX],B[MAX];
	char S[10];
	int stable=1;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d",S,&v);
		B[i].suit=S[0];
		A[i].suit=B[i].suit;
		B[i].value=v;
		A[i].value=B[i].value;
	}
	mergeSort(A,n,0,n);
	quickSort(B,n,0,n-1);
	for(i=0;i<n;i++)
	{
		if(A[i].suit!=B[i].suit)stable=0;
	}
	if(stable==1)printf("Stable\n");
	else printf("Not stable\n");
    for(i=0;i<n;i++)
    {
    	printf("%c %d\n",B[i].suit,B[i].value);
    }
	return 0;
}

Measured memory_bytes: 5060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    string s;
    
    cin >> s;
    
    int x = 700;
    
    rep(i,3){
    
    if(s[i] == 'o'){
    
    x += 100;
    
    }else{}
    
    }
    
    cout << x << endl;


    
/////////////////////////////////////////////////////
return 0;}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

const long long INF = 1000000000000000000 + 7;

int main() {
  ll n;
  cin >> n;
  vector<ll> wcount(n + 1);
  vector<char> ch(n, 0);

  /* cout << n << endl; */
  /* cout << wcount.at(4) << endl; */

  for (long long i = 0; i < n; i++) {
    char c;
    cin >> c;
    ch.at(i) = c;
    if (c == 'W') {
      wcount.at(i + 1) = wcount.at(i) + 1;
    } else {
      wcount.at(i + 1) = wcount.at(i);
    }
  }

  vector<ll> ans(n + 1, INF);

  for (long long i = 0; i < n + 1; i++) {
    ll r = (n - i) - (wcount.at(n) - wcount.at(i));
    ans.at(i) = max(wcount.at(i), r);
  }

  sort(ans.begin(), ans.end());
  cout << ans.at(0) << endl;
}


Measured memory_bytes: 6664
#include<stdio.h>
int main(void)
{
    int n,a[11],i,j,w;
	char card[100];
	while(1){
	    scanf("%d",&n);
		if(n==0) break;
		scanf("%s",card);
		for(i=0;i<=n;i++) a[i]=0;
		j=0;
		for(i=0;i<100;i++){
		    if(card[i]=='S'){
			    a[n]=a[n]+a[j]+1;
				a[j]=0;
			}
			if(card[i]=='L'){
			    a[j]=a[j]+a[n]+1;
				a[n]=0;
			}
			if(card[i]=='M'){
			    a[j]++;
			}
			j++;
			if(j==n) j=0;
		}
		for(i=0;i<n-1;i++){
		    for(j=i+1;j<n;j++){
			    if(a[i]>a[j]){
				    w=a[i];
					a[i]=a[j];
					a[j]=w;
				}
			}
		}
		for(i=0;i<=n;i++){
		    if(i==n) printf("%d\n",a[i]);
			else printf("%d ",a[i]);
		}
	}
	return 0;
}

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

int main(){
    ll K, N;
    cin >> K >> N;
    vector<ll> a(N);
    vector<ll> ki(N);
    rep(i, N) cin >> a.at(i);
    rep(i, N-1) ki.at(i) = a.at(i+1) - a.at(i);
    ki.at(N-1) = K - a.at(N-1) + a.at(0);
    ll max = 0;
    rep(i, N) if(max < ki.at(i)) max = ki.at(i);
    ll ans = K - max;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n,t; cin>>n>>t;
	int tmp=0,ans=0;
	rep(i,n){
		int s; cin>>s;
		if(tmp>s) ans+=s+t-tmp;
		else ans+=t;
		tmp=s+t;
	}
	cout<<ans<<endl;
  	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        int N = RInt();
        var list = new List<int>();
        list.Add(2);
        int num = 7;
        while (list.Count<N)
        {
            bool frag = true;
            for (int i = 2; i*i<=num; i++)
            {
                if (num % i == 0)
                {
                    frag = false;
                }
            }
            if (frag)
            {
                list.Add(num);
            }
            num += 5;
        }
        WriteLine(string.Join(" ",list));
    }
}

class Scanner
{
    public static int RInt() => int.Parse(Console.ReadLine());
    public static long RLong() => long.Parse(Console.ReadLine());
    public static string RString() => Console.ReadLine();
    public static double RDouble() => double.Parse(Console.ReadLine());

    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static string[] RStrings() => Console.ReadLine().Split();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static T1 ReadStream<T1>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadStream<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadStream<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadStream<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}

Measured memory_bytes: 27748
import java.util.Scanner;

public class Main {

	private static int[] first = new int[6];
	private static int[] second = new int[6];

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		for(int i = 0; i < 6; i++){
			first[i] = scan.nextInt();
		}
		for(int i = 0; i < 6; i++){
			second[i] = scan.nextInt();
		}

		for(int i = 0; i < 6; i++){
			if(first[0] == second[i]){
				action0(i);
				/*System.out.println("-----------action0-----------");
				System.out.println(first[0] + " " + first[1] + " " + first[2]
						+ " " + first[3] + " " + first[4] + " " + first[5]);
				System.out.println(second[0] + " " + second[1] + " " + second[2] + " "
						+ second[3] + " " + second[4] + " " + second[5]);*/
				if(first[5] == second[5]){
					for(int j = 1; j <= 4; j++){
						if(first[1] == second[j]){
							action1(j);
							/*System.out.println("-----------action1-----------");
							System.out.println(first[0] + " " + first[1] + " " + first[2]
									+ " " + first[3] + " " + first[4] + " " + first[5]);
							System.out.println(second[0] + " " + second[1] + " " + second[2] + " "
									+ second[3] + " " + second[4] + " " + second[5]);*/
							if(first[3] == second[4]){
								int intTemp = second[4];
								second[4] = second[3];
								second[3] = intTemp;
							}
						}
					}
				}
			}
		}
		if(check()){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		scan.close();
	}
	static void action0(int i){
		int intTemp;
		switch(i){
		case 1:
			intTemp = second[0];
			second[0] = second[1];
			second[1] = second[5];
			second[5] = second[4];
			second[4] = intTemp;
			break;
		case 2:
			intTemp = second[0];
			second[0] = second[2];
			second[2] = second[5];
			second[5] = second[3];
			second[3] = intTemp;
			break;
		case 3:
			intTemp = second[0];
			second[0] = second[3];
			second[3] = second[5];
			second[5] = second[2];
			second[2] = intTemp;
			break;
		case 4:
			intTemp = second[0];
			second[0] = second[4];
			second[4] = second[5];
			second[5] = second[1];
			second[1] = intTemp;
			break;
		case 5:
			intTemp = second[0];
			second[0] = second[5];
			second[5] = intTemp;
			intTemp = second[1];
			second[1] = second[4];
			second[4] = intTemp;
			break;
		default:
			break;
		}
	}
	static void action1(int j){
		int intTemp;
		switch(j){
		case 2:
			intTemp = second[1];
			second[1] = second[2];
			second[2] = second[4];
			second[4] = second[3];
			second[4] = intTemp;
			break;
		case 3:
			intTemp = second[1];
			second[1] = second[3];
			second[3] = second[4];
			second[4] = second[2];
			second[2] = intTemp;
			break;
		case 4:
			intTemp = second[1];
			second[1] = second[4];
			second[4] = intTemp;
			intTemp = second[2];
			second[2] = second[3];
			second[3] = intTemp;
			break;
		default :
		}
	}

	static boolean check(){
		if(first[0] == second[0] && first[1] == second[1] && first[2] == second[2] && first[3] == second[3] && first[4] == second[4] && first[5] == second[5]){
			return true;
		}else{
			return false;
		}
	}
}

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

double eps = 1e-9;
double pi = acos(-1);

#define fast_io ios_base::sync_with_stdio(false); cin.tie(0);
#define ll long long
#define en "\n"
#define ff first
#define ss second
#define sp(x) fixed << setprecision(x)
#define VECT(v)  vector<int>v
#define SCAN(v)  int temp; for(int i=0; i<n; i++) {cin>>temp; v.push_back(temp);}
#define PRINT(v) for(int i = 0; i < v.size(); i++) cout << v[i] << " "; cout << en;
#define SORT(v)  sort(v.begin(), v.end());
#define RSORT(v) sort(v.begin(), v.end(), greater<>())
#define CASEP(v) cout<<"Case "<<tc<<": "<<v<<"\n"
#define DEBUG(v) cout << v << " "; cout << en;

int main(void)
{
	#ifndef ONLINE_JUDGE
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif

	fast_io

	string s;
	cin >> s;

	int cnt = 0;
	int ans = 0;

	for(int i = 0; i < s.size(); i++)
	{
		if(s[i] == 'R')
		{
			cnt++;
		}
		else
			cnt = 0;

		ans = max(ans, cnt);
	}
	cout << ans << en;

	return 0;
}

Measured memory_bytes: 3632
N = int(input())
h = list(map(int,input().split()))
h.append(0)

count=0
while 1:
  flag=0
  for i in range(N):
    if h[i]>0:
      h[i] -= 1
      flag = 1
      if h[i+1] == 0:
        count += 1
      else:
        pass
  if flag == 0:
    break
print(count)

Measured memory_bytes: 3060
n = int(input())
a = list(map(int,input().split()))
b = [0] * n
ans = []
for i in range(n-1, -1, -1):
    if i == n-1:
        b[i] = a[i]
    else:
        sm = sum(b[i::i+1])
        b[i] = abs(a[i] - (sm % 2))
    if b[i] == 1:
        ans.append(i+1)
print(len(ans))
print(' '.join(map(str,ans)))


Measured memory_bytes: 19892
#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 INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;



int main() {
  int n,m;
  cin >> n >> m;
  cout << (n==m?"Yes":"No");
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();    
        int N, M;
        {int[] a = r.ii(); N = a[0]; M = a[1];}
        HashSet<Integer> a = new HashSet<>();
        HashSet<Integer> b = new HashSet<>();
        for(int i = 0; i < M ; i++){
            int[] temp = r.ii();
            if(temp[0] == 1)
                b.add(temp[1]);
            else if(temp[1] == N)
                a.add(temp[0]);
        }
        a.retainAll(b);
        println(a.size() > 0 ? "POSSIBLE" : "IMPOSSIBLE");
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 64028
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  int r, s, p;
  cin >> r >> s >> p;
  string t;
  cin >> t;
  vector<char> my;
  my.push_back('L');
  int index;
  int ans = 0;
  for(int i = 0; i < n; ++i){
    if(i + 1 - k < 0) index = 0;
    else index = i + 1 - k;
    if(t[i] == 'r' && my[index] != 'p'){
      my.push_back('p');
      ans += p;
    }
    else if(t[i] == 's' && my[index] != 'r'){
      my.push_back('r');
      ans += r;
    }
    else if(t[i] == 'p' && my[index] != 's'){
      my.push_back('s');
      ans += s;
    }
    else my.push_back('L');
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int a = x1 - x2;
  int b = y1 - y2;

  int x3 = x2 + b;
  int y3 = y2 - a;
  int x4 = x3 + a;
  int y4 = y3 + b;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace C_ABC155
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            var lst = new List<string>();
            for (int i = 0; i < s[0]; i++)
            {
                string a = ReadLine();
                lst.Add(a);
            }
            StringComparer cmp = StringComparer.OrdinalIgnoreCase;

            lst.Sort(cmp);
            var cntlst = new List<int[]>();
            int cnt = 1;
            int maxcnt = 1;
            for (int i = 0; i < s[0] - 1; i++)
            {
                //    WriteLine("{0}, {1} ",lst[i],lst[i+1]);

                if (lst[i] != lst[i + 1] )
                {
                    int[] a = new int[2] { i, cnt };
                    cntlst.Add(a);
                    if (maxcnt < cnt) maxcnt = cnt;
                    cnt = 1;
                     if (i == s[0] - 2)
                    {
                        int[] b = new int[2] { i+1, cnt };
                        cntlst.Add(b);
                        if (maxcnt < cnt) maxcnt = cnt;
                        cnt = 1;
                    }                   
                }
                else
                {
                    cnt++;
                    if (i == s[0] - 2)
                    {
                        int[] a = new int[2] { i, cnt };
                        cntlst.Add(a);
                        if (maxcnt < cnt) maxcnt = cnt;
                        cnt = 1;
                    }
                }
            }
            int n = cntlst.Count();
            //WriteLine(maxcnt);
            for (int i = 0; i < n; i++)
            {
               // WriteLine("{0}, {1} ", cntlst[i][0], cntlst[i][1]);
                if (cntlst[i][1] == maxcnt)
                {
                    WriteLine(lst[cntlst[i][0]]);
                }
            }


        }
    }
}


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

#define mp make_pair
#define pb push_back
#define f first
#define s second

using namespace std;

typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
typedef map<int,int> mii;
typedef unordered_map<int,int> umii;
typedef queue<int> qi;



int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	
	string s; cin >> s;
	bool czy = true;
	int j = s.size()-1;
	for (int i = 0; i < s.size()/2; i ++) {
		if (s[i] != s[j]) {
			czy = false;
			break;
		}
		j --;
	}
	
	if (czy) {
		j = (s.size()-1)/2-1;
		bool xd = true;
		for (int i = 0; i < (s.size()-1)/4; i ++) {
			if (s[i] != s[j]) {
				xd = false;
				break;
			}
			j --;
		}
		
		j = s.size()-1;
		for (int i = (s.size()+3)/2-1; i < ((s.size()+3)/2-1 + s.size()-1)/2; i ++) {
			if (s[i] != s[j]) {
				xd = false;
				break;
			}
			j --;
		}
		
		if (xd) {
			cout << "Yes\n";
		}
		else {
			cout << "No\n";
		}
	}
	else {
		cout << "No\n";
	}
		
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

long long fact(int x);

int main(){
	int x;
	scanf("%d",&x);
	
	long long result;
	
	result = fact(x);
	
	printf("%lld\n",result);
	
	return 0;
}

long long fact(int x){
	if(x == 1) return 1;
	else return (x*fact(x-1))%1000000007;
}

Measured memory_bytes: 1664
N = int(input())
A = list(map(int,input().split()))
Q = int(input())

cnt_dict = {}


s = sum(A)

ans = 0

for item in A:
    if item not in cnt_dict:
        cnt_dict[item] = 0
    cnt_dict[item] += 1

for _ in range(Q):
    X,Y = map(int,input().split())

    if X not in cnt_dict:
        cnt_dict[X] = 0
    if Y not in cnt_dict:
        cnt_dict[Y] = 0

    s -= cnt_dict[X] * X
    s += cnt_dict[X] * Y

    cnt_dict[Y] += cnt_dict[X]
    cnt_dict[X] = 0


    print(s)





'''
#初期案　遅すぎ

N = int(input())
A = list(map(int,input().split()))
Q = int(input())



for i in range(Q):
    X,Y = map(int,input().split())

    ans = 0

    for j in range(N):
        if A[j] == X:
            ans += Y
            A[j] = Y
        else:
            ans += A[j]

    print(ans)

    '''


Measured memory_bytes: 23180
n = int(input())
*A, = map(int,  input().split())
 
ans = 0
for i in range(n):
    for j in range(n-1):
        if A[j+1] < A[j]:
            A[j], A[j+1] = A[j+1], A[j]
            ans += 1
print(*A)
print(ans)


Measured memory_bytes: 5608
/******************
*  Author: BD747  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

int n;
int a[105];
double ave;
double dif;
int ans;

int main(){

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		ave+=a[i];
	}
	ave/=((double)n);
	dif=1e9;
	for(int i=0;i<n;i++){
		if(abs(ave-a[i])<dif){
			ans=i;
			dif=abs(ave-a[i]);
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{
    ll N,K,S;
    cin >> N >> K >> S;
    ll tmp = 1;
    if(S==(ll)1e9) tmp = 1;
    else tmp = (ll)1e9;

    for (ll i=0; i<N-K; ++i)
    {
        cout << tmp << " ";
    }
    for (ll i=0; i<K; ++i)
    {
        cout << S << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; ++i)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define P pair<int, int>

class C{
  public:
    int now, cnt, num, stay_num;
    vector<int> v;
    C(){ now = 0; cnt = 0; stay_num = 0; }
};

int main() {
  int n, time;
  while(cin >>n >>time && n){
    vector<C> v(n);
    REP(i, n){
      int tmp;
      while(cin >>tmp && tmp) v[i].v.push_back(tmp);
      v[i].num = i;
    }

    int ans = 0, next = 0, last = 0;
    REP(t, time){
      bool stay_end = false;
      REP(i, n){
        //稼働中
        if(v[i].now % 2 == 0){
          v[i].cnt += 1;
          if(v[i].cnt >= v[i].v[ v[i].now ]){
            v[i].cnt = 0;
            v[i].now = (v[i].now + 1 >= v[i].v.size() ? 0 : v[i].now + 1);
            v[i].stay_num = last;
            last += 1;
          }
        }
        //待ち番号 == next
        else if(v[i].stay_num == next){
          v[i].cnt += 1;
          if(v[i].cnt >= v[i].v[ v[i].now ]){
            v[i].cnt = 0;
            v[i].now = (v[i].now + 1 >= v[i].v.size() ? 0 : v[i].now + 1);
            stay_end = true;
          }
        }
        //待ち番号 > next
        else{
          ans += 1;
        }
      }
      if(stay_end) next += 1;
    }
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 1240
//55
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int cs=0;
  for(int n,m;cin>>n>>m,n|m;){
    int p[20]={n};
    int c;
    for(c=0;p[m]==0;c++){
      int n[20]={};
      for(int i=0;i<19;i++){
	n[0]+=p[i]/2;
	n[i+1]+=p[i]/2;
	n[i]+=p[i]%2;
      }
      copy(n,n+m+1,p);
    }
    cout<<"Case "<<++cs<<": "<<c<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}

void solve(){
	int n, k;
	cin>>n>>k;
	map<int, int>m;
	multimap<int, int> mm;
	rep(i,0,n){
		int t;
		cin>>t;
		m[t]++;
	}
	for(auto it = m.begin(); it != m.end(); it++)
		mm.insert({it->y, it->x});
	int size = sz(m);
	auto it = mm.begin();
	int ans=0;
	while(size > k){
		size--;
		ans+= it->x;
		it++;
	}
	cout<<ans<<endl;

}
	
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
  t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 19072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
//int a[200005], b[200005];
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    int ans = 0;
    for ( int i = 28; i >= 0; i-- ) {
        rep(j, n) a[j] %= (1<<(i+1));
        rep(j, n) b[j] %= (1<<(i+1));
        int cnt = 0;
        sort(b.begin(), b.end());
        rep(j, n) {
//            int idx_lower2 = distance(b.begin(), lower_bound(b.begin(), b.end(), (1<<i)*2-a[j]));
//            int idx_lower1 = distance(b.begin(), lower_bound(b.begin(), b.end(), (1<<i)-a[j]));
//            int idx_lower4 = distance(b.begin(), lower_bound(b.begin(), b.end(), (1<<i)*4-a[j]));
//            int idx_lower3 = distance(b.begin(), lower_bound(b.begin(), b.end(), (1<<i)*3-a[j]));
//            cnt+=lower_bound(b.begin(), b.end(), (1<<i)*2-a[j])-lower_bound(b.begin(), b.end(), (1<<i)-a[j]);
//            cnt+=lower_bound(b.begin(), b.end(), (1<<i)*4-a[j])-lower_bound(b.begin(), b.end(), (1<<i)*3-a[j]);
            cnt+= distance(lower_bound(b.begin(), b.end(), (1<<i)*2-a[j]), lower_bound(b.begin(), b.end(), (1<<i)-a[j]));
            cnt+= distance(lower_bound(b.begin(), b.end(), (1<<i)*4-a[j]), lower_bound(b.begin(), b.end(), (1<<i)*3-a[j]));
        }
        if ( (cnt&1) ) ans += (1<<i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
l = list(map(int,input().split()))

def is_ok(n, su):
    return l[n] > su

def binary_search(left, right, su):
    while (abs(right - left) > 1):
        mid = (left + right) // 2
        if is_ok(mid, su):  right = mid
        else:  left = mid
    return right

l = sorted(l)
ans = 0
for i in range(2, N):
    for j in range(1, i):
        left = j
        right = -1
        ret = binary_search(right, left, l[i] - l[j])
        if ret != right:  ans += j - ret
print(ans)

Measured memory_bytes: 74200
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
 
int main(){
int a=read(),b=read();
if (a+b==15) puts("+");
else if (a*b==15) puts("*");
else puts("x");
}

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

int main(){
  int n;
  string s;
  set<string> pin;
  cin >> n >> s;
  
  int cnt = 0; set<char> tmp;
  for(int i=0;i<n;i++){ //mainloop
    if(!tmp.count(s.at(i))){ // 1st digit if
      tmp.insert(s.at(i));
      set<char>  tmp2;
      queue<pair<char,int>> q;
      for(int j=i+1;j<n;j++){//2nd digit
        if(!tmp2.count(s.at(j))){
          tmp2.insert(s.at(j)); q.push(make_pair(s.at(j),j));
        }
        if(q.size() >= 10) break;
      }//2nd digit
      while(!q.empty()){// 3rd digit and count
        char x = (q.front()).first; int from = (q.front()).second; q.pop();
        set<char> tmp3;
        for(int j=from+1;j<n;j++){
          if(!tmp3.count(s.at(j))){
            tmp3.insert(s.at(j)); cnt++;
          }
          if(tmp3.size() >= 10) break;
        }
      }// 3rd digit and count
    }// 1st digit if
    if(tmp.size() >= 10) break;
  }//main loop
  cout << cnt << endl;
}

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

#define rep(X, N) for (ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(), (V).end()
#define endl "\n"

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;


int main(){

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr<<#n<<" = "<<n<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using pint = pair<int,int>;

const int INF = (1 << 30);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    set<char> have;
    rep(i,s.size()){
        have.insert(s[i]);
    }

    char n='a';
    if(s.size()==26){
        if(s=="zyxwvutsrqponmlkjihgfedcba"){
            cout<<-1<<endl;
            return 0;
        }
        
        REV(i,0,s.size()-1){
            n=s[i];
            for(;islower(n);n++){
                if(have.find(n)==have.end()){
                    s[i]=n;
                    rep(j,i+1){
                        cout<<s[j];
                    }cout<<endl;
                    return 0;
                }
            }
            have.erase(s[i]);
        }

    }else{
        rep(i, 26){
            if(have.find(n)==have.end()){
                cout<<s<<n<<endl;
                return 0;
            }
            n++;
        }
    }

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <cmath>
using namespace std;


int main() {
    string a, b;
    cin >> a >> b;
    double num = stoi(a + b);
    num = sqrt(num);
    if (num == (int)num) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
typedef long long llong;
using namespace std;

int main(){
	int n;
	cin>>n;
	
	vector<vector<int> > vac(n,vector<int>(3));
	REP(i,n){
		REP(j,3) cin>>vac[i][j];
	}
	
	vector<vector<int> > dp(n,vector<int>(3,-INF));
	REP(i,3) dp[0][i]=vac[0][i];
	for(int i=1;i<n;++i){
		REP(j,3){
			REP(k,3){
				if(j==k) continue;
				dp[i][j]=max(dp[i-1][k]+vac[i][j],dp[i][j]);
			}
		}
	}
	
	int ans=dp[n-1][0];
	for(int i=1;i<3;++i) ans=max(dp[n-1][i],ans);
	
	cout<<ans<<endl;
	return 0;
}//解答参考.

Measured memory_bytes: 11136
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    int N,A,B,C,D; cin>>N>>A>>B>>C>>D;
    vector<char>s(N);
    rep(i,N)cin>>s[i];
    bool judge =true;
    if(C<D){
        for(int i=A;i<D-2;i++){
            if(s[i]=='#'&&s[i+1]=='#'){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    else {
        for(int i=B;i<D+1;i++){
            if(s[i-2]=='.'&&s[i-1]=='.'&&s[i]=='.')judge=false;
        }
        if(judge){
            cout<<"No"<<endl;
            return 0;
        }
        for(int i=A;i<C-2;i++){
            if(s[i]=='#'&&s[i+1]=='#'){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
#ABC124 C

s = list(map(int,list(input())))
n = len(s)
ans1 = 0
ans2 = 0
for i in range(n):
    if i % 2 == 0:
        if s[i] != 1:
            ans1 += 1
    else:
        if s[i] != 0:
            ans1 += 1
for i in range(n):
    if i % 2 == 0:
        if s[i] != 0:
            ans2 += 1
    else:
        if s[i] != 1:
            ans2 += 1
print(min(ans1,ans2))


Measured memory_bytes: 49616
n = gets.to_i

m = gets.to_i
roads = (1..m).map {
    i, j, c1, c2 = gets.split(",").map(&:to_i)
    [i-1, j-1, c1, c2] 
}

s, t, given, price = gets.split(",").map(&:to_i)
s -= 1
t -= 1

cost = [Float::INFINITY] * n 
cost[s] = 0 
(n-1).times {
    roads.each{|i, j, c1, c2|
        cost[j] = [cost[j], cost[i] + c1].min
        cost[i] = [cost[i], cost[j] + c2].min
    }   
}
outward_cost = cost[t]

cost = [Float::INFINITY] * n 
cost[t] = 0 
(n-1).times {
    roads.each{|i, j, c1, c2|
        cost[j] = [cost[j], cost[i] + c1].min
        cost[i] = [cost[i], cost[j] + c2].min
    }   
}
homeward_cost = cost[s]

p given - outward_cost - price - homeward_cost

Measured memory_bytes: 6112