akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
  int n;
  cin >> n;
  int t[n+1];
  int x[n+1];
  int y[n+1];
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
 
  for(int i=1;i<=n;i++){
    cin >> t[i] >> x[i] >> y[i];
    t[i] = abs(t[i]-t[i-1]);
    x[i] = abs(x[i]-x[i-1]);
    y[i] = abs(y[i]-y[i-1]);
  }
  for(int i=1;i<=n;i++){
    if(x[i]+y[i]>t[i]){
      cout << "No" << endl;
      return 0;
    }
 
    if(t[i]%2==0){
      if(x[i]%2==1){
        if(y[i]%2==0){
          cout << "No" << endl;
          return 0;
        }
        else{
          continue;
        }
      }
      else{
        if(y[i]%2==0){
          continue;
        }
        else{
          cout << "No" << endl;
          return 0;
        }
      }
    }
 
if(t[i]%2==1){
      if(x[i]%2==1){
        if(y[i]%2==1){
          cout << "No" << endl;
          return 0;
        }
        else{
          continue;
        }
      }
      else{
        if(y[i]%2==1){
          continue;
        }
        else{
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
 
    cout << "Yes" << endl;
 
 
}

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

const int M = 998244353;
class mll {
public:
	long long x;
	mll(long long x = 0) : x((x% M + M) % M) {};
	void operator *= (const mll& a) {
		(x *= a.x) %= M;
	}
	mll pow(long long& n) {
		long long xx = x;
		x = 1;
		while (n > 0) {
			if (n & 1) x = x * xx % M;
			xx = xx * xx % M;
			n >>= 1;
		}
		return *this;
	}

};

int main() {
	int N;
	cin >> N;
	vector<int> Dist(N);
	int zero;
	cin >> zero;
	for (int i = 1; i < N; i++) {
		int d;
		cin >> d;
		Dist[d]++;
	}
	if (zero != 0 || Dist[0] > 0) {
		cout << 0 << endl;
		return 0;
	}
	Dist[0] = 1;
	mll ans = 1;
	for (int i = 1; i < N; i++) {
		mll k = (long long)Dist[i-1];
		long long m = (long long)Dist[i];
		ans *= k.pow(m);
	}
	cout << ans.x << endl;

}


Measured memory_bytes: 640
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b, c = rs()
if a[-1] == b[0] and b[-1] == c[0]:
  print('YES')
else:
  print('NO')










Measured memory_bytes: 27088
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using static System.Math;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] d = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Array.Sort(d);
        int ans = d[n / 2] - d[n / 2 - 1];
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 18016
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int A[200000], B[200000];
int N;

int cal() {
	int a = N - 2;
	int b = N - 1;
	int c = N;
	if (B[a] == 1 && B[b] == 0 && B[c] == 1) {
		int r = 2;
		int s = 0;
		while (b - r >= 0) {
			if (B[b - r] == s && B[b + r] == s) r++;
			else return 1 - s;
		    s = 1 - s;
		}
		if (N % 2) return B[b];
		return 1 - B[b];
	}
	else if (B[a] == 0 && B[b] == 1 && B[c] == 0) {
		int r = 2;
		int s = 1;
		while (b - r >= 0) {
			if (B[b - r] == s && B[b + r] == s) r++;
			else return 1 - s;
		    s = 1 - s;
		}
		if (N % 2) return B[b];
		return 1 - B[b];
	}
	else {
		if (B[a] + B[b] + B[c] > 1) return 1;
		return 0;
	}
	return 0;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> N;
    int s = 1, t = 2 * N - 1;
    for (int i = 0;i < 2 * N - 1;i++) {
    	cin >> A[i];
    }
    while (s + 1 < t) {
    	int m = s + (t - s) / 2;
    	for (int i = 0;i < 2 * N - 1;i++) {
    		if (A[i] <= m) B[i] = 0;
    		else B[i] = 1;
    	}
    	if (cal() == 0) t = m;
    	else s = m;
    }
    cout << t << endl;
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
#define PINT pair<int,int>
#define f1 first
#define s2 second
const int INF = 1e9 + 7;

using namespace std;

int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n],b[n];
    REP(i,n) cin >> a[i];
    REP(i,n) cin >> b[i];

    ll bit[29];
    REP(i,29) bit[i]=0;
    for(int i=29;i>0;--i){
        int md = 1<<i;
        REP(j,n) a[j] = a[j]%md;
        REP(j,n) b[j] = b[j]%md;
        sort(b,b+n);
        md /= 2;

        REP(j,n){
            bit[i-1] += lower_bound(b,b+n,2*md-a[j])-lower_bound(b,b+n,md-a[j]);
            bit[i-1] += lower_bound(b,b+n,4*md-a[j])-lower_bound(b,b+n,3*md-a[j]);
        }
    }

    int ans=0;
    REP(i,29){
        if(bit[i]%2==0) continue;
        else ans += (1<<i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
from collections import deque


def solve(i):
    if i in memo:
        return memo[i]
    q = deque([i])
    while True:
        nxt_i = next_ind[i]
        if nxt_i >= n:
            break
        q.append(nxt_i)
        i = nxt_i
    while q:
        memo[q.pop()] = nxt_i % n
    return memo[i]



n, k = map(int, input().split())
a = list(map(int, input().split())) + [-1, -1]
k_time = k
n += 2
aa = a + a
next_ind = [-1] * (2 * n)
tmp_memo = {}
for i in range(2 * n)[::-1]:
    if aa[i] not in tmp_memo:
        tmp_memo[aa[i]] = i + 1
    else:
        next_ind[i] = tmp_memo[aa[i]]
        tmp_memo[aa[i]] = i + 1

log_size = k.bit_length() + 2
double = [[-1] * n for i in range(log_size)]

# ダブリングで2^0回(= 1回)たどって到達する値を求める
memo = {}
for i in range(n):
    double[0][i] = solve(i)

# ダブリングで2^k回たどって到達する値を求める
for k in range(1, log_size):
    for i in range(n):
        double[k][i] = double[k - 1][double[k - 1][i]]

pos = 0
k_time -= 1
for k in range(log_size):
    if (k_time >> k) & 1:
        pos = double[k][pos]
q = deque([])
set_ = set()
for i in range(pos, n):
    if a[i] not in set_:
        set_.add(a[i])
        q.append(a[i])
    else:
        while True:
            tmp = q.pop()
            set_.remove(tmp)
            if tmp == a[i]:
                break
print(*q)

Measured memory_bytes: 164956
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int b = int.Parse(Console.ReadLine());
            double a = 100;
            for(int c = 0; c < b; c++)
            {
                a = a * 1.05;
                double e = a % 1;
                if (e == 0)
                    a = a - e;
                else
                    a = a - e + 1;
            }
            Console.WriteLine(a*1000);
        }
        
    }
}

Measured memory_bytes: 9236
#include <bits/stdc++.h>
using namespace std;
int main(){
   long long n,m,ans=0;
  cin >> n >>m;
  long long h[n],mm[n];
  for(int i=0;i<n;i++){
    cin >> h[i];
    mm[i]=0;
  }
  long long a[m],b[m];
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    mm[a[i]-1]=max(mm[a[i]-1],h[b[i]-1]);
    mm[b[i]-1]=max(mm[b[i]-1],h[a[i]-1]);
  }
  for(int i=0;i<n;i++){
    if(h[i]>mm[i])ans++;
  }
  
  cout << ans <<endl;
  
}



Measured memory_bytes: 6700
using System;

namespace ABC126
{
	class Program
	{
		static void Main(String[] args)
		{
			// 入力
			int[] info = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
			char[] S = Console.ReadLine().ToCharArray();
			// 解く
			if (info.Length>=2 && info[1]>=1 && info[1]<=S.Length)
			{
				int index = info[1] - 1;
				S[index] = Char.ToLower(S[index]);
			}
			// 出力
			Console.WriteLine(S);
		}
	}
}

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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define PI (3.141592653589793238462643383279502884197169399375105820974944)
#define MP make_pair
#define n1 first
#define n2 second
#define ALL(x) (x).begin(), (x).end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDB pair<db,db>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const db eps = 0.000001;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 1450555;
const int M = 1155;
const int L = 20;

int a[N], cnt[N];
void solve() {
    int n;
    cin >> n;

    ll sum = 0;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        cnt[a[i]]++;
        sum += a[i];
    }

    int q;
    cin >> q;
    for (int i = 1; i <= q; i++){
        int b, c;
        cin >> b >> c;
        sum += 1ll*cnt[b] * (c - b);
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << endl;
    }

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 4436
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long inf = 1ll << 61;
const long long mod = 1000000007;
typedef pair<int, int> P;
signed main() {
	string s; cin >> s;
	int cnt = s.size();
	string lst = "";
	rep(i, s.size()-1) {
		if (s[i] == s[i + 1]) {
			cnt--;
			i+=2;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 640
//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2676345#1
//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2676345#1
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
#include<fstream>
#include<cstring>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define P pair<int,int>
#define ll __int64

int dp[5000][5000];
int n,m;
string a,b;

int main(){
while(cin>>a>>b){
if(a.size()>b.size())swap(a,b);
n=a.size();
m=b.size();

int ans=0;
rep(i,5000)rep(j,5000)dp[i][j]=0;

for(int i=1;i<=n;i++){
	for(int j=1;j<=m;j++){
	if(a[i-1]==b[j-1]){
		//	dp[i][j]=1;
		dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
	}
	ans=max(ans,dp[i][j]);


/*
		if(i&1){//2,4,6,8...番目
			if(a[i]==b[j]){
				if(j-1>=0)
				dp[1][j]=max(dp[1][j],dp[0][j-1]+1);
				else dp[1][j]=max(dp[1][j],1);
				ans=max(ans,dp[1][j]);
			}
		}
		else{//1,3,5,7,9...番目
			if(a[i]==b[j]){
				if(j-1>=0)
				dp[0][j]=(dp[0][j],dp[1][j-1]+1);
				else dp[0][j]=max(dp[0][j],1);
				ans=max(ans,dp[0][j]);
			}
		}
*/

	}
}

cout<<ans<<endl;
}


	return 0;
}



Measured memory_bytes: 100808
#include <bits/stdc++.h>
#define inf 0x7fffffff
#define ll long long
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int max_3 (int a,int b,int c)
{
        if (a >= max(b,c))
            return a;
        if (b >= max(a,c))
            return b;
        return c;
}
int main() {
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
        // Code Starts...
        int days;
        cin>>days;
        vector<vector<int> > a(days,vector<int>(3,0)),b(days,vector<int>(3,0)),c(days,vector<int>(3,0));
        for (int i=0;i<days;i++)
        {
            for (int j=0;j<3;j++)
                cin>>a[i][j];
        }
        vector<vector<int> > dp(days,vector<int>(3,0));
        for (int i=0;i<3;i++)
        {
            dp[0][i] = a[0][i];
        }
        for (int i=1;i<days;i++)
        {
            for (int j=0;j<3;j++)
            {
                dp[i][j] = a[i][j] + max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
            }
        }
        cout<< *max_element(dp[days-1].begin(),dp[days-1].end());
        // Code Ends...
        return 0;
}


Measured memory_bytes: 22144
def bubblesort(a,n):
    count = 0
    for i in range(n):
        for j in reversed(range(i+1,n)):
            if a[j] < a[j-1]:
                a[j-1],a[j] = a[j],a[j-1]
                count += 1
    print(" ".join(map(str,a)))
    print(count)
N = int(input())
A = [int(s) for s in input().split()]
bubblesort(A,N)



Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    
    bool judge = true;
    rep(i, N) {
        if (A[i] > i) judge = false;
    }
    REP(i, N) {
        if (A[i] > A[i - 1] + 1) judge = false;
    }
    if (!judge) {
        cout << -1 << endl;
        return 0;
    }
    
    long long ans = 0;
    REP(i, N) {
        if (A[i - 1] + 1 != A[i]) ans += A[i - 1];
    }
    ans += A[N - 1];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1152
package main

import (
	"fmt"
	"strings"
)

func main() {
	var a, b, c string
	fmt.Scanf("%s %s %s", &a, &b, &c)

	abc := a + b + c
	if strings.Count(abc, "5") == 2 && strings.Count(abc, "7") == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
#define MAX 500000

int H, A[MAX+1];

int left(int i) {
  return 2*i;
}

int right(int i) {
  return 2*i+1;
}

void maxHeapify(int i) {
  int argmax;
  int l = left(i);
  int r = right(i);
  if (l<=H && A[i]<A[l]) {
    argmax = l;
  } else {
    argmax = i;
  }
  if (r<=H && A[argmax]<A[r]) {
    argmax = r;
  }

  if (argmax!=i) {
    swap(A[i], A[argmax]);
    maxHeapify(argmax);
  }
}

int main() {
  cin >> H;
  for (int i=1; i<=H; i++) {
    cin >> A[i];
  }

  for (int i=H/2; i>=1; i--) {
    maxHeapify(i);
  }

  for (int i=1; i<=H; i++) {
    cout << " " << A[i];
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 5044
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += p[i];
  }
  sum -= p[N - 1] / 2;
  
  cout << sum << endl;
  
  return 0;
}

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

#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

 
using namespace std;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
 
#define deb(x) {x}
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------

int n,m;
string a,b;
map<char,vi> pos;

void solve()
{
	cin>>a>>b;
	n=a.length();m=b.length();
	
	rep(i,0,n)pos[a[i]].pb(i);
	
	for (char x:b)if (pos.find(x)==pos.end()){cout<<"-1\n";return;}
		
	int cur=0,j=0,c;

	while(j!=m)
	{
		c=cur%n;
		
		auto it = lower_bound(all(pos[b[j]]),c);
		
		if (it==pos[b[j]].end())
		{
			cur += (n-c);
			c=0;
			it = lower_bound(all(pos[b[j]]),c);
		}
		
		
		cur += (*it-c);
		//cout<<cur<<" "<<j<<"\n";
		j++;
		cur++;
		
	}
	cout<<cur<<"\n";
	
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
 	
 	#ifdef local
    //freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif
 
 	int t=1;
    //cin>>t;
    
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
	}
	
    #ifdef local
    {qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}



Measured memory_bytes: 1736
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		
		// 計算
		int result = 0;
		int keta = String.valueOf(n).length();
		for(int i = 1; i <= n; i++){
		    int head = Integer.valueOf(String.valueOf(i).substring(0,1));
		    int tail = i%10;
		    if(tail == 0) continue;
		    //System.out.println("i:" + i + " head:" + head + " tail:" + tail + " result:" + result);
		    if(head == tail){
		        result++;
		        int p = 10;
		        for(int j = 2; j <= keta; j++){
		            if((((tail+1)*p - 1)/10)*10 + head <= n){
		                //System.out.println((((tail+1)*p - 1)/10)*10 + head);
		                result += pow(10, j-2);
		            }else if(tail*p + head <= n){
		                result += (n%p)/10;
		                if(n%10 >= head) result++;
		            }
		            p *= 10;
		        }
		    }else{
		        int p = 10;
		        for(int j = 2; j <= keta; j++){
		            if((((tail+1)*p - 1)/10)*10 + head <= n){
		                result += pow(10, j-2);
		            }else if(tail*p + head <= n){
		                result += (n%p)/10;
		                if(n%10 >= head) result++;
		            }
		            p *= 10;
		        }
		    }
		}
		
		// 出力
		System.out.println(result);
	}
}




Measured memory_bytes: 41816
#include<bits/stdc++.h>
#define MOD     1000000007
#define int     long long int
#define fastIO  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI      3.1415926535897932384626
#define pb      push_back
#define clr(x)  memset(x, 0, sizeof(x))
#define MP      make_pair
const int N=1e5+1;
using namespace std;
int gcd(int a,int b){if(a==0)return b;return gcd(b%a,a);}
int lcm(int a,int b){return (max(a,b)/gcd(a,b))*min(a,b);}
int powermodm(int x,int n,int M){int result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
int gcdExtended(int a, int b, int *x, int *y){if (a == 0){*x = 0, *y = 1;return b;}int x1, y1;int gcd = gcdExtended(b % a, a, &x1, &y1);*x = y1 - (b / a) * x1;*y = x1;return gcd;}
int modInverse(int a, int m){int x, y;int g = gcdExtended(a, m, &x, &y);if (g != 1)return -1;else{int res = (x % m + m) % m;return res;}}
bool isPrime(int a){if(a==1) return false;if(a==2) return true;if(a%2==0) return false;int root=sqrt(a);for(int i=3;i<=(int)root;i+=2){if(a%i==0)return false;}return true;}

main()
{
    fastIO;
    int n;
    cin >> n;
    int h[n];
    for(int i=0;i<n;i++) cin >> h[i];
    int dp[n];
    for(int i=0;i<n;i++)dp[i]=INT_MAX;
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        if(i-1>=0)
            dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i-2>=0)
            dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1];
}


Measured memory_bytes: 5180
use std::io;
use std::str::FromStr;

fn input_int_tuple() -> (i32, i32) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i32> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (a, b) = input_int_tuple();
    let mut max = a + b;
    if a - b > max {
        max = a - b;
    }
    if a * b > max {
        max = a * b;
    }
    println!("{}", max);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String args[]){
		
		
		Scanner sc =new Scanner(System.in);
		StringBuilder result = new StringBuilder();

		while(sc.hasNext()){
			
			String deck = sc.next();

			if("-".equals(deck)){
				break;
			}
			
			int    shufleNumbers = Integer.parseInt(sc.next());
			
			for(int i=0;i<shufleNumbers;i++){
				
				int count = Integer.parseInt(sc.next());
				deck =  deck.substring(count) +deck.substring(0,count);
				
			}
			
			result.append(deck + System.lineSeparator());
			
		}
		
		System.out.print(result);
		
		sc.close();
	}

}



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

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

const int maxn=100003;

int dfn[maxn],pre[maxn][23],root[maxn],num[maxn*23],N,dep[maxn],head[maxn],n,Q,ls[maxn*23],rs[maxn*23];
ll sum[maxn*23],dis[maxn];

struct EDGE{
	int to,nxt,w,c;
}edge[maxn<<1];

void addedge(int u,int v,int c,int w){
	static int sz=0;edge[++sz].to=v;edge[sz].nxt=head[u];
	edge[sz].w=w;edge[sz].c=c;head[u]=sz;
}

int newnode(int x){
	++N;
	ls[N]=ls[x];
	rs[N]=rs[x];
	sum[N]=sum[x];
	num[N]=num[x];
	return N;
}

void update(int id,int l,int r,int pos,int w){
	++num[id];
	sum[id]+=w;
	if(l==r) return ;
	int mid=(l+r)/2;
	if(pos<=mid){
		ls[id]=newnode(ls[id]);
		update(ls[id],l,mid,pos,w);
	}else{
		rs[id]=newnode(rs[id]);
		update(rs[id],mid+1,r,pos,w);
	}
}

pair<int,ll> query(int id,int l,int r,int pos){
	if(l==r)return make_pair(num[id],sum[id]);
	int mid=(l+r)/2;
	if(pos<=mid)return query(ls[id],l,mid,pos);
	else return query(rs[id],mid+1,r,pos);
}

void dfs(int u){
	int to;
	dep[u]=dep[pre[u][0]]+1;
	for(int i=head[u];i;i=edge[i].nxt){
		to=edge[i].to;
		if(to==pre[u][0]) continue;
		root[to]=newnode(root[u]);
		update(root[to],1,n,edge[i].c,edge[i].w);
		pre[to][0]=u;
		for(int j=1;j<23;++j)
			pre[to][j]=pre[pre[to][j-1]][j-1];
		dis[to]=dis[u]+edge[i].w;
		dfs(to);
	}
}

int lca(int u,int v){
	if(dep[u]<dep[v])swap(u,v);
	for(int i=20;i>=0;--i)
		if(dep[pre[u][i]]>=dep[v])
			u=pre[u][i];
	if(u==v)return u;
	for(int i=20;i>=0;--i)
		if(pre[u][i]!=pre[v][i])
			u=pre[u][i],v=pre[v][i];
	return pre[u][0];
}

ll D(int u,int x,int y){
	pair<int,ll> p=query(root[u],1,n,x);
//	printf("%d : %d %lld %lld %d !\n",u,p.first,p.second,dis[u],x);
	return dis[u]-p.second+1ll*y*p.first;
}

int main(){
	scanf("%d%d",&n,&Q);
	for(int i=1;i<n;++i){
		int u,v,c,w;
		scanf("%d%d%d%d",&u,&v,&c,&w);
		addedge(u,v,c,w);
		addedge(v,u,c,w);
	}
	root[1]=++N;
	dfs(1);
//	for(int i=1;i<=n;++i)
//		printf("%lld ",dis[i]);
//	puts("");
//	for(int i=1;i<=n;++i)
//		printf("%d ",root[i]);
//	puts("");
	while(Q--){
		int x,y,u,v;
		scanf("%d%d%d%d",&x,&y,&u,&v);
		printf("%lld\n",D(u,x,y)+D(v,x,y)-2*D(lca(u,v),x,y));
	}
	return 0;
}



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

int main(){
  int N,L,sum;
  cin >> N >> L;
  
  if(L>0){
    for(int i=0;i<N-1;i++){
      sum+=L+i+1;
    }
  }
  else if(L*(-1)>=N){
    for(int i=0;i<N-1;i++){
      sum+=L+i;
    }
  }
  else{
    for(int i=0;i<N;i++){
      if(L+i==0) continue;
      else sum+=L+i;
    }
  }
  
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
#define MOD 1000000007
using namespace std;

int main(){
  int H, W, N;
  cin >> H >> W >> N;
  if(H > W) swap(H, W);
  int ret = (N + W - 1) / W;
  cout << ret << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.insert(0,0)
a.append(0)
total=0
for i in range(1,n+2):
    total+=abs(a[i]-a[i-1])
for i in range(1,n+1):
    print(total-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]))

Measured memory_bytes: 14048
from heapq import heappop, heappush

manhattan = [[abs((i % 4) - (j % 4)) + abs((i // 4) - (j // 4)) for j in range(16)] for i in range(16)]
movables = [{1, 4}, {0, 2, 5}, {1, 3, 6}, {2, 7}, {0, 5, 8}, {1, 4, 6, 9}, {2, 5, 7, 10}, {3, 6, 11},
            {4, 9, 12}, {5, 8, 10, 13}, {6, 9, 11, 14}, {7, 10, 15}, {8, 13}, {9, 12, 14}, {10, 13, 15}, {11, 14}]
swap_mul = [[(1 << mf) - (1 << mt) for mt in range(0, 64, 4)] for mf in range(0, 64, 4)]
destination = 0xfedcba9876543210

i = 0
board_init = 0
blank_init = 0
for _ in range(4):
    for n in map(int, input().split()):
        if n:
            n -= 1
        else:
            n = 15
            blank_init = i
        board_init += n * 16 ** i
        i += 1

estimation_init = sum(manhattan[i][((board_init >> (4 * i)) & 15)] for i in range(16) if i != blank_init)

queue = [(estimation_init, board_init, blank_init)]
visited = set()

while True:
    estimation, board, blank = heappop(queue)
    if board in visited:
        continue
    elif board == destination:
        print(estimation)
        break
    visited.add(board)
    for new_blank in movables[blank]:
        num = (board >> (4 * new_blank)) & 15
        new_board = board + swap_mul[new_blank][blank] * (15 - num)
        if new_board in visited:
            continue
        new_estimation = estimation + 1 - manhattan[new_blank][num] + manhattan[blank][num]
        if new_estimation > 45:
            continue
        heappush(queue, (new_estimation, new_board, new_blank))

Measured memory_bytes: 163400
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  string s;
  cin >> s;
  rep(i,sz(s)){
    if(s[i] == '7'){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  print("No");
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    ll n=s.length();
    ll m=t.length();
    bool check[26]={0};
    for(int i=0;i<n;i++){
        check[s[i]-'a']=true;
    }
    for(int i=0;i<m;i++){
        if(check[t[i]-'a']==false){
            cout << -1<<endl;
            return 0;
        }
    }
    ll alpha[26];
    for(int i=0;i<26;i++){
        alpha[i]=-1;
    }
    ll maki[n][26];
    for(int i=n-1;i>=0;i--){
        for(int j=0;j<26;j++){
            maki[i][j]=alpha[j];
        }
        alpha[s[i]-'a']=i;
    }
    for(int i=n-1;i>=0;i--){
        for(int j=0;j<26;j++){
            maki[i][j]=alpha[j];
        }
        alpha[s[i]-'a']=i;
    }
    ll index=n-1;
    ll ans=0;
    ll niko;
    for(int i=0;i<m;i++){
        niko=(maki[index][t[i]-'a']-index+n)%n;
        if(niko==0){
            niko+=n;
        }
        ans+=niko;
        //cout << niko<<" "<<ans<<endl;
        index=maki[index][t[i]-'a'];
    }
    cout << ans<<endl;
    /*for(int i=0;i<n;i++){
        for(int j=0;j<26;j++){
            cout << maki[i][j]<<" ";
        }cout << endl;
    }*/
    return 0;
}



Measured memory_bytes: 20944
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  int n;
  cin >> n;
  vector<int> a(1 << (n + 1) + 1);
  for (int i = 0; i < (1 << n); i++) {
    cin >> a[(1 << n) + i];
  }
  for (int i = (1 << n) - 1; i >= 1; i--) {
    a[i] = (a[2 * i] == a[2 * i + 1] ? a[2 * i] : abs(a[2 * i] - a[2 * i + 1]));
  }
  cout << a[1] << endl;
}

Measured memory_bytes: 7480
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

/*template <class T>void Sort(vector<T> & a) { sort(a.begin(), a.end()); }
template <class T>void ReSort(vector<T>& a) { sort(a.rbegin(), a.rend()); }
template <class T>void Reverse(vector<T>& a) { reverse(a.begin(), a.end()); }
template <class T>void Unique(vector<T>& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T>T Sum(vector<T> a, T init = 0) { return accumulate(a.begin(), a.end(), init); }*/
template <class T>void Sort(T & a) { sort(a.begin(), a.end()); }
template <class T>void ReSort(T& a) { sort(a.rbegin(), a.rend()); }
template <class T>void Reverse(T& a) { reverse(a.begin(), a.end()); }
template <class T>void Unique(T& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T>T Sum(T a, T init = 0) { return accumulate(a.begin(), a.end(), init); }

//INPUT//
void CINPUT() {}
template<class H, class ...T> void CINPUT(H&& h, T&& ...t) { cin >> h; CINPUT(forward<T>(t)...); }
#define in(...) int __VA_ARGS__; CINPUT(__VA_ARGS__);
#define In(T,...) T __VA_ARGS__; CINPUT(__VA_ARGS__);
#define Vin(T,name,n) int n; cin>>n; vector<T> name(n); rep(i,n)cin>>name[i];
#define VIn(T,name,n) vector<T> name(n); rep(i,n)cin>>name[i];
#define VIn2(T,name,name2,n) vector<T> name(n),name2(n); rep(i,n)cin>>name[i]>>name2[i];

//OUTPUT//
void print() { cout << endl; }
template <class H> void print(H&& h) { cout << h << endl; }
template <class H, class... T> void print(H&& h, T&& ... t) { cout << h << " "; print(forward<T>(t)...); }
template<class T>void out(T n) { cout << n << endl; }
template<class T>void out(vector<T> a, string sep = " ", string end = "\n") { for (int i = 0; i < (int)a.size(); ++i)cout << a[i] << (i == (int)a.size() - 1 ? end : sep); }
void yes(bool f) { puts(f ? "yes" : "no"); }
void Yes(bool f) { puts(f ? "Yes" : "No"); }
void YES(bool f) { puts(f ? "YES" : "NO"); }
void poss(bool f) { puts(f ? "possible" : "impossible"); }
void Poss(bool f) { puts(f ? "Possible" : "Impossible"); }
void POSS(bool f) { puts(f ? "POSSIBLE" : "IMPOSSIBLE"); }

int main() {
	In(string, s, t);
	Reverse(t);
	YES(s == t);
}


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

#define ll long long

int main() {
	string s;
	cin >> s;
	int a = find(s.begin(),s.end(),'A') - s.begin();
	int z = find(s.rbegin(),s.rend(),'Z') - s.rbegin();
	z = (int) s.size() - z - 1;
	cout << z-a+1 << '\n';
	return 0;
}


Measured memory_bytes: 3704
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

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

    int n = s.length();
    int flag = 0;
    for(int i = 0; i < n; i++){
        if(s[i] != t[i]){
            flag = 1;
            break;
        }
    }

    if(flag == 1){ 
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3628
N,Y = map(int,input().split())
x = 0
y = 0
z = 0
flag = False
for i in range(N+1):
  for j in range(N+1-i):
    if 0 <= (Y-10000*i-5000*j)/1000 and (Y-10000*i-5000*j)/1000 == N-i-j:
      x = i
      y = j
      z = N-i-j
      flag = True
      break
if flag == False:
  print(-1,-1,-1)
else:
  print(x,y,z)

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

int main() {
	int a, b;
	cin >> a;
	cin >> b;

	if (a*b % 2 == 0) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int count = 0;
	int[] suuti = new int[N-1];
	for(int i = 0; i<suuti.length;i++) {
		suuti[i] = sc.nextInt();
	}
	for(int i = 0; i<suuti.length; i++) {
		count += i == 0? suuti[i]:Math.min(suuti[i-1],suuti[i]);
	}
	count += suuti[suuti.length-1];
	System.out.println(count);
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  ll ans_p = 0;
  ll sum_p = 0;
  rep(i, n) {
    if(i%2) { // -
      if(sum_p + a[i] < 0) {
        sum_p += a[i];
      }
      else {
        ans_p += (sum_p+a[i]) + 1;
        sum_p = -1;
      }
    }
    else { // +
      if(sum_p + a[i] > 0) {
        sum_p += a[i];
      }
      else {
        ans_p += abs(sum_p+a[i]) + 1;
        sum_p = 1;
      }
    }
  }

  ll ans_m = 0;
  ll sum_m = 0;
  rep(i, n) {
    if(!(i%2)) { // +
      if(sum_m + a[i] < 0) {
        sum_m += a[i];
      }
      else {
        ans_m += (sum_m+a[i]) + 1;
        sum_m = -1;
      }
    }
    else { // -
      if(sum_m + a[i] > 0) {
        sum_m += a[i];
      }
      else {
        ans_m += abs(sum_m+a[i]) + 1;
        sum_m = 1;
      }
    }
  }
  cout << min(ans_m, ans_p) << endl;
}


Measured memory_bytes: 3776
st = input()
if "N" in st:
    if ("S" in st) is False:
        print("No")
        exit()
if "W" in st:
    if ("E" in st) is False:
        print("No")
        exit()
if "S" in st:
    if ("N" in st) is False:
        print("No")
        exit()
if "E" in st:
    if ("W" in st) is False:
        print("No")
        exit()
print("Yes")

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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	int a,b,k;
	cin >> k >> a >> b;
	if(b/k-a/k >0 || b%k == 0 || a %k == 0) cout << "OK" << endl;
	else cout << "NG" << endl;

  return 0;
}


Measured memory_bytes: 3592
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int[] a;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int c = 0;
        for (int i = 0; i < q; i++) {
            int t = sc.nextInt();
            // if (binarySearchContains(t)) {
            //     c++;
            // }
            if (Arrays.binarySearch(a, t) >= 0) {
                c++;
            }
        }
        System.out.println(c);
    }

    public static boolean binarySearchContains(int v) {
        int l = 0; // left
        int r = a.length - 1; // right
        while (l <= r) {
            int m = (r + l) / 2;
            if (a[m] == v) {
                return true;
            }
            if (a[m] > v) {
                r = m - 1;
            } else {
                l = m + 1;
            }
        }
        return false;
    }
}

Measured memory_bytes: 78336
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC123_C_Five_Transportations
{
	class Program
	{
		static void Main(string[] args)
		{
			long n = long.Parse(Console.ReadLine());
			long[] persons = new long[5];
			for(int j = 0; j < 5; j++)
			{
				persons[j] = long.Parse(Console.ReadLine());
			}
			long minLimit = persons.Min();
			int minIndex = Array.IndexOf(persons, minLimit) + 1;
			long output = 0;
			decimal i = Math.Ceiling((decimal)n / minLimit);

			if (i == 0)
			{
				output = 5;
			}
			else
			{
				output = (long)i + 4;
			}

			Console.WriteLine(output);
		}
	}
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a[100005],x[100005],y[100005];
    cin>>n;
    a[0]=0;
    x[0]=0;
    y[0]=0;
    for(int i=1;i<=n;i++){
        cin>>a[i]>>x[i]>>y[i];
    }
    for(int i=1;i<=n;i++){
        unsigned int k=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
        if(a[i]<k){
            cout<<"No";
            return 0;
        }
        else{
            if((a[i]-a[i-1]-k)%2!=0){
                cout<<"No";
                return 0;
            }
        }    
    }
    cout<<"Yes";
}

Measured memory_bytes: 1408
#!/usr/bin/env ruby
# encoding: utf-8

while line = gets
	n = line.to_i
	a = 0
	result = 0
	while a < 10
		b = 0
		while b < 10
			c = 0
			while c < 10
				d = 0
				while d < 10
					if n == a + b + c + d
						result += 1
					end
					d += 1
				end
				c += 1
			end
			b += 1
		end
		a += 1
	end
	puts result
end

Measured memory_bytes: 6096
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

ll N;
ll cnt[10][10],ans=0;

int main(){
   cin>>N;

   FOR(i,1,N+1){
     ll a=i;
     ll b=i%10;
     while(a>=10){
       a=a/10;
     }
     cnt[a][b]++;
   }

   FOR(i,1,10){
     FOR(j,i,10){
       if(i==j) ans+=cnt[i][i]*cnt[i][i];
       else ans+=2*cnt[i][j]*cnt[j][i];
     }
   }

   cout<<ans<<endl;
}


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

int main()
{
  int64_t X, K, D;
  cin >> X >> K >> D;
  X = abs(X);

  int64_t mi;
  long long int kd = K * D;
  if (__builtin_smulll_overflow(K, D, &kd))
    mi = 0;
  else
    mi = X - K * D;
  if (mi > 0)
  {
    cout << mi << endl;
  }
  else
  {
    int64_t p = X / D;
    if ((K - p) % 2 == 0)
    {
      cout << X % D << endl;
    }
    else
    {
      int64_t r = X % D;
      int64_t r1 = X % D + D;
      int64_t r2 = abs(r - D);
      cout << min(r1, r2) << endl;
    }
  }
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vvi vector<vector<int> >
#define vb vector<bool>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define pii pair<int,int>
#define mii map<int,int>
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mkp make_pair
#define input(a,b,n) for(i=b;i<n;i++){cin>>a[i];}
#define print(a) for(i=0;i<a.size();i++){cout<<a[i]<<" ";}cout<<endl;
#define trace(a); cout<<"a="<<a<<endl;
#define trace(a,b); cout<<"a="<<a<<" b="<<b<<endl;
#define fast; ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int inf=0x3f3f3f3f3f3f3f3f;
int power(int a, int b){
    int res = 1;
    while(b!=0){
        if(b&1){
            res *= a; 
        }
        a = (a * a);
        b = (b / 2);
    }
    return res;
}
int32_t main()
{
	fast;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
    	int k,a,b;
      cin>>k>>a>>b;
      int z=b/k;
      int zz=z*k;
      if(zz>=a&&zz<=b)
     cout<<"OK"<<endl;
      else
      {
        cout<<"NG"<<endl;
      }
	}
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
    while (true) {
        int n;
        cin >> n;
        if(n==0) break;
        int max_length=0;
        string names[n];
        string codes[n];
        rep(i,n){
            cin >> names[i];
            if(names[i].length()>max_length) max_length=names[i].length();
            bool a = true;
            codes[i]="";
            rep(j,names[i].length()){
                if(a){
                    codes[i].push_back(names[i][j]);
                    a = false;
                }
                if(names[i][j]=='a' || names[i][j]=='i' || names[i][j]=='u' || names[i][j]=='e' || names[i][j]=='o'){
                    a = true;
                }
            }
            // cout << codes[i] << endl;
        }
        string codes2[n];
        bool b = false;
        repi(k,1,max_length+1){
            rep(i,n){
                if(codes[i].length()<k) codes2[i]=codes2[i];
                else codes2[i]=codes[i].substr(0,k);
            }
            bool a =true;
            rep(i,n-1){
                for(int j=i+1;j<n;j++){
                    if(codes2[i]==codes2[j]){
                        // cout << k << " same" << endl;
                        a=false;
                        break;
                    }
                }
                if(!a) break;
            }
            if(a){
                b = true;
                cout << k << endl;
                break;
            }
        }
        if(!b) cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3020
#include <stdio.h>

int main(void)
{
    int N,A,B,a[5];
    int total=0;
    scanf("%d%d%d",&N,&A,&B);
    for(int n=1;n<=N;n++){
        int pow=1;
        int sum=0;
        for(int i=0;i<=4;i++){
            a[i]=(n/pow)%10;
            //printf("a[%d] = %d\n",i,a[i]);
            sum+=a[i];
            pow*=10;
        }
        //printf("sum = %d\n",sum);
        if(A<=sum&&sum<=B)
            total+=n;
    }
    printf("%d\n",total);
    return 0;
}


Measured memory_bytes: 128
n = int(input())
S = []
ans = ''

for i in range(n):
    S.append(str(input()))

data1 = []
data2 = []

for i in range(len(S[0])):
    if not S[0][i] in data1:
        data1.append(S[0][i])
        data2.append(1)
    else:
        data2[data1.index(S[0][i])] += 1

for i in range(1, n):
    for j in range(len(data1)):
        data2[j] = min(data2[j], S[i].count(data1[j]))

for i in range(len(data1)):
    ans += data1[i] * data2[i]

print(''.join(sorted(ans)))



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

int main () {
    long long N, A, B;
    cin >> N >> A >> B;
    if (A > B) {
        cout << 0 << endl;
    }
    else if (N == 1 && A != B) {
        cout << 0 << endl;
    }
    else {
        cout << (N-2) * (B-A) + 1 << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b){
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b){
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b){
	int res=1;
	while(b){
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=100002;
 
void solve(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22){
		cout<<"bust";
	}
	else{
		cout<<"win";
	}
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 256
using System;

class P
{
public static void Main()
{
            //????????????????????????
            double r = Double.Parse(Console.ReadLine());

            //?????¨???
            double pi = Math.PI;
            //??¢???
            double S = pi * r * r;
            //?????¨
            double L = 2 * pi * r;

            //??¨???
            Console.WriteLine("{0:f5} {1:f5}", S, L);
}
}

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

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

int main() {
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
    return 0;
}

Measured memory_bytes: 3640
A, B = map(int, input().split())
rA = set(range(int((A-0.001)//0.08 + 1), int((A+0.999)//0.08 + 1)))
rB = set(range(int((B-0.001)//0.1 + 1), int((B+0.999)//0.1 + 1)))
if len(rA & rB) == 0:
    print(-1)
else:
    print(min(rA & rB))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
const int N = 3010;
int n;
long double dp[N][N],ans=0,a[N];

int main(){
	scanf("%d",&n);
    for(int i = 1; i <= n; ++i)scanf("%Lf",a+i);
    dp[0][1] = 1-a[1];
  	dp[1][0] = a[1];
    for(int i = 2; i <= n; ++i)dp[i][0] = dp[i-1][0]*a[i],dp[0][i]=dp[0][i-1]*(1-a[i]);
  	for(int i = 1; i <= n; ++i){
    	for(int j = 1; j <= n; ++j){
            if(i+j > n)continue;
        	dp[i][j] = (dp[i-1][j]*a[i+j]+dp[i][j-1]*(1-a[i+j]));
        	if(i+j == n && i > j)ans+=dp[i][j];
        } 
    }
  printf("%.12Lf",ans+dp[n][0]);
	return 0;
}

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



def main():
    A, B = map(int, input().split())

    if 0 < A:
        sign = 1
    elif A <= 0 <= B:
        sign = 0
    else: # B < 0
        even = (B-A+1) % 2 == 0
        sign = 1 if even else -1

    if sign > 0:
        print("Positive")
    elif sign == 0:
        print("Zero")
    else:
        print("Negative")

if __name__ == "__main__": main()


Measured memory_bytes: 3060