akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c, d, e, f, g, h, i; cin >> a >> b >> c >> d >> e >> f >> g >> h >> i;
	if ((d - a == e - b) && (e - b == f - c)) {
		if ((g - d == h - e) && (h - e == i - f)) {
			cout << "Yes" << endl; return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



void solve()
{
    int n;
    scanf("%d", &n);
    vector<int> x(n), y(n);
    int xmin = INF, xmax = -INF;
    int ymin = INF, ymax = -INF;
    int i;
    for (i = 0; i < n; i++) {
        scanf("%d%d", &x[i], &y[i]);
        if (x[i] > y[i]) swap(x[i], y[i]);
        xmin = MIN(xmin, x[i]);
        xmax = MAX(xmax, x[i]);
        ymin = MIN(ymin, y[i]);
        ymax = MAX(ymax, y[i]);
    }

    ll ans = ((ll)xmax - xmin)*((ll)ymax - ymin);

    vector<pair<int, int> > z;
    for (i = 0; i < n; i++) {
        z.push_back(make_pair(x[i], y[i]));
    }
    sort(z.begin(), z.end());

    vector<int> ymin0(n), ymax0(n);
    for (i = 0; i < n; i++) {
        if (i == 0) {
            ymin0[i] = ymax0[i] = z[i].second;
        }
        else {
            ymin0[i] = MIN(ymin0[i - 1], z[i].second);
            ymax0[i] = MAX(ymax0[i - 1], z[i].second);
        }
    }

    vector<int> xmin0(n), xmax0(n);
    for (i = n-1; i >= 0; i--) {
        if (i == n-1) {
            xmin0[i] = xmax0[i] = z[i].first;
        }
        else {
            xmin0[i] = MIN(xmin0[i + 1], z[i].first);
            xmax0[i] = MAX(xmax0[i + 1], z[i].first);
        }
    }

    for (i = 0; i < n-1; i++) {
        int min = MIN(ymin0[i], xmin0[i + 1]);
        int max = MAX(ymax0[i], xmax0[i + 1]);
        ll tmp = ((ll)ymax-xmin)*((ll)max - min);
        ans = MIN(ans, tmp);
    }

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

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define ind(a) scanf("%d", &a)
#define inlld(a) scanf("%lld", &a)
#define ind2(a, b) scanf("%d%d", &a, &b)
#define inlld2(a, b) scanf("%lld%lld", &a, &b)
#define ind3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define inlld3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

using namespace std;

const int N=105;
const int NN=1e5+5;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

ll n, w, arr[N][2], dp[N][NN];

ll solve(ll i, ll j)
{
    if(j>w)
        return -1e18;
    if(i==n+1)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    return dp[i][j]=max(solve(i+1, j+arr[i][0])+arr[i][1], solve(i+1, j));
}

int main() 
{
    inlld2(n, w);
    for(ll a=1; a<=n; a++)
        inlld2(arr[a][0], arr[a][1]);
    memset(dp, -1, sizeof(dp));
    printf("%lld\n", solve(1, 0));
    return 0;
}

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

using namespace std;

int N, M;
int p[100000];
int uf[100000];

inline int root(int x) {
	if (x != uf[x]) return uf[x] = root(uf[x]);
	return x;
}

inline void unite(int x, int y)
{
	x = root(x);
	y = root(y);
	if (x == y) return;
	uf[y] = x;
}


int main()
{
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> p[i];
		p[i]--;
	}
	for (int i = 0; i < N; i++) uf[i] = i;
	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		x--;y--;
		unite(x, y);
	}
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (root(i) == root(p[i])) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

using namespace std;

int main(void)
{
  string str;
  cin >> str;

  for(int i = 0; i < str.size(); i++){
    string s;
    if(str[i] == 'A') s = "T";
    else if(str[i] == 'C') s = "G";
    else if(str[i] == 'G') s = "C";
    else if(str[i] == 'T') s = "A";
    cout << s;
  }
  cout << endl;
}


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

ifstream in ( "test.in"  );
ofstream out( "test.out" );

deque<int> que;

int main() {
    
    int n;
    cin >> n;
    
    for( int i = 1; i <= n; i ++ ) {
        int x;
        cin >> x;
        
        if( i % 2 == 0 )
            que.push_back( x );
        else
            que.push_front( x );
    }
    
    if( n % 2 == 0 )
        reverse( que.begin(), que.end() );
    
    for( int x : que )
        cout << x << " ";
    
    return 0;
}


Measured memory_bytes: 2944
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

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

	long res = count(S.begin(), next(S.begin(),6), '1');

	cout << res << endl;

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] A = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
        }
        long current = A[0];
        long ans = 0;
        for (int i = 1; i < N; i++) {
            if (A[i] < current) {
                ans += current - A[i];
                continue;
            }
            current = A[i];
        }
        System.out.println(ans);

    }
}


Measured memory_bytes: 60936
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;
#pragma unused(M)

int n;
vector<int> as;
bool solve(){
	if((as.back() % 2 == 1 && as.size() > 2 && as[0] == as[2]) ||
			(as.back() % 2 == 0 && as.size() > 1 && as[0] == as[1])){
		return false;
	}
	int idx = 0;
	while(idx < as.size() && as[0] == as[idx]) idx++;
	if(idx == as.size()){
		return true;
	}
	int num = as[idx], cnt = 1;
	for(int i=idx + 1;i<n;i++){
		if(as[i] == num){
			cnt++;
		}else if(cnt == 1){
			return false;
		}else if(num != as[i] - 1){
			return false;
		}else{
			num = as[i];
			cnt = 1;
		}
	}
	if(cnt == 1){
		return false;
	}
	return true;
}

int main(){
	cin >> n;
	as.resize(n);
	for(int i=0;i<n;i++){
		cin >> as[i];
	}
	sort(as.begin(), as.end());
	if(solve()){
		cout << "Possible" << endl;
	}else{
		cout << "Impossible" << endl;
	}
	return 0;
}



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

#define INF 9999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int>pi;

/*---------------------------------------------------*/

int main(){
  int n,cnt=0;
  int a[110];
  int color[8]={0};
  cin>>n;
  rep(i,n)cin>>a[i];
  rep(i,n){
    if(1<=a[i]&&a[i]<=399)color[0]=1;
    else if(400<=a[i]&&a[i]<=799)color[1]=1;
    else if(800<=a[i]&&a[i]<=1199)color[2]=1;
    else if(1200<=a[i]&&a[i]<=1599)color[3]=1;
    else if(1600<=a[i]&&a[i]<=1999)color[4]=1;
    else if(2000<=a[i]&&a[i]<=2399)color[5]=1;
    else if(2400<=a[i]&&a[i]<=2799)color[6]=1;
    else if(2800<=a[i]&&a[i]<=3199)color[7]=1;
    else if(3200<=a[i])cnt++;
   }
  int sum=0;
  rep(i,8)if(color[i]==1)sum++;
  if(sum==0){a[0]=1;cnt--;sum++;}
  cout<<sum<<" "<<sum+cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
n, limit = map(int, sys.stdin.readline().split()) 
L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]

dp = [dict() for i in range(n)]
#print(dp)
dp[0][L[0][1]] = L[0][0]

for i in range(1, n):
    dp[i][L[i][1]] = min(L[i][0], dp[i-1].get(L[i][1], float('inf')))
    for v, w in dp[i-1].items():
        dp[i][v] = min(dp[i-1][v], dp[i].get(v, float('inf')))
        dp[i][L[i][1] + v] = min(L[i][0] + dp[i-1][v], dp[i-1].get(L[i][1] + v, float('inf'))) 
        
ans = 0
for v, w in dp[-1].items():
    if w <=limit:
        if ans < v:
            ans = v
#print(dp)
print(ans)

Measured memory_bytes: 291720
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int k;
	cin>>k;
	int h[100005];
	for(int i=0;i<n;i++)
		cin>>h[i];
	long long dp[100005];
	dp[n-1] = 0;
	for(int i=n-2;i>=0;i--)
	{
		dp[i] = 10e9;
		for(int j = 1;j<=k && j+i < n;j++)
			dp[i] = min(dp[i],dp[i+j]+abs(h[i+j]-h[i]));
		
	}
	cout<<dp[0];
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll n,cnt=0,mx=0,mn=1e9+7,ans=1e9+7; cin>>n;
	vector<ll> arr(n);
	for(auto i=0;i<n;++i){cin>>arr[i]; mx=max(mx,arr[i]); mn=min(mn,arr[i]);}
	for(auto j=mn;j<=mx;++j){
		cnt=0;
		for(auto i=0;i<n;++i){
			cnt+=(abs(j-arr[i])*abs(j-arr[i]));
		}
		ans=min(ans,cnt);
	}
	cout<<ans<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
ans = 0
t = (n - 1) * (n - 2) // 2
for k, v in c.items():
    ans += v * (v - 1) // 2
for y in a:
    x = c[y]
    print(ans - x * (x - 1) // 2 + (x - 1) * (x - 2) // 2)


Measured memory_bytes: 87884
//#pragma warning disable

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

public class ModuloInt
{
    readonly long _n;
    readonly long _mod;

    public ModuloInt(long n, long mod)
    {
        _n = n % mod;
        _mod = mod;
    }

    public long ToInt64()
    {
        return _n;
    }

    public static ModuloInt operator +(ModuloInt x, long y) { return new ModuloInt(x._n + y, x._mod); }
    public static ModuloInt operator +(long x, ModuloInt y) { return new ModuloInt(x + y._n, y._mod); }
    public static ModuloInt operator +(ModuloInt x, ModuloInt y)
    {
        if (x._mod != y._mod) { throw new Exception(); }
        return new ModuloInt(x._n + y._n, x._mod);
    }
    public static ModuloInt operator -(ModuloInt x, long y) { return new ModuloInt(x._n - y, x._mod); }
    public static ModuloInt operator -(long x, ModuloInt y) { return new ModuloInt(x - y._n, y._mod); }
    public static ModuloInt operator -(ModuloInt x, ModuloInt y)
    {
        if (x._mod != y._mod) { throw new Exception(); }
        return new ModuloInt(x._n - y._n, x._mod);
    }
    public static ModuloInt operator *(ModuloInt x, long y) { return new ModuloInt(x._n * y, x._mod); }
    public static ModuloInt operator *(long x, ModuloInt y) { return new ModuloInt(x * y._n, y._mod); }
    public static ModuloInt operator *(ModuloInt x, ModuloInt y)
    {
        if (x._mod != y._mod) { throw new Exception(); }
        return new ModuloInt(x._n * y._n, x._mod);
    }
}

public class Test
{
    public static void Main()
    {
        var N = long.Parse(Console.ReadLine());

        var factors = new int[N + 1];  // factors[i] は i の約数の数 (ただし i >= 2)

        for (int i = 2; i <= N; i++)
        {
            // i を素因数分解する
            int num = i;
            for (int j = 2; num != 1; j++)
            {
                while (num % j == 0)
                {
                    factors[j]++;
                    num /= j;
                }
            }
        }

        //Console.WriteLine(string.Join(",", factors));

        var result = new ModuloInt(1, (long)Math.Pow(10, 9) + 7);

        foreach (var factor in factors)
        {
            result *= (factor + 1);  // 素因数を0個または1個または・・・factor個選ぶことができるので、factor+1通り。
        }

        Console.WriteLine(result.ToInt64());
    }
}

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

int main( ){
  int a[127] = {};
  char x;
  while( cin >> x ){
    if(isalpha(x))a[(int)x]++;
  }
  for(int j=97;j<123;j++){
    cout<<(char)j<<" : "<<a[j-32]+a[j]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3084
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
#from fractions import gcd
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

X, Y, Z = map(int, input().split())

print(Z, X, Y)




Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define pb push_back
#define S second
#define F first

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
int cnt[maxn];
int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1;i <= n;i++){
        int a;
        cin >> a;
        cnt[a]++;
    }
    int answer = 1;
    for (int i = n - 1;i > 0;i-= 2){
       // cout << i << ' ' << cnt[i] << endl;
        if (cnt[i] != 2){
            cout << 0 << endl;
            return 0;
        }
        answer *= 2;
        answer %= mod;
    }
    cout << answer << endl;

}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int num[30];

int main()
{
	string str;cin >> str;
	
	REP(i,str.size())
	{
		num[str[i]-'a']++;
	}
	
	REP(i,26)
	{
		if(num[i] == 0)
		{
			char ans = 'a'+i;
			cout << ans << endl;
			return 0;
		}
	}
	
	cout << "None" << endl;
	
	
	return 0;
}

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

using namespace std;
#define maxN 1000001

bool d[maxN] = {false};
vector<int> pr;

void Sieve()
{
    for (int i = 2; i <= 1000; ++i)
        if (d[i] == false)
            for (int j = i; i*j < maxN; ++j)
                d[i*j] = true;
    for (int i = 2; i < maxN; ++i)
        if (d[i] == false) pr.push_back(i);
}

bool checkPrime(int n)
{
    if (n < 2) return false;
    if (n < maxN) return (d[n]==false);
    for (int i = 0; i < pr.size() && pr[i]*pr[i] <= n; ++i)
        if (n % pr[i] == 0) return false;
    return true;
}

int main()
{
    Sieve();
    int n, x, res = 0;
    cin>>n;
    for (int i = 0; i < n; ++i)
    {
        cin>>x;
        if (checkPrime(x)) res++;
    }
    cout<<res<<"\n";
    return 0;
}

Measured memory_bytes: 4280
Imports System

Module Program
    Sub Main(args As String())
        Dim tmpA As String() = Split(Console.ReadLine(), " ")

        Dim zeigaku8 As Long = CLng(tmpA(0))
        Dim hontai8A As Long = Math.Ceiling(zeigaku8 / 0.08)
        Dim hontai8B As Long = Math.Floor((zeigaku8 + 1) / 0.08)

        If hontai8B = ((zeigaku8 + 1) / 0.08) Then
            hontai8B = hontai8B - 1
        End If

        Dim zeigaku10 As Long = CLng(tmpA(1))
        Dim hontai10A As Long = zeigaku10 / 0.1
        Dim hontai10B As Long = (zeigaku10 + 1) / 0.1 - 1

        Dim i As Long = 0
        For i = hontai10A To hontai10B
            If hontai8A <= i Then
                If i <= hontai8B Then
                    Console.WriteLine(i)
                    Exit Sub
                End If
            End If
        Next

        Console.WriteLine(-1)
    End Sub
End Module


Measured memory_bytes: 13536
#include <bits/stdc++.h>
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> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

int main(void){
    ll s; cin >> s;
    VI done(1000000,0);
    ll prev = s;
    ll m=1;
    while(1){
        m++;
        done[prev] = 1;
        if(prev%2) prev = 3*prev+1;
        else prev = prev/2;
        if(done[prev]){
            cout << m << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;cin>>N;
	double X[N];string U[N];
	double count=0;
	for(int i=0;i<N;i++){
		cin>>X[i]>>U[i];
		if(U[i]=="BTC"){
			X[i]*=380000;
		}count+=X[i];
	}cout<<count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
int A,B;
cin>>A>>B;
int sum, sub, mult;
sum=A+B;
sub=A-B;
mult=A*B;
if(sum>=sub && sum>=mult)
    cout<<sum<<endl;
else if(sub >=sum && sub>=mult)
    cout<<sub<<endl;
else
    cout<< mult<<endl;
return 0;
}



Measured memory_bytes: 256
#上下左右に#が全て隣接しているならOK

N, M = map(int, input().split())
#print(N)
c = 0
l = []
for i in range(N):
  l.append(list(input()))
  
#print(l)
N -= 1
M -= 1

for i in range(N):
  for j in range(M):
    if l[i][j] == ".":
      pass
    else:
      if i-1>=0 and i+1<=N and j-1>=0 and j+1<=M and l[i-1][j] == "." and l[i+1][j] == "." and l[i][j-1] == "." and l[i][j+1] == ".":
        c+=1
      if i==0 and j-1>=0 and j+1<=M and l[i+1][j] == "." and l[i][j-1] == "." and l[i][j+1] == ".":
        c+=1
      if i-1>=0 and i+1<=N and j==0 and l[i-1][j] == "." and l[i+1][j] == "." and l[i][j+1] == ".":
        c+=1
      if i==N and j-1>=0 and j+1<=M and l[i-1][j] == "." and l[i][j-1] == "." and l[i][j+1] == ".":
        c+=1
      if i-1>=0 and i+1<=N and j-1>=0 and j==M and l[i-1][j] == "." and l[i+1][j] == "." and l[i][j-1] == ".":
        c+=1
      if i==0 and j==0 and l[i+1][j] == "." and l[i][j+1] == ".":
        c+=1
      if i==0 and j==M and l[i+1][j] == "." and l[i][j-1] == ".":
        c+=1
      if i==N and j==0 and l[i-1][j] == "." and l[i][j+1] == ".":
        c+=1
      if i==N and j==M and l[i-1][j] == "." and l[i][j-1] == ".":
        c+=1

if c == 0:
  print("Yes")
else:
  print("No")

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

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

  int ans = 0;
  int m = n + 1;
  for (int i = 0; i < n; i++) {
    m = min(p[i], m);
    if (m == p[i]) ans++;
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 1024
// C - Synthetic Kadomatsu

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int N, A, B, C;
int ans = INF;

void calc(vector<int>l, int mp) {
	int n = l.size();
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			if (j == i) continue;
			for (int k=0; k<n; k++) {
				if (k == i || k == j) continue;

				ans = min(ans, mp + abs(l[i] - A) + abs(l[j] - B) + abs(l[k] - C));
			}
		}
	}
}

void solve(vector<int> l, int mp) {
	int n = l.size();

	/*
	// **** debug ****
	for (int i=0; i<n; i++) {
		cout << l[i] << " ";
	}
	cout << "mp=" << mp << endl;
	*/

	calc(l, mp);

	if (n <= 3) return;

	for (int i=0; i<n; i++) {
		for (int j=i+1; j<n; j++) {
			vector<int> nl;
			for (int k=0; k<i; k++) {
				nl.push_back(l[k]);
			}

			for (int k=i+1; k<n; k++) {
				if (k == j) nl.push_back(l[k] + l[i]);
				else nl.push_back(l[k]);
			}

			solve(nl, mp + 10);
		}
	}

}

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

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

	solve(l, 0);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3644
for i in range(100000):
    H,W=input().split()
    if H=="0" and W =="0":
        break
    t=""
    s=""
    for j in range(int(W)):
        if j%2==0:
            s+="#"
            t+="."
        else:
            s+="."
            t+="#"
    for k in range(int(H)):
        if k%2==0:
            print(s)
        else:
            print(t)
    print("")



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

using namespace std;
using ll = long long;
using ld = long double;

ld dp[4000][4000];

int main() {
    ios_base::sync_with_stdio(0);
    cout.tie(0); cin.tie(0);
    cout.precision(20); cout << fixed;
    int n;
    cin >> n;
    vector<ld> p(n);
    for (ld &e : p) {
        cin >> e;
    }
    dp[0][0] = 1 - p[0];
    dp[0][1] = p[0];
    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= n; j++) {
            dp[i][j] = dp[i - 1][j] * (1 - p[i]) + (j != 0 ? dp[i - 1][j - 1] : 0) * p[i];
        }
    }
    ld sum = 0;
    for (int i = n / 2 + 1; i <= n; i++) {
        sum += dp[n - 1][i];
    }
    cout << sum;
}


Measured memory_bytes: 188288
import sys
sys.setrecursionlimit(200000)

n,w = (int(x) for x in input().split())
a = [tuple(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w+1) for _ in range(n+1)]

def rec(i, j):
  if dp[i][j] != 0:
    return dp[i][j]
  if i == n:
    res = 0
  elif j < a[i][0]:
    res = rec(i+1, j)
  else:
    res = max(rec(i+1, j), rec(i+1, j - a[i][0]) + a[i][1])
  dp[i][j] = res
  return dp[i][j]

print(int(rec(0, w)))


Measured memory_bytes: 126040
def main():
    n = int(input())
    if n ==1:
        print(1)
        exit()
    x_y_list = []
    p_q_dic = {}
    for i in range(n):
        x,y = map(int,input().split(' '))
        x_y_list.append((x,y))
    for i in range(n):
        x_i = x_y_list[i][0]
        y_i = x_y_list[i][1]
        for j in range(n):
            if i == j:
                continue
            x_j = x_y_list[j][0]
            y_j = x_y_list[j][1]
            p = x_j - x_i
            q = y_j - y_i
            if (p !=0 or q !=0) and (p,q) in p_q_dic:
                p_q_dic[(p,q)] += 1
            elif p != 0 or q != 0:
                p_q_dic[(p,q)] = 1
    p_q_sorted = sorted(p_q_dic.values(),reverse=True)
    print(n-p_q_sorted[0])

main()


Measured memory_bytes: 3444
#include <stdio.h>

int main() {
  int n;
  scanf("%d",&n);
  int a[n],i,j;
  for(i=0; i<n; i++) scanf("%d",&a[i]);

  for(i=0; i<n; i++) {
    for(j=i-1; j>=0; j--) {
      if(a[j]>a[j+1]) {
	int tmp=a[j];
	a[j]=a[j+1];
	a[j+1]=tmp;
      } else break;
    }
    for(j=0; j<n; j++) {
      if(j) printf(" ");
      printf("%d",a[j]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 604
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void)
{
char S[100];
long N, index;
long isTsuyoiKaibun = 1;
  
  scanf("%s", &S);
  N = strlen(S);
  
  for (index = 0; index < N/2; ++index) {
    if (S[index] != S[N-index-1] || S[index] != S[(N/2)-index - 1]) {
      isTsuyoiKaibun = 0;
      break;
    }
  }
  
  if (isTsuyoiKaibun == 1) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
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 ll LINF = 1001002003004005006ll;

ll a, b, c, d;
map<ll, ll> mem;

ll f(ll x){
	if(!x) return 0;
	if(mem.count(x)) return mem[x];
	ll res = LINF;
	if(LINF/d > x) res = x * d;
	auto f2 = [&](ll y){
		if(y >= x) return LINF;
		return f(y);
	};
	{
		ll l = x/2*2, r = l+2;
		chmin(res, f2(l/2)+a+(x-l)*d);
		chmin(res, f2(r/2)+a+(r-x)*d);
	}
	{
		ll l = x/3*3, r = l+3;
		chmin(res, f2(l/3)+b+(x-l)*d);
		chmin(res, f2(r/3)+b+(r-x)*d);
	}
	{
		ll l = x/5*5, r = l+5;
		chmin(res, f2(l/5)+c+(x-l)*d);
		chmin(res, f2(r/5)+c+(r-x)*d);
	}
	return mem[x] = res;
}

void solve(){
	ll n;
	cin >> n >> a >> b >> c >> d;
	mem = map<ll,ll>();
	cout << f(n) << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int ts;
	cin >> ts;
	rep(ti,ts) solve();
	return 0;
}

Measured memory_bytes: 4828
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int rot[24][6] = {
    {0,1,2,3,4,5}, {0,2,4,1,3,5}, {0,4,3,2,1,5}, {0,3,1,4,2,5},
    {1,5,2,3,0,4}, {1,2,0,5,3,4}, {1,0,3,2,5,4}, {1,3,5,0,2,4},
    {2,5,4,1,0,3}, {2,4,0,5,1,3}, {2,0,1,4,5,3}, {2,1,5,0,4,3},
    {3,4,5,0,1,2}, {3,5,1,4,0,2}, {3,1,0,5,4,2}, {3,0,4,1,5,2},
    {4,0,2,3,5,1}, {4,2,5,0,3,1}, {4,5,3,2,0,1}, {4,3,0,5,2,1},
    {5,4,2,3,1,0}, {5,2,1,4,3,0}, {5,1,3,2,4,0}, {5,3,4,1,2,0}
};

int main() {
    int n;
    while (cin >> n, n) {
        vector<vector<string> > work;
        for (int i=0; i<n; ++i) {
            vector<string> v(6);
            for (int j=0; j<6; ++j) {
                cin >> v[j];
            }
            work.push_back(v);
        }
        int res = 0;
        for (int i=0; i<n; ++i) {
            bool ok = true;
            for (int j=i+1; j<n && ok; ++j) {
                for (int k=0; k<24 && ok; ++k) {
                    if (work[i][0] == work[j][rot[k][0]] &&
                        work[i][1] == work[j][rot[k][1]] &&
                        work[i][2] == work[j][rot[k][2]] &&
                        work[i][3] == work[j][rot[k][3]] &&
                        work[i][4] == work[j][rot[k][4]] &&
                        work[i][5] == work[j][rot[k][5]]) {
                        ok = false;
                    }
                }
            }
            if ( ! ok) ++res;
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1236
#include <stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  
  if(100 <= n && n <= 111) printf("111");
  if(111 < n && n <= 222) printf("222");
  if(222 < n && n <= 333) printf("333");
  if(333 < n && n <= 444) printf("444");
  if(444 < n && n <= 555) printf("555");
  if(555 < n && n <= 666) printf("666");
  if(666 < n && n <= 777) printf("777");
  if(777 < n && n <= 888) printf("888");
  if(888 < n && n <= 999) printf("999");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    ll N, D; cin >> N >> D;
    int ans = 0;
    REP(i, 0, N) {
        ll x, y; cin >> x >> y;
        if (D * D >= x * x + y * y) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
n, m = map(int,input().split())
ab = []
for i in range(n):
    ab.append(list(map(int,input().split())))

ab = sorted(ab, key=lambda x:(x[0], x[1]))

cost = 0
while m > 0:
    a, b = ab.pop(0)
    if b > m:
        cost += m * a
        m = 0
    else:
        cost += b * a
        m -= b
print(cost)

Measured memory_bytes: 35600
import itertools
import bisect
N = int(input())
L = list(map(int, input().split()))
ans = 0
LS = sorted(L)
l = len(LS)
for i in range(l):
  for j in range(l):
    if i < j:
      k = bisect.bisect_left(LS,LS[i]+LS[j])
      ans += k-j-1
print(ans)


Measured memory_bytes: 74348
import sys
input = sys.stdin.readline

def main():
    k , s = map( int , input().split() )

    ans = 0

    for i in range( k + 1 ):
        if i > s:
            break
        if s - i > 2 * k:
            continue
        for j in range( k + 1 ):
            if i + j > s:
                break
            if s - i - j > k:
                continue
            ans += 1

    print( ans )




main()

Measured memory_bytes: 9180
# include <bits/stdc++.h>
# define ll long long int
# define pb push_back
# define pf push_front
# define mpi make_pair
# define pi pair<ll,ll>
# define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
# define mod 1000000007
# define endl "\n"
using namespace std;
int main()
{
  fast
  ll n,a[25],b[25],c[25],ans=0,check;
  c[0]=0;
  cin>>n;
  for(ll i=1;i<=n;i++)
  {
    cin>>a[i];
  }
  for(ll i=1;i<=n;i++)
  {
    cin>>b[i];
  }
  for(ll i=1;i<=n-1;i++)
  {
    cin>>c[i];
  }
  ans+=b[a[1]];
  check=a[1];
  for(ll i=2;i<=n;i++)
  {
    if(a[i]==check+1)
    {
    ans+=b[a[i]]+c[a[i]-1];
    }
    else
    {
      ans+=b[a[i]];
    }
    check=a[i];
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 508
void main()
{
    long n = readln.chomp.to!long;

    long x = 1, y = 1;
    foreach (i; 0 .. n)
    {
        long[] tmp = readln.split.to!(long[]);
        long t = tmp[0], a = tmp[1];

        long m = max((x+t-1)/t, (y+a-1)/a);
        x = m * t, y = m * a;
    }

    writeln(x + y);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

using namespace std;

const int maxn = 200000 + 5;
int n, m;
int vis[maxn];
int u[maxn], v[maxn];
int main() {
    int flag = 0;
    scanf("%d%d", &n, &m);
    for(int i = 0; i < m; i++) {
        scanf("%d%d", &u[i], &v[i]);
        if(u[i] == 1) vis[v[i]] = 1;
    }
    for(int i = 0; i < m; i++) {
        if(v[i] == n && vis[u[i]]) flag = 1;
    }
    if(flag) printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,ta,ao;
  cin>>a>>b>>c>>d;
  ta=(c-1)/b;
  ao=(a-1)/d;
  if(ta<=ao){
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3612
N = int(input())
li = list(map(int,input().split()))
li2 = []
key =[0] #key ０でおｋ　１で1下げ
cnt = 0
flg = True
if N == 1:
    ans ="Yes"
    flg = False
while flg :
    cur1 = li[cnt]
    cur2 = li[cnt+1]
    sa = cur2 - cur1
    if key[cnt] == 0:
        if sa < -1:
            ans = "No"
            flg = False
        elif sa == -1:
            key.append(1)
            cnt += 1
        else:
            key.append(0)
            cnt += 1
    else:
        if sa < 0:
            ans = "No"
            flg = False
        elif sa == 0:
            key.append(1)
            cnt += 1
        else:
            key.append(0)
            cnt += 1
    if cnt == len(li)-1:
        ans = "Yes"
        flg = False
print(ans)

Measured memory_bytes: 14480
#include <stdio.h>

int main(void)
{
	char top[11];
	int num[10];
	int i;
	
	while (scanf("%s", top) != EOF){
		for (i = 0; i < 10; i++){
			num[i] = top[i] - '0';
		}
		for (i = 0; i < 9; i++){
			int j;
			for (j = 0; 9 - j > i; j++){
				num[j] = (num[j] + num[j + 1]) % 10;
			}
		}
		printf("%d\n", num[0]);
	}
	
	return 0;
}

Measured memory_bytes: 536
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int w = sc.nextInt();
        sc.close();

        if (s > w) {
            System.out.println("safe");
        } else {
            System.out.println("unsafe");
        }
    }
}


Measured memory_bytes: 27080
h,n=map(int,input().split())
A=[]
B=[]
for i in range(n):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
#dp[i]=x  ダメージi与えるのに必要な魔力x　答えはdp[h]
INF=10**10
dp=[INF]*(10**5+5)
dp[0]=0
for i in range(h+max(A)+2):
  m=dp[i]
  for j in range(n):
    if i-A[j]<0:
      continue
    a=dp[i-A[j]]+B[j]
    if a<m:
      m=a
  dp[i]=m
  for j in range(i+1,i+1-max(A)-3,-1):
    if dp[j]>dp[j+1]:
      dp[j]=dp[j+1]
print(dp[h])

Measured memory_bytes: 43612
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd
#define bod 100000007
/****************************/
using namespace std;
int now;
int ans;
int n;
int main()
{
	cin>>n;
	while(1)
	{
		now+=n;
		ans++;
		if(now%360==0)
		{
			cout<<ans;
			return 0;
		}
	}
	return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for (int i = 0; i < N - 2; i++)
  {
    if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1e9
#define pb push_back
#define mp  make_pair
#define loop(a,n) for(long long i=a;i<n;i++)
#define vil vector<long long int>
#define vi vector<int>
#define sz(v) v.size()
#define setbits(x)          __builtin_popcountll(x)
#define ff first
#define ss second
using namespace std;


ll gcd(ll a, ll b) {
  if (a == 0)return b;
  return gcd(b % a, a);
}
bool isperfect(ll n) {
  ll y = sqrt(n);
  if (n % y == 0 && y * y == n)return true;
  return false;
}
bool comp(pair<int,int> a, pair<int,int> b) {
    if(a.first == b.first) return a.second>b.second;
  return a.first < b.first;
}
 ll powi(ll a, ll b) {
  ll ans = 1;
  while (b > 0) {
    if (b & 1)ans = (ans * a);
    b = b >> 1;
    a = (a * a);
  }
  return ans;
}
bool isprime(ll n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)return false;
  }
  return true;
}
bool prime[10000000];
void seive() {

  prime[1] = true;
  for (int i = 2; i * i < 10000000; i++) {

    if (prime[i])continue;
    for (int j = i * i; j < 10000000; j += i) {
      prime[j] = true;
    }

  }
}

int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  string s,t;
  cin>>s>>t;
  ll cnt=0;
  for(int i=0;i<s.length();i++) cnt+=(s[i]!=t[i]);
  cout<<cnt;
}




  

Measured memory_bytes: 3776
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;

public class Main{


	static Function<List<Integer>,String> toStr = ls -> {
		StringBuilder sb = new StringBuilder();
		for(Integer i: ls)
			sb.append(i);
		return String.valueOf(Integer.parseInt(sb.toString()));
	};
	static BiFunction<Integer,Integer,List<Integer>> toL = (d,l) -> {
		List<Integer> ls = new LinkedList<>();
		String tmp = new Integer(d).toString();
		for(int i = 0; i < l - tmp.length() ; i++)
			ls.add(0);

		for(String s: tmp.split(""))
			ls.add(Integer.parseInt(s));
		return ls;
	};

	static Function<List<Integer>,Integer> toI = ls ->
	{
		Integer tmp = 0;
		for(int i = 0;i < ls.size();i ++)
		{
			tmp += (int) (ls.get(i) * Math.pow(10,ls.size() - (i + 1)));
		}
		return tmp;
	};

	static Consumer<Dataset> solveD = data -> {
		List<List<Integer>> history = new LinkedList<>();
		List<Integer> num = toL.apply(data.a,data.l);
		history.add(num);
		List<Integer> max,min;
		int j = 0;
		for(int i = 0;;i++)
		{
			max = num.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
			min = num.stream().sorted(Comparator.naturalOrder()).collect(Collectors.toList());
			num = toL.apply(toI.apply(max) - toI.apply(min),data.l);
			j = history.indexOf(num);
			if(j >= 0)
			{
				System.out.println(j + " " + toStr.apply(num) + " " + (i-j+1));
				break;
			}
			else
				history.add(num);
		}

	};

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		LinkedList<Dataset> ls = readD();
		ls.parallelStream().forEachOrdered(e->solveD.accept(e));
	}





	static LinkedList<Dataset> readD()
	{
		Scanner sc = new Scanner(System.in);
		LinkedList<Dataset> res = new LinkedList<>();
		int a,l;
		while(true)
		{
			a = sc.nextInt();
			l = sc.nextInt();
			if(a == 0 && l == 0)
				return res;
			else
				res.add(new Dataset(a,l));
		}
	}

}
class Dataset
{
	int a;
	int l;
	Dataset(int a,int l)
	{
		this.a = a;
		this.l = l;
	}
}

Measured memory_bytes: 37100
#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define foror(i,a,b) for(i=a;i<b;i++)
#define foror2(i,a,b) for(i=a;i>b;i--)
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define MOD 1000000000
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
using ll = long long;
using namespace std;
char a[105][105];
int main()
{
 //freopen("in.txt", "r", stdin);
 //freopen("out.txt", "w", stdout);
 int h,w;
 scanf("%d%d",&h,&w);
 char pop;
 for(int i=1;i<=h;i++)
 scanf("%s",a[i]);
 for(int i=0;i<=w;i++)
  {
        a[0][i]='#';
        a[h+1][i]='#';
  }
 for(int i=0;i<=h+1;i++)
  {
        a[i][w]='#';
  }
  for(int i=0;i<=h+1;i++)
  {
          if(i!=0)
          cout<<endl;
          cout<<"#";
          for(int j=0;j<=w;j++)
          printf("%c",a[i][j]);
  }
 //fclose(stdin);
 //fclose(stdout);
 }


Measured memory_bytes: 256
from itertools import accumulate
def find(x):
    if par[x] == x:
        return x
    else:
        return find(par[x])

def unite(x, y):
    x = find(x)
    y = find(y)
    
    if x != y:
        if rank[x] < rank[y]:
            par[x] = y
            size[y] += size[x]
        else:
            par[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1

def same(x, y):
    return find(x) == find(y)

N, M = map(int, input().split())
AB = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(M)]

par = list(range(N))
rank = [1] * N
size = [1] * N

ans = [0] * M
for i in range(M-1, -1, -1):
    x = find(AB[i][0])
    y = find(AB[i][1])
    if x != y:
        ans[i] = size[x] * size[y]
        unite(x, y)
        
for i in accumulate(ans):
    print(i)
        

Measured memory_bytes: 34912
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define ms(n, t) memset(n, t, sizeof(n))
#define U 10050
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#define sp
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	char ch = next<char>();
	if ('a' <= ch && ch <= 'z') cout<<'a'<<endl;
	else cout<<'A'<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N, M;
	while (cin >> N >> M, N | M) {
		vector<int> P(N);
		for (int i = 0; i < N; i++) {
			cin >> P[i];
		}
		P.push_back(0);
		sort(P.begin(), P.end());
		P.erase(unique(P.begin(), P.end()), P.end());
		int N = P.size();
		vector<int> all;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				all.push_back(P[i] + P[j]);
			}
		}
		sort(all.begin(), all.end());
		all.erase(unique(all.begin(), all.end()), all.end());
		int res = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				int id = upper_bound(all.begin(), all.end(), M - (P[i] + P[j])) - all.begin() - 1;
				if (id >= 0) {
					res = max(res, P[i] + P[j] + all[id]);
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}



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

void fnInput(string& rsTarget)
{
  cin >> rsTarget;
}

int fnParse(string sTarget)
{
  const vector<string> cnvsWord{"dream", "dreamer", "erase", "eraser"};
  int ixBgn, ixEnd;
  ixBgn = sTarget.size();

  while (ixBgn)
  {
    bool bRslt = false;
    ixEnd = ixBgn;
    for (int i = 0; i < cnvsWord.size(); i++)
    {
      ixBgn = ixEnd - cnvsWord[i].size();
      if (ixBgn < 0)  continue;

      if (sTarget.substr(ixBgn, cnvsWord[i].size()) == cnvsWord[i])
      {
        bRslt = true;
        break;
      }
    }
    if (!bRslt)  return 0;
  }
  return 1;
}

int main()
{
  string sTarget;
  
  fnInput(sTarget);
  if (fnParse(sTarget)) cout << "YES" << endl;
  else                  cout << "NO"  << endl;

  return 0;
}


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


int main(){
  double n,k;
  int i;
  cin >> n >> k;
  vector<double> p(n);
  for(i=0;i<n;++i){
    cin >> p[i];
  }
  double ans=0;
  vector<double> s(n+1);
  double kid=0;
  s[0]=0;
  for(i=0;i<n;++i){
    s[i+1]=s[i]+p[i];
  }
  double left,right;
  double su=0;
  left=0;
  right=k;
  for(i=0;i<=n-k;++i){
    double as=s[right+i]-s[left+i];
    if(su<as){
      kid=left+i;
      su=as;
    }
  }
  double j,go;
  i=0;
  while(i<k){
    go=0;
    for(j=p[kid+i];j>0;--j){
      go+=j;
    }
    ans+=go/p[kid+i];
    i++;
  }
  printf("%10f\n",ans);
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    std::cin >> n;
    int a[100002];
    long long int b=0LL;
    a[0]=0;
    for (int i = 1; i <= n; i++) {
        std::cin >> a[i];
        b+=abs(a[i-1]-a[i]);
        a[i+1]=0;
    }
    
    b+=abs(a[n]-0);
    
    for (int i = 1; i <= n; i++) {
        std::cout << b+abs(a[i-1]-a[i+1])-(abs(a[i-1]-a[i])+abs(a[i]-a[i+1])) << std::endl;
    }
}


Measured memory_bytes: 1664
n = gets.chomp.to_i

heart = []
spade = []
club = []
dia = []
for i in 1..13
  heart.push(i)
  spade.push(i)
  club.push(i)
  dia.push(i)
end

n.times do
  design, rank = gets.chomp.split
  rank = rank.to_i
  case design
  when "S"
    spade.delete(rank)
  when "H"
    heart.delete(rank)
  when "C"
    club.delete(rank)
  when "D"
    dia.delete(rank)
  end
end


spade.size.times do |i|
  puts "S #{spade[i]}"
end
heart.size.times do |i|
  puts "H #{heart[i]}"
end
club.size.times do |i|
  puts "C #{club[i]}"
end
dia.size.times do |i|
  puts "D #{dia[i]}"
end

Measured memory_bytes: 8664
#include <bits/stdc++.h>
using namespace std;
char s[500010];
int n, vis[500010], ans[500010];
int main() {
    scanf("%s", s + 1);
    n = strlen(s + 1) + 1;
    s[0] = '>';
    s[n] = '<';
    queue < int > q;
    for (int i = 1; i <= n; i++) {
        if (s[i - 1] == '>' && s[i] == '<') {
            vis[i] = 1;
            ans[i] = 0;
            q.push(i);
        }
    }
    s[0] = '<';
    s[n] = '>';
    while (!q.empty()) {
        int now = q.front();
        q.pop();
        if (s[now - 1] == '>') {
            ans[now - 1] = ans[now] + 1;
            if (!vis[now - 1]) {
                vis[now - 1] = 1;
                q.push(now - 1);
            }
        }
        if (s[now] == '<') {
            ans[now + 1] = ans[now] + 1;
            if (!vis[now + 1]) {
                vis[now + 1] = 1;
                q.push(now + 1);
            }
        }
    }
    long long sum = 0;
    for (int i = 1; i <= n; i++) sum += ans[i];
    return cout << sum << endl, 0;
}

Measured memory_bytes: 5504