akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**9)

N, P = list(map(int, input().split()))
S = input()

if P == 2 or P == 5:
    ans = 0
    for i in range(N):
        if int(S[i]) % P == 0:
            ans += i + 1
    print(ans)
    sys.exit()

num = [0] * P
num[0] = 1
now, ans = 0, 0
_10 = 1
for i in range(N-1, -1, -1):
    now = (now + int(S[i]) * _10) % P
    _10 *= 10
    _10 %= P
    ans += num[now]
    num[now] += 1

print(ans)


Measured memory_bytes: 3500
//Apparat : drobucs, aleonov, vit_72
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <iomanip>
#include <algorithm>
#include <string>
#include <queue>
#include <numeric>
#include <stack>

//#pragma warning(disable : 4996)
//#pragma GCC optimize("O3")

using namespace std;

#define nptr nullptr
#define all(x) (x).begin(), (x).end()
#define drobucs ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define ff first
#define ss second
#define pbb push_back
#define sz(x) (int)(x).size()

typedef long long ll;

const int maxn = (int)1e6 + 13;
const ll INFL = 9e18 + 13ll;
const ll INF = 2e9 + 13;
const ll MOD = (int)1e9 + 7, MOD2 = 998244353;//1e9 + 21, 1e9 + 33, 1e9 + 87, 1e9 + 93
const ll base = 101, base2 = 37;

ll a[13][13];

int main() {
    drobucs;

    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        int m = i;
        while (m >= 10)m /= 10;
        a[m][i % 10]++;
    }
    ll ans = 0;
    for (int i = 1; i <= 9; ++i)
        for (int j = 1; j <= 9; ++j)
            ans += a[i][j] * a[j][i];
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3604
import java.util.*;
public class Main {
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args) {
 
    while(kbd.hasNext()){
        int n = kbd.nextInt();
        int x = kbd.nextInt();
        int z=0;
        if(!(n==0 && x==0)){
        for(int a=1; a<=n-2; a++){
            for(int b=2; b<=n-1; b++){
            for(int c=3; c<=n; c++){
                //System.out.println(a+" "+b+" "+c);
                if(m(a,b,c,x)) z++;
            }
            }
        }
        System.out.println(z);
        }
    }
    }
    static boolean m(int a, int b, int c, int x){
    boolean p = a+b+c==x;
    boolean q = a<b && b<c;
    return p&&q;
    }
}

Measured memory_bytes: 19624
h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]

ans = 0
for row in range(2 ** h):
    for col in range(2 ** w):
        a = [[0 for _ in range(w)] for _ in range(h)]
        for i in range(h):
            for j in range(w):
                if row & (1 << i) or col & (1 << j):
                    a[i][j] = '.'
                else:
                    a[i][j] = c[i][j]
        black = 0
        for line in a:
            for cell in line:
                if cell == '#':
                    black += 1
        if black == k:
            ans += 1
print(ans)

Measured memory_bytes: 9136
loop {
  a, b = gets.split.map &:to_i
  break if a == 0
  x = gets.to_i.times.map { Complex(*gets.split) }
  dp = Hash.new 0
  dp[1 + 1i] = 1
  (1..a).each {|i|
    (1..b).each {|j|
      z = Complex(i, j)
      if !x.include?(z)
        dp[z] += dp[z-1] + dp[z-1i]
      end
    }
  }
  p dp[Complex(a, b)]
}



Measured memory_bytes: 6924
#include <iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define ll long long
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define mem(a,t) memset(a,t,sizeof(a))
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define sz(v) ((int)sizeof(v))
const int inf=1e9;
const int N=1e5+5;
const int mod=1e9+7;
vector<pair<int,int> >a,b;
vector<pair<int,pair<int,int> > >g;
vector<int>pre;
int findd(int k){
    if(k!=pre[k])
        pre[k]=findd(pre[k]);
    return pre[k];
}
int main(){
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    pre.resize(n);
    rep(i,0,n) pre[i]=i;
    rep(i,0,n){
        int x,y;
        cin>>x>>y;
        a.pb(mp(x,i));
        b.pb(mp(y,i));
    }
    sort(all(a));
    sort(all(b));
    for(int i=1;i<n;++i){
        int t=abs(a[i].fi-a[i-1].fi);
        g.pb(mp(t,mp(a[i-1].se,a[i].se)));
        t=abs(b[i].fi-b[i-1].fi);
        g.pb(mp(t,mp(b[i-1].se,b[i].se)));
    }
    sort(all(g));
    int cnt=0;
    ll ans=0;
    rep(i,0,g.size()){
        int u,v;
        u=g[i].se.fi;
        v=g[i].se.se;
        int f1=findd(u);
        int f2=findd(v);
        if(f1!=f2){
            pre[f1]=f2;
            ++cnt;
            ans+=g[i].fi;
            if(cnt==n-1) break;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    string s, t;
    cin >> s >> t;
    int len = t.size();
    bool ok = false;
    while(len--){
        if(s == t){
            ok = true;
            break;
        }
        rotate(begin(t), begin(t)+1, end(t));
    }
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
int main(){
     
  int N;
     
  cin>>N;
     
  string str[10001];
     
  long long cnt=0;
     
  long long temp1=0,temp2=0,temp3=0;
      
  for(int i=0;i<N;i++){
	cin>>str[i];
     
	for(int j=0;j<str[i].length();j++){
	  if(str[i][j]=='A'&&str[i][j+1]=='B'){
		cnt++;
	  }
	}
     
	if(str[i][0]=='B'&str[i][str[i].length()-1]=='A'){
	  temp3++;
	  continue;
	}
    	  
	if(str[i][0]=='B'){
	  temp1++;
	}
     
	if(str[i][str[i].length()-1]=='A'){
	  temp2++;
	}
    	
  }

  if(temp3>=1){
	if(temp1<temp2){
	  if(temp2>=1){
		cout<<cnt+temp1+temp3<<endl;
	  }else{
		cout<<cnt+temp1<<endl;
	  }
	}else if(temp1>temp2){
	  if(temp1>=1){
		cout<<cnt+temp2+temp3<<endl;
	  }else{
		cout<<cnt+temp2<<endl;
	  }
	}else{
	  if(temp1>=1||temp2>=1){
		cout<<temp1+cnt+temp3<<endl;
	  }else {
		cout<<temp1+cnt+temp3-1<<endl;
	  }
	}
  }else{
    	
	cout<<cnt+min(temp1,temp2)<<endl;
     
  }
      
    		
    		  
  return 0;
}


Measured memory_bytes: 768
#![allow(non_snake_case)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

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

fn main() {
    input!(
        s: chars,
    );
    let len = s.len();
    if len % 2 != 0 {
        println!("No");
        return;
    } 
    for i in 0..(len/2) {
        if !((s[i*2] == 'h') && (s[i*2+1] == 'i')) {
            println!("No");
            return;
        }
    }
    println!("Yes");
}



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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> snuke(n, 0);
    rep(i,k) {
        int d;
        cin >> d;
        rep(j,d) {
            int a;
            cin >> a;
            snuke[a-1] = 1;
        }
    }
    int ans = snuke.size() - accumulate(snuke.begin(), snuke.end(), 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]

for i in range(0, 1000):
    number_str = str(i)
    if len(number_str) == N:
        for j in range(M):
            if number_str[sc[j][0]-1] == str(sc[j][1]):
                pass
            else:
                break
        else:
            print(i)
            break
else:
    print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int a, b, c;
    std::cin>>a>>b>>c;

    int ans;
    if(a == b){
        ans = c;
    }else if(a == c){
        ans = b;
    }else{
        ans = a;
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = INT64_MAX;

ll dp[100], bstX[35000][20], bstY[35000][20];

vector<vector<ll>> gr, psh;
vector<set<ll>> s;

ll gcd(ll a, ll b) {
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}

set<ll> ss;

void debug() {
	debug();
}

vector<ll> vec;

bool solve() {
	vector<ll> pr, suf;
	pr.push_back(0);
	suf.push_back(0);
	ll cnt = 0, val = 0, s = 0;
	for (int i = 0; i < vec.size(); i++) {
		if (vec[i] != 1) {
			cnt++;
			val = vec[i];
		}
		pr.push_back(gcd(pr.back(), vec[i]));
		s += vec[i] - 1;
	}

	if (cnt == 0) return false;
	if (cnt == 1 && val == 2) return true;
	for (int i = vec.size() - 1; i >= 0; i--) {
		suf.push_back(gcd(suf.back(), vec[i]));
	}

	reverse(suf.begin(), suf.end());

	for (int i = 0; i < vec.size(); i++) {
		if (vec[i] == 1) continue;
		ll g = gcd(pr[i], suf[i + 1]);
		g = gcd(g, vec[i] - 1);
		if (g != 1) {
			vec[i]--;
			for (int j = 0; j < vec.size(); j++) {
				vec[j] /= g;
			}
			bool k = solve();
			for (int j = 0; j < vec.size(); j++) {
				vec[j] *= g;
			}
			vec[i]++;
			if (!k) return true;
		}
	}

	if (s % 2 == 0) {
		return false;
	}
	else {
		return true;
	}
}

int main()
{
	fastInp;

	ll n;
	cin >> n;

	vec.resize(n);

	ll s = 0;
	for (int i = 0; i < n; i++) {
		cin >> vec[i];
		s += vec[i] - 1;
	}
	
	if (n % 2 == 0) {
		if (s % 2 == 0) {
			cout << "Second";
		}
		else {
			cout << "First";
		}
	}
	else {
		if (s % 2 == 0) {
			if (solve()) {
				cout << "First";
			}
			else {
				cout << "Second";
			}
		}
		else {
			cout << "First";
		}
	}

	return 0;
}

Measured memory_bytes: 42252
#!/usr/bin/env python3

import sys
import pprint
import math

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(0)
	a, b, h, m = map(int, sys.stdin.readline().split())
	log.print(a, b, h, m)
	mk = math.radians(360 - (360 / 60) * m)
	mx = math.cos(mk) * b
	my = math.sin(mk) * b
	hk = math.radians(360 - (360 / 12) * h - (360 / 12) * (m / 60))
	hx = math.cos(hk) * a
	hy = math.sin(hk) * a
	log.print(math.degrees(hk), math.degrees(mk), hx, hy, mx, my, )
	print(math.sqrt((hx-mx)**2+(hy-my)**2))


	


main()

Measured memory_bytes: 72384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s, p;
    cin >> s >> p;
    int c = 0;
  	if (s == p) {
    	cout << 0;
    }
  	else {
      for (int i=0;i<s.size();i++) {
          if (s[i] != p[i]) {
              c += 1;
          }
      }

      cout << c;
    }
}

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

int main(void){
    int n;
    cin>>n;
    vector<int> A(n);
    rep(i,n) cin>>A[i];
    sort(A.begin(),A.end(),greater<int>());
    long long sum=A[0];//初めの二人
    rep(i,n-2) sum+=A[1+i/2];
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 4040
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265358979

using namespace std;
typedef pair<long long int, long long int> P;




int main(void) {
	long long int h, w, n;
	long long int a, b;
	long long int count[10] = {};
	long long int point = 0;
	long long int mas = 1;
	long long int p;

	cin >> h >> w >> n;

	vector<P>dp(9*100001);

	FOR(i, 1, n) {
		cin >> a >> b;
		FOR(t, 0, 2) {
			FOR(s, 0, 2) {
				if (a - s >= 1 && b - t >= 1&&a-s<=h-2&&b-t<=w-2) {
					dp[point].first = a - s;
					dp[point].second = b - t;
					point++;
				}
			}
		}
	}
	count[0] = (h - 2)*(w - 2);
	sort(dp.begin(), dp.end());

	
	FOR(i, 0, dp.size() - 1) {
		if (dp[i].first != 0) {
			p = i;
			break;
		}
	}
	

	FOR(i,p+1,dp.size()-1) {
		if (dp[i].first == dp[i - 1].first&&dp[i].second == dp[i - 1].second) {
			mas++;
			if (i == dp.size() - 1) {
				count[mas]++;
				count[0]--;
			}
		}
		else {
			count[mas]++;
			if (i == dp.size() - 1) {
				count[1]++;
				count[0]--;
			}
			count[0]--;
			mas = 1;
		}
	}

	FOR(i, 0, 9) {
		cout << count[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int w, a, b;
    cin >> w >> a >> b;
    cout << max(abs(a-b)-w , 0);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(),a.end());

    cout << (a[1]-a[0])+(a[2]-a[1]) << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
h, w = map(int, input().split())
grid = np.array([list(input()) for _ in range(h)])

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

flag = False
for x in range(h):
    for y in range(w):
        if grid[x, y] == '.':
            continue
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if nx >= 0 and nx < h and ny >= 0 and ny < w:
                if grid[nx, ny] == '#':
                    break
        else:
            flag = True
            break
    if flag:
        break

if flag:
    print('No')
else:
    print('Yes')

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

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

    ll k = 0;
    while(true) {
        if(K == 0) {
            cout << '1' << endl;
            return 0;
        }
        if(S[k] == '1') {
            k++;
            K--;
        } else {
            break;
        }
    }

    cout << S[k] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
typedef struct{
  int value;
  char pattern;
}Card;
 
void BubbleSort(Card *, int);
void SelectionSort(Card *, int);
 
int main(void){
 
  int n,i,flagb=1,flags=1;
  Card cb[36],cs[36];
  char tmp;
 
  scanf("%d%c",&n,&tmp);
 
  for(i = 0 ; i < n ; i++)
    scanf("%c%d%c",&cb[i].pattern,&cb[i].value,&tmp);
 
   
  for(i = 0 ; i < n ; i++){
    cs[i] = cb[i];
  }
 
  SelectionSort(cs, n);
  BubbleSort(cb, n);
 
  for(i = 0 ; i < n ; i++){
    printf("%c%d",cb[i].pattern,cb[i].value);
    if(i!=n-1) printf(" ");
    if(cb[i].pattern != cb[i].pattern || cb[i].value != cb[i].value) flagb=0;
 
  }
 
  printf("\n");
 
  if(flagb==1) printf("Stable\n");
  else printf("Not stable\n");
 
 for(i = 0 ; i < n ; i++){
    printf("%c%d",cs[i].pattern,cs[i].value);
    if(i!=n-1) printf(" ");
    if(cs[i].pattern != cb[i].pattern || cs[i].value != cb[i].value) flags=0;
  }
 
  printf("\n");
 
  if(flags==1) printf("Stable\n");
  else printf("Not stable\n");
 
  return 0;
}
 
void BubbleSort(Card *c, int n){
 
  int i,j;
  Card tmp;
 
  for(i = 0 ; i <= n-1 ; i++){
    for(j = n-1 ; j > i ; j--){
      if(c[j].value < c[j-1].value){
    tmp = c[j];
    c[j] = c[j-1];
    c[j-1] = tmp;
      }
    }
  }
 
  return;
 
}
 
 
void SelectionSort(Card *c, int n){
 
  int i,minj,j;
  Card tmp;
 
  for(i = 0 ; i <= n-1 ; i++){
    minj = i;
    for(j = i ; j <= n-1 ; j++){
      if(c[j].value < c[minj].value){
    minj = j;
      }
    }
    tmp = c[i];
    c[i] = c[minj];
    c[minj] = tmp;
     
  }
 
  return;
 
}

Measured memory_bytes: 612
#include <iostream>
using namespace std ;
int main()
{
    int A , B ;
    string x ;
    cin >> A ;
    cin >> x ;
    cin >> B ;
    int subss = A - B ;
    int adds = A + B ;
    if (A >= 1 && B <= 10e9)
    {
        if (x == "+")
            cout << adds ;
        if (x == "-")
            cout << subss ;
    }
}





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

int num = 1;
vector<int> A;

// S[i] を c に書きかえる
void update(int i, char c) {
  i += num - 1;
  A.at(i) = 1LL << (c - 'a');  // ビットフラグ
  while (i > 0) {
    i = (i - 1) / 2;
    A.at(i) = A.at(i*2 + 1) | A.at(i*2 + 2);
  }
}

// 「区間 [a, b) でどの文字が登場するか」を保持したビットフラグを返す
int query(int a, int b, int k, int l, int r) {
  if (r <= a || b <= l) return 0;
  if (a <= l && r <= b) return A.at(k);
  else {
    int c1 = query(a, b, 2*k+1, l, (l+r)/2);
    int c2 = query(a, b, 2*k+2, (l+r)/2, r);
    return c1 | c2;
  }
}

int main() {
  int N; cin >> N;
  string S; cin >> S;
  num = 1;
  while (num < N) num *= 2;
  A = vector<int>(2*num - 1, 0);  // 完全二分木
  for (int i = 0; i < N; i++) update(i, S.at(i));

  int Q; cin >> Q;
  for (int i = 0; i < Q; i++) {
    int com; cin >> com;
    if (com == 1) {
      int idx; cin >> idx; idx--;
      char c; cin >> c;
      update(idx, c);
    }
    if (com == 2) {
      int left, right; cin >> left >> right;
      left--;
      long long bit = query(left, right, 0, 0, num);
      int cnt = 0;
      for (int i = 0; i < 26; i++) {
        if ((bit >> i) & 1) cnt++;  // i 番目のビットが立っている
      }
      cout << cnt << endl;
    }
  }
}

Measured memory_bytes: 4996
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>

using namespace std;

void judge_7(string& s) {
    vector<int> abcd(4);
    for (int i = 0; i < 4; i++)
        abcd[i] = s[i] - '0';

    if (abcd[0] + abcd[1] + abcd[2] + abcd[3] == 7) {
        cout << abcd[0] << "+" << abcd[1] << "+" << abcd[2] << "+" << abcd[3] << "=7" << endl;
        return;
    }
    else if (abcd[0] + abcd[1] + abcd[2] - abcd[3] == 7) {
        cout << abcd[0] << "+" << abcd[1] << "+" << abcd[2] << "-" << abcd[3] << "=7" << endl;
        return;
    }
    else if (abcd[0] + abcd[1] - abcd[2] + abcd[3] == 7) {
        cout << abcd[0] << "+" << abcd[1] << "-" << abcd[2] << "+" << abcd[3] << "=7" << endl;
        return;
    }
    else if (abcd[0] - abcd[1] + abcd[2] + abcd[3] == 7) {
        cout << abcd[0] << "-" << abcd[1] << "+" << abcd[2] << "+" << abcd[3] << "=7" << endl;
        return;
    }
    else if (abcd[0] + abcd[1] - abcd[2] - abcd[3] == 7) {
        cout << abcd[0] << "+" << abcd[1] << "-" << abcd[2] << "-" << abcd[3] << "=7" << endl;
        return;
    }
    else if (abcd[0] - abcd[1] + abcd[2] - abcd[3] == 7) {
        cout << abcd[0] << "-" << abcd[1] << "+" << abcd[2] << "-" << abcd[3] << "=7" << endl;
        return;
    }
    else if (abcd[0] - abcd[1] - abcd[2] + abcd[3] == 7) {
        cout << abcd[0] << "-" << abcd[1] << "-" << abcd[2] << "+" << abcd[3] << "=7" << endl;
        return;
    }
    else if (abcd[0] - abcd[1] - abcd[2] - abcd[3] == 7) {
        cout << abcd[0] << "-" << abcd[1] << "-" << abcd[2] << "-" << abcd[3] << "=7" << endl;
        return;
    }
}
int main() {
    string s;
    cin >> s;
    judge_7(s);
    
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
int main()
{
    int n ;
    cin >> n ;
    int nn = n ;

    int sum = 0 ;
    while( n )
    {
        sum += n%10 ;
        n /= 10 ;
    }
   // cout << sum << endl ;
    if(nn % sum  == 0)
        cout << "Yes" << endl ;
    else cout << "No" << endl ;

}


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


int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n)
    cin >> a[i];
  int m = 0;
  vector<int> ans(n);
  for (int i=n; i>0; i--)
  {
    int s = 0;
    for (int j = n - 1 - n % i; j > i - 1; j -= i)
      s += ans[j];
    ans[i-1] = (a[i-1] ^ s % 2) & 1;
    m += ans[i-1];
  }
  printf("%d\n", m);
  int id = 0;
  while (id < n && ans[id] == 0)
    id++;
  if (id < n)
  {
    printf("%d", id + 1);
    for (int i=id+1; i<n; i++)
      if (ans[i] == 1)
        printf(" %d", i + 1);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 2432
X = int( input() )

cnt = 0

n5 = 0
n4 = 0
n3 = 0
n2 = 0
n1 = 0
n0 = 0

while X >= 100:
  if( (X % 100) % 5 == 0 and (X % 100) != 0 ): #5の倍数
    X -= 105
    n5 += 1
  elif( (X % 100) % 4 == 0 and (X % 100) != 0 ): #4の倍数
    X -= 104
    n4 += 1
  elif( (X % 100) % 3 == 0 and (X % 100) != 0 ): #4の倍数
    X -= 103
    n3 += 1
  elif( (X % 100) % 2 == 0 and (X % 100) != 0 ): #4の倍数
    X -= 102
    n2 += 1
  elif( (X % 100) % 1 == 0 and (X % 100) != 0 ): #4の倍数
    X -= 101
    n1 += 1
  else:
    n0 = n0 + X / 100
    X = 0
    break
    
if( X == 0 ):
  print("1")
else:
  print("0")
  
#print("^^")
#print(n5)
#print(n4)
#print(n3)
#print(n2)
#print(n1)
#print(n0)

Measured memory_bytes: 39856
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	char s[100005];
	while(~scanf("%s",s))
	{
		int a,m=0;
		a=strlen(s);
		for(int i=1;i<a;i++)
		{
			if(s[i]!=s[i-1])
			m++;	
		}
		printf("%d\n",m);	
	}
	return 0;
} 

Measured memory_bytes: 384
import scala.math.min
object Main {
  def main(args:Array[String]) = {
    
    // printf("%d\n", b(Array(218, 233, 389, 645, 704, 728), 2, 5, v => v < 218+233))
    // System.exit(0)

    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val lines = Array.fill(n)(sc.nextInt).sorted
    var sum = 0
    for(i <- 0 to lines.size-1) {
      for(j <- i+1 to lines.size-2) {
        val r  = b(lines, j+1, lines.size-1, v => v < lines(i)+lines(j))
        sum += r
        // printf("%d:%d -> %d\n", lines(i), lines(j), r)
      }
    }
    println(sum)
  }
  def b(ar:Array[Int], start:Int, end:Int, f: Int=> Boolean): Int = {
    // @scala.annotation.tailrec
    def b_(start2 :Int, end2 :Int): Int = {
      // printf("%d:%d\n", start2, end2)
      // 要素が残り1つ
      if (start2 == end2) {
        if (f(ar(start2))) {
          return end + 1 - start // 右端に到達
        } else {
          return 0               // 左端に到達
        }
      }
      // 要素が残り2つ
      if (start2+1 == end2) {
        return (f(ar(start2)), f(ar(end2))) match {
          case (true, false)  => end2 - start
          case (_,    _)      => b_(start2, start2)
        }
      }
      // 要素が3つ以上
      var middle = (start2 + end2) / 2
      return (f(ar(middle)), f(ar(middle+1))) match {
        case (true, false)  => middle+1 - start
        case (true, true)   => b_(middle, end2)
        case (false, false) => b_(start2, middle)
      }
    }
    b_(start, end)
  }
}


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

int main() {
	int a;
	int b;

	cin >> a >> b;
	cout << fixed;
	cout << setprecision(6) << a/b <<" "<< (int)(a%b) <<" "<< (double)a/b << endl;
	return 0;
}


Measured memory_bytes: 3284
import java.util.*;

public class Main{

     public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x[] = new int[n];
        int y[] = new int[n];
        int h[] = new int[n];
        
        for(int i=0;i<n;i++){
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            h[i] = sc.nextInt();
        }
        
        
        loop:
        for(int i=0;i<=100;i++){
            for(int j=0;j<=100;j++){
                int H;
                
                if(h[0] > 0){
                    H = Math.abs(i-x[0]) + Math.abs(j-y[0]) + h[0];
                    
                    if(check(x, y, h, H, i, j)){
                        System.out.println(i+" "+j+" "+H);
                        break loop;
                    }
                }
                else{
                    for(H = 1; H<=Math.abs(i-x[0]) + Math.abs(j-y[0]);H++){
                        if(check(x, y, h, H, i, j)){
                            System.out.println(i+" "+j+" "+H);
                            break loop;
                        }
                    }
                }
                
                
            }
        }
        
    
     }
     
     static boolean check(int x[], int y[], int h[], int H, int cx, int cy){
         for(int i=1;i<x.length;i++){
             if(Math.max(H - Math.abs(cx - x[i]) - Math.abs(cy - y[i]), 0) != h[i]){
                 return false;
             }
         }
         
         return true;
     }
}

Measured memory_bytes: 25044
function Main(input) {
  input = input.trim()
 input = input.split("");
 var sum =700;
 for(var i=0;i<3;i++){
   if(input[i]=="o"){
     sum+=100;
   }
 }
console.log(sum)
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define INF (1 << 25)

using namespace std;

int dp[401][401];

int main()
{
  int n, m;
  cin >> n >> m;
  for(int i = 0; i < 401; i++){
    for(int j = 0; j < 401; j++){
      if(i == j) dp[i][j] = 0;
      else dp[i][j] = -INF;
    }
  }
  for(int i = 0; i < m; i++){
    int a, b, c;
    cin >> a >> b >> c;
    dp[a][b] = c;
  }
  for(int k = 0; k < n; k++){
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++) dp[i][j] = max(dp[i][j], dp[i][k] + dp[k][j]);
    }
  }
  cout << dp[0][n-1] << endl;
  return 0;
}

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

int main() {
  int x, a, b, c;
  cin >> x;
  a = x / 100;
  b = (x-a*100) / 10;
  c = (x-a*100-b*10) / 1;
  cout << a + b + c << endl;
}


Measured memory_bytes: 256
hash = {"a"=> "0", "b"=> "1", "c"=> "2"}
s = []

3.times do
    s << gets.chomp.gsub(/[abc]/, hash).split("").map(&:to_i)
end

ptr = s[0].shift
while !s[ptr].empty?
    ptr = s[ptr].shift
end

if ptr == 0
    puts "A"
elsif ptr == 1
    puts "B"
else
    puts "C"
end

Measured memory_bytes: 1788
#include <iostream>                            
#include <cmath>                               
using namespace std;                           
                                               
int main(void){                                
 long int n,a,b,c,d,e,min,group,count = 0;     
  cin >> n;                                    
  cin >> a;min = a;                            
  cin >> b;if(b < min) min =b;                 
  cin >> c;if(c < min) min = c;                
  cin >> d;if(d < min) min = d;                
  cin >> e;if(e < min) min = e;                
  if(n % min == 0) cout << n/min + 4 <<endl;   
  else  cout << n/min + 5 <<endl;              
  return 0;                                    
}                                              

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.next();
        int min1=0;
        int min2=0;
        for (int i=0 ; i<str.length();i++){
        	if(i%2 ==Character.getNumericValue(str.charAt(i))){
        		min1 +=1;
        	}else{
        		min2 +=1;
        	}
        }
        System.out.println(Math.min(min1,min2));
    }
}

Measured memory_bytes: 23800
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

N = iIn()

n = 1
while 1:
  if n**2 > N:
    print((n-1)**2)
    exit()
  else:
    n += 1

Measured memory_bytes: 63660
#include<bits/stdc++.h>
using namespace std;
int h,w,a,b;
long long totalsum = 0,n,m,nm,facn,facm,facnm;
long long x,y,xy,facx,facy,facxy;
long long arr[100010],arr2[100010];

long long invmod(long long ac)
{
	int i,j;
	long long num[40],ans=1;
	int idx=1000000005;
//	int idx = 2;
	int idx3=30,idx2=1073741824;
	num[0] = ac;
	num[1] = ac*ac;
	num[1] %= 1000000007;
	for(i=2;i<=30;i++)
	{
		num[i] = num[i-1] * num[i-1];
//		printf("num[%d]=%lld\n",i,num[i]);
		num[i] %= 1000000007;
	}
//	while(idx>0)
//	{
//		if(idx >= idx2)
//		{
//			idx -= idx2;
//			ans *= num[idx3];
//			ans %= 1000000007;
//		}
//		idx3--;
//		idx2 /= 2;
//	}
	for(i=0;i<=30;i++)
	{
		j = (1 << i);
		if(idx & j )
		{
			ans *= num[i];
			ans %= 1000000007;
		}
	}
	return ans;
}

int main()
{
	int i,j,k;
//	for(i=1;i<10;i++)
//	printf("%lld\n",invmod(i));
	scanf("%d %d %d %d",&h,&w,&a,&b);
	
	n = 1-1;		facn=1;
	m = b-1;		facm=1;
	nm = n+m;		facnm=1;
	for(i=1;i<=n;i++)
	{
		facn *= i;
		facn %= 1000000007;
	}
	for(i=1;i<=m;i++)
	{
		facm *= i;
		facm %= 1000000007;
	}
	for(i=1;i<=nm;i++)
	{
		facnm *= i;
		facnm %= 1000000007;
	}
	
	x = a+1-1;	facx=1;
	y = w-b-1;	facy=1;
	xy = x+y;	facxy=1;
	for(i=1;i<=x;i++)
	{
		facx *= i;
		facx %= 1000000007;
	}
	for(i=1;i<=y;i++)
	{
		facy *= i;
		facy %= 1000000007;
	}
	for(i=1;i<=xy;i++)
	{
		facxy *= i;
		facxy %= 1000000007;
	}
	
	long long a1,a2,a3,a4,a5;
	for(i=1;i<=h-a;i++)
	{
		a1 = facn * facm;
		a1 %= 1000000007;
	//	a2 = facnm / a1;
//		printf("a1 = %lld * %lld = %lld\n",facn,facm,a1);
//		a2 = facnm * invmod(a1);
//		printf("a2 = facnm(%lld) * invmod(%lld)%d = %lld\n",facnm,a1,invmod(a1),a2);
		a2 = facnm * invmod(facn);
		a2 %= 1000000007;
		a2 *= invmod(facm);
		a2 %= 1000000007;
	//	printf("a2 = facnm(%lld) * invmod(%lld)%lld * invmod(%lld)%lld = %lld\n",facnm,facn,invmod(facn),facm,invmod(facm),a2);
		
		a3 = facx * facy;
		a3 %= 1000000007;
	//	a4 = facxy / a3;
	//	a4 = facxy * invmod(a3);
	//	printf("a4 = facxy(%lld) * invmod(%lld)%lld = %lld\n",facxy,a3,invmod(a3),a4);
		a4 = facxy * invmod(facx);
		a4 %= 1000000007;
		a4 *= invmod(facy);
		a4 %= 1000000007;
//		printf("x=%d y=%d\n",x,y);
//		printf("a4 = facxy(%lld) * invmod(%lld)%lld * invmod(%lld)%lld = %lld\n",facxy,facx,invmod(facx),facy,invmod(facy),a4);
		
		n++;
		facn *= n;
		facn %= 1000000007;	
		nm++;
		facnm *= nm;
		facnm %= 1000000007;
		
		x++;
		facx *= x;
		facx %= 1000000007;	
		xy++;
		facxy *= xy;
		facxy %= 1000000007;
		
		arr[i] = a2;
		arr2[h-a+1-i] = a4;
//		printf("arr[%d] , arr[%d]\n",i,h-a+1-i);
	//	totalsum += a2 * a4;
	//	totalsum %= 1000000007;
	}
	for(i=1;i<=h-a;i++)
	{
//		printf("i=%d\n",i);
		totalsum += arr[i] * arr2[i];
		totalsum %= 1000000007;
	}
	printf("%lld\n",totalsum);
}

Measured memory_bytes: 5196
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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

int main(){
    string S; cin >> S;
    if(S.length() == 3)
        swap(S[0], S[2]);
    cout << S << endl;
    return 0;
}


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

void Main() {
  string S;
  cin >> S;
  int ans = S.length();
  for (int i = 0; i < S.length() - 1; i++) {
    if (S[i] != S[i + 1]) {
      ans = min(ans, max(i + 1, int(S.length() - i - 1)));
    }
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll A,B,K;
    cin >> A >> B >> K;
    if(K >= A){
        K -= A;
        A = 0;
        if(K >= B){
            K -=B;
            B = 0;
        }else{
            B -= K;
        }
    }else{
        A -=K;
    }

    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), b(n), c(m), d(m);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    for (ll i = 0; i < m; i++)
    {
        cin >> c[i] >> d[i];
    }

    for (ll i = 0; i < n; i++)
    {
        ll min = 1000000000;
        ll ans = 0;
        for (ll k = 0; k < m; k++)
        {
            if (min > abs(a[i] - c[k]) + abs(b[i] - d[k]))
            {
                min = abs(a[i] - c[k]) + abs(b[i] - d[k]);
                ans = k + 1;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/



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

    int d, n; cin >> d >> n;
    int seed = pow(100, d);
    if(n < 100) cout << seed*n << endl;
    else cout << seed*101 << endl;

    return 0;
}

Measured memory_bytes: 384
def GSD(x, y):
    while True:
        x0 = max(x, y)
        y0 = min(x, y)
        if x0 % y0 == 0:
            return y0
        x = x0 % y0
        y = y0
x, y = map(int, input().split(' '))
print(GSD(x, y))


Measured memory_bytes: 5600
#include<iostream>
#define MAX_V 100000
#define MAX_E 500000
#define INF 1e9
using namespace std;
struct edge {
	int from, to, cost;
};
edge es[MAX_E];
int d[MAX_V];
int V;
int E;

bool find_negative_loop(int s)
{
	d[s] = 0;
	int count = 0;
	while (true)
	{
		bool update = false;
		count++;
		for (int i = 0; i < E; i++)
		{

			if (d[es[i].from] != INF && d[es[i].to] > d[es[i].from] + es[i].cost)
			{
				if (count == V)
				{
					return true;
				}
				d[es[i].to] = d[es[i].from] + es[i].cost;
				update = true;
			}
		}
		if (update == false)
		{
			break;
		}


	}
	return false;
}

int main() {
	int r;
	cin >> V >> E >> r;
	for (int i = 0; i < MAX_V; i++) {
		d[i] = INF;
	}
	for (int i = 0; i < E; i++) {
		cin >> es[i].from >> es[i].to >> es[i].cost;
	}
	if (find_negative_loop(r)) {
		cout << "NEGATIVE CYCLE" << endl;
	}
	else {
		for (int i = 0; i < V; i++) {
			if (d[i] == INF) {
				cout << "INF" << endl;
			}
			else {
				cout << d[i] << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 9212
def main():
    N, Q = [int(q) for q in input().split()]
    S = input()
    lr = [
        [int(q) - 1 for q in input().split()]
        for _ in range(Q)
    ]

    ttt = [0]
    res = 0
    for i in range(1, len(S)):
        if S[i - 1] == "A" and S[i] == "C":
            res += 1
        ttt.append(res)

    for l, r in lr:
        print(ttt[r] - ttt[l])


if __name__ == '__main__':
    main()


Measured memory_bytes: 24464
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 998244353;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
constexpr auto PI = 3.14159265358979323846264338327950L;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    ll a, ans = 1;
    cin >> N;
    bool flag = false;
    for (int i = 0; i < N; ++i) {
        cin >> a;
        ans *= a;
        if (a == 0) {
            cout << 0 << endl;
            return 0;
        }
        if (ans > 1000000000000000000)flag = true;
    }
    if (flag == false && ans > 0 && ans <= 1000000000000000000) {
        cout << ans << endl;
    }
    else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AHitachiString solver = new AHitachiString();
        solver.solve(1, in, out);
        out.close();
    }

    static class AHitachiString {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            StringBuilder str = new StringBuilder(in.next());
            String ret = "No";
            while (true) {
                if (str.toString().equals("hi")) {
                    ret = "Yes";
                    break;
                } else if (!str.toString().startsWith("hi")) {
                    break;
                } else {
                    str.delete(0, 2);
                }
            }
            out.println(ret);
        }

    }

    static class Scanner {
        private final InputStream in;
        private final byte[] buffer;
        private int ptr;
        private int buflen;

        public Scanner(InputStream in) {
            this.in = in;
            this.buffer = new byte[1024];
            this.ptr = 0;
            this.buflen = 0;
        }

        private boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }

        private byte readByte() {
            if (hasNextByte()) return buffer[ptr++];
            return -1;
        }

        private boolean isPrintableChar(byte c) {
            return '!' <= c && c <= '~';
        }

        private void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
        }

        public boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            byte b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

    }
}



Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a.at(i);
    deque<int> b;
    if(n%2==0){
        for(int i=0; i<n; i++){
            if(i%2==1)
                b.push_front(a.at(i));
            else
                b.push_back(a.at(i));
        }
    }else{
        for(int i=0; i<n; i++){
            if(i%2==0)
                b.push_front(a.at(i));
            else
                b.push_back(a.at(i));
        }
    }
    for(int i=0; i<n; i++){
        if(i==n-1) cout<<b.at(i)<<endl;
        else cout<<b.at(i)<<' ';
    }
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
const int MAX=1e5+100,INF=99999999,MOD=1e9+7;
long long x[MAX],y[MAX],n,m;

int main()
{	cin>>n>>m;
    for(int i=1;i<=n;++i)
        cin>>x[i];
    for(int i=1;i<=m;++i)
        cin>>y[i];
    long long ax=0,ay=0;
    for(int i=1;i<=n;++i)
        ax=(ax+((i-1)*x[i]-(n-i)*x[i]))%MOD;
    for(int i=1;i<=m;++i)
        ay=(ay+((i-1)*y[i]-(m-i)*y[i]))%MOD;
    cout<<ax%MOD*ay%MOD<<endl;
    return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  
  auto chk = [](int n) {
    string ns = to_string(n);
    bool ans = true;
    for (int i = 0; i < ns.size(); i++) {
      if (ns[i] != ns[0]) {
        ans = false;
        break;
      }
    }
    
    return ans;
  };
  
  while (!chk(n)) {
    n++;
  }
  
  cout << n << '\n';
}


Measured memory_bytes: 3676
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    K = int(input())

    ans = 1
    while N > 0:
        if ans >= K:
            break
        ans *= 2
        N -= 1

    ans += K * N
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Numerics;

public class Program
{
    public static void Main(string[] args)
    {
        string n = Console.ReadLine();

        Console.WriteLine(n.Replace('9', 'b').Replace('1', '9').Replace('b', '1'));
        Console.ReadLine();
    }
}

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    string s; cin >> s;
    int x,MX;
    x = MX = 0;
    for(char c : s){
      x += (c == 'I') ? 1 : -1;
      MX = max(MX,x);
    }
    cout << MX << "\n";
    return 0;
}


Measured memory_bytes: 256
def check(x0, y0, x1, y1, x2, y2, x3, y3)
  a1, b1, a2, b2 = x0 - x1, y0 - y1, x2 - x3, y2 - y3
  if a1 * a2 + b1 * b2 == 0
    puts "1"
  elsif a1 * b2 - a2 * b1 == 0
    puts "2"
  else
    puts "0"
  end
end
def main(input = STDIN)
  input.gets.to_i.times{check(*input.gets.split(" ").map(&:to_i))}
end
main

Measured memory_bytes: 6112
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    vector<int> x(5);
    for (int i = 0; i < 5; i++) {
        cin >> x[i];
    }

    cout << find(x.begin(), x.end(), 0) - x.begin() + 1 << endl;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <tuple>
#include <vector>

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

int main(void) {
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) { cin >> A[i]; }

  sort(A.rbegin(), A.rend());
  if (N % 2 == 0) {
    ll ret = 0;
    rep(i, N / 2 - 1) { ret += A[i] * 2; }
    ret += A[N / 2 - 1];
    ret -= A[N / 2];
    for (int i = N / 2 + 1; i < N; ++i) {
      ret -= A[i] * 2;
    }
    cout << ret << endl;
  } else {
    ll ret1 = 0;
    rep(i, N / 2 - 1) { ret1 += A[i] * 2; }
    ret1 += A[N / 2 - 1];
    ret1 += A[N / 2];
    for (int i = N / 2 + 1; i < N; ++i) {
      ret1 -= 2 * A[i];
    }

    ll ret2 = 0;
    rep(i, N / 2) { ret2 += A[i] * 2; }
    ret2 -= A[N / 2];
    ret2 -= A[N / 2 + 1];
    for (int i = N / 2 + 2; i < N; ++i) {
      ret2 -= 2 * A[i];
    }


    cout << max(ret1, ret2)  << endl;
  }

  return 0;
}


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

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

	constexpr int MAX = 300;
	static int dp[MAX + 1];
	dp[0] = 1;

	for(int i = 1; i * i < MAX; ++i) {
		const int value = i * i;

		for(int j = 0; j <= MAX - value; ++j) {
			dp[j + value] += dp[j];
		}
	}

	for(int n; cin >> n && n;) {
		cout << dp[n] << endl;
	}
	return EXIT_SUCCESS;
}

Measured memory_bytes: 1192
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <string>

using namespace std;
#define M 110

int main(){
  int a, b, N, i, L;
  string S[M], t;
  cin >> N >> L;
  for (i = 0; i < N; i++)
    cin >> S[i];
  vector<string> v(S, S+N);

  sort(v.begin(), v.end());
  for (i = 0; i < N; i++)
    cout << v.at(i);

  return 0;
}


Measured memory_bytes: 256