akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

const (
	BASE = 1000000007
)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	n := nextInt()
	a := make([]uint64, n)
	for i := 0; i < n; i++ {
		a[i] = uint64(nextInt())
	}

	var r uint64 = 0
	var m uint64 = 0

	for i := n - 2; i >= 0; i-- {
		m = (m + a[i+1]) % BASE
		r = (r + (a[i] * m)) % BASE
	}

	fmt.Println(r)
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl A(N + 2);
    for (ll i = 0; i < N; i++) {
        cin >> A[i + 1];
    }

    ll cost = 0;
    for (ll i = 0; i <= N; i++) {
        cost += abs(A[i] - A[i + 1]);
    }

    for (ll i = 1; i <= N; i++) {
        ll ans = cost - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) + abs(A[i - 1] - A[i + 1]);
        cout << ans << "\n";
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 2048
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
using namespace std;
long long s;
long long a[90];
int main(void)
{
     int i,j,k,n,m;
     a[0]=2;
     a[1]=1;
     for(i=2;i<=86;i++)
          a[i]=a[i-1]+a[i-2];
     scanf("%d",&n);
     printf("%lld\n",a[n]);
     return 0;
}


Measured memory_bytes: 256
//   __                    .__              ________ .________ ________   ______  
//  |  | __  ____    ______|  |__   __ __  /  _____/ |   ____//   __   \ /  __  \ 
//  |  |/ /_/ __ \  /  ___/|  |  \ |  |  \/   __  \  |____  \ \____    / >      < 
//  |    < \  ___/  \___ \ |   Y  \|  |  /\  |__\  \ /       \   /    / /   --   \
//  |__|_ \ \___  >/____  >|___|  /|____/  \_____  //______  /  /____/  \______  /
//       \/     \/      \/      \/               \/        \/                  \/ 

#include<bits/stdc++.h>
#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<
#define int long long
using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int a,b;

//vi divi;

int output =1;

void givdiv(int x){
	if(x%2==0){
		output++;
		while(x%2==0)
			x/=2;
	}
	for(int i=3;i*i<=x;i++){
		if(x%i==0){
			output++;
			while(x%i==0)
				x/=i;
		}
	}
	if(x>1)
		output++;
	return;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	cin>>a>>b;
	int c = __gcd(a,b);
	// cout<<"c = "<<c<<endl;
	// for(int i=1;i*i<=c;i++){
	// 	if(c%i==0){
	// 		if(i==c/i)
	// 			divi.pb(i);
	// 		else{
	// 			divi.pb(i);
	// 			divi.pb(c/i);
	// 		}
	// 	}
	// }
	givdiv(c);
	cout<<output;
	return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    int2(a, b);

    cout << min(a, b) << " ";
    /*
    if (a + b < n) {
        cout << 0 << endl;
    } else {
        cout << max(a, b) - min(a, b) << endl;
    }
    */

    int t = n - a;
    if (t < b) {
        cout << b - t << endl;
    } else {
        cout << 0 << endl;
    }


    return 0;
}


Measured memory_bytes: 256
s = input()
ma = 0
#ma_s = ''
for i in range(len(s)+1):
    for j in range(i,len(s)+1):
        part = s[i:j]
        flag = 1
        for k in range(len(part)):
            if not part[k] in 'ATGC':
                flag = 0
        if flag:
            if ma < len(part):
                ma = len(part)
                #ma_s = part
#print(ma_s)
print(ma)

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline bool minup(T1& m, T2 x){ if(m>x){ m=static_cast<T2>(x); return true; } return false; }
template<class T1, class T2> inline bool maxup(T1& m, T2 x){ if(m<x){ m=static_cast<T2>(x); return true; } return false; }

#define INF 100000000000000LL
#define MOD 1000000009
#define EPS 1E-9

typedef ll Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void WarshallFloyd(const Matrix &g, Matrix &dist)
{
  int n = g.size();
  dist = g;
  rep(k, n) rep(i, n) rep(j, n) minup(dist[i][j], dist[i][k] + dist[k][j]);
}

int V, E;
int s, t;
Weight d;

int main()
{
  cin >> V >> E;
  Matrix g(V, Array(V, INF + INF));  rep(i, V) g[i][i] = 0LL;
  Matrix dist(V, Array(V));
  rep(i, E){
    cin >> s >> t >> d;
    g[s][t] = d;
  }

  WarshallFloyd(g, dist);

  rep(i, V) if(dist[i][i] < 0LL){
    puts("NEGATIVE CYCLE");
    return 0;
  }

  rep(i, V) rep(j, V){
    if(dist[i][j] >= INF) printf("INF");
    else cout << dist[i][j];
    putchar(j>=V-1 ? '\n' : ' ');
  }

  return 0;
}

Measured memory_bytes: 1392
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<set>
#include<list>

using namespace std;


/*
//1
int main(){
	for(int i=0; i<7;i++){
		int a, b;
		cin >> a >> b;
		cout << a- b << endl;

	}

	return 0;
}
*/

/*
//2
int main(){
	int t[4] = {6000, 4000, 3000, 2000};
	for(int i=0; i<4; i++){
		int T,n;
		cin >> T >> n;
		T--;
		cout << t[T]*n << endl;
	}

	return 0;
}
*/

/*
//3
int main(){
	int N;
	cin >> N;
	for(int i=0; i<N; i++){
		int x, y, b, p;
		cin >> x >> y >> b >> p;
		
		if(b >= 5 && p >= 2){
			int ans = (b*x + p*y)*0.8;
			cout << ans << endl;
		}
		else if(b >= 5 && p < 2){
			int ans = (b*x + 2*y)*0.8;
			ans = min( b*x + p*y, ans );
			cout << ans << endl;
		}
		else if(b < 5 && p >= 2){
			int ans = (5*x + p*y)*0.8;
			ans = min( b*x + p*y, ans );
			cout << ans << endl;
		}
		else{
			int ans = (5*x + 2*y)*0.8;
			ans = min( b*x + p*y, ans );
			cout << ans << endl;
		}
	}

	return 0;
}
*/


//4
int main(){
	while(true){
		int N;
		cin >> N;
		if(N == 0) break;
		int ans = 2;
		int num = N;
		bool b = false;
		for(int i=0; i<N; i++){
			int k;
			cin >> k;
			if(k == 0) num--;
			if(k >= 2) b = true;
		}
		if(b){
			cout << ans + num - 1 << endl;
		}
		else{
			cout << "NA" << endl;
		}
	}



	return 0;
}


/*
//5
int main(){


	return 0;
}
*/

/*
//6
int main(){
	int Q;
	cin >> Q;
	for(int i=0; i<Q; i++){
		int c,a,n;
		cin >> c >> a >> n;
		int ans = 0;
		while(c != 0 && a != 0 && n != 0){
			c--;
			a--;
			n--;
			ans++;
		}
		while(c >= 2 && a >= 1){
			c -= 2;
			a--;
			ans++;
		}
		while(c >= 3){
			c -= 3;
			ans++;
		}
		cout << ans << endl;
	}

	return 0;
}
*/

/*
//7
int main(){


	return 0;
}
*/

/*
//8
int main(){


	return 0;
}
*/

/*
//9
int main(){


	return 0;
}
*/

/*
//10
int main(){


	return 0;
}
*/




Measured memory_bytes: 3100
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

L, R = map(int, input().split())

ans = float('inf')
for i in range(L, R):
    for j in range(L+1, R+1):
        ans = min(ans, i*j % 2019)
        if ans == 0:
            print(0)
            exit()

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int K,A,B;
    cin >> K >> A >> B;
    bool a=false;
    for(int i=A;i<=B;i++){
        if(i%K==0){
            a=true;
            break;
        }
        
    }  
    if(a)cout << "OK" << endl;
    else cout << "NG" << endl;
}

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

int main(void){
	int a,b,c,ans;
	cin >>a>>b>>c;
	if(a==b && b==c)ans=1;
	else if(a==b || b==c || a==c)ans=2;
	else ans = 3;
	cout << ans;
	
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	
	
	

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int a[] = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = s.nextInt();
		}
		Arrays.parallelSort(a);
		long sum = a[n-1];
		int i = 0,index=n-2;
		for(i=n-3;i>0;i-=2) {
			sum+=2*a[index];
			index--;
		}
		if(i==0) {
			sum+=a[index];
		}
		System.out.println(sum);
	}

}

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int sumr[n]={},sumg[n]={},sumb[n]={};
    if(s[0]=='R'){
        sumr[0]=1;
        sumg[0]=0;
        sumb[0]=0;
    }
    if(s[0]=='G'){
        sumg[0]=1;
        sumr[0]=0;
        sumb[0]=0;
    }
    if(s[0]=='R'){
        sumb[0]=1;
        sumg[0]=0;
        sumr[0]=0;
    }

    //cout << sumr[0] << " " << sumb[0] << " " << sumg[0] << endl; 
    for(int i=1; i<n; i++){
        if(s[i]=='R'){
            sumr[i]=sumr[i-1]+1;
            sumb[i]=sumb[i-1];
            sumg[i]=sumg[i-1];
        }
        if(s[i]=='G'){
            sumg[i]=sumg[i-1]+1;
            sumb[i]=sumb[i-1];
            sumr[i]=sumr[i-1];
        }
        if(s[i]=='B'){
            sumb[i]=sumb[i-1]+1;
            sumr[i]=sumr[i-1];
            sumg[i]=sumg[i-1];
        }
    }
   
    cout << endl;
    ll cnt=0;
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            
            if(s[i]=='R'&&s[j]=='G'){
                cnt+=sumb[n-1]-sumb[j];
                if(2*j-i<n&&s[2*j-i]=='B')cnt--;
            }if(s[i]=='R'&&s[j]=='B'){
                cnt+=sumg[n-1]-sumg[j];
                if(2*j-i<n&&s[2*j-i]=='G')cnt--;
            }if(s[i]=='B'&&s[j]=='G'){
                cnt+=sumr[n-1]-sumr[j];
                if(2*j-i<n&&s[2*j-i]=='R')cnt--;
            }if(s[i]=='G'&&s[j]=='R'){
                cnt+=sumb[n-1]-sumb[j];
                if(2*j-i<n&&s[2*j-i]=='B')cnt--;
            }if(s[i]=='G'&&s[j]=='B'){
                cnt+=sumr[n-1]-sumr[j];
                if(2*j-i<n&&s[2*j-i]=='R')cnt--;
            }if(s[i]=='B'&&s[j]=='R'){
                cnt+=sumg[n-1]-sumg[j];
                if(2*j-i<n&&s[2*j-i]=='G')cnt--;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3628
import sys
N, M = map(int, input().split())
L_lis = []
R_lis = []

for _ in range(M):
    L, R = map(int, input().split())
    L_lis.append((L))
    R_lis.append((R))

ans = 0
for i in range(max(L_lis),(min(R_lis) + 1)):
    ans = ans + 1

print(ans)

Measured memory_bytes: 10996
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
 
   
int main(){
  string s; cin >> s;
  int cnt=0;
  int n=s.size();
  rep(i,n){
    if(s.at(i)=='2')cnt++;
  }
  cout << cnt << endl;
} 

Measured memory_bytes: 3516
#include <stdio.h>
#include <string.h>

#define M 1046527
#define NIL -1
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch)
{
    if (ch == 'A')
        return 1;
    else if (ch == 'C')
        return 2;
    else if (ch == 'G')
        return 3;
    else if (ch == 'T')
        return 4;
    else
        return 0;
}

/* convert a string into an integer value */
long long getKey(char str[])
{
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++)
    {
        sum += p * (getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int find(char str[])
{

    long long key, i, h;
    key = getKey(str);
    for (i = 0;; i++)
    {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0)
            return 1;
        else if (strlen(H[h]) == 0)
        {
            //strcpy(H[h], str);
            return 0;
        }
    }
}

int insert(char str[])
{

    long long key, i, h;
    key = getKey(str);
    for (i = 0;; i++)
    {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0)
            return 1;
        else if (strlen(H[h]) == 0)
        {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main()
{
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++)
        H[i][0] = '\0';

    scanf("%d", &n);

    for (i = 0; i < n; i++)
    {
        scanf("%s %s", com, str);

        if (com[0] == 'i')
        {
            insert(str);
        }
        else
        {
            if (find(str))
            {
                printf("yes\n");
            }
            else
            {
                printf("no\n");
            }
        }
    }

    return 0;
}


Measured memory_bytes: 16052
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {
	int D, N, result;
	cin >> D;
	cin >> N;

	if (N == 100) {
		N = 101 ;
	} 

	//result = N * pow(10, 2 * D);
	//cout << result;
	cout << fixed << setprecision(0);
	cout << N * pow(10, 2 * D);

	return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n;
    cin >> n;
    if(n==1)COUT("Hello World");
    else {
        int a,b;
        cin >> a >> b;
        COUT(a+b);
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
const int N=200005;
const int MOD=1e9+7;
int add (int x,int y)   {x=x+y;return x>=MOD?x-MOD:x;}
int mul (int x,int y)   {return (LL)x*y%MOD;}
int dec (int x,int y)   {x=x-y;return x<0?x+MOD:x;}
int Pow (int x,int y)
{
	if (y==0) return 1;
	if (y==1) return x;
	int lalal=Pow(x,y>>1);
	lalal=mul(lalal,lalal);
	if (y&1) lalal=mul(lalal,x);
	return lalal;
}
int n;
int a[N],nn=1;
int f[N];
int last[N];
int main()
{
	scanf("%d",&n);
	scanf("%d",&a[1]);
	for (int u=2;u<=n;u++)
	{
		int x;
		scanf("%d",&x);
		if (x==a[nn]) continue;
		a[++nn]=x;
	}
	f[0]=1;
	for (int u=1;u<=nn;u++)
	{
		f[u]=f[u-1];
		if (last[a[u]]!=0) 	f[u]=add(f[u],f[last[a[u]]]);
		last[a[u]]=u;
	}
	printf("%d\n",f[nn]);
	return 0;
}

Measured memory_bytes: 2560
//arc074 q2 practice 2017/06/17
#include <cstdio>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <tuple>
#define pb push_back
#define mkt make_tuple
#define pqueue priority_queue
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
const int INF =  2147483647;
const ll INFLL = 9223372036854775807;



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

  int n;
  cin >> n;
  ll ans = -INFLL;
  vl tm(n+1, 0), tu(n+1, 0), ai(3 * n);
  for (size_t i = 0; i < 3 * n; i++) {
    ll a;
    cin >> a;
    ai[i] = a;
  }
  pqueue<ll, vl, greater<ll>> mae;
  pqueue<ll, vl> ushiro;
  for (size_t i = 0; i < n; i++) {
    tm[0] += ai[i];
    mae.push(ai[i]);
  }
  for (size_t i = 2 * n; i < 3 * n; i++) {
    tu[0] += ai[i];
    ushiro.push(ai[i]);
  }
  for (size_t i = 0; i < n; i++) {
    ll min_mae = mae.top(), max_ushiro = ushiro.top();
    if (min_mae < ai[n+i]) {
      mae.pop(); mae.push(ai[n+i]);
      tm[i+1] = tm[i] - min_mae + ai[n+i];
    } else {
      tm[i+1] = tm[i];
    }
    if (max_ushiro > ai[2*n-1-i]) {
      ushiro.pop(); ushiro.push(ai[2*n-1-i]);
      tu[i+1] = tu[i] - max_ushiro + ai[2*n-1-i];
    } else {
      tu[i+1] = tu[i];
    }
  }
  for (size_t i = 0; i < n+1; i++) {
    ll tmpans = tm[i] - tu[n-i];
    if (ans < tmpans) {
      ans = tmpans;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6516
import sys
sys.setrecursionlimit(2000000)


n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
    for j in range(len(a[0])):
        a[i][j] -= 1

visited = [[-1] *(len(a[0])) for i in range(n)]
memo = [[-1] * (n) for i in range(n)]

for i in range(n):
    for j in range(len(a[0])):
        memo[i][a[i][j]] = j

def solve(i_me, j_me, rec_times):
    if rec_times >= 10000:
        print(-1)
        exit()
    i_you = a[i_me][j_me]
    j_you = memo[i_you][i_me]
    
    if visited[i_me][j_me] > 0 and visited[i_you][j_you] > 0:
        return max(visited[i_me][j_me], visited[i_you][j_you])

    if j_me == 0 and j_you == 0:
        visited[i_me][j_me] = 1
        visited[i_you][j_you] = 1
        return 1
    
    if j_you == 0:
        day = solve(i_me, j_me - 1, rec_times + 1) + 1
    elif j_me == 0:
        day = solve(i_you, j_you - 1, rec_times + 1) + 1    
    else:
        day = max(solve(i_me, j_me - 1, rec_times + 1), solve(i_you, j_you - 1, rec_times + 1)) + 1
    visited[i_me][j_me] = day
    visited[i_you][j_you] = day
    return day
    
for i in range(n):
    solve(i, len(a[0]) - 1, 0)
ans = 0
for i in range(n):
    ans = max(ans,visited[i][-1])
print(ans)


Measured memory_bytes: 92508
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define endl 		"\n"
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1) {std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " : " << arg1;
	ZZ(comma, args...);
}
#define MAXN   10000001
int spf[MAXN];
void sieve()
{
	spf[1] = 1;
	for (int i = 2; i < MAXN; i++)
		spf[i] = i;
	for (int i = 4; i < MAXN; i += 2)
		spf[i] = 2;
	for (int i = 3; i * i < MAXN; i++)
	{
		if (spf[i] == i)
		{
			for (int j = i * i; j < MAXN; j += i)
				if (spf[j] == j)
					spf[j] = i;
		}
	}
}

set<int> getFactorization(int x)
{
	set<int> s;
	while (x != 1)
	{
		// ret.push_back(spf[x]);
		s.insert(spf[x]);
		x = x / spf[x];
	}
	return s;
}
ll f(ll i) {
	set<int> s = getFactorization((int)i);
	ll ans = 1;
	for (auto k : s) {
		int e = 0;
		while (i % k == 0) {
			i /= k;
			e++;
		}
		ans *= (e + 1);
	}
	return ans;
}
void solve() {
	ll n;
	cin >> n;
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		// trace(i, f(i))
		ans = ans + (i * f(i));
	}
	// trace(f)
	cout << ans;
}
int main() {
	fast_io;
	int t = 1;
	// cin>>t;
	sieve();
	while (t--) {
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 42652
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <algorithm>
using namespace std;

const int mod = 1000000007;
int main () {
	vector<long long int> v(26, 0);
	int n;
	string s;
	cin >> n;
	cin >> s;
	for (int i = 0; i < n; i++) {
		v[s[i] - 'a']++;
	}
	long long int res = 1;
	for (int i = 0; i < 26; i++) {
		res = res * (v[i] + 1) % mod;
	}
	cout << (res - 1 + mod) % mod;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,i,j,s;
int main()
{
	cin>>n;
	n++;
	while (n>=10)
	{
		s+=9;
		n/=10;
	}
	cout<<s+n-1;
	return 0;
}

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

#define LL long long int
#define L long int
#define IM INT_MAX
#define Im INT_MIN
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define read  freopen("input.txt", "r", stdin)
#define write freopen("output.txt", "w", stdout)


int main()
{

int n;

cin>>n;

vector<LL>v;

for(int i=0;i<n;i++){
    int x;
    cin>>x;
    v.push_back(x);
}

LL ans=0;

for(int i=0;i<n-1;i++){
    if(v[i]>v[i+1]){
        ans+=(v[i]-v[i+1]);
        v[i+1]+=(v[i]-v[i+1]);
    }
}

cout<<ans;

return 0;
}


Measured memory_bytes: 5300
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

long mod = 1000000007;
/* C++の構造体 メンバがpublicなclass */
typedef struct mint
{
    ll x;
    mint(ll x = 0) : x(x % mod) {} //コンストラクタ
    /* 演算子オーバーロード */
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
} mint_t;

ll intpow(mint_t m, int n)
{
    if (n == 0) return 1;
    mint_t ans(1);
    while (n >= 1)
    {
        if ((n % 2) == 0){
            m *= m.x;
            n /= 2;
        }else {
            ans *= m.x;
            n -= 1;
        }
    }
    return ans.x;
}


int main()
{
    ll n, k;
    cin >> n >> k;

    mint ans = 0;

    for (ll i = k; i <= n+1; i++)
    {
        mint tmpk = i;
        tmpk *= i-1;
        mint tmp = i;
        tmp *= n;
        tmp -= tmpk;
        tmp += 1;
        //cout << tmp.x << endl;
        ans += tmp;
    }
    cout << ans.x << endl;

}



Measured memory_bytes: 3636
N=input()
N=int(N)
M=list(map(int,input().split()))

for i in range(N):
  M[i]=M[i]-(i+1)

M.sort()

if N%2==0:
  p=int((M[int(N/2)-1]+M[int(N/2)])/2)
else:
  p=M[int((N+1)/2)-1] 

sum=0
for i in range(N):
  sum=sum+abs(M[i]-p)

  
print(sum)



Measured memory_bytes: 26128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll MOD=1e9+7;
const ll INF=1ll<<60;


//　定数, 変数 *********************************************
int N,M;
// *********************************************************
int main(){

    // 入力スタンダード
    cin >> N >> M;

    vector<vector<int>> G(N);
    for(int i=0; i<M; i++){
        int a,b;
        cin >> a >> b;
        a--; //配列用に減算
        b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    
    queue<pair<int, int>> que;
    que.push({0, -1});
    vector<bool> visit(N,0); // {0, 0, 0, .... ,0} N個の0
    visit[0]=1;
    vector<int> ans(N);
    while(!que.empty()){
        pair<int, int> p = que.front();
        que.pop();
        int pos = p.first;
        ans[pos] = p.second + 1;
        for(int nx: G[pos]){ //今いる部屋posからたどる道全てについてまわす
            if(!visit[nx]){
                visit[nx] = 1;
                que.push({nx, pos});
            }
        }

    }

    cout << "Yes" <<endl;
    for(int i=1; i<N; i++){
        cout << ans[i] << endl;
    }




    return 0;
}

Measured memory_bytes: 10756
N,A,B,C = map(int,input().split(" "))
l = []
none = 10**6
for i in range(N):
    l.append(int(input()))


def dfs(cur,a,b,c):
    if cur == N:
        return abs(A-a) + abs(B-b) + abs(C-c) - 30 if min(a,b,c) > 0 else none

    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l[cur],b,c) + 10
    ret2 = dfs(cur+1,a,b+l[cur],c) + 10
    ret3 = dfs(cur+1,a,b,c+l[cur]) + 10

    return min(ret0,ret1,ret2,ret3)

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


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.next().equals("H") ? 1 : -1;
        int b = sc.next().equals("H") ? 1 : -1;
        
        System.out.println(a*b==1?"H":"D");
    }
}


Measured memory_bytes: 21204
class UnionFind:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n
 
    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

    def count(self, x):
        return -self.table[self._root(x)]
 
    def find(self, x, y):
        return self._root(x) == self._root(y)
 
    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1

N, M = map(int, input().split())
p = [int(i) for i in input().split()]
d = dict()
ins = UnionFind(N)
for i in range(M):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    ins.union(x, y)

ans = 0
for i, x in enumerate(p):
    if ins.find(i, x-1):
        ans += 1
print(ans)

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

using ll = long long int;
using P = std::pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rag(con) std::begin(con), std::end(con)

constexpr int MAX = 1e6 + 10;

int pb[MAX];

int gcd(int a, int b)
{
    if (a < b)
        std::swap(a, b);
    return (b == 0) ? a : gcd(b, a % b);
}

int main()
{
    int n;

    std::cin >> n;

    int g = -1;

    rep(i, n)
    {
        int a;
        std::cin >> a;
        if (g < 0)
            g = a;
        else
            g = gcd(g, a);
        int x = 2;
        while (a >= x * x)
        {
            if (a % x == 0)
            {
                while (a % x == 0)
                    a /= x;
                ++pb[x];
            }
            ++x;
        }
        if (a > 1)
        {
            pb[a]++;
        }
    }

    /*rep(i, 10)
            std::cerr
        << pb[i] << ' ';
    std::cerr << std::endl;*/

    for (int i = 1; i < MAX; ++i)
    {
        if (pb[i] > 1)
        {
            if (g == 1)
                std::cout << "setwise coprime" << std::endl;
            else
            {
                std::cout << "not coprime" << std::endl;
            }
            return 0;
        }
    }

    std::cout << "pairwise coprime" << std::endl;

    return 0;
}

Measured memory_bytes: 7328
#include<stdio.h>
main(){
	double a,b,c,d,e,f,x,y;
	while(1){
	
		if(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) == EOF) break;
		
		y=(a*f-d*c)/(-d*b+a*e);
		x=(c-b*y)/a;
		
		printf("%.3f %.3f\n",x,y);
	}
	
	return 0;
}

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

int main(){
  int n,l,answer;
  cin >> n >> l;
  answer = n * l;
  for(int i; i < n; i++){
     answer += i;
  }
  if(l < 0 && l < -n + 1)
    answer -= (l + n -1);
  if(l > 0)
    answer -= l;
  cout << answer << endl;
}
             
            
          
      
    


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#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 repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

const string key[10]= {
  " ","',.!?",
  "abcABC","defDEF","ghiGHI","jklJKL",
  "mnoMNO","pqrsPQRS","tuvTUV","wxyzWXYZ"
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  while(cin >> s){
    ll c =0;
    char m = s[0];
    string ans;
    if(s.back() != '0')
      s += '0';
    rep(i,s.size()){
      if(s[i] == '0'){
        m = s[i];
        c = 0;
        ++i;
        while(m == s[i]){
          ans += ' ';
          ++i;
        }
        --i;
      }
      else{
        m = s[i];
        c = 0;
        while(m == s[i]){
          ++c;
          ++i;
        }
        --c;
        ans += key[m-'0'][c];
        --i;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3172
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let mut a = v[0];
	let mut b = v[1];
	if a == 1 {
		a += 13;
	}
	if b == 1 {
		b += 13;
	}
	if a < b {
		println!("Bob");
	}else if a > b {
		println!("Alice");
	}else{
		println!("Draw");
	}
}

Measured memory_bytes: 4352
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  S[K - 1] += 'a' - 'A';
  string ans = S;
  cout << ans << endl;
  return 0;
}


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

int main(){
    int r,d,x2000;
    int preans=0,ans=0;

    cin >> r >> d >> x2000;

    preans = x2000;
    for (int i=0; i<10; i++){
        ans = (r*preans)-d;

        cout << ans <<endl;

        preans = ans;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N;
	cin >> N;
	vector<ll> A(N + 1), B(N);
	REP(i, N + 1) cin >> A[i];
	REP(i, N) cin >> B[i];
	ll res = 0;
	REP(i, N) {
		if (A[i] < B[i]) {
			res += A[i];
			B[i] -= A[i];
			if (A[i + 1] > B[i]) {
				A[i + 1] -= B[i];
				res += B[i];
			}
			else {
				res += A[i + 1];
				A[i + 1] = 0;
			}
		}
		else {
			res += B[i];
		}
	}
	cout << res << endl;
	
	return 0;
}


Measured memory_bytes: 1792
/*  ex7-1
    toshiwaka */

//point構造体
typedef struct point{
    int x_elem;
    int y_elem;
}point;

//ref_pointからx,y軸方向にshift_x,shift_yだけそれぞれ移動
//移動後の点の座標をshifted_pointのメンバに代入
void shift_point(point *shifted_point, point *ref_point, int shift_x, int shift_y);

#include <stdio.h>

int main(void) {
  //point:正方形の頂点
  //diff:2点間のx,y軸方向の距離
  point vertex[4], diff;

  //入力
  scanf("%d %d %d %d", &vertex[0].x_elem, &vertex[0].y_elem, &vertex[1].x_elem, &vertex[1].y_elem);

  //2点間のx,y軸方向の距離
  diff.x_elem = vertex[1].x_elem - vertex[0].x_elem;
  diff.y_elem = vertex[1].y_elem - vertex[0].y_elem;

  //残りの２点を算出
  shift_point(&vertex[2], &vertex[1], -1 * diff.y_elem, diff.x_elem);
  shift_point(&vertex[3], &vertex[0], -1 * diff.y_elem, diff.x_elem);

  //出力
  printf("%d %d %d %d\n", vertex[2].x_elem, vertex[2].y_elem, vertex[3].x_elem, vertex[3].y_elem);

  return 0;
}


//ref_pointからx,y軸方向にshift_x,shift_yだけそれぞれ移動
//移動後の点の座標をshifted_pointのメンバに代入
void shift_point(point *shifted_point, point *ref_point, int shift_x, int shift_y){
  shifted_point->x_elem = ref_point->x_elem + shift_x;
  shifted_point->y_elem = ref_point->y_elem + shift_y;
};

Measured memory_bytes: 1684
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef double Weight;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

Matrix mat(15, Array(15));
vector<vector<Weight> > best(1<<15,vector<Weight>(15, INF));
vector<vector<int> >    prev(1<<15,vector<int>(15));

int main() {
  int n;
  cin >> n;
  
  int a[n], l[n], m[n];
  REP(i,n)
    cin >> a[i] >> l[i] >> m[i];

  REP(i,n)
    REP(j,n)
    mat[i][j] = abs(l[j]-l[i]);

  int N = 1<<n;

  REP(i,n) best[1<<i][i] = 0;
  REP(S,N) {
    int we = 0;
    REP(i,n) // ツ個サツ催敖づ個重ツつウツづーツ計ツ算
      if (S&(1<<i))
        we += m[i];
    we = 70 + 20 * we;
    REP(i,n)
      if (S&(1<<i))
        REP(j,n) {
          if (best[S|(1<<j)][j] > best[S][i] + mat[i][j] / 2000.0 * we) {
            best[S|(1<<j)][j] = best[S][i] + mat[i][j] / 2000.0 * we;
            prev[S|(1<<j)][j] = i;
          }
        }
  }

  vector<int> path;
  int t = min_element(ALL(best[N-1])) - best[N-1].begin(); // ツ可スツ氾板姪堋づ個陳クツ点ツづ終ツづュツづゥツづ個つェツ暗ェツ氾板短ツつュツづ按づゥツつゥ

  int S = N-1;
  int count = 0;
  while(S) {
    path.push_back(t);
    int tmp = prev[S][t];
    S ^= (1<<t);
    t = tmp;
    count++;
    if (count == n) break;
  }
  reverse(ALL(path));

  REP(i, path.size()) {
    if (i)
      cout << " ";
    cout << a[path[i]];
  }
  cout << endl;
}

Measured memory_bytes: 7792
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int n = parseInt(sc.next());
		int[] d = new int[n];
		for(i=0;i<n;i++) {
			d[i] = parseInt(sc.next());
		}
		sc.close();
		Arrays.sort(d);
		System.out.println(d[n/2]-d[n/2-1]);
	}
}


Measured memory_bytes: 50200
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

//        int n=sc.nextInt();
        String s=sc.nextString(),h="hi",x=h;
        for (int i = 0; i < 11; i++) {
			if(s.equals(h))ret("Yes");
			h+=x;
		}
    
        out.println("No");
     	out.flush();
    }
    
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,y; double d;
//	P(int  x, int y, double d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}


class P implements Comparable<P>{
    int i,x,r,f;
    P(int i,int x,int r,int f) {
    	this.i=i;
    	this.x=x;
    	this.r=r;
    	this.f=f;
    }

    public int compareTo(P p){
    	if(-this.r+p.r==0) {
    		return -this.x+p.x;
    	}
        return -this.r+p.r;
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 25300
use warnings;
use strict;

my $temp = <STDIN>;
chomp $temp;
my $temps = <STDIN>;
chomp $temps;
my @nums = split (" ", $temps);
my @numssort = sort {$b <=> $a} @nums;

my %count;
$count{"0"} = 0;
my $prevnum=0;
my $answer=0;


foreach(@numssort){
   if($_ == $prevnum){
      $count{$_}++;
   }else{
      $count{$_} = 1;
      if ($count{$prevnum} - $prevnum >= 0){
         $answer = $answer + $count{$prevnum} - $prevnum;
      }else{
         $answer = $answer + $count{$prevnum};
      }
   }
   $prevnum = $_;
}

if ($count{$prevnum} - $prevnum >= 0){
         $answer = $answer + $count{$prevnum} - $prevnum;
      }else{
         $answer = $answer + $count{$prevnum};
      }

print $answer, "\n";

Measured memory_bytes: 36912
use std::io::{self, BufRead};

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let n: usize = lines.next().unwrap().unwrap().parse().unwrap();
  let mut xs: Vec<(usize, usize)> = Vec::new();
  for _ in 0..n {
    let ys: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
    xs.push((ys[0], ys[1]));
  }
  xs.sort_by(|x, y| x.1.cmp(&y.1));
  let mut sum: usize = 0;
  for i in 0..n {
    sum += xs[i].0;
    if xs[i].1 < sum {
      println!("No");
      return;
    }
  }
  println!("Yes");
}

Measured memory_bytes: 9284
#include <stdio.h>
#include <stdlib.h>

int num_choice(int n, int a[], long nums[], long comb[]);
long comb2(long a);
int main(void);

int num_choice(int n, int a[], long nums[], long comb[]){
    int ii1;
    for(ii1=0; ii1<n; ii1++){
       nums[a[ii1]-1]++;
    }
    for(ii1=0; ii1<n; ii1++){
       comb[ii1] = comb2(nums[ii1]);
    }
    return 0;
}

long comb2(long a){
    return (a*(a-1))/(long)2;
}

int main(void){
    int n, ii1, k=0;
    long sum, sum_a=0;
    scanf("%d", &n);
    int a[200000];
    for(ii1=0; ii1<n; ii1++)
        scanf("%d", &a[ii1]);
    long nums[200000] = {0};
    long comb[200000];
    num_choice(n, a, nums, comb);
    for(ii1=0; ii1<n; ii1++){
        sum_a += comb[ii1];
    }
    for(ii1=0; ii1<n; ii1++){
        sum = sum_a - comb[a[ii1]-1] + comb2(nums[a[ii1]-1]-1);
        printf("%ld\n", sum);
    }

    return 0;
}


Measured memory_bytes: 6400
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

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

n = ri()
c = collections.Counter([rr()[0] for _ in range(n)])
d = [v for k, v in c.items() if k in 'MARCH']
ans = 0
if len(d) >= 3:
    for lis in itertools.combinations(d, 3):
        a, b, c = lis
        ans += a*b*c
    print(ans)
else:
    print(0)


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

int main() {
    int a,b,k;
    cin >> a >> b >> k;
    if((b-a+2)/2 <= k){
        for(int i=a;i<=b;i++)cout << i << endl;
    }
    else{
        for(int i=a;i<a+k;i++)cout << i << endl;
        for(int i=b-k+1;i<=b;i++)cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
P = list(map(int, input().split()))


class UnionFind:
    def __init__(self, n):
        self.p = [-1]*n
        self.r = [1]*n

    def find(self, x):
        if self.p[x] < 0:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def union(self, x, y):
        rx, ry = self.find(x), self.find(y)
        if rx != ry:
            if self.r[rx] > self.r[ry]:
                rx, ry = ry, rx
            if self.r[rx] == self.r[ry]:
                self.r[ry] += 1
            self.p[ry] += self.p[rx]
            self.p[rx] = ry

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


uf = UnionFind(n)
for _ in range(m):
    x, y = list(map(lambda x: int(x)-1, input().split()))
    uf.union(x, y)

ans = 0
for i in range(n):
    p = P[i]
    if uf.same(p-1, i):
        ans += 1
print(ans)

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

int main() {

  string s;
  string alphabet = "abcdefghijklmnopqrstuvwxyz";

  cin >> s;
  int count;
  

  for(string::iterator iter_a = alphabet.begin(); iter_a != alphabet.end(); iter_a++){ 
    count = 0;
    for(string::iterator iter = s.begin(); iter != s.end(); iter++) {
      if(*iter == *iter_a) {
	count++;
      }
    }
    if (count>=2) {
      cout << "no" << endl;
      return 0;
    }
  }
  
  cout << "yes" << endl;
  return 0;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10,p=1e9+7;
int inc(int x,int y){x+=y;return x>=p?x-p:x;}
int mul(int x,int y){return (ll)x*y%p;}
int n,a[N],cir[N],link[N],len[N],top[N];
bool ok[N];
int length(int x){
	if (top[x]) return link[x];
	link[x]=length(a[x])+1;
	top[x]=top[a[x]];
	return link[x];
}
int cnt[N];
void init(){
	static int vis[N],deg[N];
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),deg[a[i]]++;
	for (int i=1;i<=n;i++)
	if (!vis[i]){
		int j=i;
		while (!vis[j]) vis[j]=i,j=a[j];
		if (vis[j]!=i) continue;
		int p=j;
		for (cir[p]=p,j=a[j];j!=p;cir[j]=p,j=a[j]);
	}
	for (int i=1;i<=n;i++)
		if (cir[i]) len[cir[i]]++,top[i]=i;
	for (int i=1;i<=n;i++) length(i);
	for (int i=1;i<=n;i++){
		if (deg[i]>2) puts("0"),exit(0);
		if (deg[i]>1&&!cir[i]) puts("0"),exit(0);
	}
	for (int i=1;i<=n;i++) link[top[i]]=max(link[top[i]],link[i]);
	for (int i=1;i<=n;i++)
		if (link[i]) ok[cir[top[i]]]=1;
	for (int i=1;i<=n;i++)
		if (!ok[i]&&len[i]) cnt[len[i]]++;
}
typedef pair<int,int> pii;
int calc(int L,int n){
	static map<pii,int> M;
	if (!n) return 1;
	pii now(L,n);
	if (M.count(now)) return M[now];
	int ans=calc(L,n-1);
	if ((L&1)&&L>1) ans=inc(ans,ans);
	if (n>1) ans=inc(ans,mul(mul(L,(n-1)),calc(L,n-2)));
	return M[now]=ans;
}
int q[N],size;
int Calc(){
	static int cnt[N];
	for (int i=0;i<=size*2;i++) cnt[i]=0;
	for (int i=1;i<=size;i++)
		if (q[i]>size) return 0;
	for (int i=1;i<=size;i++) cnt[size+i-q[i]]++,cnt[size+i]--;
	for (int i=1;i<=size*2;i++) cnt[i]+=cnt[i-1];
	for (int i=1;i<=size;i++) cnt[i]=cnt[i+size]=cnt[i]+cnt[i+size];
	cnt[0]=cnt[size];
	for (int i=1;i<=size;i++)
		if (cnt[i]>1) return 0;
	int ans=1;
	for (int i=1;i<=size;i++)
		if (q[i]&&!cnt[size+i-q[i]-1]) ans=inc(ans,ans);
	return ans;
}
int main()
{
	init();
	int ans=1;
	for (int i=1;i<=n;i++)
		if (cnt[i]) ans=mul(ans,calc(i,cnt[i]));
	for (int i=1;i<=n;i++)
	if (ok[i]&&len[i]){
		q[size=1]=link[i];
		for (int j=a[i];j!=i;j=a[j]) q[++size]=link[j];
		ans=mul(ans,Calc());
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 20992